@alwith/module-chat 0.1.30 → 0.1.32

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 (111) hide show
  1. package/dist/activity-host.js +1 -1
  2. package/dist/approval/choice-elicitation-form.js +1 -1
  3. package/dist/approval/permission-view.js +1 -1
  4. package/dist/approval/schema-elicitation-form.js +1 -1
  5. package/dist/approval/url-elicitation-card.js +1 -1
  6. package/dist/chunk-2r04c28x.js +2 -0
  7. package/dist/chunk-32fcg6q4.js +2 -0
  8. package/dist/chunk-47f4a577.js +1 -0
  9. package/dist/chunk-664xazrz.js +1 -0
  10. package/dist/chunk-67ws5eed.js +1 -0
  11. package/dist/{chunk-7471tnsq.js → chunk-6h5760d3.js} +1 -1
  12. package/dist/chunk-6m16qe9q.js +2 -0
  13. package/dist/chunk-71kpqt2g.js +2 -0
  14. package/dist/chunk-8dtcrk6t.js +2 -0
  15. package/dist/chunk-8gv9naya.js +1 -0
  16. package/dist/chunk-8k4z0gfx.js +2 -0
  17. package/dist/{chunk-nvtvm7jc.js → chunk-a5b2tm60.js} +2 -2
  18. package/dist/chunk-bwzjm3g8.js +1 -0
  19. package/dist/chunk-cwp8ct1z.js +2 -0
  20. package/dist/chunk-d0ptk8x8.js +1 -0
  21. package/dist/chunk-dj84q7tx.js +1 -0
  22. package/dist/chunk-e12qaex5.js +2 -0
  23. package/dist/chunk-h96s3j1e.js +2 -0
  24. package/dist/chunk-hfhzy9c2.js +1 -0
  25. package/dist/chunk-jrnjwjft.js +7 -0
  26. package/dist/chunk-naw83wcw.js +2 -0
  27. package/dist/chunk-pqgtv07g.js +2 -0
  28. package/dist/chunk-r5d37dc0.js +1 -0
  29. package/dist/chunk-rq0cpnvn.js +1 -0
  30. package/dist/chunk-ryf0p4v8.js +3 -0
  31. package/dist/chunk-s72dbmv3.js +1 -0
  32. package/dist/chunk-sxjgyvnx.js +1 -0
  33. package/dist/chunk-vk39871j.js +1 -0
  34. package/dist/chunk-wmsdg5fb.js +1 -0
  35. package/dist/chunk-ya0gvswb.js +2 -0
  36. package/dist/chunk-zt7a6b1m.js +1 -0
  37. package/dist/codex/activity-group.js +1 -1
  38. package/dist/codex/assistant-message.js +2 -2
  39. package/dist/codex/async-question-card.js +2 -2
  40. package/dist/codex/edited-files-card.js +1 -1
  41. package/dist/codex/image-view-activity.js +1 -1
  42. package/dist/codex/markdown-renderer.js +5 -5
  43. package/dist/codex/navigation-preview.js +1 -1
  44. package/dist/codex/navigation-rail.js +1 -1
  45. package/dist/codex/patch-view.js +2 -2
  46. package/dist/codex/plan.js +1 -1
  47. package/dist/codex/terminal-output.js +1 -1
  48. package/dist/codex/user-message.js +1 -1
  49. package/dist/codex/virtualized-turn-list.js +1 -1
  50. package/dist/composer/completion-menu.js +3 -3
  51. package/dist/composer/effort-slider.d.ts +1 -1
  52. package/dist/composer/effort-slider.js +1 -1
  53. package/dist/composer/menu-radio.js +1 -1
  54. package/dist/composer/model-select.js +1 -1
  55. package/dist/composer/permission-mode-select.js +1 -1
  56. package/dist/composer/prompt-input-attachments.js +1 -1
  57. package/dist/composer/prompt-input-context.js +1 -1
  58. package/dist/composer/prompt-input-textarea.js +2 -2
  59. package/dist/composer/prompt-input.js +1 -1
  60. package/dist/image-lightbox.js +1 -1
  61. package/dist/image-preview-dialog.js +1 -1
  62. package/dist/lib/group-blocks.js +1 -1
  63. package/dist/lib/stream-style.js +1 -1
  64. package/dist/search/chat-search.js +1 -1
  65. package/dist/search/find-bar.js +1 -1
  66. package/dist/ui/button.js +1 -1
  67. package/dist/ui/card.js +1 -1
  68. package/dist/ui/checkbox.js +1 -1
  69. package/dist/ui/dialog.js +1 -1
  70. package/dist/ui/dropdown-menu.js +1 -1
  71. package/dist/ui/field.js +1 -1
  72. package/dist/ui/hover-card.js +1 -1
  73. package/dist/ui/input-group-textarea.js +1 -1
  74. package/dist/ui/input-group.js +1 -1
  75. package/dist/ui/input.js +1 -1
  76. package/dist/ui/label.js +1 -1
  77. package/dist/ui/radio-group.js +1 -1
  78. package/dist/ui/separator.js +1 -1
  79. package/dist/ui/switch.js +1 -1
  80. package/dist/ui/textarea.js +1 -1
  81. package/dist/ui/tooltip.js +1 -1
  82. package/package.json +1 -1
  83. package/dist/chunk-2kjmc9hg.js +0 -1
  84. package/dist/chunk-2sc7ppw2.js +0 -1
  85. package/dist/chunk-51qk29t6.js +0 -2
  86. package/dist/chunk-5hqv4m75.js +0 -1
  87. package/dist/chunk-67gms74t.js +0 -2
  88. package/dist/chunk-85y9tqsd.js +0 -2
  89. package/dist/chunk-99xmegcw.js +0 -2
  90. package/dist/chunk-9cdspnb1.js +0 -2
  91. package/dist/chunk-ake02dgs.js +0 -1
  92. package/dist/chunk-b5srhd6k.js +0 -1
  93. package/dist/chunk-bbnrzw5x.js +0 -2
  94. package/dist/chunk-bgj6z7z4.js +0 -2
  95. package/dist/chunk-d1xydh51.js +0 -2
  96. package/dist/chunk-h310nm02.js +0 -2
  97. package/dist/chunk-j63t6dxg.js +0 -1
  98. package/dist/chunk-jnx3t913.js +0 -2
  99. package/dist/chunk-pkxfrrwf.js +0 -1
  100. package/dist/chunk-pnncsvbz.js +0 -1
  101. package/dist/chunk-q00ycy4m.js +0 -7
  102. package/dist/chunk-qf9n7v84.js +0 -1
  103. package/dist/chunk-r9k7kszp.js +0 -1
  104. package/dist/chunk-rka1mc9r.js +0 -1
  105. package/dist/chunk-s4w6yjc0.js +0 -1
  106. package/dist/chunk-t83jwyey.js +0 -1
  107. package/dist/chunk-twww750f.js +0 -2
  108. package/dist/chunk-x6jyxw9c.js +0 -1
  109. package/dist/chunk-xc6fz2xk.js +0 -3
  110. package/dist/chunk-xgy0heva.js +0 -1
  111. package/dist/chunk-ytqka33j.js +0 -2
