(()=>{var a={};a.id=974,a.ids=[974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4494:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>h});var d=c(5735),e=c(91970),f=c(17323),g=c(54894);async function h(a){let b=await a.searchParams;if(!(b?.choose==="1"||Array.isArray(b?.choose)&&b?.choose[0]==="1")){let a=(0,g.mj)();a&&(0,e.redirect)(`/projects/${a}`)}return(0,d.jsx)(f.default,{})}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},17323:(a,b,c)=>{"use strict";c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/Users/dannyruchtie/Documents/moondream/web/src/app/HomeClient.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/dannyruchtie/Documents/moondream/web/src/app/HomeClient.tsx","default")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},20803:(a,b,c)=>{Promise.resolve().then(c.bind(c,77941))},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},42911:(a,b,c)=>{"use strict";c.d(b,{L:()=>p});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(87550),i=c.n(h);let j=`PRAGMA foreign_keys = ON;

CREATE TABLE IF NOT EXISTS projects (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  created_at TEXT NOT NULL DEFAULT (datetime('now')),
  updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);

CREATE TABLE IF NOT EXISTS assets (
  id TEXT PRIMARY KEY,
  project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
  original_name TEXT NOT NULL,
  mime_type TEXT NOT NULL,
  byte_size INTEGER NOT NULL,
  sha256 TEXT NOT NULL,
  storage_path TEXT NOT NULL,
  storage_url TEXT NOT NULL,
  thumb_path TEXT,
  thumb_url TEXT,
  width INTEGER,
  height INTEGER,
  created_at TEXT NOT NULL DEFAULT (datetime('now'))
);

CREATE UNIQUE INDEX IF NOT EXISTS assets_project_sha256_uq ON assets(project_id, sha256);
CREATE INDEX IF NOT EXISTS assets_project_id_idx ON assets(project_id);

CREATE TABLE IF NOT EXISTS asset_ai (
  asset_id TEXT PRIMARY KEY REFERENCES assets(id) ON DELETE CASCADE,
  caption TEXT,
  tags_json TEXT,
  status TEXT NOT NULL DEFAULT 'pending',
  model_version TEXT,
  updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);

CREATE TABLE IF NOT EXISTS canvas_objects (
  id TEXT PRIMARY KEY,
  project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
  type TEXT NOT NULL,
  asset_id TEXT REFERENCES assets(id) ON DELETE SET NULL,
  x REAL NOT NULL DEFAULT 0,
  y REAL NOT NULL DEFAULT 0,
  scale_x REAL NOT NULL DEFAULT 1,
  scale_y REAL NOT NULL DEFAULT 1,
  rotation REAL NOT NULL DEFAULT 0,
  width REAL,
  height REAL,
  z_index INTEGER NOT NULL DEFAULT 0,
  props_json TEXT,
  created_at TEXT NOT NULL DEFAULT (datetime('now')),
  updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);

CREATE INDEX IF NOT EXISTS canvas_objects_project_id_idx ON canvas_objects(project_id);

-- Full-text search across filename + AI caption + tags
CREATE VIRTUAL TABLE IF NOT EXISTS asset_search USING fts5(
  asset_id UNINDEXED,
  project_id UNINDEXED,
  original_name,
  caption,
  tags
);
`,k=`PRAGMA foreign_keys = ON;

CREATE TABLE IF NOT EXISTS project_view (
  project_id TEXT PRIMARY KEY REFERENCES projects(id) ON DELETE CASCADE,
  world_x REAL NOT NULL DEFAULT 0,
  world_y REAL NOT NULL DEFAULT 0,
  zoom REAL NOT NULL DEFAULT 1,
  updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
`,l=`PRAGMA foreign_keys = ON;

-- Store caption embeddings for semantic/vector search.
-- We keep this schema portable so it can be migrated to Supabase/pgvector later.
CREATE TABLE IF NOT EXISTS asset_embeddings (
  asset_id TEXT PRIMARY KEY REFERENCES assets(id) ON DELETE CASCADE,
  model TEXT NOT NULL,
  dim INTEGER NOT NULL,
  embedding BLOB,
  updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);

-- Store per-tag segmentation results so searches like "apple" can highlight on-image regions.
-- One row per (asset_id, tag).
CREATE TABLE IF NOT EXISTS asset_segments (
  asset_id TEXT NOT NULL REFERENCES assets(id) ON DELETE CASCADE,
  tag TEXT NOT NULL,
  svg TEXT,
  bbox_json TEXT,
  updated_at TEXT NOT NULL DEFAULT (datetime('now')),
  PRIMARY KEY (asset_id, tag)
);

CREATE INDEX IF NOT EXISTS asset_segments_tag_idx ON asset_segments(tag);
`,m=`PRAGMA foreign_keys = ON;

-- Small key/value store for local app state (desktop + local-first web).
-- Used for "reopen last project" on launch.
CREATE TABLE IF NOT EXISTS app_state (
  key TEXT PRIMARY KEY,
  value TEXT,
  updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
`,n=`PRAGMA foreign_keys = ON;

-- Soft-delete assets (Trash) so deletes are reversible.
ALTER TABLE assets ADD COLUMN deleted_at TEXT;
ALTER TABLE assets ADD COLUMN trashed_storage_path TEXT;
ALTER TABLE assets ADD COLUMN trashed_thumb_path TEXT;

-- Allow re-uploading a file after trashing it by enforcing uniqueness only for non-deleted assets.
DROP INDEX IF EXISTS assets_project_sha256_uq;
CREATE UNIQUE INDEX IF NOT EXISTS assets_project_sha256_uq
  ON assets(project_id, sha256)
  WHERE deleted_at IS NULL;

CREATE INDEX IF NOT EXISTS assets_deleted_at_idx ON assets(deleted_at);
`,o=`PRAGMA foreign_keys = ON;

-- Track per-project revision counters so clients can detect stale writes (helps multi-device + iCloud scenarios).
CREATE TABLE IF NOT EXISTS project_sync (
  project_id TEXT PRIMARY KEY REFERENCES projects(id) ON DELETE CASCADE,
  canvas_rev INTEGER NOT NULL DEFAULT 0,
  view_rev INTEGER NOT NULL DEFAULT 0,
  canvas_updated_at TEXT NOT NULL DEFAULT (datetime('now')),
  view_updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
`;function p(){if(!globalThis.__moondreamDb){let a,b=process.env.MOONDREAM_DB_PATH||((a=(process.env.MOONDREAM_DATA_DIR||"").trim())?g().resolve(a,"moondream.sqlite3"):g().resolve(process.cwd(),"..","data","moondream.sqlite3"));e().mkdirSync(g().dirname(b),{recursive:!0});let c=new(i())(b);c.pragma("journal_mode = WAL"),c.pragma("busy_timeout = 5000"),globalThis.__moondreamDb=c}var a=globalThis.__moondreamDb;a.pragma("foreign_keys = ON");let b=a.prepare("PRAGMA user_version").get(),c=b?.user_version??0;if(c<1){a.exec("BEGIN");try{a.exec(j),a.exec("PRAGMA user_version = 1"),a.exec("COMMIT")}catch(b){throw a.exec("ROLLBACK"),b}c=1}if(c<2){a.exec("BEGIN");try{a.exec(k),a.exec("PRAGMA user_version = 2"),a.exec("COMMIT")}catch(b){throw a.exec("ROLLBACK"),b}c=2}if(c<3){a.exec("BEGIN");try{a.exec(l),a.exec("PRAGMA user_version = 3"),a.exec("COMMIT")}catch(b){throw a.exec("ROLLBACK"),b}c=3}if(c<4){a.exec("BEGIN");try{a.exec(m),a.exec("PRAGMA user_version = 4"),a.exec("COMMIT")}catch(b){throw a.exec("ROLLBACK"),b}}if(c<5){a.exec("BEGIN");try{a.exec(n),a.exec("PRAGMA user_version = 5"),a.exec("COMMIT")}catch(b){throw a.exec("ROLLBACK"),b}}if(c<6){a.exec("BEGIN");try{a.exec(o),a.exec("PRAGMA user_version = 6"),a.exec("COMMIT")}catch(b){throw a.exec("ROLLBACK"),b}}return globalThis.__moondreamDb}},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},44779:(a,b,c)=>{Promise.resolve().then(c.bind(c,17323))},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},73024:a=>{"use strict";a.exports=require("node:fs")},73852:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>C.a,__next_app__:()=>K,handler:()=>M,routeModule:()=>L});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(63747),o=c(24235),p=c(23938),q=c(261),r=c(66758),s=c(77243),t=c(26713),u=c(37527),v=c(22820),w=c(88216),x=c(47929),y=c(79551),z=c(89125),A=c(86439),B=c(95547),C=c.n(B),D=c(61287),E=c(81494),F=c(70722),G=c(70753),H=c(43954),I={};for(let a in D)0>["default","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(I[a]=()=>D[a]);c.d(b,I);let J={children:["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,4494)),"/Users/dannyruchtie/Documents/moondream/web/src/app/page.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/Users/dannyruchtie/Documents/moondream/web/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,95547,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]}.children,K={require:c,loadChunk:()=>Promise.resolve()},L=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:J},distDir:".next",relativeProjectDir:""});async function M(a,b,d){var B;L.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let I=!!(0,h.getRequestMeta)(a,"minimalMode"),N="/page";"/index"===N&&(N="/");let O=await L.prepare(a,b,{srcPage:N,multiZoneDraftMode:!1});if(!O)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:P,query:Q,params:R,pageIsDynamic:S,buildManifest:T,nextFontManifest:U,reactLoadableManifest:V,serverActionsManifest:W,clientReferenceManifest:X,subresourceIntegrityManifest:Y,prerenderManifest:Z,isDraftMode:$,resolvedPathname:_,revalidateOnlyGenerated:aa,routerServerContext:ab,nextConfig:ac,parsedUrl:ad,interceptionRoutePatterns:ae,deploymentId:af}=O,ag=(0,q.normalizeAppPath)(N),{isOnDemandRevalidate:ah}=O,ai=ac.experimental.ppr&&!ac.cacheComponents&&(0,H.isInterceptionRouteAppPath)(_)?null:L.match(_,Z),aj=!!Z.routes[_],ak=a.headers["user-agent"]||"",al=(0,t.getBotType)(ak),am=(0,p.isHtmlBotRequest)(a),an=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ao=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ap=(0,r.getIsPossibleServerAction)(a),aq=(0,m.checkIsAppPPREnabled)(ac.experimental.ppr);if(!(0,h.getRequestMeta)(a,"postponed")&&aq&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let b=[];for await(let c of a)b.push(c);let c=Buffer.concat(b).toString("utf8");(0,h.addRequestMeta)(a,"postponed",c)}let ar=aq&&(null==(B=Z.routes[ag]??Z.dynamicRoutes[ag])?void 0:B.renderingMode)==="PARTIALLY_STATIC",as=!1,at=!1,au=ar?(0,h.getRequestMeta)(a,"postponed"):void 0,av=ar&&ao&&!an;I&&(av=av&&!!au);let aw=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),ax=(!am||!ar)&&(!ak||(0,p.shouldServeStreamingMetadata)(ak,ac.htmlLimitedBots)),ay=!!((ai||aj||Z.routes[ag])&&!(am&&ar)),az=ar&&!0===ac.cacheComponents,aA=!0===L.isDev||!ay||"string"==typeof au||(az&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?av&&!I:av),aB=am&&ar,aC=null;$||!ay||aA||ap||au||av||(aC=_);let aD=aC;!aD&&L.isDev&&(aD=_),L.isDev||$||!ay||!ao||av||(0,k.d)(a.headers);let aE={...D,tree:J,GlobalError:C(),handler:M,routeModule:L,__next_app__:K};W&&X&&(0,o.setManifestsSingleton)({page:N,clientReferenceManifest:X,serverActionsManifest:W});let aF=a.method||"GET",aG=(0,g.getTracer)(),aH=aG.getActiveScopeSpan(),aI=async()=>((null==ab?void 0:ab.render404)?await ab.render404(a,b,ad,!1):b.end("This page could not be found"),null);try{let f=L.getVaryHeader(_,ae);b.setHeader("Vary",f);let k=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return L.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aG.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aF} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aF} ${N}`)})},m=(0,h.getRequestMeta)(a,"incrementalCache"),o=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let l={query:Q,params:R,page:ag,sharedContext:{buildId:P},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aE,Component:(0,j.T)(aE),params:R,routeModule:L,page:N,postponed:f,shouldWaitOnAllReady:aB,serveStreamingMetadata:ax,supportsDynamicResponse:"string"==typeof f||aA,buildManifest:T,nextFontManifest:U,reactLoadableManifest:V,subresourceIntegrityManifest:Y,setCacheStatus:null==ab?void 0:ab.setCacheStatus,setIsrStatus:null==ab?void 0:ab.setIsrStatus,setReactDebugChannel:null==ab?void 0:ab.setReactDebugChannel,sendErrorsToBrowser:null==ab?void 0:ab.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),L.relativeProjectDir),isDraftMode:$,botType:al,isOnDemandRevalidate:ah,isPossibleServerAction:ap,assetPrefix:ac.assetPrefix,nextConfigOutput:ac.output,crossOrigin:ac.crossOrigin,trailingSlash:ac.trailingSlash,images:ac.images,previewProps:Z.preview,deploymentId:af,enableTainting:ac.experimental.taint,htmlLimitedBots:ac.htmlLimitedBots,reactMaxHeadersLength:ac.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:m,cacheLifeProfiles:ac.cacheLife,basePath:ac.basePath,serverActions:ac.experimental.serverActions,...as||at?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:as}:{},cacheComponents:!!ac.cacheComponents,experimental:{isRoutePPREnabled:ar,expireTime:ac.expireTime,staleTimes:ac.experimental.staleTimes,dynamicOnHover:!!ac.experimental.dynamicOnHover,inlineCss:!!ac.experimental.inlineCss,authInterrupts:!!ac.experimental.authInterrupts,clientTraceMetadata:ac.experimental.clientTraceMetadata||[],clientParamParsingOrigins:ac.experimental.clientParamParsingOrigins},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>L.onRequestError(a,b,d,e,ab),err:(0,h.getRequestMeta)(a,"invokeError"),dev:L.isDev}};as&&(l.renderOpts.nextExport=!0,l.renderOpts.supportsDynamicResponse=!1,l.renderOpts.isDebugDynamicAccesses=as),i&&(l.renderOpts.supportsDynamicResponse=!1);let n=await k(e,l),{metadata:o}=n,{cacheControl:p,headers:q={},fetchTags:r,fetchMetrics:s}=o;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,ay&&(null==p?void 0:p.revalidate)===0&&!L.isDev&&!ar){let a=o.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${_}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:n,headers:q,rscData:o.flightData,postponed:o.postponed,status:o.statusCode,segmentData:o.segmentData},cacheControl:p}},p=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i,forceStaticRender:j=!1})=>{let k,l=!1===L.isDev,q=c||b.writableEnded;if(ah&&aa&&!f&&!I)return(null==ab?void 0:ab.render404)?await ab.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ai&&(k=(0,v.parseFallbackField)(ai.fallback)),k===v.FallbackMode.PRERENDER&&(0,t.isBot)(ak)&&(!ar||am)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ah=!0),ah&&(k!==v.FallbackMode.NOT_FOUND||f)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),!I&&k!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aD&&!q&&!$&&S&&(l||!aj)){if((l||ai)&&k===v.FallbackMode.NOT_FOUND){if(ac.experimental.adapterPath)return await aI();throw new A.NoFallbackError}if(ar&&(ac.cacheComponents?!av:!ao)){let b=l&&"string"==typeof(null==ai?void 0:ai.fallback)?ai.fallback:ag,c=l&&(null==ai?void 0:ai.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ai.fallbackRouteParams):at?(0,n.getFallbackRouteParams)(ag,L):null,f=await L.handleResponse({cacheKey:b,req:a,nextConfig:ac,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:Z,isRoutePPREnabled:ar,responseGenerator:async()=>o({span:i,postponed:void 0,fallbackRouteParams:c,forceStaticRender:!1}),waitUntil:d.waitUntil,isMinimalMode:I});if(null===f)return null;if(f)return delete f.cacheControl,f}}let r=ah||g||!au?void 0:au;if(az&&!I&&m&&av&&!j){let b=await m.get(_,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(r=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,G.scheduleOnNextTick)(async()=>{let b=L.getResponseCache(a);try{await b.revalidate(_,m,ar,!1,a=>p({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if(as&&void 0!==r)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=l&&(null==ai?void 0:ai.fallbackRouteParams)&&(0,h.getRequestMeta)(a,"renderFallbackShell")?(0,n.createOpaqueFallbackRouteParams)(ai.fallbackRouteParams):at?(0,n.getFallbackRouteParams)(ag,L):null;return o({span:i,postponed:r,fallbackRouteParams:s,forceStaticRender:j})},q=async c=>{var f,g,i,j,k;let l,m=await L.handleResponse({cacheKey:aC,responseGenerator:a=>p({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ah,isRoutePPREnabled:ar,req:a,nextConfig:ac,prerenderManifest:Z,waitUntil:d.waitUntil,isMinimalMode:I});if($&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!m){if(aC)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;ay&&!av&&(!n||an)&&(I||b.setHeader("x-nextjs-cache",ah?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=m;if(au)l={revalidate:0,expire:void 0};else if(av)l={revalidate:0,expire:void 0};else if(!L.isDev)if($)l={revalidate:0,expire:void 0};else if(ay){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??ac.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof aw&&(null==q?void 0:q.kind)===u.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];I&&ay&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(aw);return void 0!==d?(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let r=az?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(q.headers){let a={...q.headers};for(let[c,d]of(I&&ay||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=q.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(I&&ay&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!q.status||ao&&ar||(b.statusCode=q.status),!I&&q.status&&E.RedirectStatusCode[q.status]&&ao&&(b.statusCode=200),n&&!av&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ao&&!$){if(void 0===q.rscData){if(q.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(ac.cacheComponents)return b.statusCode=404,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new F.InvariantError(`Expected RSC response, got ${q.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:q.html,cacheControl:m.cacheControl})}return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.fromStatic(q.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=q.html;if(!n||I||ao)return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:m.cacheControl});if(as)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let A=new TransformStream;return v.push(A.readable),o({span:c,postponed:q.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(A.writable)}).catch(a=>{A.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aH)return await aG.withPropagatedContext(a.headers,()=>aG.trace(i.BaseServerSpan.handleRequest,{spanName:`${aF} ${N}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aF,"http.target":a.url}},q));await q(aH)}catch(b){throw b instanceof A.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:N,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:ay,isOnDemandRevalidate:ah})},!1,ab),b}}},76760:a=>{"use strict";a.exports=require("node:path")},77941:(a,b,c)=>{"use strict";c.d(b,{default:()=>g});var d=c(48249),e=c(19099),f=c(67484);function g(){let a=(0,e.useRouter)(),[b,c]=(0,f.useState)("My invite project"),[g,h]=(0,f.useState)(!1),[i,j]=(0,f.useState)(null),[k,l]=(0,f.useState)([]),m=async()=>{let a=await fetch("/api/projects");a.ok&&l((await a.json()).projects??[])};return(0,d.jsx)("div",{className:"min-h-screen bg-zinc-950 text-zinc-50",children:(0,d.jsxs)("div",{className:"mx-auto max-w-3xl px-6 py-12",children:[(0,d.jsxs)("div",{className:"mt-8 rounded-xl border border-zinc-800 bg-zinc-950",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-zinc-900 px-4 py-3",children:[(0,d.jsx)("div",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Projects"}),(0,d.jsx)("button",{onClick:m,className:"rounded-md border border-zinc-800 bg-zinc-950 px-2 py-1 text-xs text-zinc-300 hover:bg-zinc-900",children:"Refresh"})]}),(0,d.jsx)("div",{className:"max-h-[360px] overflow-auto p-2",children:0===k.length?(0,d.jsx)("div",{className:"p-3 text-sm text-zinc-500",children:"No projects yet."}):k.map(b=>(0,d.jsxs)("button",{onClick:()=>a.push(`/projects/${b.id}`),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-zinc-900",children:[(0,d.jsx)("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-white/10 bg-zinc-900",children:(0,d.jsx)("img",{src:`/files/projects/${b.id}/preview`,alt:"",className:"h-full w-full object-cover",onError:a=>{a.currentTarget.style.display="none"}})}),(0,d.jsx)("div",{className:"min-w-0",children:(0,d.jsx)("div",{className:"text-sm text-zinc-200",children:b.name})})]},b.id))})]}),(0,d.jsxs)("div",{className:"mt-8 rounded-xl border border-zinc-800 bg-zinc-900 p-4",children:[(0,d.jsx)("input",{value:b,onChange:a=>c(a.target.value),className:"w-full rounded-lg border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm outline-none focus:border-zinc-600",placeholder:"Project name"}),i?(0,d.jsx)("div",{className:"mt-2 text-sm text-red-400",children:i}):null,(0,d.jsx)("button",{disabled:g,onClick:async()=>{h(!0),j(null);try{let c=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})});if(!c.ok)throw Error("Failed to create project");let d=await c.json();await m(),a.push(`/projects/${d.project.id}`)}catch(a){j(a.message)}finally{h(!1)}},className:"mt-4 inline-flex items-center justify-center rounded-lg bg-zinc-50 px-4 py-2 text-sm font-medium text-zinc-950 disabled:opacity-60",children:g?"Creating…":"Create project"})]})]})})}},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},87550:a=>{"use strict";a.exports=require("better-sqlite3")},96487:()=>{}};var b=require("../webpack-runtime.js");b.C(a);var c=b.X(0,[741,888,430],()=>b(b.s=73852));module.exports=c})();