@flexkit/studio 0.2.17 → 0.2.19
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-nav-button-V5DFHADL.js +2 -0
- package/dist/{activity-nav-button-7SVTTHBQ.js.map → activity-nav-button-V5DFHADL.js.map} +1 -1
- package/dist/chat-page-LAK4TFN4.js +4 -0
- package/dist/chat-page-LAK4TFN4.js.map +1 -0
- package/dist/chunk-2NXQF2F7.js +2 -0
- package/dist/chunk-2NXQF2F7.js.map +1 -0
- package/dist/chunk-4IEOAKKK.js +2 -0
- package/dist/chunk-4IEOAKKK.js.map +1 -0
- package/dist/{chunk-3C2EG3SI.js → chunk-54AXLGAK.js} +2 -2
- package/dist/{chunk-3C2EG3SI.js.map → chunk-54AXLGAK.js.map} +1 -1
- package/dist/chunk-6RRB47OZ.js +8 -0
- package/dist/chunk-6RRB47OZ.js.map +1 -0
- package/dist/chunk-A7XHA2P6.js +3 -0
- package/dist/chunk-A7XHA2P6.js.map +1 -0
- package/dist/chunk-BMO7JFAX.js +2 -0
- package/dist/chunk-BMO7JFAX.js.map +1 -0
- package/dist/{chunk-U5D3EDCY.js → chunk-BMX4URYN.js} +2 -2
- package/dist/{chunk-U5D3EDCY.js.map → chunk-BMX4URYN.js.map} +1 -1
- package/dist/chunk-CLCIE5RF.js +2 -0
- package/dist/chunk-CLCIE5RF.js.map +1 -0
- package/dist/{chunk-RYKUNA7Z.js → chunk-DFLAX7EE.js} +2 -2
- package/dist/{chunk-RYKUNA7Z.js.map → chunk-DFLAX7EE.js.map} +1 -1
- package/dist/chunk-DGIY4SKN.js +7 -0
- package/dist/chunk-DGIY4SKN.js.map +1 -0
- package/dist/chunk-DHVKE36X.js +3 -0
- package/dist/chunk-DHVKE36X.js.map +1 -0
- package/dist/chunk-EMFHKTAV.js +2 -0
- package/dist/chunk-EMFHKTAV.js.map +1 -0
- package/dist/chunk-ERDARDGB.js +2 -0
- package/dist/chunk-ERDARDGB.js.map +1 -0
- package/dist/chunk-H2RWSC56.js +3 -0
- package/dist/chunk-H2RWSC56.js.map +1 -0
- package/dist/{chunk-FDN23BPI.js → chunk-HCJAM5LG.js} +2 -2
- package/dist/{chunk-FDN23BPI.js.map → chunk-HCJAM5LG.js.map} +1 -1
- package/dist/chunk-ME55YNBF.js +30 -0
- package/dist/chunk-ME55YNBF.js.map +1 -0
- package/dist/chunk-OOYCTZ3C.js +379 -0
- package/dist/chunk-OOYCTZ3C.js.map +1 -0
- package/dist/chunk-QWQHXMXW.js +2 -0
- package/dist/{chunk-FNWEP2NM.js.map → chunk-QWQHXMXW.js.map} +1 -1
- package/dist/{chunk-ALCK2BJY.js → chunk-UOR437J2.js} +2 -2
- package/dist/{chunk-ALCK2BJY.js.map → chunk-UOR437J2.js.map} +1 -1
- package/dist/{chunk-3KMR2CXS.js → chunk-V6RB45UU.js} +2 -2
- package/dist/{chunk-3KMR2CXS.js.map → chunk-V6RB45UU.js.map} +1 -1
- package/dist/chunk-VMWUMFUL.js +4 -0
- package/dist/chunk-VMWUMFUL.js.map +1 -0
- package/dist/chunk-XMOSCJOI.js +2 -0
- package/dist/chunk-XMOSCJOI.js.map +1 -0
- package/dist/chunk-XNHSHVG2.js +7 -0
- package/dist/chunk-XNHSHVG2.js.map +1 -0
- package/dist/chunk-YDVO6XWD.js +2 -0
- package/dist/chunk-YDVO6XWD.js.map +1 -0
- package/dist/chunk-ZKA2HKNI.js +2 -0
- package/dist/chunk-ZKA2HKNI.js.map +1 -0
- package/dist/entry-3JSFO4OU.js +2 -0
- package/dist/entry-3JSFO4OU.js.map +1 -0
- package/dist/index.css +712 -246
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/list-SY3L2ACH.js +3 -0
- package/dist/list-SY3L2ACH.js.map +1 -0
- package/dist/list-Z2C74QDN.js +2 -0
- package/dist/{list-EXNTXASK.js.map → list-Z2C74QDN.js.map} +1 -1
- package/dist/pages-INCA54HE.js +5 -0
- package/dist/{pages-NWZLOKQM.js.map → pages-INCA54HE.js.map} +1 -1
- package/dist/plugin-pages-WO3MCJKC.js +2 -0
- package/dist/{plugin-pages-2KMZFNFB.js.map → plugin-pages-WO3MCJKC.js.map} +1 -1
- package/dist/record-links-CTB4SC4J.js +2 -0
- package/dist/record-links-CTB4SC4J.js.map +1 -0
- package/dist/root-6MSWGFZX.js +2 -0
- package/dist/root-6MSWGFZX.js.map +1 -0
- package/dist/root-B4D3C37Q.js +2 -0
- package/dist/root-B4D3C37Q.js.map +1 -0
- package/dist/root-DOOWSYWY.js +23 -0
- package/dist/root-DOOWSYWY.js.map +1 -0
- package/dist/root-JA2LFGNX.js +2 -0
- package/dist/root-JA2LFGNX.js.map +1 -0
- package/dist/root-OGX4DUTM.js +2 -0
- package/dist/root-OGX4DUTM.js.map +1 -0
- package/dist/{root-BRCN3D2D.js → root-XHXX3SZG.js} +3 -3
- package/dist/{root-BRCN3D2D.js.map → root-XHXX3SZG.js.map} +1 -1
- package/dist/search-Z4M4R4NJ.js +2 -0
- package/dist/{search-7IJJYUSR.js.map → search-Z4M4R4NJ.js.map} +1 -1
- package/dist/skills-pages-TP2XQPCQ.js +2 -0
- package/dist/{skills-pages-4ELHNJVY.js.map → skills-pages-TP2XQPCQ.js.map} +1 -1
- package/dist/source-5J56KIFA.js +2 -0
- package/dist/source-5J56KIFA.js.map +1 -0
- package/dist/spec-renderer-3GAVSV52.js +2 -0
- package/dist/{spec-renderer-EX7SCFWH.js.map → spec-renderer-3GAVSV52.js.map} +1 -1
- package/dist/ui.d.ts +15 -5
- package/dist/ui.js +1 -1
- package/package.json +13 -5
- package/dist/activity-nav-button-7SVTTHBQ.js +0 -2
- package/dist/chat-page-X3MIN6YC.js +0 -4
- package/dist/chat-page-X3MIN6YC.js.map +0 -1
- package/dist/chunk-7ZFUS62K.js +0 -3
- package/dist/chunk-7ZFUS62K.js.map +0 -1
- package/dist/chunk-D6H64Z37.js +0 -8
- package/dist/chunk-D6H64Z37.js.map +0 -1
- package/dist/chunk-FNWEP2NM.js +0 -2
- package/dist/chunk-NLRSLQUT.js +0 -3
- package/dist/chunk-NLRSLQUT.js.map +0 -1
- package/dist/chunk-P6BZ4QP7.js +0 -2
- package/dist/chunk-P6BZ4QP7.js.map +0 -1
- package/dist/chunk-PKAWL5W4.js +0 -4
- package/dist/chunk-PKAWL5W4.js.map +0 -1
- package/dist/chunk-RNMAR527.js +0 -384
- package/dist/chunk-RNMAR527.js.map +0 -1
- package/dist/chunk-YCCFUGWJ.js +0 -7
- package/dist/chunk-YCCFUGWJ.js.map +0 -1
- package/dist/list-EXNTXASK.js +0 -2
- package/dist/pages-NWZLOKQM.js +0 -5
- package/dist/plugin-pages-2KMZFNFB.js +0 -2
- package/dist/root-A6FK3OR6.js +0 -2
- package/dist/root-A6FK3OR6.js.map +0 -1
- package/dist/root-CUNQWMK4.js +0 -23
- package/dist/root-CUNQWMK4.js.map +0 -1
- package/dist/root-SCCUPXFD.js +0 -2
- package/dist/root-SCCUPXFD.js.map +0 -1
- package/dist/search-7IJJYUSR.js +0 -2
- package/dist/skills-pages-4ELHNJVY.js +0 -2
- package/dist/spec-renderer-EX7SCFWH.js +0 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import'./index.css';function s(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}var l=20*1024*1024,k=200,P=20,d=["pdf","docx","pptx","md","markdown","txt","html","htm"],T=d.map(e=>`.${e}`).join(","),p="PDF, Word, PowerPoint, Markdown, text or HTML",w=new Set(d);function m(e){let t=/\.([a-z0-9]{1,8})$/i.exec(e.trim());return t?t[1].toLowerCase():null}function I(e){let t=m(e.name);return !t||!w.has(t)?`${e.name} is not a supported document. Add ${p} files.`:e.size<=0?`${e.name} is empty.`:e.size>l?`${e.name} is larger than ${K(l)}.`:null}function K(e){return e<1024?`${String(e)} B`:e<1024*1024?`${(e/1024).toFixed(e<10*1024?1:0)} KB`:`${(e/(1024*1024)).toFixed(e<10*1024*1024?1:0)} MB`}function A(e){let t=e.trim();if(!t)return {error:"Enter the address of a public page."};let n;try{n=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:`https://${t}`);}catch{return {error:"Enter a valid address, for example https://example.com/handbook"}}return n.protocol!=="https:"?{error:"The address must use HTTPS."}:n.username||n.password?{error:"The address cannot include credentials."}:(n.hash="",{url:n.toString()})}var f={icon:"html",label:"Web page"},g={icon:"txt",label:"Text"},x={"application/pdf":{icon:"pdf",label:"PDF"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{icon:"docx",label:"Word"},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{icon:"pptx",label:"PowerPoint"},"text/markdown":{icon:"document",label:"Markdown"},"text/html":{icon:"html",label:"HTML"},"text/plain":g};function b(e){return e.kind==="url"?f:x[e.mimeType]??g}function _(e){return b(e).label}function u(e){return !!(e&&(e.state==="queued"||e.state==="extracting"||e.state==="embedding"||e.state==="publishing"))}function $(e,t){return e.status==="processing"||u(t)}function S(e){let{progress:t}=e;switch(e.state){case "queued":return "Waiting to be processed";case "extracting":return "Reading the document";case "embedding":return t?.passageCount?`Indexing passages (${String(t.embeddedCount??0)} of ${String(t.passageCount)})`:"Indexing passages";case "publishing":return "Publishing";default:return t?.message??e.state}}function F(e,t){let n=e.currentVersion,r=n?.status==="published",o=n?.passageCount??0,i=`${String(o)} ${o===1?"passage":"passages"}`;return u(t)?{label:r?"Re-indexing":"Indexing",detail:S(t),tone:"busy"}:e.status==="failed"||!r&&(t?.state==="failed"||n?.status==="failed")?{label:"Failed",detail:t?.error?.message??n?.error??"Indexing failed",tone:"error"}:e.status==="processing"||!r?{label:"Indexing",detail:"Waiting to be processed",tone:"busy"}:t?.state==="failed"?{label:"Ready",detail:`${i} \xB7 the last re-index failed: ${t.error?.message??"unknown error"}`,tone:"ready"}:n&&n.warnings.length>0?{label:"Ready",detail:`${i} \xB7 indexed with warnings`,tone:"ready"}:{label:"Ready",detail:i,tone:"ready"}}function M(e){let t=[];return e.page!==void 0&&t.push(`p. ${String(e.page)}`),e.slide!==void 0&&t.push(`slide ${String(e.slide)}`),e.headingPath&&e.headingPath.length>0&&t.push(e.headingPath.join(" \u203A ")),t.join(" \xB7 ")}function R(e){let[,t]=/^[A-Z_]+:\s*(.*)$/.exec(e)??[],n=t??e;return n.charAt(0).toUpperCase()+n.slice(1)}function W(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function C(e,t){return `/${encodeURIComponent(e)}/knowledge/${encodeURIComponent(t)}`}function G(e,t){let n=t?.trim()||(e.title??"").trim();return n||(e.recordId.length>12?`${e.recordId.slice(0,8)}\u2026`:e.recordId)}function J(e){let t=new Map;for(let n of e){let r=t.get(n.entityPlural);r||(r={entity:n.entity,entityPlural:n.entityPlural,links:[]},t.set(n.entityPlural,r)),r.links.push(n);}return [...t.values()]}function N(e,t){let n=new Set(t);return e.filter(r=>!n.has(r.id)).sort((r,o)=>+(o.status==="ready")-+(r.status==="ready"))}function h(e){return !e.startsWith("_")}function O(e,t){return e.find(n=>n.name===t)}function a(e){return e.menu?.label?.trim()||e.plural}function V(e,t){let n=new Set([...t].map(r=>r.entity));return e.filter(r=>h(r.name)&&!n.has(r.name)).sort((r,o)=>a(r).localeCompare(a(o)))}var c="flexkit-knowledge:viewMode";function D(){try{return s()?.getItem(c)==="grid"?"grid":"list"}catch{return "list"}}function v(e){try{s()?.setItem(c,e);}catch{}}
|
|
2
|
+
export{s as a,k as b,P as c,T as d,p as e,I as f,K as g,A as h,b as i,_ as j,$ as k,F as l,M as m,R as n,W as o,C as p,G as q,J as r,N as s,h as t,O as u,a as v,V as w,D as x,v as y};//# sourceMappingURL=chunk-A7XHA2P6.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-A7XHA2P6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/local-storage.ts","../src/apps/knowledge/knowledge.ts"],"names":["getLocalStorage","KNOWLEDGE_MAX_FILE_BYTES","KNOWLEDGE_MAX_TITLE_LENGTH","KNOWLEDGE_PASSAGES_PAGE_SIZE","KNOWLEDGE_EXTENSIONS","KNOWLEDGE_ACCEPT","extension","KNOWLEDGE_FORMATS_LABEL","KNOWLEDGE_EXTENSION_SET","getExtension","filename","match","getKnowledgeFileProblem","file","formatFileSize","bytes","parseKnowledgeUrl","value","trimmed","url","WEB_PAGE_FORMAT","TEXT_FORMAT","KNOWLEDGE_FORMATS","getKnowledgeFormat","source","getKnowledgeKindLabel","isKnowledgeJobActive","job","isKnowledgeSourceBusy","describeJobPhase","progress","summarizeKnowledgeStatus","version","published","passages","readyDetail","formatKnowledgeLocator","locator","parts","formatKnowledgeWarning","warning","captured","text","toggleSpaceCode","current","code","entry","getKnowledgeSourcePath","projectId","sourceId","getKnowledgeLinkLabel","link","resolved","groupKnowledgeLinks","links","groups","group","getAttachableSources","sources","attachedIds","attached","a","b","isKnowledgeLinkableEntity","entityName","findEntityByName","schema","entity","getEntityLinkLabel","getLinkableEntities","linked","taken","VIEW_MODE_STORAGE_KEY","getStoredKnowledgeViewMode","setStoredKnowledgeViewMode","mode"],"mappings":"oBAKO,SAASA,CAAAA,EAAkC,CAChD,GAAI,CACF,OAAO,OAAO,YAAA,CAAiB,GAAA,CAAc,IAAA,CAAO,YACtD,CAAA,KAAQ,CACN,OAAO,IACT,CACF,CCkKO,IAAMC,CAAAA,CAA2B,GAAK,IAAA,CAAO,IAAA,CAEvCC,CAAAA,CAA6B,GAAA,CAG7BC,CAAAA,CAA+B,EAAA,CAEtCC,EAAuB,CAAC,KAAA,CAAO,MAAA,CAAQ,MAAA,CAAQ,IAAA,CAAM,UAAA,CAAY,MAAO,MAAA,CAAQ,KAAK,CAAA,CAG9EC,CAAAA,CAAmBD,CAAAA,CAAqB,GAAA,CAAKE,GAAc,CAAA,CAAA,EAAIA,CAAS,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,GAAG,EAEpFC,CAAAA,CAA0B,+CAAA,CAEjCC,CAAAA,CAA+C,IAAI,GAAA,CAAIJ,CA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A,GAASH,CAAU,CAC3D,CAGO,SAASI,CAAAA,CAAmBD,EAA+D,CAChG,OAAOA,CAAAA,CAAO,IAAA,EAAM,KAAA,EAAO,IAAA,IAAUA,CAAAA,CAAO,MAC9C,CAOO,SAASE,CAAAA,CACdH,CAAAA,CACAI,EACK,CACL,IAAMC,CAAAA,CAAQ,IAAI,GAAA,CAAI,CAAC,GAAGD,CAAM,CAAA,CAAE,GAAA,CAAKnB,CAAAA,EAASA,CAAAA,CAAK,MAAM,CAAC,CAAA,CAE5D,OAAOe,CAAAA,CACJ,MAAA,CAAQC,CAAAA,EAAWJ,CAAAA,CAA0BI,EAAO,IAAI,CAAA,EAAK,CAACI,CAAAA,CAAM,GAAA,CAAIJ,CAAAA,CAAO,IAAI,CAAC,CAAA,CACpF,IAAA,CAAK,CAACN,CAAAA,CAAGC,CAAAA,GAAMM,EAAmBP,CAAC,CAAA,CAAE,aAAA,CAAcO,CAAAA,CAAmBN,CAAC,CAAC,CAAC,CAC9E,CAIA,IAAMU,CAAAA,CAAwB,4BAAA,CAGvB,SAASC,GAAgD,CAC9D,GAAI,CACF,OAAOzE,CAAAA,EAAgB,EAAG,QAAQwE,CAAqB,CAAA,GAAM,MAAA,CAAS,MAAA,CAAS,MACjF,CAAA,KAAQ,CACN,OAAO,MACT,CACF,CAEO,SAASE,CAAAA,CAA2BC,EAA+B,CACxE,GAAI,CACF3E,CAAAA,EAAgB,EAAG,OAAA,CAAQwE,EAAuBG,CAAI,EACxD,CAAA,KAAQ,CAER,CACF","file":"chunk-A7XHA2P6.js","sourcesContent":["/**\n * The browser's local storage, or null where there is none or touching it\n * throws (server rendering, a sandboxed frame, blocked site data). Callers\n * still wrap each read and write, since storage can fail per call.\n */\nexport function getLocalStorage(): Storage | null {\n try {\n return typeof localStorage === 'undefined' ? null : localStorage;\n } catch {\n return null;\n }\n}\n","import { getLocalStorage } from '../../core/local-storage';\n\n/**\n * Types and pure helpers of the Knowledge section: documents the team adds\n * so the agent can search and cite them. Everything here runs without React\n * so the list and detail pages stay thin and the rules are unit-tested.\n */\n\nexport type KnowledgeSourceKind = 'upload' | 'url';\n\nexport type KnowledgeSourceStatus = 'processing' | 'ready' | 'failed';\n\nexport type KnowledgeVersionStatus = 'processing' | 'published' | 'retired' | 'failed';\n\nexport type KnowledgeJobState =\n | 'queued'\n | 'extracting'\n | 'embedding'\n | 'publishing'\n | 'completed'\n | 'failed'\n | 'cancelled';\n\nexport interface KnowledgeLocator {\n page?: number;\n slide?: number;\n headingPath?: string[];\n charStart: number;\n charEnd: number;\n}\n\nexport interface KnowledgeVersion {\n id: string;\n status: KnowledgeVersionStatus;\n sha256: string | null;\n extractionVersion: number;\n passageCount: number;\n warnings: string[];\n error: string | null;\n publishedAt: string | null;\n createdAt: string;\n}\n\nexport interface KnowledgeSource {\n id: string;\n title: string;\n kind: KnowledgeSourceKind;\n originUrl: string | null;\n mimeType: string;\n path: string | null;\n size: number | null;\n sha256: string | null;\n /** Space codes that may read the source; empty means every project member. */\n spaces: string[];\n agentVisible: boolean;\n status: KnowledgeSourceStatus;\n createdBy: string | null;\n createdAt: string;\n updatedAt: string;\n /** The published version, or the newest one while the first ingestion runs. */\n currentVersion: KnowledgeVersion | null;\n /** The opening of the document's text, carried by listings for the grid's cards. */\n preview?: string | null;\n /** When the list was searched: whether the title or the content matched. */\n matchedIn?: 'title' | 'content' | null;\n}\n\nexport interface KnowledgeJobProgress {\n phase: KnowledgeJobState;\n message?: string;\n passageCount?: number;\n embeddedCount?: number;\n warnings?: string[];\n}\n\nexport interface KnowledgeJobError {\n code: string;\n message: string;\n hint?: string;\n}\n\nexport interface KnowledgeJob {\n id: string;\n sourceId: string;\n versionId: string;\n state: KnowledgeJobState;\n progress: KnowledgeJobProgress | null;\n error: KnowledgeJobError | null;\n createdAt: string;\n updatedAt: string;\n startedAt: string | null;\n completedAt: string | null;\n}\n\nexport interface KnowledgePassage {\n id: string;\n order: number;\n text: string;\n locator: KnowledgeLocator;\n}\n\nexport interface KnowledgeSourcesList {\n count: number;\n hasMore: boolean;\n sources: KnowledgeSource[];\n}\n\nexport interface KnowledgeSourceDetail {\n job: KnowledgeJob | null;\n source: KnowledgeSource;\n}\n\nexport interface KnowledgePassagesPage {\n passages: KnowledgePassage[];\n source: { id: string; title: string };\n total: number;\n version: { id: string; passageCount: number };\n}\n\n/** A record a document is attached to, as the platform lists it. */\nexport interface KnowledgeLink {\n entity: string;\n entityPlural: string;\n recordId: string;\n /** The record's display value when the platform could read it; null when the Studio must resolve it. */\n title: string | null;\n createdAt: string;\n}\n\n/** An entity type a document applies to: every record of the type inherits it. */\nexport interface KnowledgeEntityLink {\n entity: string;\n entityPlural: string;\n}\n\nexport interface KnowledgeLinksList {\n links: KnowledgeLink[];\n entities: KnowledgeEntityLink[];\n}\n\nexport interface KnowledgeRecordSources {\n /** Attached to the record itself. */\n sources: KnowledgeSource[];\n /** Attached to the record's entity type (and not to the record). */\n inherited: KnowledgeSource[];\n}\n\nexport interface KnowledgeEntitySources {\n sources: KnowledgeSource[];\n}\n\nexport interface KnowledgeRecordRef {\n entity: string;\n recordId: string;\n}\n\n/** What a document is attached to: a record, or every record of the entity when `recordId` is absent. */\nexport interface KnowledgeLinkTarget {\n entity: string;\n recordId?: string;\n}\n\nexport interface KnowledgeSourcePatch {\n agentVisible?: boolean;\n spaces?: string[];\n title?: string;\n}\n\n/** What registering a document returns: queued for indexing, or already present. */\nexport type RegisterKnowledgeSourceResult =\n | { duplicate: true; source: KnowledgeSource }\n | { duplicate?: false; job: KnowledgeJob; source: KnowledgeSource; version: KnowledgeVersion };\n\nexport const KNOWLEDGE_MAX_FILE_BYTES = 20 * 1024 * 1024;\n\nexport const KNOWLEDGE_MAX_TITLE_LENGTH = 200;\n\n/** Passages the API returns per page of a source. */\nexport const KNOWLEDGE_PASSAGES_PAGE_SIZE = 20;\n\nconst KNOWLEDGE_EXTENSIONS = ['pdf', 'docx', 'pptx', 'md', 'markdown', 'txt', 'html', 'htm'] as const;\n\n/** Value of the file input's `accept` attribute. */\nexport const KNOWLEDGE_ACCEPT = KNOWLEDGE_EXTENSIONS.map((extension) => `.${extension}`).join(',');\n\nexport const KNOWLEDGE_FORMATS_LABEL = 'PDF, Word, PowerPoint, Markdown, text or HTML';\n\nconst KNOWLEDGE_EXTENSION_SET: ReadonlySet<string> = new Set(KNOWLEDGE_EXTENSIONS);\n\nfunction getExtension(filename: string): string | null {\n const match = /\\.([a-z0-9]{1,8})$/i.exec(filename.trim());\n\n return match ? match[1]!.toLowerCase() : null;\n}\n\n/** Why a file cannot be added, or null when it can; mirrors the server rules so the user hears it before uploading. */\nexport function getKnowledgeFileProblem(file: { name: string; size: number }): string | null {\n const extension = getExtension(file.name);\n\n if (!extension || !KNOWLEDGE_EXTENSION_SET.has(extension)) {\n return `${file.name} is not a supported document. Add ${KNOWLEDGE_FORMATS_LABEL} files.`;\n }\n\n if (file.size <= 0) {\n return `${file.name} is empty.`;\n }\n\n if (file.size > KNOWLEDGE_MAX_FILE_BYTES) {\n return `${file.name} is larger than ${formatFileSize(KNOWLEDGE_MAX_FILE_BYTES)}.`;\n }\n\n return null;\n}\n\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) {\n return `${String(bytes)} B`;\n }\n\n if (bytes < 1024 * 1024) {\n return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;\n }\n\n return `${(bytes / (1024 * 1024)).toFixed(bytes < 10 * 1024 * 1024 ? 1 : 0)} MB`;\n}\n\n/** A public page address the server will accept: https, no credentials, hash dropped. */\nexport function parseKnowledgeUrl(value: string): { error: string } | { url: string } {\n const trimmed = value.trim();\n\n if (!trimmed) {\n return { error: 'Enter the address of a public page.' };\n }\n\n let url: URL;\n\n try {\n url = new URL(/^[a-z][a-z0-9+.-]*:\\/\\//i.test(trimmed) ? trimmed : `https://${trimmed}`);\n } catch {\n return { error: 'Enter a valid address, for example https://example.com/handbook' };\n }\n\n if (url.protocol !== 'https:') {\n return { error: 'The address must use HTTPS.' };\n }\n\n if (url.username || url.password) {\n return { error: 'The address cannot include credentials.' };\n }\n\n url.hash = '';\n\n return { url: url.toString() };\n}\n\n/** The Untitled UI file icon drawn for a format (see `KnowledgeTypeIcon`). */\nexport type KnowledgeFileIcon = 'pdf' | 'docx' | 'pptx' | 'document' | 'txt' | 'html';\n\nexport interface KnowledgeFormat {\n /** How people call the format: \"PDF\", \"Word\", \"Web page\". */\n label: string;\n icon: KnowledgeFileIcon;\n}\n\nconst WEB_PAGE_FORMAT: KnowledgeFormat = { icon: 'html', label: 'Web page' };\nconst TEXT_FORMAT: KnowledgeFormat = { icon: 'txt', label: 'Text' };\n\n/** The formats the platform indexes, by media type; anything else it accepts reads as text. */\nexport const KNOWLEDGE_FORMATS: { readonly [mimeType: string]: KnowledgeFormat } = {\n 'application/pdf': { icon: 'pdf', label: 'PDF' },\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': { icon: 'docx', label: 'Word' },\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation': { icon: 'pptx', label: 'PowerPoint' },\n 'text/markdown': { icon: 'document', label: 'Markdown' },\n 'text/html': { icon: 'html', label: 'HTML' },\n 'text/plain': TEXT_FORMAT,\n};\n\n/** The format of a document: a web page by its kind, else by its media type. */\nexport function getKnowledgeFormat(source: Pick<KnowledgeSource, 'kind' | 'mimeType'>): KnowledgeFormat {\n if (source.kind === 'url') {\n return WEB_PAGE_FORMAT;\n }\n\n return KNOWLEDGE_FORMATS[source.mimeType] ?? TEXT_FORMAT;\n}\n\nexport function getKnowledgeKindLabel(source: Pick<KnowledgeSource, 'kind' | 'mimeType'>): string {\n return getKnowledgeFormat(source).label;\n}\n\nexport type KnowledgeStatusTone = 'muted' | 'ready' | 'busy' | 'error';\n\nexport interface KnowledgeStatusSummary {\n /** Short badge text. */\n label: string;\n /** One line under the title. */\n detail: string;\n tone: KnowledgeStatusTone;\n}\n\nexport function isKnowledgeJobActive(job: KnowledgeJob | null | undefined): boolean {\n return Boolean(\n job &&\n (job.state === 'queued' || job.state === 'extracting' || job.state === 'embedding' || job.state === 'publishing')\n );\n}\n\n/** Whether the source changes on its own right now, so the page should poll. */\nexport function isKnowledgeSourceBusy(source: Pick<KnowledgeSource, 'status'>, job?: KnowledgeJob | null): boolean {\n return source.status === 'processing' || isKnowledgeJobActive(job);\n}\n\nfunction describeJobPhase(job: KnowledgeJob): string {\n const { progress } = job;\n\n switch (job.state) {\n case 'queued':\n return 'Waiting to be processed';\n case 'extracting':\n return 'Reading the document';\n case 'embedding': {\n if (progress?.passageCount) {\n return `Indexing passages (${String(progress.embeddedCount ?? 0)} of ${String(progress.passageCount)})`;\n }\n\n return 'Indexing passages';\n }\n case 'publishing':\n return 'Publishing';\n default:\n return progress?.message ?? job.state;\n }\n}\n\n/**\n * One status for the list row and the detail header. A source keeps serving\n * its published version while a re-index runs or fails, so the badge speaks\n * about the document, and the detail line about what is happening to it.\n */\nexport function summarizeKnowledgeStatus(source: KnowledgeSource, job?: KnowledgeJob | null): KnowledgeStatusSummary {\n const version = source.currentVersion;\n const published = version?.status === 'published';\n const passages = version?.passageCount ?? 0;\n const readyDetail = `${String(passages)} ${passages === 1 ? 'passage' : 'passages'}`;\n\n if (isKnowledgeJobActive(job)) {\n return {\n label: published ? 'Re-indexing' : 'Indexing',\n detail: describeJobPhase(job!),\n tone: 'busy',\n };\n }\n\n if (source.status === 'failed' || (!published && (job?.state === 'failed' || version?.status === 'failed'))) {\n const message = job?.error?.message ?? version?.error ?? 'Indexing failed';\n\n return { label: 'Failed', detail: message, tone: 'error' };\n }\n\n if (source.status === 'processing' || !published) {\n return { label: 'Indexing', detail: 'Waiting to be processed', tone: 'busy' };\n }\n\n if (job?.state === 'failed') {\n return {\n label: 'Ready',\n detail: `${readyDetail} · the last re-index failed: ${job.error?.message ?? 'unknown error'}`,\n tone: 'ready',\n };\n }\n\n if (version && version.warnings.length > 0) {\n return { label: 'Ready', detail: `${readyDetail} · indexed with warnings`, tone: 'ready' };\n }\n\n return { label: 'Ready', detail: readyDetail, tone: 'ready' };\n}\n\n/** Where a passage sits, the way a citation reads: \"p. 3 · Returns › Window\". */\nexport function formatKnowledgeLocator(locator: KnowledgeLocator): string {\n const parts: string[] = [];\n\n if (locator.page !== undefined) {\n parts.push(`p. ${String(locator.page)}`);\n }\n\n if (locator.slide !== undefined) {\n parts.push(`slide ${String(locator.slide)}`);\n }\n\n if (locator.headingPath && locator.headingPath.length > 0) {\n parts.push(locator.headingPath.join(' › '));\n }\n\n return parts.join(' · ');\n}\n\n/** Splits a stored warning such as \"TEXT_TRUNCATED: only the first…\" into readable text. */\nexport function formatKnowledgeWarning(warning: string): string {\n const [, captured] = /^[A-Z_]+:\\s*(.*)$/.exec(warning) ?? [];\n const text = captured ?? warning;\n\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\n/** The spaces a source will carry after toggling one; empty means every member. */\nexport function toggleSpaceCode(current: string[], code: string): string[] {\n return current.includes(code) ? current.filter((entry) => entry !== code) : [...current, code];\n}\n\n/** The document page in the Knowledge app; absolute so it works from any app. */\nexport function getKnowledgeSourcePath(projectId: string, sourceId: string): string {\n return `/${encodeURIComponent(projectId)}/knowledge/${encodeURIComponent(sourceId)}`;\n}\n\n/**\n * What a linked record is called: the label the Studio resolved from the\n * record itself, else what the platform could read, else a shortened id so\n * the row still identifies the record.\n */\nexport function getKnowledgeLinkLabel(\n link: Pick<KnowledgeLink, 'recordId' | 'title'>,\n resolved?: string | null\n): string {\n const text = resolved?.trim() || (link.title ?? '').trim();\n\n if (text) {\n return text;\n }\n\n return link.recordId.length > 12 ? `${link.recordId.slice(0, 8)}…` : link.recordId;\n}\n\nexport interface KnowledgeLinkGroup {\n entity: string;\n entityPlural: string;\n links: KnowledgeLink[];\n}\n\n/** Links grouped per entity in first-seen order, so each group resolves its labels with one query. */\nexport function groupKnowledgeLinks(links: KnowledgeLink[]): KnowledgeLinkGroup[] {\n const groups = new Map<string, KnowledgeLinkGroup>();\n\n for (const link of links) {\n let group = groups.get(link.entityPlural);\n\n if (!group) {\n group = { entity: link.entity, entityPlural: link.entityPlural, links: [] };\n groups.set(link.entityPlural, group);\n }\n\n group.links.push(link);\n }\n\n return [...groups.values()];\n}\n\n/** The documents a picker may still attach to a record: the ones not attached yet, usable ones first. */\nexport function getAttachableSources(sources: KnowledgeSource[], attachedIds: Iterable<string>): KnowledgeSource[] {\n const attached = new Set(attachedIds);\n\n return sources\n .filter((source) => !attached.has(source.id))\n .sort((a, b) => Number(b.status === 'ready') - Number(a.status === 'ready'));\n}\n\n/** Whether documents may be attached to the entity: built-in ones (assets, tags) are not something a document is about. */\nexport function isKnowledgeLinkableEntity(entityName: string): boolean {\n return !entityName.startsWith('_');\n}\n\n/** The deployed entity with this name, if the Studio knows it. */\nexport function findEntityByName<T extends { name: string }>(schema: T[], entityName: string): T | undefined {\n return schema.find((entity) => entity.name === entityName);\n}\n\n/** How an entity type is called in the Knowledge views: its sidebar label, else its plural. */\nexport function getEntityLinkLabel(entity: { menu?: { label?: string }; plural: string }): string {\n return entity.menu?.label?.trim() || entity.plural;\n}\n\n/**\n * The entity types a document can still be attached to: the project's own\n * entities (built-in ones such as assets and tags are not something a\n * document is about) minus the ones already linked, by label.\n */\nexport function getLinkableEntities<T extends { menu?: { label?: string }; name: string; plural: string }>(\n schema: T[],\n linked: Iterable<Pick<KnowledgeEntityLink, 'entity'>>\n): T[] {\n const taken = new Set([...linked].map((link) => link.entity));\n\n return schema\n .filter((entity) => isKnowledgeLinkableEntity(entity.name) && !taken.has(entity.name))\n .sort((a, b) => getEntityLinkLabel(a).localeCompare(getEntityLinkLabel(b)));\n}\n\nexport type KnowledgeViewMode = 'list' | 'grid';\n\nconst VIEW_MODE_STORAGE_KEY = 'flexkit-knowledge:viewMode';\n\n/** The list is the default; the choice is remembered per browser, like the asset manager's. */\nexport function getStoredKnowledgeViewMode(): KnowledgeViewMode {\n try {\n return getLocalStorage()?.getItem(VIEW_MODE_STORAGE_KEY) === 'grid' ? 'grid' : 'list';\n } catch {\n return 'list';\n }\n}\n\nexport function setStoredKnowledgeViewMode(mode: KnowledgeViewMode): void {\n try {\n getLocalStorage()?.setItem(VIEW_MODE_STORAGE_KEY, mode);\n } catch {\n // Private mode or blocked storage: the choice lasts for the session only.\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'./index.css';import {createContext,useReducer,useContext}from'react';import {uniqBy,props}from'ramda';import {jsx}from'react/jsx-runtime';var d=createContext([]),A=createContext(()=>{});function u(i,t){let o=t.type;switch(t._id||(t._id=Date.now().toString()),o){case "DeleteEntity":return uniqBy(props(["type","_id"]),[...i,t]);case "AddEntity":return uniqBy(props(["type","_id"]),[...i,t]);case "EditEntity":return uniqBy(props(["type","_id"]),[...i,t]);case "EditRelationship":return uniqBy(props(["type","_id"]),[...i,t]);case "AlertDialog":return uniqBy(props(["type","_id"]),[...i,t]);case "Dismiss":return i.filter(a=>a._id!==t._id);default:throw Error(`Unknown action: ${o}`)}}function l({children:i}){let[t,o]=useReducer(u,[]);return jsx(d.Provider,{value:t,children:jsx(A.Provider,{value:o,children:i})})}function D(){return useContext(d)}function h(){return useContext(A)}export{l as a,D as b,h as c};//# sourceMappingURL=chunk-BMO7JFAX.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-BMO7JFAX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/entities/actions-context.tsx"],"names":["ActionsContext","createContext","EntityDispatchContext","actionsReducer","actions","action","actionType","uniqBy","props","item","ActionsProvider","children","entityActions","dispatchEntityActions","useReducer","jsx","useActions","useContext","useDispatch"],"mappings":"iJAcA,IAAMA,CAAAA,CAAiBC,aAAAA,CAA6B,EAAE,CAAA,CAChDC,CAAAA,CAAwBD,cAAgC,IAAG,CAAA,CAAY,EAE7E,SAASE,CAAAA,CAAeC,EAAmBC,CAAAA,CAA0B,CACnE,IAAMC,CAAAA,CAAaD,CAAAA,CAAO,KAM1B,OAJKA,CAAAA,CAAO,MACVA,CAAAA,CAAO,GAAA,CAAM,KA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CAC9B,OAAOC,UAAAA,CAAWjB,CAAc,CAClC,CAEA,SAASkB,GAAgC,CACvC,OAAOD,UAAAA,CAAWf,CAAqB,CACzC","file":"chunk-BMO7JFAX.js","sourcesContent":["'use client';\n\nimport { createContext, useContext, useReducer } from 'react';\nimport type { Dispatch, JSX, ReactNode } from 'react';\nimport { props, uniqBy } from 'ramda';\nimport type {\n Action,\n ActionAddEntity,\n ActionAlertDialog,\n ActionDeleteEntity,\n ActionEditEntity,\n ActionEditRelationship,\n} from './types';\n\nconst ActionsContext = createContext<Action[] | []>([]);\nconst EntityDispatchContext = createContext<Dispatch<Action>>(() => undefined);\n\nfunction actionsReducer(actions: Action[], action: Action): Action[] {\n const actionType = action.type;\n\n if (!action._id) {\n action._id = Date.now().toString();\n }\n\n switch (actionType) {\n case 'DeleteEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionDeleteEntity[]), action]);\n }\n case 'AddEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAddEntity[]), action]);\n }\n case 'EditEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditEntity[]), action]);\n }\n case 'EditRelationship': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditRelationship[]), action]);\n }\n case 'AlertDialog': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAlertDialog[]), action]);\n }\n case 'Dismiss': {\n return actions.filter((item) => item._id !== action._id);\n }\n default: {\n throw Error(`Unknown action: ${actionType as string}`);\n }\n }\n}\n\nfunction ActionsProvider({ children }: { children: ReactNode }): JSX.Element {\n const [entityActions, dispatchEntityActions] = useReducer(actionsReducer, []);\n\n return (\n <ActionsContext.Provider value={entityActions}>\n <EntityDispatchContext.Provider value={dispatchEntityActions}>{children}</EntityDispatchContext.Provider>\n </ActionsContext.Provider>\n );\n}\n\nfunction useActions(): Action[] {\n return useContext(ActionsContext);\n}\n\nfunction useDispatch(): Dispatch<Action> {\n return useContext(EntityDispatchContext);\n}\n\nexport { ActionsProvider, useActions, useDispatch };\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {g,f as f$1}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import'./index.css';import {g,f as f$1}from'./chunk-DHVKE36X.js';import {b}from'./chunk-5CVDMZUI.js';import {a,b as b$1,c,e}from'./chunk-USNXQOMJ.js';import {b as b$2}from'./chunk-6NRQMG26.js';import {useEffect}from'react';import {BellIcon}from'lucide-react';import {Link}from'react-router-dom';import A from'swr';import {jsx,jsxs}from'react/jsx-runtime';function T(t){let{data:i}=A(t?g(t).activitySummary():null,f$1,{refreshInterval:3e4});return i}function f(t){return t>99?"99+":t.toString()}function $({projectId:t}){let i=T(t),e$1=i?.needsActionCount??0,r=i?.unreadCount??0;useEffect(()=>{let n=b();if(n)return n.setBadgeCount(e$1),()=>{n.setBadgeCount(0);}},[e$1]);let s=e$1>0?`Activity: ${f(e$1)} waiting for you`:r>0?`Activity: ${f(r)} unread`:"Activity";return jsx(a,{children:jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(b$2,{asChild:true,"aria-label":s,className:"fk:relative fk:h-8 fk:w-8 fk:rounded-full",size:"icon",variant:"ghost",children:jsxs(Link,{to:`/${t}/ai/activity`,children:[jsx(BellIcon,{className:"fk:size-4"}),e$1>0?jsx("span",{className:"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white",children:f(e$1)}):r>0?jsx("span",{className:"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success"}):null]})})}),jsx(e,{children:s})]})})}export{T as a,$ as b};//# sourceMappingURL=chunk-BMX4URYN.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-BMX4URYN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/apps/ai/activity-nav-button.tsx"],"names":["useActivitySummary","projectId","data","useSWR","paths","fetcher","formatCount","count","ActivityNavButton","summary","needsAction","unread","useEffect","desktop","getDesktop","label","jsx","TooltipProvider","jsxs","Tooltip","TooltipTrigger","Button","Link","BellIcon","TooltipContent"],"mappings":"mWAeO,SAASA,CAAAA,CAAmBC,EAA4D,CAC7F,GAAM,CAAE,IAAA,CAAAC,CAAK,EAAIC,CAAAA,CAAwBF,CAAAA,CAAYG,EAAMH,CAAS,CAAA,CAAE,iBAAgB,CAAI,IAAA,CAAMI,IAAS,CACvG,eAAA,CAAiB,GACnB,CAAC,CAAA,CAED,OAAOH,CACT,CAEA,SAASI,EAAYC,CAAAA,CAAuB,CAC1C,OAAOA,CAAAA,CAAQ,EAAA,CAAK,MAAQA,CAAAA,CAAM,QAAA,EACpC,CAGO,SAASC,EAAkB,CAAE,SAAA,CAAAP,CAAU,CAAA,CAAuC,CACnF,IAAMQ,CAAAA,CAAUT,CAAAA,CAAmBC,CAAS,CAAA,CACtCS,GAAAA,CAAcD,GAAS,gBAAA,EAAoB,CAAA,CAC3CE,EAASF,CAAAA,EAAS,WAAA,EAAe,EAGvCG,SAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAUC,GAAW,CAE3B,GAAKD,EAIL,OAAAA,CAAAA,CAAQ,cAAcH,GAAW,CAAA,CAE1B,IAAM,CACXG,CAAAA,CAAQ,aAAA,CAAc,CAAC,EACzB,CACF,EAAG,CAACH,GAAW,CAAC,CAAA,CAEhB,IAAMK,EACJL,GAAAA,CAAc,CAAA,CACV,aAAaJ,CAAAA,CAAYI,GAAW,CAAC,CAAA,gBAAA,CAAA,CACrCC,CAAAA,CAAS,EACP,CAAA,UAAA,EAAaL,CAAAA,CAAYK,CAAM,CAAC,CAAA,OAAA,CAAA,CAChC,WAER,OACEK,GAAAA,CAACC,EAAA,CACC,QAAA,CAAAC,KAACC,GAAAA,CAAA,CACC,UAAAH,GAAAA,CAACI,CAAAA,CAAA,CAAe,OAAA,CAAO,IAAA,CACrB,SAAAJ,GAAAA,CAACK,GAAAA,CAAA,CAAO,OAAA,CAAO,IAAA,CAAC,YAAA,CAAYN,CAAAA,CAAO,SAAA,CAAU,2CAAA,CAA4C,KAAK,MAAA,CAAO,OAAA,CAAQ,QAC3G,QAAA,CAAAG,IAAAA,CAACI,KAAA,CAAK,EAAA,CAAI,IAAIrB,CAAS,CAAA,YAAA,CAAA,CACrB,UAAAe,GAAAA,CAACO,QAAAA,CAAA,CAAS,SAAA,CAAU,WAAA,CAAY,EAC/Bb,GAAAA,CAAc,CAAA,CACbM,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,yMAAA,CACb,SAAAV,CAAAA,CAAYI,GAAW,EAC1B,CAAA,CACEC,CAAAA,CAAS,EACXK,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,yEAAA,CAA0E,CAAA,CACxF,MACN,CAAA,CACF,CAAA,CACF,EACAA,GAAAA,CAACQ,CAAAA,CAAA,CAAgB,QAAA,CAAAT,CAAAA,CAAM,CAAA,CAAA,CACzB,CAAA,CACF,CAEJ","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/apps/ai/activity-nav-button.tsx"],"names":["useActivitySummary","projectId","data","useSWR","paths","fetcher","formatCount","count","ActivityNavButton","summary","needsAction","unread","useEffect","desktop","getDesktop","label","jsx","TooltipProvider","jsxs","Tooltip","TooltipTrigger","Button","Link","BellIcon","TooltipContent"],"mappings":"mWAeO,SAASA,CAAAA,CAAmBC,EAA4D,CAC7F,GAAM,CAAE,IAAA,CAAAC,CAAK,EAAIC,CAAAA,CAAwBF,CAAAA,CAAYG,EAAMH,CAAS,CAAA,CAAE,iBAAgB,CAAI,IAAA,CAAMI,IAAS,CACvG,eAAA,CAAiB,GACnB,CAAC,CAAA,CAED,OAAOH,CACT,CAEA,SAASI,EAAYC,CAAAA,CAAuB,CAC1C,OAAOA,CAAAA,CAAQ,EAAA,CAAK,MAAQA,CAAAA,CAAM,Q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AC,MAAA,CAAA,CAAK,UAAU,yEAAA,CAA0E,CAAA,CACxF,MACN,CAAA,CACF,CAAA,CACF,EACAA,GAAAA,CAACQ,CAAAA,CAAA,CAAgB,QAAA,CAAAT,CAAAA,CAAM,CAAA,CAAA,CACzB,CAAA,CACF,CAEJ","file":"chunk-BMX4URYN.js","sourcesContent":["import { useEffect } from 'react';\nimport type { JSX } from 'react';\nimport { BellIcon } from 'lucide-react';\nimport { Link } from 'react-router-dom';\nimport useSWR from 'swr';\nimport { Button } from '../../ui/primitives/button';\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/primitives/tooltip';\nimport { getDesktop } from '../../core/desktop';\nimport { fetcher, paths } from './api';\nimport type { ActivitySummary } from './types';\n\n/**\n * The project's Activity badge counts. `ActivityNotifier` refreshes the same\n * SWR key on every poll, so every reader stays in sync with one request.\n */\nexport function useActivitySummary(projectId: string | undefined): ActivitySummary | undefined {\n const { data } = useSWR<ActivitySummary>(projectId ? paths(projectId).activitySummary() : null, fetcher, {\n refreshInterval: 30_000,\n });\n\n return data;\n}\n\nfunction formatCount(count: number): string {\n return count > 99 ? '99+' : count.toString();\n}\n\n/** Navbar shortcut to Activity, so pending items are visible from every app. */\nexport function ActivityNavButton({ projectId }: { projectId: string }): JSX.Element {\n const summary = useActivitySummary(projectId);\n const needsAction = summary?.needsActionCount ?? 0;\n const unread = summary?.unreadCount ?? 0;\n // The desktop app shows what waits for you on its dock or taskbar icon;\n // leaving the project or signing out clears it.\n useEffect(() => {\n const desktop = getDesktop();\n\n if (!desktop) {\n return;\n }\n\n desktop.setBadgeCount(needsAction);\n\n return () => {\n desktop.setBadgeCount(0);\n };\n }, [needsAction]);\n\n const label =\n needsAction > 0\n ? `Activity: ${formatCount(needsAction)} waiting for you`\n : unread > 0\n ? `Activity: ${formatCount(unread)} unread`\n : 'Activity';\n\n return (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button asChild aria-label={label} className=\"fk:relative fk:h-8 fk:w-8 fk:rounded-full\" size=\"icon\" variant=\"ghost\">\n <Link to={`/${projectId}/ai/activity`}>\n <BellIcon className=\"fk:size-4\" />\n {needsAction > 0 ? (\n <span className=\"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white\">\n {formatCount(needsAction)}\n </span>\n ) : unread > 0 ? (\n <span className=\"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success\" />\n ) : null}\n </Link>\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'./index.css';import {useRef,useState}from'react';import {jsxs,jsx}from'react/jsx-runtime';function t(n){return Array.from(n.dataTransfer.types).includes("Files")}function E({children:n,disabled:a=false,onDropFiles:l}){let r=useRef(0),[s,o]=useState(false);function d(){r.current=0,o(false);}function u(e){t(e)&&(e.preventDefault(),e.stopPropagation(),r.current+=1,a||o(true));}function c(e){t(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=a?"none":"copy");}function p(e){t(e)&&(e.preventDefault(),e.stopPropagation(),r.current=Math.max(0,r.current-1),r.current===0&&o(false));}function D(e){if(!t(e)||(e.preventDefault(),e.stopPropagation(),d(),a))return;let i=Array.from(e.dataTransfer.files);i.length!==0&&l(i);}return jsxs("div",{className:"fk:relative fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",onDragEnter:u,onDragLeave:p,onDragOver:c,onDrop:D,children:[jsx("div",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:n}),s?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:z-30 fk:flex fk:items-center fk:justify-center fk:rounded-md fk:border-2 fk:border-dashed fk:border-primary fk:bg-background/80 fk:corner-squircle",children:jsx("p",{className:"fk:text-sm fk:font-medium fk:text-foreground",children:"Drop files to upload"})}):null]})}export{E as a};//# sourceMappingURL=chunk-CLCIE5RF.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-CLCIE5RF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/apps/asset-manager/data-grid/asset-drop-zone.tsx"],"names":["hasFileDrag","event","AssetDropZone","children","disabled","onDropFiles","dragDepthRef","useRef","isDragActive","setIsDragActive","useState","clearDragState","handleDragEnter","handleDragOver","handleDragLeave","handleDrop","files","jsxs","jsx"],"mappings":"iGAQA,SAASA,CAAAA,CAAYC,EAA2C,CAC9D,OAAO,MAAM,IAAA,CAAKA,CAAAA,CAAM,YAAA,CAAa,KAAK,CAAA,CAAE,QAAA,CAAS,OAAO,CAC9D,CAEO,SAASC,CAAAA,CAAc,CAAE,SAAAC,CAAAA,CAAU,QAAA,CAAAC,CAAAA,CAAW,KAAA,CAAO,WAAA,CAAAC,CAAY,EAAoC,CAC1G,IAAMC,EAAeC,MAAAA,CAAO,CAAC,EACvB,CAACC,CAAAA,CAAcC,CAAe,CAAA,CAAIC,QAAAA,CAAS,KAAK,EAEtD,SAASC,CAAAA,EAAuB,CAC9BL,CAAAA,CAAa,OAAA,CAAU,EACvBG,CAAAA,CAAgB,KAAK,EACvB,CAEA,SAASG,EAAgBX,CAAAA,CAAwC,CAC1DD,EAAYC,CAAK,CAAA,GAItBA,EAAM,cAAA,EAAe,CACrBA,CAAAA,CAAM,eAAA,EAAgB,CACtBK,CAAAA,CAAa,SAAW,CAAA,CAEnBF,CAAAA,EACHK,EAAgB,IAAI,CAAA,EAExB,CAEA,SAASI,CAAAA,CAAeZ,CAAAA,CAAwC,CACzDD,CAAAA,CAAYC,CAAK,IAItBA,CAAAA,CAAM,cAAA,GACNA,CAAAA,CAAM,eAAA,GACNA,CAAAA,CAAM,YAAA,CAAa,UAAA,CAAaG,CAAAA,CAAW,MAAA,CAAS,MAAA,EACtD,CAEA,SAASU,CAAAA,CAAgBb,EAAwC,CAC1DD,CAAAA,CAAYC,CAAK,CAAA,GAItBA,CAAAA,CAAM,gBAAe,CACrBA,CAAAA,CAAM,iBAAgB,CACtBK,CAAAA,CAAa,QAAU,IAAA,CAAK,GAAA,CAAI,EAAGA,CAAAA,CAAa,OAAA,CAAU,CAAC,CAAA,CAEvDA,CAAAA,CAAa,OAAA,GAAY,GAC3BG,CAAAA,CAAgB,KAAK,GAEzB,CAEA,SAASM,EAAWd,CAAAA,CAAwC,CAS1D,GARI,CAACD,CAAAA,CAAYC,CAAK,IAItBA,CAAAA,CAAM,cAAA,GACNA,CAAAA,CAAM,eAAA,GACNU,CAAAA,EAAe,CAEXP,CAAAA,CAAAA,CACF,OAGF,IAAMY,CAAAA,CAAQ,MAAM,IAAA,CAAKf,CAAAA,CAAM,aAAa,KAAK,CAAA,CAE7Ce,EAAM,MAAA,GAAW,CAAA,EAIrBX,CAAAA,CAAYW,CAAK,EACnB,CAEA,OACEC,IAAAA,CAAC,KAAA,CAAA,CACC,UAAU,sDAAA,CACV,WAAA,CAAaL,EACb,WAAA,CAAaE,CAAAA,CACb,UAAA,CAAYD,CAAAA,CACZ,MAAA,CAAQE,CAAAA,CAER,UAAAG,GAAAA,CAAC,KAAA,CAAA,CAAI,UAAU,0CAAA,CAA4C,QAAA,CAAAf,EAAS,CAAA,CACnEK,CAAAA,CACCU,GAAAA,CAAC,KAAA,CAAA,CACC,aAAA,CAAW,IAAA,CACX,UAAU,qMAAA,CAEV,QAAA,CAAAA,IAAC,GAAA,CAAA,CAAE,SAAA,CAAU,+CAA+C,QAAA,CAAA,sBAAA,CAAoB,CAAA,CAClF,CAAA,CACE,IAAA,CAAA,CACN,CAEJ","file":"chunk-CLCIE5RF.js","sourcesContent":["import { useRef, useState, type DragEvent, type JSX, type ReactNode } from 'react';\n\ninterface AssetDropZoneProps {\n children: ReactNode;\n disabled?: boolean;\n onDropFiles: (files: File[]) => void;\n}\n\nfunction hasFileDrag(event: DragEvent<HTMLDivElement>): boolean {\n return Array.from(event.dataTransfer.types).includes('Files');\n}\n\nexport function AssetDropZone({ children, disabled = false, onDropFiles }: AssetDropZoneProps): JSX.Element {\n const dragDepthRef = useRef(0);\n const [isDragActive, setIsDragActive] = useState(false);\n\n function clearDragState(): void {\n dragDepthRef.current = 0;\n setIsDragActive(false);\n }\n\n function handleDragEnter(event: DragEvent<HTMLDivElement>): void {\n if (!hasFileDrag(event)) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n dragDepthRef.current += 1;\n\n if (!disabled) {\n setIsDragActive(true);\n }\n }\n\n function handleDragOver(event: DragEvent<HTMLDivElement>): void {\n if (!hasFileDrag(event)) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n event.dataTransfer.dropEffect = disabled ? 'none' : 'copy';\n }\n\n function handleDragLeave(event: DragEvent<HTMLDivElement>): void {\n if (!hasFileDrag(event)) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);\n\n if (dragDepthRef.current === 0) {\n setIsDragActive(false);\n }\n }\n\n function handleDrop(event: DragEvent<HTMLDivElement>): void {\n if (!hasFileDrag(event)) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n clearDragState();\n\n if (disabled) {\n return;\n }\n\n const files = Array.from(event.dataTransfer.files);\n\n if (files.length === 0) {\n return;\n }\n\n onDropFiles(files);\n }\n\n return (\n <div\n className=\"fk:relative fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\"\n onDragEnter={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n >\n <div className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">{children}</div>\n {isDragActive ? (\n <div\n aria-hidden\n className=\"fk:pointer-events-none fk:absolute fk:inset-0 fk:z-30 fk:flex fk:items-center fk:justify-center fk:rounded-md fk:border-2 fk:border-dashed fk:border-primary fk:bg-background/80 fk:corner-squircle\"\n >\n <p className=\"fk:text-sm fk:font-medium fk:text-foreground\">Drop files to upload</p>\n </div>\n ) : null}\n </div>\n );\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {x}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import'./index.css';import {x}from'./chunk-6RRB47OZ.js';import {g,f}from'./chunk-DHVKE36X.js';import {s}from'./chunk-DGIY4SKN.js';import {e,g as g$1,h,j}from'./chunk-SZEGGBOC.js';import {c,h as h$1,i,k,j as j$1}from'./chunk-32ZU4MLE.js';import {b}from'./chunk-6NRQMG26.js';import {useState,useEffect,useMemo,useTransition}from'react';import {LoaderCircle,MessageSquareIcon,MoreHorizontalIcon,PencilIcon,Trash2Icon}from'lucide-react';import {useLocation,useNavigate}from'react-router-dom';import H,{useSWRConfig}from'swr';import U from'swr/infinite';import {jsx,jsxs}from'react/jsx-runtime';function ue(){let a=useLocation(),n="/agent",t=a.pathname.indexOf(n);return t===-1?`${a.pathname.replace(/\/$/,"")}/agent`:a.pathname.slice(0,t+n.length)}function de(a,n){let[t,o]=useState(a);return useEffect(()=>{let f=window.setTimeout(()=>{o(a);},n);return ()=>{window.clearTimeout(f);}},[n,a]),t}function Z(a){let n=new Date(a.lastMessageAt??a.updatedAt).getTime(),t=new Date,o=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime();return n>=o?"Today":n>=o-864e5?"Yesterday":n>=o-7*864e5?"Previous 7 days":"Older"}function ee(a){let n=[];for(let t of a){let o=Z(t),f=n.find(u=>u.label===o);f?f.chats.push(t):n.push({chats:[t],label:o});}return n}function te({active:a,api:n,chat:t,onChanged:o,onDeleted:f,onOpen:u}){let[r,l]=useState(null),[g,d]=useState(t.title??""),[p,D]=useTransition(),k$1=t.title?.trim()||"New chat";function v(){D(async()=>{await n.renameAgentChat(t.id,g.trim()),l(null),o();});}function y(){D(async()=>{await n.deleteAgentChat(t.id),l(null),f();});}return jsxs("div",{className:`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${a?"fk:bg-sidebar-accent":"fk:hover:bg-accent/60"} fk:corner-squircle`,children:[jsx("button",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm",title:k$1,type:"button",onClick:u,children:k$1}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsx(b,{className:"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100",size:"icon",variant:"ghost",children:jsx(MoreHorizontalIcon,{className:"fk:size-4"})})}),jsxs(h,{align:"start",children:[jsxs(j,{onClick:()=>{d(t.title??""),l("rename");},children:[jsx(PencilIcon,{className:"fk:size-4"}),"Rename"]}),jsxs(j,{className:"fk:text-destructive",onClick:()=>l("delete"),children:[jsx(Trash2Icon,{className:"fk:size-4"}),"Delete"]})]})]}),jsx(c,{open:r==="rename",onOpenChange:m=>l(m?"rename":null),children:jsxs(h$1,{className:"fk:max-w-sm",children:[jsx(i,{children:jsx(k,{children:"Rename chat"})}),jsx(s,{value:g,onChange:m=>d(m.target.value),placeholder:"Chat title"}),jsx(j$1,{children:jsx(b,{disabled:p||!g.trim(),size:"sm",onClick:v,children:p?"Saving...":"Save"})})]})}),jsx(c,{open:r==="delete",onOpenChange:m=>l(m?"delete":null),children:jsxs(h$1,{className:"fk:max-w-sm",children:[jsx(i,{children:jsx(k,{children:"Delete chat?"})}),jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["\u201C",k$1,"\u201D and its messages will be permanently deleted."]}),jsx(j$1,{children:jsx(b,{disabled:p,size:"sm",variant:"destructive",onClick:y,children:p?"Deleting...":"Delete"})})]})})]})}function ne({onOpen:a,projectId:n,query:t}){let{data:o,isLoading:f$1}=H(g(n).agentChatSearch(t),f,{keepPreviousData:true});return f$1&&!o?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),"Searching..."]}):o?.results.length?jsx("div",{className:"fk:space-y-1",children:o.results.map(u=>jsxs("button",{className:"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle",type:"button",onClick:()=>a(u.chatId),children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm",children:u.chatTitle?.trim()||"New chat"}),jsx("span",{className:"fk:block fk:truncate fk:text-xs fk:text-muted-foreground",children:u.snippet})]},u.messageId))}):jsx("p",{className:"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:"No matching chats."})}function me({query:a}){let{api:n,projectId:t}=x(),o=useNavigate(),f$1=useLocation(),{mutate:u}=useSWRConfig(),r=/\/agent\/chats\/([^/]+)/.exec(f$1.pathname)?.[1],{data:l,isLoading:g$1,mutate:d,setSize:p,size:D}=U((s,c)=>!t||c&&!c.hasMore?null:g(t).agentChats(s*30),f,{revalidateFirstPage:true}),{data:k}=H(t&&r?g(t).agentChat(r):null,f),v=useMemo(()=>{let s=(l??[]).flatMap(h=>h.chats),c=k?.chat.title?.trim();return !r||!c?s:s.map(h=>h.id!==r||h.title?.trim()?h:{...h,title:c})},[k?.chat.title,r,l]),y=l?.[l.length-1]?.hasMore??false,m=useMemo(()=>ee(v),[v]);if(useEffect(()=>{d();},[r,d]),!t||!n)return null;let J=n,z=t;function L(s){o(`agent/chats/${s}`);}function X(s){d(),s===r?o("agent"):u(g(z).agentChat(s),void 0,{revalidate:false});}return jsx("div",{className:"fk:space-y-2",children:a?jsx(ne,{projectId:z,query:a,onOpen:L}):jsxs("div",{className:"fk:space-y-3",children:[m.map(s=>jsxs("div",{children:[jsx("p",{className:"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:s.label}),jsx("div",{className:"fk:space-y-0.5",children:s.chats.map(c=>jsx(te,{active:c.id===r,api:J,chat:c,onChanged:()=>{d();},onDeleted:()=>X(c.id),onOpen:()=>L(c.id)},c.id))})]},s.label)),g$1?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),"Loading recent chats..."]}):null,!g$1&&v.length===0?jsxs("div",{className:"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground",children:[jsx(MessageSquareIcon,{className:"fk:size-5"}),jsx("span",{children:"No chats yet. Start a conversation with the agent."})]}):null,y?jsx(b,{className:"fk:w-full",size:"sm",variant:"ghost",onClick:()=>{p(D+1);},children:"Load more"}):null]})})}export{ue as a,de as b,me as c};//# sourceMappingURL=chunk-DFLAX7EE.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-DFLAX7EE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/apps/ai/agent/chat-list.tsx"],"names":["useAgentBasePath","location","useLocation","marker","index","useDebouncedValue","value","delayMs","debounced","setDebounced","useState","useEffect","timeout","getChatGroupLabel","chat","timestamp","now","startOfToday","groupChats","chats","groups","label","group","candidate","ChatListItem","active","api","onChanged","onDeleted","onOpen","dialog","setDialog","title","setTitle","isMutating","startMutation","useTransition","handleRename","handleDelete","jsxs","jsx","DropdownMenu","DropdownMenuTrigger","Button","MoreHorizontalIcon","DropdownMenuContent","DropdownMenuItem","PencilIcon","Trash2Icon","Dialog","open","DialogContent","DialogHeader","DialogTitle","Input","event","DialogFooter","SearchResults","projectId","query","data","isLoading","useSWR","paths","fetcher","LoaderCircle","result","AgentChatsSection","useProjectApi","navigate","useNavigate","globalMutate","useSWRConfig","activeChatId","mutate","setSize","size","useSWRInfinite","pageIndex","previousPage","activeChatDetail","useMemo","listed","page","generatedTitle","hasMore","chatApi","chatProjectId","openChat","chatId","handleDeleted","MessageSquareIcon"],"mappings":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AAA,CACN,CAAA,CAEJ,CAEJ","file":"chunk-RYKUNA7Z.js","sourcesContent":["import type { JSX } from 'react';\nimport { useEffect, useMemo, useState, useTransition } from 'react';\nimport { LoaderCircle, MessageSquareIcon, MoreHorizontalIcon, PencilIcon, Trash2Icon } from 'lucide-react';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport useSWR, { useSWRConfig } from 'swr';\nimport useSWRInfinite from 'swr/infinite';\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n Input,\n} from '../../../ui';\nimport { fetcher, paths, type ApiClient } from '../api';\nimport { useProjectApi } from '../replay';\nimport type { AgentChat, AgentChatDetail, AgentChatSearchResult, AgentChatsList } from '../types';\n\n/** Returns the absolute route prefix of the agent app (`.../ai/agent`). */\nexport function useAgentBasePath(): string {\n const location = useLocation();\n const marker = '/agent';\n const index = location.pathname.indexOf(marker);\n\n if (index === -1) {\n return `${location.pathname.replace(/\\/$/, '')}/agent`;\n }\n\n return location.pathname.slice(0, index + marker.length);\n}\n\nexport function useDebouncedValue(value: string, delayMs: number): string {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => {\n setDebounced(value);\n }, delayMs);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [delayMs, value]);\n\n return debounced;\n}\n\nfunction getChatGroupLabel(chat: AgentChat): string {\n const timestamp = new Date(chat.lastMessageAt ?? chat.updatedAt).getTime();\n const now = new Date();\n const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();\n\n if (timestamp >= startOfToday) {\n return 'Today';\n }\n\n if (timestamp >= startOfToday - 86_400_000) {\n return 'Yesterday';\n }\n\n if (timestamp >= startOfToday - 7 * 86_400_000) {\n return 'Previous 7 days';\n }\n\n return 'Older';\n}\n\nfunction groupChats(chats: AgentChat[]): { chats: AgentChat[]; label: string }[] {\n const groups: { chats: AgentChat[]; label: string }[] = [];\n\n for (const chat of chats) {\n const label = getChatGroupLabel(chat);\n const group = groups.find((candidate) => candidate.label === label);\n\n if (group) {\n group.chats.push(chat);\n } else {\n groups.push({ chats: [chat], label });\n }\n }\n\n return groups;\n}\n\nfunction ChatListItem({\n active,\n api,\n chat,\n onChanged,\n onDeleted,\n onOpen,\n}: {\n active: boolean;\n api: ApiClient;\n chat: AgentChat;\n onChanged: () => void;\n onDeleted: () => void;\n onOpen: () => void;\n}): JSX.Element {\n const [dialog, setDialog] = useState<'rename' | 'delete' | null>(null);\n const [title, setTitle] = useState(chat.title ?? '');\n const [isMutating, startMutation] = useTransition();\n const label = chat.title?.trim() || 'New chat';\n\n function handleRename(): void {\n startMutation(async () => {\n await api.renameAgentChat(chat.id, title.trim());\n setDialog(null);\n onChanged();\n });\n }\n\n function handleDelete(): void {\n startMutation(async () => {\n await api.deleteAgentChat(chat.id);\n setDialog(null);\n onDeleted();\n });\n }\n\n return (\n <div\n className={`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${\n active ? 'fk:bg-sidebar-accent' : 'fk:hover:bg-accent/60'\n } fk:corner-squircle`}\n >\n <button\n className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm\"\n title={label}\n type=\"button\"\n onClick={onOpen}\n >\n {label}\n </button>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n className=\"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100\"\n size=\"icon\"\n variant=\"ghost\"\n >\n <MoreHorizontalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\">\n <DropdownMenuItem\n onClick={() => {\n setTitle(chat.title ?? '');\n setDialog('rename');\n }}\n >\n <PencilIcon className=\"fk:size-4\" />\n Rename\n </DropdownMenuItem>\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={() => setDialog('delete')}>\n <Trash2Icon className=\"fk:size-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n <Dialog open={dialog === 'rename'} onOpenChange={(open) => setDialog(open ? 'rename' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Rename chat</DialogTitle>\n </DialogHeader>\n <Input value={title} onChange={(event) => setTitle(event.target.value)} placeholder=\"Chat title\" />\n <DialogFooter>\n <Button disabled={isMutating || !title.trim()} size=\"sm\" onClick={handleRename}>\n {isMutating ? 'Saving...' : 'Save'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n <Dialog open={dialog === 'delete'} onOpenChange={(open) => setDialog(open ? 'delete' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Delete chat?</DialogTitle>\n </DialogHeader>\n <p className=\"fk:text-sm fk:text-muted-foreground\">\n “{label}” and its messages will be permanently deleted.\n </p>\n <DialogFooter>\n <Button disabled={isMutating} size=\"sm\" variant=\"destructive\" onClick={handleDelete}>\n {isMutating ? 'Deleting...' : 'Delete'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n}\n\nfunction SearchResults({\n onOpen,\n projectId,\n query,\n}: {\n onOpen: (_chatId: string) => void;\n projectId: string;\n query: string;\n}): JSX.Element {\n const { data, isLoading } = useSWR<{ results: AgentChatSearchResult[] }>(\n paths(projectId).agentChatSearch(query),\n fetcher,\n { keepPreviousData: true }\n );\n\n if (isLoading && !data) {\n return (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Searching...\n </div>\n );\n }\n\n if (!data?.results.length) {\n return <p className=\"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">No matching chats.</p>;\n }\n\n return (\n <div className=\"fk:space-y-1\">\n {data.results.map((result) => (\n <button\n className=\"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle\"\n key={result.messageId}\n type=\"button\"\n onClick={() => onOpen(result.chatId)}\n >\n <span className=\"fk:block fk:truncate fk:text-sm\">{result.chatTitle?.trim() || 'New chat'}</span>\n <span className=\"fk:block fk:truncate fk:text-xs fk:text-muted-foreground\">{result.snippet}</span>\n </button>\n ))}\n </div>\n );\n}\n\n/**\n * ChatGPT-style chats section embedded in the AI sidebar: new chat button and\n * the user's recent chats grouped by date with rename/delete. When `query` is\n * set, the recent list is replaced by hybrid keyword + semantic search results.\n * Rendered inside the app layout route, so relative navigation resolves\n * against the app root (`agent`, `agent/chats/:chatId`).\n */\nexport function AgentChatsSection({ query }: { query: string }): JSX.Element | null {\n const { api, projectId } = useProjectApi();\n const navigate = useNavigate();\n const location = useLocation();\n const { mutate: globalMutate } = useSWRConfig();\n const activeChatId = /\\/agent\\/chats\\/([^/]+)/.exec(location.pathname)?.[1];\n const { data, isLoading, mutate, setSize, size } = useSWRInfinite<AgentChatsList>(\n (pageIndex, previousPage: AgentChatsList | null) => {\n if (!projectId || (previousPage && !previousPage.hasMore)) {\n return null;\n }\n\n return paths(projectId).agentChats(pageIndex * 30);\n },\n fetcher,\n { revalidateFirstPage: true }\n );\n const { data: activeChatDetail } = useSWR<AgentChatDetail>(\n projectId && activeChatId ? paths(projectId).agentChat(activeChatId) : null,\n fetcher\n );\n const chats = useMemo(() => {\n const listed = (data ?? []).flatMap((page) => page.chats);\n const generatedTitle = activeChatDetail?.chat.title?.trim();\n\n if (!activeChatId || !generatedTitle) {\n return listed;\n }\n\n return listed.map((chat) => {\n if (chat.id !== activeChatId || chat.title?.trim()) {\n return chat;\n }\n\n return { ...chat, title: generatedTitle };\n });\n }, [activeChatDetail?.chat.title, activeChatId, data]);\n const hasMore = data?.[data.length - 1]?.hasMore ?? false;\n const groups = useMemo(() => groupChats(chats), [chats]);\n\n // Refresh the list when the user lands on a chat (new chats, fresh titles).\n useEffect(() => {\n void mutate();\n }, [activeChatId, mutate]);\n\n if (!projectId || !api) {\n return null;\n }\n\n const chatApi = api;\n const chatProjectId = projectId;\n\n function openChat(chatId: string): void {\n navigate(`agent/chats/${chatId}`);\n }\n\n function handleDeleted(chatId: string): void {\n void mutate();\n\n if (chatId === activeChatId) {\n navigate('agent');\n } else {\n // Drop the cached detail so a re-open does not show stale data.\n void globalMutate(paths(chatProjectId).agentChat(chatId), undefined, { revalidate: false });\n }\n }\n\n return (\n <div className=\"fk:space-y-2\">\n {query ? (\n <SearchResults projectId={chatProjectId} query={query} onOpen={openChat} />\n ) : (\n <div className=\"fk:space-y-3\">\n {groups.map((group) => (\n <div key={group.label}>\n <p className=\"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground\">{group.label}</p>\n <div className=\"fk:space-y-0.5\">\n {group.chats.map((chat) => (\n <ChatListItem\n active={chat.id === activeChatId}\n api={chatApi}\n chat={chat}\n key={chat.id}\n onChanged={() => void mutate()}\n onDeleted={() => handleDeleted(chat.id)}\n onOpen={() => openChat(chat.id)}\n />\n ))}\n </div>\n </div>\n ))}\n {isLoading ? (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Loading recent chats...\n </div>\n ) : null}\n {!isLoading && chats.length === 0 ? (\n <div className=\"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground\">\n <MessageSquareIcon className=\"fk:size-5\" />\n <span>No chats yet. Start a conversation with the agent.</span>\n </div>\n ) : null}\n {hasMore ? (\n <Button className=\"fk:w-full\" size=\"sm\" variant=\"ghost\" onClick={() => void setSize(size + 1)}>\n Load more\n </Button>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/apps/ai/agent/chat-list.tsx"],"names":["useAgentBasePath","location","useLocation","marker","index","useDebouncedValue","value","delayMs","debounced","setDebounced","useState","useEffect","timeout","getChatGroupLabel","chat","timestamp","now","startOfToday","groupChats","chats","groups","label","group","candidate","ChatListItem","active","api","onChanged","onDeleted","onOpen","dialog","setDialog","title","setTitle","isMutating","startMutation","useTransition","handleRename","handleDelete","jsxs","jsx","DropdownMenu","DropdownMenuTrigger","Button","MoreHorizontalIcon","DropdownMenuContent","DropdownMenuItem","PencilIcon","Trash2Icon","Dialog","open","DialogContent","DialogHeader","DialogTitle","Input","event","DialogFooter","SearchResults","projectId","query","data","isLoading","useSWR","paths","fetcher","LoaderCircle","result","AgentChatsSection","useProjectApi","navigate","useNavigate","globalMutate","useSWRConfig","activeChatId","mutate","setSize","size","useSWRInfinite","pageIndex","previousPage","activeChatDetail","useMemo","listed","page","generatedTitle","hasMore","chatApi","chatProjectId","openChat","chatId","handleDeleted","MessageSquareIcon"],"mappings":"8kBAwBO,SAASA,EAAAA,EAA2B,CACzC,IAAMC,CAAAA,CAAWC,WAAAA,EAAY,CACvBC,CAAAA,CAAS,QAAA,CACTC,CAAAA,CAAQH,CAAAA,CAAS,QAAA,CAAS,OAAA,CAAQE,CAAM,CAAA,CAE9C,OAAIC,CAAAA,GAAU,EAAA,CACL,CAAA,EAAGH,CAAAA,CAAS,SAAS,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,MAAA,CAAA,CAGzCA,CAAAA,CAAS,QAAA,CAAS,KAAA,CAAM,CAAA,CAAGG,CAAAA,CAAQD,CAAAA,CAAO,MAAM,CACzD,CAEO,SAASE,EAAAA,CAAkBC,CAAAA,CAAeC,CAAAA,CAAyB,CACxE,GAAM,CAACC,CAAAA,CAAWC,CAAY,CAAA,CAAIC,QAAAA,CAASJ,CAAK,CAAA,CAEhD,OAAAK,SAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAU,MAAA,CAAO,UAAA,CAAW,IAAM,CAC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CAAA,CAAE,yBAAA,CAAA,CAE1D,CAAA,CACE,IAAA,CACH,CAACJ,GAAAA,EAAa1C,CAAAA,CAAM,MAAA,GAAW,CAAA,CAC9BoB,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,iHAAA,CACb,QAAA,CAAA,CAAAC,GAAAA,CAACmD,iBAAAA,CAAA,CAAkB,SAAA,CAAU,WAAA,CAAY,CAAA,CACzCnD,GAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,oDAAA,CAAkD,CAAA,CAAA,CAC1D,CAAA,CACE,IAAA,CACH6C,CAAAA,CACC7C,GAAAA,CAACG,CAAAA,CAAA,CAAO,SAAA,CAAU,WAAA,CAAY,IAAA,CAAK,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAS,IAAG,CAAQgC,CAAAA,CAAQC,CAAAA,CAAO,CAAC,EAAA,CAAA,CAAG,QAAA,CAAA,WAAA,CAE/F,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CAEJ,CAEJ","file":"chunk-DFLAX7EE.js","sourcesContent":["import type { JSX } from 'react';\nimport { useEffect, useMemo, useState, useTransition } from 'react';\nimport { LoaderCircle, MessageSquareIcon, MoreHorizontalIcon, PencilIcon, Trash2Icon } from 'lucide-react';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport useSWR, { useSWRConfig } from 'swr';\nimport useSWRInfinite from 'swr/infinite';\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n Input,\n} from '../../../ui';\nimport { fetcher, paths, type ApiClient } from '../api';\nimport { useProjectApi } from '../replay';\nimport type { AgentChat, AgentChatDetail, AgentChatSearchResult, AgentChatsList } from '../types';\n\n/** Returns the absolute route prefix of the agent app (`.../ai/agent`). */\nexport function useAgentBasePath(): string {\n const location = useLocation();\n const marker = '/agent';\n const index = location.pathname.indexOf(marker);\n\n if (index === -1) {\n return `${location.pathname.replace(/\\/$/, '')}/agent`;\n }\n\n return location.pathname.slice(0, index + marker.length);\n}\n\nexport function useDebouncedValue(value: string, delayMs: number): string {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => {\n setDebounced(value);\n }, delayMs);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [delayMs, value]);\n\n return debounced;\n}\n\nfunction getChatGroupLabel(chat: AgentChat): string {\n const timestamp = new Date(chat.lastMessageAt ?? chat.updatedAt).getTime();\n const now = new Date();\n const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();\n\n if (timestamp >= startOfToday) {\n return 'Today';\n }\n\n if (timestamp >= startOfToday - 86_400_000) {\n return 'Yesterday';\n }\n\n if (timestamp >= startOfToday - 7 * 86_400_000) {\n return 'Previous 7 days';\n }\n\n return 'Older';\n}\n\nfunction groupChats(chats: AgentChat[]): { chats: AgentChat[]; label: string }[] {\n const groups: { chats: AgentChat[]; label: string }[] = [];\n\n for (const chat of chats) {\n const label = getChatGroupLabel(chat);\n const group = groups.find((candidate) => candidate.label === label);\n\n if (group) {\n group.chats.push(chat);\n } else {\n groups.push({ chats: [chat], label });\n }\n }\n\n return groups;\n}\n\nfunction ChatListItem({\n active,\n api,\n chat,\n onChanged,\n onDeleted,\n onOpen,\n}: {\n active: boolean;\n api: ApiClient;\n chat: AgentChat;\n onChanged: () => void;\n onDeleted: () => void;\n onOpen: () => void;\n}): JSX.Element {\n const [dialog, setDialog] = useState<'rename' | 'delete' | null>(null);\n const [title, setTitle] = useState(chat.title ?? '');\n const [isMutating, startMutation] = useTransition();\n const label = chat.title?.trim() || 'New chat';\n\n function handleRename(): void {\n startMutation(async () => {\n await api.renameAgentChat(chat.id, title.trim());\n setDialog(null);\n onChanged();\n });\n }\n\n function handleDelete(): void {\n startMutation(async () => {\n await api.deleteAgentChat(chat.id);\n setDialog(null);\n onDeleted();\n });\n }\n\n return (\n <div\n className={`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${\n active ? 'fk:bg-sidebar-accent' : 'fk:hover:bg-accent/60'\n } fk:corner-squircle`}\n >\n <button\n className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm\"\n title={label}\n type=\"button\"\n onClick={onOpen}\n >\n {label}\n </button>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n className=\"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100\"\n size=\"icon\"\n variant=\"ghost\"\n >\n <MoreHorizontalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\">\n <DropdownMenuItem\n onClick={() => {\n setTitle(chat.title ?? '');\n setDialog('rename');\n }}\n >\n <PencilIcon className=\"fk:size-4\" />\n Rename\n </DropdownMenuItem>\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={() => setDialog('delete')}>\n <Trash2Icon className=\"fk:size-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n <Dialog open={dialog === 'rename'} onOpenChange={(open) => setDialog(open ? 'rename' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Rename chat</DialogTitle>\n </DialogHeader>\n <Input value={title} onChange={(event) => setTitle(event.target.value)} placeholder=\"Chat title\" />\n <DialogFooter>\n <Button disabled={isMutating || !title.trim()} size=\"sm\" onClick={handleRename}>\n {isMutating ? 'Saving...' : 'Save'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n <Dialog open={dialog === 'delete'} onOpenChange={(open) => setDialog(open ? 'delete' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Delete chat?</DialogTitle>\n </DialogHeader>\n <p className=\"fk:text-sm fk:text-muted-foreground\">\n “{label}” and its messages will be permanently deleted.\n </p>\n <DialogFooter>\n <Button disabled={isMutating} size=\"sm\" variant=\"destructive\" onClick={handleDelete}>\n {isMutating ? 'Deleting...' : 'Delete'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n}\n\nfunction SearchResults({\n onOpen,\n projectId,\n query,\n}: {\n onOpen: (_chatId: string) => void;\n projectId: string;\n query: string;\n}): JSX.Element {\n const { data, isLoading } = useSWR<{ results: AgentChatSearchResult[] }>(\n paths(projectId).agentChatSearch(query),\n fetcher,\n { keepPreviousData: true }\n );\n\n if (isLoading && !data) {\n return (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Searching...\n </div>\n );\n }\n\n if (!data?.results.length) {\n return <p className=\"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">No matching chats.</p>;\n }\n\n return (\n <div className=\"fk:space-y-1\">\n {data.results.map((result) => (\n <button\n className=\"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle\"\n key={result.messageId}\n type=\"button\"\n onClick={() => onOpen(result.chatId)}\n >\n <span className=\"fk:block fk:truncate fk:text-sm\">{result.chatTitle?.trim() || 'New chat'}</span>\n <span className=\"fk:block fk:truncate fk:text-xs fk:text-muted-foreground\">{result.snippet}</span>\n </button>\n ))}\n </div>\n );\n}\n\n/**\n * ChatGPT-style chats section embedded in the AI sidebar: new chat button and\n * the user's recent chats grouped by date with rename/delete. When `query` is\n * set, the recent list is replaced by hybrid keyword + semantic search results.\n * Rendered inside the app layout route, so relative navigation resolves\n * against the app root (`agent`, `agent/chats/:chatId`).\n */\nexport function AgentChatsSection({ query }: { query: string }): JSX.Element | null {\n const { api, projectId } = useProjectApi();\n const navigate = useNavigate();\n const location = useLocation();\n const { mutate: globalMutate } = useSWRConfig();\n const activeChatId = /\\/agent\\/chats\\/([^/]+)/.exec(location.pathname)?.[1];\n const { data, isLoading, mutate, setSize, size } = useSWRInfinite<AgentChatsList>(\n (pageIndex, previousPage: AgentChatsList | null) => {\n if (!projectId || (previousPage && !previousPage.hasMore)) {\n return null;\n }\n\n return paths(projectId).agentChats(pageIndex * 30);\n },\n fetcher,\n { revalidateFirstPage: true }\n );\n const { data: activeChatDetail } = useSWR<AgentChatDetail>(\n projectId && activeChatId ? paths(projectId).agentChat(activeChatId) : null,\n fetcher\n );\n const chats = useMemo(() => {\n const listed = (data ?? []).flatMap((page) => page.chats);\n const generatedTitle = activeChatDetail?.chat.title?.trim();\n\n if (!activeChatId || !generatedTitle) {\n return listed;\n }\n\n return listed.map((chat) => {\n if (chat.id !== activeChatId || chat.title?.trim()) {\n return chat;\n }\n\n return { ...chat, title: generatedTitle };\n });\n }, [activeChatDetail?.chat.title, activeChatId, data]);\n const hasMore = data?.[data.length - 1]?.hasMore ?? false;\n const groups = useMemo(() => groupChats(chats), [chats]);\n\n // Refresh the list when the user lands on a chat (new chats, fresh titles).\n useEffect(() => {\n void mutate();\n }, [activeChatId, mutate]);\n\n if (!projectId || !api) {\n return null;\n }\n\n const chatApi = api;\n const chatProjectId = projectId;\n\n function openChat(chatId: string): void {\n navigate(`agent/chats/${chatId}`);\n }\n\n function handleDeleted(chatId: string): void {\n void mutate();\n\n if (chatId === activeChatId) {\n navigate('agent');\n } else {\n // Drop the cached detail so a re-open does not show stale data.\n void globalMutate(paths(chatProjectId).agentChat(chatId), undefined, { revalidate: false });\n }\n }\n\n return (\n <div className=\"fk:space-y-2\">\n {query ? (\n <SearchResults projectId={chatProjectId} query={query} onOpen={openChat} />\n ) : (\n <div className=\"fk:space-y-3\">\n {groups.map((group) => (\n <div key={group.label}>\n <p className=\"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground\">{group.label}</p>\n <div className=\"fk:space-y-0.5\">\n {group.chats.map((chat) => (\n <ChatListItem\n active={chat.id === activeChatId}\n api={chatApi}\n chat={chat}\n key={chat.id}\n onChanged={() => void mutate()}\n onDeleted={() => handleDeleted(chat.id)}\n onOpen={() => openChat(chat.id)}\n />\n ))}\n </div>\n </div>\n ))}\n {isLoading ? (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Loading recent chats...\n </div>\n ) : null}\n {!isLoading && chats.length === 0 ? (\n <div className=\"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground\">\n <MessageSquareIcon className=\"fk:size-5\" />\n <span>No chats yet. Start a conversation with the agent.</span>\n </div>\n ) : null}\n {hasMore ? (\n <Button className=\"fk:w-full\" size=\"sm\" variant=\"ghost\" onClick={() => void setSize(size + 1)}>\n Load more\n </Button>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import'./index.css';import {t,j,e as e$2,g as g$1,h as h$1}from'./chunk-SZEGGBOC.js';import {v,z,A,c as c$2,d as d$1,h,k,m,n,o,p,q,r,t as t$1,u,s,w,x,b as b$3}from'./chunk-32ZU4MLE.js';import {b as b$2}from'./chunk-U45E5X3H.js';import {a as a$2,d,c as c$1,e as e$1,g}from'./chunk-HDOIOXMP.js';import {a as a$1,b as b$1,c,e}from'./chunk-USNXQOMJ.js';import {b}from'./chunk-6NRQMG26.js';import {a}from'./chunk-O2QMYUPS.js';import {BrainIcon,ChevronDownIcon,XCircleIcon,CheckCircleIcon,CircleIcon,ClockIcon,SquareArrowOutUpRight,CheckIcon,GripVerticalIcon,XIcon,PanelLeftIcon,Info,X,Loader2Icon,OctagonXIcon,TriangleAlertIcon,InfoIcon,CircleCheckIcon,CopyIcon,ArrowDownIcon,DownloadIcon,ChevronLeftIcon,ChevronRightIcon,ImageIcon,Monitor,PlusIcon,ArrowUpIcon,SquareIcon,BookIcon,LoaderIcon,MicIcon,WrenchIcon,FileTextIcon,VideoIcon,PaperclipIcon,GlobeIcon,Music2Icon}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import*as H from'react';import {createContext,memo,useMemo,useRef,useState,useEffect,useCallback,useContext,Children,isValidElement}from'react';import {Collapsible,Label,Slot,Checkbox,Popover,Dialog,Switch,Tabs,Toggle,ToggleGroup,HoverCard}from'radix-ui';import {FormProvider,Controller,useFormContext,useFormState}from'react-hook-form';import*as xe from'react-resizable-panels';import {NavLink}from'react-router-dom';import {cva}from'class-variance-authority';import {groupBy}from'ramda';import {iconNames,DynamicIcon}from'lucide-react/dynamic';import {Drawer}from'@base-ui/react/drawer';import {Toaster}from'sonner';export{toast as qa}from'sonner';import {createHighlighter}from'shiki';import {StickToBottom,useStickToBottomContext}from'use-stick-to-bottom';import {cjk}from'@streamdown/cjk';import {code}from'@streamdown/code';import {math}from'@streamdown/math';import {mermaid}from'@streamdown/mermaid';import {Streamdown}from'streamdown';import {nanoid}from'nanoid';import {useControllableState}from'@radix-ui/react-use-controllable-state';import {motion}from'motion/react';function Jr({href:e,children:t}){return jsx(b,{asChild:true,className:"fk:h-6 fk:px-1! fk:py-0 fk:text-sm fk:font-light fk:text-link",size:"sm",variant:"link",children:jsxs("a",{href:e,target:"_blank",children:[t," ",jsx(SquareArrowOutUpRight,{className:"fk:size-3",strokeWidth:3})]})})}function $t({className:e,...t}){return jsx(Label.Root,{"data-slot":"label",className:a("fk:flex fk:items-center fk:gap-2 fk:text-sm fk:leading-none fk:font-medium fk:select-none fk:group-data-[disabled=true]:pointer-events-none fk:group-data-[disabled=true]:opacity-50 fk:peer-disabled:cursor-not-allowed fk:peer-disabled:opacity-50",e),...t})}var nn=FormProvider,Vo=H.createContext({}),an=({...e})=>jsx(Vo.Provider,{value:{name:e.name},children:jsx(Controller,{...e})}),Xe=()=>{let e=H.useContext(Vo),t=H.useContext(Go),{getFieldState:o}=useFormContext(),r=useFormState({name:e.name}),a=o(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:s}=t;return {id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...a}},Go=H.createContext({});function sn({className:e,...t}){let o=H.useId();return jsx(Go.Provider,{value:{id:o},children:jsx("div",{"data-slot":"form-item",className:a("fk:grid fk:gap-2",e),...t})})}function ln({className:e,...t}){let{error:o,formItemId:r}=Xe();return jsx($t,{"data-slot":"form-label","data-error":!!o,className:a("fk:data-[error=true]:text-destructive",e),htmlFor:r,...t})}function fn({...e}){let{error:t,formItemId:o,formDescriptionId:r,formMessageId:a}=Xe();return jsx(Slot.Root,{"data-slot":"form-control",id:o,"aria-describedby":t?`${r} ${a}`:`${r}`,"aria-invalid":!!t,...e})}function pn({className:e,...t}){let{formDescriptionId:o}=Xe();return jsx("p",{"data-slot":"form-description",id:o,className:a("fk:text-sm fk:text-muted-foreground",e),...t})}function cn({className:e,...t}){let{error:o,formMessageId:r}=Xe(),a$1=o?String(o?.message??""):t.children;return a$1?jsx("p",{"data-slot":"form-message",id:r,className:a("fk:text-sm fk:text-destructive",e),...t,children:a$1}):null}function un({className:e,...t}){return jsx(Checkbox.Root,{"data-slot":"checkbox",className:a("fk:peer fk:size-4 fk:shrink-0 fk:rounded-[4px] fk:border fk:border-input fk:shadow-xs fk:transition-shadow fk:outline-none fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:disabled:cursor-not-allowed fk:disabled:opacity-50 fk:aria-invalid:border-destructive fk:aria-invalid:ring-destructive/20 fk:data-[state=checked]:border-primary fk:data-[state=checked]:bg-primary fk:data-[state=checked]:text-primary-foreground fk:dark:bg-input/30 fk:dark:aria-invalid:ring-destructive/40 fk:dark:data-[state=checked]:bg-primary fk:corner-squircle",e),...t,children:jsx(Checkbox.Indicator,{"data-slot":"checkbox-indicator",className:"fk:grid fk:place-content-center fk:text-current fk:transition-none",children:jsx(CheckIcon,{className:"fk:size-3.5"})})})}function ue({...e}){return jsx(Collapsible.Root,{"data-slot":"collapsible",...e})}function me({...e}){return jsx(Collapsible.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function ke({...e}){return jsx(Collapsible.CollapsibleContent,{"data-slot":"collapsible-content",...e})}function Jt({className:e,type:t,...o}){return jsx("input",{type:t,"data-slot":"input",className:a("fk:h-9 fk:w-full fk:min-w-0 fk:rounded-md fk:border fk:border-input fk:bg-background fk:px-3 fk:py-1 fk:text-base fk:shadow-xs fk:transition-[color,box-shadow] fk:outline-none fk:selection:bg-primary fk:selection:text-primary-foreground fk:file:inline-flex fk:file:h-7 fk:file:border-0 fk:file:bg-transparent fk:file:text-sm fk:file:font-medium fk:file:text-foreground fk:placeholder:text-muted-foreground fk:disabled:pointer-events-none fk:disabled:cursor-not-allowed fk:disabled:opacity-50 fk:md:text-sm fk:dark:bg-input/30 fk:corner-squircle","fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50","fk:aria-invalid:border-destructive fk:aria-invalid:ring-destructive/20 fk:dark:aria-invalid:ring-destructive/40",e),...o})}function kn({...e}){return jsx(Popover.Root,{"data-slot":"popover",...e})}function gn({...e}){return jsx(Popover.Trigger,{"data-slot":"popover-trigger",...e})}function bn({className:e,align:t="center",sideOffset:o=4,...r}){return jsx(Popover.Portal,{children:jsx(Popover.Content,{"data-slot":"popover-content",align:t,sideOffset:o,className:a("fk:z-50 fk:w-72 fk:origin-(--radix-popover-content-transform-origin) fk:rounded-md fk:border fk:bg-popover fk:p-4 fk:text-popover-foreground fk:shadow-md fk:outline-hidden fk:data-[side=bottom]:slide-in-from-top-2 fk:data-[side=left]:slide-in-from-right-2 fk:data-[side=right]:slide-in-from-left-2 fk:data-[side=top]:slide-in-from-bottom-2 fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95 fk:corner-squircle",e),...r})})}function hn({...e}){return jsx(Popover.Anchor,{"data-slot":"popover-anchor",...e})}function xn({className:e,...t}){return jsx(xe.Group,{"data-slot":"resizable-panel-group",className:a("fk:flex fk:h-full fk:w-full fk:aria-[orientation=vertical]:flex-col",e),...t})}function Pn({...e}){return jsx(xe.Panel,{"data-slot":"resizable-panel",...e})}function Cn({withHandle:e,className:t,...o}){return jsx(xe.Separator,{"data-slot":"resizable-handle",className:a("fk:relative fk:flex fk:w-px fk:items-center fk:justify-center fk:bg-border fk:after:absolute fk:after:inset-y-0 fk:after:left-1/2 fk:after:w-1 fk:after:-translate-x-1/2 fk:focus-visible:ring-1 fk:focus-visible:ring-ring fk:focus-visible:ring-offset-1 fk:focus-visible:outline-hidden fk:aria-[orientation=horizontal]:h-px fk:aria-[orientation=horizontal]:w-full fk:aria-[orientation=horizontal]:after:left-0 fk:aria-[orientation=horizontal]:after:h-1 fk:aria-[orientation=horizontal]:after:w-full fk:aria-[orientation=horizontal]:after:translate-x-0 fk:aria-[orientation=horizontal]:after:-translate-y-1/2 fk:[&[aria-orientation=horizontal]>div]:rotate-90",t),...o,children:e&&jsx("div",{className:"fk:z-10 fk:flex fk:h-8 fk:w-3 fk:items-center fk:justify-center fk:rounded-xs fk:border fk:bg-border fk:corner-squircle",children:jsx(GripVerticalIcon,{className:"fk:size-2.5"})})})}function Zt({...e}){return jsx(Dialog.Root,{"data-slot":"sheet",...e})}function wn({...e}){return jsx(Dialog.Trigger,{"data-slot":"sheet-trigger",...e})}function Tn({...e}){return jsx(Dialog.Close,{"data-slot":"sheet-close",...e})}function _o({...e}){return jsx(Dialog.Portal,{"data-slot":"sheet-portal",...e})}function Uo({className:e,...t}){return jsx(Dialog.Overlay,{"data-slot":"sheet-overlay",className:a("fk:fixed fk:inset-0 fk:z-50 fk:bg-black/50 fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0",e),...t})}function Yt({className:e,children:t,side:o="right",showCloseButton:r=true,...a$1}){return jsxs(_o,{children:[jsx(Uo,{}),jsxs(Dialog.Content,{"data-slot":"sheet-content",className:a("fk:fixed fk:z-50 fk:flex fk:flex-col fk:gap-4 fk:bg-background fk:shadow-lg fk:transition fk:ease-in-out fk:data-[state=closed]:animate-out fk:data-[state=closed]:duration-300 fk:data-[state=open]:animate-in fk:data-[state=open]:duration-500",o==="right"&&"fk:inset-y-0 fk:right-0 fk:h-full fk:w-3/4 fk:border-l fk:data-[state=closed]:slide-out-to-right fk:data-[state=open]:slide-in-from-right fk:sm:max-w-sm",o==="left"&&"fk:inset-y-0 fk:left-0 fk:h-full fk:w-3/4 fk:border-r fk:data-[state=closed]:slide-out-to-left fk:data-[state=open]:slide-in-from-left fk:sm:max-w-sm",o==="top"&&"fk:inset-x-0 fk:top-0 fk:h-auto fk:border-b fk:data-[state=closed]:slide-out-to-top fk:data-[state=open]:slide-in-from-top",o==="bottom"&&"fk:inset-x-0 fk:bottom-0 fk:h-auto fk:border-t fk:data-[state=closed]:slide-out-to-bottom fk:data-[state=open]:slide-in-from-bottom",e),...a$1,children:[t,r&&jsxs(Dialog.Close,{className:"fk:absolute fk:top-4 fk:right-4 fk:rounded-xs fk:opacity-70 fk:ring-offset-background fk:transition-opacity fk:hover:opacity-100 fk:focus:ring-2 fk:focus:ring-ring fk:focus:ring-offset-2 fk:focus:outline-hidden fk:disabled:pointer-events-none fk:data-[state=open]:bg-secondary fk:corner-squircle",children:[jsx(XIcon,{className:"fk:size-4"}),jsx("span",{className:"fk:sr-only",children:"Close"})]})]})]})}function Qt({className:e,...t}){return jsx("div",{"data-slot":"sheet-header",className:a("fk:flex fk:flex-col fk:gap-1.5 fk:p-4",e),...t})}function Sn({className:e,...t}){return jsx("div",{"data-slot":"sheet-footer",className:a("fk:mt-auto fk:flex fk:flex-col fk:gap-2 fk:p-4",e),...t})}function eo({className:e,...t}){return jsx(Dialog.Title,{"data-slot":"sheet-title",className:a("fk:font-semibold fk:text-foreground",e),...t})}function to({className:e,...t}){return jsx(Dialog.Description,{"data-slot":"sheet-description",className:a("fk:text-sm fk:text-muted-foreground",e),...t})}var oo=768;function qo(){let[e,t]=H.useState(void 0);return H.useEffect(()=>{let o=window.matchMedia(`(max-width: ${oo-1}px)`),r=()=>{t(window.innerWidth<oo);};return o.addEventListener("change",r),t(window.innerWidth<oo),()=>o.removeEventListener("change",r)},[]),!!e}var Wo="flexkit:sidebar:state";function Rn(){return document.cookie.split("; ").find(e=>e.startsWith(`${Wo}=`))?.split("=")[1]!=="false"}var Mn=3600*24*7,An="16rem",Dn="18rem",zn="2rem",Ln="b",Xo=H.createContext(null);function Ye(){let e=H.useContext(Xo);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function Bn({defaultOpen:e=true,open:t,onOpenChange:o,className:r,style:a$2,children:s,...i}){let l=qo(),[f,p]=H.useState(false),[u,k]=H.useState(e),g=t??u,T=H.useCallback(d=>{let v=typeof d=="function"?d(g):d;o?o(v):k(v),document.cookie=`${Wo}=${v}; path=/; max-age=${Mn}`;},[o,g]),b=H.useCallback(()=>l?p(d=>!d):T(d=>!d),[l,T,p]);H.useEffect(()=>{let d=v=>{v.key===Ln&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),b());};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[b]);let P=g?"expanded":"collapsed",y=H.useMemo(()=>({state:P,open:g,setOpen:T,isMobile:l,openMobile:f,setOpenMobile:p,toggleSidebar:b}),[P,g,T,l,f,p,b]);return jsx(Xo.Provider,{value:y,children:jsx(a$1,{delayDuration:0,children:jsx("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":An,"--sidebar-width-icon":zn,...a$2},className:a("fk:group/sidebar-wrapper fk:flex fk:w-full fk:has-data-[variant=inset]:bg-sidebar fk:overflow-hidden",r),...i,children:s})})})}function ro({side:e="left",variant:t="sidebar",collapsible:o="offcanvas",className:r,children:a$1,...s}){let{isMobile:i,state:l,openMobile:f,setOpenMobile:p}=Ye();return o==="none"?jsx("div",{"data-slot":"sidebar",className:a("fk:flex fk:h-full fk:w-(--sidebar-width) fk:flex-col fk:bg-sidebar fk:text-sidebar-foreground",r),...s,children:a$1}):i?jsx(Zt,{open:f,onOpenChange:p,...s,children:jsxs(Yt,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"fk:w-(--sidebar-width) fk:bg-sidebar fk:p-0 fk:text-sidebar-foreground fk:[&>button]:hidden",style:{"--sidebar-width":Dn},side:e,children:[jsxs(Qt,{className:"fk:sr-only",children:[jsx(eo,{children:"Sidebar"}),jsx(to,{children:"Displays the mobile sidebar."})]}),jsx("div",{className:"fk:flex fk:h-full fk:w-full fk:flex-col",children:a$1})]})}):jsxs("div",{className:"fk:group fk:peer flexkit-sidebar-desktop-block fk:text-sidebar-foreground","data-state":l,"data-collapsible":l==="collapsed"?o:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[jsx("div",{"data-slot":"sidebar-gap",className:a("fk:relative fk:w-(--sidebar-width) fk:bg-transparent fk:transition-[width] fk:duration-200 fk:ease-linear","fk:group-data-[collapsible=offcanvas]:w-0","fk:group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"fk:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"fk:group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),jsx("div",{"data-slot":"sidebar-container",className:a("fk:relative fk:inset-y-0 fk:z-10 flexkit-sidebar-desktop-flex fk:h-[calc(100svh-3.5rem)] fk:w-(--sidebar-width) fk:transition-[left,right,width] fk:duration-200 fk:ease-linear",e==="left"?"fk:left-0 fk:group-data-[collapsible=offcanvas]:-left-(--sidebar-width)":"fk:right-0 k:group-data-[collapsible=offcanvas]:-right-(--sidebar-width)",t==="floating"||t==="inset"?"fk:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)] fk:group-data-[side=left]:border-r":"fk:group-data-[collapsible=icon]:w-(--sidebar-width-icon) fk:group-data-[side=left]:border-r fk:group-data-[side=right]:border-l",r),...s,children:jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"fk:flex fk:h-full fk:w-full fk:flex-col fk:bg-sidebar fk:group-data-[variant=floating]:rounded-lg fk:group-data-[variant=floating]:border fk:group-data-[variant=floating]:border-sidebar-border fk:group-data-[variant=floating]:shadow-sm",children:a$1})})]})}function En({className:e,onClick:t,...o}){let{toggleSidebar:r}=Ye();return jsxs(b,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:a("fk:size-7",e),onClick:a=>{t?.(a),r();},...o,children:[jsx(PanelLeftIcon,{}),jsx("span",{className:"fk:sr-only",children:"Toggle Sidebar"})]})}function no({className:e,...t}){let{toggleSidebar:o}=Ye();return jsx("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:o,title:"Toggle Sidebar",className:a("fk:absolute fk:inset-y-0 fk:z-20 flexkit-sidebar-sm-flex fk:w-4 fk:-translate-x-1/2 fk:transition-all fk:ease-linear fk:group-data-[side=left]:-right-4 fk:group-data-[side=right]:left-0 fk:after:absolute fk:after:inset-y-0 fk:after:left-1/2 fk:after:w-[2px] fk:hover:after:bg-sidebar-border","fk:in-data-[side=left]:cursor-w-resize fk:in-data-[side=right]:cursor-e-resize","fk:[[data-side=left][data-state=collapsed]_&]:cursor-e-resize fk:[[data-side=right][data-state=collapsed]_&]:cursor-w-resize","fk:group-data-[collapsible=offcanvas]:translate-x-0 fk:group-data-[collapsible=offcanvas]:after:left-full fk:hover:group-data-[collapsible=offcanvas]:bg-sidebar","fk:[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","fk:[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})}function Hn({className:e,...t}){return jsx("main",{"data-slot":"sidebar-inset",className:a("fk:relative fk:flex fk:flex-1 fk:flex-col fk:bg-background fk:overflow-hidden fk:peer-data-[variant=inset]:h-[calc(100svh-3.625rem)]",e),...t})}function ao({className:e,...t}){return jsx("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:a("fk:flex fk:min-h-0 fk:flex-1 fk:flex-col fk:overflow-auto fk:group-data-[collapsible=icon]:overflow-hidden",e),...t})}function ct({className:e,...t}){return jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:a("fk:relative fk:flex fk:w-full fk:min-w-0 fk:flex-col fk:p-2",e),...t})}function so({className:e,asChild:t=false,...o}){let r=t?Slot.Root:"div";return jsx(r,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:a("fk:flex fk:h-8 fk:shrink-0 fk:items-center fk:rounded-md fk:px-2 fk:text-xs fk:font-medium fk:text-sidebar-foreground/70 fk:ring-sidebar-ring fk:outline-hidden fk:transition-[margin,opacity] fk:duration-200 fk:ease-linear fk:focus-visible:ring-2 fk:[&>svg]:size-4 fk:[&>svg]:shrink-0 fk:corner-squircle","fk:group-data-[collapsible=icon]:-mt-8 fk:group-data-[collapsible=icon]:opacity-0",e),...o})}function Fn({className:e,...t}){return jsx("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:a("fk:w-full fk:text-sm",e),...t})}function dt({className:e,...t}){return jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:a("fk:flex fk:w-full fk:min-w-0 fk:flex-col fk:gap-1",e),...t})}function ut({className:e,...t}){return jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:a("fk:group/menu-item fk:relative",e),...t})}var Vn=cva("fk:peer/menu-button fk:flex fk:w-full fk:items-center fk:gap-2 fk:overflow-hidden fk:rounded-md fk:p-2 fk:text-left fk:text-sm fk:ring-sidebar-ring fk:outline-hidden fk:transition-[width,height,padding] fk:group-has-data-[sidebar=menu-action]/menu-item:pr-8 fk:group-data-[collapsible=icon]:size-8! fk:group-data-[collapsible=icon]:p-2! fk:hover:bg-sidebar-accent fk:hover:text-sidebar-accent-foreground fk:focus-visible:ring-2 fk:active:bg-sidebar-accent fk:active:text-sidebar-accent-foreground fk:disabled:pointer-events-none fk:disabled:opacity-50 fk:aria-disabled:pointer-events-none fk:aria-disabled:opacity-50 fk:data-[active=true]:bg-sidebar-accent fk:data-[active=true]:font-medium fk:data-[active=true]:text-sidebar-accent-foreground fk:data-[state=open]:hover:bg-sidebar-accent fk:data-[state=open]:hover:text-sidebar-accent-foreground fk:[&>span:last-child]:truncate fk:[&>svg]:size-4 fk:[&>svg]:shrink-0 fk:corner-squircle",{variants:{variant:{default:"fk:hover:bg-sidebar-accent fk:hover:text-sidebar-accent-foreground",outline:"fk:bg-background fk:shadow-[0_0_0_1px_hsl(var(--sidebar-border))] fk:hover:bg-sidebar-accent fk:hover:text-sidebar-accent-foreground fk:hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"fk:h-8 fk:text-sm",sm:"fk:h-7 fk:text-xs",lg:"fk:h-12 fk:text-sm fk:group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function mt({asChild:e$1=false,isActive:t=false,variant:o="default",size:r="default",tooltip:a$1,className:s,...i}){let l=e$1?Slot.Root:"button",{isMobile:f,state:p}=Ye(),u=jsx(l,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":t,className:a(Vn({variant:o,size:r}),s),...i});return a$1?(typeof a$1=="string"&&(a$1={children:a$1}),jsxs(b$1,{children:[jsx(c,{asChild:true,children:u}),jsx(e,{side:"right",align:"center",hidden:p!=="collapsed"||f,...a$1})]})):u}function Ko(e){return e.trim().replace(/([a-z])([A-Z0-9])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var Gn="dock";function On(e){return e.replace(/(^|-)([a-z0-9])/g,(t,o,r)=>r.toUpperCase())}function Jo(e){let t=new Set(e),o=new Map;for(let a of e){let s=On(a);o.has(s)||o.set(s,a);}let r=a=>{let s=a.trim();if(t.has(s))return s;let i=o.get(s);if(i)return i;let l=Ko(s);return t.has(l)?l:void 0};return (a,s)=>{if(a){let i=r(a);if(i)return i}if(s){let i=Ko(s),f=[i,`${i}s`,i.endsWith("s")?i.slice(0,-1):""].filter(Boolean).find(p=>t.has(p));if(f)return f}return Gn}}var qn=Jo(iconNames);function $n(e,t){return qn(e,t)}function io({name:e,fallbackFor:t,className:o="fk:h-4 fk:w-4",strokeWidth:r=2}){return jsx(DynamicIcon,{className:o,fallback:()=>jsx("span",{"aria-hidden":true,className:`fk:inline-block ${o}`}),name:$n(e,t),strokeWidth:r})}var Zo=NavLink;function Kn({className:e,menuGroups:t,schema:o}){let r=o.filter(i=>i.menu?.hidden!==true),a=groupBy(i=>i.menu?.group&&t?.find(l=>l.name===i.menu?.group)?.name||"ungrouped",r),s=t?.filter(i=>a[i.name]?.length);return jsxs(ro,{className:e,collapsible:"icon",variant:"inset",children:[jsxs(ao,{children:[s?.map(i=>jsxs(ct,{children:[jsx(so,{children:i.title}),jsx(dt,{children:a[i.name]?.map(l=>jsx(ut,{children:jsx(mt,{asChild:true,isActive:location.pathname.includes(`/list/${l.plural}`),tooltip:kt(l.menu?.label??l.plural),children:jsxs(Zo,{to:`list/${l.plural}`,children:[jsx(io,{className:"fk:h-4 fk:w-4 fk:mr-2",fallbackFor:l.name,name:l.menu?.icon}),jsx("span",{children:kt(l.menu?.label??l.plural)})]})})},l.plural))})]},i.name)),jsx(ct,{children:jsx(dt,{children:a.ungrouped?.map(i=>jsx(ut,{children:jsx(mt,{asChild:true,isActive:location.pathname.includes(`/list/${i.plural}`),tooltip:kt(i.menu?.label??i.plural),children:jsxs(Zo,{to:`list/${i.plural}`,children:[jsx(io,{className:"fk:h-4 fk:w-4 fk:mr-2",fallbackFor:i.name,name:i.menu?.icon}),jsx("span",{children:kt(i.menu?.label??i.plural)})]})})},i.plural))})})]}),jsx(no,{})]})}function kt(e){let t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1).trim()}function Jn({className:e,size:t="default",...o}){return jsx(Switch.Root,{"data-slot":"switch","data-size":t,className:a("fk:peer fk:group/switch fk:inline-flex fk:shrink-0 fk:items-center fk:rounded-full fk:border fk:border-transparent fk:shadow-xs fk:transition-all fk:outline-none fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:disabled:cursor-not-allowed fk:disabled:opacity-50 fk:data-[size=default]:h-5 fk:data-[size=default]:w-8 fk:data-[size=sm]:h-3.5 fk:data-[size=sm]:w-6 fk:data-[state=checked]:bg-success fk:data-[state=unchecked]:bg-input fk:dark:data-[state=unchecked]:bg-input/80 fk:corner-squircle",e),...o,children:jsx(Switch.Thumb,{"data-slot":"switch-thumb",className:a("fk:pointer-events-none fk:block fk:rounded-full fk:bg-white fk:ring-0 fk:transition-transform fk:group-data-[size=default]/switch:size-3.75 fk:group-data-[size=sm]/switch:size-3 fk:data-[state=checked]:translate-x-[calc(100%-2px)] fk:data-[state=unchecked]:translate-x-0.25 fk:dark:data-[state=checked]:bg-white fk:dark:data-[state=unchecked]:bg-white fk:corner-squircle")})})}function jn({className:e,containerClassName:t,onScroll:o,ref:r,...a$1}){return jsx("div",{ref:r,"data-slot":"table-container",className:a("fk:relative fk:h-full fk:w-full fk:min-w-0 fk:overflow-auto fk:rounded-t-md fk:border-border fk:border fk:corner-squircle",t),onScroll:o,children:jsx("table",{"data-slot":"table",className:a("fk:w-full fk:caption-bottom fk:text-sm",e),...a$1})})}function Zn({className:e,...t}){return jsx("thead",{"data-slot":"table-header",className:a("fk:[&_tr]:border-b fk:bg-muted fk:dark:bg-muted",e),...t})}function Yn({className:e,...t}){return jsx("tbody",{"data-slot":"table-body",className:a("fk:[&_tr:last-child]:border-0",e),...t})}function Qn({className:e,...t}){return jsx("tfoot",{"data-slot":"table-footer",className:a("fk:border-t fk:bg-muted/50 fk:font-medium fk:[&>tr]:last:border-b-0",e),...t})}function ea({className:e,...t}){return jsx("tr",{"data-slot":"table-row",className:a("fk:border-b fk:transition-colors fk:hover:bg-muted/50 fk:has-aria-expanded:bg-muted/50 fk:data-[state=selected]:bg-muted",e),...t})}function ta({className:e,...t}){return jsx("th",{"data-slot":"table-head",className:a("fk:h-10 fk:px-4 fk:text-left fk:align-middle fk:font-medium fk:whitespace-nowrap fk:text-foreground fk:[&:has([role=checkbox])]:pr-0 fk:*:[[role=checkbox]]:translate-y-[2px]",e),...t})}function oa({className:e,...t}){return jsx("td",{"data-slot":"table-cell",className:a("fk:px-4 fk:py-1 fk:align-middle fk:whitespace-nowrap fk:[&:has([role=checkbox])]:pr-0 fk:*:[[role=checkbox]]:translate-y-[2px]",e),...t})}function ra({className:e,...t}){return jsx("caption",{"data-slot":"table-caption",className:a("fk:mt-4 fk:pb-2 fk:text-sm fk:text-muted-foreground",e),...t})}function aa({className:e,orientation:t="horizontal",...o}){return jsx(Tabs.Root,{"data-slot":"tabs","data-orientation":t,orientation:t,className:a("fk:group/tabs fk:flex fk:data-[orientation=horizontal]:flex-col",e),...o})}var sa=cva("fk:group/tabs-list fk:inline-flex fk:w-fit fk:items-center fk:justify-center fk:rounded-lg fk:text-muted-foreground fk:group-data-[orientation=horizontal]/tabs:h-9 fk:group-data-[orientation=vertical]/tabs:h-fit fk:group-data-[orientation=vertical]/tabs:flex-col fk:data-[variant=line]:rounded-none fk:corner-squircle",{variants:{variant:{default:"fk:bg-muted",line:"fk:gap-1 fk:bg-transparent"}},defaultVariants:{variant:"default"}});function ia({className:e,variant:t="default",...o}){return jsx(Tabs.List,{"data-slot":"tabs-list","data-variant":t,className:a(sa({variant:t}),e),...o})}function la({className:e,type:t="button",...o}){return jsx(Tabs.Trigger,{"data-slot":"tabs-trigger",type:t,className:a("fk:relative fk:inline-flex fk:h-[calc(100%-1px)] fk:flex-1 fk:items-center fk:justify-center fk:gap-1.5 fk:rounded-md fk:border fk:border-transparent! fk:px-4 fk:py-1 fk:text-sm fk:font-medium fk:whitespace-nowrap fk:text-foreground/60 fk:transition-all fk:group-data-[orientation=vertical]/tabs:w-full fk:group-data-[orientation=vertical]/tabs:justify-start fk:hover:text-foreground fk:focus-visible:border-ring! fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:focus-visible:outline-1 fk:focus-visible:outline-ring fk:disabled:pointer-events-none fk:disabled:opacity-50 fk:group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm fk:group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none fk:dark:text-muted-foreground fk:dark:hover:text-foreground fk:[&_svg]:pointer-events-none fk:[&_svg]:shrink-0 fk:[&_svg:not([class*='size-'])]:size-4 fk:corner-squircle","fk:group-data-[variant=line]/tabs-list:bg-transparent fk:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent fk:dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent! fk:dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","fk:data-[state=active]:bg-background fk:data-[state=active]:text-foreground fk:dark:data-[state=active]:bg-muted-foreground/10 fk:dark:data-[state=active]:text-foreground fk:data-[state=active]:scale-[1.05]","fk:after:absolute fk:after:bg-foreground fk:after:opacity-0 fk:after:transition-opacity fk:group-data-[orientation=horizontal]/tabs:after:inset-x-0 fk:group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] fk:group-data-[orientation=horizontal]/tabs:after:h-0.5 fk:group-data-[orientation=vertical]/tabs:after:inset-y-0 fk:group-data-[orientation=vertical]/tabs:after:-right-1 fk:group-data-[orientation=vertical]/tabs:after:w-0.5 fk:group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...o})}function fa({className:e,...t}){return jsx(Tabs.Content,{"data-slot":"tabs-content",className:a("fk:flex-1 fk:outline-none fk:flex fk:flex-col",e),...t})}function lo({className:e,...t}){return jsx("textarea",{"data-slot":"textarea",className:a("fk:flex fk:field-sizing-content fk:min-h-16 fk:w-full fk:rounded-md fk:border fk:border-input fk:bg-background fk:px-3 fk:py-2 fk:text-base fk:shadow-xs fk:transition-[color,box-shadow] fk:outline-none fk:placeholder:text-muted-foreground fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:disabled:cursor-not-allowed fk:disabled:opacity-50 fk:aria-invalid:border-destructive fk:aria-invalid:ring-destructive/20 fk:md:text-sm fk:dark:bg-input/30 fk:dark:aria-invalid:ring-destructive/40 fk:corner-squircle",e),...t})}var ht=cva("fk:inline-flex fk:items-center fk:justify-center fk:gap-2 fk:rounded-md fk:text-sm fk:font-medium fk:whitespace-nowrap fk:transition-[color,box-shadow] fk:outline-none fk:hover:bg-muted fk:hover:text-muted-foreground fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:disabled:pointer-events-none fk:disabled:opacity-50 fk:aria-invalid:border-destructive fk:aria-invalid:ring-destructive/20 fk:data-[state=on]:bg-accent fk:data-[state=on]:text-accent-foreground fk:dark:aria-invalid:ring-destructive/40 fk:[&_svg]:pointer-events-none fk:[&_svg]:shrink-0 fk:[&_svg:not([class*='size-'])]:size-4 fk:corner-squircle",{variants:{variant:{default:"fk:bg-transparent",outline:"fk:border fk:border-input fk:bg-transparent fk:shadow-xs fk:hover:bg-accent fk:hover:text-accent-foreground"},size:{default:"fk:h-9 fk:min-w-9 fk:px-2",sm:"fk:h-8 fk:min-w-8 fk:px-1.5",lg:"fk:h-10 fk:min-w-10 fk:px-2.5"}},defaultVariants:{variant:"default",size:"default"}});function ua({className:e,variant:t,size:o,...r}){return jsx(Toggle.Root,{"data-slot":"toggle",className:a(ht({variant:t,size:o,className:e})),...r})}var tr=H.createContext({size:"default",variant:"default",spacing:0});function ka({className:e,variant:t,size:o,spacing:r=0,children:a$1,...s}){return jsx(ToggleGroup.Root,{"data-slot":"toggle-group","data-variant":t,"data-size":o,"data-spacing":r,style:{"--gap":r},className:a("fk:group/toggle-group fk:flex fk:w-fit fk:items-center fk:gap-[--spacing(var(--gap))] fk:rounded-md fk:data-[spacing=default]:data-[variant=outline]:shadow-xs fk:corner-squircle",e),...s,children:jsx(tr.Provider,{value:{variant:t,size:o,spacing:r},children:a$1})})}function ga({className:e,children:t,variant:o,size:r,...a$1}){let s=H.useContext(tr);return jsx(ToggleGroup.Item,{"data-slot":"toggle-group-item","data-variant":s.variant||o,"data-size":s.size||r,"data-spacing":s.spacing,className:a(ht({variant:s.variant||o,size:s.size||r}),"fk:w-auto fk:min-w-0 fk:shrink-0 fk:px-3 fk:focus:z-10 fk:focus-visible:z-10","fk:data-[spacing=0]:rounded-none fk:data-[spacing=0]:shadow-none fk:data-[spacing=0]:first:rounded-l-md fk:data-[spacing=0]:last:rounded-r-md fk:data-[spacing=0]:data-[variant=outline]:border-l-0 fk:data-[spacing=0]:data-[variant=outline]:first:border-l",e),...a$1,children:t})}function or(){return jsx(e,{className:"fk:max-w-64 fk:p-3",children:jsxs("div",{className:"fk:flex fk:gap-2.5",children:[jsx(Info,{className:"fk:mt-0.5 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-70"}),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("p",{className:"fk:text-sm fk:font-semibold fk:leading-none",children:"Insufficient permissions"}),jsx("p",{className:"fk:text-xs fk:opacity-70 fk:leading-snug",children:"Your member role cannot perform this action"})]})]})})}function ha({disabled:e,children:t}){return e?jsx(a$1,{children:jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx("span",{className:"fk:inline-flex",children:t})}),jsx(or,{})]})}):jsx(Fragment,{children:t})}var rr=H.createContext(null);function xa(){let e=H.useContext(rr);if(!e)throw new Error("useDrawer must be used within a Drawer.");return e}function nr({modal:e=true,swipeDirection:t="right",...o}){let r=H.useMemo(()=>({modal:e,swipeDirection:t}),[e,t]);return jsx(rr.Provider,{value:r,children:jsx(Drawer.Root,{"data-slot":"drawer",modal:e,swipeDirection:t,...o})})}function Pa({...e}){return jsx(Drawer.Portal,{"data-slot":"drawer-portal",...e})}function Ca({className:e,...t}){return jsx(Drawer.Backdrop,{"data-slot":"drawer-overlay",className:a("fk:fixed fk:inset-0 fk:z-50 fk:min-h-dvh fk:bg-overlay/75 fk:backdrop-blur-[1px] fk:select-none","fk:opacity-[max(var(--drawer-overlay-min-opacity,0),calc(1-var(--drawer-swipe-progress)))] fk:transition-opacity fk:duration-450 fk:ease-[cubic-bezier(0.32,0.72,0,1)]","fk:data-starting-style:opacity-0 fk:data-ending-style:pointer-events-none fk:data-ending-style:opacity-0 fk:data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] fk:data-swiping:duration-0","fk:supports-[-webkit-touch-callout:none]:absolute",e),...t})}function ar({className:e,children:t,...o}){let{modal:r,swipeDirection:a$1}=xa(),s=a$1==="down"||a$1==="up"?"y":"x";return jsxs(Pa,{children:[r===true?jsx(Ca,{}):null,jsx(Drawer.Viewport,{"data-slot":"drawer-viewport","data-modal":r,className:"fk:pointer-events-none fk:fixed fk:inset-0 fk:z-50 fk:select-none fk:data-[modal=true]:pointer-events-auto",children:jsx(Drawer.Popup,{"data-slot":"drawer-popup","data-swipe-axis":s,className:a("fk:group/drawer-popup fk:pointer-events-auto fk:fixed fk:z-50 fk:m-(--drawer-inset,0px) fk:flex fk:h-(--drawer-content-height) fk:max-h-(--drawer-content-max-height,none) fk:min-h-0 fk:w-(--drawer-content-width,auto) fk:transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] fk:flex-col fk:bg-background fk:transition-[transform,height,opacity,filter] fk:duration-450 fk:ease-[cubic-bezier(0.22,1,0.36,1)] fk:will-change-transform fk:outline-none fk:select-none fk:[interpolate-size:allow-keywords]","fk:data-nested-drawer-open:overflow-hidden fk:data-nested-drawer-open:brightness-90","fk:after:pointer-events-none fk:after:absolute fk:after:bg-(--drawer-bleed-background,var(--background)) fk:data-[swipe-axis=x]:after:inset-y-0 fk:data-[swipe-axis=x]:after:w-(--bleed) fk:data-[swipe-axis=y]:after:inset-x-0 fk:data-[swipe-axis=y]:after:h-(--bleed) fk:data-[swipe-direction=down]:after:top-full fk:data-[swipe-direction=left]:after:right-full fk:data-[swipe-direction=right]:after:left-full fk:data-[swipe-direction=up]:after:bottom-full","fk:[--drawer-content-height:var(--drawer-height,auto)] fk:data-[swipe-axis=x]:[--drawer-content-width:clamp(40vw,95vw,60rem)] fk:data-[swipe-axis=y]:[--drawer-content-max-height:calc(100dvh-6rem)]","fk:[--bleed:3rem] fk:[--peek:40%] fk:[--stack-room:max(0px,calc(100vw-100%))] fk:[--stack-gap:min(var(--peek),calc(var(--stack-room)/max(1,var(--stack-levels,1))))] fk:[--stack-step:0.02] fk:[--stack-height:var(--drawer-frontmost-height,var(--drawer-height,0px))] fk:[--stack-peek-offset:max(0px,calc((var(--nested-drawers)-var(--stack-progress))*var(--stack-gap)))] fk:[--stack-progress:clamp(0,var(--drawer-swipe-progress),1)] fk:[--stack-scale-base:max(0,calc(1-(var(--nested-drawers)*var(--stack-step))))] fk:[--stack-scale:clamp(0,calc(var(--stack-scale-base)+(var(--stack-step)*var(--stack-progress))),1)] fk:[--stack-shrink:calc(1-var(--stack-scale))]","fk:data-ending-style:transform-(--closed-transform) fk:data-ending-style:opacity-[0.9999] fk:data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] fk:data-nested-drawer-swiping:duration-0 fk:data-ending-style:data-nested-drawer-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)] fk:data-starting-style:transform-(--closed-transform) fk:data-swiping:duration-0 fk:data-ending-style:data-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)]","fk:data-[swipe-axis=y]:inset-x-0 fk:data-[swipe-axis=y]:data-nested-drawer-open:h-(--stack-height)","fk:data-[swipe-axis=x]:inset-y-0","fk:data-[swipe-direction=down]:bottom-0 fk:data-[swipe-direction=down]:origin-bottom fk:data-[swipe-direction=down]:rounded-t-[20px] fk:data-[swipe-direction=down]:border-t fk:data-[swipe-direction=down]:[--closed-transform:translate3d(0,calc(100%+var(--drawer-inset,0px)+2px),0)] fk:data-[swipe-direction=down]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)-var(--stack-peek-offset)-(var(--stack-shrink)*var(--stack-height)))]","fk:data-[swipe-direction=up]:top-0 fk:data-[swipe-direction=up]:origin-top fk:data-[swipe-direction=up]:rounded-b-[20px] fk:data-[swipe-direction=up]:border-b fk:data-[swipe-direction=up]:[--closed-transform:translate3d(0,calc(-100%-var(--drawer-inset,0px)-2px),0)] fk:data-[swipe-direction=up]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)+var(--stack-peek-offset)+(var(--stack-shrink)*var(--stack-height)))]","fk:data-[swipe-direction=left]:left-0 fk:data-[swipe-direction=left]:origin-left fk:data-[swipe-direction=left]:rounded-r-[20px] fk:data-[swipe-direction=left]:border-r fk:data-[swipe-direction=left]:[--closed-transform:translate3d(calc(-100%-var(--drawer-inset,0px)-2px),0,0)] fk:data-[swipe-direction=left]:[--translate-x:calc(var(--drawer-swipe-movement-x)+var(--stack-peek-offset)+(var(--stack-shrink)*100%))]","fk:data-[swipe-direction=right]:right-0 fk:data-[swipe-direction=right]:origin-right fk:data-[swipe-direction=right]:rounded-l-[20px] fk:data-[swipe-direction=right]:border-l fk:data-[swipe-direction=right]:[--closed-transform:translate3d(calc(100%+var(--drawer-inset,0px)+2px),0,0)] fk:data-[swipe-direction=right]:[--translate-x:calc(var(--drawer-swipe-movement-x)-var(--stack-peek-offset)-(var(--stack-shrink)*100%))]","fk:corner-squircle fk:shadow-2xl",e),...o,children:jsx(Drawer.Content,{"data-slot":"drawer-content",className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col fk:overflow-hidden fk:overscroll-contain fk:rounded-[inherit] fk:select-text fk:group-data-swiping/drawer-popup:select-none",children:t})})})]})}function sr({className:e,...t}){return jsx("div",{"data-slot":"drawer-header",className:a("fk:flex fk:shrink-0 fk:gap-2.5 fk:p-4 fk:group-data-[swipe-axis=y]/drawer-popup:text-center fk:md:text-left",e),...t})}function ir({className:e,...t}){return jsx(Drawer.Title,{"data-slot":"drawer-title",className:a("fk:flex fk:items-center fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",e),...t})}function lr({className:e,...t}){return jsx(Drawer.Description,{"data-slot":"drawer-description",className:a("fk:text-sm fk:text-muted-foreground",e),...t})}var pr=createContext(1);function Qf({children:e,size:t}){return jsx(pr.Provider,{value:Math.max(1,t),children:e})}function cr({actions:e,beforeClose:t$1,children:o,depth:r,forceClose:a=false,isFocused:s,nested:i,onFormChange:l,onClose:f,panel:p,title:u}){let[k,g]=useState(false),b$1={"--stack-levels":useContext(pr)-1},P=useCallback(()=>a||!(t$1?t$1():true)?false:(g(false),true),[t$1,a]);return useEffect(()=>{a&&g(false);},[a]),useEffect(()=>{g(true);},[]),jsx(nr,{disablePointerDismissal:true,onOpenChange:(y,d)=>{!y&&!P()&&d.cancel();},onOpenChangeComplete:y=>{y||f();},open:k,swipeDirection:"right",children:jsxs(ar,{style:b$1,children:[jsxs(sr,{className:"fk:px-10",children:[jsx(ir,{className:"fk:w-full",children:u||jsx(t,{className:"fk:h-5 fk:w-[120px]"})}),jsx(lr,{className:"fk:sr-only",children:u||"Loading form"}),e,jsxs(b,{className:"",onClick:()=>{P();},size:"icon",variant:"ghost",children:[jsx(X,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Close"})]})]}),jsx(v,{}),jsx("div",{className:"fk:min-h-0 fk:flex-1 fk:px-10 fk:pt-6 fk:overflow-y-auto fk:pb-16",children:o}),p,i]})})}var Ea=({richColors:e=true,style:t,...o})=>{let{theme:r="system"}=b$2();return jsx(Toaster,{theme:r,richColors:e,className:"toaster group",icons:{success:jsx(CircleCheckIcon,{className:"fk:size-4"}),info:jsx(InfoIcon,{className:"fk:size-4"}),warning:jsx(TriangleAlertIcon,{className:"fk:size-4"}),error:jsx(OctagonXIcon,{className:"fk:size-4"}),loading:jsx(Loader2Icon,{className:"fk:size-4 fk:animate-spin"})},style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border))","--border-radius":"var(--radius)",...t},...o})};function et({...e}){return jsx(HoverCard.Root,{"data-slot":"hover-card",...e})}function tt({...e}){return jsx(HoverCard.Trigger,{"data-slot":"hover-card-trigger",...e})}function ot({className:e,align:t="center",sideOffset:o=4,...r}){return jsx(HoverCard.Portal,{"data-slot":"hover-card-portal",children:jsx(HoverCard.Content,{"data-slot":"hover-card-content",align:t,sideOffset:o,className:a("fk:z-50 fk:w-64 fk:origin-(--radix-hover-card-content-transform-origin) fk:rounded-md fk:border fk:bg-popover fk:p-4 fk:text-popover-foreground fk:shadow-md fk:outline-hidden fk:data-[side=bottom]:slide-in-from-top-2 fk:data-[side=left]:slide-in-from-right-2 fk:data-[side=right]:slide-in-from-left-2 fk:data-[side=top]:slide-in-from-bottom-2 fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95 fk:corner-squircle",e),...r})})}function uo({className:e,...t}){return jsx(Loader2Icon,{role:"status","aria-label":"Loading",className:a("fk:size-4 fk:animate-spin",e),...t})}function mo({className:e,...t}){return jsx("div",{"data-slot":"input-group",role:"group",className:a("fk:group/input-group fk:border-input fk:dark:bg-input/30 fk:shadow-xs fk:relative fk:flex fk:w-full fk:items-center fk:rounded-lg fk:border fk:outline-none fk:transition-[color,box-shadow] fk:corner-squircle","fk:h-9 fk:has-[>textarea]:h-auto","fk:has-[>[data-align=inline-start]]:[&>input]:pl-2","fk:has-[>[data-align=inline-end]]:[&>input]:pr-2","fk:has-[>[data-align=block-start]]:h-auto fk:has-[>[data-align=block-start]]:flex-col fk:has-[>[data-align=block-start]]:[&>input]:pb-3","fk:has-[>[data-align=block-end]]:h-auto fk:has-[>[data-align=block-end]]:flex-col fk:has-[>[data-align=block-end]]:[&>input]:pt-3","fk:has-[[data-slot=input-group-control]:focus-visible]:ring-ring fk:has-[[data-slot=input-group-control]:focus-visible]:ring-1","fk:has-[[data-slot][aria-invalid=true]]:ring-destructive/20 fk:has-[[data-slot][aria-invalid=true]]:border-destructive fk:dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...t})}var Va=cva("fk:text-muted-foreground fk:flex fk:h-auto fk:cursor-text fk:select-none fk:items-center fk:justify-center fk:gap-2 fk:py-1.5 fk:text-sm fk:font-medium fk:group-data-[disabled=true]/input-group:opacity-50 fk:[&>kbd]:rounded-[calc(var(--radius)-5px)] fk:[&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"fk:order-first fk:pl-3 fk:has-[>button]:ml-[-0.45rem] fk:has-[>kbd]:ml-[-0.35rem]","inline-end":"fk:order-last fk:pr-3 fk:has-[>button]:mr-[-0.4rem] fk:has-[>kbd]:mr-[-0.35rem]","block-start":"fk:[.border-b]:pb-3 fk:order-first fk:w-full fk:justify-start fk:px-3 fk:pt-3 fk:group-has-[>input]/input-group:pt-2.5","block-end":"fk:[.border-t]:pt-3 fk:order-last fk:w-full fk:justify-start fk:px-3 fk:pb-3 fk:group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function Ct({className:e,align:t="inline-start",...o}){return jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:a(Va({align:t}),e),onClick:r=>{r.target.closest("button")||r.currentTarget.parentElement?.querySelector("input")?.focus();},...o})}var Ga=cva("fk:flex fk:items-center fk:gap-2 fk:text-sm fk:shadow-none",{variants:{size:{xs:"fk:h-6 fk:gap-1 fk:rounded-[calc(var(--radius)-5px)] fk:px-2 fk:has-[>svg]:px-2 fk:[&>svg:not([class*=size-])]:size-3.5 fk:corner-squircle",sm:"fk:h-8 fk:gap-1.5 fk:rounded-lg fk:px-2.5 fk:has-[>svg]:px-2.5 fk:corner-squircle","icon-xs":"fk:size-6 fk:rounded-[calc(var(--radius)-5px)] fk:p-0 fk:has-[>svg]:p-0 fk:corner-squircle","icon-sm":"fk:size-8 fk:p-0 fk:has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function yt({className:e,type:t="button",variant:o="ghost",size:r="xs",...a$1}){return jsx(b,{type:t,"data-size":r,variant:o,className:a(Ga({size:r}),e),...a$1})}function Oa({className:e,...t}){return jsx("span",{className:a("fk:text-muted-foreground fk:flex fk:items-center fk:gap-2 fk:text-sm fk:[&_svg:not([class*=size-])]:size-4 fk:[&_svg]:pointer-events-none",e),...t})}function _a({className:e,...t}){return jsx(Jt,{"data-slot":"input-group-control",className:a("fk:flex-1 fk:rounded-none fk:border-0 fk:bg-transparent fk:shadow-none fk:focus-visible:ring-0 fk:dark:bg-transparent fk:corner-squircle",e),...t})}function ko({className:e,...t}){return jsx(lo,{"data-slot":"input-group-control",className:a("fk:flex-1 fk:resize-none fk:rounded-none fk:border-0 fk:bg-transparent fk:py-3 fk:shadow-none fk:focus-visible:ring-0 fk:dark:bg-transparent fk:corner-squircle",e),...t})}var Ya={audio:Music2Icon,document:FileTextIcon,image:ImageIcon,source:GlobeIcon,unknown:PaperclipIcon,video:VideoIcon},Qa=e=>{if(e.type==="source-document")return "source";let t=e.mediaType??"";return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/")||t.startsWith("text/")?"document":"unknown"},es=e=>{if(e.type==="source-document")return e.title||e.filename||"Source";let t=Qa(e);return e.filename||(t==="image"?"Image":"Attachment")},ts=(e,t,o)=>o?jsx("img",{alt:t||"Image",className:"fk:size-full fk:object-cover",height:96,src:e,width:96}):jsx("img",{alt:t||"Image",className:"fk:size-full fk:rounded fk:object-cover fk:corner-squircle",height:20,src:e,width:20}),kr=createContext(null),os=createContext(null),Ip=()=>useContext(kr)??{variant:"grid"},go=()=>{let e=useContext(os);if(!e)throw new Error("Attachment components must be used within <Attachment>");return e},Np=({variant:e="grid",className:t,children:o,...r})=>{let a$1=useMemo(()=>({variant:e}),[e]);return jsx(kr.Provider,{value:a$1,children:jsx("div",{className:a("fk:flex fk:items-start",e==="list"?"fk:flex-col fk:gap-2":"fk:flex-wrap fk:gap-2",e==="grid"&&"fk:ml-auto fk:w-fit",t),...r,children:o})})};var Rp=({fallbackIcon:e,className:t,...o})=>{let{data:r,mediaCategory:a$1,variant:s}=go(),i=s==="inline"?"fk:size-3":"fk:size-4",l=p=>jsx(p,{className:a(i,"fk:text-muted-foreground")}),f=()=>{if(a$1==="image"&&r.type==="file"&&r.url)return ts(r.url,r.filename,s==="grid");if(a$1==="video"&&r.type==="file"&&r.url)return jsx("video",{className:"fk:size-full fk:object-cover",muted:true,src:r.url});let p=Ya[a$1];return e??l(p)};return jsx("div",{className:a("fk:flex fk:shrink-0 fk:items-center fk:justify-center fk:overflow-hidden",s==="grid"&&"fk:size-full fk:bg-muted",s==="inline"&&"fk:size-5 fk:rounded fk:bg-background fk:corner-squircle",s==="list"&&"fk:size-12 fk:rounded fk:bg-muted fk:corner-squircle",t),...o,children:f()})},Mp=({showMediaType:e=false,className:t,...o})=>{let{data:r,variant:a$1}=go(),s=es(r);return a$1==="grid"?null:jsxs("div",{className:a("fk:min-w-0 fk:flex-1",t),...o,children:[jsx("span",{className:"fk:block fk:truncate",children:s}),e&&r.mediaType&&jsx("span",{className:"fk:block fk:truncate fk:text-muted-foreground fk:text-xs",children:r.mediaType})]})},Ap=({label:e="Remove",className:t,children:o,...r})=>{let{onRemove:a$1,variant:s}=go(),i=useCallback(l=>{l.stopPropagation(),a$1?.();},[a$1]);return a$1?jsxs(b,{"aria-label":e,className:a(s==="grid"&&["fk:absolute fk:top-2 fk:right-2 fk:size-6 fk:rounded-full fk:p-0 fk:corner-squircle","fk:bg-background/80 fk:backdrop-blur-sm","fk:opacity-0 fk:transition-opacity fk:group-hover:opacity-100","fk:hover:bg-background","fk:[&>svg]:size-3"],s==="inline"&&["fk:size-5 fk:rounded fk:p-0 fk:corner-squircle","fk:opacity-0 fk:transition-opacity fk:group-hover:opacity-100","fk:[&>svg]:size-2.5"],s==="list"&&["fk:size-8 fk:shrink-0 fk:rounded fk:p-0 fk:corner-squircle","fk:[&>svg]:size-4"],t),onClick:i,type:"button",variant:"ghost",...r,children:[o??jsx(XIcon,{}),jsx("span",{className:"fk:sr-only",children:e})]}):null},Dp=({openDelay:e=0,closeDelay:t=0,...o})=>jsx(et,{closeDelay:t,openDelay:e,...o}),zp=e=>jsx(tt,{...e}),Lp=({align:e="start",className:t,...o})=>jsx(ot,{align:e,className:a("fk:w-auto fk:p-2",t),...o}),Bp=({className:e,children:t,...o})=>jsx("div",{className:a("fk:flex fk:items-center fk:justify-center fk:p-4 fk:text-muted-foreground fk:text-sm",e),...o,children:t??"No attachments"});var ps=e=>e&&e&1,cs=e=>e&&e&2,ds=e=>e&&e&4,us=e=>e.map((t,o)=>({key:`line-${o}`,tokens:t.map((r,a)=>({key:`line-${o}-${a}`,token:r}))})),ms=({token:e})=>jsx("span",{className:"fk:dark:bg-(--shiki-dark-bg)! fk:dark:text-(--shiki-dark)!",style:{backgroundColor:e.bgColor,color:e.color,fontStyle:ps(e.fontStyle)?"italic":void 0,fontWeight:cs(e.fontStyle)?"bold":void 0,textDecoration:ds(e.fontStyle)?"underline":void 0,...e.htmlStyle},children:e.content}),ks=a("fk:block","fk:before:content-[counter(line)]","fk:before:inline-block","fk:before:[counter-increment:line]","fk:before:w-8","fk:before:mr-4","fk:before:text-right","fk:before:text-muted-foreground/50","fk:before:font-mono","fk:before:select-none"),gs=({keyedLine:e,showLineNumbers:t})=>jsx("span",{className:t?ks:"fk:block",children:e.tokens.length===0?`
|
|
2
|
+
`:e.tokens.map(({token:o,key:r})=>jsx(ms,{token:o},r))}),yr=createContext({code:""}),br=new Map,hr=new Map,we=new Map,bs=(e,t)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return `${t}:${e.length}:${o}:${r}`},hs=e=>{let t=br.get(e);if(t)return t;let o=createHighlighter({langs:[e],themes:["github-light","github-dark"]});return br.set(e,o),o},vs=e=>({bg:"transparent",fg:"inherit",tokens:e.split(`
|
|
3
|
+
`).map(t=>t===""?[]:[{color:"inherit",content:t}])}),vr=(e,t,o)=>{let r=bs(e,t),a=hr.get(r);return a||(o&&(we.has(r)||we.set(r,new Set),we.get(r)?.add(o)),hs(t).then(s=>{let l=s.getLoadedLanguages().includes(t)?t:"text",f=s.codeToTokens(e,{lang:l,themes:{dark:"github-dark",light:"github-light"}}),p={bg:f.bg??"transparent",fg:f.fg??"inherit",tokens:f.tokens};hr.set(r,p);let u=we.get(r);if(u){for(let k of u)k(p);we.delete(r);}}).catch(s=>{console.error("Failed to highlight code:",s),we.delete(r);}),null)},wr=memo(({tokenized:e,showLineNumbers:t,className:o})=>{let r=useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]),a$1=useMemo(()=>us(e.tokens),[e.tokens]);return jsx("pre",{className:a("fk:dark:bg-(--shiki-dark-bg)! fk:dark:text-(--shiki-dark)! fk:m-0 fk:p-4 fk:text-sm",o),style:r,children:jsx("code",{className:a("fk:font-mono fk:text-sm",t&&"fk:[counter-increment:line_0] fk:[counter-reset:line]"),children:a$1.map(s=>jsx(gs,{keyedLine:s,showLineNumbers:t},s.key))})})},(e,t)=>e.tokenized===t.tokenized&&e.showLineNumbers===t.showLineNumbers&&e.className===t.className);wr.displayName="CodeBlockBody";var xs=({className:e,language:t,style:o,...r})=>jsx("div",{className:a("fk:group fk:relative fk:w-full fk:overflow-hidden fk:rounded-md fk:border fk:bg-background fk:text-foreground fk:corner-squircle",e),"data-language":t,style:{containIntrinsicSize:"auto 200px",contentVisibility:"auto",...o},...r}),qp=({children:e,className:t,...o})=>jsx("div",{className:a("fk:flex fk:items-center fk:justify-between fk:border-b fk:bg-muted/80 fk:px-3 fk:py-2 fk:text-muted-foreground fk:text-xs",t),...o,children:e}),$p=({children:e,className:t,...o})=>jsx("div",{className:a("fk:flex fk:items-center fk:gap-2",t),...o,children:e}),Wp=({children:e,className:t,...o})=>jsx("span",{className:a("fk:font-mono",t),...o,children:e}),Xp=({children:e,className:t,...o})=>jsx("div",{className:a("fk:-my-1 fk:-mr-1 fk:flex fk:items-center fk:gap-2",t),...o,children:e}),Ps=({code:e,language:t,showLineNumbers:o=false})=>{let r=useMemo(()=>vs(e),[e]),a=useMemo(()=>vr(e,t)??r,[e,t,r]),[s,i]=useState(null),l=useRef({code:e,language:t});return (l.current.code!==e||l.current.language!==t)&&(l.current={code:e,language:t},i(null)),useEffect(()=>{let p=false;return vr(e,t,u=>{p||i(u);}),()=>{p=true;}},[e,t]),jsx("div",{className:"fk:relative fk:overflow-auto",children:jsx(wr,{showLineNumbers:o,tokenized:s??a})})},wt=({code:e,language:t,showLineNumbers:o=false,className:r,children:a,...s})=>{let i=useMemo(()=>({code:e}),[e]);return jsx(yr.Provider,{value:i,children:jsxs(xs,{className:r,language:t,...s,children:[a,jsx(Ps,{code:e,language:t,showLineNumbers:o})]})})},Kp=({onCopy:e,onError:t,timeout:o=2e3,children:r,className:a$1,...s})=>{let[i,l]=useState(false),f=useRef(0),{code:p}=useContext(yr),u=useCallback(async()=>{if(typeof window>"u"||!navigator?.clipboard?.writeText){t?.(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(p),l(!0),e?.(),f.current=window.setTimeout(()=>l(!1),o));}catch(g){t?.(g);}},[p,e,t,o,i]);useEffect(()=>()=>{window.clearTimeout(f.current);},[]);let k=i?CheckIcon:CopyIcon;return jsx(b,{className:a("fk:shrink-0",a$1),onClick:u,size:"icon",variant:"ghost",...s,children:r??jsx(k,{size:14})})},Jp=e=>jsx(a$2,{...e}),jp=({className:e,...t})=>jsx(d,{className:a("fk:h-7 fk:border-none fk:bg-transparent fk:px-2 fk:text-xs fk:shadow-none",e),size:"sm",...t}),Zp=e=>jsx(c$1,{...e}),Yp=({align:e="end",...t})=>jsx(e$1,{align:e,...t}),Qp=e=>jsx(g,{...e});var ic=({className:e,...t})=>jsx(StickToBottom,{className:a("fk:relative fk:flex-1 fk:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),lc=({className:e,...t})=>jsx(StickToBottom.Content,{className:a("fk:flex fk:flex-col fk:gap-8 fk:p-4",e),...t}),fc=({className:e,title:t="No messages yet",description:o="Start a conversation to see messages here",icon:r,children:a$1,...s})=>jsx("div",{className:a("fk:flex fk:size-full fk:flex-col fk:items-center fk:justify-center fk:gap-3 fk:p-8 fk:text-center",e),...s,children:a$1??jsxs(Fragment,{children:[r&&jsx("div",{className:"fk:text-muted-foreground",children:r}),jsxs("div",{className:"fk:space-y-1",children:[jsx("h3",{className:"fk:font-medium fk:text-sm",children:t}),o&&jsx("p",{className:"fk:text-muted-foreground fk:text-sm",children:o})]})]})}),pc=({className:e,...t})=>{let{isAtBottom:o,scrollToBottom:r}=useStickToBottomContext(),a$1=useCallback(()=>{r();},[r]);return !o&&jsx(b,{className:a("fk:absolute fk:bottom-4 fk:left-[50%] fk:translate-x-[-50%] fk:rounded-full fk:dark:bg-background fk:dark:hover:bg-muted fk:corner-squircle",e),onClick:a$1,size:"icon",type:"button",variant:"outline",...t,children:jsx(ArrowDownIcon,{className:"fk:size-4"})})},Ss=e=>e.parts.filter(t=>t.type==="text").map(t=>t.text).join(""),Nr=e=>`**${e.role.charAt(0).toUpperCase()+e.role.slice(1)}:** ${Ss(e)}`,Is=(e,t=Nr)=>e.map((o,r)=>t(o,r)).join(`
|
|
4
|
+
|
|
5
|
+
`),cc=({messages:e,filename:t="conversation.md",formatMessage:o=Nr,className:r,children:a$1,...s})=>{let i=useCallback(()=>{let l=Is(e,o),f=new Blob([l],{type:"text/markdown"}),p=URL.createObjectURL(f),u=document.createElement("a");u.href=p,u.download=t,document.body.append(u),u.click(),u.remove(),URL.revokeObjectURL(p);},[e,t,o]);return jsx(b,{className:a("fk:absolute fk:top-4 fk:right-4 fk:rounded-full fk:dark:bg-background fk:dark:hover:bg-muted fk:corner-squircle",r),onClick:i,size:"icon",type:"button",variant:"outline",...s,children:a$1??jsx(DownloadIcon,{className:"fk:size-4"})})};var Tc=({className:e,from:t,...o})=>jsx("div",{className:a("fk:group fk:flex fk:w-full fk:max-w-[95%] fk:flex-col fk:gap-2",t==="user"?"fk:is-user fk:ml-auto fk:justify-end":"fk:is-assistant",e),...o}),Sc=({children:e,className:t,...o})=>jsx("div",{className:a("fk:is-user:dark fk:flex fk:w-fit fk:min-w-0 fk:max-w-full fk:flex-col fk:gap-2 fk:overflow-hidden fk:text-sm","fk:group-[.is-user]:ml-auto fk:group-[.is-user]:rounded-lg fk:group-[.is-user]:bg-secondary fk:group-[.is-user]:px-4 fk:group-[.is-user]:py-3 fk:group-[.is-user]:text-foreground","fk:group-[.is-assistant]:text-foreground",t),...o,children:e}),Ic=({className:e,children:t,...o})=>jsx("div",{className:a("fk:flex fk:items-center fk:gap-1",e),...o,children:t}),Nc=({tooltip:e$1,children:t,label:o,variant:r="ghost",size:a="icon-sm",...s})=>{let i=jsxs(b,{size:a,type:"button",variant:r,...s,children:[t,jsx("span",{className:"fk:sr-only",children:o||e$1})]});return e$1?jsx(a$1,{children:jsxs(b$1,{children:[jsx(c,{asChild:true,children:i}),jsx(e,{children:jsx("p",{children:e$1})})]})}):i},Ar=createContext(null),nt=()=>{let e=useContext(Ar);if(!e)throw new Error("MessageBranch components must be used within MessageBranch");return e},Rc=({defaultBranch:e=0,onBranchChange:t,className:o,...r})=>{let[a$1,s]=useState(e),[i,l]=useState([]),f=useCallback(g=>{s(g),t?.(g);},[t]),p=useCallback(()=>{let g=a$1>0?a$1-1:i.length-1;f(g);},[a$1,i.length,f]),u=useCallback(()=>{let g=a$1<i.length-1?a$1+1:0;f(g);},[a$1,i.length,f]),k=useMemo(()=>({branches:i,currentBranch:a$1,goToNext:u,goToPrevious:p,setBranches:l,totalBranches:i.length}),[i,a$1,u,p]);return jsx(Ar.Provider,{value:k,children:jsx("div",{className:a("fk:grid fk:w-full fk:gap-2 fk:[&>div]:pb-0",o),...r})})},Mc=({children:e,...t})=>{let{currentBranch:o,setBranches:r,branches:a$1}=nt(),s=useMemo(()=>Array.isArray(e)?e:[e],[e]);return useEffect(()=>{a$1.length!==s.length&&r(s);},[s,a$1,r]),s.map((i,l)=>jsx("div",{className:a("fk:grid fk:gap-2 fk:overflow-hidden fk:[&>div]:pb-0",l===o?"fk:block":"fk:hidden"),...t,children:i},i.key))},Ac=({className:e,...t})=>{let{totalBranches:o}=nt();return o<=1?null:jsx(z,{className:a("fk:[&>*:not(:first-child)]:rounded-l-md fk:[&>*:not(:last-child)]:rounded-r-md",e),orientation:"horizontal",...t})},Dc=({children:e,...t})=>{let{goToPrevious:o,totalBranches:r}=nt();return jsx(b,{"aria-label":"Previous branch",disabled:r<=1,onClick:o,size:"icon-sm",type:"button",variant:"ghost",...t,children:e??jsx(ChevronLeftIcon,{size:14})})},zc=({children:e,...t})=>{let{goToNext:o,totalBranches:r}=nt();return jsx(b,{"aria-label":"Next branch",disabled:r<=1,onClick:o,size:"icon-sm",type:"button",variant:"ghost",...t,children:e??jsx(ChevronRightIcon,{size:14})})},Lc=({className:e,...t})=>{let{currentBranch:o,totalBranches:r}=nt();return jsxs(A,{className:a("fk:border-none fk:bg-transparent fk:text-muted-foreground fk:shadow-none",e),...t,children:[o+1," of ",r]})},Gs={cjk:cjk,code:code,math:math,mermaid:mermaid},Os=memo(({className:e,...t})=>jsx(Streamdown,{className:a("fk:size-full fk:[&>*:first-child]:mt-0 fk:[&>*:last-child]:mb-0",e),plugins:Gs,prefix:"fk",...t}),(e,t)=>e.children===t.children&&t.isAnimating===e.isAnimating);Os.displayName="MessageResponse";var Bc=({className:e,children:t,...o})=>jsx("div",{className:a("fk:mt-4 fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-4",e),...o,children:t});var Oc=e=>jsx(c$2,{...e}),_c=e=>jsx(d$1,{...e}),Uc=({className:e,children:t,title:o="Model Selector",...r})=>jsxs(h,{"aria-describedby":void 0,className:a("fk:outline! fk:border-none! fk:p-0 fk:outline-border! fk:outline-solid!",e),...r,children:[jsx(k,{className:"fk:sr-only",children:o}),jsx(m,{className:"fk:**:data-[slot=command-input-wrapper]:h-auto",children:t})]}),qc=e=>jsx(n,{...e}),$c=({className:e,...t})=>jsx(o,{className:a("fk:h-auto fk:py-3.5",e),...t}),Wc=e=>jsx(p,{...e}),Xc=e=>jsx(q,{...e}),Kc=e=>jsx(r,{...e}),Jc=e=>jsx(t$1,{...e}),jc=e=>jsx(u,{...e}),Zc=e=>jsx(s,{...e}),Yc=({provider:e,className:t,...o})=>jsx("img",{...o,alt:`${e} logo`,className:a("fk:size-3 fk:dark:invert",t),height:12,src:`https://models.dev/logos/${e}.svg`,width:12}),Qc=({className:e,...t})=>jsx("div",{className:a("fk:flex fk:shrink-0 fk:items-center fk:-space-x-1 fk:[&>img]:rounded-full fk:[&>img]:bg-background fk:[&>img]:p-px fk:[&>img]:ring-1 fk:dark:[&>img]:bg-foreground",e),...t}),ed=({className:e,...t})=>jsx("span",{className:a("fk:flex-1 fk:truncate fk:text-left",e),...t});var qs=cva("fk:group/attachment fk:relative fk:flex fk:w-fit fk:max-w-full fk:min-w-0 fk:shrink-0 fk:flex-wrap fk:rounded-xl fk:border fk:bg-card fk:text-card-foreground fk:transition-colors fk:focus-within:ring-1 fk:focus-within:ring-ring/50 fk:has-[>a,>button]:hover:bg-muted/50 fk:data-[state=error]:border-destructive/30 fk:data-[state=idle]:border-dashed fk:corner-squircle",{variants:{size:{default:"fk:gap-2 fk:text-sm fk:has-data-[slot=attachment-content]:px-2.5 fk:has-data-[slot=attachment-content]:py-2 fk:has-data-[slot=attachment-media]:p-2",sm:"fk:gap-2.5 fk:text-xs fk:has-data-[slot=attachment-content]:px-2 fk:has-data-[slot=attachment-content]:py-1.5 fk:has-data-[slot=attachment-media]:p-1.5",xs:"fk:gap-1.5 fk:rounded-lg fk:text-xs fk:has-data-[slot=attachment-content]:px-1.5 fk:has-data-[slot=attachment-content]:py-1 fk:has-data-[slot=attachment-media]:p-1"},orientation:{horizontal:"fk:min-w-40 fk:items-center",vertical:"fk:w-24 fk:flex-col fk:has-data-[slot=attachment-content]:w-30"}}});function vo({className:e,state:t="done",size:o="default",orientation:r="horizontal",...a$1}){return jsx("div",{"data-slot":"attachment","data-state":t,"data-size":o,"data-orientation":r,className:a(qs({size:o,orientation:r}),e),...a$1})}var $s=cva("fk:relative fk:flex fk:aspect-square fk:w-10 fk:shrink-0 fk:items-center fk:justify-center fk:overflow-hidden fk:rounded-lg fk:bg-muted fk:text-foreground fk:group-data-[orientation=vertical]/attachment:w-full fk:group-data-[size=sm]/attachment:w-8 fk:group-data-[size=xs]/attachment:w-7 fk:group-data-[size=xs]/attachment:rounded-md fk:group-data-[state=error]/attachment:bg-destructive/10 fk:group-data-[state=error]/attachment:text-destructive fk:group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! fk:[&_svg]:pointer-events-none fk:[&_svg:not([class*=size-])]:size-4 fk:group-data-[orientation=vertical]/attachment:[&_svg:not([class*=size-])]:size-6 fk:group-data-[size=xs]/attachment:[&_svg:not([class*=size-])]:size-3.5 fk:corner-squircle",{variants:{variant:{icon:"",image:"fk:opacity-60 fk:group-data-[state=done]/attachment:opacity-100 fk:group-data-[state=idle]/attachment:opacity-100 fk:*:[img]:aspect-square fk:*:[img]:w-full fk:*:[img]:object-cover"}},defaultVariants:{variant:"icon"}});function xo({className:e,variant:t="icon",...o}){return jsx("div",{"data-slot":"attachment-media","data-variant":t,className:a($s({variant:t}),e),...o})}function Po({className:e,...t}){return jsx("div",{"data-slot":"attachment-content",className:a("fk:max-w-full fk:min-w-0 fk:flex-1 fk:leading-tight fk:group-data-[orientation=vertical]/attachment:px-1",e),...t})}function Co({className:e,...t}){return jsx("span",{"data-slot":"attachment-title",className:a("fk:block fk:max-w-full fk:min-w-0 fk:truncate fk:font-medium fk:group-data-[state=processing]/attachment:shimmer fk:group-data-[state=uploading]/attachment:shimmer",e),...t})}function Ws({className:e,...t}){return jsx("span",{"data-slot":"attachment-description",className:a("fk:mt-0.5 fk:block fk:min-w-0 fk:truncate fk:text-xs fk:text-muted-foreground fk:group-data-[state=error]/attachment:text-destructive/80","fk:max-w-full",e),...t})}function yo({className:e,...t}){return jsx("div",{"data-slot":"attachment-actions",className:a("fk:relative fk:z-20 fk:flex fk:shrink-0 fk:items-center fk:group-data-[orientation=vertical]/attachment:absolute fk:group-data-[orientation=vertical]/attachment:top-3 fk:group-data-[orientation=vertical]/attachment:right-3 fk:group-data-[orientation=vertical]/attachment:gap-1",e),...t})}function wo({className:e,variant:t,size:o="icon-xs",...r}){return jsx(b,{"data-slot":"attachment-action",variant:t??"ghost",size:o,className:a(e),...r})}function Xs({className:e,asChild:t=false,type:o,...r}){let a$1=t?Slot.Root:"button";return jsx(a$1,{"data-slot":"attachment-trigger",type:t?void 0:o??"button",className:a("fk:absolute fk:inset-0 fk:z-10 fk:outline-none",e),...r})}function Ks({className:e,...t}){return jsx("div",{"data-slot":"attachment-group",className:a("fk:flex fk:min-w-0 fk:scroll-fade-x fk:snap-x fk:snap-mandatory fk:scroll-px-1 fk:gap-3 fk:overflow-x-auto fk:overscroll-x-contain fk:py-1 fk:*:data-[slot=attachment]:flex-none fk:*:data-[slot=attachment]:snap-start",e),...t})}var oi=async e=>{try{let o=await(await fetch(e)).blob();return new Promise(r=>{let a=new FileReader;a.onloadend=()=>r(a.result),a.onerror=()=>r(null),a.readAsDataURL(o);})}catch{return null}},ri=async()=>{if(typeof navigator>"u"||!navigator.mediaDevices?.getDisplayMedia)return null;let e=null,t=document.createElement("video");t.muted=true,t.playsInline=true;try{e=await navigator.mediaDevices.getDisplayMedia({audio:!1,video:!0}),t.srcObject=e,await new Promise((f,p)=>{t.onloadedmetadata=()=>f(),t.onerror=()=>p(new Error("Failed to load screen stream"));}),await t.play();let o=t.videoWidth,r=t.videoHeight;if(!o||!r)return null;let a=document.createElement("canvas");a.width=o,a.height=r;let s=a.getContext("2d");if(!s)return null;s.drawImage(t,0,0,o,r);let i=await new Promise(f=>{a.toBlob(f,"image/png");});if(!i)return null;let l=new Date().toISOString().replaceAll(/[:.]/g,"-").replace("T","_").replace("Z","");return new File([i],`screenshot-${l}.png`,{lastModified:Date.now(),type:"image/png"})}finally{if(e)for(let o of e.getTracks())o.stop();t.pause(),t.srcObject=null;}},So=createContext(null),Io=createContext(null),Pd=()=>{let e=useContext(So);if(!e)throw new Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");return e},Br=()=>useContext(So),Cd=()=>{let e=useContext(Io);if(!e)throw new Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");return e},ni=()=>useContext(Io),yd=({initialInput:e="",children:t})=>{let[o,r]=useState(e),a=useCallback(()=>r(""),[]),[s,i]=useState([]),l=useRef(null),f=useRef(()=>{}),p=useCallback(d=>{let v=Array.from(d);v.length!==0&&i(E=>[...E,...v.map(M=>({filename:M.name,id:nanoid(),mediaType:M.type,type:"file",url:URL.createObjectURL(M)}))]);},[]),u=useCallback(d=>{i(v=>{let E=v.find(M=>M.id===d);return E?.url&&URL.revokeObjectURL(E.url),v.filter(M=>M.id!==d)});},[]),k=useCallback(()=>{i(d=>{for(let v of d)v.url&&URL.revokeObjectURL(v.url);return []});},[]),g=useRef(s);useEffect(()=>{g.current=s;},[s]),useEffect(()=>()=>{for(let d of g.current)d.url&&URL.revokeObjectURL(d.url);},[]);let T=useCallback(()=>{f.current?.();},[]),b=useMemo(()=>({add:p,clear:k,fileInputRef:l,files:s,openFileDialog:T,remove:u}),[s,p,u,k,T]),P=useCallback((d,v)=>{l.current=d.current,f.current=v;},[]),y=useMemo(()=>({__registerFileInput:P,attachments:b,textInput:{clear:a,setInput:r,value:o}}),[o,a,b,P]);return jsx(So.Provider,{value:y,children:jsx(Io.Provider,{value:b,children:t})})},Er=createContext(null),It=()=>{let e=ni(),o=useContext(Er)??e;if(!o)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return o},Hr=createContext(null),wd=()=>{let e=useContext(Hr);if(!e)throw new Error("usePromptInputReferencedSources must be used within a LocalReferencedSourcesContext.Provider");return e},Td=({label:e="Add photos or files",onSelect:t,...o})=>{let r=It(),a=useCallback(s=>{t?.(s),!s.defaultPrevented&&r.openFileDialog();},[r,t]);return jsxs(j,{...o,onSelect:a,children:[jsx(ImageIcon,{className:"fk:mr-2 fk:size-4"})," ",e]})},Sd=({label:e="Take screenshot",onSelect:t,...o})=>{let r=It(),a=useCallback(async s=>{if(t?.(s),!s.defaultPrevented)try{let i=await ri();i&&r.add([i]);}catch(i){if(i instanceof DOMException&&(i.name==="NotAllowedError"||i.name==="AbortError"))return;throw i}},[t,r]);return jsxs(j,{...o,onSelect:a,children:[jsx(Monitor,{className:"fk:mr-2 fk:size-4"}),e]})},Id=({className:e,accept:t,multiple:o,globalDrop:r,syncHiddenInput:a$1,maxFiles:s,maxFileSize:i,onError:l,onSubmit:f,children:p,...u})=>{let k=Br(),g=!!k,T=useRef(null),b=useRef(null),[P,y]=useState([]),d=g?k.attachments.files:P,[v,E]=useState([]),M=useRef(d);useEffect(()=>{M.current=d;},[d]);let Me=useCallback(()=>{T.current?.click();},[]),W=useCallback(m=>!t||t.trim()===""?true:t.split(",").map(h=>h.trim()).filter(Boolean).some(h=>{if(h.startsWith("."))return m.name.toLowerCase().endsWith(h.toLowerCase());if(h.endsWith("/*")){let S=h.slice(0,-1);return m.type.startsWith(S)}return m.type===h}),[t]),st=useCallback(m=>{let x=Array.from(m),h=x.filter(Q=>W(Q));if(x.length&&h.length===0){l?.({code:"accept",message:"No files match the accepted types."});return}let S=Q=>i?Q.size<=i:true,G=h.filter(S);if(h.length>0&&G.length===0){l?.({code:"max_file_size",message:"All files exceed the maximum size."});return}y(Q=>{let z=typeof s=="number"?Math.max(0,s-Q.length):void 0,he=typeof z=="number"?G.slice(0,z):G;typeof z=="number"&&G.length>z&&l?.({code:"max_files",message:"Too many files. Some were not added."});let ve=[];for(let Nt of he)ve.push({filename:Nt.name,id:nanoid(),mediaType:Nt.type,type:"file",url:URL.createObjectURL(Nt)});return [...Q,...ve]});},[W,s,i,l]),se=useCallback(m=>y(x=>{let h=x.find(S=>S.id===m);return h?.url&&URL.revokeObjectURL(h.url),x.filter(S=>S.id!==m)}),[]),J=useCallback(m=>{let x=Array.from(m),h=x.filter(ve=>W(ve));if(x.length&&h.length===0){l?.({code:"accept",message:"No files match the accepted types."});return}let S=ve=>i?ve.size<=i:true,G=h.filter(S);if(h.length>0&&G.length===0){l?.({code:"max_file_size",message:"All files exceed the maximum size."});return}let Q=d.length,z=typeof s=="number"?Math.max(0,s-Q):void 0,he=typeof z=="number"?G.slice(0,z):G;typeof z=="number"&&G.length>z&&l?.({code:"max_files",message:"Too many files. Some were not added."}),he.length>0&&k?.attachments.add(he);},[W,i,s,l,d.length,k]),j=useCallback(()=>g?k?.attachments.clear():y(m=>{for(let x of m)x.url&&URL.revokeObjectURL(x.url);return []}),[g,k]),Z=useCallback(()=>E([]),[]),F=g?J:st,Ae=g?k.attachments.remove:se,it=g?k.attachments.openFileDialog:Me,De=useCallback(()=>{j(),Z();},[j,Z]);useEffect(()=>{g&&k.__registerFileInput(T,()=>T.current?.click());},[g,k]),useEffect(()=>{a$1&&T.current&&d.length===0&&(T.current.value="");},[d,a$1]),useEffect(()=>{let m=b.current;if(!m||r)return;let x=S=>{S.dataTransfer?.types?.includes("Files")&&S.preventDefault();},h=S=>{S.dataTransfer?.types?.includes("Files")&&S.preventDefault(),S.dataTransfer?.files&&S.dataTransfer.files.length>0&&F(S.dataTransfer.files);};return m.addEventListener("dragover",x),m.addEventListener("drop",h),()=>{m.removeEventListener("dragover",x),m.removeEventListener("drop",h);}},[F,r]),useEffect(()=>{if(!r)return;let m=h=>{h.dataTransfer?.types?.includes("Files")&&h.preventDefault();},x=h=>{h.dataTransfer?.types?.includes("Files")&&h.preventDefault(),h.dataTransfer?.files&&h.dataTransfer.files.length>0&&F(h.dataTransfer.files);};return document.addEventListener("dragover",m),document.addEventListener("drop",x),()=>{document.removeEventListener("dragover",m),document.removeEventListener("drop",x);}},[F,r]),useEffect(()=>()=>{if(!g)for(let m of M.current)m.url&&URL.revokeObjectURL(m.url);},[g]);let lt=useCallback(m=>{m.currentTarget.files&&F(m.currentTarget.files),m.currentTarget.value="";},[F]),D=useMemo(()=>({add:F,clear:j,fileInputRef:T,files:d.map(m=>({...m,id:m.id})),openFileDialog:it,remove:Ae}),[d,F,Ae,j,it]),ft=useMemo(()=>({add:m=>{let x=Array.isArray(m)?m:[m];E(h=>[...h,...x.map(S=>({...S,id:nanoid()}))]);},clear:Z,remove:m=>{E(x=>x.filter(h=>h.id!==m));},sources:v}),[v,Z]),ie=useCallback(async m=>{m.preventDefault();let x=m.currentTarget,h=g?k.textInput.value:new FormData(x).get("message")||"";g||x.reset();try{let S=await Promise.all(d.map(async({id:Q,...z})=>{if(z.url?.startsWith("blob:")){let he=await oi(z.url);return {...z,url:he??z.url}}return z})),G=f({files:S,text:h},m);if(G instanceof Promise)try{await G,De(),g&&k.textInput.clear();}catch{}else De(),g&&k.textInput.clear();}catch{}},[g,k,d,f,De]),Y=jsxs(Fragment,{children:[jsx("input",{accept:t,"aria-label":"Upload files",className:"fk:hidden",multiple:o,onChange:lt,ref:T,title:"Upload files",type:"file"}),jsx("form",{className:a("fk:w-full",e),onSubmit:ie,ref:b,...u,children:jsx(mo,{className:"fk:overflow-hidden fk:rounded-3xl",children:p})})]}),ze=jsx(Hr.Provider,{value:ft,children:Y});return jsx(Er.Provider,{value:D,children:ze})},Nd=({className:e,...t})=>jsx("div",{className:a("fk:contents",e),...t}),Rd=({onChange:e,onKeyDown:t,className:o,placeholder:r="What would you like to know?",...a$1})=>{let s=Br(),i=It(),[l,f]=useState(false),p=useCallback(b=>{if(t?.(b),!b.defaultPrevented){if(b.key==="Enter"){if(l||b.nativeEvent.isComposing||b.shiftKey)return;b.preventDefault();let{form:P}=b.currentTarget;if(P?.querySelector('button[type="submit"]')?.disabled)return;P?.requestSubmit();}if(b.key==="Backspace"&&b.currentTarget.value===""&&i.files.length>0){b.preventDefault();let P=i.files[i.files.length-1];P&&i.remove(P.id);}}},[t,l,i]),u=useCallback(b=>{let P=b.clipboardData?.items;if(!P)return;let y=[];for(let d of Array.from(P))if(d.kind==="file"){let v=d.getAsFile();v&&y.push(v);}y.length>0&&(b.preventDefault(),i.add(y));},[i]),k=useCallback(()=>f(false),[]),g=useCallback(()=>f(true),[]),T=s?{onChange:b=>{s.textInput.setInput(b.currentTarget.value),e?.(b);},value:s.textInput.value}:{onChange:e};return jsx(ko,{className:a("fk:field-sizing-content fk:max-h-48 fk:min-h-16 fk:p-3",o),name:"message",onCompositionEnd:k,onCompositionStart:g,onKeyDown:p,onPaste:u,placeholder:r,...a$1,...T})},zr=e=>!!(e.url&&e.mediaType?.startsWith("image/")),ai=()=>{let e=It();return e.files.map(t=>{let o=t.filename??"Attachment";return jsxs(vo,{size:"sm",children:[jsx(xo,{variant:zr(t)?"image":"icon",children:zr(t)?jsx("img",{alt:o,src:t.url}):jsx(FileTextIcon,{})}),jsx(Po,{children:jsx(Co,{children:o})}),jsx(yo,{children:jsx(wo,{"aria-label":`Remove ${o}`,onClick:()=>e.remove(t.id),children:jsx(XIcon,{})})})]},t.id)})},Md=({className:e,children:t,...o})=>jsx(Ct,{align:"block-start",className:a("fk:flex-wrap fk:gap-1",e),...o,children:t??jsx(ai,{})}),Ad=({className:e,...t})=>jsx(Ct,{align:"block-end",className:a("fk:justify-between fk:gap-1",e),...t}),Dd=({className:e,...t})=>jsx("div",{className:a("fk:flex fk:min-w-0 fk:items-center fk:gap-1",e),...t}),si=({variant:e$1="ghost",className:t,size:o,tooltip:r,...a$1})=>{let s=o??(Children.count(a$1.children)>1?"sm":"icon-sm"),i=jsx(yt,{className:a(t),size:s,type:"button",variant:e$1,...a$1});if(!r)return i;let l=typeof r=="string"?r:r.content,f=typeof r=="string"?void 0:r.shortcut,p=typeof r=="string"?"top":r.side??"top";return jsxs(b$1,{children:[jsx(c,{asChild:true,children:i}),jsxs(e,{side:p,children:[l,f&&jsx("span",{className:"fk:ml-2 fk:text-muted-foreground",children:f})]})]})},zd=e=>jsx(e$2,{...e}),Ld=({className:e,children:t,size:o="icon-sm",variant:r="outline",...a$1})=>jsx(g$1,{asChild:true,children:jsx(si,{className:a("fk:rounded-full",e),size:o,variant:r,...a$1,children:t??jsx(PlusIcon,{className:"fk:size-4"})})}),Bd=({className:e,onCloseAutoFocus:t,...o})=>jsx(h$1,{align:"start",className:a(e),onCloseAutoFocus:r=>{t?.(r),!r.defaultPrevented&&r.preventDefault();},...o}),Ed=({className:e,...t})=>jsx(j,{className:a(e),...t}),Hd=({className:e,variant:t="default",size:o="icon-sm",status:r,onStop:a$1,onClick:s,children:i,...l})=>{let f=r==="submitted"||r==="streaming",p=jsx(ArrowUpIcon,{className:"fk:size-4"});r==="submitted"?p=jsx(uo,{}):r==="streaming"?p=jsx(SquareIcon,{className:"fk:size-4"}):r==="error"&&(p=jsx(XIcon,{className:"fk:size-4"}));let u=useCallback(k=>{if(f&&a$1){k.preventDefault(),a$1();return}s?.(k);},[f,a$1,s]);return jsx(yt,{"aria-label":f?"Stop":"Submit",className:a("fk:rounded-full",e),onClick:u,size:o,type:f&&a$1?"button":"submit",variant:t,...l,children:i??p})},Fd=e=>jsx(a$2,{...e}),Vd=({className:e,...t})=>jsx(d,{className:a("fk:border-none fk:bg-transparent fk:font-medium fk:text-muted-foreground fk:shadow-none fk:transition-colors","fk:hover:bg-accent fk:hover:text-foreground fk:aria-expanded:bg-accent fk:aria-expanded:text-foreground",e),...t}),Gd=({className:e,...t})=>jsx(e$1,{className:a(e),...t}),Od=({className:e,...t})=>jsx(g,{className:a(e),...t}),_d=({className:e,...t})=>jsx(c$1,{className:a(e),...t}),Ud=({openDelay:e=0,closeDelay:t=0,...o})=>jsx(et,{closeDelay:t,openDelay:e,...o}),qd=e=>jsx(tt,{...e}),$d=({align:e="start",...t})=>jsx(ot,{align:e,...t}),Wd=({className:e,...t})=>jsx("div",{className:a(e),...t}),Xd=({className:e,...t})=>jsx("div",{className:a(e),...t}),Kd=({className:e,...t})=>jsx("h3",{className:a("fk:mb-2 fk:px-3 fk:font-medium fk:text-muted-foreground fk:text-xs",e),...t}),Jd=({className:e,...t})=>jsx("div",{className:a("fk:space-y-1",e),...t}),jd=({className:e,...t})=>jsx("div",{className:a("fk:flex fk:items-center fk:gap-2 fk:px-3 fk:py-2 fk:text-xs fk:hover:bg-accent",e),...t}),Zd=({className:e,...t})=>jsx(m,{className:a(e),...t}),Yd=({className:e,...t})=>jsx(o,{className:a(e),...t}),Qd=({className:e,...t})=>jsx(p,{className:a(e),...t}),eu=({className:e,...t})=>jsx(q,{className:a(e),...t}),tu=({className:e,...t})=>jsx(r,{className:a(e),...t}),ou=({className:e,...t})=>jsx(t$1,{className:a(e),...t}),ru=({className:e,...t})=>jsx(s,{className:a(e),...t});var Fr=new Map,ci=e=>{let t=Fr.get(e);return t||(t=motion.create(e),Fr.set(e,t)),t},di=({children:e,as:t="p",className:o,duration:r=2,spread:a$1=2})=>{let s=ci(t),i=useMemo(()=>(e?.length??0)*a$1,[e,a$1]);return jsx(s,{animate:{backgroundPosition:"0% center"},className:a("fk:relative fk:inline-block fk:bg-[length:250%_100%,auto] fk:bg-clip-text fk:text-transparent","fk:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] fk:[background-repeat:no-repeat,padding-box]",o),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{duration:r,ease:"linear",repeat:Number.POSITIVE_INFINITY},children:e})},No=memo(di);var Or=createContext(null),Si=()=>{let e=useContext(Or);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Ii=1e3,Ni=1e3,Ri=memo(({className:e,isStreaming:t=false,open:o,defaultOpen:r,onOpenChange:a$1,duration:s,children:i,...l})=>{let f=r??t,p=r===false,[u,k]=useControllableState({defaultProp:f,onChange:a$1,prop:o}),[g,T]=useControllableState({defaultProp:void 0,prop:s}),b=useRef(t),[P,y]=useState(false),d=useRef(null);useEffect(()=>{t?(b.current=true,d.current===null&&(d.current=Date.now())):d.current!==null&&(T(Math.ceil((Date.now()-d.current)/Ni)),d.current=null);},[t,T]),useEffect(()=>{t&&!u&&!p&&k(true);},[t,u,k,p]),useEffect(()=>{if(b.current&&!t&&u&&!P){let M=setTimeout(()=>{k(false),y(true);},Ii);return ()=>clearTimeout(M)}},[t,u,k,P]);let v=useCallback(M=>{k(M);},[k]),E=useMemo(()=>({duration:g,isOpen:u,isStreaming:t,setIsOpen:k}),[g,u,t,k]);return jsx(Or.Provider,{value:E,children:jsx(ue,{className:a("fk:not-prose fk:mb-4",e),onOpenChange:v,open:u,...l,children:i})})}),Mi=(e,t)=>e||t===0?jsx(No,{duration:1,children:"Thinking..."}):t===void 0?jsx("p",{children:"Thought for a few seconds"}):jsxs("p",{children:["Thought for ",t," seconds"]}),Ai=memo(({className:e,children:t,getThinkingMessage:o=Mi,...r})=>{let{isStreaming:a$1,isOpen:s,duration:i}=Si();return jsx(me,{className:a("fk:flex fk:w-full fk:items-center fk:gap-2 fk:text-muted-foreground fk:text-sm fk:transition-colors fk:hover:text-foreground",e),...r,children:t??jsxs(Fragment,{children:[jsx(BrainIcon,{className:"fk:size-4"}),o(a$1,i),jsx(ChevronDownIcon,{className:a("fk:size-4 fk:transition-transform",s?"fk:rotate-180":"fk:rotate-0")})]})})}),Di={cjk:cjk,code:code,math:math,mermaid:mermaid},zi=memo(({className:e,children:t,...o})=>jsx(ke,{className:a("fk:mt-4 fk:text-sm","fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:slide-out-to-top-2 fk:data-[state=open]:slide-in-from-top-2 fk:text-muted-foreground fk:outline-none fk:data-[state=closed]:animate-out fk:data-[state=open]:animate-in",e),...o,children:jsx(Streamdown,{plugins:Di,children:t})}));Ri.displayName="Reasoning";Ai.displayName="ReasoningTrigger";zi.displayName="ReasoningContent";var Iu=({className:e,...t})=>jsx(ue,{className:a("fk:not-prose fk:mb-4 fk:text-primary fk:text-xs",e),...t}),Nu=({className:e,count:t,children:o,...r})=>jsx(me,{className:a("fk:flex fk:items-center fk:gap-2",e),...r,children:o??jsxs(Fragment,{children:[jsxs("p",{className:"fk:font-medium",children:["Used ",t," sources"]}),jsx(ChevronDownIcon,{className:"fk:h-4 fk:w-4"})]})}),Ru=({className:e,...t})=>jsx(ke,{className:a("fk:mt-3 fk:flex fk:w-fit fk:flex-col fk:gap-2","fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:slide-out-to-top-2 fk:data-[state=open]:slide-in-from-top-2 fk:outline-none fk:data-[state=closed]:animate-out fk:data-[state=open]:animate-in",e),...t}),Mu=({href:e,title:t,children:o,...r})=>jsx("a",{className:"fk:flex fk:items-center fk:gap-2",href:e,rel:"noreferrer",target:"_blank",...r,children:o??jsxs(Fragment,{children:[jsx(BookIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:block fk:font-medium",children:t})]})});var Gi=6e4;function Oi(){return typeof window<"u"&&"MediaRecorder"in window&&typeof navigator<"u"&&"mediaDevices"in navigator&&typeof navigator.mediaDevices.getUserMedia=="function"}function _i(){return ["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(t=>MediaRecorder.isTypeSupported(t))}function qr(e,t){return e instanceof DOMException&&(e.name==="NotAllowedError"||e.name==="PermissionDeniedError")?new Error("Microphone permission was denied. Enable the microphone to dictate."):e instanceof DOMException&&e.name==="NotFoundError"?new Error("No microphone was found."):e instanceof Error?e:new Error(t)}function Ui(e){return e instanceof Error&&e.name==="AbortError"}function qi(e,t,o){return e?o?"Cancel transcription":t?"Stop recording":"Dictate":"Dictation is not available in this browser."}var Fu=({className:e$1,disabled:t,onAudioRecorded:o,onError:r,onTranscriptionChange:a$1,size:s="icon-sm",variant:i="ghost",...l})=>{let[f,p]=useState(false),[u,k]=useState(false),[g,T]=useState(false),b$2=useRef(null),P=useRef(null),y=useRef([]),d=useRef(null),v=useRef(null),E=useRef(false),M=useRef(!!t),Me=useRef(o),W=useRef(r),st=useRef(a$1);M.current=!!t,Me.current=o,W.current=r,st.current=a$1,useEffect(()=>{T(Oi());},[]);let se=useCallback(()=>{if(P.current){for(let D of P.current.getTracks())D.stop();P.current=null;}},[]),J=useCallback(()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null);},[]),j=useCallback(()=>{J(),b$2.current?.state==="recording"&&b$2.current.stop(),p(false);},[J]),Z=useCallback(()=>{v.current?.abort(),v.current=null,k(false);},[]),F=useCallback(()=>{Z(),J();let D=b$2.current;D?.state==="recording"&&(E.current=true,D.stop()),p(false),se();},[Z,J,se]),Ae=useCallback(async()=>{if(!M.current){if(!Me.current){W.current?.(new Error("Dictation is not configured."));return}try{let D=await navigator.mediaDevices.getUserMedia({audio:!0});if(M.current){for(let Y of D.getTracks())Y.stop();return}P.current=D;let ft=_i(),ie=ft?new MediaRecorder(D,{mimeType:ft}):new MediaRecorder(D);y.current=[],ie.ondataavailable=Y=>{Y.data.size>0&&y.current.push(Y.data);},ie.onstop=async()=>{if(se(),J(),p(!1),E.current){E.current=!1,y.current=[];return}let Y=new Blob(y.current,{type:ie.mimeType||"audio/webm"});if(Y.size===0)return;let ze=new AbortController;v.current=ze,k(!0);try{let m=Me.current;if(!m)return;let x=await m(Y,ze.signal);x&&st.current?.(x);}catch(m){if(Ui(m))return;W.current?.(qr(m,"Transcription failed."));}finally{v.current===ze&&(v.current=null,k(!1));}},ie.onerror=()=>{p(!1),se(),J(),W.current?.(new Error("Recording failed. Try again."));},b$2.current=ie,ie.start(250),p(!0),d.current=window.setTimeout(()=>{j();},Gi);}catch(D){p(false),se(),W.current?.(qr(D,"Could not start the microphone."));}}},[J,se,j]);useEffect(()=>{t&&F();},[F,t]),useEffect(()=>()=>{F();},[F]);let it=useCallback(()=>{if(u){Z();return}if(f){j();return}Ae();},[Z,f,u,Ae,j]),De=t||!g||!o,lt=qi(g&&!!o,f,u);return jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsxs("span",{className:"fk:relative fk:inline-flex fk:items-center fk:justify-center",children:[f?[0,1,2].map(D=>jsx("span",{className:"fk:absolute fk:inset-0 fk:animate-ping fk:rounded-full fk:border-2 fk:border-red-400/30 fk:corner-squircle",style:{animationDelay:`${String(D*.3)}s`,animationDuration:"2s"}},D)):null,jsxs(b,{"aria-label":lt,"aria-pressed":f,size:s,variant:f?"destructive":i,...l,className:a("fk:relative fk:z-10 fk:rounded-full fk:dark:hover:bg-accent fk:corner-squircle",e$1),disabled:De,onClick:it,type:"button",children:[u?jsx(LoaderIcon,{className:"fk:size-4 fk:animate-spin"}):null,!u&&f?jsx(SquareIcon,{className:"fk:size-4"}):null,u||f?null:jsx(MicIcon,{className:"fk:size-5"})]})]})}),jsx(e,{children:lt})]})};var $u=({className:e,children:t,...o})=>jsxs(w,{className:"fk:w-full fk:overflow-x-auto fk:whitespace-nowrap",...o,children:[jsx("div",{className:a("fk:flex fk:w-max fk:flex-nowrap fk:items-center fk:gap-2",e),children:t}),jsx(x,{className:"fk:hidden",orientation:"horizontal"})]}),Wu=({suggestion:e,onClick:t,className:o,variant:r="outline",size:a$1="sm",children:s,...i})=>{let l=useCallback(()=>{t?.(e);},[t,e]);return jsx(b,{className:a("fk:cursor-pointer fk:rounded-full fk:px-4 fk:corner-squircle",o),onClick:l,size:a$1,type:"button",variant:r,...i,children:s||e})};var tm=({className:e,...t})=>jsx(ue,{className:a("fk:group fk:not-prose fk:mb-4 fk:w-full fk:rounded-md fk:border fk:corner-squircle",e),...t}),Zi={"approval-requested":"Awaiting Approval","approval-responded":"Responded","input-available":"Running","input-streaming":"Pending","output-available":"Completed","output-denied":"Denied","output-error":"Error"},Yi={"approval-requested":jsx(ClockIcon,{className:"fk:size-4 fk:text-yellow-600"}),"approval-responded":jsx(CheckCircleIcon,{className:"fk:size-4 fk:text-blue-600"}),"input-available":jsx(ClockIcon,{className:"fk:size-4 fk:animate-pulse"}),"input-streaming":jsx(CircleIcon,{className:"fk:size-4"}),"output-available":jsx(CheckCircleIcon,{className:"fk:size-4 fk:text-green-600"}),"output-denied":jsx(XCircleIcon,{className:"fk:size-4 fk:text-orange-600"}),"output-error":jsx(XCircleIcon,{className:"fk:size-4 fk:text-red-600"})},Qi=e=>jsxs(b$3,{className:"fk:gap-1.5 fk:py-px fk:rounded-full fk:text-xs fk:corner-squircle",variant:"secondary",children:[Yi[e],Zi[e]]}),om=({className:e,title:t,type:o,state:r,toolName:a$1,...s})=>{let i=o==="dynamic-tool"?a$1:o.split("-").slice(1).join("-");return jsxs(me,{className:a("fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-4 fk:px-3 fk:py-2",e),...s,children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(WrenchIcon,{className:"fk:size-4 fk:text-muted-foreground"}),jsx("span",{className:"fk:font-medium fk:text-sm",children:t??i}),Qi(r)]}),jsx(ChevronDownIcon,{className:"fk:size-4 fk:text-muted-foreground fk:transition-transform fk:group-data-[state=open]:rotate-180"})]})},rm=({className:e,...t})=>jsx(ke,{className:a("fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:slide-out-to-top-2 fk:data-[state=open]:slide-in-from-top-2 fk:space-y-4 fk:p-4 fk:text-popover-foreground fk:outline-none fk:data-[state=closed]:animate-out fk:data-[state=open]:animate-in",e),...t}),nm=({className:e,input:t,...o})=>jsxs("div",{className:a("fk:space-y-2 fk:overflow-hidden",e),...o,children:[jsx("h4",{className:"fk:font-medium fk:text-muted-foreground fk:text-xs fk:uppercase fk:tracking-wide",children:"Parameters"}),jsx("div",{className:"fk:rounded-md fk:bg-muted/50 fk:corner-squircle",children:jsx(wt,{code:JSON.stringify(t,null,2),language:"json"})})]}),am=({className:e,output:t,errorText:o,...r})=>{if(!(t||o))return null;let a$1=jsx("div",{children:t});return typeof t=="object"&&!isValidElement(t)?a$1=jsx(wt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(a$1=jsx(wt,{code:t,language:"json"})),jsxs("div",{className:a("fk:space-y-2",e),...r,children:[jsx("h4",{className:"fk:font-medium fk:text-muted-foreground fk:text-xs fk:uppercase fk:tracking-wide",children:o?"Error":"Result"}),jsxs("div",{className:a("fk:overflow-x-auto fk:rounded-md fk:text-xs fk:[&_table]:w-full fk:corner-squircle",o?"fk:bg-destructive/10 fk:text-destructive":"fk:bg-muted/50 fk:text-foreground"),children:[o&&jsx("div",{children:o}),a$1]})]})};var tl=cva("fk:relative fk:w-full fk:rounded-lg fk:border fk:px-4 fk:py-3 fk:[&>svg~*]:pl-7 fk:[&>svg+div]:translate-y-[-3px] fk:[&>svg]:absolute fk:[&>svg]:left-4 fk:[&>svg]:top-4 fk:[&>svg]:text-foreground fk:corner-squircle",{variants:{variant:{default:"fk:bg-card fk:text-card-foreground",destructive:"fk:border-none fk:text-destructive fk:bg-destructive-foreground fk:[&>svg]:text-destructive"}},defaultVariants:{variant:"default"}});function ol({className:e,variant:t,...o}){return jsx("div",{"data-slot":"alert",role:"alert",className:a(tl({variant:t}),e),...o})}function rl({className:e,...t}){return jsx("div",{"data-slot":"alert-title",className:a("fk:col-start-2 fk:line-clamp-1 fk:min-h-4 fk:font-medium fk:tracking-tight",e),...t})}function nl({className:e,...t}){return jsx("div",{"data-slot":"alert-description",className:a("fk:text-sm fk:[&_p]:leading-relaxed",e),...t})}
|
|
6
|
+
export{jn as $,Qp as $a,Ad as $b,Zt as A,_a as Aa,Jc as Ab,ru as Ac,wn as B,ko as Ba,jc as Bb,No as Bc,Tn as C,Qa as Ca,Zc as Cb,Si as Cc,_o as D,es as Da,Yc as Db,Ri as Dc,Uo as E,Ip as Ea,Qc as Eb,Ai as Ec,Yt as F,go as Fa,ed as Fb,zi as Fc,Qt as G,Np as Ga,vo as Gb,Iu as Gc,Sn as H,Rp as Ha,xo as Hb,Nu as Hc,eo as I,Mp as Ia,Po as Ib,Ru as Ic,to as J,Ap as Ja,Co as Jb,Mu as Jc,Rn as K,Dp as Ka,Ws as Kb,Fu as Kc,Ye as L,zp as La,yo as Lb,$u as Lc,Bn as M,Lp as Ma,wo as Mb,Wu as Mc,ro as N,Bp as Na,Xs as Nb,tm as Nc,En as O,vr as Oa,Ks as Ob,Qi as Oc,no as P,xs as Pa,Pd as Pb,om as Pc,Hn as Q,qp as Qa,Cd as Qb,rm as Qc,ao as R,$p as Ra,yd as Rb,nm as Rc,ct as S,Wp as Sa,It as Sb,am as Sc,so as T,Xp as Ta,Hr as Tb,ol as Tc,Fn as U,Ps as Ua,wd as Ub,rl as Uc,dt as V,wt as Va,Td as Vb,nl as Vc,ut as W,Kp as Wa,Sd as Wb,mt as X,Jp as Xa,Id as Xb,io as Y,jp as Ya,Nd as Yb,Kn as Z,Zp as Za,Rd as Zb,Jn as _,Yp as _a,Md as _b,ht as a,Zn as aa,ic as ab,Dd as ac,ua as b,Yn as ba,lc as bb,si as bc,ka as c,Qn as ca,fc as cb,zd as cc,ga as d,ea as da,pc as db,Ld as dc,$t as e,ta as ea,Is as eb,Bd as ec,Jr as f,oa as fa,cc as fb,Ed as fc,nn as g,ra as ga,Tc as gb,Hd as gc,an as h,aa as ha,Sc as hb,Fd as hc,Xe as i,ia,Ic as ib,Vd as ic,sn as j,la as ja,Nc as jb,Gd as jc,ln as k,fa as ka,Rc as kb,Od as kc,fn as l,lo as la,Mc as lb,_d as lc,pn as m,or as ma,Ac as mb,Ud as mc,cn as n,ha as na,Dc as nb,qd as nc,un as o,Qf as oa,zc as ob,$d as oc,ue as p,cr as pa,Lc as pb,Wd as pc,me as q,Os as qb,Xd as qc,ke as r,Ea as ra,Bc as rb,Kd as rc,Jt as s,et as sa,Oc as sb,Jd as sc,kn as t,tt as ta,_c as tb,jd as tc,gn as u,ot as ua,Uc as ub,Zd as uc,bn as v,uo as va,qc as vb,Yd as vc,hn as w,mo as wa,$c as wb,Qd as wc,xn as x,Ct as xa,Wc as xb,eu as xc,Pn as y,yt as ya,Xc as yb,tu as yc,Cn as z,Oa as za,Kc as zb,ou as zc};//# sourceMappingURL=chunk-DGIY4SKN.js.map
|
|
7
|
+
//# sourceMappingURL=chunk-DGIY4SKN.js.map
|