@phtngyn/cms 0.2.0-beta.5 → 0.2.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "directory": "packages/nuxt"
18
18
  },
19
19
  "name": "@phtngyn/cms",
20
- "version": "0.2.0-beta.5",
20
+ "version": "0.2.0-beta.6",
21
21
  "type": "module",
22
22
  "files": [
23
23
  "bin",
package/src/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { applyContent, diffContent, exportContent, planContent } from "./cli/content.js";
2
2
  import { o as renderConfigurationReport } from "./installation-BoG8E3nJ.js";
3
- import { a as resetCmsDevelopment, i as loadCmsProjectEnvironment, n as checkCmsConfiguration, r as doctorCmsDevelopment, t as bootstrapCmsDevelopment } from "./dev-lifecycle-DdBluSiR.js";
3
+ import { a as resetCmsDevelopment, i as loadCmsProjectEnvironment, n as checkCmsConfiguration, r as doctorCmsDevelopment, t as bootstrapCmsDevelopment } from "./dev-lifecycle-CExksm2R.js";
4
4
  import { diagnosticFromCause, renderDiagnostic } from "./internal/diagnostics.js";
5
5
  import { Config, Console, Effect, Layer, Match, Option, Redacted, Runtime, Schema } from "effect";
6
6
  import { NodeChildProcessSpawner, NodeCrypto, NodeFileSystem, NodePath, NodeRuntime, NodeStdio, NodeTerminal } from "@effect/platform-node-shared";
@@ -8,7 +8,7 @@ import { FetchHttpClient } from "effect/unstable/http";
8
8
  import { Argument, CliError, Command, Flag, Prompt } from "effect/unstable/cli";
9
9
 
10
10
  //#region package.json
11
- var version = "0.2.0-beta.5";
11
+ var version = "0.2.0-beta.6";
12
12
 
13
13
  //#endregion
14
14
  //#region src/cli.ts
@@ -199,7 +199,7 @@ async function doctorCmsDevelopment(rootDir, full = false, envFile) {
199
199
  }
200
200
  const bundledStudio = new URL("../studio/host.js", import.meta.url);
201
201
  const publishedStudio = new URL("../../studio/host.js", import.meta.url);
202
- const workspaceStudio = new URL("../../../../apps/studio/dist/host.js", import.meta.url);
202
+ const workspaceStudio = new URL("../../../studio/dist/host.js", import.meta.url);
203
203
  checks.push(existsSync(bundledStudio) || existsSync(publishedStudio) || existsSync(workspaceStudio) ? pass("assets", "CMS and Studio package assets complete") : fail("assets", "CMS and Studio package assets complete", "Run the package build before publishing."));
204
204
  try {
205
205
  const readiness = await fetch(new URL(CMS_READINESS_PATH, configuration.baseUrl), { signal: AbortSignal.timeout(2e3) });
@@ -532,4 +532,4 @@ function inPhaseSync(phase, operation) {
532
532
 
533
533
  //#endregion
534
534
  export { resetCmsDevelopment as a, loadCmsProjectEnvironment as i, checkCmsConfiguration as n, doctorCmsDevelopment as r, bootstrapCmsDevelopment as t };
535
- //# sourceMappingURL=dev-lifecycle-DdBluSiR.js.map
535
+ //# sourceMappingURL=dev-lifecycle-CExksm2R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-lifecycle-CExksm2R.js","names":["AuthoringCatalogSchema"],"sources":["../../../../sql-pg/src/Migration.ts","../../../../auth/src/LocalDevelopment.ts","../../../src/internal/dev-lifecycle.ts"],"sourcesContent":["import type { PgPoolConfig } from '@effect/sql-pg/PgClient'\nimport { Effect, Schema } from 'effect'\nimport { embeddedMigrations } from './internal/database/embedded-migrations.generated'\nimport { migrateCmsDatabase } from './internal/database/migrations'\nimport { schemaClientLayer } from './internal/postgres/scoped-client'\n\nexport interface PostgresMigration {\n readonly createdAt: number\n readonly hash: string\n readonly name: string\n readonly statements: ReadonlyArray<string>\n}\n\n/** Migration history used by development tooling to verify pending SQL without mutating the database. */\nexport const postgresMigrations: ReadonlyArray<PostgresMigration> = Object.freeze(\n embeddedMigrations.map((migration) =>\n Object.freeze({\n createdAt: migration.folderMillis,\n hash: migration.hash,\n name: migration.name,\n statements: Object.freeze([...migration.sql]),\n }),\n ),\n)\n\nexport class MigrationFailed extends Schema.TaggedError<MigrationFailed>()('Postgres.MigrationFailed', {\n cause: Schema.Defect(),\n operation: Schema.String,\n}) {}\n\nexport interface PostgresMigrationOptions extends PgPoolConfig {\n readonly schema: string\n}\n\nexport function migratePostgres(options: PostgresMigrationOptions): Effect.Effect<void, MigrationFailed> {\n const { schema, ...poolOptions } = options\n\n return migrateCmsDatabase(schema).pipe(\n Effect.provide(\n schemaClientLayer({ ...poolOptions, applicationName: options.applicationName ?? '@internal/migrate' }, schema),\n ),\n Effect.mapError((cause) => new MigrationFailed({ cause, operation: 'Postgres.migrate' })),\n )\n}\n","import type { BetterAuthOptions } from 'better-auth'\nimport { Effect, Schema } from 'effect'\nimport { createCmsBetterAuth } from './internal/better-auth'\n\nexport interface LocalAdministratorOptions {\n readonly baseUrl: string\n readonly database: NonNullable<BetterAuthOptions['database']>\n readonly email: string\n readonly name: string\n readonly password: string\n readonly secret: string\n}\n\nexport type LocalAdministratorResult = 'created' | 'updated' | 'verified'\n\nexport class LocalAdministratorFailed extends Schema.TaggedError<LocalAdministratorFailed>()(\n 'LocalAdministrator.Failed',\n { cause: Schema.Defect() },\n) {}\n\n/** Reconciles the one local-development administrator without exposing Better Auth's admin routes. */\nexport const reconcileLocalAdministrator = Effect.fn('LocalAdministrator.reconcile')(function* (\n options: LocalAdministratorOptions,\n) {\n const auth = createCmsBetterAuth({\n baseURL: options.baseUrl,\n database: options.database,\n secret: options.secret,\n })\n\n return yield* Effect.tryPromise({\n // oxlint-disable-next-line effecttsgo/async-function -- Better Auth's internal adapter exposes its transaction as one Promise workflow.\n try: async () => {\n const context = await auth.$context\n const existing = await context.internalAdapter.findUserByEmail(options.email, { includeAccounts: true })\n\n if (!existing) {\n const user = await context.internalAdapter.createUser(\n { email: options.email, name: options.name, role: 'administrator' },\n { method: 'admin' },\n )\n\n const password = await context.password.hash(options.password)\n await context.internalAdapter.linkAccount({\n accountId: user.id,\n password,\n providerId: 'credential',\n userId: user.id,\n })\n\n return 'created' as const\n }\n\n const isAdministrator =\n Schema.is(Schema.Struct({ role: Schema.String }))(existing.user) && existing.user.role === 'administrator'\n\n let changed = existing.user.name !== options.name || !isAdministrator\n\n if (changed)\n await context.internalAdapter.updateUser(existing.user.id, {\n name: options.name,\n role: 'administrator',\n })\n\n const credential = existing.accounts.find(\n (account) => account.providerId === 'credential' && account.accountId === existing.user.id,\n )\n\n const passwordMatches = credential?.password\n ? await context.password.verify({ hash: credential.password, password: options.password })\n : false\n\n if (!passwordMatches) {\n const password = await context.password.hash(options.password)\n\n if (credential) await context.internalAdapter.updatePassword(existing.user.id, password)\n else\n await context.internalAdapter.createAccount({\n accountId: existing.user.id,\n password,\n providerId: 'credential',\n userId: existing.user.id,\n })\n\n changed = true\n }\n\n return changed ? ('updated' as const) : ('verified' as const)\n },\n catch: (cause) => new LocalAdministratorFailed({ cause }),\n })\n})\n","/* oxlint-disable effecttsgo/async-function effecttsgo/global-fetch effecttsgo/global-timers effecttsgo/new-promise effecttsgo/node-builtin-import -- The CLI boundary coordinates Promise-based Nuxt, pg, S3, fetch, WebSocket, and filesystem APIs. */\nimport type { AuthoringCatalog } from '@internal/protocol/Configuration'\nimport type { ConfigurationCheckReport } from '@internal/protocol/ConfigurationChanges'\nimport { AuthoringCatalog as AuthoringCatalogSchema } from '@internal/protocol/Configuration'\nimport { CMS_READINESS_PATH, STUDIO_API_PATH, STUDIO_COLLABORATION_PATH } from '@internal/protocol/HttpPaths'\nimport { NodeCrypto, NodeFileSystem, NodePath } from '@effect/platform-node-shared'\nimport {\n DeleteObjectCommand,\n HeadBucketCommand,\n ListObjectsV2Command,\n PutObjectCommand,\n S3Client,\n} from '@aws-sdk/client-s3'\nimport { loadNuxt, loadNuxtConfig } from '@nuxt/kit'\nimport { setupDotenv } from 'c12'\nimport { Effect, Layer, Redacted, References, Result, Schema } from 'effect'\nimport { Pool } from 'pg'\nimport { existsSync } from 'node:fs'\nimport { readFile } from 'node:fs/promises'\nimport { randomUUID } from 'node:crypto'\nimport { resolve } from 'node:path'\nimport { createCmsContentClient, readCmsContentDirectory } from '../Content'\nimport { postgresMigrations } from '@internal/sql-pg/Migration'\nimport { postgresConfigurationCheckLayer } from '@internal/sql-pg/Postgres'\nimport { checkConfiguration } from '@internal/server/ConfigurationChanges'\nimport { reconcileLocalAdministrator } from '@internal/auth/LocalDevelopment'\nimport { loadCmsConfiguration } from './cms-config'\nimport {\n cmsRuntimeConfigurationDefaults,\n cmsRuntimeConfigurationFromEnvironment,\n compileCmsConfiguration,\n resolveCmsInstallation,\n} from './configuration'\nimport { installCms, scopedDatabaseUrl } from '../runtime/installation'\nimport type { NuxtCmsInstallationOptions } from '../runtime/installation'\n\nexport type CmsDoctorStatus = 'pass' | 'fail' | 'not-verified'\n\nexport interface CmsDoctorCheck {\n readonly id: string\n readonly label: string\n readonly phase: string\n readonly status: CmsDoctorStatus\n readonly detail?: string\n}\n\nexport interface CmsDoctorReport {\n readonly ok: boolean\n readonly checks: ReadonlyArray<CmsDoctorCheck>\n}\n\nexport interface CmsBootstrapOptions {\n readonly content?: string\n readonly email: string\n readonly name: string\n readonly password: string\n readonly publish: boolean\n readonly rootDir: string\n readonly envFile?: string\n readonly verbose?: boolean\n}\n\nexport interface CmsBootstrapReport {\n readonly administrator: 'created' | 'updated' | 'verified'\n readonly contentApplied: boolean\n}\n\nexport interface CmsResetOptions {\n readonly bootstrap?: Omit<CmsBootstrapOptions, 'rootDir'>\n readonly database: boolean\n readonly media: boolean\n readonly rootDir: string\n readonly envFile?: string\n readonly yes: boolean\n readonly verbose?: boolean\n}\n\nexport interface CmsResetReport {\n readonly executed: boolean\n readonly targets: ReadonlyArray<string>\n readonly bootstrapped: boolean\n}\n\nexport async function checkCmsConfiguration(\n rootDir: string,\n envFile?: string,\n verbose = false,\n): Promise<ConfigurationCheckReport> {\n const project = await inPhase('configuration.load', () => loadConfiguration(rootDir, envFile))\n const authoring = await inPhase('configuration.authoring', () => prepareAuthoring(rootDir, verbose))\n\n const resolved = inPhaseSync('configuration.compile', () =>\n resolveCmsInstallation(project.authored.configuration, project.runtime, authoring),\n )\n\n const pool = new Pool({ connectionString: resolved.database.url })\n\n try {\n const pending = await inPhase('configuration.migrations', () => verifyMigrations(pool, resolved.database.schema))\n\n if (pending > 0)\n throw new CmsLifecycleFailed({\n cause: new Error(`${pending} database migration${pending === 1 ? ' is' : 's are'} pending.`),\n message: 'Run cms dev bootstrap before checking configuration changes.',\n phase: 'configuration.migrations',\n })\n } finally {\n await pool.end()\n }\n\n return inPhase('configuration.check', () =>\n Effect.runPromise(\n checkConfiguration(resolved.configuration, { documentModel: resolved.documentModel }).pipe(\n Effect.provide(\n postgresConfigurationCheckLayer({\n schema: resolved.database.schema,\n url: Redacted.make(resolved.database.url),\n }),\n ),\n ),\n ),\n )\n}\n\nconst nodeLayer = Layer.merge(NodeCrypto.layer, Layer.merge(NodeFileSystem.layer, NodePath.layer))\n\nconst InitializationStatus = Schema.Struct({ needsAdministrator: Schema.optionalKey(Schema.Boolean) })\n\nconst CauseCarrier = Schema.Struct({ cause: Schema.Unknown })\n\nclass CmsLifecycleFailed extends Schema.TaggedError<CmsLifecycleFailed>()('CmsLifecycleFailed', {\n cause: Schema.Defect(),\n message: Schema.String,\n phase: Schema.String,\n}) {}\n\nconst isCmsLifecycleFailed = Schema.is(CmsLifecycleFailed)\n\nexport async function doctorCmsDevelopment(rootDir: string, full = false, envFile?: string): Promise<CmsDoctorReport> {\n const checks: CmsDoctorCheck[] = []\n let configuration: NuxtCmsInstallationOptions\n\n try {\n const project = await loadConfiguration(rootDir, envFile)\n compileCmsConfiguration(project.authored.configuration)\n configuration = resolveCmsInstallation(project.authored.configuration, project.runtime, {\n revision: 'doctor',\n components: [],\n })\n checks.push(pass('configuration', 'Configuration loaded'))\n } catch (cause) {\n checks.push(fail('configuration', 'Configuration loaded', message(cause)))\n\n return report(checks)\n }\n\n const pool = new Pool({ connectionString: configuration.database.url })\n\n try {\n await pool.query('select 1')\n checks.push(pass('postgres', 'PostgreSQL reachable'))\n\n try {\n const pending = await verifyMigrations(pool, configuration.database.schema)\n checks.push(\n pending === 0\n ? pass('migrations', 'Database schema current')\n : fail(\n 'migrations',\n 'Database schema current',\n `${pending} migration${pending === 1 ? ' is' : 's are'} pending; run cms dev bootstrap.`,\n ),\n )\n } catch (cause) {\n checks.push(fail('migrations', 'Database schema current', message(cause)))\n }\n\n if (full) {\n await pool.query('begin')\n\n try {\n await pool.query(\n `create table \"${configuration.database.schema}\".\"__cms_doctor_${randomUUID().replaceAll('-', '')}\" (id integer)`,\n )\n checks.push(pass('postgres-write', 'PostgreSQL write access'))\n } finally {\n await pool.query('rollback')\n }\n } else {\n checks.push(notVerified('postgres-write', 'PostgreSQL write access', 'Use --full for a transient write check.'))\n }\n } catch (cause) {\n checks.push(fail('postgres', 'PostgreSQL reachable', message(cause)))\n } finally {\n await pool.end()\n }\n\n if (configuration.media === undefined) {\n checks.push(pass('s3', 'Media storage disabled'))\n } else {\n const storage = configuration.media\n const client = s3Client(storage)\n let publicProbeKey: string | undefined\n\n try {\n await client.send(new HeadBucketCommand({ Bucket: storage.bucket }))\n checks.push(pass('s3', 'S3 bucket reachable'))\n\n if (full) {\n const relativeKey = `.doctor/${randomUUID()}`\n const key = `${storage.prefix}${relativeKey}`\n await client.send(new PutObjectCommand({ Bucket: storage.bucket, Key: key, Body: new Uint8Array() }))\n publicProbeKey = key\n checks.push(pass('s3-write', 'S3 write access'))\n } else {\n checks.push(notVerified('s3-write', 'S3 write access', 'Use --full for a transient write check.'))\n }\n } catch (cause) {\n checks.push(fail('s3', 'S3 bucket reachable', message(cause)))\n }\n\n try {\n if (full && !publicProbeKey) {\n checks.push(notVerified('media-url', 'Public media URL reachable', 'The transient S3 upload failed.'))\n } else {\n const url = publicProbeKey\n ? publicObjectUrl(storage.publicBaseUrl, publicProbeKey.slice(storage.prefix.length))\n : new URL(storage.publicBaseUrl)\n\n const response = await fetch(url, { method: 'HEAD' })\n checks.push(\n response.ok || (!full && response.status === 404)\n ? pass('media-url', 'Public media URL reachable')\n : fail('media-url', 'Public media URL reachable', `${url.href} returned HTTP ${response.status}.`),\n )\n }\n } catch (cause) {\n checks.push(fail('media-url', 'Public media URL reachable', message(cause)))\n } finally {\n if (publicProbeKey)\n try {\n await client.send(new DeleteObjectCommand({ Bucket: storage.bucket, Key: publicProbeKey }))\n } catch (cause) {\n checks.push(fail('s3-cleanup', 'S3 doctor cleanup', message(cause)))\n }\n\n client.destroy()\n }\n }\n\n const bundledStudio = new URL('../studio/host.js', import.meta.url)\n const publishedStudio = new URL('../../studio/host.js', import.meta.url)\n const workspaceStudio = new URL('../../../studio/dist/host.js', import.meta.url)\n checks.push(\n existsSync(bundledStudio) || existsSync(publishedStudio) || existsSync(workspaceStudio)\n ? pass('assets', 'CMS and Studio package assets complete')\n : fail('assets', 'CMS and Studio package assets complete', 'Run the package build before publishing.'),\n )\n\n try {\n const readiness = await fetch(new URL(CMS_READINESS_PATH, configuration.baseUrl), {\n signal: AbortSignal.timeout(2_000),\n })\n\n checks.push(\n readiness.ok\n ? pass('server', 'Running server readiness')\n : fail('server', 'Running server readiness', `Returned HTTP ${readiness.status}.`),\n )\n\n if (readiness.ok) {\n try {\n await probeWebSocket(new URL(STUDIO_COLLABORATION_PATH, configuration.baseUrl))\n checks.push(pass('websocket', 'Running server WebSocket support'))\n } catch (cause) {\n checks.push(fail('websocket', 'Running server WebSocket support', message(cause)))\n }\n } else {\n checks.push(notVerified('websocket', 'Running server WebSocket support', 'Readiness did not succeed.'))\n }\n } catch {\n checks.push(notVerified('server', 'Running server readiness', 'Start Nuxt to verify the readiness endpoint.'))\n checks.push(notVerified('websocket', 'Running server WebSocket support', 'Start Nuxt to verify WebSockets.'))\n }\n\n return report(checks)\n}\n\nexport async function bootstrapCmsDevelopment(options: CmsBootstrapOptions): Promise<CmsBootstrapReport> {\n if (!options.email || !options.password) throw new Error('CMS_EMAIL and CMS_PASSWORD are required for bootstrap.')\n const project = await inPhase('bootstrap.configuration', () => loadConfiguration(options.rootDir, options.envFile))\n const authoring = await inPhase('bootstrap.authoring', () => prepareAuthoring(options.rootDir, options.verbose))\n\n const resolved = inPhaseSync('bootstrap.configuration', () =>\n resolveCmsInstallation(project.authored.configuration, project.runtime, authoring),\n )\n\n const installation = await inPhase('bootstrap.installation', () =>\n Effect.runPromise(\n installCms(resolved).pipe(Effect.provideService(References.MinimumLogLevel, options.verbose ? 'Info' : 'None')),\n ),\n )\n\n const localFetch: typeof globalThis.fetch = (input, init) => {\n const request = input instanceof Request ? new Request(input, init) : new Request(input, init)\n const headers = new Headers(request.headers)\n headers.set('x-forwarded-for', '127.0.0.1')\n\n return installation.fetch(new Request(request, { headers }))\n }\n\n try {\n const status = await inPhase('bootstrap.initialization', () =>\n localFetch(new URL(`${STUDIO_API_PATH}/initialization`, resolved.baseUrl)),\n )\n\n const state = await inPhase('bootstrap.initialization', async () =>\n Result.getOrThrow(Schema.decodeUnknownResult(InitializationStatus)(await status.json())),\n )\n\n let initialized = false\n\n if (state.needsAdministrator) {\n const claimed = await inPhase('bootstrap.initialization', () =>\n localFetch(new URL(`${STUDIO_API_PATH}/initialization`, resolved.baseUrl), {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n email: options.email,\n initializationToken: resolved.initializationToken,\n name: options.name,\n password: options.password,\n }),\n }),\n )\n\n if (!claimed.ok)\n throw new CmsLifecycleFailed({\n cause: new Error(`Administrator initialization failed (${claimed.status}).`),\n message: `Administrator initialization failed (${claimed.status}).`,\n phase: 'bootstrap.initialization',\n })\n initialized = true\n }\n\n const administrator = initialized\n ? 'created'\n : await inPhase('bootstrap.administrator', () =>\n reconcileAdministrator(resolved, {\n email: options.email,\n name: options.name,\n password: options.password,\n }),\n )\n\n const content = createCmsContentClient({\n baseUrl: resolved.baseUrl,\n credentials: { email: options.email, password: options.password },\n fetch: localFetch,\n })\n\n if (!options.content) {\n await inPhase('bootstrap.content', () => content.diff({ sources: [] }))\n\n return { administrator, contentApplied: false }\n }\n\n const contentDirectory = options.content\n const source = await inPhase('bootstrap.content', () => readCmsContentDirectory(contentDirectory))\n\n const plan = await inPhase('bootstrap.content', () =>\n content.plan(source, { overwrite: true, publish: options.publish }),\n )\n\n if (!plan.valid) {\n const details = [\n ...plan.conflicts.map((entry) => `${entry.filePath}: conflicts with the current CMS content`),\n ...plan.issues.map(\n (issue) =>\n `${issue.documentId ?? issue.key ?? 'content'}${issue.field ? ` (${issue.field})` : ''}: ${issue.message}`,\n ),\n ]\n\n throw new CmsLifecycleFailed({\n cause: new Error(`Bootstrap content has conflicts or validation errors. ${details.join(' ')}`),\n message: `Bootstrap content has conflicts or validation errors. ${details.join(' ')}`,\n phase: 'bootstrap.content',\n })\n }\n\n await inPhase('bootstrap.content', () => content.apply(plan))\n\n return { administrator, contentApplied: true }\n } finally {\n await installation.close()\n }\n}\n\nasync function reconcileAdministrator(\n configuration: NuxtCmsInstallationOptions,\n administrator: Pick<CmsBootstrapOptions, 'email' | 'name' | 'password'>,\n): Promise<CmsBootstrapReport['administrator']> {\n const pool = new Pool({ connectionString: scopedDatabaseUrl(configuration.database) })\n\n try {\n return await Effect.runPromise(\n reconcileLocalAdministrator({\n baseUrl: configuration.baseUrl,\n database: pool,\n email: administrator.email,\n name: administrator.name,\n password: administrator.password,\n secret: `cms-authentication:${configuration.secret}`,\n }),\n )\n } finally {\n await pool.end()\n }\n}\n\nexport async function resetCmsDevelopment(options: CmsResetOptions): Promise<CmsResetReport> {\n const project = await inPhase('reset.configuration', () => loadConfiguration(options.rootDir, options.envFile))\n\n const configuration = inPhaseSync('reset.configuration', () =>\n resolveCmsInstallation(project.authored.configuration, project.runtime, {\n revision: 'reset',\n components: [],\n }),\n )\n\n const targets = [\n ...(options.database ? [`PostgreSQL schema ${configuration.database.schema}`] : []),\n ...(options.media && configuration.media !== undefined\n ? [`S3 prefix ${configuration.media.bucket}/${configuration.media.prefix}`]\n : []),\n ]\n\n if (!options.yes) return { executed: false, targets, bootstrapped: false }\n await inPhase('reset.safety', () => refuseRunningInstallation(configuration.baseUrl))\n\n if (options.database) await inPhase('reset.database', () => resetDatabase(configuration.database))\n\n const media = configuration.media\n\n if (options.media && media !== undefined) await inPhase('reset.media', () => resetMedia(media))\n\n if (options.bootstrap)\n await bootstrapCmsDevelopment({\n rootDir: options.rootDir,\n envFile: options.envFile,\n verbose: options.verbose,\n ...options.bootstrap,\n })\n\n return { executed: true, targets, bootstrapped: options.bootstrap !== undefined }\n}\n\nexport async function loadCmsProjectEnvironment(rootDir: string, envFile?: string): Promise<void> {\n await setupDotenv({ cwd: resolve(rootDir), fileName: envFile ? ['.env', envFile] : '.env' })\n}\n\nasync function loadConfiguration(rootDir: string, envFile?: string) {\n const absoluteRoot = resolve(rootDir)\n await loadCmsProjectEnvironment(absoluteRoot, envFile)\n const authored = await Effect.runPromise(loadCmsConfiguration(absoluteRoot).pipe(Effect.provide(nodeLayer)))\n const nuxt = await loadNuxtConfig({ cwd: absoluteRoot, dotenv: false })\n const defaults = cmsRuntimeConfigurationDefaults(authored.configuration, nuxt.runtimeConfig.cms)\n const runtime = await Effect.runPromise(cmsRuntimeConfigurationFromEnvironment(defaults))\n\n return { authored, runtime }\n}\n\nasync function prepareAuthoring(rootDir: string, verbose = false): Promise<AuthoringCatalog> {\n const nuxt = await loadNuxt({\n cwd: rootDir,\n dev: true,\n ready: true,\n overrides: {\n logLevel: verbose ? 'verbose' : 'silent',\n ...(verbose ? undefined : { devtools: { enabled: false }, seo: { metaDataFiles: false } }),\n },\n })\n\n try {\n const source = (await readFile(resolve(nuxt.options.buildDir, 'cms/authoring.mjs'), 'utf8'))\n .replace(/^export default /u, '')\n .trim()\n\n return Result.getOrThrow(Schema.decodeUnknownResult(AuthoringCatalogSchema)(JSON.parse(source)))\n } finally {\n await nuxt.close()\n }\n}\n\nasync function refuseRunningInstallation(baseUrl: string): Promise<void> {\n try {\n await fetch(new URL(CMS_READINESS_PATH, baseUrl), { signal: AbortSignal.timeout(1_000) })\n throw new Error('Refusing to reset while the CMS server is running.')\n } catch (cause) {\n if (cause instanceof Error && cause.message.startsWith('Refusing')) throw cause\n }\n}\n\nasync function verifyMigrations(pool: Pool, schema: string): Promise<number> {\n const ledger = await pool.query<{ exists: boolean }>(\n 'select exists(select 1 from information_schema.tables where table_schema = $1 and table_name = $2) as exists',\n [schema, '__drizzle_migrations'],\n )\n\n const applied = ledger.rows[0]?.exists\n ? (\n await pool.query<{ createdAt: string; hash: string }>(\n `select created_at as \"createdAt\", hash from \"${schema}\".\"__drizzle_migrations\" order by created_at`,\n )\n ).rows\n : []\n\n const matches = applied.every(\n (migration, index) =>\n migration.hash === postgresMigrations[index]?.hash &&\n Number(migration.createdAt) === postgresMigrations[index]?.createdAt,\n )\n\n if (!matches || applied.length > postgresMigrations.length)\n throw new Error('The applied migration history does not match this CMS release.')\n\n const pending = postgresMigrations.slice(applied.length)\n const connection = await pool.connect()\n\n try {\n await connection.query('begin')\n await connection.query(`create schema if not exists \"${schema}\"`)\n await connection.query(`set local search_path to \"${schema}\"`)\n\n for (const migration of pending) for (const statement of migration.statements) await connection.query(statement)\n } finally {\n await connection.query('rollback')\n connection.release()\n }\n\n return pending.length\n}\n\nfunction publicObjectUrl(baseUrl: string, key: string): URL {\n const base = new URL(baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`)\n\n return new URL(key.split('/').map(encodeURIComponent).join('/'), base)\n}\n\nasync function probeWebSocket(httpUrl: URL): Promise<void> {\n const url = new URL(httpUrl)\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:'\n\n await new Promise<void>((resolve, reject) => {\n const socket = new WebSocket(url)\n\n const timeout = setTimeout(() => {\n socket.close()\n reject(new Error('The WebSocket handshake timed out.'))\n }, 2_000)\n\n socket.addEventListener('open', () => {\n clearTimeout(timeout)\n socket.close()\n resolve()\n })\n socket.addEventListener('error', () => {\n clearTimeout(timeout)\n reject(new Error(`Could not open ${url.href}.`))\n })\n })\n}\n\nasync function resetDatabase(database: NuxtCmsInstallationOptions['database']): Promise<void> {\n const pool = new Pool({ connectionString: database.url })\n\n try {\n const client = await pool.connect()\n\n try {\n await client.query('select pg_advisory_lock(hashtextextended($1, 0))', ['cms:development-reset:v1'])\n await client.query(`drop schema if exists \"${database.schema}\" cascade`)\n await client.query(`create schema \"${database.schema}\"`)\n } finally {\n client.release()\n }\n } finally {\n await pool.end()\n }\n}\n\nasync function resetMedia(storage: NonNullable<NuxtCmsInstallationOptions['media']>): Promise<void> {\n const client = s3Client(storage)\n\n try {\n let continuationToken: string | undefined\n\n do {\n const page = await client.send(\n new ListObjectsV2Command({\n Bucket: storage.bucket,\n Prefix: storage.prefix,\n ContinuationToken: continuationToken,\n }),\n )\n\n for (const object of page.Contents ?? [])\n if (object.Key) await client.send(new DeleteObjectCommand({ Bucket: storage.bucket, Key: object.Key }))\n continuationToken = page.IsTruncated ? page.NextContinuationToken : undefined\n } while (continuationToken)\n } finally {\n client.destroy()\n }\n}\n\nfunction s3Client(storage: NonNullable<NuxtCmsInstallationOptions['media']>): S3Client {\n return new S3Client({\n region: storage.region,\n endpoint: storage.endpoint,\n forcePathStyle: storage.forcePathStyle,\n credentials: storage.credentials,\n })\n}\n\nfunction pass(id: string, label: string): CmsDoctorCheck {\n return { id, label, phase: `doctor.${id}`, status: 'pass' }\n}\n\nfunction fail(id: string, label: string, detail: string): CmsDoctorCheck {\n return { id, label, phase: `doctor.${id}`, status: 'fail', detail }\n}\n\nfunction notVerified(id: string, label: string, detail: string): CmsDoctorCheck {\n return { id, label, phase: `doctor.${id}`, status: 'not-verified', detail }\n}\n\nfunction report(checks: ReadonlyArray<CmsDoctorCheck>): CmsDoctorReport {\n return { ok: checks.every((check) => check.status !== 'fail'), checks }\n}\n\nfunction message(cause: unknown): string {\n if (cause instanceof Error && cause.message) return cause.message\n\n if (Schema.is(CauseCarrier)(cause)) return message(cause.cause)\n\n return String(cause)\n}\n\nasync function inPhase<Value>(phase: string, operation: () => PromiseLike<Value>): Promise<Value> {\n try {\n return await operation()\n } catch (cause) {\n if (isCmsLifecycleFailed(cause)) throw cause\n throw new CmsLifecycleFailed({ cause, message: message(cause), phase })\n }\n}\n\nfunction inPhaseSync<Value>(phase: string, operation: () => Value): Value {\n try {\n return operation()\n } catch (cause) {\n if (isCmsLifecycleFailed(cause)) throw cause\n throw new CmsLifecycleFailed({ cause, message: message(cause), phase })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAcA,MAAa,qBAAuD,OAAO,OACzE,mBAAmB,KAAK,cACtB,OAAO,OAAO;CACZ,WAAW,UAAU;CACrB,MAAM,UAAU;CAChB,MAAM,UAAU;CAChB,YAAY,OAAO,OAAO,CAAC,GAAG,UAAU,GAAG,CAAC;AAC9C,CAAC,CACH,CACF;AAEA,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CAAC,4BAA4B;CACrG,OAAO,OAAO,OAAO;CACrB,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC;;;;ACbJ,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,6BACA,EAAE,OAAO,OAAO,OAAO,EAAE,CAC3B,CAAC,CAAC,CAAC;;AAGH,MAAa,8BAA8B,OAAO,GAAG,8BAA8B,CAAC,CAAC,WACnF,SACA;CACA,MAAM,OAAO,oBAAoB;EAC/B,SAAS,QAAQ;EACjB,UAAU,QAAQ;EAClB,QAAQ,QAAQ;CAClB,CAAC;CAED,OAAO,OAAO,OAAO,WAAW;EAE9B,KAAK,YAAY;GACf,MAAM,UAAU,MAAM,KAAK;GAC3B,MAAM,WAAW,MAAM,QAAQ,gBAAgB,gBAAgB,QAAQ,OAAO,EAAE,iBAAiB,KAAK,CAAC;GAEvG,IAAI,CAAC,UAAU;IACb,MAAM,OAAO,MAAM,QAAQ,gBAAgB,WACzC;KAAE,OAAO,QAAQ;KAAO,MAAM,QAAQ;KAAM,MAAM;IAAgB,GAClE,EAAE,QAAQ,QAAQ,CACpB;IAEA,MAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,QAAQ,QAAQ;IAC7D,MAAM,QAAQ,gBAAgB,YAAY;KACxC,WAAW,KAAK;KAChB;KACA,YAAY;KACZ,QAAQ,KAAK;IAC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as doctorCmsDevelopment, t as bootstrapCmsDevelopment } from "../dev-lifecycle-DdBluSiR.js";
1
+ import { a as resetCmsDevelopment, i as loadCmsProjectEnvironment, n as checkCmsConfiguration, r as doctorCmsDevelopment, t as bootstrapCmsDevelopment } from "../dev-lifecycle-CExksm2R.js";
2
2
 
3
3
  export { bootstrapCmsDevelopment, checkCmsConfiguration, doctorCmsDevelopment, loadCmsProjectEnvironment, resetCmsDevelopment };
@@ -0,0 +1,335 @@
1
+ import { $ as e, Bt as t, Dt as n, Et as r, It as i, Nt as a, Pt as o, Q as s, Y as c, at as l, cn as u, dn as d, en as f, et as p, ht as m, mt as h, nt as g, on as _, q as ee, st as v, tt as y, wt as b } from "./editor-P2rB7Csp.js";
2
+ import { Ai as x, F as te, Fa as S, I as ne, L as re, Mi as C, Mr as w, Nr as T, O as ie, P as E, Pr as D, j as ae, ji as O, jr as oe, lr as k, n as A, pa as j, r as se, t as ce, ur as M, xr as le, z as ue } from "./SelectMenu-BgikeouH.js";
3
+ //#region virtual:nuxt-ui-templates/ui/collapsible.ts
4
+ var N = { slots: {
5
+ root: "",
6
+ content: "data-[state=open]:animate-[collapsible-down_200ms_var(--ease-out)] data-[state=closed]:animate-[collapsible-up_200ms_var(--ease-out)] data-[state=closed]:overflow-hidden"
7
+ } }, de = {
8
+ __name: "Collapsible",
9
+ props: {
10
+ as: {
11
+ type: null,
12
+ required: !1
13
+ },
14
+ class: {
15
+ type: null,
16
+ required: !1
17
+ },
18
+ ui: {
19
+ type: Object,
20
+ required: !1
21
+ },
22
+ defaultOpen: {
23
+ type: Boolean,
24
+ required: !1
25
+ },
26
+ open: {
27
+ type: Boolean,
28
+ required: !1
29
+ },
30
+ disabled: {
31
+ type: Boolean,
32
+ required: !1
33
+ },
34
+ unmountOnHide: {
35
+ type: Boolean,
36
+ required: !1,
37
+ default: !0
38
+ }
39
+ },
40
+ emits: ["update:open"],
41
+ setup(e, { emit: r }) {
42
+ let i = e, a = r, c = o(), d = D("collapsible", i), f = j(), h = T(S(d, "as", "defaultOpen", "open", "disabled", "unmountOnHide"), a), g = s(() => w({
43
+ extend: N,
44
+ ...f.ui?.collapsible || {}
45
+ })());
46
+ return (e, r) => (b(), p(_(C), m(_(h), {
47
+ "data-slot": "root",
48
+ class: g.value.root({ class: [_(d).ui?.root, _(d).class] })
49
+ }), {
50
+ default: t(({ open: r }) => [c.default ? (b(), p(_(x), {
51
+ key: 0,
52
+ "as-child": ""
53
+ }, {
54
+ default: t(() => [n(e.$slots, "default", { open: r })]),
55
+ _: 2
56
+ }, 1024)) : y("", !0), l(_(O), {
57
+ "data-slot": "content",
58
+ class: u(g.value.content({ class: _(d).ui?.content }))
59
+ }, {
60
+ default: t(() => [n(e.$slots, "content")]),
61
+ _: 3
62
+ }, 8, ["class"])]),
63
+ _: 3
64
+ }, 16, ["class"]));
65
+ }
66
+ }, fe = { key: 2 }, pe = { class: "grid grid-flow-col auto-cols-fr overflow-x-auto rounded-md border border-default" }, me = ["aria-pressed", "onClick"], he = { class: "block truncate" }, P = { key: 3 }, F = {
67
+ key: 4,
68
+ class: "overflow-hidden rounded-md border border-default bg-elevated/20"
69
+ }, I = {
70
+ type: "button",
71
+ class: "group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left transition-[background-color,transform] duration-150 ease-out hover:bg-elevated/50 active:scale-[0.99] motion-reduce:transition-none"
72
+ }, L = { class: "min-w-0 flex-1" }, ge = { class: "block truncate text-xs text-muted" }, _e = { class: "shrink-0 text-xs font-medium text-muted group-hover:text-highlighted" }, ve = { class: "grid gap-4 border-t border-default px-3 py-3 sm:grid-cols-2" }, ye = {
73
+ key: 5,
74
+ class: "-mt-2 text-xs text-error"
75
+ }, be = {
76
+ key: 6,
77
+ class: "-mt-2 text-xs text-error"
78
+ }, xe = { class: "flex w-full justify-end gap-2" }, R = "__top_level__", z = /* @__PURE__ */ v({
79
+ __name: "CreateDocumentDialog",
80
+ props: /*@__PURE__*/ h({
81
+ catalog: {},
82
+ context: {}
83
+ }, {
84
+ open: { type: Boolean },
85
+ openModifiers: {}
86
+ }),
87
+ emits: /*@__PURE__*/ h(["close"], ["update:open"]),
88
+ setup(n, { emit: o }) {
89
+ let m = o, h = a(n, "open"), v = E(), x = v.bootstrap.documents, S = x.types.filter((e) => e.canCreate), C = (x.locales?.locales ?? []).map((e) => ({
90
+ label: $(e),
91
+ value: String(e)
92
+ })), w = f(""), T = f(!1), D = f(""), O = f(""), j = f(!1), N = f(""), z = f(R), B = f(x.locales?.defaultLocale ?? ""), V = f(!1), H = s(() => {
93
+ let e = S.map((e) => ({
94
+ collection: e.collection,
95
+ key: `entry:${e.collection}`,
96
+ kind: "entry",
97
+ label: e.label,
98
+ type: e,
99
+ urlHint: e.routes.entry.replace(/:[a-z][\w.]*\*?/giu, "…")
100
+ }));
101
+ return [...S.filter((e) => !n.catalog.entries.value.some((t) => t.document.collection === e.collection && t.document.locale === (B.value || void 0) && t.document.placement.kind === "home")).flatMap((e) => {
102
+ let t = A(x, {
103
+ collection: e.collection,
104
+ locale: B.value || void 0,
105
+ placement: { kind: "home" },
106
+ title: "Home"
107
+ });
108
+ return k(t) || n.catalog.entries.value.some((e) => e.document.path === t.success.path) ? [] : [{
109
+ collection: e.collection,
110
+ key: `home:${e.collection}`,
111
+ kind: "home",
112
+ label: "Home",
113
+ type: e,
114
+ urlHint: t.success.path
115
+ }];
116
+ }), ...e];
117
+ }), U = s(() => H.value.find((e) => e.key === N.value)), W = s(() => n.catalog.entries.value.find((e) => e.document.collection === U.value?.collection && e.document.locale === (B.value || void 0) && e.document.placement.kind === "home")), Se = s(() => H.value.length > 1 ? "Choose a page type and add a title." : "Add a title to get started."), Ce = s(() => U.value?.kind === "home" ? "Homepage" : z.value === R || z.value === W.value?.document.id ? "Top level" : n.catalog.byId(z.value)?.document.title ?? "Selected location"), we = s(() => {
118
+ let e = [Ce.value];
119
+ return C.length && e.unshift($(B.value)), e.join(" · ");
120
+ }), G = s(() => {
121
+ if (U.value?.kind === "home") return { kind: "home" };
122
+ let e = z.value === R ? W.value?.document.id : z.value;
123
+ return e ? {
124
+ kind: "entry",
125
+ parentDocumentId: e,
126
+ slug: O.value
127
+ } : void 0;
128
+ }), K = s(() => {
129
+ let e = U.value, t = G.value;
130
+ if (!e || !t || e.kind === "entry" && !O.value.trim()) return;
131
+ let r = {
132
+ collection: e.collection,
133
+ placement: t,
134
+ title: D.value || "Untitled"
135
+ }, i = r.placement.kind === "entry" ? n.catalog.byId(r.placement.parentDocumentId)?.document.path : void 0;
136
+ return A(x, B.value ? {
137
+ ...r,
138
+ locale: B.value
139
+ } : r, i);
140
+ }), q = s(() => {
141
+ let e = K.value;
142
+ return e && M(e) ? e.success : void 0;
143
+ }), J = s(() => {
144
+ let e = K.value;
145
+ return e && k(e) ? e.failure : "";
146
+ }), Y = s(() => q.value && n.catalog.entries.value.some((e) => e.document.path === q.value?.path)), X = s(() => {
147
+ let e = U.value;
148
+ if (!e || e.kind === "home" || !e.type.hierarchy) return [];
149
+ let t = n.catalog.entries.value.flatMap((t) => t.document.collection !== e.collection || t.document.locale !== (B.value || void 0) || t.document.placement.kind === "home" ? [] : [{
150
+ description: String(t.document.path),
151
+ label: t.document.title,
152
+ value: String(t.document.id)
153
+ }]);
154
+ return n.context?.parent && !t.some((e) => e.value === n.context.parent) && t.push({
155
+ description: n.context.parent,
156
+ label: "Selected location",
157
+ value: n.context.parent
158
+ }), [{
159
+ description: "Add this page directly below the homepage.",
160
+ label: "Top level",
161
+ value: R
162
+ }, ...t];
163
+ }), Z = s(() => !!D.value.trim() && !!U.value && !!q.value && !Y.value);
164
+ i(D, (e) => {
165
+ j.value || (O.value = se(e));
166
+ }), i(N, () => z.value = R, { flush: "sync" }), i(B, () => {
167
+ z.value = R, U.value || (N.value = Q());
168
+ }, { flush: "sync" }), i(h, (e) => {
169
+ e && (w.value = "", D.value = "", O.value = "", j.value = !1, V.value = !1, B.value = n.context?.locale ?? x.locales?.defaultLocale ?? "", N.value = n.context?.collection ? `entry:${n.context.collection}` : Q(), z.value = n.context?.parent === W.value?.document.id ? R : n.context?.parent || R, n.context?.slug && (O.value = n.context.slug, j.value = !0));
170
+ }, { immediate: !0 });
171
+ async function Te() {
172
+ let e = U.value, t = G.value;
173
+ if (Z.value && e && t && !T.value) {
174
+ T.value = !0, w.value = "";
175
+ try {
176
+ let r = {
177
+ collection: e.collection,
178
+ placement: t,
179
+ title: D.value
180
+ }, i = await v.gateway.documents.create(B.value ? {
181
+ ...r,
182
+ locale: B.value
183
+ } : r);
184
+ await n.catalog.refresh(!0);
185
+ let a = n.catalog.byId(i.documentId);
186
+ if (!a) throw Error("The page was created but could not be opened.");
187
+ m("close", a.document.id);
188
+ } catch (e) {
189
+ w.value = ue(e);
190
+ } finally {
191
+ T.value = !1;
192
+ }
193
+ }
194
+ }
195
+ function Q() {
196
+ return H.value[0]?.key ?? "";
197
+ }
198
+ function $(e) {
199
+ try {
200
+ return new Intl.DisplayNames(void 0, { type: "language" }).of(e) ?? e.toLocaleUpperCase();
201
+ } catch {
202
+ return e.toLocaleUpperCase();
203
+ }
204
+ }
205
+ return (n, i) => {
206
+ let a = re, o = te, s = ne, f = oe, m = ie, v = ce, x = de, S = le, E = ae;
207
+ return b(), p(E, {
208
+ open: h.value,
209
+ "onUpdate:open": i[7] ||= (e) => h.value = e,
210
+ title: "Create page",
211
+ description: Se.value,
212
+ ui: { content: "max-w-lg" }
213
+ }, {
214
+ body: t(() => [e("form", {
215
+ id: "create-document-form",
216
+ class: "space-y-4",
217
+ onSubmit: ee(Te, ["prevent"])
218
+ }, [
219
+ w.value ? (b(), p(a, {
220
+ key: 0,
221
+ description: w.value,
222
+ color: "error",
223
+ variant: "subtle"
224
+ }, null, 8, ["description"])) : y("", !0),
225
+ H.value.length ? H.value.length > 1 ? (b(), g("fieldset", fe, [i[8] ||= e("legend", { class: "mb-2 text-sm font-medium text-highlighted" }, "Page type", -1), e("div", pe, [(b(!0), g(c, null, r(H.value, (t) => (b(), g("button", {
226
+ key: t.key,
227
+ type: "button",
228
+ "aria-pressed": t.key === N.value,
229
+ class: u(["min-w-28 border-l border-default px-3 py-2 text-center text-sm transition-[color,background-color,transform] duration-150 ease-out first:border-l-0 active:scale-[0.98] motion-reduce:transition-none", t.key === N.value ? "bg-muted font-medium text-highlighted" : "bg-default text-muted hover:bg-muted/50 hover:text-highlighted"]),
230
+ onClick: (e) => N.value = t.key
231
+ }, [e("span", he, d(t.label), 1)], 10, me))), 128))])])) : y("", !0) : (b(), p(a, {
232
+ key: 1,
233
+ title: "Document creation is not configured",
234
+ description: "A developer needs to make at least one collection creatable in Studio.",
235
+ color: "warning",
236
+ variant: "subtle"
237
+ })),
238
+ U.value ? (b(), g("div", P, [l(s, {
239
+ label: "Title",
240
+ required: ""
241
+ }, {
242
+ default: t(() => [l(o, {
243
+ modelValue: D.value,
244
+ "onUpdate:modelValue": i[0] ||= (e) => D.value = e,
245
+ autofocus: "",
246
+ placeholder: "About us",
247
+ class: "w-full"
248
+ }, null, 8, ["modelValue"])]),
249
+ _: 1
250
+ })])) : y("", !0),
251
+ U.value ? (b(), g("div", F, [l(x, {
252
+ open: V.value,
253
+ "onUpdate:open": i[5] ||= (e) => V.value = e
254
+ }, {
255
+ content: t(() => [e("div", ve, [
256
+ _(C).length ? (b(), p(s, {
257
+ key: 0,
258
+ label: "Language"
259
+ }, {
260
+ default: t(() => [l(m, {
261
+ modelValue: B.value,
262
+ "onUpdate:modelValue": i[1] ||= (e) => B.value = e,
263
+ items: _(C),
264
+ "value-key": "value",
265
+ class: "w-full"
266
+ }, null, 8, ["modelValue", "items"])]),
267
+ _: 1
268
+ })) : y("", !0),
269
+ U.value.kind === "entry" && U.value.type.hierarchy ? (b(), p(s, {
270
+ key: 1,
271
+ label: "Location",
272
+ class: u(_(C).length ? "" : "sm:col-span-2")
273
+ }, {
274
+ default: t(() => [l(v, {
275
+ modelValue: z.value,
276
+ "onUpdate:modelValue": i[2] ||= (e) => z.value = e,
277
+ "aria-label": "Location",
278
+ items: X.value,
279
+ "value-key": "value",
280
+ "filter-fields": ["label", "description"],
281
+ "search-input": { placeholder: "Search pages…" },
282
+ class: "w-full"
283
+ }, null, 8, ["modelValue", "items"])]),
284
+ _: 1
285
+ }, 8, ["class"])) : y("", !0),
286
+ U.value.kind === "entry" ? (b(), p(s, {
287
+ key: 2,
288
+ label: "Page address",
289
+ description: "The final part of this page's web address.",
290
+ class: "sm:col-span-2",
291
+ required: ""
292
+ }, {
293
+ default: t(() => [l(o, {
294
+ modelValue: O.value,
295
+ "onUpdate:modelValue": [i[3] ||= (e) => O.value = e, i[4] ||= (e) => j.value = !0],
296
+ placeholder: "about-us",
297
+ class: "w-full"
298
+ }, null, 8, ["modelValue"])]),
299
+ _: 1
300
+ })) : y("", !0)
301
+ ])]),
302
+ default: t(() => [e("button", I, [
303
+ e("span", L, [e("span", ge, d(we.value), 1), e("span", { class: u(["mt-0.5 block truncate font-mono text-xs", Y.value || J.value ? "text-error" : "text-highlighted"]) }, d(q.value?.path || U.value.urlHint), 3)]),
304
+ e("span", _e, d(V.value ? "Done" : "Edit details"), 1),
305
+ l(f, {
306
+ name: "i-lucide-chevron-down",
307
+ class: u(["size-3.5 shrink-0 text-dimmed transition-transform duration-150 ease-out motion-reduce:transition-none", V.value ? "rotate-180" : ""])
308
+ }, null, 8, ["class"])
309
+ ])]),
310
+ _: 1
311
+ }, 8, ["open"])])) : y("", !0),
312
+ Y.value ? (b(), g("p", ye, "This page address is already in use.")) : J.value ? (b(), g("p", be, d(J.value), 1)) : y("", !0)
313
+ ], 32)]),
314
+ footer: t(() => [e("div", xe, [l(S, {
315
+ color: "neutral",
316
+ variant: "ghost",
317
+ label: "Cancel",
318
+ class: "transition-transform duration-150 ease-out active:scale-[0.97] motion-reduce:transition-none",
319
+ onClick: i[6] ||= (e) => h.value = !1
320
+ }), l(S, {
321
+ type: "submit",
322
+ form: "create-document-form",
323
+ color: "neutral",
324
+ label: "Create page",
325
+ class: "transition-transform duration-150 ease-out active:scale-[0.97] motion-reduce:transition-none",
326
+ loading: T.value,
327
+ disabled: !Z.value
328
+ }, null, 8, ["loading", "disabled"])])]),
329
+ _: 1
330
+ }, 8, ["open", "description"]);
331
+ };
332
+ }
333
+ });
334
+ //#endregion
335
+ export { z as default };