import{n as e}from"./rolldown-runtime-BG2f4sTM.js";import{$lt as t,Dvt as n,J5 as r,K5 as i,K_t as a,Mft as o,Mvt as s,O_t as c,Qlt as l,Ydt as u,Z_t as d,a6 as f,aB as p,bft as m,cV as h,cdt as g,dft as _,gft as v,i6 as y,iB as b,jft as x,ldt as S,npt as C,oV as w,tft as T,xft as E,ymt as D}from"./app-initial-BHB6SClA.js";function O(e){let t=r(e);if(t==null)return null;let n;try{n=new URL(e)}catch{return null}return M[t.appId]?.getRequest(n)??null}function k(e,t){return M[e.sourceAppId]?.getTitle(e,t)??null}function A(e,t){let n=D(t._meta);if(n.status!==`valid`)return null;for(let t of n.resources)if(O(t.url)?.cacheKey===e.cacheKey)return t.title?.trim()||null;return null}var j,M,N=e((()=>{i(),C(),f(),j=`id,name,mimeType,webViewLink`,M={"google-drive":{getRequest(e){let t=/^\/(document|spreadsheets)(?:\/u\/\d+)?\/d\/(?:e\/)?([^/]+)/u.exec(e.pathname),n=e.hostname.endsWith(`sheets.google.com`)&&t==null?/^\/(?:spreadsheets\/)?d\/(?:e\/)?([^/]+)/u.exec(e.pathname):null,r=t?.[1]??(n==null?null:`spreadsheets`),i=t?.[2]??n?.[1];return i==null?null:r===`document`?{arguments:{fields:j,fileId:i},cacheKey:`google-drive:document:${i}`,server:`codex_apps`,sourceAppId:`google-drive`,tool:`google_drive.get_file_metadata`}:r===`spreadsheets`?{arguments:{fields:j,fileId:i},cacheKey:`google-drive:spreadsheet:${i}`,server:`codex_apps`,sourceAppId:`google-drive`,tool:`google_drive.get_file_metadata`}:null},getTitle(e,t){return A(e,t)??y(t.structuredContent)?.title??null}}}})),P,F,I,L,R=e((()=>{c(),h(),p(),o(),l(),S(),N(),P=1440*60*1e3,F=t(`conversation-sources:connector-asset-title-cache`,{}),I=a(x,({get:e})=>e(F)!=null),L=d(x,({hostId:e,url:t},{get:n,scope:r})=>{let i=O(t),a=i==null?null:JSON.stringify([e,i.cacheKey]),o=n(I);return{enabled:i!=null&&o,queryFn:async()=>{let t=r.get(F);if(i==null||a==null||t==null)return null;let n=t[a];if(n!=null&&Date.now()-n.resolvedAt<P)return n.title;try{let t=w({isCodexAppsServer:i.server===`codex_apps`,toolResult:await b(r,e,i.server,i.tool,i.arguments)}),n=k(i,t);return n!=null&&r.set(F,{...r.get(F),[a]:{resolvedAt:Date.now(),title:n}}),n}catch{return null}},queryKey:[`connector-asset-title`,a??JSON.stringify([e,t])],retry:!1,staleTime:g.FIVE_MINUTES}},{key:({hostId:e,url:t})=>JSON.stringify([e,O(t)?.cacheKey??t])})}));function z(e){let t=(0,B.c)(7),{className:n,children:r,isVisible:i}=e,a=!!T(),o;t[0]!==r||t[1]!==n||t[2]!==i||t[3]!==a?(o=i?(0,V.jsx)(_.div,{className:m(`overflow-hidden`,n),animate:{height:`auto`,opacity:1,transitionEnd:{overflow:`visible`}},exit:a?{opacity:0,overflow:`hidden`,pointerEvents:`none`}:{height:0,opacity:0,overflow:`hidden`,pointerEvents:`none`},transition:H,children:r}):null,t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o):o=t[4];let s;return t[5]===o?s=t[6]:(s=(0,V.jsx)(v,{initial:!1,children:o}),t[5]=o,t[6]=s),s}var B,V,H,U=e((()=>{B=s(),E(),u(),V=n(),H={duration:.22,ease:[.23,1,.32,1]}}));function W({label:e,title:t=null,url:n}){try{let r=new URL(n);return r.protocol!==`http:`&&r.protocol!==`https:`||r.username!==``||r.password!==``?null:{label:e?.trim()||`${r.host.replace(/^www\./u,``)}${r.pathname}`,title:t?.trim()||null,url:r.href}}catch{return null}}function G(e){let t=new Set;return e.filter(e=>t.has(e.url)?!1:(t.add(e.url),!0))}var K=e((()=>{}));export{U as a,z as i,G as n,L as o,K as r,R as s,W as t};
//# sourceMappingURL=turn-sources-model-knQ2PXxB.js.map