@inkeep/agents-ui 0.0.0-dev-20260612033415 → 0.0.0-dev-20260612035557

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.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),p=require("react"),b=require("../../atoms/icons/custom-icon.cjs"),E=require("../../providers/image-preview-provider.cjs"),M=require("../../providers/message-provider.cjs"),u=require("./chat-provider.cjs"),m=require("../../atoms/file-upload.cjs"),F=require("../../utils/misc.cjs"),x=require("../../utils/compose-event-handlers.cjs"),s=require("../factory.cjs"),j=require("../../providers/config-provider.cjs"),y={"application/pdf":"filePdf","text/plain":"fileText","text/markdown":"fileMarkdown","text/html":"fileHtml","text/csv":"fileCsv","text/x-log":"fileLog","application/json":"fileJson","text/x-sql":"fileSql","application/x-sql":"fileSql","text/x-script.python":"filePy","text/x-python":"filePy","text/x-python-script":"filePy"};function g(t){return t.startsWith("image/")}const v={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/webp":[".webp"],"application/pdf":[".pdf"],"text/plain":[".txt",".text",".bat",".cfg",".conf",".def",".dic",".in",".list"],"text/x-log":[".log"],"text/markdown":[".md",".markdown"],"text/html":[".html",".htm"],"text/csv":[".csv"],"text/xml":[".xml"],"text/css":[".css"],"application/json":[".json"],"application/yaml":[".yaml",".yml"],"application/x-yaml":[".yaml",".yml"],"text/x-yaml":[".yaml",".yml"],"application/toml":[".toml"],"application/x-toml":[".toml"],"application/graphql":[".graphql",".gql"],"application/x-graphql":[".graphql",".gql"],"text/x-graphql":[".graphql",".gql"],"application/x-ndjson":[".ndjson"],"application/json5":[".json5"],"application/x-json5":[".json5"],"application/javascript":[".js",".mjs"],"text/javascript":[".js",".mjs"],"application/typescript":[".ts"],"text/x-typescript":[".ts"],"text/jsx":[".jsx"],"text/tsx":[".tsx"],"text/x-sh":[".sh"],"text/x-bash":[".bash"],"application/x-bash":[".bash"],"text/x-zsh":[".zsh"],"text/x-shellscript":[".sh",".ksh"],"application/x-powershell":[".ps1"],"text/vbscript":[".vbs"],"text/x-awk":[".awk"],"application/x-awk":[".awk"],"text/x-c":[".c",".h"],"text/x-c++":[".cpp",".cc",".cxx",".hh"],"text/x-csharp":[".cs"],"text/x-objectivec":[".m"],"text/x-objectivec++":[".mm"],"text/x-java":[".java"],"text/x-scala":[".scala"],"application/x-scala":[".scala"],"text/x-kotlin":[".kt"],"text/x-groovy":[".groovy"],"text/x-clojure":[".clj"],"text/x-go":[".go"],"text/x-golang":[".go"],"text/x-rust":[".rs"],"application/x-rust":[".rs"],"text/x-swift":[".swift"],"text/x-dart":[".dart"],"text/x-python":[".py"],"text/x-script.python":[".py"],"text/x-python-script":[".py"],"text/x-ruby":[".rb"],"text/x-perl":[".pl"],"text/x-lua":[".lua"],"text/x-r":[".r"],"text/x-R":[".r"],"text/x-julia":[".jl"],"text/x-elixir":[".ex"],"text/x-erlang":[".erl"],"text/x-haskell":[".hs"],"text/x-lisp":[".lisp"],"text/x-php":[".php"],"application/x-php":[".php"],"application/x-httpd-php":[".php"],"application/x-httpd-php-source":[".php"],"text/x-tex":[".tex"],"text/x-rst":[".rst"],"text/x-handlebars":[".hbs"],"text/x-mustache":[".mustache"],"text/x-ejs":[".ejs"],"text/x-jinja2":[".jinja",".jinja2"],"text/x-liquid":[".liquid"],"text/x-erb":[".erb"],"text/x-twig":[".twig"],"text/x-pug":[".pug"],"text/x-jade":[".jade"],"text/x-tmpl":[".tmpl"],"text/x-astro":[".astro"],"text/x-sass":[".sass"],"text/x-scss":[".scss"],"text/x-less":[".less"],"text/x-sql":[".sql"],"application/x-sql":[".sql"],"text/x-makefile":[".makefile",".mk"],"text/x-cmake":[".cmake"],"text/x-dockerfile":[".dockerfile"],"text/x-gradle":[".gradle"],"text/x-ini":[".ini"],"text/x-properties":[".properties"],"text/x-protobuf":[".proto"],"application/x-protobuf":[".proto"],"text/x-hcl":[".hcl"],"text/x-terraform":[".tf"],"application/x-terraform":[".tf"],"text/x-diff":[".diff"],"text/x-patch":[".patch"],"application/x-patch":[".patch"],"text/x-asm":[".asm",".s"],"message/rfc822":[".eml",".mht",".mhtml",".mime",".nws"],"text/srt":[".srt"],"application/x-subrip":[".srt"],"text/x-subrip":[".srt"],"text/vtt":[".vtt"],"text/x-vcard":[".vcf"],"text/calendar":[".ics",".ifb"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":[".pptx"],"application/vnd.oasis.opendocument.text":[".odt"],"application/vnd.oasis.opendocument.spreadsheet":[".ods"],"application/vnd.oasis.opendocument.presentation":[".odp"],"application/vnd.apple.pages":[".pages"],"application/vnd.apple.numbers":[".numbers"],"application/vnd.apple.keynote":[".key"],"application/x-iwork-pages-sffpages":[".pages"],"application/x-iwork-numbers-sffnumbers":[".numbers"],"application/x-iwork-keynote-sffkey":[".key"]},k=new Set(Object.keys(v)),I=10,P=1024*1024*10,T=Object.entries(v).reduce((t,[e,i])=>{for(const n of i)t[n]=e;return t},{});function w(t){if(t.type)return t;const e=`.${t.name.split(".").pop()?.toLowerCase()}`,i=T[e];return i?new File([t],t.name,{type:i}):t}function N(t){if(!t.length)return null;const e=i=>t.some(n=>n.errors.includes(i));return e("TOO_MANY_FILES")?{title:"Attachment limit reached",message:`You can only attach up to ${I} files per message.`}:e("FILE_INVALID_TYPE")?{title:"Unsupported file type",message:"Supported formats include images, PDFs, text, code, and document files."}:e("FILE_TOO_LARGE")?{title:"File too large",message:`Files must be smaller than ${P/1024/1024}MB.`}:e("FILE_EXISTS")?{title:"File already exists",message:`The file "${t.find(n=>n.errors.includes("FILE_EXISTS"))?.file.name??"file"}" is already attached to this message.`}:{title:"File rejected",message:"This file could not be added."}}const q=s.ikp("div",{_id:"aiChatMessage__Files"}),f=new WeakSet;function L(t,e){const i=e.map(a=>{if(!a.providerMetadata)return{...a};try{return{...a,providerMetadata:structuredClone(a.providerMetadata)}}catch{return{...a}}});let n;try{n=t(i)}catch(a){return f.has(t)||(f.add(t),console.warn("[aiChatSettings] transformMessageFiles threw",a)),e}return Array.isArray(n)?n.filter(a=>a!=null):(f.has(t)||(f.add(t),console.warn("[aiChatSettings] transformMessageFiles must return an array, got:",n)),e)}const A=({children:t,...e})=>{const{message:i}=M.useMessage(),{aiChatSettings:n}=j.useInkeepConfig();if(i.role!=="user")return null;const a=(i.parts??[]).filter(l=>l.type==="file"),r=n.transformMessageFiles,d=(r?L(r,a):a).filter(l=>k.has(l.mediaType??""));return d.length?o.jsx(q,{...e,children:t(d)}):null},S=s.ikp("button",{_id:"aiChatMessage__File"}),U=({url:t,name:e,mediaType:i,onClick:n,...a})=>{const{openImagePreview:r}=E.useImagePreview(),[c,d]=p.useState(!0),l=p.useMemo(()=>new File([],e??"file",{type:i}),[e,i]);return o.jsx(_.Provider,{value:{file:l,objectUrl:t,isLoading:c,setIsLoading:d,onRemove:()=>{}},children:o.jsx(S,{type:"button","aria-label":g(i??"")?`Preview ${e??"file"}`:`Open ${e??"file"} in new tab`,"data-loading":F.dataAttr(c),onClick:x.composeEventHandlers(n,()=>{if(g(i??""))r({url:t,name:e??"file"});else if(t)if(t.startsWith("data:")){const C=document.createElement("a");C.href=t,C.download=e??"file",C.click()}else window.open(t,"_blank","noopener,noreferrer")}),...a})})},R=s.ikp("div",{_id:"aiChatInput__Fieldset"}),O=t=>{const e=m.useFileUploadApi();return o.jsx(R,{...e.getDropzoneProps({disableClick:!0}),"data-drag-over":F.dataAttr(e.dragging),...t})},H=({...t})=>{const{files:e,setFiles:i,showInputNotification:n}=u.useChat();return o.jsx(m.FileUploadRoot,{accept:v,maxFiles:I,maxFileSize:P,preventDocumentDrop:!0,acceptedFiles:e,onFileAccept:a=>i(a.files),onFileReject:a=>{const r=N(a.files);r&&n(r)},children:o.jsx(O,{...t})})},D=s.ikp("div",{_id:"aiChatInput__DropZone"}),B=s.ikp("div",{_id:"aiChatInput__Notification"}),X=t=>{const{inputNotification:e}=u.useChat();return e?o.jsx(B,{role:"alert",...t}):null},Y=s.ikp("p",{_id:"aiChatInput__NotificationTitle"}),$=({children:t,...e})=>{const{inputNotification:i}=u.useChat();return i?.title?o.jsxs(Y,{...e,children:[t,i.title]}):null},z=s.ikp("p",{_id:"aiChatInput__NotificationMessage"}),Z=t=>{const{inputNotification:e}=u.useChat();return o.jsx(z,{...t,children:e?.message})},K=s.ikp("button",{_id:"aiChatInput__NotificationClose"}),W=({onClick:t,...e})=>{const{clearInputNotification:i}=u.useChat();return o.jsx(K,{type:"button","aria-label":"Dismiss",onClick:x.composeEventHandlers(t,i),...e})},V=s.ikp("div",{_id:"aiChatInput__NotificationContent"}),G=s.ikp("div",{_id:"aiChatInput__NotificationHeader"}),J=s.ikp(b.CustomIcon,{_id:"aiChatInput__FileUploadButtonIcon",iconKey:"fileUpload"}),Q=s.ikp("button",{_id:"aiChatInput__FileUploadButton"}),tt=t=>{const{aiChatSettings:e}=j.useInkeepConfig(),i=m.useFileUploadApi(),{onClick:n,...a}=t;return o.jsx(Q,{type:"button","aria-label":"Upload file",disabled:e.isViewOnly,onClick:x.composeEventHandlers(n,()=>i.openFilePicker()),...a})},et=s.ikp("input",{_id:"aiChatInput__FileInput"}),it=t=>{const e=m.useFileUploadApi();return o.jsx(et,{...t,...e.getHiddenInputProps()})},nt=s.ikp("div",{_id:"aiChatInput__FileList"}),at=({children:t,...e})=>{const n=m.useFileUploadApi().acceptedFiles;return n.length?o.jsx(nt,{...e,children:t(n)}):null},_=p.createContext(null);function h(){const t=p.useContext(_);if(!t)throw new Error("useFileContext must be used within EmbeddedChatPrimitiveFileItem");return t}const ot=s.ikp("div",{_id:"aiChatInput__FileItem"}),st=({file:t,...e})=>{const i=m.useFileUploadApi(),[n,a]=p.useState(void 0),[r,c]=p.useState(!0);p.useEffect(()=>i.createFileUrl(t,l=>{a(l),c(!0)}),[t]);const d=()=>i.deleteFile(t);return o.jsx(_.Provider,{value:{file:t,objectUrl:n,isLoading:r,setIsLoading:c,onRemove:d},children:o.jsx(ot,{"data-loading":F.dataAttr(r),...e})})},rt=s.ikp("button",{_id:"aiChatInput__FilePreviewTrigger"}),lt=({onClick:t,...e})=>{const{objectUrl:i,file:n}=h(),{openImagePreview:a}=E.useImagePreview();return o.jsx(rt,{type:"button","aria-label":`Preview ${n.name}`,disabled:!i,onClick:x.composeEventHandlers(t,()=>{i&&a({url:i,name:n.name})}),...e})},pt=s.ikp("span",{_id:"aiChatInput__FileContent"}),ct=t=>o.jsx(pt,{...t}),dt=s.ikp("img",{_id:"aiChatInput__FileThumbnail"}),mt=({onLoad:t,...e})=>{const{objectUrl:i,file:n,setIsLoading:a}=h();return o.jsx(dt,{src:i,alt:n.name,onLoad:x.composeEventHandlers(t,()=>a(!1)),...e})},xt=({className:t})=>{const{file:e}=h(),i=y[w(e).type]??"file";return o.jsx(b.CustomIcon,{iconKey:i,className:t})},ut=s.ikp("span",{_id:"aiChatInput__FileName"}),ht=t=>{const{file:e}=h();return o.jsx(ut,{...t,children:e.name})},ft=s.ikp("button",{_id:"aiChatInput__FileRemove"}),vt=s.ikp(b.CustomIcon,{_id:"aiChatInput__FileRemoveIcon",iconKey:"close"}),Ct=({onClick:t,...e})=>{const{onRemove:i}=h();return o.jsx(ft,{type:"button","aria-label":"Remove file",onClick:x.composeEventHandlers(t,i),...e})};exports.ACCEPTED_FILE_MIME_TYPES=k;exports.EmbeddedChatPrimitiveDropZone=D;exports.EmbeddedChatPrimitiveFileContent=ct;exports.EmbeddedChatPrimitiveFileInput=it;exports.EmbeddedChatPrimitiveFileItem=st;exports.EmbeddedChatPrimitiveFileList=at;exports.EmbeddedChatPrimitiveFileName=ht;exports.EmbeddedChatPrimitiveFilePreviewTrigger=lt;exports.EmbeddedChatPrimitiveFileRemove=Ct;exports.EmbeddedChatPrimitiveFileRemoveIcon=vt;exports.EmbeddedChatPrimitiveFileThumbnail=mt;exports.EmbeddedChatPrimitiveFileTypeIcon=xt;exports.EmbeddedChatPrimitiveFileUploadButton=tt;exports.EmbeddedChatPrimitiveFileUploadButtonIcon=J;exports.EmbeddedChatPrimitiveInputFieldset=H;exports.EmbeddedChatPrimitiveInputNotification=X;exports.EmbeddedChatPrimitiveInputNotificationClose=W;exports.EmbeddedChatPrimitiveInputNotificationContent=V;exports.EmbeddedChatPrimitiveInputNotificationHeader=G;exports.EmbeddedChatPrimitiveInputNotificationMessage=Z;exports.EmbeddedChatPrimitiveInputNotificationTitle=$;exports.EmbeddedChatPrimitiveMessageFile=U;exports.EmbeddedChatPrimitiveMessageFiles=A;exports.FILE_ACCEPT_MAP=v;exports.FILE_TYPE_ICON_MAP=y;exports.MAX_FILES=I;exports.MAX_FILE_SIZE=P;exports.isImageMimeType=g;exports.normalizeFileType=w;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),p=require("react"),b=require("../../atoms/icons/custom-icon.cjs"),j=require("../../providers/image-preview-provider.cjs"),N=require("../../providers/message-provider.cjs"),u=require("./chat-provider.cjs"),m=require("../../atoms/file-upload.cjs"),F=require("../../utils/misc.cjs"),x=require("../../utils/compose-event-handlers.cjs"),s=require("../factory.cjs"),y=require("../../providers/config-provider.cjs"),k={"application/pdf":"filePdf","text/plain":"fileText","text/markdown":"fileMarkdown","text/html":"fileHtml","text/csv":"fileCsv","text/x-log":"fileLog","application/json":"fileJson","text/x-sql":"fileSql","application/x-sql":"fileSql","text/x-script.python":"filePy","text/x-python":"filePy","text/x-python-script":"filePy"};function C(e){return e.startsWith("image/")}const v={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/webp":[".webp"],"application/pdf":[".pdf"],"text/plain":[".txt",".text",".bat",".cfg",".conf",".def",".dic",".in",".list"],"text/x-log":[".log"],"text/markdown":[".md",".markdown"],"text/html":[".html",".htm"],"text/csv":[".csv"],"text/xml":[".xml"],"text/css":[".css"],"application/json":[".json"],"application/yaml":[".yaml",".yml"],"application/x-yaml":[".yaml",".yml"],"text/x-yaml":[".yaml",".yml"],"application/toml":[".toml"],"application/x-toml":[".toml"],"application/graphql":[".graphql",".gql"],"application/x-graphql":[".graphql",".gql"],"text/x-graphql":[".graphql",".gql"],"application/x-ndjson":[".ndjson"],"application/json5":[".json5"],"application/x-json5":[".json5"],"application/javascript":[".js",".mjs"],"text/javascript":[".js",".mjs"],"application/typescript":[".ts"],"text/x-typescript":[".ts"],"text/jsx":[".jsx"],"text/tsx":[".tsx"],"text/x-sh":[".sh"],"text/x-bash":[".bash"],"application/x-bash":[".bash"],"text/x-zsh":[".zsh"],"text/x-shellscript":[".sh",".ksh"],"application/x-powershell":[".ps1"],"text/vbscript":[".vbs"],"text/x-awk":[".awk"],"application/x-awk":[".awk"],"text/x-c":[".c",".h"],"text/x-c++":[".cpp",".cc",".cxx",".hh"],"text/x-csharp":[".cs"],"text/x-objectivec":[".m"],"text/x-objectivec++":[".mm"],"text/x-java":[".java"],"text/x-scala":[".scala"],"application/x-scala":[".scala"],"text/x-kotlin":[".kt"],"text/x-groovy":[".groovy"],"text/x-clojure":[".clj"],"text/x-go":[".go"],"text/x-golang":[".go"],"text/x-rust":[".rs"],"application/x-rust":[".rs"],"text/x-swift":[".swift"],"text/x-dart":[".dart"],"text/x-python":[".py"],"text/x-script.python":[".py"],"text/x-python-script":[".py"],"text/x-ruby":[".rb"],"text/x-perl":[".pl"],"text/x-lua":[".lua"],"text/x-r":[".r"],"text/x-R":[".r"],"text/x-julia":[".jl"],"text/x-elixir":[".ex"],"text/x-erlang":[".erl"],"text/x-haskell":[".hs"],"text/x-lisp":[".lisp"],"text/x-php":[".php"],"application/x-php":[".php"],"application/x-httpd-php":[".php"],"application/x-httpd-php-source":[".php"],"text/x-tex":[".tex"],"text/x-rst":[".rst"],"text/x-handlebars":[".hbs"],"text/x-mustache":[".mustache"],"text/x-ejs":[".ejs"],"text/x-jinja2":[".jinja",".jinja2"],"text/x-liquid":[".liquid"],"text/x-erb":[".erb"],"text/x-twig":[".twig"],"text/x-pug":[".pug"],"text/x-jade":[".jade"],"text/x-tmpl":[".tmpl"],"text/x-astro":[".astro"],"text/x-sass":[".sass"],"text/x-scss":[".scss"],"text/x-less":[".less"],"text/x-sql":[".sql"],"application/x-sql":[".sql"],"text/x-makefile":[".makefile",".mk"],"text/x-cmake":[".cmake"],"text/x-dockerfile":[".dockerfile"],"text/x-gradle":[".gradle"],"text/x-ini":[".ini"],"text/x-properties":[".properties"],"text/x-protobuf":[".proto"],"application/x-protobuf":[".proto"],"text/x-hcl":[".hcl"],"text/x-terraform":[".tf"],"application/x-terraform":[".tf"],"text/x-diff":[".diff"],"text/x-patch":[".patch"],"application/x-patch":[".patch"],"text/x-asm":[".asm",".s"],"message/rfc822":[".eml",".mht",".mhtml",".mime",".nws"],"text/srt":[".srt"],"application/x-subrip":[".srt"],"text/x-subrip":[".srt"],"text/vtt":[".vtt"],"text/x-vcard":[".vcf"],"text/calendar":[".ics",".ifb"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":[".pptx"],"application/vnd.oasis.opendocument.text":[".odt"],"application/vnd.oasis.opendocument.spreadsheet":[".ods"],"application/vnd.oasis.opendocument.presentation":[".odp"],"application/vnd.apple.pages":[".pages"],"application/vnd.apple.numbers":[".numbers"],"application/vnd.apple.keynote":[".key"],"application/x-iwork-pages-sffpages":[".pages"],"application/x-iwork-numbers-sffnumbers":[".numbers"],"application/x-iwork-keynote-sffkey":[".key"]},w=new Set(Object.keys(v)),I=10,P=1024*1024*10,T=Object.entries(v).reduce((e,[t,i])=>{for(const n of i)e[n]=t;return e},{});function M(e){if(e.type)return e;const t=`.${e.name.split(".").pop()?.toLowerCase()}`,i=T[t];return i?new File([e],e.name,{type:i}):e}function q(e){if(!e.length)return null;const t=i=>e.some(n=>n.errors.includes(i));return t("TOO_MANY_FILES")?{title:"Attachment limit reached",message:`You can only attach up to ${I} files per message.`}:t("FILE_INVALID_TYPE")?{title:"Unsupported file type",message:"Supported formats include images, PDFs, text, code, and document files."}:t("FILE_TOO_LARGE")?{title:"File too large",message:`Files must be smaller than ${P/1024/1024}MB.`}:t("FILE_EXISTS")?{title:"File already exists",message:`The file "${e.find(n=>n.errors.includes("FILE_EXISTS"))?.file.name??"file"}" is already attached to this message.`}:{title:"File rejected",message:"This file could not be added."}}const L=s.ikp("div",{_id:"aiChatMessage__Files"}),f=new WeakSet;let E=!1;function A(e,t){const i=t.map(a=>{if(!a.providerMetadata)return{...a};try{return{...a,providerMetadata:structuredClone(a.providerMetadata)}}catch{return E||(E=!0,console.warn("[transformMessageFiles] providerMetadata is not structured-cloneable; passing a shared reference. A transformer that mutates it writes through into live message state.")),{...a}}});let n;try{n=e(i)}catch(a){return f.has(e)||(f.add(e),console.warn("[transformMessageFiles] transformer threw",a)),t}return Array.isArray(n)?n.filter(a=>a!=null):(f.has(e)||(f.add(e),console.warn("[transformMessageFiles] transformer must return an array, got:",n)),t)}const S=({children:e,...t})=>{const{message:i}=N.useMessage(),{aiChatSettings:n}=y.useInkeepConfig();if(i.role!=="user")return null;const a=(i.parts??[]).filter(l=>l.type==="file"),r=n.transformMessageFiles,d=(r?A(r,a):a).filter(l=>w.has(l.mediaType??""));return d.length?o.jsx(L,{...t,children:e(d)}):null},U=s.ikp("button",{_id:"aiChatMessage__File"}),R=({url:e,name:t,mediaType:i,onClick:n,...a})=>{const{openImagePreview:r}=j.useImagePreview(),[c,d]=p.useState(!0),l=p.useMemo(()=>new File([],t??"file",{type:i}),[t,i]);return o.jsx(_.Provider,{value:{file:l,objectUrl:e,isLoading:c,setIsLoading:d,onRemove:()=>{}},children:o.jsx(U,{type:"button","aria-label":C(i??"")?`Preview ${t??"file"}`:`Open ${t??"file"} in new tab`,"data-loading":F.dataAttr(c),onClick:x.composeEventHandlers(n,()=>{if(C(i??""))r({url:e,name:t??"file"});else if(e)if(e.startsWith("data:")){const g=document.createElement("a");g.href=e,g.download=t??"file",g.click()}else window.open(e,"_blank","noopener,noreferrer")}),...a})})},O=s.ikp("div",{_id:"aiChatInput__Fieldset"}),H=e=>{const t=m.useFileUploadApi();return o.jsx(O,{...t.getDropzoneProps({disableClick:!0}),"data-drag-over":F.dataAttr(t.dragging),...e})},D=({...e})=>{const{files:t,setFiles:i,showInputNotification:n}=u.useChat();return o.jsx(m.FileUploadRoot,{accept:v,maxFiles:I,maxFileSize:P,preventDocumentDrop:!0,acceptedFiles:t,onFileAccept:a=>i(a.files),onFileReject:a=>{const r=q(a.files);r&&n(r)},children:o.jsx(H,{...e})})},B=s.ikp("div",{_id:"aiChatInput__DropZone"}),X=s.ikp("div",{_id:"aiChatInput__Notification"}),Y=e=>{const{inputNotification:t}=u.useChat();return t?o.jsx(X,{role:"alert",...e}):null},$=s.ikp("p",{_id:"aiChatInput__NotificationTitle"}),z=({children:e,...t})=>{const{inputNotification:i}=u.useChat();return i?.title?o.jsxs($,{...t,children:[e,i.title]}):null},Z=s.ikp("p",{_id:"aiChatInput__NotificationMessage"}),W=e=>{const{inputNotification:t}=u.useChat();return o.jsx(Z,{...e,children:t?.message})},K=s.ikp("button",{_id:"aiChatInput__NotificationClose"}),V=({onClick:e,...t})=>{const{clearInputNotification:i}=u.useChat();return o.jsx(K,{type:"button","aria-label":"Dismiss",onClick:x.composeEventHandlers(e,i),...t})},G=s.ikp("div",{_id:"aiChatInput__NotificationContent"}),J=s.ikp("div",{_id:"aiChatInput__NotificationHeader"}),Q=s.ikp(b.CustomIcon,{_id:"aiChatInput__FileUploadButtonIcon",iconKey:"fileUpload"}),ee=s.ikp("button",{_id:"aiChatInput__FileUploadButton"}),te=e=>{const{aiChatSettings:t}=y.useInkeepConfig(),i=m.useFileUploadApi(),{onClick:n,...a}=e;return o.jsx(ee,{type:"button","aria-label":"Upload file",disabled:t.isViewOnly,onClick:x.composeEventHandlers(n,()=>i.openFilePicker()),...a})},ie=s.ikp("input",{_id:"aiChatInput__FileInput"}),ne=e=>{const t=m.useFileUploadApi();return o.jsx(ie,{...e,...t.getHiddenInputProps()})},ae=s.ikp("div",{_id:"aiChatInput__FileList"}),oe=({children:e,...t})=>{const n=m.useFileUploadApi().acceptedFiles;return n.length?o.jsx(ae,{...t,children:e(n)}):null},_=p.createContext(null);function h(){const e=p.useContext(_);if(!e)throw new Error("useFileContext must be used within EmbeddedChatPrimitiveFileItem");return e}const se=s.ikp("div",{_id:"aiChatInput__FileItem"}),re=({file:e,...t})=>{const i=m.useFileUploadApi(),[n,a]=p.useState(void 0),[r,c]=p.useState(!0);p.useEffect(()=>i.createFileUrl(e,l=>{a(l),c(!0)}),[e]);const d=()=>i.deleteFile(e);return o.jsx(_.Provider,{value:{file:e,objectUrl:n,isLoading:r,setIsLoading:c,onRemove:d},children:o.jsx(se,{"data-loading":F.dataAttr(r),...t})})},le=s.ikp("button",{_id:"aiChatInput__FilePreviewTrigger"}),pe=({onClick:e,...t})=>{const{objectUrl:i,file:n}=h(),{openImagePreview:a}=j.useImagePreview();return o.jsx(le,{type:"button","aria-label":`Preview ${n.name}`,disabled:!i,onClick:x.composeEventHandlers(e,()=>{i&&a({url:i,name:n.name})}),...t})},ce=s.ikp("span",{_id:"aiChatInput__FileContent"}),de=e=>o.jsx(ce,{...e}),me=s.ikp("img",{_id:"aiChatInput__FileThumbnail"}),xe=({onLoad:e,...t})=>{const{objectUrl:i,file:n,setIsLoading:a}=h();return o.jsx(me,{src:i,alt:n.name,onLoad:x.composeEventHandlers(e,()=>a(!1)),...t})},ue=({className:e})=>{const{file:t}=h(),i=k[M(t).type]??"file";return o.jsx(b.CustomIcon,{iconKey:i,className:e})},he=s.ikp("span",{_id:"aiChatInput__FileName"}),fe=e=>{const{file:t}=h();return o.jsx(he,{...e,children:t.name})},ve=s.ikp("button",{_id:"aiChatInput__FileRemove"}),ge=s.ikp(b.CustomIcon,{_id:"aiChatInput__FileRemoveIcon",iconKey:"close"}),Ce=({onClick:e,...t})=>{const{onRemove:i}=h();return o.jsx(ve,{type:"button","aria-label":"Remove file",onClick:x.composeEventHandlers(e,i),...t})};exports.ACCEPTED_FILE_MIME_TYPES=w;exports.EmbeddedChatPrimitiveDropZone=B;exports.EmbeddedChatPrimitiveFileContent=de;exports.EmbeddedChatPrimitiveFileInput=ne;exports.EmbeddedChatPrimitiveFileItem=re;exports.EmbeddedChatPrimitiveFileList=oe;exports.EmbeddedChatPrimitiveFileName=fe;exports.EmbeddedChatPrimitiveFilePreviewTrigger=pe;exports.EmbeddedChatPrimitiveFileRemove=Ce;exports.EmbeddedChatPrimitiveFileRemoveIcon=ge;exports.EmbeddedChatPrimitiveFileThumbnail=xe;exports.EmbeddedChatPrimitiveFileTypeIcon=ue;exports.EmbeddedChatPrimitiveFileUploadButton=te;exports.EmbeddedChatPrimitiveFileUploadButtonIcon=Q;exports.EmbeddedChatPrimitiveInputFieldset=D;exports.EmbeddedChatPrimitiveInputNotification=Y;exports.EmbeddedChatPrimitiveInputNotificationClose=V;exports.EmbeddedChatPrimitiveInputNotificationContent=G;exports.EmbeddedChatPrimitiveInputNotificationHeader=J;exports.EmbeddedChatPrimitiveInputNotificationMessage=W;exports.EmbeddedChatPrimitiveInputNotificationTitle=z;exports.EmbeddedChatPrimitiveMessageFile=R;exports.EmbeddedChatPrimitiveMessageFiles=S;exports.FILE_ACCEPT_MAP=v;exports.FILE_TYPE_ICON_MAP=k;exports.MAX_FILES=I;exports.MAX_FILE_SIZE=P;exports.isImageMimeType=C;exports.normalizeFileType=M;
@@ -1,16 +1,16 @@
1
1
  "use client";
