@yuriai/web 0.2.0-beta.2 → 0.2.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/assets/{AssistantView-8ju42ZTW.js → AssistantView-AVEdhX2E.js} +3 -3
  2. package/dist/assets/{DiagramView-rw0YYQMb.js → DiagramView-kaRtAbB8.js} +1 -1
  3. package/dist/assets/{GuiPluginSurface-CZyG8VSt.js → GuiPluginSurface-Clv5w8qE.js} +1 -1
  4. package/dist/assets/{MarkdownRenderer-CtlVSzEr.js → MarkdownRenderer-BsZicwlM.js} +2 -2
  5. package/dist/assets/MarkdownRendererImpl-BUhSSjjo.js +10 -0
  6. package/dist/assets/{MarkstreamRendererImpl-Bh0SBb3A.js → MarkstreamRendererImpl-Drf8lHZM.js} +1 -1
  7. package/dist/assets/{MobileDetailNavigation-BmVdW83D.js → MobileDetailNavigation-CtYXRw3B.js} +1 -1
  8. package/dist/assets/{MobileShareBridge-DsEPHal0.js → MobileShareBridge-sU74EJ95.js} +1 -1
  9. package/dist/assets/{MobileTabPageHeader-C3XsN5mD.js → MobileTabPageHeader-BWhQHf6s.js} +1 -1
  10. package/dist/assets/{MultiRunWindow-E69FtA8j.js → MultiRunWindow-9DdpcXYS.js} +1 -1
  11. package/dist/assets/{SettingsView-cAxZUqrO.js → SettingsView-Dm-Zxoje.js} +1 -1
  12. package/dist/assets/{SettingsWindow-lAKvVEKw.js → SettingsWindow-Cgnhlx6v.js} +1 -1
  13. package/dist/assets/{TerminalView-Dk4wVZaD.js → TerminalView-DpkoeLoM.js} +1 -1
  14. package/dist/assets/{ToolOutputDialog-USJ-ZgXn.js → ToolOutputDialog-Cy30GA5T.js} +1 -1
  15. package/dist/assets/{appThemeRegistry-LtxIx7El.js → appThemeRegistry-q9ZHhYPY.js} +1 -1
  16. package/dist/assets/{capgoAdapter-DCIeVZw_.js → capgoAdapter-ClmWgQsn.js} +1 -1
  17. package/dist/assets/{fileMentionTouchSelection-CRlBHcv1.js → fileMentionTouchSelection-C5fQjVCV.js} +1 -1
  18. package/dist/assets/{fileReferenceActions-ZQ5--HF8.js → fileReferenceActions-EkHzD38t.js} +1 -1
  19. package/dist/assets/{gitApi-BKjA7Bpe.js → gitApi-DL9TCObI.js} +1 -1
  20. package/dist/assets/{host-u2MH0QSP.js → host-DeoWZHPC.js} +1 -1
  21. package/dist/assets/{insertionBoundaries-D_wrLY-Q.js → insertionBoundaries-DrjyD1xA.js} +1 -1
  22. package/dist/assets/{main-C4Zc7_s8.js → main-1iPWY6JE.js} +2 -2
  23. package/dist/assets/{main-CkA5yk63.js → main-ClH8U0K_.js} +4 -4
  24. package/dist/assets/{mcpQueries-s9QcLjGw.js → mcpQueries-Am1xehao.js} +1 -1
  25. package/dist/assets/{miniChat-C_wwveSN.js → miniChat-DV5fIjdE.js} +2 -2
  26. package/dist/assets/{mobile-TuU7P2PX.js → mobile-C7hRNLd2.js} +2 -2
  27. package/dist/assets/{mobileBackNavigation-C6OcBTbS.js → mobileBackNavigation-BjN2y4on.js} +1 -1
  28. package/dist/assets/{multirun-cZcReWkT.js → multirun-Dj8jiZnI.js} +1 -1
  29. package/dist/assets/{native-config-DnQvXgu6.js → native-config-6ZcbOTlU.js} +1 -1
  30. package/dist/assets/{projectMeta-DXlpoXd3.js → projectMeta-Bh_8p-5O.js} +1 -1
  31. package/dist/assets/{readiness-m2mD0fyj.js → readiness-6dRSpsKU.js} +1 -1
  32. package/dist/assets/{renderElectronMiniChatApp-COXM_nk2.js → renderElectronMiniChatApp-fvAvjcX3.js} +2 -2
  33. package/dist/assets/{renderMobileApp-CbU3BLr6.js → renderMobileApp-J5PuS_NT.js} +4 -4
  34. package/dist/assets/{runtimeConfig-jHTvOptz.js → runtimeConfig-BndFf_Fb.js} +1 -1
  35. package/dist/assets/runtimeEndpointReset-DlxONsUh.js +149 -0
  36. package/dist/assets/{sessionChangeSummary-C7Y5e238.js → sessionChangeSummary-CUnP0Mge.js} +1 -1
  37. package/dist/assets/{sessionLookup-BscEQpqH.js → sessionLookup-EBl9PXiP.js} +1 -1
  38. package/dist/assets/{speechSettingsQueries-DVKcuOEf.js → speechSettingsQueries-CgSGK19J.js} +1 -1
  39. package/dist/assets/{types-eQY4TOgr.js → types-aeu41u0o.js} +1 -1
  40. package/dist/assets/{useAppFontEffects-DOp_gxxk.js → useAppFontEffects-By2DRO_9.js} +5 -5
  41. package/dist/assets/{useDesktopWindowControlsLayout-CPqgnywT.js → useDesktopWindowControlsLayout-B9xDW29G.js} +1 -1
  42. package/dist/assets/{useEffectiveDirectory-9Efzl9IZ.js → useEffectiveDirectory-C5E5H7K7.js} +1 -1
  43. package/dist/assets/{useMobileNavigationStore-Cwk7wARY.js → useMobileNavigationStore-BDW0aRpC.js} +3 -3
  44. package/dist/assets/{useWorkerHighlightedLines-ClwAu-Q3.js → useWorkerHighlightedLines-5IurZLOp.js} +1 -1
  45. package/dist/index.html +5 -5
  46. package/dist/mini-chat.html +5 -5
  47. package/dist/mobile.html +5 -5
  48. package/package.json +1 -1
  49. package/server/lib/content-search/DOCUMENTATION.md +17 -11
  50. package/server/lib/content-search/index.js +1 -0
  51. package/server/lib/content-search/runtime.js +50 -9
  52. package/server/lib/content-search/runtime.test.js +72 -1
  53. package/server/lib/content-search/service.js +12 -1
  54. package/dist/assets/MarkdownRendererImpl-wN873oJ5.js +0 -10
  55. package/dist/assets/runtimeEndpointReset-BOuzWhtp.js +0 -149