@@ -1,6 +1,6 @@
1
- import{ke}from"../chunk-kew8ef6z.js";import{K,we}from"../chunk-tm40sncc.js";import{W}from"../chunk-aaybyhdj.js";import{decodeHTMLAttribute as T,decodeHTMLStrict as E}from"entities";import ae from"katex";import{CheckIcon as U,ChevronLeftIcon as se,ChevronRightIcon as ie,CopyIcon as ce,DownloadIcon as de,FileIcon as le,LinkIcon as ue,MailIcon as me,XIcon as ge}from"lucide-react";import"katex/dist/katex.min.css";import{createContext as fe,createElement as B,memo as D,startTransition as he,useContext as pe,useEffect as h,useLayoutEffect as X,useMemo as G,useRef as p,useState as f}from"react";import{jsxDEV as a,Fragment as re}from"react/jsx-dev-runtime";var J=fe(null);function v(){let e=pe(J);if(e===null)throw Error("Markdown host is missing");return e}var be=80,F=/\[([^\]\n]+)\]\(([^)\n]+)$/,xe=/(^|\n)[^\S\n]*!\[[^\]\n]*(?:\](?:\([^\n]*)?)?\s*$/,Te=/\uE200[^\uE201]*$/,ve=4,Ce=new Set("7zipx.accdb.asarpack.asciidoc.backup.backupdb.bundle.ccproj.cdrdao.code-workspace.config.debugin.deploy.design.docbook.dockerfile.dockerignore.editorconfig.eslintignore.gitattributes.gitignore.gitignore.gitkeep.gradle.graphqls.ignore.ipynb.keychain.keynote.licensee.lockfile.lockfile.markdown.markup.matlab.mkdocs.models.module.msstyle.notebook.npmignore.output.packageinfo.parquet.pickle.plistx.policy.postcssrc.prettierignore.projectfile.python.readme.review.robots.schema.search.series.settingsjson.shader.sqlite.sqlite3.storyboard.styles.system.target.terraform.update.vertex.webapp.webdoc.webpackrc.widget.workspace.xcodeproj.yarnlock".split("."));function C(e,n){let t=0;for(let r=n-1;r>=0&&e[r]==="\\";r-=1)t+=1;return t%2===1}function V(e,n,t){if(t.length!==1)return!1;return e[n-1]===t||e[n+1]===t}function ye(e,n){let t=0;for(let r=0;r<=e.length-n.length;){if(e.startsWith(n,r)&&!C(e,r)&&!V(e,r,n)){t+=1,r+=n.length;continue}r+=1}return t}function Ne(e,n){for(let t=e.length-n.length;t>=0;t-=1)if(e.startsWith(n,t)&&!C(e,t)&&!V(e,t,n))return t;return-1}function Me(e,n){let t=0;for(let r=0;r<=e.length-n.length;){if(e.startsWith(n,r)&&!C(e,r)){t+=1,r+=n.length;continue}r+=1}return t}function Le(e){return Me(e,"```")%2===1}function Z(e){let n=0;for(let t=0;t<e.length;){if(e.startsWith("```",t)){for(t+=3;t<e.length&&!e.startsWith("```",t);)t+=1;if(t<e.length)t+=3;continue}if(e[t]==="`"&&!C(e,t))n+=1;t+=1}return n%2===1}function Ee(e){return e.endsWith(`
1
+ import{ke}from"../chunk-kew8ef6z.js";import{K,we}from"../chunk-tm40sncc.js";import{W}from"../chunk-aaybyhdj.js";import{decodeHTMLAttribute as v,decodeHTMLStrict as I}from"entities";import se from"katex";import{CheckIcon as B,ChevronLeftIcon as ie,ChevronRightIcon as ce,CopyIcon as de,DownloadIcon as le,FileIcon as ue,LinkIcon as me,MailIcon as ge,XIcon as fe}from"lucide-react";import"katex/dist/katex.min.css";import{createContext as he,createElement as D,memo as X,startTransition as pe,useContext as be,useEffect as p,useLayoutEffect as G,useMemo as J,useRef as k,useState as h}from"react";import{jsx as a,jsxs as g,Fragment as oe}from"react/jsx-runtime";var V=he(null);function C(){let e=be(V);if(e===null)throw Error("Markdown host is missing");return e}var xe=80,A=/\[([^\]\n]+)\]\(([^)\n]+)$/,Te=/(^|\n)[^\S\n]*!\[[^\]\n]*(?:\](?:\([^\n]*)?)?\s*$/,ve=/\uE200[^\uE201]*$/,Ce=4,ye=new Set("7zipx.accdb.asarpack.asciidoc.backup.backupdb.bundle.ccproj.cdrdao.code-workspace.config.debugin.deploy.design.docbook.dockerfile.dockerignore.editorconfig.eslintignore.gitattributes.gitignore.gitignore.gitkeep.gradle.graphqls.ignore.ipynb.keychain.keynote.licensee.lockfile.lockfile.markdown.markup.matlab.mkdocs.models.module.msstyle.notebook.npmignore.output.packageinfo.parquet.pickle.plistx.policy.postcssrc.prettierignore.projectfile.python.readme.review.robots.schema.search.series.settingsjson.shader.sqlite.sqlite3.storyboard.styles.system.target.terraform.update.vertex.webapp.webdoc.webpackrc.widget.workspace.xcodeproj.yarnlock".split("."));function y(e,n){let t=0;for(let r=n-1;r>=0&&e[r]==="\\";r-=1)t+=1;return t%2===1}function Z(e,n,t){if(t.length!==1)return!1;return e[n-1]===t||e[n+1]===t}function Ne(e,n){let t=0;for(let r=0;r<=e.length-n.length;){if(e.startsWith(n,r)&&!y(e,r)&&!Z(e,r,n)){t+=1,r+=n.length;continue}r+=1}return t}function Me(e,n){for(let t=e.length-n.length;t>=0;t-=1)if(e.startsWith(n,t)&&!y(e,t)&&!Z(e,t,n))return t;return-1}function Le(e,n){let t=0;for(let r=0;r<=e.length-n.length;){if(e.startsWith(n,r)&&!y(e,r)){t+=1,r+=n.length;continue}r+=1}return t}function Ee(e){return Le(e,"```")%2===1}function Y(e){let n=0;for(let t=0;t<e.length;){if(e.startsWith("```",t)){for(t+=3;t<e.length&&!e.startsWith("```",t);)t+=1;if(t<e.length)t+=3;continue}if(e[t]==="`"&&!y(e,t))n+=1;t+=1}return n%2===1}function Ie(e){return e.endsWith(`
2
2
  `)?`${e}\`\`\``:`${e}
3
- \`\`\``}function A(e,n){if(!e.includes(n)||ye(e,n)%2===0)return e;let t=Ne(e,n);if(t<0)return e;let r=e.slice(t+n.length);if(r.length===0||/^\s/.test(r)||r.includes(`
4
- `)||Z(r))return e;return`${e}${n}`}function Ie(e){return e.startsWith("/")&&!e.startsWith("//")||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\]+\\[^\\]+/.test(e)||/^\/\/[^/]+\/[^/]+/.test(e)}function Y(e){let n=e.replaceAll("`","").trim(),t=n.match(/^(.*?):(\d+)(?::(\d+))?(?:[-–](\d+)(?::(\d+))?)?$/);if(t!==null){let[,o,s,i,c,d]=t;if(o===void 0||s===void 0)throw Error("Codex file location is incomplete");return{path:o,line:Number.parseInt(s,10),column:i===void 0?void 0:Number.parseInt(i,10),endLine:c===void 0?void 0:Number.parseInt(c,10),endColumn:d===void 0?void 0:Number.parseInt(d,10)}}let r=n.match(/^(.*?)#L(\d+)(?:C(\d+))?(?:-L(\d+)(?:C(\d+))?)?$/);if(r!==null){let[,o,s,i,c,d]=r;if(o===void 0||s===void 0)throw Error("Codex hash file location is incomplete");return{path:o,line:Number.parseInt(s,10),column:i===void 0?void 0:Number.parseInt(i,10),endLine:c===void 0?void 0:Number.parseInt(c,10),endColumn:d===void 0?void 0:Number.parseInt(d,10)}}return{path:n}}function $e(e){let{path:n,line:t,column:r,endLine:o,endColumn:s}=Y(e);if(/^[a-z][a-z0-9+.-]*:\/\//i.test(n)||/^www\./i.test(n)||/^(mailto|tel):/i.test(n))return!1;if(t!==void 0||r!==void 0||o!==void 0||s!==void 0)return!0;if(!/(?:^|[\\/])[^\\/]+\.(?!\d+$)[^\\/.]+$/i.test(n))return!1;let i=/[\\/]/.test(n),c=n.split(/[\\/]/).at(-1);if(c===void 0)throw Error("Codex streaming link target has no file name");let d=c.split(".").at(-1);if(d===void 0||d.length===0)return!1;if(!i&&/[a-z]/.test(d)&&/[A-Z]/.test(d.slice(1)))return!1;if(!i){let u=d.toLowerCase();if(u.length>ve&&!Ce.has(u))return!1}return!0}function Re(e){let{path:n}=Y(e);if(Ie(n))return!0;try{return new URL(n).protocol==="file:"}catch{return!1}}function Pe(e){let n=e.match(F);if(n===null)return e;let t=n[2];if(t===void 0)throw Error("Codex streaming link target is missing");return $e(t)||Re(t)?e.replace(F,"$1"):`${e})`}function Se(e){let n=e.replace(Te,"");if(n.length===0||n.includes("`")&&Z(n))return{isCodeFenceOpen:!1,markdown:n};if(n.includes("```")&&Le(n))return{isCodeFenceOpen:!0,markdown:Ee(n)};if(n.includes("!["))n=n.replace(xe,(t,r)=>r);if(n.includes("]("))n=Pe(n);return n=A(n,"**"),n=A(n,"*"),{isCodeFenceOpen:!1,markdown:n}}function Fe(e){return e?.type==="paragraph"&&"tokens"in e&&Array.isArray(e.tokens)}function H(e){return Fe(e)&&e.tokens.length===1&&e.tokens[0]?.type==="image"}function Q(e){for(let n=0;n<e.length;n+=1){let t=e[n];if(t===void 0)throw Error(`Codex Markdown token is missing at index ${n}`);if("tokens"in t&&Array.isArray(t.tokens))Q(t.tokens);if(!H(t))continue;let r=[...t.tokens],o=n+1,s=o;for(;;){while(e[o]?.type==="space")o+=1;let i=e[o];if(!H(i))break;r.push(...i.tokens),o+=1,s=o}if(s===n+1)continue;t.tokens=r,t.text=r.map((i)=>i.raw).join(`
5
- `),t.raw=e.slice(n,s).map((i)=>i.raw).join(""),e.splice(n+1,s-n-1)}}function _(e){return{type:"text",raw:e,text:e}}function Ae(e){return{type:"paragraph",raw:e.raw,text:e.text,tokens:e.tokens??[e]}}function L(e){for(let n of e){if(n.type==="list")for(let t of n.items){let r=t.tokens[0];if(r?.type==="heading"){let o=r,s=o.raw.trimEnd(),i=s.match(/^#{1,6}\s+/)?.[0];if(i!==void 0)t.tokens[0]={type:"paragraph",raw:o.raw,text:s,tokens:o.tokens===void 0?[_(s)]:[_(i),...o.tokens]}}if(t.loose)t.tokens=t.tokens.map((o)=>o.type==="text"?Ae(o):o);L(t.tokens)}if("tokens"in n&&Array.isArray(n.tokens))L(n.tokens)}}function He(e,n,t){e.preventDefault(),e.stopPropagation(),t.openLink(n)}function _e(e){try{let n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?null:`${n.origin}/favicon.ico`}catch{return null}}function Oe(e){let n=_e(e);return n===null?[]:[n,`https://www.google.com/s2/favicons?domain=${new URL(e).origin}&sz=32`]}function je({href:e}){let n=G(()=>Oe(e),[e]),[t,r]=f(),o=n.length===0&&!/^[a-z][a-z0-9+.-]*:/i.test(e),s=e.toLowerCase().startsWith("mailto:")?me:o?le:ue;return a("span",{className:"codex-markdown-favicon",children:[t===void 0?a("span",{className:"codex-markdown-favicon-fallback",children:a(s,{"aria-hidden":!0},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,n.map((i)=>a("img",{alt:"",className:t===i?"codex-markdown-favicon-image-loaded":void 0,decoding:"async",draggable:!1,referrerPolicy:"no-referrer",src:i,onLoad:()=>r((c)=>c!==void 0&&n.includes(c)?c:i)},i,!1,void 0,this))]},void 0,!0,void 0,this)}function We({children:e,href:n,title:t}){let r=v();if(r.preview)return a("span",{children:e},void 0,!1,void 0,this);return a("a",{className:"codex-markdown-link","data-inline-mention-interactive":"",href:n,title:t,onClick:(o)=>He(o,n,r),children:a("span",{className:"codex-markdown-link-mention","data-layout":"inline-flow","data-interactive":"","data-underline-on-hover":"",children:[a("span",{className:"codex-markdown-link-icon-container","data-markdown-copy":"exclude",children:a(je,{href:n},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("span",{className:"codex-markdown-link-label",children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function qe({code:e,language:n}){let{theme:t,copyLabel:r}=v(),o=p(null),[s,i]=f(null),[c,d]=f(null),[u,k]=f(!1);if(h(()=>{let g=ke(i,d);return o.current=g,()=>{g.dispose(),o.current=null}},[]),h(()=>{let g=o.current;if(g===null)throw Error("Code highlighter is not mounted");g.update(e,n)},[e,n]),c!==null)throw c;let b=s!==null&&s.code===e&&s.language===n?s.html:null;return a("div",{className:"codex-markdown-code-block","data-markdown-copy":"code-block","data-markdown-copy-text":e,"data-theme":t==="dark"?"dark":"light",children:[a("div",{className:"codex-markdown-code-header","data-markdown-copy":"exclude",children:[a("div",{className:"codex-markdown-code-title",children:n},void 0,!1,void 0,this),a("div",{className:"codex-markdown-code-actions",children:a("button",{type:"button",className:"codex-markdown-code-copy",title:r,onClick:()=>{navigator.clipboard.writeText(e),k(!0),window.setTimeout(()=>k(!1),2000)},children:u?a(U,{},void 0,!1,void 0,this):a(ce,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a("div",{className:"codex-markdown-code-container",dir:"ltr",children:a("code",{className:"codex-markdown-code-content hljs",...b===null?{children:e}:{dangerouslySetInnerHTML:{__html:b}}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ke({code:e,language:n}){return v().preview?a("span",{children:e},void 0,!1,void 0,this):a(ze,{code:e,language:n},void 0,!1,void 0,this)}function ze({code:e,language:n}){let t=p(null),[r,o]=f(!1);if(h(()=>{if(r)return;let s=t.current;if(s===null)throw Error("Codex code block placeholder is not mounted");if(typeof IntersectionObserver>"u"){let c=window.setTimeout(()=>o(!0),0);return()=>window.clearTimeout(c)}let i=new IntersectionObserver((c)=>{if(!c.some((d)=>d.isIntersecting))return;o(!0),i.disconnect()},{rootMargin:"600px 0px"});return i.observe(s),()=>i.disconnect()},[r]),r)return a(qe,{code:e,language:n},void 0,!1,void 0,this);return a("div",{ref:t,className:"codex-markdown-code-block",children:a("pre",{className:"codex-markdown-code-placeholder",children:a("code",{children:e},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Ue(e){let n=[...document.body.querySelectorAll('[data-markdown-image-preview-trigger="true"]')],t=n.map((o)=>{let s=o.querySelector("img");if(s===null)throw Error("Codex image preview trigger has no image");return{src:s.currentSrc||s.src,alt:s.alt}}),r=n.indexOf(e);if(r===-1)throw Error("Codex image preview trigger is outside the document");return{images:t,index:r}}function Be({preview:e,setPreview:n}){let t=e.images[e.index];if(t===void 0)throw Error(`Codex image preview index is out of range: ${e.index}`);return a("div",{className:"codex-markdown-image-preview",children:[a("img",{src:t.src,alt:t.alt},void 0,!1,void 0,this),a("div",{className:"codex-markdown-image-preview-actions",children:[a("button",{type:"button","aria-label":"Previous image",disabled:e.index===0,onClick:()=>n({...e,index:e.index-1}),children:a(se,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("a",{href:t.src,download:!0,"aria-label":"Download image",children:a(de,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("button",{type:"button","aria-label":"Next image",disabled:e.index===e.images.length-1,onClick:()=>n({...e,index:e.index+1}),children:a(ie,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("button",{type:"button","aria-label":"Close image preview",onClick:()=>n(void 0),children:a(ge,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function De(e){return v().preview?a(re,{children:e.alt},void 0,!1,void 0,this):a(Xe,{...e},void 0,!1,void 0,this)}function Xe({src:e,alt:n,title:t,allowWide:r}){let o=p(null),[s,i]=f();h(()=>{let d=o.current;if(d===null)throw Error("Codex image preview dialog is not mounted");if(s===void 0){if(d.open)d.close();return}if(!d.open)d.showModal()},[s]);let c=n.length===0?"Open image preview":n;return a(re,{children:[a("button",{type:"button",className:`codex-markdown-image-trigger${r?"codex-markdown-image-trigger-wide":""}`,"aria-label":c,"data-markdown-image-preview-trigger":"true",onClick:(d)=>i(Ue(d.currentTarget)),children:a("img",{className:`codex-markdown-image${r?"codex-markdown-image-wide":""}`,src:e,alt:n,title:t,loading:"lazy"},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("dialog",{ref:o,className:"codex-markdown-image-dialog","aria-label":c,onClose:()=>i(void 0),children:s===void 0?null:a(Be,{preview:s,setPreview:i},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ge({value:e,display:n}){let t=p(null);return X(()=>{if(t.current===null)throw Error("Codex math root is not mounted");ae.render(e,t.current,{displayMode:n,throwOnError:!1})},[n,e]),a("span",{ref:t,className:n?"codex-markdown-math-block":"codex-markdown-inline-math"},void 0,!1,void 0,this)}var Je=150,x=null;function O(e,n){let t=x;if(t===null)return e;let r=t.cursor,o=r+e.length;t.cursor=o;let s=[],i=r;for(let c of t.runs){if(c.end<=r)continue;if(c.start>=o)break;let d=Math.max(r,c.start),u=Math.min(o,c.end);if(i<d)s.push(e.slice(i-r,d-r));s.push(a("span",{className:"codex-markdown-fade",children:e.slice(d-r,u-r)},`${n}:${t.generation}:${c.start}`,!1,void 0,this)),i=u}if(i<o)s.push(e.slice(i-r));return s}function ee(e){let n=5381;for(let t=0;t<e.length;t+=1)n=(n*33+e.charCodeAt(t))%4294967296;return n.toString(36)}function j(e){let n=e.trim();if(n.length===0)return"";let t=n.split(`
6
- `,1)[0];if(t===void 0)throw Error("Codex Markdown token has no first line");return(t.match(/\S+/)?.[0]??t).slice(0,be)}function Ve(e){switch(e.type){case"code":return e.raw.trimStart().match(/^(```|~~~)/)?.[1]??"";case"link":return e.href;case"image":{let n=e;return`${n.href}:${j(n.text)}`}case"html":case"space":case"br":case"hr":case"def":return e.raw;case"math":return j(e.text);default:return""}}function ne(e){return`${e.type==="math"?`math-${e.display?"block":"inline"}`:e.type}-${ee(Ve(e))}`}function m(e,n){let t=new Map;return e.map((r)=>{let o=ne(r),s=t.get(o)??0;return t.set(o,s+1),te(r,`${n}-${o}-${s}`)})}function Ze(e,n){let t=e.task?e.tokens.filter((r)=>r.type!=="checkbox"):e.tokens;return a("li",{className:`codex-markdown-list-item${e.task?"codex-markdown-task-list-item":""}`,children:[e.task?a("div",{className:"codex-markdown-task-checkbox",children:[a("input",{type:"checkbox",className:"codex-markdown-checkbox",checked:e.checked,"data-state":e.checked?"checked":"unchecked",readOnly:!0,disabled:!0},void 0,!1,void 0,this),e.checked?a(U,{},void 0,!1,void 0,this):null]},void 0,!0,void 0,this):null,m(t,n)]},n,!0,void 0,this)}function Ye(e,n){let r=`codex-markdown-list ${e.items.some((s)=>s.task)?"codex-markdown-task-list":e.ordered?"codex-markdown-ordered-list":"codex-markdown-unordered-list"}`,o=m(e.items,n);return e.ordered?a("ol",{className:r,start:e.start===""?void 0:e.start,children:o},n,!1,void 0,this):a("ul",{className:r,children:o},n,!1,void 0,this)}function q(e,n,t){let r=t?"th":"td",o=/^\d+$/.test(e.text);return B(r,{key:n,className:`${t?"codex-markdown-table-header":"codex-markdown-table-cell"}${o?" codex-markdown-numeric-table-cell":""}`,align:e.align??void 0},...m(e.tokens,n))}function Qe(e,n){let t=new Map;return a("div",{className:"codex-markdown-table-container","data-markdown-table":!0,tabIndex:-1,children:a("div",{className:"codex-markdown-table-scroller",children:a("div",{className:"codex-markdown-table-wrapper",children:a("table",{className:"codex-markdown-table",children:[a("thead",{children:a("tr",{className:"codex-markdown-table-row",children:e.header.map((r,o)=>q(r,`${n}-header-${o}`,!0))},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("tbody",{className:"codex-markdown-table-body",children:e.rows.map((r)=>{let o=ee(r.map((c)=>c.text).join("\x00")),s=t.get(o)??0;t.set(o,s+1);let i=`${n}-row-${o}-${s}`;return a("tr",{className:"codex-markdown-table-row",children:r.map((c,d)=>q(c,`${i}-cell-${d}`,!1))},i,!1,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},n,!1,void 0,this)}function z(e,n,t){let r=T(e.href);if(!W(r))return null;return a(De,{src:r,alt:E(e.text),title:e.title==null?void 0:T(e.title),allowWide:t},n,!1,void 0,this)}function te(e,n){switch(e.type){case"space":case"def":case"internalMessage":return null;case"hr":return a("hr",{className:"codex-markdown-horizontal-rule"},n,!1,void 0,this);case"heading":{let t=e,o={1:"h1",2:"h2",3:"h3",4:"h4",5:"h5",6:"h6"}[t.depth];if(o===void 0)throw Error(`Unsupported Codex Markdown heading depth: ${t.depth}`);return B(o,{key:n,className:`codex-markdown-heading codex-markdown-heading-${t.depth}`},...m(t.tokens,n))}case"paragraph":{let t=e,r=t.tokens.filter((i)=>i.type!=="space"&&i.type!=="br"),o=r.length>0&&r.every((i)=>i.type==="image"),s=o&&r.length>1;return a("p",{className:`codex-markdown-paragraph${o?"codex-markdown-media-paragraph codex-markdown-media-wide-block":""}${s?"codex-markdown-media-grid-paragraph":""}`,"data-markdown-image-grid":s?"true":void 0,"data-wide-markdown-block":o?"true":void 0,"data-wide-markdown-block-kind":o?"image":void 0,children:o?r.map((i,c)=>z(i,`${n}-image-${c}`,!0)):m(t.tokens,n)},n,!1,void 0,this)}case"text":{let t=e;return t.tokens===void 0?O(E(t.text),n):m(t.tokens,n)}case"escape":return O(e.text,n);case"strong":return a("strong",{className:"codex-markdown-strong",children:m(e.tokens,n)},n,!1,void 0,this);case"em":return a("em",{children:m(e.tokens,n)},n,!1,void 0,this);case"del":return a("del",{children:m(e.tokens,n)},n,!1,void 0,this);case"codespan":return a("span",{className:"codex-markdown-inline-code",dir:"ltr","data-markdown-copy":"inline-code",children:e.text},n,!1,void 0,this);case"br":return a("br",{},n,!1,void 0,this);case"link":{let t=e,r=m(t.tokens,n),o=T(t.href);return W(o)?a(We,{href:o,title:t.title==null?void 0:T(t.title),children:r},n,!1,void 0,this):a("span",{children:r},n,!1,void 0,this)}case"image":return z(e,n,!1);case"code":{let t=e;return a(Ke,{code:t.text,language:t.lang},n,!1,void 0,this)}case"blockquote":return a("blockquote",{className:"codex-markdown-blockquote",children:m(e.tokens,n)},n,!1,void 0,this);case"list":return Ye(e,n);case"list_item":return Ze(e,n);case"table":return Qe(e,n);case"html":{let t=e;return/^<br\s*\/?>$/i.test(t.raw.trim())?a("br",{},n,!1,void 0,this):t.raw}case"math":{let t=e;return a(Ge,{value:t.text,display:t.display},n,!1,void 0,this)}default:throw Error(`Unsupported Codex Markdown token: ${JSON.stringify(e)}`)}}function w(e){switch(e.type){case"text":{let n=e;return n.tokens===void 0?E(n.text):n.tokens.map(w).join("")}case"escape":return e.text;case"paragraph":case"heading":case"strong":case"em":case"del":case"link":case"blockquote":case"list_item":return e.tokens.map(w).join("");case"list":return e.items.map(w).join("");case"table":{let n=e;return[n.header,...n.rows].map((t)=>t.map((r)=>r.tokens.map(w).join("")).join("")).join("")}default:return""}}function en({token:e,tokenKey:n,offset:t,runs:r,generation:o}){let s=x;try{return x={cursor:t,runs:r,generation:o},te(e,n)}finally{x=s}}var nn=D(function({result:n}){let{text:t,isStreaming:r}=n,o=G(()=>{let l=n.tokens;if(n.source.includes("!["))Q(l);L(l);let I=new Map,R=0;return l.map((N)=>{let M=ne(N),P=I.get(M)??0;I.set(M,P+1);let S=w(N),oe={token:N,tokenKey:`root-${M}-${P}`,offset:R,visibleText:S};return R+=S.length,oe})},[n]),s=o.map((l)=>l.visibleText).join(""),i=p({text:"",visibleText:"",runs:[],generation:0}),c=i.current,d=t.startsWith(c.text)||s.startsWith(c.visibleText),u=d?c.visibleText.length:0,k=performance.now(),b=r&&d?c.runs.filter((l)=>k-l.firstSeenAtMs<Je):[],y=c.generation+(d?0:1),g={text:t,visibleText:s,runs:b.filter((l)=>l.start<s.length).map((l)=>({...l,end:Math.min(l.end,s.length)})),generation:y};if(r&&s.length>u)g.runs.push({start:u,end:s.length,firstSeenAtMs:k});return X(()=>{i.current=g}),a("div",{dir:"auto",className:"codex-markdown-content codex-markdown-root","data-streaming":r?"true":void 0,children:o.map((l)=>a(en,{token:l.token,tokenKey:l.tokenKey,offset:l.offset,runs:g.runs,generation:y},l.tokenKey,!1,void 0,this))},void 0,!1,void 0,this)}),tn=D(function({text:n,isStreaming:t}){let r=p(null),[o,s]=f(()=>K(n,t)),[i,c]=f(null);if(h(()=>{let d=we((u)=>{he(()=>s(u))},c);return r.current=d,()=>{d.dispose(),r.current=null}},[]),h(()=>{let d=r.current;if(d===null)throw Error("Markdown parser is not mounted");let u=t?Se(n).markdown:n;d.update({source:u,text:n,isStreaming:t})},[t,n]),i!==null)throw i;return o===null?a("div",{"data-markdown-pending":!0},void 0,!1,void 0,this):a(nn,{result:o},void 0,!1,void 0,this)});function mn({text:e,streaming:n,host:t}){let r=n===!0,[o,s]=f(e);return h(()=>{if(o===e)return;if(!r){s(e);return}let i=requestAnimationFrame(()=>s(e));return()=>cancelAnimationFrame(i)},[o,r,e]),a(J.Provider,{value:t,children:a(tn,{text:r?o:e,isStreaming:r},void 0,!1,void 0,this)},void 0,!1,void 0,this)}export{mn as CodexMarkdownRenderer};
3
+ \`\`\``}function H(e,n){if(!e.includes(n)||Ne(e,n)%2===0)return e;let t=Me(e,n);if(t<0)return e;let r=e.slice(t+n.length);if(r.length===0||/^\s/.test(r)||r.includes(`
4
+ `)||Y(r))return e;return`${e}${n}`}function $e(e){return e.startsWith("/")&&!e.startsWith("//")||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\]+\\[^\\]+/.test(e)||/^\/\/[^/]+\/[^/]+/.test(e)}function Q(e){let n=e.replaceAll("`","").trim(),t=n.match(/^(.*?):(\d+)(?::(\d+))?(?:[-–](\d+)(?::(\d+))?)?$/);if(t!==null){let[,o,s,i,c,d]=t;if(o===void 0||s===void 0)throw Error("Codex file location is incomplete");return{path:o,line:Number.parseInt(s,10),column:i===void 0?void 0:Number.parseInt(i,10),endLine:c===void 0?void 0:Number.parseInt(c,10),endColumn:d===void 0?void 0:Number.parseInt(d,10)}}let r=n.match(/^(.*?)#L(\d+)(?:C(\d+))?(?:-L(\d+)(?:C(\d+))?)?$/);if(r!==null){let[,o,s,i,c,d]=r;if(o===void 0||s===void 0)throw Error("Codex hash file location is incomplete");return{path:o,line:Number.parseInt(s,10),column:i===void 0?void 0:Number.parseInt(i,10),endLine:c===void 0?void 0:Number.parseInt(c,10),endColumn:d===void 0?void 0:Number.parseInt(d,10)}}return{path:n}}function Re(e){let{path:n,line:t,column:r,endLine:o,endColumn:s}=Q(e);if(/^[a-z][a-z0-9+.-]*:\/\//i.test(n)||/^www\./i.test(n)||/^(mailto|tel):/i.test(n))return!1;if(t!==void 0||r!==void 0||o!==void 0||s!==void 0)return!0;if(!/(?:^|[\\/])[^\\/]+\.(?!\d+$)[^\\/.]+$/i.test(n))return!1;let i=/[\\/]/.test(n),c=n.split(/[\\/]/).at(-1);if(c===void 0)throw Error("Codex streaming link target has no file name");let d=c.split(".").at(-1);if(d===void 0||d.length===0)return!1;if(!i&&/[a-z]/.test(d)&&/[A-Z]/.test(d.slice(1)))return!1;if(!i){let u=d.toLowerCase();if(u.length>Ce&&!ye.has(u))return!1}return!0}function Pe(e){let{path:n}=Q(e);if($e(n))return!0;try{return new URL(n).protocol==="file:"}catch{return!1}}function Se(e){let n=e.match(A);if(n===null)return e;let t=n[2];if(t===void 0)throw Error("Codex streaming link target is missing");return Re(t)||Pe(t)?e.replace(A,"$1"):`${e})`}function Fe(e){let n=e.replace(ve,"");if(n.length===0||n.includes("`")&&Y(n))return{isCodeFenceOpen:!1,markdown:n};if(n.includes("```")&&Ee(n))return{isCodeFenceOpen:!0,markdown:Ie(n)};if(n.includes("!["))n=n.replace(Te,(t,r)=>r);if(n.includes("]("))n=Se(n);return n=H(n,"**"),n=H(n,"*"),{isCodeFenceOpen:!1,markdown:n}}function Ae(e){return e?.type==="paragraph"&&"tokens"in e&&Array.isArray(e.tokens)}function _(e){return Ae(e)&&e.tokens.length===1&&e.tokens[0]?.type==="image"}function ee(e){for(let n=0;n<e.length;n+=1){let t=e[n];if(t===void 0)throw Error(`Codex Markdown token is missing at index ${n}`);if("tokens"in t&&Array.isArray(t.tokens))ee(t.tokens);if(!_(t))continue;let r=[...t.tokens],o=n+1,s=o;for(;;){while(e[o]?.type==="space")o+=1;let i=e[o];if(!_(i))break;r.push(...i.tokens),o+=1,s=o}if(s===n+1)continue;t.tokens=r,t.text=r.map((i)=>i.raw).join(`
5
+ `),t.raw=e.slice(n,s).map((i)=>i.raw).join(""),e.splice(n+1,s-n-1)}}function O(e){return{type:"text",raw:e,text:e}}function He(e){return{type:"paragraph",raw:e.raw,text:e.text,tokens:e.tokens??[e]}}function E(e){for(let n of e){if(n.type==="list")for(let t of n.items){let r=t.tokens[0];if(r?.type==="heading"){let o=r,s=o.raw.trimEnd(),i=s.match(/^#{1,6}\s+/)?.[0];if(i!==void 0)t.tokens[0]={type:"paragraph",raw:o.raw,text:s,tokens:o.tokens===void 0?[O(s)]:[O(i),...o.tokens]}}if(t.loose)t.tokens=t.tokens.map((o)=>o.type==="text"?He(o):o);E(t.tokens)}if("tokens"in n&&Array.isArray(n.tokens))E(n.tokens)}}function _e(e,n,t){e.preventDefault(),e.stopPropagation(),t.openLink(n)}function Oe(e){try{let n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?null:`${n.origin}/favicon.ico`}catch{return null}}function je(e){let n=Oe(e);return n===null?[]:[n,`https://www.google.com/s2/favicons?domain=${new URL(e).origin}&sz=32`]}function We({href:e}){let n=J(()=>je(e),[e]),[t,r]=h(),o=n.length===0&&!/^[a-z][a-z0-9+.-]*:/i.test(e),s=e.toLowerCase().startsWith("mailto:")?ge:o?ue:me;return g("span",{className:"codex-markdown-favicon",children:[t===void 0?a("span",{className:"codex-markdown-favicon-fallback",children:a(s,{"aria-hidden":!0})}):null,n.map((i)=>a("img",{alt:"",className:t===i?"codex-markdown-favicon-image-loaded":void 0,decoding:"async",draggable:!1,referrerPolicy:"no-referrer",src:i,onLoad:()=>r((c)=>c!==void 0&&n.includes(c)?c:i)},i))]})}function qe({children:e,href:n,title:t}){let r=C();if(r.preview)return a("span",{children:e});return a("a",{className:"codex-markdown-link","data-inline-mention-interactive":"",href:n,title:t,onClick:(o)=>_e(o,n,r),children:g("span",{className:"codex-markdown-link-mention","data-layout":"inline-flow","data-interactive":"","data-underline-on-hover":"",children:[a("span",{className:"codex-markdown-link-icon-container","data-markdown-copy":"exclude",children:a(We,{href:n})}),a("span",{className:"codex-markdown-link-label",children:e})]})})}function Ke({code:e,language:n}){let{theme:t,copyLabel:r}=C(),o=k(null),[s,i]=h(null),[c,d]=h(null),[u,w]=h(!1);if(p(()=>{let f=ke(i,d);return o.current=f,()=>{f.dispose(),o.current=null}},[]),p(()=>{let f=o.current;if(f===null)throw Error("Code highlighter is not mounted");f.update(e,n)},[e,n]),c!==null)throw c;let x=s!==null&&s.code===e&&s.language===n?s.html:null;return g("div",{className:"codex-markdown-code-block","data-markdown-copy":"code-block","data-markdown-copy-text":e,"data-theme":t==="dark"?"dark":"light",children:[g("div",{className:"codex-markdown-code-header","data-markdown-copy":"exclude",children:[a("div",{className:"codex-markdown-code-title",children:n}),a("div",{className:"codex-markdown-code-actions",children:a("button",{type:"button",className:"codex-markdown-code-copy",title:r,onClick:()=>{navigator.clipboard.writeText(e),w(!0),window.setTimeout(()=>w(!1),2000)},children:u?a(B,{}):a(de,{})})})]}),a("div",{className:"codex-markdown-code-container",dir:"ltr",children:a("code",{className:"codex-markdown-code-content hljs",...x===null?{children:e}:{dangerouslySetInnerHTML:{__html:x}}})})]})}function ze({code:e,language:n}){return C().preview?a("span",{children:e}):a(Ue,{code:e,language:n})}function Ue({code:e,language:n}){let t=k(null),[r,o]=h(!1);if(p(()=>{if(r)return;let s=t.current;if(s===null)throw Error("Codex code block placeholder is not mounted");if(typeof IntersectionObserver>"u"){let c=window.setTimeout(()=>o(!0),0);return()=>window.clearTimeout(c)}let i=new IntersectionObserver((c)=>{if(!c.some((d)=>d.isIntersecting))return;o(!0),i.disconnect()},{rootMargin:"600px 0px"});return i.observe(s),()=>i.disconnect()},[r]),r)return a(Ke,{code:e,language:n});return a("div",{ref:t,className:"codex-markdown-code-block",children:a("pre",{className:"codex-markdown-code-placeholder",children:a("code",{children:e})})})}function Be(e){let n=[...document.body.querySelectorAll('[data-markdown-image-preview-trigger="true"]')],t=n.map((o)=>{let s=o.querySelector("img");if(s===null)throw Error("Codex image preview trigger has no image");return{src:s.currentSrc||s.src,alt:s.alt}}),r=n.indexOf(e);if(r===-1)throw Error("Codex image preview trigger is outside the document");return{images:t,index:r}}function De({preview:e,setPreview:n}){let t=e.images[e.index];if(t===void 0)throw Error(`Codex image preview index is out of range: ${e.index}`);return g("div",{className:"codex-markdown-image-preview",children:[a("img",{src:t.src,alt:t.alt}),g("div",{className:"codex-markdown-image-preview-actions",children:[a("button",{type:"button","aria-label":"Previous image",disabled:e.index===0,onClick:()=>n({...e,index:e.index-1}),children:a(ie,{})}),a("a",{href:t.src,download:!0,"aria-label":"Download image",children:a(le,{})}),a("button",{type:"button","aria-label":"Next image",disabled:e.index===e.images.length-1,onClick:()=>n({...e,index:e.index+1}),children:a(ce,{})}),a("button",{type:"button","aria-label":"Close image preview",onClick:()=>n(void 0),children:a(fe,{})})]})]})}function Xe(e){return C().preview?a(oe,{children:e.alt}):a(Ge,{...e})}function Ge({src:e,alt:n,title:t,allowWide:r}){let o=k(null),[s,i]=h();p(()=>{let d=o.current;if(d===null)throw Error("Codex image preview dialog is not mounted");if(s===void 0){if(d.open)d.close();return}if(!d.open)d.showModal()},[s]);let c=n.length===0?"Open image preview":n;return g(oe,{children:[a("button",{type:"button",className:`codex-markdown-image-trigger${r?"codex-markdown-image-trigger-wide":""}`,"aria-label":c,"data-markdown-image-preview-trigger":"true",onClick:(d)=>i(Be(d.currentTarget)),children:a("img",{className:`codex-markdown-image${r?"codex-markdown-image-wide":""}`,src:e,alt:n,title:t,loading:"lazy"})}),a("dialog",{ref:o,className:"codex-markdown-image-dialog","aria-label":c,onClose:()=>i(void 0),children:s===void 0?null:a(De,{preview:s,setPreview:i})})]})}function Je({value:e,display:n}){let t=k(null);return G(()=>{if(t.current===null)throw Error("Codex math root is not mounted");se.render(e,t.current,{displayMode:n,throwOnError:!1})},[n,e]),a("span",{ref:t,className:n?"codex-markdown-math-block":"codex-markdown-inline-math"})}var Ve=150,T=null;function j(e,n){let t=T;if(t===null)return e;let r=t.cursor,o=r+e.length;t.cursor=o;let s=[],i=r;for(let c of t.runs){if(c.end<=r)continue;if(c.start>=o)break;let d=Math.max(r,c.start),u=Math.min(o,c.end);if(i<d)s.push(e.slice(i-r,d-r));s.push(a("span",{className:"codex-markdown-fade",children:e.slice(d-r,u-r)},`${n}:${t.generation}:${c.start}`)),i=u}if(i<o)s.push(e.slice(i-r));return s}function ne(e){let n=5381;for(let t=0;t<e.length;t+=1)n=(n*33+e.charCodeAt(t))%4294967296;return n.toString(36)}function q(e){let n=e.trim();if(n.length===0)return"";let t=n.split(`
6
+ `,1)[0];if(t===void 0)throw Error("Codex Markdown token has no first line");return(t.match(/\S+/)?.[0]??t).slice(0,xe)}function Ze(e){switch(e.type){case"code":return e.raw.trimStart().match(/^(```|~~~)/)?.[1]??"";case"link":return e.href;case"image":{let n=e;return`${n.href}:${q(n.text)}`}case"html":case"space":case"br":case"hr":case"def":return e.raw;case"math":return q(e.text);default:return""}}function te(e){return`${e.type==="math"?`math-${e.display?"block":"inline"}`:e.type}-${ne(Ze(e))}`}function m(e,n){let t=new Map;return e.map((r)=>{let o=te(r),s=t.get(o)??0;return t.set(o,s+1),re(r,`${n}-${o}-${s}`)})}function Ye(e,n){let t=e.task?e.tokens.filter((r)=>r.type!=="checkbox"):e.tokens;return g("li",{className:`codex-markdown-list-item${e.task?"codex-markdown-task-list-item":""}`,children:[e.task?g("div",{className:"codex-markdown-task-checkbox",children:[a("input",{type:"checkbox",className:"codex-markdown-checkbox",checked:e.checked,"data-state":e.checked?"checked":"unchecked",readOnly:!0,disabled:!0}),e.checked?a(B,{}):null]}):null,m(t,n)]},n)}function Qe(e,n){let r=`codex-markdown-list ${e.items.some((s)=>s.task)?"codex-markdown-task-list":e.ordered?"codex-markdown-ordered-list":"codex-markdown-unordered-list"}`,o=m(e.items,n);return e.ordered?a("ol",{className:r,start:e.start===""?void 0:e.start,children:o},n):a("ul",{className:r,children:o},n)}function z(e,n,t){let r=t?"th":"td",o=/^\d+$/.test(e.text);return D(r,{key:n,className:`${t?"codex-markdown-table-header":"codex-markdown-table-cell"}${o?" codex-markdown-numeric-table-cell":""}`,align:e.align??void 0},...m(e.tokens,n))}function en(e,n){let t=new Map;return a("div",{className:"codex-markdown-table-container","data-markdown-table":!0,tabIndex:-1,children:a("div",{className:"codex-markdown-table-scroller",children:a("div",{className:"codex-markdown-table-wrapper",children:g("table",{className:"codex-markdown-table",children:[a("thead",{children:a("tr",{className:"codex-markdown-table-row",children:e.header.map((r,o)=>z(r,`${n}-header-${o}`,!0))})}),a("tbody",{className:"codex-markdown-table-body",children:e.rows.map((r)=>{let o=ne(r.map((c)=>c.text).join("\x00")),s=t.get(o)??0;t.set(o,s+1);let i=`${n}-row-${o}-${s}`;return a("tr",{className:"codex-markdown-table-row",children:r.map((c,d)=>z(c,`${i}-cell-${d}`,!1))},i)})})]})})})},n)}function U(e,n,t){let r=v(e.href);if(!W(r))return null;return a(Xe,{src:r,alt:I(e.text),title:e.title==null?void 0:v(e.title),allowWide:t},n)}function re(e,n){switch(e.type){case"space":case"def":case"internalMessage":return null;case"hr":return a("hr",{className:"codex-markdown-horizontal-rule"},n);case"heading":{let t=e,o={1:"h1",2:"h2",3:"h3",4:"h4",5:"h5",6:"h6"}[t.depth];if(o===void 0)throw Error(`Unsupported Codex Markdown heading depth: ${t.depth}`);return D(o,{key:n,className:`codex-markdown-heading codex-markdown-heading-${t.depth}`},...m(t.tokens,n))}case"paragraph":{let t=e,r=t.tokens.filter((i)=>i.type!=="space"&&i.type!=="br"),o=r.length>0&&r.every((i)=>i.type==="image"),s=o&&r.length>1;return a("p",{className:`codex-markdown-paragraph${o?"codex-markdown-media-paragraph codex-markdown-media-wide-block":""}${s?"codex-markdown-media-grid-paragraph":""}`,"data-markdown-image-grid":s?"true":void 0,"data-wide-markdown-block":o?"true":void 0,"data-wide-markdown-block-kind":o?"image":void 0,children:o?r.map((i,c)=>U(i,`${n}-image-${c}`,!0)):m(t.tokens,n)},n)}case"text":{let t=e;return t.tokens===void 0?j(I(t.text),n):m(t.tokens,n)}case"escape":return j(e.text,n);case"strong":return a("strong",{className:"codex-markdown-strong",children:m(e.tokens,n)},n);case"em":return a("em",{children:m(e.tokens,n)},n);case"del":return a("del",{children:m(e.tokens,n)},n);case"codespan":return a("span",{className:"codex-markdown-inline-code",dir:"ltr","data-markdown-copy":"inline-code",children:e.text},n);case"br":return a("br",{},n);case"link":{let t=e,r=m(t.tokens,n),o=v(t.href);return W(o)?a(qe,{href:o,title:t.title==null?void 0:v(t.title),children:r},n):a("span",{children:r},n)}case"image":return U(e,n,!1);case"code":{let t=e;return a(ze,{code:t.text,language:t.lang},n)}case"blockquote":return a("blockquote",{className:"codex-markdown-blockquote",children:m(e.tokens,n)},n);case"list":return Qe(e,n);case"list_item":return Ye(e,n);case"table":return en(e,n);case"html":{let t=e;return/^<br\s*\/?>$/i.test(t.raw.trim())?a("br",{},n):t.raw}case"math":{let t=e;return a(Je,{value:t.text,display:t.display},n)}default:throw Error(`Unsupported Codex Markdown token: ${JSON.stringify(e)}`)}}function b(e){switch(e.type){case"text":{let n=e;return n.tokens===void 0?I(n.text):n.tokens.map(b).join("")}case"escape":return e.text;case"paragraph":case"heading":case"strong":case"em":case"del":case"link":case"blockquote":case"list_item":return e.tokens.map(b).join("");case"list":return e.items.map(b).join("");case"table":{let n=e;return[n.header,...n.rows].map((t)=>t.map((r)=>r.tokens.map(b).join("")).join("")).join("")}default:return""}}function nn({token:e,tokenKey:n,offset:t,runs:r,generation:o}){let s=T;try{return T={cursor:t,runs:r,generation:o},re(e,n)}finally{T=s}}var tn=X(function({result:n}){let{text:t,isStreaming:r}=n,o=J(()=>{let l=n.tokens;if(n.source.includes("!["))ee(l);E(l);let R=new Map,P=0;return l.map((M)=>{let L=te(M),S=R.get(L)??0;R.set(L,S+1);let F=b(M),ae={token:M,tokenKey:`root-${L}-${S}`,offset:P,visibleText:F};return P+=F.length,ae})},[n]),s=o.map((l)=>l.visibleText).join(""),i=k({text:"",visibleText:"",runs:[],generation:0}),c=i.current,d=t.startsWith(c.text)||s.startsWith(c.visibleText),u=d?c.visibleText.length:0,w=performance.now(),x=r&&d?c.runs.filter((l)=>w-l.firstSeenAtMs<Ve):[],N=c.generation+(d?0:1),f={text:t,visibleText:s,runs:x.filter((l)=>l.start<s.length).map((l)=>({...l,end:Math.min(l.end,s.length)})),generation:N};if(r&&s.length>u)f.runs.push({start:u,end:s.length,firstSeenAtMs:w});return G(()=>{i.current=f}),a("div",{dir:"auto",className:"codex-markdown-content codex-markdown-root","data-streaming":r?"true":void 0,children:o.map((l)=>a(nn,{token:l.token,tokenKey:l.tokenKey,offset:l.offset,runs:f.runs,generation:N},l.tokenKey))})}),rn=X(function({text:n,isStreaming:t}){let r=k(null),[o,s]=h(()=>K(n,t)),[i,c]=h(null);if(p(()=>{let d=we((u)=>{pe(()=>s(u))},c);return r.current=d,()=>{d.dispose(),r.current=null}},[]),p(()=>{let d=r.current;if(d===null)throw Error("Markdown parser is not mounted");let u=t?Fe(n).markdown:n;d.update({source:u,text:n,isStreaming:t})},[t,n]),i!==null)throw i;return o===null?a("div",{"data-markdown-pending":!0}):a(tn,{result:o})});function gn({text:e,streaming:n,host:t}){let r=n===!0,[o,s]=h(e);return p(()=>{if(o===e)return;if(!r){s(e);return}let i=requestAnimationFrame(()=>s(e));return()=>cancelAnimationFrame(i)},[o,r,e]),a(V.Provider,{value:t,children:a(rn,{text:r?o:e,isStreaming:r})})}export{gn as CodexMarkdownRenderer};
@@ -1 +1 @@
1
- import{Te}from"../chunk-67gms74t.js";export{Te as NavigationPreview};
1
+ import{Te}from"../chunk-e12qaex5.js";export{Te as NavigationPreview};
@@ -1 +1 @@
1
- import{Te}from"../chunk-67gms74t.js";import{useCallback as xe,useEffect as P,useLayoutEffect as ye,useMemo as Q,useRef as I,useState as E}from"react";import"@alwith/module-chat/navigation-rail.css";import{jsxDEV as h,Fragment as Ne}from"react/jsx-dev-runtime";var we=4,ge=10;function Se(T,x){let v=new Map(x.flatMap((c)=>c.itemIds.map((w)=>[w,c.key]))),p=Array(T.length),C;for(let c=T.length-1;c>=0;c--)C=v.get(T[c])??C,p[c]=C;let O=Math.max(-1,...x.map((c)=>c.key))+1,B=new Set,n=[];for(let[c,w]of T.entries()){let S=v.get(w),g=n.at(-1);if(!g||S!==void 0&&S!==g.key||S===void 0&&g.itemIds.length>=64&&p[c]!==g.key){let y=S!==void 0&&!B.has(S)?S:O++;g={key:y,startIndex:c,itemIds:[]},n.push(g),B.add(y)}g.itemIds.push(w)}return n}function me(T,x){if(T.size!==x.size)return!1;for(let v of T)if(!x.has(v))return!1;return!0}function Le({audio:T,beforeReveal:x,ensureItemMounted:v,items:p,onPreviewItem:C,renderPreview:O,onRevealError:B,scrollRoot:n,targetTopMarginPx:c=16}){let[w,S]=E(()=>{let e=p.at(-1);return new Set(e===void 0?[]:[e.id])}),[g,y]=E(null),[W,A]=E(null),[X,U]=E(!1),[_,fe]=E(()=>new Set),[pe,ve]=E(!0),[be,j]=E(null),{installUnlock:Z,preload:ee,playSequence:te}=T,K=I(null),M=I(null),R=I(!1),H=I(null),L=I(0),N=I(null),G=I(new Set),V=Q(()=>p.map((e)=>e.id).join("\x00"),[p]),F=I(p);F.current=p;let ne=I(_),re=I(w),ie=I({itemIdsKey:V,scrollRoot:n});if(ie.current.scrollRoot!==n)L.current+=1,ie.current={itemIdsKey:V,scrollRoot:n};let m=Q(()=>v===void 0?p.filter((e)=>_.has(e.id)):p,[v,p,_]),se=Q(()=>m.map((e)=>({inputTokens:e.inputTokens,outputTokens:e.outputTokens})),[m]),z=I({ids:"",groups:[]}),ae=m.map((e)=>e.id).join("\x00");if(z.current.ids!==ae)z.current={ids:ae,groups:Se(m.map((e)=>e.id),z.current.groups)};P(()=>Z(),[Z]),P(()=>()=>{if(L.current+=1,N.current!==null)clearTimeout(N.current)},[]),P(()=>{y(null),U(!1),A(null),M.current=null,R.current=!1,H.current=null,j(null),G.current.clear()},[n]),P(()=>{ee()},[ee]),P(()=>{if(n===null)return;let e=new Set,t=new Map,r=new Set(F.current.map((o)=>o.id)),i=()=>{let o=new Set(t.values()),l=F.current.filter((f)=>o.has(f.id)).map((f)=>f.id),u=l.findIndex((f)=>e.has(f));if(u===-1)return;let b=u;for(let f=u+1;f<l.length;f++)if(e.has(l[f]))b=f;let k=new Set(l.slice(u,b+1));if(me(re.current,k))return;re.current=k,S(k)},s=new IntersectionObserver((o)=>{for(let l of o){let u=t.get(l.target);if(l.isIntersecting)e.add(u);else e.delete(u)}i()},{root:n,rootMargin:`-${c}px 0px 0px 0px`}),a=()=>{let o=new Set,l=new Set;for(let u of n.querySelectorAll("[data-content-search-unit-key]")){let b=u.dataset.contentSearchUnitKey;if(b===void 0||!r.has(b)||o.has(b))continue;o.add(b);let k=u.closest("[data-turn-key]"),f=k===null||l.has(k)?u:k;if(l.add(f),t.has(f))continue;t.set(f,b),s.observe(f)}for(let u of t.keys()){if(l.has(u))continue;s.unobserve(u),e.delete(t.get(u)),t.delete(u)}if(i(),me(ne.current,o))return;ne.current=o,fe(o)};a();let d=new MutationObserver((o)=>{if(o.some((u)=>[...u.addedNodes,...u.removedNodes].some((b)=>b instanceof Element&&(b.matches("[data-turn-key], [data-content-search-unit-key]")||b.querySelector("[data-turn-key], [data-content-search-unit-key]")!==null))))a()});return d.observe(n,{childList:!0,subtree:!0}),()=>{d.disconnect(),s.disconnect()}},[V,n,c]);let J=m.find((e)=>w.has(e.id))?.id??m.at(-1)?.id;ye(()=>{let e=K.current;if(e===null||M.current!==null||J===void 0)return;let t=e.querySelector(`[data-thread-user-message-navigation-item-id="${CSS.escape(J)}"]`);if(t===null)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(i.top<r.top)e.scrollTop+=i.top-r.top;else if(i.bottom>r.bottom)e.scrollTop+=i.bottom-r.bottom+1},[J,V]),P(()=>{let e=n?.querySelector("[data-thread-user-message-navigation-content]");if(!n||!e)return;let t=()=>{let i=n.getBoundingClientRect(),s=e.getBoundingClientRect();if(i.width===0||s.width===0)return;let a=n.offsetWidth>0?i.width/n.offsetWidth:1;ve((s.left-i.left)/a>=48)},r=new ResizeObserver(t);return r.observe(n),r.observe(e),t(),()=>r.disconnect()},[n]);let Ie=xe(async(e,t="smooth")=>{if(n===null)throw Error("Thread user-message navigation scroll root is missing");let r=L.current+1;L.current=r,x();let i=()=>n.querySelector(`[data-content-search-unit-key="${CSS.escape(e.id)}"]`),s=i(),a=s!==null&&n.clientHeight>0&&s.closest("[data-turn-key]")!==null&&Math.abs(s.getBoundingClientRect().top-n.getBoundingClientRect().top)>n.clientHeight*2;if((s===null||a)&&v!==void 0){if(t==="instant"&&e.isLoaded===!1)return;s=await v(e,()=>L.current===r)??i(),t="instant"}if(L.current!==r)return;if(s===null)return;let d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;s.scrollIntoView({behavior:d?"instant":t,block:"start"}),s.querySelector("[data-user-message-bubble], [data-composer-attachment-pill]")?.animate?.([{backgroundColor:"color-mix(in srgb, var(--foreground) 14%, transparent)"},{backgroundColor:"color-mix(in srgb, var(--foreground) 14%, transparent)",offset:0.35},{backgroundColor:"transparent"}],{duration:d?0:1000,easing:"cubic-bezier(0.23, 1, 0.32, 1)"})},[x,v,n]);if(m.length<we||!pe)return null;let Y=()=>{if(N.current!==null)clearTimeout(N.current);N.current=null},oe=(e,t=!1)=>{if(Y(),C===void 0||e.isLoaded!==!1||G.current.has(e.turnKey))return;let r=()=>{N.current=null,G.current.add(e.turnKey),C(e).catch(()=>G.current.delete(e.turnKey))};if(t)r();else N.current=setTimeout(r,150)},q=g===null?null:m.find((e)=>e.id===g.item.id)??m.find((e)=>e.nativeTurnId!==void 0&&e.nativeTurnId===g.item.nativeTurnId)??g.item,ue=(e,t="smooth")=>{Ie(e,t).catch((r)=>{if(B)B(r);else throw r})},de=m.findIndex((e)=>e.id===(W??be)),le=K.current,he=g===null||!le?.contains(g.button)?0:Me(le,g.button),ce=(e)=>{let t=e?.closest("[data-thread-user-message-navigation-item-id]"),r=K.current;if(t===void 0||t===null||!r.contains(t))return null;let i=t.dataset.threadUserMessageNavigationItemId,s=m.findIndex((a)=>a.id===i);return{button:t,item:m[s],index:s}},D=(e)=>{let t=M.current;if(t?.pointerId!==e.pointerId)return;if(M.current=null,A(null),t.captureTarget.hasPointerCapture(e.pointerId))t.captureTarget.releasePointerCapture(e.pointerId)};return h("nav",{"aria-label":"User messages",className:"thread-user-message-navigation absolute start-4 top-1/2 z-20 -translate-y-1/2",children:h(Te,{open:X,onOpenChange:U,side:"inline-end",sideOffset:0,align:"center",alignOffset:he,trigger:h("div",{ref:K,"data-thread-user-message-navigation-rail-list":!0,"data-scrubbing":W===null?void 0:"",className:"thread-user-message-navigation-rail-list",onPointerEnter:()=>{H.current=null},onPointerDown:(e)=>{if(e.button!==0)return;Y();let t=ce(e.target instanceof Element?e.target:null);if(t===null)return;R.current=!1,M.current={pointerId:e.pointerId,itemId:t.item.id,itemIndex:t.index,captureTarget:t.button},t.button.setPointerCapture(e.pointerId),A(t.item.id),y(t),U(!0)},onPointerMove:(e)=>{let t=M.current;if(t===null){let d=ce(e.target instanceof Element?e.target:null);if(d!==null){j(d.item.id);let o=H.current;if(o!==null&&o!==d.index)te(o,d.index,se);H.current=d.index,y((l)=>l?.item.id===d.item.id?l:d),oe(d.item)}return}if(t.pointerId!==e.pointerId)return;if((e.buttons&1)===0){D(e);return}let r=e.currentTarget.getBoundingClientRect(),i=Math.max(0,Math.min(m.length-1,Math.floor((e.clientY-r.top+e.currentTarget.scrollTop)/ge))),a={button:e.currentTarget.querySelectorAll("[data-thread-user-message-navigation-item-id]")[i],item:m[i],index:i};if(a.item.id===t.itemId)return;te(t.itemIndex,a.index,se),H.current=a.index,M.current={...t,itemId:a.item.id,itemIndex:a.index},R.current=!0,A(a.item.id),y(a),ue(a.item,"instant")},onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,onPointerLeave:()=>{if(Y(),j(null),H.current=null,M.current===null&&!X)y(null)},children:h("div",{className:"flex flex-col",children:z.current.groups.map((e)=>h("div",{className:"flex w-9 shrink-0 flex-col [content-visibility:auto]",style:{height:e.itemIds.length*ge},children:m.slice(e.startIndex,e.startIndex+e.itemIds.length).map((t,r)=>{let i=e.startIndex+r,s=Math.abs(i-de),a=de===-1||s>3?void 0:[1,0.7,0.4,0.2][s];return h("button",{type:"button","data-thread-user-message-navigation-item-id":t.id,"data-scrub-target":W===t.id?"":void 0,"aria-current":w.has(t.id)?"true":void 0,"aria-label":`Jump to user message ${i+1}`,className:"thread-user-message-navigation-row",onClick:(d)=>{if(R.current){R.current=!1;return}let o={button:d.currentTarget,item:t,index:i};y(o),U(!0),ue(t)},onFocus:(d)=>{oe(t,!0),y({button:d.currentTarget,item:t,index:i}),U(!0)},children:h("span",{className:"flex h-0.5 w-[30px] items-center",children:h("span",{className:"thread-user-message-navigation-marker",style:a===void 0?void 0:{"--marker-progress":a}},void 0,!1,void 0,this)},void 0,!1,void 0,this)},t.id,!1,void 0,this)})},e.key,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),children:q!==null&&h("div",{className:"bg-popover/95 text-popover-foreground ring-border w-80 max-w-[calc(100vw-1rem)] overflow-hidden rounded-xl p-2 text-sm leading-5 shadow-xl ring-[0.5px] backdrop-blur-sm",children:O?O(q):h(Ne,{children:[h("div",{className:"min-w-0 truncate font-medium",children:q.label},void 0,!1,void 0,this),q.response.length>0&&h("div",{className:"text-muted-foreground mt-1 line-clamp-3",children:q.response},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Me(T,x){let v=T.getBoundingClientRect(),p=x.getBoundingClientRect();return p.top+p.height/2-(v.top+v.height/2)}export{Le as ThreadUserMessageNavigationRail};
1
+ import{Te}from"../chunk-e12qaex5.js";import{useCallback as xe,useEffect as P,useLayoutEffect as ye,useMemo as Q,useRef as I,useState as E}from"react";import"@alwith/module-chat/navigation-rail.css";import{jsx as T,jsxs as ke,Fragment as Ne}from"react/jsx-runtime";var we=4,ge=10;function Se(h,x){let v=new Map(x.flatMap((c)=>c.itemIds.map((w)=>[w,c.key]))),p=Array(h.length),C;for(let c=h.length-1;c>=0;c--)C=v.get(h[c])??C,p[c]=C;let O=Math.max(-1,...x.map((c)=>c.key))+1,B=new Set,n=[];for(let[c,w]of h.entries()){let S=v.get(w),g=n.at(-1);if(!g||S!==void 0&&S!==g.key||S===void 0&&g.itemIds.length>=64&&p[c]!==g.key){let y=S!==void 0&&!B.has(S)?S:O++;g={key:y,startIndex:c,itemIds:[]},n.push(g),B.add(y)}g.itemIds.push(w)}return n}function me(h,x){if(h.size!==x.size)return!1;for(let v of h)if(!x.has(v))return!1;return!0}function Pe({audio:h,beforeReveal:x,ensureItemMounted:v,items:p,onPreviewItem:C,renderPreview:O,onRevealError:B,scrollRoot:n,targetTopMarginPx:c=16}){let[w,S]=E(()=>{let e=p.at(-1);return new Set(e===void 0?[]:[e.id])}),[g,y]=E(null),[W,A]=E(null),[X,U]=E(!1),[_,fe]=E(()=>new Set),[pe,ve]=E(!0),[be,j]=E(null),{installUnlock:Z,preload:ee,playSequence:te}=h,K=I(null),M=I(null),R=I(!1),H=I(null),L=I(0),N=I(null),G=I(new Set),V=Q(()=>p.map((e)=>e.id).join("\x00"),[p]),F=I(p);F.current=p;let ne=I(_),re=I(w),ie=I({itemIdsKey:V,scrollRoot:n});if(ie.current.scrollRoot!==n)L.current+=1,ie.current={itemIdsKey:V,scrollRoot:n};let m=Q(()=>v===void 0?p.filter((e)=>_.has(e.id)):p,[v,p,_]),se=Q(()=>m.map((e)=>({inputTokens:e.inputTokens,outputTokens:e.outputTokens})),[m]),z=I({ids:"",groups:[]}),ae=m.map((e)=>e.id).join("\x00");if(z.current.ids!==ae)z.current={ids:ae,groups:Se(m.map((e)=>e.id),z.current.groups)};P(()=>Z(),[Z]),P(()=>()=>{if(L.current+=1,N.current!==null)clearTimeout(N.current)},[]),P(()=>{y(null),U(!1),A(null),M.current=null,R.current=!1,H.current=null,j(null),G.current.clear()},[n]),P(()=>{ee()},[ee]),P(()=>{if(n===null)return;let e=new Set,t=new Map,r=new Set(F.current.map((o)=>o.id)),i=()=>{let o=new Set(t.values()),l=F.current.filter((f)=>o.has(f.id)).map((f)=>f.id),u=l.findIndex((f)=>e.has(f));if(u===-1)return;let b=u;for(let f=u+1;f<l.length;f++)if(e.has(l[f]))b=f;let k=new Set(l.slice(u,b+1));if(me(re.current,k))return;re.current=k,S(k)},s=new IntersectionObserver((o)=>{for(let l of o){let u=t.get(l.target);if(l.isIntersecting)e.add(u);else e.delete(u)}i()},{root:n,rootMargin:`-${c}px 0px 0px 0px`}),a=()=>{let o=new Set,l=new Set;for(let u of n.querySelectorAll("[data-content-search-unit-key]")){let b=u.dataset.contentSearchUnitKey;if(b===void 0||!r.has(b)||o.has(b))continue;o.add(b);let k=u.closest("[data-turn-key]"),f=k===null||l.has(k)?u:k;if(l.add(f),t.has(f))continue;t.set(f,b),s.observe(f)}for(let u of t.keys()){if(l.has(u))continue;s.unobserve(u),e.delete(t.get(u)),t.delete(u)}if(i(),me(ne.current,o))return;ne.current=o,fe(o)};a();let d=new MutationObserver((o)=>{if(o.some((u)=>[...u.addedNodes,...u.removedNodes].some((b)=>b instanceof Element&&(b.matches("[data-turn-key], [data-content-search-unit-key]")||b.querySelector("[data-turn-key], [data-content-search-unit-key]")!==null))))a()});return d.observe(n,{childList:!0,subtree:!0}),()=>{d.disconnect(),s.disconnect()}},[V,n,c]);let J=m.find((e)=>w.has(e.id))?.id??m.at(-1)?.id;ye(()=>{let e=K.current;if(e===null||M.current!==null||J===void 0)return;let t=e.querySelector(`[data-thread-user-message-navigation-item-id="${CSS.escape(J)}"]`);if(t===null)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(i.top<r.top)e.scrollTop+=i.top-r.top;else if(i.bottom>r.bottom)e.scrollTop+=i.bottom-r.bottom+1},[J,V]),P(()=>{let e=n?.querySelector("[data-thread-user-message-navigation-content]");if(!n||!e)return;let t=()=>{let i=n.getBoundingClientRect(),s=e.getBoundingClientRect();if(i.width===0||s.width===0)return;let a=n.offsetWidth>0?i.width/n.offsetWidth:1;ve((s.left-i.left)/a>=48)},r=new ResizeObserver(t);return r.observe(n),r.observe(e),t(),()=>r.disconnect()},[n]);let Ie=xe(async(e,t="smooth")=>{if(n===null)throw Error("Thread user-message navigation scroll root is missing");let r=L.current+1;L.current=r,x();let i=()=>n.querySelector(`[data-content-search-unit-key="${CSS.escape(e.id)}"]`),s=i(),a=s!==null&&n.clientHeight>0&&s.closest("[data-turn-key]")!==null&&Math.abs(s.getBoundingClientRect().top-n.getBoundingClientRect().top)>n.clientHeight*2;if((s===null||a)&&v!==void 0){if(t==="instant"&&e.isLoaded===!1)return;s=await v(e,()=>L.current===r)??i(),t="instant"}if(L.current!==r)return;if(s===null)return;let d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;s.scrollIntoView({behavior:d?"instant":t,block:"start"}),s.querySelector("[data-user-message-bubble], [data-composer-attachment-pill]")?.animate?.([{backgroundColor:"color-mix(in srgb, var(--foreground) 14%, transparent)"},{backgroundColor:"color-mix(in srgb, var(--foreground) 14%, transparent)",offset:0.35},{backgroundColor:"transparent"}],{duration:d?0:1000,easing:"cubic-bezier(0.23, 1, 0.32, 1)"})},[x,v,n]);if(m.length<we||!pe)return null;let Y=()=>{if(N.current!==null)clearTimeout(N.current);N.current=null},oe=(e,t=!1)=>{if(Y(),C===void 0||e.isLoaded!==!1||G.current.has(e.turnKey))return;let r=()=>{N.current=null,G.current.add(e.turnKey),C(e).catch(()=>G.current.delete(e.turnKey))};if(t)r();else N.current=setTimeout(r,150)},q=g===null?null:m.find((e)=>e.id===g.item.id)??m.find((e)=>e.nativeTurnId!==void 0&&e.nativeTurnId===g.item.nativeTurnId)??g.item,ue=(e,t="smooth")=>{Ie(e,t).catch((r)=>{if(B)B(r);else throw r})},de=m.findIndex((e)=>e.id===(W??be)),le=K.current,he=g===null||!le?.contains(g.button)?0:Me(le,g.button),ce=(e)=>{let t=e?.closest("[data-thread-user-message-navigation-item-id]"),r=K.current;if(t===void 0||t===null||!r.contains(t))return null;let i=t.dataset.threadUserMessageNavigationItemId,s=m.findIndex((a)=>a.id===i);return{button:t,item:m[s],index:s}},D=(e)=>{let t=M.current;if(t?.pointerId!==e.pointerId)return;if(M.current=null,A(null),t.captureTarget.hasPointerCapture(e.pointerId))t.captureTarget.releasePointerCapture(e.pointerId)};return T("nav",{"aria-label":"User messages",className:"thread-user-message-navigation absolute start-4 top-1/2 z-20 -translate-y-1/2",children:T(Te,{open:X,onOpenChange:U,side:"inline-end",sideOffset:0,align:"center",alignOffset:he,trigger:T("div",{ref:K,"data-thread-user-message-navigation-rail-list":!0,"data-scrubbing":W===null?void 0:"",className:"thread-user-message-navigation-rail-list",onPointerEnter:()=>{H.current=null},onPointerDown:(e)=>{if(e.button!==0)return;Y();let t=ce(e.target instanceof Element?e.target:null);if(t===null)return;R.current=!1,M.current={pointerId:e.pointerId,itemId:t.item.id,itemIndex:t.index,captureTarget:t.button},t.button.setPointerCapture(e.pointerId),A(t.item.id),y(t),U(!0)},onPointerMove:(e)=>{let t=M.current;if(t===null){let d=ce(e.target instanceof Element?e.target:null);if(d!==null){j(d.item.id);let o=H.current;if(o!==null&&o!==d.index)te(o,d.index,se);H.current=d.index,y((l)=>l?.item.id===d.item.id?l:d),oe(d.item)}return}if(t.pointerId!==e.pointerId)return;if((e.buttons&1)===0){D(e);return}let r=e.currentTarget.getBoundingClientRect(),i=Math.max(0,Math.min(m.length-1,Math.floor((e.clientY-r.top+e.currentTarget.scrollTop)/ge))),a={button:e.currentTarget.querySelectorAll("[data-thread-user-message-navigation-item-id]")[i],item:m[i],index:i};if(a.item.id===t.itemId)return;te(t.itemIndex,a.index,se),H.current=a.index,M.current={...t,itemId:a.item.id,itemIndex:a.index},R.current=!0,A(a.item.id),y(a),ue(a.item,"instant")},onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,onPointerLeave:()=>{if(Y(),j(null),H.current=null,M.current===null&&!X)y(null)},children:T("div",{className:"flex flex-col",children:z.current.groups.map((e)=>T("div",{className:"flex w-9 shrink-0 flex-col [content-visibility:auto]",style:{height:e.itemIds.length*ge},children:m.slice(e.startIndex,e.startIndex+e.itemIds.length).map((t,r)=>{let i=e.startIndex+r,s=Math.abs(i-de),a=de===-1||s>3?void 0:[1,0.7,0.4,0.2][s];return T("button",{type:"button","data-thread-user-message-navigation-item-id":t.id,"data-scrub-target":W===t.id?"":void 0,"aria-current":w.has(t.id)?"true":void 0,"aria-label":`Jump to user message ${i+1}`,className:"thread-user-message-navigation-row",onClick:(d)=>{if(R.current){R.current=!1;return}let o={button:d.currentTarget,item:t,index:i};y(o),U(!0),ue(t)},onFocus:(d)=>{oe(t,!0),y({button:d.currentTarget,item:t,index:i}),U(!0)},children:T("span",{className:"flex h-0.5 w-[30px] items-center",children:T("span",{className:"thread-user-message-navigation-marker",style:a===void 0?void 0:{"--marker-progress":a}})})},t.id)})},e.key))})}),children:q!==null&&T("div",{className:"bg-popover/95 text-popover-foreground ring-border w-80 max-w-[calc(100vw-1rem)] overflow-hidden rounded-xl p-2 text-sm leading-5 shadow-xl ring-[0.5px] backdrop-blur-sm",children:O?O(q):ke(Ne,{children:[T("div",{className:"min-w-0 truncate font-medium",children:q.label}),q.response.length>0&&T("div",{className:"text-muted-foreground mt-1 line-clamp-3",children:q.response})]})})})})}function Me(h,x){let v=h.getBoundingClientRect(),p=x.getBoundingClientRect();return p.top+p.height/2-(v.top+v.height/2)}export{Pe as ThreadUserMessageNavigationRail};
@@ -1,2 +1,2 @@
1
- import{html as n}from"diff2html";import{ColorSchemeType as r}from"diff2html/lib/types";import{useMemo as s}from"react";import{jsxDEV as a}from"react/jsx-dev-runtime";function f(i){let t=0,e=0;for(let o of i.split(`
2
- `)){if(o.startsWith("+++")||o.startsWith("---"))continue;if(o.startsWith("+"))t+=1;else if(o.startsWith("-"))e+=1}return{additions:t,deletions:e}}function h({patch:i,theme:t}){let e=s(()=>n(i,{drawFileList:!1,outputFormat:"line-by-line",matching:"lines",colorScheme:t==="dark"?r.DARK:r.LIGHT}),[i,t]);return a("div",{className:"codex-patch-view",dangerouslySetInnerHTML:{__html:e}},void 0,!1,void 0,this)}export{h as PatchView,f as patchStats};
1
+ import{html as n}from"diff2html";import{ColorSchemeType as r}from"diff2html/lib/types";import{useMemo as s}from"react";import{jsx as a}from"react/jsx-runtime";function d(e){let t=0,i=0;for(let o of e.split(`
2
+ `)){if(o.startsWith("+++")||o.startsWith("---"))continue;if(o.startsWith("+"))t+=1;else if(o.startsWith("-"))i+=1}return{additions:t,deletions:i}}function f({patch:e,theme:t}){let i=s(()=>n(e,{drawFileList:!1,outputFormat:"line-by-line",matching:"lines",colorScheme:t==="dark"?r.DARK:r.LIGHT}),[e,t]);return a("div",{className:"codex-patch-view",dangerouslySetInnerHTML:{__html:i}})}export{f as PatchView,d as patchStats};
@@ -1 +1 @@
1
- import{k}from"../chunk-bbnrzw5x.js";export{k as CodexPlan};
1
+ import{k}from"../chunk-h96s3j1e.js";export{k as CodexPlan};
@@ -1 +1 @@
1
- import{AnsiUp as s}from"ansi_up";import{useMemo as e}from"react";import{jsxDEV as r}from"react/jsx-dev-runtime";function a({text:n}){let o=e(()=>{let t=new s;return t.use_classes=!1,t.ansi_to_html(n)},[n]);return r("pre",{className:"codex-command-output",dangerouslySetInnerHTML:{__html:o}},void 0,!1,void 0,this)}export{a as TerminalOutput};
1
+ import{AnsiUp as o}from"ansi_up";import{useMemo as s}from"react";import{jsx as r}from"react/jsx-runtime";function a({text:n}){let e=s(()=>{let t=new o;return t.use_classes=!1,t.ansi_to_html(n)},[n]);return r("pre",{className:"codex-command-output",dangerouslySetInnerHTML:{__html:e}})}export{a as TerminalOutput};
@@ -1 +1 @@
1
- import{U,xt}from"../chunk-ytqka33j.js";import"../chunk-d1xydh51.js";export{xt as CodexUserMessage,U as CopyAction};
1
+ import{U,vt}from"../chunk-32fcg6q4.js";import"../chunk-6m16qe9q.js";export{vt as CodexUserMessage,U as CopyAction};
@@ -1 +1 @@
1
- import{ue,g,z,me,pe,ge}from"../chunk-p4c1w6qx.js";import{forwardRef as Te,useCallback as w,useEffect as xe,useImperativeHandle as be,useLayoutEffect as L,useMemo as ie,useRef as s,useState as N}from"react";import{jsxDEV as m}from"react/jsx-dev-runtime";var Pe=12,J=2,W=800,ye=new Map;function Be({turnKey:_,heightPx:v,placeholder:U=!1,deferUntilReady:n=!1,observe:T,onReady:M,children:k}){let f=s(null),[b,G]=N(!1),X=w((x)=>{f.current=x,T(_,x)},[T,_]);return L(()=>{let x=f.current;if(x===null)throw Error("Codex turn element is missing");let P=()=>{M(x),G(!0)};if(x.querySelector("[data-markdown-pending]")===null){P();return}let d=new MutationObserver(()=>{if(x.querySelector("[data-markdown-pending]")!==null)return;d.disconnect(),P()});return d.observe(x,{childList:!0,subtree:!0}),()=>d.disconnect()},[M]),m("div",{style:b?void 0:{position:"relative",height:v,overflow:"hidden"},children:[m("div",{ref:X,className:"[&_[data-virtualized-turn-content]]:[content-visibility:visible]","data-turn-key":_,"aria-busy":!b||void 0,style:!b&&!U&&n?{visibility:"hidden"}:void 0,"data-turn-ready":b?"":void 0,children:k},void 0,!1,void 0,this),!b&&!U&&n&&m("div",{"aria-hidden":"true",className:"codex-turn-loading",children:m("div",{className:"codex-turn-loading-lines",children:[m("span",{},void 0,!1,void 0,this),m("span",{},void 0,!1,void 0,this),m("span",{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Me=Te(function({entries:v,renderTurn:U,scrollElement:n,sessionKey:T,leadingContent:M,leadingInsetPx:k=0,preserveViewport:f=!1},b){let G=s(null),[X,x]=N(k),P=M!==void 0&&M!==null;L(()=>{let e=G.current;if(e===null)return;let t=()=>x(e.getBoundingClientRect().height);t();let o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[P]);let d=ie(()=>ye.get(T),[T]),[Q,Y]=N(()=>d?.turnHeightsByKey??{}),i=ie(()=>ue({entries:v,gapPx:Pe,measuredHeightsByKey:Q,leadingInsetPx:P?X:k}),[v,Q,P,X,k]),ve=ie(()=>{let e=g({distanceFromBottomPx:d?.distanceFromBottomPx??0,layout:i,overscanCount:J,viewportHeightPx:W}),t=d?.renderedWindow;if(t===void 0||t===null)return e;return z({anchorKey:t.anchorKey,layout:i,previousRange:{startIndex:0,endIndex:Math.min(t.count,e.endIndex-e.startIndex)}})??e},[d,i]),[C,oe]=N(ve),[p,ae]=N(W),[c,se]=N(null),S=s(d?.distanceFromBottomPx??0),E=s(C),ce=s(i.turnKeys),l=s(Q),D=s(i),de=s(i),B=s(new Map),R=s(null),I=s(null),O=s(null),A=s(new Map),Z=s(!1),le=s(()=>{}),V=s(null),he=w(()=>{if(!f||n===null||R.current!==null||V.current!==null)return;let e=n.getBoundingClientRect();if(e.height<=0)return;let t=[...B.current].filter(([,r])=>r.hasAttribute("data-turn-ready")).map(([r,u])=>{let a=u.getBoundingClientRect(),h=D.current.turnIndexByKey.get(r),K=h===void 0?a.height:D.current.heightsPx[h];return{key:r,element:u,rect:a,bottom:a.top+K}}).filter(({rect:r,bottom:u})=>u>e.top&&r.top<e.bottom).toSorted((r,u)=>r.rect.top-u.rect.top),o=t.flatMap((r)=>[...r.element.querySelectorAll("[data-user-message-bubble], .codex-markdown-root > *")].filter((u)=>!u.closest('[aria-hidden="true"], [inert]')).map((u)=>({key:r.key,element:u,rect:u.getBoundingClientRect()})).filter(({rect:u})=>u.height>0&&u.top>=e.top&&u.top<e.bottom)).toSorted((r,u)=>r.rect.top-u.rect.top)[0]??t[0];if(o)V.current={key:o.key,element:o.element,top:o.rect.top-e.top,scrollTop:n.scrollTop}},[f,n]),ee=s(he);ee.current=he;let H=w((e,t)=>{let o=Math.min(e,i.totalHeightPx),r=g({distanceFromBottomPx:o,layout:i,overscanCount:J,viewportHeightPx:t}),u=E.current,a=u.startIndex<=r.startIndex&&u.endIndex>=r.endIndex?u:r;if(S.current=o,E.current=a,ce.current=i.turnKeys,ae(t),a!==u)oe(a)},[i]),q=w((e)=>{let t=Math.max(0,e.scrollHeight-i.totalHeightPx);return Math.max(0,e.scrollHeight-e.clientHeight-e.scrollTop-t)},[i.totalHeightPx]),Re=w((e)=>{let t=e.dataset.turnKey;if(t===void 0)throw Error("Codex measured turn is missing its key");let o=Math.max(1,e.getBoundingClientRect().height);if(l.current[t]===o)return;ee.current();let r={...l.current,[t]:o};l.current=r,Y(r)},[]),te=w(()=>{if(I.current!==null)return I.current;return I.current=new ResizeObserver((e)=>{for(let t of e){let o=t.target;if(!("turnReady"in o.dataset)&&o.querySelector("[data-markdown-pending]")!==null)continue;let r=o.dataset.turnKey;if(r===void 0)throw Error("Codex measured turn is missing its key");let u=Math.max(1,t.borderBoxSize[0]?.blockSize??t.contentRect.height);A.current.set(r,u)}if(O.current!==null||A.current.size===0)return;O.current=requestAnimationFrame(()=>{O.current=null;let t=[...A.current].filter(([r,u])=>l.current[r]!==u);if(A.current.clear(),t.length===0)return;ee.current();let o={...l.current,...Object.fromEntries(t)};l.current=o,Y(o)})}),I.current},[]),He=w((e,t)=>{let o=B.current.get(e);if(o!==void 0)te().unobserve(o),B.current.delete(e);if(t===null)return;if(t.dataset.turnKey!==e)throw Error(`Codex turn key does not match its element: ${e}`);B.current.set(e,t),te().observe(t)},[te]);xe(()=>()=>{if(I.current?.disconnect(),O.current!==null)cancelAnimationFrame(O.current);A.current.clear(),I.current=null,B.current.clear()},[]),L(()=>{le.current=()=>{if(n===null)return;let e=q(n);if(R.current!==null){S.current=e,ae(n.clientHeight||W);return}H(e,n.clientHeight||W)}},[q,n,H]),L(()=>{if(n===null)return;if(!Z.current){Z.current=!0;let o=d?.distanceFromBottomPx??0;n.scrollTo({behavior:"instant",top:Math.max(0,o>0?D.current.totalHeightPx-n.clientHeight-o:n.scrollHeight-n.clientHeight)})}let e=()=>le.current();e(),n.addEventListener("scroll",e,{passive:!0});let t=new ResizeObserver(e);return t.observe(n),()=>{n.removeEventListener("scroll",e),t.disconnect()}},[d,n]),L(()=>{if(n===null||c===null)return;let e=B.current.get(c.turnKey);if(e?.querySelector("[data-markdown-pending]")!==null)return;let t=e.offsetHeight;if(t<=0)return;if(l.current[c.turnKey]!==t){let h={...l.current,[c.turnKey]:t};l.current=h,Y(h);return}let o=c.getTargetElement(e)??e,r=e.getBoundingClientRect(),u=o.getBoundingClientRect(),a=ge({align:c.align,layout:i,targetHeightPx:u.height,targetOffsetPx:u.top-r.top,turnKey:c.turnKey,viewportHeightPx:n.clientHeight});if(a===null)throw Error(`Codex virtual turn is missing: ${c.turnKey}`);n.scrollTo({behavior:"instant",top:Math.max(0,i.totalHeightPx-n.clientHeight-a)}),H(a,n.clientHeight||W),queueMicrotask(()=>{if(R.current!==c)return;c.complete(),R.current=null,se(null)})},[i,c,n,H]),L(()=>{let e=de.current;if(de.current=i,D.current=i,n===null||c!==null){V.current=null;return}let t=V.current;V.current=null;let o=t===null?void 0:n.contains(t.element)?t.element:B.current.get(t.key);if(f&&e!==i&&t!==null&&o!==void 0){let u=o.getBoundingClientRect().top-n.getBoundingClientRect().top,a=n.scrollTop-t.scrollTop;n.scrollTop+=u-t.top+a,H(q(n),n.clientHeight);return}let r=S.current;if(f&&e!==i&&Z.current)r=Math.max(0,e.totalHeightPx-n.clientHeight-n.scrollTop);if((r>24||f)&&e!==i){let u=q(n);if(u<=96&&!f){H(u,p);return}let a=g({distanceFromBottomPx:r,layout:e,overscanCount:0,viewportHeightPx:p}),h=e.turnKeys.slice(a.startIndex,a.endIndex).filter((y)=>i.turnIndexByKey.has(y)),K=h.find((y)=>l.current[y]!==void 0)??h[0];if(K!==void 0){let y=me({anchorKey:K,distanceFromBottomPx:r,nextLayout:i,previousLayout:e});if(y===null)throw Error(`Codex viewport anchor is missing: ${K}`);r=y,n.scrollTo({behavior:"instant",top:Math.max(0,i.totalHeightPx-n.clientHeight-r)})}}H(r,p)},[i,c,q,n,H,p,f]),L(()=>{E.current=C},[C]),xe(()=>()=>{R.current?.complete(),R.current=null;let e=E.current,o=D.current.turnKeys[e.startIndex];ye.set(T,{distanceFromBottomPx:S.current,renderedWindow:o===void 0?null:{anchorKey:o,count:e.endIndex-e.startIndex},turnHeightsByKey:l.current})},[T]),be(b,()=>({scrollToKey(e,t=(r)=>r,o={align:"center"}){R.current?.complete();let r=i.turnIndexByKey.get(e);if(r===void 0)throw Error(`Codex virtual turn is missing: ${e}`);let u=i.turnKeys[r],a=pe({layout:i,turnKey:e,viewportHeightPx:p});if(a===null)throw Error(`Codex virtual turn is missing: ${e}`);let h=g({distanceFromBottomPx:a,layout:i,overscanCount:J,viewportHeightPx:p});return E.current=h,oe(h),new Promise((K)=>{let y={align:o.align,complete:K,getTargetElement:t,turnKey:u};R.current=y,se(y)})}}),[i,p]);let F=C,j=ce.current;if(!(j===i.turnKeys||j.length===i.turnKeys.length&&j.every((e,t)=>e===i.turnKeys[t]))){let e=j[C.startIndex];F=(e===void 0?null:z({anchorKey:e,layout:i,previousRange:C}))??g({distanceFromBottomPx:S.current,layout:i,overscanCount:J,viewportHeightPx:p})}let ne=v.length-1,fe=v[ne],re=v.slice(F.startIndex,Math.min(F.endIndex,ne)).map((e,t)=>({entry:e,index:F.startIndex+t}));if(fe!==void 0)re.push({entry:fe,index:ne});return m("div",{"data-codex-thread":!0,"data-codex-virtualized-pending-key":c?.turnKey,"data-codex-virtualized-range":`${F.startIndex}:${F.endIndex}`,"data-codex-virtualized-total-count":v.length,"data-codex-virtualized-turn-count":re.length,className:"relative shrink-0",style:{height:i.totalHeightPx},children:[P&&m("div",{ref:G,"data-codex-thread-leading":!0,className:"absolute inset-x-0 top-0",children:M},void 0,!1,void 0,this),re.map(({entry:e,index:t})=>m("div",{className:"absolute inset-x-0",style:{top:i.topOffsetsPx[t]??0},children:m(Be,{turnKey:e.turnKey,heightPx:i.heightsPx[t],placeholder:e.placeholder,deferUntilReady:e.deferUntilReady,observe:He,onReady:Re,children:U(e,t)},void 0,!1,void 0,this)},e.turnKey,!1,void 0,this))]},void 0,!0,void 0,this)});export{Me as VirtualizedTurnList};
1
+ import{ue,g,z,me,pe,ge}from"../chunk-p4c1w6qx.js";import{forwardRef as be,useCallback as w,useEffect as ye,useImperativeHandle as Pe,useLayoutEffect as L,useMemo as ie,useRef as s,useState as N}from"react";import{jsx as H,jsxs as oe}from"react/jsx-runtime";var Be=12,J=2,W=800,ve=new Map;function Ke({turnKey:_,heightPx:y,placeholder:U=!1,deferUntilReady:n=!1,observe:T,onReady:M,children:k}){let m=s(null),[b,G]=N(!1),X=w((f)=>{m.current=f,T(_,f)},[T,_]);return L(()=>{let f=m.current;if(f===null)throw Error("Codex turn element is missing");let P=()=>{M(f),G(!0)};if(f.querySelector("[data-markdown-pending]")===null){P();return}let d=new MutationObserver(()=>{if(f.querySelector("[data-markdown-pending]")!==null)return;d.disconnect(),P()});return d.observe(f,{childList:!0,subtree:!0}),()=>d.disconnect()},[M]),oe("div",{style:b?void 0:{position:"relative",height:y,overflow:"hidden"},children:[H("div",{ref:X,className:"[&_[data-virtualized-turn-content]]:[content-visibility:visible]","data-turn-key":_,"aria-busy":!b||void 0,style:!b&&!U&&n?{visibility:"hidden"}:void 0,"data-turn-ready":b?"":void 0,children:k}),!b&&!U&&n&&H("div",{"aria-hidden":"true",className:"codex-turn-loading",children:oe("div",{className:"codex-turn-loading-lines",children:[H("span",{}),H("span",{}),H("span",{})]})})]})}var Ce=be(function({entries:y,renderTurn:U,scrollElement:n,sessionKey:T,leadingContent:M,leadingInsetPx:k=0,preserveViewport:m=!1},b){let G=s(null),[X,f]=N(k),P=M!==void 0&&M!==null;L(()=>{let e=G.current;if(e===null)return;let t=()=>f(e.getBoundingClientRect().height);t();let o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[P]);let d=ie(()=>ve.get(T),[T]),[Q,Y]=N(()=>d?.turnHeightsByKey??{}),i=ie(()=>ue({entries:y,gapPx:Be,measuredHeightsByKey:Q,leadingInsetPx:P?X:k}),[y,Q,P,X,k]),Re=ie(()=>{let e=g({distanceFromBottomPx:d?.distanceFromBottomPx??0,layout:i,overscanCount:J,viewportHeightPx:W}),t=d?.renderedWindow;if(t===void 0||t===null)return e;return z({anchorKey:t.anchorKey,layout:i,previousRange:{startIndex:0,endIndex:Math.min(t.count,e.endIndex-e.startIndex)}})??e},[d,i]),[C,ae]=N(Re),[v,se]=N(W),[c,ce]=N(null),S=s(d?.distanceFromBottomPx??0),E=s(C),de=s(i.turnKeys),l=s(Q),D=s(i),le=s(i),B=s(new Map),p=s(null),I=s(null),O=s(null),A=s(new Map),Z=s(!1),he=s(()=>{}),V=s(null),fe=w(()=>{if(!m||n===null||p.current!==null||V.current!==null)return;let e=n.getBoundingClientRect();if(e.height<=0)return;let t=[...B.current].filter(([,r])=>r.hasAttribute("data-turn-ready")).map(([r,u])=>{let a=u.getBoundingClientRect(),h=D.current.turnIndexByKey.get(r),K=h===void 0?a.height:D.current.heightsPx[h];return{key:r,element:u,rect:a,bottom:a.top+K}}).filter(({rect:r,bottom:u})=>u>e.top&&r.top<e.bottom).toSorted((r,u)=>r.rect.top-u.rect.top),o=t.flatMap((r)=>[...r.element.querySelectorAll("[data-user-message-bubble], .codex-markdown-root > *")].filter((u)=>!u.closest('[aria-hidden="true"], [inert]')).map((u)=>({key:r.key,element:u,rect:u.getBoundingClientRect()})).filter(({rect:u})=>u.height>0&&u.top>=e.top&&u.top<e.bottom)).toSorted((r,u)=>r.rect.top-u.rect.top)[0]??t[0];if(o)V.current={key:o.key,element:o.element,top:o.rect.top-e.top,scrollTop:n.scrollTop}},[m,n]),ee=s(fe);ee.current=fe;let R=w((e,t)=>{let o=Math.min(e,i.totalHeightPx),r=g({distanceFromBottomPx:o,layout:i,overscanCount:J,viewportHeightPx:t}),u=E.current,a=u.startIndex<=r.startIndex&&u.endIndex>=r.endIndex?u:r;if(S.current=o,E.current=a,de.current=i.turnKeys,se(t),a!==u)ae(a)},[i]),q=w((e)=>{let t=Math.max(0,e.scrollHeight-i.totalHeightPx);return Math.max(0,e.scrollHeight-e.clientHeight-e.scrollTop-t)},[i.totalHeightPx]),He=w((e)=>{let t=e.dataset.turnKey;if(t===void 0)throw Error("Codex measured turn is missing its key");let o=Math.max(1,e.getBoundingClientRect().height);if(l.current[t]===o)return;ee.current();let r={...l.current,[t]:o};l.current=r,Y(r)},[]),te=w(()=>{if(I.current!==null)return I.current;return I.current=new ResizeObserver((e)=>{for(let t of e){let o=t.target;if(!("turnReady"in o.dataset)&&o.querySelector("[data-markdown-pending]")!==null)continue;let r=o.dataset.turnKey;if(r===void 0)throw Error("Codex measured turn is missing its key");let u=Math.max(1,t.borderBoxSize[0]?.blockSize??t.contentRect.height);A.current.set(r,u)}if(O.current!==null||A.current.size===0)return;O.current=requestAnimationFrame(()=>{O.current=null;let t=[...A.current].filter(([r,u])=>l.current[r]!==u);if(A.current.clear(),t.length===0)return;ee.current();let o={...l.current,...Object.fromEntries(t)};l.current=o,Y(o)})}),I.current},[]),Te=w((e,t)=>{let o=B.current.get(e);if(o!==void 0)te().unobserve(o),B.current.delete(e);if(t===null)return;if(t.dataset.turnKey!==e)throw Error(`Codex turn key does not match its element: ${e}`);B.current.set(e,t),te().observe(t)},[te]);ye(()=>()=>{if(I.current?.disconnect(),O.current!==null)cancelAnimationFrame(O.current);A.current.clear(),I.current=null,B.current.clear()},[]),L(()=>{he.current=()=>{if(n===null)return;let e=q(n);if(p.current!==null){S.current=e,se(n.clientHeight||W);return}R(e,n.clientHeight||W)}},[q,n,R]),L(()=>{if(n===null)return;if(!Z.current){Z.current=!0;let o=d?.distanceFromBottomPx??0;n.scrollTo({behavior:"instant",top:Math.max(0,o>0?D.current.totalHeightPx-n.clientHeight-o:n.scrollHeight-n.clientHeight)})}let e=()=>he.current();e(),n.addEventListener("scroll",e,{passive:!0});let t=new ResizeObserver(e);return t.observe(n),()=>{n.removeEventListener("scroll",e),t.disconnect()}},[d,n]),L(()=>{if(n===null||c===null)return;let e=B.current.get(c.turnKey);if(e?.querySelector("[data-markdown-pending]")!==null)return;let t=e.offsetHeight;if(t<=0)return;if(l.current[c.turnKey]!==t){let h={...l.current,[c.turnKey]:t};l.current=h,Y(h);return}let o=c.getTargetElement(e)??e,r=e.getBoundingClientRect(),u=o.getBoundingClientRect(),a=ge({align:c.align,layout:i,targetHeightPx:u.height,targetOffsetPx:u.top-r.top,turnKey:c.turnKey,viewportHeightPx:n.clientHeight});if(a===null)throw Error(`Codex virtual turn is missing: ${c.turnKey}`);n.scrollTo({behavior:"instant",top:Math.max(0,i.totalHeightPx-n.clientHeight-a)}),R(a,n.clientHeight||W),queueMicrotask(()=>{if(p.current!==c)return;c.complete(),p.current=null,ce(null)})},[i,c,n,R]),L(()=>{let e=le.current;if(le.current=i,D.current=i,n===null||c!==null){V.current=null;return}let t=V.current;V.current=null;let o=t===null?void 0:n.contains(t.element)?t.element:B.current.get(t.key);if(m&&e!==i&&t!==null&&o!==void 0){let u=o.getBoundingClientRect().top-n.getBoundingClientRect().top,a=n.scrollTop-t.scrollTop;n.scrollTop+=u-t.top+a,R(q(n),n.clientHeight);return}let r=S.current;if(m&&e!==i&&Z.current)r=Math.max(0,e.totalHeightPx-n.clientHeight-n.scrollTop);if((r>24||m)&&e!==i){let u=q(n);if(u<=96&&!m){R(u,v);return}let a=g({distanceFromBottomPx:r,layout:e,overscanCount:0,viewportHeightPx:v}),h=e.turnKeys.slice(a.startIndex,a.endIndex).filter((x)=>i.turnIndexByKey.has(x)),K=h.find((x)=>l.current[x]!==void 0)??h[0];if(K!==void 0){let x=me({anchorKey:K,distanceFromBottomPx:r,nextLayout:i,previousLayout:e});if(x===null)throw Error(`Codex viewport anchor is missing: ${K}`);r=x,n.scrollTo({behavior:"instant",top:Math.max(0,i.totalHeightPx-n.clientHeight-r)})}}R(r,v)},[i,c,q,n,R,v,m]),L(()=>{E.current=C},[C]),ye(()=>()=>{p.current?.complete(),p.current=null;let e=E.current,o=D.current.turnKeys[e.startIndex];ve.set(T,{distanceFromBottomPx:S.current,renderedWindow:o===void 0?null:{anchorKey:o,count:e.endIndex-e.startIndex},turnHeightsByKey:l.current})},[T]),Pe(b,()=>({scrollToKey(e,t=(r)=>r,o={align:"center"}){p.current?.complete();let r=i.turnIndexByKey.get(e);if(r===void 0)throw Error(`Codex virtual turn is missing: ${e}`);let u=i.turnKeys[r],a=pe({layout:i,turnKey:e,viewportHeightPx:v});if(a===null)throw Error(`Codex virtual turn is missing: ${e}`);let h=g({distanceFromBottomPx:a,layout:i,overscanCount:J,viewportHeightPx:v});return E.current=h,ae(h),new Promise((K)=>{let x={align:o.align,complete:K,getTargetElement:t,turnKey:u};p.current=x,ce(x)})}}),[i,v]);let F=C,j=de.current;if(!(j===i.turnKeys||j.length===i.turnKeys.length&&j.every((e,t)=>e===i.turnKeys[t]))){let e=j[C.startIndex];F=(e===void 0?null:z({anchorKey:e,layout:i,previousRange:C}))??g({distanceFromBottomPx:S.current,layout:i,overscanCount:J,viewportHeightPx:v})}let ne=y.length-1,xe=y[ne],re=y.slice(F.startIndex,Math.min(F.endIndex,ne)).map((e,t)=>({entry:e,index:F.startIndex+t}));if(xe!==void 0)re.push({entry:xe,index:ne});return oe("div",{"data-codex-thread":!0,"data-codex-virtualized-pending-key":c?.turnKey,"data-codex-virtualized-range":`${F.startIndex}:${F.endIndex}`,"data-codex-virtualized-total-count":y.length,"data-codex-virtualized-turn-count":re.length,className:"relative shrink-0",style:{height:i.totalHeightPx},children:[P&&H("div",{ref:G,"data-codex-thread-leading":!0,className:"absolute inset-x-0 top-0",children:M}),re.map(({entry:e,index:t})=>H("div",{className:"absolute inset-x-0",style:{top:i.topOffsetsPx[t]??0},children:H(Ke,{turnKey:e.turnKey,heightPx:i.heightsPx[t],placeholder:e.placeholder,deferUntilReady:e.deferUntilReady,observe:Te,onReady:He,children:U(e,t)})},e.turnKey))]})});export{Ce as VirtualizedTurnList};
@@ -1,3 +1,3 @@
1
- import{e}from"../chunk-xgy0heva.js";import{R}from"../chunk-b5srhd6k.js";import"../chunk-z3gwnjmk.js";import{q}from"../chunk-15a7wypc.js";import{Le}from"../chunk-tbr607hk.js";import{_e}from"../chunk-twww750f.js";import{autoUpdate as rt}from"@floating-ui/dom";import{cn as J}from"cn";import{BookOpenTextIcon as st,FileIcon as it,StoreIcon as lt}from"lucide-react";import{useCallback as ut,useEffect as v,useLayoutEffect as X,useMemo as Y,useRef as Z,useState as g}from"react";import{createPortal as at}from"react-dom";import{jsxDEV as i,Fragment as ct}from"react/jsx-dev-runtime";function wt({handleRef:c,anchorRef:m,commands:T,searchFiles:a,onMention:_,onSearchError:H,fileSearchDebounceMs:C=0,bashMode:A=!1,forcedOpen:l=!1,onForcedOpenChange:f,emptyLabel:F,fileStatusLabels:E,morePlugins:M}){let j=_e(),u=j.textInput.value,[z,K]=g(0),[y,D]=g(null),[b,h]=g(0),U=Z(null);v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=()=>K(t.selectionStart??0),o=()=>{if(document.activeElement===t)n()};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("input",n),t.addEventListener("select",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("input",n),t.removeEventListener("select",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",o)}});let V=Y(()=>A&&u.startsWith("!")?null:Le(u,z),[u,z,A]),r=V?.kind==="at"&&!a?null:V,P=`${r?.kind??"forced"}:${r?.query??""}:${l}`,[O,tt]=g(P);if(O!==P)tt(P),h(0);let L=Z(null);v(()=>{if(!l){L.current=null;return}if(L.current===null)L.current=u;else if(u!==L.current)f?.(!1)},[l,u,f]);let x=r?.kind==="at"?r.query:null;v(()=>{if(x===null||!a){D(null);return}let t=!0,n=()=>{a(x).then((s)=>{if(t)D({query:x,search:a,items:s})},(s)=>{if(t)D({query:x,search:a,items:[]}),H(s)})},o=C>0?window.setTimeout(n,C):null;if(o===null)n();return()=>{if(t=!1,o!==null)window.clearTimeout(o)}},[x,a,C,H]);let d=Y(()=>{if(r?.kind==="at")return y?.query===r.query&&y.search===a?y.items:[];if(r)return q(T,r.query);if(l)return q(T,"");return[]},[r,l,T,y,a]),[et,N]=g(!1);v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=()=>N(!0),o=()=>{if(N(!1),l)f?.(!1)};return N(document.activeElement===t),t.addEventListener("focus",n),t.addEventListener("blur",o),()=>{t.removeEventListener("focus",n),t.removeEventListener("blur",o)}},[c,l,f]),v(()=>{if(l)c.current?.getTextarea()?.focus()},[l,c]);let p=et&&(r!==null?r.kind==="slash"||d.length>0||!!E:l);v(()=>{if(!p)return;U.current?.querySelector(`[data-idx="${b}"]`)?.scrollIntoView({block:"nearest"})},[b,p]);function W(t){let n=c.current?.getTextarea();if(!n)return;let o,s;if(r){let B=r.kind==="slash"?`/${t.payload} `:`@${t.label} `;if(o=u.slice(0,r.start)+B+u.slice(r.end),r.kind==="at")_?.(t.payload);s=r.start+B.length}else if(l)o=`${u.length===0||u.endsWith(`
2
- `)?u:`${u}
3
- `}/${t.payload} `,s=o.length,f?.(!1);else return;j.textInput.setInput(o),requestAnimationFrame(()=>{n.focus(),n.setSelectionRange(s,s)})}v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=(o)=>{if(!p)return;if(c.current?.isComposing()||o.isComposing||o.keyCode===229)return;if(o.key==="ArrowDown")o.preventDefault(),o.stopPropagation(),h((s)=>d.length===0?0:Math.min(d.length-1,s+1));else if(o.key==="ArrowUp")o.preventDefault(),o.stopPropagation(),h((s)=>Math.max(0,s-1));else if(o.key==="Enter"||o.key==="Tab"){o.preventDefault(),o.stopPropagation();let s=d[b];if(s)W(s)}else if(o.key==="Escape")if(o.preventDefault(),o.stopPropagation(),r)K(Math.max(0,r.start-1)),t.setSelectionRange(r.start,r.start);else f?.(!1)};return t.addEventListener("keydown",n,!0),()=>t.removeEventListener("keydown",n,!0)});let[k,Q]=g(null),[S,nt]=g(null),I=ut(()=>{let t=m?.current;if(!t)return;let n=t.getBoundingClientRect();Q({left:n.left,width:n.width,bottom:window.innerHeight-n.top+8})},[m]);if(X(()=>{if(!p){Q(null);return}I()},[p,I]),X(()=>{let t=m?.current;if(!p||!t||!S)return;return rt(t,S,I,{animationFrame:!0})},[p,S,m,I]),!p||m&&!k)return null;let w=r?r.kind==="slash":l,ot=w?st:it,G=i("div",{ref:nt,className:m?"fixed z-50":"absolute inset-x-0 bottom-full z-50 mb-2",style:m&&k?{left:k.left,width:k.width,bottom:k.bottom}:void 0,children:i("div",{ref:U,role:"listbox",onMouseDown:(t)=>t.preventDefault(),className:"bg-popover text-popover-foreground ring-foreground/10 pointer-events-auto w-full overflow-hidden rounded-lg p-1 shadow-md ring-1 outline-hidden",children:[i("div",{className:"max-h-72 overflow-y-auto",children:[d.length===0&&w&&i("div",{className:"text-muted-foreground px-2 py-3 text-xs",children:F},void 0,!1,void 0,this),d.length===0&&!w&&E&&i("div",{role:"status",className:"text-muted-foreground px-2 py-3 text-xs",children:y?.query===x&&y.search===a?E.empty:E.loading},void 0,!1,void 0,this),d.map((t,n)=>i(e,{type:"button",variant:"ghost",role:"option","aria-selected":n===b,"data-idx":n,onMouseDown:(o)=>{o.preventDefault(),W(t)},onMouseEnter:()=>h(n),className:J("flex h-auto w-full items-center justify-start gap-2.5 rounded-md px-2.5 py-2 text-start",n===b&&"bg-muted"),children:[i(ot,{className:J("size-4 shrink-0",w?"text-blue-500":"text-muted-foreground")},void 0,!1,void 0,this),i("span",{className:"text-foreground shrink-0 text-sm font-medium",children:t.label},void 0,!1,void 0,this),t.description&&i("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:t.description},void 0,!1,void 0,this)]},t.key,!0,void 0,this))]},void 0,!0,void 0,this),w&&M&&i(ct,{children:[i(R,{},void 0,!1,void 0,this),i(e,{type:"button",variant:"ghost",onMouseDown:(t)=>{t.preventDefault(),f?.(!1),M.open()},className:"h-auto w-full justify-start px-2.5 py-2",children:[i(lt,{"data-icon":"inline-start"},void 0,!1,void 0,this),M.label]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return m?at(G,document.body):G}export{wt as CompletionMenu};
1
+ import{e}from"../chunk-vk39871j.js";import{R}from"../chunk-8gv9naya.js";import"../chunk-z3gwnjmk.js";import{q}from"../chunk-15a7wypc.js";import{Le}from"../chunk-tbr607hk.js";import{_e}from"../chunk-cwp8ct1z.js";import{autoUpdate as st}from"@floating-ui/dom";import{cn as X}from"cn";import{BookOpenTextIcon as it,FileIcon as lt,StoreIcon as ut}from"lucide-react";import{useCallback as at,useEffect as v,useLayoutEffect as Y,useMemo as Z,useRef as _,useState as g}from"react";import{createPortal as ct}from"react-dom";import{jsx as p,jsxs as E,Fragment as mt}from"react/jsx-runtime";function Et({handleRef:a,anchorRef:c,commands:C,searchFiles:u,onMention:F,onSearchError:A,fileSearchDebounceMs:M=0,bashMode:j=!1,forcedOpen:i=!1,onForcedOpenChange:f,emptyLabel:O,fileStatusLabels:h,morePlugins:D}){let z=_e(),l=z.textInput.value,[K,U]=g(0),[y,P]=g(null),[b,L]=g(0),V=_(null);v(()=>{let t=a.current?.getTextarea();if(!t)return;let n=()=>U(t.selectionStart??0),o=()=>{if(document.activeElement===t)n()};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("input",n),t.addEventListener("select",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("input",n),t.removeEventListener("select",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",o)}});let W=Z(()=>j&&l.startsWith("!")?null:Le(l,K),[l,K,j]),r=W?.kind==="at"&&!u?null:W,N=`${r?.kind??"forced"}:${r?.query??""}:${i}`,[tt,et]=g(N);if(tt!==N)et(N),L(0);let I=_(null);v(()=>{if(!i){I.current=null;return}if(I.current===null)I.current=l;else if(l!==I.current)f?.(!1)},[i,l,f]);let x=r?.kind==="at"?r.query:null;v(()=>{if(x===null||!u){P(null);return}let t=!0,n=()=>{u(x).then((s)=>{if(t)P({query:x,search:u,items:s})},(s)=>{if(t)P({query:x,search:u,items:[]}),A(s)})},o=M>0?window.setTimeout(n,M):null;if(o===null)n();return()=>{if(t=!1,o!==null)window.clearTimeout(o)}},[x,u,M,A]);let d=Z(()=>{if(r?.kind==="at")return y?.query===r.query&&y.search===u?y.items:[];if(r)return q(C,r.query);if(i)return q(C,"");return[]},[r,i,C,y,u]),[nt,S]=g(!1);v(()=>{let t=a.current?.getTextarea();if(!t)return;let n=()=>S(!0),o=()=>{if(S(!1),i)f?.(!1)};return S(document.activeElement===t),t.addEventListener("focus",n),t.addEventListener("blur",o),()=>{t.removeEventListener("focus",n),t.removeEventListener("blur",o)}},[a,i,f]),v(()=>{if(i)a.current?.getTextarea()?.focus()},[i,a]);let m=nt&&(r!==null?r.kind==="slash"||d.length>0||!!h:i);v(()=>{if(!m)return;V.current?.querySelector(`[data-idx="${b}"]`)?.scrollIntoView({block:"nearest"})},[b,m]);function Q(t){let n=a.current?.getTextarea();if(!n)return;let o,s;if(r){let H=r.kind==="slash"?`/${t.payload} `:`@${t.label} `;if(o=l.slice(0,r.start)+H+l.slice(r.end),r.kind==="at")F?.(t.payload);s=r.start+H.length}else if(i)o=`${l.length===0||l.endsWith(`
2
+ `)?l:`${l}
3
+ `}/${t.payload} `,s=o.length,f?.(!1);else return;z.textInput.setInput(o),requestAnimationFrame(()=>{n.focus(),n.setSelectionRange(s,s)})}v(()=>{let t=a.current?.getTextarea();if(!t)return;let n=(o)=>{if(!m)return;if(a.current?.isComposing()||o.isComposing||o.keyCode===229)return;if(o.key==="ArrowDown")o.preventDefault(),o.stopPropagation(),L((s)=>d.length===0?0:Math.min(d.length-1,s+1));else if(o.key==="ArrowUp")o.preventDefault(),o.stopPropagation(),L((s)=>Math.max(0,s-1));else if(o.key==="Enter"||o.key==="Tab"){o.preventDefault(),o.stopPropagation();let s=d[b];if(s)Q(s)}else if(o.key==="Escape")if(o.preventDefault(),o.stopPropagation(),r)U(Math.max(0,r.start-1)),t.setSelectionRange(r.start,r.start);else f?.(!1)};return t.addEventListener("keydown",n,!0),()=>t.removeEventListener("keydown",n,!0)});let[k,G]=g(null),[B,ot]=g(null),T=at(()=>{let t=c?.current;if(!t)return;let n=t.getBoundingClientRect();G({left:n.left,width:n.width,bottom:window.innerHeight-n.top+8})},[c]);if(Y(()=>{if(!m){G(null);return}T()},[m,T]),Y(()=>{let t=c?.current;if(!m||!t||!B)return;return st(t,B,T,{animationFrame:!0})},[m,B,c,T]),!m||c&&!k)return null;let w=r?r.kind==="slash":i,rt=w?it:lt,J=p("div",{ref:ot,className:c?"fixed z-50":"absolute inset-x-0 bottom-full z-50 mb-2",style:c&&k?{left:k.left,width:k.width,bottom:k.bottom}:void 0,children:E("div",{ref:V,role:"listbox",onMouseDown:(t)=>t.preventDefault(),className:"bg-popover text-popover-foreground ring-foreground/10 pointer-events-auto w-full overflow-hidden rounded-lg p-1 shadow-md ring-1 outline-hidden",children:[E("div",{className:"max-h-72 overflow-y-auto",children:[d.length===0&&w&&p("div",{className:"text-muted-foreground px-2 py-3 text-xs",children:O}),d.length===0&&!w&&h&&p("div",{role:"status",className:"text-muted-foreground px-2 py-3 text-xs",children:y?.query===x&&y.search===u?h.empty:h.loading}),d.map((t,n)=>E(e,{type:"button",variant:"ghost",role:"option","aria-selected":n===b,"data-idx":n,onMouseDown:(o)=>{o.preventDefault(),Q(t)},onMouseEnter:()=>L(n),className:X("flex h-auto w-full items-center justify-start gap-2.5 rounded-md px-2.5 py-2 text-start",n===b&&"bg-muted"),children:[p(rt,{className:X("size-4 shrink-0",w?"text-blue-500":"text-muted-foreground")}),p("span",{className:"text-foreground shrink-0 text-sm font-medium",children:t.label}),t.description&&p("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:t.description})]},t.key))]}),w&&D&&E(mt,{children:[p(R,{}),E(e,{type:"button",variant:"ghost",onMouseDown:(t)=>{t.preventDefault(),f?.(!1),D.open()},className:"h-auto w-full justify-start px-2.5 py-2",children:[p(ut,{"data-icon":"inline-start"}),D.label]})]})]})});return c?ct(J,document.body):J}export{Et as CompletionMenu};
@@ -6,5 +6,5 @@ export declare function EffortSlider({ name, value, levels, disabled, onChange }
6
6
  name: string;
7
7
  }>;
8
8
  disabled?: boolean;
9
- onChange: (v: string) => void;
9
+ onChange: (v: string) => void | Promise<void>;
10
10
  }): import("react").JSX.Element;
@@ -1 +1 @@
1
- import{Q}from"../chunk-h310nm02.js";export{Q as EffortSlider};
1
+ import{Q}from"../chunk-71kpqt2g.js";export{Q as EffortSlider};
@@ -1 +1 @@
1
- import{n}from"../chunk-bgj6z7z4.js";import"../chunk-s4w6yjc0.js";export{n as MenuRadioSelect};
1
+ import{n}from"../chunk-ya0gvswb.js";import"../chunk-47f4a577.js";export{n as MenuRadioSelect};
@@ -1 +1 @@
1
- import{e}from"../chunk-xgy0heva.js";import{v,b,m,y,D,w,N,S,E,J,s}from"../chunk-s4w6yjc0.js";import{L}from"../chunk-j63t6dxg.js";import{ie,ae,se}from"../chunk-qf9n7v84.js";import{Q}from"../chunk-h310nm02.js";import{n}from"../chunk-bgj6z7z4.js";import{cn as p}from"cn";import{ArrowUpRight as pe,ChevronUp as q,Loader2Icon as H,Zap as K}from"lucide-react";import{Fragment as ce,useState as X}from"react";import{jsxDEV as a,Fragment as h}from"react/jsx-dev-runtime";function ye({value:g,onChange:Y,models:C,modelGroups:R,compactCatalog:d,effortPresentation:G="slider",unavailableEffort:T,providerMenu:x,header:M,className:P,condensed:I,stripLabelPrefix:A,showDescription:ee,showModelList:ne=!0,loading:oe,switching:F,isLoading:te,effortConfig:o,booleanOptions:z,onBooleanChange:j,selectOptions:le=[],t:c,...u}){let[de,re]=X(!1),[me,ue]=X(!1),r=z?.find((i)=>i.id==="fast_mode"),B=d?z?.filter((i)=>i!==r):z,U=(i)=>A&&i.startsWith(A)?i.slice(A.length):i;if(oe)return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:a(e,{variant:"ghost",disabled:!0,className:p("h-7 min-w-0 shrink gap-1.5 rounded-md px-2 text-xs font-normal",P),children:[a(H,{className:"size-3 animate-spin"},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground truncate",children:c("model.loadingModels")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:[x&&a(v,{open:de,onOpenChange:re,children:[a(ie,{children:[a(ae,{render:a(b,{render:a(e,{"data-testid":"provider-trigger",variant:"ghost",disabled:u.disabled,className:p("h-7 shrink-0 gap-1 rounded-md px-1.5","hover:bg-accent"),children:[x.icon,a(q,{className:"size-2.5 shrink-0 opacity-60"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),a(se,{children:c("model.switchProvider")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(m,{side:"top",align:"end",sideOffset:4,className:"z-100 min-w-[10rem]",children:[x.groups.map((i,l)=>a(ce,{children:[l>0&&i.length>0&&a(s,{},void 0,!1,void 0,this),a(n,{value:x.value,onValueChange:x.onChange,options:i},void 0,!1,void 0,this)]},l,!0,void 0,this)),x.moreAction&&a(h,{children:[a(s,{},void 0,!1,void 0,this),a(w,{onClick:x.moreAction,className:"whitespace-nowrap",children:[a("span",{className:"min-w-0 flex-1 truncate",children:c("model.moreModels")},void 0,!1,void 0,this),a(pe,{className:"size-4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a(v,{open:me,onOpenChange:ue,children:[a(ie,{children:[a(ae,{render:a(b,{render:a(e,{"data-testid":"model-trigger","aria-busy":F,variant:"ghost",className:p("h-7 gap-1.5 rounded-md px-2 text-xs font-normal","hover:bg-accent","max-w-full min-w-0 shrink",I&&"h-7 gap-1 px-1.5 text-[11px]",P),...u,children:[g.icon,z?.some((i)=>i.id==="fast_mode"&&i.currentValue&&!i.disabled)&&a(K,{"aria-hidden":"true",className:"size-3 shrink-0"},void 0,!1,void 0,this),a("span",{className:p("min-w-0 flex-1 truncate text-start",I&&"text-[11px]"),children:U(g.label)||c("model.selectModel")},void 0,!1,void 0,this),o&&a("span",{className:"text-muted-foreground grid shrink-0 justify-items-center",children:[a("span",{className:"invisible col-start-1 row-start-1",children:o.sizer??o.levels.reduce((i,l)=>l.name.length>i.length?l.name:i,"")},void 0,!1,void 0,this),a("span",{className:"col-start-1 row-start-1",children:o.levels.find((i)=>i.value===o.value)?.name??o.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?a(H,{"data-testid":"model-switch-loading",className:"size-3 shrink-0 animate-spin"},void 0,!1,void 0,this):a(q,{className:p("size-3 shrink-0",I&&"size-2.5")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),a(se,{children:c("model.switchModel")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(m,{side:"top",align:"end",sideOffset:4,className:p("z-100 w-auto max-w-[min(24rem,calc(100vw-1rem))] min-w-[14rem]",d&&"flex h-[350px] w-80 min-w-0 flex-col overflow-hidden rounded-xl p-1.5"),children:[d&&a(h,{children:[a(y,{"data-model-menu-header":!0,className:"flex shrink-0 items-center justify-between gap-2 px-1 py-1",children:[o?G==="slider"?a("div",{role:"menuitem","aria-label":o.name,className:"min-w-0 [&>div]:justify-start [&>div]:gap-3 [&>div]:px-2 [&>div]:py-1.5",children:a(Q,{...o,disabled:u.disabled},void 0,!1,void 0,this)},void 0,!1,void 0,this):a(N,{children:[a(S,{disabled:u.disabled,className:"h-8 min-w-0 flex-1 gap-2 rounded-md",children:[a("span",{children:o.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground min-w-0 truncate text-xs",children:o.levels.find((i)=>i.value===o.value)?.name??o.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(E,{children:a(n,{value:o.value,onValueChange:o.onChange,options:o.levels.map((i)=>({value:i.value,label:i.name}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):T?a(w,{disabled:!0,className:"h-8 min-w-0 flex-1 gap-2",children:[a("span",{children:T.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground truncate text-xs",children:T.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this):a(D,{className:"min-w-0 flex-1 truncate",children:M?.name},void 0,!1,void 0,this),r&&a(J,{"aria-label":r.name,title:r.title??r.name,disabled:u.disabled||r.disabled,checked:r.currentValue,closeOnClick:!1,onCheckedChange:(i)=>j?.(r.id,i),className:p("hover:bg-accent focus:hover:bg-accent focus-visible:bg-accent ml-auto size-8 shrink-0 justify-center rounded-md p-0 focus:bg-transparent [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",r.currentValue&&!r.disabled?"text-foreground [&_svg]:fill-current":"text-muted-foreground"),children:r.icon??a(K,{className:"size-4","aria-hidden":"true"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(s,{className:"shrink-0"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M&&!d&&a(h,{children:[a("div",{className:"flex items-center gap-2 px-2 py-2",children:[M.icon,a("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:M.name},void 0,!1,void 0,this),M.action]},void 0,!0,void 0,this),a(s,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(y,{"data-model-menu-list":d?"":void 0,className:d?"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain":void 0,children:[ne&&(te?a(w,{disabled:!0,className:"text-muted-foreground",children:c("model.loadingModels")},void 0,!1,void 0,this):C.length===0?a(w,{disabled:!0,className:"text-muted-foreground",children:c("model.noModelsAvailable")},void 0,!1,void 0,this):(()=>{let i=C.filter((t)=>!t.more),l=C.filter((t)=>t.more),W=i.length>0&&l.length>0,O=(t,k)=>({disabled:u.disabled,icon:t.icon,value:t.api_id,label:U(t.label),description:k?.noDescription?void 0:ee?t.description:void 0}),V=(t)=>{let k=C.find((_)=>_.api_id===t);if(k)Y(k)};if(d)return a(n,{value:g.api_id,onValueChange:V,itemClassName:"min-w-0 max-w-full font-normal whitespace-nowrap",options:C.map((t)=>O(t))},void 0,!1,void 0,this);return a(h,{children:[R?R.map((t)=>{let k=t.models.filter((f)=>!f.more),_=t.models.filter((f)=>f.more),Z=k.length>0&&_.length>0;return a(y,{children:[a(D,{className:"text-muted-foreground text-xs font-normal",children:t.name},void 0,!1,void 0,this),a(n,{value:g.api_id,onValueChange:V,itemClassName:"font-medium whitespace-nowrap",options:(Z?k:t.models).map((f)=>O(f))},void 0,!1,void 0,this),Z&&a(N,{children:[a(S,{className:"font-medium whitespace-nowrap",children:c("model.moreModels")},void 0,!1,void 0,this),a(E,{children:a(n,{value:g.api_id,onValueChange:V,itemClassName:"font-medium whitespace-nowrap",options:_.map((f)=>O(f,{noDescription:!0}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},t.id,!0,void 0,this)}):a(n,{value:g.api_id,onValueChange:V,itemClassName:"font-medium whitespace-nowrap",options:(W?i:C).map((t)=>O(t))},void 0,!1,void 0,this),!R&&W&&a(N,{children:[a(S,{className:"font-medium whitespace-nowrap",children:c("model.moreModels")},void 0,!1,void 0,this),a(E,{children:a(n,{value:g.api_id,onValueChange:V,itemClassName:"font-medium whitespace-nowrap",options:l.map((t)=>O(t,{noDescription:!0}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)})()),!d&&o&&a(h,{children:[a(s,{},void 0,!1,void 0,this),G==="menu"?a(N,{children:[a(S,{disabled:u.disabled,children:[a("span",{className:"flex-1",children:o.name},void 0,!1,void 0,this),a("span",{className:"text-muted-foreground",children:o.levels.find((i)=>i.value===o.value)?.name??o.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a(E,{children:a(n,{value:o.value,onValueChange:o.onChange,options:o.levels.map((i)=>({value:i.value,label:i.name}))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):a(Q,{...o,disabled:u.disabled},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!d&&!o&&T&&a(h,{children:[a(s,{},void 0,!1,void 0,this),a(w,{disabled:!0,children:[a("span",{className:"flex-1",children:T.name},void 0,!1,void 0,this),a("span",{children:T.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),le.map((i)=>a(y,{children:[a(s,{},void 0,!1,void 0,this),a(D,{children:i.name},void 0,!1,void 0,this),a(n,{value:i.value,onValueChange:i.onChange,options:i.options,itemClassName:"whitespace-nowrap"},void 0,!1,void 0,this)]},i.id,!0,void 0,this)),B&&B.length>0&&a(h,{children:[!o&&a(s,{},void 0,!1,void 0,this),B.map((i)=>d?a(J,{"aria-label":i.name,title:i.title,disabled:u.disabled||i.disabled,checked:i.currentValue,closeOnClick:!1,onCheckedChange:(l)=>j?.(i.id,l),className:"justify-between gap-3 py-2.5 pr-2 [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",children:[a("span",{className:"flex items-center gap-2",children:[i.icon,i.name]},void 0,!0,void 0,this),a("span",{"aria-hidden":"true",className:p("flex h-[18px] w-8 shrink-0 items-center rounded-full p-0.5",i.currentValue?"bg-primary":"bg-input"),children:a("span",{className:p("bg-background size-3.5 rounded-full shadow-xs transition-transform",i.currentValue&&"translate-x-3.5")},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},i.id,!0,void 0,this):a("div",{title:i.title,className:p("flex items-center justify-between gap-3 px-2 py-2.5",i.disabled&&"opacity-50"),children:[a("span",{className:"flex items-center gap-2 text-sm font-medium",children:[i.icon,i.name]},void 0,!0,void 0,this),a(L,{"aria-label":i.name,disabled:u.disabled||i.disabled,checked:i.currentValue,onCheckedChange:(l)=>j?.(i.id,l)},void 0,!1,void 0,this)]},i.id,!0,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d&&M?.action&&a(h,{children:[a(s,{className:"shrink-0"},void 0,!1,void 0,this),a(y,{"data-model-menu-footer":!0,className:"shrink-0",children:M.action},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{ye as ModelSelect};
1
+ import{e}from"../chunk-vk39871j.js";import{x,b,m,y,D,w,N,S,E,J,s}from"../chunk-47f4a577.js";import{L}from"../chunk-664xazrz.js";import{ie,ae,se}from"../chunk-s72dbmv3.js";import{Q}from"../chunk-71kpqt2g.js";import{n}from"../chunk-ya0gvswb.js";import{cn as c}from"cn";import{ArrowUpRight as ce,ChevronUp as H,Loader2Icon as K,Zap as X}from"lucide-react";import{Fragment as he,useState as Y}from"react";import{jsx as a,jsxs as o,Fragment as g}from"react/jsx-runtime";function ke({value:v,onChange:ee,models:T,modelGroups:I,compactCatalog:r,effortPresentation:P="slider",unavailableEffort:O,providerMenu:M,header:k,className:F,condensed:A,stripLabelPrefix:j,showDescription:ne,showModelList:oe=!0,loading:te,switching:U,isLoading:le,effortConfig:t,booleanOptions:_,onBooleanChange:B,selectOptions:de=[],t:h,...p}){let[re,me]=Y(!1),[ue,pe]=Y(!1),u=_?.find((i)=>i.id==="fast_mode"),G=r?_?.filter((i)=>i!==u):_,W=(i)=>j&&i.startsWith(j)?i.slice(j.length):i;if(te)return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:o(e,{variant:"ghost",disabled:!0,className:c("h-7 min-w-0 shrink gap-1.5 rounded-md px-2 text-xs font-normal",F),children:[a(K,{className:"size-3 animate-spin"}),a("span",{className:"text-muted-foreground truncate",children:h("model.loadingModels")})]})});return o("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:[M&&o(x,{open:re,onOpenChange:me,children:[o(ie,{children:[a(ae,{render:a(b,{render:o(e,{"data-testid":"provider-trigger",variant:"ghost",disabled:p.disabled,className:c("h-7 shrink-0 gap-1 rounded-md px-1.5","hover:bg-accent"),children:[M.icon,a(H,{className:"size-2.5 shrink-0 opacity-60"})]})})}),a(se,{children:h("model.switchProvider")})]}),o(m,{side:"top",align:"end",sideOffset:4,className:"z-100 min-w-[10rem]",children:[M.groups.map((i,d)=>o(he,{children:[d>0&&i.length>0&&a(s,{}),a(n,{value:M.value,onValueChange:M.onChange,options:i})]},d)),M.moreAction&&o(g,{children:[a(s,{}),o(w,{onClick:M.moreAction,className:"whitespace-nowrap",children:[a("span",{className:"min-w-0 flex-1 truncate",children:h("model.moreModels")}),a(ce,{className:"size-4"})]})]})]})]}),o(x,{open:ue,onOpenChange:pe,children:[o(ie,{children:[a(ae,{render:a(b,{render:o(e,{"data-testid":"model-trigger","aria-busy":U,variant:"ghost",className:c("h-7 gap-1.5 rounded-md px-2 text-xs font-normal","hover:bg-accent","max-w-full min-w-0 shrink",A&&"h-7 gap-1 px-1.5 text-[11px]",F),...p,children:[v.icon,_?.some((i)=>i.id==="fast_mode"&&i.currentValue&&!i.disabled)&&a(X,{"aria-hidden":"true",className:"size-3 shrink-0"}),a("span",{className:c("min-w-0 flex-1 truncate text-start",A&&"text-[11px]"),children:W(v.label)||h("model.selectModel")}),t&&o("span",{className:"text-muted-foreground grid shrink-0 justify-items-center",children:[a("span",{className:"invisible col-start-1 row-start-1",children:t.sizer??t.levels.reduce((i,d)=>d.name.length>i.length?d.name:i,"")}),a("span",{className:"col-start-1 row-start-1",children:t.levels.find((i)=>i.value===t.value)?.name??t.value})]}),U?a(K,{"data-testid":"model-switch-loading",className:"size-3 shrink-0 animate-spin"}):a(H,{className:c("size-3 shrink-0",A&&"size-2.5")})]})})}),a(se,{children:h("model.switchModel")})]}),o(m,{side:"top",align:"end",sideOffset:4,className:c("z-100 w-auto max-w-[min(24rem,calc(100vw-1rem))] min-w-[14rem]",r&&"flex h-[350px] w-80 min-w-0 flex-col overflow-hidden rounded-xl p-1.5"),children:[r&&o(g,{children:[o(y,{"data-model-menu-header":!0,className:"flex shrink-0 items-center justify-between gap-2 px-1 py-1",children:[t?P==="slider"?a("div",{role:"menuitem","aria-label":t.name,className:"min-w-0 [&>div]:justify-start [&>div]:gap-3 [&>div]:px-2 [&>div]:py-1.5",children:a(Q,{...t,disabled:p.disabled})}):o(N,{children:[o(S,{disabled:p.disabled,className:"h-8 min-w-0 flex-1 gap-2 rounded-md",children:[a("span",{children:t.name}),a("span",{className:"text-muted-foreground min-w-0 truncate text-xs",children:t.levels.find((i)=>i.value===t.value)?.name??t.value})]}),a(E,{children:a(n,{value:t.value,onValueChange:t.onChange,options:t.levels.map((i)=>({value:i.value,label:i.name}))})})]}):O?o(w,{disabled:!0,className:"h-8 min-w-0 flex-1 gap-2",children:[a("span",{children:O.name}),a("span",{className:"text-muted-foreground truncate text-xs",children:O.label})]}):a(D,{className:"min-w-0 flex-1 truncate",children:k?.name}),u&&a(J,{"aria-label":u.name,title:u.title??u.name,disabled:p.disabled||u.disabled,checked:u.currentValue,closeOnClick:!1,onCheckedChange:(i)=>B?.(u.id,i),className:c("hover:bg-accent focus:hover:bg-accent focus-visible:bg-accent ml-auto size-8 shrink-0 justify-center rounded-md p-0 focus:bg-transparent [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",u.currentValue&&!u.disabled?"text-foreground [&_svg]:fill-current":"text-muted-foreground"),children:u.icon??a(X,{className:"size-4","aria-hidden":"true"})})]}),a(s,{className:"shrink-0"})]}),k&&!r&&o(g,{children:[o("div",{className:"flex items-center gap-2 px-2 py-2",children:[k.icon,a("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:k.name}),k.action]}),a(s,{})]}),o(y,{"data-model-menu-list":r?"":void 0,className:r?"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain":void 0,children:[oe&&(le?a(w,{disabled:!0,className:"text-muted-foreground",children:h("model.loadingModels")}):T.length===0?a(w,{disabled:!0,className:"text-muted-foreground",children:h("model.noModelsAvailable")}):(()=>{let i=T.filter((l)=>!l.more),d=T.filter((l)=>l.more),Z=i.length>0&&d.length>0,V=(l,f)=>({disabled:p.disabled,icon:l.icon,value:l.api_id,label:W(l.label),description:f?.noDescription?void 0:ne?l.description:void 0}),z=(l)=>{let f=T.find((R)=>R.api_id===l);if(f)ee(f)};if(r)return a(n,{value:v.api_id,onValueChange:z,itemClassName:"min-w-0 max-w-full font-normal whitespace-nowrap",options:T.map((l)=>V(l))});return o(g,{children:[I?I.map((l)=>{let f=l.models.filter((C)=>!C.more),R=l.models.filter((C)=>C.more),q=f.length>0&&R.length>0;return o(y,{children:[a(D,{className:"text-muted-foreground text-xs font-normal",children:l.name}),a(n,{value:v.api_id,onValueChange:z,itemClassName:"font-medium whitespace-nowrap",options:(q?f:l.models).map((C)=>V(C))}),q&&o(N,{children:[a(S,{className:"font-medium whitespace-nowrap",children:h("model.moreModels")}),a(E,{children:a(n,{value:v.api_id,onValueChange:z,itemClassName:"font-medium whitespace-nowrap",options:R.map((C)=>V(C,{noDescription:!0}))})})]})]},l.id)}):a(n,{value:v.api_id,onValueChange:z,itemClassName:"font-medium whitespace-nowrap",options:(Z?i:T).map((l)=>V(l))}),!I&&Z&&o(N,{children:[a(S,{className:"font-medium whitespace-nowrap",children:h("model.moreModels")}),a(E,{children:a(n,{value:v.api_id,onValueChange:z,itemClassName:"font-medium whitespace-nowrap",options:d.map((l)=>V(l,{noDescription:!0}))})})]})]})})()),!r&&t&&o(g,{children:[a(s,{}),P==="menu"?o(N,{children:[o(S,{disabled:p.disabled,children:[a("span",{className:"flex-1",children:t.name}),a("span",{className:"text-muted-foreground",children:t.levels.find((i)=>i.value===t.value)?.name??t.value})]}),a(E,{children:a(n,{value:t.value,onValueChange:t.onChange,options:t.levels.map((i)=>({value:i.value,label:i.name}))})})]}):a(Q,{...t,disabled:p.disabled})]}),!r&&!t&&O&&o(g,{children:[a(s,{}),o(w,{disabled:!0,children:[a("span",{className:"flex-1",children:O.name}),a("span",{children:O.label})]})]}),de.map((i)=>o(y,{children:[a(s,{}),a(D,{children:i.name}),a(n,{value:i.value,onValueChange:i.onChange,options:i.options,itemClassName:"whitespace-nowrap"})]},i.id)),G&&G.length>0&&o(g,{children:[!t&&a(s,{}),G.map((i)=>r?o(J,{"aria-label":i.name,title:i.title,disabled:p.disabled||i.disabled,checked:i.currentValue,closeOnClick:!1,onCheckedChange:(d)=>B?.(i.id,d),className:"justify-between gap-3 py-2.5 pr-2 [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",children:[o("span",{className:"flex items-center gap-2",children:[i.icon,i.name]}),a("span",{"aria-hidden":"true",className:c("flex h-[18px] w-8 shrink-0 items-center rounded-full p-0.5",i.currentValue?"bg-primary":"bg-input"),children:a("span",{className:c("bg-background size-3.5 rounded-full shadow-xs transition-transform",i.currentValue&&"translate-x-3.5")})})]},i.id):o("div",{title:i.title,className:c("flex items-center justify-between gap-3 px-2 py-2.5",i.disabled&&"opacity-50"),children:[o("span",{className:"flex items-center gap-2 text-sm font-medium",children:[i.icon,i.name]}),a(L,{"aria-label":i.name,disabled:p.disabled||i.disabled,checked:i.currentValue,onCheckedChange:(d)=>B?.(i.id,d)})]},i.id))]})]}),r&&k?.action&&o(g,{children:[a(s,{className:"shrink-0"}),a(y,{"data-model-menu-footer":!0,className:"shrink-0",children:k.action})]})]})]})]})}export{ke as ModelSelect};
@@ -1 +1 @@
1
- import{e}from"../chunk-xgy0heva.js";import{v,b,m}from"../chunk-s4w6yjc0.js";import{n}from"../chunk-bgj6z7z4.js";import{useState as f}from"react";import{jsxDEV as o}from"react/jsx-dev-runtime";function N({value:p,currentName:t,icon:r,options:s,label:i,header:a,onValueChange:l,showLabel:d=!1,disabled:u=!1}){let[c,g]=f(!1);return o(v,{open:c,onOpenChange:g,children:[o(b,{render:o(e,{disabled:u,variant:"ghost","aria-label":`${i}: ${t}`,title:t,className:"text-muted-foreground data-popup-open:hover:bg-muted h-7 gap-1.5 rounded-full bg-transparent px-2 text-xs font-normal whitespace-nowrap data-popup-open:bg-transparent",children:[r,o("span",{className:d?"max-w-40 truncate":"hidden max-w-40 truncate @[40rem]/input-footer:inline-block",children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),o(m,{align:"start",sideOffset:4,className:"permission-mode-menu z-100 w-auto max-w-[calc(100vw-2rem)] min-w-72 rounded-xl p-1.5",children:[a&&o("div",{className:"text-muted-foreground flex items-center px-1.5 pt-0.5 pb-1 text-[11px] leading-4",children:o("span",{children:a},void 0,!1,void 0,this)},void 0,!1,void 0,this),o(n,{value:p,onValueChange:l,itemClassName:"items-center gap-2 py-1 pr-6 pl-2 whitespace-nowrap",options:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{N as PermissionModeSelect};
1
+ import{e}from"../chunk-vk39871j.js";import{x,b,m}from"../chunk-47f4a577.js";import{n}from"../chunk-ya0gvswb.js";import{useState as w}from"react";import{jsx as o,jsxs as a}from"react/jsx-runtime";function C({value:r,currentName:t,icon:s,options:i,label:d,header:p,onValueChange:l,showLabel:u=!1,disabled:c=!1}){let[g,f]=w(!1);return a(x,{open:g,onOpenChange:f,children:[o(b,{render:a(e,{disabled:c,variant:"ghost","aria-label":`${d}: ${t}`,title:t,className:"text-muted-foreground data-popup-open:hover:bg-muted h-7 gap-1.5 rounded-full bg-transparent px-2 text-xs font-normal whitespace-nowrap data-popup-open:bg-transparent",children:[s,o("span",{className:u?"max-w-40 truncate":"hidden max-w-40 truncate @[40rem]/input-footer:inline-block",children:t})]})}),a(m,{align:"start",sideOffset:4,className:"permission-mode-menu z-100 w-auto max-w-[calc(100vw-2rem)] min-w-72 rounded-xl p-1.5",children:[p&&o("div",{className:"text-muted-foreground flex items-center px-1.5 pt-0.5 pb-1 text-[11px] leading-4",children:o("span",{children:p})}),o(n,{value:r,onValueChange:l,itemClassName:"items-center gap-2 py-1 pr-6 pl-2 whitespace-nowrap",options:i})]})]})}export{C as PermissionModeSelect};
@@ -1 +1 @@
1
- import"../chunk-wf194rae.js";import{e}from"../chunk-xgy0heva.js";import"../chunk-2kjmc9hg.js";import{Ae}from"../chunk-51qk29t6.js";import{Xe,Ze,Ye}from"../chunk-t83jwyey.js";import{h}from"../chunk-twww750f.js";import{cn as v}from"cn";import{PaperclipIcon as H,XIcon as k}from"lucide-react";import{Fragment as T,useEffect as M,useRef as L,useState as P}from"react";import{jsxDEV as t,Fragment as E}from"react/jsx-dev-runtime";function z(n){return t(Ye,{align:"start",...n},void 0,!1,void 0,this)}function W({data:n,t:r,className:l,...m}){let c=h(),[u,f]=P(!1),[N,d]=P(1),I=L(null),a=n.filename||"",o=(n.mediaType?.startsWith("image/")&&n.url?"image":"file")==="image",C=a||(o?r("input.image"):r("input.attachment"));return M(()=>{if(!u)return;let p=0.1,g=(i)=>Math.min(10,Math.max(0.1,i)),y=(i)=>{if(!(i.ctrlKey||i.metaKey))return;let s=i.key,x=s==="+"||s==="=",A=s==="-"||s==="_",w=s==="0";if(!x&&!A&&!w)return;i.preventDefault(),d((b)=>{if(w)return 1;if(x)return g(b+p);return g(b-p)})};return window.addEventListener("keydown",y,{passive:!1}),()=>window.removeEventListener("keydown",y)},[u]),t(E,{children:[t(Xe,{children:[t(Ze,{render:t("div",{className:v("group border-border hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent relative flex h-8 cursor-pointer items-center gap-1.5 rounded-md border px-1.5 text-sm font-medium transition-all select-none",l),...m,children:[t("div",{className:"relative size-5 shrink-0",children:[o?t(e,{type:"button",variant:"ghost",size:"icon-xs","aria-label":r("input.image"),className:"bg-background absolute inset-0 size-5 overflow-hidden rounded p-0 transition-opacity group-hover:opacity-0",onClick:()=>{d(1),f(!0)},children:t("img",{alt:a||"attachment",className:"size-5 object-cover",height:20,src:n.url,width:20},void 0,!1,void 0,this)},void 0,!1,void 0,this):t("div",{className:"bg-background text-muted-foreground absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded transition-opacity group-hover:opacity-0",children:t(H,{className:"size-3"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t(e,{"aria-label":r("input.removeAttachment"),className:v("absolute -top-1 -right-1 size-4 rounded-full p-0 opacity-0 transition-opacity [&>svg]:size-3","pointer-events-none group-hover:pointer-events-auto group-hover:opacity-100"),onClick:(p)=>{p.stopPropagation(),c.remove(n.id)},type:"button",variant:"ghost",children:[t(k,{},void 0,!1,void 0,this),t("span",{className:"sr-only",children:r("input.removeAttachment")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!o&&t("span",{className:"max-w-40 flex-1 truncate text-xs",children:C},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(z,{className:"w-auto p-2",children:t("div",{className:"w-auto space-y-3",children:[o&&t("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:t("img",{alt:a||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:n.url,width:448},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("div",{className:"flex items-center gap-2.5",children:t("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[t("h4",{className:"truncate text-sm leading-none font-semibold",children:a||(o?"Image":"Attachment")},void 0,!1,void 0,this),n.mediaType&&t("p",{className:"text-muted-foreground truncate font-mono text-xs",children:n.mediaType},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&n.url&&t(Ae,{containerRef:I,filename:a||r("input.image"),onOpenChange:f,onScaleChange:d,open:u,scale:N,url:n.url},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function X({children:n,className:r,...l}){let m=h();if(!m.files.length)return null;return t("div",{className:v("flex w-full flex-wrap items-center gap-1",r),...l,children:m.files.map((c)=>t(T,{children:n(c)},c.id,!1,void 0,this))},void 0,!1,void 0,this)}export{W as PromptInputAttachment,X as PromptInputAttachments};
1
+ import"../chunk-wf194rae.js";import{e}from"../chunk-vk39871j.js";import"../chunk-sxjgyvnx.js";import{Ae}from"../chunk-8k4z0gfx.js";import{Xe,Ze,Ye}from"../chunk-dj84q7tx.js";import{h}from"../chunk-cwp8ct1z.js";import{cn as f}from"cn";import{PaperclipIcon as k,XIcon as T}from"lucide-react";import{Fragment as M,useEffect as L,useRef as z,useState as N}from"react";import{jsx as t,jsxs as o,Fragment as R}from"react/jsx-runtime";function E(n){return t(Ye,{align:"start",...n})}function X({data:n,t:r,className:u,...c}){let p=h(),[d,g]=N(!1),[I,v]=N(1),C=z(null),s=n.filename||"",i=(n.mediaType?.startsWith("image/")&&n.url?"image":"file")==="image",A=s||(i?r("input.image"):r("input.attachment"));return L(()=>{if(!d)return;let l=0.1,y=(a)=>Math.min(10,Math.max(0.1,a)),x=(a)=>{if(!(a.ctrlKey||a.metaKey))return;let m=a.key,w=m==="+"||m==="=",H=m==="-"||m==="_",b=m==="0";if(!w&&!H&&!b)return;a.preventDefault(),v((P)=>{if(b)return 1;if(w)return y(P+l);return y(P-l)})};return window.addEventListener("keydown",x,{passive:!1}),()=>window.removeEventListener("keydown",x)},[d]),o(R,{children:[o(Xe,{children:[t(Ze,{render:o("div",{className:f("group border-border hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent relative flex h-8 cursor-pointer items-center gap-1.5 rounded-md border px-1.5 text-sm font-medium transition-all select-none",u),...c,children:[o("div",{className:"relative size-5 shrink-0",children:[i?t(e,{type:"button",variant:"ghost",size:"icon-xs","aria-label":r("input.image"),className:"bg-background absolute inset-0 size-5 overflow-hidden rounded p-0 transition-opacity group-hover:opacity-0",onClick:()=>{v(1),g(!0)},children:t("img",{alt:s||"attachment",className:"size-5 object-cover",height:20,src:n.url,width:20})}):t("div",{className:"bg-background text-muted-foreground absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded transition-opacity group-hover:opacity-0",children:t(k,{className:"size-3"})}),o(e,{"aria-label":r("input.removeAttachment"),className:f("absolute -top-1 -right-1 size-4 rounded-full p-0 opacity-0 transition-opacity [&>svg]:size-3","pointer-events-none group-hover:pointer-events-auto group-hover:opacity-100"),onClick:(l)=>{l.stopPropagation(),p.remove(n.id)},type:"button",variant:"ghost",children:[t(T,{}),t("span",{className:"sr-only",children:r("input.removeAttachment")})]})]}),!i&&t("span",{className:"max-w-40 flex-1 truncate text-xs",children:A})]})}),t(E,{className:"w-auto p-2",children:o("div",{className:"w-auto space-y-3",children:[i&&t("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:t("img",{alt:s||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:n.url,width:448})}),t("div",{className:"flex items-center gap-2.5",children:o("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[t("h4",{className:"truncate text-sm leading-none font-semibold",children:s||(i?"Image":"Attachment")}),n.mediaType&&t("p",{className:"text-muted-foreground truncate font-mono text-xs",children:n.mediaType})]})})]})})]}),i&&n.url&&t(Ae,{containerRef:C,filename:s||r("input.image"),onOpenChange:g,onScaleChange:v,open:d,scale:I,url:n.url})]})}function _({children:n,className:r,...u}){let c=h();if(!c.files.length)return null;return t("div",{className:f("flex w-full flex-wrap items-center gap-1",r),...u,children:c.files.map((p)=>t(M,{children:n(p)},p.id))})}export{X as PromptInputAttachment,_ as PromptInputAttachments};
@@ -1 +1 @@
1
- import{X,Pt,Z,It,C,_e,T,Mt,Nt,Y,h}from"../chunk-twww750f.js";export{Y as LocalAttachmentsContext,Nt as PromptInputProvider,Z as PromptInputSubmissionContext,X as PromptInputSubmitContext,C as ProviderAttachmentsContext,T as useOptionalPromptInputController,h as usePromptInputAttachments,_e as usePromptInputController,It as usePromptInputSubmission,Pt as usePromptInputSubmit,Mt as useProviderAttachments};
1
+ import{X,Pt,Z,It,C,_e,T,Mt,Nt,Y,h}from"../chunk-cwp8ct1z.js";export{Y as LocalAttachmentsContext,Nt as PromptInputProvider,Z as PromptInputSubmissionContext,X as PromptInputSubmitContext,C as ProviderAttachmentsContext,T as useOptionalPromptInputController,h as usePromptInputAttachments,_e as usePromptInputController,It as usePromptInputSubmission,Pt as usePromptInputSubmit,Mt as useProviderAttachments};
@@ -1,3 +1,3 @@
1
- import"../chunk-r9k7kszp.js";import{ne}from"../chunk-jnx3t913.js";import{Ie,Me,F}from"../chunk-nx3k6k2p.js";import{T,h}from"../chunk-twww750f.js";import{cn as A}from"cn";import{forwardRef as D,useCallback as M,useEffect as K,useImperativeHandle as L,useRef as f}from"react";import{jsxDEV as z}from"react/jsx-dev-runtime";var R=(i)=>!i.shiftKey,N=()=>!1,q=D(({onChange:i,onCompositionStart:v,onCompositionEnd:x,className:y,placeholder:b,bashMode:E=!1,isSendShortcut:I=R,isNewlineShortcut:C=N,...H},P)=>{let n=T(),l=h(),o=f(!1),u=f(!1),r=f(null),s=M(()=>{let e=r.current;if(!e||o.current)return;e.style.height="auto",e.style.height=`${e.scrollHeight}px`},[]);K(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(()=>{requestAnimationFrame(s)});return t.observe(e),()=>t.disconnect()},[s]);let c=E&&(n?.textInput.value??"").startsWith("!"),S=(e)=>{if(o.current||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229||u.current)return;if(e.key.length===1&&e.key.charCodeAt(0)<32&&e.key!==`
1
+ import"../chunk-d0ptk8x8.js";import{ne}from"../chunk-2r04c28x.js";import{Ie,Me,F}from"../chunk-nx3k6k2p.js";import{T,h}from"../chunk-cwp8ct1z.js";import{cn as A}from"cn";import{forwardRef as D,useCallback as M,useEffect as K,useImperativeHandle as L,useRef as f}from"react";import{jsx as z}from"react/jsx-runtime";var R=(i)=>!i.shiftKey,N=()=>!1,q=D(({onChange:i,onCompositionStart:v,onCompositionEnd:x,className:y,placeholder:b,bashMode:E=!1,isSendShortcut:I=R,isNewlineShortcut:C=N,...H},P)=>{let n=T(),l=h(),o=f(!1),u=f(!1),r=f(null),s=M(()=>{let e=r.current;if(!e||o.current)return;e.style.height="auto",e.style.height=`${e.scrollHeight}px`},[]);K(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(()=>{requestAnimationFrame(s)});return t.observe(e),()=>t.disconnect()},[s]);let c=E&&(n?.textInput.value??"").startsWith("!"),S=(e)=>{if(o.current||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229||u.current)return;if(e.key.length===1&&e.key.charCodeAt(0)<32&&e.key!==`
2
2
  `&&e.key!=="\r"&&e.key!=="\t"){e.preventDefault();return}if(c&&n){let t=e.currentTarget.selectionStart===0&&e.currentTarget.selectionEnd===0;if(e.key==="Escape"||(e.key==="Backspace"||e.key==="Delete")&&t){e.preventDefault(),n.textInput.setInput(n.textInput.value.slice(1));return}}if(e.key==="Enter"){if(C(e.nativeEvent)){e.preventDefault();let t=e.currentTarget,{selectionStart:a,selectionEnd:m,value:p}=t,d=`${p.slice(0,a)}
3
- ${p.slice(m)}`;if(n)n.textInput.setInput(d);else t.value=d;let g=a+1;t.setSelectionRange(g,g),s();return}if(I(e.nativeEvent)){e.preventDefault();let t=e.currentTarget.form;if(!t)return;let a=t.querySelector('button[type="submit"]');if(!a||a.disabled)return;t.requestSubmit(a)}}if(e.key==="Backspace"&&e.currentTarget.value===""&&l.files.length>0){e.preventDefault();let t=l.files.at(-1);if(t)l.remove(t.id)}},k=(e)=>{let t=e.clipboardData?.items;if(!t)return;let{imageFiles:a,sawNonImageFile:m}=Ie(t),p=Me(t);if(a.length>0)e.preventDefault(),l.add(a);else if(m&&!p)e.preventDefault()},w=n?{value:o.current&&r.current?r.current.value:c?n.textInput.value.slice(1):n.textInput.value,onChange:(e)=>{let t=o.current?e.currentTarget.value:F(e.currentTarget);n.textInput.setInput(c?`!${t}`:t),s(),i?.(e)}}:{onChange:(e)=>{if(!o.current)F(e.currentTarget);s(),i?.(e)}};return L(P,()=>({resetHeight:()=>{if(r.current)r.current.style.height="auto"},focus:()=>{r.current?.focus()},isComposing:()=>o.current||u.current,getTextarea:()=>r.current}),[]),z(ne,{"data-chat-input":!0,ref:r,rows:3,className:A("field-sizing-content max-h-(--chat-input-max-height) min-h-[calc(var(--chat-input-line-height)*3)] min-w-0 flex-1 overflow-x-hidden","leading-(--chat-input-line-height)","placeholder:text-chat-input-placeholder p-0 pe-2.5","bg-chat-input-bg",y),name:"message",onCompositionEnd:(e)=>{o.current=!1;let t=F(e.currentTarget);n?.textInput.setInput(c?`!${t}`:t),s(),x?.(e),u.current=!0,requestAnimationFrame(()=>{u.current=!1})},onCompositionStart:(e)=>{u.current=!1,o.current=!0,v?.(e)},onKeyDown:S,onPaste:k,placeholder:b,...H,...w},void 0,!1,void 0,this)});q.displayName="PromptInputTextarea";export{q as PromptInputTextarea};
3
+ ${p.slice(m)}`;if(n)n.textInput.setInput(d);else t.value=d;let g=a+1;t.setSelectionRange(g,g),s();return}if(I(e.nativeEvent)){e.preventDefault();let t=e.currentTarget.form;if(!t)return;let a=t.querySelector('button[type="submit"]');if(!a||a.disabled)return;t.requestSubmit(a)}}if(e.key==="Backspace"&&e.currentTarget.value===""&&l.files.length>0){e.preventDefault();let t=l.files.at(-1);if(t)l.remove(t.id)}},k=(e)=>{let t=e.clipboardData?.items;if(!t)return;let{imageFiles:a,sawNonImageFile:m}=Ie(t),p=Me(t);if(a.length>0)e.preventDefault(),l.add(a);else if(m&&!p)e.preventDefault()},w=n?{value:o.current&&r.current?r.current.value:c?n.textInput.value.slice(1):n.textInput.value,onChange:(e)=>{let t=o.current?e.currentTarget.value:F(e.currentTarget);n.textInput.setInput(c?`!${t}`:t),s(),i?.(e)}}:{onChange:(e)=>{if(!o.current)F(e.currentTarget);s(),i?.(e)}};return L(P,()=>({resetHeight:()=>{if(r.current)r.current.style.height="auto"},focus:()=>{r.current?.focus()},isComposing:()=>o.current||u.current,getTextarea:()=>r.current}),[]),z(ne,{"data-chat-input":!0,ref:r,rows:3,className:A("field-sizing-content max-h-(--chat-input-max-height) min-h-[calc(var(--chat-input-line-height)*3)] min-w-0 flex-1 overflow-x-hidden","leading-(--chat-input-line-height)","placeholder:text-chat-input-placeholder p-0 pe-2.5","bg-chat-input-bg",y),name:"message",onCompositionEnd:(e)=>{o.current=!1;let t=F(e.currentTarget);n?.textInput.setInput(c?`!${t}`:t),s(),x?.(e),u.current=!0,requestAnimationFrame(()=>{u.current=!1})},onCompositionStart:(e)=>{u.current=!1,o.current=!0,v?.(e)},onKeyDown:S,onPaste:k,placeholder:b,...H,...w})});q.displayName="PromptInputTextarea";export{q as PromptInputTextarea};
@@ -1 +1 @@
1
- import{Se,j}from"../chunk-wbpw278r.js";import"../chunk-ta690ra0.js";import{Ne}from"../chunk-98t2nc02.js";import"../chunk-xgy0heva.js";import"../chunk-r9k7kszp.js";import"../chunk-jnx3t913.js";import{Qe,ee,te}from"../chunk-pkxfrrwf.js";import{X,Z,C,T,Y}from"../chunk-twww750f.js";import{cn as P}from"cn";import{ArrowUpIcon as Ie,Loader2Icon as ye,SquareIcon as xe,XIcon as Le}from"lucide-react";import{Children as se,useCallback as h,useEffect as M,useMemo as Te,useRef as E,useState as Fe}from"react";import{flushSync as Me}from"react-dom";import{jsxDEV as o}from"react/jsx-dev-runtime";function ie(u){let s=new FormData(u).get("message");return typeof s==="string"?s:""}var De=({className:u,bashMode:s=!1,attachmentPolicy:I,onCommand:d,onSubmitError:y,canSubmit:f,onSubmitAsync:g,accept:A,multiple:ae,globalDrop:w,syncHiddenInput:B,maxFiles:k,maxFileSize:D,onError:b,onSubmit:ue,children:le,...pe})=>{let i=T(),l=!!i,me=s&&l&&i.textInput.value.startsWith("!"),x=E(null),S=E(null),N=E(!1),[ce,R]=Fe([]),c=l?i.attachments.files:ce,O=E(c);O.current=c;let de=h(()=>{x.current?.click()},[]),W=h((e)=>{if(!A||A.trim()==="")return!0;return A.split(",").map((t)=>t.trim()).filter(Boolean).some((t)=>{if(t.endsWith("/*")){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t})},[A]),G=h((e)=>{if(e.type)return e.type;let r=(e.name||"").toLowerCase();if(r.endsWith(".png"))return"image/png";if(r.endsWith(".jpg")||r.endsWith(".jpeg"))return"image/jpeg";if(r.endsWith(".webp"))return"image/webp";if(r.endsWith(".gif"))return"image/gif";if(r.endsWith(".bmp"))return"image/bmp";if(r.endsWith(".svg"))return"image/svg+xml";return""},[]),fe=h((e)=>{let r=[...e],t=r.filter((a)=>W(a));if(r.length&&t.length===0){b?.({code:"accept",message:"No files match the accepted types."});return}let n=(a)=>D?a.size<=D:!0,m=t.filter(n);if(t.length>0&&m.length===0){b?.({code:"max_file_size",message:"All files exceed the maximum size."});return}R((a)=>{let v=I?I.uniqueFiles(m,a):m,p=typeof k==="number"?Math.max(0,k-a.length):void 0,H=typeof p==="number"?v.slice(0,p):v;if(typeof p==="number"&&v.length>p)b?.({code:"max_files",message:"Too many files. Some were not added."});let ne=[];for(let F of H){let oe=I?.sourcePath(F);ne.push({id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(F),mediaType:G(F),filename:F.name,size:F.size,lastModified:F.lastModified,...oe===void 0?{}:{sourcePath:oe}})}return[...a,...ne]})},[I,G,W,k,D,b]),ge=h((e)=>R((r)=>{let t=r.find((n)=>n.id===e);if(t?.url)URL.revokeObjectURL(t.url);return r.filter((n)=>n.id!==e)}),[]),be=h(()=>R((e)=>{for(let r of e)if(r.url)URL.revokeObjectURL(r.url);return[]}),[]),q=l?i.attachments.add:fe,L=h((e)=>{let r=[...e],t=r.filter((m)=>!(m.type??"").toLowerCase().startsWith("image/"));if(t.length>0){b?.({code:"unsupported_type",message:`Only image attachments are supported. ${t.length} non-image file(s) were ignored.`});return}let n=r.reduce((m,a)=>m+a.size,0);if(n>0){let m=c.filter((a)=>(a.mediaType??"").toLowerCase().startsWith("image/")).reduce((a,v)=>a+(v.size??0),0);if(Se(m,n)){b?.({code:"max_total_size",message:`Total image size must not exceed ${j}MB.`});return}}q(r)},[c,q,b]),J=l?i.attachments.remove:ge,U=l?i.attachments.clear:be,K=l?i.attachments.openFileDialog:de;M(()=>{if(!l)return;i.__registerFileInput(x,()=>x.current?.click())},[l,i]),M(()=>{if(B&&x.current&&c.length===0)x.current.value=""},[c,B]),M(()=>{let e=S.current;if(!e)return;if(w)return;let r=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault()},t=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault();if(n.dataTransfer?.files&&n.dataTransfer.files.length>0)L(n.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",t),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",t)}},[L,w]),M(()=>{if(!w)return;let e=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault()},r=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault();if(t.dataTransfer?.files&&t.dataTransfer.files.length>0)L(t.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[L,w]),M(()=>()=>{if(!l){for(let e of O.current)if(e.url)URL.revokeObjectURL(e.url)}},[l]);let ve=(e)=>{if(e.currentTarget.files)L(e.currentTarget.files);e.currentTarget.value=""},Q=Te(()=>({files:c.map((e)=>({...e,id:e.id})),add:L,remove:J,clear:U,openFileDialog:K,fileInputRef:x}),[c,L,J,U,K]),_=E({controller:i,files:c,canSubmit:f});_.current={controller:i,files:c,canSubmit:f};let z=E(!0);M(()=>(z.current=!0,()=>{z.current=!1}),[]);let V=async(e)=>{let r=f===void 0?!0:f();if(r!==!0)return{status:"blocked",reason:r};if(N.current)return{status:"blocked",reason:"submission_pending"};if(e===null&&g===void 0)throw Error("Awaitable submission requires onSubmitAsync");let t=S.current;if(t===null)return{status:"blocked",reason:"form_unmounted"};let n=l?i.textInput.value:ie(t),m=i?.textInput.getRevision?.(),a=c,v=()=>{if(!z.current)return;let p=_.current;if(p.files!==a)return;if(l){if(m===void 0||p.controller===null||p.controller.textInput.getRevision?.()!==m)return;if(p.controller.textInput.clearSubmitted===void 0)p.controller.textInput.clear();else p.controller.textInput.clearSubmitted()}else if(ie(t)===n)t.reset();U()};N.current=!0;try{if(d?.(n.trim()))return v(),{status:"accepted"};let p=await Ne(a),H=_.current.canSubmit===void 0?!0:_.current.canSubmit();if(H!==!0)return{status:"blocked",reason:H};if(!z.current)return{status:"blocked",reason:"form_unmounted"};if(p.rejectedCount>0)b?.({code:"accept",message:"One or more images are corrupted and were removed before sending."});if(g!==void 0)await g({text:n,files:p.files});else if(e!==null)await ue({text:n,files:p.files},e);return v(),{status:"accepted"}}finally{N.current=!1}},he=(e)=>{e.preventDefault(),V(e).catch(y)},Pe=h((e)=>{if(!e.trim())return;if(l&&i)Me(()=>{i.textInput.setInput(e)});S.current?.requestSubmit()},[i,l]),re=o(Z.Provider,{value:()=>V(null),children:o(X.Provider,{value:Pe,children:[o("input",{accept:A,"aria-label":"Upload files",className:"hidden",multiple:ae,onChange:ve,ref:x,title:"Upload files",type:"file"},void 0,!1,void 0,this),o("form",{className:P("w-full",u),onSubmit:he,ref:S,"data-tour":"chat-input",...pe,children:o(Qe,{className:P("codex-composer-surface overflow-y-auto has-[[data-slot=input-group-control]:focus-visible]:ring-0",me&&"border! border-[rgb(255,0,135)] has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(255,0,135)] dark:border-[rgb(253,93,177)] dark:has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(253,93,177)]"),children:le},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return l?o(C.Provider,{value:Q,children:re},void 0,!1,void 0,this):o(Y.Provider,{value:Q,children:re},void 0,!1,void 0,this)};function Re({className:u,...s}){return o("div",{className:P("flex w-full min-w-0 flex-row items-end gap-2",u),...s},void 0,!1,void 0,this)}function Ue({className:u,...s}){return o(ee,{align:"block-end",className:P("order-first flex-wrap gap-1 p-2 pb-1.5",u),...s},void 0,!1,void 0,this)}function Be({className:u,...s}){return o(ee,{align:"block-end",className:P("mt-3.5 justify-between gap-1 p-0",u),...s},void 0,!1,void 0,this)}function Oe({className:u,...s}){return o("div",{className:P("flex items-center gap-1",u),...s},void 0,!1,void 0,this)}var We=({variant:u="ghost",className:s,size:I,collapsed:d=!1,...y})=>{let f=d||se.count(y.children)<=1?"icon-xs":"xs";return o(te,{className:P("h-7 rounded-full text-xs font-medium hover:bg-transparent dark:hover:bg-transparent",(d||se.count(y.children)<=1)&&"size-7",s),size:f,type:"button",variant:u,...y},void 0,!1,void 0,this)},Ge=({className:u,variant:s="ghost",size:I="icon-xs",status:d,children:y,...f})=>{let g=o(Ie,{className:"size-4"},void 0,!1,void 0,this);if(d==="submitted")g=o(ye,{className:"size-4 animate-spin"},void 0,!1,void 0,this);else if(d==="streaming")g=o(xe,{className:"size-3 fill-current"},void 0,!1,void 0,this);else if(d==="error")g=o(Le,{className:"size-4"},void 0,!1,void 0,this);return o(te,{"aria-label":"Submit",className:P("bg-foreground text-background hover:bg-foreground/70 size-7 rounded-full p-0 transition-opacity disabled:opacity-50",u),size:I,type:"submit",variant:s,...f,children:y??g},void 0,!1,void 0,this)};export{j as MAX_TOTAL_IMAGE_MB,De as PromptInput,Re as PromptInputBody,We as PromptInputButton,Be as PromptInputFooter,Ue as PromptInputHeader,Ge as PromptInputSubmit,Oe as PromptInputTools};
1
+ import{Se,j}from"../chunk-wbpw278r.js";import"../chunk-ta690ra0.js";import{Ne}from"../chunk-98t2nc02.js";import"../chunk-vk39871j.js";import"../chunk-d0ptk8x8.js";import"../chunk-2r04c28x.js";import{Qe,ee,te}from"../chunk-hfhzy9c2.js";import{X,Z,C,T,Y}from"../chunk-cwp8ct1z.js";import{cn as P}from"cn";import{ArrowUpIcon as Ie,Loader2Icon as ye,SquareIcon as xe,XIcon as Le}from"lucide-react";import{Children as se,useCallback as h,useEffect as M,useMemo as Te,useRef as E,useState as Fe}from"react";import{flushSync as Me}from"react-dom";import{jsx as a,jsxs as Ee}from"react/jsx-runtime";function ie(u){let o=new FormData(u).get("message");return typeof o==="string"?o:""}var Re=({className:u,bashMode:o=!1,attachmentPolicy:I,onCommand:d,onSubmitError:y,canSubmit:f,onSubmitAsync:g,accept:A,multiple:ae,globalDrop:w,syncHiddenInput:B,maxFiles:k,maxFileSize:D,onError:b,onSubmit:ue,children:le,...pe})=>{let s=T(),l=!!s,me=o&&l&&s.textInput.value.startsWith("!"),x=E(null),S=E(null),N=E(!1),[ce,R]=Fe([]),c=l?s.attachments.files:ce,O=E(c);O.current=c;let de=h(()=>{x.current?.click()},[]),W=h((e)=>{if(!A||A.trim()==="")return!0;return A.split(",").map((t)=>t.trim()).filter(Boolean).some((t)=>{if(t.endsWith("/*")){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t})},[A]),G=h((e)=>{if(e.type)return e.type;let r=(e.name||"").toLowerCase();if(r.endsWith(".png"))return"image/png";if(r.endsWith(".jpg")||r.endsWith(".jpeg"))return"image/jpeg";if(r.endsWith(".webp"))return"image/webp";if(r.endsWith(".gif"))return"image/gif";if(r.endsWith(".bmp"))return"image/bmp";if(r.endsWith(".svg"))return"image/svg+xml";return""},[]),fe=h((e)=>{let r=[...e],t=r.filter((i)=>W(i));if(r.length&&t.length===0){b?.({code:"accept",message:"No files match the accepted types."});return}let n=(i)=>D?i.size<=D:!0,m=t.filter(n);if(t.length>0&&m.length===0){b?.({code:"max_file_size",message:"All files exceed the maximum size."});return}R((i)=>{let v=I?I.uniqueFiles(m,i):m,p=typeof k==="number"?Math.max(0,k-i.length):void 0,H=typeof p==="number"?v.slice(0,p):v;if(typeof p==="number"&&v.length>p)b?.({code:"max_files",message:"Too many files. Some were not added."});let ne=[];for(let F of H){let oe=I?.sourcePath(F);ne.push({id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(F),mediaType:G(F),filename:F.name,size:F.size,lastModified:F.lastModified,...oe===void 0?{}:{sourcePath:oe}})}return[...i,...ne]})},[I,G,W,k,D,b]),ge=h((e)=>R((r)=>{let t=r.find((n)=>n.id===e);if(t?.url)URL.revokeObjectURL(t.url);return r.filter((n)=>n.id!==e)}),[]),be=h(()=>R((e)=>{for(let r of e)if(r.url)URL.revokeObjectURL(r.url);return[]}),[]),q=l?s.attachments.add:fe,L=h((e)=>{let r=[...e],t=r.filter((m)=>!(m.type??"").toLowerCase().startsWith("image/"));if(t.length>0){b?.({code:"unsupported_type",message:`Only image attachments are supported. ${t.length} non-image file(s) were ignored.`});return}let n=r.reduce((m,i)=>m+i.size,0);if(n>0){let m=c.filter((i)=>(i.mediaType??"").toLowerCase().startsWith("image/")).reduce((i,v)=>i+(v.size??0),0);if(Se(m,n)){b?.({code:"max_total_size",message:`Total image size must not exceed ${j}MB.`});return}}q(r)},[c,q,b]),J=l?s.attachments.remove:ge,U=l?s.attachments.clear:be,K=l?s.attachments.openFileDialog:de;M(()=>{if(!l)return;s.__registerFileInput(x,()=>x.current?.click())},[l,s]),M(()=>{if(B&&x.current&&c.length===0)x.current.value=""},[c,B]),M(()=>{let e=S.current;if(!e)return;if(w)return;let r=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault()},t=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault();if(n.dataTransfer?.files&&n.dataTransfer.files.length>0)L(n.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",t),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",t)}},[L,w]),M(()=>{if(!w)return;let e=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault()},r=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault();if(t.dataTransfer?.files&&t.dataTransfer.files.length>0)L(t.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[L,w]),M(()=>()=>{if(!l){for(let e of O.current)if(e.url)URL.revokeObjectURL(e.url)}},[l]);let ve=(e)=>{if(e.currentTarget.files)L(e.currentTarget.files);e.currentTarget.value=""},Q=Te(()=>({files:c.map((e)=>({...e,id:e.id})),add:L,remove:J,clear:U,openFileDialog:K,fileInputRef:x}),[c,L,J,U,K]),_=E({controller:s,files:c,canSubmit:f});_.current={controller:s,files:c,canSubmit:f};let z=E(!0);M(()=>(z.current=!0,()=>{z.current=!1}),[]);let V=async(e)=>{let r=f===void 0?!0:f();if(r!==!0)return{status:"blocked",reason:r};if(N.current)return{status:"blocked",reason:"submission_pending"};if(e===null&&g===void 0)throw Error("Awaitable submission requires onSubmitAsync");let t=S.current;if(t===null)return{status:"blocked",reason:"form_unmounted"};let n=l?s.textInput.value:ie(t),m=s?.textInput.getRevision?.(),i=c,v=()=>{if(!z.current)return;let p=_.current;if(p.files!==i)return;if(l){if(m===void 0||p.controller===null||p.controller.textInput.getRevision?.()!==m)return;if(p.controller.textInput.clearSubmitted===void 0)p.controller.textInput.clear();else p.controller.textInput.clearSubmitted()}else if(ie(t)===n)t.reset();U()};N.current=!0;try{if(d?.(n.trim()))return v(),{status:"accepted"};let p=await Ne(i),H=_.current.canSubmit===void 0?!0:_.current.canSubmit();if(H!==!0)return{status:"blocked",reason:H};if(!z.current)return{status:"blocked",reason:"form_unmounted"};if(p.rejectedCount>0)b?.({code:"accept",message:"One or more images are corrupted and were removed before sending."});if(g!==void 0)await g({text:n,files:p.files});else if(e!==null)await ue({text:n,files:p.files},e);return v(),{status:"accepted"}}finally{N.current=!1}},he=(e)=>{e.preventDefault(),V(e).catch(y)},Pe=h((e)=>{if(!e.trim())return;if(l&&s)Me(()=>{s.textInput.setInput(e)});S.current?.requestSubmit()},[s,l]),re=a(Z.Provider,{value:()=>V(null),children:Ee(X.Provider,{value:Pe,children:[a("input",{accept:A,"aria-label":"Upload files",className:"hidden",multiple:ae,onChange:ve,ref:x,title:"Upload files",type:"file"}),a("form",{className:P("w-full",u),onSubmit:he,ref:S,"data-tour":"chat-input",...pe,children:a(Qe,{className:P("codex-composer-surface overflow-y-auto has-[[data-slot=input-group-control]:focus-visible]:ring-0",me&&"border! border-[rgb(255,0,135)] has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(255,0,135)] dark:border-[rgb(253,93,177)] dark:has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(253,93,177)]"),children:le})})]})});return l?a(C.Provider,{value:Q,children:re}):a(Y.Provider,{value:Q,children:re})};function Ue({className:u,...o}){return a("div",{className:P("flex w-full min-w-0 flex-row items-end gap-2",u),...o})}function Be({className:u,...o}){return a(ee,{align:"block-end",className:P("order-first flex-wrap gap-1 p-2 pb-1.5",u),...o})}function Oe({className:u,...o}){return a(ee,{align:"block-end",className:P("mt-3.5 justify-between gap-1 p-0",u),...o})}function We({className:u,...o}){return a("div",{className:P("flex items-center gap-1",u),...o})}var Ge=({variant:u="ghost",className:o,size:I,collapsed:d=!1,...y})=>{let f=d||se.count(y.children)<=1?"icon-xs":"xs";return a(te,{className:P("h-7 rounded-full text-xs font-medium hover:bg-transparent dark:hover:bg-transparent",(d||se.count(y.children)<=1)&&"size-7",o),size:f,type:"button",variant:u,...y})},je=({className:u,variant:o="ghost",size:I="icon-xs",status:d,children:y,...f})=>{let g=a(Ie,{className:"size-4"});if(d==="submitted")g=a(ye,{className:"size-4 animate-spin"});else if(d==="streaming")g=a(xe,{className:"size-3 fill-current"});else if(d==="error")g=a(Le,{className:"size-4"});return a(te,{"aria-label":"Submit",className:P("bg-foreground text-background hover:bg-foreground/70 size-7 rounded-full p-0 transition-opacity disabled:opacity-50",u),size:I,type:"submit",variant:o,...f,children:y??g})};export{j as MAX_TOTAL_IMAGE_MB,Re as PromptInput,Ue as PromptInputBody,Ge as PromptInputButton,Oe as PromptInputFooter,Be as PromptInputHeader,je as PromptInputSubmit,We as PromptInputTools};
@@ -1 +1 @@
1
- import{Re}from"./chunk-d1xydh51.js";export{Re as ImageLightbox};
1
+ import{Re}from"./chunk-6m16qe9q.js";export{Re as ImageLightbox};
@@ -1 +1 @@
1
- import{Ae}from"./chunk-51qk29t6.js";import"./chunk-wf194rae.js";import"./chunk-2kjmc9hg.js";import"./chunk-xgy0heva.js";export{Ae as ImagePreviewDialog};
1
+ import{Ae}from"./chunk-8k4z0gfx.js";import"./chunk-wf194rae.js";import"./chunk-sxjgyvnx.js";import"./chunk-vk39871j.js";export{Ae as ImagePreviewDialog};
@@ -1 +1 @@
1
- import{fe}from"../chunk-7471tnsq.js";import"../chunk-nvtvm7jc.js";export{fe as groupBlocksForStyle};
1
+ import{fe}from"../chunk-6h5760d3.js";import"../chunk-a5b2tm60.js";export{fe as groupBlocksForStyle};
@@ -1 +1 @@
1
- import{vt,ve,ot,l,bt}from"../chunk-nvtvm7jc.js";export{vt as STREAM_STYLES,ot as TOOL_CATEGORIES,l as describeToolUse,ve as isCodexLook,bt as toolDotClass};
1
+ import{xt,xe,ot,l,bt}from"../chunk-a5b2tm60.js";export{xt as STREAM_STYLES,ot as TOOL_CATEGORIES,l as describeToolUse,xe as isCodexLook,bt as toolDotClass};
@@ -1 +1 @@
1
- import{e}from"../chunk-xgy0heva.js";import"../chunk-ake02dgs.js";import{ce}from"../chunk-9cdspnb1.js";import"../chunk-11n6ah6p.js";import{A}from"../chunk-h7y6vmb3.js";import{cn as Y}from"cn";import{SearchIcon as Z}from"lucide-react";import{useCallback as _,useEffect as g,useMemo as z,useRef as v,useState as R}from"react";import{jsxDEV as y,Fragment as et}from"react/jsx-dev-runtime";var D="chat-search",F="chat-search-current",U=150;function it(o){let r=o??"";return[...document.querySelectorAll("[data-chat-scroll]")].find((l)=>l.dataset.chatScroll===r)??null}var j=12;function J(o,r="center"){let l=o.closest("[data-chat-scroll]");if(!l)return;let d=o.getBoundingClientRect(),m=l.getBoundingClientRect(),x=r==="start"?j:(l.clientHeight-d.height)/2;l.scrollTo({top:l.scrollTop+(d.top-m.top)-x,behavior:"smooth"})}function q(o){let r=o.startContainer.parentElement;if(!r)return;J(r)}var T=new Map;function Q(){if(typeof CSS>"u"||!("highlights"in CSS)||typeof Highlight>"u")return;if(T.size===0){CSS.highlights.delete(D),CSS.highlights.delete(F);return}let o=[...T.values()];CSS.highlights.set(D,new Highlight(...o.flatMap((r)=>r.all))),CSS.highlights.set(F,new Highlight(...o.flatMap((r)=>r.current?[r.current]:[])))}function tt(){let o=Symbol();return{clearHighlights:()=>{T.delete(o),Q()},applyHighlights:(r,l)=>{T.set(o,{all:r,current:l}),Q()}}}function ut({getViewport:o,findSourceMatches:r,revealTurn:l,subscribeOpen:d,labels:m,placement:x="header"}){let{clearHighlights:i,applyHighlights:p}=z(tt,[]),S=r!==void 0,[s,w]=R(!1),[u,K]=R(""),h=z(()=>s&&u.trim()&&r?r(u.trim()):[],[r,s,u]),[O,L]=R(0),[V,E]=R(0),C=v([]),H=v(0),a=v(null),P=v(null),G=v(null);g(()=>{if(!d)return;return d(()=>{w(!0);let t=G.current;if(t!==null)t.focus(),t.select()})},[d]);let I=_(async(c,t)=>{let n=h[c];if(n===void 0)return;let f=o();if(f===null)throw Error("Chat scroll container is missing");if(l)await l(n.turnKey,t);if(t.aborted)return;let b=f.querySelector(`[data-turn-key="${CSS.escape(n.turnKey)}"]`);if(b===null)throw Error(`Codex turn is missing: ${n.turnKey}`);if(!l)J(b,"start");if(await new Promise((X)=>requestAnimationFrame(()=>X())),t.aborted)return;let B=A(b,u.trim());C.current=B;let N=B[n.occurrenceInTurn];if(p(B,N??null),N!==void 0)q(N)},[p,h,o,u,l]),k=v(I);g(()=>{k.current=I},[I]);let M=_(()=>{w(!1),K(""),H.current=0,a.current?.abort(),a.current=null,i(),C.current=[]},[i]);g(()=>{if(!s)return;let c=(t)=>{if(t.key==="Escape"&&P.current?.contains(document.activeElement))t.preventDefault(),M()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s,M]),g(()=>{if(!s||!u.trim()){i(),C.current=[],L(0),E(0),H.current=0;return}let c=setTimeout(()=>{if(S)return;let t=o();if(!t)return;let n=A(t,u);if(C.current=n,L(n.length),E(0),p(n,n[0]??null),n[0])q(n[0])},U);return()=>{clearTimeout(c),i()}},[p,i,S,s,u,o]),g(()=>{if(!s||!S||!u.trim())return;let c=new AbortController;a.current?.abort(),a.current=c;let t=setTimeout(()=>{C.current=[],H.current=0,L(h.length),E(0),i(),k.current(0,c.signal)},U);return()=>{if(c.abort(),a.current===c)a.current=null;clearTimeout(t),i()}},[i,h.length,S,s,u]),g(()=>()=>{a.current?.abort(),i()},[i]),g(()=>{if(!s)i()},[i,s]);let W=_((c)=>{if(S){if(h.length===0)return;let n=(H.current+(c?-1:1)+h.length)%h.length;H.current=n,E(n),a.current?.abort();let f=new AbortController;a.current=f,k.current(n,f.signal);return}let t=C.current;if(!t.length)return;E((n)=>{let f=(n+(c?-1:1)+t.length)%t.length,b=t[f];return p(t,b),q(b),f})},[p,h.length,S]);return y(et,{children:[x==="header"&&y(e,{variant:"ghost",size:"icon-sm",title:m.search,onClick:()=>s?M():w(!0),children:y(Z,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),s&&y("div",{"data-chat-search":!0,ref:P,className:Y("bg-background border-b",x==="body"?"relative shrink-0":"absolute inset-x-0 top-full z-30"),children:[y(ce,{ref:G,value:u,onChange:K,onFind:W,onClose:M,placeholder:m.placeholder,prevTitle:m.previous,nextTitle:m.next},void 0,!1,void 0,this),u.trim()&&y("div",{className:"text-muted-foreground border-border border-t px-3 py-1 text-[11px]",children:O===0?"0 / 0":`${V+1} / ${O}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{ut as ChatSearch,A as collectMatches,it as findChatScrollContainer,J as scrollChatElementIntoView};
1
+ import{e}from"../chunk-vk39871j.js";import"../chunk-wmsdg5fb.js";import{ce}from"../chunk-naw83wcw.js";import"../chunk-11n6ah6p.js";import{A}from"../chunk-h7y6vmb3.js";import{cn as Z}from"cn";import{SearchIcon as j}from"lucide-react";import{useCallback as _,useEffect as g,useMemo as z,useRef as v,useState as M}from"react";import{jsx as R,jsxs as J,Fragment as rt}from"react/jsx-runtime";var D="chat-search",F="chat-search-current",U=150;function st(o){let r=o??"";return[...document.querySelectorAll("[data-chat-scroll]")].find((l)=>l.dataset.chatScroll===r)??null}var tt=12;function V(o,r="center"){let l=o.closest("[data-chat-scroll]");if(!l)return;let d=o.getBoundingClientRect(),m=l.getBoundingClientRect(),H=r==="start"?tt:(l.clientHeight-d.height)/2;l.scrollTo({top:l.scrollTop+(d.top-m.top)-H,behavior:"smooth"})}function q(o){let r=o.startContainer.parentElement;if(!r)return;V(r)}var T=new Map;function Q(){if(typeof CSS>"u"||!("highlights"in CSS)||typeof Highlight>"u")return;if(T.size===0){CSS.highlights.delete(D),CSS.highlights.delete(F);return}let o=[...T.values()];CSS.highlights.set(D,new Highlight(...o.flatMap((r)=>r.all))),CSS.highlights.set(F,new Highlight(...o.flatMap((r)=>r.current?[r.current]:[])))}function et(){let o=Symbol();return{clearHighlights:()=>{T.delete(o),Q()},applyHighlights:(r,l)=>{T.set(o,{all:r,current:l}),Q()}}}function at({getViewport:o,findSourceMatches:r,revealTurn:l,subscribeOpen:d,labels:m,placement:H="header"}){let{clearHighlights:i,applyHighlights:p}=z(et,[]),S=r!==void 0,[s,w]=M(!1),[u,K]=M(""),h=z(()=>s&&u.trim()&&r?r(u.trim()):[],[r,s,u]),[O,L]=M(0),[W,y]=M(0),C=v([]),E=v(0),a=v(null),P=v(null),G=v(null);g(()=>{if(!d)return;return d(()=>{w(!0);let t=G.current;if(t!==null)t.focus(),t.select()})},[d]);let I=_(async(c,t)=>{let n=h[c];if(n===void 0)return;let f=o();if(f===null)throw Error("Chat scroll container is missing");if(l)await l(n.turnKey,t);if(t.aborted)return;let b=f.querySelector(`[data-turn-key="${CSS.escape(n.turnKey)}"]`);if(b===null)throw Error(`Codex turn is missing: ${n.turnKey}`);if(!l)V(b,"start");if(await new Promise((Y)=>requestAnimationFrame(()=>Y())),t.aborted)return;let B=A(b,u.trim());C.current=B;let N=B[n.occurrenceInTurn];if(p(B,N??null),N!==void 0)q(N)},[p,h,o,u,l]),k=v(I);g(()=>{k.current=I},[I]);let x=_(()=>{w(!1),K(""),E.current=0,a.current?.abort(),a.current=null,i(),C.current=[]},[i]);g(()=>{if(!s)return;let c=(t)=>{if(t.key==="Escape"&&P.current?.contains(document.activeElement))t.preventDefault(),x()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s,x]),g(()=>{if(!s||!u.trim()){i(),C.current=[],L(0),y(0),E.current=0;return}let c=setTimeout(()=>{if(S)return;let t=o();if(!t)return;let n=A(t,u);if(C.current=n,L(n.length),y(0),p(n,n[0]??null),n[0])q(n[0])},U);return()=>{clearTimeout(c),i()}},[p,i,S,s,u,o]),g(()=>{if(!s||!S||!u.trim())return;let c=new AbortController;a.current?.abort(),a.current=c;let t=setTimeout(()=>{C.current=[],E.current=0,L(h.length),y(0),i(),k.current(0,c.signal)},U);return()=>{if(c.abort(),a.current===c)a.current=null;clearTimeout(t),i()}},[i,h.length,S,s,u]),g(()=>()=>{a.current?.abort(),i()},[i]),g(()=>{if(!s)i()},[i,s]);let X=_((c)=>{if(S){if(h.length===0)return;let n=(E.current+(c?-1:1)+h.length)%h.length;E.current=n,y(n),a.current?.abort();let f=new AbortController;a.current=f,k.current(n,f.signal);return}let t=C.current;if(!t.length)return;y((n)=>{let f=(n+(c?-1:1)+t.length)%t.length,b=t[f];return p(t,b),q(b),f})},[p,h.length,S]);return J(rt,{children:[H==="header"&&R(e,{variant:"ghost",size:"icon-sm",title:m.search,onClick:()=>s?x():w(!0),children:R(j,{})}),s&&J("div",{"data-chat-search":!0,ref:P,className:Z("bg-background border-b",H==="body"?"relative shrink-0":"absolute inset-x-0 top-full z-30"),children:[R(ce,{ref:G,value:u,onChange:K,onFind:X,onClose:x,placeholder:m.placeholder,prevTitle:m.previous,nextTitle:m.next}),u.trim()&&R("div",{className:"text-muted-foreground border-border border-t px-3 py-1 text-[11px]",children:O===0?"0 / 0":`${W+1} / ${O}`})]})]})}export{at as ChatSearch,A as collectMatches,st as findChatScrollContainer,V as scrollChatElementIntoView};
@@ -1 +1 @@
1
- import{ce}from"../chunk-9cdspnb1.js";import"../chunk-ake02dgs.js";import"../chunk-xgy0heva.js";export{ce as FindBar};
1
+ import{ce}from"../chunk-naw83wcw.js";import"../chunk-wmsdg5fb.js";import"../chunk-vk39871j.js";export{ce as FindBar};
package/dist/ui/button.js CHANGED
@@ -1 +1 @@
1
- import{mt,e}from"../chunk-xgy0heva.js";export{e as Button,mt as buttonVariants};
1
+ import{mt,e}from"../chunk-vk39871j.js";export{e as Button,mt as buttonVariants};
package/dist/ui/card.js CHANGED
@@ -1 +1 @@
1
- import{Ve,Ke,We,qe,Lt,Ge,je}from"../chunk-x6jyxw9c.js";export{Ve as Card,Lt as CardAction,Ge as CardContent,qe as CardDescription,je as CardFooter,Ke as CardHeader,We as CardTitle};
1
+ import{Ve,Ke,We,qe,Lt,Ge,je}from"../chunk-rq0cpnvn.js";export{Ve as Card,Lt as CardAction,Ge as CardContent,qe as CardDescription,je as CardFooter,Ke as CardHeader,We as CardTitle};