@inkeep/agents-ui 0.0.0-dev-20260611213628 → 0.0.0-dev-20260612033415
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/primitives/components/embedded-chat/file-upload-input.cjs +1 -1
- package/dist/primitives/components/embedded-chat/file-upload-input.js +177 -161
- package/dist/styled/inkeep.css.cjs +3 -0
- package/dist/styled/inkeep.css.js +3 -0
- package/dist/types/config/ai.d.ts +19 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("react"),b=require("../../atoms/icons/custom-icon.cjs"),_=require("../../providers/image-preview-provider.cjs"),y=require("../../providers/message-provider.cjs"),m=require("./chat-provider.cjs"),p=require("../../atoms/file-upload.cjs"),g=require("../../utils/misc.cjs"),c=require("../../utils/compose-event-handlers.cjs"),o=require("../factory.cjs"),w=require("../../providers/config-provider.cjs"),E={"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(t){return t.startsWith("image/")}const u={"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"]},j=new Set(Object.keys(u)),F=10,I=1024*1024*10,N=Object.entries(u).reduce((t,[e,i])=>{for(const n of i)t[n]=e;return t},{});function k(t){if(t.type)return t;const e=`.${t.name.split(".").pop()?.toLowerCase()}`,i=N[e];return i?new File([t],t.name,{type:i}):t}function T(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 ${F} 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 ${I/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 M=o.ikp("div",{_id:"aiChatMessage__Files"}),q=({children:t,...e})=>{const{message:i}=y.useMessage();if(i.role!=="user")return null;const n=(i.parts??[]).filter(s=>{if(s.type!=="file")return!1;const l=s.mediaType;return j.has(l??"")});return n.length?a.jsx(M,{...e,children:t(n)}):null},L=o.ikp("button",{_id:"aiChatMessage__File"}),A=({url:t,name:e,mediaType:i,onClick:n,...s})=>{const{openImagePreview:l}=_.useImagePreview(),[d,h]=r.useState(!0),f=r.useMemo(()=>new File([],e??"file",{type:i}),[e,i]);return a.jsx(P.Provider,{value:{file:f,objectUrl:t,isLoading:d,setIsLoading:h,onRemove:()=>{}},children:a.jsx(L,{type:"button","aria-label":C(i??"")?`Preview ${e??"file"}`:`Open ${e??"file"} in new tab`,"data-loading":g.dataAttr(d),onClick:c.composeEventHandlers(n,()=>{if(C(i??""))l({url:t,name:e??"file"});else if(t)if(t.startsWith("data:")){const v=document.createElement("a");v.href=t,v.download=e??"file",v.click()}else window.open(t,"_blank","noopener,noreferrer")}),...s})})},U=o.ikp("div",{_id:"aiChatInput__Fieldset"}),S=t=>{const e=p.useFileUploadApi();return a.jsx(U,{...e.getDropzoneProps({disableClick:!0}),"data-drag-over":g.dataAttr(e.dragging),...t})},R=({...t})=>{const{files:e,setFiles:i,showInputNotification:n}=m.useChat();return a.jsx(p.FileUploadRoot,{accept:u,maxFiles:F,maxFileSize:I,preventDocumentDrop:!0,acceptedFiles:e,onFileAccept:s=>i(s.files),onFileReject:s=>{const l=T(s.files);l&&n(l)},children:a.jsx(S,{...t})})},O=o.ikp("div",{_id:"aiChatInput__DropZone"}),H=o.ikp("div",{_id:"aiChatInput__Notification"}),D=t=>{const{inputNotification:e}=m.useChat();return e?a.jsx(H,{role:"alert",...t}):null},B=o.ikp("p",{_id:"aiChatInput__NotificationTitle"}),X=({children:t,...e})=>{const{inputNotification:i}=m.useChat();return i?.title?a.jsxs(B,{...e,children:[t,i.title]}):null},Y=o.ikp("p",{_id:"aiChatInput__NotificationMessage"}),$=t=>{const{inputNotification:e}=m.useChat();return a.jsx(Y,{...t,children:e?.message})},z=o.ikp("button",{_id:"aiChatInput__NotificationClose"}),Z=({onClick:t,...e})=>{const{clearInputNotification:i}=m.useChat();return a.jsx(z,{type:"button","aria-label":"Dismiss",onClick:c.composeEventHandlers(t,i),...e})},K=o.ikp("div",{_id:"aiChatInput__NotificationContent"}),V=o.ikp("div",{_id:"aiChatInput__NotificationHeader"}),W=o.ikp(b.CustomIcon,{_id:"aiChatInput__FileUploadButtonIcon",iconKey:"fileUpload"}),G=o.ikp("button",{_id:"aiChatInput__FileUploadButton"}),J=t=>{const{aiChatSettings:e}=w.useInkeepConfig(),i=p.useFileUploadApi(),{onClick:n,...s}=t;return a.jsx(G,{type:"button","aria-label":"Upload file",disabled:e.isViewOnly,onClick:c.composeEventHandlers(n,()=>i.openFilePicker()),...s})},Q=o.ikp("input",{_id:"aiChatInput__FileInput"}),tt=t=>{const e=p.useFileUploadApi();return a.jsx(Q,{...t,...e.getHiddenInputProps()})},et=o.ikp("div",{_id:"aiChatInput__FileList"}),it=({children:t,...e})=>{const n=p.useFileUploadApi().acceptedFiles;return n.length?a.jsx(et,{...e,children:t(n)}):null},P=r.createContext(null);function x(){const t=r.useContext(P);if(!t)throw new Error("useFileContext must be used within EmbeddedChatPrimitiveFileItem");return t}const nt=o.ikp("div",{_id:"aiChatInput__FileItem"}),at=({file:t,...e})=>{const i=p.useFileUploadApi(),[n,s]=r.useState(void 0),[l,d]=r.useState(!0);r.useEffect(()=>i.createFileUrl(t,f=>{s(f),d(!0)}),[t]);const h=()=>i.deleteFile(t);return a.jsx(P.Provider,{value:{file:t,objectUrl:n,isLoading:l,setIsLoading:d,onRemove:h},children:a.jsx(nt,{"data-loading":g.dataAttr(l),...e})})},ot=o.ikp("button",{_id:"aiChatInput__FilePreviewTrigger"}),st=({onClick:t,...e})=>{const{objectUrl:i,file:n}=x(),{openImagePreview:s}=_.useImagePreview();return a.jsx(ot,{type:"button","aria-label":`Preview ${n.name}`,disabled:!i,onClick:c.composeEventHandlers(t,()=>{i&&s({url:i,name:n.name})}),...e})},lt=o.ikp("span",{_id:"aiChatInput__FileContent"}),rt=t=>a.jsx(lt,{...t}),pt=o.ikp("img",{_id:"aiChatInput__FileThumbnail"}),ct=({onLoad:t,...e})=>{const{objectUrl:i,file:n,setIsLoading:s}=x();return a.jsx(pt,{src:i,alt:n.name,onLoad:c.composeEventHandlers(t,()=>s(!1)),...e})},dt=({className:t})=>{const{file:e}=x(),i=E[k(e).type]??"file";return a.jsx(b.CustomIcon,{iconKey:i,className:t})},mt=o.ikp("span",{_id:"aiChatInput__FileName"}),xt=t=>{const{file:e}=x();return a.jsx(mt,{...t,children:e.name})},ut=o.ikp("button",{_id:"aiChatInput__FileRemove"}),ht=o.ikp(b.CustomIcon,{_id:"aiChatInput__FileRemoveIcon",iconKey:"close"}),ft=({onClick:t,...e})=>{const{onRemove:i}=x();return a.jsx(ut,{type:"button","aria-label":"Remove file",onClick:c.composeEventHandlers(t,i),...e})};exports.ACCEPTED_FILE_MIME_TYPES=j;exports.EmbeddedChatPrimitiveDropZone=O;exports.EmbeddedChatPrimitiveFileContent=rt;exports.EmbeddedChatPrimitiveFileInput=tt;exports.EmbeddedChatPrimitiveFileItem=at;exports.EmbeddedChatPrimitiveFileList=it;exports.EmbeddedChatPrimitiveFileName=xt;exports.EmbeddedChatPrimitiveFilePreviewTrigger=st;exports.EmbeddedChatPrimitiveFileRemove=ft;exports.EmbeddedChatPrimitiveFileRemoveIcon=ht;exports.EmbeddedChatPrimitiveFileThumbnail=ct;exports.EmbeddedChatPrimitiveFileTypeIcon=dt;exports.EmbeddedChatPrimitiveFileUploadButton=J;exports.EmbeddedChatPrimitiveFileUploadButtonIcon=W;exports.EmbeddedChatPrimitiveInputFieldset=R;exports.EmbeddedChatPrimitiveInputNotification=D;exports.EmbeddedChatPrimitiveInputNotificationClose=Z;exports.EmbeddedChatPrimitiveInputNotificationContent=K;exports.EmbeddedChatPrimitiveInputNotificationHeader=V;exports.EmbeddedChatPrimitiveInputNotificationMessage=$;exports.EmbeddedChatPrimitiveInputNotificationTitle=X;exports.EmbeddedChatPrimitiveMessageFile=A;exports.EmbeddedChatPrimitiveMessageFiles=q;exports.FILE_ACCEPT_MAP=u;exports.FILE_TYPE_ICON_MAP=E;exports.MAX_FILES=F;exports.MAX_FILE_SIZE=I;exports.isImageMimeType=C;exports.normalizeFileType=k;
|
|
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,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
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";
|
|
4
4
|
import { CustomIcon as v } from "../../atoms/icons/custom-icon.js";
|
|
5
|
-
import { useImagePreview as
|
|
6
|
-
import { useMessage as
|
|
7
|
-
import { useChat as
|
|
8
|
-
import { useFileUploadApi as
|
|
9
|
-
import { dataAttr as
|
|
10
|
-
import { composeEventHandlers as
|
|
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";
|
|
10
|
+
import { composeEventHandlers as d } from "../../utils/compose-event-handlers.js";
|
|
11
11
|
import { ikp as o } from "../factory.js";
|
|
12
|
-
import { useInkeepConfig as
|
|
12
|
+
import { useInkeepConfig as y } from "../../providers/config-provider.js";
|
|
13
13
|
const L = {
|
|
14
14
|
"application/pdf": "filePdf",
|
|
15
15
|
"text/plain": "fileText",
|
|
@@ -24,10 +24,10 @@ const L = {
|
|
|
24
24
|
"text/x-python": "filePy",
|
|
25
25
|
"text/x-python-script": "filePy"
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function C(t) {
|
|
28
28
|
return t.startsWith("image/");
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const b = {
|
|
31
31
|
// Images
|
|
32
32
|
"image/png": [".png"],
|
|
33
33
|
"image/jpeg": [".jpg", ".jpeg"],
|
|
@@ -173,7 +173,7 @@ const _ = {
|
|
|
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
|
-
},
|
|
176
|
+
}, q = new Set(Object.keys(b)), j = 10, E = 1024 * 1024 * 10, S = Object.entries(b).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 _ = {
|
|
|
182
182
|
);
|
|
183
183
|
function R(t) {
|
|
184
184
|
if (t.type) return t;
|
|
185
|
-
const e = `.${t.name.split(".").pop()?.toLowerCase()}`, i =
|
|
185
|
+
const e = `.${t.name.split(".").pop()?.toLowerCase()}`, i = S[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 ${
|
|
193
|
+
message: `You can only attach up to ${j} 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 ${
|
|
199
|
+
message: `Files must be smaller than ${E / 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,266 +205,282 @@ function U(t) {
|
|
|
205
205
|
message: "This file could not be added."
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
|
-
const
|
|
208
|
+
const A = o("div", {
|
|
209
209
|
_id: "aiChatMessage__Files"
|
|
210
|
-
}),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
}), f = /* @__PURE__ */ new WeakSet();
|
|
211
|
+
function O(t, e) {
|
|
212
|
+
const i = e.map((a) => {
|
|
213
|
+
if (!a.providerMetadata) return { ...a };
|
|
214
|
+
try {
|
|
215
|
+
return { ...a, providerMetadata: structuredClone(a.providerMetadata) };
|
|
216
|
+
} catch {
|
|
217
|
+
return { ...a };
|
|
218
|
+
}
|
|
217
219
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
let n;
|
|
221
|
+
try {
|
|
222
|
+
n = t(i);
|
|
223
|
+
} catch (a) {
|
|
224
|
+
return f.has(t) || (f.add(t), console.warn("[aiChatSettings] transformMessageFiles threw", a)), e;
|
|
225
|
+
}
|
|
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);
|
|
227
|
+
}
|
|
228
|
+
const mt = ({ children: t, ...e }) => {
|
|
229
|
+
const { message: i } = N(), { aiChatSettings: n } = y();
|
|
230
|
+
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 ?? "")
|
|
233
|
+
);
|
|
234
|
+
return c.length ? /* @__PURE__ */ s(A, { ...e, children: t(c) }) : null;
|
|
235
|
+
}, D = o("button", {
|
|
220
236
|
_id: "aiChatMessage__File"
|
|
221
|
-
}),
|
|
237
|
+
}), ut = ({
|
|
222
238
|
url: t,
|
|
223
239
|
name: e,
|
|
224
240
|
mediaType: i,
|
|
225
241
|
onClick: n,
|
|
226
|
-
...
|
|
242
|
+
...a
|
|
227
243
|
}) => {
|
|
228
|
-
const { openImagePreview:
|
|
244
|
+
const { openImagePreview: r } = P(), [p, c] = g(!0), l = M(
|
|
229
245
|
() => new File([], e ?? "file", { type: i }),
|
|
230
246
|
[e, i]
|
|
231
247
|
);
|
|
232
|
-
return /* @__PURE__ */
|
|
233
|
-
|
|
248
|
+
return /* @__PURE__ */ s(
|
|
249
|
+
F.Provider,
|
|
234
250
|
{
|
|
235
|
-
value: { file:
|
|
251
|
+
value: { file: l, objectUrl: t, isLoading: p, setIsLoading: c, onRemove: () => {
|
|
236
252
|
} },
|
|
237
|
-
children: /* @__PURE__ */
|
|
238
|
-
|
|
253
|
+
children: /* @__PURE__ */ s(
|
|
254
|
+
D,
|
|
239
255
|
{
|
|
240
256
|
type: "button",
|
|
241
|
-
"aria-label":
|
|
242
|
-
"data-loading":
|
|
243
|
-
onClick:
|
|
244
|
-
if (
|
|
245
|
-
|
|
257
|
+
"aria-label": C(i ?? "") ? `Preview ${e ?? "file"}` : `Open ${e ?? "file"} in new tab`,
|
|
258
|
+
"data-loading": _(p),
|
|
259
|
+
onClick: d(n, () => {
|
|
260
|
+
if (C(i ?? ""))
|
|
261
|
+
r({ url: t, name: e ?? "file" });
|
|
246
262
|
else if (t)
|
|
247
263
|
if (t.startsWith("data:")) {
|
|
248
|
-
const
|
|
249
|
-
|
|
264
|
+
const h = document.createElement("a");
|
|
265
|
+
h.href = t, h.download = e ?? "file", h.click();
|
|
250
266
|
} else
|
|
251
267
|
window.open(t, "_blank", "noopener,noreferrer");
|
|
252
268
|
}),
|
|
253
|
-
...
|
|
269
|
+
...a
|
|
254
270
|
}
|
|
255
271
|
)
|
|
256
272
|
}
|
|
257
273
|
);
|
|
258
|
-
},
|
|
274
|
+
}, $ = o("div", {
|
|
259
275
|
_id: "aiChatInput__Fieldset"
|
|
260
|
-
}),
|
|
261
|
-
const e =
|
|
262
|
-
return /* @__PURE__ */
|
|
263
|
-
|
|
276
|
+
}), B = (t) => {
|
|
277
|
+
const e = m();
|
|
278
|
+
return /* @__PURE__ */ s(
|
|
279
|
+
$,
|
|
264
280
|
{
|
|
265
281
|
...e.getDropzoneProps({ disableClick: !0 }),
|
|
266
|
-
"data-drag-over":
|
|
282
|
+
"data-drag-over": _(e.dragging),
|
|
267
283
|
...t
|
|
268
284
|
}
|
|
269
285
|
);
|
|
270
|
-
},
|
|
286
|
+
}, ft = ({
|
|
271
287
|
...t
|
|
272
288
|
}) => {
|
|
273
|
-
const { files: e, setFiles: i, showInputNotification: n } =
|
|
274
|
-
return /* @__PURE__ */
|
|
275
|
-
|
|
289
|
+
const { files: e, setFiles: i, showInputNotification: n } = x();
|
|
290
|
+
return /* @__PURE__ */ s(
|
|
291
|
+
T,
|
|
276
292
|
{
|
|
277
|
-
accept:
|
|
278
|
-
maxFiles:
|
|
279
|
-
maxFileSize:
|
|
293
|
+
accept: b,
|
|
294
|
+
maxFiles: j,
|
|
295
|
+
maxFileSize: E,
|
|
280
296
|
preventDocumentDrop: !0,
|
|
281
297
|
acceptedFiles: e,
|
|
282
|
-
onFileAccept: (
|
|
283
|
-
onFileReject: (
|
|
284
|
-
const
|
|
285
|
-
|
|
298
|
+
onFileAccept: (a) => i(a.files),
|
|
299
|
+
onFileReject: (a) => {
|
|
300
|
+
const r = U(a.files);
|
|
301
|
+
r && n(r);
|
|
286
302
|
},
|
|
287
|
-
children: /* @__PURE__ */
|
|
303
|
+
children: /* @__PURE__ */ s(B, { ...t })
|
|
288
304
|
}
|
|
289
305
|
);
|
|
290
|
-
},
|
|
306
|
+
}, ht = o("div", {
|
|
291
307
|
_id: "aiChatInput__DropZone"
|
|
292
|
-
}),
|
|
308
|
+
}), z = o("div", {
|
|
293
309
|
_id: "aiChatInput__Notification"
|
|
294
|
-
}),
|
|
295
|
-
const { inputNotification: e } =
|
|
296
|
-
return e ? /* @__PURE__ */
|
|
297
|
-
},
|
|
310
|
+
}), gt = (t) => {
|
|
311
|
+
const { inputNotification: e } = x();
|
|
312
|
+
return e ? /* @__PURE__ */ s(z, { role: "alert", ...t }) : null;
|
|
313
|
+
}, H = o("p", {
|
|
298
314
|
_id: "aiChatInput__NotificationTitle"
|
|
299
|
-
}),
|
|
315
|
+
}), vt = ({
|
|
300
316
|
children: t,
|
|
301
317
|
...e
|
|
302
318
|
}) => {
|
|
303
|
-
const { inputNotification: i } =
|
|
304
|
-
return i?.title ? /* @__PURE__ */
|
|
319
|
+
const { inputNotification: i } = x();
|
|
320
|
+
return i?.title ? /* @__PURE__ */ w(H, { ...e, children: [
|
|
305
321
|
t,
|
|
306
322
|
i.title
|
|
307
323
|
] }) : null;
|
|
308
|
-
},
|
|
324
|
+
}, X = o("p", {
|
|
309
325
|
_id: "aiChatInput__NotificationMessage"
|
|
310
|
-
}),
|
|
311
|
-
const { inputNotification: e } =
|
|
312
|
-
return /* @__PURE__ */
|
|
313
|
-
},
|
|
326
|
+
}), _t = (t) => {
|
|
327
|
+
const { inputNotification: e } = x();
|
|
328
|
+
return /* @__PURE__ */ s(X, { ...t, children: e?.message });
|
|
329
|
+
}, Y = o("button", {
|
|
314
330
|
_id: "aiChatInput__NotificationClose"
|
|
315
|
-
}),
|
|
331
|
+
}), bt = ({
|
|
316
332
|
onClick: t,
|
|
317
333
|
...e
|
|
318
334
|
}) => {
|
|
319
|
-
const { clearInputNotification: i } =
|
|
320
|
-
return /* @__PURE__ */
|
|
321
|
-
|
|
335
|
+
const { clearInputNotification: i } = x();
|
|
336
|
+
return /* @__PURE__ */ s(
|
|
337
|
+
Y,
|
|
322
338
|
{
|
|
323
339
|
type: "button",
|
|
324
340
|
"aria-label": "Dismiss",
|
|
325
|
-
onClick:
|
|
341
|
+
onClick: d(t, i),
|
|
326
342
|
...e
|
|
327
343
|
}
|
|
328
344
|
);
|
|
329
|
-
},
|
|
345
|
+
}, Ft = o("div", {
|
|
330
346
|
_id: "aiChatInput__NotificationContent"
|
|
331
|
-
}),
|
|
347
|
+
}), Ct = o("div", {
|
|
332
348
|
_id: "aiChatInput__NotificationHeader"
|
|
333
|
-
}),
|
|
349
|
+
}), It = o(v, {
|
|
334
350
|
_id: "aiChatInput__FileUploadButtonIcon",
|
|
335
351
|
iconKey: "fileUpload"
|
|
336
|
-
}),
|
|
352
|
+
}), K = o("button", {
|
|
337
353
|
_id: "aiChatInput__FileUploadButton"
|
|
338
|
-
}),
|
|
339
|
-
const { aiChatSettings: e } =
|
|
340
|
-
return /* @__PURE__ */
|
|
341
|
-
|
|
354
|
+
}), Pt = (t) => {
|
|
355
|
+
const { aiChatSettings: e } = y(), i = m(), { onClick: n, ...a } = t;
|
|
356
|
+
return /* @__PURE__ */ s(
|
|
357
|
+
K,
|
|
342
358
|
{
|
|
343
359
|
type: "button",
|
|
344
360
|
"aria-label": "Upload file",
|
|
345
361
|
disabled: e.isViewOnly,
|
|
346
|
-
onClick:
|
|
347
|
-
...
|
|
362
|
+
onClick: d(n, () => i.openFilePicker()),
|
|
363
|
+
...a
|
|
348
364
|
}
|
|
349
365
|
);
|
|
350
|
-
},
|
|
366
|
+
}, W = o("input", {
|
|
351
367
|
_id: "aiChatInput__FileInput"
|
|
352
|
-
}),
|
|
353
|
-
const e =
|
|
354
|
-
return /* @__PURE__ */
|
|
355
|
-
},
|
|
368
|
+
}), yt = (t) => {
|
|
369
|
+
const e = m();
|
|
370
|
+
return /* @__PURE__ */ s(W, { ...t, ...e.getHiddenInputProps() });
|
|
371
|
+
}, Z = o("div", {
|
|
356
372
|
_id: "aiChatInput__FileList"
|
|
357
|
-
}),
|
|
358
|
-
const n =
|
|
359
|
-
return n.length ? /* @__PURE__ */
|
|
360
|
-
},
|
|
361
|
-
function
|
|
362
|
-
const t =
|
|
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);
|
|
377
|
+
function u() {
|
|
378
|
+
const t = I.useContext(F);
|
|
363
379
|
if (!t) throw new Error("useFileContext must be used within EmbeddedChatPrimitiveFileItem");
|
|
364
380
|
return t;
|
|
365
381
|
}
|
|
366
|
-
const
|
|
382
|
+
const V = o("div", {
|
|
367
383
|
_id: "aiChatInput__FileItem"
|
|
368
|
-
}),
|
|
369
|
-
const i =
|
|
370
|
-
|
|
371
|
-
|
|
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
|
+
a(l), p(!0);
|
|
372
388
|
}), [t]);
|
|
373
|
-
const
|
|
374
|
-
return /* @__PURE__ */
|
|
375
|
-
},
|
|
389
|
+
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", {
|
|
376
392
|
_id: "aiChatInput__FilePreviewTrigger"
|
|
377
|
-
}),
|
|
393
|
+
}), wt = ({
|
|
378
394
|
onClick: t,
|
|
379
395
|
...e
|
|
380
396
|
}) => {
|
|
381
|
-
const { objectUrl: i, file: n } =
|
|
382
|
-
return /* @__PURE__ */
|
|
383
|
-
|
|
397
|
+
const { objectUrl: i, file: n } = u(), { openImagePreview: a } = P();
|
|
398
|
+
return /* @__PURE__ */ s(
|
|
399
|
+
G,
|
|
384
400
|
{
|
|
385
401
|
type: "button",
|
|
386
402
|
"aria-label": `Preview ${n.name}`,
|
|
387
403
|
disabled: !i,
|
|
388
|
-
onClick:
|
|
389
|
-
i &&
|
|
404
|
+
onClick: d(t, () => {
|
|
405
|
+
i && a({ url: i, name: n.name });
|
|
390
406
|
}),
|
|
391
407
|
...e
|
|
392
408
|
}
|
|
393
409
|
);
|
|
394
|
-
},
|
|
410
|
+
}, J = o("span", {
|
|
395
411
|
_id: "aiChatInput__FileContent"
|
|
396
|
-
}),
|
|
412
|
+
}), kt = (t) => /* @__PURE__ */ s(J, { ...t }), Q = o("img", {
|
|
397
413
|
_id: "aiChatInput__FileThumbnail"
|
|
398
|
-
}),
|
|
414
|
+
}), Mt = ({
|
|
399
415
|
onLoad: t,
|
|
400
416
|
...e
|
|
401
417
|
}) => {
|
|
402
|
-
const { objectUrl: i, file: n, setIsLoading:
|
|
403
|
-
return /* @__PURE__ */
|
|
404
|
-
|
|
418
|
+
const { objectUrl: i, file: n, setIsLoading: a } = u();
|
|
419
|
+
return /* @__PURE__ */ s(
|
|
420
|
+
Q,
|
|
405
421
|
{
|
|
406
422
|
src: i,
|
|
407
423
|
alt: n.name,
|
|
408
|
-
onLoad:
|
|
424
|
+
onLoad: d(t, () => a(!1)),
|
|
409
425
|
...e
|
|
410
426
|
}
|
|
411
427
|
);
|
|
412
|
-
},
|
|
413
|
-
const { file: e } =
|
|
414
|
-
return /* @__PURE__ */
|
|
415
|
-
},
|
|
428
|
+
}, Nt = ({ className: t }) => {
|
|
429
|
+
const { file: e } = u(), i = L[R(e).type] ?? "file";
|
|
430
|
+
return /* @__PURE__ */ s(v, { iconKey: i, className: t });
|
|
431
|
+
}, tt = o("span", {
|
|
416
432
|
_id: "aiChatInput__FileName"
|
|
417
|
-
}),
|
|
418
|
-
const { file: e } =
|
|
419
|
-
return /* @__PURE__ */
|
|
420
|
-
},
|
|
433
|
+
}), Tt = (t) => {
|
|
434
|
+
const { file: e } = u();
|
|
435
|
+
return /* @__PURE__ */ s(tt, { ...t, children: e.name });
|
|
436
|
+
}, et = o("button", {
|
|
421
437
|
_id: "aiChatInput__FileRemove"
|
|
422
|
-
}),
|
|
438
|
+
}), Lt = o(v, {
|
|
423
439
|
_id: "aiChatInput__FileRemoveIcon",
|
|
424
440
|
iconKey: "close"
|
|
425
|
-
}),
|
|
441
|
+
}), qt = ({
|
|
426
442
|
onClick: t,
|
|
427
443
|
...e
|
|
428
444
|
}) => {
|
|
429
|
-
const { onRemove: i } =
|
|
430
|
-
return /* @__PURE__ */
|
|
431
|
-
|
|
445
|
+
const { onRemove: i } = u();
|
|
446
|
+
return /* @__PURE__ */ s(
|
|
447
|
+
et,
|
|
432
448
|
{
|
|
433
449
|
type: "button",
|
|
434
450
|
"aria-label": "Remove file",
|
|
435
|
-
onClick:
|
|
451
|
+
onClick: d(t, i),
|
|
436
452
|
...e
|
|
437
453
|
}
|
|
438
454
|
);
|
|
439
455
|
};
|
|
440
456
|
export {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
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,
|
|
476
|
+
_t as EmbeddedChatPrimitiveInputNotificationMessage,
|
|
477
|
+
vt as EmbeddedChatPrimitiveInputNotificationTitle,
|
|
478
|
+
ut as EmbeddedChatPrimitiveMessageFile,
|
|
479
|
+
mt as EmbeddedChatPrimitiveMessageFiles,
|
|
480
|
+
b as FILE_ACCEPT_MAP,
|
|
465
481
|
L as FILE_TYPE_ICON_MAP,
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
482
|
+
j as MAX_FILES,
|
|
483
|
+
E as MAX_FILE_SIZE,
|
|
484
|
+
C as isImageMimeType,
|
|
469
485
|
R as normalizeFileType
|
|
470
486
|
};
|
|
@@ -43,6 +43,25 @@ export interface InkeepAIChatSettings {
|
|
|
43
43
|
* @beta This type is subject to change.
|
|
44
44
|
*/
|
|
45
45
|
files?: FileUIPart[];
|
|
46
|
+
/**
|
|
47
|
+
* Transform the file attachments displayed on a user message before they render as
|
|
48
|
+
* chips. Called per message at render time with the message's file parts, for live
|
|
49
|
+
* and history-loaded messages alike. The input includes all of the message's file
|
|
50
|
+
* parts regardless of MIME type; the widget's accepted-file-types filter is
|
|
51
|
+
* re-applied to the returned list, so unsupported types still never render. Return
|
|
52
|
+
* the parts to display: omit entries to hide them, or return shallow-modified copies
|
|
53
|
+
* (for example, with a friendlier filename) to rename them. Display-only, so it does
|
|
54
|
+
* not affect what is sent to the agent, stored, or visible to the LLM. Not a
|
|
55
|
+
* security boundary: hidden parts are still sent, stored in conversation history,
|
|
56
|
+
* and present in client memory, and if the transformer throws or returns a
|
|
57
|
+
* non-array, the widget fails open and renders the original untransformed parts.
|
|
58
|
+
* 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
|
+
* Return new or copied objects and do not mutate the input parts.
|
|
61
|
+
*
|
|
62
|
+
* @beta This type is subject to change.
|
|
63
|
+
*/
|
|
64
|
+
transformMessageFiles?: (files: FileUIPart[]) => FileUIPart[];
|
|
46
65
|
/**
|
|
47
66
|
* The placeholder text to display in the chat input field when empty.
|
|
48
67
|
* Use this to provide guidance on what kind of questions users can ask.
|