2
- import { jsx as s, jsxs as w } from "react/jsx-runtime";
3
- import I, { useState as g, useEffect as k, useMemo as M } from "react";
2
+ import { jsx as s, jsxs as k } from "react/jsx-runtime";
3
+ import P, { useState as g, useEffect as M, useMemo as N } from "react";
4
4
  import { CustomIcon as v } from "../../atoms/icons/custom-icon.js";
5
- import { useImagePreview as P } from "../../providers/image-preview-provider.js";
6
- import { useMessage as N } from "../../providers/message-provider.js";
7
- import { useChat as x } from "./chat-provider.js";
8
- import { useFileUploadApi as m, FileUploadRoot as T } from "../../atoms/file-upload.js";
9
- import { dataAttr as _ } from "../../utils/misc.js";
5
+ import { useImagePreview as y } from "../../providers/image-preview-provider.js";
6
+ import { useMessage as T } from "../../providers/message-provider.js";
7
+ import { useChat as m } from "./chat-provider.js";
8
+ import { useFileUploadApi as x, FileUploadRoot as L } from "../../atoms/file-upload.js";
9
+ import { dataAttr as b } from "../../utils/misc.js";
10
10
  import { composeEventHandlers as d } from "../../utils/compose-event-handlers.js";
11
11
  import { ikp as o } from "../factory.js";