@@ -1 +1 @@
1
- import{A as e,C as t,E as n,F as r,I as i,M as a,P as o,S as s,T as c,_ as l,a as u,b as d,g as f,h as p,i as m,k as h,n as g,o as _,r as v,t as y,x as b}from"./vendor-opencode-client-BcpAhe9I.js";import{i as x}from"./vendor-tanstack-query-core-BWz0ose6.js";import{c as S,l as ee,o as te}from"./path-utils-QNmCUIdP.js";import{n as ne}from"./pathNormalization-ewtPqJWn.js";import{i as re,o as ie}from"./fileReferenceParser-D6pFtXag.js";import{n as ae,t as oe}from"./vendor-solid-js-B2FO7pdm.js";import{a as se,c as ce,d as C,f as w,h as le,i as T,l as E,m as D,n as ue,o as O,p as de,r as fe,s as pe,t as k,u as A}from"./vendor-opencode-plugin-BglYYlJt.js";import{ft as j,pt as M,wt as N,y as P}from"./vendor-effect-DXlObQuU.js";var F={"@opencode/plugin/gui":O,"@opencode/plugin/gui/main":O,"@opencode/plugin/gui/file":se,"@opencode/plugin/gui/review":T,"@opencode/plugin/gui/browser":fe,"@opencode/plugin/rpc":k,"@opencode/schema/rpc":ue,"@opencode/client":i,"@opencode/client/effect":g,"@opencode/client/solid":y,effect:P,"solid-js":a,"solid-js/web":ae,"solid-js/store":u},I=new Set(`assert assert/strict async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns dns/promises domain events fs fs/promises http http2 https inspector inspector/promises module net os path path/posix path/win32 perf_hooks process punycode querystring readline readline/promises repl stream stream/consumers stream/promises stream/web string_decoder sys timers timers/promises tls trace_events tty url util util/types v8 vm wasi worker_threads zlib`.split(` `));function L(){let e=new Proxy(function(){},{get:(t,n)=>n===`then`?void 0:n===Symbol.hasInstance?()=>!1:n===Symbol.toPrimitive||n===`toString`?()=>`[main-only module]`:e,apply:()=>e,construct:()=>e,set:()=>!0});return e}function R(e){if(e.length>16777216)throw Error(`GUI bundle exceeds 16 MiB`);let t={exports:{}};Function(`require`,`module`,`exports`,e)(e=>{if(Object.hasOwn(F,e))return F[e];if(e===`electron`||e.startsWith(`node:`)||I.has(e))return L();throw Error(`Unsupported GUI shared module: ${e}`)},t,t.exports);let n=t.exports,r=n&&typeof n==`object`&&`default`in n?n.default:n;if(!r||typeof r!=`object`)throw Error(`GUI bundle must default-export Plugin.define`);if(!(`setup`in r)||typeof r.setup!=`function`)throw Error(`This host requires a window setup; main-only plugins are unsupported`);if(`os`in r&&r.os!==void 0)throw Error(`OS-restricted plugins require the native GUI host`);if(`main`in r&&r.main!==void 0&&typeof r.main!=`function`)throw Error(`Invalid GUI main entry`);if(`stores`in r&&r.stores!==void 0){if(!r.stores||typeof r.stores!=`object`||Array.isArray(r.stores))throw Error(`Invalid GUI stores`);for(let e of Object.values(r.stores))if(!e||typeof e!=`object`||!(`schema`in e)||!N(e.schema)||!(`scope`in e)||![`global`,`session`].includes(String(e.scope))||!(`initial`in e))throw Error(`Invalid GUI store declaration`)}if(`i18n`in r&&r.i18n!==void 0){if(!r.i18n||typeof r.i18n!=`object`||Array.isArray(r.i18n))throw Error(`Invalid GUI locale catalog`);for(let e of Object.values(r.i18n))if(!e||typeof e!=`object`||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`GUI locales must be inline string dictionaries`)}return r}function z(e){let t=e;if(/^file:/i.test(t)){let e=new URL(t);t=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(t)&&(t=t.slice(1))}let n=ne(t)??``;return n===`.`?``:n}var B=e=>/^(?:\/|[a-z]:\/)/i.test(e),V=()=>{throw Error(`Unsupported GUI file API: tree`)},H=class extends Error{},U=e=>new TextEncoder().encode(e).byteLength,me=class{files;query;transport;root;api;ended=!1;states=new Map;inflight=new Map;watches=new Map;apiLeases=new Map;registeredOwners=new WeakSet;endedOwners=new WeakSet;leaseCount=0;rerun=new Set;selections=new Map;scrolls=new Map;subscriptions=new Map;constructor(e,t,r,i){this.files=e,this.query=t,this.transport=r,this.root=i,this.root=z(i),this.api={root:this.root,ready:()=>!this.ended,resolve:e=>this.resolve(e),absolute:B,get:e=>{let t=this.track(e,`file`);return this.states.get(t)},missing:e=>{let t=this.track(e,`missing`);return this.states.get(t)?.notFound===!0},sync:(e,t)=>{let r=n();return this.ended||r&&this.endedOwners.has(r)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(n(),this.resolve(e)),exists:async e=>{try{if(this.files.statFile)return(await this.query.fetchQuery(this.statOptions(e))).isFile;let t=this.full(e);return(await this.files.listDirectory(t.slice(0,t.lastIndexOf(`/`)))).entries.some(e=>!e.isDirectory&&z(e.path)===t)}catch{return!1}},search:async(e,t)=>{if(t?.kind===`any`)throw Error(`Unsupported GUI file search: directories`);t?.signal?.throwIfAborted();let n=await this.query.fetchQuery({queryKey:[`gui-plugin-files`,r,this.root,`search`,e,t?.limit],gcTime:3e4,queryFn:async({signal:n})=>(n.throwIfAborted(),this.files.search({directory:this.root,query:e,maxResults:t?.limit??100}))});if(t?.signal?.throwIfAborted(),this.ended)throw new DOMException(`GUI file model was disposed`,`AbortError`);return n.map(e=>this.resolve(e.path))},selection:{get:e=>this.selections.get(this.track(e,`selection`)),set:(e,t)=>{let n=this.resolve(e),r=this.selections.get(n);r===t||r&&t&&r.start===t.start&&r.end===t.end&&r.side===t.side&&r.endSide===t.endSide||(this.selections.set(n,t),this.trim(this.selections,`selection`),this.changed(n,`selection`))}},scroll:{get:e=>this.scrolls.get(this.track(e,`scroll`))??{},set:(e,t)=>{let n=this.resolve(e),r=this.scrolls.get(n),i={...r,...t};(r?.top!==i.top||r?.left!==i.left)&&(this.scrolls.set(n,i),this.trim(this.scrolls,`scroll`),this.changed(n,`scroll`))}},tree:{list:V,state:V,sync:V,expand:V,collapse:V}}}resolve(e){let t=z(e);if(!B(t))return t;if(t===this.root)return``;let n=this.root.endsWith(`/`)?this.root:`${this.root}/`;return t.startsWith(n)?t.slice(n.length):t}full(e){let t=this.resolve(e);return B(t)?t:z(`${this.root}/${t}`)}input(e){return{scopeDirectory:this.root,path:this.full(e),options:{directory:this.root}}}statOptions(e){return{...ee(this.files,this.input(e),this.transport),gcTime:3e4}}track(n,r){let i=this.resolve(n),a=c();if(!a||this.ended)return i;let o=`${r}:${i}`,s=this.subscriptions.get(o);s||(s={revision:t(0),listeners:new Set},this.subscriptions.set(o,s));let l=s;return l.listeners.has(a)||(l.listeners.add(a),e(a,()=>h(()=>{l.listeners.delete(a),!l.listeners.size&&this.subscriptions.get(o)===l&&this.subscriptions.delete(o)}))),l.revision[0](),i}changed(e,t){this.ended||this.subscriptions.get(`${t}:${e}`)?.revision[1](e=>e+1)}trim(e,t){for(;e.size>64;){let n=e.keys().next().value;e.delete(n),this.changed(n,t)}}setState(e,t){let n=this.states.get(e);n?.content?.content===t.content?.content&&n?.content?.type===t.content?.type&&(t.content=n?.content),!(n&&n.loaded===t.loaded&&n.loading===t.loading&&n.error===t.error&&n.notFound===t.notFound&&n.content===t.content)&&(this.states.set(e,t),p(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=n();if(this.ended||t&&this.endedOwners.has(t)||!this.files.statFile)return;let r=this.resolve(e),i=this.apiLeases.get(t);if(i?.has(r))return;if(this.leaseCount>=256)throw Error(`GUI file consumer limit exceeded`);let a=this.watch(r);i||(i=new Map,this.apiLeases.set(t,i)),i.set(r,a),this.leaseCount++,t&&!this.registeredOwners.has(t)&&(this.registeredOwners.add(t),h(()=>{`fn`in t||this.endedOwners.add(t),this.registeredOwners.delete(t);for(let e of[...this.apiLeases.get(t)?.keys()??[]])this.releaseApiLease(t,e)}))}releaseApiLease(e,t){let n=this.apiLeases.get(e),r=n?.get(t);r&&(n.delete(t),this.leaseCount--,n.size||this.apiLeases.delete(e),r())}reserve(e){if(!this.states.has(e)){if(this.states.size>=64){let e=[...this.states.keys()].find(e=>!this.watches.has(e)&&!this.inflight.has(e));if(!e)throw Error(`GUI file cache limit exceeded`);let t=this.states.get(e)?.notFound===!0;this.states.delete(e),p(()=>{this.changed(e,`file`),t&&this.changed(e,`missing`)})}this.states.set(e,{path:e,name:e.split(`/`).at(-1)??e})}}async sync(e,t=!1){if(this.ended)return;let n=this.resolve(e);if(this.inflight.has(n))return t&&this.rerun.add(n),this.inflight.get(n);if(!t&&this.states.get(n)?.loaded&&!this.states.get(n)?.error)return;this.reserve(n);let r=this.states.get(n);this.setState(n,{...r,path:n,name:n.split(`/`).at(-1)??n,loading:!r?.loaded&&!this.watches.get(n)?.failed});let i=(async()=>{try{do{this.rerun.delete(n);let e=this.watches.get(n),r=e?.epoch;try{let i=S(this.files,this.input(n),this.transport),a=await this.query.fetchQuery({...i,gcTime:3e4,staleTime:t?0:3e4,queryFn:async()=>{if(!this.files.readFile)throw Error(`File content reads are unavailable in this runtime`);let e=await this.files.readFile(this.full(n),{directory:this.root});if(e.exists===!1)throw new H(`File does not exist`);let t=e.content;if(U(t)>131072)throw Error(`GUI file preview exceeds 128 KiB`);return t}});if(this.ended)return;if(U(a)>131072)throw Error(`GUI file preview exceeds 128 KiB`);(!e||e.epoch===r&&!e.failed)&&this.setState(n,{path:n,name:n.split(`/`).at(-1)??n,loaded:!0,loading:!1,content:{type:`text`,content:a}})}catch(t){if(this.ended)return;if((!e||e.epoch===r&&!e.failed)&&this.setState(n,{...this.states.get(n),loading:!1,...t instanceof H?{notFound:!0}:{},error:String(t)}),!this.rerun.has(n))throw t}t=!0}while(!this.ended&&this.rerun.has(n))}finally{this.inflight.delete(n),this.rerun.delete(n)}})();return this.inflight.set(n,i),i}watch(e){if(this.ended||!this.files.statFile)return()=>{};let t=this.resolve(e),n=this.watches.get(t);if(!n){if(this.watches.size>=64)throw Error(`GUI file watch limit exceeded`);this.reserve(t),n={count:0,epoch:0,failed:!1,stop:()=>{}};let e=n;this.watches.set(t,e);let r,i=new x(this.query,{...this.statOptions(t),refetchInterval:2e3,refetchIntervalInBackground:!1}),a=i.subscribe(n=>{if(this.ended||this.watches.get(t)!==e||n.isFetching)return;if(n.isError||n.isSuccess&&!n.data.isFile){e.failed=!0,e.epoch++,this.setState(t,{...this.states.get(t),loading:!1,notFound:n.isSuccess?!0:this.states.get(t)?.notFound,error:n.isError?String(n.error):`File does not exist`});return}if(!n.data||!n.isSuccess)return;let i=`${n.data.size}:${n.data.mtimeMs??``}`,a=e.failed||r!==void 0&&i!==r;e.failed=!1,r=i,a&&(e.epoch++,this.sync(t,!0).catch(()=>{}))});e.stop=()=>{a(),i.destroy()}}n.count++;let r=!0;return()=>{r&&(r=!1,--n.count===0&&this.watches.get(t)===n&&this.stopWatch(t))}}stopWatch(e){this.watches.get(e)?.stop(),this.watches.delete(e)}dispose(){this.ended=!0;for(let e of this.watches.values())e.stop();this.watches.clear(),this.apiLeases.clear(),this.leaseCount=0,this.rerun.clear(),this.states.clear(),this.inflight.clear(),this.selections.clear(),this.scrolls.clear(),this.subscriptions.clear()}},W=256,G=2097152,K=e=>structuredClone(_(e)),he=class{backend;transport;memory=new Map;resets=new Map;constructor(e,t){this.backend=e,this.transport=t}forPlugin(e,n){let r=(t,n=`global`)=>{if(typeof n==`object`&&`session`in n&&!n.session.location)throw Error(`Unsupported GUI storage: session location is unknown`);let r=n===`global`?n:`session`in n?[n.session.server.id,n.session.id,n.session.location]:[n.server,n.directory];return`yuri.gui-plugin.${JSON.stringify([this.transport,e,r,t])}`},i=e=>{if(n.aborted)throw Error(`GUI plugin has been disposed`);if(e!==void 0)throw Error(`Unsupported GUI storage migration: from`)},a=new Map;return{store:(e,o)=>{i(o.from);let s=r(e,o.scope),c=a.get(s);if(c)return c;if(a.size>=W)throw Error(`GUI plugin store limit exceeded`);let l=j(o.schema),u=M(o.schema),d=l(u(K(o.initial)));if(JSON.stringify(u(d)).length>G)throw Error(`GUI plugin store exceeds 2 MiB`);let f=d,p=this.backend.getItem(s);if(p!==null&&p.length<=G)try{f=l(JSON.parse(p))}catch{f=d}let[m,h]=t(f),g=e=>{i();let t=JSON.stringify(u(K(e)));if(t.length>G)throw Error(`GUI plugin store exceeds 2 MiB`);let n=l(JSON.parse(t));this.backend.setItem(s,t),h(()=>n)},_={get value(){return m()},ready:()=>!0,set:g,update:e=>{let t=K(m());if(e(t)!==void 0)throw Error(`Store update must not return a replacement`);g(t)}},v=()=>h(()=>K(d)),y=this.resets.get(s)??new Set;return y.add(v),this.resets.set(s,y),n.addEventListener(`abort`,()=>{y.delete(v),y.size||this.resets.delete(s),a.clear()},{once:!0}),a.set(s,_),_},memory:(e,t)=>{i();let n=r(e),a=this.memory.get(n);if(a)return[a[0],e=>{i(),a[1](e)}];if(this.memory.size>=W)throw Error(`GUI plugin memory store limit exceeded`);if(JSON.stringify(t.initial).length>G)throw Error(`GUI plugin memory exceeds 2 MiB`);let[o,s]=v(K(t.initial)),c=[o,e=>{i();let t=K(_(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>G)throw Error(`GUI plugin memory exceeds 2 MiB`);s(m(t))}];return this.memory.set(n,[o,e=>{let t=K(_(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>G)throw Error(`GUI plugin memory exceeds 2 MiB`);s(m(t))}]),c},remove:(e,t)=>{i(t?.from);let n=r(e,t?.scope);this.backend.removeItem(n);for(let e of this.resets.get(n)??[])e()}}}dispose(){this.memory.clear(),this.resets.clear()}},ge=`yuri.file-icon`,q=`http://www.w3.org/2000/svg`,_e=new Set([`svg`,`g`,`path`,`rect`,`circle`,`ellipse`,`line`,`polyline`,`polygon`,`defs`,`linearGradient`,`radialGradient`,`stop`,`clipPath`,`mask`,`use`,`title`,`desc`]),J=e=>e.trim().replace(/^\./,``).toLowerCase();function Y(e,t){if(typeof e!=`string`)throw Error(`GUI file icon requires SVG text`);let n=t.get(e);if(n)return n;if(e.length>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);let r=new TextEncoder().encode(e).byteLength;if(r>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);if(!/^\s*<svg[\s>]/.test(e)||/<!|<\?/.test(e))throw Error(`Invalid GUI file icon SVG`);let i=new DOMParser().parseFromString(e,`image/svg+xml`),a=i.documentElement;if(a?.localName!==`svg`||a.namespaceURI!==q||i.querySelector(`parsererror`))throw Error(`Invalid GUI file icon SVG`);for(let e of[a,...a.querySelectorAll(`*`)]){if(e.namespaceURI!==q||!_e.has(e.localName))throw Error(`Unsupported GUI file icon SVG element`);for(let t of e.attributes){let e=t.name.toLowerCase(),n=t.value.trim();if(e.startsWith(`on`)||e===`style`||e===`xml:base`||n.includes(`\\`)||Array.from(n).some(e=>e.charCodeAt(0)<32)||(e===`href`||e.endsWith(`:href`))&&!/^#[\w.-]+$/.test(n)||/url\s*\(/i.test(n)&&!/^url\(\s*#[\w.-]+\s*\)$/.test(n))throw Error(`Unsupported GUI file icon SVG reference or attribute`)}}let o={source:e,bytes:r,uri:`data:image/svg+xml,${encodeURIComponent(e)}`};return t.set(e,o),o}var ve=class{plugins=new Map;index=new Map;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});get(e,t){if(t?.isDirectory)return;let n=e.split(/[\\/]/).at(-1)??``,r=t?.extension??(n.includes(`.`)?n.slice(n.lastIndexOf(`.`)+1):``),i=this.index.get(J(r));return t?.themeVariant===`light`?i?.light.uri:i?.dark.uri}replace(e,t){if(t.length>64)throw Error(`GUI file icon per-plugin limit exceeded`);if(!t.length){this.remove(e);return}let n=new Map;for(let t of this.plugins.get(e)??[])for(let e of[t.dark,t.light])n.set(e.source,e);let r=new Set,i=t.map(e=>{if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||r.has(e.id))throw Error(`Invalid or duplicate GUI file icon id`);if(r.add(e.id),!(`extensions`in e)||!Array.isArray(e.extensions)||!e.extensions.length||e.extensions.length>64)throw Error(`GUI file icon requires 1–64 extensions`);let t=e.extensions.map(e=>{if(typeof e!=`string`)throw Error(`Invalid GUI file icon extension`);let t=J(e);if(!/^[a-z0-9][a-z0-9_+-]{0,63}$/.test(t))throw Error(`Invalid GUI file icon extension`);return t}),i=Y(`svg`in e?e.svg:void 0,n),a=`lightSvg`in e&&e.lightSvg!==void 0?Y(e.lightSvg,n):i;return{id:e.id,extensions:[...new Set(t)],dark:i,light:a}}),a=i.length,o=i.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0);for(let[t,n]of this.plugins)t!==e&&(a+=n.length,o+=n.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0));if(a>512||o>8388608)throw Error(`GUI file icon total limit exceeded`);this.plugins.set(e,i),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map;for(let t of this.plugins.values())for(let n of t)for(let t of n.extensions)e.set(t,n);let t=e.size!==this.index.size||[...e].some(([e,t])=>{let n=this.index.get(e);return n?.dark.uri!==t.dark.uri||n?.light.uri!==t.light.uri});if(this.index=e,t)for(let e of this.listeners)e()}},X=e=>{throw Error(`Unsupported GUI host API: ${e}`)};function Z(e,t){return new Proxy(t,{get:(t,n)=>n in t?Reflect.get(t,n):X(`${e}.${String(n)}`)})}var Q=e=>Object.freeze(e.map(e=>Object.freeze(e)));function $(e,t){if(e){for(let n of e.owned??[])$(n,t);e.cleanups&&=e.cleanups.map(e=>()=>{try{Promise.resolve(e()).catch(t)}catch(e){t(e)}})}}var ye=class{options;fileIcons=new ve;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=t(0);views=t(0);session=t();appearance;layouts=new Map;files;storage;ended=!1;contracts=new Map;snapshot=Object.freeze({plugins:Object.freeze([]),commands:Object.freeze([]),panels:Object.freeze([]),settings:Object.freeze([]),menuItems:Object.freeze([]),activePanel:null});screen;constructor(e){this.options=e,this.appearance=t({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new he(e.storage,e.transport);let n=()=>(this.session[0](),this.files?.api??X(`screen.file without a session`));this.screen=Z(`screen`,{get file(){return n()}})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;changed(){this.changes[1](e=>e+1)}setSession(e){if(this.ended)return;let t=this.session[0]();if(t?.id===e?.id&&t?.directory===e?.directory)return;if(!e)for(let e of[...this.panelMounts])e();this.files?.dispose(),this.files=e?new me(this.options.files,this.options.queryClient,this.options.transport,e.directory):void 0;let n=Z(`session.server`,{id:this.options.transport,name:this.options.transport,client:this.options.client}),r=e?Object.freeze(Z(`session`,{id:e.id,directory:e.directory,key:`${this.options.transport}\n${e.id}`,tab:e.id,server:n,pending:!1,visit:{},location:{directory:e.directory}})):void 0;this.session[1](r),this.publish()}setAppearance(e){if(this.ended)return;let t=this.appearance[0]();(t.locale!==e.locale||t.mode!==e.mode||t.narrow!==e.narrow)&&this.appearance[1]({...e})}install(r,i){let a=this.instances.get(r);if(this.ended||a?.status===`active`&&a.revision===i.revision)return;a&&(this.instances.delete(r),this.release(a));let c={id:r,revision:i.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:t(0),commands:[],panels:[],settings:[],menus:[]};this.instances.set(r,c);try{let t=R(i.code);s(r=>{c.dispose=r,c.root=n(),f(()=>l(D.Provider,{value:c.context=this.context(c,t,i.options),get children(){c.owner=n();let e=o(()=>t.setup(c.context));if(typeof e==`function`)c.cleanups.add(()=>{Promise.resolve(e()).catch(e=>{c.error=String(e)})});else if(e!==void 0)throw e&&typeof e==`object`&&`then`in e&&Promise.resolve(e).catch(()=>{}),Error(`GUI setup must be synchronous and return only cleanup`);return null}}),e=>this.fail(c,e)),c.controller.signal.aborted||e(c.owner,()=>b(()=>{if(c.iconChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===ge).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(c.id,e)}catch(e){o(()=>this.fail(c,e))}})),c.controller.signal.aborted||e(c.owner,()=>b(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(c)}catch(e){o(()=>this.fail(c,e))}o(()=>this.publish())}))})}catch(e){this.fail(c,e)}this.changed(),this.publish()}release(e){e.controller.abort();for(let t of[...e.cleanups])try{t()}catch(t){e.error??=String(t)}e.cleanups.clear(),$(e.root,t=>{e.error??=String(t)});try{e.dispose?.()}catch(t){e.error??=String(t)}e.contributions.clear(),e.commands=[],e.panels=[],e.settings=[],e.menus=[],this.fileIcons.remove(e.id);for(let t of this.contracts.values())t.provider===e&&(t.provider=void 0,t.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))}fail(e,t){e.status!==`failed`&&this.instances.get(e.id)===e&&(e.status=`failed`,e.error=t instanceof Error?t.message:String(t),this.release(e),this.publish())}uninstall(e){let t=this.instances.get(e);if(t){this.instances.delete(e),this.release(t);for(let t of this.layouts.values())t.open=t.open.filter(t=>!t.startsWith(`${e}:`)),t.active?.startsWith(`${e}:`)&&(t.active=null);this.changed(),this.publish()}}dispose(){this.ended||(this.ended=!0,p(()=>{for(let e of[...this.instances.keys()])this.uninstall(e)}),this.files?.dispose(),this.fileIcons.dispose(),this.storage.dispose(),this.layouts.clear(),this.fileViews.clear(),this.contracts.clear(),this.listeners.clear())}own(e,t){let i=!0,a=()=>{i&&(i=!1,e.cleanups.delete(a),t())};return e.controller.signal.aborted||r(w)?.ended?(a(),a):(e.cleanups.add(a),n()&&h(a),a)}list(e){this.changes[0]();let t=[];for(let n of this.instances.values())if(n.status===`active`){for(let r of n.contributions)if(r.registry===e.id){let e=r.read();e!==void 0&&t.push(e)}}return t}context(e,t,i){let a=this.storage.forPlugin(e.id,e.controller.signal),c=Object.fromEntries(Object.entries(t.stores??{}).map(([e,t])=>[e,t.scope===`global`?a.store(e,{...t,scope:`global`}):n=>a.store(e,{...t,scope:{session:n}})])),l=(e,n)=>{let r=this.appearance[0]().locale;return(t.i18n?.[r]?.[e]??t.i18n?.[r.split(`-`)[0]]?.[e]??t.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,t)=>String(n?.[t]??e))},u=Z(`layout`,{narrow:()=>this.appearance[0]().narrow,ready:()=>!!this.session[0](),open:(t,n,r)=>{e.controller.signal.aborted||this.openPanel(t,n,r)},close:(t,n)=>{e.controller.signal.aborted||this.closeFor(t,n)},toggle:(e,t)=>u.state(e,t)===`visible`?u.close(e,t):u.open(e,t),hide:(t,n)=>{if(e.controller.signal.aborted)return;let r=this.layout(n);r.active===t&&r.shown&&(r.shown=!1,this.changed())},state:(e,t)=>{this.changes[0]();let n=this.layout(t);return n.active===e?n.shown?`visible`:`active`:n.open.includes(e)?`open`:`closed`},stored:t=>(this.changes[0](),this.layout(t).open.filter(t=>t.startsWith(`${e.id}:`)).map(t=>t.slice(e.id.length+1))),side:{opened:e=>(this.changes[0](),this.layout(e).shown),toggle:t=>{if(e.controller.signal.aborted)return;let n=this.layout(t);n.shown=!n.shown,this.changed()},menu:()=>this.list(E).filter(e=>e.menu===`session.panel`).sort((e,t)=>(e.order??0)-(t.order??0))},scroll:{get:(e,t)=>(this.changes[0](),this.layout(e).scroll.get(t)),set:(t,n,r)=>{if(e.controller.signal.aborted)return;let i=this.layout(t).scroll;if(!i.has(n)&&i.size>=128)throw Error(`GUI layout scroll limit exceeded`);i.set(n,{...r}),this.changed()}}});return Z(`ctx`,{id:e.id,options:i,signal:e.controller.signal,client:this.options.client,storage:a,stores:c,app:{name:`yuri`,version:``,channel:`local`,platform:`web`,packaged:!1},desktop:void 0,t:l,plural:(e,t,n)=>{let r=`${e}.${new Intl.PluralRules(this.appearance[0]().locale).select(t)}`;return l(r,{...n,count:t})===r?l(`${e}.other`,{...n,count:t}):l(r,{...n,count:t})},add:(t,i)=>{if(e.controller.signal.aborted||r(w)?.ended)return()=>{};if([`server`,`titlebar-item`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(t.id)&&X(`registry.${t.id}`),e.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let a=()=>{},c,l=s(e=>{a=e,c=n();let r=d(()=>typeof i==`function`?i():i);if(t.id===`style`){let e=document.createElement(`style`);document.head.append(e),h(()=>e.remove()),b(()=>{let t=r();e.textContent=t===void 0?``:String(t)})}return{registry:t.id,read:r}},n()??e.owner);e.contributions.add(l);let u=()=>{t.id===`yuri.file-icon`&&e.iconChanges[1](e=>e+1)};return o(u),o(()=>this.changed()),this.own(e,()=>{$(c,t=>{e.error??=String(t)}),a(),e.contributions.delete(l),o(u),o(()=>this.changed())})},list:e=>this.list(e),provide:(t,n)=>{if(e.controller.signal.aborted||r(w)?.ended)return()=>{};if(t.kind!==`contract`||!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw Error(`Contract must belong to the providing plugin`);let i=this.contract(t.id);if(i.provider)throw Error(`Contract already provided: ${t.id}`);return i.provider=e,i.live[1]({status:`active`,value:n,generation:++i.generation}),this.own(e,()=>{i.provider===e&&(i.provider=void 0,i.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))})},use:e=>this.contract(e.id,e.kind===`ipc`).live[0],main:t=>{if(!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw Error(`IPC must belong to the plugin`);return new Proxy({state:()=>void 0},{get:(e,t)=>t===`state`?e.state:t===`on`?()=>X(`native IPC events`):()=>Promise.reject(Error(`Unsupported GUI host API: native IPC`))})},sessions:{current:this.session[0],list:()=>{let e=this.session[0]();return e?[e]:[]}},screen:{current:()=>this.session[0]()?this.screen:void 0},layout:u,appearance:{mode:()=>this.appearance[0]().mode,font:()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`monospace`},locale:{locale:()=>this.appearance[0]().locale,direction:()=>/^(ar|fa|he|ur)(-|$)/i.test(this.appearance[0]().locale)?`rtl`:`ltr`},system:{copy:e=>navigator.clipboard.writeText(e),openExternal:e=>{let t=new URL(e);[`https:`,`http:`,`mailto:`].includes(t.protocol)||X(`system.openExternal protocol`),window.open(e,`_blank`,`noopener,noreferrer`)},save:async e=>{let t=URL.createObjectURL(new Blob([e.content],{type:`text/plain`}));try{let n=document.createElement(`a`);return n.href=t,n.download=e.name,n.click(),!0}finally{setTimeout(()=>URL.revokeObjectURL(t),0)}}},commands:{run:t=>e.controller.signal.aborted||!this.command(t)?!1:(this.runCommand(t),!0)},links:{open:t=>!e.controller.signal.aborted&&this.navigateLink(e,t),exists:t=>o(()=>{if(e.controller.signal.aborted)return!1;let n=this.linkHandler(t);try{return Promise.resolve(n?.value.exists?.(t)??!1).catch(()=>!1)}catch{return!1}})}})}contract(e,n=!1){let r=this.contracts.get(e);if(!r){if(this.contracts.size>=256)throw Error(`GUI contract limit exceeded`);let n=t({status:`inactive`,reason:`disabled`});r={live:[le(n[0]),n[1]],generation:0},this.contracts.set(e,r)}return n&&r.provider&&X(`IPC contract collision`),r}derive(e){if(e.status!==`active`)return;let t=[],n=[],r=[],i=[],a=this.session[0]();for(let o of e.contributions){if(o.registry===`yuri.file-icon`)continue;let s=o.read();if(s!==void 0){if(o.registry===pe.id){let n=s;n.enabled!==!1&&t.push({key:`${e.id}.${n.id}`,title:n.title,description:n.description,bind:n.bind,hidden:n.hidden,run:()=>this.invoke(e,()=>n.run())})}else if(o.registry===A.id&&a){let t=s,r=`${e.id}:`,i=this.layout(a).open.filter(e=>e.startsWith(r)).map(e=>e.slice(r.length));for(let r of t.list({session:a,screen:this.screen,open:i}))n.push({plugin:e,panel:t,tab:r})}else if(o.registry===C.id){let e=s;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,r.push(e)}else if(o.registry===E.id){let e=s;e.menu===`session.panel`?(e.title,i.push(e)):X(`MenuItem.${e.menu}`)}}}for(let e of n)e.tab.title;e.commands=t,e.panels=n,e.settings=r,e.menus=i,o(()=>this.views[1](e=>e+1))}publish(){let e=o(this.session[0]),t=e?this.layouts.get(e.key):void 0,n=[...this.instances.values()],r=n.filter(e=>e.status===`active`),i=r.flatMap(e=>e.panels.map(({tab:n})=>{let r=n.file?this.filePath(n.file):void 0;return{key:`${e.id}:${n.id}`,pluginId:e.id,title:n.title,file:r,inline:!!(r&&this.fileViews.has(r)),active:t?.shown===!0&&t.active===`${e.id}:${n.id}`}}));this.snapshot=Object.freeze({plugins:Q(n.map(({id:e,revision:t,status:n,error:r})=>({id:e,revision:t,status:n,error:r}))),commands:Q(r.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(i),settings:Q(r.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(r.flatMap(e=>e.menus.map(t=>({key:`${e.id}:${t.id}`,title:t.title,description:t.description,run:()=>{this.invoke(e,()=>t.run())}})))),activePanel:t?.shown&&i.some(e=>e.key===t.active)?t.active:null,sessionKey:e?.key});for(let e of this.listeners)e()}invoke(t,n){if(!t.controller.signal.aborted)try{let r=e(t.owner??null,n);if(r instanceof Promise)return r.catch(e=>this.fail(t,e))}catch(e){this.fail(t,e)}}command(e){return[...this.instances.values()].flatMap(e=>e.commands).find(t=>t.key===e)}runCommand(e){return this.command(e)?.run()}linkHandler(e){let t=[];for(let e of this.instances.values())for(let n of e.contributions)if(n.registry===ce.id){let r=n.read();r&&t.push({instance:e,value:r})}for(let n of t.sort((e,t)=>(t.value.priority??0)-(e.value.priority??0)))try{if(n.value.match(e))return n}catch(e){this.fail(n.instance,e)}}navigateLink(e,t){if(this.ended)return!1;let n=ie(t.href);if(!n||!re(n.path))return this.openLink(t);let r=this.session[0]();if(!r||t.session&&(t.session.key!==r.key||t.session.server.id!==r.server.id))return!1;if(!this.options.focusFile)return this.openLink(t);let i=te(t.base??r.directory,n.path),a=n.line===void 0?``:`:${n.line}${n.column===void 0?``:`:${n.column}`}`;return this.invoke(e,()=>this.options.focusFile(i+a,r.directory)),!0}openLink(e){if(this.ended)return!1;let t={...e,session:e.session??this.session[0]()},n=this.linkHandler(t);return n?(this.invoke(n.instance,()=>n.value.open(t)),!0):!1}filePath(e,t=this.session[0]()?.directory){let n=z(e);return/^(?:\/|[a-z]:\/)/i.test(n)||!t?n:z(`${t}/${n}`)}registerFileView(e,t){if(this.ended)return()=>{};let n=this.filePath(e,t),r=this.fileViews.get(n)??0;this.fileViews.set(n,r+1),r===0&&(this.changed(),this.publish());let i=!1;return()=>{if(i||this.ended)return;i=!0;let e=(this.fileViews.get(n)??1)-1;if(e){this.fileViews.set(n,e);return}{let e=this.session[0](),t=e&&this.layouts.get(e.key);t?.active&&this.snapshot.panels.some(e=>e.key===t.active&&e.file===n)&&(t.shown=!1),this.fileViews.delete(n)}this.changed(),this.publish()}}filePanel(e,t){let n=this.filePath(e,t);return this.snapshot.panels.find(e=>e.file===n&&e.inline)}panelVisible(e){let t=this.session[0]();if(!t)return!1;let n=this.panel(e)?.tab.file;if(n&&this.fileViews.has(this.filePath(n)))return!0;let r=this.layouts.get(t.key);return!!(r?.shown&&r.active===e)}layout(e){let t=this.layouts.get(e.key);if(!t){if(this.layouts.size>=128)throw Error(`GUI session layout limit exceeded`);t={open:[],active:null,shown:!1,scroll:new Map},this.layouts.set(e.key,t)}return t}openPanel(e,t,n){if(this.ended)return;let r=this.layout(t),i=r.active,a=r.shown,o=r.open.length;if(!r.open.includes(e)){if(r.open.length>=64)throw Error(`GUI panel tab limit exceeded`);r.open=[...r.open,e]}n?.tab!==`append`&&(r.active=e,r.shown=!(this.appearance[0]().narrow&&n?.background)),(i!==r.active||a!==r.shown||o!==r.open.length)&&(this.changed(),this.publish());let s=this.panel(e);t.key===this.session[0]()?.key&&s&&n?.tab!==`append`&&this.invoke(s.plugin,()=>s.panel.focus?.({...this.props(e),restored:!1}))}selectPanel(e){let t=this.session[0]();t&&this.openPanel(e,t)}closeFor(e,t){let n=this.layout(t),r=t.key===this.session[0]()?.key?this.panel(e):void 0;if(!n.open.includes(e)||r?.tab.pinned||r?.tab.closable===!1)return;let i=this.session[0](),a=r&&i?{tab:r.tab,session:i,screen:this.screen}:void 0;n.open=n.open.filter(t=>t!==e),n.active===e&&(n.active=n.open.at(-1)??null),this.changed(),this.publish(),r&&a&&this.invoke(r.plugin,()=>r.panel.close?.(a))}closePanel(e){let t=this.session[0]();t&&this.closeFor(e,t)}hidePanel(){let e=this.session[0]();if(!e)return;let t=this.layout(e);t.shown&&(t.shown=!1,this.changed(),this.publish())}panel(e){return[...this.instances.values()].flatMap(e=>e.panels).find(t=>`${t.plugin.id}:${t.tab.id}`===e)}props(e){let t=this.panel(e)?.tab,n=()=>(this.views[0](),this.panel(e)?.tab??t??X(`panel no longer listed`)),r=()=>this.session[0]()??X(`panel without session`);return{get tab(){return n()},get session(){return r()},screen:this.screen}}mountPanel(e,t){let n=this.panel(e);if(!n)return()=>{};let r=()=>{let t=d(()=>{this.session[0](),this.changes[0](),this.views[0]();let t=this.panel(e)?.tab.file;return t&&this.files&&this.panelVisible(e)?{model:this.files,file:t}:void 0},void 0,{equals:(e,t)=>e?.model===t?.model&&e?.file===t?.file});return b(()=>{let e=t();e&&(h(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))}),o(()=>n.panel.render(this.props(e)))},i=this.mount(n.plugin,t,()=>l(de.Provider,{value:{visible:()=>(this.changes[0](),this.panelVisible(e)),present:()=>(this.changes[0](),this.panelVisible(e)),placement:()=>this.appearance[0]().narrow?`mobile`:`side`,reserve:()=>!1,animate:()=>!1,sidebar:Z(`panel.sidebar`,{}),open:()=>{let e=this.session[0]();return e?n.plugin.context.layout.stored(e):[]}},get children(){return r()}})),a=()=>{this.panelMounts.delete(a),i()};return this.panelMounts.add(a),this.own(n.plugin,a)}mountSettings(e,t){for(let n of this.instances.values()){let r=n.settings.find(t=>`${n.id}:${t.id}`===e);if(r)return this.mount(n,t,()=>r.render({}))}return()=>{}}mount(e,t,r){if(e.controller.signal.aborted)return()=>{};let i=()=>{},a,s=t=>{queueMicrotask(()=>this.fail(e,t))};try{i=oe(()=>l(D.Provider,{value:e.context,get children(){return a=n(),f(()=>o(r),s)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(a,t=>{e.error??=String(t)}),i(),t.replaceChildren()})}};export{ye as GuiPluginHost};
1
+ import{A as e,C as t,E as n,F as r,I as i,M as a,P as o,S as s,T as c,_ as l,a as u,b as d,g as f,h as p,i as m,k as h,n as g,o as _,r as v,t as y,x as b}from"./vendor-opencode-client-BcpAhe9I.js";import{i as x}from"./vendor-tanstack-query-core-BWz0ose6.js";import{c as S,l as ee,o as te}from"./path-utils-QNmCUIdP.js";import{n as ne}from"./pathNormalization-ewtPqJWn.js";import{i as re,o as ie}from"./fileReferenceParser-D6pFtXag.js";import{n as ae,t as oe}from"./vendor-solid-js-B2FO7pdm.js";import{a as se,c as ce,d as C,f as w,h as le,i as T,l as E,m as D,n as ue,o as O,p as de,r as fe,s as pe,t as k,u as A}from"./vendor-opencode-plugin-BglYYlJt.js";import{ft as j,pt as M,wt as N,y as P}from"./vendor-effect-DXlObQuU.js";var F={"@opencode/plugin/gui":O,"@opencode/plugin/gui/main":O,"@opencode/plugin/gui/file":se,"@opencode/plugin/gui/review":T,"@opencode/plugin/gui/browser":fe,"@opencode/plugin/rpc":k,"@opencode/schema/rpc":ue,"@opencode/client":i,"@opencode/client/effect":g,"@opencode/client/solid":y,effect:P,"solid-js":a,"solid-js/web":ae,"solid-js/store":u},I=new Set(`assert assert/strict async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns dns/promises domain events fs fs/promises http http2 https inspector inspector/promises module net os path path/posix path/win32 perf_hooks process punycode querystring readline readline/promises repl stream stream/consumers stream/promises stream/web string_decoder sys timers timers/promises tls trace_events tty url util util/types v8 vm wasi worker_threads zlib`.split(` `));function L(){let e=new Proxy(function(){},{get:(t,n)=>n===`then`?void 0:n===Symbol.hasInstance?()=>!1:n===Symbol.toPrimitive||n===`toString`?()=>`[main-only module]`:e,apply:()=>e,construct:()=>e,set:()=>!0});return e}function R(e){if(e.length>16777216)throw Error(`GUI bundle exceeds 16 MiB`);let t={exports:{}};Function(`require`,`module`,`exports`,e)(e=>{if(Object.hasOwn(F,e))return F[e];if(e===`electron`||e.startsWith(`node:`)||I.has(e))return L();throw Error(`Unsupported GUI shared module: ${e}`)},t,t.exports);let n=t.exports,r=n&&typeof n==`object`&&`default`in n?n.default:n;if(!r||typeof r!=`object`)throw Error(`GUI bundle must default-export Plugin.define`);if(!(`setup`in r)||typeof r.setup!=`function`)throw Error(`This host requires a window setup; main-only plugins are unsupported`);if(`os`in r&&r.os!==void 0)throw Error(`OS-restricted plugins require the native GUI host`);if(`main`in r&&r.main!==void 0&&typeof r.main!=`function`)throw Error(`Invalid GUI main entry`);if(`stores`in r&&r.stores!==void 0){if(!r.stores||typeof r.stores!=`object`||Array.isArray(r.stores))throw Error(`Invalid GUI stores`);for(let e of Object.values(r.stores))if(!e||typeof e!=`object`||!(`schema`in e)||!N(e.schema)||!(`scope`in e)||![`global`,`session`].includes(String(e.scope))||!(`initial`in e))throw Error(`Invalid GUI store declaration`)}if(`i18n`in r&&r.i18n!==void 0){if(!r.i18n||typeof r.i18n!=`object`||Array.isArray(r.i18n))throw Error(`Invalid GUI locale catalog`);for(let e of Object.values(r.i18n))if(!e||typeof e!=`object`||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`GUI locales must be inline string dictionaries`)}return r}function z(e){let t=e;if(/^file:/i.test(t)){let e=new URL(t);t=`${e.hostname&&e.hostname!==`localhost`?`//${e.hostname}`:``}${decodeURIComponent(e.pathname)}`,/^\/[a-z]:\//i.test(t)&&(t=t.slice(1))}let n=ne(t)??``;return n===`.`?``:n}var B=e=>/^(?:\/|[a-z]:\/)/i.test(e),V=()=>{throw Error(`Unsupported GUI file API: tree`)},H=class extends Error{},U=e=>new TextEncoder().encode(e).byteLength,me=class{files;query;transport;root;api;ended=!1;states=new Map;inflight=new Map;watches=new Map;apiLeases=new Map;registeredOwners=new WeakSet;endedOwners=new WeakSet;leaseCount=0;rerun=new Set;selections=new Map;scrolls=new Map;subscriptions=new Map;constructor(e,t,r,i){this.files=e,this.query=t,this.transport=r,this.root=i,this.root=z(i),this.api={root:this.root,ready:()=>!this.ended,resolve:e=>this.resolve(e),absolute:B,get:e=>{let t=this.track(e,`file`);return this.states.get(t)},missing:e=>{let t=this.track(e,`missing`);return this.states.get(t)?.notFound===!0},sync:(e,t)=>{let r=n();return this.ended||r&&this.endedOwners.has(r)?Promise.resolve():(this.acquireApiLease(e),this.sync(e,t?.force))},unwatch:e=>this.releaseApiLease(n(),this.resolve(e)),exists:async e=>{try{if(this.files.statFile)return(await this.query.fetchQuery(this.statOptions(e))).isFile;let t=this.full(e);return(await this.files.listDirectory(t.slice(0,t.lastIndexOf(`/`)))).entries.some(e=>!e.isDirectory&&z(e.path)===t)}catch{return!1}},search:async(e,t)=>{if(t?.kind===`any`)throw Error(`Unsupported GUI file search: directories`);t?.signal?.throwIfAborted();let n=await this.query.fetchQuery({queryKey:[`gui-plugin-files`,r,this.root,`search`,e,t?.limit],gcTime:3e4,queryFn:async({signal:n})=>(n.throwIfAborted(),this.files.search({directory:this.root,query:e,maxResults:t?.limit??100}))});if(t?.signal?.throwIfAborted(),this.ended)throw new DOMException(`GUI file model was disposed`,`AbortError`);return n.map(e=>this.resolve(e.path))},selection:{get:e=>this.selections.get(this.track(e,`selection`)),set:(e,t)=>{let n=this.resolve(e),r=this.selections.get(n);r===t||r&&t&&r.start===t.start&&r.end===t.end&&r.side===t.side&&r.endSide===t.endSide||(this.selections.set(n,t),this.trim(this.selections,`selection`),this.changed(n,`selection`))}},scroll:{get:e=>this.scrolls.get(this.track(e,`scroll`))??{},set:(e,t)=>{let n=this.resolve(e),r=this.scrolls.get(n),i={...r,...t};(r?.top!==i.top||r?.left!==i.left)&&(this.scrolls.set(n,i),this.trim(this.scrolls,`scroll`),this.changed(n,`scroll`))}},tree:{list:V,state:V,sync:V,expand:V,collapse:V}}}resolve(e){let t=z(e);if(!B(t))return t;if(t===this.root)return``;let n=this.root.endsWith(`/`)?this.root:`${this.root}/`;return t.startsWith(n)?t.slice(n.length):t}full(e){let t=this.resolve(e);return B(t)?t:z(`${this.root}/${t}`)}input(e){return{scopeDirectory:this.root,path:this.full(e),options:{directory:this.root}}}statOptions(e){return{...ee(this.files,this.input(e),this.transport),gcTime:3e4}}track(n,r){let i=this.resolve(n),a=c();if(!a||this.ended)return i;let o=`${r}:${i}`,s=this.subscriptions.get(o);s||(s={revision:t(0),listeners:new Set},this.subscriptions.set(o,s));let l=s;return l.listeners.has(a)||(l.listeners.add(a),e(a,()=>h(()=>{l.listeners.delete(a),!l.listeners.size&&this.subscriptions.get(o)===l&&this.subscriptions.delete(o)}))),l.revision[0](),i}changed(e,t){this.ended||this.subscriptions.get(`${t}:${e}`)?.revision[1](e=>e+1)}trim(e,t){for(;e.size>64;){let n=e.keys().next().value;e.delete(n),this.changed(n,t)}}setState(e,t){let n=this.states.get(e);n?.content?.content===t.content?.content&&n?.content?.type===t.content?.type&&(t.content=n?.content),!(n&&n.loaded===t.loaded&&n.loading===t.loading&&n.error===t.error&&n.notFound===t.notFound&&n.content===t.content)&&(this.states.set(e,t),p(()=>{this.changed(e,`file`),n?.notFound===!0!=(t.notFound===!0)&&this.changed(e,`missing`)}))}acquireApiLease(e){let t=n();if(this.ended||t&&this.endedOwners.has(t)||!this.files.statFile)return;let r=this.resolve(e),i=this.apiLeases.get(t);if(i?.has(r))return;if(this.leaseCount>=256)throw Error(`GUI file consumer limit exceeded`);let a=this.watch(r);i||(i=new Map,this.apiLeases.set(t,i)),i.set(r,a),this.leaseCount++,t&&!this.registeredOwners.has(t)&&(this.registeredOwners.add(t),h(()=>{`fn`in t||this.endedOwners.add(t),this.registeredOwners.delete(t);for(let e of[...this.apiLeases.get(t)?.keys()??[]])this.releaseApiLease(t,e)}))}releaseApiLease(e,t){let n=this.apiLeases.get(e),r=n?.get(t);r&&(n.delete(t),this.leaseCount--,n.size||this.apiLeases.delete(e),r())}reserve(e){if(!this.states.has(e)){if(this.states.size>=64){let e=[...this.states.keys()].find(e=>!this.watches.has(e)&&!this.inflight.has(e));if(!e)throw Error(`GUI file cache limit exceeded`);let t=this.states.get(e)?.notFound===!0;this.states.delete(e),p(()=>{this.changed(e,`file`),t&&this.changed(e,`missing`)})}this.states.set(e,{path:e,name:e.split(`/`).at(-1)??e})}}async sync(e,t=!1){if(this.ended)return;let n=this.resolve(e);if(this.inflight.has(n))return t&&this.rerun.add(n),this.inflight.get(n);if(!t&&this.states.get(n)?.loaded&&!this.states.get(n)?.error)return;this.reserve(n);let r=this.states.get(n);this.setState(n,{...r,path:n,name:n.split(`/`).at(-1)??n,loading:!r?.loaded&&!this.watches.get(n)?.failed});let i=(async()=>{try{do{this.rerun.delete(n);let e=this.watches.get(n),r=e?.epoch;try{let i=S(this.files,this.input(n),this.transport),a=await this.query.fetchQuery({...i,gcTime:3e4,staleTime:t?0:3e4,queryFn:async()=>{if(!this.files.readFile)throw Error(`File content reads are unavailable in this runtime`);let e=await this.files.readFile(this.full(n),{directory:this.root});if(e.exists===!1)throw new H(`File does not exist`);let t=e.content;if(U(t)>131072)throw Error(`GUI file preview exceeds 128 KiB`);return t}});if(this.ended)return;if(U(a)>131072)throw Error(`GUI file preview exceeds 128 KiB`);(!e||e.epoch===r&&!e.failed)&&this.setState(n,{path:n,name:n.split(`/`).at(-1)??n,loaded:!0,loading:!1,content:{type:`text`,content:a}})}catch(t){if(this.ended)return;if((!e||e.epoch===r&&!e.failed)&&this.setState(n,{...this.states.get(n),loading:!1,...t instanceof H?{notFound:!0}:{},error:String(t)}),!this.rerun.has(n))throw t}t=!0}while(!this.ended&&this.rerun.has(n))}finally{this.inflight.delete(n),this.rerun.delete(n)}})();return this.inflight.set(n,i),i}watch(e){if(this.ended||!this.files.statFile)return()=>{};let t=this.resolve(e),n=this.watches.get(t);if(!n){if(this.watches.size>=64)throw Error(`GUI file watch limit exceeded`);this.reserve(t),n={count:0,epoch:0,failed:!1,stop:()=>{}};let e=n;this.watches.set(t,e);let r,i=new x(this.query,{...this.statOptions(t),refetchInterval:2e3,refetchIntervalInBackground:!1}),a=i.subscribe(n=>{if(this.ended||this.watches.get(t)!==e||n.isFetching)return;if(n.isError||n.isSuccess&&!n.data.isFile){e.failed=!0,e.epoch++,this.setState(t,{...this.states.get(t),loading:!1,notFound:n.isSuccess?!0:this.states.get(t)?.notFound,error:n.isError?String(n.error):`File does not exist`});return}if(!n.data||!n.isSuccess)return;let i=`${n.data.size}:${n.data.mtimeMs??``}`,a=e.failed||r!==void 0&&i!==r;e.failed=!1,r=i,a&&(e.epoch++,this.sync(t,!0).catch(()=>{}))});e.stop=()=>{a(),i.destroy()}}n.count++;let r=!0;return()=>{r&&(r=!1,--n.count===0&&this.watches.get(t)===n&&this.stopWatch(t))}}stopWatch(e){this.watches.get(e)?.stop(),this.watches.delete(e)}dispose(){this.ended=!0;for(let e of this.watches.values())e.stop();this.watches.clear(),this.apiLeases.clear(),this.leaseCount=0,this.rerun.clear(),this.states.clear(),this.inflight.clear(),this.selections.clear(),this.scrolls.clear(),this.subscriptions.clear()}},W=256,G=2097152,K=e=>structuredClone(_(e)),he=class{backend;transport;memory=new Map;resets=new Map;constructor(e,t){this.backend=e,this.transport=t}forPlugin(e,n){let r=(t,n=`global`)=>{if(typeof n==`object`&&`session`in n&&!n.session.location)throw Error(`Unsupported GUI storage: session location is unknown`);let r=n===`global`?n:`session`in n?[n.session.server.id,n.session.id,n.session.location]:[n.server,n.directory];return`yuri.gui-plugin.${JSON.stringify([this.transport,e,r,t])}`},i=e=>{if(n.aborted)throw Error(`GUI plugin has been disposed`);if(e!==void 0)throw Error(`Unsupported GUI storage migration: from`)},a=new Map;return{store:(e,o)=>{i(o.from);let s=r(e,o.scope),c=a.get(s);if(c)return c;if(a.size>=W)throw Error(`GUI plugin store limit exceeded`);let l=j(o.schema),u=M(o.schema),d=l(u(K(o.initial)));if(JSON.stringify(u(d)).length>G)throw Error(`GUI plugin store exceeds 2 MiB`);let f=d,p=this.backend.getItem(s);if(p!==null&&p.length<=G)try{f=l(JSON.parse(p))}catch{f=d}let[m,h]=t(f),g=e=>{i();let t=JSON.stringify(u(K(e)));if(t.length>G)throw Error(`GUI plugin store exceeds 2 MiB`);let n=l(JSON.parse(t));this.backend.setItem(s,t),h(()=>n)},_={get value(){return m()},ready:()=>!0,set:g,update:e=>{let t=K(m());if(e(t)!==void 0)throw Error(`Store update must not return a replacement`);g(t)}},v=()=>h(()=>K(d)),y=this.resets.get(s)??new Set;return y.add(v),this.resets.set(s,y),n.addEventListener(`abort`,()=>{y.delete(v),y.size||this.resets.delete(s),a.clear()},{once:!0}),a.set(s,_),_},memory:(e,t)=>{i();let n=r(e),a=this.memory.get(n);if(a)return[a[0],e=>{i(),a[1](e)}];if(this.memory.size>=W)throw Error(`GUI plugin memory store limit exceeded`);if(JSON.stringify(t.initial).length>G)throw Error(`GUI plugin memory exceeds 2 MiB`);let[o,s]=v(K(t.initial)),c=[o,e=>{i();let t=K(_(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>G)throw Error(`GUI plugin memory exceeds 2 MiB`);s(m(t))}];return this.memory.set(n,[o,e=>{let t=K(_(o));if(e(t)!==void 0)throw Error(`Memory update must not return a replacement`);if(JSON.stringify(t).length>G)throw Error(`GUI plugin memory exceeds 2 MiB`);s(m(t))}]),c},remove:(e,t)=>{i(t?.from);let n=r(e,t?.scope);this.backend.removeItem(n);for(let e of this.resets.get(n)??[])e()}}}dispose(){this.memory.clear(),this.resets.clear()}},ge=`yuri.file-icon`,q=`http://www.w3.org/2000/svg`,_e=new Set([`svg`,`g`,`path`,`rect`,`circle`,`ellipse`,`line`,`polyline`,`polygon`,`defs`,`linearGradient`,`radialGradient`,`stop`,`clipPath`,`mask`,`use`,`title`,`desc`]),J=e=>e.trim().replace(/^\./,``).toLowerCase();function Y(e,t){if(typeof e!=`string`)throw Error(`GUI file icon requires SVG text`);let n=t.get(e);if(n)return n;if(e.length>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);let r=new TextEncoder().encode(e).byteLength;if(r>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);if(!/^\s*<svg[\s>]/.test(e)||/<!|<\?/.test(e))throw Error(`Invalid GUI file icon SVG`);let i=new DOMParser().parseFromString(e,`image/svg+xml`),a=i.documentElement;if(a?.localName!==`svg`||a.namespaceURI!==q||i.querySelector(`parsererror`))throw Error(`Invalid GUI file icon SVG`);for(let e of[a,...a.querySelectorAll(`*`)]){if(e.namespaceURI!==q||!_e.has(e.localName))throw Error(`Unsupported GUI file icon SVG element`);for(let t of e.attributes){let e=t.name.toLowerCase(),n=t.value.trim();if(e.startsWith(`on`)||e===`style`||e===`xml:base`||n.includes(`\\`)||Array.from(n).some(e=>e.charCodeAt(0)<32)||(e===`href`||e.endsWith(`:href`))&&!/^#[\w.-]+$/.test(n)||/url\s*\(/i.test(n)&&!/^url\(\s*#[\w.-]+\s*\)$/.test(n))throw Error(`Unsupported GUI file icon SVG reference or attribute`)}}let o={source:e,bytes:r,uri:`data:image/svg+xml,${encodeURIComponent(e)}`};return t.set(e,o),o}var ve=class{plugins=new Map;index=new Map;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});get(e,t){if(t?.isDirectory)return;let n=e.split(/[\\/]/).at(-1)??``,r=t?.extension??(n.includes(`.`)?n.slice(n.lastIndexOf(`.`)+1):``),i=this.index.get(J(r));return t?.themeVariant===`light`?i?.light.uri:i?.dark.uri}replace(e,t){if(t.length>64)throw Error(`GUI file icon per-plugin limit exceeded`);if(!t.length){this.remove(e);return}let n=new Map;for(let t of this.plugins.get(e)??[])for(let e of[t.dark,t.light])n.set(e.source,e);let r=new Set,i=t.map(e=>{if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||r.has(e.id))throw Error(`Invalid or duplicate GUI file icon id`);if(r.add(e.id),!(`extensions`in e)||!Array.isArray(e.extensions)||!e.extensions.length||e.extensions.length>64)throw Error(`GUI file icon requires 1–64 extensions`);let t=e.extensions.map(e=>{if(typeof e!=`string`)throw Error(`Invalid GUI file icon extension`);let t=J(e);if(!/^[a-z0-9][a-z0-9_+-]{0,63}$/.test(t))throw Error(`Invalid GUI file icon extension`);return t}),i=Y(`svg`in e?e.svg:void 0,n),a=`lightSvg`in e&&e.lightSvg!==void 0?Y(e.lightSvg,n):i;return{id:e.id,extensions:[...new Set(t)],dark:i,light:a}}),a=i.length,o=i.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0);for(let[t,n]of this.plugins)t!==e&&(a+=n.length,o+=n.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0));if(a>512||o>8388608)throw Error(`GUI file icon total limit exceeded`);this.plugins.set(e,i),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map;for(let t of this.plugins.values())for(let n of t)for(let t of n.extensions)e.set(t,n);let t=e.size!==this.index.size||[...e].some(([e,t])=>{let n=this.index.get(e);return n?.dark.uri!==t.dark.uri||n?.light.uri!==t.light.uri});if(this.index=e,t)for(let e of this.listeners)e()}},X=e=>{throw Error(`Unsupported GUI host API: ${e}`)};function Z(e,t){return new Proxy(t,{get:(t,n)=>n in t?Reflect.get(t,n):X(`${e}.${String(n)}`)})}var Q=e=>Object.freeze(e.map(e=>Object.freeze(e)));function $(e,t){if(e){for(let n of e.owned??[])$(n,t);e.cleanups&&=e.cleanups.map(e=>()=>{try{Promise.resolve(e()).catch(t)}catch(e){t(e)}})}}var ye=class{options;fileIcons=new ve;instances=new Map;listeners=new Set;panelMounts=new Set;fileViews=new Map;changes=t(0);views=t(0);session=t();appearance;layouts=new Map;files;storage;ended=!1;contracts=new Map;snapshot=Object.freeze({plugins:Object.freeze([]),commands:Object.freeze([]),panels:Object.freeze([]),settings:Object.freeze([]),menuItems:Object.freeze([]),activePanel:null});screen;constructor(e){this.options=e,this.appearance=t({locale:e.locale,mode:e.mode,narrow:e.narrow}),this.storage=new he(e.storage,e.transport);let n=()=>(this.session[0](),this.files?.api??X(`screen.file without a session`));this.screen=Z(`screen`,{get file(){return n()}})}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;changed(){this.changes[1](e=>e+1)}setSession(e){if(this.ended)return;let t=this.session[0]();if(t?.id===e?.id&&t?.directory===e?.directory)return;if(!e)for(let e of[...this.panelMounts])e();this.files?.dispose(),this.files=e?new me(this.options.files,this.options.queryClient,this.options.transport,e.directory):void 0;let n=Z(`session.server`,{id:this.options.transport,name:this.options.transport,client:this.options.client}),r=e?Object.freeze(Z(`session`,{id:e.id,directory:e.directory,key:`${this.options.transport}\n${e.id}`,tab:e.id,server:n,pending:!1,visit:{},location:{directory:e.directory}})):void 0;this.session[1](r),this.publish()}setAppearance(e){if(this.ended)return;let t=this.appearance[0]();(t.locale!==e.locale||t.mode!==e.mode||t.narrow!==e.narrow)&&this.appearance[1]({...e})}install(r,i){let a=this.instances.get(r);if(this.ended||a?.status===`active`&&a.revision===i.revision)return;a&&(this.instances.delete(r),this.release(a));let c={id:r,revision:i.revision,controller:new AbortController,status:`active`,cleanups:new Set,contributions:new Set,iconChanges:t(0),commands:[],panels:[],settings:[],menus:[]};this.instances.set(r,c);try{let t=R(i.code);s(r=>{c.dispose=r,c.root=n(),f(()=>l(D.Provider,{value:c.context=this.context(c,t,i.options),get children(){c.owner=n();let e=o(()=>t.setup(c.context));if(typeof e==`function`)c.cleanups.add(()=>{Promise.resolve(e()).catch(e=>{c.error=String(e)})});else if(e!==void 0)throw e&&typeof e==`object`&&`then`in e&&Promise.resolve(e).catch(()=>{}),Error(`GUI setup must be synchronous and return only cleanup`);return null}}),e=>this.fail(c,e)),c.controller.signal.aborted||e(c.owner,()=>b(()=>{if(c.iconChanges[0](),!c.controller.signal.aborted)try{let e=[...c.contributions].filter(e=>e.registry===ge).map(e=>e.read()).filter(e=>e!==void 0);this.fileIcons.replace(c.id,e),c.iconError!==void 0&&o(()=>{c.iconError=void 0,this.publish()})}catch(e){o(()=>{this.fileIcons.remove(c.id),c.iconError=e instanceof Error?e.message:String(e),this.publish()})}})),c.controller.signal.aborted||e(c.owner,()=>b(()=>{this.changes[0](),this.session[0](),this.appearance[0]();try{this.derive(c)}catch(e){o(()=>this.fail(c,e))}o(()=>this.publish())}))})}catch(e){this.fail(c,e)}this.changed(),this.publish()}release(e){e.controller.abort();for(let t of[...e.cleanups])try{t()}catch(t){e.error??=String(t)}e.cleanups.clear(),$(e.root,t=>{e.error??=String(t)});try{e.dispose?.()}catch(t){e.error??=String(t)}e.contributions.clear(),e.commands=[],e.panels=[],e.settings=[],e.menus=[],this.fileIcons.remove(e.id);for(let t of this.contracts.values())t.provider===e&&(t.provider=void 0,t.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))}fail(e,t){e.status!==`failed`&&this.instances.get(e.id)===e&&(e.status=`failed`,e.error=t instanceof Error?t.message:String(t),this.release(e),this.publish())}uninstall(e){let t=this.instances.get(e);if(t){this.instances.delete(e),this.release(t);for(let t of this.layouts.values())t.open=t.open.filter(t=>!t.startsWith(`${e}:`)),t.active?.startsWith(`${e}:`)&&(t.active=null);this.changed(),this.publish()}}dispose(){this.ended||(this.ended=!0,p(()=>{for(let e of[...this.instances.keys()])this.uninstall(e)}),this.files?.dispose(),this.fileIcons.dispose(),this.storage.dispose(),this.layouts.clear(),this.fileViews.clear(),this.contracts.clear(),this.listeners.clear())}own(e,t){let i=!0,a=()=>{i&&(i=!1,e.cleanups.delete(a),t())};return e.controller.signal.aborted||r(w)?.ended?(a(),a):(e.cleanups.add(a),n()&&h(a),a)}list(e){this.changes[0]();let t=[];for(let n of this.instances.values())if(n.status===`active`){for(let r of n.contributions)if(r.registry===e.id){let e=r.read();e!==void 0&&t.push(e)}}return t}context(e,t,i){let a=this.storage.forPlugin(e.id,e.controller.signal),c=Object.fromEntries(Object.entries(t.stores??{}).map(([e,t])=>[e,t.scope===`global`?a.store(e,{...t,scope:`global`}):n=>a.store(e,{...t,scope:{session:n}})])),l=(e,n)=>{let r=this.appearance[0]().locale;return(t.i18n?.[r]?.[e]??t.i18n?.[r.split(`-`)[0]]?.[e]??t.i18n?.en?.[e]??e).replace(/\{\{(\w+)\}\}/g,(e,t)=>String(n?.[t]??e))},u=Z(`layout`,{narrow:()=>this.appearance[0]().narrow,ready:()=>!!this.session[0](),open:(t,n,r)=>{e.controller.signal.aborted||this.openPanel(t,n,r)},close:(t,n)=>{e.controller.signal.aborted||this.closeFor(t,n)},toggle:(e,t)=>u.state(e,t)===`visible`?u.close(e,t):u.open(e,t),hide:(t,n)=>{if(e.controller.signal.aborted)return;let r=this.layout(n);r.active===t&&r.shown&&(r.shown=!1,this.changed())},state:(e,t)=>{this.changes[0]();let n=this.layout(t);return n.active===e?n.shown?`visible`:`active`:n.open.includes(e)?`open`:`closed`},stored:t=>(this.changes[0](),this.layout(t).open.filter(t=>t.startsWith(`${e.id}:`)).map(t=>t.slice(e.id.length+1))),side:{opened:e=>(this.changes[0](),this.layout(e).shown),toggle:t=>{if(e.controller.signal.aborted)return;let n=this.layout(t);n.shown=!n.shown,this.changed()},menu:()=>this.list(E).filter(e=>e.menu===`session.panel`).sort((e,t)=>(e.order??0)-(t.order??0))},scroll:{get:(e,t)=>(this.changes[0](),this.layout(e).scroll.get(t)),set:(t,n,r)=>{if(e.controller.signal.aborted)return;let i=this.layout(t).scroll;if(!i.has(n)&&i.size>=128)throw Error(`GUI layout scroll limit exceeded`);i.set(n,{...r}),this.changed()}}});return Z(`ctx`,{id:e.id,options:i,signal:e.controller.signal,client:this.options.client,storage:a,stores:c,app:{name:`yuri`,version:``,channel:`local`,platform:`web`,packaged:!1},desktop:void 0,t:l,plural:(e,t,n)=>{let r=`${e}.${new Intl.PluralRules(this.appearance[0]().locale).select(t)}`;return l(r,{...n,count:t})===r?l(`${e}.other`,{...n,count:t}):l(r,{...n,count:t})},add:(t,i)=>{if(e.controller.signal.aborted||r(w)?.ended)return()=>{};if([`server`,`titlebar-item`,`composer-pill`,`slot`,`file.viewer`,`menubar-item`].includes(t.id)&&X(`registry.${t.id}`),e.contributions.size>=256)throw Error(`GUI contribution limit exceeded`);let a=()=>{},c,l=s(e=>{a=e,c=n();let r=()=>typeof i==`function`?i():i,o;if(t.id===`yuri.file-icon`){let e=d(()=>{try{return{ok:!0,value:r()}}catch(e){return{ok:!1,error:e}}});o=()=>{let t=e();if(!t.ok)throw t.error;return t.value}}else o=d(r);if(t.id===`style`){let e=document.createElement(`style`);document.head.append(e),h(()=>e.remove()),b(()=>{let t=o();e.textContent=t===void 0?``:String(t)})}return{registry:t.id,read:o}},n()??e.owner);e.contributions.add(l);let u=()=>{t.id===`yuri.file-icon`&&e.iconChanges[1](e=>e+1)};return o(u),o(()=>this.changed()),this.own(e,()=>{$(c,t=>{e.error??=String(t)}),a(),e.contributions.delete(l),o(u),o(()=>this.changed())})},list:e=>this.list(e),provide:(t,n)=>{if(e.controller.signal.aborted||r(w)?.ended)return()=>{};if(t.kind!==`contract`||!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw Error(`Contract must belong to the providing plugin`);let i=this.contract(t.id);if(i.provider)throw Error(`Contract already provided: ${t.id}`);return i.provider=e,i.live[1]({status:`active`,value:n,generation:++i.generation}),this.own(e,()=>{i.provider===e&&(i.provider=void 0,i.live[1]({status:`inactive`,reason:e.status===`failed`?`failed`:`disabled`}))})},use:e=>this.contract(e.id,e.kind===`ipc`).live[0],main:t=>{if(!(t.id===e.id||t.id.startsWith(`${e.id}.`)))throw Error(`IPC must belong to the plugin`);return new Proxy({state:()=>void 0},{get:(e,t)=>t===`state`?e.state:t===`on`?()=>X(`native IPC events`):()=>Promise.reject(Error(`Unsupported GUI host API: native IPC`))})},sessions:{current:this.session[0],list:()=>{let e=this.session[0]();return e?[e]:[]}},screen:{current:()=>this.session[0]()?this.screen:void 0},layout:u,appearance:{mode:()=>this.appearance[0]().mode,font:()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`monospace`},locale:{locale:()=>this.appearance[0]().locale,direction:()=>/^(ar|fa|he|ur)(-|$)/i.test(this.appearance[0]().locale)?`rtl`:`ltr`},system:{copy:e=>navigator.clipboard.writeText(e),openExternal:e=>{let t=new URL(e);[`https:`,`http:`,`mailto:`].includes(t.protocol)||X(`system.openExternal protocol`),window.open(e,`_blank`,`noopener,noreferrer`)},save:async e=>{let t=URL.createObjectURL(new Blob([e.content],{type:`text/plain`}));try{let n=document.createElement(`a`);return n.href=t,n.download=e.name,n.click(),!0}finally{setTimeout(()=>URL.revokeObjectURL(t),0)}}},commands:{run:t=>e.controller.signal.aborted||!this.command(t)?!1:(this.runCommand(t),!0)},links:{open:t=>!e.controller.signal.aborted&&this.navigateLink(e,t),exists:t=>o(()=>{if(e.controller.signal.aborted)return!1;let n=this.linkHandler(t);try{return Promise.resolve(n?.value.exists?.(t)??!1).catch(()=>!1)}catch{return!1}})}})}contract(e,n=!1){let r=this.contracts.get(e);if(!r){if(this.contracts.size>=256)throw Error(`GUI contract limit exceeded`);let n=t({status:`inactive`,reason:`disabled`});r={live:[le(n[0]),n[1]],generation:0},this.contracts.set(e,r)}return n&&r.provider&&X(`IPC contract collision`),r}derive(e){if(e.status!==`active`)return;let t=[],n=[],r=[],i=[],a=this.session[0]();for(let o of e.contributions){if(o.registry===`yuri.file-icon`)continue;let s=o.read();if(s!==void 0){if(o.registry===pe.id){let n=s;n.enabled!==!1&&t.push({key:`${e.id}.${n.id}`,title:n.title,description:n.description,bind:n.bind,hidden:n.hidden,run:()=>this.invoke(e,()=>n.run())})}else if(o.registry===A.id&&a){let t=s,r=`${e.id}:`,i=this.layout(a).open.filter(e=>e.startsWith(r)).map(e=>e.slice(r.length));for(let r of t.list({session:a,screen:this.screen,open:i}))n.push({plugin:e,panel:t,tab:r})}else if(o.registry===C.id){let e=s;(e.page||e.section)&&X(`SettingsPage host sections`),e.title,r.push(e)}else if(o.registry===E.id){let e=s;e.menu===`session.panel`?(e.title,i.push(e)):X(`MenuItem.${e.menu}`)}}}for(let e of n)e.tab.title;e.commands=t,e.panels=n,e.settings=r,e.menus=i,o(()=>this.views[1](e=>e+1))}publish(){let e=o(this.session[0]),t=e?this.layouts.get(e.key):void 0,n=[...this.instances.values()],r=n.filter(e=>e.status===`active`),i=r.flatMap(e=>e.panels.map(({tab:n})=>{let r=n.file?this.filePath(n.file):void 0;return{key:`${e.id}:${n.id}`,pluginId:e.id,title:n.title,file:r,inline:!!(r&&this.fileViews.has(r)),active:t?.shown===!0&&t.active===`${e.id}:${n.id}`}}));this.snapshot=Object.freeze({plugins:Q(n.map(({id:e,revision:t,status:n,error:r,iconError:i})=>({id:e,revision:t,status:n,error:r??i}))),commands:Q(r.flatMap(e=>e.commands.filter(e=>!e.hidden))),panels:Q(i),settings:Q(r.flatMap(e=>e.settings.map(t=>({key:`${e.id}:${t.id}`,pluginId:e.id,title:t.title})))),menuItems:Q(r.flatMap(e=>e.menus.map(t=>({key:`${e.id}:${t.id}`,title:t.title,description:t.description,run:()=>{this.invoke(e,()=>t.run())}})))),activePanel:t?.shown&&i.some(e=>e.key===t.active)?t.active:null,sessionKey:e?.key});for(let e of this.listeners)e()}invoke(t,n){if(!t.controller.signal.aborted)try{let r=e(t.owner??null,n);if(r instanceof Promise)return r.catch(e=>this.fail(t,e))}catch(e){this.fail(t,e)}}command(e){return[...this.instances.values()].flatMap(e=>e.commands).find(t=>t.key===e)}runCommand(e){return this.command(e)?.run()}linkHandler(e){let t=[];for(let e of this.instances.values())for(let n of e.contributions)if(n.registry===ce.id){let r=n.read();r&&t.push({instance:e,value:r})}for(let n of t.sort((e,t)=>(t.value.priority??0)-(e.value.priority??0)))try{if(n.value.match(e))return n}catch(e){this.fail(n.instance,e)}}navigateLink(e,t){if(this.ended)return!1;let n=ie(t.href);if(!n||!re(n.path))return this.openLink(t);let r=this.session[0]();if(!r||t.session&&(t.session.key!==r.key||t.session.server.id!==r.server.id))return!1;if(!this.options.focusFile)return this.openLink(t);let i=te(t.base??r.directory,n.path),a=n.line===void 0?``:`:${n.line}${n.column===void 0?``:`:${n.column}`}`;return this.invoke(e,()=>this.options.focusFile(i+a,r.directory)),!0}openLink(e){if(this.ended)return!1;let t={...e,session:e.session??this.session[0]()},n=this.linkHandler(t);return n?(this.invoke(n.instance,()=>n.value.open(t)),!0):!1}filePath(e,t=this.session[0]()?.directory){let n=z(e);return/^(?:\/|[a-z]:\/)/i.test(n)||!t?n:z(`${t}/${n}`)}registerFileView(e,t){if(this.ended)return()=>{};let n=this.filePath(e,t),r=this.fileViews.get(n)??0;this.fileViews.set(n,r+1),r===0&&(this.changed(),this.publish());let i=!1;return()=>{if(i||this.ended)return;i=!0;let e=(this.fileViews.get(n)??1)-1;if(e){this.fileViews.set(n,e);return}{let e=this.session[0](),t=e&&this.layouts.get(e.key);t?.active&&this.snapshot.panels.some(e=>e.key===t.active&&e.file===n)&&(t.shown=!1),this.fileViews.delete(n)}this.changed(),this.publish()}}filePanel(e,t){let n=this.filePath(e,t);return this.snapshot.panels.find(e=>e.file===n&&e.inline)}panelVisible(e){let t=this.session[0]();if(!t)return!1;let n=this.panel(e)?.tab.file;if(n&&this.fileViews.has(this.filePath(n)))return!0;let r=this.layouts.get(t.key);return!!(r?.shown&&r.active===e)}layout(e){let t=this.layouts.get(e.key);if(!t){if(this.layouts.size>=128)throw Error(`GUI session layout limit exceeded`);t={open:[],active:null,shown:!1,scroll:new Map},this.layouts.set(e.key,t)}return t}openPanel(e,t,n){if(this.ended)return;let r=this.layout(t),i=r.active,a=r.shown,o=r.open.length;if(!r.open.includes(e)){if(r.open.length>=64)throw Error(`GUI panel tab limit exceeded`);r.open=[...r.open,e]}n?.tab!==`append`&&(r.active=e,r.shown=!(this.appearance[0]().narrow&&n?.background)),(i!==r.active||a!==r.shown||o!==r.open.length)&&(this.changed(),this.publish());let s=this.panel(e);t.key===this.session[0]()?.key&&s&&n?.tab!==`append`&&this.invoke(s.plugin,()=>s.panel.focus?.({...this.props(e),restored:!1}))}selectPanel(e){let t=this.session[0]();t&&this.openPanel(e,t)}closeFor(e,t){let n=this.layout(t),r=t.key===this.session[0]()?.key?this.panel(e):void 0;if(!n.open.includes(e)||r?.tab.pinned||r?.tab.closable===!1)return;let i=this.session[0](),a=r&&i?{tab:r.tab,session:i,screen:this.screen}:void 0;n.open=n.open.filter(t=>t!==e),n.active===e&&(n.active=n.open.at(-1)??null),this.changed(),this.publish(),r&&a&&this.invoke(r.plugin,()=>r.panel.close?.(a))}closePanel(e){let t=this.session[0]();t&&this.closeFor(e,t)}hidePanel(){let e=this.session[0]();if(!e)return;let t=this.layout(e);t.shown&&(t.shown=!1,this.changed(),this.publish())}panel(e){return[...this.instances.values()].flatMap(e=>e.panels).find(t=>`${t.plugin.id}:${t.tab.id}`===e)}props(e){let t=this.panel(e)?.tab,n=()=>(this.views[0](),this.panel(e)?.tab??t??X(`panel no longer listed`)),r=()=>this.session[0]()??X(`panel without session`);return{get tab(){return n()},get session(){return r()},screen:this.screen}}mountPanel(e,t){let n=this.panel(e);if(!n)return()=>{};let r=()=>{let t=d(()=>{this.session[0](),this.changes[0](),this.views[0]();let t=this.panel(e)?.tab.file;return t&&this.files&&this.panelVisible(e)?{model:this.files,file:t}:void 0},void 0,{equals:(e,t)=>e?.model===t?.model&&e?.file===t?.file});return b(()=>{let e=t();e&&(h(e.model.watch(e.file)),e.model.sync(e.file).catch(()=>{}))}),o(()=>n.panel.render(this.props(e)))},i=this.mount(n.plugin,t,()=>l(de.Provider,{value:{visible:()=>(this.changes[0](),this.panelVisible(e)),present:()=>(this.changes[0](),this.panelVisible(e)),placement:()=>this.appearance[0]().narrow?`mobile`:`side`,reserve:()=>!1,animate:()=>!1,sidebar:Z(`panel.sidebar`,{}),open:()=>{let e=this.session[0]();return e?n.plugin.context.layout.stored(e):[]}},get children(){return r()}})),a=()=>{this.panelMounts.delete(a),i()};return this.panelMounts.add(a),this.own(n.plugin,a)}mountSettings(e,t){for(let n of this.instances.values()){let r=n.settings.find(t=>`${n.id}:${t.id}`===e);if(r)return this.mount(n,t,()=>r.render({}))}return()=>{}}mount(e,t,r){if(e.controller.signal.aborted)return()=>{};let i=()=>{},a,s=t=>{queueMicrotask(()=>this.fail(e,t))};try{i=oe(()=>l(D.Provider,{value:e.context,get children(){return a=n(),f(()=>o(r),s)}}),t)}catch(t){this.fail(e,t)}return this.own(e,()=>{$(a,t=>{e.error??=String(t)}),i(),t.replaceChildren()})}};export{ye as GuiPluginHost};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-CAZiOV2G.js";import{D as r,O as i,nn as a}from"./persistence-CcGnI3Ek.js";import{t as o}from"./runtimeAPIRegistry-C2VogTny.js";import{a as s,i as c,r as l}from"./vendor-zustand-o69pgTEK.js";import{it as u,rt as d}from"./vendor-base-ui-CdzJ6My_.js";import{B as f,Ct as p,M as m,Mt as h}from"./platform-CxNhofMC.js";import{b as g,n as ee,x as _}from"./useUIStore-NMQx_cnG.js";import{n as v}from"./vendor-react-BP2cRVqX.js";import{s as y}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as b,o as x}from"./queryRuntime-BuRnpVtK.js";import{n as S}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as te,r as C,u as ne}from"./button-4sNruiRJ.js";import{Bt as re,Dr as ie,Pr as ae,S as w,Un as T,Ya as E,cn as oe,ct as se,d as D,do as ce,fo as O,ht as le,lt as ue,ut as de,vn as k,wa as A,y as fe,za as pe}from"./useMobileNavigationStore-Cwk7wARY.js";import{t as me}from"./AgentAvatar-k7s0gPMz.js";import{n as j}from"./Icon-BX4GW-k_.js";import{g as he,v as ge}from"./gitApi-BKjA7Bpe.js";import{f as _e,o as M}from"./projectMeta-DXlpoXd3.js";import{c as ve,d as ye,l as N,n as be,r as xe,t as Se}from"./fileMentionTouchSelection-CRlBHcv1.js";import{n as Ce}from"./textarea-CaGuTnhs.js";var we=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=T([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},Te=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName&&e.agentName===r.agentName}),Ee=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Te(e.rows,t.rows),De=(e,t)=>Te(e,t)?e:t.slice(),Oe=(e,t,n)=>{e&&(t.current&&Ee(t.current,n)||(t.current=n,e(n)))},ke=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},P=e(u(),1),F=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},I=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,L=(e,t)=>{let n=F(t),r=F(e);if(!n||!r)return!1;let i=I(n),a=I(r);return a===i||a.startsWith(`${i}/`)},Ae=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=F(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>F(e)).filter(e=>L(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>F(e)).filter(e=>L(e,t)))):[],s=typeof i.selectedPath==`string`?F(i.selectedPath):null,c=s&&L(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},R=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},z=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},je=s()(l(c((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=F((t||``).trim()),a=F((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:R({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=e=>I(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=I(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=I(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:R({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=F((t||``).trim()),a=n?F(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:R({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=F((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=F((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>F((e||``).trim())).filter(e=>e&&L(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=z(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:g(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Ae(t)}},partialize:e=>({byRoot:Ae(e.byRoot)})}),{name:`files-view-tabs-store`})),B=v(),Me=(e,t)=>{let n=(0,B.c)(4),r=t===void 0?200:t,[i,a]=P.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),P.useEffect(o,s),i},Ne=()=>{let e=(0,B.c)(17),t=D(Pe),n=k(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=w(r),a=D(V),o=D(H),s=O(U),c=O(Fe),l=p(Ie);if(t){let r;e[2]===i?r=e[3]:(r=fe(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function Pe(e){return e.currentSessionId}function V(e){return e.worktreeMetadata}function H(e){return e.newSessionDraft}function U(e){return e.activeProjectId}function Fe(e){return e.projects}function Ie(e){return e.currentDirectory}var W=d(),Le=`bg-transparent font-[inherit] text-[var(--primary-base)]`,G=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,W.jsx)(`mark`,{className:Le,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Re=P.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:a,onSessionSelect:o,onClose:s,style:c,onRowsChange:l},u)=>{let{t:d}=te(),f=Ne()??``,p=D(e=>e.currentSessionId),m=ae(e=>e.activeSessions),g=re({enabled:!!o}),_=O(e=>e.activeProjectId),v=O(e=>e.projects),y=P.useMemo(()=>v.find(e=>e.id===_)?.path??null,[_,v]),b=P.useMemo(()=>{let e=y||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,f]),x=je(e=>b?e.byRoot[b]:void 0),w=A(e=>e.agents),T=h(e=>e.searchFiles),oe=Me(e,180),ce=i(),k=r(),[fe,he]=P.useState([]),[ge,_e]=P.useState(!1),[M,ye]=P.useState(0),N=P.useRef(0),we=P.useRef({query:e,directory:f,ids:[]}),[Te,Ee]=P.useState(360),[De,F]=P.useState({}),[I,L]=P.useState({}),Ae=P.useRef([]),R=P.useRef([]),z=P.useRef([]),B=P.useRef(null),Pe=P.useRef(null),V=P.useRef(null);V.current||=Se();let H=ee(e=>e.isMobile),U=(e??``).trim(),Fe=E({directory:f||null}),Ie=P.useMemo(()=>a?Fe.data??[]:[],[a,Fe.data]),Le=P.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return de(n,U,{limit:6})},[U,b,x]),Re=P.useMemo(()=>n?pe(w).filter(e=>e.mode!==`primary`):[],[w,n]),ze=P.useMemo(()=>o?se({sessions:ie(m,g),currentSessionId:p,searchQuery:U}):[],[m,p,g,U,o]),K=Le,Be=fe,q=P.useMemo(()=>ve({skills:Ie,agents:Re,sessions:ze,recentFiles:K,pathHits:Be,searchQuery:U,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`),skillBadge:d(`chat.commandAutocomplete.badge.skill`)}),[Ie,Re,ze,K,Be,U,d]);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!B.current||B.current.contains(t)||s()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[s]),P.useEffect(()=>{if(!f){he([]);return}let e=(oe??``).trim(),t=le(e);if(!t){he([]);return}let n=!1;_e(!0);let r={includeHidden:ce,respectGitignore:!k};return Promise.all([T(f,t,80,{...r,type:`file`}),T(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Le.map(e=>e.path));he(ue({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||he([])}).finally(()=>{n||_e(!1)}),()=>{n=!0}},[f,oe,Le,T,ce,k]),P.useLayoutEffect(()=>{let t=we.current,n=t.ids[N.current],r=t.query===e&&t.directory===f?Math.max(0,q.findIndex(e=>e.id===n)):0;we.current={query:e,directory:f,ids:q.map(e=>e.id)},N.current=r,ye(r)},[q,e,f]),P.useEffect(()=>{F({}),L({})},[q]),P.useEffect(()=>{Ae.current[M]?.scrollIntoView({block:`nearest`})},[M]),P.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};R.current.forEach((n,r)=>{if(!n)return;let i=z.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),F(e),L(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[q]),P.useEffect(()=>{let e=R.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ee(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let Ve=S(e=>{t(e)}),He=S(e=>{n?.(e)}),Ue=S(e=>{o?.(e)}),We=S(e=>{a?.(e)}),Ge=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&V.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&V.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(V.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>V.current?.pointerCancel(),onClick:()=>{V.current?.click(t)},onMouseMove:()=>{N.current=e,ye(e)}}),J=e=>{let t=q.length;if(t===0)return;let n=(e%t+t)%t,r=q[n];if(r.agentName!==void 0){He(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ie.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&We(e);return}if(r.id.startsWith(`session:`)){let e=ze.find(e=>r.id===`session:${e.id}`);e&&Ue(e);return}let i=r.id.startsWith(`recent:`)?K.find(e=>r.id===`recent:${e.path}`):Be.find(e=>r.id===`file:${e.path}`);i&&Ve(i)};P.useEffect(()=>{Oe(l,Pe,{rows:q,highlightedIndex:M})},[l,M,q]);let Ke=P.useRef(l);return Ke.current=l,P.useEffect(()=>()=>{ke(Ke.current,Pe)},[]),P.useImperativeHandle(u,()=>({acceptIndex:e=>{J(e)},handleKeyDown:e=>{if(e===`Escape`){s();return}let t=q.length;if(t!==0){if(e===`ArrowDown`){N.current=(N.current+1)%t,ye(N.current);return}if(e===`ArrowUp`){N.current=(N.current-1+t)%t,ye(N.current);return}(e===`Enter`||e===`Tab`)&&J(N.current)}}})),(0,W.jsxs)(be,{ref:B,isMobile:H,className:`max-w-[640px] max-h-64`,style:c,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,W.jsxs)(`div`,{className:`py-1`,children:[q.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?ne(e.title,{maxLength:60}):e.title,i=M===t,a=De[t]??!1,o=I[t]??2.6;return(0,W.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{Ae.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,H&&`min-h-11`,xe(H,i),!H&&i&&`text-interactive-selection-foreground`),...Ge(t,()=>J(t)),children:[(0,W.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,W.jsx)(j,{name:e.iconName,className:`size-3.5 text-current`}):(0,W.jsx)(me,{name:e.agentName,size:20})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{ref:e=>{R.current[t]=e},className:`relative block min-w-0 overflow-hidden file-mention-marquee-container`,style:i?{"--file-mention-marquee-width":`${Te}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,W.jsx)(`span`,{ref:e=>{z.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,W.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:G(e.title,U)}):(0,W.jsx)(`span`,{className:`block truncate`,children:G(r,U)})]}),e.subtitle?(0,W.jsx)(`div`,{className:C(`truncate text-muted-foreground`,H?`typography-micro`:`typography-meta`),children:G(e.subtitle,U)}):null]})]},e.id)}),ge&&Be.length===0?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ge&&q.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!H&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),ze=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),K=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&ze.has(n))},Be=(e,t)=>!e||t({name:e}),q=` `,Ve=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===q&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},He=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ue=C(He,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),We=C(He,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),Ge=C(He,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),J=C(He,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Ke=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),qe=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!a()}},Je=P.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=D(e=>e.currentSessionId),p=D(e=>!!e.newSessionDraft?.open),m=D(P.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=oe(f??``,m??void 0),g=P.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=P.useMemo(()=>qe(g,d),[g,d]),b=g.hasMessages,[x,S]=P.useState([]),[ne,re]=P.useState(!1),ie=ce({directory:r}),ae=P.useMemo(()=>ie.data??[],[ie.data]),w=ie.isFetching,[T,E]=P.useState(0),se=P.useRef(0),O=P.useRef(!1),le=P.useRef([]),ue=P.useRef(null),de=P.useRef(!1),k=P.useRef(null),A=P.useRef(!1),fe=P.useRef(null);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!ue.current||ue.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),P.useEffect(()=>{(async()=>{re(w);try{let t=ae.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),n=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...a()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],r=!b,i=we(n.filter(e=>(r||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>Ke(e,i)?e:i)}catch{let t=!b,n=we([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...a()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>Ke(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ae,w,u,o]),P.useEffect(()=>{E(0)},[x]),P.useEffect(()=>{se.current=T},[T]),P.useEffect(()=>{le.current[T]?.scrollIntoView({block:`nearest`})},[T]),P.useEffect(()=>{Oe(c,fe,{rows:N(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[x,c,T,u]);let pe=P.useRef(c);pe.current=c,P.useEffect(()=>()=>{ke(pe.current,fe)},[]),P.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,K(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){O.current=!0,E(e=>(e+1)%r);return}if(e===`ArrowUp`){O.current=!0,E(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(se.current%r+r)%r,i=x[n];i&&t(i,K(i,e===`Enter`))}}}}),[x,n,t]);let me=e=>{let t=ye(e);switch(e.name){case`new`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,W.jsxs)(be,{ref:ue,isMobile:d,className:`max-w-[450px] max-h-64`,style:i,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,W.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,W.jsxs)(`div`,{ref:e=>{le.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,xe(d,r===T),!d&&r===T&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(k.current={x:e.clientX,y:e.clientY},A.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!k.current)return;let t=e.clientX-k.current.x,n=e.clientY-k.current.y;Math.hypot(t,n)>6&&(A.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=A.current;k.current=null,A.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),de.current=!0,t(n,K(n,d)))},onPointerCancel:()=>{k.current=null,A.current=!1},onClick:()=>{if(de.current){de.current=!1;return}t(n,K(n,d))},onMouseMove:()=>{O.current=!1,E(r)},children:[(0,W.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:me(n)}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,G(n.name,e)]}),n.isSkill?(0,W.jsx)(`span`,{className:Ue,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,W.jsx)(`span`,{className:Ue,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,W.jsx)(`span`,{className:J,children:`Yuri`}):i?(0,W.jsx)(`span`,{className:J,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,W.jsx)(`span`,{className:n.scope===`project`?Ge:We,children:n.scope}):null,n.agent&&(0,W.jsx)(`span`,{className:J,children:n.agent})]}),n.description&&!d&&(0,W.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:G(n.description,e)})]})]},n.id)}),x.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Je.displayName=`CommandAutocomplete`;var Ye=2,Xe=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ze=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Qe=e=>Xe(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Xe(e.branches),Y=(e,t)=>JSON.stringify([e,t]),$e=e=>`version`in e&&e.version===Ye&&Xe(e.entries),et=e=>{if(!e)return null;try{let t=JSON.parse(e);return Xe(t)?t.version===Ye&&Xe(t.entries)?{version:Ye,entries:t.entries}:t:null}catch{return null}},tt=(e,t)=>{try{e.setItem(`yuri.gitBranchCache`,JSON.stringify(t))}catch{}},nt=(e,t,n)=>{let r=Ze(e);if(!r||!t)return null;let i;try{i=n.getItem(`yuri.gitBranchCache`)}catch{return null}let a=et(i);if(!a)return null;if($e(a))return Qe(a.entries[Y(t,r)])?a.entries[Y(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Ze(e);r&&Qe(n)&&(o[Y(t,r)]=n)}return tt(n,{version:Ye,entries:o}),o[Y(t,r)]??null},rt=(e,t,n,r)=>{let i=Ze(e);if(!i||!t||!Qe(n))return;let a=null;try{a=r.getItem(`yuri.gitBranchCache`)}catch{return}let o=et(a);tt(r,{version:Ye,entries:{...o&&$e(o)?o.entries:{},[Y(t,i)]:n}})},it=3e4,X=Ze,at=(e,t=n())=>x.git.branches(X(e),t),ot=(e,t=n())=>x.git.remotes(X(e),t),st=async(e,t,n)=>{n.throwIfAborted();let r=o()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),i},ct=async(e,t,n)=>{n.throwIfAborted();let r=o()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await f(e,{signal:n});return n.throwIfAborted(),i},lt=(e,t,r=n(),i=_())=>{let a=X(e),o=t;return{queryKey:at(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await st(a,o,e);return rt(a,r,t,i),t},staleTime:it,gcTime:1/0,initialData:()=>nt(a,r,i)??void 0,initialDataUpdatedAt:0}},ut=(e,t,r=n())=>{let i=X(e),a=t;return{queryKey:ot(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return ct(i,a,e)},staleTime:it,gcTime:1/0}},dt=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=X(e),u=y,l=lt(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},ft=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=X(e),u=y,l=ut(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},pt=(e,t,r=b,i=n())=>r.fetchQuery(lt(e,t,i)),mt=(e,t,r=b,i=n())=>r.fetchQuery({...lt(e,t,i),staleTime:0}),ht=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,gt=1e4,_t=6e4,vt=5e3,yt=3e4,bt=6e4,xt=25,St=40,Ct=2,wt=15e3,Tt=500,Et=30,Dt=20971520,Ot=new Map,kt=new Map,At=new Map,jt=new Map,Mt=new Map,Nt=(e,t)=>`${t}:${e}`,Pt=e=>kt.get(e)??0,Ft=e=>{let t=Pt(e)+1;return kt.set(e,t),t},It=e=>{let t=(At.get(e)??0)+1;return At.set(e,t),t},Lt=e=>{let t=Ot.get(e);if(t)return t;let n=new Set;return Ot.set(e,n),n},Z=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),Rt=(e,t=Et,n=Dt)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},zt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},Bt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Vt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&Bt(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&zt(e.diffStats,t.diffStats))},Ht=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},Ut=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},Wt=e=>!e||e.trim().length===0,Gt=e=>(e||``).trim()===`U`,Kt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Jt=e=>Wt(e.index)&&Wt(e.working_dir),Q=s()(l((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Ft(r),n&&Ft(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=Nt(n,a),s=jt.get(o)??(a===`light`?jt.get(Nt(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>_t,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(Vt(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),s=Ht(i.status,u),l=Ut(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&Ft(n);let h={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();jt.set(o,c);try{return await c}finally{jt.get(o)===c&&jt.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?Kt(e):qt(e);t!==e&&(l=!0),Jt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=It(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await mt(r,i,void 0,o):await pt(r,i,void 0,o);if(s!==At.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(ht(i)||console.error(`Failed to fetch git branches:`,i),s!==At.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Z();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>gt||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Rt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Ft(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,xt);await t().prefetchDiffs(e,n,i,{maxFiles:xt})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=St}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Lt(n),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>Tt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Pt(n);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],ee=()=>{let e=h;return h+=1,e<p.length?p[e]:null},_=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${wt}ms`)),wt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},v=async()=>{for(;;){if(m!==Pt(n))return;let e=ee();if(!e)return;try{g.push(await _(e))}catch{}finally{u.delete(e)}}},y=Math.min(Ct,p.length);if(await Promise.allSettled(Array.from({length:y},()=>v())),p.forEach(e=>u.delete(e)),m!==Pt(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),te=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:te})});let C=Rt(S);b.set(n,{...x,diffCache:C}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<vt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=vt)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=yt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=gt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=bt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Yt=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),Q(n)},Xt=e=>{let r=(0,B.c)(3),i=P.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],Q(a)},Zt=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),Q(n)},Qt=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),Q(n)},$t=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),Q(n)},en=e=>{let t=(0,B.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=P.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),Q(i)},tn=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),Q(n)},nn=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),Q(n)},rn=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),Q(n)},an=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),on=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),sn=async e=>{let t=await _e(e);try{let n=an((await he(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=an((await ge(e)).tracking);if(t?.remote)return t.remote}catch{}return null},cn=async(e,t)=>{let n=await sn(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},ln=async(e,t,n)=>{let r=on(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await cn(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},un=async(e,t,n)=>{let r=await ln(e.path,t,n);return M(e,r)},dn=`yuri:lastWorktreeSourceBranch`,fn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,pn=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},mn=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},hn=(e,t,n)=>{let r=mn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},gn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=hn(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},_n=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},vn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{je as A,ft as C,Re as D,Be as E,Ne as O,dt as S,Ve as T,en as _,dn as a,Qt as b,un as c,$t as d,Xt as f,Zt as g,tn as h,hn as i,De as j,Me as k,sn as l,nn as m,_n as n,pn as o,rn as p,gn as r,fn as s,vn as t,ln as u,Yt as v,Je as w,mt as x,Q as y};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-CAZiOV2G.js";import{D as r,O as i,nn as a}from"./persistence-CcGnI3Ek.js";import{t as o}from"./runtimeAPIRegistry-C2VogTny.js";import{a as s,i as c,r as l}from"./vendor-zustand-o69pgTEK.js";import{it as u,rt as d}from"./vendor-base-ui-CdzJ6My_.js";import{B as f,Ct as p,M as m,Mt as h}from"./platform-CxNhofMC.js";import{b as g,n as ee,x as _}from"./useUIStore-NMQx_cnG.js";import{n as v}from"./vendor-react-BP2cRVqX.js";import{s as y}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as b,o as x}from"./queryRuntime-BuRnpVtK.js";import{n as S}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as te,r as C,u as ne}from"./button-4sNruiRJ.js";import{Bt as re,Dr as ie,Pr as ae,S as w,Un as T,Ya as E,cn as oe,ct as se,d as D,do as ce,fo as O,ht as le,lt as ue,ut as de,vn as k,wa as A,y as fe,za as pe}from"./useMobileNavigationStore-BDW0aRpC.js";import{t as me}from"./AgentAvatar-k7s0gPMz.js";import{n as j}from"./Icon-BX4GW-k_.js";import{g as he,v as ge}from"./gitApi-DL9TCObI.js";import{f as _e,o as M}from"./projectMeta-Bh_8p-5O.js";import{c as ve,d as ye,l as N,n as be,r as xe,t as Se}from"./fileMentionTouchSelection-C5fQjVCV.js";import{n as Ce}from"./textarea-CaGuTnhs.js";var we=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=T([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},Te=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName&&e.agentName===r.agentName}),Ee=(e,t)=>e.highlightedIndex===t.highlightedIndex&&Te(e.rows,t.rows),De=(e,t)=>Te(e,t)?e:t.slice(),Oe=(e,t,n)=>{e&&(t.current&&Ee(t.current,n)||(t.current=n,e(n)))},ke=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},P=e(u(),1),F=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},I=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,L=(e,t)=>{let n=F(t),r=F(e);if(!n||!r)return!1;let i=I(n),a=I(r);return a===i||a.startsWith(`${i}/`)},Ae=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=F(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>F(e)).filter(e=>L(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>F(e)).filter(e=>L(e,t)))):[],s=typeof i.selectedPath==`string`?F(i.selectedPath):null,c=s&&L(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},R=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},z=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},je=s()(l(c((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=F((t||``).trim()),a=F((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:R({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=e=>I(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=I(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:R({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=I(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=I(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:R({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=F((t||``).trim()),a=n?F(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!L(a,i)||e(e=>{let t=e.byRoot[i],n=z(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:R({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=F((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=F((t||``).trim()),i=F((n||``).trim());!r||!i||!L(i,r)||e(e=>{let t=e.byRoot[r],n=z(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=F((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>F((e||``).trim())).filter(e=>e&&L(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=z(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:R({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:g(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:Ae(t)}},partialize:e=>({byRoot:Ae(e.byRoot)})}),{name:`files-view-tabs-store`})),B=v(),Me=(e,t)=>{let n=(0,B.c)(4),r=t===void 0?200:t,[i,a]=P.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),P.useEffect(o,s),i},Ne=()=>{let e=(0,B.c)(17),t=D(Pe),n=k(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=w(r),a=D(V),o=D(H),s=O(U),c=O(Fe),l=p(Ie);if(t){let r;e[2]===i?r=e[3]:(r=fe(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function Pe(e){return e.currentSessionId}function V(e){return e.worktreeMetadata}function H(e){return e.newSessionDraft}function U(e){return e.activeProjectId}function Fe(e){return e.projects}function Ie(e){return e.currentDirectory}var W=d(),Le=`bg-transparent font-[inherit] text-[var(--primary-base)]`,G=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,W.jsx)(`mark`,{className:Le,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Re=P.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:a,onSessionSelect:o,onClose:s,style:c,onRowsChange:l},u)=>{let{t:d}=te(),f=Ne()??``,p=D(e=>e.currentSessionId),m=ae(e=>e.activeSessions),g=re({enabled:!!o}),_=O(e=>e.activeProjectId),v=O(e=>e.projects),y=P.useMemo(()=>v.find(e=>e.id===_)?.path??null,[_,v]),b=P.useMemo(()=>{let e=y||f;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[y,f]),x=je(e=>b?e.byRoot[b]:void 0),w=A(e=>e.agents),T=h(e=>e.searchFiles),oe=Me(e,180),ce=i(),k=r(),[fe,he]=P.useState([]),[ge,_e]=P.useState(!1),[M,ye]=P.useState(0),N=P.useRef(0),we=P.useRef({query:e,directory:f,ids:[]}),[Te,Ee]=P.useState(360),[De,F]=P.useState({}),[I,L]=P.useState({}),Ae=P.useRef([]),R=P.useRef([]),z=P.useRef([]),B=P.useRef(null),Pe=P.useRef(null),V=P.useRef(null);V.current||=Se();let H=ee(e=>e.isMobile),U=(e??``).trim(),Fe=E({directory:f||null}),Ie=P.useMemo(()=>a?Fe.data??[]:[],[a,Fe.data]),Le=P.useMemo(()=>{if(!b||!x)return[];let e=[x.selectedPath,...x.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${b}/`)?e.slice(b.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return de(n,U,{limit:6})},[U,b,x]),Re=P.useMemo(()=>n?pe(w).filter(e=>e.mode!==`primary`):[],[w,n]),ze=P.useMemo(()=>o?se({sessions:ie(m,g),currentSessionId:p,searchQuery:U}):[],[m,p,g,U,o]),K=Le,Be=fe,q=P.useMemo(()=>ve({skills:Ie,agents:Re,sessions:ze,recentFiles:K,pathHits:Be,searchQuery:U,untitledSession:d(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:d(`chat.fileMentionAutocomplete.sessionType`),skillBadge:d(`chat.commandAutocomplete.badge.skill`)}),[Ie,Re,ze,K,Be,U,d]);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!B.current||B.current.contains(t)||s()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[s]),P.useEffect(()=>{if(!f){he([]);return}let e=(oe??``).trim(),t=le(e);if(!t){he([]);return}let n=!1;_e(!0);let r={includeHidden:ce,respectGitignore:!k};return Promise.all([T(f,t,80,{...r,type:`file`}),T(f,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Le.map(e=>e.path));he(ue({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||he([])}).finally(()=>{n||_e(!1)}),()=>{n=!0}},[f,oe,Le,T,ce,k]),P.useLayoutEffect(()=>{let t=we.current,n=t.ids[N.current],r=t.query===e&&t.directory===f?Math.max(0,q.findIndex(e=>e.id===n)):0;we.current={query:e,directory:f,ids:q.map(e=>e.id)},N.current=r,ye(r)},[q,e,f]),P.useEffect(()=>{F({}),L({})},[q]),P.useEffect(()=>{Ae.current[M]?.scrollIntoView({block:`nearest`})},[M]),P.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};R.current.forEach((n,r)=>{if(!n)return;let i=z.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),F(e),L(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[q]),P.useEffect(()=>{let e=R.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&Ee(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let Ve=S(e=>{t(e)}),He=S(e=>{n?.(e)}),Ue=S(e=>{o?.(e)}),We=S(e=>{a?.(e)}),Ge=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&V.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&V.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(V.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>V.current?.pointerCancel(),onClick:()=>{V.current?.click(t)},onMouseMove:()=>{N.current=e,ye(e)}}),J=e=>{let t=q.length;if(t===0)return;let n=(e%t+t)%t,r=q[n];if(r.agentName!==void 0){He(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ie.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&We(e);return}if(r.id.startsWith(`session:`)){let e=ze.find(e=>r.id===`session:${e.id}`);e&&Ue(e);return}let i=r.id.startsWith(`recent:`)?K.find(e=>r.id===`recent:${e.path}`):Be.find(e=>r.id===`file:${e.path}`);i&&Ve(i)};P.useEffect(()=>{Oe(l,Pe,{rows:q,highlightedIndex:M})},[l,M,q]);let Ke=P.useRef(l);return Ke.current=l,P.useEffect(()=>()=>{ke(Ke.current,Pe)},[]),P.useImperativeHandle(u,()=>({acceptIndex:e=>{J(e)},handleKeyDown:e=>{if(e===`Escape`){s();return}let t=q.length;if(t!==0){if(e===`ArrowDown`){N.current=(N.current+1)%t,ye(N.current);return}if(e===`ArrowUp`){N.current=(N.current-1+t)%t,ye(N.current);return}(e===`Enter`||e===`Tab`)&&J(N.current)}}})),(0,W.jsxs)(be,{ref:B,isMobile:H,className:`max-w-[640px] max-h-64`,style:c,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,W.jsxs)(`div`,{className:`py-1`,children:[q.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?ne(e.title,{maxLength:60}):e.title,i=M===t,a=De[t]??!1,o=I[t]??2.6;return(0,W.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{Ae.current[t]=e},className:C(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,H&&`min-h-11`,xe(H,i),!H&&i&&`text-interactive-selection-foreground`),...Ge(t,()=>J(t)),children:[(0,W.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,W.jsx)(j,{name:e.iconName,className:`size-3.5 text-current`}):(0,W.jsx)(me,{name:e.agentName,size:20})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{ref:e=>{R.current[t]=e},className:`relative block min-w-0 overflow-hidden file-mention-marquee-container`,style:i?{"--file-mention-marquee-width":`${Te}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,W.jsx)(`span`,{ref:e=>{z.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,W.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:G(e.title,U)}):(0,W.jsx)(`span`,{className:`block truncate`,children:G(r,U)})]}),e.subtitle?(0,W.jsx)(`div`,{className:C(`truncate text-muted-foreground`,H?`typography-micro`:`typography-meta`),children:G(e.subtitle,U)}):null]})]},e.id)}),ge&&Be.length===0?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ge&&q.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:d(`chat.fileMentionAutocomplete.empty`)})]})}),!H&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:d(`chat.autocomplete.keyboardHint`)})]})}),ze=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`goal`,`btw`]),K=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&ze.has(n))},Be=(e,t)=>!e||t({name:e}),q=` `,Ve=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===q&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},He=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ue=C(He,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),We=C(He,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),Ge=C(He,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),J=C(He,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Ke=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),qe=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!a()}},Je=P.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:i,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=D(e=>e.currentSessionId),p=D(e=>!!e.newSessionDraft?.open),m=D(P.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=oe(f??``,m??void 0),g=P.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v,canUseReviewHandoffFlow:y}=P.useMemo(()=>qe(g,d),[g,d]),b=g.hasMessages,[x,S]=P.useState([]),[ne,re]=P.useState(!1),ie=ce({directory:r}),ae=P.useMemo(()=>ie.data??[],[ie.data]),w=ie.isFetching,[T,E]=P.useState(0),se=P.useRef(0),O=P.useRef(!1),le=P.useRef([]),ue=P.useRef(null),de=P.useRef(!1),k=P.useRef(null),A=P.useRef(!1),fe=P.useRef(null);P.useEffect(()=>{let e=e=>{let t=e.target;!t||!ue.current||ue.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),P.useEffect(()=>{(async()=>{re(w);try{let t=ae.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),n=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...a()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],r=!b,i=we(n.filter(e=>(r||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>Ke(e,i)?e:i)}catch{let t=!b,n=we([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!b?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...a()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...y?[{id:`yuri:handoff-review`,name:`handoff-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.handoffReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:goal`,name:`goal`,source:`yuri`,description:u(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);S(e=>Ke(e,n)?e:n)}finally{re(!1)}})()},[e,b,_,v,y,ae,w,u,o]),P.useEffect(()=>{E(0)},[x]),P.useEffect(()=>{se.current=T},[T]),P.useEffect(()=>{le.current[T]?.scrollIntoView({block:`nearest`})},[T]),P.useEffect(()=>{Oe(c,fe,{rows:N(x,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:T})},[x,c,T,u]);let pe=P.useRef(c);pe.current=c,P.useEffect(()=>()=>{ke(pe.current,fe)},[]),P.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=x[e];r&&t(r,K(r,n))},handleKeyDown:e=>{let r=x.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){O.current=!0,E(e=>(e+1)%r);return}if(e===`ArrowUp`){O.current=!0,E(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(se.current%r+r)%r,i=x[n];i&&t(i,K(i,e===`Enter`))}}}}),[x,n,t]);let me=e=>{let t=ye(e);switch(e.name){case`new`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,W.jsx)(j,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,W.jsxs)(be,{ref:ue,isMobile:d,className:`max-w-[450px] max-h-64`,style:i,children:[(0,W.jsx)(Ce,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,W.jsx)(j,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,W.jsxs)(`div`,{children:[x.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,W.jsxs)(`div`,{ref:e=>{le.current[r]=e},className:C(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,xe(d,r===T),!d&&r===T&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(k.current={x:e.clientX,y:e.clientY},A.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!k.current)return;let t=e.clientX-k.current.x,n=e.clientY-k.current.y;Math.hypot(t,n)>6&&(A.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=A.current;k.current=null,A.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),de.current=!0,t(n,K(n,d)))},onPointerCancel:()=>{k.current=null,A.current=!1},onClick:()=>{if(de.current){de.current=!1;return}t(n,K(n,d))},onMouseMove:()=>{O.current=!1,E(r)},children:[(0,W.jsx)(`div`,{className:C(!d&&`mt-0.5`),children:me(n)}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,G(n.name,e)]}),n.isSkill?(0,W.jsx)(`span`,{className:Ue,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,W.jsx)(`span`,{className:Ue,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,W.jsx)(`span`,{className:J,children:`Yuri`}):i?(0,W.jsx)(`span`,{className:J,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,W.jsx)(`span`,{className:n.scope===`project`?Ge:We,children:n.scope}):null,n.agent&&(0,W.jsx)(`span`,{className:J,children:n.agent})]}),n.description&&!d&&(0,W.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:G(n.description,e)})]})]},n.id)}),x.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,W.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});Je.displayName=`CommandAutocomplete`;var Ye=2,Xe=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ze=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Qe=e=>Xe(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Xe(e.branches),Y=(e,t)=>JSON.stringify([e,t]),$e=e=>`version`in e&&e.version===Ye&&Xe(e.entries),et=e=>{if(!e)return null;try{let t=JSON.parse(e);return Xe(t)?t.version===Ye&&Xe(t.entries)?{version:Ye,entries:t.entries}:t:null}catch{return null}},tt=(e,t)=>{try{e.setItem(`yuri.gitBranchCache`,JSON.stringify(t))}catch{}},nt=(e,t,n)=>{let r=Ze(e);if(!r||!t)return null;let i;try{i=n.getItem(`yuri.gitBranchCache`)}catch{return null}let a=et(i);if(!a)return null;if($e(a))return Qe(a.entries[Y(t,r)])?a.entries[Y(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Ze(e);r&&Qe(n)&&(o[Y(t,r)]=n)}return tt(n,{version:Ye,entries:o}),o[Y(t,r)]??null},rt=(e,t,n,r)=>{let i=Ze(e);if(!i||!t||!Qe(n))return;let a=null;try{a=r.getItem(`yuri.gitBranchCache`)}catch{return}let o=et(a);tt(r,{version:Ye,entries:{...o&&$e(o)?o.entries:{},[Y(t,i)]:n}})},it=3e4,X=Ze,at=(e,t=n())=>x.git.branches(X(e),t),ot=(e,t=n())=>x.git.remotes(X(e),t),st=async(e,t,n)=>{n.throwIfAborted();let r=o()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await m(e,{signal:n});return n.throwIfAborted(),i},ct=async(e,t,n)=>{n.throwIfAborted();let r=o()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await f(e,{signal:n});return n.throwIfAborted(),i},lt=(e,t,r=n(),i=_())=>{let a=X(e),o=t;return{queryKey:at(a,r),queryFn:async({signal:e})=>{if(!a)throw Error(`Git branches require a directory`);let t=await st(a,o,e);return rt(a,r,t,i),t},staleTime:it,gcTime:1/0,initialData:()=>nt(a,r,i)??void 0,initialDataUpdatedAt:0}},ut=(e,t,r=n())=>{let i=X(e),a=t;return{queryKey:ot(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return ct(i,a,e)},staleTime:it,gcTime:1/0}},dt=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=X(e),u=y,l=lt(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},ft=(e,r,i)=>{let a=(0,B.c)(9),o=i===void 0||i,s=P.useSyncExternalStore(t,n,n),c,l,u;a[0]!==e||a[1]!==r||a[2]!==s?(c=X(e),u=y,l=ut(c,r,s),a[0]=e,a[1]=r,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},pt=(e,t,r=b,i=n())=>r.fetchQuery(lt(e,t,i)),mt=(e,t,r=b,i=n())=>r.fetchQuery({...lt(e,t,i),staleTime:0}),ht=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,gt=1e4,_t=6e4,vt=5e3,yt=3e4,bt=6e4,xt=25,St=40,Ct=2,wt=15e3,Tt=500,Et=30,Dt=20971520,Ot=new Map,kt=new Map,At=new Map,jt=new Map,Mt=new Map,Nt=(e,t)=>`${t}:${e}`,Pt=e=>kt.get(e)??0,Ft=e=>{let t=Pt(e)+1;return kt.set(e,t),t},It=e=>{let t=(At.get(e)??0)+1;return At.set(e,t),t},Lt=e=>{let t=Ot.get(e);if(t)return t;let n=new Set;return Ot.set(e,n),n},Z=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),Rt=(e,t=Et,n=Dt)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},zt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},Bt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Vt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&Bt(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&zt(e.diffStats,t.diffStats))},Ht=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},Ut=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},Wt=e=>!e||e.trim().length===0,Gt=e=>(e||``).trim()===`U`,Kt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Jt=e=>Wt(e.index)&&Wt(e.working_dir),Q=s()(l((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&Ft(r),n&&Ft(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=Nt(n,a),s=jt.get(o)??(a===`light`?jt.get(Nt(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>_t,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0);if(Vt(s.status,u)){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),s=Ht(i.status,u),l=Ut(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&Ft(n);let h={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();jt.set(o,c);try{return await c}finally{jt.get(o)===c&&jt.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?Kt(e):qt(e);t!==e&&(l=!0),Jt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=It(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await mt(r,i,void 0,o):await pt(r,i,void 0,o);if(s!==At.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(ht(i)||console.error(`Failed to fetch git branches:`,i),s!==At.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Z();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>gt||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Rt(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{Ft(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,xt);await t().prefetchDiffs(e,n,i,{maxFiles:xt})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=St}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Lt(n),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>Tt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Pt(n);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],ee=()=>{let e=h;return h+=1,e<p.length?p[e]:null},_=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${wt}ms`)),wt)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},v=async()=>{for(;;){if(m!==Pt(n))return;let e=ee();if(!e)return;try{g.push(await _(e))}catch{}finally{u.delete(e)}}},y=Math.min(Ct,p.length);if(await Promise.allSettled(Array.from({length:y},()=>v())),p.forEach(e=>u.delete(e)),m!==Pt(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),te=Date.now();g.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:te})});let C=Rt(S);b.set(n,{...x,diffCache:C}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<vt||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=Mt.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=vt)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=yt)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=gt)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=bt)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Yt=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),Q(n)},Xt=e=>{let r=(0,B.c)(3),i=P.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],Q(a)},Zt=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),Q(n)},Qt=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),Q(n)},$t=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),Q(n)},en=e=>{let t=(0,B.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=P.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),Q(i)},tn=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),Q(n)},nn=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),Q(n)},rn=e=>{let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),Q(n)},an=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),on=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),sn=async e=>{let t=await _e(e);try{let n=an((await he(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=an((await ge(e)).tracking);if(t?.remote)return t.remote}catch{}return null},cn=async(e,t)=>{let n=await sn(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},ln=async(e,t,n)=>{let r=on(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await cn(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},un=async(e,t,n)=>{let r=await ln(e.path,t,n);return M(e,r)},dn=`yuri:lastWorktreeSourceBranch`,fn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,pn=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},mn=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},hn=(e,t,n)=>{let r=mn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},gn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=hn(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},_n=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},vn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{je as A,ft as C,Re as D,Be as E,Ne as O,dt as S,Ve as T,en as _,dn as a,Qt as b,un as c,$t as d,Xt as f,Zt as g,tn as h,hn as i,De as j,Me as k,sn as l,nn as m,_n as n,pn as o,rn as p,gn as r,fn as s,vn as t,ln as u,Yt as v,Je as w,mt as x,Q as y};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-workbox-window-15MWHJyx.js","assets/rolldown-runtime-hePW80VL.js","assets/renderMobileApp-CbU3BLr6.js","assets/runtime-auth-ef9W7A43.js","assets/runtime-switch-CAZiOV2G.js","assets/persistence-CcGnI3Ek.js","assets/runtime-fetch-BAN5Gnnp.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-NMQx_cnG.js","assets/vendor-react-BP2cRVqX.js","assets/queryRuntime-BuRnpVtK.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/platform-CxNhofMC.js","assets/vendor-opencode-client-BcpAhe9I.js","assets/vendor-effect-DXlObQuU.js","assets/runtime-file-resource-yx0xpKe-.js","assets/path-utils-QNmCUIdP.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/capgoAdapter-DCIeVZw_.js","assets/types-eQY4TOgr.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-sonner-ZS8XIOVl.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-4sNruiRJ.js","assets/store-Dy_l1m3m.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/MobileShareBridge-DsEPHal0.js","assets/MobileDetailNavigation-BmVdW83D.js","assets/useMobileNavigationStore-Cwk7wARY.js","assets/useAssistantUIStore-D7JZlg_Q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/Icon-BX4GW-k_.js","assets/AgentAvatar-k7s0gPMz.js","assets/agentColors-DWSbQXy2.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-7lEG-JsF.js","assets/dualLimitLru-D8Sphgua.js","assets/useThemeSystem-8jhE4Zyk.js","assets/dialog-DLc0nKV7.js","assets/rasterizePng-056Poix7.js","assets/gitApi-BKjA7Bpe.js","assets/useAppFontEffects-DOp_gxxk.js","assets/desktopHosts-DNc_ga0E.js","assets/desktopRelayRestore-BWl7Zy8M.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-DXlpoXd3.js","assets/input-BhopRvzu.js","assets/tooltip-Bxj4llmx.js","assets/device-B-trKdcC.js","assets/MobileResizableSheet-THVjYOSA.js","assets/vendor-framer-motion-DsGBcZHB.js","assets/MobileWindowStack-DGLdgoGr.js","assets/textarea-CaGuTnhs.js","assets/OverlayScrollbar-C-Od80p5.js","assets/vendor-dnd-kit-core-5pNnzVdw.js","assets/vendor-dnd-kit-accessibility-COSwgjFs.js","assets/vendor-dnd-kit-sortable-Dm50I0m7.js","assets/speechSettingsQueries-DVKcuOEf.js","assets/dropdown-menu.styles-B-E_v3QZ.js","assets/YuriLogo-DvKVga_x.js","assets/image-loading-ClwkpTt4.js","assets/image-loading-D9Z_BASK.css","assets/sessionChangeSummary-C7Y5e238.js","assets/LoadingImage-DDEN3tpH.js","assets/ImageLoadingPlaceholder-OnlbaJBG.js","assets/sessionChangeSummary-CRYRvpy7.css","assets/fileMentionTouchSelection-CRlBHcv1.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/insertionBoundaries-D_wrLY-Q.js","assets/appThemeRegistry-LtxIx7El.js","assets/MarkdownRenderer-CtlVSzEr.js","assets/useEffectiveDirectory-9Efzl9IZ.js","assets/markdownHeightCache-Ci4Phpkv.js","assets/url-MRa-FtQa.js","assets/toolHelpers-DL452NVK.js","assets/react-BYRXYlGz.js","assets/FadeInOnReveal-DuelAGXz.js","assets/useWorkerHighlightedLines-ClwAu-Q3.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/markdownTheme-DHoKvD6O.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-cmdk-RDxC-9Iz.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-dKp0SH4C.js","assets/vendor-motion-CIQx6DBb.js","assets/useFontPreferences-n13Q1-rH.js","assets/terminalApi-Bs5skvIp.js","assets/MobileTabPageHeader-C3XsN5mD.js","assets/vendor-codemirror-autocomplete-7c2L_4dM.js","assets/vendor-codemirror-lang-angular-DXOgWEVj.js","assets/vendor-codemirror-lang-json-mLulNbwB.js","assets/vendor-codemirror-lang-markdown-CV1IO6Qs.js","assets/vendor-codemirror-lang-python-YM2WVLHF.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/mcpQueries-s9QcLjGw.js","assets/collapsible-BT03pxhm.js","assets/vendor-codemirror-commands-B8KrBQ9B.js","assets/vendor-codemirror-search-ZqtrPLjU.js","assets/vendor-replit-codemirror-vim-DDj0dSVY.js","assets/vendor-codemirror-language-data-Ctd4WxgW.js","assets/projectActions-BX0cjZoq.js","assets/runtimeEndpointReset-BOuzWhtp.js","assets/scheduledTaskNavigation-CE4sIXxf.js","assets/mobileBackNavigation-C6OcBTbS.js","assets/sessionLookup-BscEQpqH.js","assets/readiness-m2mD0fyj.js","assets/vendor-cron-parser-BmO80h0C.js","assets/runtimeEndpointReset-DmY_4gYI.css","assets/SettingsView-cAxZUqrO.js","assets/native-config-DnQvXgu6.js","assets/GuiPluginWindow-BHbqKl7P.js","assets/vendor-yaml-C9KlJAlj.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/AssistantView-8ju42ZTW.js","assets/assistant-attachment-cache-BIxi1vPM.js","assets/renderMobileApp-1G4-5u-t.css","assets/src-CZA3gFyl.css","assets/main-CkA5yk63.js","assets/useDesktopWindowControlsLayout-CPqgnywT.js","assets/diagram-1AdssMXJ.js","assets/vendor-react-drawio-Ck9ZKdNN.js","assets/multirun-cZcReWkT.js","assets/vendor-zumer-snapdom-yq9vlCKr.js","assets/vendor-html-to-image-BDMm2v6d.js","assets/main-qSeeJRW1.css"])))=>i.map(i=>d[i]);
2
- import{n as e,t}from"./runtimeConfig-jHTvOptz.js";import{o as n}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */var r=`true`,i=`false`,a=r===`true`,o=i===`true`;function s(e={}){let{immediate:t=!1,onNeedReload:r,onNeedRefresh:i,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=e,d,f,p,m=async(e=!0)=>{await f,a||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await n(async()=>{let{Workbox:e}=await import(`./vendor-workbox-window-15MWHJyx.js`).then(e=>e.t);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!o)if(a)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(r?r():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(r?r():window.location.reload())}),i?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:t}).then(e=>{l?l(`/sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}window.__YURI_RUNTIME_APIS__=t();var c=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(pointer: coarse)`).matches,l=(()=>{let e=new URLSearchParams(window.location.search).get(`surface`);if(e===`mobile`)return`mobile`;if(e===`desktop`)return`desktop`;let t=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),n=navigator.maxTouchPoints||0;return t>0&&t<=760&&(n>0||c())?`mobile`:`desktop`})();window.__YURI_SURFACE__=l;var u=()=>!(!(`serviceWorker`in navigator)||!window.isSecureContext||window.location.protocol!==`http:`&&window.location.protocol!==`https:`||document.prerendering||String(document.visibilityState)===`prerender`),d=e=>{let t=!1,n=()=>{t||u()&&(t=!0,e())},r=()=>{setTimeout(n,0)};document.readyState===`complete`?r():window.addEventListener(`load`,r,{once:!0}),(document.prerendering||String(document.visibilityState)===`prerender`)&&document.addEventListener(`visibilitychange`,n,{once:!0})},f=()=>{d(()=>{try{s({onRegisterError(e){console.warn(`[PWA] service worker registration skipped:`,e)}})}catch(e){console.warn(`[PWA] service worker registration skipped:`,e)}})},p=`yuri.dev.module-reload`,m=(e,t)=>{console.error(`[yuri] failed to load ${t}:`,e)};l===`mobile`?n(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-CbU3BLr6.js`);return{renderMobileApp:e}},__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137])).then(({renderMobileApp:e})=>{try{sessionStorage.removeItem(p)}catch{}e(window.__YURI_RUNTIME_APIS__??t())}).catch(e=>m(e,`renderMobileApp`)):e().then(()=>n(()=>import(`./main-CkA5yk63.js`),__vite__mapDeps([138,1,3,4,6,5,7,8,9,10,11,12,13,14,15,16,17,62,18,19,20,21,22,23,24,106,26,108,27,28,29,30,31,32,33,34,35,36,38,39,40,41,42,43,44,46,47,37,48,49,50,51,57,58,60,61,63,53,56,52,54,55,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,59,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,107,109,110,111,112,113,114,115,116,117,118,119,120,139,121,122,123,124,125,126,127,140,141,142,143,144,145,137]))).then(()=>{try{sessionStorage.removeItem(p)}catch{}}).catch(e=>m(e,`desktop main`)),f();
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-workbox-window-15MWHJyx.js","assets/rolldown-runtime-hePW80VL.js","assets/renderMobileApp-J5PuS_NT.js","assets/runtime-auth-ef9W7A43.js","assets/runtime-switch-CAZiOV2G.js","assets/persistence-CcGnI3Ek.js","assets/runtime-fetch-BAN5Gnnp.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-NMQx_cnG.js","assets/vendor-react-BP2cRVqX.js","assets/queryRuntime-BuRnpVtK.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/platform-CxNhofMC.js","assets/vendor-opencode-client-BcpAhe9I.js","assets/vendor-effect-DXlObQuU.js","assets/runtime-file-resource-yx0xpKe-.js","assets/path-utils-QNmCUIdP.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/capgoAdapter-ClmWgQsn.js","assets/types-aeu41u0o.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-sonner-ZS8XIOVl.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-4sNruiRJ.js","assets/store-Dy_l1m3m.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/MobileShareBridge-sU74EJ95.js","assets/MobileDetailNavigation-CtYXRw3B.js","assets/useMobileNavigationStore-BDW0aRpC.js","assets/useAssistantUIStore-D7JZlg_Q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/Icon-BX4GW-k_.js","assets/AgentAvatar-k7s0gPMz.js","assets/agentColors-DWSbQXy2.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-7lEG-JsF.js","assets/dualLimitLru-D8Sphgua.js","assets/useThemeSystem-8jhE4Zyk.js","assets/dialog-DLc0nKV7.js","assets/rasterizePng-056Poix7.js","assets/gitApi-DL9TCObI.js","assets/useAppFontEffects-By2DRO_9.js","assets/desktopHosts-DNc_ga0E.js","assets/desktopRelayRestore-BWl7Zy8M.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-Bh_8p-5O.js","assets/input-BhopRvzu.js","assets/tooltip-Bxj4llmx.js","assets/device-B-trKdcC.js","assets/MobileResizableSheet-THVjYOSA.js","assets/vendor-framer-motion-DsGBcZHB.js","assets/MobileWindowStack-DGLdgoGr.js","assets/textarea-CaGuTnhs.js","assets/OverlayScrollbar-C-Od80p5.js","assets/vendor-dnd-kit-core-5pNnzVdw.js","assets/vendor-dnd-kit-accessibility-COSwgjFs.js","assets/vendor-dnd-kit-sortable-Dm50I0m7.js","assets/speechSettingsQueries-CgSGK19J.js","assets/dropdown-menu.styles-B-E_v3QZ.js","assets/YuriLogo-DvKVga_x.js","assets/image-loading-ClwkpTt4.js","assets/image-loading-D9Z_BASK.css","assets/sessionChangeSummary-CUnP0Mge.js","assets/LoadingImage-DDEN3tpH.js","assets/ImageLoadingPlaceholder-OnlbaJBG.js","assets/sessionChangeSummary-CRYRvpy7.css","assets/fileMentionTouchSelection-C5fQjVCV.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/insertionBoundaries-DrjyD1xA.js","assets/appThemeRegistry-q9ZHhYPY.js","assets/MarkdownRenderer-BsZicwlM.js","assets/useEffectiveDirectory-C5E5H7K7.js","assets/markdownHeightCache-Ci4Phpkv.js","assets/url-MRa-FtQa.js","assets/toolHelpers-DL452NVK.js","assets/react-BYRXYlGz.js","assets/FadeInOnReveal-DuelAGXz.js","assets/useWorkerHighlightedLines-5IurZLOp.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/markdownTheme-DHoKvD6O.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-cmdk-RDxC-9Iz.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-dKp0SH4C.js","assets/vendor-motion-CIQx6DBb.js","assets/useFontPreferences-n13Q1-rH.js","assets/terminalApi-Bs5skvIp.js","assets/MobileTabPageHeader-BWhQHf6s.js","assets/vendor-codemirror-autocomplete-7c2L_4dM.js","assets/vendor-codemirror-lang-angular-DXOgWEVj.js","assets/vendor-codemirror-lang-json-mLulNbwB.js","assets/vendor-codemirror-lang-markdown-CV1IO6Qs.js","assets/vendor-codemirror-lang-python-YM2WVLHF.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/mcpQueries-Am1xehao.js","assets/collapsible-BT03pxhm.js","assets/vendor-codemirror-commands-B8KrBQ9B.js","assets/vendor-codemirror-search-ZqtrPLjU.js","assets/vendor-replit-codemirror-vim-DDj0dSVY.js","assets/vendor-codemirror-language-data-Ctd4WxgW.js","assets/projectActions-BX0cjZoq.js","assets/runtimeEndpointReset-DlxONsUh.js","assets/scheduledTaskNavigation-CE4sIXxf.js","assets/mobileBackNavigation-BjN2y4on.js","assets/sessionLookup-EBl9PXiP.js","assets/readiness-6dRSpsKU.js","assets/vendor-cron-parser-BmO80h0C.js","assets/runtimeEndpointReset-DmY_4gYI.css","assets/SettingsView-Dm-Zxoje.js","assets/native-config-6ZcbOTlU.js","assets/GuiPluginWindow-BHbqKl7P.js","assets/vendor-yaml-C9KlJAlj.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/AssistantView-AVEdhX2E.js","assets/assistant-attachment-cache-BIxi1vPM.js","assets/renderMobileApp-1G4-5u-t.css","assets/src-CZA3gFyl.css","assets/main-ClH8U0K_.js","assets/useDesktopWindowControlsLayout-B9xDW29G.js","assets/diagram-1AdssMXJ.js","assets/vendor-react-drawio-Ck9ZKdNN.js","assets/multirun-Dj8jiZnI.js","assets/vendor-zumer-snapdom-yq9vlCKr.js","assets/vendor-html-to-image-BDMm2v6d.js","assets/main-qSeeJRW1.css"])))=>i.map(i=>d[i]);
2
+ import{n as e,t}from"./runtimeConfig-BndFf_Fb.js";import{o as n}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */var r=`true`,i=`false`,a=r===`true`,o=i===`true`;function s(e={}){let{immediate:t=!1,onNeedReload:r,onNeedRefresh:i,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=e,d,f,p,m=async(e=!0)=>{await f,a||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await n(async()=>{let{Workbox:e}=await import(`./vendor-workbox-window-15MWHJyx.js`).then(e=>e.t);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!o)if(a)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(r?r():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(r?r():window.location.reload())}),i?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:t}).then(e=>{l?l(`/sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}window.__YURI_RUNTIME_APIS__=t();var c=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(pointer: coarse)`).matches,l=(()=>{let e=new URLSearchParams(window.location.search).get(`surface`);if(e===`mobile`)return`mobile`;if(e===`desktop`)return`desktop`;let t=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),n=navigator.maxTouchPoints||0;return t>0&&t<=760&&(n>0||c())?`mobile`:`desktop`})();window.__YURI_SURFACE__=l;var u=()=>!(!(`serviceWorker`in navigator)||!window.isSecureContext||window.location.protocol!==`http:`&&window.location.protocol!==`https:`||document.prerendering||String(document.visibilityState)===`prerender`),d=e=>{let t=!1,n=()=>{t||u()&&(t=!0,e())},r=()=>{setTimeout(n,0)};document.readyState===`complete`?r():window.addEventListener(`load`,r,{once:!0}),(document.prerendering||String(document.visibilityState)===`prerender`)&&document.addEventListener(`visibilitychange`,n,{once:!0})},f=()=>{d(()=>{try{s({onRegisterError(e){console.warn(`[PWA] service worker registration skipped:`,e)}})}catch(e){console.warn(`[PWA] service worker registration skipped:`,e)}})},p=`yuri.dev.module-reload`,m=(e,t)=>{console.error(`[yuri] failed to load ${t}:`,e)};l===`mobile`?n(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-J5PuS_NT.js`);return{renderMobileApp:e}},__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137])).then(({renderMobileApp:e})=>{try{sessionStorage.removeItem(p)}catch{}e(window.__YURI_RUNTIME_APIS__??t())}).catch(e=>m(e,`renderMobileApp`)):e().then(()=>n(()=>import(`./main-ClH8U0K_.js`),__vite__mapDeps([138,1,3,4,6,5,7,8,9,10,11,12,13,14,15,16,17,62,18,19,20,21,22,23,24,106,26,108,27,28,29,30,31,32,33,34,35,36,38,39,40,41,42,43,44,46,47,37,48,49,50,51,57,58,60,61,63,53,56,52,54,55,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,59,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,107,109,110,111,112,113,114,115,116,117,118,119,120,139,121,122,123,124,125,126,127,140,141,142,143,144,145,137]))).then(()=>{try{sessionStorage.removeItem(p)}catch{}}).catch(e=>m(e,`desktop main`)),f();