@brightsideoy/kama 0.1.0-alpha.111 → 0.1.0-alpha.113

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/README.md CHANGED
@@ -87,40 +87,61 @@ At the heart of KAMA is the Schema Engine. Instead of complex database migration
87
87
 
88
88
  ## Getting Started
89
89
 
90
- KAMA comes with a scaffolding CLI to instantly spin up a full monorepo (Backend + Astro Frontend).
90
+ KAMA comes with an interactive executable CLI to instantly spin up a full monorepo (Backend Worker + optional Astro Frontend), add new sites to existing workspaces, or promote local setups to Cloudflare Edge.
91
91
 
92
- ## 1. Initialize a Workspace
92
+ ### 1. Initialize a Workspace\*\*
93
+
94
+ Run the KAMA CLI to start the workspace wizard:
93
95
 
94
96
  ```bash
95
- npx @brightsideoy/kama@alpha
97
+ npx kama init
96
98
  ```
97
99
 
98
- Select **"Kickstart new KAMA Monorepo"**. The CLI will automatically:
100
+ The CLI will prompt you for your setup preferences and automatically:
99
101
 
100
- - Authenticate with Cloudflare (if deploying to the Edge).
101
- - Create a new D1 database (or local SQLite equivalent).
102
- - Bind your R2 media buckets.
103
- - Setup the Worker backend and Astro frontend.
102
+ - Scaffold the `kama-worker` engine and content definition directories (`content/definitions/`).
103
+ - Authenticate with Cloudflare and auto-provision a remote D1 database + R2 bucket bindings (if deploying to Edge).
104
+ - Scaffold a fully configured Astro frontend site inside `sites/` with built-in edge-caching middleware.
105
+ - Configure local SQLite fallback environments for completely offline development.
104
106
 
105
- ## 2. Local Development
107
+ ### 2. Local Development
106
108
 
107
- Start the backend and frontend simultaneously on your local machine:
109
+ Start the local CMS dev server from your workspace root:
108
110
 
109
111
  ```bash
110
112
  npm run dev:cms
111
113
  ```
112
114
 
113
- This bundles your local YAML schemas, syncs the local SQLite/D1 database, and starts the Wrangler dev server on your localhost.
115
+ This command automatically compiles your YAML/JSON schemas into runtime JavaScript definitions, syncs your local SQLite database, and launches the Miniflare worker environment on `http://localhost:8787`.
116
+
117
+ ### 3. Management Commands\*\*
118
+
119
+ You can run CLI commands anytime inside your workspace.
120
+
121
+ #### Add a New Astro Frontend Site
122
+
123
+ ```bash
124
+ npx kama add site
125
+ ```
126
+
127
+ #### Promote a Local Workspace to Cloudflare Edge
128
+
129
+ Convert a local offline workspace to Cloudflare Edge (auto-links domains & D1 databases):
114
130
 
115
- ## 3. Deploy
131
+ ```bash
132
+ npx kama promote
133
+ ```
116
134
 
117
- Push your API, schemas, and database migrations to Cloudflare's global network, or package it for your virtual server:
135
+ ### 4. Deploy
136
+
137
+ Deploy your CMS engine, content definitions, and database migrations to Cloudflare Edge:
118
138
 
119
139
  ```bash
120
140
  npm run deploy:cms
121
141
  ```
122
142
 
123
- <br>
143
+ > **Note:** For self-hosted virtual servers (VPS) or Docker environments, you can run `npm run dev:cms` under PM2/Docker as a standalone `workerd` server.
144
+ > <br>
124
145
 
125
146
  ## Directory Structure Overview
126
147
 
package/bin/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { execSync } from 'node:child_process';
3
- import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';
4
- import { join, dirname } from 'node:path';
3
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync } from 'node:fs';
4
+ import { join, dirname, basename } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import * as readline from 'node:readline/promises';
7
7
 
8
- // Dynamically resolve the current CLI version to inject into package.json files
8
+ // Dynamically resolve current package version
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = dirname(__filename);
11
11
  let currentKamaVersion = 'alpha';
@@ -25,28 +25,55 @@ const rl = readline.createInterface({
25
25
  });
26
26
 
27
27
  async function main() {
28
- console.log('\nšŸ”„ --- KAMA SITE GENERATOR --- šŸ”„\n');
28
+ const args = process.argv.slice(2);
29
+ const command = args[0]?.toLowerCase();
30
+ const subCommand = args[1]?.toLowerCase();
29
31
 
30
- console.log('Select mode:');
31
- console.log(' 1) Kickstart new Kama Monorepo (CMS + Optional Site)');
32
- console.log(' 2) Add a new Astro Site to current workspace (sites/)');
32
+ console.log('\nšŸ”„ --- KAMA ENGINE CLI --- šŸ”„\n');
33
33
 
34
- const choice = await rl.question('\nChoice [1/2]: ');
35
-
36
- if (choice.trim() === '2') {
34
+ if (command === 'init') {
35
+ await createFullWorkspace();
36
+ } else if (command === 'add' && subCommand === 'site') {
37
37
  await createNewSiteOnly();
38
+ } else if (command === 'promote') {
39
+ await promoteLocalToCloudflare();
38
40
  } else {
39
- await createFullWorkspace();
41
+ // Interactive menu when invoked without arguments or unrecognized command
42
+ console.log('Available Commands:');
43
+ console.log(' 1) npx kama init - Kickstart new Monorepo (CMS + Optional Site)');
44
+ console.log(' 2) npx kama add site - Add new Astro Site to current workspace (sites/)');
45
+ console.log(' 3) npx kama promote - Promote current Local workspace to Cloudflare Edge');
46
+
47
+ const choice = await rl.question('\nSelect choice [1/2/3]: ');
48
+
49
+ if (choice.trim() === '3') {
50
+ await promoteLocalToCloudflare();
51
+ } else if (choice.trim() === '2') {
52
+ await createNewSiteOnly();
53
+ } else {
54
+ await createFullWorkspace();
55
+ }
40
56
  }
41
57
 
42
58
  rl.close();
43
59
  }
44
60
 
45
61
  /**
46
- * MODE 1: Kickstart full Monorepo Workspace
62
+ * COMMAND: npx kama init
63
+ * Kickstart full Monorepo Workspace
47
64
  */
48
65
  async function createFullWorkspace() {
49
- const projName = (await rl.question('Project folder name [kama-workspace]: ')) || 'kama-workspace';
66
+ const cwdName = basename(process.cwd());
67
+ const hasExistingPkg = existsSync(join(process.cwd(), 'package.json'));
68
+
69
+ const defaultDirPrompt = hasExistingPkg ? '.' : cwdName;
70
+ const inputName = await rl.question(`Project folder name (use '.' for current dir) [${defaultDirPrompt}]: `);
71
+
72
+ const chosenFolder = inputName.trim() || defaultDirPrompt;
73
+ const isCurrentDir = chosenFolder === '.';
74
+
75
+ const projName = isCurrentDir ? cwdName : chosenFolder;
76
+ const rootDir = isCurrentDir ? process.cwd() : join(process.cwd(), projName);
50
77
 
51
78
  console.log('\nšŸŒ Where do you plan to deploy KAMA?');
52
79
  console.log(' 1) Local Development Only (SQLite / Testing)');
@@ -54,14 +81,12 @@ async function createFullWorkspace() {
54
81
  const envChoice = await rl.question('\nChoice [1/2]: ');
55
82
  const isCloudflare = envChoice.trim() === '2';
56
83
 
57
- // šŸŽÆ Ask if user wants an Astro frontend site scaffolded
58
84
  const createSiteInput = await rl.question('\nšŸš€ Do you want to scaffold an initial Astro frontend site? (y/n) [y]: ');
59
85
  const shouldCreateSite = createSiteInput.trim().toLowerCase() !== 'n';
60
86
 
61
87
  let cmsDomain = 'localhost:8787';
62
88
  let siteDomain = 'localhost:4321';
63
89
 
64
- // Only ask for domains if deploying to Cloudflare Edge
65
90
  if (isCloudflare) {
66
91
  cmsDomain = (await rl.question('\nCMS Admin Domain (e.g., admin.t3cloud.eu): ')) || 'admin.t3cloud.eu';
67
92
  if (shouldCreateSite) {
@@ -69,21 +94,20 @@ async function createFullWorkspace() {
69
94
  }
70
95
  }
71
96
 
72
- // Standardize scheme for localhost vs custom edge domains
73
97
  const cmsProtocol = isCloudflare ? 'https://' : 'http://';
74
98
  const cmsFullUrl = `${cmsProtocol}${cmsDomain.replace(/^https?:\/\//, '')}`;
75
99
 
76
- const rootDir = join(process.cwd(), projName);
77
-
78
- // šŸŽÆ Derive dynamic worker, database, and bucket names from project folder name
79
100
  const workerName = `${projName}-worker`.toLowerCase().replace(/[^a-z0-9_-]/g, '-');
80
101
  let dbName = `${projName}-db`.replace(/[^a-zA-Z0-9_-]/g, '_');
81
102
  const bucketName = `${projName}-media-prod`.toLowerCase().replace(/[^a-z0-9_-]/g, '-');
82
103
 
83
- console.log(`\nšŸ“ Creating workspace folder at ./${projName}...`);
84
- mkdirSync(rootDir, { recursive: true });
104
+ if (!isCurrentDir) {
105
+ console.log(`\nšŸ“ Creating workspace folder at ./${projName}...`);
106
+ mkdirSync(rootDir, { recursive: true });
107
+ } else {
108
+ console.log(`\nšŸ“ Initializing workspace in current directory (${rootDir})...`);
109
+ }
85
110
 
86
- // šŸŽÆ Generate root .gitignore so auto-generated bundles and secrets stay out of git
87
111
  writeFileSync(
88
112
  join(rootDir, '.gitignore'),
89
113
  `node_modules/
@@ -99,7 +123,6 @@ sites/*/dist/
99
123
  `
100
124
  );
101
125
 
102
- // šŸŽÆ Scaffold full schema directory structure
103
126
  const schemaCategories = [
104
127
  'block-layouts',
105
128
  'blocks',
@@ -114,10 +137,8 @@ sites/*/dist/
114
137
  mkdirSync(join(rootDir, 'content', 'definitions', category), { recursive: true });
115
138
  }
116
139
 
117
- // šŸŽÆ Populate starter example YAML files
118
140
  scaffoldSampleSchemas(rootDir);
119
141
 
120
- // --- AUTO D1 CREATION MAGIC ---
121
142
  let d1DatabaseId = '00000000-0000-0000-0000-000000000000';
122
143
  let isAuthenticated = false;
123
144
 
@@ -189,9 +210,7 @@ sites/*/dist/
189
210
  } else {
190
211
  console.log(`\nšŸ’» Local mode selected. Skipping Cloudflare authentication and domain setup...`);
191
212
  }
192
- // ------------------------------
193
213
 
194
- // šŸŽÆ 1. Root package.json (includes 'sites/*' wildcard in workspaces so user can add sites later)
195
214
  writeFileSync(
196
215
  join(rootDir, 'package.json'),
197
216
  JSON.stringify({
@@ -210,16 +229,13 @@ sites/*/dist/
210
229
  }, null, 2)
211
230
  );
212
231
 
213
- // šŸŽÆ 2. Setup CMS Worker with Dynamic Names
214
232
  console.log(`\nā˜ļø Configuring CMS Worker '${workerName}' (${cmsDomain})...`);
215
233
  const cmsDir = join(rootDir, 'kama-worker');
216
234
  mkdirSync(cmsDir, { recursive: true });
217
235
 
218
- // šŸŽÆ Properly wrap and inject BUNDLED_DEFINITIONS from LOCAL workspace, not node_modules
219
236
  const cmsWorkerIndexContent = `import kamaWorker from '@brightsideoy/kama';
220
237
  import * as bundledModule from './bundled-definitions.js';
221
238
 
222
- // Resolve BUNDLED_DEFINITIONS across all module resolution formats
223
239
  const BUNDLED_DEFINITIONS =
224
240
  bundledModule.BUNDLED_DEFINITIONS ||
225
241
  bundledModule.default?.BUNDLED_DEFINITIONS ||
@@ -238,10 +254,7 @@ export default {
238
254
  };
239
255
  `;
240
256
 
241
- writeFileSync(
242
- join(cmsDir, 'index.js'),
243
- cmsWorkerIndexContent
244
- );
257
+ writeFileSync(join(cmsDir, 'index.js'), cmsWorkerIndexContent);
245
258
 
246
259
  writeFileSync(
247
260
  join(cmsDir, 'package.json'),
@@ -260,13 +273,12 @@ export default {
260
273
  '@brightsideoy/kama': currentKamaVersion,
261
274
  },
262
275
  devDependencies: {
263
- wrangler: '^4.0.0', // šŸ‘ˆ Updated to ^4.0.0 to support ES import attributes in dependencies
276
+ wrangler: '^4.0.0',
264
277
  tsx: '^4.19.2',
265
278
  },
266
279
  }, null, 2)
267
280
  );
268
281
 
269
- // šŸŽÆ Fixed CMS wrangler.json
270
282
  const cmsWranglerConfig = {
271
283
  $schema: '../node_modules/wrangler/config-schema.json',
272
284
  name: workerName,
@@ -300,28 +312,27 @@ export default {
300
312
  cmsWranglerConfig.routes = [{ pattern: cmsDomain, custom_domain: true }];
301
313
  }
302
314
 
303
- writeFileSync(
304
- join(cmsDir, 'wrangler.json'),
305
- JSON.stringify(cmsWranglerConfig, null, 2)
306
- );
315
+ writeFileSync(join(cmsDir, 'wrangler.json'), JSON.stringify(cmsWranglerConfig, null, 2));
307
316
 
308
- // šŸŽÆ Fixed .dev.vars
309
317
  writeFileSync(
310
318
  join(cmsDir, '.dev.vars'),
311
319
  `# Cloudflare Edge Cache Purging Secrets\nCLOUDFLARE_API_TOKEN=${isCloudflare ? 'cfut_YOUR_CUSTOM_PURGE_TOKEN' : 'local_token'}\n`
312
320
  );
313
321
 
314
- // šŸŽÆ 3. Setup Astro Site (ONLY if requested)
315
322
  if (shouldCreateSite) {
316
323
  const siteFolderName = isCloudflare ? siteDomain.split('.')[0] : 'web';
317
324
  await generateAstroSite(rootDir, siteFolderName, siteDomain, cmsFullUrl, workerName, isCloudflare);
318
325
  } else {
319
- console.log(`\nā„¹ļø Skipping Astro site creation. You can add a site later by running 'npx create-kama' (Mode 2) inside this workspace.`);
326
+ console.log(`\nā„¹ļø Skipping Astro site creation. You can add a site later by running 'npx kama add site' inside this workspace.`);
320
327
  }
321
328
 
322
329
  console.log(`\n✨ Workspace ready! Next steps:`);
323
- console.log(` 1. cd ${projName}`);
324
- console.log(` 2. npm install`);
330
+ if (!isCurrentDir) {
331
+ console.log(` 1. cd ${projName}`);
332
+ console.log(` 2. npm install`);
333
+ } else {
334
+ console.log(` 1. npm install`);
335
+ }
325
336
 
326
337
  if (isCloudflare) {
327
338
  if (d1DatabaseId === '00000000-0000-0000-0000-000000000000' || d1DatabaseId === 'REPLACE_WITH_YOUR_D1_ID') {
@@ -332,12 +343,13 @@ export default {
332
343
  console.log(` 6. Run 'npm run dev:cms' from the workspace root to start the backend.`);
333
344
  } else {
334
345
  console.log(` 3. Run 'npm run dev:cms' from the workspace root to start the local SQLite backend.`);
335
- console.log(`\nšŸ’” Note: You can deploy to Cloudflare later by updating 'kama-worker/wrangler.json' with real IDs.`);
346
+ console.log(`\nšŸ’” Note: You can deploy to Cloudflare later by running 'npx kama promote'.`);
336
347
  }
337
348
  }
338
349
 
339
350
  /**
340
- * MODE 2: Add Site to existing workspace
351
+ * COMMAND: npx kama add site
352
+ * Add Astro Site to existing workspace
341
353
  */
342
354
  async function createNewSiteOnly() {
343
355
  const rootDir = process.cwd();
@@ -379,12 +391,88 @@ async function createNewSiteOnly() {
379
391
  }
380
392
 
381
393
  /**
382
- * Helper: Scaffolds initial starter schemas for all category folders
394
+ * COMMAND: npx kama promote
395
+ * Promote current Local workspace to Cloudflare Edge
383
396
  */
397
+ async function promoteLocalToCloudflare() {
398
+ const rootDir = process.cwd();
399
+ const workerWranglerPath = join(rootDir, 'kama-worker', 'wrangler.json');
400
+
401
+ if (!existsSync(workerWranglerPath)) {
402
+ console.error('āŒ Error: Could not find kama-worker/wrangler.json. Run this command inside your workspace root.');
403
+ return;
404
+ }
405
+
406
+ console.log('\n🌐 --- PROMOTING WORKSPACE TO CLOUDFLARE EDGE --- 🌐\n');
407
+
408
+ try {
409
+ execSync('npx wrangler whoami', { stdio: 'pipe' });
410
+ console.log('āœ… Logged in to Cloudflare.');
411
+ } catch (e) {
412
+ console.log('🌐 Launching browser for Cloudflare login...');
413
+ try {
414
+ execSync('npx wrangler login', { stdio: 'inherit' });
415
+ } catch (loginError) {
416
+ console.log('āŒ Cloudflare login failed or was cancelled.');
417
+ return;
418
+ }
419
+ }
420
+
421
+ const cmsDomain = (await rl.question('\nCMS Admin Domain (e.g., admin.t3cloud.eu): ')) || 'admin.t3cloud.eu';
422
+
423
+ const sitesFolderDir = join(rootDir, 'sites');
424
+ let siteDomain = '';
425
+ if (existsSync(sitesFolderDir)) {
426
+ siteDomain = await rl.question('Frontend Website Domain (e.g., kama.t3cloud.eu): ');
427
+ }
428
+
429
+ const currentConfig = JSON.parse(readFileSync(workerWranglerPath, 'utf-8'));
430
+ const dbName = currentConfig.d1_databases?.[0]?.database_name || 'kama_db';
431
+
432
+ console.log(`\nšŸ—„ļø Provisioning remote Cloudflare D1 Database '${dbName}'...`);
433
+ let d1DatabaseId = '00000000-0000-0000-0000-000000000000';
434
+
435
+ try {
436
+ const d1Output = execSync(`npx wrangler d1 create ${dbName}`, { encoding: 'utf-8', stdio: 'pipe' });
437
+ const match = d1Output.match(/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/);
438
+ if (match) d1DatabaseId = match[0];
439
+ } catch (err) {
440
+ console.log('āš ļø Could not auto-create D1 (it may already exist). Please verify on your Cloudflare dashboard.');
441
+ }
442
+
443
+ currentConfig.vars.CDN_DOMAIN = cmsDomain;
444
+ if (siteDomain) {
445
+ currentConfig.vars.PUBLIC_FRONTEND_URL = `https://${siteDomain}`;
446
+ }
447
+ currentConfig.routes = [{ pattern: cmsDomain, custom_domain: true }];
448
+ if (currentConfig.d1_databases?.[0]) {
449
+ currentConfig.d1_databases[0].database_id = d1DatabaseId;
450
+ }
451
+
452
+ writeFileSync(workerWranglerPath, JSON.stringify(currentConfig, null, 2));
453
+
454
+ if (siteDomain && existsSync(sitesFolderDir)) {
455
+ const sites = readdirSync(sitesFolderDir);
456
+ if (sites.length > 0) {
457
+ const siteWranglerPath = join(sitesFolderDir, sites[0], 'wrangler.json');
458
+ if (existsSync(siteWranglerPath)) {
459
+ const siteConfig = JSON.parse(readFileSync(siteWranglerPath, 'utf-8'));
460
+ siteConfig.routes = [{ pattern: siteDomain, custom_domain: true }];
461
+ siteConfig.vars.PUBLIC_CMS_URL = `https://${cmsDomain}`;
462
+ siteConfig.vars.PUBLIC_API_URL = `https://${cmsDomain}`;
463
+ writeFileSync(siteWranglerPath, JSON.stringify(siteConfig, null, 2));
464
+ }
465
+ }
466
+ }
467
+
468
+ console.log(`\nāœ… Workspace successfully configured for Cloudflare Edge!`);
469
+ console.log(`\nNext steps:`);
470
+ console.log(` 1. Run 'npm run deploy:cms' from the root to publish your backend and database.`);
471
+ }
472
+
384
473
  function scaffoldSampleSchemas(rootDir) {
385
474
  const defsDir = join(rootDir, 'content', 'definitions');
386
475
 
387
- // 1. Channels
388
476
  writeFileSync(join(defsDir, 'channels', 'website.yaml'), `id: website
389
477
  label: Main Website
390
478
  defaultLanguage: en
@@ -393,7 +481,6 @@ languages:
393
481
  - fi
394
482
  `);
395
483
 
396
- // 2. Nodes
397
484
  writeFileSync(join(defsDir, 'nodes', 'page.yaml'), `id: page
398
485
  label: Page
399
486
  inTree: true
@@ -432,7 +519,6 @@ tabs:
432
519
  linkedTo: title
433
520
  `);
434
521
 
435
- // 3. Blocks
436
522
  writeFileSync(join(defsDir, 'blocks', 'hero.yaml'), `id: hero
437
523
  label: Hero Section
438
524
  fields:
@@ -453,7 +539,6 @@ fields:
453
539
  type: richtext
454
540
  `);
455
541
 
456
- // 4. Block Layouts
457
542
  writeFileSync(join(defsDir, 'block-layouts', 'two-column.yaml'), `id: two-column
458
543
  label: Two Column Layout
459
544
  regions:
@@ -463,7 +548,6 @@ regions:
463
548
  label: Right Column
464
549
  `);
465
550
 
466
- // 5. Node Layouts
467
551
  writeFileSync(join(defsDir, 'node-layouts', 'single-column.yml'), `id: single-column
468
552
  label: Single Column Page
469
553
  regions:
@@ -471,7 +555,6 @@ regions:
471
555
  label: Main Content Area
472
556
  `);
473
557
 
474
- // 6. Field Sets
475
558
  writeFileSync(join(defsDir, 'field-sets', 'page-base.yaml'), `id: page-base
476
559
  label: Base Page Fields
477
560
  fields:
@@ -483,7 +566,6 @@ fields:
483
566
  type: text
484
567
  `);
485
568
 
486
- // 7. Trees
487
569
  writeFileSync(join(defsDir, 'trees', 'navigation.yaml'), `id: navigation
488
570
  label: Main Navigation Tree
489
571
  maxDepth: 3
@@ -492,9 +574,6 @@ allowedNodeTypes:
492
574
  `);
493
575
  }
494
576
 
495
- /**
496
- * Helper: Scaffolds the Astro site with middleware, wrangler.json, & slug page
497
- */
498
577
  async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsFullUrl, workerName = 'kama-worker', isCloudflare = false) {
499
578
  console.log(`\nšŸš€ Scaffolding Astro site (${siteFolder}) mapped to ${siteDomain} (Service: ${workerName})...`);
500
579
 
@@ -521,7 +600,7 @@ async function generateAstroSite(rootDir, siteFolder, siteDomain, cmsFullUrl, wo
521
600
  '@astrojs/cloudflare': '^14.2.5',
522
601
  '@brightsideoy/kama': currentKamaVersion,
523
602
  astro: '^7.2.0',
524
- wrangler: '^4.0.0', // šŸ‘ˆ Updated to ^4.0.0
603
+ wrangler: '^4.0.0',
525
604
  },
526
605
  }, null, 2)
527
606
  );
@@ -583,7 +662,6 @@ export default defineConfig({
583
662
  `PUBLIC_CMS_URL="${cmsFullUrl}"\nPUBLIC_API_URL="${cmsFullUrl}"\n`
584
663
  );
585
664
 
586
- // šŸŽÆ Scaffold the Base Layout
587
665
  writeFileSync(
588
666
  join(siteDir, 'src/layouts/Layout.astro'),
589
667
  `---
@@ -607,7 +685,6 @@ const { title } = Astro.props;
607
685
  </html>`
608
686
  );
609
687
 
610
- // šŸŽÆ Scaffold the Dynamic Slug Page
611
688
  writeFileSync(
612
689
  join(siteDir, 'src/pages/[...slug].astro'),
613
690
  `---
@@ -615,10 +692,6 @@ import Layout from '../layouts/Layout.astro';
615
692
 
616
693
  const { slug } = Astro.params;
617
694
  const cmsUrl = import.meta.env.PUBLIC_CMS_URL;
618
-
619
- // Example Data Fetch: Replace with actual KAMA fetch logic
620
- // const response = await fetch(\`\${cmsUrl}/api/pages/\${slug || 'home'}\`);
621
- // const pageData = await response.json();
622
695
  ---
623
696
  <Layout title="Kama Generated Site">
624
697
  \t<main>
@@ -628,7 +701,6 @@ const cmsUrl = import.meta.env.PUBLIC_CMS_URL;
628
701
  </Layout>`
629
702
  );
630
703
 
631
- // šŸŽÆ Scaffold the Full Edge-Caching Middleware
632
704
  writeFileSync(
633
705
  join(siteDir, 'src/middleware.ts'),
634
706
  `import { defineMiddleware } from "astro:middleware";
@@ -639,8 +711,8 @@ export const onRequest = defineMiddleware(async (context, next) => {
639
711
  const cfContext = (context.locals as any).cfContext;
640
712
  const workerEnv = cfContext?.env || (env as any);
641
713
  const HTML_CACHE = workerEnv?.HTML_CACHE;
714
+ const cleanLookupPath = pathname.replace(/\\/$/, "") || "/";
642
715
 
643
- // šŸŽÆ 1. CACHE PURGE ENDPOINT
644
716
  if (pathname === "/api/purge" || pathname === "/api/purge/") {
645
717
  if (context.request.method !== "POST") return new Response("Method Not Allowed", { status: 405 });
646
718
 
@@ -658,12 +730,11 @@ export const onRequest = defineMiddleware(async (context, next) => {
658
730
  }));
659
731
  }
660
732
 
661
- // Surgical delete
662
733
  if (Array.isArray(body.deleted_urls) && body.deleted_urls.length > 0) {
663
734
  await Promise.all(body.deleted_urls.map(async (u: string) => {
664
735
  const path = new URL(u).pathname.replace(/\\/$/, "") || "/";
665
736
  const [siteVer, pageVer] = await Promise.all([
666
- HTML_CACHE.get("site_version"), HTML_CACHE.get(\`v:\${path}\`)
737
+ HTML_CACHE.get("site_version"), HTML_CACHE.get(\`v:\${cleanLookupPath}\`)
667
738
  ]);
668
739
  if (siteVer || pageVer) {
669
740
  await HTML_CACHE.delete(\`\${path}:v:\${siteVer || "1"}:\${pageVer || "1"}\`);
@@ -673,7 +744,6 @@ export const onRequest = defineMiddleware(async (context, next) => {
673
744
  }
674
745
  }
675
746
 
676
- // Astro Worker Cache layer flush
677
747
  if (typeof cfContext?.cache?.purge === 'function') await cfContext.cache.purge({ purgeEverything: true });
678
748
 
679
749
  return new Response(JSON.stringify({ success: true }), { status: 200 });
@@ -682,10 +752,8 @@ export const onRequest = defineMiddleware(async (context, next) => {
682
752
  }
683
753
  }
684
754
 
685
- // šŸŽÆ 2. KV HTML STATIC LOOKUP
686
755
  const isWarmer = context.request.headers.get("X-Cache-Warmer") === "true";
687
756
  const isHtmlPage = !pathname.includes('.') && !pathname.startsWith('/api/');
688
- const cleanLookupPath = pathname.replace(/\\/$/, "") || "/";
689
757
  let activeCacheKey = cleanLookupPath;
690
758
 
691
759
  if (isHtmlPage && HTML_CACHE && !isWarmer) {
@@ -714,7 +782,6 @@ export const onRequest = defineMiddleware(async (context, next) => {
714
782
 
715
783
  const response = await next();
716
784
 
717
- // šŸŽÆ 3. KV HTML STATIC WRITE
718
785
  if (isHtmlPage && HTML_CACHE && response.status === 200 && response.headers.get("content-type")?.includes("text/html")) {
719
786
  const htmlText = await response.clone().text();
720
787
  const writeTask = (async () => {
@@ -1234,7 +1234,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
1234
1234
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
1235
1235
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ng(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(Og(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=Mg(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Og(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Ag(t.key)&&!Og(t.sep,`newline`)){let e=Mg(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Og(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!Og(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ng(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||Og(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=Mg(jg(t));Pg(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
1236
1236
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
1237
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=Mg(jg(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=Mg(jg(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function Ig(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Dg||null,prettyErrors:t}}function Lg(e,t={}){let{lineCounter:n,prettyErrors:r}=Ig(t),i=new Fg(n?.addNewLine),a=new eg(t),o=Array.from(a.compose(i.parse(e)));if(r&&n)for(let t of o)t.errors.forEach(xh(e,n)),t.warnings.forEach(xh(e,n));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function Rg(e,t={}){let{lineCounter:n,prettyErrors:r}=Ig(t),i=new Fg(n?.addNewLine),a=new eg(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new yh(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(xh(e,n)),o.warnings.forEach(xh(e,n))),o}function zg(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=Rg(e,n);if(!i)return null;if(i.warnings.forEach(e=>Zp(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function Bg(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return Wf(e)&&!r?e.toString(n):new gh(e,r,n).toString(n)}var Vg=c({Alias:()=>vp,CST:()=>hg,Composer:()=>eg,Document:()=>gh,Lexer:()=>Eg,LineCounter:()=>Dg,Pair:()=>sm,Parser:()=>Fg,Scalar:()=>xp,Schema:()=>mh,YAMLError:()=>vh,YAMLMap:()=>pm,YAMLParseError:()=>yh,YAMLSeq:()=>hm,YAMLWarning:()=>bh,isAlias:()=>Uf,isCollection:()=>Yf,isDocument:()=>Wf,isMap:()=>Gf,isNode:()=>Xf,isPair:()=>Kf,isScalar:()=>qf,isSeq:()=>Jf,parse:()=>zg,parseAllDocuments:()=>Lg,parseDocument:()=>Rg,stringify:()=>Bg,visit:()=>tp,visitAsync:()=>rp}),Hg={},Ug={},Wg={},Gg={},Kg={},qg={},Jg={};try{Hg=Object.assign({"../../content/definitions/nodes/address.yaml":wd,"../../content/definitions/nodes/article.yaml":Ed,"../../content/definitions/nodes/event.yaml":Od,"../../content/definitions/nodes/external-link.yaml":Ad,"../../content/definitions/nodes/page.yaml":Md,"../../content/definitions/nodes/person.yaml":Pd,"../../content/definitions/nodes/product.yaml":Id}),Ug=Object.assign({"../../content/definitions/trees/navigation.yaml":Rd,"../../content/definitions/trees/social-links.yaml":Bd}),Wg=Object.assign({"../../content/definitions/blocks/button.yaml":Hd,"../../content/definitions/blocks/header.yaml":Wd,"../../content/definitions/blocks/header_image.yaml":Kd,"../../content/definitions/blocks/hero.yaml":Jd,"../../content/definitions/blocks/image_card.yaml":Xd,"../../content/definitions/blocks/single_image.yaml":Zd,"../../content/definitions/blocks/text.yaml":$d}),Gg=Object.assign({"../../content/definitions/node-layouts/landing-page.yml":tf,"../../content/definitions/node-layouts/single-column.yml":rf,"../../content/definitions/node-layouts/three-column.yml":of,"../../content/definitions/node-layouts/two-column.yml":cf}),Kg=Object.assign({"../../content/definitions/block-layouts/three-column.yaml":uf,"../../content/definitions/block-layouts/two-column.yaml":ff}),qg=Object.assign({"../../content/definitions/field-sets/access.yaml":mf,"../../content/definitions/field-sets/channel-base.yaml":gf,"../../content/definitions/field-sets/comments.yaml":vf,"../../content/definitions/field-sets/content-block.yaml":bf,"../../content/definitions/field-sets/page-base.yaml":Sf,"../../content/definitions/field-sets/page-meta.yaml":wf,"../../content/definitions/field-sets/page-social.yaml":Ef,"../../content/definitions/field-sets/tree-base.yaml":Of,"../../content/definitions/field-sets/visibility.yaml":Af}),Jg=Object.assign({"../../content/definitions/channels/ecommerce.yaml":Mf,"../../content/definitions/channels/website.yaml":Pf})}catch{}var Yg={},Xg={},Zg={},Qg={},$g={},e_={},t_={};function n_(e){let t=e.split(`/`);return t[t.length-1].replace(/\.(yaml|yml)$/,``)}function r_(e){let t={...qg,...e_};for(let n in t)if(n_(n)===e){let e=t[n]?.default||``;return Vg.parse(e)||{}}return{}}function i_(e,t){e&&typeof t==`object`&&t&&(e.inTree===void 0&&t.inTree!==void 0&&(e.inTree=!!t.inTree),e.inVault===void 0&&t.inVault!==void 0&&(e.inVault=!!t.inVault),e.hasCanvas===void 0&&t.hasCanvas!==void 0&&(e.hasCanvas=!!t.hasCanvas))}function a_(e={},t={}){let n={...e,...t},r={...e.rules||{},...t.rules||{}};return t.required===!0||String(t.required).toLowerCase()===`true`||t.rules?.required===!0||String(t.rules?.required).toLowerCase()===`true`||t.required===void 0&&(e.required===!0||String(e.required).toLowerCase()===`true`||e.rules?.required===!0||String(e.rules?.required).toLowerCase()===`true`)?(n.required=!0,r.required=!0):(t.required===!1||t.rules?.required===!1)&&(n.required=!1,r.required=!1),n.rules=r,n}function o_(e,t,n){let r={};if(!e)return r;if(Array.isArray(e)){for(let i of e)if(typeof i==`string`){if(i.startsWith(`fieldSet:`)){let e=i.replace(`fieldSet:`,``).trim();s_(r_(e),e,r,t,n)}else r[i]=a_(r[i],{type:`text`,label:i})}else if(typeof i==`object`&&i){let e=Object.entries(i);if(e.length>0){let[i,a]=e[0];if(i===`fieldSet`){let e=String(a);s_(r_(e),e,r,t,n)}else{let e=typeof a==`object`&&a?a:{};r[i]=a_(r[i],e)}}}}else if(typeof e==`object`&&e)for(let[i,a]of Object.entries(e))if(i===`fieldSet`){let e=String(a);s_(r_(e),e,r,t,n)}else r[i]=typeof a==`object`&&a?a_(r[i],a):a_(r[i],{type:`text`,label:String(a)});return r}function s_(e,t,n,r,i){if(i_(i,e),e.tabs&&r){if(typeof e.tabs==`object`)for(let[t,n]of Object.entries(e.tabs)){let e=typeof n==`object`&&n?n:{label:String(n)},a=e.label||t;r[t]||(r[t]={label:a,fields:{}});let o=o_(e.fields||[],r,i);Object.entries(o).forEach(([e,n])=>{r[t].fields[e]=a_(r[t].fields[e],n)})}return}let a=o_(e.fields||e,r,i);if(e.tab&&r){let n=e.tab.id||t,i=e.tab.label||e.label||n;r[n]||(r[n]={label:i,fields:{}}),Object.entries(a).forEach(([e,t])=>{let i=r[n].fields[e];r[n].fields[e]=a_(i,t)})}else Object.entries(a).forEach(([e,t])=>{let r=n[e];n[e]=a_(r,t)})}function c_(e){let t={},n={};if(e.tabs){if(Array.isArray(e.tabs)){for(let r of e.tabs)if(typeof r==`object`&&r.fieldSet){let i=String(r.fieldSet),a=r_(i);i_(e,a);let o=a.tab?.id||i,s=a.tab?.label||a.label||o;t[o]||(t[o]={label:s,fields:{}});let c=o_(a.fields||a,t,e);Object.entries(c).forEach(([e,r])=>{t[o].fields[e]=a_(t[o].fields[e],r),n[e]=a_(n[e],r)})}}else if(typeof e.tabs==`object`)for(let[r,i]of Object.entries(e.tabs)){let a=typeof i==`object`&&i?i:{label:String(i)},o=a.label||r;t[r]||(t[r]={label:o,fields:{}});let s=o_(a.fields||[],t,e);Object.entries(s).forEach(([e,i])=>{t[r].fields[e]=a_(t[r].fields[e],i),n[e]=a_(n[e],i)})}}if(e.fields){let r=o_(e.fields,t,e);Object.entries(r).forEach(([e,t])=>{n[e]=a_(n[e],t)}),Object.keys(t).length===0||!t.settings&&Object.keys(r).length>0?t.settings={label:`Settings`,fields:r}:t.settings&&Object.keys(r).length>0&&Object.entries(r).forEach(([e,n])=>{t.settings.fields[e]=a_(t.settings.fields[e],n)})}e.tabs=t,e.fields=n}function l_(){let e={},t={...Jg,...t_};for(let n in t){let r=t[n]?.default||``,i=Vg.parse(r);if(!i)continue;c_(i);let a=n_(n),o=i.id||a;i.id=o,e[o]=i}return e}function u_(){let e={},t={...Hg,...Yg};for(let n in t){let r=t[n]?.default||``,i=Vg.parse(r);if(!i)continue;c_(i),i.inTree=i.inTree===!0,i.inVault=i.inVault!==!1,i.hasCanvas=i.hasCanvas===!0,i.allowedBlocks=i.allowedBlocks||i.allowedElements||[],i.allowedLayouts=i.allowedLayouts||[];let a=n_(n),o=i.id||a;i.id=o,e[o]=i}return e}function d_(){let e={},t={...Ug,...Xg};for(let n in t){let r=t[n]?.default||``,i=Vg.parse(r);if(!i)continue;c_(i);let a=n_(n),o=i.id||a;i.id=o,e[o]=i}return e}function f_(){let e={},t={...Wg,...Zg};for(let n in t){let r=t[n]?.default||``,i=Vg.parse(r);if(!i)continue;i.fields=o_(i.fields);let a=n_(n),o=i.id||a;i.id=o,e[o]=i}return e}function p_(e,t=`main`,n=`Main Content`){let r={};for(let i in e){let a=e[i]?.default||``,o=Vg.parse(a);if(!o)continue;c_(o);let s=n_(i),c=o.id||s,l={};if(o.regions&&typeof o.regions==`object`)for(let[e,t]of Object.entries(o.regions)){let n=t;l[e]={label:n?.label||e,inherit:n?.inherit??n?.inherited??!1,allowedBlocks:n?.allowedBlocks||n?.allowedElements||[],...n}}else l[t]={label:n};r[c]={...o,id:c,label:o.label||c,layout:o.layout||{columns:`1fr`,areas:[[t]]},regions:l,fields:o.fields||{},tabs:o.tabs||{}}}return r}function m_(){return p_({...Gg,...Qg},`content`,`Content`)}function h_(){return p_({...Kg,...$g})}var g_=L(!1),__=L(`Unsaved Changes`),v_=L(`You have unsaved changes. Are you sure you want to discard them?`),y_=L(`Discard Changes`),b_=L(`Keep Editing`),x_;function S_(){return{isOpen:g_,title:__,message:v_,confirmLabel:y_,cancelLabel:b_,confirmDiscard:(e,t,n,r)=>(e&&(v_.value=e),t&&(__.value=t),y_.value=n||`Discard Changes`,b_.value=r||`Keep Editing`,g_.value=!0,new Promise(e=>{x_=e})),handleConfirm:()=>{g_.value=!1,x_&&x_(!0)},handleCancel:()=>{g_.value=!1,x_&&x_(!1)}}}var C_=`kama_cms_offline_queue`,w_=new Map,T_=new Map,E_=L({hasConflict:!1,nodeId:null,serverData:null});function D_(){let{isPendingOfflineSave:e,isDocumentUnverified:t}=Hv(),n=()=>{if(typeof window>`u`)return{};try{let e=localStorage.getItem(C_);return e?JSON.parse(e):{}}catch(e){return console.warn(`āš ļø Failed to parse offline queue from LocalStorage:`,e),{}}},r=(t,r)=>{if(!(typeof window>`u`))try{let i=n();i[String(t)]={data:JSON.parse(JSON.stringify(r)),timestamp:Date.now()},localStorage.setItem(C_,JSON.stringify(i)),e.value=!0}catch(e){console.error(`āŒ Failed to persist offline draft to storage:`,e)}},i=e=>n()[String(e)]||null,a=t=>{if(!(typeof window>`u`))try{let r=n();delete r[String(t)],localStorage.setItem(C_,JSON.stringify(r));let i=Object.keys(r);e.value=i.length>0}catch(e){console.warn(`āš ļø Failed to clear offline draft from storage:`,e)}},o=e=>{t.value=e},s=async t=>{let r=n(),i=Object.keys(r);if(i.length===0){e.value=!1;return}e.value=!0;for(let e of i)try{await t(e)&&a(e)}catch(t){console.error(`āŒ Auto-sync failed for node ${e}:`,t)}let o=Object.keys(n());e.value=o.length>0},c=e=>w_.get(String(e)),l=(e,t)=>{w_.set(String(e),{node:JSON.parse(JSON.stringify(t.node)),blocks:JSON.parse(JSON.stringify(t.blocks)),regionMeta:JSON.parse(JSON.stringify(t.regionMeta))}),String(E_.value.nodeId)===String(e)&&m()},u=e=>{w_.delete(String(e)),a(e)},d=e=>T_.get(e),f=(e,t)=>{T_.set(e,JSON.parse(JSON.stringify(t)))},p=e=>{T_.clear();let t=String(e);for(let[e]of w_.entries())e!==t&&w_.delete(e)},m=()=>{E_.value={hasConflict:!1,nodeId:null,serverData:null}};return{conflictState:E_,getCachedDocument:c,saveToCache:l,clearCache:u,invalidateAfterSave:p,clearConflict:m,evaluateServerResponse:(e,t,n)=>{let r=c(e);if(i(e))return E_.value={hasConflict:!0,nodeId:e,serverData:t},{action:`show_conflict_warning`};if(!r)return n?(E_.value={hasConflict:!0,nodeId:e,serverData:t},{action:`show_conflict_warning`}):{action:`update_silently`};let a=new Date(r.node.updatedAt||0).getTime();return new Date(t.node.updatedAt||0).getTime()>a&&n?(E_.value={hasConflict:!0,nodeId:e,serverData:t},{action:`show_conflict_warning`}):{action:`update_silently`}},resolveWithServer:e=>{if(!E_.value.serverData||!E_.value.nodeId)return;let t=E_.value.serverData,n=E_.value.nodeId;a(n),l(String(n),t),e(t),m()},resolveWithLocal:()=>{m()},getCachedInheritedRegion:d,setCachedInheritedRegion:f,persistOfflineDraft:r,getPersistedOfflineDraft:i,clearPersistedOfflineDraft:a,processOfflineQueue:s,markUnverified:o}}var O_={"Content-Type":`application/json`},k_={async getNode(e){return fetch(`/api/cms/nodes.json?id=${e}`)},async getInheritedRegion(e,t,n,r){let i=r?`&channelId=${r}`:``;return fetch(`/api/v1/node/${encodeURIComponent(e)}?treeId=${t}&lang=${n}&preview=true${i}`)},async saveNode(e){return fetch(`/api/cms/nodes.json`,{method:`POST`,headers:O_,body:JSON.stringify({node:e})})},async createInTree(e){return fetch(`/api/cms/tree.json`,{method:`POST`,headers:O_,body:JSON.stringify(e)})},async publishNode(e){return fetch(`/api/cms/nodes/publish`,{method:`POST`,headers:O_,body:JSON.stringify({id:e})})},async deleteNode(e){return fetch(`/api/cms/nodes.json?id=${e}`,{method:`DELETE`})},async restoreNode(e){return fetch(`/api/cms/nodes/restore`,{method:`POST`,headers:O_,body:JSON.stringify({id:e})})},async purgeNode(e){return fetch(`/api/cms/nodes/purge?id=${e}`,{method:`DELETE`})},async toggleVisibility(e,t){return fetch(`/api/cms/nodes.json`,{method:`POST`,headers:O_,body:JSON.stringify({node:{id:e,isHidden:t}})})}},A_=L(typeof navigator<`u`&&!navigator.onLine),j_=L(A_.value?`offline`:`online`),M_=L(!1),N_=L(!1),P_=L(null),F_=L(!1),I_=L(!1);typeof window<`u`&&(window.addEventListener(`online`,()=>{A_.value=!1,j_.value=`online`;let e=D_();e.processOfflineQueue(async t=>{try{let n=e.getPersistedOfflineDraft(t);if(!n)return!0;let r=n.data,i=[];Object.entries(r.blocks||{}).forEach(([e,t])=>{r.regionMeta?.[e]?.isInherited||t.forEach((t,n)=>{i.push({instanceId:String(t.instanceId||t.id),componentId:t.componentId||t.elementType||`text-block`,elementType:t.componentId||t.elementType||`text-block`,region:e,sortOrder:n,data:t.data||{}})})});let a={id:typeof t==`number`?t:Number(t)||null,...r.node,blocks:i};return delete a.isNew,delete a._draftParentId,delete a._isTreeDraft,delete a.trees,(await k_.saveNode(a)).ok}catch{return!1}})}),window.addEventListener(`offline`,()=>{A_.value=!0,j_.value=`offline`}));var L_=L({type:`dashboard`}),R_=L(`content`),z_=L(!1),B_=L([]),V_=L(null),H_=L(``),U_=L(`en`),W_=L([]),G_=L(null),K_=L(``),q_=L([]),J_=L([]),Y_=L(`all`),X_=L(``),Z_=L(`updatedAt`),Q_=L(`DESC`),$_=L(null),ev=L({}),tv=L(null),nv=L(null),rv=L({}),iv=L({}),av=L({}),ov=L({}),sv=L({}),cv=L(!1),lv=L(!1),uv=L(!1),dv=()=>({id:``,title:``,slug:``,nodeType:`node`,channelId:``,language:`en`,isHidden:!1,status:`draft`,publishedAt:null,children:[],disabledRegions:{}}),fv=L(dv()),pv=L({}),mv=L({}),hv=L(null),gv=L({}),_v=L(``),vv=L(``),yv=L(``),bv=L({total:0,byType:[]}),xv=L(!1),Sv=()=>{xv.value=!1},Cv=K(()=>L_.value.type===`dashboard`?`none`:L_.value.type),wv=K(()=>L_.value.type===`node`&&L_.value.id||null),Tv=K(()=>M_.value),Ev=K(()=>fv.value?.id?fv.value.status===`draft`||Ov.value:!1),Dv=(e,t)=>{if(!e)return{};let n={};for(let[t,r]of Object.entries(e))t!==`isHidden`&&t!==`hidden`&&t!==`channels`&&t!==`trees`&&(n[t]=r&&typeof r==`object`&&typeof r.id==`string`&&r.id.startsWith(`ast_`)?r.id:r);let r=e.nodeType||e.contentType,i=r?t[r]:null;if(i?.fields)for(let[e,t]of Object.entries(i.fields))t?.liveSync===!0&&delete n[e];return n},Ov=K(()=>{if(uv.value||!_v.value)return!1;let e=JSON.stringify({node:Dv(fv.value,iv.value),blocks:pv.value}),t=JSON.parse(_v.value||`{}`);return e!==JSON.stringify({node:Dv(t.node||{},iv.value),blocks:t.blocks||{}})}),kv=K(()=>!vv.value||!V_.value?!1:JSON.stringify(V_.value)!==vv.value),Av=K(()=>!yv.value||!G_.value?!1:JSON.stringify(G_.value)!==yv.value),jv=async()=>{let{confirmDiscard:e}=S_(),t=fv.value?.isNew===!0&&String(fv.value?.id||``).startsWith(`draft-`),n=!!(fv.value?.title||``).trim(),r=Object.values(pv.value||{}).some(e=>e.length>0),i=n||r,a=Ov.value&&(!t||i);return Cv.value===`node`&&(a||N_.value)?await e(`You have unsaved changes on the active document. Are you sure you want to discard them?`,`Discard Document Changes?`,`Discard Changes`,`Keep Editing`):!0},Mv=async(e,t=!1)=>{!t&&!await jv()||(L_.value=e,e.type!==`node`&&(fv.value=dv(),_v.value=``,pv.value={}),e.type!==`channel`&&(V_.value=null,vv.value=``),e.type!==`tree`&&(G_.value=null,yv.value=``))},Nv=async(e,t=!1)=>{e===`none`?await Mv({type:`dashboard`},t):await Mv({type:e},t)},Pv=(e=!1)=>Nv(`none`,e),Fv=(e,t=!1)=>Mv({type:`node`,id:e},t),Iv=(e,t=!1)=>Mv({type:`channel`,id:e},t),Lv=(e,t=!1)=>Mv({type:`tree`,id:e},t),Rv=()=>{fv.value=dv(),pv.value={},mv.value={},hv.value=null,gv.value={},_v.value=``,uv.value=!1,M_.value=!1},zv=(e,t,n)=>{if(!e&&!n)return;let r=t=>e&&String(t.id)===String(e)||n&&t.treeNodeId&&String(t.treeNodeId)===String(n);fv.value&&r(fv.value)&&Object.assign(fv.value,t);let i=e=>{if(Array.isArray(e))for(let n=0;n<e.length;n++)r(e[n])&&Object.assign(e[n],t),e[n].children&&e[n].children.length>0&&i(e[n].children)};if(i(q_.value),Array.isArray(J_.value))for(let e=0;e<J_.value.length;e++)r(J_.value[e])&&Object.assign(J_.value[e],t)},Bv=e=>{e.nodes&&(iv.value=e.nodes),e.trees&&(rv.value=e.trees),e.channels&&(ev.value=e.channels),(e.blocks||e.elements)&&(av.value=e.blocks||e.elements),ov.value=e.nodeLayouts&&Object.keys(e.nodeLayouts).length>0?e.nodeLayouts:m_(),sv.value=e.blockLayouts&&Object.keys(e.blockLayouts).length>0?e.blockLayouts:h_(),e.channelTemplate!==void 0&&($_.value=e.channelTemplate),e.userTemplate!==void 0&&(tv.value=e.userTemplate),e.treeTemplate!==void 0&&(nv.value=e.treeTemplate),lv.value=!0},Vv=async(e=`/api/cms/schemas.json`)=>{if(!cv.value){cv.value=!0;try{let t=await fetch(e,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Failed to load schemas`);Bv(await t.json())}catch(e){console.warn(`āš ļø API failed to load schemas, using local fallbacks`,e),iv.value=u_(),rv.value=d_(),ev.value=l_(),av.value=f_(),ov.value=m_(),sv.value=h_(),lv.value=!0}finally{cv.value=!1}}};function Hv(){return{isOffline:A_,connectionStatus:j_,isDocumentUnverified:M_,isPendingOfflineSave:N_,isReadOnlyMode:Tv,isSaving:F_,isAutoSavePending:I_,blockClipboard:P_,activeView:L_,activeViewMode:Cv,activeContentId:wv,setViewMode:Nv,navigateTo:Mv,goToDashboard:Pv,openNode:Fv,openChannel:Iv,openTree:Lv,activeTab:R_,shouldFocusTitle:z_,allChannels:B_,activeChannelSettings:V_,selectedChannelId:H_,selectedLanguage:U_,availableTrees:W_,activeTreeSettings:G_,selectedTreeId:K_,nodeTree:q_,vaultNodes:J_,currentVaultType:Y_,currentVaultSearch:X_,currentVaultSort:Z_,currentVaultOrder:Q_,channelTemplateSchema:$_,channelSchemas:ev,userTemplateSchema:tv,treeTemplateSchema:nv,treeSchemas:rv,nodeSchemas:iv,blockSchemas:av,nodeLayoutSchemas:ov,blockLayoutSchemas:sv,isSchemasLoading:cv,isSchemasLoaded:lv,setSchemas:Bv,fetchSchemas:Vv,isDocumentLoading:uv,activeNode:fv,resetActiveNode:Rv,isNodeDirty:Ov,isChannelDirty:kv,isTreeDirty:Av,hasUnpublishedChanges:Ev,nodeSnapshot:_v,channelSnapshot:vv,siteSnapshot:vv,treeSnapshot:yv,updateNodeInState:zv,blocks:pv,regionMeta:mv,selectedBlock:hv,validationErrors:gv,vaultStats:bv,hasLoadedStats:xv,invalidateStats:Sv,confirmDiscardUnsaved:jv}}var Uv=e=>e==null||typeof e==`string`&&e.trim()===``,Wv={required:(e,t,n)=>(t===!0||String(t).toLowerCase()===`true`)&&Uv(e)?n.rules?.customMessage||`${n.label||`This field`} is required.`:``,min:(e,t,n)=>Uv(e)||typeof t!=`number`?``:typeof e==`number`&&e<t?n.rules?.customMessage||`${n.label||`Field`} must be at least ${t}.`:typeof e==`string`&&e.length<t?n.rules?.customMessage||`${n.label||`Field`} must be at least ${t} characters.`:``,max:(e,t,n)=>Uv(e)||typeof t!=`number`?``:typeof e==`number`&&e>t?n.rules?.customMessage||`${n.label||`Field`} cannot exceed ${t}.`:typeof e==`string`&&e.length>t?n.rules?.customMessage||`${n.label||`Field`} cannot exceed ${t} characters.`:``,email:(e,t,n)=>t!==!0&&String(t).toLowerCase()!==`true`||Uv(e)||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(e))?``:n.rules?.customMessage||`Please enter a valid email address.`,pattern:(e,t,n)=>{if(Uv(e)||!t||typeof t!=`string`)return``;try{if(!new RegExp(t).test(String(e)))return n.rules?.customMessage||`${n.label||`Field`} format is invalid.`}catch{console.warn(`[Validators] Invalid pattern for ${n.label||`field`}:`,t)}return``},unique:async(e,t,n,r)=>(t!==!0&&String(t).toLowerCase()!==`true`||Uv(e),``),uniqueSibling:async(e,t,n,r)=>(t!==!0&&String(t).toLowerCase()!==`true`||Uv(e),``)};function Gv(e,t){Wv[e]=t}function Kv(){let e=Object.assign({"../../definitions/validators/iban.ts":f,"../../definitions/validators/magic-word.ts":m});for(let t in e){let n=e[t];if(!n)continue;let r=t.split(`/`).pop()?.replace(/\.ts$/,``)||``;for(let[e,t]of Object.entries(n))typeof t==`function`&&Gv(e==="default"?r:e,t)}}Kv();function qv(e,t,n){if(!n||typeof n!=`object`)return``;let r=n.rules||{},i={fieldKey:e};if((n.required===!0||String(n.required).toLowerCase()===`true`||r.required===!0||String(r.required).toLowerCase()===`true`)&&Uv(t))return r.customMessage||`${n.label||e} is required.`;for(let[e,a]of Object.entries(r)){if(e===`customMessage`||e===`uniqueMessage`||e===`unique`||e===`uniqueSibling`||e===`required`)continue;let r=Wv[e];if(r){let e=r(t,a,n,i);if(typeof e==`string`&&e!==``)return e}}return``}async function Jv(e,t,n,r){if(!n||typeof n!=`object`)return``;let i=qv(e,t,n);if(i)return i;let a={...n.rules};n.unique!==void 0&&a.unique===void 0&&(a.unique=n.unique);let o={fieldKey:e,entityType:r?.entityType,excludeId:r?.excludeId,formData:r?.formData};for(let[e,r]of Object.entries(a)){if(e===`customMessage`||e===`uniqueMessage`)continue;let i=Wv[e];if(i){let e=await i(t,r,n,o);if(e)return e}}return``}function Yv(e){for(let t in e){let n=e[t];if(n)for(let[e,t]of Object.entries(n))typeof t==`function`&&Gv(e,t)}}function Xv(){let{validationErrors:e}=Hv(),t=(e,t)=>{if(e)return t in e?e[t]:t.split(`.`).reduce((e,t)=>e&&e[t]!==void 0?e[t]:void 0,e)};return{validateAgainstSchema:async(n,r,i)=>{let a={};if(!n||!r)return e.value=a,!0;let o={...r.fields||{}};if(r.tabs&&typeof r.tabs==`object`&&Object.values(r.tabs).forEach(e=>{e?.fields&&(Array.isArray(e.fields)?e.fields.forEach(e=>{typeof e==`object`&&e&&Object.entries(e).forEach(([e,t])=>{o[e]={...o[e]||{},...t}})}):typeof e.fields==`object`&&Object.entries(e.fields).forEach(([e,t])=>{o[e]={...o[e]||{},...t}}))}),Object.keys(o).length===0)return e.value=a,!0;let s=n.id,c=typeof s==`number`||s&&!String(s).startsWith(`draft-`)?String(s):``;for(let[e,r]of Object.entries(o)){if(!r||typeof r!=`object`)continue;let o=await Jv(e,t(n,e),r,{entityType:i,excludeId:c,formData:n});o&&(a[e]=o)}return e.value=a,Object.keys(a).length===0}}}var Zv=null,Qv=null;function $v(){let{allChannels:e,selectedChannelId:t,availableTrees:n,channelSchemas:r,treeSchemas:i}=Hv(),a=async()=>{Zv?.abort(),Zv=new AbortController;try{let[n,i]=await Promise.all([fetch(`/api/cms/schemas.json`,{signal:Zv.signal}),fetch(`/api/cms/channels.json`,{signal:Zv.signal})]);if(n.ok){let e=await n.json();e.channelSchemas&&(r.value=e.channelSchemas)}if(i.ok){let n=await i.json();e.value=n.channels||[],!t.value&&n.channels?.length>0&&(t.value=String(n.channels[0].id))}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[CMS Sync] Failed to fetch channels:`,e)}},o=async()=>{Qv?.abort(),Qv=new AbortController;try{let[e,t]=await Promise.all([fetch(`/api/cms/schemas.json`,{signal:Qv.signal}),fetch(`/api/cms/trees.json`,{signal:Qv.signal})]);if(e.ok){let t=await e.json();t.treeSchemas&&(i.value=t.treeSchemas)}if(t.ok){let e=await t.json();n.value=Array.isArray(e)?e:[]}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[CMS Sync] Failed to load trees:`,e)}};return{fetchChannels:a,fetchTrees:o,syncSystemMetadata:async()=>{await Promise.all([a(),o()])}}}function ey(e){return e===!0||e===1||String(e)===`true`||String(e)===`1`}function ty(e){if(!e)return{isDraft:!1,isUnpublishedDraft:!1,isHidden:!1,isScheduled:!1,isCurrentlyVisible:!1,hasUnpublishedChanges:!1,statusBadge:`active`,badgeLabel:`Unknown`};let t=!!(e.isNew||!e.id||String(e.id).startsWith(`draft-`)),n=!t&&e.status===`draft`&&!e.publishedAt,r=ey(e.isHidden)||ey(e.disabled),i=ey(e.hasUnpublishedChanges)||!!e.publishedAt&&(e.status===`draft`||!e.status),a=e.startShowingAt?new Date(e.startShowingAt).getTime():null,o=e.stopShowingAt?new Date(e.stopShowingAt).getTime():null,s=!!(a||o),c=Date.now(),l=!0,u=`valid`;a&&c<a?(l=!1,u=`pending`):o&&c>o&&(l=!1,u=`expired`);let d=!t&&!n&&!r&&l,f=`active`,p=`Visible`;return t?(f=`draft`,p=`Unsaved`):n?(f=`unpublished_draft`,p=`Draft`):i?(f=`unpublished_changes`,p=`Unpublished Changes`):r?(f=`hidden`,p=`Hidden`):u===`pending`?(f=`scheduled_pending`,p=`Scheduled`):u===`expired`&&(f=`scheduled_expired`,p=`Expired`),{isDraft:t,isUnpublishedDraft:n,isHidden:r,isScheduled:s,isCurrentlyVisible:d,hasUnpublishedChanges:i,statusBadge:f,badgeLabel:p}}function ny(e,t){let n=e.value||{};return Object.keys(n).length===0&&(n=t(),e.value=n),n}function ry(e,t){if(t&&e[t])return t;let n=Object.keys(e||{});return n.length===1?n[0]:``}function iy(e,t){let n={...t?.fields||{},...e?.fields||{}};return e?.tabs&&Object.values(e.tabs).forEach(e=>{e?.fields&&(n={...n,...e.fields})}),n}function ay(e){return Object.values(e||{}).map(e=>({value:e.id,label:e.label||e.id}))}function oy(e,t=!1){let n=t?`label`:`title`;if(!e)return[{key:n,config:{type:`text`,label:`Page Title`}}];let r=iy(e),i=[];for(let[e,t]of Object.entries(r))(t?.showAsEditorTitle===!0||String(t?.showAsEditorTitle).toLowerCase()===`true`)&&i.push({key:e,config:{...t}});if(i.length===0){let t=r[n]?{...r[n]}:{type:`text`,label:e.label||`Page Title`};i.push({key:n,config:t})}return i}var sy=0,cy=0,ly=L({});function uy(){let{allChannels:e,selectedChannelId:t,selectedLanguage:n,availableTrees:r,activeTreeSettings:i,selectedTreeId:a,nodeTree:o,vaultNodes:s,treeTemplateSchema:c,treeSchemas:l,activeNode:u,blocks:d,regionMeta:f,selectedBlock:p,validationErrors:m,nodeSnapshot:h,treeSnapshot:g,activeTab:_,shouldFocusTitle:v,setViewMode:y,currentVaultType:b,currentVaultSearch:x,currentVaultSort:S,currentVaultOrder:C,isTreeDirty:w,confirmDiscardUnsaved:T}=Hv(),{validateAgainstSchema:E}=Xv(),{fetchTrees:D,fetchChannels:ee,syncSystemMetadata:te}=$v(),O=L(!1),k=L(!0),ne=L(0),re=()=>ny(l,d_),ie=()=>{g.value=JSON.stringify(i.value||{})},ae=K(()=>{if(!t.value||t.value===`all`)return r.value.map(e=>({id:e.id,key:e.key,label:e.label||e.key||`Tree ${e.id}`}));let n=e.value.find(e=>String(e.id)===String(t.value));return!n||!Array.isArray(n.trees)?[]:n.trees.map(e=>{let t=typeof e==`object`?e.treeId||e.id:e;if(!t)return null;let n=r.value.find(e=>String(e.id)===String(t)||e.key===t);return n?{id:n.id,key:n.key,label:n.label||n.key||`Tree ${n.id}`}:null}).filter(Boolean)}),A=(e,t,n=null)=>{for(let r of e){if(String(r.id)===String(t)||String(r.treeNodeId)===String(t))return n;if(r.children&&r.children.length>0){let e=A(r.children,t,r);if(e)return e}}return null},oe=(e,t)=>{if(!e||!Array.isArray(e))return!1;for(let n of e){if(String(n.id)===String(t.id)||n.treeNodeId&&String(n.treeNodeId)===String(t.treeNodeId))return n.disabledRegions={...t.disabledRegions||{}},t.channels&&(n.channels=t.channels),t.title&&(n.title=t.title),t.slug&&(n.slug=t.slug),t.isHidden!==void 0&&(n.isHidden=ey(t.isHidden)),!0;if(n.children&&n.children.length>0&&oe(n.children,t))return!0}return!1},se=K(()=>!u.value?.id&&!u.value?.treeNodeId?!1:!!A(o.value,u.value.id||u.value.treeNodeId||``)),ce=e=>ly.value[e]||[],le=async e=>{if(e)try{let r=t.value&&t.value!==`all`?`&channelId=${t.value}`:``,i=await fetch(`/api/cms/tree.json?treeId=${e}&lang=${n.value}&preview=true${r}`);if(i.ok){let t=await i.json(),n=Array.isArray(t)?t:t.tree||[],r=new Set,s=[];for(let e of n){if(e.deletedAt&&String(e.deletedAt).trim()!==``)continue;let t=String(e.treeNodeId||e.id);r.has(t)||(r.add(t),s.push({...e,isHidden:ey(e.isHidden)}))}ly.value[e]=s,String(e)===String(a.value)&&(o.value=s)}}catch(t){console.error(`[CMS] Failed to fetch nodes for tree ${e}:`,t)}},ue=async()=>{if(!a.value){o.value=[];return}++sy,await le(a.value)},j=async(e,r)=>{ly.value[e]=r,String(e)===String(a.value)&&(o.value=r);try{let i={treeId:e,language:n.value,tree:r};t.value&&t.value!==`all`&&(i.channelId=t.value);let a=await fetch(`/api/cms/tree.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(`[Tree Save] HTTP ${a.status}: ${e.error||`Unknown error`}`)}}catch(t){throw console.error(`[Tree Sync] Failed to save node order for tree ${e}:`,t),t}},de=async()=>{a.value&&await j(a.value,ly.value[a.value]||o.value)},fe=async e=>{let n=!1,r=``,i=``;typeof e==`string`?(b.value=e,n=!0):e&&typeof e==`object`&&(n=e.reset??!1,e.type!==void 0&&(b.value=e.type),e.search!==void 0&&(x.value=e.search),e.sort!==void 0&&(S.value=e.sort),e.order!==void 0&&(C.value=e.order),e.ensureItemId&&(r=e.ensureItemId),e.assetId&&(i=e.assetId));let a=Array.isArray(b.value)&&b.value.length>0?b.value.join(`,`):b.value||`all`,o=x.value||``;if(!n&&O.value||!n&&!k.value)return;let c=++cy;n&&(ne.value=0,k.value=!0,s.value=[]),O.value=!0;try{let e=new URLSearchParams({limit:`50`,offset:String(ne.value),sort:S.value,order:C.value});a&&a!==`all`&&e.append(`type`,a),o.trim()&&e.append(`q`,o.trim()),t.value&&t.value!==`all`&&e.append(`channelId`,t.value),r&&e.append(`ensureItemId`,r),i&&e.append(`assetId`,i);let l=await fetch(`/api/cms/nodes.json?${e.toString()}`);if(c!==cy)return;if(!l.ok)throw Error(`Failed to fetch vault nodes (${l.status})`);let u=await l.json(),d=(Array.isArray(u)?u:u.items||[]).map(e=>({...e,isHidden:ey(e.isHidden)}));k.value=!Array.isArray(u)&&!!u.hasMore,s.value=n?d:[...s.value,...d],ne.value+=d.length}catch(e){c===cy&&console.error(`[CMS] Failed to fetch vault nodes:`,e)}finally{c===cy&&(O.value=!1)}},M=async n=>{if(!t.value||t.value===`all`)return;let i=e.value.findIndex(e=>String(e.id)===String(t.value));if(i>-1){let t=e.value[i],o=Array.isArray(t.trees)?[...t.trees]:[],s=r.value.find(e=>String(e.id)===String(n)||e.key===n),c=s?s.id:n,l=s?s.key:String(n);o.some(e=>String(typeof e==`object`?e.treeId||e.id:e)===String(c)||(typeof e==`object`?e.treeId||e.id:e)===l)||(o.push({treeId:c,key:l}),(await fetch(`/api/cms/channels.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,trees:o})})).ok&&await ee()),a.value=String(c),await ue()}},N=async n=>{if(!t.value||t.value===`all`)return;let r=e.value.findIndex(e=>String(e.id)===String(t.value));if(r>-1){let t={...e.value[r]};Array.isArray(t.trees)&&(t.trees=t.trees.filter(e=>String(typeof e==`object`?e.treeId||e.id:e)!==String(n)),await fetch(`/api/cms/channels.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),await ee());let i=ae.value;a.value=i.length>0?String(i[0].id):``,await ue()}},pe=async(n,r)=>{if(!t.value||t.value===`all`)return;let i=e.value.findIndex(e=>String(e.id)===String(t.value));if(i>-1){let t={...e.value[i]},a=Array.isArray(t.trees)?[...t.trees]:[];if(n<0||n>=a.length||r<0||r>=a.length)return;let[o]=a.splice(n,1);a.splice(r,0,o),t.trees=a,e.value[i]=t;try{await fetch(`/api/cms/channels.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}catch(e){console.error(`Failed to reorder channel trees:`,e)}}},me=async()=>{i.value=null,g.value=``,await y(`none`,!0)};return{currentChannelTrees:ae,hasParentNode:se,isLoading:O,hasMore:k,isTreeDirty:w,treeNodesMap:ly,getNodesForTree:ce,fetchNodeTreeForId:le,saveTreeOrderForId:j,reorderChannelTrees:pe,fetchTrees:D,fetchNodeTree:ue,fetchVaultNodes:fe,linkTreeToChannel:M,unlinkTreeFromChannel:N,handleAddNewTree:async()=>{if(!await T())return!1;let e=re(),n=ry(e),r={id:`draft-${Date.now()}`,isNew:!0,key:``,label:``,treeType:n,channels:t.value&&t.value!==`all`?[Number(t.value)||t.value]:[]};if(n&&e[n]){let t=iy(e[n],c.value);for(let[e,n]of Object.entries(t))r[e]===void 0&&(r[e]=n?.default??``)}return i.value=r,ie(),m.value={},await y(`tree`,!0),!0},cancelNewTree:me,saveTreeSettings:async()=>{if(!i.value)return!1;m.value={};let e=re(),n=!i.value.id||String(i.value.id).startsWith(`draft-`),r=i.value.treeType||Object.keys(e)[0]||`navigation`,o=e[r]||{};if(!await E(i.value,{fields:iy(o,c.value)},`tree`))return!1;try{let e=i.value.id,o={...JSON.parse(JSON.stringify(i.value)),id:n?null:typeof e==`number`?e:Number(e)||null,treeType:r};delete o.isNew;let s=await fetch(`/api/cms/trees.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)});if(s.ok){let e=(await s.json()).id;return i.value.id=e,i.value.treeType=r,delete i.value.isNew,await te(),ie(),n&&t.value&&t.value!==`all`?await M(e):(a.value=String(e),await ue()),await y(`tree`,!0),!0}{let e=await s.json().catch(()=>({}));return s.status===409&&e.field&&(m.value={[e.field]:e.error||`This key is already in use.`}),!1}}catch(e){return console.error(`[CMS] Error saving tree settings:`,e),!1}},deleteTree:async t=>{let n=t||i.value?.id;if(n){if(String(n).startsWith(`draft-`)){await me();return}try{let t=await fetch(`/api/cms/trees.json?id=${n}`,{method:`DELETE`});if(t.ok){i.value=null,e.value.forEach(e=>{Array.isArray(e.trees)&&(e.trees=e.trees.filter(e=>{let t=typeof e==`object`?e.treeId||e.id:e;return String(t)!==String(n)}))}),await te();let t=ae.value;if(t.length>0){let e=String(t[0].id);a.value=e,await ue()}else a.value=``,o.value=[],await y(`none`,!0)}else{let e=await t.json().catch(()=>({}));alert(`Failed to delete tree. ${e.error||`Check server console.`}`)}}catch{alert(`Network error: Could not reach server to delete the tree.`)}}},saveTreeOrder:de,attachVaultNodeToTree:async(e,r=null)=>{if(!a.value)return alert(`Please select a Navigation Tree before attaching content.`);try{let i={action:`attach`,contentId:e,treeId:a.value,language:n.value,parentId:r?r.treeNodeId||r.id:null};t.value&&t.value!==`all`&&(i.channelId=t.value),(await fetch(`/api/cms/tree.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)})).ok&&(await ue(),await fe({reset:!0,ensureItemId:String(e)}))}catch(e){console.error(`[CMS] Failed to attach vault node to tree:`,e)}},detachTreeNode:async e=>{try{(await fetch(`/api/cms/tree.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`detach`,treeNodeId:e,treeId:a.value})})).ok&&await ue()}catch(e){console.error(`[CMS] Failed to detach tree node:`,e)}},findParentNodeInTree:A,updateNodeInTree:oe,handleTreeChange:async e=>{if(e?.added?.element?._isNew){if(!await y(`node`))return;let n=e.added.element;delete n._isNew,d.value={},f.value={},p.value=null;let r=ey(n.isHidden),i={...n,parentId:null,isHidden:r,status:`draft`,blocks:[]};t.value&&t.value!==`all`&&(i.channels=[t.value]),await fetch(`/api/cms/nodes.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),u.value={...n,isHidden:r,status:`draft`,isNew:!1,disabledRegions:{}},_.value=`content`,v.value=!0,h.value=JSON.stringify({node:u.value,blocks:d.value})}await de()},openTreeSettings:async e=>{if(!await T())return!1;let n=r.value.find(t=>String(t.id)===String(e)||t.key===e),o=n?.treeType||n?.type||Object.keys(l.value||{})[0]||`navigation`;return i.value=n?{...n,treeType:o,channels:Array.isArray(n.channels)?[...n.channels]:[]}:{id:null,key:String(e),label:String(e),treeType:o,channels:t.value&&t.value!==`all`?[Number(t.value)||t.value]:[]},a.value=String(n?n.id:e),ie(),m.value={},await y(`tree`,!0),!0},checkUnsavedChanges:T,updateTreeSnapshot:ie}}function dy(e){if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)e[t].isNew||String(e[t].id).startsWith(`draft-`)?e.splice(t,1):e[t].children&&e[t].children.length>0&&dy(e[t].children)}function fy(){let e=Hv(),t=uy(),{confirmDiscardUnsaved:n}=e,r=async()=>{if(!await n())return;dy(e.nodeTree.value),e.selectedBlock.value=null,e.setViewMode(`node`),e.validationErrors.value={};let t=e.selectedChannelId.value&&e.selectedChannelId.value!==`all`?Number(e.selectedChannelId.value)||e.selectedChannelId.value:``,r={id:`draft-${Date.now()}`,title:``,slug:``,nodeType:``,layoutId:`inherit`,channelId:t,channels:t?[t]:[],language:e.selectedLanguage.value,status:`draft`,children:[],isNew:!0,_draftParentId:null,_isTreeDraft:!0,disabledRegions:{}};e.nodeTree.value.push(r),e.activeNode.value=r,e.blocks.value={},e.regionMeta.value={},e.activeTab.value=`settings`,e.shouldFocusTitle.value=!0,Ty(e)},i=async t=>{if(!t)return;let n=t.dataJson||t;if(n&&typeof n==`object`){let t=JSON.parse(JSON.stringify(n));t.subpageLayoutId&&t.subpageLayoutId!==`inherit`&&(e.activeNode.value.resolvedLayoutId=t.subpageLayoutId);let r=new Set([`id`,`treeNodeId`,`contentId`,`parentId`,`_draftParentId`,`title`,`slug`,`children`,`isNew`,`nodeType`,`status`,`disabledRegions`]);Object.entries(t).forEach(([t,n])=>{!r.has(t)&&n!=null&&(e.activeNode.value[t]===void 0||e.activeNode.value[t]===``)&&(e.activeNode.value[t]=n)})}try{let{resolveInheritedRegion:r}=Ey(),i=String(e.selectedChannelId.value||``),a=String(e.selectedLanguage.value||`en`),o=n.subpageLayoutId;(!o||o===`inherit`)&&(o=n.resolvedLayoutId||n.layoutId);let s=o?e.nodeLayoutSchemas.value[o]:null,c=[];if(s?.regions)for(let[e,t]of Object.entries(s.regions)){let n=t.inherit||t.inherited;(n===`parent`||n===!0||String(n).toLowerCase()===`true`)&&c.push(e)}for(let n of c){let o=await r(t,n,i,a);o&&o.blocks&&o.blocks.length>0&&(e.blocks.value[n]=JSON.parse(JSON.stringify(o.blocks)),e.regionMeta.value[n]={isInherited:!0,inheritedFromId:String(o.inheritedFromId),inheritedFromTitle:o.inheritedFromTitle})}}catch(e){console.warn(`[Draft Hierarchy] Failed to resolve inherited region:`,e)}};return{handleAddRootNode:r,handleAddChild:async t=>{if(!await n())return;dy(e.nodeTree.value),e.selectedBlock.value=null,e.setViewMode(`node`),e.validationErrors.value={};let r=e.selectedChannelId.value&&e.selectedChannelId.value!==`all`?Number(e.selectedChannelId.value)||e.selectedChannelId.value:``,a=t.treeNodeId||t.id,o={id:`draft-${Date.now()}`,title:``,slug:``,nodeType:``,layoutId:`inherit`,channelId:r,channels:r?[r]:[],language:e.selectedLanguage.value,status:`draft`,children:[],isNew:!0,_draftParentId:a,_isTreeDraft:!0,disabledRegions:{}};t.children||=[],t.children.push(o),e.activeNode.value=o,e.blocks.value={},e.regionMeta.value={},e.activeTab.value=`settings`,e.shouldFocusTitle.value=!0,await i(t),Ty(e)},handleAddSibling:async r=>{if(!await n())return;dy(e.nodeTree.value),e.selectedBlock.value=null,e.setViewMode(`node`),e.validationErrors.value={};let a=r.treeNodeId||r.id||``,o=t.findParentNodeInTree(e.nodeTree.value,a),s=o?o.children:e.nodeTree.value,c=s?s.findIndex(e=>{if(e===r)return!0;let t=e.treeNodeId||e.id;return String(t)===String(a)}):-1,l=e.selectedChannelId.value&&e.selectedChannelId.value!==`all`?Number(e.selectedChannelId.value)||e.selectedChannelId.value:``,u={id:`draft-${Date.now()}`,title:``,slug:``,nodeType:``,layoutId:`inherit`,channelId:l,channels:l?[l]:[],language:e.selectedLanguage.value,status:`draft`,children:[],isNew:!0,_draftParentId:o?o.treeNodeId||o.id:null,_isTreeDraft:!0,disabledRegions:{}};s&&c!==-1?s.splice(c+1,0,u):s&&s.push(u),e.activeNode.value=u,e.blocks.value={},e.regionMeta.value={},e.activeTab.value=`settings`,e.shouldFocusTitle.value=!1,o&&await i(o),Ty(e)}}}var py=null,my=null;function hy(e){if(!e||typeof e!=`object`)return{};try{return JSON.parse(JSON.stringify(e))}catch{return{}}}function gy(e,t,n,r,i,a){let o=Hv(),s=uy(),c=D_(),{confirmDiscardUnsaved:l}=o,u=(e,t)=>{typeof window<`u`&&(window.dispatchEvent(new CustomEvent(`cms-node-updated`,{detail:{nodeId:e,action:t}})),t.startsWith(`asset-`)&&window.dispatchEvent(new CustomEvent(`cms-assets-updated`)))};ri(()=>o.activeNode.value?.nodeType,(e,t)=>{if(o.activeNode.value?.isNew&&e&&e!==t&&!Object.values(o.blocks.value||{}).some(e=>e.length>0)){let t=o.nodeSchemas.value[e];t&&by(o.activeNode.value,t),Ty(o)}});let d=async e=>{if(!await l())return!1;let t=r.value,n=Object.keys(t),i=e;if(i===void 0){let e=o.currentVaultType.value;if(typeof e==`string`&&e!==`all`&&n.includes(e))i=e;else if(Array.isArray(e)){let t=e.filter(e=>n.includes(e));t.length===1&&(i=t[0])}}let s=i?t[i]||o.nodeSchemas.value[i]:null,c=o.selectedChannelId.value&&o.selectedChannelId.value!==`all`?Number(o.selectedChannelId.value)||o.selectedChannelId.value:``,u={id:`draft-${Date.now()}`,isNew:!0,title:``,slug:``,nodeType:i||``,layoutId:`inherit`,channelId:c,language:o.selectedLanguage.value||`en`,status:`draft`,channels:c?[c]:[],disabledRegions:{},_isTreeDraft:!1};s&&by(u,s),o.activeNode.value=u,o.blocks.value={},o.regionMeta.value={},o.selectedBlock.value=null,Ty(o),o.validationErrors.value={};let d=a.value.find(e=>e.key!==`content`&&e.key!==`connections`)?.key||`settings`;return o.activeTab.value=d,o.setViewMode(`node`),o.shouldFocusTitle.value=!0,!0},f=async e=>await d(e),p=async()=>{o.activeNode.value.isNew=!1;let e=t=>{for(let n=t.length-1;n>=0;n--)t[n].isNew||String(t[n].id).startsWith(`draft-`)?t.splice(n,1):t[n].children&&e(t[n].children)};e(o.nodeTree.value),o.selectedBlock.value=null,o.resetActiveNode(),o.nodeTree.value.length>0?await t(o.nodeTree.value[0]):o.setViewMode(`none`,!0)},m=async()=>{if(o.isDocumentUnverified.value||o.isDocumentLoading.value)return;if(o.isOffline.value){c.persistOfflineDraft(o.activeNode.value.id,{node:o.activeNode.value,blocks:o.blocks.value,regionMeta:o.regionMeta.value}),Ty(o);return}let e=o.nodeSchemas.value[o.activeNode.value.nodeType],t=oy(e,o.activeViewMode.value===`channel`||o.activeViewMode.value===`tree`).map(e=>o.activeNode.value[e.key]).filter(e=>e!=null&&String(e).trim()!==``).join(` `),n=o.activeNode.value.slug?String(o.activeNode.value.slug).trim():``;n||=(t.trim()||`draft-page`).toLowerCase().replace(/[^a-z0-9\s-]/g,``).replace(/[\s-]+/g,`-`).replace(/^-+|-+$/g,``)||`draft-page-${Date.now()}`;let r=!!o.activeNode.value._isTreeDraft,i=o.activeNode.value.id||o.activeContentId.value,a=typeof i==`number`?i:Number(i)||null,s=o.activeNode.value.isNew||r||String(i||``).startsWith(`draft-`);if(!s&&!o.isNodeDirty.value&&!o.isPendingOfflineSave.value)return;let l={...o.activeNode.value};l.slug=n,l.status=`draft`,delete l.id,delete l.isNew,delete l._draftParentId,delete l._isTreeDraft,delete l.children,delete l.treeNodeId;let d=ey(o.activeNode.value.isHidden);l.isHidden=d;let f=o.selectedChannelId.value&&o.selectedChannelId.value!==`all`?Number(o.selectedChannelId.value)||o.selectedChannelId.value:null,p=xy(o.activeNode.value.channels).map(e=>typeof e==`string`&&!isNaN(Number(e))?Number(e):e);o.activeNode.value.channels===void 0&&f&&(p=[f]),l.channels=p,l.channelId=p.length>0?p[0]:``;let h=[];Object.entries(o.blocks.value||{}).forEach(([e,t])=>{o.regionMeta.value[e]?.isInherited||Array.isArray(t)&&t.forEach((t,n)=>{h.push({instanceId:String(t.instanceId||t.id||`block-${Date.now()}`),componentId:String(t.componentId||t.elementType||`text`),elementType:String(t.componentId||t.elementType||`text`),region:String(e||`content`),sortOrder:n,data:hy(t.data)})})});try{let e=null,t=null,i;if(i=s&&r?await k_.createInTree({action:`create`,title:l.title||`Untitled Page`,slug:n,nodeType:o.activeNode.value.nodeType,treeId:o.selectedTreeId.value,parentId:o.activeNode.value._draftParentId||null,channels:p,channelId:p.length>0?p[0]:null,isHidden:d,nodeData:{...l,status:`draft`,blocks:h}}):s?await k_.saveNode({id:null,...l,status:`draft`,blocks:h}):await k_.saveNode({id:a,...l,status:`draft`,blocks:h}),i.ok){let r=await i.json();e=r.id||r.nodeId||a,t=r.treeNodeId||null;let l=o.activeNode.value.id;if(o.activeNode.value.id=String(e),o.activeNode.value.slug=n,t?o.activeNode.value.treeNodeId=String(t):delete o.activeNode.value.treeNodeId,o.activeNode.value.isNew=!1,o.activeNode.value.status=`draft`,o.activeNode.value.channels=p,delete o.activeNode.value._isTreeDraft,delete o.activeNode.value._draftParentId,Ty(o),o.nodeTree.value&&t){let r=i=>{for(let a=0;a<i.length;a++){if(i[a]===o.activeNode.value||String(i[a].id)===String(l)||String(i[a].id).startsWith(`draft-`))return i[a].id=String(e),i[a].treeNodeId=String(t||e),i[a].slug=n,i[a].isNew=!1,delete i[a]._isTreeDraft,delete i[a]._draftParentId,!0;if(i[a].children&&r(i[a].children))return!0}return!1};r(o.nodeTree.value)}o.updateNodeInState(e,{slug:n,status:`draft`,isHidden:d},t||o.activeNode.value.treeNodeId),c.clearPersistedOfflineDraft(e),c.invalidateAfterSave(e),c.saveToCache(e,{node:o.activeNode.value,blocks:o.blocks.value,regionMeta:o.regionMeta.value}),o.invalidateStats(),u(e,s?`create`:`update`)}else{let e=await i.json().catch(()=>({}));if(i.status===409&&(e.field===`slug`||e.error?.toLowerCase().includes(`slug`)||e.error?.toLowerCase().includes(`exists`))){let e=Math.random().toString(36).substring(2,6),t=`${n}-${e}`;return o.activeNode.value.slug=t,typeof window<`u`&&window.dispatchEvent(new CustomEvent(`cms-toast`,{detail:{type:`warning`,message:`The URL slug "${n}" was already in use. It has been auto-appended to "${t}".`}})),o.validationErrors.value.slug&&delete o.validationErrors.value.slug,await m()}i.status===409&&e.field&&(o.validationErrors.value={...o.validationErrors.value,[e.field]:e.error||`This value is already in use.`})}}catch(e){console.error(`Network error auto-saving node draft:`,e),c.persistOfflineDraft(a||o.activeNode.value.id,{node:o.activeNode.value,blocks:o.blocks.value,regionMeta:o.regionMeta.value}),Ty(o)}},h=async()=>{o.isSaving.value=!0,o.isAutoSavePending.value=!1,py&&=(clearTimeout(py),null);try{my=m(),await my}finally{my=null,o.isSaving.value=!1}};return ri([()=>o.activeNode.value,()=>o.blocks.value],()=>{if(!o.activeNode.value?.id||o.isDocumentLoading.value||o.activeNode.value.isNew&&!o.activeNode.value.nodeType)return;let e=o.activeNode.value.isNew&&!(o.activeNode.value.title||``).trim();if(!o.isNodeDirty.value||e){o.isAutoSavePending.value=!1;return}o.isAutoSavePending.value=!0,py&&clearTimeout(py),py=setTimeout(()=>{h()},1e3)},{deep:!0}),{handleAddNewNode:d,createVaultNode:f,cancelNewNode:p,saveNewNode:async()=>await m(),saveNode:h,publishNode:async()=>{if(o.isDocumentUnverified.value||!await e())return!1;py||o.isAutoSavePending.value||o.isNodeDirty.value?await h():my&&await my;let t=o.activeNode.value.id||o.activeContentId.value,n=typeof t==`number`?t:Number(t)||null;if(!n)return!1;o.isSaving.value=!0;try{let e=await k_.publishNode(n);if(e.ok){let t=await e.json();return o.activeNode.value.status=`published`,o.activeNode.value.publishedAt=t.publishedAt,o.nodeTree.value&&s.updateNodeInTree(o.nodeTree.value,o.activeNode.value),o.updateNodeInState(n,{status:`published`,publishedAt:t.publishedAt},o.activeNode.value.treeNodeId),Ty(o),c.invalidateAfterSave(n),c.saveToCache(n,{node:o.activeNode.value,blocks:o.blocks.value,regionMeta:o.regionMeta.value}),o.invalidateStats(),o.activeNode.value.treeNodeId&&(await s.saveTreeOrder(),await s.fetchNodeTree()),await s.fetchVaultNodes({reset:!0,ensureItemId:String(n)}),u(n,`publish`),!0}}finally{o.isSaving.value=!1}return!1},deleteNode:async e=>{let t=e||o.activeNode.value?.id||o.activeContentId.value;if(!t||String(t).startsWith(`draft-`))return p(),!0;try{if((await k_.deleteNode(t)).ok)return c.invalidateAfterSave(t),o.invalidateStats(),o.nodeTree.value&&o.nodeTree.value.length>0&&await s.fetchNodeTree(),await s.fetchVaultNodes({reset:!0}),(String(o.activeNode.value?.id)===String(t)||String(o.activeNode.value?.treeNodeId)===String(t))&&p(),u(t,`delete`),!0}catch(e){console.error(`[CMS] Failed to delete node:`,e)}return!1},restoreNode:async e=>{if(!e)return!1;try{if((await k_.restoreNode(e)).ok)return o.invalidateStats(),await s.fetchVaultNodes({reset:!0}),u(e,`restore`),!0}catch(e){console.error(`[CMS] Failed to restore node:`,e)}return!1},purgeNode:async e=>{if(!e)return!1;try{if((await k_.purgeNode(e)).ok)return o.invalidateStats(),await s.fetchVaultNodes({reset:!0}),u(e,`purge`),!0}catch(e){console.error(`[CMS] Failed to purge node:`,e)}return!1},toggleNodeVisibility:async e=>{if(!e||!e.id||String(e.id).startsWith(`draft-`))return!1;let t=!ey(e.isHidden);try{if((await k_.toggleVisibility(e.id,t)).ok)return e.isHidden=t,o.updateNodeInState(e.id,{isHidden:t},e.treeNodeId),Ty(o),u(e.id,`update`),!0}catch(e){console.error(`[CMS] Failed to toggle node visibility:`,e)}return!1}}}var _y=0;function vy(e){return e&&{...e,isHidden:ey(e.isHidden)}}function yy(e,t=!1){if(!e)return``;let n=new Date,r=String(e).toLowerCase().trim(),i=e=>{let n=e=>e.toString().padStart(2,`0`),r=`${e.getFullYear()}-${n(e.getMonth()+1)}-${n(e.getDate())}`;return t?r:`${r}T${n(e.getHours())}:${n(e.getMinutes())}`};if(r===`now`||r===`today`)return i(n);let a=r.match(/^([+-])\s*(\d+)\s*(minute|hour|day|week|month|year)s?$/);if(a){let e=a[1]===`+`?1:-1,t=parseInt(a[2],10)*e,r=a[3],o=new Date(n);return r===`minute`?o.setMinutes(o.getMinutes()+t):r===`hour`?o.setHours(o.getHours()+t):r===`day`?o.setDate(o.getDate()+t):r===`week`?o.setDate(o.getDate()+t*7):r===`month`?o.setMonth(o.getMonth()+t):r===`year`&&o.setFullYear(o.getFullYear()+t),i(o)}return String(e)}function by(e,t){let n=e=>e==null||e===``,r=t=>{t&&Object.entries(t).forEach(([t,r])=>{r?.default!==void 0&&n(e[t])&&(e[t]=r.type===`datetime`||r.type===`date`?yy(r.default,r.type===`date`):r.default)})};r(t?.fields),t?.tabs&&Object.values(t.tabs).forEach(e=>r(e?.fields))}function xy(e){if(!e)return[];if(Array.isArray(e))return e.map(e=>typeof e==`object`&&e?e.id||e.channelId:e).filter(Boolean);if(typeof e==`string`)try{let t=JSON.parse(e);return Array.isArray(t)?xy(t):[e]}catch{return[e]}return[e]}function Sy(e,t,n,r){let i=e?.layoutId;if((!i||i===`inherit`)&&!e?.resolvedLayoutId&&n&&r){let t=r.findParentNodeInTree(n.nodeTree.value,e?._draftParentId||e?.parentId||``);for(;t;){if(t.subpageLayoutId&&t.subpageLayoutId!==`inherit`){i=t.subpageLayoutId;break}if(t.layoutId&&t.layoutId!==`inherit`){i=t.layoutId;break}if(t.resolvedLayoutId){i=t.resolvedLayoutId;break}t=r.findParentNodeInTree(n.nodeTree.value,t.parentId||``)}}if(!i||i===`inherit`){let n=e?.nodeType?t.nodeSchemas.value[e.nodeType]:null;i=e?.resolvedLayoutId||n?.defaultLayout}let a=i?t.nodeLayoutSchemas.value[i]:null;return a?.regions&&Object.keys(a.regions).length>0?a.regions:{content:{label:`Content`}}}var Cy=e=>e===`parent`||e===!0||String(e).toLowerCase()===`true`;function wy(e,t){let n=e.activeNode.value,r=n?.nodeType?e.nodeSchemas.value[n.nodeType]:null,i=n?.layoutId;(!i||i===`inherit`)&&(i=n?.resolvedLayoutId||r?.defaultLayout);let a=i?e.nodeLayoutSchemas.value[i]:null,o=a?.regions&&Object.keys(a.regions).length>0?a.regions:{content:{label:`Content`}},s=new Set(Object.keys(o)),c=t=>{Array.isArray(t)&&t.forEach(t=>{let n=t.componentId||t.elementType,r=e.blockLayoutSchemas.value[n];r?.regions&&Object.keys(r.regions).forEach(n=>{let r=`${t.instanceId||t.id}_${n}`;s.add(r),e.blocks.value[r]&&c(e.blocks.value[r])})})};return t&&Array.isArray(t)&&t.forEach(t=>{let n=t.componentId||t.elementType,r=e.blockLayoutSchemas.value[n];r?.regions&&Object.keys(r.regions).forEach(e=>{let n=`${t.instanceId||t.id}_${e}`;s.add(n)})}),Object.keys(o).forEach(t=>c(e.blocks.value[t]||[])),s}function Ty(e){if(!e.activeNode.value)return;wy(e).forEach(t=>{e.blocks.value[t]||(e.blocks.value[t]=[])}),e.activeNode.value.disabledRegions||(e.activeNode.value.disabledRegions={}),e.activeNode.value.channels||(e.activeNode.value.channels=[]);let t=Dv(JSON.parse(JSON.stringify(e.activeNode.value)),e.nodeSchemas.value),n=JSON.parse(JSON.stringify(e.blocks.value));e.nodeSnapshot.value=JSON.stringify({node:t,blocks:n})}function Ey(){let e=Hv(),t=uy(),n=D_(),r=fy(),{confirmDiscardUnsaved:i}=e,a=()=>Ty(e),o=K(()=>e.nodeSchemas.value[e.activeNode.value?.nodeType]||null),s=K(()=>Sy(e.activeNode.value,{nodeSchemas:e.nodeSchemas,nodeLayoutSchemas:e.nodeLayoutSchemas},e,t)),c=K(()=>{let t=[],n=e.activeNode.value,r=e.nodeSchemas.value[n?.nodeType];if(r){if(r.hasCanvas===!0&&t.push({key:`content`,label:`Content`}),r.tabs&&typeof r.tabs==`object`)for(let[e,n]of Object.entries(r.tabs)){let r=typeof n==`string`?n:n?.label||e;t.push({key:e,label:r})}t.filter(e=>e.key!==`content`).length===0&&t.push({key:`settings`,label:r.label||`Settings`}),t.push({key:`connections`,label:`Connections`})}return t}),l=K(()=>{let t={};for(let[n,r]of Object.entries(e.nodeSchemas.value||{})){let e=r.inTree;(e===!0||String(e)===`true`||e===1)&&(t[n]=r)}return t}),u=K(()=>Object.keys(l.value).map(e=>({value:e,label:l.value[e].label||e}))),d=K(()=>{let t={};for(let[n,r]of Object.entries(e.nodeSchemas.value||{}))r.inVault!==!1&&String(r.inVault)!==`false`&&(t[n]=r);return t}),f=K(()=>Object.keys(d.value).map(e=>({value:e,label:d.value[e].label||e}))),p=K(()=>{let t=e.activeNode.value||{};return!!(t.treeNodeId||t._isTreeDraft===!0||t.parentId||t._draftParentId)}),m=t=>{if(!e.activeNode.value?.nodeType)return t===`settings`||t===`content`||t===`node`?{nodeType:{label:`Select Node Type`,type:`select`,options:p.value?u.value:f.value,rules:{required:!0}}}:{};let n=o.value;if(!n)return{};let r=t;t===`node`&&!n.tabs?.node&&n.tabs?.settings&&(r=`settings`);let i=n.tabs?.[r]?.fields||n.fields||{},a=JSON.parse(JSON.stringify(i));return a.nodeType&&(a.nodeType.type=`select`,a.nodeType.options=p.value?u.value:f.value),a},h=K(()=>Object.keys(e.validationErrors.value).length===0),g=e=>{},_=async()=>{e.validationErrors.value={};let t=!0,n=``,r=o.value;if(!r)return!1;let i={...r.fields||{}};r.tabs&&Object.values(r.tabs).forEach(e=>{Object.assign(i,e.fields||{})});let a=e.activeNode.value?.id,s=typeof a==`number`||a&&!String(a).startsWith(`draft-`)?String(a):``,l=e.activeNode.value?.treeId||e.selectedTreeId.value||e.activeTreeSettings.value?.id,u=e.activeNode.value?._draftParentId??e.activeNode.value?.parentId??null,d={...e.activeNode.value,treeId:l,parentId:u};for(let[a,o]of Object.entries(i)){let i=e.activeNode.value[a],c=await Jv(a,i,o,{entityType:`node`,excludeId:e.activeNode.value?.treeNodeId||s,formData:d});if(c&&(e.validationErrors.value[a]=c,t=!1,!n)){for(let[e,t]of Object.entries(r.tabs||{}))if(t.fields?.[a]){n=e;break}}}if(!t){let t=n||c.value.find(e=>e.key!==`content`&&e.key!==`connections`)?.key||`content`;return e.activeTab.value!==t&&(e.activeTab.value=t),e.shouldFocusTitle.value=!0,!1}return!0},v=(e,t)=>{let n={},r=new Set(t.map(e=>String(e.blockId||e.instanceId||e.id))),i=!0;for(;i;){i=!1;for(let[t,a]of Object.entries(e))if(!n[t]){for(let e of r)if(e&&(t.startsWith(`${e}_`)||t.startsWith(`${e}-`))){n[t]=a,a.forEach(e=>r.add(String(e.blockId||e.instanceId||e.id))),i=!0;break}}}return n},y=async(r,i,a,o)=>{if(!r||r.isNew||String(r.id||``).startsWith(`draft-`))return{blocks:[]};let s=r;for(;s;){let r=s.disabledRegions?.[i],a=n.getCachedDocument(s.id),o=a?.blocks?.[i]?.length>0&&!a?.regionMeta?.[i]?.isInherited;if(r||o)break;let c=t.findParentNodeInTree(e.nodeTree.value,s.id||s.treeNodeId||``);if(!c)break;s=c}let c=String(s?.slug||``).trim().toLowerCase();if(!c||c===`page-title`||c===`untitled`)return{blocks:[]};let l=String(a);(l===`all`||l===`undefined`||l===`null`||!l)&&(l=``);let u=String(o);(u===`undefined`||u===`null`||!u)&&(u=`en`);let d=`${c}_${i}_${e.selectedTreeId.value}_${l}_${u}`,f=n.getCachedInheritedRegion(d);if(f)return f;let p=n.getCachedDocument(s.id);if(p&&p.blocks[i]?.length>0){let e={blocks:p.blocks[i],subRegions:v(p.blocks,p.blocks[i]),inheritedFromId:String(s.id),inheritedFromTitle:s.title||s.slug};return n.setCachedInheritedRegion(d,e),e}try{let t=await k_.getInheritedRegion(c,e.selectedTreeId.value,u,l);if(t.ok){let e=await t.json(),r=e.content?.[i]||[];if(r.length>0){let t={blocks:r,subRegions:v(e.content,r),inheritedFromId:String(s.id),inheritedFromTitle:s.title||s.slug};return n.setCachedInheritedRegion(d,t),t}}}catch(e){console.warn(`āš ļø Failed to fetch inherited region:`,e)}return{blocks:[]}},b=async r=>{if(String(e.activeNode.value?.id)===String(r.id)&&!e.activeNode.value?.isNew||e.activeNode.value?.isNew&&String(e.activeNode.value.id||``).startsWith(`draft-`)||!await i())return;e.selectedBlock.value=null,e.nodeSnapshot.value=``,e.selectedTreeId.value&&(e.nodeTree.value=t.getNodesForTree(e.selectedTreeId.value)),e.isDocumentLoading.value=!0,n.clearConflict(),n.markUnverified(!1);let a=++_y,o=String(r.id),s=n.getCachedDocument(o),l=n.getPersistedOfflineDraft(r.id);dy(e.nodeTree.value),e.validationErrors.value={};let u=e.nodeSchemas.value[r.nodeType]||Object.values(e.nodeSchemas.value)[0],d=t.findParentNodeInTree(e.nodeTree.value,r.id||r.treeNodeId||``),f=xy(r.channels||r.channelId).map(e=>typeof e==`string`&&!isNaN(Number(e))?Number(e):e),p=String(f[0]||e.selectedChannelId.value||``),m=String(r.language||e.selectedLanguage.value||`en`);if(l){e.setViewMode(`node`),e.activeNode.value=JSON.parse(JSON.stringify(l.data.node)),e.blocks.value=JSON.parse(JSON.stringify(l.data.blocks)),e.regionMeta.value=JSON.parse(JSON.stringify(l.data.regionMeta)),Ty(e),e.isDocumentLoading.value=!1,e.isPendingOfflineSave.value=!0;return}if(s){e.setViewMode(`node`),e.activeNode.value=JSON.parse(JSON.stringify(s.node)),e.blocks.value=JSON.parse(JSON.stringify(s.blocks)),e.regionMeta.value=JSON.parse(JSON.stringify(s.regionMeta)),Ty(e),e.isDocumentLoading.value=!1;return}try{let i=await k_.getNode(r.id);if(a!==_y)return;if(i.ok){let o=await i.json(),s=o.node||r,l=s.disabledRegions||{},h=s.channels||s.channelId||f,g={...vy(s),id:s.id||r.id,treeNodeId:s.treeNodeId||r.treeNodeId,isNew:!1,disabledRegions:l,channels:xy(h).map(e=>typeof e==`string`&&!isNaN(Number(e))?Number(e):e),trees:s.trees||[]};by(g,u);let _=Sy(g,{nodeSchemas:e.nodeSchemas,nodeLayoutSchemas:e.nodeLayoutSchemas},e,t),v={};for(let e of Object.keys(_))Cy(_[e].inherit)&&d&&(v[e]=y(d,e,p,m));let b={};for(let[e,t]of Object.entries(v))b[e]=await t;if(a!==_y)return;let x={},S={},C=new Set(Object.keys(_));if(Array.isArray(o.blocks)&&o.blocks.forEach(e=>C.add(e.region||`content`)),C.forEach(e=>{x[e]=[]}),Array.isArray(o.blocks)){let t=new Set;[...o.blocks].sort((e,t)=>{let n=String(e.region||``).includes(`_`),r=String(t.region||``).includes(`_`);return n&&!r?1:!n&&r?-1:0}).forEach(n=>{let r=n.instanceId||n.id;if(t.has(r))return;t.add(r);let i=n.region||`content`;x[i]||(x[i]=[]);let a=e.blockSchemas.value[n.componentId||n.elementType],o=typeof n.data==`string`?JSON.parse(n.data):n.data||{};a?.fields&&Object.entries(a.fields).forEach(([e,t])=>{(o[e]===void 0||o[e]===null)&&(o[e]=t.default===void 0?``:t.default)}),x[i].push({instanceId:String(r),blockId:String(n.blockId||n.instanceId||n.id),componentId:String(n.componentId||n.elementType||`text`),region:i,data:{...o}})})}for(let e of Object.keys(_)){let t=x[e]&&x[e].length>0,n=l[e];if(Cy(_[e].inherit)&&!t&&!n&&d){let t=b[e];if(t&&t.blocks&&t.blocks.length>0){if(x[e]=t.blocks,S[e]={isInherited:!0,inheritedFromId:t.inheritedFromId,inheritedFromTitle:t.inheritedFromTitle},t.subRegions)for(let[n,r]of Object.entries(t.subRegions))n!==e&&Array.isArray(r)&&r.length>0&&(x[n]=r,S[n]={isInherited:!0,inheritedFromId:t.inheritedFromId,inheritedFromTitle:t.inheritedFromTitle})}else S[e]={isInherited:!1}}else S[e]={isInherited:!1}}let w={};Object.keys(x).forEach(e=>{S[e]?.isInherited?w[e]=[]:w[e]=x[e]});let T={node:g,blocks:w,regionMeta:S};if(n.evaluateServerResponse(r.id,T,e.isNodeDirty.value).action===`update_silently`){e.setViewMode(`node`),e.activeNode.value=g,e.blocks.value=x,e.regionMeta.value=S;let i=c.value;if(!i.some(e=>e.key===`content`)&&e.activeTab.value===`content`&&(e.activeTab.value=i.find(e=>e.key!==`content`&&e.key!==`connections`)?.key||`settings`),g.trees&&g.trees.length>0){let n=String(g.trees[0].treeId);e.selectedTreeId.value!==n&&(e.selectedTreeId.value=n,e.nodeTree.value=t.getNodesForTree(n))}await Ir(),Ty(e),n.saveToCache(r.id,{node:g,blocks:x,regionMeta:S})}n.markUnverified(!1)}else n.markUnverified(!0)}catch(e){console.warn(`āš ļø Network error fetching node content:`,e),n.markUnverified(!0)}finally{e.isDocumentLoading.value=!1}},x=async t=>{let n=e=>{for(let r of e){if(String(r.id)===String(t))return r;if(r.children){let e=n(r.children);if(e)return e}}return null},r=n(e.nodeTree.value);r?await b(r):await b({id:String(t),title:`Loading...`,slug:``,nodeType:`node`,channelId:``,language:`en`})};ri([()=>e.activeNode.value?.id,()=>e.activeNode.value?.nodeType],([n,r])=>{if(e.activeNode.value?.isNew&&r){let r=Sy(e.activeNode.value,{nodeSchemas:e.nodeSchemas,nodeLayoutSchemas:e.nodeLayoutSchemas},e,t),i=t.findParentNodeInTree(e.nodeTree.value,e.activeNode.value._draftParentId||e.activeNode.value.parentId||``),a=String(e.selectedChannelId.value||``),o=String(e.selectedLanguage.value||`en`),s={...e.regionMeta.value},c=!1;for(let t of Object.keys(r))if(!s[t]){let l=r[t].inherit;Cy(l)&&i?(s[t]={isInherited:!0},c=!0,y(i,t,a,o).then(r=>{e.activeNode.value?.id===n&&(r&&r.blocks&&r.blocks.length>0?(e.blocks.value[t]=r.blocks,e.regionMeta.value[t]={isInherited:!0,inheritedFromId:r.inheritedFromId,inheritedFromTitle:r.inheritedFromTitle}):e.regionMeta.value[t]={isInherited:!1})})):(s[t]={isInherited:!1},c=!0)}c&&(e.regionMeta.value=s)}},{immediate:!0});let S=gy(_,b,l,d,p,c);return{applySchemaDefaults:by,currentNodeSchema:o,currentLayoutRegions:s,availableNodeTabs:c,treeEligibleNodeSchemas:l,treeEligibleNodeTypes:u,vaultEligibleNodeSchemas:d,vaultEligibleNodeTypes:f,isTreeContext:p,isNodeDirty:e.isNodeDirty,confirmDiscardUnsaved:i,isFormValid:h,getFieldsForTab:m,setFormValidator:g,validateActiveNode:_,loadNodeContent:b,navigateToNodeById:x,resolveInheritedRegion:y,handleAddRootNode:r.handleAddRootNode,handleAddChild:r.handleAddChild,handleAddSibling:r.handleAddSibling,handleAddNewNode:S.handleAddNewNode,createVaultNode:S.createVaultNode,cancelNewNode:S.cancelNewNode,saveNewNode:S.saveNewNode,saveNode:S.saveNode,publishNode:S.publishNode,deleteNode:S.deleteNode,restoreNode:S.restoreNode,purgeNode:S.purgeNode,toggleNodeVisibility:S.toggleNodeVisibility,updateNodeSnapshot:a}}function Dy(){let{allChannels:e,activeChannelSettings:t,selectedChannelId:n,selectedLanguage:r,channelSnapshot:i,channelTemplateSchema:a,channelSchemas:o,validationErrors:s,setViewMode:c,isChannelDirty:l,confirmDiscardUnsaved:u}=Hv(),{validateAgainstSchema:d}=Xv(),{fetchChannels:f,syncSystemMetadata:p}=$v(),m=()=>ny(o,l_),h=K(()=>ay(m())),g=()=>{i.value=JSON.stringify(t.value||{})},_=async()=>{if(!t.value)return!1;s.value={};let r=m(),i=t.value.channelType||t.value.type||Object.keys(r)[0]||`website`,o=iy(r[i]||a.value,a.value);if(!await d(t.value,{fields:o},`channel`))return!1;try{let r=t.value.id,a=t.value.isNew||String(r||``).startsWith(`draft-`)?null:typeof r==`number`?r:Number(r)||null,o={...JSON.parse(JSON.stringify(t.value)),id:a,channelType:i};delete o.isNew;let l=await fetch(`/api/cms/channels.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)});if(l.ok){let r=await l.json();t.value.id=r.id,delete t.value.isNew,await p(),n.value=String(r.id);let a=e.value.find(e=>String(e.id)===String(r.id));return a&&(t.value={...a,channelType:a.channelType||a.type||i,trees:Array.isArray(a.trees)?[...a.trees]:[]}),g(),await c(`channel`,!0),!0}{let e=await l.json().catch(()=>({}));return l.status===409&&e.field?s.value={[e.field]:e.error||`This key is already in use.`}:alert(e.error||`Failed to save channel settings.`),!1}}catch(e){return console.error(`[CMS] Error saving channel:`,e),!1}},v=async()=>{t.value=null,i.value=``,await c(`none`,!0)},y=async e=>{let r=e||t.value?.id;if(r){if(String(r).startsWith(`draft-`)){await v();return}try{let e=await fetch(`/api/cms/channels.json?id=${r}`,{method:`DELETE`});if(e.ok)t.value=null,i.value=``,await p(),n.value=`all`,await c(`none`,!0);else{let t=await e.json().catch(()=>({}));alert(`Failed to delete channel. ${t.error||`Check server console.`}`)}}catch{alert(`Network error: Could not reach server to delete the channel.`)}}},b=async()=>{if(!await u())return!1;let r=n.value;(!r||r===`all`)&&e.value.length>0&&(r=String(e.value[0].id),n.value=r);let i=e.value.find(e=>String(e.id)===String(r));if(i){let e=m(),n=Object.keys(e)[0]||`website`,r=i.channelType||i.type||n,a=JSON.parse(JSON.stringify(i));a.channelType=r,a.trees=Array.isArray(i.trees)?[...i.trees]:[];let o=e[r];if(o){let e={};by(e,o),Object.keys(e).forEach(t=>{(a[t]===void 0||a[t]===null)&&(a[t]=e[t])})}t.value=a,g(),s.value={},await c(`channel`,!0)}return!0},x=async e=>{if(!await u())return!1;let n=m(),r=ry(n,e),i=r?n[r]:null,a={id:`draft-${Date.now()}`,isNew:!0,key:``,label:``,channelType:r,domain:`localhost`,baseUrl:`http://localhost:3000`,defaultLanguage:`en`,trees:[]};return i&&by(a,i),t.value=a,g(),s.value={},await c(`channel`,!0),!0};return{allChannels:e,activeChannelSettings:t,selectedChannelId:n,selectedLanguage:r,isChannelDirty:l,channelTypeOptions:h,confirmDiscardUnsaved:u,fetchChannels:f,saveChannelSettings:_,cancelNewChannel:v,deleteChannel:y,openCurrentChannelSettings:b,handleAddNewChannel:x,onChannelSelectChange:async e=>{let r=e.target,i=String(t.value?.id||`all`);r.value===`__add_new__`?await x()||Ir(()=>{n.value=i}):await b()||Ir(()=>{n.value=i})},updateChannelSnapshot:g}}var Oy=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},ky=e=>e===``,Ay=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),jy=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),My=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Ny=e=>{let t=My(e);return t.charAt(0).toUpperCase()+t.slice(1)},Py={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},Fy=({name:e,iconNode:t,absoluteStrokeWidth:n,"absolute-stroke-width":r,strokeWidth:i,"stroke-width":a,size:o=Py.width,color:s=Py.stroke,...c},{slots:l})=>Uo(`svg`,{...Py,...c,width:o,height:o,stroke:s,"stroke-width":ky(n)||ky(r)||n===!0||r===!0?Number(i||a||Py[`stroke-width`])*24/Number(o):i||a||Py[`stroke-width`],class:Ay(`lucide`,c.class,...e?[`lucide-${jy(Ny(e))}-icon`,`lucide-${jy(e)}`]:[`lucide-icon`]),...!l.default&&!Oy(c)&&{"aria-hidden":`true`}},[...t.map(e=>Uo(...e)),...l.default?[l.default()]:[]]),q=(e,t)=>(n,{slots:r,attrs:i})=>Uo(Fy,{...i,...n,iconNode:t,name:e},r),Iy=q(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ly=q(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Ry=q(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),zy=q(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),By=q(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Vy=q(`bold`,[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]),Hy=q(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),Uy=q(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),Wy=q(`chart-no-axes-column`,[[`path`,{d:`M5 21v-6`,key:`1hz6c0`}],[`path`,{d:`M12 21V3`,key:`1lcnhd`}],[`path`,{d:`M19 21V9`,key:`unv183`}]]),Gy=q(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ky=q(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),qy=q(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Jy=q(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Yy=q(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Xy=q(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Zy=q(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Qy=q(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),$y=q(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),eb=q(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),tb=q(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),nb=q(`crop`,[[`path`,{d:`M6 2v14a2 2 0 0 0 2 2h14`,key:`ron5a4`}],[`path`,{d:`M18 22V8a2 2 0 0 0-2-2H2`,key:`7s9ehn`}]]),rb=q(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ib=q(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ab=q(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),ob=q(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),sb=q(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),cb=q(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),lb=q(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),ub=q(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),db=q(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),fb=q(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),pb=q(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),mb=q(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),hb=q(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),gb=q(`heading-4`,[[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17 10v3a1 1 0 0 0 1 1h3`,key:`tj5zdr`}],[`path`,{d:`M21 10v8`,key:`1kdml4`}],[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}]]),_b=q(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),vb=q(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),yb=q(`italic`,[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]),bb=q(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),xb=q(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Sb=q(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),Cb=q(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),wb=q(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),Tb=q(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),Eb=q(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Db=q(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),Ob=q(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),kb=q(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Ab=q(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),jb=q(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),Mb=q(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Nb=q(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Pb=q(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Fb=q(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ib=q(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),Lb=q(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Rb=q(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),zb=q(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Bb=q(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Vb=q(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Hb=q(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ub=q(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Wb=q(`strikethrough`,[[`path`,{d:`M16 4H9a3 3 0 0 0-2.83 4`,key:`43sutm`}],[`path`,{d:`M14 12a4 4 0 0 1 0 8H6`,key:`nlfj13`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),Gb=q(`subscript`,[[`path`,{d:`m4 5 8 8`,key:`1eunvl`}],[`path`,{d:`m12 5-8 8`,key:`1ah0jp`}],[`path`,{d:`M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07`,key:`e8ta8j`}]]),Kb=q(`superscript`,[[`path`,{d:`m4 19 8-8`,key:`hr47gm`}],[`path`,{d:`m12 19-8-8`,key:`1dhhmo`}],[`path`,{d:`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`,key:`1dfcux`}]]),qb=q(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Jb=q(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Yb=q(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),Xb=q(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Zb=q(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Qb=q(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),$b=[`disabled`],ex=yi({__name:`CmsButton`,props:{variant:{},size:{},disabled:{type:Boolean}},setup(e){return(t,n)=>(z(),B(`button`,{class:w([`cms-btn`,`btn-${e.variant||`primary`}`,e.size===`sm`?`btn-sm`:`btn-md`]),disabled:e.disabled},[$i(t.$slots,`default`,{},void 0,!0)],10,$b))}}),tx=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},nx=tx(ex,[[`__scopeId`,`data-v-ffc5ce5f`]]),rx={class:`logo-area`},ix={class:`version-link`,href:`https://kama.t3cloud.eu`,target:`_blank`,rel:`noreferrer`},ax={key:0,class:`center-status-area`},ox={class:`user-area`},sx={class:`user-name`},cx={class:`user-avatar`},lx={class:`modal-content`},ux={class:`modal-header`},dx={class:`modal-body dynamic-form`},fx={class:`form-group`},px={class:`form-group`},mx={class:`form-group`},hx={class:`modal-footer`},gx=tx(yi({__name:`GlobalTopBar`,setup(e){let t=L(!1),{goToDashboard:n,isOffline:r,isReadOnlyMode:i,isPendingOfflineSave:a}=Hv(),o=L({firstName:`Admin`,lastName:`User`,email:`admin@kama-cms.com`}),s=K(()=>o.value.firstName||o.value.lastName?`${o.value.firstName} ${o.value.lastName}`.trim():o.value.email.split(`@`)[0]),c=K(()=>i.value?{text:`Unverified Document (Read-Only)`,icon:Jb,class:`status-danger`}:r.value?{text:`Working Offline — Saving locally`,icon:Zb,class:`status-warning`}:a.value?{text:`Reconnected — Syncing offline queue...`,icon:Lb,class:`status-info`,spin:!0}:null),l=()=>{t.value=!1},u=e=>{e.key===`Escape`&&t.value&&(t.value=!1)};return Xs(()=>window.addEventListener(`keydown`,u)),ec(()=>window.removeEventListener(`keydown`,u)),(e,r)=>(z(),B(W,null,[H(`header`,{class:w([`global-top-bar`,{"has-status-bg":c.value}])},[H(`div`,rx,[H(`button`,{class:`logo`,title:`Go to Dashboard`,onClick:r[0]||=(...e)=>R(n)&&R(n)(...e)},[...r[8]||=[Eo(`<svg id="b" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 117.14 27.38" data-v-7ff0bd90><g id="c" data-v-7ff0bd90><path d="M22.48,22.51c1.94,2.9,2.37,3.49,3.49,4.87h-8.56c-.46-1.05-1.42-2.8-2.27-4.18l-5.1-8.16-3.32,3.32v4.15c0,2.04.07,3.13.26,4.87H0c.2-1.68.26-2.9.26-4.87V4.87C.26,2.86.2,1.58,0,0h6.98c-.2,1.71-.26,2.8-.26,4.87v5.83l6.55-7.01c1.28-1.35,2.14-2.47,2.86-3.69h8.89c-.59.59-.82.86-1.28,1.32l-2.3,2.3-6.88,7.21,7.93,11.68Z" data-v-7ff0bd90></path><path d="M46.97,27.38c-.26-1.58-.46-2.44-.79-3.55l-.89-2.8h-9.38l-.89,2.8c-.43,1.32-.66,2.34-.82,3.55h-7.7c.49-.99.79-1.78,1.58-4.02l7.11-19.81c.59-1.61.89-2.6,1.05-3.55h8.59c.23.95.46,1.81,1.12,3.55l7.14,19.81c.63,1.74,1.15,3.09,1.58,4.02h-7.7ZM40.55,5.63l-3.06,9.87h6.19l-3.13-9.87Z" data-v-7ff0bd90></path><path d="M68.92,27.38c-.16-1.15-.53-2.37-1.42-4.87l-3.03-8.75c-.03-.16-1.02-3.23-1.12-3.49q-.36-1.18-.53-1.65c.2,2.07.33,4.77.33,6.52v7.14c0,2.27.07,3.72.26,5.1h-6.48c.2-1.48.26-2.86.26-5.1V5.13c0-1.97-.1-3.72-.26-5.13h8.69c.23,1.42.49,2.47,1.25,4.64l4.94,14.19,4.9-14.19c.76-2.21,1.02-3.26,1.22-4.64h8.72c-.2,1.58-.26,2.93-.26,5.13v17.15c0,2.5.07,3.78.26,5.1h-6.48c.2-1.51.26-2.77.26-5.1v-7.18c0-.79.1-3.26.16-4.28q.1-1.74.13-2.24c-.72,2.57-1.05,3.75-1.48,4.94l-3.19,9.02c-.82,2.34-1.25,3.79-1.42,4.84h-5.73Z" data-v-7ff0bd90></path><path d="M109.44,27.38c-.26-1.58-.46-2.44-.79-3.55l-.89-2.8h-9.38l-.89,2.8c-.43,1.32-.66,2.34-.82,3.55h-7.7c.49-.99.79-1.78,1.58-4.02l7.11-19.81c.59-1.61.89-2.6,1.05-3.55h8.59c.23.95.46,1.81,1.12,3.55l7.14,19.81c.63,1.74,1.15,3.09,1.58,4.02h-7.7ZM103.02,5.63l-3.06,9.87h6.19l-3.13-9.87Z" data-v-7ff0bd90></path></g></svg>`,1)]]),H(`a`,ix,` v`+I(R(`0.1.0-alpha.111`)),1)]),G(wu,{name:`fade`},{default:Jr(()=>[c.value?(z(),B(`div`,ax,[H(`div`,{class:w([`status-badge`,c.value.class])},[(z(),V(qi(c.value.icon),{size:13,class:w({"animate-spin":c.value.spin})},null,8,[`class`])),H(`span`,null,I(c.value.text),1)],2)])):U(``,!0)]),_:1}),H(`div`,ox,[H(`button`,{class:`user-profile-btn`,onClick:r[1]||=e=>t.value=!0},[H(`span`,sx,I(s.value),1),H(`div`,cx,[G(R(Xb),{size:15})])])])],2),(z(),V(xs,{to:`body`},[G(wu,{name:`modal-fade`},{default:Jr(()=>[t.value?(z(),B(`div`,{key:0,class:`modal-backdrop`,onClick:r[7]||=dd(e=>t.value=!1,[`self`])},[H(`div`,lx,[H(`div`,ux,[r[9]||=H(`h3`,null,`User Preferences`,-1),H(`button`,{class:`close-btn`,onClick:r[2]||=e=>t.value=!1},[G(R(Qb),{size:16})])]),H(`div`,dx,[H(`div`,fx,[r[10]||=H(`div`,{class:`label-row`},[H(`label`,null,`First Name`)],-1),Yr(H(`input`,{type:`text`,"onUpdate:modelValue":r[3]||=e=>o.value.firstName=e,placeholder:`First Name`},null,512),[[id,o.value.firstName]])]),H(`div`,px,[r[11]||=H(`div`,{class:`label-row`},[H(`label`,null,`Last Name`)],-1),Yr(H(`input`,{type:`text`,"onUpdate:modelValue":r[4]||=e=>o.value.lastName=e,placeholder:`Last Name`},null,512),[[id,o.value.lastName]])]),H(`div`,mx,[r[12]||=H(`div`,{class:`label-row`},[H(`label`,null,`E-mail`),H(`span`,{class:`help-text-inline`},`(Used as username)`)],-1),Yr(H(`input`,{type:`email`,"onUpdate:modelValue":r[5]||=e=>o.value.email=e,placeholder:`email@example.com`},null,512),[[id,o.value.email]])])]),H(`div`,hx,[G(nx,{variant:`secondary`,onClick:r[6]||=e=>t.value=!1},{default:Jr(()=>[...r[13]||=[To(` Cancel `,-1)]]),_:1}),G(nx,{variant:`primary`,onClick:l},{default:Jr(()=>[...r[14]||=[To(` Save Preferences `,-1)]]),_:1})])])])):U(``,!0)]),_:1})]))],64))}}),[[`__scopeId`,`data-v-7ff0bd90`]]),_x=[`disabled`],vx={class:`trigger-label`},yx={key:0,class:`select-menu`,role:`listbox`},bx=[`onClick`],xx=[`onClick`],Sx={class:`option-content-wrapper`},Cx={class:`option-content`},wx={class:`option-label`},Tx={key:0,class:`option-subtitle`},Ex={class:`option-meta-actions`},Dx=[`title`,`onClick`],Ox=tx(yi({__name:`CmsSelect`,props:{modelValue:{},options:{},placeholder:{default:`Select an option...`},disabled:{type:Boolean,default:!1},icon:{}},emits:[`update:modelValue`,`change`,`add-new`,`option-action`],setup(e,{emit:t}){let n=e,r=t,i=L(!1),a=L(null),o=()=>{n.disabled||(i.value=!i.value)},s=()=>{i.value=!1},c=e=>{if(!e.disabled){if(e.isAddNew){r(`add-new`),s();return}r(`update:modelValue`,e.id),r(`change`,e.id),s()}},l=(e,t)=>{e.stopPropagation(),r(`option-action`,t.id),s()},u=e=>{a.value&&!a.value.contains(e.target)&&s()};Xs(()=>window.addEventListener(`click`,u)),ec(()=>window.removeEventListener(`click`,u));let d=K(()=>n.options.find(e=>String(e.id)===String(n.modelValue)));return(t,n)=>(z(),B(`div`,{ref_key:`dropdownRef`,ref:a,class:w([`cms-select-wrapper`,{"is-open":i.value,"is-disabled":e.disabled}])},[H(`button`,{type:`button`,class:`select-trigger`,onClick:o,disabled:e.disabled},[e.icon?(z(),V(qi(e.icon),{key:0,size:14,class:`trigger-icon`})):U(``,!0),H(`span`,vx,I(d.value?.label||e.placeholder),1),G(R(Ky),{size:13,class:`caret-icon`})],8,_x),G(wu,{name:`dropdown-fade`},{default:Jr(()=>[i.value?(z(),B(`ul`,yx,[(z(!0),B(W,null,Zi(e.options,t=>(z(),B(W,{key:String(t.id)},[t.isAddNew?(z(),B(`li`,{key:0,class:`menu-item add-new-item`,onClick:e=>c(t)},[(z(),V(qi(t.icon||R(Fb)),{size:13,class:`add-icon`})),H(`span`,null,I(t.label),1)],8,bx)):(z(),B(`li`,{key:1,class:w([`menu-item`,{"is-selected":String(t.id)===String(e.modelValue),"is-disabled":t.disabled}]),onClick:e=>c(t)},[H(`div`,Sx,[t.icon?(z(),V(qi(t.icon),{key:0,size:13,class:`option-lead-icon`})):U(``,!0),H(`div`,Cx,[H(`span`,wx,I(t.label),1),t.subtitle?(z(),B(`span`,Tx,I(t.subtitle),1)):U(``,!0)])]),H(`div`,Ex,[String(t.id)===String(e.modelValue)?(z(),V(R(Gy),{key:0,size:13,class:`check-icon`})):U(``,!0),t.hasAction?(z(),B(`button`,{key:1,type:`button`,class:`option-action-btn`,title:t.actionTitle||`Settings`,onClick:e=>l(e,t)},[(z(),V(qi(t.actionIcon||R(Hb)),{size:12}))],8,Dx)):U(``,!0)])],10,xx))],64))),128))])):U(``,!0)]),_:1})],2))}}),[[`__scopeId`,`data-v-3ef89cc7`]]),kx={class:`channel-selector-row`},Ax=tx(yi({__name:`ChannelOperations`,setup(e){let{allChannels:t,selectedChannelId:n,activeChannelSettings:r,activeViewMode:i,setViewMode:a,resetActiveNode:o}=Hv(),{openCurrentChannelSettings:s,handleAddNewChannel:c,openChannelSettings:l}=Dy(),{confirmDiscardUnsaved:u}=Ey(),d=K(()=>i.value===`channel`),f=K(()=>{let e=[{id:`all`,label:`All Channels`}];if(Array.isArray(t.value)&&t.value.forEach(t=>{t&&t.id!==void 0&&e.push({id:String(t.id),label:t.label||t.key||`Channel ${t.id}`,subtitle:t.domain||void 0,hasAction:!0,actionIcon:Hb,actionTitle:`Channel Settings`})}),d.value&&r.value?.id){let t=String(r.value.id);(t.startsWith(`draft-`)||r.value.isNew)&&(e.some(e=>String(e.id)===t)||e.push({id:t,label:r.value.label||`New Channel...`}))}return e.push({id:`__add_new__`,label:`Add Channel...`,isAddNew:!0}),e}),p=K(()=>{if(d.value&&r.value?.id){let e=String(r.value.id);if(e.startsWith(`draft-`)||r.value.isNew)return e}return n.value?String(n.value):`all`}),m=async e=>{await u()&&(e===`__add_new__`?await c():(n.value=String(e),d.value&&e!==`all`?await s():(a(`none`),o())))},h=async e=>{await u()&&(n.value=String(e),typeof l==`function`?await l(e):await s())};return(e,t)=>(z(),B(`div`,kx,[G(Ox,{"model-value":p.value,options:f.value,icon:R(fb),onChange:m,onAddNew:t[0]||=e=>m(`__add_new__`),onOptionAction:h},null,8,[`model-value`,`options`,`icon`])]))}}),[[`__scopeId`,`data-v-fb02e871`]]);function jx(e){Object.getOwnPropertySymbols(e).forEach(t=>{$w[t]=e[t]})}function Mx(e,t=``){return{type:0,source:t,children:e,helpers:new Set,components:[],directives:[],hoists:[],imports:[],cached:[],temps:0,codegenNode:void 0,loc:iT}}function Nx(e,t,n,r,i,a,o,s=!1,c=!1,l=!1,u=iT){return e&&(s?(e.helper(yw),e.helper(Zx(e.inSSR,l))):e.helper(Xx(e.inSSR,l)),o&&e.helper(jw)),{type:13,tag:t,props:n,children:r,patchFlag:i,dynamicProps:a,directives:o,isBlock:s,disableTracking:c,isComponent:l,loc:u}}function Px(e,t=iT){return{type:17,loc:t,elements:e}}function Fx(e,t=iT){return{type:15,loc:t,properties:e}}function Ix(e,t){return{type:16,loc:iT,key:F(e)?Lx(e,!0):e,value:t}}function Lx(e,t=!1,n=iT,r=0){return{type:4,loc:n,content:e,isStatic:t,constType:t?3:r}}function Rx(e,t){return{type:5,loc:t,content:F(e)?Lx(e,!1,t):e}}function zx(e,t=iT){return{type:8,loc:t,children:e}}function Bx(e,t=[],n=iT){return{type:14,loc:n,callee:e,arguments:t}}function Vx(e,t=void 0,n=!1,r=!1,i=iT){return{type:18,params:e,returns:t,newline:n,isSlot:r,loc:i}}function Hx(e,t,n,r=!0){return{type:19,test:e,consequent:t,alternate:n,newline:r,loc:iT}}function Ux(e,t,n=!1,r=!1){return{type:20,index:e,value:t,needPauseTracking:n,inVOnce:r,needArraySpread:!1,loc:iT}}function Wx(e){return{type:21,body:e,loc:iT}}function Gx(e){return{type:22,elements:e,loc:iT}}function Kx(e,t,n){return{type:23,test:e,consequent:t,alternate:n,loc:iT}}function qx(e,t){return{type:24,left:e,right:t,loc:iT}}function Jx(e){return{type:25,expressions:e,loc:iT}}function Yx(e){return{type:26,returns:e,loc:iT}}function Xx(e,t){return e||t?Sw:Cw}function Zx(e,t){return e||t?bw:xw}function Qx(e,{helper:t,removeHelper:n,inSSR:r}){e.isBlock||(e.isBlock=!0,n(Xx(r,e.isComponent)),t(yw),t(Zx(r,e.isComponent)))}function $x(e){return e>=97&&e<=122||e>=65&&e<=90}function eS(e){return e===32||e===10||e===9||e===12||e===13}function tS(e){return e===47||e===62||eS(e)}function nS(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function rS(e,{compatConfig:t}){let n=t&&t[e];return e===`MODE`?n||3:n}function iS(e,t){let n=rS(`MODE`,t),r=rS(e,t);return n===3?r===!0:r!==!1}function aS(e,t,n,...r){return iS(e,t)}function oS(e,t,n,...r){if(rS(e,t)===`suppress-warning`)return;let{message:i,link:a}=uT[e],o=`(deprecation ${e}) ${typeof i==`function`?i(...r):i}${a?`
1237
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=Mg(jg(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=Mg(jg(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function Ig(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Dg||null,prettyErrors:t}}function Lg(e,t={}){let{lineCounter:n,prettyErrors:r}=Ig(t),i=new Fg(n?.addNewLine),a=new eg(t),o=Array.from(a.compose(i.parse(e)));if(r&&n)for(let t of o)t.errors.forEach(xh(e,n)),t.warnings.forEach(xh(e,n));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function Rg(e,t={}){let{lineCounter:n,prettyErrors:r}=Ig(t),i=new Fg(n?.addNewLine),a=new eg(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new yh(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(xh(e,n)),o.warnings.forEach(xh(e,n))),o}function zg(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=Rg(e,n);if(!i)return null;if(i.warnings.forEach(e=>Zp(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function Bg(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return Wf(e)&&!r?e.toString(n):new gh(e,r,n).toString(n)}var Vg=c({Alias:()=>vp,CST:()=>hg,Composer:()=>eg,Document:()=>gh,Lexer:()=>Eg,LineCounter:()=>Dg,Pair:()=>sm,Parser:()=>Fg,Scalar:()=>xp,Schema:()=>mh,YAMLError:()=>vh,YAMLMap:()=>pm,YAMLParseError:()=>yh,YAMLSeq:()=>hm,YAMLWarning:()=>bh,isAlias:()=>Uf,isCollection:()=>Yf,isDocument:()=>Wf,isMap:()=>Gf,isNode:()=>Xf,isPair:()=>Kf,isScalar:()=>qf,isSeq:()=>Jf,parse:()=>zg,parseAllDocuments:()=>Lg,parseDocument:()=>Rg,stringify:()=>Bg,visit:()=>tp,visitAsync:()=>rp}),Hg={},Ug={},Wg={},Gg={},Kg={},qg={},Jg={};try{Hg=Object.assign({"../../content/definitions/nodes/address.yaml":wd,"../../content/definitions/nodes/article.yaml":Ed,"../../content/definitions/nodes/event.yaml":Od,"../../content/definitions/nodes/external-link.yaml":Ad,"../../content/definitions/nodes/page.yaml":Md,"../../content/definitions/nodes/person.yaml":Pd,"../../content/definitions/nodes/product.yaml":Id}),Ug=Object.assign({"../../content/definitions/trees/navigation.yaml":Rd,"../../content/definitions/trees/social-links.yaml":Bd}),Wg=Object.assign({"../../content/definitions/blocks/button.yaml":Hd,"../../content/definitions/blocks/header.yaml":Wd,"../../content/definitions/blocks/header_image.yaml":Kd,"../../content/definitions/blocks/hero.yaml":Jd,"../../content/definitions/blocks/image_card.yaml":Xd,"../../content/definitions/blocks/single_image.yaml":Zd,"../../content/definitions/blocks/text.yaml":$d}),Gg=Object.assign({"../../content/definitions/node-layouts/landing-page.yml":tf,"../../content/definitions/node-layouts/single-column.yml":rf,"../../content/definitions/node-layouts/three-column.yml":of,"../../content/definitions/node-layouts/two-column.yml":cf}),Kg=Object.assign({"../../content/definitions/block-layouts/three-column.yaml":uf,"../../content/definitions/block-layouts/two-column.yaml":ff}),qg=Object.assign({"../../content/definitions/field-sets/access.yaml":mf,"../../content/definitions/field-sets/channel-base.yaml":gf,"../../content/definitions/field-sets/comments.yaml":vf,"../../content/definitions/field-sets/content-block.yaml":bf,"../../content/definitions/field-sets/page-base.yaml":Sf,"../../content/definitions/field-sets/page-meta.yaml":wf,"../../content/definitions/field-sets/page-social.yaml":Ef,"../../content/definitions/field-sets/tree-base.yaml":Of,"../../content/definitions/field-sets/visibility.yaml":Af}),Jg=Object.assign({"../../content/definitions/channels/ecommerce.yaml":Mf,"../../content/definitions/channels/website.yaml":Pf})}catch{}var Yg={},Xg={},Zg={},Qg={},$g={},e_={},t_={};function n_(e){let t=e.split(`/`);return t[t.length-1].replace(/\.(yaml|yml)$/,``)}function r_(e){let t={...qg,...e_};for(let n in t)if(n_(n)===e){let e=t[n]?.default||``;return Vg.parse(e)||{}}return{}}function i_(e,t){e&&typeof t==`object`&&t&&(e.inTree===void 0&&t.inTree!==void 0&&(e.inTree=!!t.inTree),e.inVault===void 0&&t.inVault!==void 0&&(e.inVault=!!t.inVault),e.hasCanvas===void 0&&t.hasCanvas!==void 0&&(e.hasCanvas=!!t.hasCanvas))}function a_(e={},t={}){let n={...e,...t},r={...e.rules||{},...t.rules||{}};return t.required===!0||String(t.required).toLowerCase()===`true`||t.rules?.required===!0||String(t.rules?.required).toLowerCase()===`true`||t.required===void 0&&(e.required===!0||String(e.required).toLowerCase()===`true`||e.rules?.required===!0||String(e.rules?.required).toLowerCase()===`true`)?(n.required=!0,r.required=!0):(t.required===!1||t.rules?.required===!1)&&(n.required=!1,r.required=!1),n.rules=r,n}function o_(e,t,n){let r={};if(!e)return r;if(Array.isArray(e)){for(let i of e)if(typeof i==`string`){if(i.startsWith(`fieldSet:`)){let e=i.replace(`fieldSet:`,``).trim();s_(r_(e),e,r,t,n)}else r[i]=a_(r[i],{type:`text`,label:i})}else if(typeof i==`object`&&i){let e=Object.entries(i);if(e.length>0){let[i,a]=e[0];if(i===`fieldSet`){let e=String(a);s_(r_(e),e,r,t,n)}else{let e=typeof a==`object`&&a?a:{};r[i]=a_(r[i],e)}}}}else if(typeof e==`object`&&e)for(let[i,a]of Object.entries(e))if(i===`fieldSet`){let e=String(a);s_(r_(e),e,r,t,n)}else r[i]=typeof a==`object`&&a?a_(r[i],a):a_(r[i],{type:`text`,label:String(a)});return r}function s_(e,t,n,r,i){if(i_(i,e),e.tabs&&r){if(typeof e.tabs==`object`)for(let[t,n]of Object.entries(e.tabs)){let e=typeof n==`object`&&n?n:{label:String(n)},a=e.label||t;r[t]||(r[t]={label:a,fields:{}});let o=o_(e.fields||[],r,i);Object.entries(o).forEach(([e,n])=>{r[t].fields[e]=a_(r[t].fields[e],n)})}return}let a=o_(e.fields||e,r,i);if(e.tab&&r){let n=e.tab.id||t,i=e.tab.label||e.label||n;r[n]||(r[n]={label:i,fields:{}}),Object.entries(a).forEach(([e,t])=>{let i=r[n].fields[e];r[n].fields[e]=a_(i,t)})}else Object.entries(a).forEach(([e,t])=>{let r=n[e];n[e]=a_(r,t)})}function c_(e){let t={},n={};if(e.tabs){if(Array.isArray(e.tabs)){for(let r of e.tabs)if(typeof r==`object`&&r.fieldSet){let i=String(r.fieldSet),a=r_(i);i_(e,a);let o=a.tab?.id||i,s=a.tab?.label||a.label||o;t[o]||(t[o]={label:s,fields:{}});let c=o_(a.fields||a,t,e);Object.entries(c).forEach(([e,r])=>{t[o].fields[e]=a_(t[o].fields[e],r),n[e]=a_(n[e],r)})}}else if(typeof e.tabs==`object`)for(let[r,i]of Object.entries(e.tabs)){let a=typeof i==`object`&&i?i:{label:String(i)},o=a.label||r;t[r]||(t[r]={label:o,fields:{}});let s=o_(a.fields||[],t,e);Object.entries(s).forEach(([e,i])=>{t[r].fields[e]=a_(t[r].fields[e],i),n[e]=a_(n[e],i)})}}if(e.fields){let r=o_(e.fields,t,e);Object.entries(r).forEach(([e,t])=>{n[e]=a_(n[e],t)}),Object.keys(t).length===0||!t.settings&&Object.keys(r).length>0?t.settings={label:`Settings`,fields:r}:t.settings&&Object.keys(r).length>0&&Object.entries(r).forEach(([e,n])=>{t.settings.fields[e]=a_(t.settings.fields[e],n)})}e.tabs=t,e.fields=n}function l_(){let e={},t={...Jg,...t_};for(let n in t){let r=t[n]?.default||``,i=Vg.parse(r);if(!i)continue;c_(i);let a=n_(n),o=i.id||a;i.id=o,e[o]=i}return e}function u_(){let e={},t={...Hg,...Yg};for(let n in t){let r=t[n]?.default||``,i=Vg.parse(r);if(!i)continue;c_(i),i.inTree=i.inTree===!0,i.inVault=i.inVault!==!1,i.hasCanvas=i.hasCanvas===!0,i.allowedBlocks=i.allowedBlocks||i.allowedElements||[],i.allowedLayouts=i.allowedLayouts||[];let a=n_(n),o=i.id||a;i.id=o,e[o]=i}return e}function d_(){let e={},t={...Ug,...Xg};for(let n in t){let r=t[n]?.default||``,i=Vg.parse(r);if(!i)continue;c_(i);let a=n_(n),o=i.id||a;i.id=o,e[o]=i}return e}function f_(){let e={},t={...Wg,...Zg};for(let n in t){let r=t[n]?.default||``,i=Vg.parse(r);if(!i)continue;i.fields=o_(i.fields);let a=n_(n),o=i.id||a;i.id=o,e[o]=i}return e}function p_(e,t=`main`,n=`Main Content`){let r={};for(let i in e){let a=e[i]?.default||``,o=Vg.parse(a);if(!o)continue;c_(o);let s=n_(i),c=o.id||s,l={};if(o.regions&&typeof o.regions==`object`)for(let[e,t]of Object.entries(o.regions)){let n=t;l[e]={label:n?.label||e,inherit:n?.inherit??n?.inherited??!1,allowedBlocks:n?.allowedBlocks||n?.allowedElements||[],...n}}else l[t]={label:n};r[c]={...o,id:c,label:o.label||c,layout:o.layout||{columns:`1fr`,areas:[[t]]},regions:l,fields:o.fields||{},tabs:o.tabs||{}}}return r}function m_(){return p_({...Gg,...Qg},`content`,`Content`)}function h_(){return p_({...Kg,...$g})}var g_=L(!1),__=L(`Unsaved Changes`),v_=L(`You have unsaved changes. Are you sure you want to discard them?`),y_=L(`Discard Changes`),b_=L(`Keep Editing`),x_;function S_(){return{isOpen:g_,title:__,message:v_,confirmLabel:y_,cancelLabel:b_,confirmDiscard:(e,t,n,r)=>(e&&(v_.value=e),t&&(__.value=t),y_.value=n||`Discard Changes`,b_.value=r||`Keep Editing`,g_.value=!0,new Promise(e=>{x_=e})),handleConfirm:()=>{g_.value=!1,x_&&x_(!0)},handleCancel:()=>{g_.value=!1,x_&&x_(!1)}}}var C_=`kama_cms_offline_queue`,w_=new Map,T_=new Map,E_=L({hasConflict:!1,nodeId:null,serverData:null});function D_(){let{isPendingOfflineSave:e,isDocumentUnverified:t}=Hv(),n=()=>{if(typeof window>`u`)return{};try{let e=localStorage.getItem(C_);return e?JSON.parse(e):{}}catch(e){return console.warn(`āš ļø Failed to parse offline queue from LocalStorage:`,e),{}}},r=(t,r)=>{if(!(typeof window>`u`))try{let i=n();i[String(t)]={data:JSON.parse(JSON.stringify(r)),timestamp:Date.now()},localStorage.setItem(C_,JSON.stringify(i)),e.value=!0}catch(e){console.error(`āŒ Failed to persist offline draft to storage:`,e)}},i=e=>n()[String(e)]||null,a=t=>{if(!(typeof window>`u`))try{let r=n();delete r[String(t)],localStorage.setItem(C_,JSON.stringify(r));let i=Object.keys(r);e.value=i.length>0}catch(e){console.warn(`āš ļø Failed to clear offline draft from storage:`,e)}},o=e=>{t.value=e},s=async t=>{let r=n(),i=Object.keys(r);if(i.length===0){e.value=!1;return}e.value=!0;for(let e of i)try{await t(e)&&a(e)}catch(t){console.error(`āŒ Auto-sync failed for node ${e}:`,t)}let o=Object.keys(n());e.value=o.length>0},c=e=>w_.get(String(e)),l=(e,t)=>{w_.set(String(e),{node:JSON.parse(JSON.stringify(t.node)),blocks:JSON.parse(JSON.stringify(t.blocks)),regionMeta:JSON.parse(JSON.stringify(t.regionMeta))}),String(E_.value.nodeId)===String(e)&&m()},u=e=>{w_.delete(String(e)),a(e)},d=e=>T_.get(e),f=(e,t)=>{T_.set(e,JSON.parse(JSON.stringify(t)))},p=e=>{T_.clear();let t=String(e);for(let[e]of w_.entries())e!==t&&w_.delete(e)},m=()=>{E_.value={hasConflict:!1,nodeId:null,serverData:null}};return{conflictState:E_,getCachedDocument:c,saveToCache:l,clearCache:u,invalidateAfterSave:p,clearConflict:m,evaluateServerResponse:(e,t,n)=>{let r=c(e);if(i(e))return E_.value={hasConflict:!0,nodeId:e,serverData:t},{action:`show_conflict_warning`};if(!r)return n?(E_.value={hasConflict:!0,nodeId:e,serverData:t},{action:`show_conflict_warning`}):{action:`update_silently`};let a=new Date(r.node.updatedAt||0).getTime();return new Date(t.node.updatedAt||0).getTime()>a&&n?(E_.value={hasConflict:!0,nodeId:e,serverData:t},{action:`show_conflict_warning`}):{action:`update_silently`}},resolveWithServer:e=>{if(!E_.value.serverData||!E_.value.nodeId)return;let t=E_.value.serverData,n=E_.value.nodeId;a(n),l(String(n),t),e(t),m()},resolveWithLocal:()=>{m()},getCachedInheritedRegion:d,setCachedInheritedRegion:f,persistOfflineDraft:r,getPersistedOfflineDraft:i,clearPersistedOfflineDraft:a,processOfflineQueue:s,markUnverified:o}}var O_={"Content-Type":`application/json`},k_={async getNode(e){return fetch(`/api/cms/nodes.json?id=${e}`)},async getInheritedRegion(e,t,n,r){let i=r?`&channelId=${r}`:``;return fetch(`/api/v1/node/${encodeURIComponent(e)}?treeId=${t}&lang=${n}&preview=true${i}`)},async saveNode(e){return fetch(`/api/cms/nodes.json`,{method:`POST`,headers:O_,body:JSON.stringify({node:e})})},async createInTree(e){return fetch(`/api/cms/tree.json`,{method:`POST`,headers:O_,body:JSON.stringify(e)})},async publishNode(e){return fetch(`/api/cms/nodes/publish`,{method:`POST`,headers:O_,body:JSON.stringify({id:e})})},async deleteNode(e){return fetch(`/api/cms/nodes.json?id=${e}`,{method:`DELETE`})},async restoreNode(e){return fetch(`/api/cms/nodes/restore`,{method:`POST`,headers:O_,body:JSON.stringify({id:e})})},async purgeNode(e){return fetch(`/api/cms/nodes/purge?id=${e}`,{method:`DELETE`})},async toggleVisibility(e,t){return fetch(`/api/cms/nodes.json`,{method:`POST`,headers:O_,body:JSON.stringify({node:{id:e,isHidden:t}})})}},A_=L(typeof navigator<`u`&&!navigator.onLine),j_=L(A_.value?`offline`:`online`),M_=L(!1),N_=L(!1),P_=L(null),F_=L(!1),I_=L(!1);typeof window<`u`&&(window.addEventListener(`online`,()=>{A_.value=!1,j_.value=`online`;let e=D_();e.processOfflineQueue(async t=>{try{let n=e.getPersistedOfflineDraft(t);if(!n)return!0;let r=n.data,i=[];Object.entries(r.blocks||{}).forEach(([e,t])=>{r.regionMeta?.[e]?.isInherited||t.forEach((t,n)=>{i.push({instanceId:String(t.instanceId||t.id),componentId:t.componentId||t.elementType||`text-block`,elementType:t.componentId||t.elementType||`text-block`,region:e,sortOrder:n,data:t.data||{}})})});let a={id:typeof t==`number`?t:Number(t)||null,...r.node,blocks:i};return delete a.isNew,delete a._draftParentId,delete a._isTreeDraft,delete a.trees,(await k_.saveNode(a)).ok}catch{return!1}})}),window.addEventListener(`offline`,()=>{A_.value=!0,j_.value=`offline`}));var L_=L({type:`dashboard`}),R_=L(`content`),z_=L(!1),B_=L([]),V_=L(null),H_=L(``),U_=L(`en`),W_=L([]),G_=L(null),K_=L(``),q_=L([]),J_=L([]),Y_=L(`all`),X_=L(``),Z_=L(`updatedAt`),Q_=L(`DESC`),$_=L(null),ev=L({}),tv=L(null),nv=L(null),rv=L({}),iv=L({}),av=L({}),ov=L({}),sv=L({}),cv=L(!1),lv=L(!1),uv=L(!1),dv=()=>({id:``,title:``,slug:``,nodeType:`node`,channelId:``,language:`en`,isHidden:!1,status:`draft`,publishedAt:null,children:[],disabledRegions:{}}),fv=L(dv()),pv=L({}),mv=L({}),hv=L(null),gv=L({}),_v=L(``),vv=L(``),yv=L(``),bv=L({total:0,byType:[]}),xv=L(!1),Sv=()=>{xv.value=!1},Cv=K(()=>L_.value.type===`dashboard`?`none`:L_.value.type),wv=K(()=>L_.value.type===`node`&&L_.value.id||null),Tv=K(()=>M_.value),Ev=K(()=>fv.value?.id?fv.value.status===`draft`||Ov.value:!1),Dv=(e,t)=>{if(!e)return{};let n={};for(let[t,r]of Object.entries(e))t!==`isHidden`&&t!==`hidden`&&t!==`channels`&&t!==`trees`&&(n[t]=r&&typeof r==`object`&&typeof r.id==`string`&&r.id.startsWith(`ast_`)?r.id:r);let r=e.nodeType||e.contentType,i=r?t[r]:null;if(i?.fields)for(let[e,t]of Object.entries(i.fields))t?.liveSync===!0&&delete n[e];return n},Ov=K(()=>{if(uv.value||!_v.value)return!1;let e=JSON.stringify({node:Dv(fv.value,iv.value),blocks:pv.value}),t=JSON.parse(_v.value||`{}`);return e!==JSON.stringify({node:Dv(t.node||{},iv.value),blocks:t.blocks||{}})}),kv=K(()=>!vv.value||!V_.value?!1:JSON.stringify(V_.value)!==vv.value),Av=K(()=>!yv.value||!G_.value?!1:JSON.stringify(G_.value)!==yv.value),jv=async()=>{let{confirmDiscard:e}=S_(),t=fv.value?.isNew===!0&&String(fv.value?.id||``).startsWith(`draft-`),n=!!(fv.value?.title||``).trim(),r=Object.values(pv.value||{}).some(e=>e.length>0),i=n||r,a=Ov.value&&(!t||i);return Cv.value===`node`&&(a||N_.value)?await e(`You have unsaved changes on the active document. Are you sure you want to discard them?`,`Discard Document Changes?`,`Discard Changes`,`Keep Editing`):!0},Mv=async(e,t=!1)=>{!t&&!await jv()||(L_.value=e,e.type!==`node`&&(fv.value=dv(),_v.value=``,pv.value={}),e.type!==`channel`&&(V_.value=null,vv.value=``),e.type!==`tree`&&(G_.value=null,yv.value=``))},Nv=async(e,t=!1)=>{e===`none`?await Mv({type:`dashboard`},t):await Mv({type:e},t)},Pv=(e=!1)=>Nv(`none`,e),Fv=(e,t=!1)=>Mv({type:`node`,id:e},t),Iv=(e,t=!1)=>Mv({type:`channel`,id:e},t),Lv=(e,t=!1)=>Mv({type:`tree`,id:e},t),Rv=()=>{fv.value=dv(),pv.value={},mv.value={},hv.value=null,gv.value={},_v.value=``,uv.value=!1,M_.value=!1},zv=(e,t,n)=>{if(!e&&!n)return;let r=t=>e&&String(t.id)===String(e)||n&&t.treeNodeId&&String(t.treeNodeId)===String(n);fv.value&&r(fv.value)&&Object.assign(fv.value,t);let i=e=>{if(Array.isArray(e))for(let n=0;n<e.length;n++)r(e[n])&&Object.assign(e[n],t),e[n].children&&e[n].children.length>0&&i(e[n].children)};if(i(q_.value),Array.isArray(J_.value))for(let e=0;e<J_.value.length;e++)r(J_.value[e])&&Object.assign(J_.value[e],t)},Bv=e=>{e.nodes&&(iv.value=e.nodes),e.trees&&(rv.value=e.trees),e.channels&&(ev.value=e.channels),(e.blocks||e.elements)&&(av.value=e.blocks||e.elements),ov.value=e.nodeLayouts&&Object.keys(e.nodeLayouts).length>0?e.nodeLayouts:m_(),sv.value=e.blockLayouts&&Object.keys(e.blockLayouts).length>0?e.blockLayouts:h_(),e.channelTemplate!==void 0&&($_.value=e.channelTemplate),e.userTemplate!==void 0&&(tv.value=e.userTemplate),e.treeTemplate!==void 0&&(nv.value=e.treeTemplate),lv.value=!0},Vv=async(e=`/api/cms/schemas.json`)=>{if(!cv.value){cv.value=!0;try{let t=await fetch(e,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Failed to load schemas`);Bv(await t.json())}catch(e){console.warn(`āš ļø API failed to load schemas, using local fallbacks`,e),iv.value=u_(),rv.value=d_(),ev.value=l_(),av.value=f_(),ov.value=m_(),sv.value=h_(),lv.value=!0}finally{cv.value=!1}}};function Hv(){return{isOffline:A_,connectionStatus:j_,isDocumentUnverified:M_,isPendingOfflineSave:N_,isReadOnlyMode:Tv,isSaving:F_,isAutoSavePending:I_,blockClipboard:P_,activeView:L_,activeViewMode:Cv,activeContentId:wv,setViewMode:Nv,navigateTo:Mv,goToDashboard:Pv,openNode:Fv,openChannel:Iv,openTree:Lv,activeTab:R_,shouldFocusTitle:z_,allChannels:B_,activeChannelSettings:V_,selectedChannelId:H_,selectedLanguage:U_,availableTrees:W_,activeTreeSettings:G_,selectedTreeId:K_,nodeTree:q_,vaultNodes:J_,currentVaultType:Y_,currentVaultSearch:X_,currentVaultSort:Z_,currentVaultOrder:Q_,channelTemplateSchema:$_,channelSchemas:ev,userTemplateSchema:tv,treeTemplateSchema:nv,treeSchemas:rv,nodeSchemas:iv,blockSchemas:av,nodeLayoutSchemas:ov,blockLayoutSchemas:sv,isSchemasLoading:cv,isSchemasLoaded:lv,setSchemas:Bv,fetchSchemas:Vv,isDocumentLoading:uv,activeNode:fv,resetActiveNode:Rv,isNodeDirty:Ov,isChannelDirty:kv,isTreeDirty:Av,hasUnpublishedChanges:Ev,nodeSnapshot:_v,channelSnapshot:vv,siteSnapshot:vv,treeSnapshot:yv,updateNodeInState:zv,blocks:pv,regionMeta:mv,selectedBlock:hv,validationErrors:gv,vaultStats:bv,hasLoadedStats:xv,invalidateStats:Sv,confirmDiscardUnsaved:jv}}var Uv=e=>e==null||typeof e==`string`&&e.trim()===``,Wv={required:(e,t,n)=>(t===!0||String(t).toLowerCase()===`true`)&&Uv(e)?n.rules?.customMessage||`${n.label||`This field`} is required.`:``,min:(e,t,n)=>Uv(e)||typeof t!=`number`?``:typeof e==`number`&&e<t?n.rules?.customMessage||`${n.label||`Field`} must be at least ${t}.`:typeof e==`string`&&e.length<t?n.rules?.customMessage||`${n.label||`Field`} must be at least ${t} characters.`:``,max:(e,t,n)=>Uv(e)||typeof t!=`number`?``:typeof e==`number`&&e>t?n.rules?.customMessage||`${n.label||`Field`} cannot exceed ${t}.`:typeof e==`string`&&e.length>t?n.rules?.customMessage||`${n.label||`Field`} cannot exceed ${t} characters.`:``,email:(e,t,n)=>t!==!0&&String(t).toLowerCase()!==`true`||Uv(e)||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(e))?``:n.rules?.customMessage||`Please enter a valid email address.`,pattern:(e,t,n)=>{if(Uv(e)||!t||typeof t!=`string`)return``;try{if(!new RegExp(t).test(String(e)))return n.rules?.customMessage||`${n.label||`Field`} format is invalid.`}catch{console.warn(`[Validators] Invalid pattern for ${n.label||`field`}:`,t)}return``},unique:async(e,t,n,r)=>(t!==!0&&String(t).toLowerCase()!==`true`||Uv(e),``),uniqueSibling:async(e,t,n,r)=>(t!==!0&&String(t).toLowerCase()!==`true`||Uv(e),``)};function Gv(e,t){Wv[e]=t}function Kv(){let e=Object.assign({"../../definitions/validators/iban.ts":f,"../../definitions/validators/magic-word.ts":m});for(let t in e){let n=e[t];if(!n)continue;let r=t.split(`/`).pop()?.replace(/\.ts$/,``)||``;for(let[e,t]of Object.entries(n))typeof t==`function`&&Gv(e==="default"?r:e,t)}}Kv();function qv(e,t,n){if(!n||typeof n!=`object`)return``;let r=n.rules||{},i={fieldKey:e};if((n.required===!0||String(n.required).toLowerCase()===`true`||r.required===!0||String(r.required).toLowerCase()===`true`)&&Uv(t))return r.customMessage||`${n.label||e} is required.`;for(let[e,a]of Object.entries(r)){if(e===`customMessage`||e===`uniqueMessage`||e===`unique`||e===`uniqueSibling`||e===`required`)continue;let r=Wv[e];if(r){let e=r(t,a,n,i);if(typeof e==`string`&&e!==``)return e}}return``}async function Jv(e,t,n,r){if(!n||typeof n!=`object`)return``;let i=qv(e,t,n);if(i)return i;let a={...n.rules};n.unique!==void 0&&a.unique===void 0&&(a.unique=n.unique);let o={fieldKey:e,entityType:r?.entityType,excludeId:r?.excludeId,formData:r?.formData};for(let[e,r]of Object.entries(a)){if(e===`customMessage`||e===`uniqueMessage`)continue;let i=Wv[e];if(i){let e=await i(t,r,n,o);if(e)return e}}return``}function Yv(e){for(let t in e){let n=e[t];if(n)for(let[e,t]of Object.entries(n))typeof t==`function`&&Gv(e,t)}}function Xv(){let{validationErrors:e}=Hv(),t=(e,t)=>{if(e)return t in e?e[t]:t.split(`.`).reduce((e,t)=>e&&e[t]!==void 0?e[t]:void 0,e)};return{validateAgainstSchema:async(n,r,i)=>{let a={};if(!n||!r)return e.value=a,!0;let o={...r.fields||{}};if(r.tabs&&typeof r.tabs==`object`&&Object.values(r.tabs).forEach(e=>{e?.fields&&(Array.isArray(e.fields)?e.fields.forEach(e=>{typeof e==`object`&&e&&Object.entries(e).forEach(([e,t])=>{o[e]={...o[e]||{},...t}})}):typeof e.fields==`object`&&Object.entries(e.fields).forEach(([e,t])=>{o[e]={...o[e]||{},...t}}))}),Object.keys(o).length===0)return e.value=a,!0;let s=n.id,c=typeof s==`number`||s&&!String(s).startsWith(`draft-`)?String(s):``;for(let[e,r]of Object.entries(o)){if(!r||typeof r!=`object`)continue;let o=await Jv(e,t(n,e),r,{entityType:i,excludeId:c,formData:n});o&&(a[e]=o)}return e.value=a,Object.keys(a).length===0}}}var Zv=null,Qv=null;function $v(){let{allChannels:e,selectedChannelId:t,availableTrees:n,channelSchemas:r,treeSchemas:i}=Hv(),a=async()=>{Zv?.abort(),Zv=new AbortController;try{let[n,i]=await Promise.all([fetch(`/api/cms/schemas.json`,{signal:Zv.signal}),fetch(`/api/cms/channels.json`,{signal:Zv.signal})]);if(n.ok){let e=await n.json();e.channelSchemas&&(r.value=e.channelSchemas)}if(i.ok){let n=await i.json();e.value=n.channels||[],!t.value&&n.channels?.length>0&&(t.value=String(n.channels[0].id))}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[CMS Sync] Failed to fetch channels:`,e)}},o=async()=>{Qv?.abort(),Qv=new AbortController;try{let[e,t]=await Promise.all([fetch(`/api/cms/schemas.json`,{signal:Qv.signal}),fetch(`/api/cms/trees.json`,{signal:Qv.signal})]);if(e.ok){let t=await e.json();t.treeSchemas&&(i.value=t.treeSchemas)}if(t.ok){let e=await t.json();n.value=Array.isArray(e)?e:[]}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[CMS Sync] Failed to load trees:`,e)}};return{fetchChannels:a,fetchTrees:o,syncSystemMetadata:async()=>{await Promise.all([a(),o()])}}}function ey(e){return e===!0||e===1||String(e)===`true`||String(e)===`1`}function ty(e){if(!e)return{isDraft:!1,isUnpublishedDraft:!1,isHidden:!1,isScheduled:!1,isCurrentlyVisible:!1,hasUnpublishedChanges:!1,statusBadge:`active`,badgeLabel:`Unknown`};let t=!!(e.isNew||!e.id||String(e.id).startsWith(`draft-`)),n=!t&&e.status===`draft`&&!e.publishedAt,r=ey(e.isHidden)||ey(e.disabled),i=ey(e.hasUnpublishedChanges)||!!e.publishedAt&&(e.status===`draft`||!e.status),a=e.startShowingAt?new Date(e.startShowingAt).getTime():null,o=e.stopShowingAt?new Date(e.stopShowingAt).getTime():null,s=!!(a||o),c=Date.now(),l=!0,u=`valid`;a&&c<a?(l=!1,u=`pending`):o&&c>o&&(l=!1,u=`expired`);let d=!t&&!n&&!r&&l,f=`active`,p=`Visible`;return t?(f=`draft`,p=`Unsaved`):n?(f=`unpublished_draft`,p=`Draft`):i?(f=`unpublished_changes`,p=`Unpublished Changes`):r?(f=`hidden`,p=`Hidden`):u===`pending`?(f=`scheduled_pending`,p=`Scheduled`):u===`expired`&&(f=`scheduled_expired`,p=`Expired`),{isDraft:t,isUnpublishedDraft:n,isHidden:r,isScheduled:s,isCurrentlyVisible:d,hasUnpublishedChanges:i,statusBadge:f,badgeLabel:p}}function ny(e,t){let n=e.value||{};return Object.keys(n).length===0&&(n=t(),e.value=n),n}function ry(e,t){if(t&&e[t])return t;let n=Object.keys(e||{});return n.length===1?n[0]:``}function iy(e,t){let n={...t?.fields||{},...e?.fields||{}};return e?.tabs&&Object.values(e.tabs).forEach(e=>{e?.fields&&(n={...n,...e.fields})}),n}function ay(e){return Object.values(e||{}).map(e=>({value:e.id,label:e.label||e.id}))}function oy(e,t=!1){let n=t?`label`:`title`;if(!e)return[{key:n,config:{type:`text`,label:`Page Title`}}];let r=iy(e),i=[];for(let[e,t]of Object.entries(r))(t?.showAsEditorTitle===!0||String(t?.showAsEditorTitle).toLowerCase()===`true`)&&i.push({key:e,config:{...t}});if(i.length===0){let t=r[n]?{...r[n]}:{type:`text`,label:e.label||`Page Title`};i.push({key:n,config:t})}return i}var sy=0,cy=0,ly=L({});function uy(){let{allChannels:e,selectedChannelId:t,selectedLanguage:n,availableTrees:r,activeTreeSettings:i,selectedTreeId:a,nodeTree:o,vaultNodes:s,treeTemplateSchema:c,treeSchemas:l,activeNode:u,blocks:d,regionMeta:f,selectedBlock:p,validationErrors:m,nodeSnapshot:h,treeSnapshot:g,activeTab:_,shouldFocusTitle:v,setViewMode:y,currentVaultType:b,currentVaultSearch:x,currentVaultSort:S,currentVaultOrder:C,isTreeDirty:w,confirmDiscardUnsaved:T}=Hv(),{validateAgainstSchema:E}=Xv(),{fetchTrees:D,fetchChannels:ee,syncSystemMetadata:te}=$v(),O=L(!1),k=L(!0),ne=L(0),re=()=>ny(l,d_),ie=()=>{g.value=JSON.stringify(i.value||{})},ae=K(()=>{if(!t.value||t.value===`all`)return r.value.map(e=>({id:e.id,key:e.key,label:e.label||e.key||`Tree ${e.id}`}));let n=e.value.find(e=>String(e.id)===String(t.value));return!n||!Array.isArray(n.trees)?[]:n.trees.map(e=>{let t=typeof e==`object`?e.treeId||e.id:e;if(!t)return null;let n=r.value.find(e=>String(e.id)===String(t)||e.key===t);return n?{id:n.id,key:n.key,label:n.label||n.key||`Tree ${n.id}`}:null}).filter(Boolean)}),A=(e,t,n=null)=>{for(let r of e){if(String(r.id)===String(t)||String(r.treeNodeId)===String(t))return n;if(r.children&&r.children.length>0){let e=A(r.children,t,r);if(e)return e}}return null},oe=(e,t)=>{if(!e||!Array.isArray(e))return!1;for(let n of e){if(String(n.id)===String(t.id)||n.treeNodeId&&String(n.treeNodeId)===String(t.treeNodeId))return n.disabledRegions={...t.disabledRegions||{}},t.channels&&(n.channels=t.channels),t.title&&(n.title=t.title),t.slug&&(n.slug=t.slug),t.isHidden!==void 0&&(n.isHidden=ey(t.isHidden)),!0;if(n.children&&n.children.length>0&&oe(n.children,t))return!0}return!1},se=K(()=>!u.value?.id&&!u.value?.treeNodeId?!1:!!A(o.value,u.value.id||u.value.treeNodeId||``)),ce=e=>ly.value[e]||[],le=async e=>{if(e)try{let r=t.value&&t.value!==`all`?`&channelId=${t.value}`:``,i=await fetch(`/api/cms/tree.json?treeId=${e}&lang=${n.value}&preview=true${r}`);if(i.ok){let t=await i.json(),n=Array.isArray(t)?t:t.tree||[],r=new Set,s=[];for(let e of n){if(e.deletedAt&&String(e.deletedAt).trim()!==``)continue;let t=String(e.treeNodeId||e.id);r.has(t)||(r.add(t),s.push({...e,isHidden:ey(e.isHidden)}))}ly.value[e]=s,String(e)===String(a.value)&&(o.value=s)}}catch(t){console.error(`[CMS] Failed to fetch nodes for tree ${e}:`,t)}},ue=async()=>{if(!a.value){o.value=[];return}++sy,await le(a.value)},j=async(e,r)=>{ly.value[e]=r,String(e)===String(a.value)&&(o.value=r);try{let i={treeId:e,language:n.value,tree:r};t.value&&t.value!==`all`&&(i.channelId=t.value);let a=await fetch(`/api/cms/tree.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(`[Tree Save] HTTP ${a.status}: ${e.error||`Unknown error`}`)}}catch(t){throw console.error(`[Tree Sync] Failed to save node order for tree ${e}:`,t),t}},de=async()=>{a.value&&await j(a.value,ly.value[a.value]||o.value)},fe=async e=>{let n=!1,r=``,i=``;typeof e==`string`?(b.value=e,n=!0):e&&typeof e==`object`&&(n=e.reset??!1,e.type!==void 0&&(b.value=e.type),e.search!==void 0&&(x.value=e.search),e.sort!==void 0&&(S.value=e.sort),e.order!==void 0&&(C.value=e.order),e.ensureItemId&&(r=e.ensureItemId),e.assetId&&(i=e.assetId));let a=Array.isArray(b.value)&&b.value.length>0?b.value.join(`,`):b.value||`all`,o=x.value||``;if(!n&&O.value||!n&&!k.value)return;let c=++cy;n&&(ne.value=0,k.value=!0,s.value=[]),O.value=!0;try{let e=new URLSearchParams({limit:`50`,offset:String(ne.value),sort:S.value,order:C.value});a&&a!==`all`&&e.append(`type`,a),o.trim()&&e.append(`q`,o.trim()),t.value&&t.value!==`all`&&e.append(`channelId`,t.value),r&&e.append(`ensureItemId`,r),i&&e.append(`assetId`,i);let l=await fetch(`/api/cms/nodes.json?${e.toString()}`);if(c!==cy)return;if(!l.ok)throw Error(`Failed to fetch vault nodes (${l.status})`);let u=await l.json(),d=(Array.isArray(u)?u:u.items||[]).map(e=>({...e,isHidden:ey(e.isHidden)}));k.value=!Array.isArray(u)&&!!u.hasMore,s.value=n?d:[...s.value,...d],ne.value+=d.length}catch(e){c===cy&&console.error(`[CMS] Failed to fetch vault nodes:`,e)}finally{c===cy&&(O.value=!1)}},M=async n=>{if(!t.value||t.value===`all`)return;let i=e.value.findIndex(e=>String(e.id)===String(t.value));if(i>-1){let t=e.value[i],o=Array.isArray(t.trees)?[...t.trees]:[],s=r.value.find(e=>String(e.id)===String(n)||e.key===n),c=s?s.id:n,l=s?s.key:String(n);o.some(e=>String(typeof e==`object`?e.treeId||e.id:e)===String(c)||(typeof e==`object`?e.treeId||e.id:e)===l)||(o.push({treeId:c,key:l}),(await fetch(`/api/cms/channels.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,trees:o})})).ok&&await ee()),a.value=String(c),await ue()}},N=async n=>{if(!t.value||t.value===`all`)return;let r=e.value.findIndex(e=>String(e.id)===String(t.value));if(r>-1){let t={...e.value[r]};Array.isArray(t.trees)&&(t.trees=t.trees.filter(e=>String(typeof e==`object`?e.treeId||e.id:e)!==String(n)),await fetch(`/api/cms/channels.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),await ee());let i=ae.value;a.value=i.length>0?String(i[0].id):``,await ue()}},pe=async(n,r)=>{if(!t.value||t.value===`all`)return;let i=e.value.findIndex(e=>String(e.id)===String(t.value));if(i>-1){let t={...e.value[i]},a=Array.isArray(t.trees)?[...t.trees]:[];if(n<0||n>=a.length||r<0||r>=a.length)return;let[o]=a.splice(n,1);a.splice(r,0,o),t.trees=a,e.value[i]=t;try{await fetch(`/api/cms/channels.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}catch(e){console.error(`Failed to reorder channel trees:`,e)}}},me=async()=>{i.value=null,g.value=``,await y(`none`,!0)};return{currentChannelTrees:ae,hasParentNode:se,isLoading:O,hasMore:k,isTreeDirty:w,treeNodesMap:ly,getNodesForTree:ce,fetchNodeTreeForId:le,saveTreeOrderForId:j,reorderChannelTrees:pe,fetchTrees:D,fetchNodeTree:ue,fetchVaultNodes:fe,linkTreeToChannel:M,unlinkTreeFromChannel:N,handleAddNewTree:async()=>{if(!await T())return!1;let e=re(),n=ry(e),r={id:`draft-${Date.now()}`,isNew:!0,key:``,label:``,treeType:n,channels:t.value&&t.value!==`all`?[Number(t.value)||t.value]:[]};if(n&&e[n]){let t=iy(e[n],c.value);for(let[e,n]of Object.entries(t))r[e]===void 0&&(r[e]=n?.default??``)}return i.value=r,ie(),m.value={},await y(`tree`,!0),!0},cancelNewTree:me,saveTreeSettings:async()=>{if(!i.value)return!1;m.value={};let e=re(),n=!i.value.id||String(i.value.id).startsWith(`draft-`),r=i.value.treeType||Object.keys(e)[0]||`navigation`,o=e[r]||{};if(!await E(i.value,{fields:iy(o,c.value)},`tree`))return!1;try{let e=i.value.id,o={...JSON.parse(JSON.stringify(i.value)),id:n?null:typeof e==`number`?e:Number(e)||null,treeType:r};delete o.isNew;let s=await fetch(`/api/cms/trees.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)});if(s.ok){let e=(await s.json()).id;return i.value.id=e,i.value.treeType=r,delete i.value.isNew,await te(),ie(),n&&t.value&&t.value!==`all`?await M(e):(a.value=String(e),await ue()),await y(`tree`,!0),!0}{let e=await s.json().catch(()=>({}));return s.status===409&&e.field&&(m.value={[e.field]:e.error||`This key is already in use.`}),!1}}catch(e){return console.error(`[CMS] Error saving tree settings:`,e),!1}},deleteTree:async t=>{let n=t||i.value?.id;if(n){if(String(n).startsWith(`draft-`)){await me();return}try{let t=await fetch(`/api/cms/trees.json?id=${n}`,{method:`DELETE`});if(t.ok){i.value=null,e.value.forEach(e=>{Array.isArray(e.trees)&&(e.trees=e.trees.filter(e=>{let t=typeof e==`object`?e.treeId||e.id:e;return String(t)!==String(n)}))}),await te();let t=ae.value;if(t.length>0){let e=String(t[0].id);a.value=e,await ue()}else a.value=``,o.value=[],await y(`none`,!0)}else{let e=await t.json().catch(()=>({}));alert(`Failed to delete tree. ${e.error||`Check server console.`}`)}}catch{alert(`Network error: Could not reach server to delete the tree.`)}}},saveTreeOrder:de,attachVaultNodeToTree:async(e,r=null)=>{if(!a.value)return alert(`Please select a Navigation Tree before attaching content.`);try{let i={action:`attach`,contentId:e,treeId:a.value,language:n.value,parentId:r?r.treeNodeId||r.id:null};t.value&&t.value!==`all`&&(i.channelId=t.value),(await fetch(`/api/cms/tree.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)})).ok&&(await ue(),await fe({reset:!0,ensureItemId:String(e)}))}catch(e){console.error(`[CMS] Failed to attach vault node to tree:`,e)}},detachTreeNode:async e=>{try{(await fetch(`/api/cms/tree.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`detach`,treeNodeId:e,treeId:a.value})})).ok&&await ue()}catch(e){console.error(`[CMS] Failed to detach tree node:`,e)}},findParentNodeInTree:A,updateNodeInTree:oe,handleTreeChange:async e=>{if(e?.added?.element?._isNew){if(!await y(`node`))return;let n=e.added.element;delete n._isNew,d.value={},f.value={},p.value=null;let r=ey(n.isHidden),i={...n,parentId:null,isHidden:r,status:`draft`,blocks:[]};t.value&&t.value!==`all`&&(i.channels=[t.value]),await fetch(`/api/cms/nodes.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),u.value={...n,isHidden:r,status:`draft`,isNew:!1,disabledRegions:{}},_.value=`content`,v.value=!0,h.value=JSON.stringify({node:u.value,blocks:d.value})}await de()},openTreeSettings:async e=>{if(!await T())return!1;let n=r.value.find(t=>String(t.id)===String(e)||t.key===e),o=n?.treeType||n?.type||Object.keys(l.value||{})[0]||`navigation`;return i.value=n?{...n,treeType:o,channels:Array.isArray(n.channels)?[...n.channels]:[]}:{id:null,key:String(e),label:String(e),treeType:o,channels:t.value&&t.value!==`all`?[Number(t.value)||t.value]:[]},a.value=String(n?n.id:e),ie(),m.value={},await y(`tree`,!0),!0},checkUnsavedChanges:T,updateTreeSnapshot:ie}}function dy(e){if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)e[t].isNew||String(e[t].id).startsWith(`draft-`)?e.splice(t,1):e[t].children&&e[t].children.length>0&&dy(e[t].children)}function fy(){let e=Hv(),t=uy(),{confirmDiscardUnsaved:n}=e,r=async()=>{if(!await n())return;dy(e.nodeTree.value),e.selectedBlock.value=null,e.setViewMode(`node`),e.validationErrors.value={};let t=e.selectedChannelId.value&&e.selectedChannelId.value!==`all`?Number(e.selectedChannelId.value)||e.selectedChannelId.value:``,r={id:`draft-${Date.now()}`,title:``,slug:``,nodeType:``,layoutId:`inherit`,channelId:t,channels:t?[t]:[],language:e.selectedLanguage.value,status:`draft`,children:[],isNew:!0,_draftParentId:null,_isTreeDraft:!0,disabledRegions:{}};e.nodeTree.value.push(r),e.activeNode.value=r,e.blocks.value={},e.regionMeta.value={},e.activeTab.value=`settings`,e.shouldFocusTitle.value=!0,Ty(e)},i=async t=>{if(!t)return;let n=t.dataJson||t;if(n&&typeof n==`object`){let t=JSON.parse(JSON.stringify(n));t.subpageLayoutId&&t.subpageLayoutId!==`inherit`&&(e.activeNode.value.resolvedLayoutId=t.subpageLayoutId);let r=new Set([`id`,`treeNodeId`,`contentId`,`parentId`,`_draftParentId`,`title`,`slug`,`children`,`isNew`,`nodeType`,`status`,`disabledRegions`]);Object.entries(t).forEach(([t,n])=>{!r.has(t)&&n!=null&&(e.activeNode.value[t]===void 0||e.activeNode.value[t]===``)&&(e.activeNode.value[t]=n)})}try{let{resolveInheritedRegion:r}=Ey(),i=String(e.selectedChannelId.value||``),a=String(e.selectedLanguage.value||`en`),o=n.subpageLayoutId;(!o||o===`inherit`)&&(o=n.resolvedLayoutId||n.layoutId);let s=o?e.nodeLayoutSchemas.value[o]:null,c=[];if(s?.regions)for(let[e,t]of Object.entries(s.regions)){let n=t.inherit||t.inherited;(n===`parent`||n===!0||String(n).toLowerCase()===`true`)&&c.push(e)}for(let n of c){let o=await r(t,n,i,a);o&&o.blocks&&o.blocks.length>0&&(e.blocks.value[n]=JSON.parse(JSON.stringify(o.blocks)),e.regionMeta.value[n]={isInherited:!0,inheritedFromId:String(o.inheritedFromId),inheritedFromTitle:o.inheritedFromTitle})}}catch(e){console.warn(`[Draft Hierarchy] Failed to resolve inherited region:`,e)}};return{handleAddRootNode:r,handleAddChild:async t=>{if(!await n())return;dy(e.nodeTree.value),e.selectedBlock.value=null,e.setViewMode(`node`),e.validationErrors.value={};let r=e.selectedChannelId.value&&e.selectedChannelId.value!==`all`?Number(e.selectedChannelId.value)||e.selectedChannelId.value:``,a=t.treeNodeId||t.id,o={id:`draft-${Date.now()}`,title:``,slug:``,nodeType:``,layoutId:`inherit`,channelId:r,channels:r?[r]:[],language:e.selectedLanguage.value,status:`draft`,children:[],isNew:!0,_draftParentId:a,_isTreeDraft:!0,disabledRegions:{}};t.children||=[],t.children.push(o),e.activeNode.value=o,e.blocks.value={},e.regionMeta.value={},e.activeTab.value=`settings`,e.shouldFocusTitle.value=!0,await i(t),Ty(e)},handleAddSibling:async r=>{if(!await n())return;dy(e.nodeTree.value),e.selectedBlock.value=null,e.setViewMode(`node`),e.validationErrors.value={};let a=r.treeNodeId||r.id||``,o=t.findParentNodeInTree(e.nodeTree.value,a),s=o?o.children:e.nodeTree.value,c=s?s.findIndex(e=>{if(e===r)return!0;let t=e.treeNodeId||e.id;return String(t)===String(a)}):-1,l=e.selectedChannelId.value&&e.selectedChannelId.value!==`all`?Number(e.selectedChannelId.value)||e.selectedChannelId.value:``,u={id:`draft-${Date.now()}`,title:``,slug:``,nodeType:``,layoutId:`inherit`,channelId:l,channels:l?[l]:[],language:e.selectedLanguage.value,status:`draft`,children:[],isNew:!0,_draftParentId:o?o.treeNodeId||o.id:null,_isTreeDraft:!0,disabledRegions:{}};s&&c!==-1?s.splice(c+1,0,u):s&&s.push(u),e.activeNode.value=u,e.blocks.value={},e.regionMeta.value={},e.activeTab.value=`settings`,e.shouldFocusTitle.value=!1,o&&await i(o),Ty(e)}}}var py=null,my=null;function hy(e){if(!e||typeof e!=`object`)return{};try{return JSON.parse(JSON.stringify(e))}catch{return{}}}function gy(e,t,n,r,i,a){let o=Hv(),s=uy(),c=D_(),{confirmDiscardUnsaved:l}=o,u=(e,t)=>{typeof window<`u`&&(window.dispatchEvent(new CustomEvent(`cms-node-updated`,{detail:{nodeId:e,action:t}})),t.startsWith(`asset-`)&&window.dispatchEvent(new CustomEvent(`cms-assets-updated`)))};ri(()=>o.activeNode.value?.nodeType,(e,t)=>{if(o.activeNode.value?.isNew&&e&&e!==t&&!Object.values(o.blocks.value||{}).some(e=>e.length>0)){let t=o.nodeSchemas.value[e];t&&by(o.activeNode.value,t),Ty(o)}});let d=async e=>{if(!await l())return!1;let t=r.value,n=Object.keys(t),i=e;if(i===void 0){let e=o.currentVaultType.value;if(typeof e==`string`&&e!==`all`&&n.includes(e))i=e;else if(Array.isArray(e)){let t=e.filter(e=>n.includes(e));t.length===1&&(i=t[0])}}let s=i?t[i]||o.nodeSchemas.value[i]:null,c=o.selectedChannelId.value&&o.selectedChannelId.value!==`all`?Number(o.selectedChannelId.value)||o.selectedChannelId.value:``,u={id:`draft-${Date.now()}`,isNew:!0,title:``,slug:``,nodeType:i||``,layoutId:`inherit`,channelId:c,language:o.selectedLanguage.value||`en`,status:`draft`,channels:c?[c]:[],disabledRegions:{},_isTreeDraft:!1};s&&by(u,s),o.activeNode.value=u,o.blocks.value={},o.regionMeta.value={},o.selectedBlock.value=null,Ty(o),o.validationErrors.value={};let d=a.value.find(e=>e.key!==`content`&&e.key!==`connections`)?.key||`settings`;return o.activeTab.value=d,o.setViewMode(`node`),o.shouldFocusTitle.value=!0,!0},f=async e=>await d(e),p=async()=>{o.activeNode.value.isNew=!1;let e=t=>{for(let n=t.length-1;n>=0;n--)t[n].isNew||String(t[n].id).startsWith(`draft-`)?t.splice(n,1):t[n].children&&e(t[n].children)};e(o.nodeTree.value),o.selectedBlock.value=null,o.resetActiveNode(),o.nodeTree.value.length>0?await t(o.nodeTree.value[0]):o.setViewMode(`none`,!0)},m=async()=>{if(o.isDocumentUnverified.value||o.isDocumentLoading.value)return;if(o.isOffline.value){c.persistOfflineDraft(o.activeNode.value.id,{node:o.activeNode.value,blocks:o.blocks.value,regionMeta:o.regionMeta.value}),Ty(o);return}let e=o.nodeSchemas.value[o.activeNode.value.nodeType],t=oy(e,o.activeViewMode.value===`channel`||o.activeViewMode.value===`tree`).map(e=>o.activeNode.value[e.key]).filter(e=>e!=null&&String(e).trim()!==``).join(` `),n=o.activeNode.value.slug?String(o.activeNode.value.slug).trim():``;n||=(t.trim()||`draft-page`).toLowerCase().replace(/[^a-z0-9\s-]/g,``).replace(/[\s-]+/g,`-`).replace(/^-+|-+$/g,``)||`draft-page-${Date.now()}`;let r=!!o.activeNode.value._isTreeDraft,i=o.activeNode.value.id||o.activeContentId.value,a=typeof i==`number`?i:Number(i)||null,s=o.activeNode.value.isNew||r||String(i||``).startsWith(`draft-`);if(!s&&!o.isNodeDirty.value&&!o.isPendingOfflineSave.value)return;let l={...o.activeNode.value};l.slug=n,l.status=`draft`,delete l.id,delete l.isNew,delete l._draftParentId,delete l._isTreeDraft,delete l.children,delete l.treeNodeId;let d=ey(o.activeNode.value.isHidden);l.isHidden=d;let f=o.selectedChannelId.value&&o.selectedChannelId.value!==`all`?Number(o.selectedChannelId.value)||o.selectedChannelId.value:null,p=xy(o.activeNode.value.channels).map(e=>typeof e==`string`&&!isNaN(Number(e))?Number(e):e);o.activeNode.value.channels===void 0&&f&&(p=[f]),l.channels=p,l.channelId=p.length>0?p[0]:``;let h=[];Object.entries(o.blocks.value||{}).forEach(([e,t])=>{o.regionMeta.value[e]?.isInherited||Array.isArray(t)&&t.forEach((t,n)=>{h.push({instanceId:String(t.instanceId||t.id||`block-${Date.now()}`),componentId:String(t.componentId||t.elementType||`text`),elementType:String(t.componentId||t.elementType||`text`),region:String(e||`content`),sortOrder:n,data:hy(t.data)})})});try{let e=null,t=null,i;if(i=s&&r?await k_.createInTree({action:`create`,title:l.title||`Untitled Page`,slug:n,nodeType:o.activeNode.value.nodeType,treeId:o.selectedTreeId.value,parentId:o.activeNode.value._draftParentId||null,channels:p,channelId:p.length>0?p[0]:null,isHidden:d,nodeData:{...l,status:`draft`,blocks:h}}):s?await k_.saveNode({id:null,...l,status:`draft`,blocks:h}):await k_.saveNode({id:a,...l,status:`draft`,blocks:h}),i.ok){let r=await i.json();e=r.id||r.nodeId||a,t=r.treeNodeId||null;let l=o.activeNode.value.id;if(o.activeNode.value.id=String(e),o.activeNode.value.slug=n,t?o.activeNode.value.treeNodeId=String(t):delete o.activeNode.value.treeNodeId,o.activeNode.value.isNew=!1,o.activeNode.value.status=`draft`,o.activeNode.value.channels=p,delete o.activeNode.value._isTreeDraft,delete o.activeNode.value._draftParentId,Ty(o),o.nodeTree.value&&t){let r=i=>{for(let a=0;a<i.length;a++){if(i[a]===o.activeNode.value||String(i[a].id)===String(l)||String(i[a].id).startsWith(`draft-`))return i[a].id=String(e),i[a].treeNodeId=String(t||e),i[a].slug=n,i[a].isNew=!1,delete i[a]._isTreeDraft,delete i[a]._draftParentId,!0;if(i[a].children&&r(i[a].children))return!0}return!1};r(o.nodeTree.value)}o.updateNodeInState(e,{slug:n,status:`draft`,isHidden:d},t||o.activeNode.value.treeNodeId),c.clearPersistedOfflineDraft(e),c.invalidateAfterSave(e),c.saveToCache(e,{node:o.activeNode.value,blocks:o.blocks.value,regionMeta:o.regionMeta.value}),o.invalidateStats(),u(e,s?`create`:`update`)}else{let e=await i.json().catch(()=>({}));if(i.status===409&&(e.field===`slug`||e.error?.toLowerCase().includes(`slug`)||e.error?.toLowerCase().includes(`exists`))){let e=Math.random().toString(36).substring(2,6),t=`${n}-${e}`;return o.activeNode.value.slug=t,typeof window<`u`&&window.dispatchEvent(new CustomEvent(`cms-toast`,{detail:{type:`warning`,message:`The URL slug "${n}" was already in use. It has been auto-appended to "${t}".`}})),o.validationErrors.value.slug&&delete o.validationErrors.value.slug,await m()}i.status===409&&e.field&&(o.validationErrors.value={...o.validationErrors.value,[e.field]:e.error||`This value is already in use.`})}}catch(e){console.error(`Network error auto-saving node draft:`,e),c.persistOfflineDraft(a||o.activeNode.value.id,{node:o.activeNode.value,blocks:o.blocks.value,regionMeta:o.regionMeta.value}),Ty(o)}},h=async()=>{o.isSaving.value=!0,o.isAutoSavePending.value=!1,py&&=(clearTimeout(py),null);try{my=m(),await my}finally{my=null,o.isSaving.value=!1}};return ri([()=>o.activeNode.value,()=>o.blocks.value],()=>{if(!o.activeNode.value?.id||o.isDocumentLoading.value||o.activeNode.value.isNew&&!o.activeNode.value.nodeType)return;let e=o.activeNode.value.isNew&&!(o.activeNode.value.title||``).trim();if(!o.isNodeDirty.value||e){o.isAutoSavePending.value=!1;return}o.isAutoSavePending.value=!0,py&&clearTimeout(py),py=setTimeout(()=>{h()},1e3)},{deep:!0}),{handleAddNewNode:d,createVaultNode:f,cancelNewNode:p,saveNewNode:async()=>await m(),saveNode:h,publishNode:async()=>{if(o.isDocumentUnverified.value||!await e())return!1;py||o.isAutoSavePending.value||o.isNodeDirty.value?await h():my&&await my;let t=o.activeNode.value.id||o.activeContentId.value,n=typeof t==`number`?t:Number(t)||null;if(!n)return!1;o.isSaving.value=!0;try{let e=await k_.publishNode(n);if(e.ok){let t=await e.json();return o.activeNode.value.status=`published`,o.activeNode.value.publishedAt=t.publishedAt,o.nodeTree.value&&s.updateNodeInTree(o.nodeTree.value,o.activeNode.value),o.updateNodeInState(n,{status:`published`,publishedAt:t.publishedAt},o.activeNode.value.treeNodeId),Ty(o),c.invalidateAfterSave(n),c.saveToCache(n,{node:o.activeNode.value,blocks:o.blocks.value,regionMeta:o.regionMeta.value}),o.invalidateStats(),o.activeNode.value.treeNodeId&&(await s.saveTreeOrder(),await s.fetchNodeTree()),await s.fetchVaultNodes({reset:!0,ensureItemId:String(n)}),u(n,`publish`),!0}}finally{o.isSaving.value=!1}return!1},deleteNode:async e=>{let t=e||o.activeNode.value?.id||o.activeContentId.value;if(!t||String(t).startsWith(`draft-`))return p(),!0;try{if((await k_.deleteNode(t)).ok)return c.invalidateAfterSave(t),o.invalidateStats(),o.nodeTree.value&&o.nodeTree.value.length>0&&await s.fetchNodeTree(),await s.fetchVaultNodes({reset:!0}),(String(o.activeNode.value?.id)===String(t)||String(o.activeNode.value?.treeNodeId)===String(t))&&p(),u(t,`delete`),!0}catch(e){console.error(`[CMS] Failed to delete node:`,e)}return!1},restoreNode:async e=>{if(!e)return!1;try{if((await k_.restoreNode(e)).ok)return o.invalidateStats(),await s.fetchVaultNodes({reset:!0}),u(e,`restore`),!0}catch(e){console.error(`[CMS] Failed to restore node:`,e)}return!1},purgeNode:async e=>{if(!e)return!1;try{if((await k_.purgeNode(e)).ok)return o.invalidateStats(),await s.fetchVaultNodes({reset:!0}),u(e,`purge`),!0}catch(e){console.error(`[CMS] Failed to purge node:`,e)}return!1},toggleNodeVisibility:async e=>{if(!e||!e.id||String(e.id).startsWith(`draft-`))return!1;let t=!ey(e.isHidden);try{if((await k_.toggleVisibility(e.id,t)).ok)return e.isHidden=t,o.updateNodeInState(e.id,{isHidden:t},e.treeNodeId),Ty(o),u(e.id,`update`),!0}catch(e){console.error(`[CMS] Failed to toggle node visibility:`,e)}return!1}}}var _y=0;function vy(e){return e&&{...e,isHidden:ey(e.isHidden)}}function yy(e,t=!1){if(!e)return``;let n=new Date,r=String(e).toLowerCase().trim(),i=e=>{let n=e=>e.toString().padStart(2,`0`),r=`${e.getFullYear()}-${n(e.getMonth()+1)}-${n(e.getDate())}`;return t?r:`${r}T${n(e.getHours())}:${n(e.getMinutes())}`};if(r===`now`||r===`today`)return i(n);let a=r.match(/^([+-])\s*(\d+)\s*(minute|hour|day|week|month|year)s?$/);if(a){let e=a[1]===`+`?1:-1,t=parseInt(a[2],10)*e,r=a[3],o=new Date(n);return r===`minute`?o.setMinutes(o.getMinutes()+t):r===`hour`?o.setHours(o.getHours()+t):r===`day`?o.setDate(o.getDate()+t):r===`week`?o.setDate(o.getDate()+t*7):r===`month`?o.setMonth(o.getMonth()+t):r===`year`&&o.setFullYear(o.getFullYear()+t),i(o)}return String(e)}function by(e,t){let n=e=>e==null||e===``,r=t=>{t&&Object.entries(t).forEach(([t,r])=>{r?.default!==void 0&&n(e[t])&&(e[t]=r.type===`datetime`||r.type===`date`?yy(r.default,r.type===`date`):r.default)})};r(t?.fields),t?.tabs&&Object.values(t.tabs).forEach(e=>r(e?.fields))}function xy(e){if(!e)return[];if(Array.isArray(e))return e.map(e=>typeof e==`object`&&e?e.id||e.channelId:e).filter(Boolean);if(typeof e==`string`)try{let t=JSON.parse(e);return Array.isArray(t)?xy(t):[e]}catch{return[e]}return[e]}function Sy(e,t,n,r){let i=e?.layoutId;if((!i||i===`inherit`)&&!e?.resolvedLayoutId&&n&&r){let t=r.findParentNodeInTree(n.nodeTree.value,e?._draftParentId||e?.parentId||``);for(;t;){if(t.subpageLayoutId&&t.subpageLayoutId!==`inherit`){i=t.subpageLayoutId;break}if(t.layoutId&&t.layoutId!==`inherit`){i=t.layoutId;break}if(t.resolvedLayoutId){i=t.resolvedLayoutId;break}t=r.findParentNodeInTree(n.nodeTree.value,t.parentId||``)}}if(!i||i===`inherit`){let n=e?.nodeType?t.nodeSchemas.value[e.nodeType]:null;i=e?.resolvedLayoutId||n?.defaultLayout}let a=i?t.nodeLayoutSchemas.value[i]:null;return a?.regions&&Object.keys(a.regions).length>0?a.regions:{content:{label:`Content`}}}var Cy=e=>e===`parent`||e===!0||String(e).toLowerCase()===`true`;function wy(e,t){let n=e.activeNode.value,r=n?.nodeType?e.nodeSchemas.value[n.nodeType]:null,i=n?.layoutId;(!i||i===`inherit`)&&(i=n?.resolvedLayoutId||r?.defaultLayout);let a=i?e.nodeLayoutSchemas.value[i]:null,o=a?.regions&&Object.keys(a.regions).length>0?a.regions:{content:{label:`Content`}},s=new Set(Object.keys(o)),c=t=>{Array.isArray(t)&&t.forEach(t=>{let n=t.componentId||t.elementType,r=e.blockLayoutSchemas.value[n];r?.regions&&Object.keys(r.regions).forEach(n=>{let r=`${t.instanceId||t.id}_${n}`;s.add(r),e.blocks.value[r]&&c(e.blocks.value[r])})})};return t&&Array.isArray(t)&&t.forEach(t=>{let n=t.componentId||t.elementType,r=e.blockLayoutSchemas.value[n];r?.regions&&Object.keys(r.regions).forEach(e=>{let n=`${t.instanceId||t.id}_${e}`;s.add(n)})}),Object.keys(o).forEach(t=>c(e.blocks.value[t]||[])),s}function Ty(e){if(!e.activeNode.value)return;wy(e).forEach(t=>{e.blocks.value[t]||(e.blocks.value[t]=[])}),e.activeNode.value.disabledRegions||(e.activeNode.value.disabledRegions={}),e.activeNode.value.channels||(e.activeNode.value.channels=[]);let t=Dv(JSON.parse(JSON.stringify(e.activeNode.value)),e.nodeSchemas.value),n=JSON.parse(JSON.stringify(e.blocks.value));e.nodeSnapshot.value=JSON.stringify({node:t,blocks:n})}function Ey(){let e=Hv(),t=uy(),n=D_(),r=fy(),{confirmDiscardUnsaved:i}=e,a=()=>Ty(e),o=K(()=>e.nodeSchemas.value[e.activeNode.value?.nodeType]||null),s=K(()=>Sy(e.activeNode.value,{nodeSchemas:e.nodeSchemas,nodeLayoutSchemas:e.nodeLayoutSchemas},e,t)),c=K(()=>{let t=[],n=e.activeNode.value,r=e.nodeSchemas.value[n?.nodeType];if(r){if(r.hasCanvas===!0&&t.push({key:`content`,label:`Content`}),r.tabs&&typeof r.tabs==`object`)for(let[e,n]of Object.entries(r.tabs)){let r=typeof n==`string`?n:n?.label||e;t.push({key:e,label:r})}t.filter(e=>e.key!==`content`).length===0&&t.push({key:`settings`,label:r.label||`Settings`}),t.push({key:`connections`,label:`Connections`})}return t}),l=K(()=>{let t={};for(let[n,r]of Object.entries(e.nodeSchemas.value||{})){let e=r.inTree;(e===!0||String(e)===`true`||e===1)&&(t[n]=r)}return t}),u=K(()=>Object.keys(l.value).map(e=>({value:e,label:l.value[e].label||e}))),d=K(()=>{let t={};for(let[n,r]of Object.entries(e.nodeSchemas.value||{}))r.inVault!==!1&&String(r.inVault)!==`false`&&(t[n]=r);return t}),f=K(()=>Object.keys(d.value).map(e=>({value:e,label:d.value[e].label||e}))),p=K(()=>{let t=e.activeNode.value||{};return!!(t.treeNodeId||t._isTreeDraft===!0||t.parentId||t._draftParentId)}),m=t=>{if(!e.activeNode.value?.nodeType)return t===`settings`||t===`content`||t===`node`?{nodeType:{label:`Select Node Type`,type:`select`,options:p.value?u.value:f.value,rules:{required:!0}}}:{};let n=o.value;if(!n)return{};let r=t;t===`node`&&!n.tabs?.node&&n.tabs?.settings&&(r=`settings`);let i=n.tabs?.[r]?.fields||n.fields||{},a=JSON.parse(JSON.stringify(i));return a.nodeType&&(a.nodeType.type=`select`,a.nodeType.options=p.value?u.value:f.value),a},h=K(()=>Object.keys(e.validationErrors.value).length===0),g=e=>{},_=async()=>{e.validationErrors.value={};let t=!0,n=``,r=o.value;if(!r)return!1;let i={...r.fields||{}};r.tabs&&Object.values(r.tabs).forEach(e=>{Object.assign(i,e.fields||{})});let a=e.activeNode.value?.id,s=typeof a==`number`||a&&!String(a).startsWith(`draft-`)?String(a):``,l=e.activeNode.value?.treeId||e.selectedTreeId.value||e.activeTreeSettings.value?.id,u=e.activeNode.value?._draftParentId??e.activeNode.value?.parentId??null,d={...e.activeNode.value,treeId:l,parentId:u};for(let[a,o]of Object.entries(i)){let i=e.activeNode.value[a],c=await Jv(a,i,o,{entityType:`node`,excludeId:e.activeNode.value?.treeNodeId||s,formData:d});if(c&&(e.validationErrors.value[a]=c,t=!1,!n)){for(let[e,t]of Object.entries(r.tabs||{}))if(t.fields?.[a]){n=e;break}}}if(!t){let t=n||c.value.find(e=>e.key!==`content`&&e.key!==`connections`)?.key||`content`;return e.activeTab.value!==t&&(e.activeTab.value=t),e.shouldFocusTitle.value=!0,!1}return!0},v=(e,t)=>{let n={},r=new Set(t.map(e=>String(e.blockId||e.instanceId||e.id))),i=!0;for(;i;){i=!1;for(let[t,a]of Object.entries(e))if(!n[t]){for(let e of r)if(e&&(t.startsWith(`${e}_`)||t.startsWith(`${e}-`))){n[t]=a,a.forEach(e=>r.add(String(e.blockId||e.instanceId||e.id))),i=!0;break}}}return n},y=async(r,i,a,o)=>{if(!r||r.isNew||String(r.id||``).startsWith(`draft-`))return{blocks:[]};let s=r;for(;s;){let r=s.disabledRegions?.[i],a=n.getCachedDocument(s.id),o=a?.blocks?.[i]?.length>0&&!a?.regionMeta?.[i]?.isInherited;if(r||o)break;let c=t.findParentNodeInTree(e.nodeTree.value,s.id||s.treeNodeId||``);if(!c)break;s=c}let c=String(s?.slug||``).trim().toLowerCase();if(!c||c===`page-title`||c===`untitled`)return{blocks:[]};let l=String(a);(l===`all`||l===`undefined`||l===`null`||!l)&&(l=``);let u=String(o);(u===`undefined`||u===`null`||!u)&&(u=`en`);let d=`${c}_${i}_${e.selectedTreeId.value}_${l}_${u}`,f=n.getCachedInheritedRegion(d);if(f)return f;let p=n.getCachedDocument(s.id);if(p&&p.blocks[i]?.length>0){let e={blocks:p.blocks[i],subRegions:v(p.blocks,p.blocks[i]),inheritedFromId:String(s.id),inheritedFromTitle:s.title||s.slug};return n.setCachedInheritedRegion(d,e),e}try{let t=await k_.getInheritedRegion(c,e.selectedTreeId.value,u,l);if(t.ok){let e=await t.json(),r=e.content?.[i]||[];if(r.length>0){let t={blocks:r,subRegions:v(e.content,r),inheritedFromId:String(s.id),inheritedFromTitle:s.title||s.slug};return n.setCachedInheritedRegion(d,t),t}}}catch(e){console.warn(`āš ļø Failed to fetch inherited region:`,e)}return{blocks:[]}},b=async r=>{if(String(e.activeNode.value?.id)===String(r.id)&&!e.activeNode.value?.isNew||e.activeNode.value?.isNew&&String(e.activeNode.value.id||``).startsWith(`draft-`)||!await i())return;e.selectedBlock.value=null,e.nodeSnapshot.value=``,e.selectedTreeId.value&&(e.nodeTree.value=t.getNodesForTree(e.selectedTreeId.value)),e.isDocumentLoading.value=!0,n.clearConflict(),n.markUnverified(!1);let a=++_y,o=String(r.id),s=n.getCachedDocument(o),l=n.getPersistedOfflineDraft(r.id);dy(e.nodeTree.value),e.validationErrors.value={};let u=e.nodeSchemas.value[r.nodeType]||Object.values(e.nodeSchemas.value)[0],d=t.findParentNodeInTree(e.nodeTree.value,r.id||r.treeNodeId||``),f=xy(r.channels||r.channelId).map(e=>typeof e==`string`&&!isNaN(Number(e))?Number(e):e),p=String(f[0]||e.selectedChannelId.value||``),m=String(r.language||e.selectedLanguage.value||`en`);if(l){e.setViewMode(`node`),e.activeNode.value=JSON.parse(JSON.stringify(l.data.node)),e.blocks.value=JSON.parse(JSON.stringify(l.data.blocks)),e.regionMeta.value=JSON.parse(JSON.stringify(l.data.regionMeta)),Ty(e),e.isDocumentLoading.value=!1,e.isPendingOfflineSave.value=!0;return}if(s){e.setViewMode(`node`),e.activeNode.value=JSON.parse(JSON.stringify(s.node)),e.blocks.value=JSON.parse(JSON.stringify(s.blocks)),e.regionMeta.value=JSON.parse(JSON.stringify(s.regionMeta)),Ty(e),e.isDocumentLoading.value=!1;return}try{let i=await k_.getNode(r.id);if(a!==_y)return;if(i.ok){let o=await i.json(),s=o.node||r,l=s.disabledRegions||{},h=s.channels||s.channelId||f,g={...vy(s),id:s.id||r.id,treeNodeId:s.treeNodeId||r.treeNodeId,isNew:!1,disabledRegions:l,channels:xy(h).map(e=>typeof e==`string`&&!isNaN(Number(e))?Number(e):e),trees:s.trees||[]};by(g,u);let _=Sy(g,{nodeSchemas:e.nodeSchemas,nodeLayoutSchemas:e.nodeLayoutSchemas},e,t),v={};for(let e of Object.keys(_))Cy(_[e].inherit)&&d&&(v[e]=y(d,e,p,m));let b={};for(let[e,t]of Object.entries(v))b[e]=await t;if(a!==_y)return;let x={},S={},C=new Set(Object.keys(_));if(Array.isArray(o.blocks)&&o.blocks.forEach(e=>C.add(e.region||`content`)),C.forEach(e=>{x[e]=[]}),Array.isArray(o.blocks)){let t=new Set;[...o.blocks].sort((e,t)=>{let n=String(e.region||``).includes(`_`),r=String(t.region||``).includes(`_`);return n&&!r?1:!n&&r?-1:0}).forEach(n=>{let r=n.instanceId||n.id;if(t.has(r))return;t.add(r);let i=n.region||`content`;x[i]||(x[i]=[]);let a=e.blockSchemas.value[n.componentId||n.elementType],o=typeof n.data==`string`?JSON.parse(n.data):n.data||{};a?.fields&&Object.entries(a.fields).forEach(([e,t])=>{(o[e]===void 0||o[e]===null)&&(o[e]=t.default===void 0?``:t.default)}),x[i].push({instanceId:String(r),blockId:String(n.blockId||n.instanceId||n.id),componentId:String(n.componentId||n.elementType||`text`),region:i,data:{...o}})})}for(let e of Object.keys(_)){let t=x[e]&&x[e].length>0,n=l[e];if(Cy(_[e].inherit)&&!t&&!n&&d){let t=b[e];if(t&&t.blocks&&t.blocks.length>0){if(x[e]=t.blocks,S[e]={isInherited:!0,inheritedFromId:t.inheritedFromId,inheritedFromTitle:t.inheritedFromTitle},t.subRegions)for(let[n,r]of Object.entries(t.subRegions))n!==e&&Array.isArray(r)&&r.length>0&&(x[n]=r,S[n]={isInherited:!0,inheritedFromId:t.inheritedFromId,inheritedFromTitle:t.inheritedFromTitle})}else S[e]={isInherited:!1}}else S[e]={isInherited:!1}}let w={};Object.keys(x).forEach(e=>{S[e]?.isInherited?w[e]=[]:w[e]=x[e]});let T={node:g,blocks:w,regionMeta:S};if(n.evaluateServerResponse(r.id,T,e.isNodeDirty.value).action===`update_silently`){e.setViewMode(`node`),e.activeNode.value=g,e.blocks.value=x,e.regionMeta.value=S;let i=c.value;if(!i.some(e=>e.key===`content`)&&e.activeTab.value===`content`&&(e.activeTab.value=i.find(e=>e.key!==`content`&&e.key!==`connections`)?.key||`settings`),g.trees&&g.trees.length>0){let n=String(g.trees[0].treeId);e.selectedTreeId.value!==n&&(e.selectedTreeId.value=n,e.nodeTree.value=t.getNodesForTree(n))}await Ir(),Ty(e),n.saveToCache(r.id,{node:g,blocks:x,regionMeta:S})}n.markUnverified(!1)}else n.markUnverified(!0)}catch(e){console.warn(`āš ļø Network error fetching node content:`,e),n.markUnverified(!0)}finally{e.isDocumentLoading.value=!1}},x=async t=>{let n=e=>{for(let r of e){if(String(r.id)===String(t))return r;if(r.children){let e=n(r.children);if(e)return e}}return null},r=n(e.nodeTree.value);r?await b(r):await b({id:String(t),title:`Loading...`,slug:``,nodeType:`node`,channelId:``,language:`en`})};ri([()=>e.activeNode.value?.id,()=>e.activeNode.value?.nodeType],([n,r])=>{if(e.activeNode.value?.isNew&&r){let r=Sy(e.activeNode.value,{nodeSchemas:e.nodeSchemas,nodeLayoutSchemas:e.nodeLayoutSchemas},e,t),i=t.findParentNodeInTree(e.nodeTree.value,e.activeNode.value._draftParentId||e.activeNode.value.parentId||``),a=String(e.selectedChannelId.value||``),o=String(e.selectedLanguage.value||`en`),s={...e.regionMeta.value},c=!1;for(let t of Object.keys(r))if(!s[t]){let l=r[t].inherit;Cy(l)&&i?(s[t]={isInherited:!0},c=!0,y(i,t,a,o).then(r=>{e.activeNode.value?.id===n&&(r&&r.blocks&&r.blocks.length>0?(e.blocks.value[t]=r.blocks,e.regionMeta.value[t]={isInherited:!0,inheritedFromId:r.inheritedFromId,inheritedFromTitle:r.inheritedFromTitle}):e.regionMeta.value[t]={isInherited:!1})})):(s[t]={isInherited:!1},c=!0)}c&&(e.regionMeta.value=s)}},{immediate:!0});let S=gy(_,b,l,d,p,c);return{applySchemaDefaults:by,currentNodeSchema:o,currentLayoutRegions:s,availableNodeTabs:c,treeEligibleNodeSchemas:l,treeEligibleNodeTypes:u,vaultEligibleNodeSchemas:d,vaultEligibleNodeTypes:f,isTreeContext:p,isNodeDirty:e.isNodeDirty,confirmDiscardUnsaved:i,isFormValid:h,getFieldsForTab:m,setFormValidator:g,validateActiveNode:_,loadNodeContent:b,navigateToNodeById:x,resolveInheritedRegion:y,handleAddRootNode:r.handleAddRootNode,handleAddChild:r.handleAddChild,handleAddSibling:r.handleAddSibling,handleAddNewNode:S.handleAddNewNode,createVaultNode:S.createVaultNode,cancelNewNode:S.cancelNewNode,saveNewNode:S.saveNewNode,saveNode:S.saveNode,publishNode:S.publishNode,deleteNode:S.deleteNode,restoreNode:S.restoreNode,purgeNode:S.purgeNode,toggleNodeVisibility:S.toggleNodeVisibility,updateNodeSnapshot:a}}function Dy(){let{allChannels:e,activeChannelSettings:t,selectedChannelId:n,selectedLanguage:r,channelSnapshot:i,channelTemplateSchema:a,channelSchemas:o,validationErrors:s,setViewMode:c,isChannelDirty:l,confirmDiscardUnsaved:u}=Hv(),{validateAgainstSchema:d}=Xv(),{fetchChannels:f,syncSystemMetadata:p}=$v(),m=()=>ny(o,l_),h=K(()=>ay(m())),g=()=>{i.value=JSON.stringify(t.value||{})},_=async()=>{if(!t.value)return!1;s.value={};let r=m(),i=t.value.channelType||t.value.type||Object.keys(r)[0]||`website`,o=iy(r[i]||a.value,a.value);if(!await d(t.value,{fields:o},`channel`))return!1;try{let r=t.value.id,a=t.value.isNew||String(r||``).startsWith(`draft-`)?null:typeof r==`number`?r:Number(r)||null,o={...JSON.parse(JSON.stringify(t.value)),id:a,channelType:i};delete o.isNew;let l=await fetch(`/api/cms/channels.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)});if(l.ok){let r=await l.json();t.value.id=r.id,delete t.value.isNew,await p(),n.value=String(r.id);let a=e.value.find(e=>String(e.id)===String(r.id));return a&&(t.value={...a,channelType:a.channelType||a.type||i,trees:Array.isArray(a.trees)?[...a.trees]:[]}),g(),await c(`channel`,!0),!0}{let e=await l.json().catch(()=>({}));return l.status===409&&e.field?s.value={[e.field]:e.error||`This key is already in use.`}:alert(e.error||`Failed to save channel settings.`),!1}}catch(e){return console.error(`[CMS] Error saving channel:`,e),!1}},v=async()=>{t.value=null,i.value=``,await c(`none`,!0)},y=async e=>{let r=e||t.value?.id;if(r){if(String(r).startsWith(`draft-`)){await v();return}try{let e=await fetch(`/api/cms/channels.json?id=${r}`,{method:`DELETE`});if(e.ok)t.value=null,i.value=``,await p(),n.value=`all`,await c(`none`,!0);else{let t=await e.json().catch(()=>({}));alert(`Failed to delete channel. ${t.error||`Check server console.`}`)}}catch{alert(`Network error: Could not reach server to delete the channel.`)}}},b=async()=>{if(!await u())return!1;let r=n.value;(!r||r===`all`)&&e.value.length>0&&(r=String(e.value[0].id),n.value=r);let i=e.value.find(e=>String(e.id)===String(r));if(i){let e=m(),n=Object.keys(e)[0]||`website`,r=i.channelType||i.type||n,a=JSON.parse(JSON.stringify(i));a.channelType=r,a.trees=Array.isArray(i.trees)?[...i.trees]:[];let o=e[r];if(o){let e={};by(e,o),Object.keys(e).forEach(t=>{(a[t]===void 0||a[t]===null)&&(a[t]=e[t])})}t.value=a,g(),s.value={},await c(`channel`,!0)}return!0},x=async e=>{if(!await u())return!1;let n=m(),r=ry(n,e),i=r?n[r]:null,a={id:`draft-${Date.now()}`,isNew:!0,key:``,label:``,channelType:r,domain:`localhost`,baseUrl:`http://localhost:3000`,defaultLanguage:`en`,trees:[]};return i&&by(a,i),t.value=a,g(),s.value={},await c(`channel`,!0),!0};return{allChannels:e,activeChannelSettings:t,selectedChannelId:n,selectedLanguage:r,isChannelDirty:l,channelTypeOptions:h,confirmDiscardUnsaved:u,fetchChannels:f,saveChannelSettings:_,cancelNewChannel:v,deleteChannel:y,openCurrentChannelSettings:b,handleAddNewChannel:x,onChannelSelectChange:async e=>{let r=e.target,i=String(t.value?.id||`all`);r.value===`__add_new__`?await x()||Ir(()=>{n.value=i}):await b()||Ir(()=>{n.value=i})},updateChannelSnapshot:g}}var Oy=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},ky=e=>e===``,Ay=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),jy=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),My=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Ny=e=>{let t=My(e);return t.charAt(0).toUpperCase()+t.slice(1)},Py={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},Fy=({name:e,iconNode:t,absoluteStrokeWidth:n,"absolute-stroke-width":r,strokeWidth:i,"stroke-width":a,size:o=Py.width,color:s=Py.stroke,...c},{slots:l})=>Uo(`svg`,{...Py,...c,width:o,height:o,stroke:s,"stroke-width":ky(n)||ky(r)||n===!0||r===!0?Number(i||a||Py[`stroke-width`])*24/Number(o):i||a||Py[`stroke-width`],class:Ay(`lucide`,c.class,...e?[`lucide-${jy(Ny(e))}-icon`,`lucide-${jy(e)}`]:[`lucide-icon`]),...!l.default&&!Oy(c)&&{"aria-hidden":`true`}},[...t.map(e=>Uo(...e)),...l.default?[l.default()]:[]]),q=(e,t)=>(n,{slots:r,attrs:i})=>Uo(Fy,{...i,...n,iconNode:t,name:e},r),Iy=q(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ly=q(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Ry=q(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),zy=q(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),By=q(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Vy=q(`bold`,[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]),Hy=q(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),Uy=q(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),Wy=q(`chart-no-axes-column`,[[`path`,{d:`M5 21v-6`,key:`1hz6c0`}],[`path`,{d:`M12 21V3`,key:`1lcnhd`}],[`path`,{d:`M19 21V9`,key:`unv183`}]]),Gy=q(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ky=q(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),qy=q(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Jy=q(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Yy=q(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Xy=q(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Zy=q(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Qy=q(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),$y=q(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),eb=q(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),tb=q(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),nb=q(`crop`,[[`path`,{d:`M6 2v14a2 2 0 0 0 2 2h14`,key:`ron5a4`}],[`path`,{d:`M18 22V8a2 2 0 0 0-2-2H2`,key:`7s9ehn`}]]),rb=q(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ib=q(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ab=q(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),ob=q(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),sb=q(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),cb=q(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),lb=q(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),ub=q(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),db=q(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),fb=q(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),pb=q(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),mb=q(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),hb=q(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),gb=q(`heading-4`,[[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17 10v3a1 1 0 0 0 1 1h3`,key:`tj5zdr`}],[`path`,{d:`M21 10v8`,key:`1kdml4`}],[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}]]),_b=q(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),vb=q(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),yb=q(`italic`,[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]),bb=q(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),xb=q(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Sb=q(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),Cb=q(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),wb=q(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),Tb=q(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),Eb=q(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Db=q(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),Ob=q(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),kb=q(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Ab=q(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),jb=q(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),Mb=q(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Nb=q(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Pb=q(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Fb=q(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ib=q(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),Lb=q(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Rb=q(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),zb=q(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Bb=q(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Vb=q(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Hb=q(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ub=q(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Wb=q(`strikethrough`,[[`path`,{d:`M16 4H9a3 3 0 0 0-2.83 4`,key:`43sutm`}],[`path`,{d:`M14 12a4 4 0 0 1 0 8H6`,key:`nlfj13`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),Gb=q(`subscript`,[[`path`,{d:`m4 5 8 8`,key:`1eunvl`}],[`path`,{d:`m12 5-8 8`,key:`1ah0jp`}],[`path`,{d:`M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07`,key:`e8ta8j`}]]),Kb=q(`superscript`,[[`path`,{d:`m4 19 8-8`,key:`hr47gm`}],[`path`,{d:`m12 19-8-8`,key:`1dhhmo`}],[`path`,{d:`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`,key:`1dfcux`}]]),qb=q(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Jb=q(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Yb=q(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),Xb=q(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Zb=q(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Qb=q(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),$b=[`disabled`],ex=yi({__name:`CmsButton`,props:{variant:{},size:{},disabled:{type:Boolean}},setup(e){return(t,n)=>(z(),B(`button`,{class:w([`cms-btn`,`btn-${e.variant||`primary`}`,e.size===`sm`?`btn-sm`:`btn-md`]),disabled:e.disabled},[$i(t.$slots,`default`,{},void 0,!0)],10,$b))}}),tx=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},nx=tx(ex,[[`__scopeId`,`data-v-ffc5ce5f`]]),rx={class:`logo-area`},ix={class:`version-link`,href:`https://kama.t3cloud.eu`,target:`_blank`,rel:`noreferrer`},ax={key:0,class:`center-status-area`},ox={class:`user-area`},sx={class:`user-name`},cx={class:`user-avatar`},lx={class:`modal-content`},ux={class:`modal-header`},dx={class:`modal-body dynamic-form`},fx={class:`form-group`},px={class:`form-group`},mx={class:`form-group`},hx={class:`modal-footer`},gx=tx(yi({__name:`GlobalTopBar`,setup(e){let t=L(!1),{goToDashboard:n,isOffline:r,isReadOnlyMode:i,isPendingOfflineSave:a}=Hv(),o=L({firstName:`Admin`,lastName:`User`,email:`admin@kama-cms.com`}),s=K(()=>o.value.firstName||o.value.lastName?`${o.value.firstName} ${o.value.lastName}`.trim():o.value.email.split(`@`)[0]),c=K(()=>i.value?{text:`Unverified Document (Read-Only)`,icon:Jb,class:`status-danger`}:r.value?{text:`Working Offline — Saving locally`,icon:Zb,class:`status-warning`}:a.value?{text:`Reconnected — Syncing offline queue...`,icon:Lb,class:`status-info`,spin:!0}:null),l=()=>{t.value=!1},u=e=>{e.key===`Escape`&&t.value&&(t.value=!1)};return Xs(()=>window.addEventListener(`keydown`,u)),ec(()=>window.removeEventListener(`keydown`,u)),(e,r)=>(z(),B(W,null,[H(`header`,{class:w([`global-top-bar`,{"has-status-bg":c.value}])},[H(`div`,rx,[H(`button`,{class:`logo`,title:`Go to Dashboard`,onClick:r[0]||=(...e)=>R(n)&&R(n)(...e)},[...r[8]||=[Eo(`<svg id="b" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 117.14 27.38" data-v-7ff0bd90><g id="c" data-v-7ff0bd90><path d="M22.48,22.51c1.94,2.9,2.37,3.49,3.49,4.87h-8.56c-.46-1.05-1.42-2.8-2.27-4.18l-5.1-8.16-3.32,3.32v4.15c0,2.04.07,3.13.26,4.87H0c.2-1.68.26-2.9.26-4.87V4.87C.26,2.86.2,1.58,0,0h6.98c-.2,1.71-.26,2.8-.26,4.87v5.83l6.55-7.01c1.28-1.35,2.14-2.47,2.86-3.69h8.89c-.59.59-.82.86-1.28,1.32l-2.3,2.3-6.88,7.21,7.93,11.68Z" data-v-7ff0bd90></path><path d="M46.97,27.38c-.26-1.58-.46-2.44-.79-3.55l-.89-2.8h-9.38l-.89,2.8c-.43,1.32-.66,2.34-.82,3.55h-7.7c.49-.99.79-1.78,1.58-4.02l7.11-19.81c.59-1.61.89-2.6,1.05-3.55h8.59c.23.95.46,1.81,1.12,3.55l7.14,19.81c.63,1.74,1.15,3.09,1.58,4.02h-7.7ZM40.55,5.63l-3.06,9.87h6.19l-3.13-9.87Z" data-v-7ff0bd90></path><path d="M68.92,27.38c-.16-1.15-.53-2.37-1.42-4.87l-3.03-8.75c-.03-.16-1.02-3.23-1.12-3.49q-.36-1.18-.53-1.65c.2,2.07.33,4.77.33,6.52v7.14c0,2.27.07,3.72.26,5.1h-6.48c.2-1.48.26-2.86.26-5.1V5.13c0-1.97-.1-3.72-.26-5.13h8.69c.23,1.42.49,2.47,1.25,4.64l4.94,14.19,4.9-14.19c.76-2.21,1.02-3.26,1.22-4.64h8.72c-.2,1.58-.26,2.93-.26,5.13v17.15c0,2.5.07,3.78.26,5.1h-6.48c.2-1.51.26-2.77.26-5.1v-7.18c0-.79.1-3.26.16-4.28q.1-1.74.13-2.24c-.72,2.57-1.05,3.75-1.48,4.94l-3.19,9.02c-.82,2.34-1.25,3.79-1.42,4.84h-5.73Z" data-v-7ff0bd90></path><path d="M109.44,27.38c-.26-1.58-.46-2.44-.79-3.55l-.89-2.8h-9.38l-.89,2.8c-.43,1.32-.66,2.34-.82,3.55h-7.7c.49-.99.79-1.78,1.58-4.02l7.11-19.81c.59-1.61.89-2.6,1.05-3.55h8.59c.23.95.46,1.81,1.12,3.55l7.14,19.81c.63,1.74,1.15,3.09,1.58,4.02h-7.7ZM103.02,5.63l-3.06,9.87h6.19l-3.13-9.87Z" data-v-7ff0bd90></path></g></svg>`,1)]]),H(`a`,ix,` v`+I(R(`0.1.0-alpha.113`)),1)]),G(wu,{name:`fade`},{default:Jr(()=>[c.value?(z(),B(`div`,ax,[H(`div`,{class:w([`status-badge`,c.value.class])},[(z(),V(qi(c.value.icon),{size:13,class:w({"animate-spin":c.value.spin})},null,8,[`class`])),H(`span`,null,I(c.value.text),1)],2)])):U(``,!0)]),_:1}),H(`div`,ox,[H(`button`,{class:`user-profile-btn`,onClick:r[1]||=e=>t.value=!0},[H(`span`,sx,I(s.value),1),H(`div`,cx,[G(R(Xb),{size:15})])])])],2),(z(),V(xs,{to:`body`},[G(wu,{name:`modal-fade`},{default:Jr(()=>[t.value?(z(),B(`div`,{key:0,class:`modal-backdrop`,onClick:r[7]||=dd(e=>t.value=!1,[`self`])},[H(`div`,lx,[H(`div`,ux,[r[9]||=H(`h3`,null,`User Preferences`,-1),H(`button`,{class:`close-btn`,onClick:r[2]||=e=>t.value=!1},[G(R(Qb),{size:16})])]),H(`div`,dx,[H(`div`,fx,[r[10]||=H(`div`,{class:`label-row`},[H(`label`,null,`First Name`)],-1),Yr(H(`input`,{type:`text`,"onUpdate:modelValue":r[3]||=e=>o.value.firstName=e,placeholder:`First Name`},null,512),[[id,o.value.firstName]])]),H(`div`,px,[r[11]||=H(`div`,{class:`label-row`},[H(`label`,null,`Last Name`)],-1),Yr(H(`input`,{type:`text`,"onUpdate:modelValue":r[4]||=e=>o.value.lastName=e,placeholder:`Last Name`},null,512),[[id,o.value.lastName]])]),H(`div`,mx,[r[12]||=H(`div`,{class:`label-row`},[H(`label`,null,`E-mail`),H(`span`,{class:`help-text-inline`},`(Used as username)`)],-1),Yr(H(`input`,{type:`email`,"onUpdate:modelValue":r[5]||=e=>o.value.email=e,placeholder:`email@example.com`},null,512),[[id,o.value.email]])])]),H(`div`,hx,[G(nx,{variant:`secondary`,onClick:r[6]||=e=>t.value=!1},{default:Jr(()=>[...r[13]||=[To(` Cancel `,-1)]]),_:1}),G(nx,{variant:`primary`,onClick:l},{default:Jr(()=>[...r[14]||=[To(` Save Preferences `,-1)]]),_:1})])])])):U(``,!0)]),_:1})]))],64))}}),[[`__scopeId`,`data-v-7ff0bd90`]]),_x=[`disabled`],vx={class:`trigger-label`},yx={key:0,class:`select-menu`,role:`listbox`},bx=[`onClick`],xx=[`onClick`],Sx={class:`option-content-wrapper`},Cx={class:`option-content`},wx={class:`option-label`},Tx={key:0,class:`option-subtitle`},Ex={class:`option-meta-actions`},Dx=[`title`,`onClick`],Ox=tx(yi({__name:`CmsSelect`,props:{modelValue:{},options:{},placeholder:{default:`Select an option...`},disabled:{type:Boolean,default:!1},icon:{}},emits:[`update:modelValue`,`change`,`add-new`,`option-action`],setup(e,{emit:t}){let n=e,r=t,i=L(!1),a=L(null),o=()=>{n.disabled||(i.value=!i.value)},s=()=>{i.value=!1},c=e=>{if(!e.disabled){if(e.isAddNew){r(`add-new`),s();return}r(`update:modelValue`,e.id),r(`change`,e.id),s()}},l=(e,t)=>{e.stopPropagation(),r(`option-action`,t.id),s()},u=e=>{a.value&&!a.value.contains(e.target)&&s()};Xs(()=>window.addEventListener(`click`,u)),ec(()=>window.removeEventListener(`click`,u));let d=K(()=>n.options.find(e=>String(e.id)===String(n.modelValue)));return(t,n)=>(z(),B(`div`,{ref_key:`dropdownRef`,ref:a,class:w([`cms-select-wrapper`,{"is-open":i.value,"is-disabled":e.disabled}])},[H(`button`,{type:`button`,class:`select-trigger`,onClick:o,disabled:e.disabled},[e.icon?(z(),V(qi(e.icon),{key:0,size:14,class:`trigger-icon`})):U(``,!0),H(`span`,vx,I(d.value?.label||e.placeholder),1),G(R(Ky),{size:13,class:`caret-icon`})],8,_x),G(wu,{name:`dropdown-fade`},{default:Jr(()=>[i.value?(z(),B(`ul`,yx,[(z(!0),B(W,null,Zi(e.options,t=>(z(),B(W,{key:String(t.id)},[t.isAddNew?(z(),B(`li`,{key:0,class:`menu-item add-new-item`,onClick:e=>c(t)},[(z(),V(qi(t.icon||R(Fb)),{size:13,class:`add-icon`})),H(`span`,null,I(t.label),1)],8,bx)):(z(),B(`li`,{key:1,class:w([`menu-item`,{"is-selected":String(t.id)===String(e.modelValue),"is-disabled":t.disabled}]),onClick:e=>c(t)},[H(`div`,Sx,[t.icon?(z(),V(qi(t.icon),{key:0,size:13,class:`option-lead-icon`})):U(``,!0),H(`div`,Cx,[H(`span`,wx,I(t.label),1),t.subtitle?(z(),B(`span`,Tx,I(t.subtitle),1)):U(``,!0)])]),H(`div`,Ex,[String(t.id)===String(e.modelValue)?(z(),V(R(Gy),{key:0,size:13,class:`check-icon`})):U(``,!0),t.hasAction?(z(),B(`button`,{key:1,type:`button`,class:`option-action-btn`,title:t.actionTitle||`Settings`,onClick:e=>l(e,t)},[(z(),V(qi(t.actionIcon||R(Hb)),{size:12}))],8,Dx)):U(``,!0)])],10,xx))],64))),128))])):U(``,!0)]),_:1})],2))}}),[[`__scopeId`,`data-v-3ef89cc7`]]),kx={class:`channel-selector-row`},Ax=tx(yi({__name:`ChannelOperations`,setup(e){let{allChannels:t,selectedChannelId:n,activeChannelSettings:r,activeViewMode:i,setViewMode:a,resetActiveNode:o}=Hv(),{openCurrentChannelSettings:s,handleAddNewChannel:c,openChannelSettings:l}=Dy(),{confirmDiscardUnsaved:u}=Ey(),d=K(()=>i.value===`channel`),f=K(()=>{let e=[{id:`all`,label:`All Channels`}];if(Array.isArray(t.value)&&t.value.forEach(t=>{t&&t.id!==void 0&&e.push({id:String(t.id),label:t.label||t.key||`Channel ${t.id}`,subtitle:t.domain||void 0,hasAction:!0,actionIcon:Hb,actionTitle:`Channel Settings`})}),d.value&&r.value?.id){let t=String(r.value.id);(t.startsWith(`draft-`)||r.value.isNew)&&(e.some(e=>String(e.id)===t)||e.push({id:t,label:r.value.label||`New Channel...`}))}return e.push({id:`__add_new__`,label:`Add Channel...`,isAddNew:!0}),e}),p=K(()=>{if(d.value&&r.value?.id){let e=String(r.value.id);if(e.startsWith(`draft-`)||r.value.isNew)return e}return n.value?String(n.value):`all`}),m=async e=>{await u()&&(e===`__add_new__`?await c():(n.value=String(e),d.value&&e!==`all`?await s():(a(`none`),o())))},h=async e=>{await u()&&(n.value=String(e),typeof l==`function`?await l(e):await s())};return(e,t)=>(z(),B(`div`,kx,[G(Ox,{"model-value":p.value,options:f.value,icon:R(fb),onChange:m,onAddNew:t[0]||=e=>m(`__add_new__`),onOptionAction:h},null,8,[`model-value`,`options`,`icon`])]))}}),[[`__scopeId`,`data-v-fb02e871`]]);function jx(e){Object.getOwnPropertySymbols(e).forEach(t=>{$w[t]=e[t]})}function Mx(e,t=``){return{type:0,source:t,children:e,helpers:new Set,components:[],directives:[],hoists:[],imports:[],cached:[],temps:0,codegenNode:void 0,loc:iT}}function Nx(e,t,n,r,i,a,o,s=!1,c=!1,l=!1,u=iT){return e&&(s?(e.helper(yw),e.helper(Zx(e.inSSR,l))):e.helper(Xx(e.inSSR,l)),o&&e.helper(jw)),{type:13,tag:t,props:n,children:r,patchFlag:i,dynamicProps:a,directives:o,isBlock:s,disableTracking:c,isComponent:l,loc:u}}function Px(e,t=iT){return{type:17,loc:t,elements:e}}function Fx(e,t=iT){return{type:15,loc:t,properties:e}}function Ix(e,t){return{type:16,loc:iT,key:F(e)?Lx(e,!0):e,value:t}}function Lx(e,t=!1,n=iT,r=0){return{type:4,loc:n,content:e,isStatic:t,constType:t?3:r}}function Rx(e,t){return{type:5,loc:t,content:F(e)?Lx(e,!1,t):e}}function zx(e,t=iT){return{type:8,loc:t,children:e}}function Bx(e,t=[],n=iT){return{type:14,loc:n,callee:e,arguments:t}}function Vx(e,t=void 0,n=!1,r=!1,i=iT){return{type:18,params:e,returns:t,newline:n,isSlot:r,loc:i}}function Hx(e,t,n,r=!0){return{type:19,test:e,consequent:t,alternate:n,newline:r,loc:iT}}function Ux(e,t,n=!1,r=!1){return{type:20,index:e,value:t,needPauseTracking:n,inVOnce:r,needArraySpread:!1,loc:iT}}function Wx(e){return{type:21,body:e,loc:iT}}function Gx(e){return{type:22,elements:e,loc:iT}}function Kx(e,t,n){return{type:23,test:e,consequent:t,alternate:n,loc:iT}}function qx(e,t){return{type:24,left:e,right:t,loc:iT}}function Jx(e){return{type:25,expressions:e,loc:iT}}function Yx(e){return{type:26,returns:e,loc:iT}}function Xx(e,t){return e||t?Sw:Cw}function Zx(e,t){return e||t?bw:xw}function Qx(e,{helper:t,removeHelper:n,inSSR:r}){e.isBlock||(e.isBlock=!0,n(Xx(r,e.isComponent)),t(yw),t(Zx(r,e.isComponent)))}function $x(e){return e>=97&&e<=122||e>=65&&e<=90}function eS(e){return e===32||e===10||e===9||e===12||e===13}function tS(e){return e===47||e===62||eS(e)}function nS(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function rS(e,{compatConfig:t}){let n=t&&t[e];return e===`MODE`?n||3:n}function iS(e,t){let n=rS(`MODE`,t),r=rS(e,t);return n===3?r===!0:r!==!1}function aS(e,t,n,...r){return iS(e,t)}function oS(e,t,n,...r){if(rS(e,t)===`suppress-warning`)return;let{message:i,link:a}=uT[e],o=`(deprecation ${e}) ${typeof i==`function`?i(...r):i}${a?`
1238
1238
  Details: ${a}`:``}`,s=SyntaxError(o);s.code=e,n&&(s.loc=n),t.onWarn(s)}function sS(e){throw e}function cS(e){}function lS(e,t,n,r){let i=`https://vuejs.org/error-reference/#compiler-${e}`,a=SyntaxError(String(i));return a.code=e,a.loc=t,a}function uS(e,t,n=!1,r=[],i=Object.create(null)){}function iee(e,t,n){return!1}function aee(e,t){if(e&&(e.type===`ObjectProperty`||e.type===`ArrayPattern`)){let e=t.length;for(;e--;){let n=t[e];if(n.type===`AssignmentExpression`)return!0;if(n.type!==`ObjectProperty`&&!n.type.endsWith(`Pattern`))break}}return!1}function oee(e){let t=e.length;for(;t--;){let n=e[t];if(n.type===`NewExpression`)return!0;if(n.type!==`MemberExpression`)break}return!1}function see(e,t){for(let n of e.params)for(let e of fS(n))t(e)}function dS(e,t){let n=e.type===`SwitchCase`?e.consequent:e.body;for(let e of n)if(e.type===`VariableDeclaration`){if(e.declare)continue;for(let n of e.declarations)for(let e of fS(n.id))t(e)}else if(e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`){if(e.declare||!e.id)continue;t(e.id)}else cee(e)?lee(e,!0,t):e.type===`SwitchStatement`&&uee(e,!0,t)}function cee(e){return e.type===`ForOfStatement`||e.type===`ForInStatement`||e.type===`ForStatement`}function lee(e,t,n){let r=e.type===`ForStatement`?e.init:e.left;if(r&&r.type===`VariableDeclaration`&&(r.kind===`var`?t:!t))for(let e of r.declarations)for(let t of fS(e.id))n(t)}function uee(e,t,n){for(let r of e.cases){for(let e of r.consequent)if(e.type===`VariableDeclaration`&&(e.kind===`var`?t:!t))for(let t of e.declarations)for(let e of fS(t.id))n(e);dS(r,n)}}function fS(e,t=[]){switch(e.type){case`Identifier`:t.push(e);break;case`MemberExpression`:let n=e;for(;n.type===`MemberExpression`;)n=n.object;t.push(n);break;case`ObjectPattern`:for(let n of e.properties)n.type===`RestElement`?fS(n.argument,t):fS(n.value,t);break;case`ArrayPattern`:e.elements.forEach(e=>{e&&fS(e,t)});break;case`RestElement`:fS(e.argument,t);break;case`AssignmentPattern`:fS(e.left,t)}return t}function pS(e){return gT.includes(e.type)?pS(e.expression):e}function mS(e){switch(e){case`Teleport`:case`teleport`:return hw;case`Suspense`:case`suspense`:return gw;case`KeepAlive`:case`keep-alive`:return _w;case`BaseTransition`:case`base-transition`:return vw}}function hS(e,t,n=t.length){return gS({offset:e.offset,line:e.line,column:e.column},t,n)}function gS(e,t,n=t.length){let r=0,i=-1;for(let e=0;e<n;e++)t.charCodeAt(e)===10&&(r++,i=e);return e.offset+=n,e.line+=r,e.column=i===-1?e.column+n:n-i,e}function _S(e,t){if(!e)throw Error(t||`unexpected compiler condition`)}function vS(e,t,n=!1){for(let r=0;r<e.props.length;r++){let i=e.props[r];if(i.type===7&&(n||i.exp)&&(F(t)?i.name===t:t.test(i.name)))return i}}function yS(e,t,n=!1,r=!1){for(let i=0;i<e.props.length;i++){let a=e.props[i];if(a.type===6){if(n)continue;if(a.name===t&&(a.value||r))return a}else if(a.name===`bind`&&(a.exp||r)&&bS(a.arg,t))return a}}function bS(e,t){return!!(e&&_T(e)&&e.content===t)}function xS(e){return e.props.some(e=>e.type===7&&e.name===`bind`&&(!e.arg||e.arg.type!==4||!e.arg.isStatic))}function SS(e){return e.type===5||e.type===2}function CS(e){return e.type===7&&e.name===`pre`}function wS(e){return e.type===7&&e.name===`slot`}function TS(e){return e.type===1&&e.tagType===3}function ES(e){return e.type===1&&e.tagType===2}function DS(e,t=[]){if(e&&!F(e)&&e.type===14){let n=e.callee;if(!F(n)&&jT.has(n))return DS(e.arguments[0],t.concat(e))}return[e,t]}function OS(e,t,n){if(e.type!==13&&kS(e,t))return;let r,i=e.type===13?e.props:e.arguments[2],a=[],o;if(i&&!F(i)&&i.type===14){let e=DS(i);i=e[0],a=e[1],o=a[a.length-1]}if(i==null||F(i))r=Fx([t]);else if(i.type===14){let e=i.arguments[0];!F(e)&&e.type===15?AS(t,e)||e.properties.unshift(t):i.callee===Vw?r=Bx(n.helper(Iw),[Fx([t]),i]):i.arguments.unshift(Fx([t])),!r&&(r=i)}else i.type===15?(AS(t,i)||i.properties.unshift(t),r=i):(r=Bx(n.helper(Iw),[Fx([t]),i]),o&&o.callee===Bw&&(o=a[a.length-2]));e.type===13?o?o.arguments[0]=r:e.props=r:o?o.arguments[0]=r:e.arguments[2]=r}function kS(e,t){var n,r,i;if(t.key.type!==4||t.key.content!==`key`)return!1;let a=e.arguments[2];if(a&&!F(a)){let[e]=DS(a);if(e&&!F(e)&&e.type===15&&AS(t,e))return!0}return(n=e.arguments)[2]||(n[2]=`{}`),(r=e.arguments)[3]||(r[3]=`undefined`),(i=e.arguments)[4]||(i[4]=`undefined`),e.arguments[5]=t.value,!0}function AS(e,t){let n=!1;if(e.key.type===4){let r=e.key.content;n=t.properties.some(e=>e.key.type===4&&e.key.content===r)}return n}function jS(e,t){return`_${t}_${e.replace(/[^\w]/g,(t,n)=>t===`-`?`_`:e.charCodeAt(n).toString())}`}function MS(e,t){if(!e||Object.keys(t).length===0)return!1;switch(e.type){case 1:for(let n=0;n<e.props.length;n++){let r=e.props[n];if(r.type===7&&(MS(r.arg,t)||MS(r.exp,t)))return!0}return e.children.some(e=>MS(e,t));case 11:return MS(e.source,t)?!0:e.children.some(e=>MS(e,t));case 9:return e.branches.some(e=>MS(e,t));case 10:return MS(e.condition,t)?!0:e.children.some(e=>MS(e,t));case 4:return!e.isStatic&&yT(e.content)&&!!t[e.content];case 8:return e.children.some(e=>ve(e)&&MS(e,t));case 5:case 12:return MS(e.content,t);case 2:case 3:case 20:return!1;default:return!1}}function NS(e){return e.type===14&&e.callee===Zw?e.arguments[1].returns:e}function PS(e){for(let t=0;t<e.length;t++)if(!eS(e.charCodeAt(t)))return!1;return!0}function FS(e){return e.type===2&&PS(e.content)||e.type===12&&FS(e.content)}function IS(e){return e.type===3||FS(e)}function LS(e){let t=e.loc,n=e.content,r=n.match(MT);if(!r)return;let[,i,a]=r,o=(e,n,r=!1)=>{let i=t.start.offset+n;return tC(e,!1,ZS(i,i+e.length),0,+!!r)},s={source:o(a.trim(),n.indexOf(a,i.length)),value:void 0,key:void 0,index:void 0,finalized:!1},c=i.trim().replace(JT,``).trim(),l=i.indexOf(c),u=c.match(qT);if(u){c=c.replace(qT,``).trim();let e=u[1].trim(),t;if(e&&(t=n.indexOf(e,l+c.length),s.key=o(e,t,!0)),u[2]){let r=u[2].trim();r&&(s.index=o(r,n.indexOf(r,s.key?t+e.length:l+c.length),!0))}}return c&&(s.value=o(c,l,!0)),s}function RS(e,t){return IT.slice(e,t)}function zS(e){KT.inSFCRoot&&(LT.innerLoc=ZS(e+1,e+1)),XS(LT);let{tag:t,ns:n}=LT;n===0&&PT.isPreTag(t)&&HT++,PT.isVoidTag(t)?VS(LT,e):(GT.unshift(LT),(n===1||n===2)&&(KT.inXML=!0)),LT=null}function BS(e,t,n){{let t=GT[0]&&GT[0].tag;t!==`script`&&t!==`style`&&e.includes(`&`)&&(e=PT.decodeEntities(e,!1))}let r=GT[0]||FT,i=r.children[r.children.length-1];i&&i.type===2?(i.content+=e,$S(i.loc,n)):r.children.push({type:2,content:e,loc:ZS(t,n)})}function VS(e,t,n=!1){n?$S(e.loc,US(t,60)):$S(e.loc,HS(t,62)+1),KT.inSFCRoot&&(e.children.length?e.innerLoc.end=j({},e.children[e.children.length-1].loc.end):e.innerLoc.end=j({},e.innerLoc.start),e.innerLoc.source=RS(e.innerLoc.start.offset,e.innerLoc.end.offset));let{tag:r,ns:i,children:a}=e;if(UT||(r===`slot`?e.tagType=2:WS(e)?e.tagType=3:GS(e)&&(e.tagType=1)),KT.inRCDATA||(e.children=qS(a)),i===0&&PT.isIgnoreNewlineTag(r)){let e=a[0];e&&e.type===2&&(e.content=e.content.replace(/^\r?\n/,``))}i===0&&PT.isPreTag(r)&&HT--,WT===e&&(UT=KT.inVPre=!1,WT=null),KT.inXML&&(GT[0]?GT[0].ns:PT.ns)===0&&(KT.inXML=!1);{let t=e.props;if(!KT.inSFCRoot&&iS(`COMPILER_NATIVE_TEMPLATE`,PT)&&e.tag===`template`&&!WS(e)){let t=GT[0]||FT,n=t.children.indexOf(e);t.children.splice(n,1,...e.children)}let n=t.find(e=>e.type===6&&e.name===`inline-template`);n&&aS(`COMPILER_INLINE_TEMPLATE`,PT,n.loc)&&e.children.length&&(n.value={type:2,content:RS(e.children[0].loc.start.offset,e.children[e.children.length-1].loc.end.offset),loc:n.loc})}}function HS(e,t){let n=e;for(;IT.charCodeAt(n)!==t&&n<IT.length-1;)n++;return n}function US(e,t){let n=e;for(;IT.charCodeAt(n)!==t&&n>=0;)n--;return n}function WS({tag:e,props:t}){if(e===`template`){for(let e=0;e<t.length;e++)if(t[e].type===7&&YT.has(t[e].name))return!0}return!1}function GS({tag:e,props:t}){if(PT.isCustomElement(e))return!1;if(e===`component`||KS(e.charCodeAt(0))||mS(e)||PT.isBuiltInComponent&&PT.isBuiltInComponent(e)||PT.isNativeTag&&!PT.isNativeTag(e))return!0;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===6){if(n.name===`is`&&n.value&&(n.value.content.startsWith(`vue:`)||aS(`COMPILER_IS_ON_ELEMENT`,PT,n.loc)))return!0}else if(n.name===`bind`&&bS(n.arg,`is`)&&aS(`COMPILER_IS_ON_ELEMENT`,PT,n.loc))return!0}return!1}function KS(e){return e>64&&e<91}function qS(e){let t=PT.whitespace!==`preserve`,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i.type===2){if(HT)i.content=i.content.replace(XT,`
1239
1239
  `);else if(PS(i.content)){let a=e[r-1]&&e[r-1].type,o=e[r+1]&&e[r+1].type;!a||!o||t&&(a===3&&(o===3||o===1)||a===1&&(o===3||o===1&&JS(i.content)))?(n=!0,e[r]=null):i.content=` `}else t&&(i.content=YS(i.content))}}return n?e.filter(Boolean):e}function JS(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n===10||n===13)return!0}return!1}function YS(e){let t=``,n=!1;for(let r=0;r<e.length;r++)eS(e.charCodeAt(r))?n||=(t+=` `,!0):(t+=e[r],n=!1);return t}function XS(e){(GT[0]||FT).children.push(e)}function ZS(e,t){return{start:KT.getPos(e),end:t==null?t:KT.getPos(t),source:t==null?t:RS(e,t)}}function QS(e){return ZS(e.start.offset,e.end.offset)}function $S(e,t){e.end=KT.getPos(t),e.source=RS(e.start.offset,t)}function eC(e){let t={type:6,name:e.rawName,nameLoc:ZS(e.loc.start.offset,e.loc.start.offset+e.rawName.length),value:void 0,loc:e.loc};if(e.exp){let n=e.exp.loc;n.end.offset<e.loc.end.offset&&(n.start.offset--,n.start.column--,n.end.offset++,n.end.column++),t.value={type:2,content:e.exp.content,loc:n}}return t}function tC(e,t=!1,n,r=0,i=0){return Lx(e,t,n,r)}function nC(e,t,n){PT.onError(lS(e,ZS(t,t),void 0,n))}function rC(){KT.reset(),LT=null,RT=null,zT=``,BT=-1,VT=-1,GT.length=0}function iC(e,t){if(rC(),IT=e,PT=j({},NT),t){let e;for(e in t)t[e]!=null&&(PT[e]=t[e])}KT.mode=PT.parseMode===`html`?1:PT.parseMode===`sfc`?2:0,KT.inXML=PT.ns===1||PT.ns===2;let n=t&&t.delimiters;n&&(KT.delimiterOpen=nS(n[0]),KT.delimiterClose=nS(n[1]));let r=FT=Mx([],e);return KT.parse(IT),r.loc=ZS(0,e.length),r.children=qS(r.children),FT=null,r}function aC(e,t){sC(e,void 0,t,!!oC(e))}function oC(e){let t=e.children.filter(e=>e.type!==3);return t.length===1&&t[0].type===1&&!ES(t[0])?t[0]:null}function sC(e,t,n,r=!1,i=!1){let{children:a}=e,o=[];for(let t=0;t<a.length;t++){let s=a[t];if(s.type===1&&s.tagType===0){let e=r?0:cC(s,n);if(e>0){if(e>=2){s.codegenNode.patchFlag=-1,o.push(s);continue}}else{let e=s.codegenNode;if(e.type===13){let t=e.patchFlag;if((t===void 0||t===512||t===1)&&uC(s,n)>=2){let t=dC(s);t&&(e.props=n.hoist(t))}e.dynamicProps&&=n.hoist(e.dynamicProps)}}}else if(s.type===12&&(r?0:cC(s,n))>=2){s.codegenNode.type===14&&s.codegenNode.arguments.length>0&&s.codegenNode.arguments.push(`-1`),o.push(s);continue}if(s.type===1){let t=s.tagType===1;t&&n.scopes.vSlot++,sC(s,e,n,!1,i),t&&n.scopes.vSlot--}else if(s.type===11)sC(s,e,n,s.children.length===1,!0);else if(s.type===9)for(let t=0;t<s.branches.length;t++)sC(s.branches[t],e,n,s.branches[t].children.length===1,i)}let s=!1;if(o.length===a.length&&e.type===1){if(e.tagType===0&&e.codegenNode&&e.codegenNode.type===13&&N(e.codegenNode.children))e.codegenNode.children=c(Px(e.codegenNode.children)),s=!0;else if(e.tagType===1&&e.codegenNode&&e.codegenNode.type===13&&e.codegenNode.children&&!N(e.codegenNode.children)&&e.codegenNode.children.type===15){let t=l(e.codegenNode,`default`);t&&(t.returns=c(Px(t.returns)),s=!0)}else if(e.tagType===3&&t&&t.type===1&&t.tagType===1&&t.codegenNode&&t.codegenNode.type===13&&t.codegenNode.children&&!N(t.codegenNode.children)&&t.codegenNode.children.type===15){let n=vS(e,`slot`,!0),r=n&&n.arg&&l(t.codegenNode,n.arg);r&&(r.returns=c(Px(r.returns)),s=!0)}}if(!s)for(let e of o)e.codegenNode=n.cache(e.codegenNode);function c(e){let t=n.cache(e);return t.needArraySpread=!0,t}function l(e,t){if(e.children&&!N(e.children)&&e.children.type===15){let n=e.children.properties.find(e=>e.key===t||e.key.content===t);return n&&n.value}}o.length&&n.transformHoist&&n.transformHoist(a,n,e)}function cC(e,t){let{constantCache:n}=t;switch(e.type){case 1:if(e.tagType!==0)return 0;let r=n.get(e);if(r!==void 0)return r;let i=e.codegenNode;if(i.type!==13||i.isBlock&&e.tag!==`svg`&&e.tag!==`foreignObject`&&e.tag!==`math`)return 0;if(i.patchFlag===void 0){let r=3,a=uC(e,t);if(a===0)return n.set(e,0),0;a<r&&(r=a);for(let i=0;i<e.children.length;i++){let a=cC(e.children[i],t);if(a===0)return n.set(e,0),0;a<r&&(r=a)}if(r>1)for(let i=0;i<e.props.length;i++){let a=e.props[i];if(a.type===7&&a.name===`bind`&&a.exp){let i=cC(a.exp,t);if(i===0)return n.set(e,0),0;i<r&&(r=i)}}if(i.isBlock){for(let t=0;t<e.props.length;t++)if(e.props[t].type===7)return n.set(e,0),0;t.removeHelper(yw),t.removeHelper(Zx(t.inSSR,i.isComponent)),i.isBlock=!1,t.helper(Xx(t.inSSR,i.isComponent))}return n.set(e,r),r}return n.set(e,0),0;case 2:case 3:return 3;case 9:case 11:case 10:return 0;case 5:case 12:return cC(e.content,t);case 4:return e.constType;case 8:let a=3;for(let n=0;n<e.children.length;n++){let r=e.children[n];if(F(r)||_e(r))continue;let i=cC(r,t);if(i===0)return 0;i<a&&(a=i)}return a;case 20:return 2;default:return 0}}function lC(e,t){if(e.type===14&&!F(e.callee)&&ZT.has(e.callee)){let n=e.arguments[0];if(n.type===4)return cC(n,t);if(n.type===14)return lC(n,t)}return 0}function uC(e,t){let n=3,r=dC(e);if(r&&r.type===15){let{properties:e}=r;for(let r=0;r<e.length;r++){let{key:i,value:a}=e[r],o=cC(i,t);if(o===0)return o;o<n&&(n=o);let s;if(s=a.type===4?cC(a,t):a.type===14?lC(a,t):0,s===0)return s;s<n&&(n=s)}}return n}function dC(e){let t=e.codegenNode;if(t.type===13)return t.props}function fC(e,{filename:t=``,prefixIdentifiers:n=!1,hoistStatic:r=!1,hmr:i=!1,cacheHandlers:a=!1,nodeTransforms:o=[],directiveTransforms:s={},transformHoist:c=null,isBuiltInComponent:l=se,isCustomElement:u=se,expressionPlugins:d=[],scopeId:f=null,slotted:p=!0,ssr:m=!1,inSSR:h=!1,ssrCssVars:g=``,bindingMetadata:_=A,inline:v=!1,isTS:y=!1,onError:b=sS,onWarn:x=cS,compatConfig:S}){let C=t.replace(/\?.*$/,``).match(/([^/\\]+)\.\w+$/),w={filename:t,selfName:C&&Me(ke(C[1])),prefixIdentifiers:n,hoistStatic:r,hmr:i,cacheHandlers:a,nodeTransforms:o,directiveTransforms:s,transformHoist:c,isBuiltInComponent:l,isCustomElement:u,expressionPlugins:d,scopeId:f,slotted:p,ssr:m,inSSR:h,ssrCssVars:g,bindingMetadata:_,inline:v,isTS:y,onError:b,onWarn:x,compatConfig:S,root:e,helpers:new Map,components:new Set,directives:new Set,hoists:[],imports:[],cached:[],constantCache:new WeakMap,vForMemoKeyedNodes:new WeakSet,temps:0,identifiers:Object.create(null),scopes:{vFor:0,vSlot:0,vPre:0,vOnce:0},parent:null,grandParent:null,currentNode:e,childIndex:0,inVOnce:!1,helper(e){let t=w.helpers.get(e)||0;return w.helpers.set(e,t+1),e},removeHelper(e){let t=w.helpers.get(e);if(t){let n=t-1;n?w.helpers.set(e,n):w.helpers.delete(e)}},helperString(e){return`_${$w[w.helper(e)]}`},replaceNode(e){w.parent.children[w.childIndex]=w.currentNode=e},removeNode(e){let t=w.parent.children,n=e?t.indexOf(e):w.currentNode?w.childIndex:-1;!e||e===w.currentNode?(w.currentNode=null,w.onNodeRemoved()):w.childIndex>n&&(w.childIndex--,w.onNodeRemoved()),w.parent.children.splice(n,1)},onNodeRemoved:se,addIdentifiers(e){},removeIdentifiers(e){},hoist(e){F(e)&&(e=Lx(e)),w.hoists.push(e);let t=Lx(`_hoisted_${w.hoists.length}`,!1,e.loc,2);return t.hoisted=e,t},cache(e,t=!1,n=!1){let r=Ux(w.cached.length,e,t,n);return w.cached.push(r),r}};return w.filters=new Set,w}function pC(e,t){let n=fC(e,t);gC(e,n),t.hoistStatic&&aC(e,n),t.ssr||mC(e,n),e.helpers=new Set([...n.helpers.keys()]),e.components=[...n.components],e.directives=[...n.directives],e.imports=n.imports,e.hoists=n.hoists,e.temps=n.temps,e.cached=n.cached,e.transformed=!0,e.filters=[...n.filters]}function mC(e,t){let{helper:n}=t,{children:r}=e;if(r.length===1){let n=oC(e);if(n&&n.codegenNode){let r=n.codegenNode;r.type===13&&Qx(r,t),e.codegenNode=r}else e.codegenNode=r[0]}else r.length>1&&(e.codegenNode=Nx(t,n(mw),void 0,e.children,64,void 0,void 0,!0,void 0,!1))}function hC(e,t){let n=0,r=()=>{n--};for(;n<e.children.length;n++){let i=e.children[n];F(i)||(t.grandParent=t.parent,t.parent=e,t.childIndex=n,t.onNodeRemoved=r,gC(i,t))}}function gC(e,t){t.currentNode=e;let{nodeTransforms:n}=t,r=[];for(let i=0;i<n.length;i++){let a=n[i](e,t);if(a&&(N(a)?r.push(...a):r.push(a)),t.currentNode)e=t.currentNode;else return}switch(e.type){case 3:t.ssr||t.helper(ww);break;case 5:t.ssr||t.helper(Fw);break;case 9:for(let n=0;n<e.branches.length;n++)gC(e.branches[n],t);break;case 10:case 11:case 1:case 0:hC(e,t)}t.currentNode=e;let i=r.length;for(;i--;)r[i]()}function _C(e,t){let n=F(e)?t=>t===e:t=>e.test(t);return(e,r)=>{if(e.type===1){let{props:i}=e;if(e.tagType===3&&i.some(wS))return;let a=[];for(let o=0;o<i.length;o++){let s=i[o];if(s.type===7&&n(s.name)){i.splice(o,1),o--;let n=t(e,s,r);n&&a.push(n)}}return a}}}function vC(e,{mode:t=`function`,prefixIdentifiers:n=t===`module`,sourceMap:r=!1,filename:i=`template.vue.html`,scopeId:a=null,optimizeImports:o=!1,runtimeGlobalName:s=`Vue`,runtimeModuleName:c=`vue`,ssrRuntimeModuleName:l=`vue/server-renderer`,ssr:u=!1,isTS:d=!1,inSSR:f=!1}){let p={mode:t,prefixIdentifiers:n,sourceMap:r,filename:i,scopeId:a,optimizeImports:o,runtimeGlobalName:s,runtimeModuleName:c,ssrRuntimeModuleName:l,ssr:u,isTS:d,inSSR:f,source:e.source,code:``,column:1,line:1,offset:0,indentLevel:0,pure:!1,map:void 0,helper(e){return`_${$w[e]}`},push(e,t=-2,n){p.code+=e},indent(){m(++p.indentLevel)},deindent(e=!1){e?--p.indentLevel:m(--p.indentLevel)},newline(){m(p.indentLevel)}};function m(e){p.push(`
1240
1240
  `+` `.repeat(e),0)}return p}function yC(e,t={}){let n=vC(e,t);t.onContextCreated&&t.onContextCreated(n);let{mode:r,push:i,prefixIdentifiers:a,indent:o,deindent:s,newline:c,scopeId:l,ssr:u}=n,d=Array.from(e.helpers),f=d.length>0,p=!a&&r!==`module`;if(bC(e,n),i(`function ${u?`ssrRender`:`render`}(${(u?[`_ctx`,`_push`,`_parent`,`_attrs`]:[`_ctx`,`_cache`]).join(`, `)}) {`),o(),p&&(i(`with (_ctx) {`),o(),f&&(i(`const { ${d.map($T).join(`, `)} } = _Vue
package/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>KAMA</title>
7
- <script type="module" crossorigin src="/assets/index-DDVVGU8N.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-THJ6BqPP.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-10GEw0KY.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightsideoy/kama",
3
- "version": "0.1.0-alpha.111",
3
+ "version": "0.1.0-alpha.113",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",