12
- import { useInkeepConfig as y } from "../../providers/config-provider.js";
13
- const L = {
12
+ import { useInkeepConfig as j } from "../../providers/config-provider.js";
13
+ const q = {
14
14
  "application/pdf": "filePdf",
15
15
  "text/plain": "fileText",
16
16
  "text/markdown": "fileMarkdown",
@@ -27,7 +27,7 @@ const L = {
27
27
  function C(t) {
28
28
  return t.startsWith("image/");
29
29
  }
30
- const b = {
30
+ const _ = {
31
31
  // Images
32
32
  "image/png": [".png"],
33
33
  "image/jpeg": [".jpg", ".jpeg"],
@@ -173,7 +173,7 @@ const b = {
173
173
  "application/x-iwork-pages-sffpages": [".pages"],
174
174
  "application/x-iwork-numbers-sffnumbers": [".numbers"],
175
175
  "application/x-iwork-keynote-sffkey": [".key"]
176
- }, q = new Set(Object.keys(b)), j = 10, E = 1024 * 1024 * 10, S = Object.entries(b).reduce(
176
+ }, S = new Set(Object.keys(_)), E = 10, w = 1024 * 1024 * 10, A = Object.entries(_).reduce(
177
177
  (t, [e, i]) => {
178
178
  for (const n of i) t[n] = e;
179
179
  return t;
@@ -182,7 +182,7 @@ const b = {
182
182
  );
183
183
  function R(t) {
184
184
  if (t.type) return t;
185
- const e = `.${t.name.split(".").pop()?.toLowerCase()}`, i = S[e];
185
+ const e = `.${t.name.split(".").pop()?.toLowerCase()}`, i = A[e];
186
186
  return i ? new File([t], t.name, { type: i }) : t;
187
187
  }
188
188
  function U(t) {
@@ -190,13 +190,13 @@ function U(t) {
190
190
  const e = (i) => t.some((n) => n.errors.includes(i));
191
191
  return e("TOO_MANY_FILES") ? {
192
192
  title: "Attachment limit reached",
193
- message: `You can only attach up to ${j} files per message.`
193
+ message: `You can only attach up to ${E} files per message.`
194
194
  } : e("FILE_INVALID_TYPE") ? {
195
195
  title: "Unsupported file type",
196
196
  message: "Supported formats include images, PDFs, text, code, and document files."
197
197
  } : e("FILE_TOO_LARGE") ? {
198
198
  title: "File too large",
199
- message: `Files must be smaller than ${E / 1024 / 1024}MB.`
199
+ message: `Files must be smaller than ${w / 1024 / 1024}MB.`
200
200
  } : e("FILE_EXISTS") ? {
201
201
  title: "File already exists",
202
202
  message: `The file "${t.find((n) => n.errors.includes("FILE_EXISTS"))?.file.name ?? "file"}" is already attached to this message.`
@@ -205,43 +205,46 @@ function U(t) {
205
205
  message: "This file could not be added."
206
206
  };
207
207
  }
208
- const A = o("div", {
208
+ const O = o("div", {
209
209
  _id: "aiChatMessage__Files"
210
210
  }), f = /* @__PURE__ */ new WeakSet();
211
- function O(t, e) {
211
+ let I = !1;
212
+ function D(t, e) {
212
213
  const i = e.map((a) => {
213
214
  if (!a.providerMetadata) return { ...a };
214
215
  try {
215
216
  return { ...a, providerMetadata: structuredClone(a.providerMetadata) };
216
217
  } catch {
217
- return { ...a };
218
+ return I || (I = !0, console.warn(
219
+ "[transformMessageFiles] providerMetadata is not structured-cloneable; passing a shared reference. A transformer that mutates it writes through into live message state."
220
+ )), { ...a };
218
221
  }
219
222
  });
220
223
  let n;
221
224
  try {
222
225
  n = t(i);
223
226
  } catch (a) {
224
- return f.has(t) || (f.add(t), console.warn("[aiChatSettings] transformMessageFiles threw", a)), e;
227
+ return f.has(t) || (f.add(t), console.warn("[transformMessageFiles] transformer threw", a)), e;
225
228
  }
226
- return Array.isArray(n) ? n.filter((a) => a != null) : (f.has(t) || (f.add(t), console.warn("[aiChatSettings] transformMessageFiles must return an array, got:", n)), e);
229
+ return Array.isArray(n) ? n.filter((a) => a != null) : (f.has(t) || (f.add(t), console.warn("[transformMessageFiles] transformer must return an array, got:", n)), e);
227
230
  }
228
- const mt = ({ children: t, ...e }) => {
229
- const { message: i } = N(), { aiChatSettings: n } = y();
231
+ const ut = ({ children: t, ...e }) => {
232
+ const { message: i } = T(), { aiChatSettings: n } = j();
230
233
  if (i.role !== "user") return null;
231
- const a = (i.parts ?? []).filter((l) => l.type === "file"), r = n.transformMessageFiles, c = (r ? O(r, a) : a).filter(
232
- (l) => q.has(l.mediaType ?? "")
234
+ const a = (i.parts ?? []).filter((l) => l.type === "file"), r = n.transformMessageFiles, c = (r ? D(r, a) : a).filter(
235
+ (l) => S.has(l.mediaType ?? "")
233
236
  );
234
- return c.length ? /* @__PURE__ */ s(A, { ...e, children: t(c) }) : null;
235
- }, D = o("button", {
237
+ return c.length ? /* @__PURE__ */ s(O, { ...e, children: t(c) }) : null;
238
+ }, $ = o("button", {
236
239
  _id: "aiChatMessage__File"
237
- }), ut = ({
240
+ }), ft = ({
238
241
  url: t,
239
242
  name: e,
240
243
  mediaType: i,
241
244
  onClick: n,
242
245
  ...a
243
246
  }) => {
244
- const { openImagePreview: r } = P(), [p, c] = g(!0), l = M(
247
+ const { openImagePreview: r } = y(), [p, c] = g(!0), l = N(
245
248
  () => new File([], e ?? "file", { type: i }),
246
249
  [e, i]
247
250
  );
@@ -251,11 +254,11 @@ const mt = ({ children: t, ...e }) => {
251
254
  value: { file: l, objectUrl: t, isLoading: p, setIsLoading: c, onRemove: () => {
252
255
  } },
253
256
  children: /* @__PURE__ */ s(
254
- D,
257
+ $,
255
258
  {
256
259
  type: "button",
257
260
  "aria-label": C(i ?? "") ? `Preview ${e ?? "file"}` : `Open ${e ?? "file"} in new tab`,
258
- "data-loading": _(p),
261
+ "data-loading": b(p),
259
262
  onClick: d(n, () => {
260
263
  if (C(i ?? ""))
261
264
  r({ url: t, name: e ?? "file" });
@@ -271,28 +274,28 @@ const mt = ({ children: t, ...e }) => {
271
274
  )
272
275
  }
273
276
  );
274
- }, $ = o("div", {
277
+ }, B = o("div", {
275
278
  _id: "aiChatInput__Fieldset"
276
- }), B = (t) => {
277
- const e = m();
279
+ }), z = (t) => {
280
+ const e = x();
278
281
  return /* @__PURE__ */ s(
279
- $,
282
+ B,
280
283
  {
281
284
  ...e.getDropzoneProps({ disableClick: !0 }),
282
- "data-drag-over": _(e.dragging),
285
+ "data-drag-over": b(e.dragging),
283
286
  ...t
284
287
  }
285
288
  );
286
- }, ft = ({
289
+ }, ht = ({
287
290
  ...t
288
291
  }) => {
289
- const { files: e, setFiles: i, showInputNotification: n } = x();
292
+ const { files: e, setFiles: i, showInputNotification: n } = m();
290
293
  return /* @__PURE__ */ s(
291
- T,
294
+ L,
292
295
  {
293
- accept: b,
294
- maxFiles: j,
295
- maxFileSize: E,
296
+ accept: _,
297
+ maxFiles: E,
298
+ maxFileSize: w,
296
299
  preventDocumentDrop: !0,
297
300
  acceptedFiles: e,
298
301
  onFileAccept: (a) => i(a.files),
@@ -300,41 +303,41 @@ const mt = ({ children: t, ...e }) => {
300
303
  const r = U(a.files);
301
304
  r && n(r);
302
305
  },
303
- children: /* @__PURE__ */ s(B, { ...t })
306
+ children: /* @__PURE__ */ s(z, { ...t })
304
307
  }
305
308
  );
306
- }, ht = o("div", {
309
+ }, gt = o("div", {
307
310
  _id: "aiChatInput__DropZone"
308
- }), z = o("div", {
311
+ }), H = o("div", {
309
312
  _id: "aiChatInput__Notification"
310
- }), gt = (t) => {
311
- const { inputNotification: e } = x();
312
- return e ? /* @__PURE__ */ s(z, { role: "alert", ...t }) : null;
313
- }, H = o("p", {
313
+ }), vt = (t) => {
314
+ const { inputNotification: e } = m();
315
+ return e ? /* @__PURE__ */ s(H, { role: "alert", ...t }) : null;
316
+ }, X = o("p", {
314
317
  _id: "aiChatInput__NotificationTitle"
315
- }), vt = ({
318
+ }), bt = ({
316
319
  children: t,
317
320
  ...e
318
321
  }) => {
319
- const { inputNotification: i } = x();
320
- return i?.title ? /* @__PURE__ */ w(H, { ...e, children: [
322
+ const { inputNotification: i } = m();
323
+ return i?.title ? /* @__PURE__ */ k(X, { ...e, children: [
321
324
  t,
322
325
  i.title
323
326
  ] }) : null;
324
- }, X = o("p", {
327
+ }, Y = o("p", {
325
328
  _id: "aiChatInput__NotificationMessage"
326
329
  }), _t = (t) => {
327
- const { inputNotification: e } = x();
328
- return /* @__PURE__ */ s(X, { ...t, children: e?.message });
329
- }, Y = o("button", {
330
+ const { inputNotification: e } = m();
331
+ return /* @__PURE__ */ s(Y, { ...t, children: e?.message });
332
+ }, W = o("button", {
330
333
  _id: "aiChatInput__NotificationClose"
331
- }), bt = ({
334
+ }), Ft = ({
332
335
  onClick: t,
333
336
  ...e
334
337
  }) => {
335
- const { clearInputNotification: i } = x();
338
+ const { clearInputNotification: i } = m();
336
339
  return /* @__PURE__ */ s(
337
- Y,
340
+ W,
338
341
  {
339
342
  type: "button",
340
343
  "aria-label": "Dismiss",
@@ -342,17 +345,17 @@ const mt = ({ children: t, ...e }) => {
342
345
  ...e
343
346
  }
344
347
  );
345
- }, Ft = o("div", {
348
+ }, Ct = o("div", {
346
349
  _id: "aiChatInput__NotificationContent"
347
- }), Ct = o("div", {
350
+ }), It = o("div", {
348
351
  _id: "aiChatInput__NotificationHeader"
349
- }), It = o(v, {
352
+ }), Pt = o(v, {
350
353
  _id: "aiChatInput__FileUploadButtonIcon",
351
354
  iconKey: "fileUpload"
352
355
  }), K = o("button", {
353
356
  _id: "aiChatInput__FileUploadButton"
354
- }), Pt = (t) => {
355
- const { aiChatSettings: e } = y(), i = m(), { onClick: n, ...a } = t;
357
+ }), yt = (t) => {
358
+ const { aiChatSettings: e } = j(), i = x(), { onClick: n, ...a } = t;
356
359
  return /* @__PURE__ */ s(
357
360
  K,
358
361
  {
@@ -363,40 +366,40 @@ const mt = ({ children: t, ...e }) => {
363
366
  ...a
364
367
  }
365
368
  );
366
- }, W = o("input", {
369
+ }, Z = o("input", {
367
370
  _id: "aiChatInput__FileInput"
368
- }), yt = (t) => {
369
- const e = m();
370
- return /* @__PURE__ */ s(W, { ...t, ...e.getHiddenInputProps() });
371
- }, Z = o("div", {
371
+ }), jt = (t) => {
372
+ const e = x();
373
+ return /* @__PURE__ */ s(Z, { ...t, ...e.getHiddenInputProps() });
374
+ }, V = o("div", {
372
375
  _id: "aiChatInput__FileList"
373
- }), jt = ({ children: t, ...e }) => {
374
- const n = m().acceptedFiles;
375
- return n.length ? /* @__PURE__ */ s(Z, { ...e, children: t(n) }) : null;
376
- }, F = I.createContext(null);
376
+ }), Et = ({ children: t, ...e }) => {
377
+ const n = x().acceptedFiles;
378
+ return n.length ? /* @__PURE__ */ s(V, { ...e, children: t(n) }) : null;
379
+ }, F = P.createContext(null);
377
380
  function u() {
378
- const t = I.useContext(F);
381
+ const t = P.useContext(F);
379
382
  if (!t) throw new Error("useFileContext must be used within EmbeddedChatPrimitiveFileItem");
380
383
  return t;
381
384
  }
382
- const V = o("div", {
385
+ const G = o("div", {
383
386
  _id: "aiChatInput__FileItem"
384
- }), Et = ({ file: t, ...e }) => {
385
- const i = m(), [n, a] = g(void 0), [r, p] = g(!0);
386
- k(() => i.createFileUrl(t, (l) => {
387
+ }), wt = ({ file: t, ...e }) => {
388
+ const i = x(), [n, a] = g(void 0), [r, p] = g(!0);
389
+ M(() => i.createFileUrl(t, (l) => {
387
390
  a(l), p(!0);
388
391
  }), [t]);
389
392
  const c = () => i.deleteFile(t);
390
- return /* @__PURE__ */ s(F.Provider, { value: { file: t, objectUrl: n, isLoading: r, setIsLoading: p, onRemove: c }, children: /* @__PURE__ */ s(V, { "data-loading": _(r), ...e }) });
391
- }, G = o("button", {
393
+ return /* @__PURE__ */ s(F.Provider, { value: { file: t, objectUrl: n, isLoading: r, setIsLoading: p, onRemove: c }, children: /* @__PURE__ */ s(G, { "data-loading": b(r), ...e }) });
394
+ }, J = o("button", {
392
395
  _id: "aiChatInput__FilePreviewTrigger"
393
- }), wt = ({
396
+ }), kt = ({
394
397
  onClick: t,
395
398
  ...e
396
399
  }) => {
397
- const { objectUrl: i, file: n } = u(), { openImagePreview: a } = P();
400
+ const { objectUrl: i, file: n } = u(), { openImagePreview: a } = y();
398
401
  return /* @__PURE__ */ s(
399
- G,
402
+ J,
400
403
  {
401
404
  type: "button",
402
405
  "aria-label": `Preview ${n.name}`,
@@ -407,17 +410,17 @@ const V = o("div", {
407
410
  ...e
408
411
  }
409
412
  );
410
- }, J = o("span", {
413
+ }, Q = o("span", {
411
414
  _id: "aiChatInput__FileContent"
412
- }), kt = (t) => /* @__PURE__ */ s(J, { ...t }), Q = o("img", {
415
+ }), Mt = (t) => /* @__PURE__ */ s(Q, { ...t }), tt = o("img", {
413
416
  _id: "aiChatInput__FileThumbnail"
414
- }), Mt = ({
417
+ }), Nt = ({
415
418
  onLoad: t,
416
419
  ...e
417
420
  }) => {
418
421
  const { objectUrl: i, file: n, setIsLoading: a } = u();
419
422
  return /* @__PURE__ */ s(
420
- Q,
423
+ tt,
421
424
  {
422
425
  src: i,
423
426
  alt: n.name,
@@ -425,26 +428,26 @@ const V = o("div", {
425
428
  ...e
426
429
  }
427
430
  );
428
- }, Nt = ({ className: t }) => {
429
- const { file: e } = u(), i = L[R(e).type] ?? "file";
431
+ }, Tt = ({ className: t }) => {
432
+ const { file: e } = u(), i = q[R(e).type] ?? "file";
430
433
  return /* @__PURE__ */ s(v, { iconKey: i, className: t });
431
- }, tt = o("span", {
434
+ }, et = o("span", {
432
435
  _id: "aiChatInput__FileName"
433
- }), Tt = (t) => {
436
+ }), Lt = (t) => {
434
437
  const { file: e } = u();
435
- return /* @__PURE__ */ s(tt, { ...t, children: e.name });
436
- }, et = o("button", {
438
+ return /* @__PURE__ */ s(et, { ...t, children: e.name });
439
+ }, it = o("button", {
437
440
  _id: "aiChatInput__FileRemove"
438
- }), Lt = o(v, {
441
+ }), qt = o(v, {
439
442
  _id: "aiChatInput__FileRemoveIcon",
440
443
  iconKey: "close"
441
- }), qt = ({
444
+ }), St = ({
442
445
  onClick: t,
443
446
  ...e
444
447
  }) => {
445
448
  const { onRemove: i } = u();
446
449
  return /* @__PURE__ */ s(
447
- et,
450
+ it,
448
451
  {
449
452
  type: "button",
450
453
  "aria-label": "Remove file",
@@ -454,33 +457,33 @@ const V = o("div", {
454
457
  );
455
458
  };
456
459
  export {
457
- q as ACCEPTED_FILE_MIME_TYPES,
458
- ht as EmbeddedChatPrimitiveDropZone,
459
- kt as EmbeddedChatPrimitiveFileContent,
460
- yt as EmbeddedChatPrimitiveFileInput,
461
- Et as EmbeddedChatPrimitiveFileItem,
462
- jt as EmbeddedChatPrimitiveFileList,
463
- Tt as EmbeddedChatPrimitiveFileName,
464
- wt as EmbeddedChatPrimitiveFilePreviewTrigger,
465
- qt as EmbeddedChatPrimitiveFileRemove,
466
- Lt as EmbeddedChatPrimitiveFileRemoveIcon,
467
- Mt as EmbeddedChatPrimitiveFileThumbnail,
468
- Nt as EmbeddedChatPrimitiveFileTypeIcon,
469
- Pt as EmbeddedChatPrimitiveFileUploadButton,
470
- It as EmbeddedChatPrimitiveFileUploadButtonIcon,
471
- ft as EmbeddedChatPrimitiveInputFieldset,
472
- gt as EmbeddedChatPrimitiveInputNotification,
473
- bt as EmbeddedChatPrimitiveInputNotificationClose,
474
- Ft as EmbeddedChatPrimitiveInputNotificationContent,
475
- Ct as EmbeddedChatPrimitiveInputNotificationHeader,
460
+ S as ACCEPTED_FILE_MIME_TYPES,
461
+ gt as EmbeddedChatPrimitiveDropZone,
462
+ Mt as EmbeddedChatPrimitiveFileContent,
463
+ jt as EmbeddedChatPrimitiveFileInput,
464
+ wt as EmbeddedChatPrimitiveFileItem,
465
+ Et as EmbeddedChatPrimitiveFileList,
466
+ Lt as EmbeddedChatPrimitiveFileName,
467
+ kt as EmbeddedChatPrimitiveFilePreviewTrigger,
468
+ St as EmbeddedChatPrimitiveFileRemove,
469
+ qt as EmbeddedChatPrimitiveFileRemoveIcon,
470
+ Nt as EmbeddedChatPrimitiveFileThumbnail,
471
+ Tt as EmbeddedChatPrimitiveFileTypeIcon,
472
+ yt as EmbeddedChatPrimitiveFileUploadButton,
473
+ Pt as EmbeddedChatPrimitiveFileUploadButtonIcon,
474
+ ht as EmbeddedChatPrimitiveInputFieldset,
475
+ vt as EmbeddedChatPrimitiveInputNotification,
476
+ Ft as EmbeddedChatPrimitiveInputNotificationClose,
477
+ Ct as EmbeddedChatPrimitiveInputNotificationContent,
478
+ It as EmbeddedChatPrimitiveInputNotificationHeader,
476
479
  _t as EmbeddedChatPrimitiveInputNotificationMessage,
477
- vt as EmbeddedChatPrimitiveInputNotificationTitle,
478
- ut as EmbeddedChatPrimitiveMessageFile,
479
- mt as EmbeddedChatPrimitiveMessageFiles,
480
- b as FILE_ACCEPT_MAP,
481
- L as FILE_TYPE_ICON_MAP,
482
- j as MAX_FILES,
483
- E as MAX_FILE_SIZE,
480
+ bt as EmbeddedChatPrimitiveInputNotificationTitle,
481
+ ft as EmbeddedChatPrimitiveMessageFile,
482
+ ut as EmbeddedChatPrimitiveMessageFiles,
483
+ _ as FILE_ACCEPT_MAP,
484
+ q as FILE_TYPE_ICON_MAP,
485
+ E as MAX_FILES,
486
+ w as MAX_FILE_SIZE,
484
487
  C as isImageMimeType,
485
488
  R as normalizeFileType
486
489
  };
@@ -3,6 +3,7 @@ import { GetHelpOption, CustomMessageAction } from './settings/actions';
3
3
  import { SearchAndChatFilters } from './filters';
4
4
  import { ComponentsConfig } from './components';
5
5
  import { FileUIPart } from 'ai';
6
+ export type { FileUIPart } from 'ai';
6
7
  export interface InkeepAIChatSettings {
7
8
  /**
8
9
  * Headers for requests
@@ -56,12 +57,14 @@ export interface InkeepAIChatSettings {
56
57
  * and present in client memory, and if the transformer throws or returns a
57
58
  * non-array, the widget fails open and renders the original untransformed parts.
58
59
  * Null entries in a returned array are dropped, treated as intent to omit rather
59
- * than as a failure. Must be pure and cheap, since it runs on every message render.
60
+ * than as a failure. Every returned (whitelisted) part is displayed verbatim, so
61
+ * returning entries that were not in the input adds chips for files the user never
62
+ * attached. Must be pure and cheap, since it runs on every message render.
60
63
  * Return new or copied objects and do not mutate the input parts.
61
64
  *
62
65
  * @beta This type is subject to change.
63
66
  */
64
- transformMessageFiles?: (files: FileUIPart[]) => FileUIPart[];
67
+ transformMessageFiles?: (files: FileUIPart[]) => Array<FileUIPart | null | undefined>;
65
68
  /**
66
69
  * The placeholder text to display in the chat input field when empty.
67
70
  * Use this to provide guidance on what kind of questions users can ask.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-ui",
3
- "version": "0.0.0-dev-20260612033415",
3
+ "version": "0.0.0-dev-20260612035557",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {