larkup 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/diagnostics/route-bundle-stats.json +6 -6
  4. package/.next/fallback-build-manifest.json +3 -3
  5. package/.next/required-server-files.js +3 -2
  6. package/.next/required-server-files.json +3 -2
  7. package/.next/server/app/_global-error.html +1 -1
  8. package/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/_not-found.html +1 -1
  16. package/.next/server/app/_not-found.rsc +16 -16
  17. package/.next/server/app/_not-found.segments/_full.segment.rsc +16 -16
  18. package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  19. package/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
  20. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  21. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  22. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next/server/app/analytics/page_client-reference-manifest.js +1 -1
  24. package/.next/server/app/analytics.html +1 -1
  25. package/.next/server/app/analytics.rsc +17 -17
  26. package/.next/server/app/analytics.segments/_full.segment.rsc +17 -17
  27. package/.next/server/app/analytics.segments/_head.segment.rsc +4 -4
  28. package/.next/server/app/analytics.segments/_index.segment.rsc +11 -11
  29. package/.next/server/app/analytics.segments/_tree.segment.rsc +1 -1
  30. package/.next/server/app/analytics.segments/analytics/__PAGE__.segment.rsc +3 -3
  31. package/.next/server/app/analytics.segments/analytics.segment.rsc +3 -3
  32. package/.next/server/app/api/chat/route.js +3 -3
  33. package/.next/server/app/api/chat/route.js.nft.json +1 -1
  34. package/.next/server/app/api/doc-editor/edit/route.js +1 -1
  35. package/.next/server/app/api/doc-editor/edit/route.js.nft.json +1 -1
  36. package/.next/server/app/api/doc-editor/export/route.js +1 -1
  37. package/.next/server/app/api/doc-editor/export/route.js.nft.json +1 -1
  38. package/.next/server/app/api/doc-editor/extract-text/route.js +1 -1
  39. package/.next/server/app/api/doc-editor/extract-text/route.js.nft.json +1 -1
  40. package/.next/server/app/api/doc-editor/parse/route.js +4 -4
  41. package/.next/server/app/api/doc-editor/parse/route.js.nft.json +1 -1
  42. package/.next/server/app/api/doc-editor/restore/route.js +1 -1
  43. package/.next/server/app/api/doc-editor/restore/route.js.nft.json +1 -1
  44. package/.next/server/app/api/document/sign/route.js +3 -3
  45. package/.next/server/app/api/document/sign/route.js.nft.json +1 -1
  46. package/.next/server/app/api/sandbox/route.js +1 -1
  47. package/.next/server/app/api/sandbox/route.js.nft.json +1 -1
  48. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  49. package/.next/server/app/chat.html +1 -1
  50. package/.next/server/app/chat.rsc +17 -17
  51. package/.next/server/app/chat.segments/_full.segment.rsc +17 -17
  52. package/.next/server/app/chat.segments/_head.segment.rsc +4 -4
  53. package/.next/server/app/chat.segments/_index.segment.rsc +11 -11
  54. package/.next/server/app/chat.segments/_tree.segment.rsc +1 -1
  55. package/.next/server/app/chat.segments/chat/__PAGE__.segment.rsc +3 -3
  56. package/.next/server/app/chat.segments/chat.segment.rsc +3 -3
  57. package/.next/server/app/data/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app/data.html +1 -1
  59. package/.next/server/app/data.rsc +17 -17
  60. package/.next/server/app/data.segments/_full.segment.rsc +17 -17
  61. package/.next/server/app/data.segments/_head.segment.rsc +4 -4
  62. package/.next/server/app/data.segments/_index.segment.rsc +11 -11
  63. package/.next/server/app/data.segments/_tree.segment.rsc +1 -1
  64. package/.next/server/app/data.segments/data/__PAGE__.segment.rsc +3 -3
  65. package/.next/server/app/data.segments/data.segment.rsc +3 -3
  66. package/.next/server/app/index.html +1 -1
  67. package/.next/server/app/index.rsc +16 -16
  68. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  69. package/.next/server/app/index.segments/_full.segment.rsc +16 -16
  70. package/.next/server/app/index.segments/_head.segment.rsc +4 -4
  71. package/.next/server/app/index.segments/_index.segment.rsc +11 -11
  72. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  73. package/.next/server/app/page_client-reference-manifest.js +1 -1
  74. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  75. package/.next/server/app/settings.html +1 -1
  76. package/.next/server/app/settings.rsc +18 -18
  77. package/.next/server/app/settings.segments/_full.segment.rsc +18 -18
  78. package/.next/server/app/settings.segments/_head.segment.rsc +4 -4
  79. package/.next/server/app/settings.segments/_index.segment.rsc +11 -11
  80. package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  81. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +4 -4
  82. package/.next/server/app/settings.segments/settings.segment.rsc +3 -3
  83. package/.next/server/chunks/{[root-of-the-server]__0lczaer._.js → [root-of-the-server]__06lx~f.._.js} +8 -8
  84. package/.next/server/chunks/{[root-of-the-server]__0qs73xp._.js → [root-of-the-server]__06w.x2m._.js} +8 -8
  85. package/.next/server/chunks/{[root-of-the-server]__03l~uw5._.js → [root-of-the-server]__08y6gy_._.js} +8 -8
  86. package/.next/server/chunks/{[root-of-the-server]__0veqa4o._.js → [root-of-the-server]__0dlwf67._.js} +1 -1
  87. package/.next/server/chunks/{[root-of-the-server]__0g36cgg._.js → [root-of-the-server]__0jrhbq8._.js} +8 -8
  88. package/.next/server/chunks/{[root-of-the-server]__10zm06g._.js → [root-of-the-server]__0oblxyb._.js} +8 -8
  89. package/.next/server/chunks/{[root-of-the-server]__100gqj0._.js → [root-of-the-server]__0ougw4j._.js} +8 -8
  90. package/.next/server/chunks/{[root-of-the-server]__044l2_f._.js → [root-of-the-server]__0yj9mzb._.js} +9 -9
  91. package/.next/server/chunks/{[root-of-the-server]__0036943._.js → [root-of-the-server]__13ydff-._.js} +8 -8
  92. package/.next/server/chunks/ssr/_0s5_0n1._.js +1 -1
  93. package/.next/server/middleware-build-manifest.js +3 -3
  94. package/.next/server/pages/404.html +1 -1
  95. package/.next/server/pages/500.html +1 -1
  96. package/.next/static/chunks/{0u4n0ggeto75y.js → 0ia5xz-yykcrq.js} +1 -1
  97. package/CHANGELOG.md +15 -0
  98. package/next-env.d.ts +1 -1
  99. package/next.config.mjs +1 -1
  100. package/package.json +4 -4
  101. /package/.next/static/{Fb01QU1MyWBHc7U1LHf5y → rZLjWvDwdTV-PtUjl-1-b}/_buildManifest.js +0 -0
  102. /package/.next/static/{Fb01QU1MyWBHc7U1LHf5y → rZLjWvDwdTV-PtUjl-1-b}/_clientMiddlewareManifest.js +0 -0
  103. /package/.next/static/{Fb01QU1MyWBHc7U1LHf5y → rZLjWvDwdTV-PtUjl-1-b}/_ssgManifest.js +0 -0
@@ -54,11 +54,11 @@ RESPONSE FORMATTING (Analytics Style):
54
54
  - Structure complex responses logically (e.g., Summary -> Key Metrics -> Breakdown).
55
55
  - If your findings contain a small table of data, format it cleanly using Markdown tables.
56
56
  - DO NOT hallucinate facts; rely strictly on the provided query results.
57
- - End with a one-sentence synthesis if appropriate, avoiding filler words.`;e.s(["DEFAULT_CONFIG",0,i,"DEFAULT_DEPLOYMENT_CONFIG",0,{type:"rag-only",authMode:"none",enabledToolIds:[],widgetStyle:{primaryColor:"#000000",position:"bottom-right",title:"Chat with AI",welcomeMessage:"Hi! How can I help you today?",placeholder:"Type a message...",darkMode:!1,borderRadius:"lg"},allowedOrigins:["*"]},"DEFAULT_SYSTEM_PROMPT",0,s],638725);let l=r.default.join(process.cwd(),".larkup"),d=r.default.join(l,"servers"),c=r.default.join(l,"workspace.json"),u={username:null,activeServerId:null,servers:[],mode:null},p=new n.AsyncLocalStorage,m=Promise.resolve();function f(e){let t=m.then(e,e);return m=t.catch(()=>{}),t}async function h(e){return await x(),f(async()=>e(await v()??u))}function g(e){return r.default.join(d,e)}function y(e,t){return`./.larkup/servers/${e}/${t}`}async function b(e){try{return await t.promises.access(e),!0}catch{return!1}}async function w(e,a){if(await b(e)){await t.promises.mkdir(r.default.dirname(a),{recursive:!0});try{await t.promises.rename(e,a)}catch{await t.promises.cp(e,a,{recursive:!0}),await t.promises.rm(e,{recursive:!0,force:!0})}}}async function v(){try{let e=await t.promises.readFile(c,"utf8");return{...u,...JSON.parse(e)}}catch{return null}}async function k(e){return await t.promises.mkdir(l,{recursive:!0}),await t.promises.writeFile(c,JSON.stringify(e,null,2),"utf8"),e}async function x(){let e=await v();return e||f(S)}async function S(){let e=await v();if(e)return e;if(!await b(r.default.join(l,"config.json")))return k(u);let n=(0,a.randomUUID)(),o=g(n);for(let e of(await t.promises.mkdir(o,{recursive:!0}),["config.json","documents.json","jobs.json","index-run.json","server-local.json"]))await w(r.default.join(l,e),r.default.join(o,e));await w(r.default.join(l,"lancedb"),r.default.join(o,"lancedb")),await w(r.default.join(l,"generated-server"),r.default.join(o,"generated-server"));let i="Default server";try{let e=r.default.join(o,"config.json"),a=JSON.parse(await t.promises.readFile(e,"utf8"));a.projectName&&(i=a.projectName),"lancedb"===a.vectorStore&&(a.storeConfig?.mode??"local")==="local"&&(a.storeConfig={...a.storeConfig,dbPath:y(n,"lancedb")}),await t.promises.writeFile(e,JSON.stringify(a,null,2),"utf8")}catch{}let s=new Date().toISOString(),d={id:n,name:i,port:8080,createdAt:s,updatedAt:s};return k({username:null,activeServerId:n,servers:[d],mode:null})}async function _(){let e=await x(),t=p.getStore()?.serverId??e.activeServerId;return t?e.servers.find(e=>e.id===t)??null:null}async function A(){let e=await _();if(!e)return null;let r=g(e.id);return await t.promises.mkdir(r,{recursive:!0}),r}async function T(){let e=await A();if(e)return e;let t=p.getStore()?.serverId;if(t)throw Error(`Server "${t}" no longer exists.`);let{server:r}=await O("my-larkup");return g(r.id)}async function I(e){return new Promise(t=>{let r=o.default.createServer();r.once("error",()=>t(!1)),r.once("listening",()=>{r.close(()=>t(!0))}),r.listen(e,"127.0.0.1")})}async function D(e){let t=Math.max(8079,...e.servers.map(e=>e.port))+1;for(;!await I(t);)t++;return t}function O(e){return h(async n=>{let o=(0,a.randomUUID)(),s=new Date().toISOString(),l={id:o,name:e.trim()||"Untitled server",port:await D(n),createdAt:s,updatedAt:s},d=g(o);await t.promises.mkdir(d,{recursive:!0});let c={};if(n.activeServerId)try{let e=await t.promises.readFile(r.default.join(g(n.activeServerId),"config.json"),"utf8");c=JSON.parse(e)}catch{}await t.promises.writeFile(r.default.join(d,"config.json"),JSON.stringify(function(e,t,r={}){return{...i,projectName:t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"my-larkup",storeConfig:{mode:"local",dbPath:y(e,"lancedb")},embeddingApiKey:r.embeddingApiKey??i.embeddingApiKey,customEmbeddings:r.customEmbeddings??i.customEmbeddings,chatApiKey:r.chatApiKey??i.chatApiKey,customChatModels:r.customChatModels??i.customChatModels,serperApiKey:r.serperApiKey??i.serperApiKey,firecrawlApiKey:r.firecrawlApiKey??i.firecrawlApiKey,updatedAt:new Date().toISOString()}}(o,l.name,c),null,2),"utf8");let u={...n,servers:[...n.servers,l],activeServerId:o};return await k(u),{workspace:u,server:l}})}e.s(["createServer",0,O,"deleteServer",0,function(e){return h(async r=>{let a=r.servers.filter(t=>t.id!==e),n=r.activeServerId===e?a[0]?.id??null:r.activeServerId;return await t.promises.rm(g(e),{recursive:!0,force:!0}),k({...r,servers:a,activeServerId:n})})},"getActiveServer",0,_,"getDataDir",0,A,"getWorkspace",0,x,"renameServer",0,function(e,t){return h(async r=>{let a=r.servers.map(r=>r.id===e?{...r,name:t.trim()||r.name,updatedAt:new Date().toISOString()}:r);return k({...r,servers:a})})},"requireDataDir",0,T,"runWithServer",0,function(e,t){return p.run({serverId:e},t)},"setActiveServer",0,function(e){return h(async t=>t.servers.some(t=>t.id===e)?k({...t,activeServerId:e}):t)},"setMode",0,function(e){return h(async t=>k({...t,mode:e}))},"setUsername",0,function(e){return h(async t=>k({...t,username:e.trim()||null}))}],192441)},367165,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(638725),n=e.i(192441);async function o(){let e=await (0,n.getDataDir)();if(!e)return a.DEFAULT_CONFIG;try{let n=await t.promises.readFile(r.default.join(e,"config.json"),"utf8"),o=JSON.parse(n),i=o.customEmbeddings,s=o.embeddingModelId;if(o.customEmbedding&&!i?.length){let e=o.customEmbedding;i=[e],"custom"===s&&(s=`custom:${e.modelName}`)}let l={...a.DEFAULT_CONFIG,...o,embeddingModelId:s??a.DEFAULT_CONFIG.embeddingModelId,customEmbeddings:i,chunking:{...a.DEFAULT_CONFIG.chunking,...o.chunking},storeConfig:{...a.DEFAULT_CONFIG.storeConfig,...o.storeConfig}};return delete l.customEmbedding,l}catch{return a.DEFAULT_CONFIG}}async function i(e){let a=await (0,n.requireDataDir)(),o={...e,updatedAt:new Date().toISOString()};return await t.promises.writeFile(r.default.join(a,"config.json"),JSON.stringify(o,null,2),"utf8"),o}e.s(["readConfig",0,o,"writeConfig",0,i])},874533,(e,t,r)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},812057,(e,t,r)=>{t.exports=e.x("node:util",()=>require("node:util"))},814747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},522734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},446786,(e,t,r)=>{t.exports=e.x("os",()=>require("os"))},310470,(e,t,r)=>{"use strict";var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={},l={VercelOidcTokenError:()=>c};for(var d in l)a(s,d,{get:l[d],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);class c extends Error{constructor(e,t){super(e),this.name="VercelOidcTokenError",this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}}},33015,(e,t,r)=>{"use strict";var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={},l={AccessTokenMissingError:()=>c,RefreshAccessTokenFailedError:()=>u};for(var d in l)a(s,d,{get:l[d],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);class c extends Error{constructor(){super("No authentication found. Please log in with the Vercel CLI (vercel login)."),this.name="AccessTokenMissingError"}}class u extends Error{constructor(e){super("Failed to refresh authentication token.",{cause:e}),this.name="RefreshAccessTokenFailedError"}}},250216,(e,t,r)=>{"use strict";var a=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,d=(e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))l.call(e,s)||s===r||n(e,s,{get:()=>t[s],enumerable:!(a=o(t,s))||a.enumerable});return e},c=(e,t,r)=>(r=null!=e?a(s(e)):{},d(!t&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),u={},p={findRootDir:()=>b,getUserDataDir:()=>w};for(var m in p)n(u,m,{get:p[m],enumerable:!0});t.exports=d(n({},"__esModule",{value:!0}),u);var f=c(e.r(814747)),h=c(e.r(522734)),g=c(e.r(446786)),y=e.r(310470);function b(){try{let e=process.cwd();for(;e!==f.default.dirname(e);){let t=f.default.join(e,".vercel");if(h.default.existsSync(t))return e;e=f.default.dirname(e)}}catch(e){throw new y.VercelOidcTokenError("Token refresh only supported in node server environments")}return null}function w(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(g.default.platform()){case"darwin":return f.default.join(g.default.homedir(),"Library/Application Support");case"linux":return f.default.join(g.default.homedir(),".local/share");case"win32":if(process.env.LOCALAPPDATA)return process.env.LOCALAPPDATA;return null;default:return null}}},775427,(e,t,r)=>{"use strict";var a=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,d=(e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))l.call(e,s)||s===r||n(e,s,{get:()=>t[s],enumerable:!(a=o(t,s))||a.enumerable});return e},c=(e,t,r)=>(r=null!=e?a(s(e)):{},d(!t&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),u={},p={isValidAccessToken:()=>v,readAuthConfig:()=>b,writeAuthConfig:()=>w};for(var m in p)n(u,m,{get:p[m],enumerable:!0});t.exports=d(n({},"__esModule",{value:!0}),u);var f=c(e.r(522734)),h=c(e.r(814747)),g=e.r(65048);function y(){let e=(0,g.getVercelDataDir)();if(!e)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return h.join(e,"auth.json")}function b(){try{let e=y();if(!f.existsSync(e))return null;let t=f.readFileSync(e,"utf8");if(!t)return null;return JSON.parse(t)}catch(e){return null}}function w(e){let t=y(),r=h.dirname(t);f.existsSync(r)||f.mkdirSync(r,{mode:504,recursive:!0}),f.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function v(e,t=0){if(!e.token)return!1;if("number"!=typeof e.expiresAt)return!0;let r=Math.floor(Date.now()/1e3);return e.expiresAt>=r+t/1e3}},371746,(e,t,r)=>{"use strict";var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={},l={processTokenResponse:()=>h,refreshTokenRequest:()=>f};for(var d in l)a(s,d,{get:l[d],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);var c=e.r(446786);let u=`@vercel/oidc node-${process.version} ${(0,c.platform)()} (${(0,c.arch)()}) ${(0,c.hostname)()}`,p=null;async function m(){if(p)return p;let e=await fetch("https://vercel.com/.well-known/openid-configuration",{headers:{"user-agent":u}});if(!e.ok)throw Error("Failed to discover OAuth endpoints");let t=await e.json();if(!t||"string"!=typeof t.token_endpoint)throw Error("Invalid OAuth discovery response");let r=t.token_endpoint;return p=r,r}async function f(e){let t=await m();return await fetch(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","user-agent":u},body:new URLSearchParams({client_id:"cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp",grant_type:"refresh_token",...e})})}async function h(e){let t=await e.json();return e.ok?"object"!=typeof t||null===t?[Error("Invalid token response")]:"string"!=typeof t.access_token?[Error("Missing access_token in response")]:"Bearer"!==t.token_type?[Error("Invalid token_type in response")]:"number"!=typeof t.expires_in?[Error("Missing expires_in in response")]:[null,t]:[Error("object"==typeof t&&t&&"error"in t?String(t.error):"Token refresh failed")]}},65048,(e,t,r)=>{"use strict";var a=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,d=(e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))l.call(e,s)||s===r||n(e,s,{get:()=>t[s],enumerable:!(a=o(t,s))||a.enumerable});return e},c=(e,t,r)=>(r=null!=e?a(s(e)):{},d(!t&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),u={},p={assertVercelOidcTokenResponse:()=>_,findProjectInfo:()=>A,getTokenPayload:()=>D,getVercelDataDir:()=>k,getVercelOidcToken:()=>S,getVercelToken:()=>x,isExpired:()=>O,loadToken:()=>I,saveToken:()=>T};for(var m in p)n(u,m,{get:p[m],enumerable:!0});t.exports=d(n({},"__esModule",{value:!0}),u);var f=c(e.r(814747)),h=c(e.r(522734)),g=e.r(310470),y=e.r(250216),b=e.r(775427),w=e.r(371746),v=e.r(33015);function k(){let e=(0,y.getUserDataDir)();return e?f.join(e,"com.vercel.cli"):null}async function x(e){let t=(0,b.readAuthConfig)();if(!t?.token)throw new v.AccessTokenMissingError;if((0,b.isValidAccessToken)(t,e?.expirationBufferMs))return t.token;if(!t.refreshToken)throw(0,b.writeAuthConfig)({}),new v.RefreshAccessTokenFailedError("No refresh token available");try{let e=await (0,w.refreshTokenRequest)({refresh_token:t.refreshToken}),[r,a]=await (0,w.processTokenResponse)(e);if(r||!a)throw(0,b.writeAuthConfig)({}),new v.RefreshAccessTokenFailedError(r);let n={token:a.access_token,expiresAt:Math.floor(Date.now()/1e3)+a.expires_in};return a.refresh_token&&(n.refreshToken=a.refresh_token),(0,b.writeAuthConfig)(n),n.token}catch(e){if((0,b.writeAuthConfig)({}),e instanceof v.AccessTokenMissingError||e instanceof v.RefreshAccessTokenFailedError)throw e;throw new v.RefreshAccessTokenFailedError(e)}}async function S(e,t,r){let a=`https://api.vercel.com/v1/projects/${t}/token?source=vercel-oidc-refresh${r?`&teamId=${r}`:""}`,n=await fetch(a,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!n.ok)throw new g.VercelOidcTokenError(`Failed to refresh OIDC token: ${n.statusText}`);let o=await n.json();return _(o),o}function _(e){if(!e||"object"!=typeof e)throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!("token"in e)||"string"!=typeof e.token)throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function A(){let e=(0,y.findRootDir)();if(!e)throw new g.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let t=f.join(e,".vercel","project.json");if(!h.existsSync(t))throw new g.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let r=JSON.parse(h.readFileSync(t,"utf8"));if("string"!=typeof r.projectId&&"string"!=typeof r.orgId)throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:r.projectId,teamId:r.orgId}}function T(e,t){let r=(0,y.getUserDataDir)();if(!r)throw new g.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let a=f.join(r,"com.vercel.token",`${t}.json`),n=JSON.stringify(e);h.mkdirSync(f.dirname(a),{mode:504,recursive:!0}),h.writeFileSync(a,n),h.chmodSync(a,432)}function I(e){let t=(0,y.getUserDataDir)();if(!t)throw new g.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let r=f.join(t,"com.vercel.token",`${e}.json`);if(!h.existsSync(r))return null;let a=JSON.parse(h.readFileSync(r,"utf8"));return _(a),a}function D(e){let t=e.split(".");if(3!==t.length)throw new g.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let r=t[1].replace(/-/g,"+").replace(/_/g,"/"),a=r.padEnd(r.length+(4-r.length%4)%4,"=");return JSON.parse(Buffer.from(a,"base64").toString("utf8"))}function O(e,t=0){return 1e3*e.exp<Date.now()+t}},705252,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(666680),n=e.i(192441);let o=Promise.resolve();function i(e){let t=o.then(e,e);return o=t.catch(()=>{}),t}async function s(e){let t=e?await (0,n.requireDataDir)():await (0,n.getDataDir)();return t?r.default.join(t,"documents.json"):null}async function l(){let e=await s(!1);if(!e)return[];try{let r=await t.promises.readFile(e,"utf8"),a=JSON.parse(r);if(!Array.isArray(a))throw Error(`Invalid document store at ${e}: expected a JSON array.`);return a}catch(e){if(e?.code==="ENOENT")return[];throw e}}async function d(e){let n=await s(!0);if(!n)return;let o=r.default.join(r.default.dirname(n),`.${r.default.basename(n)}.${process.pid}.${(0,a.randomUUID)()}.tmp`);try{await t.promises.writeFile(o,JSON.stringify(e,null,2),"utf8"),await t.promises.rename(o,n)}catch(e){throw await t.promises.unlink(o).catch(()=>{}),e}}function c(e){let t=e.content.trim();return{id:e.id??(0,a.randomUUID)(),title:e.title.trim()||"Untitled",url:e.url,source:e.source,content:t,charCount:t.length,jobId:e.jobId,metadata:e.metadata,status:"unindexed",createdAt:new Date().toISOString()}}async function u(){let e=await l(),t=e.reduce((e,t)=>e+t.charCount,0);return{docCount:e.length,charCount:t,bySource:e.reduce((e,t)=>(e[t.source]=(e[t.source]??0)+1,e),{})}}e.s(["addCrawledDocuments",0,function(e,t){return i(async()=>{let r=await l(),a=new Set(r.filter(e=>e.url).map(e=>e.url)),n=0;for(let o of t)!(o.url&&a.has(o.url))&&o.content.trim()&&(r.push(c({...o,jobId:e})),o.url&&a.add(o.url),n++);return n>0&&await d(r),n})},"addDocument",0,function(e){return i(async()=>{let t=await l(),r=c(e);return t.push(r),await d(t),r})},"addDocuments",0,function(e){return i(async()=>{if(0===e.length)return[];let t=await l(),r=e.map(c);return t.push(...r),await d(t),r})},"clearDocuments",0,function(){return i(async()=>{await d([])})},"corpusStats",0,u,"deleteDocument",0,function(e){return i(async()=>{let t=await l();await d(t.filter(t=>t.id!==e))})},"deleteDocuments",0,function(e){return i(async()=>{let t=await l(),r=new Set(e);await d(t.filter(e=>!r.has(e.id)))})},"readDocuments",0,l,"replaceDocuments",0,function(e){return i(async()=>{let t=new Date().toISOString();await d(e.map(e=>({...e,status:"unindexed",createdAt:e.createdAt||t})))})},"updateDocument",0,function(e,t){return i(async()=>{let r=await l(),a=r.findIndex(t=>t.id===e);if(a<0)return;let n=r[a],o=void 0!==t.content?t.content.trim():n.content,i={...n,title:void 0!==t.title?t.title.trim()||"Untitled":n.title,content:o,charCount:o.length,url:void 0!==t.url?t.url||void 0:n.url,metadata:void 0!==t.metadata?t.metadata:n.metadata,status:"unindexed"};return r[a]=i,await d(r),i})},"updateDocumentsStatus",0,function(e,t){return i(async()=>{let r=await l(),a=new Set(e),n=!1;for(let e of r)a.has(e.id)&&(e.status=t,n=!0);n&&await d(r)})}])},399828,e=>{"use strict";let t={"openai/text-embedding-3-small":{dimensions:1536,maxInputTokens:8191},"openai/text-embedding-3-large":{dimensions:3072,maxInputTokens:8191},"openai/text-embedding-ada-002":{dimensions:1536,maxInputTokens:8191},"google/gemini-embedding-2":{dimensions:768,maxInputTokens:2048},"google/gemini-embedding-001":{dimensions:768,maxInputTokens:2048},"cohere/embed-english-v3.0":{dimensions:1024,maxInputTokens:512},"cohere/embed-multilingual-v3.0":{dimensions:1024,maxInputTokens:512},"voyage/voyage-3":{dimensions:1024,maxInputTokens:32e3},"voyage/voyage-3-lite":{dimensions:512,maxInputTokens:32e3},"voyage/voyage-code-3":{dimensions:1024,maxInputTokens:32e3},"mistral/mistral-embed":{dimensions:1024,maxInputTokens:8192},"jina/jina-embeddings-v3":{dimensions:1024,maxInputTokens:8192},"jina/jina-clip-v2":{dimensions:1024,maxInputTokens:8192},"nomic/nomic-embed-text-v1.5":{dimensions:768,maxInputTokens:8192}},r=[{id:"openai/text-embedding-3-small",label:"text-embedding-3-small",provider:"openai",dimensions:1536,maxInputTokens:8191,description:"Fast, cheap, strong general-purpose default."},{id:"openai/text-embedding-3-large",label:"text-embedding-3-large",provider:"openai",dimensions:3072,maxInputTokens:8191,description:"Highest quality OpenAI embeddings, larger vectors."},{id:"openai/text-embedding-ada-002",label:"text-embedding-ada-002",provider:"openai",dimensions:1536,maxInputTokens:8191,description:"Legacy model — kept for backward compatibility."},{id:"google/gemini-embedding-001",label:"gemini-embedding-001",provider:"google",dimensions:768,maxInputTokens:2048,description:"Gemini embedding 001."},{id:"cohere/embed-english-v3.0",label:"embed-english-v3.0",provider:"cohere",dimensions:1024,maxInputTokens:512,description:"Tuned for retrieval; great for English-heavy corpora."},{id:"cohere/embed-multilingual-v3.0",label:"embed-multilingual-v3.0",provider:"cohere",dimensions:1024,maxInputTokens:512,description:"100+ language multilingual retrieval embeddings."},{id:"voyage/voyage-3",label:"voyage-3",provider:"voyage",dimensions:1024,maxInputTokens:32e3,description:"Voyage's best general-purpose retrieval model."},{id:"voyage/voyage-3-lite",label:"voyage-3-lite",provider:"voyage",dimensions:512,maxInputTokens:32e3,description:"Optimized for latency and cost with strong performance."},{id:"voyage/voyage-code-3",label:"voyage-code-3",provider:"voyage",dimensions:1024,maxInputTokens:32e3,description:"Specialized for code retrieval tasks."},{id:"mistral/mistral-embed",label:"mistral-embed",provider:"mistral",dimensions:1024,maxInputTokens:8192,description:"Mistral's efficient embedding model for retrieval."},{id:"jina/jina-embeddings-v3",label:"jina-embeddings-v3",provider:"jina",dimensions:1024,maxInputTokens:8192,description:"Multilingual, task-specific embeddings from Jina AI."},{id:"jina/jina-clip-v2",label:"jina-clip-v2",provider:"jina",dimensions:1024,maxInputTokens:8192,description:"Multimodal embeddings for text and images."},{id:"nomic/nomic-embed-text-v1.5",label:"nomic-embed-text-v1.5",provider:"nomic",dimensions:768,maxInputTokens:8192,description:"Open-source, highly capable text embeddings."}];e.s(["EMBEDDING_DIMENSIONS",0,t,"EMBEDDING_MODELS",0,r,"getEmbeddingModel",0,function(e){return r.find(t=>t.id===e)},"getEmbeddingModelsForProvider",0,function(e,t){return"vercel_ai_gateway"===t?e:e.filter(e=>e.provider?.toLowerCase()===t.toLowerCase())},"toEmbeddingDescriptor",0,function(e){let r=t[e.id],a=e.id.split("/")[0]||e.owned_by;return{id:e.id,label:e.name||e.id.split("/").slice(1).join("/"),provider:a,dimensions:r?.dimensions??e.context_window??768,maxInputTokens:r?.maxInputTokens??e.max_tokens??2048,description:e.description||""}}])},979598,e=>{"use strict";let t={lancedb:{id:"lancedb",label:"LanceDB",description:"Embedded vector database for local development, LanceDB Cloud, or persistent S3-compatible storage such as Cloudflare R2.",runtime:"both",installStatus:"installed",docsUrl:"https://lancedb.github.io/lancedb/",serverDependencies:{"@lancedb/lancedb":"^0.30.0"},fields:[{key:"mode",label:"Mode",type:"select",required:!0,defaultValue:"local",help:"Use a local disk, LanceDB Cloud, or an S3-compatible bucket for persistent serverless deployments.",options:[{label:"Local (on-disk)",value:"local"},{label:"S3-compatible (Vercel / R2 / S3)",value:"s3"},{label:"Cloud",value:"cloud"}]},{key:"dbPath",label:"Database path",type:"path",required:!0,defaultValue:"./.larkup/lancedb",placeholder:"./.larkup/lancedb",help:"Directory where the LanceDB tables are stored.",showWhen:{key:"mode",equals:["local"]}},{key:"s3Uri",label:"Database URI",type:"text",required:!0,placeholder:"s3://my-bucket/larkup/my-server",help:"A dedicated, private bucket prefix for LanceDB table files. This is persistent across Vercel invocations.",showWhen:{key:"mode",equals:["s3"]}},{key:"s3Endpoint",label:"S3 endpoint",type:"text",required:!1,placeholder:"https://<account-id>.r2.cloudflarestorage.com",help:"Required for Cloudflare R2 and other S3-compatible providers. Leave blank for AWS S3.",showWhen:{key:"mode",equals:["s3"]}},{key:"s3Region",label:"Region",type:"text",required:!0,defaultValue:"auto",placeholder:"auto",help:"Use “auto” for Cloudflare R2, or your bucket region for AWS S3.",showWhen:{key:"mode",equals:["s3"]}},{key:"s3AccessKeyId",label:"Access key ID",type:"password",required:!0,secret:!0,help:"Use an object read/write credential restricted to this bucket.",showWhen:{key:"mode",equals:["s3"]}},{key:"s3SecretAccessKey",label:"Secret access key",type:"password",required:!0,secret:!0,help:"Stored as a deployment environment variable; never expose it in the browser.",showWhen:{key:"mode",equals:["s3"]}},{key:"uri",label:"Cloud URI",type:"text",required:!0,placeholder:"db://my-database",help:"Your LanceDB Cloud database URI.",showWhen:{key:"mode",equals:["cloud"]}},{key:"apiKey",label:"API key",type:"password",required:!0,secret:!0,placeholder:"sk_...",help:"LanceDB Cloud API key. Stored as an env var in the generated server.",showWhen:{key:"mode",equals:["cloud"]}},{key:"tableName",label:"Table name",type:"text",required:!0,defaultValue:"documents",help:"The table that holds your embedded chunks."}]},pinecone:{id:"pinecone",label:"Pinecone",description:"Fully-managed cloud vector database. Cloud-only — requires an API key and an existing index.",runtime:"cloud",installStatus:"installed",docsUrl:"https://docs.pinecone.io/",serverDependencies:{"@pinecone-database/pinecone":"^6.0.0"},fields:[{key:"apiKey",label:"API key",type:"password",required:!0,secret:!0,placeholder:"pcsk_...",help:"Pinecone API key. Stored as an env var in the generated server."},{key:"indexName",label:"Index name",type:"text",required:!0,placeholder:"rag-index",help:"Name of the Pinecone index to upsert into / query. For hybrid/lexical mode this index must use the 'dotproduct' metric."},{key:"namespace",label:"Namespace",type:"text",required:!1,placeholder:"default",help:"Optional namespace to isolate this dataset within the index."},{key:"sparseModel",label:"Sparse model",type:"text",required:!0,defaultValue:"pinecone-sparse-english-v0",help:"Pinecone-hosted sparse model used to generate keyword vectors via the Inference API. Both dense and sparse vectors are stored in the same index.",showWhenIndexType:["lexical","hybrid"]}]},weaviate:{id:"weaviate",label:"Weaviate",description:"Open-source AI-native vector database with built-in hybrid search, BM25, and multi-tenancy.",runtime:"both",installStatus:"coming-soon",docsUrl:"https://weaviate.io/developers/weaviate",serverDependencies:{weaviate:"^3.0.0"},fields:[{key:"host",label:"Host URL",type:"text",required:!0,placeholder:"https://my-cluster.weaviate.network",help:"Weaviate Cloud URL or self-hosted host address."},{key:"apiKey",label:"API key",type:"password",required:!1,secret:!0,placeholder:"weaviate-api-key",help:"Weaviate Cloud API key (optional for self-hosted)."},{key:"className",label:"Collection name",type:"text",required:!0,defaultValue:"Documents",help:"The Weaviate collection (class) that holds your embedded chunks."}]},qdrant:{id:"qdrant",label:"Qdrant",description:"High-performance vector search engine with rich filtering, built for production-scale RAG.",runtime:"both",installStatus:"coming-soon",docsUrl:"https://qdrant.tech/documentation/",serverDependencies:{"@qdrant/js-client-rest":"^1.9.0"},fields:[{key:"url",label:"Host URL",type:"text",required:!0,placeholder:"http://localhost:6333",help:"Qdrant server URL (local or Qdrant Cloud endpoint)."},{key:"apiKey",label:"API key",type:"password",required:!1,secret:!0,placeholder:"qdrant-api-key",help:"Qdrant Cloud API key (leave blank for local)."},{key:"collectionName",label:"Collection name",type:"text",required:!0,defaultValue:"documents",help:"Qdrant collection to upsert into and query."}]},chroma:{id:"chroma",label:"Chroma",description:"Open-source, developer-friendly embedding database. Great for rapid local prototyping.",runtime:"both",installStatus:"installable",docsUrl:"https://docs.trychroma.com/",serverDependencies:{chromadb:"^1.9.0"},fields:[{key:"mode",label:"Mode",type:"select",required:!0,defaultValue:"server",help:"Server connects to a self-hosted Chroma instance. Cloud connects to Chroma Cloud.",options:[{label:"Server (Self-hosted)",value:"server"},{label:"Cloud (Chroma Cloud)",value:"cloud"}]},{key:"host",label:"Server URL",type:"text",required:!0,placeholder:"http://localhost:8000",defaultValue:"http://localhost:8000",help:"Chroma server URL (local Docker or remote).",showWhen:{key:"mode",equals:["server"]}},{key:"authToken",label:"Auth Token",type:"password",required:!1,secret:!0,placeholder:"chroma-token",help:"Optional static auth token for Chroma server.",showWhen:{key:"mode",equals:["server"]}},{key:"apiKey",label:"API Key",type:"password",required:!0,secret:!0,placeholder:"sk_...",help:"Chroma Cloud API Key.",showWhen:{key:"mode",equals:["cloud"]}},{key:"tenant",label:"Tenant",type:"text",required:!0,defaultValue:"default_tenant",help:"Tenant name for Chroma Cloud.",showWhen:{key:"mode",equals:["cloud"]}},{key:"database",label:"Database",type:"text",required:!0,defaultValue:"default_database",help:"Database name for Chroma Cloud.",showWhen:{key:"mode",equals:["cloud"]}},{key:"collectionName",label:"Collection name",type:"text",required:!0,defaultValue:"documents",help:"Chroma collection to store and retrieve embeddings."}]},pgvector:{id:"pgvector",label:"pgvector",description:"PostgreSQL extension for vector similarity search. Self-host vectors alongside your relational data.",runtime:"both",installStatus:"coming-soon",docsUrl:"https://github.com/pgvector/pgvector",serverDependencies:{pg:"^8.11.0",pgvector:"^0.2.0"},fields:[{key:"connectionString",label:"Connection string",type:"password",required:!0,secret:!0,placeholder:"postgresql://user:pass@localhost:5432/db",help:"Full PostgreSQL connection string."},{key:"tableName",label:"Table name",type:"text",required:!0,defaultValue:"embeddings",help:"The table used to store vector embeddings. Created automatically if absent."}]},supabase:{id:"supabase",label:"Supabase",description:"Postgres-backed vector store via the pgvector extension with Supabase's managed infrastructure.",runtime:"cloud",installStatus:"coming-soon",docsUrl:"https://supabase.com/docs/guides/ai",serverDependencies:{"@supabase/supabase-js":"^2.43.0"},fields:[{key:"url",label:"Project URL",type:"text",required:!0,placeholder:"https://xyz.supabase.co",help:"Your Supabase project URL."},{key:"serviceKey",label:"Service role key",type:"password",required:!0,secret:!0,placeholder:"eyJhbGci...",help:"Supabase service_role key (not the anon key). Stored as an env var."},{key:"tableName",label:"Table name",type:"text",required:!0,defaultValue:"documents",help:"Supabase table with a vector column for embeddings."}]}};Object.values(t),e.s(["getVectorStore",0,function(e){return t[e]},"validateStoreConfig",0,function(e,t,r){let a={};for(let n of e.fields.filter(e=>{if(e.showWhen){let r=t[e.showWhen.key]??"";if(!e.showWhen.equals.includes(r))return!1}return!e.showWhenIndexType||!r||!!e.showWhenIndexType.includes(r)}))n.required&&!t[n.key]?.trim()&&(a[n.key]=`${n.label} is required`);return a}])},585071,e=>{"use strict";var t=e.i(192441);async function r(r,a){let n={...r.storeConfig},o=await (0,t.getActiveServer)(),i=o?.id;if(i){let e=i.replace(/[^a-zA-Z0-9_-]/g,"_");"pinecone"===r.vectorStore?n.namespace=i:"chroma"===r.vectorStore?n.collectionName=`documents_${e}`:"lancedb"!==r.vectorStore&&r.vectorStore||(n.tableName=`documents_${e}`)}switch(r.vectorStore){case"pinecone":{let{PineconeAdapter:t}=await e.A(77149);return new t({apiKey:n.apiKey,indexName:n.indexName,namespace:n.namespace,sparseModel:n.sparseModel,indexType:r.indexType,onRateLimit:a})}case"chroma":{let{ChromaAdapter:t}=await e.A(195059);return new t({mode:n.mode,host:n.host,authToken:n.authToken,apiKey:n.apiKey,tenant:n.tenant,database:n.database,collectionName:n.collectionName,indexType:r.indexType})}default:{let{LanceDBAdapter:t}=await e.A(184904);return new t({mode:n.mode,dbPath:n.dbPath,uri:n.uri,apiKey:n.apiKey,s3Uri:n.s3Uri,s3Endpoint:n.s3Endpoint,s3Region:n.s3Region,s3AccessKeyId:n.s3AccessKeyId,s3SecretAccessKey:n.s3SecretAccessKey,tableName:n.tableName})}}}e.s(["createAdapter",0,r])},489694,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(192441);let n=Promise.resolve();function o(e){let t=n.then(e,e);return n=t.catch(()=>{}),t}async function i(e){let t=e?await (0,a.requireDataDir)():await (0,a.getDataDir)();return t?r.default.join(t,"index-run.json"):null}async function s(){let e=await i(!1);if(!e)return null;try{let r=await t.promises.readFile(e,"utf8");return JSON.parse(r)}catch{return null}}async function l(){let e=await s();return!!(e&&("chunking"===e.status||"embedding"===e.status||"upserting"===e.status))}e.s(["claimRun",0,function(e){return o(async()=>{let r=await s();if(r&&("chunking"===r.status||"embedding"===r.status||"upserting"===r.status))throw Error("An indexing run is already in progress.");let a=await i(!0),n={...e,updatedAt:new Date().toISOString()};return a&&await t.promises.writeFile(a,JSON.stringify(n,null,2),"utf8"),n})},"isRunning",0,l,"patchRun",0,function(e,r){return o(async()=>{let a=await s();if(!a||r&&a.id!==r)return null;let n={...a,...e,updatedAt:new Date().toISOString()},o=await i(!0);return o&&await t.promises.writeFile(o,JSON.stringify(n,null,2),"utf8"),n})},"readRun",0,s])},224361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},688947,(e,t,r)=>{t.exports=e.x("stream",()=>require("stream"))},427699,(e,t,r)=>{t.exports=e.x("events",()=>require("events"))},500874,(e,t,r)=>{t.exports=e.x("buffer",()=>require("buffer"))},660526,(e,t,r)=>{t.exports=e.x("node:os",()=>require("node:os"))},811917,(e,t,r)=>{t.exports=e.x("dockerode-2f9c00396d72a1e4",()=>require("dockerode-2f9c00396d72a1e4"))},983131,778923,e=>{"use strict";var t=e.i(811917),r=e.i(902157),a=e.i(750227),n=e.i(660526),o=e.i(666680);let i="larkup-sandbox:latest",s="/sandbox/output",l=a.default.join({get url(){return`file://${e.P("packages/sandbox/dist/docker-runner.js")}`}}.dirname??"/ROOT/packages/sandbox/dist",".."),d=null;function c(){return d||(d=new t.default),d}async function u(){let e=c();try{let t=await e.version(),r=await e.listImages({filters:{reference:[i]}});return{status:r.length>0?"ready":"image-not-found",backend:"docker",dockerVersion:t.Version,imageReady:r.length>0}}catch(e){return{status:"docker-not-found",backend:"docker",error:e.message??"Docker daemon not available"}}}async function p(e){let t=c(),n=a.default.join(l,"Dockerfile");try{await r.promises.access(n)}catch{throw Error(`Sandbox Dockerfile not found at ${n}. Ensure the @larkup/sandbox package is properly installed.`)}e?.("Building sandbox image…");let o=await t.buildImage({context:l,src:["Dockerfile"]},{t:i});await new Promise((r,a)=>{t.modem.followProgress(o,e=>{e?a(e):r()},t=>{t.stream&&e?.(t.stream.trim())})}),e?.("Sandbox image built successfully ✓")}async function m(){let e=c();if((await e.listImages({filters:{reference:[i]}})).length>0)return!0;try{return await p(),!0}catch{return!1}}async function f(e,t){let i,l,d=c(),u=Date.now(),p=a.default.join(n.default.tmpdir(),`larkup-sandbox-${(0,o.randomUUID)()}`),m=a.default.join(p,"input"),f=a.default.join(p,"output");if(await r.promises.mkdir(m,{recursive:!0}),await r.promises.mkdir(f,{recursive:!0}),e.files)for(let t of e.files){let e=a.default.join(m,t.name);t.isBase64?await r.promises.writeFile(e,Buffer.from(t.content,"base64")):await r.promises.writeFile(e,t.content,"utf8")}if("python"===e.language){var h;h=e.code,i=`
57
+ - End with a one-sentence synthesis if appropriate, avoiding filler words.`;e.s(["DEFAULT_CONFIG",0,i,"DEFAULT_DEPLOYMENT_CONFIG",0,{type:"rag-only",authMode:"none",enabledToolIds:[],widgetStyle:{primaryColor:"#000000",position:"bottom-right",title:"Chat with AI",welcomeMessage:"Hi! How can I help you today?",placeholder:"Type a message...",darkMode:!1,borderRadius:"lg"},allowedOrigins:["*"]},"DEFAULT_SYSTEM_PROMPT",0,s],638725);let l=r.default.join(process.cwd(),".larkup"),d=r.default.join(l,"servers"),c=r.default.join(l,"workspace.json"),u={username:null,activeServerId:null,servers:[],mode:null},p=new n.AsyncLocalStorage,m=Promise.resolve();function f(e){let t=m.then(e,e);return m=t.catch(()=>{}),t}async function h(e){return await x(),f(async()=>e(await v()??u))}function g(e){return r.default.join(d,e)}function y(e,t){return`./.larkup/servers/${e}/${t}`}async function b(e){try{return await t.promises.access(e),!0}catch{return!1}}async function w(e,a){if(await b(e)){await t.promises.mkdir(r.default.dirname(a),{recursive:!0});try{await t.promises.rename(e,a)}catch{await t.promises.cp(e,a,{recursive:!0}),await t.promises.rm(e,{recursive:!0,force:!0})}}}async function v(){try{let e=await t.promises.readFile(c,"utf8");return{...u,...JSON.parse(e)}}catch{return null}}async function k(e){return await t.promises.mkdir(l,{recursive:!0}),await t.promises.writeFile(c,JSON.stringify(e,null,2),"utf8"),e}async function x(){let e=await v();return e||f(S)}async function S(){let e=await v();if(e)return e;if(!await b(r.default.join(l,"config.json")))return k(u);let n=(0,a.randomUUID)(),o=g(n);for(let e of(await t.promises.mkdir(o,{recursive:!0}),["config.json","documents.json","jobs.json","index-run.json","server-local.json"]))await w(r.default.join(l,e),r.default.join(o,e));await w(r.default.join(l,"lancedb"),r.default.join(o,"lancedb")),await w(r.default.join(l,"generated-server"),r.default.join(o,"generated-server"));let i="Default server";try{let e=r.default.join(o,"config.json"),a=JSON.parse(await t.promises.readFile(e,"utf8"));a.projectName&&(i=a.projectName),"lancedb"===a.vectorStore&&(a.storeConfig?.mode??"local")==="local"&&(a.storeConfig={...a.storeConfig,dbPath:y(n,"lancedb")}),await t.promises.writeFile(e,JSON.stringify(a,null,2),"utf8")}catch{}let s=new Date().toISOString(),d={id:n,name:i,port:8080,createdAt:s,updatedAt:s};return k({username:null,activeServerId:n,servers:[d],mode:null})}async function _(){let e=await x(),t=p.getStore()?.serverId??e.activeServerId;return t?e.servers.find(e=>e.id===t)??null:null}async function A(){let e=await _();if(!e)return null;let r=g(e.id);return await t.promises.mkdir(r,{recursive:!0}),r}async function T(){let e=await A();if(e)return e;let t=p.getStore()?.serverId;if(t)throw Error(`Server "${t}" no longer exists.`);let{server:r}=await O("my-larkup");return g(r.id)}async function I(e){return new Promise(t=>{let r=o.default.createServer();r.once("error",()=>t(!1)),r.once("listening",()=>{r.close(()=>t(!0))}),r.listen(e,"127.0.0.1")})}async function D(e){let t=Math.max(8079,...e.servers.map(e=>e.port))+1;for(;!await I(t);)t++;return t}function O(e){return h(async n=>{let o=(0,a.randomUUID)(),s=new Date().toISOString(),l={id:o,name:e.trim()||"Untitled server",port:await D(n),createdAt:s,updatedAt:s},d=g(o);await t.promises.mkdir(d,{recursive:!0});let c={};if(n.activeServerId)try{let e=await t.promises.readFile(r.default.join(g(n.activeServerId),"config.json"),"utf8");c=JSON.parse(e)}catch{}await t.promises.writeFile(r.default.join(d,"config.json"),JSON.stringify(function(e,t,r={}){return{...i,projectName:t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"my-larkup",storeConfig:{mode:"local",dbPath:y(e,"lancedb")},embeddingApiKey:r.embeddingApiKey??i.embeddingApiKey,customEmbeddings:r.customEmbeddings??i.customEmbeddings,chatApiKey:r.chatApiKey??i.chatApiKey,customChatModels:r.customChatModels??i.customChatModels,serperApiKey:r.serperApiKey??i.serperApiKey,firecrawlApiKey:r.firecrawlApiKey??i.firecrawlApiKey,updatedAt:new Date().toISOString()}}(o,l.name,c),null,2),"utf8");let u={...n,servers:[...n.servers,l],activeServerId:o};return await k(u),{workspace:u,server:l}})}e.s(["createServer",0,O,"deleteServer",0,function(e){return h(async r=>{let a=r.servers.filter(t=>t.id!==e),n=r.activeServerId===e?a[0]?.id??null:r.activeServerId;return await t.promises.rm(g(e),{recursive:!0,force:!0}),k({...r,servers:a,activeServerId:n})})},"getActiveServer",0,_,"getDataDir",0,A,"getWorkspace",0,x,"renameServer",0,function(e,t){return h(async r=>{let a=r.servers.map(r=>r.id===e?{...r,name:t.trim()||r.name,updatedAt:new Date().toISOString()}:r);return k({...r,servers:a})})},"requireDataDir",0,T,"runWithServer",0,function(e,t){return p.run({serverId:e},t)},"setActiveServer",0,function(e){return h(async t=>t.servers.some(t=>t.id===e)?k({...t,activeServerId:e}):t)},"setMode",0,function(e){return h(async t=>k({...t,mode:e}))},"setUsername",0,function(e){return h(async t=>k({...t,username:e.trim()||null}))}],192441)},367165,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(638725),n=e.i(192441);async function o(){let e=await (0,n.getDataDir)();if(!e)return a.DEFAULT_CONFIG;try{let n=await t.promises.readFile(r.default.join(e,"config.json"),"utf8"),o=JSON.parse(n),i=o.customEmbeddings,s=o.embeddingModelId;if(o.customEmbedding&&!i?.length){let e=o.customEmbedding;i=[e],"custom"===s&&(s=`custom:${e.modelName}`)}let l={...a.DEFAULT_CONFIG,...o,embeddingModelId:s??a.DEFAULT_CONFIG.embeddingModelId,customEmbeddings:i,chunking:{...a.DEFAULT_CONFIG.chunking,...o.chunking},storeConfig:{...a.DEFAULT_CONFIG.storeConfig,...o.storeConfig}};return delete l.customEmbedding,l}catch{return a.DEFAULT_CONFIG}}async function i(e){let a=await (0,n.requireDataDir)(),o={...e,updatedAt:new Date().toISOString()};return await t.promises.writeFile(r.default.join(a,"config.json"),JSON.stringify(o,null,2),"utf8"),o}e.s(["readConfig",0,o,"writeConfig",0,i])},874533,(e,t,r)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},812057,(e,t,r)=>{t.exports=e.x("node:util",()=>require("node:util"))},814747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},522734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},446786,(e,t,r)=>{t.exports=e.x("os",()=>require("os"))},310470,(e,t,r)=>{"use strict";var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={},l={VercelOidcTokenError:()=>c};for(var d in l)a(s,d,{get:l[d],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);class c extends Error{constructor(e,t){super(e),this.name="VercelOidcTokenError",this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}}},33015,(e,t,r)=>{"use strict";var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={},l={AccessTokenMissingError:()=>c,RefreshAccessTokenFailedError:()=>u};for(var d in l)a(s,d,{get:l[d],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);class c extends Error{constructor(){super("No authentication found. Please log in with the Vercel CLI (vercel login)."),this.name="AccessTokenMissingError"}}class u extends Error{constructor(e){super("Failed to refresh authentication token.",{cause:e}),this.name="RefreshAccessTokenFailedError"}}},250216,(e,t,r)=>{"use strict";var a=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,d=(e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))l.call(e,s)||s===r||n(e,s,{get:()=>t[s],enumerable:!(a=o(t,s))||a.enumerable});return e},c=(e,t,r)=>(r=null!=e?a(s(e)):{},d(!t&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),u={},p={findRootDir:()=>b,getUserDataDir:()=>w};for(var m in p)n(u,m,{get:p[m],enumerable:!0});t.exports=d(n({},"__esModule",{value:!0}),u);var f=c(e.r(814747)),h=c(e.r(522734)),g=c(e.r(446786)),y=e.r(310470);function b(){try{let e=process.cwd();for(;e!==f.default.dirname(e);){let t=f.default.join(e,".vercel");if(h.default.existsSync(t))return e;e=f.default.dirname(e)}}catch(e){throw new y.VercelOidcTokenError("Token refresh only supported in node server environments")}return null}function w(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(g.default.platform()){case"darwin":return f.default.join(g.default.homedir(),"Library/Application Support");case"linux":return f.default.join(g.default.homedir(),".local/share");case"win32":if(process.env.LOCALAPPDATA)return process.env.LOCALAPPDATA;return null;default:return null}}},775427,(e,t,r)=>{"use strict";var a=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,d=(e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))l.call(e,s)||s===r||n(e,s,{get:()=>t[s],enumerable:!(a=o(t,s))||a.enumerable});return e},c=(e,t,r)=>(r=null!=e?a(s(e)):{},d(!t&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),u={},p={isValidAccessToken:()=>v,readAuthConfig:()=>b,writeAuthConfig:()=>w};for(var m in p)n(u,m,{get:p[m],enumerable:!0});t.exports=d(n({},"__esModule",{value:!0}),u);var f=c(e.r(522734)),h=c(e.r(814747)),g=e.r(65048);function y(){let e=(0,g.getVercelDataDir)();if(!e)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return h.join(e,"auth.json")}function b(){try{let e=y();if(!f.existsSync(e))return null;let t=f.readFileSync(e,"utf8");if(!t)return null;return JSON.parse(t)}catch(e){return null}}function w(e){let t=y(),r=h.dirname(t);f.existsSync(r)||f.mkdirSync(r,{mode:504,recursive:!0}),f.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function v(e,t=0){if(!e.token)return!1;if("number"!=typeof e.expiresAt)return!0;let r=Math.floor(Date.now()/1e3);return e.expiresAt>=r+t/1e3}},371746,(e,t,r)=>{"use strict";var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={},l={processTokenResponse:()=>h,refreshTokenRequest:()=>f};for(var d in l)a(s,d,{get:l[d],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);var c=e.r(446786);let u=`@vercel/oidc node-${process.version} ${(0,c.platform)()} (${(0,c.arch)()}) ${(0,c.hostname)()}`,p=null;async function m(){if(p)return p;let e=await fetch("https://vercel.com/.well-known/openid-configuration",{headers:{"user-agent":u}});if(!e.ok)throw Error("Failed to discover OAuth endpoints");let t=await e.json();if(!t||"string"!=typeof t.token_endpoint)throw Error("Invalid OAuth discovery response");let r=t.token_endpoint;return p=r,r}async function f(e){let t=await m();return await fetch(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","user-agent":u},body:new URLSearchParams({client_id:"cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp",grant_type:"refresh_token",...e})})}async function h(e){let t=await e.json();return e.ok?"object"!=typeof t||null===t?[Error("Invalid token response")]:"string"!=typeof t.access_token?[Error("Missing access_token in response")]:"Bearer"!==t.token_type?[Error("Invalid token_type in response")]:"number"!=typeof t.expires_in?[Error("Missing expires_in in response")]:[null,t]:[Error("object"==typeof t&&t&&"error"in t?String(t.error):"Token refresh failed")]}},65048,(e,t,r)=>{"use strict";var a=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,d=(e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))l.call(e,s)||s===r||n(e,s,{get:()=>t[s],enumerable:!(a=o(t,s))||a.enumerable});return e},c=(e,t,r)=>(r=null!=e?a(s(e)):{},d(!t&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),u={},p={assertVercelOidcTokenResponse:()=>_,findProjectInfo:()=>A,getTokenPayload:()=>D,getVercelDataDir:()=>k,getVercelOidcToken:()=>S,getVercelToken:()=>x,isExpired:()=>O,loadToken:()=>I,saveToken:()=>T};for(var m in p)n(u,m,{get:p[m],enumerable:!0});t.exports=d(n({},"__esModule",{value:!0}),u);var f=c(e.r(814747)),h=c(e.r(522734)),g=e.r(310470),y=e.r(250216),b=e.r(775427),w=e.r(371746),v=e.r(33015);function k(){let e=(0,y.getUserDataDir)();return e?f.join(e,"com.vercel.cli"):null}async function x(e){let t=(0,b.readAuthConfig)();if(!t?.token)throw new v.AccessTokenMissingError;if((0,b.isValidAccessToken)(t,e?.expirationBufferMs))return t.token;if(!t.refreshToken)throw(0,b.writeAuthConfig)({}),new v.RefreshAccessTokenFailedError("No refresh token available");try{let e=await (0,w.refreshTokenRequest)({refresh_token:t.refreshToken}),[r,a]=await (0,w.processTokenResponse)(e);if(r||!a)throw(0,b.writeAuthConfig)({}),new v.RefreshAccessTokenFailedError(r);let n={token:a.access_token,expiresAt:Math.floor(Date.now()/1e3)+a.expires_in};return a.refresh_token&&(n.refreshToken=a.refresh_token),(0,b.writeAuthConfig)(n),n.token}catch(e){if((0,b.writeAuthConfig)({}),e instanceof v.AccessTokenMissingError||e instanceof v.RefreshAccessTokenFailedError)throw e;throw new v.RefreshAccessTokenFailedError(e)}}async function S(e,t,r){let a=`https://api.vercel.com/v1/projects/${t}/token?source=vercel-oidc-refresh${r?`&teamId=${r}`:""}`,n=await fetch(a,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!n.ok)throw new g.VercelOidcTokenError(`Failed to refresh OIDC token: ${n.statusText}`);let o=await n.json();return _(o),o}function _(e){if(!e||"object"!=typeof e)throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!("token"in e)||"string"!=typeof e.token)throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function A(){let e=(0,y.findRootDir)();if(!e)throw new g.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let t=f.join(e,".vercel","project.json");if(!h.existsSync(t))throw new g.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let r=JSON.parse(h.readFileSync(t,"utf8"));if("string"!=typeof r.projectId&&"string"!=typeof r.orgId)throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:r.projectId,teamId:r.orgId}}function T(e,t){let r=(0,y.getUserDataDir)();if(!r)throw new g.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let a=f.join(r,"com.vercel.token",`${t}.json`),n=JSON.stringify(e);h.mkdirSync(f.dirname(a),{mode:504,recursive:!0}),h.writeFileSync(a,n),h.chmodSync(a,432)}function I(e){let t=(0,y.getUserDataDir)();if(!t)throw new g.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let r=f.join(t,"com.vercel.token",`${e}.json`);if(!h.existsSync(r))return null;let a=JSON.parse(h.readFileSync(r,"utf8"));return _(a),a}function D(e){let t=e.split(".");if(3!==t.length)throw new g.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let r=t[1].replace(/-/g,"+").replace(/_/g,"/"),a=r.padEnd(r.length+(4-r.length%4)%4,"=");return JSON.parse(Buffer.from(a,"base64").toString("utf8"))}function O(e,t=0){return 1e3*e.exp<Date.now()+t}},705252,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(666680),n=e.i(192441);let o=Promise.resolve();function i(e){let t=o.then(e,e);return o=t.catch(()=>{}),t}async function s(e){let t=e?await (0,n.requireDataDir)():await (0,n.getDataDir)();return t?r.default.join(t,"documents.json"):null}async function l(){let e=await s(!1);if(!e)return[];try{let r=await t.promises.readFile(e,"utf8"),a=JSON.parse(r);if(!Array.isArray(a))throw Error(`Invalid document store at ${e}: expected a JSON array.`);return a}catch(e){if(e?.code==="ENOENT")return[];throw e}}async function d(e){let n=await s(!0);if(!n)return;let o=r.default.join(r.default.dirname(n),`.${r.default.basename(n)}.${process.pid}.${(0,a.randomUUID)()}.tmp`);try{await t.promises.writeFile(o,JSON.stringify(e,null,2),"utf8"),await t.promises.rename(o,n)}catch(e){throw await t.promises.unlink(o).catch(()=>{}),e}}function c(e){let t=e.content.trim();return{id:e.id??(0,a.randomUUID)(),title:e.title.trim()||"Untitled",url:e.url,source:e.source,content:t,charCount:t.length,jobId:e.jobId,metadata:e.metadata,status:"unindexed",createdAt:new Date().toISOString()}}async function u(){let e=await l(),t=e.reduce((e,t)=>e+t.charCount,0);return{docCount:e.length,charCount:t,bySource:e.reduce((e,t)=>(e[t.source]=(e[t.source]??0)+1,e),{})}}e.s(["addCrawledDocuments",0,function(e,t){return i(async()=>{let r=await l(),a=new Set(r.filter(e=>e.url).map(e=>e.url)),n=0;for(let o of t)!(o.url&&a.has(o.url))&&o.content.trim()&&(r.push(c({...o,jobId:e})),o.url&&a.add(o.url),n++);return n>0&&await d(r),n})},"addDocument",0,function(e){return i(async()=>{let t=await l(),r=c(e);return t.push(r),await d(t),r})},"addDocuments",0,function(e){return i(async()=>{if(0===e.length)return[];let t=await l(),r=e.map(c);return t.push(...r),await d(t),r})},"clearDocuments",0,function(){return i(async()=>{await d([])})},"corpusStats",0,u,"deleteDocument",0,function(e){return i(async()=>{let t=await l();await d(t.filter(t=>t.id!==e))})},"deleteDocuments",0,function(e){return i(async()=>{let t=await l(),r=new Set(e);await d(t.filter(e=>!r.has(e.id)))})},"readDocuments",0,l,"replaceDocuments",0,function(e){return i(async()=>{let t=new Date().toISOString();await d(e.map(e=>({...e,status:"unindexed",createdAt:e.createdAt||t})))})},"updateDocument",0,function(e,t){return i(async()=>{let r=await l(),a=r.findIndex(t=>t.id===e);if(a<0)return;let n=r[a],o=void 0!==t.content?t.content.trim():n.content,i={...n,title:void 0!==t.title?t.title.trim()||"Untitled":n.title,content:o,charCount:o.length,url:void 0!==t.url?t.url||void 0:n.url,metadata:void 0!==t.metadata?t.metadata:n.metadata,status:"unindexed"};return r[a]=i,await d(r),i})},"updateDocumentsStatus",0,function(e,t){return i(async()=>{let r=await l(),a=new Set(e),n=!1;for(let e of r)a.has(e.id)&&(e.status=t,n=!0);n&&await d(r)})}])},399828,e=>{"use strict";let t={"openai/text-embedding-3-small":{dimensions:1536,maxInputTokens:8191},"openai/text-embedding-3-large":{dimensions:3072,maxInputTokens:8191},"openai/text-embedding-ada-002":{dimensions:1536,maxInputTokens:8191},"google/gemini-embedding-2":{dimensions:768,maxInputTokens:2048},"google/gemini-embedding-001":{dimensions:768,maxInputTokens:2048},"cohere/embed-english-v3.0":{dimensions:1024,maxInputTokens:512},"cohere/embed-multilingual-v3.0":{dimensions:1024,maxInputTokens:512},"voyage/voyage-3":{dimensions:1024,maxInputTokens:32e3},"voyage/voyage-3-lite":{dimensions:512,maxInputTokens:32e3},"voyage/voyage-code-3":{dimensions:1024,maxInputTokens:32e3},"mistral/mistral-embed":{dimensions:1024,maxInputTokens:8192},"jina/jina-embeddings-v3":{dimensions:1024,maxInputTokens:8192},"jina/jina-clip-v2":{dimensions:1024,maxInputTokens:8192},"nomic/nomic-embed-text-v1.5":{dimensions:768,maxInputTokens:8192}},r=[{id:"openai/text-embedding-3-small",label:"text-embedding-3-small",provider:"openai",dimensions:1536,maxInputTokens:8191,description:"Fast, cheap, strong general-purpose default."},{id:"openai/text-embedding-3-large",label:"text-embedding-3-large",provider:"openai",dimensions:3072,maxInputTokens:8191,description:"Highest quality OpenAI embeddings, larger vectors."},{id:"openai/text-embedding-ada-002",label:"text-embedding-ada-002",provider:"openai",dimensions:1536,maxInputTokens:8191,description:"Legacy model — kept for backward compatibility."},{id:"google/gemini-embedding-001",label:"gemini-embedding-001",provider:"google",dimensions:768,maxInputTokens:2048,description:"Gemini embedding 001."},{id:"cohere/embed-english-v3.0",label:"embed-english-v3.0",provider:"cohere",dimensions:1024,maxInputTokens:512,description:"Tuned for retrieval; great for English-heavy corpora."},{id:"cohere/embed-multilingual-v3.0",label:"embed-multilingual-v3.0",provider:"cohere",dimensions:1024,maxInputTokens:512,description:"100+ language multilingual retrieval embeddings."},{id:"voyage/voyage-3",label:"voyage-3",provider:"voyage",dimensions:1024,maxInputTokens:32e3,description:"Voyage's best general-purpose retrieval model."},{id:"voyage/voyage-3-lite",label:"voyage-3-lite",provider:"voyage",dimensions:512,maxInputTokens:32e3,description:"Optimized for latency and cost with strong performance."},{id:"voyage/voyage-code-3",label:"voyage-code-3",provider:"voyage",dimensions:1024,maxInputTokens:32e3,description:"Specialized for code retrieval tasks."},{id:"mistral/mistral-embed",label:"mistral-embed",provider:"mistral",dimensions:1024,maxInputTokens:8192,description:"Mistral's efficient embedding model for retrieval."},{id:"jina/jina-embeddings-v3",label:"jina-embeddings-v3",provider:"jina",dimensions:1024,maxInputTokens:8192,description:"Multilingual, task-specific embeddings from Jina AI."},{id:"jina/jina-clip-v2",label:"jina-clip-v2",provider:"jina",dimensions:1024,maxInputTokens:8192,description:"Multimodal embeddings for text and images."},{id:"nomic/nomic-embed-text-v1.5",label:"nomic-embed-text-v1.5",provider:"nomic",dimensions:768,maxInputTokens:8192,description:"Open-source, highly capable text embeddings."}];e.s(["EMBEDDING_DIMENSIONS",0,t,"EMBEDDING_MODELS",0,r,"getEmbeddingModel",0,function(e){return r.find(t=>t.id===e)},"getEmbeddingModelsForProvider",0,function(e,t){return"vercel_ai_gateway"===t?e:e.filter(e=>e.provider?.toLowerCase()===t.toLowerCase())},"toEmbeddingDescriptor",0,function(e){let r=t[e.id],a=e.id.split("/")[0]||e.owned_by;return{id:e.id,label:e.name||e.id.split("/").slice(1).join("/"),provider:a,dimensions:r?.dimensions??e.context_window??768,maxInputTokens:r?.maxInputTokens??e.max_tokens??2048,description:e.description||""}}])},979598,e=>{"use strict";let t={lancedb:{id:"lancedb",label:"LanceDB",description:"Embedded vector database for local development, LanceDB Cloud, or persistent S3-compatible storage such as Cloudflare R2.",runtime:"both",installStatus:"installed",docsUrl:"https://lancedb.github.io/lancedb/",serverDependencies:{"@lancedb/lancedb":"^0.30.0"},fields:[{key:"mode",label:"Mode",type:"select",required:!0,defaultValue:"local",help:"Use a local disk, LanceDB Cloud, or an S3-compatible bucket for persistent serverless deployments.",options:[{label:"Local (on-disk)",value:"local"},{label:"S3-compatible (Vercel / R2 / S3)",value:"s3"},{label:"Cloud",value:"cloud"}]},{key:"dbPath",label:"Database path",type:"path",required:!0,defaultValue:"./.larkup/lancedb",placeholder:"./.larkup/lancedb",help:"Directory where the LanceDB tables are stored.",showWhen:{key:"mode",equals:["local"]}},{key:"s3Uri",label:"Database URI",type:"text",required:!0,placeholder:"s3://my-bucket/larkup/my-server",help:"A dedicated, private bucket prefix for LanceDB table files. This is persistent across Vercel invocations.",showWhen:{key:"mode",equals:["s3"]}},{key:"s3Endpoint",label:"S3 endpoint",type:"text",required:!1,placeholder:"https://<account-id>.r2.cloudflarestorage.com",help:"Required for Cloudflare R2 and other S3-compatible providers. Leave blank for AWS S3.",showWhen:{key:"mode",equals:["s3"]}},{key:"s3Region",label:"Region",type:"text",required:!0,defaultValue:"auto",placeholder:"auto",help:"Use “auto” for Cloudflare R2, or your bucket region for AWS S3.",showWhen:{key:"mode",equals:["s3"]}},{key:"s3AccessKeyId",label:"Access key ID",type:"password",required:!0,secret:!0,help:"Use an object read/write credential restricted to this bucket.",showWhen:{key:"mode",equals:["s3"]}},{key:"s3SecretAccessKey",label:"Secret access key",type:"password",required:!0,secret:!0,help:"Stored as a deployment environment variable; never expose it in the browser.",showWhen:{key:"mode",equals:["s3"]}},{key:"uri",label:"Cloud URI",type:"text",required:!0,placeholder:"db://my-database",help:"Your LanceDB Cloud database URI.",showWhen:{key:"mode",equals:["cloud"]}},{key:"apiKey",label:"API key",type:"password",required:!0,secret:!0,placeholder:"sk_...",help:"LanceDB Cloud API key. Stored as an env var in the generated server.",showWhen:{key:"mode",equals:["cloud"]}},{key:"tableName",label:"Table name",type:"text",required:!0,defaultValue:"documents",help:"The table that holds your embedded chunks."}]},pinecone:{id:"pinecone",label:"Pinecone",description:"Fully-managed cloud vector database. Cloud-only — requires an API key and an existing index.",runtime:"cloud",installStatus:"installed",docsUrl:"https://docs.pinecone.io/",serverDependencies:{"@pinecone-database/pinecone":"^6.0.0"},fields:[{key:"apiKey",label:"API key",type:"password",required:!0,secret:!0,placeholder:"pcsk_...",help:"Pinecone API key. Stored as an env var in the generated server."},{key:"indexName",label:"Index name",type:"text",required:!0,placeholder:"rag-index",help:"Name of the Pinecone index to upsert into / query. For hybrid/lexical mode this index must use the 'dotproduct' metric."},{key:"namespace",label:"Namespace",type:"text",required:!1,placeholder:"default",help:"Optional namespace to isolate this dataset within the index."},{key:"sparseModel",label:"Sparse model",type:"text",required:!0,defaultValue:"pinecone-sparse-english-v0",help:"Pinecone-hosted sparse model used to generate keyword vectors via the Inference API. Both dense and sparse vectors are stored in the same index.",showWhenIndexType:["lexical","hybrid"]}]},weaviate:{id:"weaviate",label:"Weaviate",description:"Open-source AI-native vector database with built-in hybrid search, BM25, and multi-tenancy.",runtime:"both",installStatus:"coming-soon",docsUrl:"https://weaviate.io/developers/weaviate",serverDependencies:{weaviate:"^3.0.0"},fields:[{key:"host",label:"Host URL",type:"text",required:!0,placeholder:"https://my-cluster.weaviate.network",help:"Weaviate Cloud URL or self-hosted host address."},{key:"apiKey",label:"API key",type:"password",required:!1,secret:!0,placeholder:"weaviate-api-key",help:"Weaviate Cloud API key (optional for self-hosted)."},{key:"className",label:"Collection name",type:"text",required:!0,defaultValue:"Documents",help:"The Weaviate collection (class) that holds your embedded chunks."}]},qdrant:{id:"qdrant",label:"Qdrant",description:"High-performance vector search engine with rich filtering, built for production-scale RAG.",runtime:"both",installStatus:"coming-soon",docsUrl:"https://qdrant.tech/documentation/",serverDependencies:{"@qdrant/js-client-rest":"^1.9.0"},fields:[{key:"url",label:"Host URL",type:"text",required:!0,placeholder:"http://localhost:6333",help:"Qdrant server URL (local or Qdrant Cloud endpoint)."},{key:"apiKey",label:"API key",type:"password",required:!1,secret:!0,placeholder:"qdrant-api-key",help:"Qdrant Cloud API key (leave blank for local)."},{key:"collectionName",label:"Collection name",type:"text",required:!0,defaultValue:"documents",help:"Qdrant collection to upsert into and query."}]},chroma:{id:"chroma",label:"Chroma",description:"Open-source, developer-friendly embedding database. Great for rapid local prototyping.",runtime:"both",installStatus:"installable",docsUrl:"https://docs.trychroma.com/",serverDependencies:{chromadb:"^1.9.0"},fields:[{key:"mode",label:"Mode",type:"select",required:!0,defaultValue:"server",help:"Server connects to a self-hosted Chroma instance. Cloud connects to Chroma Cloud.",options:[{label:"Server (Self-hosted)",value:"server"},{label:"Cloud (Chroma Cloud)",value:"cloud"}]},{key:"host",label:"Server URL",type:"text",required:!0,placeholder:"http://localhost:8000",defaultValue:"http://localhost:8000",help:"Chroma server URL (local Docker or remote).",showWhen:{key:"mode",equals:["server"]}},{key:"authToken",label:"Auth Token",type:"password",required:!1,secret:!0,placeholder:"chroma-token",help:"Optional static auth token for Chroma server.",showWhen:{key:"mode",equals:["server"]}},{key:"apiKey",label:"API Key",type:"password",required:!0,secret:!0,placeholder:"sk_...",help:"Chroma Cloud API Key.",showWhen:{key:"mode",equals:["cloud"]}},{key:"tenant",label:"Tenant",type:"text",required:!0,defaultValue:"default_tenant",help:"Tenant name for Chroma Cloud.",showWhen:{key:"mode",equals:["cloud"]}},{key:"database",label:"Database",type:"text",required:!0,defaultValue:"default_database",help:"Database name for Chroma Cloud.",showWhen:{key:"mode",equals:["cloud"]}},{key:"collectionName",label:"Collection name",type:"text",required:!0,defaultValue:"documents",help:"Chroma collection to store and retrieve embeddings."}]},pgvector:{id:"pgvector",label:"pgvector",description:"PostgreSQL extension for vector similarity search. Self-host vectors alongside your relational data.",runtime:"both",installStatus:"coming-soon",docsUrl:"https://github.com/pgvector/pgvector",serverDependencies:{pg:"^8.11.0",pgvector:"^0.2.0"},fields:[{key:"connectionString",label:"Connection string",type:"password",required:!0,secret:!0,placeholder:"postgresql://user:pass@localhost:5432/db",help:"Full PostgreSQL connection string."},{key:"tableName",label:"Table name",type:"text",required:!0,defaultValue:"embeddings",help:"The table used to store vector embeddings. Created automatically if absent."}]},supabase:{id:"supabase",label:"Supabase",description:"Postgres-backed vector store via the pgvector extension with Supabase's managed infrastructure.",runtime:"cloud",installStatus:"coming-soon",docsUrl:"https://supabase.com/docs/guides/ai",serverDependencies:{"@supabase/supabase-js":"^2.43.0"},fields:[{key:"url",label:"Project URL",type:"text",required:!0,placeholder:"https://xyz.supabase.co",help:"Your Supabase project URL."},{key:"serviceKey",label:"Service role key",type:"password",required:!0,secret:!0,placeholder:"eyJhbGci...",help:"Supabase service_role key (not the anon key). Stored as an env var."},{key:"tableName",label:"Table name",type:"text",required:!0,defaultValue:"documents",help:"Supabase table with a vector column for embeddings."}]}};Object.values(t),e.s(["getVectorStore",0,function(e){return t[e]},"validateStoreConfig",0,function(e,t,r){let a={};for(let n of e.fields.filter(e=>{if(e.showWhen){let r=t[e.showWhen.key]??"";if(!e.showWhen.equals.includes(r))return!1}return!e.showWhenIndexType||!r||!!e.showWhenIndexType.includes(r)}))n.required&&!t[n.key]?.trim()&&(a[n.key]=`${n.label} is required`);return a}])},585071,e=>{"use strict";var t=e.i(192441);async function r(r,a){let n={...r.storeConfig},o=await (0,t.getActiveServer)(),i=o?.id;if(i){let e=i.replace(/[^a-zA-Z0-9_-]/g,"_");"pinecone"===r.vectorStore?n.namespace=i:"chroma"===r.vectorStore?n.collectionName=`documents_${e}`:"lancedb"!==r.vectorStore&&r.vectorStore||(n.tableName=`documents_${e}`)}switch(r.vectorStore){case"pinecone":{let{PineconeAdapter:t}=await e.A(77149);return new t({apiKey:n.apiKey,indexName:n.indexName,namespace:n.namespace,sparseModel:n.sparseModel,indexType:r.indexType,onRateLimit:a})}case"chroma":{let{ChromaAdapter:t}=await e.A(195059);return new t({mode:n.mode,host:n.host,authToken:n.authToken,apiKey:n.apiKey,tenant:n.tenant,database:n.database,collectionName:n.collectionName,indexType:r.indexType})}default:{let{LanceDBAdapter:t}=await e.A(184904);return new t({mode:n.mode,dbPath:n.dbPath,uri:n.uri,apiKey:n.apiKey,s3Uri:n.s3Uri,s3Endpoint:n.s3Endpoint,s3Region:n.s3Region,s3AccessKeyId:n.s3AccessKeyId,s3SecretAccessKey:n.s3SecretAccessKey,tableName:n.tableName})}}}e.s(["createAdapter",0,r])},489694,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(192441);let n=Promise.resolve();function o(e){let t=n.then(e,e);return n=t.catch(()=>{}),t}async function i(e){let t=e?await (0,a.requireDataDir)():await (0,a.getDataDir)();return t?r.default.join(t,"index-run.json"):null}async function s(){let e=await i(!1);if(!e)return null;try{let r=await t.promises.readFile(e,"utf8");return JSON.parse(r)}catch{return null}}async function l(){let e=await s();return!!(e&&("chunking"===e.status||"embedding"===e.status||"upserting"===e.status))}e.s(["claimRun",0,function(e){return o(async()=>{let r=await s();if(r&&("chunking"===r.status||"embedding"===r.status||"upserting"===r.status))throw Error("An indexing run is already in progress.");let a=await i(!0),n={...e,updatedAt:new Date().toISOString()};return a&&await t.promises.writeFile(a,JSON.stringify(n,null,2),"utf8"),n})},"isRunning",0,l,"patchRun",0,function(e,r){return o(async()=>{let a=await s();if(!a||r&&a.id!==r)return null;let n={...a,...e,updatedAt:new Date().toISOString()},o=await i(!0);return o&&await t.promises.writeFile(o,JSON.stringify(n,null,2),"utf8"),n})},"readRun",0,s])},224361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},688947,(e,t,r)=>{t.exports=e.x("stream",()=>require("stream"))},427699,(e,t,r)=>{t.exports=e.x("events",()=>require("events"))},500874,(e,t,r)=>{t.exports=e.x("buffer",()=>require("buffer"))},660526,(e,t,r)=>{t.exports=e.x("node:os",()=>require("node:os"))},983131,778923,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(660526),n=e.i(666680);let o="larkup-sandbox:latest",i="/sandbox/output",s=r.default.join({get url(){return`file://${e.P("packages/sandbox/dist/docker-runner.js")}`}}.dirname??"/ROOT/packages/sandbox/dist",".."),l=null;async function d(){if(!l){let{default:e}=await import("dockerode");l=new e}return l}async function c(){let e=await d();try{let t=await e.version(),r=await e.listImages({filters:{reference:[o]}});return{status:r.length>0?"ready":"image-not-found",backend:"docker",dockerVersion:t.Version,imageReady:r.length>0}}catch(e){return{status:"docker-not-found",backend:"docker",error:e.message??"Docker daemon not available"}}}async function u(e){let a=await d(),n=r.default.join(s,"Dockerfile");try{await t.promises.access(n)}catch{throw Error(`Sandbox Dockerfile not found at ${n}. Ensure the @larkup/sandbox package is properly installed.`)}e?.("Building sandbox image…");let i=await a.buildImage({context:s,src:["Dockerfile"]},{t:o});await new Promise((t,r)=>{a.modem.followProgress(i,e=>{e?r(e):t()},t=>{t.stream&&e?.(t.stream.trim())})}),e?.("Sandbox image built successfully ✓")}async function p(){let e=await d();if((await e.listImages({filters:{reference:[o]}})).length>0)return!0;try{return await u(),!0}catch{return!1}}async function m(e,o){let s,l,c=await d(),u=Date.now(),p=r.default.join(a.default.tmpdir(),`larkup-sandbox-${(0,n.randomUUID)()}`),m=r.default.join(p,"input"),f=r.default.join(p,"output");if(await t.promises.mkdir(m,{recursive:!0}),await t.promises.mkdir(f,{recursive:!0}),e.files)for(let a of e.files){let e=r.default.join(m,a.name);a.isBase64?await t.promises.writeFile(e,Buffer.from(a.content,"base64")):await t.promises.writeFile(e,a.content,"utf8")}if("python"===e.language){var h;h=e.code,s=`
58
58
  import sys, os, json, traceback
59
59
 
60
60
  # Ensure output directory exists
61
- os.makedirs("${s}", exist_ok=True)
61
+ os.makedirs("${i}", exist_ok=True)
62
62
 
63
63
  # ============================================================
64
64
  # SAFETY PREAMBLE: Suppress warnings & patch deprecated APIs
@@ -146,7 +146,7 @@ try:
146
146
  def _patched_show(*args, **kwargs):
147
147
  for fig_num in plt.get_fignums():
148
148
  fig = plt.figure(fig_num)
149
- fname = f"${s}/chart_{_figure_count[0]}.png"
149
+ fname = f"${i}/chart_{_figure_count[0]}.png"
150
150
  fig.savefig(fname, dpi=150, bbox_inches="tight", facecolor="white")
151
151
  _figure_count[0] += 1
152
152
  plt.close("all")
@@ -187,13 +187,13 @@ except Exception as e:
187
187
 
188
188
  # List generated artifacts
189
189
  artifacts = []
190
- if os.path.isdir("${s}"):
191
- for f in sorted(os.listdir("${s}")):
192
- fp = os.path.join("${s}", f)
190
+ if os.path.isdir("${i}"):
191
+ for f in sorted(os.listdir("${i}")):
192
+ fp = os.path.join("${i}", f)
193
193
  if os.path.isfile(fp):
194
194
  artifacts.append(f)
195
195
  if artifacts:
196
196
  print("\\n__ARTIFACTS__:" + json.dumps(artifacts))
197
- `;let t=a.default.join(p,"run.py");await r.promises.writeFile(t,i,"utf8"),l=["python3","/sandbox/run.py"]}else{let t=a.default.join(p,"run.js");await r.promises.writeFile(t,e.code,"utf8"),l=["node","/sandbox/run.js"]}let g=e.timeout??t.timeoutMs,y=null;try{y=await d.createContainer({Image:t.imageName,Cmd:l,Entrypoint:[],WorkingDir:"/sandbox/input",HostConfig:{AutoRemove:!1,Memory:1024*t.memoryMB*1024,CpuShares:t.cpuShares,NetworkMode:t.networkDisabled?"none":"bridge",Binds:[`${m}:/sandbox/input:ro`,`${f}:${s}:rw`,`${p}/run.py:/sandbox/run.py:ro`],ReadonlyRootfs:!1},Tty:!1,AttachStdout:!0,AttachStderr:!0}),await y.start();let e=y.wait(),n=new Promise((e,t)=>{setTimeout(async()=>{try{await y?.kill()}catch{}t(Error(`Execution timed out after ${g}ms`))},g)}),o=await Promise.race([e,n]),i=await y.logs({stdout:!0,stderr:!0,follow:!1}),c=function(e){let t="",r="";if("string"==typeof e)return{stdout:e,stderr:""};let a=0;for(;a<e.length&&!(a+8>e.length);){let n=e.readUInt8(a),o=e.readUInt32BE(a+4);if((a+=8)+o>e.length)break;let i=e.subarray(a,a+o).toString("utf8");1===n?t+=i:2===n&&(r+=i),a+=o}return t||r||!(e.length>0)||(t=e.toString("utf8")),{stdout:t,stderr:r}}(i),h=[];try{for(let e of(await r.promises.readdir(f))){let t=a.default.join(f,e),n=await r.promises.readFile(t),o={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".svg":"image/svg+xml",".gif":"image/gif",".csv":"text/csv",".json":"application/json",".txt":"text/plain",".html":"text/html",".pdf":"application/pdf"}[a.default.extname(e).toLowerCase()]??"application/octet-stream";h.push({name:e,mimeType:o,data:n.toString("base64")})}}catch{}let{stdout:b,stderr:w}=c;return{stdout:b.replace(/\n__ARTIFACTS__:.*$/m,"").trimEnd(),stderr:w,exitCode:o.StatusCode??1,artifacts:h,executionTimeMs:Date.now()-u}}catch(e){return{stdout:"",stderr:e.message??"Execution failed",exitCode:1,artifacts:[],executionTimeMs:Date.now()-u}}finally{if(y)try{await y.remove({force:!0})}catch{}try{await r.promises.rm(p,{recursive:!0,force:!0})}catch{}}}let h={imageName:"larkup-sandbox:latest",memoryMB:512,cpuShares:1024,timeoutMs:3e4,networkDisabled:!0};e.s(["SandboxManager",0,class{config;constructor(e){this.config={backend:e?.backend??"docker",docker:e?.docker,remote:e?.remote}}async healthCheck(){switch(this.config.backend){case"docker":return u();case"e2b":case"modal":case"custom":return{status:"error",backend:this.config.backend,error:`${this.config.backend} backend is not yet implemented. Use Docker for local execution.`};default:return{status:"error",backend:this.config.backend,error:`Unknown backend: ${this.config.backend}`}}}async setup(e){if("docker"===this.config.backend)await p(e);else throw Error(`Setup not supported for backend: ${this.config.backend}`)}async execute(e){switch(this.config.backend){case"docker":if(!await m())return{stdout:"",stderr:"Sandbox image not available. Run setup first or ensure Docker is installed.",exitCode:1,artifacts:[],executionTimeMs:0};return f(e,{...h,...this.config.docker});case"e2b":case"modal":case"custom":return{stdout:"",stderr:`${this.config.backend} backend is not yet implemented.`,exitCode:1,artifacts:[],executionTimeMs:0};default:return{stdout:"",stderr:`Unknown backend: ${this.config.backend}`,exitCode:1,artifacts:[],executionTimeMs:0}}}}],778923),e.s([],983131)},608778,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(666680),n=e.i(192441);let o=[/^\d{4}-\d{2}-\d{2}$/,/^\d{2}\/\d{2}\/\d{4}$/,/^\d{2}-\d{2}-\d{4}$/,/^\d{4}\/\d{2}\/\d{2}$/,/^\d{4}-\d{2}-\d{2}T/];function i(e){if(null==e||""===e)return NaN;if(e instanceof Date)return e.getTime();let t=String(e).trim();if(!t)return NaN;let r=Date.parse(t);if(!isNaN(r))return r;let a=t.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);if(a){let e=Date.parse(`${a[3]}-${a[2]}-${a[1]}`);if(!isNaN(e))return e}let n=t.match(/^(\d{2})-(\d{2})-(\d{4})$/);if(n){let e=Date.parse(`${n[3]}-${n[2]}-${n[1]}`);if(!isNaN(e))return e}return NaN}async function s(e){let t=e?await (0,n.requireDataDir)():await (0,n.getDataDir)();return t?r.default.join(t,"tabular-datasets.json"):null}async function l(){let e=await s(!1);if(!e)return[];try{let r=await t.promises.readFile(e,"utf8");return JSON.parse(r)}catch{return[]}}async function d(e){let r=await s(!0);r&&await t.promises.writeFile(r,JSON.stringify(e,null,2),"utf8")}async function c(e,t){if(0===t.length)throw Error("Cannot save an empty dataset");let r=Object.keys(t[0]),n=r.map(e=>{let r=t.map(t=>t[e]),a=function(e){let t=e.filter(e=>null!=e&&""!==e);if(0===t.length)return"mixed";let r=0,a=0,n=0;for(let e of t){let t=String(e).trim();"true"===t||"false"===t?a++:isNaN(Number(t))||""===t?(o.some(e=>e.test(t))||!isNaN(Date.parse(t)))&&n++:r++}let i=.8*t.length;return r>=i?"number":a>=i?"boolean":n>=i?"date":"string"}(r),n=r.filter(e=>null!=e&&""!==e),s=new Set(n.map(String)),l={name:e,type:a,nullCount:r.length-n.length,uniqueCount:s.size,sampleValues:[...s].slice(0,5)};if("number"===a){let e,t,r,a,o,i,s=n.map(Number).filter(e=>!isNaN(e));s.length>0&&(t=(e=[...s].sort((e,t)=>e-t)).length,a=(r=e.reduce((e,t)=>e+t,0))/t,o=t%2==0?(e[t/2-1]+e[t/2])/2:e[Math.floor(t/2)],i=Math.sqrt(e.reduce((e,t)=>e+(t-a)**2,0)/t),l.stats={min:e[0],max:e[t-1],mean:Number(a.toFixed(4)),median:Number(o.toFixed(4)),stddev:Number(i.toFixed(4)),sum:Number(r.toFixed(4))})}if("date"===a){let e=n.map(String),t=e.map(i).filter(e=>!isNaN(e));if(t.length>0){let r=[...t].sort((e,t)=>e-t);l.dateRange={min:e[t.indexOf(r[0])]??new Date(r[0]).toISOString().split("T")[0],max:e[t.indexOf(r[r.length-1])]??new Date(r[r.length-1]).toISOString().split("T")[0],format:function(e){for(let t of e){if(/^\d{4}-\d{2}-\d{2}$/.test(t))break;if(/^\d{4}-\d{2}-\d{2}T/.test(t))return"YYYY-MM-DDTHH:mm:ss";if(/^\d{2}\/\d{2}\/\d{4}$/.test(t))return"DD/MM/YYYY";if(/^\d{2}-\d{2}-\d{4}$/.test(t))return"DD-MM-YYYY";if(/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"YYYY/MM/DD"}return"YYYY-MM-DD"}(e)}}}return l}),s={totalRows:t.length,totalColumns:n.length,numericColumns:n.filter(e=>"number"===e.type).length,categoricalColumns:n.filter(e=>"string"===e.type).length,dateColumns:n.filter(e=>"date"===e.type).length},c={id:(0,a.randomUUID)(),fileName:e,columns:n,rows:t,summary:s,rowCount:t.length,createdAt:new Date().toISOString()},u=await l();return u.push(c),await d(u),c}async function u(){return(await l()).map(({rows:e,...t})=>t)}async function p(e){return(await l()).find(t=>t.id===e)??null}async function m(e){let t=await l();await d(t.filter(t=>t.id!==e))}async function f(e){let t,r=await p(e.datasetId);if(!r)throw Error(`Dataset not found: ${e.datasetId}`);let a=[...r.rows],n=new Map;for(let e of r.columns)n.set(e.name,e.type);if(e.filters&&e.filters.length>0)for(let t of e.filters){let e="date"===n.get(t.column);a=a.filter(r=>{let a=r[t.column];if(e&&["eq","neq","gt","gte","lt","lte"].includes(t.op)){let e=i(a),r=i(t.value);if(isNaN(e)||isNaN(r))return"eq"===t.op?String(a)===String(t.value):"neq"===t.op&&String(a)!==String(t.value);switch(t.op){case"eq":return e===r;case"neq":return e!==r;case"gt":return e>r;case"gte":return e>=r;case"lt":return e<r;case"lte":return e<=r}}switch(t.op){case"eq":return String(a)===String(t.value);case"neq":return String(a)!==String(t.value);case"gt":return Number(a)>Number(t.value);case"gte":return Number(a)>=Number(t.value);case"lt":return Number(a)<Number(t.value);case"lte":return Number(a)<=Number(t.value);case"contains":return String(a).toLowerCase().includes(String(t.value).toLowerCase());case"in":return Array.isArray(t.value)&&t.value.includes(a);default:return!0}})}if(e.groupBy&&e.groupBy.length>0&&e.aggregations){let t=new Map;for(let r of a){let a=e.groupBy.map(e=>String(r[e])).join("|||"),n=t.get(a)??[];n.push(r),t.set(a,n)}let r=[];for(let[a,n]of t.entries()){let t={},o=a.split("|||");for(let r of(e.groupBy.forEach((e,r)=>{t[e]=o[r]}),e.aggregations)){let e=n.map(e=>Number(e[r.column])).filter(e=>!isNaN(e));t[`${r.op}_${r.column}`]=h(r.op,e)}r.push(t)}a=r}if(e.aggregations&&e.aggregations.length>0&&(!e.groupBy||0===e.groupBy.length))for(let r of(t={},e.aggregations)){let e=a.map(e=>Number(e[r.column])).filter(e=>!isNaN(e));t[`${r.op}_${r.column}`]=h(r.op,e)}if(e.columns&&e.columns.length>0&&(a=a.map(t=>{let r={};for(let a of e.columns)a in t&&(r[a]=t[a]);return r})),e.sortBy){let t="desc"===e.sortOrder?-1:1;a.sort((r,a)=>{let n=r[e.sortBy],o=a[e.sortBy];return null==n&&null==o?0:null==n?1:null==o?-1:"number"==typeof n&&"number"==typeof o?(n-o)*t:String(n).localeCompare(String(o))*t})}let o=a.length;return e.limit&&e.limit>0&&(a=a.slice(0,e.limit)),{columns:a.length>0?Object.keys(a[0]):e.columns??r.columns.map(e=>e.name),rows:a,totalRows:o,aggregationResults:t}}function h(e,t){if(0===t.length)return 0;switch(e){case"sum":return Number(t.reduce((e,t)=>e+t,0).toFixed(4));case"avg":return Number((t.reduce((e,t)=>e+t,0)/t.length).toFixed(4));case"count":return t.length;case"min":return Math.min(...t);case"max":return Math.max(...t);case"median":{let e=[...t].sort((e,t)=>e-t),r=e.length;return r%2==0?Number(((e[r/2-1]+e[r/2])/2).toFixed(4)):e[Math.floor(r/2)]}default:return 0}}e.s(["deleteTabularDataset",0,m,"getTabularDataset",0,p,"listTabularDatasets",0,u,"queryTabular",0,f,"saveTabularDataset",0,c])},225970,e=>{e.v(e=>Promise.resolve().then(()=>e(65048)))},953341,e=>{e.v(t=>Promise.all(["server/chunks/0ozc_@vercel_oidc_dist_token_0m1934l.js"].map(t=>e.l(t))).then(()=>t(624299)))},77149,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0cumfx6._.js"].map(t=>e.l(t))).then(()=>t(292483)))},195059,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0veqa4o._.js"].map(t=>e.l(t))).then(()=>t(148089)))},184904,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0e_itje._.js"].map(t=>e.l(t))).then(()=>t(46465)))},313282,e=>{e.v(t=>Promise.all(["server/chunks/packages_core_src_analytics-store_ts_03tqnqs._.js"].map(t=>e.l(t))).then(()=>t(43697)))},195213,e=>{e.v(e=>Promise.resolve().then(()=>e(568886)))},627270,e=>{e.v(e=>Promise.resolve().then(()=>e(612069)))},311108,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0d7p0xo._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(104757)))},118890,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0y5y7tu._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(508582)))},3366,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0qhpl6k._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(835716)))},654210,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__05wk..v._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(38862)))},187616,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0v67rlo._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(129921)))},465615,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0.r5yhr._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(426237)))}];
197
+ `;let a=r.default.join(p,"run.py");await t.promises.writeFile(a,s,"utf8"),l=["python3","/sandbox/run.py"]}else{let a=r.default.join(p,"run.js");await t.promises.writeFile(a,e.code,"utf8"),l=["node","/sandbox/run.js"]}let g=e.timeout??o.timeoutMs,y=null;try{y=await c.createContainer({Image:o.imageName,Cmd:l,Entrypoint:[],WorkingDir:"/sandbox/input",HostConfig:{AutoRemove:!1,Memory:1024*o.memoryMB*1024,CpuShares:o.cpuShares,NetworkMode:o.networkDisabled?"none":"bridge",Binds:[`${m}:/sandbox/input:ro`,`${f}:${i}:rw`,`${p}/run.py:/sandbox/run.py:ro`],ReadonlyRootfs:!1},Tty:!1,AttachStdout:!0,AttachStderr:!0}),await y.start();let e=y.wait(),a=new Promise((e,t)=>{setTimeout(async()=>{try{await y?.kill()}catch{}t(Error(`Execution timed out after ${g}ms`))},g)}),n=await Promise.race([e,a]),s=await y.logs({stdout:!0,stderr:!0,follow:!1}),d=function(e){let t="",r="";if("string"==typeof e)return{stdout:e,stderr:""};let a=0;for(;a<e.length&&!(a+8>e.length);){let n=e.readUInt8(a),o=e.readUInt32BE(a+4);if((a+=8)+o>e.length)break;let i=e.subarray(a,a+o).toString("utf8");1===n?t+=i:2===n&&(r+=i),a+=o}return t||r||!(e.length>0)||(t=e.toString("utf8")),{stdout:t,stderr:r}}(s),h=[];try{for(let e of(await t.promises.readdir(f))){let a=r.default.join(f,e),n=await t.promises.readFile(a),o={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".svg":"image/svg+xml",".gif":"image/gif",".csv":"text/csv",".json":"application/json",".txt":"text/plain",".html":"text/html",".pdf":"application/pdf"}[r.default.extname(e).toLowerCase()]??"application/octet-stream";h.push({name:e,mimeType:o,data:n.toString("base64")})}}catch{}let{stdout:b,stderr:w}=d;return{stdout:b.replace(/\n__ARTIFACTS__:.*$/m,"").trimEnd(),stderr:w,exitCode:n.StatusCode??1,artifacts:h,executionTimeMs:Date.now()-u}}catch(e){return{stdout:"",stderr:e.message??"Execution failed",exitCode:1,artifacts:[],executionTimeMs:Date.now()-u}}finally{if(y)try{await y.remove({force:!0})}catch{}try{await t.promises.rm(p,{recursive:!0,force:!0})}catch{}}}let f={imageName:"larkup-sandbox:latest",memoryMB:512,cpuShares:1024,timeoutMs:3e4,networkDisabled:!0};e.s(["SandboxManager",0,class{config;constructor(e){this.config={backend:e?.backend??"docker",docker:e?.docker,remote:e?.remote}}async healthCheck(){switch(this.config.backend){case"docker":return c();case"e2b":case"modal":case"custom":return{status:"error",backend:this.config.backend,error:`${this.config.backend} backend is not yet implemented. Use Docker for local execution.`};default:return{status:"error",backend:this.config.backend,error:`Unknown backend: ${this.config.backend}`}}}async setup(e){if("docker"===this.config.backend)await u(e);else throw Error(`Setup not supported for backend: ${this.config.backend}`)}async execute(e){switch(this.config.backend){case"docker":if(!await p())return{stdout:"",stderr:"Sandbox image not available. Run setup first or ensure Docker is installed.",exitCode:1,artifacts:[],executionTimeMs:0};return m(e,{...f,...this.config.docker});case"e2b":case"modal":case"custom":return{stdout:"",stderr:`${this.config.backend} backend is not yet implemented.`,exitCode:1,artifacts:[],executionTimeMs:0};default:return{stdout:"",stderr:`Unknown backend: ${this.config.backend}`,exitCode:1,artifacts:[],executionTimeMs:0}}}}],778923),e.s([],983131)},608778,e=>{"use strict";var t=e.i(902157),r=e.i(750227),a=e.i(666680),n=e.i(192441);let o=[/^\d{4}-\d{2}-\d{2}$/,/^\d{2}\/\d{2}\/\d{4}$/,/^\d{2}-\d{2}-\d{4}$/,/^\d{4}\/\d{2}\/\d{2}$/,/^\d{4}-\d{2}-\d{2}T/];function i(e){if(null==e||""===e)return NaN;if(e instanceof Date)return e.getTime();let t=String(e).trim();if(!t)return NaN;let r=Date.parse(t);if(!isNaN(r))return r;let a=t.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);if(a){let e=Date.parse(`${a[3]}-${a[2]}-${a[1]}`);if(!isNaN(e))return e}let n=t.match(/^(\d{2})-(\d{2})-(\d{4})$/);if(n){let e=Date.parse(`${n[3]}-${n[2]}-${n[1]}`);if(!isNaN(e))return e}return NaN}async function s(e){let t=e?await (0,n.requireDataDir)():await (0,n.getDataDir)();return t?r.default.join(t,"tabular-datasets.json"):null}async function l(){let e=await s(!1);if(!e)return[];try{let r=await t.promises.readFile(e,"utf8");return JSON.parse(r)}catch{return[]}}async function d(e){let r=await s(!0);r&&await t.promises.writeFile(r,JSON.stringify(e,null,2),"utf8")}async function c(e,t){if(0===t.length)throw Error("Cannot save an empty dataset");let r=Object.keys(t[0]),n=r.map(e=>{let r=t.map(t=>t[e]),a=function(e){let t=e.filter(e=>null!=e&&""!==e);if(0===t.length)return"mixed";let r=0,a=0,n=0;for(let e of t){let t=String(e).trim();"true"===t||"false"===t?a++:isNaN(Number(t))||""===t?(o.some(e=>e.test(t))||!isNaN(Date.parse(t)))&&n++:r++}let i=.8*t.length;return r>=i?"number":a>=i?"boolean":n>=i?"date":"string"}(r),n=r.filter(e=>null!=e&&""!==e),s=new Set(n.map(String)),l={name:e,type:a,nullCount:r.length-n.length,uniqueCount:s.size,sampleValues:[...s].slice(0,5)};if("number"===a){let e,t,r,a,o,i,s=n.map(Number).filter(e=>!isNaN(e));s.length>0&&(t=(e=[...s].sort((e,t)=>e-t)).length,a=(r=e.reduce((e,t)=>e+t,0))/t,o=t%2==0?(e[t/2-1]+e[t/2])/2:e[Math.floor(t/2)],i=Math.sqrt(e.reduce((e,t)=>e+(t-a)**2,0)/t),l.stats={min:e[0],max:e[t-1],mean:Number(a.toFixed(4)),median:Number(o.toFixed(4)),stddev:Number(i.toFixed(4)),sum:Number(r.toFixed(4))})}if("date"===a){let e=n.map(String),t=e.map(i).filter(e=>!isNaN(e));if(t.length>0){let r=[...t].sort((e,t)=>e-t);l.dateRange={min:e[t.indexOf(r[0])]??new Date(r[0]).toISOString().split("T")[0],max:e[t.indexOf(r[r.length-1])]??new Date(r[r.length-1]).toISOString().split("T")[0],format:function(e){for(let t of e){if(/^\d{4}-\d{2}-\d{2}$/.test(t))break;if(/^\d{4}-\d{2}-\d{2}T/.test(t))return"YYYY-MM-DDTHH:mm:ss";if(/^\d{2}\/\d{2}\/\d{4}$/.test(t))return"DD/MM/YYYY";if(/^\d{2}-\d{2}-\d{4}$/.test(t))return"DD-MM-YYYY";if(/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"YYYY/MM/DD"}return"YYYY-MM-DD"}(e)}}}return l}),s={totalRows:t.length,totalColumns:n.length,numericColumns:n.filter(e=>"number"===e.type).length,categoricalColumns:n.filter(e=>"string"===e.type).length,dateColumns:n.filter(e=>"date"===e.type).length},c={id:(0,a.randomUUID)(),fileName:e,columns:n,rows:t,summary:s,rowCount:t.length,createdAt:new Date().toISOString()},u=await l();return u.push(c),await d(u),c}async function u(){return(await l()).map(({rows:e,...t})=>t)}async function p(e){return(await l()).find(t=>t.id===e)??null}async function m(e){let t=await l();await d(t.filter(t=>t.id!==e))}async function f(e){let t,r=await p(e.datasetId);if(!r)throw Error(`Dataset not found: ${e.datasetId}`);let a=[...r.rows],n=new Map;for(let e of r.columns)n.set(e.name,e.type);if(e.filters&&e.filters.length>0)for(let t of e.filters){let e="date"===n.get(t.column);a=a.filter(r=>{let a=r[t.column];if(e&&["eq","neq","gt","gte","lt","lte"].includes(t.op)){let e=i(a),r=i(t.value);if(isNaN(e)||isNaN(r))return"eq"===t.op?String(a)===String(t.value):"neq"===t.op&&String(a)!==String(t.value);switch(t.op){case"eq":return e===r;case"neq":return e!==r;case"gt":return e>r;case"gte":return e>=r;case"lt":return e<r;case"lte":return e<=r}}switch(t.op){case"eq":return String(a)===String(t.value);case"neq":return String(a)!==String(t.value);case"gt":return Number(a)>Number(t.value);case"gte":return Number(a)>=Number(t.value);case"lt":return Number(a)<Number(t.value);case"lte":return Number(a)<=Number(t.value);case"contains":return String(a).toLowerCase().includes(String(t.value).toLowerCase());case"in":return Array.isArray(t.value)&&t.value.includes(a);default:return!0}})}if(e.groupBy&&e.groupBy.length>0&&e.aggregations){let t=new Map;for(let r of a){let a=e.groupBy.map(e=>String(r[e])).join("|||"),n=t.get(a)??[];n.push(r),t.set(a,n)}let r=[];for(let[a,n]of t.entries()){let t={},o=a.split("|||");for(let r of(e.groupBy.forEach((e,r)=>{t[e]=o[r]}),e.aggregations)){let e=n.map(e=>Number(e[r.column])).filter(e=>!isNaN(e));t[`${r.op}_${r.column}`]=h(r.op,e)}r.push(t)}a=r}if(e.aggregations&&e.aggregations.length>0&&(!e.groupBy||0===e.groupBy.length))for(let r of(t={},e.aggregations)){let e=a.map(e=>Number(e[r.column])).filter(e=>!isNaN(e));t[`${r.op}_${r.column}`]=h(r.op,e)}if(e.columns&&e.columns.length>0&&(a=a.map(t=>{let r={};for(let a of e.columns)a in t&&(r[a]=t[a]);return r})),e.sortBy){let t="desc"===e.sortOrder?-1:1;a.sort((r,a)=>{let n=r[e.sortBy],o=a[e.sortBy];return null==n&&null==o?0:null==n?1:null==o?-1:"number"==typeof n&&"number"==typeof o?(n-o)*t:String(n).localeCompare(String(o))*t})}let o=a.length;return e.limit&&e.limit>0&&(a=a.slice(0,e.limit)),{columns:a.length>0?Object.keys(a[0]):e.columns??r.columns.map(e=>e.name),rows:a,totalRows:o,aggregationResults:t}}function h(e,t){if(0===t.length)return 0;switch(e){case"sum":return Number(t.reduce((e,t)=>e+t,0).toFixed(4));case"avg":return Number((t.reduce((e,t)=>e+t,0)/t.length).toFixed(4));case"count":return t.length;case"min":return Math.min(...t);case"max":return Math.max(...t);case"median":{let e=[...t].sort((e,t)=>e-t),r=e.length;return r%2==0?Number(((e[r/2-1]+e[r/2])/2).toFixed(4)):e[Math.floor(r/2)]}default:return 0}}e.s(["deleteTabularDataset",0,m,"getTabularDataset",0,p,"listTabularDatasets",0,u,"queryTabular",0,f,"saveTabularDataset",0,c])},225970,e=>{e.v(e=>Promise.resolve().then(()=>e(65048)))},953341,e=>{e.v(t=>Promise.all(["server/chunks/0ozc_@vercel_oidc_dist_token_0m1934l.js"].map(t=>e.l(t))).then(()=>t(624299)))},77149,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0cumfx6._.js"].map(t=>e.l(t))).then(()=>t(292483)))},195059,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0dlwf67._.js"].map(t=>e.l(t))).then(()=>t(148089)))},184904,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0e_itje._.js"].map(t=>e.l(t))).then(()=>t(46465)))},313282,e=>{e.v(t=>Promise.all(["server/chunks/packages_core_src_analytics-store_ts_03tqnqs._.js"].map(t=>e.l(t))).then(()=>t(43697)))},195213,e=>{e.v(e=>Promise.resolve().then(()=>e(568886)))},627270,e=>{e.v(e=>Promise.resolve().then(()=>e(612069)))},311108,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0d7p0xo._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(104757)))},118890,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0y5y7tu._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(508582)))},3366,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0qhpl6k._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(835716)))},654210,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__05wk..v._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(38862)))},187616,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0v67rlo._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(129921)))},465615,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0.r5yhr._.js","server/chunks/0gvc_next_03p7xh-._.js"].map(t=>e.l(t))).then(()=>t(426237)))}];
198
198
 
