@brightsideoy/kama 0.1.0-alpha.36 → 0.1.0-alpha.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +1643 -182
  2. package/package.json +6 -5
  3. package/schema.sql +22 -0
package/dist/index.js CHANGED
@@ -4396,10 +4396,1452 @@ var Mr = /* @__PURE__ */ d({
4396
4396
  stringify: () => jr,
4397
4397
  visit: () => P,
4398
4398
  visitAsync: () => re
4399
- });
4399
+ }), Nr = {
4400
+ rawNodes: {
4401
+ address: {
4402
+ id: "address",
4403
+ label: "Address",
4404
+ inTree: !1,
4405
+ tabs: {
4406
+ settings: {
4407
+ label: "Address",
4408
+ fields: [
4409
+ { title: {
4410
+ label: "Address Title",
4411
+ required: !0
4412
+ } },
4413
+ { street: { label: "Street" } },
4414
+ { city: { label: "City" } },
4415
+ { area: { label: "County / Area" } },
4416
+ { zip: { label: "ZIP" } },
4417
+ { country: { label: "Country" } }
4418
+ ]
4419
+ },
4420
+ geolocation: {
4421
+ label: "Geolocation",
4422
+ fields: [
4423
+ { lat: { label: "Latitude" } },
4424
+ { lng: { label: "Longitude" } },
4425
+ { timezone: { label: "Timezone" } },
4426
+ { fieldSet: "access" }
4427
+ ]
4428
+ }
4429
+ }
4430
+ },
4431
+ article: {
4432
+ id: "article",
4433
+ label: "Article",
4434
+ inTree: !1,
4435
+ hasCanvas: !0,
4436
+ regions: { content: { label: "Content" } },
4437
+ allowedElements: [
4438
+ "header",
4439
+ "hero",
4440
+ "text",
4441
+ "image_card",
4442
+ "header_image",
4443
+ "two-column",
4444
+ "three-column"
4445
+ ],
4446
+ tabs: { settings: {
4447
+ label: "Article",
4448
+ fields: [
4449
+ { fieldSet: "page-base" },
4450
+ { title: {
4451
+ label: "Article title",
4452
+ required: !0
4453
+ } },
4454
+ { slug: { linkedTo: "title" } },
4455
+ { articleDate: {
4456
+ type: "date",
4457
+ label: "Article Date",
4458
+ public: !0,
4459
+ default: "now",
4460
+ index: !0
4461
+ } },
4462
+ { abstract: {
4463
+ label: "Abstract",
4464
+ type: "textarea",
4465
+ public: !0
4466
+ } },
4467
+ { fieldSet: "page-meta" },
4468
+ { fieldSet: "page-social" },
4469
+ { fieldSet: "access" }
4470
+ ]
4471
+ } }
4472
+ },
4473
+ event: {
4474
+ id: "event",
4475
+ label: "Event",
4476
+ inTree: !1,
4477
+ hasCanvas: !0,
4478
+ regions: { main: { label: "Content" } },
4479
+ allowedElements: ["title-set", "text-block"],
4480
+ tabs: { settings: {
4481
+ label: "Event",
4482
+ fields: [
4483
+ { fieldSet: "page-base" },
4484
+ { title: {
4485
+ label: "Event Title",
4486
+ required: !0
4487
+ } },
4488
+ { slug: { linkedTo: "title" } },
4489
+ { startTime: {
4490
+ type: "datetime",
4491
+ label: "Starts",
4492
+ public: !0,
4493
+ index: !0
4494
+ } },
4495
+ { endTime: {
4496
+ type: "datetime",
4497
+ label: "Finishes",
4498
+ public: !0,
4499
+ index: !0
4500
+ } },
4501
+ { abstract: {
4502
+ label: "Abstract",
4503
+ type: "textarea",
4504
+ public: !0
4505
+ } },
4506
+ { fieldSet: "page-meta" },
4507
+ { fieldSet: "page-social" },
4508
+ { fieldSet: "access" }
4509
+ ]
4510
+ } }
4511
+ },
4512
+ "external-link": {
4513
+ id: "external-link",
4514
+ label: "External Link",
4515
+ inTree: !0,
4516
+ tabs: { settings: {
4517
+ label: "Link",
4518
+ fields: [
4519
+ { fieldSet: "page-base" },
4520
+ "nodeType",
4521
+ { title: { label: "Link Text" } },
4522
+ { iconName: {
4523
+ label: "Icon",
4524
+ type: "icon",
4525
+ dbType: "text",
4526
+ packages: [
4527
+ "heroicons",
4528
+ "lucide",
4529
+ "mdi"
4530
+ ]
4531
+ } },
4532
+ { slug: {
4533
+ label: "Slug",
4534
+ linkedTo: "menuTitle, title"
4535
+ } },
4536
+ { url: {
4537
+ label: "URL",
4538
+ type: "text",
4539
+ public: !0
4540
+ } },
4541
+ { fieldSet: "access" }
4542
+ ]
4543
+ } }
4544
+ },
4545
+ page: {
4546
+ id: "page",
4547
+ label: "Page",
4548
+ inTree: !0,
4549
+ inVault: !0,
4550
+ hasCanvas: !0,
4551
+ defaultLayout: "single-column",
4552
+ allowedBlocks: [
4553
+ "header",
4554
+ "hero",
4555
+ "text",
4556
+ "image_card",
4557
+ "header_image",
4558
+ "two-column",
4559
+ "three-column"
4560
+ ],
4561
+ tabs: { settings: {
4562
+ label: "Page",
4563
+ fields: [
4564
+ { fieldSet: "page-base" },
4565
+ { layoutId: {
4566
+ label: "Page Layout",
4567
+ type: "layout-select",
4568
+ dbType: "text",
4569
+ default: "inherit",
4570
+ inheritsFromParent: !0,
4571
+ allowedLayouts: [
4572
+ "two-column",
4573
+ "single-column",
4574
+ "three-column",
4575
+ "landing-page"
4576
+ ],
4577
+ options: [{
4578
+ label: "Inherit Layout",
4579
+ value: "inherit"
4580
+ }]
4581
+ } },
4582
+ { subpageLayoutId: {
4583
+ label: "Subpages Layout Rule",
4584
+ type: "layout-select",
4585
+ dbType: "text",
4586
+ default: "inherit",
4587
+ inheritsFromParent: !0,
4588
+ allowedLayouts: [
4589
+ "two-column",
4590
+ "three-column",
4591
+ "single-column",
4592
+ "landing-page"
4593
+ ],
4594
+ options: [{
4595
+ label: "Inherit Layout",
4596
+ value: "inherit"
4597
+ }]
4598
+ } },
4599
+ { menuTitle: {
4600
+ label: "Menu Title",
4601
+ type: "text",
4602
+ dbType: "text",
4603
+ public: !0
4604
+ } },
4605
+ { fieldSet: "page-meta" },
4606
+ { fieldSet: "page-social" },
4607
+ { fieldSet: "access" }
4608
+ ]
4609
+ } }
4610
+ },
4611
+ person: {
4612
+ id: "person",
4613
+ label: "Person",
4614
+ inTree: !1,
4615
+ inVault: !0,
4616
+ hasCanvas: !1,
4617
+ tabs: { settings: {
4618
+ label: "Person",
4619
+ fields: [
4620
+ { image: {
4621
+ label: "Image",
4622
+ type: "asset",
4623
+ multiple: !1,
4624
+ maxSizeMB: 15,
4625
+ allowedTypes: ["image/*"],
4626
+ maxPreviewWidth: 300,
4627
+ crops: { list_thumb: {
4628
+ label: "List View",
4629
+ aspectRatio: 1,
4630
+ shape: "circle"
4631
+ } },
4632
+ public: !0
4633
+ } },
4634
+ { title: {
4635
+ label: "Title",
4636
+ required: !1
4637
+ } },
4638
+ { firstName: { label: "First Name" } },
4639
+ { lastName: { label: "Last Name" } },
4640
+ { position: null },
4641
+ { fieldSet: "access" }
4642
+ ]
4643
+ } }
4644
+ },
4645
+ product: {
4646
+ id: "product",
4647
+ label: "Product",
4648
+ inTree: !1,
4649
+ inVault: !0,
4650
+ hasCanvas: !1,
4651
+ layout: {
4652
+ columns: "3fr 1fr",
4653
+ areas: [["main", "sidebar"]]
4654
+ },
4655
+ regions: {
4656
+ main: { label: "Product Content" },
4657
+ sidebar: { label: "Sidebar" }
4658
+ },
4659
+ allowedElements: ["text-block", "image_card"],
4660
+ tabs: {
4661
+ settings: {
4662
+ label: "Product",
4663
+ fields: [
4664
+ { fieldSet: "page-base" },
4665
+ { title: {
4666
+ label: "Product Name",
4667
+ required: !0,
4668
+ public: !0
4669
+ } },
4670
+ { slug: { linkedTo: "title" } },
4671
+ { price: {
4672
+ label: "Price (€)",
4673
+ type: "number",
4674
+ public: !0
4675
+ } },
4676
+ { description: {
4677
+ label: "Short Abstract",
4678
+ type: "textarea",
4679
+ public: !0
4680
+ } },
4681
+ { fieldSet: "meta" },
4682
+ { fieldSet: "access" }
4683
+ ]
4684
+ },
4685
+ media: {
4686
+ label: "Media",
4687
+ fields: [{ featuredImage: {
4688
+ label: "Main Product Image",
4689
+ description: "This is the primary image used in product grids, search results, and catalogs.",
4690
+ type: "asset",
4691
+ multiple: !1,
4692
+ maxSizeMB: 15,
4693
+ allowedTypes: [
4694
+ "image/jpeg",
4695
+ "image/png",
4696
+ "image/webp"
4697
+ ],
4698
+ crops: {
4699
+ list_thumb: {
4700
+ label: "List View (4:3)",
4701
+ aspectRatio: 1.333
4702
+ },
4703
+ catalog_card: {
4704
+ label: "Portrait Card (3:4)",
4705
+ aspectRatio: .75
4706
+ }
4707
+ },
4708
+ public: !0
4709
+ } }, { gallery: {
4710
+ label: "Product Gallery",
4711
+ description: "Drag up to 10 images here for the product detail carousel.",
4712
+ type: "asset",
4713
+ multiple: !0,
4714
+ maxItems: 10,
4715
+ allowedTypes: [
4716
+ "image/jpeg",
4717
+ "image/png",
4718
+ "image/webp"
4719
+ ],
4720
+ crops: {
4721
+ carousel: {
4722
+ label: "Carousel Hero (16:9)",
4723
+ aspectRatio: 1.777
4724
+ },
4725
+ zoom: {
4726
+ label: "Detail Zoom (Square)",
4727
+ aspectRatio: 1
4728
+ }
4729
+ },
4730
+ public: !0
4731
+ } }]
4732
+ }
4733
+ }
4734
+ }
4735
+ },
4736
+ rawTrees: {
4737
+ navigation: {
4738
+ id: "navigation",
4739
+ label: "Site Navigation",
4740
+ tabs: { settings: {
4741
+ label: "Tree",
4742
+ fields: [
4743
+ { fieldSet: "tree-base" },
4744
+ { baseUrl: {
4745
+ label: "Base URL",
4746
+ type: "text",
4747
+ dbType: "text",
4748
+ public: !0
4749
+ } },
4750
+ { defaultLanguage: {
4751
+ label: "Channel Language / Locale",
4752
+ type: "language-select",
4753
+ dbType: "text",
4754
+ public: !0
4755
+ } },
4756
+ { maxDepth: {
4757
+ type: "select",
4758
+ label: "Maximum Menu Depth",
4759
+ default: "3",
4760
+ options: [
4761
+ "1",
4762
+ "2",
4763
+ "3",
4764
+ "4"
4765
+ ]
4766
+ } },
4767
+ { fieldSet: "access" }
4768
+ ]
4769
+ } }
4770
+ },
4771
+ "social-links": {
4772
+ id: "social-links",
4773
+ label: "Social links",
4774
+ tabs: { settings: {
4775
+ label: "Tree",
4776
+ fields: [{ fieldSet: "tree-base" }, { fieldSet: "access" }]
4777
+ } }
4778
+ }
4779
+ },
4780
+ rawChannels: {
4781
+ ecommerce: {
4782
+ id: "ecommerce",
4783
+ label: "E-Commerce",
4784
+ tabs: { settings: {
4785
+ label: "Channel",
4786
+ fields: [
4787
+ { fieldSet: "channel-base" },
4788
+ { currency: {
4789
+ label: "Default Currency",
4790
+ type: "select",
4791
+ default: "EUR",
4792
+ options: [
4793
+ "EUR",
4794
+ "USD",
4795
+ "GBP"
4796
+ ]
4797
+ } },
4798
+ { checkoutUrl: {
4799
+ label: "Checkout Endpoint URL",
4800
+ type: "text",
4801
+ public: !0
4802
+ } },
4803
+ { fieldSet: "access" }
4804
+ ]
4805
+ } }
4806
+ },
4807
+ website: {
4808
+ id: "website",
4809
+ label: "Website",
4810
+ tabs: {
4811
+ settings: {
4812
+ label: "Channel",
4813
+ fields: [
4814
+ { fieldSet: "channel-base" },
4815
+ { domain: {
4816
+ label: "Hostname",
4817
+ type: "text",
4818
+ dbType: "text",
4819
+ index: !0,
4820
+ public: !0
4821
+ } },
4822
+ { baseUrl: {
4823
+ label: "Base URL",
4824
+ type: "text",
4825
+ dbType: "text",
4826
+ public: !0
4827
+ } },
4828
+ { defaultLanguage: {
4829
+ label: "Channel Language / Locale",
4830
+ type: "language-select",
4831
+ dbType: "text",
4832
+ public: !0
4833
+ } }
4834
+ ]
4835
+ },
4836
+ access: {
4837
+ label: "Access",
4838
+ fields: [{ fieldSet: "access" }]
4839
+ }
4840
+ }
4841
+ }
4842
+ },
4843
+ rawBlocks: {
4844
+ header: {
4845
+ id: "header",
4846
+ label: "Header",
4847
+ group: "Content",
4848
+ fields: [
4849
+ { headline: {
4850
+ type: "richtext",
4851
+ editor: "header",
4852
+ label: "Headline",
4853
+ public: !0,
4854
+ default: "Header here..."
4855
+ } },
4856
+ { fieldSet: "access" },
4857
+ { hidden: { default: !1 } }
4858
+ ]
4859
+ },
4860
+ header_image: {
4861
+ id: "header_image",
4862
+ label: "Header Image",
4863
+ group: "Content",
4864
+ description: "Image for page header.",
4865
+ fields: [
4866
+ { image: {
4867
+ label: "Image",
4868
+ type: "asset",
4869
+ required: !0,
4870
+ multiple: !1,
4871
+ maxSizeMB: 15,
4872
+ allowedTypes: ["image/*"],
4873
+ crops: { standard: {
4874
+ label: "Page header (21:9)",
4875
+ aspectRatio: 2.333
4876
+ } },
4877
+ public: !0
4878
+ } },
4879
+ { fieldSet: "access" },
4880
+ { hidden: { default: !1 } }
4881
+ ]
4882
+ },
4883
+ hero: {
4884
+ id: "hero",
4885
+ label: "Hero",
4886
+ group: "Content",
4887
+ fields: [
4888
+ { heroBadge: {
4889
+ type: "text",
4890
+ label: "Badge",
4891
+ public: !0
4892
+ } },
4893
+ { heroTitle: {
4894
+ type: "text",
4895
+ label: "Title",
4896
+ public: !0
4897
+ } },
4898
+ { heroSubTitle: {
4899
+ type: "text",
4900
+ label: "Sub-Title",
4901
+ public: !0
4902
+ } },
4903
+ { headline: {
4904
+ type: "richtext",
4905
+ editor: "header",
4906
+ label: "Headline",
4907
+ public: !0,
4908
+ default: "Header here..."
4909
+ } },
4910
+ { fieldSet: "access" },
4911
+ { hidden: { default: !1 } }
4912
+ ]
4913
+ },
4914
+ image_card: {
4915
+ id: "image_card",
4916
+ label: "Image Card",
4917
+ Group: "Content",
4918
+ description: "A versatile card with an image, text, and a CTA button.",
4919
+ fields: [
4920
+ { image: {
4921
+ label: "Card Image",
4922
+ showLabel: !1,
4923
+ type: "asset",
4924
+ required: !0,
4925
+ multiple: !1,
4926
+ maxSizeMB: 15,
4927
+ maxPreviewWidth: "300px",
4928
+ allowedTypes: ["image/*"],
4929
+ crops: { standard: {
4930
+ label: "Card Header (16:9)",
4931
+ aspectRatio: 3
4932
+ } },
4933
+ public: !0
4934
+ } },
4935
+ { headline: {
4936
+ label: "Headline",
4937
+ type: "text",
4938
+ required: !0,
4939
+ public: !0,
4940
+ default: "Headline..."
4941
+ } },
4942
+ { summary: {
4943
+ label: "Text",
4944
+ description: "Keep it brief, 2-3 sentences max.",
4945
+ type: "richtext",
4946
+ editor: "minimal",
4947
+ public: !0,
4948
+ default: "Card text content..."
4949
+ } },
4950
+ { linkUrl: {
4951
+ label: "Link URL",
4952
+ type: "text",
4953
+ description: "Where should this card link to? (e.g., /about or https://...)",
4954
+ public: !0,
4955
+ default: "https://"
4956
+ } },
4957
+ { linkText: {
4958
+ label: "Button Text",
4959
+ type: "text",
4960
+ description: "e.g., 'Read More' or 'Buy Now'",
4961
+ default: "Read More",
4962
+ public: !0
4963
+ } },
4964
+ { fieldSet: "access" },
4965
+ { hidden: { default: !1 } }
4966
+ ]
4967
+ },
4968
+ text: {
4969
+ id: "text",
4970
+ label: "Text",
4971
+ group: "Content",
4972
+ description: "Paragraph body",
4973
+ fields: [
4974
+ { body: {
4975
+ label: "Text",
4976
+ type: "richtext",
4977
+ editor: "default",
4978
+ default: "Write content here...",
4979
+ public: !0
4980
+ } },
4981
+ { fieldSet: "access" },
4982
+ { hidden: { default: !1 } }
4983
+ ]
4984
+ }
4985
+ },
4986
+ rawElements: {
4987
+ header: {
4988
+ id: "header",
4989
+ label: "Header",
4990
+ group: "Content",
4991
+ fields: [
4992
+ { headline: {
4993
+ type: "richtext",
4994
+ editor: "header",
4995
+ label: "Headline",
4996
+ public: !0,
4997
+ default: "Header here..."
4998
+ } },
4999
+ { fieldSet: "access" },
5000
+ { hidden: { default: !1 } }
5001
+ ]
5002
+ },
5003
+ header_image: {
5004
+ id: "header_image",
5005
+ label: "Header Image",
5006
+ group: "Content",
5007
+ description: "Image for page header.",
5008
+ fields: [
5009
+ { image: {
5010
+ label: "Image",
5011
+ type: "asset",
5012
+ required: !0,
5013
+ multiple: !1,
5014
+ maxSizeMB: 15,
5015
+ allowedTypes: ["image/*"],
5016
+ crops: { standard: {
5017
+ label: "Page header (21:9)",
5018
+ aspectRatio: 2.333
5019
+ } },
5020
+ public: !0
5021
+ } },
5022
+ { fieldSet: "access" },
5023
+ { hidden: { default: !1 } }
5024
+ ]
5025
+ },
5026
+ hero: {
5027
+ id: "hero",
5028
+ label: "Hero",
5029
+ group: "Content",
5030
+ fields: [
5031
+ { heroBadge: {
5032
+ type: "text",
5033
+ label: "Badge",
5034
+ public: !0
5035
+ } },
5036
+ { heroTitle: {
5037
+ type: "text",
5038
+ label: "Title",
5039
+ public: !0
5040
+ } },
5041
+ { heroSubTitle: {
5042
+ type: "text",
5043
+ label: "Sub-Title",
5044
+ public: !0
5045
+ } },
5046
+ { headline: {
5047
+ type: "richtext",
5048
+ editor: "header",
5049
+ label: "Headline",
5050
+ public: !0,
5051
+ default: "Header here..."
5052
+ } },
5053
+ { fieldSet: "access" },
5054
+ { hidden: { default: !1 } }
5055
+ ]
5056
+ },
5057
+ image_card: {
5058
+ id: "image_card",
5059
+ label: "Image Card",
5060
+ Group: "Content",
5061
+ description: "A versatile card with an image, text, and a CTA button.",
5062
+ fields: [
5063
+ { image: {
5064
+ label: "Card Image",
5065
+ showLabel: !1,
5066
+ type: "asset",
5067
+ required: !0,
5068
+ multiple: !1,
5069
+ maxSizeMB: 15,
5070
+ maxPreviewWidth: "300px",
5071
+ allowedTypes: ["image/*"],
5072
+ crops: { standard: {
5073
+ label: "Card Header (16:9)",
5074
+ aspectRatio: 3
5075
+ } },
5076
+ public: !0
5077
+ } },
5078
+ { headline: {
5079
+ label: "Headline",
5080
+ type: "text",
5081
+ required: !0,
5082
+ public: !0,
5083
+ default: "Headline..."
5084
+ } },
5085
+ { summary: {
5086
+ label: "Text",
5087
+ description: "Keep it brief, 2-3 sentences max.",
5088
+ type: "richtext",
5089
+ editor: "minimal",
5090
+ public: !0,
5091
+ default: "Card text content..."
5092
+ } },
5093
+ { linkUrl: {
5094
+ label: "Link URL",
5095
+ type: "text",
5096
+ description: "Where should this card link to? (e.g., /about or https://...)",
5097
+ public: !0,
5098
+ default: "https://"
5099
+ } },
5100
+ { linkText: {
5101
+ label: "Button Text",
5102
+ type: "text",
5103
+ description: "e.g., 'Read More' or 'Buy Now'",
5104
+ default: "Read More",
5105
+ public: !0
5106
+ } },
5107
+ { fieldSet: "access" },
5108
+ { hidden: { default: !1 } }
5109
+ ]
5110
+ },
5111
+ text: {
5112
+ id: "text",
5113
+ label: "Text",
5114
+ group: "Content",
5115
+ description: "Paragraph body",
5116
+ fields: [
5117
+ { body: {
5118
+ label: "Text",
5119
+ type: "richtext",
5120
+ editor: "default",
5121
+ default: "Write content here...",
5122
+ public: !0
5123
+ } },
5124
+ { fieldSet: "access" },
5125
+ { hidden: { default: !1 } }
5126
+ ]
5127
+ }
5128
+ },
5129
+ rawBlockLayouts: {
5130
+ "three-column": {
5131
+ id: "three-column",
5132
+ label: "Three Columns (33/33/33)",
5133
+ showLabel: !1,
5134
+ group: "Sub-Layouts",
5135
+ layout: {
5136
+ columns: "1fr 1fr 1fr",
5137
+ areas: [[
5138
+ "left",
5139
+ "middle",
5140
+ "right"
5141
+ ]]
5142
+ },
5143
+ regions: {
5144
+ left: {
5145
+ label: "Left Column",
5146
+ showLabel: !1
5147
+ },
5148
+ middle: {
5149
+ label: "Middle Column",
5150
+ showLabel: !1
5151
+ },
5152
+ right: {
5153
+ label: "Right Column",
5154
+ showLabel: !1
5155
+ }
5156
+ }
5157
+ },
5158
+ "two-column": {
5159
+ id: "two-column",
5160
+ label: "Two Columns (50/50)",
5161
+ showLabel: !1,
5162
+ group: "Sub-Layouts",
5163
+ layout: {
5164
+ columns: "1fr 1fr",
5165
+ areas: [["left", "right"]]
5166
+ },
5167
+ regions: {
5168
+ left: {
5169
+ label: "Left Column",
5170
+ showLabel: !1
5171
+ },
5172
+ right: {
5173
+ label: "Right Column",
5174
+ showLabel: !1
5175
+ }
5176
+ },
5177
+ fields: { gap: {
5178
+ label: "Column Gap",
5179
+ type: "select",
5180
+ default: "2rem",
5181
+ options: [
5182
+ {
5183
+ label: "None",
5184
+ value: "0"
5185
+ },
5186
+ {
5187
+ label: "Small",
5188
+ value: "1rem"
5189
+ },
5190
+ {
5191
+ label: "Medium",
5192
+ value: "2rem"
5193
+ },
5194
+ {
5195
+ label: "Large",
5196
+ value: "4rem"
5197
+ }
5198
+ ]
5199
+ } }
5200
+ }
5201
+ },
5202
+ rawNodeLayouts: {
5203
+ "landing-page": {
5204
+ id: "landing-page",
5205
+ label: "Landing Page",
5206
+ layout: {
5207
+ columns: "1fr",
5208
+ areas: [
5209
+ ["header"],
5210
+ ["hero"],
5211
+ ["content"],
5212
+ ["footer"]
5213
+ ]
5214
+ },
5215
+ regions: {
5216
+ header: {
5217
+ label: "Header",
5218
+ inherit: "parent"
5219
+ },
5220
+ hero: { label: "Hero / Top Banner" },
5221
+ content: { label: "Content" },
5222
+ footer: {
5223
+ label: "Footer",
5224
+ inherit: "parent"
5225
+ }
5226
+ }
5227
+ },
5228
+ "single-column": {
5229
+ id: "single-column",
5230
+ label: "Single Column",
5231
+ layout: {
5232
+ columns: "1fr",
5233
+ areas: [
5234
+ ["header"],
5235
+ ["content"],
5236
+ ["footer"]
5237
+ ]
5238
+ },
5239
+ regions: {
5240
+ header: {
5241
+ label: "Header Image",
5242
+ showLabel: !0,
5243
+ inherit: "parent",
5244
+ allowOverride: !0,
5245
+ dropType: "image",
5246
+ maxPreviewWidth: "800px",
5247
+ multiple: !1,
5248
+ maxSizeMB: 20,
5249
+ allowedTypes: ["image/*"],
5250
+ crops: {
5251
+ standard: {
5252
+ label: "Desktop Header (4:1)",
5253
+ aspectRatio: 4
5254
+ },
5255
+ tablet: {
5256
+ label: "Tablet Header (2:1)",
5257
+ aspectRatio: 2
5258
+ },
5259
+ mobile: {
5260
+ label: "Mobile Header (4:3)",
5261
+ aspectRatio: 1.33
5262
+ }
5263
+ },
5264
+ public: !0
5265
+ },
5266
+ content: { label: "Content" },
5267
+ footer: {
5268
+ label: "Footer",
5269
+ inherit: "parent"
5270
+ }
5271
+ }
5272
+ },
5273
+ "three-column": {
5274
+ id: "three-column",
5275
+ label: "Three Column",
5276
+ layout: {
5277
+ columns: "2fr 7fr 3fr",
5278
+ areas: [
5279
+ [
5280
+ "header",
5281
+ "header",
5282
+ "header"
5283
+ ],
5284
+ [
5285
+ "left_nav",
5286
+ "content",
5287
+ "right_sidebar"
5288
+ ],
5289
+ [
5290
+ "footer",
5291
+ "footer",
5292
+ "footer"
5293
+ ]
5294
+ ]
5295
+ },
5296
+ regions: {
5297
+ header: {
5298
+ label: "Header Image",
5299
+ showLabel: !0,
5300
+ inherit: "parent",
5301
+ allowOverride: !0,
5302
+ dropType: "image",
5303
+ maxPreviewWidth: "800px",
5304
+ multiple: !1,
5305
+ maxSizeMB: 20,
5306
+ allowedTypes: ["image/*"],
5307
+ crops: {
5308
+ standard: {
5309
+ label: "Desktop Header (4:1)",
5310
+ aspectRatio: 4
5311
+ },
5312
+ tablet: {
5313
+ label: "Tablet Header (2:1)",
5314
+ aspectRatio: 2
5315
+ },
5316
+ mobile: {
5317
+ label: "Mobile Header (4:3)",
5318
+ aspectRatio: 1.33
5319
+ }
5320
+ },
5321
+ public: !0
5322
+ },
5323
+ left_nav: { label: "Left Navigation" },
5324
+ content: { label: "Content" },
5325
+ right_sidebar: { label: "Right Sidebar" },
5326
+ footer: {
5327
+ label: "Footer",
5328
+ inherit: "parent"
5329
+ }
5330
+ }
5331
+ },
5332
+ "two-column": {
5333
+ id: "two-column",
5334
+ label: "Two Column",
5335
+ layout: {
5336
+ columns: "10fr 4fr",
5337
+ areas: [
5338
+ ["header", "header"],
5339
+ ["content", "sidebar"],
5340
+ ["footer", "footer"]
5341
+ ]
5342
+ },
5343
+ regions: {
5344
+ header: {
5345
+ label: "Header Image",
5346
+ showLabel: !0,
5347
+ inherit: "parent",
5348
+ allowOverride: !0,
5349
+ dropType: "image",
5350
+ maxPreviewWidth: "800px",
5351
+ multiple: !1,
5352
+ maxSizeMB: 20,
5353
+ allowedTypes: ["image/*"],
5354
+ crops: {
5355
+ standard: {
5356
+ label: "Desktop Header (4:1)",
5357
+ aspectRatio: 4
5358
+ },
5359
+ tablet: {
5360
+ label: "Tablet Header (2:1)",
5361
+ aspectRatio: 2
5362
+ },
5363
+ mobile: {
5364
+ label: "Mobile Header (4:3)",
5365
+ aspectRatio: 1.33
5366
+ }
5367
+ },
5368
+ public: !0
5369
+ },
5370
+ content: { label: "Content" },
5371
+ sidebar: { label: "Sidebar" },
5372
+ footer: {
5373
+ label: "Footer",
5374
+ inherit: "parent"
5375
+ }
5376
+ }
5377
+ }
5378
+ },
5379
+ rawLayouts: {
5380
+ "landing-page": {
5381
+ id: "landing-page",
5382
+ label: "Landing Page",
5383
+ layout: {
5384
+ columns: "1fr",
5385
+ areas: [
5386
+ ["header"],
5387
+ ["hero"],
5388
+ ["content"],
5389
+ ["footer"]
5390
+ ]
5391
+ },
5392
+ regions: {
5393
+ header: {
5394
+ label: "Header",
5395
+ inherit: "parent"
5396
+ },
5397
+ hero: { label: "Hero / Top Banner" },
5398
+ content: { label: "Content" },
5399
+ footer: {
5400
+ label: "Footer",
5401
+ inherit: "parent"
5402
+ }
5403
+ }
5404
+ },
5405
+ "single-column": {
5406
+ id: "single-column",
5407
+ label: "Single Column",
5408
+ layout: {
5409
+ columns: "1fr",
5410
+ areas: [
5411
+ ["header"],
5412
+ ["content"],
5413
+ ["footer"]
5414
+ ]
5415
+ },
5416
+ regions: {
5417
+ header: {
5418
+ label: "Header Image",
5419
+ showLabel: !0,
5420
+ inherit: "parent",
5421
+ allowOverride: !0,
5422
+ dropType: "image",
5423
+ maxPreviewWidth: "800px",
5424
+ multiple: !1,
5425
+ maxSizeMB: 20,
5426
+ allowedTypes: ["image/*"],
5427
+ crops: {
5428
+ standard: {
5429
+ label: "Desktop Header (4:1)",
5430
+ aspectRatio: 4
5431
+ },
5432
+ tablet: {
5433
+ label: "Tablet Header (2:1)",
5434
+ aspectRatio: 2
5435
+ },
5436
+ mobile: {
5437
+ label: "Mobile Header (4:3)",
5438
+ aspectRatio: 1.33
5439
+ }
5440
+ },
5441
+ public: !0
5442
+ },
5443
+ content: { label: "Content" },
5444
+ footer: {
5445
+ label: "Footer",
5446
+ inherit: "parent"
5447
+ }
5448
+ }
5449
+ },
5450
+ "three-column": {
5451
+ id: "three-column",
5452
+ label: "Three Columns (33/33/33)",
5453
+ showLabel: !1,
5454
+ group: "Sub-Layouts",
5455
+ layout: {
5456
+ columns: "1fr 1fr 1fr",
5457
+ areas: [[
5458
+ "left",
5459
+ "middle",
5460
+ "right"
5461
+ ]]
5462
+ },
5463
+ regions: {
5464
+ left: {
5465
+ label: "Left Column",
5466
+ showLabel: !1
5467
+ },
5468
+ middle: {
5469
+ label: "Middle Column",
5470
+ showLabel: !1
5471
+ },
5472
+ right: {
5473
+ label: "Right Column",
5474
+ showLabel: !1
5475
+ }
5476
+ }
5477
+ },
5478
+ "two-column": {
5479
+ id: "two-column",
5480
+ label: "Two Columns (50/50)",
5481
+ showLabel: !1,
5482
+ group: "Sub-Layouts",
5483
+ layout: {
5484
+ columns: "1fr 1fr",
5485
+ areas: [["left", "right"]]
5486
+ },
5487
+ regions: {
5488
+ left: {
5489
+ label: "Left Column",
5490
+ showLabel: !1
5491
+ },
5492
+ right: {
5493
+ label: "Right Column",
5494
+ showLabel: !1
5495
+ }
5496
+ },
5497
+ fields: { gap: {
5498
+ label: "Column Gap",
5499
+ type: "select",
5500
+ default: "2rem",
5501
+ options: [
5502
+ {
5503
+ label: "None",
5504
+ value: "0"
5505
+ },
5506
+ {
5507
+ label: "Small",
5508
+ value: "1rem"
5509
+ },
5510
+ {
5511
+ label: "Medium",
5512
+ value: "2rem"
5513
+ },
5514
+ {
5515
+ label: "Large",
5516
+ value: "4rem"
5517
+ }
5518
+ ]
5519
+ } }
5520
+ }
5521
+ },
5522
+ rawFieldSets: {
5523
+ access: {
5524
+ tab: {
5525
+ id: "access",
5526
+ label: "Access"
5527
+ },
5528
+ fields: {
5529
+ isHidden: {
5530
+ type: "boolean",
5531
+ label: "Hidden",
5532
+ default: !1,
5533
+ public: !1,
5534
+ variant: "danger",
5535
+ dbType: "integer",
5536
+ index: !0,
5537
+ position: "sidebar",
5538
+ liveSync: !0
5539
+ },
5540
+ startShowingAt: {
5541
+ type: "datetime",
5542
+ label: "Start Showing At",
5543
+ position: "sidebar",
5544
+ public: !1,
5545
+ index: !0
5546
+ },
5547
+ stopShowingAt: {
5548
+ type: "datetime",
5549
+ label: "Stop Showing At",
5550
+ position: "sidebar",
5551
+ public: !1,
5552
+ index: !0
5553
+ }
5554
+ }
5555
+ },
5556
+ "channel-base": {
5557
+ id: "channel-base",
5558
+ label: "Channel Base Properties",
5559
+ fields: [
5560
+ { id: {
5561
+ label: "Internal ID",
5562
+ type: "hidden",
5563
+ dbType: "integer",
5564
+ primaryKey: !0
5565
+ } },
5566
+ { label: {
5567
+ label: "Channel Name",
5568
+ type: "text",
5569
+ dbType: "text",
5570
+ public: !0,
5571
+ rules: { required: !0 }
5572
+ } },
5573
+ { key: {
5574
+ label: "API Identifier",
5575
+ type: "slug",
5576
+ dbType: "text",
5577
+ public: !0,
5578
+ index: !0,
5579
+ linkedTo: "label",
5580
+ placeholder: "e.g. main-site, store-eu",
5581
+ rules: {
5582
+ required: !0,
5583
+ unique: !0,
5584
+ pattern: "^[a-z0-9-_]+$",
5585
+ customMessage: "API key must be unique and contain only lowercase letters, numbers, hyphens, or underscores."
5586
+ }
5587
+ } }
5588
+ ]
5589
+ },
5590
+ comments: {
5591
+ tab: {
5592
+ id: "comments",
5593
+ label: "Comments"
5594
+ },
5595
+ fields: { isHidden: {
5596
+ type: "textarea",
5597
+ label: "Comments",
5598
+ public: !1,
5599
+ index: !0,
5600
+ position: "sidebar"
5601
+ } }
5602
+ },
5603
+ "content-block": {
5604
+ id: "content-block",
5605
+ label: "Content Block Base Properties",
5606
+ fields: [
5607
+ { id: {
5608
+ label: "ID",
5609
+ type: "hidden",
5610
+ dbType: "text",
5611
+ primaryKey: !0
5612
+ } },
5613
+ { contentId: {
5614
+ label: "Node ID",
5615
+ type: "text",
5616
+ dbType: "text",
5617
+ rules: { required: !0 }
5618
+ } },
5619
+ { sortOrder: {
5620
+ label: "Sort Order",
5621
+ type: "number",
5622
+ dbType: "integer",
5623
+ rules: { required: !0 }
5624
+ } },
5625
+ { elementType: {
5626
+ label: "Element Component Type",
5627
+ type: "text",
5628
+ dbType: "text",
5629
+ rules: { required: !0 }
5630
+ } },
5631
+ { dataJson: {
5632
+ label: "Content Field Data",
5633
+ type: "json",
5634
+ dbType: "json",
5635
+ rules: { required: !0 }
5636
+ } },
5637
+ { region: {
5638
+ label: "Grid Region",
5639
+ type: "text",
5640
+ dbType: "text",
5641
+ default: "main",
5642
+ rules: { required: !0 }
5643
+ } }
5644
+ ]
5645
+ },
5646
+ "page-base": {
5647
+ id: "page-base",
5648
+ label: "Base Page Properties",
5649
+ fields: [
5650
+ { id: {
5651
+ label: "ID",
5652
+ type: "hidden",
5653
+ dbType: "text",
5654
+ primaryKey: !0,
5655
+ public: !0
5656
+ } },
5657
+ { channelId: {
5658
+ label: "Channel ID",
5659
+ type: "hidden",
5660
+ dbType: "text",
5661
+ public: !0,
5662
+ index: !0
5663
+ } },
5664
+ { nodeType: {
5665
+ label: "Type",
5666
+ type: "select",
5667
+ dbType: "text",
5668
+ default: "page",
5669
+ public: !0,
5670
+ position: "sidebar",
5671
+ rules: { required: !0 }
5672
+ } },
5673
+ { title: {
5674
+ label: "Page Title",
5675
+ type: "text",
5676
+ dbType: "text",
5677
+ public: !0,
5678
+ rules: { required: !0 }
5679
+ } },
5680
+ { slug: {
5681
+ label: "URL Slug",
5682
+ type: "slug",
5683
+ linkedTo: "title",
5684
+ dbType: "text",
5685
+ public: !0,
5686
+ index: !0,
5687
+ rules: {
5688
+ required: !0,
5689
+ uniqueSibling: !0,
5690
+ pattern: "^[a-z0-9_-]+$",
5691
+ customMessage: "Slug can only contain lowercase letters, numbers, hyphens, and underscores."
5692
+ }
5693
+ } }
5694
+ ]
5695
+ },
5696
+ "page-meta": {
5697
+ tab: {
5698
+ id: "page-meta",
5699
+ label: "Meta"
5700
+ },
5701
+ fields: {
5702
+ metaDescription: {
5703
+ label: "Meta Description",
5704
+ type: "textarea",
5705
+ public: !0
5706
+ },
5707
+ metaKeywords: {
5708
+ label: "Meta Keywords",
5709
+ type: "textarea",
5710
+ required: !1,
5711
+ public: !0
5712
+ }
5713
+ }
5714
+ },
5715
+ "page-social": {
5716
+ tab: {
5717
+ id: "page-social",
5718
+ label: "Social"
5719
+ },
5720
+ fields: {
5721
+ fbTitle: {
5722
+ label: "Facebook Title (og:title)",
5723
+ type: "text",
5724
+ inherits: "title",
5725
+ public: !0,
5726
+ description: "The title of your article as it should appear on Facebook."
5727
+ },
5728
+ fbDescription: {
5729
+ label: "Facebook Description (og:description)",
5730
+ type: "textarea",
5731
+ inherits: "metaDescription",
5732
+ public: !0,
5733
+ description: "A 2-4 sentence summary of the content."
5734
+ },
5735
+ xTitle: {
5736
+ label: "X Title (twitter:title)",
5737
+ type: "text",
5738
+ inherits: "fbTitle",
5739
+ public: !0,
5740
+ description: "Keep it concise (under 70 characters is ideal for X)."
5741
+ },
5742
+ xDescription: {
5743
+ label: "X Description (twitter:description)",
5744
+ type: "textarea",
5745
+ inherits: "fbDescription",
5746
+ public: !0
5747
+ },
5748
+ socialImage: {
5749
+ label: "Master Social Image",
5750
+ type: "image",
5751
+ maxPreviewWidth: "620px",
5752
+ multiple: !1,
5753
+ maxSizeMB: 10,
5754
+ allowedTypes: [
5755
+ "image/jpeg",
5756
+ "image/png",
5757
+ "image/webp"
5758
+ ],
5759
+ public: !0
5760
+ },
5761
+ fbImage: {
5762
+ label: "Facebook / LinkedIn Image",
5763
+ type: "image",
5764
+ maxPreviewWidth: "620px",
5765
+ inherits: "socialImage",
5766
+ public: !0,
5767
+ description: "Auto-cropped to 1.91:1. Drop a new image here to override.",
5768
+ crops: { aspectRatio: 1.91 }
5769
+ },
5770
+ xImage: {
5771
+ label: "X (Twitter) Image",
5772
+ type: "image",
5773
+ maxPreviewWidth: "620px",
5774
+ inherits: "socialImage",
5775
+ public: !0,
5776
+ description: "Auto-cropped to 2:1. Drop a new image here to override.",
5777
+ crops: { aspectRatio: 2 }
5778
+ },
5779
+ whatsappImage: {
5780
+ label: "Messaging / Square Image",
5781
+ type: "image",
5782
+ maxPreviewWidth: "620px",
5783
+ inherits: "socialImage",
5784
+ public: !0,
5785
+ description: "Auto-cropped to 1:1. Drop a new image here to override.",
5786
+ crops: { whatsappImage: {
5787
+ label: "WhatsApp Image (1:1)",
5788
+ aspectRatio: 1
5789
+ } }
5790
+ }
5791
+ }
5792
+ },
5793
+ "tree-base": {
5794
+ id: "tree-base",
5795
+ label: "Tree Base Properties",
5796
+ fields: [
5797
+ { id: {
5798
+ label: "Internal ID",
5799
+ type: "hidden",
5800
+ dbType: "integer",
5801
+ primaryKey: !0
5802
+ } },
5803
+ { label: {
5804
+ label: "Label",
5805
+ type: "text",
5806
+ dbType: "text",
5807
+ public: !0,
5808
+ rules: { required: !0 }
5809
+ } },
5810
+ { key: {
5811
+ label: "API Identifier",
5812
+ type: "slug",
5813
+ dbType: "text",
5814
+ index: !0,
5815
+ public: !0,
5816
+ linkedTo: "label",
5817
+ placeholder: "e.g. main-site, store-eu",
5818
+ rules: {
5819
+ required: !0,
5820
+ unique: !0,
5821
+ pattern: "^[a-z0-9-_]+$",
5822
+ customMessage: "API key must be unique and contain only lowercase letters, numbers, hyphens, or underscores."
5823
+ }
5824
+ } }
5825
+ ]
5826
+ },
5827
+ visibility: { fields: { showInMenus: {
5828
+ type: "boolean",
5829
+ label: "Show in Menus",
5830
+ default: !0,
5831
+ position: "sidebar",
5832
+ public: !0,
5833
+ variant: "alert"
5834
+ } } }
5835
+ },
5836
+ rawTemplates: {},
5837
+ nodeTemplate: { fields: {} },
5838
+ treeTemplate: { fields: {} },
5839
+ channelTemplate: { fields: {} },
5840
+ userTemplate: { fields: {} }
5841
+ };
4400
5842
  //#endregion
4401
5843
  //#region server/db/dynamic-sync.ts
4402
- async function Nr(e, t) {
5844
+ async function Pr(e, t) {
4403
5845
  try {
4404
5846
  let n = await e.prepare(`PRAGMA table_info("${t}")`).all(), r = Array.isArray(n) ? n : n?.results || [];
4405
5847
  return new Set(r.map((e) => e.name));
@@ -4407,7 +5849,8 @@ async function Nr(e, t) {
4407
5849
  return /* @__PURE__ */ new Set();
4408
5850
  }
4409
5851
  }
4410
- var Pr = {
5852
+ var Fr = {
5853
+ content_schemas: "\n id TEXT PRIMARY KEY,\n name TEXT NOT NULL,\n type TEXT UNIQUE NOT NULL,\n schemaJson TEXT NOT NULL,\n isSystem INTEGER DEFAULT 1,\n createdAt TEXT DEFAULT CURRENT_TIMESTAMP,\n updatedAt TEXT DEFAULT CURRENT_TIMESTAMP\n ",
4411
5854
  users: "\n id TEXT PRIMARY KEY,\n email TEXT UNIQUE NOT NULL,\n name TEXT NOT NULL,\n globalRole TEXT DEFAULT 'editor',\n createdAt TEXT DEFAULT CURRENT_TIMESTAMP,\n updatedAt TEXT DEFAULT CURRENT_TIMESTAMP\n ",
4412
5855
  user_accounts: "\n id TEXT PRIMARY KEY,\n userId TEXT NOT NULL,\n provider TEXT NOT NULL,\n providerAccountId TEXT NOT NULL,\n passwordHash TEXT NOT NULL,\n createdAt TEXT DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE,\n UNIQUE(provider, providerAccountId)\n ",
4413
5856
  sessions: "\n id TEXT PRIMARY KEY,\n userId TEXT NOT NULL,\n expiresAt TEXT NOT NULL,\n createdAt TEXT DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE\n ",
@@ -4421,7 +5864,8 @@ var Pr = {
4421
5864
  node_revisions: "\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n nodeId INTEGER NOT NULL,\n version INTEGER NOT NULL DEFAULT 1,\n snapshotJson TEXT NOT NULL,\n createdById TEXT,\n createdAt TEXT DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (nodeId) REFERENCES content_nodes(id) ON DELETE CASCADE,\n FOREIGN KEY (createdById) REFERENCES users(id) ON DELETE SET NULL\n ",
4422
5865
  assets: "\n id TEXT PRIMARY KEY,\n filename TEXT NOT NULL,\n mimeType TEXT NOT NULL,\n sizeBytes INTEGER NOT NULL,\n storageKeyPrivate TEXT,\n cdnUrl TEXT,\n parentAssetId TEXT,\n cropCoordinatesJson TEXT,\n isSystemVariant INTEGER DEFAULT 0,\n dataJson TEXT DEFAULT '{}',\n createdById TEXT,\n createdAt TEXT DEFAULT CURRENT_TIMESTAMP,\n updatedAt TEXT DEFAULT CURRENT_TIMESTAMP,\n deletedAt TEXT,\n FOREIGN KEY (parentAssetId) REFERENCES assets(id) ON DELETE SET NULL,\n FOREIGN KEY (createdById) REFERENCES users(id) ON DELETE SET NULL\n ",
4423
5866
  node_assets: "\n nodeId INTEGER NOT NULL,\n assetId TEXT NOT NULL,\n fieldKey TEXT NOT NULL,\n sortOrder INTEGER DEFAULT 0,\n PRIMARY KEY (nodeId, assetId, fieldKey),\n FOREIGN KEY (nodeId) REFERENCES content_nodes(id) ON DELETE CASCADE,\n FOREIGN KEY (assetId) REFERENCES assets(id) ON DELETE CASCADE\n "
4424
- }, Fr = [
5867
+ }, Ir = [
5868
+ "CREATE INDEX IF NOT EXISTS idx_content_schemas_type ON content_schemas(type);",
4425
5869
  "CREATE INDEX IF NOT EXISTS idx_sessions_user ON sessions(userId);",
4426
5870
  "CREATE INDEX IF NOT EXISTS idx_sessions_expires ON sessions(expiresAt);",
4427
5871
  "CREATE INDEX IF NOT EXISTS idx_channels_visibility ON channels(isHidden);",
@@ -4443,13 +5887,13 @@ var Pr = {
4443
5887
  "CREATE INDEX IF NOT EXISTS idx_assets_deleted ON assets(deletedAt);",
4444
5888
  "CREATE INDEX IF NOT EXISTS idx_assets_parent ON assets(parentAssetId);"
4445
5889
  ];
4446
- async function Ir(e) {
5890
+ async function Lr(e, t) {
4447
5891
  try {
4448
5892
  await e.prepare("PRAGMA foreign_keys = ON;").run();
4449
5893
  } catch {}
4450
- for (let [t, n] of Object.entries(Pr)) await e.prepare(`CREATE TABLE IF NOT EXISTS "${t}" (${n});`).run();
4451
- for (let [t] of Object.entries(Pr)) {
4452
- let n = await Nr(e, t);
5894
+ for (let [t, n] of Object.entries(Fr)) await e.prepare(`CREATE TABLE IF NOT EXISTS "${t}" (${n});`).run();
5895
+ for (let [t] of Object.entries(Fr)) {
5896
+ let n = await Pr(e, t);
4453
5897
  if (n.size > 0) {
4454
5898
  if (t === "content_nodes" && !n.has("disabledRegionsJson")) try {
4455
5899
  await e.prepare("ALTER TABLE \"content_nodes\" ADD COLUMN disabledRegionsJson TEXT DEFAULT '{}';").run();
@@ -4464,12 +5908,29 @@ async function Ir(e) {
4464
5908
  }
4465
5909
  }
4466
5910
  }
4467
- for (let t of Fr) try {
5911
+ for (let t of Ir) try {
4468
5912
  await e.prepare(t).run();
4469
5913
  } catch {}
4470
- await Lr(e);
5914
+ await Rr(e, t || Nr), await zr(e);
5915
+ }
5916
+ async function Rr(e, t) {
5917
+ if (!t) return;
5918
+ let n = t.rawNodes || {}, r = Object.entries(n);
5919
+ for (let [t, n] of r) {
5920
+ if (!n || typeof n != "object") continue;
5921
+ let r = n.type || n.id || t, i = n.name || n.label || n.title || r, a = `schema_${r}`, o = JSON.stringify(n);
5922
+ try {
5923
+ let t = e.prepare("SELECT id FROM content_schemas WHERE type = ?"), n = typeof t.bind == "function" ? await t.bind(r).all() : await t.all(r);
5924
+ if ((Array.isArray(n) ? n : n?.results || []).length === 0) {
5925
+ let t = e.prepare("\n INSERT INTO content_schemas (id, name, type, schemaJson, isSystem, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)\n ");
5926
+ typeof t.bind == "function" ? await t.bind(a, i, r, o).run() : await t.run(a, i, r, o), console.log(`✅ [D1 Auto-Seed] Seeded node schema: ${r}`);
5927
+ }
5928
+ } catch (e) {
5929
+ console.warn(`⚠️ [D1 Auto-Seed Warning] Failed to seed ${r}:`, e);
5930
+ }
5931
+ }
4471
5932
  }
4472
- async function Lr(e) {
5933
+ async function zr(e) {
4473
5934
  try {
4474
5935
  let t = await e.prepare("SELECT COUNT(*) as count FROM channels").get(), n = 1;
4475
5936
  if (!t || t.count === 0) {
@@ -4490,7 +5951,7 @@ async function Lr(e) {
4490
5951
  }
4491
5952
  //#endregion
4492
5953
  //#region server/middleware/media-static.ts
4493
- function Rr() {
5954
+ function Br() {
4494
5955
  return async (e, t) => {
4495
5956
  if (e.env?.MEDIA_BUCKET) {
4496
5957
  let t = e.req.path.replace(/^\/media\//, ""), n = await e.env.MEDIA_BUCKET.get(t, { onlyIf: e.req.raw.headers });
@@ -4521,18 +5982,18 @@ function Rr() {
4521
5982
  }
4522
5983
  //#endregion
4523
5984
  //#region node_modules/lru-cache/dist/esm/browser/index.min.js
4524
- var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, Hr = () => J.hasSubscribers || Br.hasSubscribers, Ur = /* @__PURE__ */ new Set(), Wr = typeof process == "object" && process ? process : {}, Gr = (e, t, n, r) => {
4525
- typeof Wr.emitWarning == "function" ? Wr.emitWarning(e, t, n, r) : console.error(`[${n}] ${t}: ${e}`);
4526
- }, Kr = (e) => !Ur.has(e), qr = (e) => !!e && e === Math.floor(e) && e > 0 && isFinite(e), Jr = (e) => qr(e) ? e <= 256 ? Uint8Array : e <= 2 ** 16 ? Uint16Array : e <= 2 ** 32 ? Uint32Array : e <= 2 ** 53 - 1 ? Yr : null : null, Yr = class extends Array {
5985
+ var Vr = { hasSubscribers: !1 }, J = Vr, Hr = Vr, Ur = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, Wr = () => J.hasSubscribers || Hr.hasSubscribers, Gr = /* @__PURE__ */ new Set(), Kr = typeof process == "object" && process ? process : {}, qr = (e, t, n, r) => {
5986
+ typeof Kr.emitWarning == "function" ? Kr.emitWarning(e, t, n, r) : console.error(`[${n}] ${t}: ${e}`);
5987
+ }, Jr = (e) => !Gr.has(e), Yr = (e) => !!e && e === Math.floor(e) && e > 0 && isFinite(e), Xr = (e) => Yr(e) ? e <= 256 ? Uint8Array : e <= 2 ** 16 ? Uint16Array : e <= 2 ** 32 ? Uint32Array : e <= 2 ** 53 - 1 ? Zr : null : null, Zr = class extends Array {
4527
5988
  constructor(e) {
4528
5989
  super(e), this.fill(0);
4529
5990
  }
4530
- }, Xr = class e {
5991
+ }, Qr = class e {
4531
5992
  heap;
4532
5993
  length;
4533
5994
  static #e = !1;
4534
5995
  static create(t) {
4535
- let n = Jr(t);
5996
+ let n = Xr(t);
4536
5997
  if (!n) return [];
4537
5998
  e.#e = !0;
4538
5999
  let r = new e(t, n);
@@ -4548,7 +6009,7 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
4548
6009
  pop() {
4549
6010
  return this.heap[--this.length];
4550
6011
  }
4551
- }, Zr = class e {
6012
+ }, $r = class e {
4552
6013
  #e;
4553
6014
  #t;
4554
6015
  #n;
@@ -4651,8 +6112,8 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
4651
6112
  constructor(t) {
4652
6113
  let { max: n = 0, ttl: r, ttlResolution: i = 1, ttlAutopurge: a, updateAgeOnGet: o, updateAgeOnHas: s, allowStale: c, dispose: l, onInsert: u, disposeAfter: d, noDisposeOnSet: f, noUpdateTTL: p, maxSize: m = 0, maxEntrySize: h = 0, sizeCalculation: g, fetchMethod: _, memoMethod: v, noDeleteOnFetchRejection: y, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: x, allowStaleOnFetchAbort: S, ignoreFetchAbort: C, backgroundFetchSize: w = 1, perf: T } = t;
4653
6114
  if (this.backgroundFetchSize = w, T !== void 0 && typeof T?.now != "function") throw TypeError("perf option must have a now() method if specified");
4654
- if (this.#s = T ?? Vr, n !== 0 && !qr(n)) throw TypeError("max option must be a nonnegative integer");
4655
- let E = n ? Jr(n) : Array;
6115
+ if (this.#s = T ?? Ur, n !== 0 && !Yr(n)) throw TypeError("max option must be a nonnegative integer");
6116
+ let E = n ? Xr(n) : Array;
4656
6117
  if (!E) throw Error("invalid max value: " + n);
4657
6118
  if (this.#e = n, this.#t = m, this.maxEntrySize = h || this.#t, this.sizeCalculation = g, this.sizeCalculation) {
4658
6119
  if (!this.#t && !this.maxEntrySize) throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
@@ -4660,26 +6121,26 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
4660
6121
  }
4661
6122
  if (v !== void 0 && typeof v != "function") throw TypeError("memoMethod must be a function if defined");
4662
6123
  if (this.#o = v, _ !== void 0 && typeof _ != "function") throw TypeError("fetchMethod must be a function if specified");
4663
- if (this.#a = _, this.#w = !!_, this.#u = /* @__PURE__ */ new Map(), this.#d = Array.from({ length: n }).fill(void 0), this.#f = Array.from({ length: n }).fill(void 0), this.#p = new E(n), this.#m = new E(n), this.#h = 0, this.#g = 0, this.#_ = Xr.create(n), this.#c = 0, this.#l = 0, typeof l == "function" && (this.#n = l), typeof u == "function" && (this.#r = u), typeof d == "function" ? (this.#i = d, this.#v = []) : (this.#i = void 0, this.#v = void 0), this.#C = !!this.#n, this.#E = !!this.#r, this.#T = !!this.#i, this.noDisposeOnSet = !!f, this.noUpdateTTL = !!p, this.noDeleteOnFetchRejection = !!y, this.allowStaleOnFetchRejection = !!x, this.allowStaleOnFetchAbort = !!S, this.ignoreFetchAbort = !!C, this.maxEntrySize !== 0) {
4664
- if (this.#t !== 0 && !qr(this.#t)) throw TypeError("maxSize must be a positive integer if specified");
4665
- if (!qr(this.maxEntrySize)) throw TypeError("maxEntrySize must be a positive integer if specified");
6124
+ if (this.#a = _, this.#w = !!_, this.#u = /* @__PURE__ */ new Map(), this.#d = Array.from({ length: n }).fill(void 0), this.#f = Array.from({ length: n }).fill(void 0), this.#p = new E(n), this.#m = new E(n), this.#h = 0, this.#g = 0, this.#_ = Qr.create(n), this.#c = 0, this.#l = 0, typeof l == "function" && (this.#n = l), typeof u == "function" && (this.#r = u), typeof d == "function" ? (this.#i = d, this.#v = []) : (this.#i = void 0, this.#v = void 0), this.#C = !!this.#n, this.#E = !!this.#r, this.#T = !!this.#i, this.noDisposeOnSet = !!f, this.noUpdateTTL = !!p, this.noDeleteOnFetchRejection = !!y, this.allowStaleOnFetchRejection = !!x, this.allowStaleOnFetchAbort = !!S, this.ignoreFetchAbort = !!C, this.maxEntrySize !== 0) {
6125
+ if (this.#t !== 0 && !Yr(this.#t)) throw TypeError("maxSize must be a positive integer if specified");
6126
+ if (!Yr(this.maxEntrySize)) throw TypeError("maxEntrySize must be a positive integer if specified");
4666
6127
  this.#M();
4667
6128
  }
4668
- if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!s, this.ttlResolution = qr(i) || i === 0 ? i : 1, this.ttlAutopurge = !!a, this.ttl = r || 0, this.ttl) {
4669
- if (!qr(this.ttl)) throw TypeError("ttl must be a positive integer if specified");
6129
+ if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!s, this.ttlResolution = Yr(i) || i === 0 ? i : 1, this.ttlAutopurge = !!a, this.ttl = r || 0, this.ttl) {
6130
+ if (!Yr(this.ttl)) throw TypeError("ttl must be a positive integer if specified");
4670
6131
  this.#D();
4671
6132
  }
4672
6133
  if (this.#e === 0 && this.ttl === 0 && this.#t === 0) throw TypeError("At least one of max, maxSize, or ttl is required");
4673
6134
  if (!this.ttlAutopurge && !this.#e && !this.#t) {
4674
6135
  let t = "LRU_CACHE_UNBOUNDED";
4675
- Kr(t) && (Ur.add(t), Gr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", t, e));
6136
+ Jr(t) && (Gr.add(t), qr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", t, e));
4676
6137
  }
4677
6138
  }
4678
6139
  getRemainingTTL(e) {
4679
6140
  return this.#u.has(e) ? 1 / 0 : 0;
4680
6141
  }
4681
6142
  #D() {
4682
- let e = new Yr(this.#e), t = new Yr(this.#e);
6143
+ let e = new Zr(this.#e), t = new Zr(this.#e);
4683
6144
  this.#x = e, this.#b = t;
4684
6145
  let n = this.ttlAutopurge ? Array.from({ length: this.#e }) : void 0;
4685
6146
  this.#S = n, this.#A = (n, i, a = this.#s.now()) => {
@@ -4729,15 +6190,15 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
4729
6190
  #A = () => {};
4730
6191
  #j = () => !1;
4731
6192
  #M() {
4732
- let e = new Yr(this.#e);
6193
+ let e = new Zr(this.#e);
4733
6194
  this.#l = 0, this.#y = e, this.#N = (t) => {
4734
6195
  this.#l -= e[t], e[t] = 0;
4735
6196
  }, this.#F = (e, t, n, r) => {
4736
- if (!qr(n)) {
6197
+ if (!Yr(n)) {
4737
6198
  if (this.#W(t)) return this.backgroundFetchSize;
4738
6199
  if (r) {
4739
6200
  if (typeof r != "function") throw TypeError("sizeCalculation must be a function");
4740
- if (n = r(t, e), !qr(n)) throw TypeError("sizeCalculation return invalid (expect positive integer)");
6201
+ if (n = r(t, e), !Yr(n)) throw TypeError("sizeCalculation return invalid (expect positive integer)");
4741
6202
  } else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
4742
6203
  }
4743
6204
  return n;
@@ -4940,7 +6401,7 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
4940
6401
  return !1;
4941
6402
  }
4942
6403
  peek(e, t = {}) {
4943
- let { status: n = Hr() ? {} : void 0 } = t;
6404
+ let { status: n = Wr() ? {} : void 0 } = t;
4944
6405
  n && (n.op = "peek", n.key = e, n.cache = this), t.status = n;
4945
6406
  let r = this.#H(e, t);
4946
6407
  return J.hasSubscribers && J.publish(n), r;
@@ -4995,10 +6456,10 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
4995
6456
  return !!t && t instanceof Promise && t.hasOwnProperty("__staleWhileFetching") && t.__abortController instanceof AbortController;
4996
6457
  }
4997
6458
  fetch(e, t = {}) {
4998
- let n = Br.hasSubscribers, { status: r = Hr() ? {} : void 0 } = t;
6459
+ let n = Hr.hasSubscribers, { status: r = Wr() ? {} : void 0 } = t;
4999
6460
  t.status = r, r && t.context && (r.context = t.context);
5000
6461
  let i = this.#G(e, t);
5001
- return r && n && (r.trace = !0, Br.tracePromise(() => i, r).catch(() => {})), i;
6462
+ return r && n && (r.trace = !0, Hr.tracePromise(() => i, r).catch(() => {})), i;
5002
6463
  }
5003
6464
  async #G(e, t = {}) {
5004
6465
  let { allowStale: n = this.allowStale, updateAgeOnGet: r = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, ttl: a = this.ttl, noDisposeOnSet: o = this.noDisposeOnSet, size: s = 0, sizeCalculation: c = this.sizeCalculation, noUpdateTTL: l = this.noUpdateTTL, noDeleteOnFetchRejection: u = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: m, forceRefresh: h = !1, status: g, signal: _ } = t;
@@ -5042,10 +6503,10 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
5042
6503
  }
5043
6504
  }
5044
6505
  forceFetch(e, t = {}) {
5045
- let n = Br.hasSubscribers, { status: r = Hr() ? {} : void 0 } = t;
6506
+ let n = Hr.hasSubscribers, { status: r = Wr() ? {} : void 0 } = t;
5046
6507
  t.status = r, r && t.context && (r.context = t.context);
5047
6508
  let i = this.#K(e, t);
5048
- return r && n && (r.trace = !0, Br.tracePromise(() => i, r).catch(() => {})), i;
6509
+ return r && n && (r.trace = !0, Hr.tracePromise(() => i, r).catch(() => {})), i;
5049
6510
  }
5050
6511
  async #K(e, t = {}) {
5051
6512
  let n = await this.#G(e, t);
@@ -5158,10 +6619,10 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
5158
6619
  for (; t = e?.shift();) this.#i?.(...t);
5159
6620
  }
5160
6621
  }
5161
- }, Qr = class {
6622
+ }, ei = class {
5162
6623
  cache;
5163
6624
  constructor(e = 1e3, t = 3e5) {
5164
- this.cache = new Zr({
6625
+ this.cache = new $r({
5165
6626
  max: e,
5166
6627
  ttl: t
5167
6628
  });
@@ -5180,7 +6641,7 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
5180
6641
  async clear() {
5181
6642
  this.cache.clear();
5182
6643
  }
5183
- }, $r = class {
6644
+ }, ti = class {
5184
6645
  kv;
5185
6646
  constructor(e) {
5186
6647
  this.kv = e;
@@ -5197,21 +6658,21 @@ var zr = { hasSubscribers: !1 }, J = zr, Br = zr, Vr = typeof performance == "ob
5197
6658
  this.kv && await this.kv.delete(e);
5198
6659
  }
5199
6660
  async clear() {}
5200
- }, ei = class {
6661
+ }, ni = class {
5201
6662
  async get() {
5202
6663
  return null;
5203
6664
  }
5204
6665
  async set() {}
5205
6666
  async delete() {}
5206
6667
  async clear() {}
5207
- }, ti = null;
6668
+ }, ri = null;
5208
6669
  function Y(e) {
5209
6670
  let t = process.env.CACHE_DRIVER || "lru";
5210
- return t === "none" || t === "off" || t === "false" ? new ei() : e?.env?.CMS_CACHE_KV ? new $r(e.env.CMS_CACHE_KV) : t === "lru" ? (ti ||= new Qr(), ti) : new ei();
6671
+ return t === "none" || t === "off" || t === "false" ? new ni() : e?.env?.CMS_CACHE_KV ? new ti(e.env.CMS_CACHE_KV) : t === "lru" ? (ri ||= new ei(), ri) : new ni();
5211
6672
  }
5212
6673
  //#endregion
5213
6674
  //#region server/utils/node-assets-interceptor.ts
5214
- function ni(e) {
6675
+ function ii(e) {
5215
6676
  if (!e || typeof e != "object") return {
5216
6677
  cleanedData: e,
5217
6678
  assetRefs: []
@@ -5251,7 +6712,7 @@ function ni(e) {
5251
6712
  assetRefs: t
5252
6713
  };
5253
6714
  }
5254
- async function ri(e, t, n) {
6715
+ async function ai(e, t, n) {
5255
6716
  if (await e.prepare("DELETE FROM node_assets WHERE nodeId = ?").run(t), n.length === 0) return;
5256
6717
  let r = /* @__PURE__ */ new Set();
5257
6718
  for (let i of n) {
@@ -5261,23 +6722,23 @@ async function ri(e, t, n) {
5261
6722
  }
5262
6723
  //#endregion
5263
6724
  //#region server/utils/asset-hydrator.ts
5264
- function ii(e) {
6725
+ function oi(e) {
5265
6726
  if (!e) return null;
5266
6727
  if (typeof e == "string" && e.startsWith("ast_")) return e;
5267
6728
  if (typeof e == "object" && e) {
5268
6729
  if (typeof e.id == "string" && e.id.startsWith("ast_")) return e.id;
5269
- if (typeof e.id == "object") return ii(e.id);
6730
+ if (typeof e.id == "object") return oi(e.id);
5270
6731
  }
5271
6732
  return null;
5272
6733
  }
5273
- async function ai(e, t) {
6734
+ async function si(e, t) {
5274
6735
  if (!t || typeof t != "object") return t;
5275
6736
  let n = /* @__PURE__ */ new Set(), r = (e) => {
5276
6737
  if (!e) return;
5277
- let t = ii(e);
6738
+ let t = oi(e);
5278
6739
  if (t) {
5279
6740
  if (n.add(t), typeof e == "object" && e.parentAssetId) {
5280
- let t = ii(e.parentAssetId);
6741
+ let t = oi(e.parentAssetId);
5281
6742
  t && n.add(t);
5282
6743
  }
5283
6744
  } else Array.isArray(e) ? e.forEach(r) : typeof e == "object" && Object.values(e).forEach(r);
@@ -5304,7 +6765,7 @@ async function ai(e, t) {
5304
6765
  AND (parentAssetId IN (${i}) OR ${Array.from(n).map(() => "filename LIKE ?").join(" OR ")})
5305
6766
  `).all(...Array.from(n), ...Array.from(n).map((e) => `%${e}%`)), c = Array.isArray(s) ? s : s?.results || [], l = /* @__PURE__ */ new Map();
5306
6767
  for (let e of c) {
5307
- let t = ii(e.parentAssetId) || Array.from(n).find((t) => e.filename.includes(t));
6768
+ let t = oi(e.parentAssetId) || Array.from(n).find((t) => e.filename.includes(t));
5308
6769
  if (!t) continue;
5309
6770
  let r = e.filename.match(/^crop_([a-z0-9]+)_/i), i = r ? r[1] : "standard", a = null;
5310
6771
  if (e.cropCoordinatesJson) try {
@@ -5330,7 +6791,7 @@ async function ai(e, t) {
5330
6791
  id: e.id,
5331
6792
  url: t,
5332
6793
  originalUrl: n,
5333
- parentAssetId: ii(e.parentAssetId) || null,
6794
+ parentAssetId: oi(e.parentAssetId) || null,
5334
6795
  cropCoordinates: r,
5335
6796
  variants: i && Object.keys(i).length > 0 ? i : void 0,
5336
6797
  filename: e.filename,
@@ -5339,7 +6800,7 @@ async function ai(e, t) {
5339
6800
  }
5340
6801
  let d = (e) => {
5341
6802
  if (!e) return e;
5342
- let t = ii(e);
6803
+ let t = oi(e);
5343
6804
  if (t) {
5344
6805
  let n = u.get(t) || {
5345
6806
  id: t,
@@ -5349,7 +6810,7 @@ async function ai(e, t) {
5349
6810
  return {
5350
6811
  ...n,
5351
6812
  id: t,
5352
- parentAssetId: n.parentAssetId ? ii(n.parentAssetId) : null,
6813
+ parentAssetId: n.parentAssetId ? oi(n.parentAssetId) : null,
5353
6814
  url: typeof e == "object" && e.url && !e.url.startsWith("blob:") ? e.url : n.url,
5354
6815
  originalUrl: typeof e == "object" && e.originalUrl && !e.originalUrl.startsWith("blob:") ? e.originalUrl : n.originalUrl,
5355
6816
  cropCoordinates: i || n.cropCoordinates || null,
@@ -5386,7 +6847,7 @@ function X(e = {}, t = {}) {
5386
6847
  ...t.rules || {}
5387
6848
  }, n;
5388
6849
  }
5389
- function oi() {
6850
+ function ci() {
5390
6851
  if (typeof process > "u" || !process?.versions?.node) return null;
5391
6852
  try {
5392
6853
  let e = (e) => {
@@ -5453,12 +6914,12 @@ function oi() {
5453
6914
  return null;
5454
6915
  }
5455
6916
  }
5456
- function si(e) {
5457
- if (e && (Object.keys(e.rawNodes || {}).length > 0 || Object.keys(e.nodes || {}).length > 0)) return ci(e);
5458
- let t = oi();
5459
- return t && Object.keys(t.rawNodes).length > 0 ? ci(t) : ci(null);
6917
+ function li(e) {
6918
+ if (e && (Object.keys(e.rawNodes || {}).length > 0 || Object.keys(e.nodes || {}).length > 0)) return ui(e);
6919
+ let t = ci();
6920
+ return t && Object.keys(t.rawNodes).length > 0 ? ui(t) : ui(null);
5460
6921
  }
5461
- function ci(e) {
6922
+ function ui(e) {
5462
6923
  if (!e) return {
5463
6924
  nodes: {},
5464
6925
  trees: {},
@@ -5698,18 +7159,18 @@ function ci(e) {
5698
7159
  //#endregion
5699
7160
  //#region server/routes/admin/nodes.ts
5700
7161
  var Z = new e();
5701
- function li(e) {
7162
+ function di(e) {
5702
7163
  return !e || !e.trim() ? null : e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/[\s-]+/g, "-").replace(/^-+|-+$/g, "") || null;
5703
7164
  }
5704
- function ui(e) {
7165
+ function fi(e) {
5705
7166
  return +(e === !0 || e === 1 || e === "1" || e === "true");
5706
7167
  }
5707
- function di(e) {
7168
+ function pi(e) {
5708
7169
  if (e == null || e === "null" || e === "" || typeof e == "string" && e.startsWith("draft-")) return null;
5709
7170
  let t = Number(e);
5710
7171
  return isNaN(t) ? null : t;
5711
7172
  }
5712
- function fi(e) {
7173
+ function mi(e) {
5713
7174
  let t = { ...e };
5714
7175
  for (let e of [
5715
7176
  "id",
@@ -5738,7 +7199,7 @@ function fi(e) {
5738
7199
  ]) delete t[e];
5739
7200
  return t;
5740
7201
  }
5741
- async function pi(e, t, n) {
7202
+ async function hi(e, t, n) {
5742
7203
  let r = {}, i = null;
5743
7204
  if (t) {
5744
7205
  let n = await e.prepare("\n WITH RECURSIVE ancestor_path(id, parentId, draftDataJson, dataJson, level) AS (\n SELECT t.id, t.parentId, c.draftDataJson, c.dataJson, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ?\n UNION ALL\n SELECT t.id, t.parentId, c.draftDataJson, c.dataJson, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT draftDataJson, dataJson FROM ancestor_path ORDER BY level ASC\n ").all(t), a = Array.isArray(n) ? n : n?.results || [];
@@ -5788,13 +7249,13 @@ Z.get("/", async (e) => {
5788
7249
  updatedAt: i.updatedAt
5789
7250
  }, s = i.draftDataJson || i.dataJson;
5790
7251
  if (s) try {
5791
- let n = typeof s == "string" ? JSON.parse(s) : s, a = await t.prepare("SELECT id as treeNodeId, treeId, parentId FROM tree_nodes WHERE contentId = ? LIMIT 1").get(r), c = ci(e.env?.BUNDLED_DEFINITIONS).nodes?.[i.contentType] || {}, l = n.layoutId || null;
7252
+ let n = typeof s == "string" ? JSON.parse(s) : s, a = await t.prepare("SELECT id as treeNodeId, treeId, parentId FROM tree_nodes WHERE contentId = ? LIMIT 1").get(r), c = ui(e.env?.BUNDLED_DEFINITIONS).nodes?.[i.contentType] || {}, l = n.layoutId || null;
5792
7253
  if (a) {
5793
- let { resolvedLayoutId: e, inheritedFields: r } = await pi(t, a.parentId, a.treeId);
7254
+ let { resolvedLayoutId: e, inheritedFields: r } = await hi(t, a.parentId, a.treeId);
5794
7255
  (l === "inherit" || !l) && (l = e || c.defaultLayout || null);
5795
7256
  for (let [e, t] of Object.entries(r)) (n[e] === void 0 || n[e] === null || n[e] === "") && t !== void 0 && (n[e] = t);
5796
7257
  } else (l === "inherit" || !l) && (l = c.defaultLayout || null);
5797
- let u = await ai(t, fi(n));
7258
+ let u = await si(t, mi(n));
5798
7259
  Object.assign(o, u), o.resolvedLayoutId = l;
5799
7260
  } catch {}
5800
7261
  let c = await t.prepare("SELECT channelId FROM node_channels WHERE nodeId = ?").all(r);
@@ -5804,7 +7265,7 @@ Z.get("/", async (e) => {
5804
7265
  let u = await t.prepare("\n SELECT * FROM content_blocks \n WHERE contentId = ? AND isDraft = 1 \n ORDER BY sortOrder ASC\n ").all(r), d = Array.isArray(u) ? u : u?.results || [], f = await Promise.all(d.map(async (e) => {
5805
7266
  let n = {};
5806
7267
  try {
5807
- n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson || "{}") : e.dataJson || {}, n && typeof n == "object" && (n = await ai(t, n));
7268
+ n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson || "{}") : e.dataJson || {}, n && typeof n == "object" && (n = await si(t, n));
5808
7269
  } catch {
5809
7270
  n = {};
5810
7271
  }
@@ -5904,7 +7365,7 @@ Z.get("/", async (e) => {
5904
7365
  assetCount: e.assetCount || 0
5905
7366
  }, i = e.draftDataJson || e.dataJson;
5906
7367
  if (i) try {
5907
- let e = typeof i == "string" ? JSON.parse(i) : i, n = await ai(t, fi(e));
7368
+ let e = typeof i == "string" ? JSON.parse(i) : i, n = await si(t, mi(e));
5908
7369
  Object.assign(r, n);
5909
7370
  } catch {}
5910
7371
  return r;
@@ -5917,7 +7378,7 @@ Z.get("/", async (e) => {
5917
7378
  limit: f
5918
7379
  });
5919
7380
  }), Z.post("/", async (e) => {
5920
- let t = e.get("db"), n = await e.req.json(), r = n.node || n.activeNode || n, i = r.id || n.id, a = i != null && i !== "" && !isNaN(Number(i)) ? Number(i) : null, { title: o, slug: s, language: c, nodeType: l, contentType: u, isHidden: d, hidden: f, is_hidden: p, blocks: m, channels: h, trees: g, ..._ } = r, v = fi(_), { cleanedData: y, assetRefs: b } = ni(v), x = ui(d === void 0 ? f === void 0 ? p : f : d), S = c || "en", C = l || u || "page", w = e.get("user")?.id || null, T = a;
7381
+ let t = e.get("db"), n = await e.req.json(), r = n.node || n.activeNode || n, i = r.id || n.id, a = i != null && i !== "" && !isNaN(Number(i)) ? Number(i) : null, { title: o, slug: s, language: c, nodeType: l, contentType: u, isHidden: d, hidden: f, is_hidden: p, blocks: m, channels: h, trees: g, ..._ } = r, v = mi(_), { cleanedData: y, assetRefs: b } = ii(v), x = fi(d === void 0 ? f === void 0 ? p : f : d), S = c || "en", C = l || u || "page", w = e.get("user")?.id || null, T = a;
5921
7382
  if (a) {
5922
7383
  let n = await t.prepare("SELECT title, slug, contentType, language, draftDataJson, dataJson, publishedAt, status FROM content_nodes WHERE id = ?").get(a);
5923
7384
  if (m === void 0 && o === void 0 && s === void 0 && h === void 0 && g === void 0 && Object.keys(v).length === 0) return await t.prepare("\n UPDATE content_nodes \n SET isHidden = ?, \n updatedById = ?, \n updatedAt = CURRENT_TIMESTAMP\n WHERE id = ?\n ").run(x, w, a), await Y(e).clear(), e.json({
@@ -5926,7 +7387,7 @@ Z.get("/", async (e) => {
5926
7387
  status: n?.status || "published"
5927
7388
  });
5928
7389
  {
5929
- let e = o === void 0 ? n?.title || "Untitled" : o, r = s === void 0 ? n?.slug ?? null : li(s), i = C || n?.contentType || "page", c = S || n?.language || "en", l = n?.draftDataJson || n?.dataJson || "{}", u = {};
7390
+ let e = o === void 0 ? n?.title || "Untitled" : o, r = s === void 0 ? n?.slug ?? null : di(s), i = C || n?.contentType || "page", c = S || n?.language || "en", l = n?.draftDataJson || n?.dataJson || "{}", u = {};
5930
7391
  try {
5931
7392
  u = JSON.parse(l);
5932
7393
  } catch {}
@@ -5937,7 +7398,7 @@ Z.get("/", async (e) => {
5937
7398
  await t.prepare("\n UPDATE content_nodes \n SET title = ?, \n slug = ?, \n language = ?,\n contentType = ?, \n isHidden = ?, \n status = 'draft', \n draftDataJson = ?, \n updatedById = ?, \n updatedAt = CURRENT_TIMESTAMP\n WHERE id = ?\n ").run(e, r, c, i, x, d, w, a);
5938
7399
  }
5939
7400
  } else {
5940
- let e = o || "Untitled", n = li(s), r = JSON.stringify(y), i = await t.prepare("\n INSERT INTO content_nodes (contentType, title, slug, language, isHidden, status, draftDataJson, dataJson, createdById, updatedById)\n VALUES (?, ?, ?, ?, ?, 'draft', ?, NULL, ?, ?)\n ").run(C, e, n, S, x, r, w, w);
7401
+ let e = o || "Untitled", n = di(s), r = JSON.stringify(y), i = await t.prepare("\n INSERT INTO content_nodes (contentType, title, slug, language, isHidden, status, draftDataJson, dataJson, createdById, updatedById)\n VALUES (?, ?, ?, ?, ?, 'draft', ?, NULL, ?, ?)\n ").run(C, e, n, S, x, r, w, w);
5941
7402
  T = Number(i.lastInsertRowid);
5942
7403
  }
5943
7404
  if (h !== void 0 && Array.isArray(h) && T) {
@@ -5955,7 +7416,7 @@ Z.get("/", async (e) => {
5955
7416
  let i = Number(t.treeId) || t.treeId;
5956
7417
  if (!e.has(i)) {
5957
7418
  e.add(i);
5958
- let a = di(t.parentId ?? t._draftParentId ?? null), o = typeof t.sortOrder == "number" ? t.sortOrder : 0;
7419
+ let a = pi(t.parentId ?? t._draftParentId ?? null), o = typeof t.sortOrder == "number" ? t.sortOrder : 0;
5959
7420
  n.push("(?, ?, ?, ?)"), r.push(i, T, a, o);
5960
7421
  }
5961
7422
  }
@@ -5966,7 +7427,7 @@ Z.get("/", async (e) => {
5966
7427
  await t.prepare("DELETE FROM content_blocks WHERE contentId = ? AND isDraft = 1").run(T);
5967
7428
  let e = [], n = [];
5968
7429
  for (let t = 0; t < m.length; t++) {
5969
- let r = m[t], i = r.componentId || r.elementType || "text-block", a = r.data || {}, o = String(r.blockId || a.blockId || r.instanceId || r.id || `block-${Date.now()}`), { cleanedData: s, assetRefs: c } = ni({
7430
+ let r = m[t], i = r.componentId || r.elementType || "text-block", a = r.data || {}, o = String(r.blockId || a.blockId || r.instanceId || r.id || `block-${Date.now()}`), { cleanedData: s, assetRefs: c } = ii({
5970
7431
  ...a,
5971
7432
  blockId: o,
5972
7433
  _instanceId: o
@@ -5984,7 +7445,7 @@ Z.get("/", async (e) => {
5984
7445
  }
5985
7446
  if (T) {
5986
7447
  let e = [...b, ...E];
5987
- await ri(t, T, e);
7448
+ await ai(t, T, e);
5988
7449
  }
5989
7450
  return await Y(e).clear(), e.json({
5990
7451
  success: !0,
@@ -6048,8 +7509,8 @@ Z.get("/", async (e) => {
6048
7509
  });
6049
7510
  //#endregion
6050
7511
  //#region server/routes/admin/trees.ts
6051
- var mi = new e();
6052
- function hi(e, t = null) {
7512
+ var gi = new e();
7513
+ function _i(e, t = null) {
6053
7514
  let n = [];
6054
7515
  for (let r = 0; r < e.length; r++) {
6055
7516
  let i = e[r];
@@ -6062,20 +7523,20 @@ function hi(e, t = null) {
6062
7523
  id: a,
6063
7524
  parentId: t,
6064
7525
  sortOrder: r
6065
- }), i.children && Array.isArray(i.children) && i.children.length > 0 && n.push(...hi(i.children, a));
7526
+ }), i.children && Array.isArray(i.children) && i.children.length > 0 && n.push(..._i(i.children, a));
6066
7527
  }
6067
7528
  }
6068
7529
  return n;
6069
7530
  }
6070
- function gi(e) {
7531
+ function vi(e) {
6071
7532
  if (e == null || e === "null" || e === "" || typeof e == "string" && e.startsWith("draft-")) return null;
6072
7533
  let t = Number(e);
6073
7534
  return isNaN(t) ? null : t;
6074
7535
  }
6075
- function _i(e) {
7536
+ function yi(e) {
6076
7537
  return +(e === !0 || e === 1 || e === "1" || e === "true");
6077
7538
  }
6078
- mi.get("/tree.json", async (e) => {
7539
+ gi.get("/tree.json", async (e) => {
6079
7540
  try {
6080
7541
  let t = e.get("db"), n = e.req.query("treeId") || "main-nav", r = e.req.query("preview") === "true", i = 1;
6081
7542
  if (isNaN(Number(n))) {
@@ -6124,7 +7585,7 @@ mi.get("/tree.json", async (e) => {
6124
7585
  } catch (t) {
6125
7586
  return console.error("[CMS Tree API] GET Error:", t), e.json({ error: t.message || "Failed to fetch tree" }, 500);
6126
7587
  }
6127
- }), mi.post("/tree.json", async (e) => {
7588
+ }), gi.post("/tree.json", async (e) => {
6128
7589
  try {
6129
7590
  let t = e.get("db"), n = await e.req.json(), r = n.treeId ? String(n.treeId).trim() : "main-nav", i = Y(e), a = 1;
6130
7591
  if (isNaN(Number(r))) {
@@ -6136,7 +7597,7 @@ mi.get("/tree.json", async (e) => {
6136
7597
  }
6137
7598
  } else a = Number(r);
6138
7599
  if (n.tree && Array.isArray(n.tree)) {
6139
- let r = hi(n.tree, null);
7600
+ let r = _i(n.tree, null);
6140
7601
  if (r.length > 0) for (let e = 0; e < r.length; e += 50) {
6141
7602
  let n = r.slice(e, e + 50), i = n.map((e) => e.id), o = i.map(() => "?").join(","), s = "UPDATE tree_nodes SET \n";
6142
7603
  s += "parentId = CASE id \n", n.forEach(() => {
@@ -6153,9 +7614,9 @@ mi.get("/tree.json", async (e) => {
6153
7614
  }
6154
7615
  return await i.clear(), e.json({ success: !0 });
6155
7616
  }
6156
- let { action: o, title: s, nodeType: c, parentId: l, contentId: u, nodeData: d = {}, pageData: f = {} } = n, p = Object.keys(d).length > 0 ? { ...d } : { ...f }, m = _i(n.isHidden === void 0 ? p.isHidden === void 0 ? p.hidden : p.isHidden : n.isHidden);
7617
+ let { action: o, title: s, nodeType: c, parentId: l, contentId: u, nodeData: d = {}, pageData: f = {} } = n, p = Object.keys(d).length > 0 ? { ...d } : { ...f }, m = yi(n.isHidden === void 0 ? p.isHidden === void 0 ? p.hidden : p.isHidden : n.isHidden);
6157
7618
  delete p._isTreeDraft, delete p._draftParentId, delete p.isNew, delete p.nodeType, delete p.contentType, delete p.title, delete p.slug, delete p.hidden, delete p.is_hidden, delete p.isHidden, delete p.status;
6158
- let h = gi(l), g = e.get("user")?.id || null;
7619
+ let h = vi(l), g = e.get("user")?.id || null;
6159
7620
  if (o === "create") {
6160
7621
  let r = p.slug || n.slug || s, o = r ? String(r).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "") : null;
6161
7622
  if (o) {
@@ -6241,7 +7702,7 @@ mi.get("/tree.json", async (e) => {
6241
7702
  details: t.message
6242
7703
  }, 500);
6243
7704
  }
6244
- }), mi.get("/trees.json", async (e) => {
7705
+ }), gi.get("/trees.json", async (e) => {
6245
7706
  try {
6246
7707
  let t = e.get("db"), n = await t.prepare("SELECT * FROM trees ORDER BY LOWER(label) ASC").all(), r = Array.isArray(n) ? n : n?.results || [], i = await t.prepare("SELECT channelId, treeId FROM channel_trees").all(), a = (Array.isArray(i) ? i : i?.results || []).reduce((e, t) => {
6247
7708
  let n = Number(t.treeId), r = Number(t.channelId);
@@ -6270,7 +7731,7 @@ mi.get("/tree.json", async (e) => {
6270
7731
  } catch {
6271
7732
  return e.json([]);
6272
7733
  }
6273
- }), mi.post("/trees.json", async (e) => {
7734
+ }), gi.post("/trees.json", async (e) => {
6274
7735
  try {
6275
7736
  let t = e.get("db"), n = await e.req.json(), r = n.id, i = r != null && r !== "" && !isNaN(Number(r)) ? Number(r) : null, a = `tree-${Date.now().toString(36)}`, o = (n.key || n.slug || a).toLowerCase().replace(/[^a-z0-9_-]/g, "-"), s = n.label?.trim() || o, c = n.treeType !== void 0 && n.treeType !== null ? n.treeType : n.type ?? "site", l = n.channelId !== void 0 && n.channelId !== null && Number(n.channelId) || null, u = +(n.isHidden === !0 || n.isHidden === 1 || n.isHidden === "true"), d = e.get("user")?.id || null, f = { ...n };
6276
7737
  if (delete f.id, delete f.key, delete f.label, delete f.treeType, delete f.type, delete f.channelId, delete f.channels, delete f.isHidden, delete f.createdById, delete f.updatedById, delete f.createdAt, delete f.updatedAt, await t.prepare("SELECT id FROM trees WHERE key = ? AND id != ? LIMIT 1").get(o, i ?? -1)) return e.json({
@@ -6309,7 +7770,7 @@ mi.get("/tree.json", async (e) => {
6309
7770
  } catch (t) {
6310
7771
  return console.error("[API Trees] Error saving tree:", t), e.json({ error: t.message || "Failed to save tree" }, 500);
6311
7772
  }
6312
- }), mi.delete("/trees.json", async (e) => {
7773
+ }), gi.delete("/trees.json", async (e) => {
6313
7774
  let t = e.get("db"), n = e.req.query("id");
6314
7775
  if (!n) return e.json({ error: "Tree ID required" }, 400);
6315
7776
  let r = Number(n);
@@ -6324,8 +7785,8 @@ mi.get("/tree.json", async (e) => {
6324
7785
  });
6325
7786
  //#endregion
6326
7787
  //#region server/routes/admin/channels.ts
6327
- var vi = new e();
6328
- vi.get("/", async (e) => {
7788
+ var bi = new e();
7789
+ bi.get("/", async (e) => {
6329
7790
  try {
6330
7791
  let t = e.get("db"), n = await t.prepare("SELECT * FROM channels ORDER BY id ASC").all(), r = Array.isArray(n) ? n : n?.results || [], i = await t.prepare("SELECT channelId, treeId, key, metaJson FROM channel_trees").all(), a = ((Array.isArray(i) ? i : i?.results || []) || []).reduce((e, t) => {
6331
7792
  e[t.channelId] || (e[t.channelId] = []);
@@ -6349,7 +7810,7 @@ vi.get("/", async (e) => {
6349
7810
  isHidden: !!e.isHidden,
6350
7811
  trees: a[e.id] || []
6351
7812
  };
6352
- }), s = e.env?.BUNDLED_DEFINITIONS, c = ci(s)?.channelTemplate || {
7813
+ }), s = e.env?.BUNDLED_DEFINITIONS, c = ui(s)?.channelTemplate || {
6353
7814
  label: "Channel Settings",
6354
7815
  fields: {
6355
7816
  key: {
@@ -6391,7 +7852,7 @@ vi.get("/", async (e) => {
6391
7852
  error: t.message
6392
7853
  }, 500);
6393
7854
  }
6394
- }), vi.post("/", async (e) => {
7855
+ }), bi.post("/", async (e) => {
6395
7856
  try {
6396
7857
  let t = e.get("db"), n = await e.req.json(), r = n.id, i = r != null && r !== "" && !isNaN(Number(r)) ? Number(r) : null, { key: a, label: o, channelType: s = "website", domain: c = "localhost", baseUrl: l = "http://localhost:4321", defaultLanguage: u = "en", isHidden: d = !1, trees: f = [], createdById: p = null, updatedById: m = null, id: h, createdAt: g, updatedAt: _, ...v } = n, y = a?.trim() || "main", b = o?.trim() || "Untitled Channel", x = Array.isArray(f) ? f : [], S = JSON.stringify(v || {}), C = e.get("user")?.id || m || p || null;
6397
7858
  if (await t.prepare("SELECT id FROM channels WHERE key = ? AND id != ? LIMIT 1").get(y, i ?? -1)) return e.json({
@@ -6428,7 +7889,7 @@ vi.get("/", async (e) => {
6428
7889
  details: t.message
6429
7890
  }, 500);
6430
7891
  }
6431
- }), vi.delete("/", async (e) => {
7892
+ }), bi.delete("/", async (e) => {
6432
7893
  let t = e.get("db"), n = e.req.query("id");
6433
7894
  if (!n) return e.json({ error: "Channel ID required" }, 400);
6434
7895
  let r = Number(n);
@@ -6446,10 +7907,10 @@ vi.get("/", async (e) => {
6446
7907
  });
6447
7908
  //#endregion
6448
7909
  //#region server/routes/admin/schemas.ts
6449
- var yi = new e(), bi = null, xi = (e) => {
7910
+ var xi = new e(), Si = null, Ci = (e) => {
6450
7911
  try {
6451
- if (!bi) {
6452
- let t = e.env?.BUNDLED_DEFINITIONS, n = si(t), r = n.userTemplate || {
7912
+ if (!Si) {
7913
+ let t = e.env?.BUNDLED_DEFINITIONS, n = li(t), r = n.userTemplate || {
6453
7914
  id: "userTemplate",
6454
7915
  label: "User Account",
6455
7916
  fields: {
@@ -6485,7 +7946,7 @@ var yi = new e(), bi = null, xi = (e) => {
6485
7946
  }
6486
7947
  }
6487
7948
  };
6488
- bi = {
7949
+ Si = {
6489
7950
  channelTemplate: n.channelTemplate || null,
6490
7951
  treeTemplate: n.treeTemplate || null,
6491
7952
  userTemplate: r,
@@ -6497,7 +7958,7 @@ var yi = new e(), bi = null, xi = (e) => {
6497
7958
  blockLayouts: n.blockLayouts || {}
6498
7959
  };
6499
7960
  }
6500
- return e.json(bi, 200, { "Cache-Control": "public, max-age=300, stale-while-revalidate=86400" });
7961
+ return e.json(Si, 200, { "Cache-Control": "public, max-age=300, stale-while-revalidate=86400" });
6501
7962
  } catch (t) {
6502
7963
  return console.error("[CMS API] Error loading schemas:", t), e.json({
6503
7964
  error: "Failed to load schemas",
@@ -6505,10 +7966,10 @@ var yi = new e(), bi = null, xi = (e) => {
6505
7966
  }, 500);
6506
7967
  }
6507
7968
  };
6508
- yi.get("/", xi), yi.get("/schemas.json", xi);
7969
+ xi.get("/", Ci), xi.get("/schemas.json", Ci);
6509
7970
  //#endregion
6510
7971
  //#region server/routes/admin/validation.ts
6511
- var Si = new e(), Ci = {
7972
+ var wi = new e(), Ti = {
6512
7973
  node: "content_nodes",
6513
7974
  nodes: "content_nodes",
6514
7975
  content_node: "content_nodes",
@@ -6520,7 +7981,7 @@ var Si = new e(), Ci = {
6520
7981
  user: "users",
6521
7982
  users: "users",
6522
7983
  user_account: "user_accounts"
6523
- }, wi = {
7984
+ }, Ei = {
6524
7985
  content_nodes: [
6525
7986
  "id",
6526
7987
  "title",
@@ -6577,11 +8038,11 @@ var Si = new e(), Ci = {
6577
8038
  "createdAt"
6578
8039
  ]
6579
8040
  };
6580
- Si.post("/validate-unique", async (e) => {
8041
+ wi.post("/validate-unique", async (e) => {
6581
8042
  try {
6582
8043
  let t = e.get("db"), { entityType: n, field: r, value: i, excludeId: a } = await e.req.json();
6583
8044
  if (!r || i == null || String(i).trim() === "") return e.json({ isUnique: !0 });
6584
- let o = Ci[n] || "content_nodes", s = r.replace(/[^a-zA-Z0-9_]/g, ""), c = (wi[o] || wi.content_nodes).includes(s), l = -1;
8045
+ let o = Ti[n] || "content_nodes", s = r.replace(/[^a-zA-Z0-9_]/g, ""), c = (Ei[o] || Ei.content_nodes).includes(s), l = -1;
6585
8046
  if (a != null && String(a).trim() !== "") {
6586
8047
  let e = Number(a);
6587
8048
  l = isNaN(e) ? String(a) : e;
@@ -6593,7 +8054,7 @@ Si.post("/validate-unique", async (e) => {
6593
8054
  } catch (t) {
6594
8055
  return console.error("[API Validation] Error validating global uniqueness:", t), e.json({ error: "Failed to validate uniqueness" }, 500);
6595
8056
  }
6596
- }), Si.post("/validate-unique-sibling", async (e) => {
8057
+ }), wi.post("/validate-unique-sibling", async (e) => {
6597
8058
  try {
6598
8059
  let t = e.get("db"), { slug: n, treeId: r, parentId: i, excludeTreeNodeId: a } = await e.req.json();
6599
8060
  if (!n || !String(n).trim() || !r) return e.json({ isUnique: !0 });
@@ -6620,8 +8081,8 @@ Si.post("/validate-unique", async (e) => {
6620
8081
  });
6621
8082
  //#endregion
6622
8083
  //#region server/routes/admin/stats.ts
6623
- var Ti = new e();
6624
- Ti.get("/", async (e) => {
8084
+ var Di = new e();
8085
+ Di.get("/", async (e) => {
6625
8086
  try {
6626
8087
  let t = e.get("db"), n = await t.prepare("\n SELECT \n COUNT(*) as total,\n SUM(CASE WHEN isHidden = 0 THEN 1 ELSE 0 END) as published,\n SUM(CASE WHEN isHidden = 1 THEN 1 ELSE 0 END) as hidden\n FROM content_nodes\n ").get(), r = Number(n?.total) || 0, i = Number(n?.published) || 0, a = Number(n?.hidden) || 0, o = await t.prepare("\n SELECT \n (SELECT COUNT(*) FROM channels) as totalChannels,\n (SELECT COUNT(*) FROM trees) as totalTrees,\n (SELECT COUNT(*) FROM users) as totalUsers\n ").get(), s = await t.prepare("\n SELECT contentType as type, COUNT(*) as count \n FROM content_nodes \n GROUP BY contentType \n ORDER BY count DESC\n ").all(), c = Array.isArray(s) ? s : s?.results || [], l = await t.prepare("\n SELECT id, title, slug, contentType, isHidden, status, updatedAt \n FROM content_nodes \n ORDER BY updatedAt DESC \n LIMIT 5\n ").all(), u = (Array.isArray(l) ? l : l?.results || []).map((e) => ({
6627
8088
  ...e,
@@ -6636,7 +8097,7 @@ Ti.get("/", async (e) => {
6636
8097
  isHidden: !!e.isHidden,
6637
8098
  channelNames: e.channelLabels ? e.channelLabels.split(",") : [],
6638
8099
  treeNames: e.treeLabels ? e.treeLabels.split(",") : []
6639
- })), p = e.env?.BUNDLED_DEFINITIONS, m = si(p), h = m.nodes || m.nodeSchemas || {}, g = c.map((e) => {
8100
+ })), p = e.env?.BUNDLED_DEFINITIONS, m = li(p), h = m.nodes || m.nodeSchemas || {}, g = c.map((e) => {
6640
8101
  let t = e.type || "node", n = h[t]?.label || t.charAt(0).toUpperCase() + t.slice(1);
6641
8102
  return {
6642
8103
  type: t,
@@ -6664,7 +8125,7 @@ Ti.get("/", async (e) => {
6664
8125
  });
6665
8126
  //#endregion
6666
8127
  //#region server/storage/provider.ts
6667
- function Ei(e) {
8128
+ function Oi(e) {
6668
8129
  let t = e.split(".").pop()?.toLowerCase() || "bin";
6669
8130
  return t = t.replace(/[^a-z0-9]/g, ""), [
6670
8131
  "php",
@@ -6679,14 +8140,14 @@ function Ei(e) {
6679
8140
  "cjs"
6680
8141
  ].includes(t) ? "bin" : t;
6681
8142
  }
6682
- var Di = class {
8143
+ var ki = class {
6683
8144
  bucket;
6684
8145
  publicDomain;
6685
8146
  constructor(e, t) {
6686
8147
  this.bucket = e, this.publicDomain = t;
6687
8148
  }
6688
8149
  async upload(e, t = "uploads") {
6689
- let n = Ei(e.name), r = `${t}/${crypto.randomUUID().replace(/-/g, "")}.${n}`;
8150
+ let n = Oi(e.name), r = `${t}/${crypto.randomUUID().replace(/-/g, "")}.${n}`;
6690
8151
  return await this.bucket.put(r, e.stream(), { httpMetadata: { contentType: e.type } }), {
6691
8152
  key: r,
6692
8153
  url: `https://${this.publicDomain}/${r}`
@@ -6695,7 +8156,7 @@ var Di = class {
6695
8156
  async delete(e) {
6696
8157
  await this.bucket.delete(e);
6697
8158
  }
6698
- }, Oi = class {
8159
+ }, Ai = class {
6699
8160
  customStoragePath;
6700
8161
  constructor(e) {
6701
8162
  this.customStoragePath = e;
@@ -6713,7 +8174,7 @@ var Di = class {
6713
8174
  ), { pipeline: a } = await import(
6714
8175
  /* @vite-ignore */
6715
8176
  "node:stream/promises"
6716
- ), o = Ei(e.name), s = `${t}/${crypto.randomUUID().replace(/-/g, "")}.${o}`, c = this.customStoragePath || "./public/media", l = n.resolve(process.cwd(), c), u = n.join(l, s);
8177
+ ), o = Oi(e.name), s = `${t}/${crypto.randomUUID().replace(/-/g, "")}.${o}`, c = this.customStoragePath || "./public/media", l = n.resolve(process.cwd(), c), u = n.join(l, s);
6717
8178
  await i.mkdir(n.dirname(u), { recursive: !0 });
6718
8179
  let d = r.createWriteStream(u);
6719
8180
  return await a(e.stream(), d), {
@@ -6736,16 +8197,16 @@ var Di = class {
6736
8197
  }
6737
8198
  }
6738
8199
  };
6739
- function ki(e) {
8200
+ function ji(e) {
6740
8201
  if (e.MEDIA_BUCKET) {
6741
8202
  let t = e.CDN_DOMAIN || "cdn.yourdomain.com";
6742
- return new Di(e.MEDIA_BUCKET, t);
8203
+ return new ki(e.MEDIA_BUCKET, t);
6743
8204
  }
6744
- return new Oi(e.LOCAL_MEDIA_PATH);
8205
+ return new Ai(e.LOCAL_MEDIA_PATH);
6745
8206
  }
6746
8207
  //#endregion
6747
8208
  //#region server/routes/admin/assets.ts
6748
- var Ai = new e();
8209
+ var Mi = new e();
6749
8210
  async function Q(e, t, n = []) {
6750
8211
  let r = e.prepare(t);
6751
8212
  if (typeof r.bind == "function") {
@@ -6758,16 +8219,16 @@ async function Q(e, t, n = []) {
6758
8219
  }
6759
8220
  return [];
6760
8221
  }
6761
- async function ji(e, t, n = []) {
8222
+ async function Ni(e, t, n = []) {
6762
8223
  let r = e.prepare(t);
6763
8224
  if (typeof r.bind == "function") return await r.bind(...n).run();
6764
8225
  if (typeof r.run == "function") return await r.run(...n);
6765
8226
  }
6766
- function Mi(e, t, n) {
8227
+ function Pi(e, t, n) {
6767
8228
  let r = e || (t ? `/media/${t}` : "");
6768
8229
  return r && n && r.startsWith(`https://${n}/`) && !r.includes("/media/") && (r = r.replace(`https://${n}/`, `https://${n}/media/`)), r;
6769
8230
  }
6770
- Ai.get("/", async (e) => {
8231
+ Mi.get("/", async (e) => {
6771
8232
  try {
6772
8233
  let t = g(e), { search: n = "", type: r = "all", page: i = "1", limit: a = "24", sort: o = "createdAt", order: s = "DESC", nodeId: c, channelId: l, trashed: u } = e.req.query(), d = Math.max(1, parseInt(i, 10) || 1), f = Math.max(1, Math.min(100, parseInt(a, 10) || 24)), p = (d - 1) * f, m = {
6773
8234
  createdAt: "a.createdAt",
@@ -6830,7 +8291,7 @@ Ai.get("/", async (e) => {
6830
8291
  try {
6831
8292
  n = JSON.parse(t.dataJson || "{}");
6832
8293
  } catch {}
6833
- let r = Mi(t.cdnUrl, t.storageKeyPrivate, e.env?.CDN_DOMAIN);
8294
+ let r = Pi(t.cdnUrl, t.storageKeyPrivate, e.env?.CDN_DOMAIN);
6834
8295
  return {
6835
8296
  id: t.id,
6836
8297
  filename: t.filename || "Untitled Asset",
@@ -6853,9 +8314,9 @@ Ai.get("/", async (e) => {
6853
8314
  details: t.message || String(t)
6854
8315
  }, 500);
6855
8316
  }
6856
- }), Ai.post("/upload", async (e) => {
8317
+ }), Mi.post("/upload", async (e) => {
6857
8318
  try {
6858
- let t = g(e), n = ki(e.env), r = await e.req.parseBody(), i = r.file, a = r.isVariant === "true" || r.isVariant === "1" || r.temporary === "true", o = r.parentAssetId || r.parentAsset, s = typeof o == "string" && o.trim().length > 0 ? o.trim() : null;
8319
+ let t = g(e), n = ji(e.env), r = await e.req.parseBody(), i = r.file, a = r.isVariant === "true" || r.isVariant === "1" || r.temporary === "true", o = r.parentAssetId || r.parentAsset, s = typeof o == "string" && o.trim().length > 0 ? o.trim() : null;
6859
8320
  s && (await Q(t, "SELECT id FROM assets WHERE id = ?", [s])).length === 0 && (s = null);
6860
8321
  let c = r.cropCoordinates, l = null, u = null;
6861
8322
  if (c) {
@@ -6872,7 +8333,7 @@ Ai.get("/", async (e) => {
6872
8333
  let y = e.env.CDN_DOMAIN, b = v.replace(/^\//, ""), x = y ? `https://${y}/media/${b}` : `/media/${b}`, S = i.type || "application/octet-stream", C = i.size || 0, w = e.get("userId"), T = typeof w == "string" && w.trim().length > 0 ? w : null;
6873
8334
  T && (await Q(t, "SELECT id FROM users WHERE id = ?", [T])).length === 0 && (T = null);
6874
8335
  let E = +!!m;
6875
- await ji(t, "\n INSERT INTO assets (id, filename, mimeType, sizeBytes, storageKeyPrivate, cdnUrl, createdById, isSystemVariant, parentAssetId, cropCoordinatesJson)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ", [
8336
+ await Ni(t, "\n INSERT INTO assets (id, filename, mimeType, sizeBytes, storageKeyPrivate, cdnUrl, createdById, isSystemVariant, parentAssetId, cropCoordinatesJson)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ", [
6876
8337
  f,
6877
8338
  i.name,
6878
8339
  S,
@@ -6887,7 +8348,7 @@ Ai.get("/", async (e) => {
6887
8348
  let D = x;
6888
8349
  if (s) {
6889
8350
  let e = await Q(t, "SELECT cdnUrl, storageKeyPrivate FROM assets WHERE id = ?", [s]);
6890
- e.length > 0 && (D = Mi(e[0].cdnUrl, e[0].storageKeyPrivate, y));
8351
+ e.length > 0 && (D = Pi(e[0].cdnUrl, e[0].storageKeyPrivate, y));
6891
8352
  }
6892
8353
  return e.json({
6893
8354
  id: f,
@@ -6906,7 +8367,7 @@ Ai.get("/", async (e) => {
6906
8367
  details: t.message || String(t)
6907
8368
  }, 500);
6908
8369
  }
6909
- }), Ai.get("/:id/details", async (e) => {
8370
+ }), Mi.get("/:id/details", async (e) => {
6910
8371
  try {
6911
8372
  let t = g(e), n = e.req.param("id"), r = await Q(t, "SELECT * FROM assets WHERE id = ?", [n]);
6912
8373
  if (!r || r.length === 0) return e.json({ error: "Asset not found" }, 404);
@@ -6925,7 +8386,7 @@ Ai.get("/", async (e) => {
6925
8386
  try {
6926
8387
  c = JSON.parse(i.dataJson || "{}");
6927
8388
  } catch {}
6928
- let l = Mi(i.cdnUrl, i.storageKeyPrivate, e.env?.CDN_DOMAIN);
8389
+ let l = Pi(i.cdnUrl, i.storageKeyPrivate, e.env?.CDN_DOMAIN);
6929
8390
  return e.json({
6930
8391
  id: i.id,
6931
8392
  filename: i.filename,
@@ -6951,7 +8412,7 @@ Ai.get("/", async (e) => {
6951
8412
  createdAt: t.createdAt,
6952
8413
  parentAssetId: t.parentAssetId || i.id,
6953
8414
  cropCoordinates: n,
6954
- url: Mi(t.cdnUrl, t.storageKeyPrivate, e.env?.CDN_DOMAIN),
8415
+ url: Pi(t.cdnUrl, t.storageKeyPrivate, e.env?.CDN_DOMAIN),
6955
8416
  originalUrl: l
6956
8417
  };
6957
8418
  })
@@ -6959,7 +8420,7 @@ Ai.get("/", async (e) => {
6959
8420
  } catch (t) {
6960
8421
  return console.error("❌ [Asset Details Error]:", t), e.json({ error: "Failed to load details" }, 500);
6961
8422
  }
6962
- }), Ai.put("/:id", async (e) => {
8423
+ }), Mi.put("/:id", async (e) => {
6963
8424
  try {
6964
8425
  let t = g(e), n = e.req.param("id"), r = await e.req.json(), i = await Q(t, "SELECT filename, dataJson FROM assets WHERE id = ?", [n]);
6965
8426
  if (!i || i.length === 0) return e.json({ error: "Asset not found" }, 404);
@@ -6967,7 +8428,7 @@ Ai.get("/", async (e) => {
6967
8428
  try {
6968
8429
  o = JSON.parse(a.dataJson || "{}");
6969
8430
  } catch {}
6970
- return r.title !== void 0 && (o.title = r.title), r.alt !== void 0 && (o.alt = r.alt), await ji(t, "UPDATE assets SET filename = ?, dataJson = ?, updatedAt = CURRENT_TIMESTAMP WHERE id = ?", [
8431
+ return r.title !== void 0 && (o.title = r.title), r.alt !== void 0 && (o.alt = r.alt), await Ni(t, "UPDATE assets SET filename = ?, dataJson = ?, updatedAt = CURRENT_TIMESTAMP WHERE id = ?", [
6971
8432
  r.filename === void 0 ? a.filename : r.filename,
6972
8433
  JSON.stringify(o),
6973
8434
  n
@@ -6975,10 +8436,10 @@ Ai.get("/", async (e) => {
6975
8436
  } catch (t) {
6976
8437
  return console.error("❌ [Asset Update Error]:", t), e.json({ error: "Failed to update asset" }, 500);
6977
8438
  }
6978
- }), Ai.delete("/:id", async (e) => {
8439
+ }), Mi.delete("/:id", async (e) => {
6979
8440
  try {
6980
8441
  let t = g(e), n = e.req.param("id"), r = (await Q(t, "SELECT id, filename, isSystemVariant FROM assets WHERE id = ?", [n]))[0];
6981
- return r ? (r.isSystemVariant ? await ji(t, "UPDATE assets SET deletedAt = CURRENT_TIMESTAMP WHERE id = ?", [n]) : await ji(t, "UPDATE assets\n SET deletedAt = CURRENT_TIMESTAMP\n WHERE id = ? OR parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
8442
+ return r ? (r.isSystemVariant ? await Ni(t, "UPDATE assets SET deletedAt = CURRENT_TIMESTAMP WHERE id = ?", [n]) : await Ni(t, "UPDATE assets\n SET deletedAt = CURRENT_TIMESTAMP\n WHERE id = ? OR parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
6982
8443
  n,
6983
8444
  n,
6984
8445
  `crop_%${r.filename ? r.filename.replace(/\.[^/.]+$/, "") : ""}%`,
@@ -6994,12 +8455,12 @@ Ai.get("/", async (e) => {
6994
8455
  details: t.message || String(t)
6995
8456
  }, 500);
6996
8457
  }
6997
- }), Ai.post("/restore", async (e) => {
8458
+ }), Mi.post("/restore", async (e) => {
6998
8459
  try {
6999
8460
  let t = g(e), n = await e.req.json(), r = n.id || n.assetId;
7000
8461
  if (!r) return e.json({ error: "Asset ID required" }, 400);
7001
8462
  let i = (await Q(t, "SELECT id, filename FROM assets WHERE id = ?", [r]))[0];
7002
- return i ? (await ji(t, "UPDATE assets \n SET deletedAt = NULL \n WHERE id = ? OR parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
8463
+ return i ? (await Ni(t, "UPDATE assets \n SET deletedAt = NULL \n WHERE id = ? OR parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
7003
8464
  r,
7004
8465
  r,
7005
8466
  `crop_%${i.filename ? i.filename.replace(/\.[^/.]+$/, "") : ""}%`,
@@ -7015,9 +8476,9 @@ Ai.get("/", async (e) => {
7015
8476
  details: t.message
7016
8477
  }, 500);
7017
8478
  }
7018
- }), Ai.delete("/purge/:id", async (e) => {
8479
+ }), Mi.delete("/purge/:id", async (e) => {
7019
8480
  try {
7020
- let t = g(e), n = ki(e.env), r = e.req.param("id"), i = (await Q(t, "SELECT id, filename, storageKeyPrivate, isSystemVariant FROM assets WHERE id = ?", [r]))[0];
8481
+ let t = g(e), n = ji(e.env), r = e.req.param("id"), i = (await Q(t, "SELECT id, filename, storageKeyPrivate, isSystemVariant FROM assets WHERE id = ?", [r]))[0];
7021
8482
  if (!i) return e.json({ error: "Asset not found" }, 404);
7022
8483
  let a = [i];
7023
8484
  i.isSystemVariant || (a = [i, ...await Q(t, "SELECT id, storageKeyPrivate FROM assets \n WHERE parentAssetId = ? OR (isSystemVariant = 1 AND (filename LIKE ? OR filename LIKE ?))", [
@@ -7034,7 +8495,7 @@ Ai.get("/", async (e) => {
7034
8495
  }
7035
8496
  }
7036
8497
  let s = o.map(() => "?").join(",");
7037
- return await ji(t, `DELETE FROM node_assets WHERE assetId IN (${s})`, o), await ji(t, `DELETE FROM assets WHERE id IN (${s})`, o), e.json({
8498
+ return await Ni(t, `DELETE FROM node_assets WHERE assetId IN (${s})`, o), await Ni(t, `DELETE FROM assets WHERE id IN (${s})`, o), e.json({
7038
8499
  success: !0,
7039
8500
  id: r,
7040
8501
  purged: !0,
@@ -7050,8 +8511,8 @@ Ai.get("/", async (e) => {
7050
8511
  });
7051
8512
  //#endregion
7052
8513
  //#region server/routes/public/node.ts
7053
- var Ni = new e();
7054
- function Pi(e, t) {
8514
+ var Fi = new e();
8515
+ function Ii(e, t) {
7055
8516
  let n = /* @__PURE__ */ new Date();
7056
8517
  if (e && String(e).trim() !== "") {
7057
8518
  let t = new Date(e);
@@ -7063,7 +8524,7 @@ function Pi(e, t) {
7063
8524
  }
7064
8525
  return !0;
7065
8526
  }
7066
- async function Fi(e, t) {
8527
+ async function Li(e, t) {
7067
8528
  if (!t || typeof t != "object") return t;
7068
8529
  let n = { ...t };
7069
8530
  for (let [t, r] of Object.entries(n)) if (typeof r == "string" && r.startsWith("ast_")) try {
@@ -7084,10 +8545,10 @@ async function Fi(e, t) {
7084
8545
  };
7085
8546
  }
7086
8547
  } catch {}
7087
- else typeof r == "object" && r && !Array.isArray(r) && !r.url && (n[t] = await Fi(e, r));
8548
+ else typeof r == "object" && r && !Array.isArray(r) && !r.url && (n[t] = await Li(e, r));
7088
8549
  return n;
7089
8550
  }
7090
- async function Ii(e, t, n) {
8551
+ async function Ri(e, t, n) {
7091
8552
  let r = t.filter((e) => e.componentId === "content-feed" || e.componentId === "article-list");
7092
8553
  for (let t of r) {
7093
8554
  let r = t.data || {}, i = r.nodeType || "article", a = Number(r.limit) || 12, o = r.sortBy || "updatedAt", s = "FROM content_nodes WHERE contentType = ? AND isHidden = 0 AND (status = 'published' OR status IS NULL)", c = [i];
@@ -7103,7 +8564,7 @@ async function Ii(e, t, n) {
7103
8564
  if (e.dataJson) try {
7104
8565
  t = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
7105
8566
  } catch {}
7106
- return Pi(t.startShowingAt, t.stopShowingAt) ? {
8567
+ return Ii(t.startShowingAt, t.stopShowingAt) ? {
7107
8568
  id: e.id,
7108
8569
  title: e.title,
7109
8570
  slug: e.slug,
@@ -7120,7 +8581,7 @@ async function Ii(e, t, n) {
7120
8581
  }
7121
8582
  }
7122
8583
  }
7123
- async function Li(e, t, n, r, i = !1) {
8584
+ async function zi(e, t, n, r, i = !1) {
7124
8585
  if (!t) return { blocks: [] };
7125
8586
  let a = await e.prepare("\n WITH RECURSIVE ancestor_path(id, contentId, title, slug, parentId, level) AS (\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? OR c.id = ?\n UNION ALL\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT * FROM ancestor_path ORDER BY level ASC\n ").all(t, t), o = Array.isArray(a) ? a : a?.results || [];
7126
8587
  if (!o || o.length === 0) return { blocks: [] };
@@ -7150,10 +8611,10 @@ async function Li(e, t, n, r, i = !1) {
7150
8611
  try {
7151
8612
  o = typeof t.dataJson == "string" ? JSON.parse(t.dataJson) : t.dataJson;
7152
8613
  } catch {}
7153
- let s = o.hidden === !0 || o.hidden === 1 || o.hidden === "1" || o.hidden === "true", l = Pi(o.startShowingAt, o.stopShowingAt);
8614
+ let s = o.hidden === !0 || o.hidden === 1 || o.hidden === "1" || o.hidden === "true", l = Ii(o.startShowingAt, o.stopShowingAt);
7154
8615
  if (!i && (s || !l)) continue;
7155
- let u = t.elementType || t.componentId || "text-block", d = r.blocks?.[u]?.fields || r.elements?.[u]?.fields || r.components?.[u]?.fields || {}, f = String(o.blockId || o._instanceId || o.id || t.blockId || t.id), p = Ri(o, d);
7156
- p = await ai(e, p), p = await Fi(e, p), p.blockId = f;
8616
+ let u = t.elementType || t.componentId || "text-block", d = r.blocks?.[u]?.fields || r.elements?.[u]?.fields || r.components?.[u]?.fields || {}, f = String(o.blockId || o._instanceId || o.id || t.blockId || t.id), p = Bi(o, d);
8617
+ p = await si(e, p), p = await Li(e, p), p.blockId = f;
7157
8618
  let m = t.region || n;
7158
8619
  c[m] || (c[m] = []), c[m].push({
7159
8620
  instanceId: t.id,
@@ -7172,7 +8633,7 @@ async function Li(e, t, n, r, i = !1) {
7172
8633
  }
7173
8634
  return { blocks: [] };
7174
8635
  }
7175
- function Ri(e, t = {}) {
8636
+ function Bi(e, t = {}) {
7176
8637
  let n = {};
7177
8638
  for (let [r, i] of Object.entries(e)) {
7178
8639
  if (r === "disabledRegions" || r === "hidden" || r === "is_hidden" || r === "isHidden" || r === "status" || r === "startShowingAt" || r === "stopShowingAt" || r === "slug" || r === "title" || r === "id" || r.startsWith("_")) continue;
@@ -7181,7 +8642,7 @@ function Ri(e, t = {}) {
7181
8642
  }
7182
8643
  return n;
7183
8644
  }
7184
- async function zi(e, t, n) {
8645
+ async function Vi(e, t, n) {
7185
8646
  if (!t) return "";
7186
8647
  let r = await e.prepare("\n WITH RECURSIVE ancestor_path(id, parentId, slug, level) AS (\n SELECT t.id, t.parentId, c.slug, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? AND t.treeId = ?\n UNION ALL\n SELECT t.id, t.parentId, c.slug, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n WHERE t.treeId = ?\n )\n SELECT slug FROM ancestor_path ORDER BY level DESC\n ").all(t, n, n), i = Array.isArray(r) ? r : r?.results || [], a = [];
7187
8648
  for (let e of i) {
@@ -7190,7 +8651,7 @@ async function zi(e, t, n) {
7190
8651
  }
7191
8652
  return "/" + a.join("/");
7192
8653
  }
7193
- async function Bi(e, t, n, r, i) {
8654
+ async function Hi(e, t, n, r, i) {
7194
8655
  let a = {}, o = null;
7195
8656
  if (t) {
7196
8657
  let n = await e.prepare("\n WITH RECURSIVE ancestor_path(id, contentId, title, slug, parentId, level) AS (\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? OR c.id = ?\n UNION ALL\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT c.dataJson, c.draftDataJson \n FROM ancestor_path ap\n INNER JOIN content_nodes c ON ap.contentId = c.id\n ORDER BY ap.level ASC\n ").all(t, t), i = Array.isArray(n) ? n : n?.results || [], s = /* @__PURE__ */ new Set([
@@ -7228,7 +8689,7 @@ async function Bi(e, t, n, r, i) {
7228
8689
  inheritedFields: a
7229
8690
  };
7230
8691
  }
7231
- Ni.get("/*", async (e) => {
8692
+ Fi.get("/*", async (e) => {
7232
8693
  try {
7233
8694
  let t = e.get("db"), n = new URL(e.req.url).pathname.match(/\/node\/(.+)$/), r = (n ? n[1] : "home").replace(/^\/+|\/+$/g, ""), i = e.req.query("channelId") || e.req.query("channel") || "1", a = e.req.query("lang") || "en", o = e.req.query("preview") === "true", s = isNaN(Number(i)) ? await t.prepare("SELECT * FROM channels WHERE key = ?").get(i) : await t.prepare("SELECT * FROM channels WHERE id = ?").get(Number(i));
7234
8695
  if (!s) return e.json({ error: `Channel '${i}' not found` }, 404);
@@ -7239,7 +8700,7 @@ Ni.get("/*", async (e) => {
7239
8700
  let t = await d.get(f);
7240
8701
  if (t) return e.header("X-Cache", "HIT"), e.json(t);
7241
8702
  }
7242
- let p = ci(e.env?.BUNDLED_DEFINITIONS), m = !isNaN(Number(r)) && r.length > 0, h = null, g = null, _ = e.req.query("treeId");
8703
+ let p = ui(e.env?.BUNDLED_DEFINITIONS), m = !isNaN(Number(r)) && r.length > 0, h = null, g = null, _ = e.req.query("treeId");
7243
8704
  if (m) h = l === null ? await t.prepare("SELECT * FROM content_nodes WHERE id = ?").get(Number(r)) : await t.prepare("\n SELECT cn.* \n FROM content_nodes cn\n INNER JOIN node_channels nc ON cn.id = nc.nodeId\n WHERE cn.id = ? AND nc.channelId = ?\n ").get(Number(r), l);
7244
8705
  else {
7245
8706
  let e = r.split("/"), n = e[e.length - 1], i = "/" + r.replace(/^\/+|\/+$/g, ""), a = `
@@ -7250,7 +8711,7 @@ Ni.get("/*", async (e) => {
7250
8711
  WHERE cn.slug = ? ${l === null ? "" : "AND nc.channelId = ?"}
7251
8712
  `, o = l === null ? [n] : [n, l], s = await t.prepare(a).all(...o), c = Array.isArray(s) ? s : s?.results || [];
7252
8713
  if (c.length > 0) for (let e of c) {
7253
- let n = (await zi(t, e.treeNodeId, e.treeId)).replace(/^\/+|\/+$/g, ""), r = i.replace(/^\/+|\/+$/g, "");
8714
+ let n = (await Vi(t, e.treeNodeId, e.treeId)).replace(/^\/+|\/+$/g, ""), r = i.replace(/^\/+|\/+$/g, "");
7254
8715
  if (n === r || r === "home" && (n === "" || n === "home")) {
7255
8716
  h = e, g = e;
7256
8717
  break;
@@ -7268,7 +8729,7 @@ Ni.get("/*", async (e) => {
7268
8729
  LIMIT 1
7269
8730
  `).get(...e);
7270
8731
  }
7271
- let v = g?.treeId || _ || "main-nav", y = g?.parentId || null, b = g?.treeNodeId ? await zi(t, g.treeNodeId, v) : `/${(h.slug || "").replace(/^\/+|\/+$/g, "")}`, x = {
8732
+ let v = g?.treeId || _ || "main-nav", y = g?.parentId || null, b = g?.treeNodeId ? await Vi(t, g.treeNodeId, v) : `/${(h.slug || "").replace(/^\/+|\/+$/g, "")}`, x = {
7272
8733
  id: h.id,
7273
8734
  title: h.title,
7274
8735
  slug: h.slug,
@@ -7286,11 +8747,11 @@ Ni.get("/*", async (e) => {
7286
8747
  k = typeof A == "string" ? JSON.parse(A) : A;
7287
8748
  } catch {}
7288
8749
  k.disabledRegions && (T = k.disabledRegions), O = k.hidden === !0 || k.hidden === 1 || k.hidden === "1" || k.hidden === "true", E = k.startShowingAt || null, D = k.stopShowingAt || null;
7289
- let j = k.layoutId, ee = j && j !== "inherit", { resolvedLayoutId: M, inheritedFields: te } = await Bi(t, y, v, o, w), N = ee ? j : M || C.defaultLayout || null;
8750
+ let j = k.layoutId, ee = j && j !== "inherit", { resolvedLayoutId: M, inheritedFields: te } = await Hi(t, y, v, o, w), N = ee ? j : M || C.defaultLayout || null;
7290
8751
  for (let [e, t] of Object.entries(te)) (k[e] === void 0 || k[e] === null || k[e] === "" || k[e] === "inherit") && t !== void 0 && (k[e] = t);
7291
- let P = await ai(t, Ri(k, w));
7292
- P = await Fi(t, P), x.slug = h.slug, x.title = h.title, Object.assign(x, P), x.layoutId = N;
7293
- let ne = !!h.isHidden || O, re = !Pi(E, D);
8752
+ let P = await si(t, Bi(k, w));
8753
+ P = await Li(t, P), x.slug = h.slug, x.title = h.title, Object.assign(x, P), x.layoutId = N;
8754
+ let ne = !!h.isHidden || O, re = !Ii(E, D);
7294
8755
  if (!o && (ne || re)) return e.json({ error: "Node is hidden or outside its scheduled publishing window" }, 404);
7295
8756
  let F = [];
7296
8757
  if (g?.treeNodeId) {
@@ -7300,7 +8761,7 @@ Ni.get("/*", async (e) => {
7300
8761
  try {
7301
8762
  t = typeof n == "string" ? JSON.parse(n) : n;
7302
8763
  } catch {}
7303
- let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a = Pi(t.startShowingAt, t.stopShowingAt), s = (e.slug || "").replace(/^\/+|\/+$/g, "");
8764
+ let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a = Ii(t.startShowingAt, t.stopShowingAt), s = (e.slug || "").replace(/^\/+|\/+$/g, "");
7304
8765
  return !o && (i || !a) ? null : {
7305
8766
  treeNodeId: e.treeNodeId,
7306
8767
  id: e.id,
@@ -7323,10 +8784,10 @@ Ni.get("/*", async (e) => {
7323
8784
  try {
7324
8785
  r = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
7325
8786
  } catch {}
7326
- let i = r.hidden === !0 || r.hidden === 1 || r.hidden === "1" || r.hidden === "true", a = Pi(r.startShowingAt, r.stopShowingAt);
8787
+ let i = r.hidden === !0 || r.hidden === 1 || r.hidden === "1" || r.hidden === "true", a = Ii(r.startShowingAt, r.stopShowingAt);
7327
8788
  if (!o && (i || !a)) continue;
7328
- let s = e.elementType || e.componentId || "text-block", c = p.blocks?.[s]?.fields || p.elements?.[s]?.fields || p.components?.[s]?.fields || {}, l = String(r.blockId || r._instanceId || r.id || e.blockId || e.id), u = Ri(r, c);
7329
- u = await ai(t, u), u.blockId = l, L[n].push({
8789
+ let s = e.elementType || e.componentId || "text-block", c = p.blocks?.[s]?.fields || p.elements?.[s]?.fields || p.components?.[s]?.fields || {}, l = String(r.blockId || r._instanceId || r.id || e.blockId || e.id), u = Bi(r, c);
8790
+ u = await si(t, u), u.blockId = l, L[n].push({
7330
8791
  instanceId: e.id,
7331
8792
  blockId: l,
7332
8793
  componentId: s,
@@ -7347,7 +8808,7 @@ Ni.get("/*", async (e) => {
7347
8808
  for (let [e, n] of Object.entries(se)) {
7348
8809
  let r = L[e] && L[e].length > 0, i = !!T[e];
7349
8810
  if (L[e] || (L[e] = [], oe[e] = { isInherited: !1 }), (n?.inherit === "parent" || n?.inherit === !0 || n?.inherit === "true" || e === "header" || e === "footer") && !r && !i && y) {
7350
- let n = await Li(t, y, e, p, o);
8811
+ let n = await zi(t, y, e, p, o);
7351
8812
  if (n.blocks.length > 0 && (L[e] = n.blocks, oe[e] = {
7352
8813
  isInherited: !0,
7353
8814
  inheritedFromId: n.inheritedFromId,
@@ -7359,7 +8820,7 @@ Ni.get("/*", async (e) => {
7359
8820
  });
7360
8821
  }
7361
8822
  }
7362
- for (let e of Object.keys(L)) await Ii(t, L[e], l);
8823
+ for (let e of Object.keys(L)) await Ri(t, L[e], l);
7363
8824
  let ce = {
7364
8825
  channelId: l || u,
7365
8826
  treeId: v,
@@ -7378,8 +8839,8 @@ Ni.get("/*", async (e) => {
7378
8839
  });
7379
8840
  //#endregion
7380
8841
  //#region server/routes/public/tree.ts
7381
- var Vi = new e();
7382
- function Hi(e, t) {
8842
+ var Ui = new e();
8843
+ function Wi(e, t) {
7383
8844
  let n = /* @__PURE__ */ new Date();
7384
8845
  if (e && String(e).trim() !== "") {
7385
8846
  let t = new Date(e);
@@ -7391,7 +8852,7 @@ function Hi(e, t) {
7391
8852
  }
7392
8853
  return !0;
7393
8854
  }
7394
- Vi.get("/:treeParam", async (e) => {
8855
+ Ui.get("/:treeParam", async (e) => {
7395
8856
  try {
7396
8857
  let t = e.get("db"), n = e.req.param("treeParam"), r = e.req.query("channelId") || e.req.query("channel") || "default", i = e.req.query("preview") === "true";
7397
8858
  if (r && r !== "default" && r !== "all") {
@@ -7410,7 +8871,7 @@ Vi.get("/:treeParam", async (e) => {
7410
8871
  if (c && c.isHidden && !i) return e.json({ error: `Tree '${n}' is hidden` }, 404);
7411
8872
  let l = c?.id || (s ? Number(n) : null), u = {};
7412
8873
  if (c && c.dataJson) try {
7413
- let t = typeof c.dataJson == "string" ? JSON.parse(c.dataJson) : c.dataJson, r = e.env?.BUNDLED_DEFINITIONS, i = ci(r), a = (i.trees?.[c.treeType || n] || i.trees?.site || {}).fields || {};
8874
+ let t = typeof c.dataJson == "string" ? JSON.parse(c.dataJson) : c.dataJson, r = e.env?.BUNDLED_DEFINITIONS, i = ui(r), a = (i.trees?.[c.treeType || n] || i.trees?.site || {}).fields || {};
7414
8875
  for (let [e, n] of Object.entries(t)) a[e]?.public === !0 && (u[e] = n);
7415
8876
  } catch (e) {
7416
8877
  console.warn("[CMS Public Tree API] Failed to parse tree dataJson", e);
@@ -7430,7 +8891,7 @@ Vi.get("/:treeParam", async (e) => {
7430
8891
  if (r) try {
7431
8892
  n = typeof r == "string" ? JSON.parse(r) : r, delete n._isTreeDraft, delete n._draftParentId, delete n.isNew, delete n.hidden, delete n.is_hidden, delete n.isHidden, delete n.status;
7432
8893
  } catch {}
7433
- let a = !i && (e.status === "draft" || e.status === "new"), o = !!e.isHidden || a || n.hidden === !0 || n.hidden === 1 || n.hidden === "1" || n.hidden === "true", s = Hi(n.startShowingAt, n.stopShowingAt), c = (e.slug || "").replace(/^\/+|\/+$/g, ""), l = c === "home" || c === "homee" ? "/" : `${t}/${c}`.replace(/\/+/g, "/"), u = {
8894
+ let a = !i && (e.status === "draft" || e.status === "new"), o = !!e.isHidden || a || n.hidden === !0 || n.hidden === 1 || n.hidden === "1" || n.hidden === "true", s = Wi(n.startShowingAt, n.stopShowingAt), c = (e.slug || "").replace(/^\/+|\/+$/g, ""), l = c === "home" || c === "homee" ? "/" : `${t}/${c}`.replace(/\/+/g, "/"), u = {
7434
8895
  id: e.id,
7435
8896
  treeNodeId: e.treeNodeId,
7436
8897
  parentId: e.parentId || null,
@@ -7465,8 +8926,8 @@ Vi.get("/:treeParam", async (e) => {
7465
8926
  });
7466
8927
  //#endregion
7467
8928
  //#region server/routes/public/assets.ts
7468
- var Ui = new e();
7469
- function Wi(e, t) {
8929
+ var Gi = new e();
8930
+ function Ki(e, t) {
7470
8931
  if (t === "webp") return "image/webp";
7471
8932
  if (t === "avif") return "image/avif";
7472
8933
  if (t === "jpeg" || t === "jpg") return "image/jpeg";
@@ -7474,7 +8935,7 @@ function Wi(e, t) {
7474
8935
  let n = e.toLowerCase();
7475
8936
  return n.endsWith(".jpg") || n.endsWith(".jpeg") ? "image/jpeg" : n.endsWith(".png") ? "image/png" : n.endsWith(".webp") ? "image/webp" : n.endsWith(".gif") ? "image/gif" : n.endsWith(".svg") ? "image/svg+xml" : n.endsWith(".pdf") ? "application/pdf" : n.endsWith(".mp4") ? "video/mp4" : n.endsWith(".webm") ? "video/webm" : "application/octet-stream";
7476
8937
  }
7477
- Ui.get("/*", async (e) => {
8938
+ Gi.get("/*", async (e) => {
7478
8939
  let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
7479
8940
  if (!t) return e.text("Asset key missing", 400);
7480
8941
  let o = e.env?.MEDIA_BUCKET, { w: l, h: u, q: d, f } = e.req.query(), p = !!(l || u || d || f), m = e.req.header("Via")?.includes("image-resizing") || e.req.header("User-Agent")?.includes("Cloudflare-ImgRen");
@@ -7514,7 +8975,7 @@ Ui.get("/*", async (e) => {
7514
8975
  if (!p) {
7515
8976
  let n = i(g);
7516
8977
  return e.body(n, 200, {
7517
- "Content-Type": Wi(t),
8978
+ "Content-Type": Ki(t),
7518
8979
  "Cache-Control": "public, max-age=86400"
7519
8980
  });
7520
8981
  }
@@ -7522,7 +8983,7 @@ Ui.get("/*", async (e) => {
7522
8983
  if (n(b)) {
7523
8984
  let n = i(b);
7524
8985
  return e.body(n, 200, {
7525
- "Content-Type": Wi(t, v),
8986
+ "Content-Type": Ki(t, v),
7526
8987
  "Cache-Control": "public, max-age=31536000, immutable",
7527
8988
  "X-Local-Cache": "HIT"
7528
8989
  });
@@ -7532,14 +8993,14 @@ Ui.get("/*", async (e) => {
7532
8993
  typeof o == "number" && (c.width = o), typeof m == "number" && (c.height = m), (c.width || c.height) && (c.fit = "cover", i = i.resize(c)), v === "webp" ? i = i.webp({ quality: typeof _ == "number" ? _ : 80 }) : v === "avif" ? i = i.avif({ quality: typeof _ == "number" ? _ : 70 }) : v === "jpeg" || v === "jpg" ? i = i.jpeg({ quality: typeof _ == "number" ? _ : 80 }) : v === "png" && (i = i.png({ quality: typeof _ == "number" ? _ : 80 }));
7533
8994
  let l = await i.toBuffer();
7534
8995
  return r(s(b), { recursive: !0 }), a(b, l), e.body(l, 200, {
7535
- "Content-Type": Wi(t, v),
8996
+ "Content-Type": Ki(t, v),
7536
8997
  "Cache-Control": "public, max-age=31536000, immutable",
7537
8998
  "X-Local-Cache": "MISS"
7538
8999
  });
7539
9000
  } catch {
7540
9001
  let n = i(g);
7541
9002
  return e.body(n, 200, {
7542
- "Content-Type": Wi(t),
9003
+ "Content-Type": Ki(t),
7543
9004
  "Cache-Control": "public, max-age=86400"
7544
9005
  });
7545
9006
  }
@@ -7550,8 +9011,8 @@ Ui.get("/*", async (e) => {
7550
9011
  });
7551
9012
  //#endregion
7552
9013
  //#region server/routes/public/paths.ts
7553
- var Gi = new e();
7554
- function Ki(e, t) {
9014
+ var qi = new e();
9015
+ function Ji(e, t) {
7555
9016
  let n = /* @__PURE__ */ new Date();
7556
9017
  if (e && String(e).trim() !== "") {
7557
9018
  let t = new Date(e);
@@ -7563,7 +9024,7 @@ function Ki(e, t) {
7563
9024
  }
7564
9025
  return !0;
7565
9026
  }
7566
- Gi.get("/", async (e) => {
9027
+ qi.get("/", async (e) => {
7567
9028
  try {
7568
9029
  let t = await e.get("db").prepare("\n SELECT \n t.id as treeNodeId,\n t.parentId,\n c.slug,\n c.contentType as nodeType,\n c.status,\n c.dataJson\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE (c.deletedAt IS NULL OR c.deletedAt = '')\n ").all(), n = Array.isArray(t) ? t : t?.results || [], r = [];
7569
9030
  function i(e = null, t = "") {
@@ -7576,7 +9037,7 @@ Gi.get("/", async (e) => {
7576
9037
  if (e.dataJson) try {
7577
9038
  n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
7578
9039
  } catch {}
7579
- let a = e.status === "published" || e.status === "active", o = Ki(n.startShowingAt, n.stopShowingAt);
9040
+ let a = e.status === "published" || e.status === "active", o = Ji(n.startShowingAt, n.stopShowingAt);
7580
9041
  if (!a || !o) continue;
7581
9042
  let s = (e.slug || "").replace(/^\/+|\/+$/g, ""), c = s === "home" || s === "homee" ? "/" : `${t}/${s}`.replace(/\/+/g, "/");
7582
9043
  e.nodeType !== "external-link" && r.push(c);
@@ -7593,7 +9054,7 @@ Gi.get("/", async (e) => {
7593
9054
  });
7594
9055
  //#endregion
7595
9056
  //#region server/index.ts
7596
- var $ = new e(), qi = !1;
9057
+ var $ = new e(), Yi = !1;
7597
9058
  $.use("*", f()), $.use("/media/*", f({
7598
9059
  origin: "*",
7599
9060
  allowMethods: [
@@ -7614,13 +9075,13 @@ $.use("*", f()), $.use("/media/*", f({
7614
9075
  let n = new URL(e.req.url), r = (e.req.header("host") || n.hostname).split(":")[0];
7615
9076
  e.set("currentDomain", r);
7616
9077
  let i = g(e);
7617
- if (e.set("db", i), !qi) try {
7618
- await Ir(i), qi = !0;
9078
+ if (e.set("db", i), !Yi) try {
9079
+ await Lr(i), Yi = !0;
7619
9080
  } catch (e) {
7620
9081
  console.error("❌ [CMS Server] Failed to initialize system tables on cold start:", e);
7621
9082
  }
7622
9083
  await t();
7623
- }), $.route("/media", Ui), $.use("/media/*", Rr()), $.route("/api/cms/nodes", Z), $.route("/api/cms/nodes.json", Z), $.route("/api/cms/formcsv", Z), $.route("/api/cms/formcsv.json", Z), $.route("/api/cms/stats", Ti), $.route("/api/cms/stats.json", Ti), $.route("/api/cms", mi), $.route("/api/cms/channels", vi), $.route("/api/cms/channels.json", vi), $.route("/api/cms/schemas", yi), $.route("/api/cms/schemas.json", yi), $.route("/api/cms", Si), $.route("/api/admin/assets", Ai), $.route("/api/v1/node", Ni), $.route("/api/v1/page", Ni), $.route("/api/v1/tree", Vi), $.route("/api/v1/all-paths", Gi), $.get("*", async (e) => {
9084
+ }), $.route("/media", Gi), $.use("/media/*", Br()), $.route("/api/cms/nodes", Z), $.route("/api/cms/nodes.json", Z), $.route("/api/cms/formcsv", Z), $.route("/api/cms/formcsv.json", Z), $.route("/api/cms/stats", Di), $.route("/api/cms/stats.json", Di), $.route("/api/cms", gi), $.route("/api/cms/channels", bi), $.route("/api/cms/channels.json", bi), $.route("/api/cms/schemas", xi), $.route("/api/cms/schemas.json", xi), $.route("/api/cms", wi), $.route("/api/admin/assets", Mi), $.route("/api/v1/node", Fi), $.route("/api/v1/page", Fi), $.route("/api/v1/tree", Ui), $.route("/api/v1/all-paths", qi), $.get("*", async (e) => {
7624
9085
  if (e.env?.ASSETS) {
7625
9086
  let t = await e.env.ASSETS.fetch(e.req.raw);
7626
9087
  if (t.status === 404) {