1import{d as De,s as Xe,z as xe,o as a,f as n,h as e,t as l,k as p,au as Ge,r as I,a2 as qe,F as G,E as be,V as st,u as Qe,ae as Ft,L as we,j as T,i as t,q as D,S as nt,O as at,ai as qt,C as lt,g as re,w as Se,m as X,aC as _t,aD as Kt,D as Le,l as Be,v as Ke,p as Oe,G as Nt,aQ as Ht,U as Mt,M as Yt,aY as ot,az as Gt,b as Xt,aE as Qt,a4 as Jt,aX as Zt,T as es,ay as ts,aw as ss}from"./C2UU-Vq0.js";import{_ as it}from"./DO9oaV8r.js";import{_ as It}from"./DlAUqK2U.js";import{u as as,a as Ut,_ as Tt,b as os,d as ns,c as ls,e as is,f as rs}from"./DGoA40cy.js";import{a as rt}from"./BMqI_q01.js";import{_ as ds}from"./DPBbG9mr.js";import{u as St,i as cs}from"./B1E8hQe-.js";import{_ as us}from"./j6DWAXk_.js";import{u as fs}from"./BIDn-En7.js";import{u as vs}from"./CdSZnBaJ.js";const ms=["aria-label"],ps={class:"no-scrollbar flex-nowrap"},bs={key:1,class:"text-base-content shrink-0 font-bold"},gs={key:0},ys={class:"text-base-content shrink-0 font-bold"},hs={class:"ms-icon text-base"},ks=De({__name:"breadcrumb",props:{crumb:{}},emits:["home"],setup(i,{emit:le}){const m=i,M=le,_=I(null),v=async(B="smooth")=>{await Ge();const W=_.value;if(!W)return;W.scrollTo({left:W.scrollWidth,behavior:B});const L=W.querySelector("ul");L&&L.scrollTo({left:L.scrollWidth,behavior:B})};return Xe(()=>{v("auto")}),xe(()=>m.crumb?.label,()=>{v()}),(B,W)=>(a(),n("div",{ref_key:"element",ref:_,class:"breadcrumbs no-scrollbar text-body max-w-full py-0 font-semibold","aria-label":B.$t("artifacts.title")},[e("ul",ps,[e("li",null,[i.crumb?(a(),n("button",{key:0,type:"button",class:"text-base-content/70 hover:text-primary shrink-0 transition-colors",onClick:W[0]||(W[0]=L=>M("home"))},[W[1]||(W[1]=e("span",{class:"ms-icon text-base"},"home_storage",-1)),e("span",null,l(B.$t("artifacts.title")),1)])):(a(),n("span",bs,[W[2]||(W[2]=e("span",{class:"ms-icon text-base"},"home_storage",-1)),e("span",null,l(B.$t("artifacts.title")),1)]))]),i.crumb?(a(),n("li",gs,[e("span",ys,[e("span",hs,l(i.crumb.icon),1),e("span",null,l(i.crumb.label),1)])])):p("",!0)])],8,ms))}}),Rl=Object.assign(ks,{__name:"ArtifactBreadcrumb"}),xs=["aria-label"],ws={class:"sr-only"},$s=De({__name:"graphSkeleton",setup(i){const le=[{left:"14%",top:"27%",size:"2.75rem",labelWidth:"4.5rem"},{left:"31%",top:"55%",size:"2.625rem",labelWidth:"5.5rem"},{left:"48%",top:"24%",size:"3rem",labelWidth:"6rem"},{left:"63%",top:"62%",size:"2.75rem",labelWidth:"4rem"},{left:"82%",top:"31%",size:"2.625rem",labelWidth:"5rem"},{left:"86%",top:"72%",size:"2.625rem",labelWidth:"4.5rem"}];return(m,M)=>(a(),n("div",{class:"border-base-300 bg-base-200/20 rounded-box relative h-full min-h-0 flex-1 overflow-hidden border","aria-label":m.$t("artifacts.graph.loading"),role:"status"},[M[0]||(M[0]=qe('<svg class="text-base-content/10 absolute inset-0 h-full w-full" viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true"><line x1="14" y1="27" x2="31" y2="55" stroke="currentColor"></line><line x1="14" y1="27" x2="48" y2="24" stroke="currentColor"></line><line x1="31" y1="55" x2="48" y2="24" stroke="currentColor"></line><line x1="31" y1="55" x2="63" y2="62" stroke="currentColor"></line><line x1="48" y1="24" x2="82" y2="31" stroke="currentColor"></line><line x1="63" y1="62" x2="82" y2="31" stroke="currentColor"></line><line x1="63" y1="62" x2="86" y2="72" stroke="currentColor"></line></svg>',1)),(a(),n(G,null,be(le,(_,v)=>e("div",{key:v,class:"absolute flex -translate-x-1/2 -translate-y-1/2 flex-col items-center gap-2",style:st({left:_.left,top:_.top}),"aria-hidden":"true"},[e("div",{class:"skeleton rounded-lg",style:st({width:_.size,height:_.size})},null,4),e("div",{class:"skeleton h-2.5 rounded",style:st({width:_.labelWidth})},null,4)],4)),64)),M[1]||(M[1]=qe('<div class="absolute top-3 left-3"><div class="skeleton h-5 w-24 rounded-full"></div></div><div class="absolute top-3 right-3"><div class="skeleton size-8 rounded-full"></div></div><div class="absolute bottom-3 left-3"><div class="skeleton h-8 w-24 rounded-lg"></div></div><div class="absolute right-3 bottom-3"><div class="skeleton h-6 w-48 rounded-lg"></div></div>',4)),e("span",ws,l(m.$t("artifacts.graph.loading")),1)],8,xs))}}),Cs=Object.assign($s,{__name:"ArtifactGraphSkeleton"}),As=["aria-label"],Fs={class:"absolute top-3 left-3 flex items-center gap-2"},_s={class:"badge badge-neutral badge-sm gap-1"},Ms=["title","aria-label"],Is=["disabled"],Us={key:0,class:"loading loading-spinner loading-sm"},Ts={class:"text-base-content/70 bg-base-100/75 text-body absolute right-3 bottom-3 rounded-lg px-2 py-1 backdrop-blur"},Ss=De({__name:"graph",props:{items:{},folders:{},query:{},backTarget:{},hasMore:{type:Boolean},loadingMore:{type:Boolean},iconForKind:{type:Function}},emits:["select","folder-select","load-more"],setup(i,{emit:le}){const m=i,M=le,_=Qe(),v=I(null),B=I(null),W=I(null),L=I(null),c=at({x:0,y:0,scale:1});let z=[];const g=qt([]),b=D(()=>g.value.length);let H=0,Y,Q,J=!1,te={x:0,y:0},ve={x:0,y:0};const se=new Map,Ae=f=>
1{if(!f)return;const k=se.get(f);if(k!==void 0)return k||void 0;const $=new Image;return se.set(f,$),$.onload=Z,$.onerror=()=>{se.set(f,null),Z()},$.src=f,$},Fe=f=>f?.status==="pending"||f?.status==="processing",$e=()=>{const f=getComputedStyle(document.documentElement);return{foreground:f.getPropertyValue("--color-base-content").trim()||"#d7dde8",surfaceRaised:f.getPropertyValue("--color-base-100").trim()||"#171c26",surface:f.getPropertyValue("--color-base-200").trim()||"#202633",border:f.getPropertyValue("--color-base-300").trim()||"#303949",primary:f.getPropertyValue("--color-primary").trim()||"#8b5cf6",error:f.getPropertyValue("--color-error").trim()||"#f87171"}},ae=(f,k=!1)=>{const $=f.kind==="folder"||f.kind==="back"?44:42;return k?$+6:$},ue=(f,k,$)=>{const R=$/2;f.beginPath(),f.roundRect(k.x-R,k.y-R,$,$,7)},fe=(f,k,$)=>{if(f.measureText(k).width<=$)return k;const R=Array.from(k),h="â¦";let u=0,x=R.length;for(;u<x;){const y=Math.ceil((u+x)/2),U=`${R.slice(0,y).join("").trimEnd()}${h}`;f.measureText(U).width<=$?u=y:x=y-1}return`${R.slice(0,u).join("").trimEnd()}${h}`},oe=()=>{const f=v.value?.clientWidth||900,k=v.value?.clientHeight||560,$=new Map(z.map(w=>[w.id,w])),R=m.query?.trim().toLocaleLowerCase()||"",h=R?m.folders.filter(w=>w.name?.toLocaleLowerCase().includes(R)):m.folders,u=m.backTarget===void 0?[]:[{...$.get("navigation:back")||{id:"navigation:back",x:f/2,y:k/2,vx:0,vy:0},label:_.t("artifacts.backFolder"),icon:"arrow_back",kind:"back",folderTarget:m.backTarget}],x=h.filter(w=>w.id).map((w,V)=>{const N=`folder:${w.id}`,E=$.get(N),d=V/Math.max(h.length,1)*Math.PI*2;return{...E||{id:N,x:f/2+Math.cos(d)*Math.min(f,k)*.2,y:k/2+Math.sin(d)*Math.min(f,k)*.2,vx:0,vy:0},label:w.name||_.t("artifacts.folders"),icon:"folder",kind:"folder",folder:w}}),y=m.items.map((w,V)=>{const N=`artifact:${w.id||V}`,E=V/Math.max(m.items.length,1)*Math.PI*2,d=$.get(N),A=Fe(w);return{...d||{id:N,x:f/2+Math.cos(E)*Math.min(f,k)*.3,y:k/2+Math.sin(E)*Math.min(f,k)*.3,vx:0,vy:0},label:w.name||_.t(`artifacts.kind.${w.kind||"file"}`),icon:w.status==="failed"?"error":m.iconForKind(w.kind),thumbnailUrl:!A&&w.status==="ready"?nt(w):void 0,kind:"artifact",item:w}});z=[...u,...x,...y];const U=new Set(z.map(w=>w.id)),P=new Map,C=(w,V,N)=>{if(w===V||!U.has(w)||!U.has(V))return;const E=[w,V].sort().join("|"),d=P.get(E);(!d||d.strength<N)&&P.set(E,{source:w,target:V,strength:N})};for(const w of y)w.item?.folderId&&C(w.id,`folder:${w.item.folderId}`,1);for(const w of x)w.folder?.parentId&&C(w.id,`folder:${w.folder.parentId}`,.9);for(const w of u)w.folderTarget&&C(w.id,`folder:${w.folderTarget}`,.9);for(let w=0;w<y.length;w++){const V=y[w];for(let N=w+1;N<y.length;N++){const E=y[N],d=V.item?.threadIds?.some(S=>E.item?.threadIds?.includes(S)),A=V.item?.tags?.some(S=>E.item?.tags?.includes(S)),F=!!(V.item?.appId&&V.item.appId===E.item?.appId);(d||A||F)&&C(V.id,E.id,d?.8:F?.6:.45)}}g.value=[...P.values()],ee()},ee=()=>{cancelAnimationFrame(H);let f=0;const k=()=>{const $=v.value?.clientWidth||900,R=v.value?.clientHeight||560,h=f<240||!!Q;if(h){for(let y=0;y<z.length;y++){const U=z[y];U!==Q&&(U.vx+=($/2-U.x)*7e-4,U.vy+=(R/2-U.y)*7e-4);for(let P=y+1;P<z.length;P++){const C=z[P];let w=C.x-U.x,V=C.y-U.y;const N=Math.max(w*w+V*V,100),E=Math.min(2.2,960/N);w/=Math.sqrt(N),V/=Math.sqrt(N),U.vx-=w*E,U.vy-=V*E,C.vx+=w*E,C.vy+=V*E}}const x=new Map(z.map(y=>[y.id,y]));for(const y of g.value){const U=x.get(y.source),P=x.get(y.target);if(!U||!P)continue;const C=P.x-U.x,w=P.y-U.y,V=Math.max(Math.hypot(C,w),1),N=(V-135)*.0025*y.strength;U.vx+=C/V*N,U.vy+=w/V*N,P.vx-=C/V*N,P.vy-=w/V*N}for(const y of z)y!==Q&&(y.vx*=.88,y.vy*=.88,y.x+=y.vx,y.y+=y.vy)}Z(),f+=1;const u=z.some(x=>x.kind==="artifact"&&Fe(x.item));(h||u)&&(H=requestAnimationFrame(k))};H=requestAnimationFrame(k)},Z=()=>{const f=v.value;if(!f)return;const k=window.devicePixelRatio||1,$=f.clientWidth,R=f.clientHeight;(f.width!==$*k||f.height!==R*k)&&(f.width=$*k,f.height=R*k);const h=f.getContext("2d");if(!h)return;const u=$e();h.setTransform(k,0,0,k,0,0),h.clearRect(0,0,$,R),h.save(),h.translate(c.x,c.y),h.scale(c.scale,c.scale);const x=new Map(z.map(y=>[y.id,y]));for(const y of g.value){const U=x.get(y.source),P=x.get(y.target);if(!U||!P)continue;const C=W.value===U.id||W.value===P.id;h.strokeStyle=u.foreground,h.globalAlpha=C?.42:.12,h.lineWidth=C?1.5:1,h.beginPath(),h.moveTo(U.x,U.y),h.lineTo(P.x,P.y),h.stroke()}h.globalAlpha=1;for(const y of z){const U=W.value===y.id||L.value===y.id,P=ae(y,U),C=P/2;h.fillStyle=y.kind==="folder"||y.kind==="back"?u.surfaceRaised:u.surface,h.globalAlpha=1,ue(h,y,P),h.fill();const w=y.kind==="artifact"&&Fe(y.item),V=y.kind==="artifact"&&y.item?.status==="failed";if(w){const d=performance.now()/1e3*Math.PI*2*1.25%(Math.PI*2);h.save(),h.beginPath(),h.arc(y.x,y.y,8,d,d+Math.PI*1.35),h.strokeStyle=u.primary,h.lineWidth=2,h.lineCap="round",h.stroke(),h.restore(
1)}else{const E=Ae(y.thumbnailUrl);if(E?.complete&&E.naturalWidth){const d=Math.max(P/E.naturalWidth,P/E.naturalHeight),A=P/d,F=P/d,S=(E.naturalWidth-A)/2,ne=(E.naturalHeight-F)/2;h.save(),ue(h,y,P-2),h.clip(),h.drawImage(E,S,ne,A,F,y.x-C+1,y.y-C+1,P-2,P-2),h.restore()}else h.fillStyle=y.kind==="folder"||y.kind==="back"?u.primary:V?u.error:u.foreground,h.font="21px 'Material Symbols Outlined'",h.textAlign="center",h.textBaseline="middle",h.fillText(V?"error":y.icon,y.x,y.y+1)}h.strokeStyle=U?u.primary:u.border,h.globalAlpha=1,h.lineWidth=U?2.5:1,ue(h,y,P),h.stroke(),h.globalAlpha=U||y.kind!=="artifact"?.95:.62,h.fillStyle=u.foreground,h.font=`${U?600:500} ${U?13:11}px sans-serif`,h.textAlign="center",h.textBaseline="alphabetic";const N=fe(h,y.label,U?180:150);h.fillText(N,y.x,y.y+C+17)}h.restore(),h.globalAlpha=1},K=f=>{const k=v.value.getBoundingClientRect();return{x:(f.clientX-k.left-c.x)/c.scale,y:(f.clientY-k.top-c.y)/c.scale}},j=f=>{const k=K(f);return[...z].reverse().find($=>{const R=ae($,W.value===$.id)/2+5;return Math.abs($.x-k.x)<=R&&Math.abs($.y-k.y)<=R})},ge=f=>{v.value?.setPointerCapture(f.pointerId),Q=j(f),te={x:f.clientX,y:f.clientY},ve={x:c.x,y:c.y},J=!Q},he=f=>{if(Q){const k=K(f);Q.x=k.x,Q.y=k.y,Q.vx=0,Q.vy=0}else J?(c.x=ve.x+f.clientX-te.x,c.y=ve.y+f.clientY-te.y):W.value=j(f)?.id||null;Z()},Ce=f=>{const k=Math.hypot(f.clientX-te.x,f.clientY-te.y),$=Q||j(f);$&&k<6&&(L.value=$.id,$.item?M("select",$.item):$.kind==="back"?M("folder-select",$.folderTarget??null):$.folder?.id&&M("folder-select",$.folder.id)),Q=void 0,J=!1,ee()},me=f=>{const k=v.value.getBoundingClientRect(),$=Math.min(2.5,Math.max(.45,c.scale*(f.deltaY>0?.9:1.1))),R=f.clientX-k.left,h=f.clientY-k.top;c.x=R-(R-c.x)/c.scale*$,c.y=h-(h-c.y)/c.scale*$,c.scale=$,Z()},_e=()=>{c.x=0,c.y=0,c.scale=1,oe()};return xe(()=>[m.items,m.folders,m.query,m.backTarget],oe,{deep:!0}),xe(W,Z),Xe(()=>{Y=new ResizeObserver(()=>oe()),B.value&&Y.observe(B.value),oe()}),Ft(()=>{cancelAnimationFrame(H),Y?.disconnect()}),(f,k)=>(a(),n("div",{ref_key:"wrapper",ref:B,class:"border-base-300 bg-base-200/20 rounded-box relative h-full min-h-0 flex-1 overflow-hidden border"},[e("canvas",{ref_key:"canvas",ref:v,class:"h-full min-h-0 w-full cursor-grab touch-none active:cursor-grabbing","aria-label":f.$t("artifacts.graph.canvasLabel"),onPointerdown:ge,onPointermove:he,onPointerleave:k[0]||(k[0]=$=>W.value=null),onPointerup:Ce,onPointercancel:Ce,onWheel:we(me,["prevent"])},null,40,As),e("div",Fs,[e("span",_s,[k[2]||(k[2]=e("span",{class:"ms-icon text-xs"},"hub",-1)),T(" "+l(f.$t("artifacts.graph.connections",{count:t(b)})),1)])]),e("button",{type:"button",class:"btn btn-sm btn-circle btn-ghost bg-base-100/80 absolute top-3 right-3 backdrop-blur",title:f.$t("artifacts.graph.reset"),"aria-label":f.$t("artifacts.graph.reset"),onClick:_e},[...k[3]||(k[3]=[e("span",{class:"ms-icon text-base"},"center_focus_strong",-1)])],8,Ms),i.hasMore&&!i.query?.trim()?(a(),n("button",{key:0,type:"button",class:"btn btn-ghost btn-sm bg-base-100/80 absolute bottom-3 left-3 backdrop-blur",disabled:i.loadingMore,onClick:k[1]||(k[1]=$=>M("load-more"))},[i.loadingMore?(a(),n("span",Us)):p("",!0),T(" "+l(f.$t("artifacts.loadMore")),1)],8,Is)):p("",!0),e("p",Ts,l(f.$t("artifacts.graph.hint")),1)],512))}}),zs=Object.assign(Ss,{__name:"ArtifactGraph"}),Ps={class:"bg-base-200 flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg"},Ls={class:"ms-icon text-base-content/40 text-2xl"},Bs={class:"min-w-0 flex-1"},Ds={class:"flex min-w-0 items-center gap-1.5"},Rs={class:"text-body truncate font-semibold"},Es={class:"text-base-content/70 artifact-list-mobile-col mt-0.5 flex-wrap items-center gap-x-1.5 text-xs font-medium"},Ws={key:0,"aria-hidden":"true",class:"opacity-50"},Vs={class:"truncate"},js={key:0,"aria-hidden":"true",class:"opacity-50"},Os={key:2},qs={class:"text-base-content/70 artifact-list-desktop-col w-20 shrink-0 text-xs"},Ks={class:"text-base-content/70 artifact-list-desktop-col-wide w-28 shrink-0 text-xs"},Ns=["aria-label"],Hs={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box border-base-300 z-50 w-52 border p-1"},Ys={key:0},Gs={key:1,class:"w-8 shrink-0"},Xs={key:1,class:"group/folder relative h-full min-w-0 focus-within:z-30"},Qs={class:"ms-icon text-base-content/60 shrink-0 text-2xl"},Js={class:"min-w-0 flex-1"},Zs={class:"flex min-w-0 items-center gap-1"},ea={class:"text-body truncate font-semibold"},ta={class:"text-base-content/70 mt-0.5 block truncate text-xs"},sa={key:0,"aria-hidden":"true"},aa={key:0,"aria-hidden":"true"},oa=["aria-label"],na={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box border-base-300 z-50 w-52 border p-1"},la={key:0},ia=De({__name:"folderCard",props:{folder:{},icon:{},dropActive:{type:Boolean},browseOnly:{type:Boolean},variant:{default:"grid"},dropUp:{type:Boolean}},emits:["open","rename","delete"],setup(i,{emit:le}){const m=i,M=le,_=lt(),v=D(()=>m.folder.artifactCount??0),B=D(()=>m.icon||"folder"),W=D(()=>({path:"/",query:m.folder.id?{folder:m.folder.id}:{}}));return(L,c)=>{const z=it;return i.variant==="list"?(a(),n("div",{key:0,class:X(["hover:bg-base-200/60 group/folder rounded-box relative flex cursor-pointer items-center gap-3 px-3 py-2.5 transition-colors focus-within:z-30",[i.dropActive?"border-primary bg-primary/10 border":""]]),onClick:c[4]||(c[4]=g=>M("open"))},[e("div",Ps,[e("span",Ls,l(t(B)),1)]),e("div",Bs,[e("div",Ds,[e("span",Rs,l(i.folder.name),1)]),e("div",Es,[t(v)>0?(a(),n(G,{key:0},[e("span",null,l(L.$t("artifacts.count",{count:t(_).formatCount(t(v))},t(v))),1),i.folder.updatedAt||i.folder.createdAt?(a(),n("span",Ws,"·")):p("",!0)],64)):i.folder.description?(a(),n(G,{key:1},[e("span",Vs,l(i.folder.description),1),i.folder.updatedAt||i.folder.createdAt?(a(),n("span",js,"·")):p("",!0)],64)):p("",!0),i.folder.updatedAt||i.folder.createdAt?(a(),n("span",Os,l(t(_).formatTime(i.folder.updatedAt||i.folder.createdAt)),1)):p("",!0)])]),c[16]||(c[16]=e("div",{class:"artifact-list-desktop-col w-24 shrink-0"},null,-1)),e("div",qs,l(t(v)>0?L.$t("artifacts.count",{count:t(_).formatCount(t(v))},t(v)):"â"),1),e("div",Ks,l(t(_).formatTime(i.folder.updatedAt||i.folder.createdAt)||"â"),1),i.browseOnly?(a(),n("div",Gs)):(a(),n("div",{key:0,class:"stretched-link-above shrink-0",onClick:c[3]||(c[3]=we(()=>{},["stop"]))},[e("div",{class:X(["dropdown dropdown-end focus-within:z-50",i.dropUp?"dropdown-top":""])},[e("button",{tabindex:"0",class:"btn btn-ghost btn-square btn-sm","aria-label":L.$t("artifacts.folderActions")},[...c[10]||(c[10]=[e("span",{class:"ms-icon text-base"},"more_horiz",-1)])],8,Ns),e("ul",Hs,[e("li",null,[e("a",{onClick:c[0]||(c[0]=g=>M("open"))},[c[11]||(c[11]=e("span",{class:"ms-icon text-base"},"folder_open",-1)),T(l(L.$t("artifacts.actions.open")),1)])]),e("li",null,[re(z,{to:t(W)},{default:Se(()=>[c[12]||(c[12]=e("span",{class:"ms-icon text-base"},"chat_add_on",-1)),T(l(L.$t("artifacts.actions.newThread")),1)]),_:1},8,["to"])]),i.folder.id?(a(),n("li",Ys,[re(z,{to:`/folders/${i.folder.id}
1/settings`},{default:Se(()=>[c[13]||(c[13]=e("span",{class:"ms-icon text-base"},"settings",-1)),T(l(L.$t("folders.actions.edit")),1)]),_:1},8,["to"])])):p("",!0),e("li",null,[e("a",{onClick:c[1]||(c[1]=g=>M("rename"))},[c[14]||(c[14]=e("span",{class:"ms-icon text-base"},"edit",-1)),T(l(L.$t("artifacts.actions.rename")),1)])]),e("li",null,[e("a",{class:"text-error",onClick:c[2]||(c[2]=g=>M("delete"))},[c[15]||(c[15]=e("span",{class:"ms-icon text-base"},"delete",-1)),T(l(L.$t("artifacts.deleteFolder")),1)])])])],2)]))],2)):(a(),n("div",Xs,[e("button",{type:"button",class:X(["rounded-box flex h-full min-h-[3.25rem] w-full min-w-0 cursor-pointer items-center gap-2.5 border px-2.5 py-2 text-start transition-colors sm:min-h-[3.5rem]",[i.browseOnly?"":"pe-9",i.dropActive?"border-primary bg-primary/10":"border-base-300 bg-base-100 hover:border-base-content/20 hover:bg-base-200/60"]]),onClick:c[5]||(c[5]=g=>M("open"))},[e("span",Qs,l(t(B)),1),e("span",Js,[e("span",Zs,[e("span",ea,l(i.folder.name),1)]),e("span",ta,[t(v)>0?(a(),n(G,{key:0},[T(l(L.$t("artifacts.count",{count:t(_).formatCount(t(v))},t(v)))+" ",1),i.folder.updatedAt||i.folder.createdAt?(a(),n("span",sa,"·")):p("",!0)],64)):i.folder.description?(a(),n(G,{key:1},[T(l(i.folder.description)+" ",1),i.folder.updatedAt||i.folder.createdAt?(a(),n("span",aa,"·")):p("",!0)],64)):p("",!0),i.folder.updatedAt||i.folder.createdAt?(a(),n(G,{key:2},[T(l(t(_).formatTime(i.folder.updatedAt||i.folder.createdAt)||"â"),1)],64)):p("",!0)])])],2),i.browseOnly?p("",!0):(a(),n("div",{key:0,class:X(["dropdown dropdown-end absolute top-1/2 right-1 -translate-y-1/2 focus-within:z-50",i.dropUp?"dropdown-top":""]),onClick:c[9]||(c[9]=we(()=>{},["stop"]))},[e("button",{tabindex:"0",class:"btn btn-ghost btn-square btn-xs","aria-label":L.$t("artifacts.folderActions")},[...c[17]||(c[17]=[e("span",{class:"ms-icon text-base"},"more_horiz",-1)])],8,oa),e("ul",na,[e("li",null,[e("a",{onClick:c[6]||(c[6]=g=>M("open"))},[c[18]||(c[18]=e("span",{class:"ms-icon text-base"},"folder_open",-1)),T(l(L.$t("artifacts.actions.open")),1)])]),e("li",null,[re(z,{to:t(W)},{default:Se(()=>[c[19]||(c[19]=e("span",{class:"ms-icon text-base"},"chat_add_on",-1)),T(l(L.$t("artifacts.actions.newThread")),1)]),_:1},8,["to"])]),i.folder.id?(a(),n("li",la,[re(z,{to:`/folders/${i.folder.id}/settings`},{default:Se(()=>[c[20]||(c[20]=e("span",{class:"ms-icon text-base"},"settings",-1)),T(l(L.$t("folders.actions.edit")),1)]),_:1},8,["to"])])):p("",!0),e("li",null,[e("a",{onClick:c[7]||(c[7]=g=>M("rename"))},[c[21]||(c[21]=e("span",{class:"ms-icon text-base"},"edit",-1)),T(l(L.$t("artifacts.actions.rename")),1)])]),e("li",null,[e("a",{class:"text-error",onClick:c[8]||(c[8]=g=>M("delete"))},[c[22]||(c[22]=e("span",{class:"ms-icon text-base"},"delete",-1)),T(l(L.$t("artifacts.deleteFolder")),1)])])])],2))]))}}}),ra=Object.assign(It(ia,[["__scopeId","data-v-16c180ba"]]),{__name:"ArtifactFolderCard"}),da=["aria-label"],ca={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box border-base-300 z-50 w-56 border p-1"},ua={key:0},fa={key:1},va={key:2},ma={key:5},pa={key:0},ba={key:1},ga=De({__name:"itemMenu",props:{item:{},folders:{default:()=>[]},shared:{type:Boolean},copied:{type:Boolean},dropUp:{type:Boolean},variant:{default:"list"}},emits:["view","download","download-pdf","copy-url","details","leave","copy-workspace","migrate","delete","move"],setup(i,{emit:le}){const m=i,M=le,{withFolder:_}=as(),v=D(()=>m.item.kind==="app"),B=D(()=>rt(m.item)),W=D(()=>m.item.kind==="creative"&&_t(m.item.slideCount)),L=D(()=>["creative","material","markdown"].includes(m.item.kind||"")),c=D(()=>_({path:"/",query:{artifactId:m.item.id}})),z=D(()=>!!(v.value?B.value:m.item.url));return(g,b)=>{const H=it;return a(),n("div",{class:X(["dropdown dropdown-end",[i.variant==="grid"?"absolute top-2 right-2 z-20 focus-within:z-50":"focus-within:z-50",i.dropUp?"dropdown-top":""]]),onClick:b[10]||(b[10]=we(()=>{},["stop"]))},[e("button",{tabindex:"0",class:X(["btn btn-sm",i.variant==="grid"?"btn-square bg-base-100/90 hover:bg-base-100 border-base-300/50 backdrop-blur-sm":"btn-ghost btn-square"]),"aria-label":g.$t("artifacts.actions.open")},[...b[11]||(b[11]=[e("span",{class:"ms-icon text-base"},"more_horiz",-1)])],10,da),e("ul",ca,[t(v)&&t(B)?(a(),n("li",ua,[re(H,{to:t(B),external:"",target:"_blank",rel:"noopener noreferrer"},{default:Se(()=>[b[12]||(b[12]=e("span",{class:"ms-icon text-base"},"open_in_new",-1)),T(l(g.$t("artifacts.actions.openApp")),1)]),_:1},8,["to"])])):p("",!0),t(v)&&!i.shared?(a(),n("li",fa,[re(H,{to:`/apps/${i.item.slug}/settings`},{default:Se(()=>[b[13]||(b[13]=e("span",{class:"ms-icon text-base"},"settings",-1)),T(l(g.$t("artifacts.detail.appSettings")),1)]),_:1},8,["to"])])):p("",!0),i.item.id&&!i.shared?(a(),n("li",va,[re(H,{to:t(c)},{default:Se(()=>[b[14]||(b[14]=e("span",{class:"ms-icon text-base"},"chat_add_on",-1)),T(l(g.$t("artifacts.actions.newThread")),1)]),_:1},8,["to"])])):p("",!0),e("li",null,[e("a",{onClick:b[0]||(b[0]=Y=>M("view"))},[b[15]||(b[15]=e("span",{class:"ms-icon text-base"},"visibility",-1)),T(l(g.$t("artifacts.actions.view")),1)])]),!t(v)&&t(W)?(a(),n("li",{key:3,class:X({"menu-disabled":!i.item.url})},[e("details",null,[e("summary",null,[b[16]||(b[16]=e("span",{class:"ms-icon text-base"},"download",-1)),T(l(g.$t("artifacts.actions.download")),1)]),e("ul",null,[e("li",null,[e("a",{onClick:b[1]||(b[1]=Y=>i.item.url&&M("download"))},[b[17]||(b[17]=e("span",{class:"ms-icon text-base"},"photo_library",-1)),T(" "+l(g.$t("artifacts.actions.downloadAllImages")),1)])]),e("li",null,[e("a",{onClick:b[2]||(b[2]=Y=>i.item.url&&M("download-pdf"))},[b[18]||(b[18]=e("span",{class:"ms-icon text-base"},"picture_as_pdf",-1)),T(" "+l(g.$t("artifacts.actions.downloadPdf")),1)])])])])],2)):t(v)?p("",!0):(a(),n("li",{key:4,class:X({"menu-disabled":!i.item.url})},[e("a",{onClick:b[3]||(b[3]=Y=>i.item.url&&M("download"))},[b[19]||(b[19]=e("span",{class:"ms-icon text-base"},"download",-1)),T(l(g.$t("artifacts.actions.download")),1)])],2)),e("li",{class:X({"menu-disabled":!t(z)})},[e("a",{onClick:b[4]||(b[4]=Y=>t(z)&&M("copy-url"))},[e("span",{class:X(["ms-icon text-base transition-colors",i.copied?"text-success":""])},l(i.copied?"check":"content_copy"),3),T(" "+l(i.copied?g.$t("common.copied"):g.$t("artifacts.actions.copyUrl")),1)])],2),e("li",null,[e("a",{onClick:b[5]||(b[5]=Y=>M("details"))},[b[20]||(b[20]=e("span",{class:"ms-icon text-base"},"info",-1)),T(l(g.$t("artifacts.actions.viewDetails")),1)])]),i.shared?(a(),n("li",ma,[e("a",{class:"text-error",onClick:b[6]||(b[6]=Y=>M("leave"))},[b[21]||(b[21]=e("span",{class:"ms-icon text-base"},"logout",-1)),T(l(g.$t("artifacts.actions.leave")),1)])])):(a(),n(G,{key:6},[t(L)?(a(),n("li",pa,[e("a",{onClick:b[7]||(b[7]=Y=>M("copy-workspace"))},[b[22]||(b[22]=e("span",{class:"ms-icon text-base"},"content_copy",-1)),T(" "+l(g.$t("workspaceCopy.action")),1)])])):p("",!0),i.shared?p("",!0):(a(),n("li",ba,[e("a",{onClick:b[8]||(b[8]=Y=>M("migrate"))},[b[23]||(b[23]=e("span",{class:"ms-icon text-base"},"move_group",-1)),T(" "+l(g.$t("workspaceMigration.action")),1)])])),e("li",null,[e("a",{class:"text-error",onClick:b[9]||(b[9]=Y=>M("delete"))},[b[24]||(b[24]=e("span",{class:"ms-icon text-base"},"delete",-1)),T(" "+l(g.$t("artifacts.actions.delete")),1)])])],64))])],2)}}}),ya=Object.assign(ga,{__name:"ArtifactItemMenu"}),ha={class:"modal-box bg-base-100 sm:rounded-box flex h-[100dvh] max-h-[100dvh] w-screen max-w-none flex-col gap-3 rounded-none p-3 sm:h-auto sm:max-h-[90vh] sm:w-full sm:max-w-2xl sm:gap-4 sm:p-6"},ka={class:"flex items-start justify-between gap-3 sm:gap-4"},xa={class:"text-subheadline font-bold"},wa={class:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto sm:flex-row sm:gap-6"},$a={class:"flex shrink-0 flex-col items-center gap-3 sm:items-start"},Ca={class:"border-base-300 bg-base-200 rounded-box relative flex aspect-square size-32 shrink-0 items-center justify-center overflow-hidden border sm:size-40"},Aa=["aria-label"],Fa=["src"],_a=["src","alt"],Ma={key:3,class:"text-base-content/60 flex flex-col items-center justify-center gap-2"},Ia={class:"ms-icon text-5xl"},Ua={class:"flex min-w-0 flex-1 flex-col gap-3"},Ta={class:"text-base-content/70 text-body"},Sa={class:"font-semibold"},za={key:0,class:"text-base-content/70 text-body"},Pa={key:1,class:"text-base-content/70 text-body"},La={key:2,class:"flex flex-wrap items-center gap-2"},Ba={key:1,class:"form-control w-full"},Da={class:"label-text text-body mb-1 font-semibold"},Ra={key:2,class:"form-control w-full"},Ea={class:"label-text text-body mb-1 font-semibold"},Wa=["placeholder"],Va={key:3,class:"form-control w-full"},ja={class:"label-text text-body mb-1 font-semibold"},Oa={value:null},qa=["value"],Ka={class:"text-base-content/70 grid grid-cols-2 gap-2 text-xs"},Na={class:"opacity-60"},Ha={class:"opacity-60"},Ya={key:0},Ga={class:"opacity-60"},Xa={class:"font-semibold"},Qa={key:1},Ja={class:"opacity-60"},Za={class:"truncate font-semibold"},eo={key:2},to={class:"opacity-60"},so={class:"truncate font-semibold"},ao={class:"opacity-60"},oo={class:"font-semibold"},no={class:"opacity-60"},lo={class:"font-semibold"},io={key:4,class:"flex flex-wrap gap-1"},ro={key:5,class:"text-base-content/70 text-body"},co={class:"border-base-300 rounded-field border p-3"},uo=["aria-label"],fo={class:"flex-1"},vo={class:"text-body font-semibold"},mo={class:"text-base-content/70 text-body"},po={class:"ms-icon text-base"},bo={class:"mt-3 space-y-3"},go={key:0,class:"alert alert-success alert-soft text-body py-2"},yo={key:1,class:"alert alert-error alert-soft text-body py-2"},ho={class:"flex items-center justify-between gap-2"},ko={class:"text-base-content/70 text-body"},xo={key:0,class:"loading loading-spinner loading-xs text-primary"},wo={key:2,class:"text-base-content/70 text-body"},$o={key:3,class:"space-y-2"},Co={class:"flex min-w-0 flex-1 items-center gap-2"},Ao={class:"min-w-0 flex-1"},Fo={class:"text-body truncate font-semibold"},_o={key:0,class:"text-base-content/70 text-body truncate"},Mo={key:0,class:"badge badge-ghost badge-xs shrink-0"},Io=["disabled","onClick"],Uo={key:0,class:"loading loading-spinner loading-xs"},To={key:4,class:"flex flex-wrap items-end gap-2"},So={class:"form-control min-w-0 flex-1"},zo={class:"label-text text-body mb-1 font-semibold"},Po=["placeholder"],Lo=["disabled"],Bo={key:0,class:"loading loading-spinner loading-xs"},Do={key:5,class:"text-base-content/70 text-body"},Ro={class:"modal-action mt-0 flex items-center gap-2"},Eo=["disabled"],Wo={key:0,class:"loading loading-spinner loading-xs"},Vo=De({__name:"details",props:{item:{},folders:{},currentUserId:{}},emits:["close","save","leave","view"],setup(i,{emit:le}){const m=i,M=le,_=D(()=>m.item.kind==="app"),v=D(()=>m.item.shared===!0),B=D(()=>!_.value&&!v.value),W=D(()=>rt(m.item)),L=Qe(),c=lt(),z=I(""),g=I(""),b=I(null),H=I(!1),Y=I(null),Q=u=>{H.value=u};xe(()=>m.item,u=>{u&&(z.value=u.name||"",g.value=u.description||"",b.value=u.folderId??null,H.value=!1)},{immediate:!0});const J=D(()=>nt(m.item)),te=D(()=>m.item.kind==="video"&&!!m.item.url&&!m.item.thumbnailUrl),ve=I(!1);xe(()=>[m.item.id,m.item.url,m.item.thumbnailUrl],()=>{ve.value=!1});const se=D(()=>m.item?z.value.trim()!==(m.item.name||"")||g.value!==(m.item.description||"")||(b.value??null)!==(m.item.folderId??null):!1),Ae=u=>L.t(`artifacts.status.${u||"ready"}`),Fe=u=>{switch(u){case"ready":return"badge-success";case"failed":return"badge-error";case"processing":case"pending":return"badge-warning";default:return"badge-ghost"}},$e=()=>{!se.value||H.value||M("save",{name:z.value.trim()||void 0,description:g.value,folderId:b.value},Q)},ae=St(),ue=Kt(),fe=I([]),oe=I(""),ee=I(""),Z=I(""),K=I(!1),j=I(!1),ge=I(null),he=I(!1),Ce=I(!1),me=D(()=>fe.value[0]?.id),_e=u=>!!u.id&&u.id===me.value;xe(oe,()=>{ee.value="",Z.value=""});const f=async()=>
1{if(!(!m.item.id||K.value)){K.value=!0,ee.value="";try{fe.value=await ae.listArtifactUsers(m.item.id),Ce.value=!0}catch(u){console.error("Failed to load artifact users",u),ee.value=L.t("artifacts.access.loadError")}finally{K.value=!1}}},k=async()=>{he.value=!he.value,he.value&&!Ce.value&&await f()},$=u=>{const x=ue.handleApiError(u);u instanceof Yt&&u.message?ee.value=u.message:x||(ee.value=L.t("artifacts.access.updateError"))},R=async()=>{const u=oe.value.trim();if(!(!m.item.id||j.value)){if(!u){ee.value=L.t("artifacts.access.usernameRequired");return}if(await ue.checkFeatureAccess("shareUsers")){j.value=!0,ee.value="",Z.value="";try{fe.value=await ae.addArtifactUser(m.item.id,u),oe.value="",Z.value=L.t("artifacts.access.addSuccess")}catch(x){console.error("Failed to share artifact",x),$(x)}finally{j.value=!1}}}},h=async u=>{if(!(!m.item.id||!u.id||ge.value)){if(u.id===m.currentUserId&&v.value){M("leave",m.item);return}ge.value=u.id,ee.value="",Z.value="";try{fe.value=await ae.removeArtifactUser(m.item.id,u.id),Z.value=L.t("artifacts.access.removeSuccess")}catch(x){console.error("Failed to revoke artifact access",x),$(x)}finally{ge.value=null}}};return Xe(async()=>{await Ge(),Y.value&&!Y.value.open&&Y.value.showModal()}),(u,x)=>{const y=Tt,U=it,P=ds;return a(),n("dialog",{ref_key:"modalRef",ref:Y,class:"modal modal-open",onCancel:x[9]||(x[9]=we(C=>M("close"),["prevent"])),onClick:x[10]||(x[10]=we(C=>M("close"),["self"]))},[e("div",ha,[e("div",ka,[e("h3",xa,l(u.$t("artifacts.detail.title")),1),e("button",{type:"button",class:"btn btn-circle btn-ghost btn-sm",onClick:x[0]||(x[0]=C=>M("close"))},[...x[11]||(x[11]=[e("span",{class:"ms-icon text-lg"},"close",-1)])])]),e("div",wa,[e("div",$a,[e("div",Ca,[(i.item.kind==="image"||i.item.kind==="video")&&(i.item.status==="processing"||i.item.status==="pending")?(a(),n("div",{key:0,class:"skeleton h-full w-full","aria-label":u.$t("editor.thread.processingMedia")},null,8,Aa)):t(te)&&t(J)&&!t(ve)&&i.item.status!=="failed"?(a(),n("video",{key:1,src:t(J),class:"h-full w-full object-cover",muted:"",playsinline:"",preload:"metadata",onError:x[1]||(x[1]=C=>ve.value=!0)},null,40,Fa)):t(J)&&!t(ve)&&i.item.status!=="failed"?(a(),n("img",{key:2,src:t(J),alt:i.item.name||"file",class:"h-full w-full object-cover",onError:x[2]||(x[2]=C=>ve.value=!0)},null,40,_a)):(a(),n("div",Ma,[e("span",Ia,l(("artifactKindIcon"in u?u.artifactKindIcon:t(Ut))(i.item.kind)),1),re(y,{kind:i.item.kind,size:"xs"},null,8,["kind"])]))])]),e("div",Ua,[t(B)?p("",!0):(a(),n(G,{key:0},[e("div",null,[e("div",Ta,l(u.$t("artifacts.detail.name")),1),e("div",Sa,l(i.item.name||u.$t("editor.untitled")),1)]),i.item.description?(a(),n("p",za,l(i.item.description),1)):p("",!0),t(v)?(a(),n("p",Pa,l(u.$t("artifacts.access.sharedNotice")),1)):p("",!0),t(_)?(a(),n("div",La,[e("button",{type:"button",class:"btn btn-secondary btn-soft btn-sm gap-2",onClick:x[3]||(x[3]=C=>M("view",i.item))},[x[12]||(x[12]=e("span",{class:"ms-icon text-base"},"visibility",-1)),T(" "+l(u.$t("artifacts.actions.view")),1)]),t(W)?(a(),Le(U,{key:0,to:t(W),external:"",target:"_blank",rel:"noopener noreferrer",class:"btn btn-primary btn-sm gap-2"},{default:Se(()=>[x[13]||(x[13]=e("span",{class:"ms-icon text-base"},"open_in_new",-1)),T(" "+l(u.$t("artifacts.detail.openApp")),1)]),_:1},8,["to"])):p("",!0)])):p("",!0)],64)),t(B)?(a(),n("label",Ba,[e("span",Da,l(u.$t("artifacts.detail.name")),1),Be(e("input",{"onUpdate:modelValue":x[4]||(x[4]=C=>Oe(z)?z.value=C:null),type:"text",class:"input input-bordered input-sm w-full"},null,512),[[Ke,t(z)]])])):p("",!0),t(B)?(a(),n("label",Ra,[e("span",Ea,l(u.$t("artifacts.detail.description")),1),Be(e("textarea",{"onUpdate:modelValue":x[5]||(x[5]=C=>Oe(g)?g.value=C:null),rows:"3",class:"textarea textarea-bordered textarea-sm w-full",placeholder:u.$t("artifacts.detail.descriptionPlaceholder")},null,8,Wa),[[Ke,t(g)]])])):p("",!0),t(B)?(a(),n("label",Va,[e("span",ja,l(u.$t("artifacts.detail.folder")),1),Be(e("select",{"onUpdate:modelValue":x[6]||(x[6]=C=>Oe(b)?b.value=C:null),class:"select select-bordered select-sm w-full"},[e("option",Oa,l(u.$t("artifacts.moveToRoot")),1),(a(!0),n(G,null,be(i.folders,C=>(a(),n("option",{key:C.id,value:C.id},l(C.name),9,qa))),128))],512),[[Nt,t(b)]])])):p("",!0),e("div",Ka,[e("div",null,[e("div",Na,l(u.$t("artifacts.detail.kind")),1),re
1(y,{kind:i.item.kind,size:"xs",class:"mt-1"},null,8,["kind"])]),e("div",null,[e("div",Ha,l(u.$t("artifacts.detail.status")),1),e("span",{class:X(["badge badge-xs",Fe(i.item.status)])},l(Ae(i.item.status)),3)]),t(_)?p("",!0):(a(),n("div",Ya,[e("div",Ga,l(u.$t("artifacts.detail.size")),1),e("div",Xa,l(t(c).formatBytes(i.item.sizeInBytes)||"â"),1)])),t(_)?p("",!0):(a(),n("div",Qa,[e("div",Ja,l(u.$t("artifacts.detail.type")),1),e("div",Za,l(i.item.contentType||"â"),1)])),t(_)&&i.item.slug?(a(),n("div",eo,[e("div",to,l(u.$t("artifacts.detail.address")),1),e("div",so,l(i.item.slug),1)])):p("",!0),e("div",null,[e("div",ao,l(u.$t("artifacts.detail.created")),1),e("div",oo,l(t(c).formatTime(i.item.createdAt)||"â"),1)]),e("div",null,[e("div",no,l(u.$t("artifacts.detail.updated")),1),e("div",lo,l(t(c).formatTime(i.item.updatedAt)||"â"),1)])]),i.item.tags&&i.item.tags.length?(a(),n("div",io,[(a(!0),n(G,null,be(i.item.tags,C=>(a(),n("span",{key:C,class:"badge badge-soft badge-sm"},l(C),1))),128))])):p("",!0),i.item.threadIds&&i.item.threadIds.length?(a(),n("p",ro,l(u.$t("artifacts.detail.usedIn",{count:t(c).formatCount(i.item.threadIds.length)},i.item.threadIds.length)),1)):p("",!0),e("section",co,[e("button",{class:"flex w-full cursor-pointer items-start justify-between gap-3 text-left transition-opacity hover:opacity-80","aria-label":u.$t("common.toggle"),onClick:k},[e("div",fo,[e("div",vo,l(u.$t("artifacts.access.title")),1),e("p",mo,l(u.$t("artifacts.access.description")),1)]),e("span",po,l(t(he)?"expand_less":"expand_more"),1)],8,uo),Be(e("div",bo,[t(Z)?(a(),n("div",go,[x[14]||(x[14]=e("span",{class:"ms-icon text-base"},"check_circle",-1)),e("span",null,l(t(Z)),1)])):p("",!0),t(ee)?(a(),n("div",yo,[x[15]||(x[15]=e("span",{class:"ms-icon text-base"},"error",-1)),e("span",null,l(t(ee)),1)])):p("",!0),e("div",ho,[e("span",ko,l(u.$t("artifacts.access.currentAccess")),1),t(K)?(a(),n("span",xo)):p("",!0)]),!t(K)&&t(fe).length===0?(a(),n("p",wo,l(u.$t("artifacts.access.noUsers")),1)):(a(),n("ul",$o,[(a(!0),n(G,null,be(t(fe),C=>(a(),n("li",{key:C.id||C.slug,class:"flex items-center justify-between gap-3"},[e("div",Co,[re(P,{user:C,size:"sm",class:"flex-shrink-0"},null,8,["user"]),e("div",Ao,[e("div",Fo,l(C.name||C.slug),1),C.slug?(a(),n("div",_o," @"+l(C.slug),1)):p("",!0)]),_e(C)?(a(),n("span",Mo,l(u.$t("artifacts.access.ownerBadge")),1)):p("",!0)]),!_e(C)&&(!t(v)||C.id===i.currentUserId)?(a(),n("button",{key:0,class:"btn btn-ghost btn-xs text-error",disabled:t(ge)===C.id,onClick:w=>h(C)},[t(ge)===C.id?(a(),n("span",Uo)):p("",!0),T(" "+l(C.id===i.currentUserId?u.$t("artifacts.actions.leave"):u.$t("artifacts.access.removeCta")),1)],8,Io)):p("",!0)]))),128))])),t(v)?p("",!0):(a(),n("div",To,[e("label",So,[e("span",zo,l(u.$t("artifacts.access.inputLabel")),1),Be(e("input",{"onUpdate:modelValue":x[7]||(x[7]=C=>Oe(oe)?oe.value=C:null),type:"text",class:"input input-bordered input-sm w-full",placeholder:u.$t("artifacts.access.inputPlaceholder"),onKeyup:Mt(R,["enter"])},null,40,Po),[[Ke,t(oe)]])]),e("button",{class:"btn btn-primary btn-sm gap-2",disabled:!t(oe).trim()||t(j),onClick:R}
1,[t(j)?(a(),n("span",Bo)):p("",!0),T(" "+l(u.$t("artifacts.access.addCta")),1)],8,Lo)])),t(v)?p("",!0):(a(),n("p",Do,l(u.$t("artifacts.access.helper")),1))],512),[[Ht,t(he)]])])])]),e("div",Ro,[x[16]||(x[16]=e("div",{class:"flex-1"},null,-1)),e("button",{type:"button",class:"btn btn-ghost btn-sm",onClick:x[8]||(x[8]=C=>M("close"))},l(u.$t("artifacts.detail.close")),1),t(B)?(a(),n("button",{key:0,type:"button",class:"btn btn-primary btn-sm gap-2",disabled:!t(se)||t(H),onClick:$e},[t(H)?(a(),n("span",Wo)):p("",!0),T(" "+l(u.$t("artifacts.detail.save")),1)],8,Eo)):p("",!0)])])],544)}}}),jo=Object.assign(Vo,{__name:"ArtifactDetails"});function Oo(i={}){const le=Qe(),m=i.client??St(),M=()=>Gt(i.threadId),_=I([]),v=I([]),B=I(),W=I(!1),L=D(()=>!!B.value),c=I(i.initialFolderId??null),z=I(null),g=I(""),b=I(),H=I(),Y=I(!0),Q=I(!1),J=I(""),te=I(""),ve=D(()=>!!b.value),se=D(()=>c.value===ot),Ae=()=>{J.value="",te.value=""},Fe=Ut,$e=async()=>{try{const d=await m.listFolders();v.value=d.items,B.value=d.nextCursor;const A=i.initialFolderId;if(A&&!v.value.some(F=>F.id===A)){const F=await m.getFolder(A);F&&(v.value=[F,...v.value])}}catch(d){console.error("Failed to load folders",d)}},ae=async()=>{if(!(!B.value||W.value)){W.value=!0;try{const d=await m.listFolders({cursor:B.value}),A=new Set(v.value.map(F=>F.id));v.value=[...v.value,...d.items.filter(F=>!A.has(F.id))],B.value=d.nextCursor}catch(d){console.error("Failed to load more folders",d)}finally{W.value=!1}}},ue=()=>c.value===null&&z.value?void 0:c.value,fe=(d,A)=>[d.name,d.slug,d.description].some(S=>S?.toLowerCase().includes(A));let oe=0;const ee=async({reset:d=!1,cursor:A}={})=>{if(Q.value||Y.value&&!d)return;Ae();const F=++oe;d?Y.value=!0:Q.value=!0;const S=g.value.trim(),ne=se.value,O=ne?"":S;try{const Ie=await m.listArtifacts({folderId:O?void 0:ue(),cursor:O?void 0:A,kind:z.value??void 0,query:O||void 0});if(F!==oe)return;let ze=(Ie.items||[]).filter(Me=>Me.status!=="deleted");if(ne&&S){const Me=S.toLowerCase();ze=ze.filter(Ue=>fe(Ue,Me))}if(d)_.value=ze;else{const Me=new Map;for(const Ue of[..._.value,...ze])Ue.id&&Me.set(Ue.id,Ue);_.value=Array.from(Me.values())}b.value=Ie.nextCursor}catch(Ie){if(F!==oe)return;console.error("Failed to load artifacts",Ie),J.value=le.t("artifacts.loadError")}finally{F===oe&&(Y.value=!1,Q.value=!1)}},Z=async()=>{!b.value||Q.value||await ee({cursor:b.value})};let K;const j=async d=>{c.value=d,K&&clearTimeout(K),g.value="",await ee({reset:!0})},ge=async d=>{z.value=d,await ee({reset:!0})},he=(d,{debounceMs:A=300}={})=>{K&&clearTimeout(K),g.value=d,K=setTimeout(()=>{ee({reset:!0})},A)},Ce=async d=>{for(let A=0;A<30;A++){await new Promise(S=>setTimeout(S,2e3));const F=await m.getArtifact(d).catch(()=>null);if(F&&(me(d,F),F.status==="ready"||F.status==="failed"))return}},me=(d,A)=>{const F=_.value.findIndex(S=>S.id===d);F!==-1&&(_.value[F]={..._.value[F],...A})},_e=d=>c.value===null&&z.value?!0:c.value===null?!d.folderId:d.folderId===c.value,f=d=>!z.value||d.kind===z.value,k=d=>{if(!d?.id||se.value||g.value.trim())return;const A=d.status!=="deleted"&&_e(d)&&f(d),F=_.value.findIndex(S=>S.id===d.id);if(!A){F!==-1&&(_.value=_.value.filter(S=>S.id!==d.id));return}F!==-1?_.value=_.value.map((S,ne)=>ne===F?{...S,...d}:S):_.value=[d,..._.value]},$=async d=>{if(!cs(d)){J.value=le.t("editor.artifact.errors.fileType");return}const A=m.generateArtifactId(),F={id:A,status:"pending",name:d.name,sizeInBytes:d.size,contentType:d.type};_.value.unshift(F);try{const S=c.value===null||se.value?null:c.value,ne=await m.requestUpload({file:d,artifactId:A,folderId:S,threadId:M()});me(A,{...ne.artifact,url:ne.finalUrls?.url||ne.artifact.url,thumbnailUrl:ne.finalUrls?.thumbnailUrl||ne.artifact.thumbnailUrl,status:"processing"}),await m.uploadToSignedUrl(ne.uploadUrl,d,ne.maxUploadBytes),te.value=le.t("artifacts.uploadSuccess"),Ce(ne.artifact.id||A)}catch(S){console.error("Failed to upload artifact",S),J.value=S instanceof Error?S.message:le.t("artifacts.uploadError"),_.value=_.value.filter(ne=>ne.id!==A)}},R=async d=>{Ae();for(const A of d.slice(0,10))await $(A)},h=async(d,A)=>{const F=await m.updateArtifact(d,A);return F&&me(d,F),F},u=async d=>{await m.deleteArtifact(d),_.value=_.value.filter(A=>A.id!==d)},x=d=>{_.value=_.value.filter(A=>A.id!==d)};return{items:_,folders:v,hasMoreFolders:L,isLoadingMoreFolders:W,loadMoreFolders:ae,currentFolderId:c,currentKind:z,searchQuery:g,nextCursor:b,totalCount:H,hasMore:ve,isSharedView:se,loading:Y,loadingMore:Q,errorMessage:J,successMessage:te,iconForKind:Fe,resetMessages:Ae,applyUpdate:me,applyStreamUpdate:k,removeFromList:x,init:async()=>{await Promise.all([$e(),ee({reset:!0})])},loadFolders:$e,loadFiles:ee,loadMore:Z,selectFolder:j,selectKind:ge,search:he,uploadFiles:R,updateArtifact:h,deleteArtifact:u,linkArtifactToThread:(d,A)=>m.linkArtifactToThread?m.linkArtifactToThread(d,A):Promise.resolve(null),listArtifactUsers:d=>m.listArtifactUsers?m.listArtifactUsers(d):Promise.resolve([]),addArtifactUser:(d,A)=>{if(!m.addArtifactUser)throw new Error("Artifact user sharing not supported in this client scope");return m.addArtifactUser(d,A)},removeArtifactUser:async(d,A,F=!1)=>
1{if(!m.removeArtifactUser)throw new Error("Artifact user sharing not supported in this client scope");const S=await m.removeArtifactUser(d,A);return F&&x(d),S},createFolder:async d=>{const A=typeof c.value=="string"&&c.value!=="root"&&c.value!==ot?c.value:null,F=await m.createFolder(d.trim(),A);return F&&(v.value=v.value.map(S=>A&&S.id===A?{...S,folderCount:(S.folderCount??0)+1}:S).concat(F),F.id&&await j(F.id)),F},renameFolder:async(d,A)=>{const F=await m.renameFolder(d,A.trim());return F&&(v.value=v.value.map(S=>S.id===d?{...S,...F}:S)),F},deleteFolder:async d=>{await m.deleteFolder(d),v.value=v.value.filter(A=>A.id!==d),c.value===d&&await j(null)}}}const qo={class:"artifact-browser bg-base-100 flex h-full min-h-0 flex-1 flex-col"},Ko={class:"mx-auto flex w-full max-w-4xl shrink-0 flex-col gap-2.5 px-3 pt-3 sm:px-6 sm:pt-4 lg:px-8"},No={class:"flex flex-nowrap items-center gap-2"},Ho={class:"input input-sm input-bordered flex min-w-0 flex-1 items-center gap-2"},Yo=["placeholder"],Go=["accept"],Xo=["title"],Qo={class:"artifact-browser-upload-label hidden"},Jo=["aria-label"],Zo=["aria-label","title"],en=["aria-label","title"],tn=["aria-label","title"],sn=["aria-label"],an=["aria-pressed"],on=["aria-pressed","onClick"],nn={class:"ms-icon text-xs"},ln={key:0,class:"mx-auto w-full max-w-4xl shrink-0 px-3 pt-2 sm:px-6 lg:px-8"},rn={key:0,class:"alert alert-error alert-soft text-body"},dn={key:1,class:"alert alert-success alert-soft text-body"},cn={class:"min-h-0 flex-1"},un={key:0,class:"mb-5"},fn={key:0,class:"artifact-browser-grid artifact-browser-grid-spaced grid gap-3"},vn={key:1,class:"divide-base-200 divide-y"},mn={key:0,class:"mb-2 flex items-center gap-2"},pn={key:1},bn={class:"divide-base-200 divide-y"},gn={key:2,class:"artifact-browser-grid artifact-browser-grid-spaced grid gap-3"},yn={key:1,class:"mb-5"},hn={class:"mb-2 flex items-center gap-2"},kn={class:"text-base-content/70 text-body font-bold tracking-wide"},xn={key:0,class:"badge badge-ghost badge-xs font-mono"},wn={key:0,class:"artifact-browser-grid artifact-browser-grid-spaced grid gap-3"},$n={key:1,class:"divide-base-200 divide-y"},Cn={key:2,class:"mt-2 flex items-center gap-2"},An={class:"ms-icon text-sm"},Fn=["disabled"],_n={key:0,class:"loading loading-spinner loading-xs"},Mn={key:2},In={key:0,class:"mb-2 flex items-center gap-2"},Un={class:"text-base-content/70 text-body font-bold tracking-wide"},Tn={key:0,class:"badge badge-ghost badge-xs font-mono"},Sn={key:1,class:"text-base-content/70 text-body flex flex-col items-center justify-center gap-2 py-16"},zn={class:"ms-icon text-base-content/40 text-4xl"},Pn={key:0},Ln={key:1},Bn={key:2},Dn={key:3},Rn={key:0},En={class:"divide-base-200 divide-y"},Wn=["onClick"],Vn={class:"bg-base-200 flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg"},jn=["aria-label"],On=["src","alt"],qn={class:"min-w-0 flex-1"},Kn={class:"flex min-w-0 items-center gap-1.5"},Nn={class:"text-body truncate font-semibold"},Hn=["title"],Yn={class:"text-base-content/70 artifact-list-mobile-col mt-0.5 flex-wrap items-center gap-x-1.5 text-xs font-medium"},Gn={key:0},Xn={key:1},Qn={key:2,"aria-hidden":"true",class:"opacity-50"},Jn={key:3},Zn={class:"artifact-list-desktop-col w-24 shrink-0"},el={class:"text-base-content/70 artifact-list-desktop-col w-20 shrink-0 text-xs"},tl={class:"text-base-content/70 artifact-list-desktop-col-wide w-28 shrink-0 text-xs"},sl={key:1,class:"artifact-browser-grid artifact-browser-grid-spaced grid gap-3"},al=["onClick"],ol=["aria-label"],nl=["src"],ll=["src","alt"],il={key:3,class:"text-base-content/60 flex h-full w-full items-center justify-center"},rl={class:"text-base-content text-body px-1 text-center font-semibold"},dl={class:"line-clamp-2"},cl={class:"text-base-content/70 mt-0.5 block text-xs font-medium"},ul=["title"],fl={key:2,class:"mt-6 text-center"},vl=["disabled"],ml={key:0,class:"loading loading-spinner loading-sm"},pl={class:"modal-box bg-base-100 max-w-sm"},bl={class:"text-body mb-3 font-bold"},gl=["placeholder"],yl={class:"modal-action"},hl=["disabled"],kl={key:0,class:"loading loading-spinner loading-xs"},xl={class:"modal-box bg-base-100 max-w-sm"},wl={class:"text-body"},$l={class:"modal-action"},Cl=["disabled"],Al={key:0,class:"loading loading-spinner loading-xs"},Fl=4,_l=De({__name:"browser",props:{mode:{default:"manage"},client:{},initialFolderId:{}},emits:["select","view-item","item-update","count-change","folder-change"],setup(i,{expose:le,emit:m}){const M=i,_=m,v=Qe(),B=lt(),W=Xt(),L=Qt(),c=fs(),z=D(()=>W.account?.id),g=Oo({client:M.client,initialFolderId:M.initialFolderId}),{items:b,folders:H,hasMoreFolders:Y,isLoadingMoreFolders:Q,currentFolderId:J,currentKind:te,hasMore:ve,isSharedView:se,totalCount:Ae,loading:Fe,loadingMore:$e,errorMessage:ae,successMessage:ue,iconForKind:fe}=g,oe=ot,ee=D(()=>M.mode==="manage"),Z=s=>s.shared===!0,K=D({get:()=>
1g.searchQuery.value,set:s=>g.search(s)}),j=Jt("artifacts:view-mode",()=>"grid"),ge=D(()=>c.enabled.value);xe(ge,s=>{!s&&j.value==="graph"&&(j.value="grid")},{immediate:!0});const he=es,Ce=s=>{g.selectKind(s)},me=I(null),_e=I(null),f=I(null),k=I(null);xe(Ae,s=>{s!==void 0&&_("count-change",s)},{immediate:!0});const $=D(()=>J.value===null),R=D(()=>typeof J.value=="string"&&!se.value?H.value.find(s=>s.id===J.value):void 0),h=D(()=>{if(!($.value||K.value||te.value))return R.value?.parentId??null}),u=D(()=>{if(K.value.trim())return H.value;if(te.value||se.value)return[];const s=$.value?null:J.value;return H.value.filter(r=>(r.parentId??null)===s)}),x=D(()=>$.value?null:se.value?{icon:"folder_shared",label:v.t("artifacts.sharedWithMe")}:{icon:"folder",label:R.value?.name||v.t("artifacts.folders")}),y=D(()=>{const s=K.value.trim().toLowerCase();if(te.value)return[];const pe=[...s?H.value.filter(ce=>ce.name?.toLowerCase().includes(s)):H.value.filter(ce=>(ce.parentId??null)===($.value?null:J.value))].sort((ce,Ye)=>new Date(Ye.updatedAt??0).getTime()-new Date(ce.updatedAt??0).getTime()).map(ce=>({key:ce.id||ce.name||"",folder:ce,target:ce.id??null,managed:!0}));if(s)return pe;if(!$.value){const ce=R.value?.parentId??null;return[{key:"view:back",folder:{name:v.t("artifacts.backFolder")},icon:"arrow_back",target:ce,managed:!1},...pe]}const ye=[];return ee.value&&ye.push({key:"view:shared",folder:{name:v.t("artifacts.sharedWithMe")},icon:"folder_shared",target:oe,managed:!1}),[...ye,...pe]}),U=I(!1),P=D(()=>U.value?y.value:y.value.slice(0,Fl)),C=D(()=>Math.max(0,y.value.length-P.value.length)),w=D(()=>y.value.length>0),V=D(()=>{if(!K.value.trim()){if($.value)return L.folderCount||void 0;if(R.value)return R.value.folderCount||void 0}}),N=D(()=>{if(!(K.value.trim()||se.value)){if(R.value)return R.value.artifactCount||void 0;$.value}}),E=s=>s.kind==="app",d=s=>v.t(`artifacts.status.${s||"ready"}`),A=s=>{switch(s){case"ready":return"badge-success";case"failed":return"badge-error";case"processing":case"pending":return"badge-warning";default:return"badge-ghost"}},F=s=>nt(s),S=s=>s.status==="pending"||s.status==="processing",ne=s=>s.kind==="video"&&!!s.url&&!s.thumbnailUrl,O=at({open:!1,title:"",placeholder:"",confirmLabel:"",value:"",busy:!1,onConfirm:null}),Ie=I(null),ze=I(null),Me=I(null),Ue=s=>{s&&!s.open&&s.showModal()},dt=async s=>{O.title=s.title,O.placeholder=s.placeholder||"",O.confirmLabel=s.confirmLabel||v.t("common.save"),O.value=s.initial||"",O.onConfirm=s.onConfirm,O.busy=!1,O.open=!0,await Ge(),Ue(ze.value),Ie.value?.focus(),Ie.value?.select()},ct=async()=>{const s=O.value.trim();if(!(!s||O.busy)){O.busy=!0;try{await O.onConfirm?.(s),O.open=!1}catch(r){console.error("Prompt action failed",r),ae.value=v.t("artifacts.deleteError")}finally{O.busy=!1}}},ie=at({open:!1,message:"",confirmLabel:"",busy:!1,onConfirm:null}),Je=s=>{ie.message=s.message,ie.confirmLabel=s.confirmLabel||v.t("common.delete"),ie.onConfirm=s.onConfirm,ie.busy=!1,ie.open=!0,Ge(()=>Ue(Me.value))},zt=async()=>{if(!ie.busy){ie.busy=!0;try{await ie.onConfirm?.(),ie.open=!1}catch(s){console.error("Confirm action failed",s),ae.value=v.t("artifacts.deleteError")}finally{ie.busy=!1}}},Pt=()=>{g.resetMessages(),me.value?.click()},Lt=async s=>{const r=s.target,de=r.files?Array.from(r.files):[];de.length&&await g.uploadFiles(de),me.value&&(me.value.value="")},Bt=()=>dt({title:v.t("artifacts.newFolder"),placeholder:v.t("artifacts.newFolderPrompt"),confirmLabel:v.t("common.create"),onConfirm:async s=>{await g.createFolder(s)}}),ut=s=>dt({title:v.t("artifacts.actions.rename"),placeholder:v.t("artifacts.renameFolderPrompt"),confirmLabel:v.t("common.rename"),initial:s.name||"",onConfirm:async r=>{s.id&&await g.renameFolder(s.id,r)}}),ft=s=>Je({message:v.t("artifacts.deleteFolderConfirm"),onConfirm:async()=>{s.id&&await g.deleteFolder(s.id)}}),vt=s=>{s.url&&(s.kind==="creative"&&_t(s.slideCount)?ns(s):ls(s.url,is(s)))},mt=s=>{rs(s)},Dt=s=>E(s)?rt(s):s.url?ss(s.url):"",We=I(null);let Ve=null;const pt=async s=>{const r=Dt(s);if(!(!r||!s.id))try{await navigator.clipboard.writeText(r),Ve&&clearTimeout(Ve),We.value=s.id,Ve=setTimeout(()=>{We.value===s.id&&(We.value=null)},2e3)}catch(de){console.error("Failed to copy artifact URL",de),ae.value=v.t("common.copyFailed")}}
1,bt=s=>Je({message:E(s)?v.t("artifacts.deleteAppConfirm"):v.t("artifacts.deleteConfirm"),onConfirm:async()=>{if(s.id){_e.value=s.id;try{await g.deleteArtifact(s.id),ke.value?.id===s.id&&Ee()}catch(r){console.error("Failed to delete artifact",r),ae.value=v.t("artifacts.deleteError")}finally{_e.value=null}}}}),gt=s=>{!s.id||Z(s)||(f.value=s)},yt=s=>{!s.id||!["creative","material","markdown"].includes(s.kind||"")||Z(s)||(k.value=s)},Rt=()=>{const s=f.value?.id;s&&(g.removeFromList(s),ke.value?.id===s&&Ee(),f.value=null)},Et=async()=>{k.value=null,await g.loadFiles({reset:!0})},Re=D(()=>J.value),Wt=s=>{const r=f.value?.id;if(!r)return;Re.value!==void 0&&(s??null)!==Re.value&&g.removeFromList(r),f.value=null},Ze=s=>Je({message:v.t("artifacts.leaveConfirm"),confirmLabel:v.t("artifacts.actions.leave"),onConfirm:async()=>{if(!(!s.id||!z.value))try{await g.removeArtifactUser(s.id,z.value,!0),ke.value?.id===s.id&&Ee(),ue.value=v.t("artifacts.access.leaveSuccess")}catch(r){console.error("Failed to leave shared artifact",r),ae.value=v.t("artifacts.access.updateError")}}}),et=s=>s.status==="ready"&&!!s.id&&(E(s)||!!s.url),je=I(null),Ne=s=>{M.mode==="manage"?_("view-item",s):je.value=s},ht=()=>{je.value=null},tt=s=>{if(M.mode==="attach"){if(!et(s))return;_("select",s);return}Ne(s)},He=I(null),kt=async(s,r)=>{const de=b.value.find(pe=>pe.id===s);if(!(!de||(de.folderId??null)===r)){g.resetMessages(),He.value=s;try{await g.updateArtifact(s,{folderId:r}),Re.value!==void 0&&r!==Re.value&&g.removeFromList(s);const pe=r?H.value.find(ye=>ye.id===r)?.name:v.t("artifacts.ungrouped");ue.value=v.t("artifacts.moveSuccess",{name:pe||v.t("artifacts.folders")}),g.loadFolders()}catch(pe){console.error("Failed to move artifact",pe),ae.value=v.t("artifacts.moveError")}finally{He.value=null}}},ke=I(null),xt=s=>{ke.value=s},Ee=()=>{ke.value=null},Vt=async(s,r)=>{if(!ke.value?.id)return;r(!0);const de=ke.value.id,pe=Re.value!==void 0&&(s.folderId??null)!==Re.value;try{const ye=await g.updateArtifact(de,s);ye&&(ke.value={...ke.value,...ye},pe&&g.removeFromList(de)),ue.value=v.t("artifacts.detail.saved"),Ee()}catch(ye){console.error("Failed to update artifact",ye),ae.value=v.t("artifacts.deleteError")}finally{r(!1)}};xe(J,s=>{_("folder-change",typeof s=="string"?s:null)}),xe(()=>M.initialFolderId,s=>{const r=s??null;r!==J.value&&g.selectFolder(r)});const Pe=M.client?null:vs();let wt,$t,Ct;return Xe(()=>{g.init(),Pe&&(wt=Pe.onEvent(s=>{s.type==="artifact:update"&&s.artifact&&(g.applyStreamUpdate(s.artifact),_("item-update",s.artifact))}),$t=Pe.onReconnect(()=>{g.loadFiles({reset:!0})}),Ct=xe(()=>L.workspaceId,(s,r)=>{s!==r&&(Pe.disconnect(),s&&Pe.connect().catch(de=>{console.warn("Failed to switch artifact stream connection:",de)}))}),L.workspaceId&&Pe.connect().catch(s=>{console.warn("Failed to connect artifact stream:",s)}))}),Ft(()=>{Ve&&clearTimeout(Ve),Ct?.(),wt?.(),$t?.(),Pe?.disconnect()}),le({createFolder:Bt,currentFolder:R,location:x,goHome:()=>g.selectFolder(null),viewItem:je,closeView:ht}),(s,r)=>{const de=Cs,pe=zs,ye=ra,ce=Tt,Ye=ya,jt=os,Ot=jo,At=us;return a(),n("div",qo,[e("div",Ko,[e("div",No,[e("label",Ho,[r[21]||(r[21]=e("span",{class:"ms-icon text-base-content/50 text-base"},"search",-1)),Be(e("input",{"onUpdate:modelValue":r[0]||(r[0]=o=>Oe(K)?K.value=o:null),type:"text",class:"min-w-0 grow",placeholder:t(j)==="graph"?s.$t("artifacts.graph.searchPlaceholder"):s.$t("artifacts.searchPlaceholder")},null,8,Yo),[[Ke,t(K)]])]),e("input",{ref_key:"fileInputRef",ref:me,type:"file",multiple:"",accept:t(Zt),class:"hidden",onChange:Lt},null,40,Go),t(se)?p("",!0):(a(),n("button",{key:0,class:"btn btn-primary btn-sm shrink-0 gap-2",title:s.$t("artifacts.upload"),onClick:Pt},[r[22]||(r[22]=e("span",{class:"ms-icon text-base"},"cloud_upload",-1)),e("span",Qo,l(s.$t("artifacts.upload")),1)],8,Xo)),e("div",{class:"join",role:"group","aria-label":s.$t("artifacts.views.label")},[e("button",{class:X(["btn join-item btn-sm btn-square",t(j)==="list"?"btn-primary btn-soft":"btn-ghost"]),"aria-label":s.$t("artifacts.views.list"),title:s.$t("artifacts.views.list"),onClick:r[1]||(r[1]=o=>j.value="list")},[...r[23]||(r[23]=[e("span",{class:"ms-icon text-base"},"view_list",-1)])],10,Zo),e("button",{class:X(["btn join-item btn-sm btn-square",t(j)==="grid"?"btn-primary btn-soft":"btn-ghost"]),"aria-label":s.$t("artifacts.views.grid"),title:s.$t("artifacts.views.grid"),onClick:r[2]||(r[2]=o=>j.value="grid")},[...r[24]||(r[24]=[e("span",{class:"ms-icon text-base"},"grid_view",-1)])],10,en),t(ge)?(a(),n("button",{key:0,class:X(["btn join-item btn-sm btn-square",t(j)==="graph"?"btn-primary btn-soft":"btn-ghost"]),"aria-label":s.$t("artifacts.views.graph"),title:s.$t("artifacts.views.graph"),onClick:r[3]||(r[3]=o=>j.value="graph")},[...r[25]||(r[25]=[e("span",{class:"ms-icon text-base"},"hub",-1)])],10,tn)):p("",!0)],8,Jo)]),e("div",{class:"no-scrollbar flex flex-nowrap items-center gap-1.5 overflow-x-auto overflow-y-hidden py-0.5",role:"group","aria-label":s.$t("artifacts.filterByKind")},[e("button",{type:"button",class:X(["badge badge-sm shrink-0 cursor-pointer gap-1 font-semibold whitespace-nowrap transition-all",t(te)?"text-base-content/70 hover:bg-base-200/60 hover:text-base-content border-transparent bg-transparent":"badge-primary badge-soft"]),"aria-pressed":!t(te),onClick:r[4]||(r[4]=o=>Ce(null))},[r[26]||(r[26]=e("span",{class:"ms-icon text-xs"},"apps",-1)),e("span",null,l(s.$t("artifacts.allKinds")),1)],10,an),(a(!0),n(G,null,be(t(he),o=>(a(),n("button",{key:o,type:"button",class:X(["badge badge-sm shrink-0 cursor-pointer gap-1 font-semibold whitespace-nowrap transition-all",t(te)===o?"badge-primary badge-soft":"text-base-content/70 hover:bg-base-200/60 hover:text-base-content border-transparent bg-transparent"]),"aria-pressed":t(te)===o,onClick:Te=>Ce(o)},[e("span",nn,l(t(fe)(o)),1),e("span",null,l(s.$t(`artifacts.kind.${o}`)),1)],10,on))),128))],8,sn)]),t(ae)||t(ue)?(a(),n("div",ln,[t(ae)?(a(),n("div",rn,[r[27]||(r[27]=e("span",{class:"ms-icon"},"error",-1)),e("span",null,l(t(ae)),1)])):p("",!0),t(ue)?(a(),n("div",dn,[r[28]||(r[28]=e("span",{class:"ms-icon"},"check_circle",-1)),e("span",null,l(t(ue)),1)])):p("",!0)])):p("",!0),e("div",cn,[e("div",{class:X(["h-full overscroll-contain",t(j)==="graph"?"overflow-hidden":"overflow-y-auto"])},[e("div",{class:X(["mx-auto flex w-full max-w-4xl flex-col gap-3 px-3 py-3 sm:gap-4 sm:px-6 sm:py-4 lg:px-8",t(j)==="graph"?"h-full":""])},[t(Fe)?(a(),n(G,{key:0},[t(j)==="graph"?(a(),Le(de,{key:0})):(a(),n(G,{key:1},[!t(te)&&!t(K)?(a(),n("section",un,[r[31]||(r[31]=e("div",{class:"mb-2 flex items-center gap-2"},[e("div",{class:"skeleton h-3.5 w-16"}
1),e("div",{class:"skeleton size-4 rounded-full"})],-1)),t(j)==="grid"?(a(),n("div",fn,[(a(!0),n(G,null,be(t($)?4:1,o=>(a(),n("div",{key:"folder-grid-skel-"+o,class:"border-base-300 bg-base-100 rounded-box flex h-full min-h-[3.25rem] items-center gap-2.5 border px-2.5 py-2 sm:min-h-[3.5rem]"},[...r[29]||(r[29]=[e("div",{class:"skeleton size-6 shrink-0 rounded"},null,-1),e("div",{class:"min-w-0 flex-1 space-y-1.5 py-0.5"},[e("div",{class:"skeleton h-3.5 w-24"}),e("div",{class:"skeleton h-2.5 w-16"})],-1)])]))),128))])):(a(),n("div",vn,[(a(!0),n(G,null,be(t($)?4:1,o=>(a(),n("div",{key:"folder-list-skel-"+o,class:"flex items-center gap-3 px-3 py-2.5"},[...r[30]||(r[30]=[qe('<div class="skeleton size-10 shrink-0 rounded-lg" data-v-904830ca></div><div class="min-w-0 flex-1" data-v-904830ca><div class="skeleton h-3.5 w-36 sm:w-48" data-v-904830ca></div></div><div class="artifact-list-desktop-col w-24 shrink-0" data-v-904830ca><div class="skeleton h-4 w-14 rounded-full" data-v-904830ca></div></div><div class="artifact-list-desktop-col w-20 shrink-0" data-v-904830ca><div class="skeleton h-3 w-12" data-v-904830ca></div></div><div class="artifact-list-desktop-col-wide w-28 shrink-0" data-v-904830ca><div class="skeleton h-3 w-20" data-v-904830ca></div></div><div class="flex w-8 shrink-0 justify-end" data-v-904830ca><div class="skeleton size-6 rounded-md" data-v-904830ca></div></div>',6)])]))),128))]))])):p("",!0),e("section",null,[!t(te)&&!t(K)?(a(),n("div",mn,[...r[32]||(r[32]=[e("div",{class:"skeleton h-3.5 w-12"},null,-1),e("div",{class:"skeleton size-4 rounded-full"},null,-1)])])):p("",!0),t(j)==="list"?(a(),n("div",pn,[e("div",bn,[(a(),n(G,null,be(6,o=>e("div",{key:"file-list-skel-"+o,class:"flex items-center gap-3 px-3 py-2.5"},[...r[33]||(r[33]=[qe('<div class="skeleton size-10 shrink-0 rounded-lg" data-v-904830ca></div><div class="min-w-0 flex-1" data-v-904830ca><div class="skeleton h-3.5 w-36 sm:w-48" data-v-904830ca></div><div class="skeleton artifact-list-mobile-col mt-1.5 h-2.5 w-24" data-v-904830ca></div></div><div class="artifact-list-desktop-col w-24 shrink-0" data-v-904830ca><div class="skeleton h-4 w-14 rounded-full" data-v-904830ca></div></div><div class="artifact-list-desktop-col w-20 shrink-0" data-v-904830ca><div class="skeleton h-3 w-12" data-v-904830ca></div></div><div class="artifact-list-desktop-col-wide w-28 shrink-0" data-v-904830ca><div class="skeleton h-3 w-20" data-v-904830ca></div></div><div class="flex w-8 shrink-0 justify-end" data-v-904830ca><div class="skeleton size-6 rounded-md" data-v-904830ca></div></div>',6)])])),64))])])):(a(),n("div",gn,[(a(),n(G,null,be(8,o=>e("div",{key:"file-grid-skel-"+o,class:"flex flex-col gap-2"},[...r[34]||(r[34]=[qe('<div class="border-base-300 bg-base-200 rounded-box relative aspect-square w-full overflow-hidden border" data-v-904830ca><div class="skeleton h-full w-full" data-v-904830ca></div><div class="skeleton absolute top-2 left-2 h-4 w-12 rounded-md" data-v-904830ca></div></div><div class="flex flex-col items-center gap-1.5 px-1 py-0.5" data-v-904830ca><div class="skeleton h-3.5 w-3/4" data-v-904830ca></div><div class="skeleton h-2.5 w-1/2" data-v-904830ca></div></div>',2)])])),64))]))])],64))],64)):(a(),n(G,{key:1},[t(j)==="graph"?(a(),Le(pe,{key:0,items:t(b),folders:t(u),query:t(K),"back-target":t(h),"has-more":t(ve),"loading-more":t($e),"icon-for-kind":t(fe),onSelect:tt,onFolderSelect:t(g).selectFolder,onLoadMore:r[5]||(r[5]=o=>t(g).loadMore())},null,8,["items","folders","query","back-target","has-more","loading-more","icon-for-kind","onFolderSelect"])):p("",!0),t(j)!=="graph"&&t(w)?(a(),n("section",yn,[e("div",hn,[e("h3",kn,l(s.$t("artifacts.folders")),1),t(V)?(a(),n("span",xn,l(t(V)),1)):p("",!0)]),t(j)==="grid"?(a(),n("div",wn,[(a(!0),n(G,null,be(t(P),(o,Te)=>(a(),Le(ye,{key:o.key,folder:o.folder,icon:o.icon,"browse-only":!o.managed||i.mode!=="manage",variant:"grid","drop-up":Te>=t(P).length-4&&t(P).length>=8,onOpen:q=>t(g).selectFolder(o.target),onRename:q=>ut(o.folder),onDelete:q=>ft(o.folder)},null,8,["folder","icon","browse-only","drop-up","onOpen","onRename","onDelete"]))),128))])):(a(),n("ul",$
1n,[(a(!0),n(G,null,be(t(P),(o,Te)=>(a(),n("li",{key:o.key,class:"relative focus-within:z-30"},[re(ye,{folder:o.folder,icon:o.icon,"browse-only":!o.managed||i.mode!=="manage",variant:"list","drop-up":Te>=t(P).length-2&&t(P).length>=4,onOpen:q=>t(g).selectFolder(o.target),onRename:q=>ut(o.folder),onDelete:q=>ft(o.folder)},null,8,["folder","icon","browse-only","drop-up","onOpen","onRename","onDelete"])]))),128))])),t(C)||t(U)?(a(),n("div",Cn,[e("button",{class:"btn btn-ghost btn-xs gap-1",onClick:r[6]||(r[6]=o=>U.value=!t(U))},[e("span",An,l(t(U)?"expand_less":"expand_more"),1),T(" "+l(t(U)?s.$t("artifacts.showFewerFolders"):s.$t("artifacts.showAllFolders",{count:t(C)})),1)]),t(U)&&t(Y)?(a(),n("button",{key:0,class:"btn btn-ghost btn-xs",disabled:t(Q),onClick:r[7]||(r[7]=o=>t(g).loadMoreFolders())},[t(Q)?(a(),n("span",_n)):p("",!0),T(" "+l(s.$t("loadMore")),1)],8,Fn)):p("",!0)])):p("",!0)])):p("",!0),t(j)!=="graph"?(a(),n("section",Mn,[t(w)?(a(),n("div",In,[e("h3",Un,l(s.$t("artifacts.files")),1),t(N)?(a(),n("span",Tn,l(t(N)),1)):p("",!0)])):p("",!0),t(b).length===0?(a(),n("div",Sn,[e("span",zn,l(t(se)?"folder_shared":"folder_open"),1),t(K)?(a(),n("p",Pn,l(s.$t("artifacts.emptySearch")),1)):t(se)?(a(),n("p",Ln,l(s.$t("artifacts.emptyShared")),1)):t(w)||!t($)?(a(),n("p",Bn,l(s.$t("artifacts.emptyFolder")),1)):(a(),n("p",Dn,l(s.$t("artifacts.empty")),1))])):(a(),n(G,{key:2},[t(j)==="list"?(a(),n("div",Rn,[e("ul",En,[(a(!0),n(G,null,be(t(b),(o,Te)=>(a(),n("li",{key:o.id,class:"relative focus-within:z-30"},[e("div",{class:X(["hover:bg-base-200/60 group rounded-box relative flex cursor-pointer items-center gap-3 px-3 py-2.5 transition-colors",[i.mode==="attach"&&!et(o)?"cursor-default opacity-70":"",t(He)===o.id?"opacity-50":""]]),onClick:q=>tt(o)},[e("div",Vn,[S(o)?(a(),n("div",{key:0,class:"skeleton relative flex h-full w-full items-center justify-center rounded-none","aria-label":d(o.status)},[...r[35]||(r[35]=[e("span",{class:"loading loading-spinner loading-xs text-primary"},null,-1)])],8,jn)):F(o)&&o.status==="ready"?(a(),n("img",{key:1,src:F(o),alt:o.name||"file",class:"h-full w-full object-cover",loading:"lazy",draggable:"false"},null,8,On)):(a(),n("span",{key:2,class:X(["ms-icon text-2xl",o.status==="failed"?"text-error":"text-base-content/40"])},l(o.status==="failed"?"error":t(fe)(o.kind)),3))]),e("div",qn,[e("div",Kn,[e("span",Nn,l(o.name),1),Z(o)?(a(),n("span",{key:0,class:"badge badge-ghost badge-xs shrink-0 gap-1",title:s.$t("artifacts.sharedWithMe")},[r[36]||(r[36]=e("span",{class:"ms-icon text-xs"},"group",-1)),T(" "+l(s.$t("artifacts.sharedBadge")),1)],8,Hn)):p("",!0),o.status&&o.status!=="ready"?(a(),n("span",{key:1,class:X(["badge badge-xs shrink-0",A(o.status)])},l(d(o.status)),3)):p("",!0)]),e("div",Yn,[re(ce,{kind:o.kind,size:"xs"},null,8,["kind"]),E(o)&&o.slug?(a(),n("span",Gn,l(o.slug),1)):o.sizeInBytes?(a(),n("span",Xn,l(t(B).formatBytes(o.sizeInBytes)),1)):p("",!0),o.updatedAt||o.createdAt?(a(),n("span",Qn,"·")):p("",!0),o.updatedAt||o.createdAt?(a(),n("span",Jn,l(t(B).formatTime(o.updatedAt||o.createdAt)),1)):p("",!0)])]),e("div",Zn,[re(ce,{kind:o.kind,size:"xs"},null,8,["kind"])]),e("div",el,l(E(o)?"â":t(B).formatBytes(o.sizeInBytes)||"â"),1),e("div",tl,l(t(B).formatTime(o.updatedAt||o.createdAt)||"â"),1),e("div",{class:"stretched-link-above shrink-0",onClick:r[8]||(r[8]=we(()=>{},["stop"]))},[re(Ye,{item:o,folders:t(H),shared:Z(o),copied:t(We)===o.id,"drop-up":Te>=t(b).length-2&&t(b).length>=4,variant:"list",onView:q=>Ne(o),onDownload:q=>vt(o),onDownloadPdf:q=>mt(o),onCopyUrl:q=>pt(o),onDetails:q=>xt(o),onLeave:q=>Ze(o),onMigrate:q=>gt(o),onCopyWorkspace:q=>yt(o),onDelete:q=>bt(o),onMove:q=>kt(o.id,q)},null,8,["item","folders","shared","copied","drop-up","onView","onDownload","onDownloadPdf","onCopyUrl","onDetails","onLeave","onMigrate","onCopyWorkspace","onDelete","onMove"])])],10,Wn)]))),128))])])):(a(),n("div",sl,[(a(!0),n(G,null,be(t(b),(o,Te)=>(a(),n("div",{key:o.id,class:X(["group relative flex flex-col gap-2 focus-within:z-30",t(He)===o.id?"opacity-50":""])},[e("button",{type:"button",class:X(["border-base-300 bg-base-200 rounded-box relative block aspect-square w-full overflow-hidden border transition-colors",i.mode==="attach"&&!et(o)?"cursor-default opacity-70":"cursor-pointer"]),onClick:q=>tt(o)},[S(o)?(a(),n("div",{key:0,class:"skeleton relative flex h-full w-full items-center justify-center rounded-none","aria-label":d(o.status)},[...r[37]||(r[37]=[e("span",{class:"loading loading-spinner loading-sm text-primary"},null,-1)])],8,ol)):ne(o)&&o.status==="ready"?(a(),n("video",{key:1,src:F(o),class:"h-full w-full object-cover",muted:"",playsinline:"",preload:"metadata"},null,8,nl)):F(o)&&o.status==="ready"?(a(),n("img",{key:2,src:F(o),alt:o.name||"file",class:"h-full w-full object-cover",loading:"lazy",draggable:"false"},null,8,ll)):(a(),n("div",il,[e("span",{class:X(["ms-icon text-5xl",o.status==="failed"?"text-error":""])},l(o.status==="failed"?"error":t(fe)(o.kind)),3)])),re(ce,{kind:o.kind,size:"xs",class:"bg-base-100/90 absolute top-2 left-2 backdrop-blur-sm"},null,8,["kind"]),o.status&&o.status!=="ready"?(a(),n("span",{key:4,class:X(["badge badge-xs absolute bottom-2 left-2",A(o.status)])},l(d(o.status)),3)):p("",!0)],10,al),re(Ye,{item:o,folders:t(H),shared:Z(o),copied:t(We)===o.id,"drop-up":Te>=t(b).length-4&&t(b).length>=8,variant:"grid",onView:q=>Ne(o),onDownload:q=>vt(o),onDownloadPdf:q=>mt(o),onCopyUrl:q=>pt(o),onDetails:q=>xt(o),onLeave:q=>Ze(o),onMigrate:q=>gt(o),onCopyWorkspace:q=>yt(o),onDelete:q=>bt(o),onMove:q=>kt(o.id,q)},null,8,["item","folders","shared","copied","drop-up","onView","onDownload","onDownloadPdf","onCopyUrl","onDetails","onLeave","onMigrate","onCopyWorkspace","onDelete","onMove"]),e("div",rl,[e("span",dl,l(o.name),1),e("span",cl,[E(o)||t(B).formatBytes(o.sizeInBytes)?(a(),n(G,{key:0},[T(l(E(o)?o.slug:t(B).formatBytes(o.sizeInBytes))+" ",1),r[38]||(r[38]=e("span",{"aria-hidden":"true"}
1,"·",-1))],64)):p("",!0),T(" "+l(t(B).formatTime(o.updatedAt||o.createdAt)||"â"),1)]),Z(o)?(a(),n("span",{key:0,class:"badge badge-ghost badge-xs mt-1 gap-1",title:s.$t("artifacts.sharedWithMe")},[r[39]||(r[39]=e("span",{class:"ms-icon text-xs"},"group",-1)),T(l(s.$t("artifacts.sharedBadge")),1)],8,ul)):p("",!0)])],2))),128))])),t(ve)&&!t(K)?(a(),n("div",fl,[e("button",{class:"btn btn-ghost btn-sm",disabled:t($e),onClick:r[9]||(r[9]=o=>t(g).loadMore())},[t($e)?(a(),n("span",ml)):p("",!0),T(" "+l(s.$t("artifacts.loadMore")),1)],8,vl)])):p("",!0)],64))])):p("",!0)],64))],2)],2)]),(a(),Le(ts,{to:"body"},[t(je)&&i.mode==="attach"?(a(),Le(jt,{key:0,item:t(je),onClose:ht},null,8,["item"])):p("",!0),t(ke)?(a(),Le(Ot,{key:1,item:t(ke),folders:t(H),"current-user-id":t(z),onClose:Ee,onSave:Vt,onLeave:Ze,onView:r[10]||(r[10]=o=>{Ee(),Ne(o)})},null,8,["item","folders","current-user-id"])):p("",!0),re(At,{open:!!t(f),"resource-type":"artifact","resource-id":t(f)?.id||"","resource-name":t(f)?.name,"current-folder-id":t(f)?.folderId,onClose:r[11]||(r[11]=o=>f.value=null),onMigrated:Rt,onMovedToFolder:Wt},null,8,["open","resource-id","resource-name","current-folder-id"]),re(At,{open:!!t(k),"resource-type":"artifact",operation:"copy","resource-id":t(k)?.id||"","resource-name":t(k)?.name,"current-folder-id":t(k)?.folderId,onClose:r[12]||(r[12]=o=>k.value=null),onCopied:r[13]||(r[13]=o=>k.value=null),onCopiedToFolder:Et},null,8,["open","resource-id","resource-name","current-folder-id"]),t(O).open?(a(),n("dialog",{key:2,ref_key:"promptDialogRef",ref:ze,class:"modal modal-open",onCancel:r[16]||(r[16]=we(o=>t(O).open=!1,["prevent"])),onClick:r[17]||(r[17]=we(o=>t(O).open=!1,["self"]))},[e("div",pl,[e("h3",bl,l(t(O).title),1),Be(e("input",{ref_key:"promptInputRef",ref:Ie,"onUpdate:modelValue":r[14]||(r[14]=o=>t(O).value=o),type:"text",class:"input input-bordered w-full",placeholder:t(O).placeholder,onKeyup:Mt(ct,["enter"])},null,40,gl),[[Ke,t(O).value]]),e("div",yl,[e("button",{class:"btn btn-ghost btn-sm",onClick:r[15]||(r[15]=o=>t(O).open=!1)},l(s.$t("common.cancel")),1),e("button",{class:"btn btn-primary btn-sm",disabled:!t(O).value.trim()||t(O).busy,onClick:ct},[t(O).busy?(a(),n("span",kl)):p("",!0),T(" "+l(t(O).confirmLabel),1)],8,hl)])])],544)):p("",!0),t(ie).open?(a(),n("dialog",{key:3,ref_key:"confirmDialogRef",ref:Me,class:"modal modal-open",onCancel:r[19]||(r[19]=we(o=>t(ie).open=!1,["prevent"])),onClick:r[20]||(r[20]=we(o=>t(ie).open=!1,["self"]))}
1,[e("div",xl,[e("p",wl,l(t(ie).message),1),e("div",$l,[e("button",{class:"btn btn-ghost btn-sm",onClick:r[18]||(r[18]=o=>t(ie).open=!1)},l(s.$t("common.cancel")),1),e("button",{class:"btn btn-error btn-sm",disabled:t(ie).busy,onClick:zt},[t(ie).busy?(a(),n("span",Al)):p("",!0),T(" "+l(t(ie).confirmLabel),1)],8,Cl)])])],544)):p("",!0)]))])}}}),El=Object.assign(It(_l,[["__scopeId","data-v-904830ca"]]),{__name:"ArtifactBrowser"});export{Rl as _,El 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.