@alwith/module-chat 0.1.30 → 0.1.31
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.
- package/dist/activity-host.js +1 -1
- package/dist/approval/choice-elicitation-form.js +1 -1
- package/dist/approval/choice-schema.js +1 -1
- package/dist/approval/permission-options.js +1 -1
- package/dist/approval/permission-view.js +1 -1
- package/dist/approval/schema-elicitation-form.js +1 -1
- package/dist/approval/url-elicitation-card.js +1 -1
- package/dist/{chunk-ta690ra0.js → chunk-0e1pdbec.js} +2 -2
- package/dist/chunk-0m271xz8.js +1 -0
- package/dist/chunk-1hy64ewz.js +1 -0
- package/dist/chunk-1twg3evk.js +1 -0
- package/dist/{chunk-kew8ef6z.js → chunk-25na55ve.js} +2 -2
- package/dist/chunk-2r04c28x.js +2 -0
- package/dist/{chunk-y1cbwywe.js → chunk-341yykkp.js} +1 -1
- package/dist/chunk-3dr41azp.js +2 -0
- package/dist/chunk-54h8srdy.js +1 -0
- package/dist/chunk-6f7mdmsp.js +2 -0
- package/dist/chunk-7n3ege46.js +2 -0
- package/dist/chunk-7tj0a2na.js +2 -0
- package/dist/chunk-8r6388q9.js +2 -0
- package/dist/{chunk-aaybyhdj.js → chunk-9me7jmzd.js} +2 -2
- package/dist/chunk-arge74eh.js +2 -0
- package/dist/chunk-bf5fh35b.js +2 -0
- package/dist/{chunk-tbr607hk.js → chunk-bhvtt6tv.js} +2 -2
- package/dist/chunk-bwzjm3g8.js +1 -0
- package/dist/chunk-d0ptk8x8.js +1 -0
- package/dist/chunk-darkfx1b.js +2 -0
- package/dist/chunk-dj8v2w6n.js +1 -0
- package/dist/chunk-g20b01rn.js +2 -0
- package/dist/{chunk-p4c1w6qx.js → chunk-g77gammg.js} +2 -2
- package/dist/chunk-hnt4tt1n.js +2 -0
- package/dist/chunk-kscn218z.js +1 -0
- package/dist/chunk-p9wpghey.js +2 -0
- package/dist/chunk-pk9khgvs.js +2 -0
- package/dist/{chunk-wf194rae.js → chunk-qj8r5xvx.js} +2 -2
- package/dist/chunk-qmbekvg9.js +2 -0
- package/dist/chunk-qwe4sfh0.js +1 -0
- package/dist/chunk-qyhgwc51.js +2 -0
- package/dist/chunk-r125b0z5.js +2 -0
- package/dist/{chunk-h7y6vmb3.js → chunk-rakd7vzb.js} +1 -1
- package/dist/chunk-reqrpvyy.js +2 -0
- package/dist/chunk-s365bfbf.js +1 -0
- package/dist/{chunk-7471tnsq.js → chunk-s3z33k7f.js} +2 -2
- package/dist/chunk-sepy631p.js +1 -0
- package/dist/{chunk-98t2nc02.js → chunk-src2j5cw.js} +2 -2
- package/dist/chunk-tygbx698.js +7 -0
- package/dist/chunk-vq236zge.js +1 -0
- package/dist/chunk-w5mg77ac.js +2 -0
- package/dist/chunk-wjejhpgw.js +1 -0
- package/dist/chunk-wjqqh1d4.js +1 -0
- package/dist/chunk-x3jp5bsh.js +3 -0
- package/dist/chunk-xhkt2dhz.js +2 -0
- package/dist/{chunk-nvtvm7jc.js → chunk-y2xbq7rb.js} +3 -3
- package/dist/chunk-yk52gm8x.js +2 -0
- package/dist/chunk-zt7a6b1m.js +1 -0
- package/dist/chunk-zy5cq9m3.js +2 -0
- package/dist/codex/activity-group.js +1 -1
- package/dist/codex/assistant-message.js +2 -2
- package/dist/codex/async-question-card.js +2 -2
- package/dist/codex/edited-files-card.js +1 -1
- package/dist/codex/image-view-activity.js +1 -1
- package/dist/codex/markdown-renderer.js +5 -5
- package/dist/codex/navigation-preview.js +1 -1
- package/dist/codex/navigation-rail.js +1 -1
- package/dist/codex/patch-view.js +2 -2
- package/dist/codex/plan.js +1 -1
- package/dist/codex/terminal-output.js +1 -1
- package/dist/codex/thread-virtualizer.js +1 -1
- package/dist/codex/user-message.js +1 -1
- package/dist/codex/virtualized-turn-list.js +1 -1
- package/dist/composer/completion-filter.js +1 -1
- package/dist/composer/completion-menu.js +3 -3
- package/dist/composer/completion-trigger.js +1 -1
- package/dist/composer/effort-slider.js +1 -1
- package/dist/composer/menu-radio.js +1 -1
- package/dist/composer/model-select.js +1 -1
- package/dist/composer/permission-mode-select.js +1 -1
- package/dist/composer/prompt-input-attachments.js +1 -1
- package/dist/composer/prompt-input-clipboard.js +1 -1
- package/dist/composer/prompt-input-context.js +1 -1
- package/dist/composer/prompt-input-textarea.js +3 -3
- package/dist/composer/prompt-input.js +1 -1
- package/dist/image-lightbox.js +1 -1
- package/dist/image-preview-dialog.js +1 -1
- package/dist/lib/code-highlighter.js +1 -1
- package/dist/lib/fuzzy.js +1 -1
- package/dist/lib/group-blocks.js +1 -1
- package/dist/lib/image-encode.js +1 -1
- package/dist/lib/limits.js +1 -1
- package/dist/lib/markdown-parser.js +1 -1
- package/dist/lib/markdown-rules.js +1 -1
- package/dist/lib/model-name.js +1 -1
- package/dist/lib/pointer-centered-zoom.js +1 -1
- package/dist/lib/prepare-prompt-files.js +1 -1
- package/dist/lib/stream-style.js +1 -1
- package/dist/lib/streaming-markdown.js +1 -1
- package/dist/search/chat-search.js +1 -1
- package/dist/search/dom-matches.js +1 -1
- package/dist/search/find-bar.js +1 -1
- package/dist/search/literal-matches.js +1 -1
- package/dist/ui/badge.js +1 -1
- package/dist/ui/button.js +1 -1
- package/dist/ui/card.js +1 -1
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/dialog.js +1 -1
- package/dist/ui/dropdown-menu.js +1 -1
- package/dist/ui/field.js +1 -1
- package/dist/ui/hover-card.js +1 -1
- package/dist/ui/input-group-textarea.js +1 -1
- package/dist/ui/input-group.js +1 -1
- package/dist/ui/input.js +1 -1
- package/dist/ui/label.js +1 -1
- package/dist/ui/radio-group.js +1 -1
- package/dist/ui/separator.js +1 -1
- package/dist/ui/switch.js +1 -1
- package/dist/ui/textarea.js +1 -1
- package/dist/ui/tooltip.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-11n6ah6p.js +0 -2
- package/dist/chunk-15a7wypc.js +0 -2
- package/dist/chunk-2kjmc9hg.js +0 -1
- package/dist/chunk-2sc7ppw2.js +0 -1
- package/dist/chunk-51qk29t6.js +0 -2
- package/dist/chunk-5hqv4m75.js +0 -1
- package/dist/chunk-67gms74t.js +0 -2
- package/dist/chunk-85y9tqsd.js +0 -2
- package/dist/chunk-99xmegcw.js +0 -2
- package/dist/chunk-9cdspnb1.js +0 -2
- package/dist/chunk-ake02dgs.js +0 -1
- package/dist/chunk-b5srhd6k.js +0 -1
- package/dist/chunk-bbnrzw5x.js +0 -2
- package/dist/chunk-bgj6z7z4.js +0 -2
- package/dist/chunk-d1xydh51.js +0 -2
- package/dist/chunk-dvfka70p.js +0 -2
- package/dist/chunk-eyn3tdcs.js +0 -2
- package/dist/chunk-h310nm02.js +0 -2
- package/dist/chunk-j63t6dxg.js +0 -1
- package/dist/chunk-jnx3t913.js +0 -2
- package/dist/chunk-nx3k6k2p.js +0 -2
- package/dist/chunk-p6kymvjw.js +0 -2
- package/dist/chunk-pkxfrrwf.js +0 -1
- package/dist/chunk-pnncsvbz.js +0 -1
- package/dist/chunk-q00ycy4m.js +0 -7
- package/dist/chunk-qf9n7v84.js +0 -1
- package/dist/chunk-r9k7kszp.js +0 -1
- package/dist/chunk-rka1mc9r.js +0 -1
- package/dist/chunk-s4w6yjc0.js +0 -1
- package/dist/chunk-t83jwyey.js +0 -1
- package/dist/chunk-tm40sncc.js +0 -2
- package/dist/chunk-twww750f.js +0 -2
- package/dist/chunk-wbpw278r.js +0 -2
- package/dist/chunk-x6jyxw9c.js +0 -1
- package/dist/chunk-xc6fz2xk.js +0 -3
- package/dist/chunk-xgy0heva.js +0 -1
- package/dist/chunk-ytqka33j.js +0 -2
- package/dist/chunk-z3gwnjmk.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createContext as f,useCallback as n,useContext as i,useEffect as et,useMemo as J,useRef as g,useState as K}from"react";import{jsx as N}from"react/jsx-runtime";var A=f(null),O=f(null);function pt(){return i(O)}var B=f(null);function gt(){return i(B)}var k=f(null);function ce(){let r=i(A);if(!r)throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");return r}var C=()=>i(A);function ft(){let r=i(k);if(!r)throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");return r}var nt=()=>i(k);function ht({initialInput:r="",revision:l,onSubmittedClear:c,onRemoveAttachment:R,attachmentPolicy:P,value:y,onValueChange:U,attachments:L,onAttachmentsChange:S,children:Q}){let T=n((t)=>{if(t.type)return t.type;let e=(t.name||"").toLowerCase();if(e.endsWith(".png"))return"image/png";if(e.endsWith(".jpg")||e.endsWith(".jpeg"))return"image/jpeg";if(e.endsWith(".webp"))return"image/webp";if(e.endsWith(".gif"))return"image/gif";if(e.endsWith(".bmp"))return"image/bmp";if(e.endsWith(".svg"))return"image/svg+xml";return""},[]),W=y!==void 0,[V,X]=K(r),a=y??V,o=g({value:a,external:l,revision:0});if(o.current.value!==a||o.current.external!==l)o.current={value:a,external:l,revision:o.current.revision+1};let j=n(()=>o.current.revision,[]),x=n((t)=>{if(o.current.value=t,o.current.revision++,W)U?.(t);else X(t)},[W,U]),h=n(()=>x(""),[x]),v=L!==void 0,[Y,Z]=K([]),I=L??Y,b=g(I);b.current=I;let s=n((t)=>{let e=typeof t==="function"?t(b.current):t;if(v)S?.(e);else Z(e)},[v,S]),w=g(null),M=g(()=>{}),E=n((t)=>{let e=[...t];if(e.length===0)return;s((m)=>{let d=P===void 0?e:P.uniqueFiles(e,m);return[...m,...d.map((u)=>{let G=P?.sourcePath(u);return{id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(u),mediaType:T(u),filename:u.name,size:u.size,lastModified:u.lastModified,...G===void 0?{}:{sourcePath:G}}})]})},[P,T,s]),H=n((t)=>{s((e)=>{let m=e.find((d)=>d.id===t);if(m?.url)URL.revokeObjectURL(m.url);return e.filter((d)=>d.id!==t)}),R?.()},[R,s]),_=n(()=>{s((t)=>{for(let e of t)if(e.url)URL.revokeObjectURL(e.url);return[]})},[s]);et(()=>{if(v)return;return()=>{for(let t of b.current)if(t.url)URL.revokeObjectURL(t.url)}},[v]);let q=n(()=>{M.current?.()},[]),F=J(()=>({files:I,add:E,remove:H,clear:_,openFileDialog:q,fileInputRef:w}),[I,E,H,_,q]),D=n((t,e)=>{w.current=t.current,M.current=e},[]),tt=J(()=>({textInput:{value:a,setInput:x,clear:h,getRevision:j,clearSubmitted:c??h},attachments:F,__registerFileInput:D}),[a,x,h,j,c,F,D]);return N(A.Provider,{value:tt,children:N(k.Provider,{value:F,children:Q})})}var z=f(null);function p(){let r=nt(),l=i(z),c=r??l;if(!c)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return c}
|
|
2
|
+
export{O,pt,B,gt,k,ce,C,ft,ht,z,p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Button as n}from"@base-ui/react/button";import{cva as d}from"class-variance-authority";import{cn as o}from"cn";import{jsx as s}from"react/jsx-runtime";var ut=d("group/button focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:ring-3 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50 shadow-xs",secondary:"bg-secondary text-secondary-foreground aria-expanded:bg-secondary aria-expanded:text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",lg:"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-9","icon-xs":"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function e({className:r,variant:t="default",size:i="default",...a}){return s(n,{"data-slot":"button",className:o(ut({variant:t,size:i,className:r})),...a})}export{ut,e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Separator as o}from"@base-ui/react/separator";import{cn as i}from"cn";import{jsx as e}from"react/jsx-runtime";function N({className:a,orientation:r="horizontal",...t}){return e(o,{"data-slot":"separator",orientation:r,className:i("bg-border shrink-0 data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...t})}export{N};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t}from"./chunk-8r6388q9.js";import{ChevronDownIcon as v,ChevronUpIcon as b,FileDiffIcon as C}from"lucide-react";import{useState as m}from"react";import{jsx as d,jsxs as o}from"react/jsx-runtime";function x(e){if(e===null||e.length===0)return 0;return e.split(`
|
|
2
|
+
`).length}function at(e){let l=new Map;for(let u of e)for(let a of u.content){if(a.type!=="diff")continue;let f=a,r=f._meta?.alwith?.hunks??[],h=r.reduce((i,s)=>i+x(s.newText),0),c=r.reduce((i,s)=>i+x(s.oldText),0);for(let i of f.changes){let s=l.get(i.path);if(s)s.additions+=h,s.deletions+=c;else l.set(i.path,{path:i.path,additions:h,deletions:c})}}return[...l.values()]}function ve({blocks:e}){return d(st,{files:at(e)})}function st({files:e,onOpen:l,renderPath:u}){let{t:a,openLink:f}=t(),[r,h]=m(!0),[c,i]=m(!1);if(e.length===0)return null;let s=e.reduce((n,p)=>n+p.additions,0),g=e.reduce((n,p)=>n+p.deletions,0);return o("section",{className:"codex-edited-files-card",children:[o("div",{className:"codex-edited-files-header",children:[d("div",{className:"codex-edited-files-icon","aria-hidden":"true",children:d(C,{})}),o("div",{className:"codex-edited-files-summary",children:[d("strong",{children:a("stream.codex.editedFilesCount",{count:e.length})}),d("button",{type:"button","data-codex-disclosure":"",onClick:()=>{h((n)=>!n),i(!1)},"aria-expanded":r,children:a(r?"stream.codex.hideChanges":"stream.codex.viewChanges")})]}),o("div",{className:"codex-edited-files-total",title:a("stream.codex.changedLines"),children:[o("span",{className:"codex-diff-additions",children:["+",s]}),o("span",{className:"codex-diff-deletions",children:["-",g]})]})]}),r&&o("div",{className:"codex-edited-files-list",children:[(c?e:e.slice(0,3)).map((n)=>o("div",{className:"codex-edited-file-row",children:[d("button",{type:"button",className:"codex-edited-file-path",title:n.path,onClick:()=>l===void 0?f(n.path):l(n),children:u===void 0?n.path:u(n)}),o("span",{className:"codex-edited-file-counts",children:[o("span",{className:"codex-diff-additions",children:["+",n.additions]}),o("span",{className:"codex-diff-deletions",children:["-",n.deletions]})]})]},n.path)),e.length>3&&o("button",{type:"button",className:"codex-edited-files-more","aria-expanded":c,onClick:()=>i((n)=>!n),children:[a(c?"stream.codex.showFewerFiles":"stream.codex.showMoreFiles",{count:e.length-3}),c?d(b,{size:16,"aria-hidden":"true"}):d(v,{size:16,"aria-hidden":"true"})]})]})]})}
|
|
3
|
+
export{at,ve,st};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t}from"./chunk-8r6388q9.js";import{i}from"./chunk-pve9b7z3.js";import{isContentEntry as N,isImage as w,isResourceLink as C}from"@alwith/api";import{ChevronRightIcon as S,ImageIcon as A,LoaderCircleIcon as R,RefreshCwIcon as B}from"lucide-react";import{useEffect as T,useState as x}from"react";import{jsx as r,jsxs as h}from"react/jsx-runtime";function f(e){return e.type==="tool_use"&&e.name==="view_image"&&e.status==="completed"}function E(e){let c=[];for(let[l,u]of e.content.entries()){if(!N(u))continue;let s=u.content;if(w(s))c.push({key:`${e.id}:${l}`,src:`data:${s.mimeType};base64,${s.data}`,alt:e.title??""});if(C(s))c.push({key:`${e.id}:${l}`,path:s.uri,alt:s.name})}if(c.length)return c;let o=e.rawInput;if(o!==null&&typeof o==="object"&&"path"in o&&typeof o.path==="string")return[{key:e.id,path:o.path,alt:o.path.split(/[\\/]/).at(-1)??o.path}];throw Error(`Image view ${e.id} has no image source`)}function U({images:e}){let{loadImage:c,openImageGallery:o,openImage:l,t:u}=t(),[s,y]=x({}),[I,k]=x(0),v=JSON.stringify(e);T(()=>{let a=!0,d=JSON.parse(v);y({});for(let n of d)(n.src!==void 0?Promise.resolve(n.src):n.path!==void 0&&c?c(n.path):Promise.reject(Error("Image loading is unavailable"))).then((m)=>{if(a)y((g)=>({...g,[n.key]:{src:m}}))},()=>{if(a)y((m)=>({...m,[n.key]:{error:!0}}))});return()=>{a=!1}},[v,c,I]);let b=e.flatMap((a)=>{let d=s[a.key];return d&&"src"in d?[{src:d.src,alt:a.alt}]:[]});return r("div",{className:"codex-image-thumbnails",children:e.map((a,d)=>{let n=s[a.key];if(!n)return r("div",{className:"codex-image-thumbnail",role:"status","aria-label":u("stream.codex.imageLoading"),children:r(R,{className:"motion-safe:animate-spin","aria-hidden":"true"})},a.key);if("error"in n)return r("button",{type:"button",className:"codex-image-thumbnail",title:a.alt,"aria-label":u("stream.codex.imageFailed"),onClick:()=>k((p)=>p+1),children:r(B,{"aria-hidden":"true"})},a.key);return r("button",{type:"button",className:"codex-image-thumbnail",title:a.alt,onClick:()=>{let p=e.slice(0,d).filter((m)=>{let g=s[m.key];return g&&"src"in g}).length;if(o)o(b,p);else l?.(n.src)},children:r("img",{src:n.src,alt:a.alt,draggable:!1})},a.key)})})}function we({blocks:e}){let{t:c}=t(),o=e.flatMap(E),[l,u]=i(`image-view:${e[0].id}`,!1);return h("div",{className:"codex-activity-item",children:[h("button",{type:"button",className:"codex-activity-header","data-codex-disclosure":"","aria-expanded":l,onClick:()=>u((s)=>!s),children:[h("span",{className:"codex-activity-label",children:[r(A,{className:"codex-activity-icon","aria-hidden":"true"}),r("span",{className:"codex-activity-leading",children:c("stream.codex.viewedImages",{count:o.length})})]}),r(S,{className:l?"codex-image-chevron codex-image-chevron-open":"codex-image-chevron","aria-hidden":"true"})]}),l&&r(U,{images:o})]})}
|
|
2
|
+
export{f,we};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)[0]??e("pattern")??e("url")??e("query")??e("description");return{category:o,...s===void 0?{}:{target:s},...n===void 0?{}:{filePath:n}}}function
|
|
3
|
-
export{
|
|
1
|
+
var Ht=["full","compact","codexUI"];function et(t){return t==="compact"||t==="codexUI"}var mt=["read","edit","delete","move","search","execute","think","fetch","switch_mode","other"];function c(t){let o=t.split(/[/\\]/).at(-1)??"";return o===""?t:o}function d(t){let o=mt.includes(t.kind)?t.kind:"other",i=t.rawInput,e=(a)=>{let r=i[a];return typeof r==="string"&&r.length>0?r:void 0},n=t.locations?.[0]?.path??e("file_path")??e("notebook_path"),s=n!==void 0?c(n):e("command")?.split(`
|
|
2
|
+
`)[0]??e("pattern")??e("url")??e("query")??e("description");return{category:o,...s===void 0?{}:{target:s},...n===void 0?{}:{filePath:n}}}function Ot(t,o){if(o)return"dot-permission";switch(t){case"completed":return"dot-success";case"failed":return"dot-error";case"in_progress":return"dot-in-progress";case"pending":return"dot-pending";case"interrupted":return"dot-interrupted";default:return console.warn("[acp] unknown tool call status:",t),"dot-pending"}}
|
|
3
|
+
export{Ht,et,mt,d,Ot};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function Ce(t){return Object.entries(t.properties??{}).map(([n,e])=>({key:n,property:e}))}function X(t){let{title:n,description:e}=t;return{title:n??void 0,description:e??void 0}}function h(t){return t.type==="array"}function F(t){return(h(t)?t.items?.oneOf??[]:t.oneOf??[]).map((e)=>{let i=e,r=i.const??i.title??"";return{value:r,label:i.title??r,...i.description?{description:i.description}:{},...i._meta?.alwith?.preview?{preview:i._meta.alwith.preview}:{}}})}
|
|
2
|
+
export{Ce,X,h,F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Radio as o}from"@base-ui/react/radio";import{RadioGroup as t}from"@base-ui/react/radio-group";import{cn as d}from"cn";import{jsx as i}from"react/jsx-runtime";function c({className:r,...e}){return i(t,{"data-slot":"radio-group",className:d("grid w-full gap-3",r),...e})}function a({className:r,...e}){return i(o.Root,{"data-slot":"radio-group-item",className:d("group/radio-group-item peer border-input group-has-[:focus-visible]/field-label:not-data-checked:border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary relative flex aspect-square size-4 shrink-0 rounded-full border outline-none group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3",r),...e,children:i(o.Indicator,{"data-slot":"radio-group-indicator",className:"flex size-4 items-center justify-center",children:i("span",{className:"bg-primary-foreground absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full"})})})}export{c,a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{cn as x}from"cn";import{jsx as c,jsxs as u}from"react/jsx-runtime";function U({name:m,value:r,levels:p,disabled:d,onChange:h}){if(p.length===0)throw Error("EffortSlider requires at least one level");let a=p,o=Math.max(0,a.findIndex((t)=>t.value===r)),i=76,l=14,s=2,n=a.length,b=s+o/Math.max(1,n-1)*(i-l-s*2);return u("div",{className:x("flex items-center justify-between px-2 py-2.5",d&&"opacity-50"),children:[u("span",{className:"text-sm",children:[m," ",u("span",{"data-effort-value":"",style:{fontSize:12},children:["(",a.find((t)=>t.value===r)?.name??r,")"]})]}),u("button",{type:"button",disabled:d,role:"slider","aria-label":m,"aria-valuemin":0,"aria-valuemax":n-1,"aria-valuenow":o,"aria-valuetext":a.find((t)=>t.value===r)?.name??r,onKeyDown:(t)=>{let e;if(t.key==="ArrowRight"||t.key==="ArrowUp")e=Math.min(n-1,o+1);else if(t.key==="ArrowLeft"||t.key==="ArrowDown")e=Math.max(0,o-1);else if(t.key==="Home")e=0;else if(t.key==="End")e=n-1;else return;if(t.preventDefault(),t.stopPropagation(),!d&&e!==o)h(a[e].value)},className:"relative shrink-0 cursor-pointer overflow-hidden rounded-full border-none p-0 disabled:cursor-default",style:{width:i,height:18,background:"var(--input)"},onClick:(t)=>{let e=t.currentTarget.getBoundingClientRect(),f=t.clientX-e.left,g=i/n,y=Math.min(n-1,Math.max(0,Math.floor(f/g)));h(a[y].value)},children:[c("span",{className:"absolute inset-y-0 left-0 w-full rounded-full",style:{background:"var(--input)"}}),a.map((t,e)=>{let f=s+l/2+e/Math.max(1,n-1)*(i-l-s*2)-2;return c("span",{className:"absolute top-1/2 size-1 -translate-y-1/2 rounded-full",style:{left:f,background:"color-mix(in srgb, var(--muted-foreground) 40%, transparent)"}},t.value)}),c("span",{className:"absolute rounded-full transition-all duration-150",style:{width:l,height:l,top:s,left:b,background:"var(--foreground)",boxShadow:"0 1px 2px #0003"}})]})]})}
|
|
2
|
+
export{U};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{be,ye}from"../chunk-tygbx698.js";import"../chunk-xhkt2dhz.js";import"../chunk-pve9b7z3.js";import"../chunk-8r6388q9.js";import"../chunk-bf5fh35b.js";import"../chunk-p9wpghey.js";import"../chunk-y2xbq7rb.js";export{ye as CodexActivityGroup,be as CodexWorkSection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t,u}from"../chunk-
|
|
2
|
-
`),
|
|
1
|
+
import{t,u}from"../chunk-8r6388q9.js";import{d}from"../chunk-y2xbq7rb.js";import{Ue}from"../chunk-s3z33k7f.js";import"../chunk-p9wpghey.js";import"../chunk-pve9b7z3.js";import"../chunk-xhkt2dhz.js";import{T}from"../chunk-bf5fh35b.js";import{be,ye}from"../chunk-tygbx698.js";import{ve}from"../chunk-x3jp5bsh.js";import"../chunk-6f7mdmsp.js";import{W}from"../chunk-qmbekvg9.js";import{cn as P}from"cn";import{jsx as n,jsxs as y}from"react/jsx-runtime";var R=new WeakMap,I=1;function N(e){if(e.type==="tool_use"||e.type==="subagent"||e.type==="collab")return`${e.type}:${e.id}`;let s=R.get(e);if(s!==void 0)return`${e.type}:${s}`;let i=I++;return R.set(e,i),`${e.type}:${i}`}function E({block:e,streaming:s,actions:i}){if(e.isApiError)return n("div",{className:"codex-stream-error",children:e.text});return y("div",{className:"codex-assistant-message",children:[n(u,{text:e.text,streaming:s}),i]})}function _({block:e,streaming:s,actions:i,renderText:r}){switch(e.type){case"text":return r===void 0?n(E,{block:e,streaming:s,actions:i}):r({block:e,streaming:s,actions:i});case"thinking":return e.thinking.length>0?n(u,{text:e.thinking,streaming:!e.isComplete}):null;case"plan":return n(T,{entries:e.entries});case"image":return n("img",{src:`data:${e.source.media_type};base64,${e.source.data}`,className:"max-h-64 rounded",alt:""});case"tool_use":case"subagent":case"collab":return null}}var S=new Set;function z({message:e,isMostRecentTurn:s,hiddenTools:i=S,time:r,beforeCopy:a,afterCopy:x,providerIcon:B,renderText:M,renderEditedFiles:C}){if(e.streaming===!0&&e.content.every((o)=>o.type==="text"?o.text.length===0:o.type==="thinking"?o.thinking.length===0:!1))return n(A,{});let h=e.content.filter((o)=>o.type==="text").map((o)=>o.text).join(`
|
|
2
|
+
`),b=!e.streaming&&h.trim().length>0?n(O,{text:h,isMostRecentTurn:s,beforeCopy:a,afterCopy:x,time:r}):null,l=Ue(e.content,"compact"),f=l.reduce((o,c,p)=>c.kind==="codexActivityGroup"?p:o,-1),k=l.findIndex((o,c)=>c>f&&o.kind==="block"&&o.block.type==="text"),w=[...e.content].toReversed().find((o)=>o.type==="text"),m=e.content.filter((o)=>o.type==="tool_use"&&d(o).category==="edit"),v=(o)=>{if(o.kind==="codexActivityGroup"){let c=o.blocks.filter((p)=>p.type!=="tool_use"||!i.has(p.name));return c.length===0?null:n(ye,{blocks:c},`activity:${N(c[0])}`)}if(o.kind!=="block")throw Error(`Codex received an incompatible grouped entry: ${o.kind}`);return n(_,{block:o.block,streaming:Boolean(e.streaming),actions:o.block===w?b:void 0,renderText:M},N(o.block))},g=f===-1?0:k===-1?l.length:k;return n(U,{stateKey:e.id,active:Boolean(e.streaming),startedAt:e.startedAt,durationMs:e.durationMs,providerId:e.providerId,providerIcon:B,work:l.slice(0,g).map(v),answer:l.length>g?l.slice(g).map(v):null,footer:f!==-1&&m.length>0&&(C===void 0?n(ve,{blocks:m}):C(m))})}function O({text:e,isMostRecentTurn:s=!1,beforeCopy:i,afterCopy:r,time:a}){let{t:x}=t();return y("div",{className:P("mt-1.5 flex h-5 w-fit -translate-x-1 items-center justify-start gap-0.5 [&_*]:transition-none",s?"opacity-100":"opacity-0 group-focus-within/am:opacity-100 group-hover/am:opacity-100"),children:[i,n(W,{text:e,label:x("actions.copy")}),r,a&&n("span",{className:"codex-user-time ms-1",title:a.full,children:a.short})]})}function A(){let{t:e}=t();return n("div",{className:"codex-pending-message py-2",role:"status",children:n("span",{className:"codex-activity-running",children:e("message.thinking")})})}function U({work:e,answer:s,footer:i,loading:r=!1,...a}){if(r)return n(A,{});return y("div",{className:"group/am codex-assistant-turn",children:[e.length>0&&n(be,{...a,children:e}),s!==null&&(e.length===0?s:n("div",{"data-local-conversation-final-assistant":!0,"data-testid":"codex-final-answer",className:"codex-final-answer",children:s})),i]})}export{z as CodexAssistantMessage,U as CodexAssistantTurn,O as CodexMessageActions};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{e}from"../chunk-
|
|
1
|
+
import{e}from"../chunk-wjejhpgw.js";import{r}from"../chunk-bwzjm3g8.js";import{c,a}from"../chunk-zt7a6b1m.js";import{o}from"../chunk-d0ptk8x8.js";import{useId as h}from"react";import{jsx as l,jsxs as g,Fragment as A}from"react/jsx-runtime";function p(n){return n!==null&&typeof n==="object"&&!Array.isArray(n)}function D(n){if(!p(n)||!p(n.codex))return[];let s=n.codex,i=s.questions;if(s.delivery!=="async"||!Array.isArray(i))return[];if(!i.every((t)=>p(t)&&typeof t.title==="string"&&t.title.trim().length>0&&(t.options===null||Array.isArray(t.options)&&t.options.every((d)=>typeof d==="string"))))return[];return i}function S(n,s){return JSON.stringify(["request_user_input_async",n,s])}function C(n){return{selected:n.options?.length?0:null,text:""}}function v(n,s){return s.selected===null?s.text:n.options?.[s.selected]??""}function B(n){return`<send_user_message_question_reply>
|
|
2
2
|
${JSON.stringify([n])}
|
|
3
|
-
</send_user_message_question_reply>`}function
|
|
3
|
+
</send_user_message_question_reply>`}function G(n){if(!p(n)||!p(n.codex))return[];let s=n.codex;return(Array.isArray(s.questionReplyParts)?s.questionReplyParts.map((t)=>p(t)?{...t,answer:t.text}:t):[s.questionReply]).filter((t)=>p(t)&&typeof t.questionItemId==="string"&&typeof t.question==="string"&&typeof t.answer==="string").map(({questionItemId:t,question:d,answer:m})=>({questionItemId:t,question:d,answer:m}))}function L({question:n,draft:s,status:i,answer:t,error:d,onChange:m,onSubmit:w,onSkip:Q,t:u}){let f=h(),x=i==="pending",k=i==="answered"||i==="skipped";return g("section",{"aria-labelledby":`${f}-title`,className:"border-border bg-card text-card-foreground flex min-w-0 flex-col gap-3 rounded-xl border p-4",children:[l("h3",{id:`${f}-title`,className:"text-sm font-medium whitespace-pre-wrap",children:n.title}),k?l("p",{className:"text-sm whitespace-pre-wrap",children:i==="answered"?t:u("asyncQuestion.skipped")}):g(A,{children:[(n.options?.length??0)>0&&g(c,{"aria-labelledby":`${f}-title`,disabled:!x,value:s.selected===null?"other":String(s.selected),onValueChange:(y)=>m({...s,selected:y==="other"?null:Number(y)}),children:[n.options?.map((y,b)=>g(r,{className:"flex items-start gap-2 text-sm",children:[l(a,{value:String(b)}),l("span",{className:"whitespace-pre-wrap",children:y})]},b)),g(r,{className:"flex items-center gap-2 text-sm",children:[l(a,{value:"other"}),u("asyncQuestion.other")]})]}),l(o,{"aria-label":u("asyncQuestion.answer"),placeholder:u("asyncQuestion.answer"),value:s.text,readOnly:!x,onChange:(y)=>m({selected:null,text:y.target.value})}),d&&l("p",{role:"alert",className:"text-destructive text-sm",children:d}),g("div",{className:"flex flex-wrap items-center gap-2",children:[l(e,{size:"sm",disabled:!x||v(n,s).trim().length===0,onClick:w,children:u(i==="submitting"?"asyncQuestion.submitting":"asyncQuestion.submit")}),l(e,{size:"sm",variant:"ghost",disabled:!x,onClick:Q,children:u("asyncQuestion.skip")}),(i==="closed"||i==="unavailable")&&l("span",{role:"status",className:"text-muted-foreground text-xs",children:u(`asyncQuestion.${i}`)})]})]})]})}export{L as AsyncQuestionCard,S as asyncQuestionId,D as asyncQuestions,C as initialQuestionDraft,v as questionAnswer,G as questionReplies,B as questionReplyEnvelope};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{at,ve,st}from"../chunk-x3jp5bsh.js";import"../chunk-8r6388q9.js";export{ve as CodexEditedFilesCard,st as EditedFilesCard,at as fileChanges};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f,
|
|
1
|
+
import{f,we}from"../chunk-xhkt2dhz.js";import"../chunk-pve9b7z3.js";import"../chunk-8r6388q9.js";export{we as ImageViewActivity,f as isImageView};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{tt}from"../chunk-25na55ve.js";import{ie,Xe}from"../chunk-g20b01rn.js";import{re}from"../chunk-9me7jmzd.js";import{decodeHTMLAttribute as v,decodeHTMLStrict as I}from"entities";import ae from"katex";import{CheckIcon as z,ChevronLeftIcon as se,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 U,memo as B,startTransition as pe,useContext as ke,useEffect as p,useLayoutEffect as D,useMemo as X,useRef as k,useState as h}from"react";import{jsx as a,jsxs as g,Fragment as te}from"react/jsx-runtime";var G=he(null);function C(){let e=ke(G);if(e===null)throw Error("Markdown host is missing");return e}var we=80,A=/\[([^\]\n]+)\]\(([^)\n]+)$/,be=/(^|\n)[^\S\n]*!\[[^\]\n]*(?:\](?:\([^\n]*)?)?\s*$/,xe=/\uE200[^\uE201]*$/,Te=4,ve=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 J(e,n,t){if(t.length!==1)return!1;return e[n-1]===t||e[n+1]===t}function Ce(e,n){let t=0;for(let r=0;r<=e.length-n.length;){if(e.startsWith(n,r)&&!y(e,r)&&!J(e,r,n)){t+=1,r+=n.length;continue}r+=1}return t}function ye(e,n){for(let t=e.length-n.length;t>=0;t-=1)if(e.startsWith(n,t)&&!y(e,t)&&!J(e,t,n))return t;return-1}function Ne(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 Me(e){return Ne(e,"```")%2===1}function V(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 Le(e){return e.endsWith(`
|
|
2
2
|
`)?`${e}\`\`\``:`${e}
|
|
3
|
-
\`\`\``}function
|
|
4
|
-
`)||
|
|
5
|
-
`),t.raw=e.slice(n,s).map((i)=>i.raw).join(""),e.splice(n+1,s-n-1)}}function
|
|
6
|
-
`,1)[0];if(t===void 0)throw Error("Codex Markdown token has no first line");return(t.match(/\S+/)?.[0]??t).slice(0,
|
|
3
|
+
\`\`\``}function H(e,n){if(!e.includes(n)||Ce(e,n)%2===0)return e;let t=ye(e,n);if(t<0)return e;let r=e.slice(t+n.length);if(r.length===0||/^\s/.test(r)||r.includes(`
|
|
4
|
+
`)||V(r))return e;return`${e}${n}`}function Ee(e){return e.startsWith("/")&&!e.startsWith("//")||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\]+\\[^\\]+/.test(e)||/^\/\/[^/]+\/[^/]+/.test(e)}function Z(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 Ie(e){let{path:n,line:t,column:r,endLine:o,endColumn:s}=Z(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>Te&&!ve.has(u))return!1}return!0}function $e(e){let{path:n}=Z(e);if(Ee(n))return!0;try{return new URL(n).protocol==="file:"}catch{return!1}}function Re(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 Ie(t)||$e(t)?e.replace(A,"$1"):`${e})`}function Pe(e){let n=e.replace(xe,"");if(n.length===0||n.includes("`")&&V(n))return{isCodeFenceOpen:!1,markdown:n};if(n.includes("```")&&Me(n))return{isCodeFenceOpen:!0,markdown:Le(n)};if(n.includes(")n=Re(n);return n=H(n,"**"),n=H(n,"*"),{isCodeFenceOpen:!1,markdown:n}}function Se(e){return e?.type==="paragraph"&&"tokens"in e&&Array.isArray(e.tokens)}function _(e){return Se(e)&&e.tokens.length===1&&e.tokens[0]?.type==="image"}function Y(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))Y(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 Fe(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"?Fe(o):o);E(t.tokens)}if("tokens"in n&&Array.isArray(n.tokens))E(n.tokens)}}function Ae(e,n,t){e.preventDefault(),e.stopPropagation(),t.openLink(n)}function He(e){try{let n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?null:`${n.origin}/favicon.ico`}catch{return null}}function _e(e){let n=He(e);return n===null?[]:[n,`https://www.google.com/s2/favicons?domain=${new URL(e).origin}&sz=32`]}function Oe({href:e}){let n=X(()=>_e(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 je({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)=>Ae(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(Oe,{href:n})}),a("span",{className:"codex-markdown-link-label",children:e})]})})}function We({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=tt(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(z,{}):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 qe({code:e,language:n}){return C().preview?a("span",{children:e}):a(Ke,{code:e,language:n})}function Ke({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(We,{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 ze(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 Ue({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(se,{})}),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 Be(e){return C().preview?a(te,{children:e.alt}):a(De,{...e})}function De({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(te,{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(ze(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(Ue,{preview:s,setPreview:i})})]})}function Ge({value:e,display:n}){let t=k(null);return D(()=>{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"})}var Je=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 Q(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 W(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,we)}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}:${W(n.text)}`}case"html":case"space":case"br":case"hr":case"def":return e.raw;case"math":return W(e.text);default:return""}}function ee(e){return`${e.type==="math"?`math-${e.display?"block":"inline"}`:e.type}-${Q(Ve(e))}`}function m(e,n){let t=new Map;return e.map((r)=>{let o=ee(r),s=t.get(o)??0;return t.set(o,s+1),ne(r,`${n}-${o}-${s}`)})}function Ze(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(z,{}):null]}):null,m(t,n)]},n)}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):a("ul",{className:r,children:o},n)}function q(e,n,t){let r=t?"th":"td",o=/^\d+$/.test(e.text);return U(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:g("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))})}),a("tbody",{className:"codex-markdown-table-body",children:e.rows.map((r)=>{let o=Q(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)})})]})})})},n)}function K(e,n,t){let r=v(e.href);if(!re(r))return null;return a(Be,{src:r,alt:I(e.text),title:e.title==null?void 0:v(e.title),allowWide:t},n)}function ne(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 U(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)=>K(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 re(o)?a(je,{href:o,title:t.title==null?void 0:v(t.title),children:r},n):a("span",{children:r},n)}case"image":return K(e,n,!1);case"code":{let t=e;return a(qe,{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 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):t.raw}case"math":{let t=e;return a(Ge,{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 en({token:e,tokenKey:n,offset:t,runs:r,generation:o}){let s=T;try{return T={cursor:t,runs:r,generation:o},ne(e,n)}finally{T=s}}var nn=B(function({result:n}){let{text:t,isStreaming:r}=n,o=X(()=>{let l=n.tokens;if(n.source.includes("!["))Y(l);E(l);let R=new Map,P=0;return l.map((M)=>{let L=ee(M),S=R.get(L)??0;R.set(L,S+1);let F=b(M),oe={token:M,tokenKey:`root-${L}-${S}`,offset:P,visibleText:F};return P+=F.length,oe})},[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<Je):[],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 D(()=>{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(en,{token:l.token,tokenKey:l.tokenKey,offset:l.offset,runs:f.runs,generation:N},l.tokenKey))})}),tn=B(function({text:n,isStreaming:t}){let r=k(null),[o,s]=h(()=>ie(n,t)),[i,c]=h(null);if(p(()=>{let d=Xe((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?Pe(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(nn,{result:o})});function mn({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(G.Provider,{value:t,children:a(tn,{text:r?o:e,isStreaming:r})})}export{mn as CodexMarkdownRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{me}from"../chunk-r125b0z5.js";export{me as NavigationPreview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{me}from"../chunk-r125b0z5.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 fe(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),[_,pe]=E(()=>new Set),[ve,be]=E(!0),[Ie,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(fe(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(),fe(ne.current,o))return;ne.current=o,pe(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;be((s.left-i.left)/a>=48)},r=new ResizeObserver(t);return r.observe(n),r.observe(e),t(),()=>r.disconnect()},[n]);let he=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||!ve)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")=>{he(e,t).catch((r)=>{if(B)B(r);else throw r})},de=m.findIndex((e)=>e.id===(W??Ie)),le=K.current,Te=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(me,{open:X,onOpenChange:U,side:"inline-end",sideOffset:0,align:"center",alignOffset:Te,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};
|
package/dist/codex/patch-view.js
CHANGED
|
@@ -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{
|
|
2
|
-
`)){if(o.startsWith("+++")||o.startsWith("---"))continue;if(o.startsWith("+"))t+=1;else if(o.startsWith("-"))
|
|
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};
|
package/dist/codex/plan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{T}from"../chunk-bf5fh35b.js";export{T as CodexPlan};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AnsiUp as
|
|
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{
|
|
1
|
+
import{xt,pe,g,K,ge,fe,he}from"../chunk-g77gammg.js";export{xt as CODEX_UNKNOWN_TURN_HEIGHT,g as calculateCodexThreadVirtualRange,fe as calculateCodexTurnCenterDistanceFromBottom,he as calculateCodexTurnTargetDistanceFromBottom,pe as createCodexThreadVirtualLayout,ge as preserveCodexThreadDistanceFromBottom,K as preserveCodexThreadRenderedWindow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{W,bt}from"../chunk-qmbekvg9.js";import"../chunk-6f7mdmsp.js";export{bt as CodexUserMessage,W as CopyAction};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{pe,g,K,ge,fe,he}from"../chunk-g77gammg.js";import{forwardRef as be,useCallback as L,useEffect as ye,useImperativeHandle as Pe,useLayoutEffect as M,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:C,children:k}){let m=s(null),[b,G]=N(!1),X=L((f)=>{m.current=f,T(_,f)},[T,_]);return M(()=>{let f=m.current;if(f===null)throw Error("Codex turn element is missing");let P=()=>{C(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()},[C]),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:C,leadingInsetPx:k=0,preserveViewport:m=!1},b){let G=s(null),[X,f]=N(k),P=C!==void 0&&C!==null;M(()=>{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(()=>pe({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 K({anchorKey:t.anchorKey,layout:i,previousRange:{startIndex:0,endIndex:Math.min(t.count,e.endIndex-e.startIndex)}})??e},[d,i]),[I,ue]=N(Re),[v,ae]=N(W),[c,se]=N(null),S=s(d?.distanceFromBottomPx??0),E=s(I),ce=s(i.turnKeys),l=s(Q),D=s(i),de=s(i),B=s(new Map),p=s(null),F=s(null),O=s(null),A=s(new Map),Z=s(!1),le=s(()=>{}),V=s(null),me=L(()=>{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),w=h===void 0?a.height:D.current.heightsPx[h];return{key:r,element:u,rect:a,bottom:a.top+w}}).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(me);ee.current=me;let R=L((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)ue(a)},[i]),q=L((e)=>{let t=Math.max(0,e.scrollHeight-i.totalHeightPx);return Math.max(0,e.scrollHeight-e.clientHeight-e.scrollTop-t)},[i.totalHeightPx]),He=L((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=L(()=>{if(F.current!==null)return F.current;return F.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)})}),F.current},[]),Te=L((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(F.current?.disconnect(),O.current!==null)cancelAnimationFrame(O.current);A.current.clear(),F.current=null,B.current.clear()},[]),M(()=>{le.current=()=>{if(n===null)return;let e=q(n);if(p.current!==null){S.current=e,ae(n.clientHeight||W);return}R(e,n.clientHeight||W)}},[q,n,R]),M(()=>{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]),M(()=>{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=he({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,se(null)})},[i,c,n,R]),M(()=>{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(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)),w=h.find((x)=>l.current[x]!==void 0)??h[0];if(w!==void 0){let x=ge({anchorKey:w,distanceFromBottomPx:r,nextLayout:i,previousLayout:e});if(x===null)throw Error(`Codex viewport anchor is missing: ${w}`);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]),M(()=>{E.current=I},[I]),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=fe({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,ue(h),new Promise((w)=>{let x={align:o.align,complete:w,getTargetElement:t,turnKey:u};p.current=x,se(x)})}}),[i,v]);let z=I,j=ce.current;if(!(j===i.turnKeys||j.length===i.turnKeys.length&&j.every((e,t)=>e===i.turnKeys[t]))){let e=j[I.startIndex];z=(e===void 0?null:K({anchorKey:e,layout:i,previousRange:I}))??g({distanceFromBottomPx:S.current,layout:i,overscanCount:J,viewportHeightPx:v})}let ne=y.length-1,xe=y[ne],re=y.slice(z.startIndex,Math.min(z.endIndex,ne)).map((e,t)=>({entry:e,index:z.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":`${z.startIndex}:${z.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:C}),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 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{V,vt}from"../chunk-arge74eh.js";import"../chunk-hnt4tt1n.js";export{vt as filterFiles,V as filterSlashCommands};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{e}from"../chunk-
|
|
2
|
-
`)?
|
|
3
|
-
`}/${t.payload} `,s=o.length,f?.(!1);else return;
|
|
1
|
+
import{e}from"../chunk-wjejhpgw.js";import{N}from"../chunk-wjqqh1d4.js";import"../chunk-hnt4tt1n.js";import{V}from"../chunk-arge74eh.js";import{ue}from"../chunk-bhvtt6tv.js";import{ce}from"../chunk-w5mg77ac.js";import{autoUpdate as st}from"@floating-ui/dom";import{cn as Y}from"cn";import{BookOpenTextIcon as it,FileIcon as lt,StoreIcon as ut}from"lucide-react";import{useCallback as at,useEffect as v,useLayoutEffect as Z,useMemo as _,useRef as R,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=ce(),l=z.textInput.value,[K,U]=g(0),[y,P]=g(null),[b,L]=g(0),W=R(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 Q=_(()=>j&&l.startsWith("!")?null:ue(l,K),[l,K,j]),r=Q?.kind==="at"&&!u?null:Q,q=`${r?.kind??"forced"}:${r?.query??""}:${i}`,[tt,et]=g(q);if(tt!==q)et(q),L(0);let I=R(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=_(()=>{if(r?.kind==="at")return y?.query===r.query&&y.search===u?y.items:[];if(r)return V(C,r.query);if(i)return V(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;W.current?.querySelector(`[data-idx="${b}"]`)?.scrollIntoView({block:"nearest"})},[b,m]);function G(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)G(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,J]=g(null),[B,ot]=g(null),T=at(()=>{let t=c?.current;if(!t)return;let n=t.getBoundingClientRect();J({left:n.left,width:n.width,bottom:window.innerHeight-n.top+8})},[c]);if(Z(()=>{if(!m){J(null);return}T()},[m,T]),Z(()=>{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,X=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:W,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(),G(t)},onMouseEnter:()=>L(n),className:Y("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:Y("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(N,{}),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(X,document.body):X}export{Et as CompletionMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ue}from"../chunk-bhvtt6tv.js";export{ue as detectTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{U}from"../chunk-zy5cq9m3.js";export{U as EffortSlider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n}from"../chunk-
|
|
1
|
+
import{n}from"../chunk-7n3ege46.js";import"../chunk-0m271xz8.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-wjejhpgw.js";import{v,x,m,b,H,y,P,I,M,J,s}from"../chunk-0m271xz8.js";import{S}from"../chunk-kscn218z.js";import{G,j,Q}from"../chunk-vq236zge.js";import{U}from"../chunk-zy5cq9m3.js";import{n}from"../chunk-7n3ege46.js";import{cn as c}from"cn";import{ArrowUpRight as ce,ChevronUp as E,Loader2Icon as ee,Zap as ne}from"lucide-react";import{Fragment as he,useState as ae}from"react";import{jsx as a,jsxs as o,Fragment as w}from"react/jsx-runtime";function ke({value:g,onChange:se,models:C,modelGroups:R,compactCatalog:r,effortPresentation:W="slider",unavailableEffort:T,providerMenu:N,header:D,className:Z,condensed:A,stripLabelPrefix:L,showDescription:ie,showModelList:oe=!0,loading:te,switching:q,isLoading:le,effortConfig:t,booleanOptions:z,onBooleanChange:B,selectOptions:de=[],t:h,...p}){let[re,me]=ae(!1),[ue,pe]=ae(!1),u=z?.find((i)=>i.id==="fast_mode"),F=r?z?.filter((i)=>i!==u):z,K=(i)=>L&&i.startsWith(L)?i.slice(L.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",Z),children:[a(ee,{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:[N&&o(v,{open:re,onOpenChange:me,children:[o(G,{children:[a(j,{render:a(x,{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:[N.icon,a(E,{className:"size-2.5 shrink-0 opacity-60"})]})})}),a(Q,{children:h("model.switchProvider")})]}),o(m,{side:"top",align:"end",sideOffset:4,className:"z-100 min-w-[10rem]",children:[N.groups.map((i,d)=>o(he,{children:[d>0&&i.length>0&&a(s,{}),a(n,{value:N.value,onValueChange:N.onChange,options:i})]},d)),N.moreAction&&o(w,{children:[a(s,{}),o(y,{onClick:N.moreAction,className:"whitespace-nowrap",children:[a("span",{className:"min-w-0 flex-1 truncate",children:h("model.moreModels")}),a(ce,{className:"size-4"})]})]})]})]}),o(v,{open:ue,onOpenChange:pe,children:[o(G,{children:[a(j,{render:a(x,{render:o(e,{"data-testid":"model-trigger","aria-busy":q,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]",Z),...p,children:[g.icon,z?.some((i)=>i.id==="fast_mode"&&i.currentValue&&!i.disabled)&&a(ne,{"aria-hidden":"true",className:"size-3 shrink-0"}),a("span",{className:c("min-w-0 flex-1 truncate text-start",A&&"text-[11px]"),children:K(g.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})]}),q?a(ee,{"data-testid":"model-switch-loading",className:"size-3 shrink-0 animate-spin"}):a(E,{className:c("size-3 shrink-0",A&&"size-2.5")})]})})}),a(Q,{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(w,{children:[o(b,{"data-model-menu-header":!0,className:"flex shrink-0 items-center justify-between gap-2 px-1 py-1",children:[t?W==="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(U,{...t,disabled:p.disabled})}):o(P,{children:[o(I,{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(M,{children:a(n,{value:t.value,onValueChange:t.onChange,options:t.levels.map((i)=>({value:i.value,label:i.name}))})})]}):T?o(y,{disabled:!0,className:"h-8 min-w-0 flex-1 gap-2",children:[a("span",{children:T.name}),a("span",{className:"text-muted-foreground truncate text-xs",children:T.label})]}):a(H,{className:"min-w-0 flex-1 truncate",children:D?.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(ne,{className:"size-4","aria-hidden":"true"})})]}),a(s,{className:"shrink-0"})]}),D&&!r&&o(w,{children:[o("div",{className:"flex items-center gap-2 px-2 py-2",children:[D.icon,a("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:D.name}),D.action]}),a(s,{})]}),o(b,{"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(y,{disabled:!0,className:"text-muted-foreground",children:h("model.loadingModels")}):C.length===0?a(y,{disabled:!0,className:"text-muted-foreground",children:h("model.noModelsAvailable")}):(()=>{let i=C.filter((l)=>!l.more),d=C.filter((l)=>l.more),X=i.length>0&&d.length>0,O=(l,k)=>({disabled:p.disabled,icon:l.icon,value:l.api_id,label:K(l.label),description:k?.noDescription?void 0:ie?l.description:void 0}),V=(l)=>{let k=C.find((_)=>_.api_id===l);if(k)se(k)};if(r)return a(n,{value:g.api_id,onValueChange:V,itemClassName:"min-w-0 max-w-full font-normal whitespace-nowrap",options:C.map((l)=>O(l))});return o(w,{children:[R?R.map((l)=>{let k=l.models.filter((f)=>!f.more),_=l.models.filter((f)=>f.more),Y=k.length>0&&_.length>0;return o(b,{children:[a(H,{className:"text-muted-foreground text-xs font-normal",children:l.name}),a(n,{value:g.api_id,onValueChange:V,itemClassName:"font-medium whitespace-nowrap",options:(Y?k:l.models).map((f)=>O(f))}),Y&&o(P,{children:[a(I,{className:"font-medium whitespace-nowrap",children:h("model.moreModels")}),a(M,{children:a(n,{value:g.api_id,onValueChange:V,itemClassName:"font-medium whitespace-nowrap",options:_.map((f)=>O(f,{noDescription:!0}))})})]})]},l.id)}):a(n,{value:g.api_id,onValueChange:V,itemClassName:"font-medium whitespace-nowrap",options:(X?i:C).map((l)=>O(l))}),!R&&X&&o(P,{children:[a(I,{className:"font-medium whitespace-nowrap",children:h("model.moreModels")}),a(M,{children:a(n,{value:g.api_id,onValueChange:V,itemClassName:"font-medium whitespace-nowrap",options:d.map((l)=>O(l,{noDescription:!0}))})})]})]})})()),!r&&t&&o(w,{children:[a(s,{}),W==="menu"?o(P,{children:[o(I,{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(M,{children:a(n,{value:t.value,onValueChange:t.onChange,options:t.levels.map((i)=>({value:i.value,label:i.name}))})})]}):a(U,{...t,disabled:p.disabled})]}),!r&&!t&&T&&o(w,{children:[a(s,{}),o(y,{disabled:!0,children:[a("span",{className:"flex-1",children:T.name}),a("span",{children:T.label})]})]}),de.map((i)=>o(b,{children:[a(s,{}),a(H,{children:i.name}),a(n,{value:i.value,onValueChange:i.onChange,options:i.options,itemClassName:"whitespace-nowrap"})]},i.id)),F&&F.length>0&&o(w,{children:[!t&&a(s,{}),F.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(S,{"aria-label":i.name,disabled:p.disabled||i.disabled,checked:i.currentValue,onCheckedChange:(d)=>B?.(i.id,d)})]},i.id))]})]}),r&&D?.action&&o(w,{children:[a(s,{className:"shrink-0"}),a(b,{"data-model-menu-footer":!0,className:"shrink-0",children:D.action})]})]})]})]})}export{ke as ModelSelect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e}from"../chunk-
|
|
1
|
+
import{e}from"../chunk-wjejhpgw.js";import{v,x,m}from"../chunk-0m271xz8.js";import{n}from"../chunk-7n3ege46.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(v,{open:g,onOpenChange:f,children:[o(x,{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};
|