199
- //# sourceMappingURL=%5Broot-of-the-server%5D__0036943._.js.map
199
+ //# sourceMappingURL=%5Broot-of-the-server%5D__13ydff-._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[215240,a=>{"use strict";var b=a.i(881479),c=a.i(396318);function d(a){return RegExp(`/${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=[/?#]|$)`)}function e(a){return(0,b.useEffect)(()=>{var b;a.beforeSend&&(null==(b=window.va)||b.call(window,"beforeSend",a.beforeSend))},[a.beforeSend]),(0,b.useEffect)(()=>{!function(a={debug:!0}){}({framework:a.framework||"react",basePath:a.basePath??function(){if("u">typeof process&&void 0!==process.env)return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}(),...void 0!==a.route&&{disableAutoTrack:!0},...a})},[]),(0,b.useEffect)(()=>{a.route&&a.path&&function({route:a,path:b}){var c;null==(c=window.va)||c.call(window,"pageview",{route:a,path:b})}({route:a.route,path:a.path})},[a.route,a.path]),null}function f(a){let f,g,h,{route:i,path:j}=(f=(0,c.useParams)(),g=(0,c.useSearchParams)(),h=(0,c.usePathname)(),f?{route:function(a,b){if(!a||!b)return a;let c=a;try{let a=Object.entries(b);for(let[b,e]of a)if(!Array.isArray(e)){let a=d(e);a.test(c)&&(c=c.replace(a,`/[${b}]`))}for(let[b,e]of a)if(Array.isArray(e)){let a=d(e.join("/"));a.test(c)&&(c=c.replace(a,`/[...${b}]`))}return c}catch(b){return a}}(h,Object.keys(f).length?f:Object.fromEntries(g.entries())),path:h}:{route:null,path:h});return b.default.createElement(e,{path:j,route:i,...a,basePath:function(){if("u">typeof process&&void 0!==process.env)return process.env.NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH}(),framework:"next"})}a.s(["Analytics",0,function(a){return b.default.createElement(b.Suspense,{fallback:null},b.default.createElement(f,{...a}))}])},554502,a=>{"use strict";var b=a.i(379152),c=a.i(881479),d=(a,b,c,d,e,f,g,h)=>{let i=document.documentElement,j=["light","dark"];function k(b){var c;(Array.isArray(a)?a:[a]).forEach(a=>{let c="class"===a,d=c&&f?e.map(a=>f[a]||a):e;c?(i.classList.remove(...d),i.classList.add(f&&f[b]?f[b]:b)):i.setAttribute(a,b)}),c=b,h&&j.includes(c)&&(i.style.colorScheme=c)}if(d)k(d);else try{let a=localStorage.getItem(b)||c,d=g&&"system"===a?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a;k(d)}catch(a){}},e=c.createContext(void 0),f={setTheme:a=>{},themes:[]};c.memo(({forcedTheme:a,storageKey:b,attribute:e,enableSystem:f,enableColorScheme:g,defaultTheme:h,value:i,themes:j,nonce:k,scriptProps:l})=>{let m=JSON.stringify([e,b,h,a,j,i,f,g]).slice(1,-1);return c.createElement("script",{...l,suppressHydrationWarning:!0,nonce:k,dangerouslySetInnerHTML:{__html:`(${d.toString()})(${m})`}})});var g=a.i(952313),h=a.i(308591),h=h,i=a.i(428142),i=i,j=a.i(601773),j=j,k=a.i(998632),k=k,l=a.i(453009),l=l;a.s(["Toaster",0,({...a})=>{var d;let{theme:m="system"}=null!=(d=c.useContext(e))?d:f;return(0,b.jsx)(g.Toaster,{closeButton:!0,theme:m,className:"toaster group z-9999999! ",icons:{success:(0,b.jsx)(h.default,{className:"size-5 text-white",fill:"#10b981"}),info:(0,b.jsx)(i.default,{className:"size-5 text-white",fill:"#3b82f6"}),warning:(0,b.jsx)(j.default,{className:"size-5 text-white",fill:"#f59e0b"}),error:(0,b.jsx)(k.default,{className:"size-5 text-white",fill:"#ef4444"}),loading:(0,b.jsx)(l.default,{className:"size-5 animate-spin text-muted-foreground"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)",zIndex:999999},toastOptions:{classNames:{toast:"group toast items-start group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900 group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:",icon:"mt-0.5",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",success:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",error:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",warning:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",info:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900"}},...a})}],554502)},881150,a=>{"use strict";var b=a.i(379152),c=a.i(295805),d=a.i(881479),e=a.i(51372),f=a.i(396318),g=a.i(234065),h=a.i(818842),i=a.i(919305),j=a.i(42598);let k=(0,j.default)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);var l=a.i(267348),m=a.i(738834),n=a.i(74192),o=a.i(599335),p=a.i(823259);let q=(0,j.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);var r=a.i(8409),s=a.i(906947),t=a.i(501356),u=a.i(94842),v=a.i(161859),w=a.i(7812),x=a.i(952313),y=a.i(660911),z=a.i(541487),A=a.i(343578);function B({target:a,open:c,onOpenChange:e}){let{deleteServer:f}=(0,v.useWorkspace)(),[g,h]=(0,d.useState)(!1);async function i(){if(a){h(!0);try{await f(a.id),x.toast.success(`Deleted "${a.name}".`),e(!1)}catch{x.toast.error("Could not delete the server.")}finally{h(!1)}}}return(0,b.jsx)(A.Dialog,{open:c,onOpenChange:e,children:(0,b.jsxs)(A.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsxs)(A.DialogHeader,{children:[(0,b.jsxs)(A.DialogTitle,{children:["Delete “",a?.name,"”?"]}),(0,b.jsx)(A.DialogDescription,{children:"This permanently removes the server's documents, index, vector data, and generated files. This cannot be undone."})]}),(0,b.jsxs)(A.DialogFooter,{children:[(0,b.jsx)(z.Button,{variant:"outline",onClick:()=>e(!1),disabled:g,children:"Cancel"}),(0,b.jsxs)(z.Button,{variant:"destructive",onClick:()=>void i(),disabled:g,children:[g&&(0,b.jsx)(y.Loader2,{className:"size-4 animate-spin"}),"Delete server"]})]})]})})}function C(){let{servers:a,activeServer:c,activateServer:e}=(0,v.useWorkspace)(),[f,g]=(0,d.useState)(!1),[h,i]=(0,d.useState)(null),[j,k]=(0,d.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(u.DropdownMenu,{children:[(0,b.jsxs)(u.DropdownMenuTrigger,{render:(0,b.jsx)("button",{type:"button",className:"flex w-full items-center gap-2 rounded-lg border border-border bg-card px-2 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),children:[(0,b.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary/12 text-primary",children:(0,b.jsx)(m.Server,{className:"size-3.5"})}),(0,b.jsx)("span",{className:"flex min-w-0 flex-1 flex-col",children:(0,b.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:c?.name??"No server"}),c?.running&&(0,b.jsx)(D,{})]})}),(0,b.jsx)(q,{className:"size-4 shrink-0 text-muted-foreground"})]}),(0,b.jsxs)(u.DropdownMenuContent,{align:"start",sideOffset:6,className:"w-(--anchor-width) min-w-[260px]",children:[(0,b.jsxs)(u.DropdownMenuGroup,{children:[(0,b.jsx)(u.DropdownMenuLabel,{children:"Your servers"}),a.map(a=>{let d=a.id===c?.id;return(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>{d||e(a.id)},className:"gap-2",children:[(0,b.jsx)("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:(0,b.jsx)(m.Server,{className:"size-3.5"})}),(0,b.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:a.name}),(0,b.jsxs)("span",{className:"flex items-center gap-2 text-[11px] text-muted-foreground tabular-nums",children:[(0,b.jsxs)("span",{children:[a.docCount," docs"]}),a.indexed&&(0,b.jsx)("span",{children:"· indexed"}),a.running&&(0,b.jsxs)("span",{className:"flex items-center gap-1 text-green-500",children:[(0,b.jsx)(D,{}),"live"]})]})]}),d&&(0,b.jsx)(p.Check,{className:"size-4 shrink-0 text-primary"})]},a.id)})]}),(0,b.jsx)(u.DropdownMenuSeparator,{}),(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>g(!0),className:"gap-2 h-9",children:[(0,b.jsx)(s.Plus,{className:"size-4"}),"New server"]}),c&&(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>i(c),className:"gap-2 h-9",children:[(0,b.jsx)(r.Pencil,{className:"size-4"}),"Rename current"]}),c&&a.length>1&&(0,b.jsxs)(u.DropdownMenuItem,{variant:"destructive",onClick:()=>k(c),className:"gap-2",children:[(0,b.jsx)(t.Trash2,{className:"size-4"}),"Delete current"]})]})]}),(0,b.jsx)(w.ServerFormDialog,{mode:"create",open:f,onOpenChange:g}),(0,b.jsx)(w.ServerFormDialog,{mode:"rename",target:h,open:null!==h,onOpenChange:a=>!a&&i(null)}),(0,b.jsx)(B,{target:j,open:null!==j,onOpenChange:a=>!a&&k(null)})]})}function D(){return(0,b.jsxs)("span",{className:"relative flex size-2",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-500"})]})}let E={"panel-default":void 0,"panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"},F=[{id:"chat",label:"Chat",href:"/chat",icon:g.MessageCircle},{id:"data",label:"Data",href:"/data",icon:h.Database},{id:"analytics",label:"Analytics",href:"/analytics",icon:k},{id:"settings",label:"Settings",href:"/settings",icon:i.Settings}];function G(){let a=(0,f.usePathname)(),{pageStyle:g,navBg:h}=(0,c.useThemeCustomizer)(),{activeServer:i}=(0,v.useWorkspace)(),[j,k]=(0,d.useState)(!0);(0,d.useEffect)(()=>{"false"===localStorage.getItem("sidebar-collapsed")&&k(!1)},[]);let p=()=>{let a=!j;k(a),localStorage.setItem("sidebar-collapsed",String(a))},q=h?E[h]:void 0;return(0,b.jsx)(o.TooltipProvider,{delay:150,children:(0,b.jsxs)("aside",{className:(0,n.cn)("sticky top-0 hidden h-screen shrink-0 flex-col self-start py-4 md:flex transition-all duration-300 ease-in-out",j?"w-18":"w-60",q?"":"bg-background","fused"===g?"border-r border-border":""),style:q?{backgroundColor:q}:void 0,children:[(0,b.jsx)("div",{className:(0,n.cn)("flex w-full items-center mb-6",j?"justify-center px-3":"justify-between px-4"),children:j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)("button",{onClick:p,"aria-label":"Expand sidebar",className:"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105"}),children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)(o.TooltipContent,{side:"right",sideOffset:10,children:"Expand sidebar"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(e.default,{href:"/chat",className:"flex items-center gap-2.5",children:[(0,b.jsx)("span",{className:"flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Larkup"})]}),(0,b.jsx)("button",{onClick:p,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors","aria-label":"Collapse sidebar",children:(0,b.jsx)(l.ChevronLeft,{className:"size-3.5"})})]})}),(0,b.jsx)("nav",{className:(0,n.cn)("flex flex-1 flex-col w-full",j?"items-center px-3 gap-3":"px-3 gap-1.5"),children:F.map(c=>{let d=c.icon,f=a===c.href||"/"!==c.href&&a?.startsWith(c.href);return j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)(e.default,{href:c.href,"aria-current":f?"page":void 0,onClick:b=>{"chat"===c.id&&"/chat"===a&&(b.preventDefault(),window.dispatchEvent(new CustomEvent("new-chat")))},className:(0,n.cn)("group relative flex size-10 items-center justify-center rounded-xl transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring",f?"bg-[#F0F0F0] text-foreground":"text-muted-foreground hover:bg-[#EBEBEB] hover:text-foreground")}),children:(0,b.jsx)(d,{className:"size-4.5",strokeWidth:f?2.25:1.75})}),(0,b.jsx)(o.TooltipContent,{side:"right",sideOffset:10,children:c.label})]},c.id):(0,b.jsxs)(e.default,{href:c.href,"aria-current":f?"page":void 0,onClick:b=>{"chat"===c.id&&"/chat"===a&&(b.preventDefault(),window.dispatchEvent(new CustomEvent("new-chat")))},className:(0,n.cn)("group relative flex items-center gap-3 rounded-xl px-3 py-2.5 text-[13px] font-medium transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring",f?"bg-[#F0F0F0] text-foreground":"text-muted-foreground hover:bg-[#EBEBEB] hover:text-foreground"),children:[(0,b.jsx)(d,{className:"size-4.5 shrink-0",strokeWidth:f?2.25:1.75}),(0,b.jsx)("span",{className:"truncate",children:c.label})]},c.id)})}),(0,b.jsx)("div",{className:(0,n.cn)("w-full pt-3",j?"px-2":"px-3"),children:j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)("button",{onClick:p,className:"flex w-full items-center justify-center py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"}),children:(0,b.jsxs)("div",{className:"relative size-8 rounded-lg border border-border bg-card flex items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:[(0,b.jsx)(m.Server,{className:"size-4"}),(0,b.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 flex size-2.5",children:i?.running?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-full rounded-full bg-green-500 border border-card"})]}):(0,b.jsx)("span",{className:"relative inline-flex size-full rounded-full bg-gray-500 border border-card"})})]})}),(0,b.jsxs)(o.TooltipContent,{side:"right",sideOffset:10,children:[i?.name??"No server"," (",i?.running?"Live":"Offline",")"]})]}):(0,b.jsx)(C,{})})]})})}let H={"panel-default":void 0,"panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"},I=[{id:"chat",label:"Chat",href:"/chat",icon:g.MessageCircle},{id:"data",label:"Data",href:"/data",icon:h.Database},{id:"analytics",label:"Analytics",href:"/analytics",icon:k},{id:"settings",label:"Settings",href:"/settings",icon:i.Settings}];function J(){let a=(0,f.usePathname)(),{username:d}=(0,v.useWorkspace)(),{navBg:g}=(0,c.useThemeCustomizer)(),h=g?H[g]:void 0;return(0,b.jsx)(o.TooltipProvider,{delay:150,children:(0,b.jsxs)("header",{className:(0,n.cn)("sticky top-0 z-50 flex h-14 shrink-0 items-center gap-6 border-b border-border px-4 md:px-6",h?"":"bg-[#F5F5F4]"),style:h?{backgroundColor:h}:void 0,children:[(0,b.jsxs)(e.default,{href:"/chat","aria-label":"larkup home",className:"flex items-center gap-2.5 shrink-0",children:[(0,b.jsx)("span",{className:"flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)("span",{className:"font-semibold tracking-tight text-foreground hidden sm:inline-block",children:"Larkup"})]}),(0,b.jsx)("nav",{className:"flex h-full items-center gap-1",children:I.map(c=>{let d=c.icon,f=a===c.href||"/"!==c.href&&a?.startsWith(c.href);return(0,b.jsxs)(e.default,{href:c.href,"aria-current":f?"page":void 0,className:(0,n.cn)("group relative flex items-center gap-2 h-full px-3 text-[13px] font-medium transition-colors outline-none",f?"text-primary":"text-muted-foreground hover:text-foreground"),children:[(0,b.jsx)(d,{className:"size-[16px]",strokeWidth:f?2.25:1.75}),(0,b.jsx)("span",{className:"hidden md:inline",children:c.label}),(0,b.jsx)("span",{className:(0,n.cn)("absolute bottom-0 left-2 right-2 h-[2px] rounded-full bg-primary transition-opacity",f?"opacity-100":"opacity-0")})]},c.id)})}),(0,b.jsx)("div",{className:"flex-1"}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)(C,{}),d&&(0,b.jsxs)("span",{className:"hidden text-sm text-muted-foreground md:block",children:["Hi, ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:d})]})]})]})})}let K=(0,j.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var L=a.i(279370),M=a.i(71129),M=M,N=a.i(961644),O=a.i(555404),P=a.i(572727),Q=a.i(4455);let R=["vercel_ai_gateway","openai","google","mistral","custom"];function S(){let{setUsername:a,createServer:c,refresh:e}=(0,v.useWorkspace)(),g=(0,f.useRouter)(),[h,i]=(0,d.useState)(""),[j,k]=(0,d.useState)("vercel_ai_gateway"),[l,m]=(0,d.useState)(""),[n,o]=(0,d.useState)(null),[p,q]=(0,d.useState)("vercel_ai_gateway"),[s,t]=(0,d.useState)(""),[u,w]=(0,d.useState)(null),[B,C]=(0,d.useState)(!1),[D,E]=(0,d.useState)(!1),[F,G]=(0,d.useState)(null),H="custom"===j,I="custom"===p,J=D||H||j!==p?s:l,S=async()=>{C(!0);try{let b=await fetch("/api/config"),{config:d}=await b.json(),f={...d};H&&n?(f.embeddingProvider="custom",f.embeddingModelId=`custom:${n.modelName}`,f.embeddingApiKey=n.apiKey||void 0,f.customEmbeddings=[n]):(f.embeddingProvider=j,f.embeddingApiKey=l),D?I&&u?(f.chatProvider="custom",f.chatModelId=`custom:${u.modelName}`,f.chatApiKey=u.apiKey||void 0,f.customChatModels=[u]):(f.chatProvider=p,f.chatApiKey=J):H&&n||(f.chatProvider=j,f.chatApiKey=l);let i=await fetch("/api/config/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({embeddingProvider:f.embeddingProvider,embeddingApiKey:f.embeddingApiKey,embeddingModelId:f.embeddingModelId,customEmbeddings:f.customEmbeddings,chatProvider:f.chatProvider,chatApiKey:f.chatApiKey,chatModelId:f.chatModelId,customChatModels:f.customChatModels})});if(!i.ok){let a=await i.json();x.toast.error(a.error||"Verification failed — please check your API key.",{duration:8e3}),C(!1);return}h.trim()&&await a(h.trim()),await c("my-larkup"),await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),e(),g.push("/chat")}catch(a){x.toast.error("Failed to complete setup")}finally{C(!1)}},T=async()=>{C(!0);try{h.trim()&&await a(h.trim()),await c("my-larkup"),e(),g.push("/chat")}catch(a){x.toast.error("Failed to complete setup")}finally{C(!1)}},U=(a,c)=>(0,b.jsxs)(O.Select,{value:a,onValueChange:a=>{var b;"custom"===(b=a??"")?("embedding"===c?k("custom"):q("custom"),G(c)):"embedding"===c?(k(b),o(null),!D&&q(b)):(q(b),w(null))},children:[(0,b.jsx)(O.SelectTrigger,{className:"w-full bg-white/90 hover:bg-white",children:(0,b.jsx)("span",{className:"flex items-center gap-2",children:P.PROVIDER_META[a]?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(P.ProviderIcon,{src:P.PROVIDER_META[a].iconSrc,alt:P.PROVIDER_META[a].label,pillBg:P.PROVIDER_META[a].pillBg,size:16}),P.PROVIDER_META[a].label]}):"Select provider"})}),(0,b.jsx)(O.SelectContent,{children:R.map(a=>{let c=P.PROVIDER_META[a];return c?(0,b.jsx)(O.SelectItem,{value:a,children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(P.ProviderIcon,{src:c.iconSrc,alt:c.label,pillBg:c.pillBg,size:16}),(0,b.jsxs)("span",{children:[c.label,"vercel_ai_gateway"===a&&" (Recommended)","custom"===a&&" (OpenAI-compatible)"]})]})},a):null})})]}),V=(a,c)=>(0,b.jsxs)("div",{className:"mt-1.5 flex items-center gap-2 rounded-lg border border-green-200 bg-green-50/50 px-3 py-2",children:[(0,b.jsx)("span",{className:"text-green-600 text-xs",children:"✓"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs font-medium text-foreground",children:a.modelName}),(0,b.jsx)("button",{type:"button",onClick:()=>G(c),className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(r.Pencil,{className:"size-3"})})]});return(0,b.jsxs)("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-background",children:[(0,b.jsxs)("div",{className:"pointer-events-none fixed inset-0 overflow-hidden",children:[(0,b.jsx)("div",{className:"absolute -left-20 -top-20 h-125 w-125 rounded-full bg-stone-200/40 blur-3xl animate-pulse"}),(0,b.jsx)("div",{className:"absolute -bottom-32 -right-32 h-150 w-150 rounded-full bg-amber-100/30 blur-3xl animate-pulse [animation-delay:1s]"})]}),(0,b.jsx)("div",{className:"relative z-10 flex min-h-full w-full flex-col items-center justify-center px-6 py-12",children:(0,b.jsxs)("div",{className:"flex w-full max-w-lg flex-col items-center gap-8 animate-fade-up",children:[(0,b.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[(0,b.jsx)("div",{className:"flex size-14 items-center justify-center rounded-xl bg-primary text-primary-foreground ",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-8",alt:"Larkup"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:"Welcome to Larkup"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Let's set up your AI models. You can change these later in Settings."})]})]}),(0,b.jsxs)("div",{className:"w-full space-y-5 rounded-2xl p-6 backdrop-blur-xl",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Your Name (Optional)"}),(0,b.jsx)(N.Input,{value:h,onChange:a=>i(a.target.value),placeholder:"How should we call you?",className:"bg-background/50"})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Embedding Provider"}),U(j,"embedding"),H&&n&&V(n,"embedding"),H&&!n&&(0,b.jsx)("p",{className:"text-[11px] text-amber-600 mt-1",children:"Please configure and test your custom model to continue."})]}),!H&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("label",{className:"text-xs font-medium text-foreground",children:["API Key",!D&&(0,b.jsxs)("span",{className:"text-muted-foreground font-normal",children:[" ","(used for both embedding & chat)"]})]}),(0,b.jsx)(N.Input,{type:"password",value:l,onChange:a=>m(a.target.value),placeholder:"sk-...",className:"bg-background/50"})]}),(0,b.jsxs)("button",{type:"button",onClick:()=>E(!D),className:"flex w-full items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[D?(0,b.jsx)(M.default,{className:"size-3.5"}):(0,b.jsx)(L.ChevronDown,{className:"size-3.5"}),"Use a different chat model"]}),D&&(0,b.jsxs)("div",{className:"space-y-3 rounded-xl border border-border/40 bg-muted/20 p-4",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Chat Provider"}),U(p,"chat"),I&&u&&V(u,"chat"),I&&!u&&(0,b.jsx)("p",{className:"text-[11px] text-amber-600 mt-1",children:"Please configure and test your custom model to continue."})]}),!I&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Chat API Key"}),(0,b.jsx)(N.Input,{type:"password",value:s,onChange:a=>t(a.target.value),placeholder:"sk-...",className:"bg-background/50"})]})]}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"More providers and fine-grained model selection available in Settings → AI Models."}),(0,b.jsxs)("div",{className:"pt-2 flex gap-3",children:[(0,b.jsx)(z.Button,{variant:"outline",className:"flex-1",onClick:T,disabled:B,children:"Skip for now"}),(0,b.jsx)(z.Button,{className:"flex-1",onClick:S,disabled:B||!(()=>{if(H){if(!n)return!1}else if(!l)return!1;if(D){if(I){if(!u)return!1}else if(!J)return!1}return!0})(),children:B?(0,b.jsx)(y.Loader2,{className:"size-4 animate-spin"}):(0,b.jsxs)(b.Fragment,{children:["Continue ",(0,b.jsx)(K,{className:"ml-1.5 size-4"})]})})]})]})]})}),(0,b.jsx)(A.Dialog,{open:null!==F,onOpenChange:a=>{a||("embedding"!==F||n||k("vercel_ai_gateway"),"chat"!==F||u||q("vercel_ai_gateway"),G(null))},children:(0,b.jsxs)(A.DialogContent,{className:"max-w-xl",children:[(0,b.jsxs)(A.DialogHeader,{children:[(0,b.jsxs)(A.DialogTitle,{children:["Custom ","embedding"===F?"Embedding":"Chat"," Model"]}),(0,b.jsxs)(A.DialogDescription,{children:["Connect an OpenAI-compatible ","embedding"===F?"embedding":"chat"," ","model. Test the connection before adding."]})]}),F&&(0,b.jsx)(Q.CustomModelForm,{type:F,onSave:a=>{"embedding"===F?(o(a),k("custom")):"chat"===F&&(w(a),q("custom")),G(null)},onCancel:()=>{"embedding"!==F||n||k("vercel_ai_gateway"),"chat"!==F||u||q("vercel_ai_gateway"),G(null)}})]})})]})}let T={"panel-default":"#FAFAFA","panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"};a.s(["ClientLayoutWrapper",0,function({children:a}){let{pageStyle:d,panelBg:e,layout:g}=(0,c.useThemeCustomizer)(),h=(0,f.usePathname)(),i=h?.includes("/chat"),{isFirstRun:j,isLoading:k}=(0,v.useWorkspace)(),l=T[e],m=l?{backgroundColor:l}:void 0;return!k&&j?(0,b.jsx)(S,{}):k?(0,b.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,b.jsx)("div",{className:"size-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):"topnav"===g?(0,b.jsxs)("div",{className:"flex flex-col h-screen overflow-hidden",children:[(0,b.jsx)(J,{}),(0,b.jsx)("main",{className:"min-w-0 flex-1 overflow-hidden",children:(0,b.jsx)("div",{className:"h-full flex flex-col bg-background text-foreground",style:m,children:(0,b.jsx)("div",{className:(0,n.cn)("flex-1 min-h-0",i||h?.includes("/settings")||h?.includes("/analytics")?"overflow-hidden flex flex-col":"overflow-auto"),children:(0,b.jsx)("div",{className:(0,n.cn)("h-full w-full",i||h?.includes("/settings")||h?.includes("/analytics")?"flex-1 min-h-0 flex flex-col":"container mx-auto pb-8"),children:a})})})})]}):(0,b.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,b.jsx)(G,{}),(0,b.jsx)("main",{className:"min-w-0 flex-1 overflow-hidden",children:(0,b.jsx)("div",{className:"fused"===d?"h-screen flex flex-col bg-background text-foreground overflow-hidden":"h-screen flex flex-col md:rounded-l-2xl border-l border-border bg-panel text-panel-foreground overflow-hidden",style:m,children:(0,b.jsx)("div",{className:(0,n.cn)("flex-1 min-h-0",i||h?.includes("/settings")||h?.includes("/analytics")?"overflow-hidden flex flex-col":"overflow-auto"),children:(0,b.jsx)("div",{className:(0,n.cn)("h-full w-full",i||h?.includes("/settings")||h?.includes("/analytics")?"flex-1 min-h-0 flex flex-col":"container mx-auto pb-8"),children:a})})})})]})}],881150)},316105,a=>{"use strict";var b=a.i(379152),c=a.i(860091),d=a.i(660911),e=a.i(881479),f=a.i(476866),g=a.i(42598);let h=(0,g.default)("boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);var i=a.i(20924);let j=(0,g.default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);var k=a.i(818842),l=a.i(171217);let m=(0,g.default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);var n=a.i(799304),o=a.i(918018),p=a.i(166243),q=a.i(434954);let r=(0,g.default)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);var s=a.i(953191),t=a.i(96607),u=a.i(541487),v=a.i(655208),w=a.i(299574),x=a.i(483115),y=a.i(95507),z=a.i(952313),A=a.i(717994),B=a.i(343578);let C=a=>fetch(a).then(a=>a.json()),D=["chunking","embedding","upserting"];function E({open:a,onOpenChange:g,trigger:h}){let[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),m=void 0!==a,r=m?a:k,s=m&&g?g:l,{data:t,isLoading:v,mutate:w}=(0,c.default)("/api/index",C,{refreshInterval:a=>a?.run&&D.includes(a.run.status)?1e3:0}),G=(0,e.useRef)(void 0);(0,e.useEffect)(()=>{let a=t?.run?.warning;a&&a!==G.current?z.toast.warning(a,{id:"rate-limit-warning",duration:7e4}):!a&&G.current&&(z.toast.dismiss("rate-limit-warning"),z.toast.success("Rate limit resolved — resuming indexing.",{duration:3e3})),G.current=a},[t?.run?.warning]);let[I,J]=(0,e.useState)(!1);async function K(a=!1){j(!0);try{let b=await fetch("/api/index",{method:"POST",body:JSON.stringify({incremental:a}),headers:{"Content-Type":"application/json"}}),c=await b.json();if(!b.ok)return void z.toast.error(c.error??"Could not start indexing.");z.toast.success("Indexing started."),w()}catch{z.toast.error("Could not start indexing.")}finally{j(!1)}}async function L(){j(!0);try{if(!(await fetch("/api/index",{method:"DELETE"})).ok)return void z.toast.error("Could not cancel indexing.");z.toast.success("Indexing cancelled."),w()}catch{z.toast.error("Could not cancel indexing.")}finally{j(!1)}}return(0,e.useEffect)(()=>{let a=t?.run?.status;a&&D.includes(a)?J(!0):I&&"completed"===a&&(J(!1),s(!1),z.toast.success("Indexing completed successfully!"))},[t?.run?.status,I,s]),(0,b.jsxs)(B.Dialog,{open:r,onOpenChange:s,children:[h?(0,b.jsx)(B.DialogTrigger,{render:(0,e.isValidElement)(h)?h:(0,b.jsx)("button",{children:h})}):(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[t?.run?.status==="completed"&&(0,b.jsxs)(A.AlertDialog,{children:[(0,b.jsx)(A.AlertDialogTrigger,{render:(0,b.jsxs)(u.Button,{disabled:!t.ready||!!(t.run&&D.includes(t.run.status))||i,variant:"outline",children:[(0,b.jsx)(q.RotateCcw,{className:"size-4 mr-2"}),"Re-Index Data"]})}),(0,b.jsxs)(A.AlertDialogContent,{children:[(0,b.jsxs)(A.AlertDialogHeader,{children:[(0,b.jsx)(A.AlertDialogTitle,{children:"Are you sure you want to re-index data?"}),(0,b.jsx)(A.AlertDialogDescription,{children:"This will rebuild the entire index from scratch. All documents will be re-processed."})]}),(0,b.jsxs)(A.AlertDialogFooter,{children:[(0,b.jsx)(A.AlertDialogCancel,{children:"Cancel"}),(0,b.jsx)(A.AlertDialogAction,{onClick:()=>{s(!0),K(!1)},children:"Continue"})]})]})]}),(0,b.jsx)(B.DialogTrigger,{render:(0,b.jsxs)(u.Button,{disabled:!t?.ready||t?.unindexedCount===0,children:[(0,b.jsx)(o.Layers,{className:"size-4 mr-2"}),"Index Data"]})})]}),(0,b.jsxs)(B.DialogContent,{className:"max-w-2xl max-h-[90vh] overflow-y-auto ",children:[(0,b.jsxs)(B.DialogHeader,{children:[(0,b.jsx)(B.DialogTitle,{children:"Index Data"}),(0,b.jsx)(B.DialogDescription,{children:"Chunk, embed, and index into your selected vector database."})]}),v||!t?(0,b.jsx)("div",{className:"py-6",children:(0,b.jsx)(y.Skeleton,{className:"h-40 w-full"})}):(0,b.jsxs)("div",{className:"space-y-6 py-4",children:[(0,b.jsx)(F,{config:t.config,docCount:t.docCount,charCount:t.charCount}),!t.ready&&(0,b.jsxs)(x.Alert,{variant:"default",children:[(0,b.jsx)(f.AlertTriangle,{className:"size-4 text-orange-500!"}),(0,b.jsx)(x.AlertTitle,{className:"text-orange-500!",children:"Not ready to index"}),(0,b.jsx)(x.AlertDescription,{children:(0,b.jsx)("ul",{className:"list-disc pl-4",children:t.blockers.map(a=>(0,b.jsx)("li",{children:a},a))})})]}),(0,b.jsx)(H,{run:t.run,running:!!(t.run&&D.includes(t.run.status))}),t.ready&&!t.run&&(0,b.jsxs)(x.Alert,{children:[(0,b.jsx)(n.Info,{className:"size-4 text-blue-500!"}),(0,b.jsx)(x.AlertTitle,{className:"text-blue-600 dark:text-blue-400",children:"Before you start indexing"}),(0,b.jsxs)(x.AlertDescription,{className:"text-muted-foreground space-y-1",children:[(0,b.jsxs)("p",{children:["Once indexing begins, two settings become"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:"locked"})," to the existing index:"]}),(0,b.jsxs)("ul",{className:"list-disc pl-4 space-y-0.5",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Embedding model"})," — you can swap to any model with the"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:"same vector dimensions"}),", but switching to a model with different dimensions will require a full re-index."]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Vector store"})," — changing the store after indexing requires starting fresh."]})]})]})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsxs)(u.Button,{onClick:()=>K(t.run?.status==="completed"),disabled:!t.ready||!!(t.run&&D.includes(t.run.status))||i||t.run?.status==="completed"&&0===t.unindexedCount,size:"lg",children:[t.run&&D.includes(t.run.status)||i?(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin mr-2"}):(0,b.jsx)(p.Play,{className:"size-4 mr-2"}),t.run&&D.includes(t.run.status)?"Indexing…":i?"Starting…":t.run?.status==="completed"?`Index new documents (${t.unindexedCount})`:`Start indexing (${t.unindexedCount})`]}),t.run?.status==="completed"&&!(t.run&&D.includes(t.run.status))&&(0,b.jsxs)(A.AlertDialog,{children:[(0,b.jsx)(A.AlertDialogTrigger,{render:(0,b.jsxs)(u.Button,{variant:"outline",size:"lg",disabled:i,children:[(0,b.jsx)(q.RotateCcw,{className:"size-4 mr-2"}),"Re-Index All"]})}),(0,b.jsxs)(A.AlertDialogContent,{children:[(0,b.jsxs)(A.AlertDialogHeader,{children:[(0,b.jsx)(A.AlertDialogTitle,{children:"Are you sure you want to re-index data?"}),(0,b.jsx)(A.AlertDialogDescription,{children:"This will rebuild the entire index from scratch. All documents will be re-processed."})]}),(0,b.jsxs)(A.AlertDialogFooter,{children:[(0,b.jsx)(A.AlertDialogCancel,{children:"Cancel"}),(0,b.jsx)(A.AlertDialogAction,{onClick:()=>{s(!0),K(!1)},children:"Continue"})]})]})]}),!!(t.run&&D.includes(t.run.status))&&(0,b.jsx)(u.Button,{onClick:L,disabled:i,size:"lg",variant:"destructive",children:"Cancel"})]}),(0,b.jsx)(u.Button,{variant:"ghost",size:"lg",onClick:()=>s(!1),children:"Close"})]})]})]})]})}function F({config:a,docCount:c,charCount:d}){let e=(0,s.getEmbeddingModel)(a.embeddingModelId),f=(0,t.getVectorStore)(a.vectorStore),g=[{icon:j,label:"Embedding model",value:e?.label??a.embeddingModelId,hint:e?`${e.dimensions} dims`:void 0},{icon:k.Database,label:"Vector store",value:f?.label??a.vectorStore},{icon:h,label:"Index type",value:a.indexType.toUpperCase()},{icon:r,label:"Chunking",value:`${a.chunking.chunkSize} / ${a.chunking.chunkOverlap}`,hint:"size / overlap"},{icon:l.FileText,label:"Corpus",value:`${c.toLocaleString()} docs`,hint:`${d.toLocaleString()} chars`}];return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground p-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-base font-semibold mb-4",children:[(0,b.jsx)(o.Layers,{className:"size-4 text-primary"}),"Index configuration"]}),(0,b.jsx)("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-5 sm:grid-cols-3",children:g.map(a=>(0,b.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,b.jsxs)("dt",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,b.jsx)(a.icon,{className:"size-3.5"}),a.label]}),(0,b.jsxs)("dd",{className:"text-sm font-medium leading-tight",children:[a.value,a.hint&&(0,b.jsx)("span",{className:"ml-1.5 font-mono text-[11px] font-normal text-muted-foreground",children:a.hint})]})]},a.label))})]})}let G={idle:{label:"Idle"},chunking:{label:"Chunking",phase:"Splitting documents into chunks"},embedding:{label:"Embedding",phase:"Generating vector embeddings"},upserting:{label:"Storing",phase:"Writing vectors to the store"},completed:{label:"Completed"},failed:{label:"Failed"}};function H({run:a,running:c}){if(!a)return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground flex flex-col items-center justify-center gap-1 py-8 text-center",children:[(0,b.jsx)(m,{className:"mb-1 size-6 text-muted-foreground/60"}),(0,b.jsx)("p",{className:"text-sm font-medium",children:"No index built yet"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Build a Larkup index to embed your corpus and make it searchable."})]});let e=G[a.status],g=a.totalChunks>0?Math.round(a.processedChunks/a.totalChunks*100):5*!!c;return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground p-4 space-y-4",children:[(0,b.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-base font-semibold",children:["completed"===a.status?(0,b.jsx)(i.CheckCircle2,{className:"size-4 text-primary"}):"failed"===a.status?(0,b.jsx)(f.AlertTriangle,{className:"size-4 text-destructive"}):(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin text-primary"}),e.label]}),(0,b.jsx)(J,{status:a.status})]}),"failed"===a.status?(0,b.jsx)(b.Fragment,{}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:e.phase??"Done"}),(0,b.jsxs)("span",{className:"font-mono tabular-nums",children:[a.processedChunks.toLocaleString(),a.totalChunks>0&&` / ${a.totalChunks.toLocaleString()}`," chunks"]})]}),(0,b.jsx)(v.Progress,{value:g,className:"**:data-[slot=progress-indicator]:bg-green-600"})]}),(0,b.jsxs)("dl",{className:"grid grid-cols-2 gap-4 pt-1 sm:grid-cols-4",children:[(0,b.jsx)(I,{label:"Documents",value:a.docCount.toLocaleString()}),(0,b.jsx)(I,{label:"Chunks",value:a.totalChunks.toLocaleString()}),(0,b.jsx)(I,{label:"Dimensions",value:a.dimensions?a.dimensions.toLocaleString():"—"}),(0,b.jsx)(I,{label:"Duration",value:a.durationMs?`${(a.durationMs/1e3).toFixed(1)}s`:c?"running…":"—"})]})]})]})}function I({label:a,value:c}){return(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("dt",{className:"text-xs text-muted-foreground",children:a}),(0,b.jsx)("dd",{className:"font-mono text-sm tabular-nums",children:c})]})}function J({status:a}){return"completed"===a?(0,b.jsx)(w.Badge,{className:"bg-primary/12 text-primary hover:bg-primary/12",children:"Ready"}):"failed"===a?(0,b.jsx)(w.Badge,{variant:"destructive",children:"Failed"}):D.includes(a)?(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-green-600",children:[(0,b.jsxs)("span",{className:"relative flex size-2",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-600 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-600"})]}),"Live"]}):null}let K=a=>fetch(a).then(a=>a.json()),L=["chunking","embedding","upserting"];a.s(["GlobalIndexProgress",0,function(){let{data:a}=(0,c.default)("/api/index",K,{refreshInterval:a=>a?.run&&L.includes(a.run.status)?1e3:0});if(!(a?.run&&L.includes(a.run.status))||!a?.run)return null;let{run:e}=a,f=e.totalChunks>0?Math.round(e.processedChunks/e.totalChunks*100):5;return(0,b.jsx)("div",{className:"fixed bottom-6 right-6 z-50",children:(0,b.jsx)(E,{trigger:(0,b.jsxs)("button",{className:"flex items-center gap-3 rounded-full border bg-background px-4 py-2 text-sm font-medium transition-all hover:bg-muted/50 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin text-primary"}),(0,b.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,b.jsx)("span",{className:"text-xs leading-none text-muted-foreground",children:"Storing..."}),(0,b.jsxs)("span",{className:"leading-none",children:[f,"%"]})]})]})})})}],316105)},150760,a=>{"use strict";var b=a.i(379152),c=a.i(881479),d=a.i(731505),e=a.i(823259),f=a.i(304995),g=a.i(130179),h=a.i(541487);let i={docker:"docker compose pull && docker compose up -d",npm:"larkup update"};a.s(["UpdateBanner",0,function(){let[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(!1),r="0.1.22",s="true"===process.env.NEXT_PUBLIC_DOCKER_ENV||"true"===process.env.NEXT_PUBLIC_RUNNING_IN_DOCKER?"docker":"npm";(0,c.useEffect)(()=>{},[r]);let t=async()=>{if("desktop"===s){o(!0);try{let{check:b}=await a.A(914053),{relaunch:c}=await a.A(69832),d=await b();d?(await d.downloadAndInstall(),await c()):o(!1)}catch(a){console.error("Auto-update failed:",a),o(!1),window.open("https://larkup.de/download","_blank")}}else try{await navigator.clipboard.writeText(i[s]),q(!0),window.setTimeout(()=>q(!1),2e3)}catch(a){console.error("Could not copy update command:",a)}};return l&&j?(0,b.jsx)("div",{role:"status","aria-live":"polite",className:"relative z-50 border-b border-border bg-background px-3 py-2 text-foreground sm:px-4",children:(0,b.jsxs)("div",{className:"mx-auto flex min-h-7 max-w-screen-2xl items-center gap-2.5",children:[(0,b.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background",children:(0,b.jsx)(d.ArrowUp,{className:"size-3.5","aria-hidden":"true"})}),(0,b.jsxs)("p",{className:"min-w-0 text-xs sm:text-sm",children:[(0,b.jsxs)("span",{className:"font-medium",children:["Larkup v",j," is available."]})," ",(0,b.jsxs)("span",{className:"hidden text-muted-foreground sm:inline",children:["You're using v",r,"."]})]}),"desktop"!==s&&(0,b.jsx)("code",{className:"ml-auto hidden max-w-[38rem] truncate rounded-[5px] border border-border bg-muted/40 px-2 py-1 font-mono text-[11px] text-muted-foreground lg:block",children:i[s]}),(0,b.jsx)(h.Button,{type:"button",variant:"desktop"===s?"default":"outline",size:"xs",onClick:t,disabled:n,"aria-label":"desktop"===s?"Update Larkup now":"Copy update command",className:"desktop"===s?"ml-auto":"ml-auto lg:ml-0",children:"desktop"===s?n?"Updating...":"Update now":p?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(e.Check,{"aria-hidden":"true"}),"Copied"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Copy,{"aria-hidden":"true"}),"Copy command"]})}),(0,b.jsx)(h.Button,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>{try{localStorage.setItem("larkup-update-dismissed",JSON.stringify({timestamp:Date.now()}))}catch{}m(!1)},"aria-label":"Dismiss update notification",title:"Remind me tomorrow",children:(0,b.jsx)(g.X,{"aria-hidden":"true"})})]})}):null}])}];
1
+ module.exports=[215240,a=>{"use strict";var b=a.i(881479),c=a.i(396318);function d(a){return RegExp(`/${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=[/?#]|$)`)}function e(a){return(0,b.useEffect)(()=>{var b;a.beforeSend&&(null==(b=window.va)||b.call(window,"beforeSend",a.beforeSend))},[a.beforeSend]),(0,b.useEffect)(()=>{!function(a={debug:!0}){}({framework:a.framework||"react",basePath:a.basePath??function(){if("u">typeof process&&void 0!==process.env)return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}(),...void 0!==a.route&&{disableAutoTrack:!0},...a})},[]),(0,b.useEffect)(()=>{a.route&&a.path&&function({route:a,path:b}){var c;null==(c=window.va)||c.call(window,"pageview",{route:a,path:b})}({route:a.route,path:a.path})},[a.route,a.path]),null}function f(a){let f,g,h,{route:i,path:j}=(f=(0,c.useParams)(),g=(0,c.useSearchParams)(),h=(0,c.usePathname)(),f?{route:function(a,b){if(!a||!b)return a;let c=a;try{let a=Object.entries(b);for(let[b,e]of a)if(!Array.isArray(e)){let a=d(e);a.test(c)&&(c=c.replace(a,`/[${b}]`))}for(let[b,e]of a)if(Array.isArray(e)){let a=d(e.join("/"));a.test(c)&&(c=c.replace(a,`/[...${b}]`))}return c}catch(b){return a}}(h,Object.keys(f).length?f:Object.fromEntries(g.entries())),path:h}:{route:null,path:h});return b.default.createElement(e,{path:j,route:i,...a,basePath:function(){if("u">typeof process&&void 0!==process.env)return process.env.NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH}(),framework:"next"})}a.s(["Analytics",0,function(a){return b.default.createElement(b.Suspense,{fallback:null},b.default.createElement(f,{...a}))}])},554502,a=>{"use strict";var b=a.i(379152),c=a.i(881479),d=(a,b,c,d,e,f,g,h)=>{let i=document.documentElement,j=["light","dark"];function k(b){var c;(Array.isArray(a)?a:[a]).forEach(a=>{let c="class"===a,d=c&&f?e.map(a=>f[a]||a):e;c?(i.classList.remove(...d),i.classList.add(f&&f[b]?f[b]:b)):i.setAttribute(a,b)}),c=b,h&&j.includes(c)&&(i.style.colorScheme=c)}if(d)k(d);else try{let a=localStorage.getItem(b)||c,d=g&&"system"===a?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a;k(d)}catch(a){}},e=c.createContext(void 0),f={setTheme:a=>{},themes:[]};c.memo(({forcedTheme:a,storageKey:b,attribute:e,enableSystem:f,enableColorScheme:g,defaultTheme:h,value:i,themes:j,nonce:k,scriptProps:l})=>{let m=JSON.stringify([e,b,h,a,j,i,f,g]).slice(1,-1);return c.createElement("script",{...l,suppressHydrationWarning:!0,nonce:k,dangerouslySetInnerHTML:{__html:`(${d.toString()})(${m})`}})});var g=a.i(952313),h=a.i(308591),h=h,i=a.i(428142),i=i,j=a.i(601773),j=j,k=a.i(998632),k=k,l=a.i(453009),l=l;a.s(["Toaster",0,({...a})=>{var d;let{theme:m="system"}=null!=(d=c.useContext(e))?d:f;return(0,b.jsx)(g.Toaster,{closeButton:!0,theme:m,className:"toaster group z-9999999! ",icons:{success:(0,b.jsx)(h.default,{className:"size-5 text-white",fill:"#10b981"}),info:(0,b.jsx)(i.default,{className:"size-5 text-white",fill:"#3b82f6"}),warning:(0,b.jsx)(j.default,{className:"size-5 text-white",fill:"#f59e0b"}),error:(0,b.jsx)(k.default,{className:"size-5 text-white",fill:"#ef4444"}),loading:(0,b.jsx)(l.default,{className:"size-5 animate-spin text-muted-foreground"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)",zIndex:999999},toastOptions:{classNames:{toast:"group toast items-start group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900 group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:",icon:"mt-0.5",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",success:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",error:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",warning:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",info:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900"}},...a})}],554502)},881150,a=>{"use strict";var b=a.i(379152),c=a.i(295805),d=a.i(881479),e=a.i(51372),f=a.i(396318),g=a.i(234065),h=a.i(818842),i=a.i(919305),j=a.i(42598);let k=(0,j.default)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);var l=a.i(267348),m=a.i(738834),n=a.i(74192),o=a.i(599335),p=a.i(823259);let q=(0,j.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);var r=a.i(8409),s=a.i(906947),t=a.i(501356),u=a.i(94842),v=a.i(161859),w=a.i(7812),x=a.i(952313),y=a.i(660911),z=a.i(541487),A=a.i(343578);function B({target:a,open:c,onOpenChange:e}){let{deleteServer:f}=(0,v.useWorkspace)(),[g,h]=(0,d.useState)(!1);async function i(){if(a){h(!0);try{await f(a.id),x.toast.success(`Deleted "${a.name}".`),e(!1)}catch{x.toast.error("Could not delete the server.")}finally{h(!1)}}}return(0,b.jsx)(A.Dialog,{open:c,onOpenChange:e,children:(0,b.jsxs)(A.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsxs)(A.DialogHeader,{children:[(0,b.jsxs)(A.DialogTitle,{children:["Delete “",a?.name,"”?"]}),(0,b.jsx)(A.DialogDescription,{children:"This permanently removes the server's documents, index, vector data, and generated files. This cannot be undone."})]}),(0,b.jsxs)(A.DialogFooter,{children:[(0,b.jsx)(z.Button,{variant:"outline",onClick:()=>e(!1),disabled:g,children:"Cancel"}),(0,b.jsxs)(z.Button,{variant:"destructive",onClick:()=>void i(),disabled:g,children:[g&&(0,b.jsx)(y.Loader2,{className:"size-4 animate-spin"}),"Delete server"]})]})]})})}function C(){let{servers:a,activeServer:c,activateServer:e}=(0,v.useWorkspace)(),[f,g]=(0,d.useState)(!1),[h,i]=(0,d.useState)(null),[j,k]=(0,d.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(u.DropdownMenu,{children:[(0,b.jsxs)(u.DropdownMenuTrigger,{render:(0,b.jsx)("button",{type:"button",className:"flex w-full items-center gap-2 rounded-lg border border-border bg-card px-2 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),children:[(0,b.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary/12 text-primary",children:(0,b.jsx)(m.Server,{className:"size-3.5"})}),(0,b.jsx)("span",{className:"flex min-w-0 flex-1 flex-col",children:(0,b.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:c?.name??"No server"}),c?.running&&(0,b.jsx)(D,{})]})}),(0,b.jsx)(q,{className:"size-4 shrink-0 text-muted-foreground"})]}),(0,b.jsxs)(u.DropdownMenuContent,{align:"start",sideOffset:6,className:"w-(--anchor-width) min-w-[260px]",children:[(0,b.jsxs)(u.DropdownMenuGroup,{children:[(0,b.jsx)(u.DropdownMenuLabel,{children:"Your servers"}),a.map(a=>{let d=a.id===c?.id;return(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>{d||e(a.id)},className:"gap-2",children:[(0,b.jsx)("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:(0,b.jsx)(m.Server,{className:"size-3.5"})}),(0,b.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:a.name}),(0,b.jsxs)("span",{className:"flex items-center gap-2 text-[11px] text-muted-foreground tabular-nums",children:[(0,b.jsxs)("span",{children:[a.docCount," docs"]}),a.indexed&&(0,b.jsx)("span",{children:"· indexed"}),a.running&&(0,b.jsxs)("span",{className:"flex items-center gap-1 text-green-500",children:[(0,b.jsx)(D,{}),"live"]})]})]}),d&&(0,b.jsx)(p.Check,{className:"size-4 shrink-0 text-primary"})]},a.id)})]}),(0,b.jsx)(u.DropdownMenuSeparator,{}),(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>g(!0),className:"gap-2 h-9",children:[(0,b.jsx)(s.Plus,{className:"size-4"}),"New server"]}),c&&(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>i(c),className:"gap-2 h-9",children:[(0,b.jsx)(r.Pencil,{className:"size-4"}),"Rename current"]}),c&&a.length>1&&(0,b.jsxs)(u.DropdownMenuItem,{variant:"destructive",onClick:()=>k(c),className:"gap-2",children:[(0,b.jsx)(t.Trash2,{className:"size-4"}),"Delete current"]})]})]}),(0,b.jsx)(w.ServerFormDialog,{mode:"create",open:f,onOpenChange:g}),(0,b.jsx)(w.ServerFormDialog,{mode:"rename",target:h,open:null!==h,onOpenChange:a=>!a&&i(null)}),(0,b.jsx)(B,{target:j,open:null!==j,onOpenChange:a=>!a&&k(null)})]})}function D(){return(0,b.jsxs)("span",{className:"relative flex size-2",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-500"})]})}let E={"panel-default":void 0,"panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"},F=[{id:"chat",label:"Chat",href:"/chat",icon:g.MessageCircle},{id:"data",label:"Data",href:"/data",icon:h.Database},{id:"analytics",label:"Analytics",href:"/analytics",icon:k},{id:"settings",label:"Settings",href:"/settings",icon:i.Settings}];function G(){let a=(0,f.usePathname)(),{pageStyle:g,navBg:h}=(0,c.useThemeCustomizer)(),{activeServer:i}=(0,v.useWorkspace)(),[j,k]=(0,d.useState)(!0);(0,d.useEffect)(()=>{"false"===localStorage.getItem("sidebar-collapsed")&&k(!1)},[]);let p=()=>{let a=!j;k(a),localStorage.setItem("sidebar-collapsed",String(a))},q=h?E[h]:void 0;return(0,b.jsx)(o.TooltipProvider,{delay:150,children:(0,b.jsxs)("aside",{className:(0,n.cn)("sticky top-0 hidden h-screen shrink-0 flex-col self-start py-4 md:flex transition-all duration-300 ease-in-out",j?"w-18":"w-60",q?"":"bg-background","fused"===g?"border-r border-border":""),style:q?{backgroundColor:q}:void 0,children:[(0,b.jsx)("div",{className:(0,n.cn)("flex w-full items-center mb-6",j?"justify-center px-3":"justify-between px-4"),children:j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)("button",{onClick:p,"aria-label":"Expand sidebar",className:"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105"}),children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)(o.TooltipContent,{side:"right",sideOffset:10,children:"Expand sidebar"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(e.default,{href:"/chat",className:"flex items-center gap-2.5",children:[(0,b.jsx)("span",{className:"flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Larkup"})]}),(0,b.jsx)("button",{onClick:p,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors","aria-label":"Collapse sidebar",children:(0,b.jsx)(l.ChevronLeft,{className:"size-3.5"})})]})}),(0,b.jsx)("nav",{className:(0,n.cn)("flex flex-1 flex-col w-full",j?"items-center px-3 gap-3":"px-3 gap-1.5"),children:F.map(c=>{let d=c.icon,f=a===c.href||"/"!==c.href&&a?.startsWith(c.href);return j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)(e.default,{href:c.href,"aria-current":f?"page":void 0,onClick:b=>{"chat"===c.id&&"/chat"===a&&(b.preventDefault(),window.dispatchEvent(new CustomEvent("new-chat")))},className:(0,n.cn)("group relative flex size-10 items-center justify-center rounded-xl transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring",f?"bg-[#F0F0F0] text-foreground":"text-muted-foreground hover:bg-[#EBEBEB] hover:text-foreground")}),children:(0,b.jsx)(d,{className:"size-4.5",strokeWidth:f?2.25:1.75})}),(0,b.jsx)(o.TooltipContent,{side:"right",sideOffset:10,children:c.label})]},c.id):(0,b.jsxs)(e.default,{href:c.href,"aria-current":f?"page":void 0,onClick:b=>{"chat"===c.id&&"/chat"===a&&(b.preventDefault(),window.dispatchEvent(new CustomEvent("new-chat")))},className:(0,n.cn)("group relative flex items-center gap-3 rounded-xl px-3 py-2.5 text-[13px] font-medium transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring",f?"bg-[#F0F0F0] text-foreground":"text-muted-foreground hover:bg-[#EBEBEB] hover:text-foreground"),children:[(0,b.jsx)(d,{className:"size-4.5 shrink-0",strokeWidth:f?2.25:1.75}),(0,b.jsx)("span",{className:"truncate",children:c.label})]},c.id)})}),(0,b.jsx)("div",{className:(0,n.cn)("w-full pt-3",j?"px-2":"px-3"),children:j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)("button",{onClick:p,className:"flex w-full items-center justify-center py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"}),children:(0,b.jsxs)("div",{className:"relative size-8 rounded-lg border border-border bg-card flex items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:[(0,b.jsx)(m.Server,{className:"size-4"}),(0,b.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 flex size-2.5",children:i?.running?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-full rounded-full bg-green-500 border border-card"})]}):(0,b.jsx)("span",{className:"relative inline-flex size-full rounded-full bg-gray-500 border border-card"})})]})}),(0,b.jsxs)(o.TooltipContent,{side:"right",sideOffset:10,children:[i?.name??"No server"," (",i?.running?"Live":"Offline",")"]})]}):(0,b.jsx)(C,{})})]})})}let H={"panel-default":void 0,"panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"},I=[{id:"chat",label:"Chat",href:"/chat",icon:g.MessageCircle},{id:"data",label:"Data",href:"/data",icon:h.Database},{id:"analytics",label:"Analytics",href:"/analytics",icon:k},{id:"settings",label:"Settings",href:"/settings",icon:i.Settings}];function J(){let a=(0,f.usePathname)(),{username:d}=(0,v.useWorkspace)(),{navBg:g}=(0,c.useThemeCustomizer)(),h=g?H[g]:void 0;return(0,b.jsx)(o.TooltipProvider,{delay:150,children:(0,b.jsxs)("header",{className:(0,n.cn)("sticky top-0 z-50 flex h-14 shrink-0 items-center gap-6 border-b border-border px-4 md:px-6",h?"":"bg-[#F5F5F4]"),style:h?{backgroundColor:h}:void 0,children:[(0,b.jsxs)(e.default,{href:"/chat","aria-label":"larkup home",className:"flex items-center gap-2.5 shrink-0",children:[(0,b.jsx)("span",{className:"flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)("span",{className:"font-semibold tracking-tight text-foreground hidden sm:inline-block",children:"Larkup"})]}),(0,b.jsx)("nav",{className:"flex h-full items-center gap-1",children:I.map(c=>{let d=c.icon,f=a===c.href||"/"!==c.href&&a?.startsWith(c.href);return(0,b.jsxs)(e.default,{href:c.href,"aria-current":f?"page":void 0,className:(0,n.cn)("group relative flex items-center gap-2 h-full px-3 text-[13px] font-medium transition-colors outline-none",f?"text-primary":"text-muted-foreground hover:text-foreground"),children:[(0,b.jsx)(d,{className:"size-[16px]",strokeWidth:f?2.25:1.75}),(0,b.jsx)("span",{className:"hidden md:inline",children:c.label}),(0,b.jsx)("span",{className:(0,n.cn)("absolute bottom-0 left-2 right-2 h-[2px] rounded-full bg-primary transition-opacity",f?"opacity-100":"opacity-0")})]},c.id)})}),(0,b.jsx)("div",{className:"flex-1"}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)(C,{}),d&&(0,b.jsxs)("span",{className:"hidden text-sm text-muted-foreground md:block",children:["Hi, ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:d})]})]})]})})}let K=(0,j.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var L=a.i(279370),M=a.i(71129),M=M,N=a.i(961644),O=a.i(555404),P=a.i(572727),Q=a.i(4455);let R=["vercel_ai_gateway","openai","google","mistral","custom"];function S(){let{setUsername:a,createServer:c,refresh:e}=(0,v.useWorkspace)(),g=(0,f.useRouter)(),[h,i]=(0,d.useState)(""),[j,k]=(0,d.useState)("vercel_ai_gateway"),[l,m]=(0,d.useState)(""),[n,o]=(0,d.useState)(null),[p,q]=(0,d.useState)("vercel_ai_gateway"),[s,t]=(0,d.useState)(""),[u,w]=(0,d.useState)(null),[B,C]=(0,d.useState)(!1),[D,E]=(0,d.useState)(!1),[F,G]=(0,d.useState)(null),H="custom"===j,I="custom"===p,J=D||H||j!==p?s:l,S=async()=>{C(!0);try{let b=await fetch("/api/config"),{config:d}=await b.json(),f={...d};H&&n?(f.embeddingProvider="custom",f.embeddingModelId=`custom:${n.modelName}`,f.embeddingApiKey=n.apiKey||void 0,f.customEmbeddings=[n]):(f.embeddingProvider=j,f.embeddingApiKey=l),D?I&&u?(f.chatProvider="custom",f.chatModelId=`custom:${u.modelName}`,f.chatApiKey=u.apiKey||void 0,f.customChatModels=[u]):(f.chatProvider=p,f.chatApiKey=J):H&&n||(f.chatProvider=j,f.chatApiKey=l);let i=await fetch("/api/config/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({embeddingProvider:f.embeddingProvider,embeddingApiKey:f.embeddingApiKey,embeddingModelId:f.embeddingModelId,customEmbeddings:f.customEmbeddings,chatProvider:f.chatProvider,chatApiKey:f.chatApiKey,chatModelId:f.chatModelId,customChatModels:f.customChatModels})});if(!i.ok){let a=await i.json();x.toast.error(a.error||"Verification failed — please check your API key.",{duration:8e3}),C(!1);return}h.trim()&&await a(h.trim()),await c("my-larkup"),await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),e(),g.push("/chat")}catch(a){x.toast.error("Failed to complete setup")}finally{C(!1)}},T=async()=>{C(!0);try{h.trim()&&await a(h.trim()),await c("my-larkup"),e(),g.push("/chat")}catch(a){x.toast.error("Failed to complete setup")}finally{C(!1)}},U=(a,c)=>(0,b.jsxs)(O.Select,{value:a,onValueChange:a=>{var b;"custom"===(b=a??"")?("embedding"===c?k("custom"):q("custom"),G(c)):"embedding"===c?(k(b),o(null),!D&&q(b)):(q(b),w(null))},children:[(0,b.jsx)(O.SelectTrigger,{className:"w-full bg-white/90 hover:bg-white",children:(0,b.jsx)("span",{className:"flex items-center gap-2",children:P.PROVIDER_META[a]?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(P.ProviderIcon,{src:P.PROVIDER_META[a].iconSrc,alt:P.PROVIDER_META[a].label,pillBg:P.PROVIDER_META[a].pillBg,size:16}),P.PROVIDER_META[a].label]}):"Select provider"})}),(0,b.jsx)(O.SelectContent,{children:R.map(a=>{let c=P.PROVIDER_META[a];return c?(0,b.jsx)(O.SelectItem,{value:a,children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(P.ProviderIcon,{src:c.iconSrc,alt:c.label,pillBg:c.pillBg,size:16}),(0,b.jsxs)("span",{children:[c.label,"vercel_ai_gateway"===a&&" (Recommended)","custom"===a&&" (OpenAI-compatible)"]})]})},a):null})})]}),V=(a,c)=>(0,b.jsxs)("div",{className:"mt-1.5 flex items-center gap-2 rounded-lg border border-green-200 bg-green-50/50 px-3 py-2",children:[(0,b.jsx)("span",{className:"text-green-600 text-xs",children:"✓"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs font-medium text-foreground",children:a.modelName}),(0,b.jsx)("button",{type:"button",onClick:()=>G(c),className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(r.Pencil,{className:"size-3"})})]});return(0,b.jsxs)("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-background",children:[(0,b.jsxs)("div",{className:"pointer-events-none fixed inset-0 overflow-hidden",children:[(0,b.jsx)("div",{className:"absolute -left-20 -top-20 h-125 w-125 rounded-full bg-stone-200/40 blur-3xl animate-pulse"}),(0,b.jsx)("div",{className:"absolute -bottom-32 -right-32 h-150 w-150 rounded-full bg-amber-100/30 blur-3xl animate-pulse [animation-delay:1s]"})]}),(0,b.jsx)("div",{className:"relative z-10 flex min-h-full w-full flex-col items-center justify-center px-6 py-12",children:(0,b.jsxs)("div",{className:"flex w-full max-w-lg flex-col items-center gap-8 animate-fade-up",children:[(0,b.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[(0,b.jsx)("div",{className:"flex size-14 items-center justify-center rounded-xl bg-primary text-primary-foreground ",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-8",alt:"Larkup"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:"Welcome to Larkup"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Let's set up your AI models. You can change these later in Settings."})]})]}),(0,b.jsxs)("div",{className:"w-full space-y-5 rounded-2xl p-6 backdrop-blur-xl",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Your Name (Optional)"}),(0,b.jsx)(N.Input,{value:h,onChange:a=>i(a.target.value),placeholder:"How should we call you?",className:"bg-background/50"})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Embedding Provider"}),U(j,"embedding"),H&&n&&V(n,"embedding"),H&&!n&&(0,b.jsx)("p",{className:"text-[11px] text-amber-600 mt-1",children:"Please configure and test your custom model to continue."})]}),!H&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("label",{className:"text-xs font-medium text-foreground",children:["API Key",!D&&(0,b.jsxs)("span",{className:"text-muted-foreground font-normal",children:[" ","(used for both embedding & chat)"]})]}),(0,b.jsx)(N.Input,{type:"password",value:l,onChange:a=>m(a.target.value),placeholder:"sk-...",className:"bg-background/50"})]}),(0,b.jsxs)("button",{type:"button",onClick:()=>E(!D),className:"flex w-full items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[D?(0,b.jsx)(M.default,{className:"size-3.5"}):(0,b.jsx)(L.ChevronDown,{className:"size-3.5"}),"Use a different chat model"]}),D&&(0,b.jsxs)("div",{className:"space-y-3 rounded-xl border border-border/40 bg-muted/20 p-4",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Chat Provider"}),U(p,"chat"),I&&u&&V(u,"chat"),I&&!u&&(0,b.jsx)("p",{className:"text-[11px] text-amber-600 mt-1",children:"Please configure and test your custom model to continue."})]}),!I&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Chat API Key"}),(0,b.jsx)(N.Input,{type:"password",value:s,onChange:a=>t(a.target.value),placeholder:"sk-...",className:"bg-background/50"})]})]}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"More providers and fine-grained model selection available in Settings → AI Models."}),(0,b.jsxs)("div",{className:"pt-2 flex gap-3",children:[(0,b.jsx)(z.Button,{variant:"outline",className:"flex-1",onClick:T,disabled:B,children:"Skip for now"}),(0,b.jsx)(z.Button,{className:"flex-1",onClick:S,disabled:B||!(()=>{if(H){if(!n)return!1}else if(!l)return!1;if(D){if(I){if(!u)return!1}else if(!J)return!1}return!0})(),children:B?(0,b.jsx)(y.Loader2,{className:"size-4 animate-spin"}):(0,b.jsxs)(b.Fragment,{children:["Continue ",(0,b.jsx)(K,{className:"ml-1.5 size-4"})]})})]})]})]})}),(0,b.jsx)(A.Dialog,{open:null!==F,onOpenChange:a=>{a||("embedding"!==F||n||k("vercel_ai_gateway"),"chat"!==F||u||q("vercel_ai_gateway"),G(null))},children:(0,b.jsxs)(A.DialogContent,{className:"max-w-xl",children:[(0,b.jsxs)(A.DialogHeader,{children:[(0,b.jsxs)(A.DialogTitle,{children:["Custom ","embedding"===F?"Embedding":"Chat"," Model"]}),(0,b.jsxs)(A.DialogDescription,{children:["Connect an OpenAI-compatible ","embedding"===F?"embedding":"chat"," ","model. Test the connection before adding."]})]}),F&&(0,b.jsx)(Q.CustomModelForm,{type:F,onSave:a=>{"embedding"===F?(o(a),k("custom")):"chat"===F&&(w(a),q("custom")),G(null)},onCancel:()=>{"embedding"!==F||n||k("vercel_ai_gateway"),"chat"!==F||u||q("vercel_ai_gateway"),G(null)}})]})})]})}let T={"panel-default":"#FAFAFA","panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"};a.s(["ClientLayoutWrapper",0,function({children:a}){let{pageStyle:d,panelBg:e,layout:g}=(0,c.useThemeCustomizer)(),h=(0,f.usePathname)(),i=h?.includes("/chat"),{isFirstRun:j,isLoading:k}=(0,v.useWorkspace)(),l=T[e],m=l?{backgroundColor:l}:void 0;return!k&&j?(0,b.jsx)(S,{}):k?(0,b.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,b.jsx)("div",{className:"size-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):"topnav"===g?(0,b.jsxs)("div",{className:"flex flex-col h-screen overflow-hidden",children:[(0,b.jsx)(J,{}),(0,b.jsx)("main",{className:"min-w-0 flex-1 overflow-hidden",children:(0,b.jsx)("div",{className:"h-full flex flex-col bg-background text-foreground",style:m,children:(0,b.jsx)("div",{className:(0,n.cn)("flex-1 min-h-0",i||h?.includes("/settings")||h?.includes("/analytics")?"overflow-hidden flex flex-col":"overflow-auto"),children:(0,b.jsx)("div",{className:(0,n.cn)("h-full w-full",i||h?.includes("/settings")||h?.includes("/analytics")?"flex-1 min-h-0 flex flex-col":"container mx-auto pb-8"),children:a})})})})]}):(0,b.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,b.jsx)(G,{}),(0,b.jsx)("main",{className:"min-w-0 flex-1 overflow-hidden",children:(0,b.jsx)("div",{className:"fused"===d?"h-screen flex flex-col bg-background text-foreground overflow-hidden":"h-screen flex flex-col md:rounded-l-2xl border-l border-border bg-panel text-panel-foreground overflow-hidden",style:m,children:(0,b.jsx)("div",{className:(0,n.cn)("flex-1 min-h-0",i||h?.includes("/settings")||h?.includes("/analytics")?"overflow-hidden flex flex-col":"overflow-auto"),children:(0,b.jsx)("div",{className:(0,n.cn)("h-full w-full",i||h?.includes("/settings")||h?.includes("/analytics")?"flex-1 min-h-0 flex flex-col":"container mx-auto pb-8"),children:a})})})})]})}],881150)},316105,a=>{"use strict";var b=a.i(379152),c=a.i(860091),d=a.i(660911),e=a.i(881479),f=a.i(476866),g=a.i(42598);let h=(0,g.default)("boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);var i=a.i(20924);let j=(0,g.default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);var k=a.i(818842),l=a.i(171217);let m=(0,g.default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);var n=a.i(799304),o=a.i(918018),p=a.i(166243),q=a.i(434954);let r=(0,g.default)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);var s=a.i(953191),t=a.i(96607),u=a.i(541487),v=a.i(655208),w=a.i(299574),x=a.i(483115),y=a.i(95507),z=a.i(952313),A=a.i(717994),B=a.i(343578);let C=a=>fetch(a).then(a=>a.json()),D=["chunking","embedding","upserting"];function E({open:a,onOpenChange:g,trigger:h}){let[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),m=void 0!==a,r=m?a:k,s=m&&g?g:l,{data:t,isLoading:v,mutate:w}=(0,c.default)("/api/index",C,{refreshInterval:a=>a?.run&&D.includes(a.run.status)?1e3:0}),G=(0,e.useRef)(void 0);(0,e.useEffect)(()=>{let a=t?.run?.warning;a&&a!==G.current?z.toast.warning(a,{id:"rate-limit-warning",duration:7e4}):!a&&G.current&&(z.toast.dismiss("rate-limit-warning"),z.toast.success("Rate limit resolved — resuming indexing.",{duration:3e3})),G.current=a},[t?.run?.warning]);let[I,J]=(0,e.useState)(!1);async function K(a=!1){j(!0);try{let b=await fetch("/api/index",{method:"POST",body:JSON.stringify({incremental:a}),headers:{"Content-Type":"application/json"}}),c=await b.json();if(!b.ok)return void z.toast.error(c.error??"Could not start indexing.");z.toast.success("Indexing started."),w()}catch{z.toast.error("Could not start indexing.")}finally{j(!1)}}async function L(){j(!0);try{if(!(await fetch("/api/index",{method:"DELETE"})).ok)return void z.toast.error("Could not cancel indexing.");z.toast.success("Indexing cancelled."),w()}catch{z.toast.error("Could not cancel indexing.")}finally{j(!1)}}return(0,e.useEffect)(()=>{let a=t?.run?.status;a&&D.includes(a)?J(!0):I&&"completed"===a&&(J(!1),s(!1),z.toast.success("Indexing completed successfully!"))},[t?.run?.status,I,s]),(0,b.jsxs)(B.Dialog,{open:r,onOpenChange:s,children:[h?(0,b.jsx)(B.DialogTrigger,{render:(0,e.isValidElement)(h)?h:(0,b.jsx)("button",{children:h})}):(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[t?.run?.status==="completed"&&(0,b.jsxs)(A.AlertDialog,{children:[(0,b.jsx)(A.AlertDialogTrigger,{render:(0,b.jsxs)(u.Button,{disabled:!t.ready||!!(t.run&&D.includes(t.run.status))||i,variant:"outline",children:[(0,b.jsx)(q.RotateCcw,{className:"size-4 mr-2"}),"Re-Index Data"]})}),(0,b.jsxs)(A.AlertDialogContent,{children:[(0,b.jsxs)(A.AlertDialogHeader,{children:[(0,b.jsx)(A.AlertDialogTitle,{children:"Are you sure you want to re-index data?"}),(0,b.jsx)(A.AlertDialogDescription,{children:"This will rebuild the entire index from scratch. All documents will be re-processed."})]}),(0,b.jsxs)(A.AlertDialogFooter,{children:[(0,b.jsx)(A.AlertDialogCancel,{children:"Cancel"}),(0,b.jsx)(A.AlertDialogAction,{onClick:()=>{s(!0),K(!1)},children:"Continue"})]})]})]}),(0,b.jsx)(B.DialogTrigger,{render:(0,b.jsxs)(u.Button,{disabled:!t?.ready||t?.unindexedCount===0,children:[(0,b.jsx)(o.Layers,{className:"size-4 mr-2"}),"Index Data"]})})]}),(0,b.jsxs)(B.DialogContent,{className:"max-w-2xl max-h-[90vh] overflow-y-auto ",children:[(0,b.jsxs)(B.DialogHeader,{children:[(0,b.jsx)(B.DialogTitle,{children:"Index Data"}),(0,b.jsx)(B.DialogDescription,{children:"Chunk, embed, and index into your selected vector database."})]}),v||!t?(0,b.jsx)("div",{className:"py-6",children:(0,b.jsx)(y.Skeleton,{className:"h-40 w-full"})}):(0,b.jsxs)("div",{className:"space-y-6 py-4",children:[(0,b.jsx)(F,{config:t.config,docCount:t.docCount,charCount:t.charCount}),!t.ready&&(0,b.jsxs)(x.Alert,{variant:"default",children:[(0,b.jsx)(f.AlertTriangle,{className:"size-4 text-orange-500!"}),(0,b.jsx)(x.AlertTitle,{className:"text-orange-500!",children:"Not ready to index"}),(0,b.jsx)(x.AlertDescription,{children:(0,b.jsx)("ul",{className:"list-disc pl-4",children:t.blockers.map(a=>(0,b.jsx)("li",{children:a},a))})})]}),(0,b.jsx)(H,{run:t.run,running:!!(t.run&&D.includes(t.run.status))}),t.ready&&!t.run&&(0,b.jsxs)(x.Alert,{children:[(0,b.jsx)(n.Info,{className:"size-4 text-blue-500!"}),(0,b.jsx)(x.AlertTitle,{className:"text-blue-600 dark:text-blue-400",children:"Before you start indexing"}),(0,b.jsxs)(x.AlertDescription,{className:"text-muted-foreground space-y-1",children:[(0,b.jsxs)("p",{children:["Once indexing begins, two settings become"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:"locked"})," to the existing index:"]}),(0,b.jsxs)("ul",{className:"list-disc pl-4 space-y-0.5",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Embedding model"})," — you can swap to any model with the"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:"same vector dimensions"}),", but switching to a model with different dimensions will require a full re-index."]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Vector store"})," — changing the store after indexing requires starting fresh."]})]})]})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsxs)(u.Button,{onClick:()=>K(t.run?.status==="completed"),disabled:!t.ready||!!(t.run&&D.includes(t.run.status))||i||t.run?.status==="completed"&&0===t.unindexedCount,size:"lg",children:[t.run&&D.includes(t.run.status)||i?(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin mr-2"}):(0,b.jsx)(p.Play,{className:"size-4 mr-2"}),t.run&&D.includes(t.run.status)?"Indexing…":i?"Starting…":t.run?.status==="completed"?`Index new documents (${t.unindexedCount})`:`Start indexing (${t.unindexedCount})`]}),t.run?.status==="completed"&&!(t.run&&D.includes(t.run.status))&&(0,b.jsxs)(A.AlertDialog,{children:[(0,b.jsx)(A.AlertDialogTrigger,{render:(0,b.jsxs)(u.Button,{variant:"outline",size:"lg",disabled:i,children:[(0,b.jsx)(q.RotateCcw,{className:"size-4 mr-2"}),"Re-Index All"]})}),(0,b.jsxs)(A.AlertDialogContent,{children:[(0,b.jsxs)(A.AlertDialogHeader,{children:[(0,b.jsx)(A.AlertDialogTitle,{children:"Are you sure you want to re-index data?"}),(0,b.jsx)(A.AlertDialogDescription,{children:"This will rebuild the entire index from scratch. All documents will be re-processed."})]}),(0,b.jsxs)(A.AlertDialogFooter,{children:[(0,b.jsx)(A.AlertDialogCancel,{children:"Cancel"}),(0,b.jsx)(A.AlertDialogAction,{onClick:()=>{s(!0),K(!1)},children:"Continue"})]})]})]}),!!(t.run&&D.includes(t.run.status))&&(0,b.jsx)(u.Button,{onClick:L,disabled:i,size:"lg",variant:"destructive",children:"Cancel"})]}),(0,b.jsx)(u.Button,{variant:"ghost",size:"lg",onClick:()=>s(!1),children:"Close"})]})]})]})]})}function F({config:a,docCount:c,charCount:d}){let e=(0,s.getEmbeddingModel)(a.embeddingModelId),f=(0,t.getVectorStore)(a.vectorStore),g=[{icon:j,label:"Embedding model",value:e?.label??a.embeddingModelId,hint:e?`${e.dimensions} dims`:void 0},{icon:k.Database,label:"Vector store",value:f?.label??a.vectorStore},{icon:h,label:"Index type",value:a.indexType.toUpperCase()},{icon:r,label:"Chunking",value:`${a.chunking.chunkSize} / ${a.chunking.chunkOverlap}`,hint:"size / overlap"},{icon:l.FileText,label:"Corpus",value:`${c.toLocaleString()} docs`,hint:`${d.toLocaleString()} chars`}];return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground p-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-base font-semibold mb-4",children:[(0,b.jsx)(o.Layers,{className:"size-4 text-primary"}),"Index configuration"]}),(0,b.jsx)("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-5 sm:grid-cols-3",children:g.map(a=>(0,b.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,b.jsxs)("dt",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,b.jsx)(a.icon,{className:"size-3.5"}),a.label]}),(0,b.jsxs)("dd",{className:"text-sm font-medium leading-tight",children:[a.value,a.hint&&(0,b.jsx)("span",{className:"ml-1.5 font-mono text-[11px] font-normal text-muted-foreground",children:a.hint})]})]},a.label))})]})}let G={idle:{label:"Idle"},chunking:{label:"Chunking",phase:"Splitting documents into chunks"},embedding:{label:"Embedding",phase:"Generating vector embeddings"},upserting:{label:"Storing",phase:"Writing vectors to the store"},completed:{label:"Completed"},failed:{label:"Failed"}};function H({run:a,running:c}){if(!a)return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground flex flex-col items-center justify-center gap-1 py-8 text-center",children:[(0,b.jsx)(m,{className:"mb-1 size-6 text-muted-foreground/60"}),(0,b.jsx)("p",{className:"text-sm font-medium",children:"No index built yet"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Build a Larkup index to embed your corpus and make it searchable."})]});let e=G[a.status],g=a.totalChunks>0?Math.round(a.processedChunks/a.totalChunks*100):5*!!c;return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground p-4 space-y-4",children:[(0,b.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-base font-semibold",children:["completed"===a.status?(0,b.jsx)(i.CheckCircle2,{className:"size-4 text-primary"}):"failed"===a.status?(0,b.jsx)(f.AlertTriangle,{className:"size-4 text-destructive"}):(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin text-primary"}),e.label]}),(0,b.jsx)(J,{status:a.status})]}),"failed"===a.status?(0,b.jsx)(b.Fragment,{}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:e.phase??"Done"}),(0,b.jsxs)("span",{className:"font-mono tabular-nums",children:[a.processedChunks.toLocaleString(),a.totalChunks>0&&` / ${a.totalChunks.toLocaleString()}`," chunks"]})]}),(0,b.jsx)(v.Progress,{value:g,className:"**:data-[slot=progress-indicator]:bg-green-600"})]}),(0,b.jsxs)("dl",{className:"grid grid-cols-2 gap-4 pt-1 sm:grid-cols-4",children:[(0,b.jsx)(I,{label:"Documents",value:a.docCount.toLocaleString()}),(0,b.jsx)(I,{label:"Chunks",value:a.totalChunks.toLocaleString()}),(0,b.jsx)(I,{label:"Dimensions",value:a.dimensions?a.dimensions.toLocaleString():"—"}),(0,b.jsx)(I,{label:"Duration",value:a.durationMs?`${(a.durationMs/1e3).toFixed(1)}s`:c?"running…":"—"})]})]})]})}function I({label:a,value:c}){return(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("dt",{className:"text-xs text-muted-foreground",children:a}),(0,b.jsx)("dd",{className:"font-mono text-sm tabular-nums",children:c})]})}function J({status:a}){return"completed"===a?(0,b.jsx)(w.Badge,{className:"bg-primary/12 text-primary hover:bg-primary/12",children:"Ready"}):"failed"===a?(0,b.jsx)(w.Badge,{variant:"destructive",children:"Failed"}):D.includes(a)?(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-green-600",children:[(0,b.jsxs)("span",{className:"relative flex size-2",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-600 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-600"})]}),"Live"]}):null}let K=a=>fetch(a).then(a=>a.json()),L=["chunking","embedding","upserting"];a.s(["GlobalIndexProgress",0,function(){let{data:a}=(0,c.default)("/api/index",K,{refreshInterval:a=>a?.run&&L.includes(a.run.status)?1e3:0});if(!(a?.run&&L.includes(a.run.status))||!a?.run)return null;let{run:e}=a,f=e.totalChunks>0?Math.round(e.processedChunks/e.totalChunks*100):5;return(0,b.jsx)("div",{className:"fixed bottom-6 right-6 z-50",children:(0,b.jsx)(E,{trigger:(0,b.jsxs)("button",{className:"flex items-center gap-3 rounded-full border bg-background px-4 py-2 text-sm font-medium transition-all hover:bg-muted/50 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin text-primary"}),(0,b.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,b.jsx)("span",{className:"text-xs leading-none text-muted-foreground",children:"Storing..."}),(0,b.jsxs)("span",{className:"leading-none",children:[f,"%"]})]})]})})})}],316105)},150760,a=>{"use strict";var b=a.i(379152),c=a.i(881479),d=a.i(731505),e=a.i(823259),f=a.i(304995),g=a.i(130179),h=a.i(541487);let i={docker:"docker compose pull && docker compose up -d",npm:"larkup update"};a.s(["UpdateBanner",0,function(){let[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(!1),r="0.1.25",s="true"===process.env.NEXT_PUBLIC_DOCKER_ENV||"true"===process.env.NEXT_PUBLIC_RUNNING_IN_DOCKER?"docker":"npm";(0,c.useEffect)(()=>{},[r]);let t=async()=>{if("desktop"===s){o(!0);try{let{check:b}=await a.A(914053),{relaunch:c}=await a.A(69832),d=await b();d?(await d.downloadAndInstall(),await c()):o(!1)}catch(a){console.error("Auto-update failed:",a),o(!1),window.open("https://larkup.de/download","_blank")}}else try{await navigator.clipboard.writeText(i[s]),q(!0),window.setTimeout(()=>q(!1),2e3)}catch(a){console.error("Could not copy update command:",a)}};return l&&j?(0,b.jsx)("div",{role:"status","aria-live":"polite",className:"relative z-50 border-b border-border bg-background px-3 py-2 text-foreground sm:px-4",children:(0,b.jsxs)("div",{className:"mx-auto flex min-h-7 max-w-screen-2xl items-center gap-2.5",children:[(0,b.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background",children:(0,b.jsx)(d.ArrowUp,{className:"size-3.5","aria-hidden":"true"})}),(0,b.jsxs)("p",{className:"min-w-0 text-xs sm:text-sm",children:[(0,b.jsxs)("span",{className:"font-medium",children:["Larkup v",j," is available."]})," ",(0,b.jsxs)("span",{className:"hidden text-muted-foreground sm:inline",children:["You're using v",r,"."]})]}),"desktop"!==s&&(0,b.jsx)("code",{className:"ml-auto hidden max-w-[38rem] truncate rounded-[5px] border border-border bg-muted/40 px-2 py-1 font-mono text-[11px] text-muted-foreground lg:block",children:i[s]}),(0,b.jsx)(h.Button,{type:"button",variant:"desktop"===s?"default":"outline",size:"xs",onClick:t,disabled:n,"aria-label":"desktop"===s?"Update Larkup now":"Copy update command",className:"desktop"===s?"ml-auto":"ml-auto lg:ml-0",children:"desktop"===s?n?"Updating...":"Update now":p?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(e.Check,{"aria-hidden":"true"}),"Copied"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Copy,{"aria-hidden":"true"}),"Copy command"]})}),(0,b.jsx)(h.Button,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>{try{localStorage.setItem("larkup-update-dismissed",JSON.stringify({timestamp:Date.now()}))}catch{}m(!1)},"aria-label":"Dismiss update notification",title:"Remind me tomorrow",children:(0,b.jsx)(g.X,{"aria-hidden":"true"})})]})}):null}])}];
2
2
 
3
3
  //# sourceMappingURL=_0s5_0n1._.js.map
@@ -7,9 +7,9 @@ globalThis.__BUILD_MANIFEST = {
7
7
  "static/chunks/03~yq9q893hmn.js"
8
8
  ],
9
9
  "lowPriorityFiles": [
10
- "static/Fb01QU1MyWBHc7U1LHf5y/_buildManifest.js",
11
- "static/Fb01QU1MyWBHc7U1LHf5y/_ssgManifest.js",
12
- "static/Fb01QU1MyWBHc7U1LHf5y/_clientMiddlewareManifest.js"
10
+ "static/rZLjWvDwdTV-PtUjl-1-b/_buildManifest.js",
11
+ "static/rZLjWvDwdTV-PtUjl-1-b/_ssgManifest.js",
12
+ "static/rZLjWvDwdTV-PtUjl-1-b/_clientMiddlewareManifest.js"
13
13
  ],
14
14
  "rootMainFiles": [
15
15
  "static/chunks/06lztj0p4bq9f.js",