PageSourceSearch

https://depot.dev/assets/useChat-DIxqyIjF.js

js depot.dev collected 2026-10-02 05:27:01 UTC 8,396 bytes, 11 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7ca48839-d7b9-5530-b1f2-5b914275e050")}catch(e){}}();
3!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0f9f2-bd26-7eb1-8765-68339404774e")}catch(e){}}();(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`6671e471206ed21e40f078c1c93b0fa72dcc83af`}}catch{}})();import{a as e}from"./chunk-pUsIRAOz.js";import{t}from"./react-BJShOJtD.js";import{t as n}from"./jsx-runtime-BYB64Sxt.js";import{t as r}from"./compiler-runtime-B2kict0c.js";import{t as i}from"./Icon-Drt9cYNH.js";var a={list_pages:{inProgress:`Exploring documentation...`,done:`Explored documentation`},grep:{inProgress:`Grepping`,done:`Grepped`},read_page:{inProgress:`Reading`,done:`Read`},readFile:{inProgress:`Reading`,done:`Read`},writeFile:{inProgress:`Writing`,done:`Write`},bash:{inProgress:`Bash`,done:`Bash`},fetch_build_details:{inProgress:`Fetching build details...`,done:`Fetched build details`},fetch_build_step_logs:{inProgress:`Fetching build step logs...`,done:`Fetched build step logs`},fetch_project_settings:{inProgress:`Fetching project settings...`,done:`Fetched project settings`},fetch_org_settings:{inProgress:`Fetching org settings...`,done:`Fetched org settings`},fetch_usage_summary:{inProgress:`Fetching usage summary...`,done:`Fetched usage summary`},fetch_job_details:{inProgress:`Fetching job details...`,done:`Fetched job details`},fetch_job_step_logs:{inProgress:`Fetching job step logs...`,done:`Fetched job step logs`},fetch_ci_workflow_details:{inProgress:`Fetching CI workflow details...`,done:`Fetched CI workflow details`},fetch_ci_job_details:{inProgress:`Fetching CI job details...`,done:`Fetched CI job details`},fetch_ci_job_step_logs:{inProgress:`Fetching CI job logs...`,done:`Fetched CI job logs`},fetch_actions_analytics:{inProgress:`Fetching actions analytics...`,done:`Fetched actions analytics`},list_projects:{inProgress:`Listing projects...`,done:`Listed projects`},fetch_registry_info:{inProgress:`Fetching registry info...`,done:`Fetched registry info`},fetch_cache_summary:{inProgress:`Fetching cache summary...`,done:`Fetched cache summary`},create_support_ticket:{inProgress:`Submitting support ticket...`,done:`Submitted support ticket`},get_pricing:{inProgress:`Fetching pricing...`,done:`Fetched pricing`},check_system_status:{inProgress:`Checking system status...`,done:`Checked system status`}};function o(e){return e.replace(/^tool-/,``)}function s(e,t){if(!t||typeof t!=`object`)return null;let n=t;switch(e){case`grep`:return typeof n.pattern==`string`?n.pattern:null;case`read_page`:return typeof n.url==`string`?n.url:null;case`fetch_build_details`:return typeof n.buildID==`string`?n.buildID:null;case`fetch_build_step_logs`:return typeof n.digest==`string`?n.digest:null;case`fetch_project_settings`:return typeof n.projectID==`string`?n.projectID:null;case`fetch_org_settings`:case`fetch_usage_summary`:case`list_projects`:case`fetch_registry_info`:case`fetch_cache_summary`:return typeof n.orgID==`string`?n.orgID:null;case`fetch_job_details`:case`fetch_ci_job_details`:case`fetch_ci_job_step_logs`:return typeof n.jobID==`string`?n.jobID:null;case`fetch_ci_workflow_details`:return typeof n.workflowID==`string`?n.workflowID:null;case`create_support_ticket`:return typeof n.kind==`string`?n.kind:null;case`bash`:return typeof n.command==`string`?n.command:null;case`readFile`:case`writeFile`:return typeof n.path==`string`?n.path:null;default:return null}}var c=r(),l=e(t(),1),u=n();function d(e){let t=(0,c.c)(21),{messages:n,toolLabels:r}=e,[a,o]=(0,l.useState)(`idle`),s=(0,l.useRef)(null),d,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>()=>{s.current&&clearTimeout(s.current)},m=[],t[0]=d,t[1]=m):(d=t[0],m=t[1]),(0,l.useEffect)(d,m);let h;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>{if(e.role===`user`){if(e.metadata?.hidden)return[];let t=e.parts.filter(p).map(f).join(``);return t?[`User:\n\n${t}`]:[]}if(e.role!==`assistant`)return[];let t=e.parts.flatMap(e=>{if(e.type===`text`&&e.text)return[e.text];if(e.type.startsWith(`tool-`)){let t=e.type.replace(/^tool-/,``);return[`[${r[t]?.done??t}]`]}return[]});return t.length?[`Assistant:\n\n${t.join(`
4
5`)}`]:[]},t[5]=r,t[6]=e),h=n.flatMap(e).join(`
6
7`),t[2]=n,t[3]=r,t[4]=h}else h=t[4];let g=h,_;t[7]===g?_=t[8]:(_=async()=>
7{if(g){s.current&&clearTimeout(s.current);try{await navigator.clipboard.writeText(g),o(`copied`)}catch{o(`error`)}s.current=setTimeout(()=>o(`idle`),2e3)}},t[7]=g,t[8]=_);let v=_,y=a===`copied`?`Conversation copied`:a===`error`?`Could not copy conversation. Try again.`:`Copy conversation`,b=!g,x=a===`copied`?`check`:`copy`,S;t[9]===x?S=t[10]:(S=(0,u.jsx)(i,{name:x,className:`size-4.5`}),t[9]=x,t[10]=S);let C;t[11]!==v||t[12]!==y||t[13]!==b||t[14]!==S?(C=(0,u.jsx)(`button`,{type:`button`,onClick:v,disabled:b,className:`cursor-pointer rounded-sm p-0 text-depot-neutral-50 transition-colors hover:text-depot-theme-primary disabled:cursor-not-allowed disabled:opacity-40`,"aria-label":y,title:y,children:S}),t[11]=v,t[12]=y,t[13]=b,t[14]=S,t[15]=C):C=t[15];let w=a===`idle`?``:y,T;t[16]===w?T=t[17]:(T=(0,u.jsx)(`span`,{role:`status`,className:`sr-only`,children:w}),t[16]=w,t[17]=T);let E;return t[18]!==T||t[19]!==C?(E=(0,u.jsxs)(u.Fragment,{children:[C,T]}),t[18]=T,t[19]=C,t[20]=E):E=t[20],E}function f(e){return e.text}function p(e){return e.type===`text`}function m(e){let t=(0,l.useRef)(e);t.current=e;let n=(0,l.useRef)([]),r=(0,l.useRef)(null),i=(0,l.useRef)(Promise.resolve()),a=(0,l.useRef)(!0),[o,s]=(0,l.useState)([]),[c,u]=(0,l.useState)(`ready`),[d,f]=(0,l.useState)();(0,l.useEffect)(()=>(a.current=!0,()=>{a.current=!1,r.current?.abort()}),[]);let p=(0,l.useCallback)(async(e,i)=>{if(!a.current)return;let o=new AbortController;r.current=o;let c=[...n.current,{id:crypto.randomUUID(),role:`user`,parts:[{type:`text`,text:e.text}],metadata:e.metadata}];n.current=c,s(c),f(void 0),u(`submitted`);let l,d=!1;try{let e=t.current,r=await e.fetch(e.api,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...i?.body,messages:c}),signal:o.signal});if(!r.ok||!r.body)throw Error(`Chat request failed: ${r.status}`);let a=r.body.pipeThrough(new TextDecoderStream).getReader(),f=e=>{if(e.type===`error`)throw Error(e.errorText);if(e.type===`finish`){d=!0;return}if(e.type===`start`)l={id:e.messageId,role:`assistant`,parts:[]};else if(l){if(e.type===`step-start`&&l.parts.push({type:`step-start`}),e.type===`text-start`&&l.parts.push({type:`text`,id:e.id,text:``}),e.type===`text-delta`){let t=l.parts.find(t=>t.type===`text`&&t.id===e.id);t?.type===`text`&&(t.text+=e.text)}if(e.type===`tool-start`&&l.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:`input-available`,input:e.input}),e.type===`tool-end`){let t=l.parts.find(t=>`toolCallId`in t&&t.toolCallId===e.toolCallId);t&&`toolCallId`in t&&(t.state=e.isError?`output-error`:`output-available`,t.output=e.output,e.isError&&(t.errorText=e.output))}}l?.parts.some(e=>e.type===`text`?e.text.length>0:e.type!==`step-start`)&&(u(`streaming`),n.current=[...c,{...l,parts:l.parts.map(e=>({...e}))}],s(n.current))},p=``;try{for(;;){let{done:e,value:t}=await a.read();if(e)break;p+=t;let n;for(;(n=p.indexOf(`
8`))!==-1;){let e=p.slice(0,n);p=p.slice(n+1),e&&f(JSON.parse(e))}}if(!d)throw Error(`Chat response ended before completion`)}finally{await a.cancel().catch(()=>{}),a.releaseLock()}return u(`ready`),l}catch(e){o.signal.aborted||(f(e instanceof Error?e:Error(String(e))),u(`error`))}finally{r.current=null}},[]);return{messages:o,sendMessage:(0,l.useCallback)((e,n)=>{let r={...t.current.body?.(),...n?.body},a=i.current.then(()=>p(e,{body:r}));return i.current=a.catch(()=>{}),a},[p]),status:c,error:d}}export{o as a,s as i,d as n,a as r,m as t};
9//# sourceMappingURL=useChat-DIxqyIjF.js.map
10//# chunkId=01a0f9f2-bd26-7eb1-8765-68339404774e
11//# debugId=7ca48839-d7b9-5530-b1f2-5b914275e050

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.