sanity-plugin-seofields 1.7.0 → 1.9.0

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 (111) hide show
  1. package/README.md +440 -29
  2. package/dist/SchemaOrgJsonLdPreview-DJLkIPq4.d.cts +78 -0
  3. package/dist/SchemaOrgJsonLdPreview-DJLkIPq4.d.ts +78 -0
  4. package/dist/SeoHealthTool-2COI27KI.cjs +8 -0
  5. package/dist/SeoHealthTool-2COI27KI.cjs.map +1 -0
  6. package/dist/SeoHealthTool-CWI3KB2V.js +8 -0
  7. package/dist/SeoHealthTool-CWI3KB2V.js.map +1 -0
  8. package/dist/{SeoPreview-WYH7NYNM.cjs → SeoPreview-LMZAWWOE.cjs} +35 -38
  9. package/dist/SeoPreview-LMZAWWOE.cjs.map +1 -0
  10. package/dist/{SeoPreview-KEGGQSPJ.js → SeoPreview-UNQBKTQO.js} +14 -11
  11. package/dist/SeoPreview-UNQBKTQO.js.map +1 -0
  12. package/dist/chunk-3OK3S2F7.cjs +673 -0
  13. package/dist/chunk-3OK3S2F7.cjs.map +1 -0
  14. package/dist/{chunk-GWPOJSGW.cjs → chunk-5XTQRILL.cjs} +1022 -307
  15. package/dist/chunk-5XTQRILL.cjs.map +1 -0
  16. package/dist/{chunk-2NMEKWO5.js → chunk-7N4MLTMR.js} +8 -15
  17. package/dist/chunk-7N4MLTMR.js.map +1 -0
  18. package/dist/{chunk-S367Y35J.cjs → chunk-A57XNQC7.cjs} +9 -20
  19. package/dist/chunk-A57XNQC7.cjs.map +1 -0
  20. package/dist/chunk-BWLJDK5J.js +624 -0
  21. package/dist/chunk-BWLJDK5J.js.map +1 -0
  22. package/dist/chunk-FUUWBQE2.cjs +195 -0
  23. package/dist/chunk-FUUWBQE2.cjs.map +1 -0
  24. package/dist/{chunk-ZBHLMQTS.cjs → chunk-HHO2AKAP.js} +44 -17
  25. package/dist/chunk-HHO2AKAP.js.map +1 -0
  26. package/dist/chunk-KIEO6QG3.js +195 -0
  27. package/dist/chunk-KIEO6QG3.js.map +1 -0
  28. package/dist/chunk-R2U7JF7U.cjs +624 -0
  29. package/dist/chunk-R2U7JF7U.cjs.map +1 -0
  30. package/dist/{chunk-HRKRV2X7.js → chunk-XZKQWV2H.js} +974 -148
  31. package/dist/chunk-XZKQWV2H.js.map +1 -0
  32. package/dist/{chunk-HDZZQCH7.js → chunk-Y46ACXM4.cjs} +45 -5
  33. package/dist/chunk-Y46ACXM4.cjs.map +1 -0
  34. package/dist/chunk-Z5AOUU4H.js +673 -0
  35. package/dist/chunk-Z5AOUU4H.js.map +1 -0
  36. package/dist/cli.js +27 -27
  37. package/dist/{component-DQ4KuQQD.d.ts → component-CjT1hvxh.d.ts} +3 -27
  38. package/dist/{component-D1sBm6ts.d.cts → component-WYh0z8as.d.cts} +3 -27
  39. package/dist/define-cli.cjs +2 -4
  40. package/dist/define-cli.cjs.map +1 -1
  41. package/dist/define-cli.js +4 -4
  42. package/dist/define-cli.js.map +1 -1
  43. package/dist/head.cjs +14 -0
  44. package/dist/head.cjs.map +1 -0
  45. package/dist/head.d.cts +254 -0
  46. package/dist/head.d.ts +254 -0
  47. package/dist/head.js +14 -0
  48. package/dist/head.js.map +1 -0
  49. package/dist/index.cjs +1797 -230
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +11 -598
  52. package/dist/index.d.ts +11 -598
  53. package/dist/index.js +1777 -197
  54. package/dist/index.js.map +1 -1
  55. package/dist/next.cjs +210 -447
  56. package/dist/next.cjs.map +1 -1
  57. package/dist/next.d.cts +8 -200
  58. package/dist/next.d.ts +8 -200
  59. package/dist/next.js +200 -124
  60. package/dist/next.js.map +1 -1
  61. package/dist/plugin-DQdThyxG.d.ts +449 -0
  62. package/dist/plugin-DoGeZP79.d.cts +449 -0
  63. package/dist/schema/next.cjs +173 -319
  64. package/dist/schema/next.cjs.map +1 -1
  65. package/dist/schema/next.d.cts +4 -4
  66. package/dist/schema/next.d.ts +4 -4
  67. package/dist/schema/next.js +172 -8
  68. package/dist/schema/next.js.map +1 -1
  69. package/dist/schema.cjs +390 -489
  70. package/dist/schema.cjs.map +1 -1
  71. package/dist/schema.d.cts +26 -16
  72. package/dist/schema.d.ts +26 -16
  73. package/dist/schema.js +236 -13
  74. package/dist/schema.js.map +1 -1
  75. package/dist/server.cjs +149 -0
  76. package/dist/server.cjs.map +1 -0
  77. package/dist/server.d.cts +102 -0
  78. package/dist/server.d.ts +102 -0
  79. package/dist/server.js +149 -0
  80. package/dist/server.js.map +1 -0
  81. package/dist/{types-CeBULNFF.d.ts → types-BAdN1RMu.d.ts} +2 -2
  82. package/dist/{types-_wBLg6RV.d.cts → types-C5i3KMgs.d.cts} +2 -2
  83. package/dist/{types-9_wbCIi9.d.ts → types-DP-DiW6f.d.cts} +29 -2
  84. package/dist/{types-Bb49oRBV.d.cts → types-DRLUGLtX.d.ts} +29 -2
  85. package/dist/{types-B91ena4g.d.cts → types-DxlPXihz.d.cts} +8 -1
  86. package/dist/{types-B91ena4g.d.ts → types-DxlPXihz.d.ts} +8 -1
  87. package/package.json +25 -3
  88. package/dist/SeoHealthDashboard-IP5BJ322.cjs +0 -10
  89. package/dist/SeoHealthDashboard-IP5BJ322.cjs.map +0 -1
  90. package/dist/SeoHealthDashboard-PTUEVYZL.js +0 -4
  91. package/dist/SeoHealthDashboard-PTUEVYZL.js.map +0 -1
  92. package/dist/SeoHealthTool-CZZRMWQK.cjs +0 -14
  93. package/dist/SeoHealthTool-CZZRMWQK.cjs.map +0 -1
  94. package/dist/SeoHealthTool-IULT4G25.js +0 -12
  95. package/dist/SeoHealthTool-IULT4G25.js.map +0 -1
  96. package/dist/SeoPreview-KEGGQSPJ.js.map +0 -1
  97. package/dist/SeoPreview-WYH7NYNM.cjs.map +0 -1
  98. package/dist/chunk-2NMEKWO5.js.map +0 -1
  99. package/dist/chunk-5YRH47VQ.cjs +0 -2167
  100. package/dist/chunk-5YRH47VQ.cjs.map +0 -1
  101. package/dist/chunk-ARELX3GK.cjs +0 -689
  102. package/dist/chunk-ARELX3GK.cjs.map +0 -1
  103. package/dist/chunk-AW7OKBQQ.js +0 -2161
  104. package/dist/chunk-AW7OKBQQ.js.map +0 -1
  105. package/dist/chunk-FONJYVF2.js +0 -610
  106. package/dist/chunk-FONJYVF2.js.map +0 -1
  107. package/dist/chunk-GWPOJSGW.cjs.map +0 -1
  108. package/dist/chunk-HDZZQCH7.js.map +0 -1
  109. package/dist/chunk-HRKRV2X7.js.map +0 -1
  110. package/dist/chunk-S367Y35J.cjs.map +0 -1
  111. package/dist/chunk-ZBHLMQTS.cjs.map +0 -1
@@ -1,6 +1,7 @@
1
- import { __spreadValues, __spreadProps } from './chunk-2NMEKWO5.js';
2
- import { defineType, defineField } from 'sanity';
3
- import { PackageIcon, PlayIcon, UserIcon, ListIcon, DocumentTextIcon, BookIcon, HomeIcon, ClipboardIcon, EarthGlobeIcon, MasterDetailIcon, DesktopIcon, CodeBlockIcon, ApiIcon, CalendarIcon, MarkerIcon, RobotIcon, HeartFilledIcon, BarChartIcon, TagIcon, CommentIcon, HelpCircleIcon, VideoIcon, ImageIcon, LinkIcon, SparkleIcon, ComponentIcon } from '@sanity/icons';
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues
4
+ } from "./chunk-7N4MLTMR.js";
4
5
 
5
6
  // src/schema/_shared.ts
6
7
  var imageObjectInnerFields = [
@@ -1098,148 +1099,8 @@ function licenseUrlField(opts = {}) {
1098
1099
  urlValidation: { schemes: ["http", "https"] }
1099
1100
  }, opts.required ? { required: opts.required } : {});
1100
1101
  }
1101
- function buildField(fieldDef, validation) {
1102
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1103
- if (fieldDef.type === "select" && ((_a = fieldDef.variants) == null ? void 0 : _a.length)) {
1104
- const variants = fieldDef.variants;
1105
- const defaultVariant = (_b = fieldDef.defaultVariant) != null ? _b : variants[0].value;
1106
- const innerFields = [
1107
- {
1108
- name: "variant",
1109
- title: "Type",
1110
- type: "string",
1111
- description: "Choose how to provide this value.",
1112
- initialValue: defaultVariant,
1113
- options: variants.map((v) => ({ title: v.title, value: v.value })),
1114
- layout: "radio"
1115
- },
1116
- ...variants.map((v) => {
1117
- if (v.fields.length === 1 && v.fields[0].name === v.value) {
1118
- return v.fields[0];
1119
- }
1120
- return {
1121
- name: v.value,
1122
- title: v.title,
1123
- type: "object",
1124
- jsonLdType: v.jsonLdType,
1125
- fields: v.fields
1126
- };
1127
- })
1128
- ];
1129
- const base2 = {
1130
- name: fieldDef.name,
1131
- title: fieldDef.title,
1132
- type: "object",
1133
- fields: innerFields.map((child) => {
1134
- const built = buildField(child, validation);
1135
- if (child.name !== "variant") {
1136
- const dv = defaultVariant;
1137
- built.hidden = ({ parent }) => {
1138
- var _a2;
1139
- return ((_a2 = parent == null ? void 0 : parent.variant) != null ? _a2 : dv) !== child.name;
1140
- };
1141
- }
1142
- return built;
1143
- })
1144
- };
1145
- if (fieldDef.description) base2.description = fieldDef.description;
1146
- return defineField(base2);
1147
- }
1148
- if (fieldDef.type === "copyrightYear") {
1149
- const base2 = {
1150
- name: fieldDef.name,
1151
- title: fieldDef.title,
1152
- type: "object",
1153
- description: (_c = fieldDef.description) != null ? _c : 'Copyright year. Toggle "Use current year" to emit the current year dynamically.',
1154
- fields: [
1155
- defineField({
1156
- name: "useDynamicYear",
1157
- title: "Use current year (dynamic)",
1158
- type: "boolean",
1159
- initialValue: false
1160
- }),
1161
- defineField({
1162
- name: "year",
1163
- title: "Static year",
1164
- type: "number",
1165
- hidden: ({ parent }) => (parent == null ? void 0 : parent.useDynamicYear) === true
1166
- })
1167
- ]
1168
- };
1169
- return defineField(base2);
1170
- }
1171
- const base = {
1172
- name: fieldDef.name,
1173
- title: fieldDef.title,
1174
- type: fieldDef.type
1175
- };
1176
- if (fieldDef.description) base.description = fieldDef.description;
1177
- if (fieldDef.initialValue !== void 0) base.initialValue = fieldDef.initialValue;
1178
- if (fieldDef.rows) base.rows = fieldDef.rows;
1179
- if (fieldDef.options) {
1180
- base.options = __spreadValues({ list: fieldDef.options }, fieldDef.layout && { layout: fieldDef.layout });
1181
- }
1182
- if (fieldDef.type === "array" && ((_d = fieldDef.fields) == null ? void 0 : _d.length) && !fieldDef.of) {
1183
- base.of = [
1184
- {
1185
- type: "object",
1186
- fields: fieldDef.fields.map((child) => buildField(child, validation))
1187
- }
1188
- ];
1189
- } else if (fieldDef.of) {
1190
- base.of = fieldDef.of;
1191
- }
1192
- if (fieldDef.type !== "array" && ((_e = fieldDef.fields) == null ? void 0 : _e.length)) {
1193
- base.fields = fieldDef.fields.map((child) => buildField(child, validation));
1194
- }
1195
- if (fieldDef.type === "url" && (fieldDef.required || fieldDef.urlValidation)) {
1196
- const required = fieldDef.required;
1197
- const requiredMsg = required ? (_f = validation == null ? void 0 : validation[required.key]) != null ? _f : required.message : void 0;
1198
- const schemes = (_h = (_g = fieldDef.urlValidation) == null ? void 0 : _g.schemes) != null ? _h : ["http", "https"];
1199
- const allowRelative = (_j = (_i = fieldDef.urlValidation) == null ? void 0 : _i.allowRelative) != null ? _j : false;
1200
- base.validation = (Rule) => {
1201
- const checks = [];
1202
- if (requiredMsg) checks.push(Rule.required().error(requiredMsg));
1203
- checks.push(
1204
- Rule.uri({ scheme: schemes, allowRelative }).error(
1205
- `Must be a valid URL (${schemes.join(", ")}).`
1206
- )
1207
- );
1208
- return checks;
1209
- };
1210
- } else if (fieldDef.required) {
1211
- const msg = (_k = validation == null ? void 0 : validation[fieldDef.required.key]) != null ? _k : fieldDef.required.message;
1212
- base.validation = (Rule) => Rule.required().error(msg);
1213
- }
1214
- return defineField(base);
1215
- }
1216
- function mapNameToSameValue(...items) {
1217
- return items.reduce(
1218
- (acc, item) => {
1219
- acc[item.name] = item.name;
1220
- return acc;
1221
- },
1222
- {}
1223
- );
1224
- }
1225
- function generateSchemaType(def, config = {}) {
1226
- return defineType(__spreadProps(__spreadValues({
1227
- name: def.name,
1228
- title: def.title,
1229
- type: "object"
1230
- }, def.icon && { icon: def.icon }), {
1231
- fields: def.fields.map((f) => buildField(f, config.validation)),
1232
- preview: {
1233
- select: mapNameToSameValue(...def.fields),
1234
- prepare(selection) {
1235
- return __spreadValues({
1236
- title: def.title,
1237
- subtitle: (def == null ? void 0 : def.customPrepareSubtitle) ? def.customPrepareSubtitle(selection) : `@type: ${def.title}`
1238
- }, def.icon && { media: def.icon });
1239
- }
1240
- }
1241
- }));
1242
- }
1102
+
1103
+ // src/schema/jsonLd.ts
1243
1104
  var SANITY_INTERNAL_KEYS = /* @__PURE__ */ new Set([
1244
1105
  "_key",
1245
1106
  "_type",
@@ -1338,6 +1199,203 @@ function buildGenericJsonLd(schemaType, data, fieldDefs, requiredFields = []) {
1338
1199
  "@type": schemaType
1339
1200
  }, body);
1340
1201
  }
1202
+
1203
+ // src/schema/generator.ts
1204
+ import { defineField, defineType } from "sanity";
1205
+
1206
+ // src/schema/components/SchemaOrgJsonLdPreview.tsx
1207
+ import { Box, Card, Flex, Stack, Text } from "@sanity/ui";
1208
+ import { useEffect, useMemo, useState } from "react";
1209
+ import { useClient, useColorScheme, useFormValue } from "sanity";
1210
+
1211
+ // src/utils/syntaxHighlight.ts
1212
+ var LIGHT = {
1213
+ default: "#24292f",
1214
+ punctuation: "#57606a",
1215
+ tag: "#1a7f37",
1216
+ // HTML tag names — vivid green
1217
+ attr: "#8250df",
1218
+ // HTML attribute names / JSON keys — vivid purple
1219
+ string: "#cf222e",
1220
+ // Attribute values / JSON string values — vivid red
1221
+ number: "#953800",
1222
+ // Numbers — orange-brown
1223
+ keyword: "#0969da"
1224
+ // true / false / null — vivid blue
1225
+ };
1226
+ var DARK = {
1227
+ default: "#cdd9e5",
1228
+ punctuation: "#768390",
1229
+ tag: "#57ab5a",
1230
+ // vivid green
1231
+ attr: "#dcbdfb",
1232
+ // vivid purple
1233
+ string: "#ff9492",
1234
+ // vivid red/pink
1235
+ number: "#ffa657",
1236
+ // orange
1237
+ keyword: "#6cb6ff"
1238
+ // vivid blue
1239
+ };
1240
+ function getColors(scheme) {
1241
+ return scheme === "dark" ? DARK : LIGHT;
1242
+ }
1243
+ function merge(tokens) {
1244
+ const out = [];
1245
+ for (const t of tokens) {
1246
+ const last = out[out.length - 1];
1247
+ if (last && last.color === t.color) {
1248
+ last.text += t.text;
1249
+ } else {
1250
+ out.push({ text: t.text, color: t.color });
1251
+ }
1252
+ }
1253
+ return out;
1254
+ }
1255
+ function parseAttrToken(code, pos, tokens, C) {
1256
+ const ch = code[pos];
1257
+ if (ch === " " || ch === " ") {
1258
+ tokens.push({ text: ch, color: C.default });
1259
+ return pos + 1;
1260
+ }
1261
+ if (ch === "/" || ch === "=") {
1262
+ tokens.push({ text: ch, color: C.punctuation });
1263
+ return pos + 1;
1264
+ }
1265
+ if (ch === '"' || ch === "'") {
1266
+ const end = ch;
1267
+ let i2 = pos + 1;
1268
+ while (i2 < code.length && code[i2] !== end) i2++;
1269
+ if (i2 < code.length) i2++;
1270
+ tokens.push({ text: code.slice(pos, i2), color: C.string });
1271
+ return i2;
1272
+ }
1273
+ let i = pos;
1274
+ while (i < code.length && code[i] !== "=" && code[i] !== " " && code[i] !== ">" && code[i] !== "/" && code[i] !== " ")
1275
+ i++;
1276
+ if (i > pos) tokens.push({ text: code.slice(pos, i), color: C.attr });
1277
+ return i;
1278
+ }
1279
+ function parseTag(code, pos, tokens, C) {
1280
+ tokens.push({ text: "<", color: C.punctuation });
1281
+ let i = pos + 1;
1282
+ if (i < code.length && code[i] === "/") {
1283
+ tokens.push({ text: "/", color: C.punctuation });
1284
+ i++;
1285
+ }
1286
+ const nameStart = i;
1287
+ while (i < code.length && code[i] !== " " && code[i] !== ">" && code[i] !== "/") i++;
1288
+ if (i > nameStart) tokens.push({ text: code.slice(nameStart, i), color: C.tag });
1289
+ while (i < code.length && code[i] !== ">") {
1290
+ i = parseAttrToken(code, i, tokens, C);
1291
+ }
1292
+ if (i < code.length && code[i] === ">") {
1293
+ tokens.push({ text: ">", color: C.punctuation });
1294
+ i++;
1295
+ }
1296
+ return i;
1297
+ }
1298
+ function tokenizeHtml(code, scheme = "light") {
1299
+ const C = getColors(scheme);
1300
+ const tokens = [];
1301
+ let i = 0;
1302
+ while (i < code.length) {
1303
+ if (code[i] === "<") {
1304
+ i = parseTag(code, i, tokens, C);
1305
+ } else if (code[i] === "\n") {
1306
+ tokens.push({ text: "\n", color: C.default });
1307
+ i++;
1308
+ } else {
1309
+ const start = i;
1310
+ while (i < code.length && code[i] !== "<" && code[i] !== "\n") i++;
1311
+ if (i > start) tokens.push({ text: code.slice(start, i), color: C.default });
1312
+ }
1313
+ }
1314
+ return merge(tokens);
1315
+ }
1316
+ function tokenizeJson(code, scheme = "light") {
1317
+ const C = getColors(scheme);
1318
+ const tokens = [];
1319
+ let i = 0;
1320
+ while (i < code.length) {
1321
+ const ch = code[i];
1322
+ if (ch === "\n") {
1323
+ tokens.push({ text: "\n", color: C.default });
1324
+ i++;
1325
+ } else if (ch === " " || ch === " ") {
1326
+ tokens.push({ text: ch, color: C.default });
1327
+ i++;
1328
+ } else if ("{}[]:,".includes(ch)) {
1329
+ tokens.push({ text: ch, color: C.punctuation });
1330
+ i++;
1331
+ } else if (ch === '"') {
1332
+ const start = i++;
1333
+ while (i < code.length) {
1334
+ if (code[i] === "\\") {
1335
+ i += 2;
1336
+ continue;
1337
+ }
1338
+ if (code[i] === '"') {
1339
+ i++;
1340
+ break;
1341
+ }
1342
+ i++;
1343
+ }
1344
+ const str = code.slice(start, i);
1345
+ let j = i;
1346
+ while (j < code.length && (code[j] === " " || code[j] === " ")) j++;
1347
+ tokens.push({ text: str, color: j < code.length && code[j] === ":" ? C.attr : C.string });
1348
+ } else if (code.slice(i, i + 4) === "null") {
1349
+ tokens.push({ text: "null", color: C.keyword });
1350
+ i += 4;
1351
+ } else if (code.slice(i, i + 4) === "true") {
1352
+ tokens.push({ text: "true", color: C.keyword });
1353
+ i += 4;
1354
+ } else if (code.slice(i, i + 5) === "false") {
1355
+ tokens.push({ text: "false", color: C.keyword });
1356
+ i += 5;
1357
+ } else if (ch === "-" || ch >= "0" && ch <= "9") {
1358
+ const start = i;
1359
+ if (ch === "-") i++;
1360
+ while (i < code.length && /[\d.eE+-]/.test(code[i])) i++;
1361
+ tokens.push({ text: code.slice(start, i), color: C.number });
1362
+ } else {
1363
+ tokens.push({ text: ch, color: C.default });
1364
+ i++;
1365
+ }
1366
+ }
1367
+ return merge(tokens);
1368
+ }
1369
+
1370
+ // src/schema/icons.ts
1371
+ import {
1372
+ ApiIcon,
1373
+ BarChartIcon,
1374
+ BookIcon,
1375
+ CalendarIcon,
1376
+ ClipboardIcon,
1377
+ CodeBlockIcon,
1378
+ CommentIcon,
1379
+ ComponentIcon,
1380
+ DesktopIcon,
1381
+ DocumentTextIcon,
1382
+ EarthGlobeIcon,
1383
+ HeartFilledIcon,
1384
+ HelpCircleIcon,
1385
+ HomeIcon,
1386
+ ImageIcon,
1387
+ LinkIcon,
1388
+ ListIcon,
1389
+ MarkerIcon,
1390
+ MasterDetailIcon,
1391
+ PackageIcon,
1392
+ PlayIcon,
1393
+ RobotIcon,
1394
+ SparkleIcon,
1395
+ TagIcon,
1396
+ UserIcon,
1397
+ VideoIcon
1398
+ } from "@sanity/icons";
1341
1399
  var SchemaOrgIcons = {
1342
1400
  // Website & WebPage
1343
1401
  website: EarthGlobeIcon,
@@ -2981,6 +3039,61 @@ function schemaOrgOpinionNewsArticle(config = {}) {
2981
3039
  );
2982
3040
  }
2983
3041
 
3042
+ // src/schema/utils.ts
3043
+ function escapeJsonForScript(json) {
3044
+ return json.replace(/</g, "\\u003C").replace(/>/g, "\\u003E").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
3045
+ }
3046
+
3047
+ // src/schema/SchemaOrgScript.tsx
3048
+ import { jsx } from "react/jsx-runtime";
3049
+ function SchemaOrgScript({
3050
+ jsonLd
3051
+ }) {
3052
+ if (!jsonLd) return null;
3053
+ return /* @__PURE__ */ jsx(
3054
+ "script",
3055
+ {
3056
+ type: "application/ld+json",
3057
+ dangerouslySetInnerHTML: { __html: escapeJsonForScript(JSON.stringify(jsonLd)) }
3058
+ }
3059
+ );
3060
+ }
3061
+
3062
+ // src/schema/organization/component.tsx
3063
+ import { jsx as jsx2 } from "react/jsx-runtime";
3064
+ function buildOrganizationJsonLd(data, imageUrlResolver) {
3065
+ var _a, _b;
3066
+ if (!(data == null ? void 0 : data.name) || !(data == null ? void 0 : data.url)) return null;
3067
+ const jsonLd = {
3068
+ "@context": "https://schema.org",
3069
+ "@type": "Organization",
3070
+ name: data.name,
3071
+ url: data.url
3072
+ };
3073
+ const logoUrl = data.logoUrl || (data.logo && imageUrlResolver ? imageUrlResolver(data.logo) : void 0);
3074
+ if (logoUrl) jsonLd.logo = logoUrl;
3075
+ if (data.description) jsonLd.description = data.description;
3076
+ if (data.sameAs) jsonLd.sameAs = data.sameAs;
3077
+ if ((_a = data.contactPoint) == null ? void 0 : _a.contactType) {
3078
+ const cp = {
3079
+ "@type": "ContactPoint",
3080
+ contactType: data.contactPoint.contactType
3081
+ };
3082
+ if (data.contactPoint.email) cp.email = data.contactPoint.email;
3083
+ if ((_b = data.contactPoint.availableLanguage) == null ? void 0 : _b.length) {
3084
+ cp.availableLanguage = data.contactPoint.availableLanguage;
3085
+ }
3086
+ jsonLd.contactPoint = cp;
3087
+ }
3088
+ return jsonLd;
3089
+ }
3090
+ function OrganizationSchema({
3091
+ data,
3092
+ imageUrlResolver
3093
+ }) {
3094
+ return /* @__PURE__ */ jsx2(SchemaOrgScript, { jsonLd: buildOrganizationJsonLd(data, imageUrlResolver) });
3095
+ }
3096
+
2984
3097
  // src/schema/person/schema.ts
2985
3098
  var personFields = [
2986
3099
  nameField({
@@ -4009,6 +4122,719 @@ function schemaOrgWebPage(config = {}) {
4009
4122
  );
4010
4123
  }
4011
4124
 
4012
- export { IETF_LANGUAGE_OPTIONS, SchemaOrgIcons, aggregateRatingFields, articleFields, blogPostingFields, bookFields, brandFields, breadcrumbListFields, buildGenericJsonLd, contactPointFields, countryFields, courseFields, datePublishedField, descriptionField, eventFields, faqPageFields, generateSchemaType, headlineField, howToFields, imageObjectFields, inLanguageField, issnField, itemListFields, jobPostingFields, legalServiceFields, localBusinessFields, movieFields, musicAlbumFields, musicRecordingFields, nameField, newsArticleFields, offerFields, opinionNewsArticleFields, personFields, placeFields, polymorphicAdditionalType, polymorphicArchivedAt, polymorphicAuthor, polymorphicCitation, polymorphicContentRating, polymorphicContributor, polymorphicCopyrightHolder, polymorphicCreator, polymorphicFunder, polymorphicGenre, polymorphicIdentifier, polymorphicImage, polymorphicIsBasedOn, polymorphicIsPartOf, polymorphicKeywords, polymorphicLicense, polymorphicLocationCreated, polymorphicMaintainer, polymorphicMaterial, polymorphicOwner, polymorphicPublisher, postalAddressFields, potentialActionSearch, productFields, profilePageFields, recipeFields, resolvePolymorphicPersonOrOrg, restaurantFields, reviewFields, schemaOrgAggregateRating, schemaOrgArticle, schemaOrgBlogPosting, schemaOrgBook, schemaOrgBrand, schemaOrgBreadcrumbList, schemaOrgContactPoint, schemaOrgCountry, schemaOrgCourse, schemaOrgEvent, schemaOrgFAQPage, schemaOrgHowTo, schemaOrgImageObject, schemaOrgItemList, schemaOrgJobPosting, schemaOrgLegalService, schemaOrgLocalBusiness, schemaOrgMovie, schemaOrgMusicAlbum, schemaOrgMusicRecording, schemaOrgNewsArticle, schemaOrgOffer, schemaOrgOpinionNewsArticle, schemaOrgPerson, schemaOrgPlace, schemaOrgPostalAddress, schemaOrgProduct, schemaOrgProfilePage, schemaOrgRecipe, schemaOrgRestaurant, schemaOrgReview, schemaOrgService, schemaOrgSocialMediaPosting, schemaOrgSoftwareApplication, schemaOrgVideoObject, schemaOrgWebApplication, schemaOrgWebPage, serviceFields, socialMediaPostingFields, softwareApplicationFields, urlField, videoObjectFields, webApplicationFields, webPageFields, withCreativeWorkCommons, withThingCommons };
4013
- //# sourceMappingURL=chunk-HRKRV2X7.js.map
4014
- //# sourceMappingURL=chunk-HRKRV2X7.js.map
4125
+ // src/schema/website/component.tsx
4126
+ import { jsx as jsx3 } from "react/jsx-runtime";
4127
+ function buildWebsiteJsonLd(data) {
4128
+ if (!(data == null ? void 0 : data.name) || !(data == null ? void 0 : data.url)) return null;
4129
+ const jsonLd = {
4130
+ "@context": "https://schema.org",
4131
+ "@type": "WebSite",
4132
+ name: data.name,
4133
+ url: data.url
4134
+ };
4135
+ if (data.description) jsonLd.description = data.description;
4136
+ if (data.inLanguage) jsonLd.inLanguage = data.inLanguage;
4137
+ const publisher = resolvePolymorphicPersonOrOrg(data.publisher);
4138
+ if (publisher) jsonLd.publisher = publisher;
4139
+ return jsonLd;
4140
+ }
4141
+ function WebsiteSchema({ data }) {
4142
+ return /* @__PURE__ */ jsx3(SchemaOrgScript, { jsonLd: buildWebsiteJsonLd(data) });
4143
+ }
4144
+
4145
+ // src/schema/SchemaOrgScripts.tsx
4146
+ import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
4147
+ var GENERIC_TYPES = {
4148
+ schemaOrgWebPage: { schemaType: "WebPage", fields: webPageFields, requiredFields: ["name"] },
4149
+ schemaOrgPerson: { schemaType: "Person", fields: personFields, requiredFields: ["name"] },
4150
+ schemaOrgBreadcrumbList: {
4151
+ schemaType: "BreadcrumbList",
4152
+ fields: breadcrumbListFields,
4153
+ requiredFields: []
4154
+ },
4155
+ schemaOrgImageObject: {
4156
+ schemaType: "ImageObject",
4157
+ fields: imageObjectFields,
4158
+ requiredFields: ["url"]
4159
+ },
4160
+ schemaOrgArticle: { schemaType: "Article", fields: articleFields, requiredFields: ["headline"] },
4161
+ schemaOrgBlogPosting: {
4162
+ schemaType: "BlogPosting",
4163
+ fields: blogPostingFields,
4164
+ requiredFields: ["headline"]
4165
+ },
4166
+ schemaOrgFAQPage: { schemaType: "FAQPage", fields: faqPageFields, requiredFields: [] },
4167
+ schemaOrgHowTo: { schemaType: "HowTo", fields: howToFields, requiredFields: ["name"] },
4168
+ schemaOrgProduct: { schemaType: "Product", fields: productFields, requiredFields: ["name"] },
4169
+ schemaOrgOffer: { schemaType: "Offer", fields: offerFields, requiredFields: ["price"] },
4170
+ schemaOrgAggregateRating: {
4171
+ schemaType: "AggregateRating",
4172
+ fields: aggregateRatingFields,
4173
+ requiredFields: ["ratingValue"]
4174
+ },
4175
+ schemaOrgReview: { schemaType: "Review", fields: reviewFields, requiredFields: [] },
4176
+ schemaOrgBrand: { schemaType: "Brand", fields: brandFields, requiredFields: ["name"] },
4177
+ schemaOrgLocalBusiness: {
4178
+ schemaType: "LocalBusiness",
4179
+ fields: localBusinessFields,
4180
+ requiredFields: ["name"]
4181
+ },
4182
+ schemaOrgPostalAddress: {
4183
+ schemaType: "PostalAddress",
4184
+ fields: postalAddressFields,
4185
+ requiredFields: []
4186
+ },
4187
+ schemaOrgContactPoint: {
4188
+ schemaType: "ContactPoint",
4189
+ fields: contactPointFields,
4190
+ requiredFields: []
4191
+ },
4192
+ schemaOrgSoftwareApplication: {
4193
+ schemaType: "SoftwareApplication",
4194
+ fields: softwareApplicationFields,
4195
+ requiredFields: ["name"]
4196
+ },
4197
+ schemaOrgWebApplication: {
4198
+ schemaType: "WebApplication",
4199
+ fields: webApplicationFields,
4200
+ requiredFields: ["name"]
4201
+ },
4202
+ schemaOrgEvent: { schemaType: "Event", fields: eventFields, requiredFields: ["name"] },
4203
+ schemaOrgPlace: { schemaType: "Place", fields: placeFields, requiredFields: ["name"] },
4204
+ schemaOrgVideoObject: {
4205
+ schemaType: "VideoObject",
4206
+ fields: videoObjectFields,
4207
+ requiredFields: ["name"]
4208
+ },
4209
+ schemaOrgCourse: { schemaType: "Course", fields: courseFields, requiredFields: ["name"] },
4210
+ schemaOrgLegalService: {
4211
+ schemaType: "LegalService",
4212
+ fields: legalServiceFields,
4213
+ requiredFields: ["name"]
4214
+ },
4215
+ schemaOrgCountry: { schemaType: "Country", fields: countryFields, requiredFields: ["name"] },
4216
+ schemaOrgBook: { schemaType: "Book", fields: bookFields, requiredFields: ["name"] },
4217
+ schemaOrgItemList: {
4218
+ schemaType: "ItemList",
4219
+ fields: itemListFields,
4220
+ requiredFields: ["name"]
4221
+ },
4222
+ schemaOrgJobPosting: {
4223
+ schemaType: "JobPosting",
4224
+ fields: jobPostingFields,
4225
+ requiredFields: ["title"]
4226
+ },
4227
+ schemaOrgMovie: { schemaType: "Movie", fields: movieFields, requiredFields: ["name"] },
4228
+ schemaOrgMusicAlbum: {
4229
+ schemaType: "MusicAlbum",
4230
+ fields: musicAlbumFields,
4231
+ requiredFields: ["name"]
4232
+ },
4233
+ schemaOrgMusicRecording: {
4234
+ schemaType: "MusicRecording",
4235
+ fields: musicRecordingFields,
4236
+ requiredFields: ["name"]
4237
+ },
4238
+ schemaOrgNewsArticle: {
4239
+ schemaType: "NewsArticle",
4240
+ fields: newsArticleFields,
4241
+ requiredFields: ["headline"]
4242
+ },
4243
+ schemaOrgOpinionNewsArticle: {
4244
+ schemaType: "OpinionNewsArticle",
4245
+ fields: opinionNewsArticleFields,
4246
+ requiredFields: ["headline"]
4247
+ },
4248
+ schemaOrgProfilePage: {
4249
+ schemaType: "ProfilePage",
4250
+ fields: profilePageFields,
4251
+ requiredFields: ["name"]
4252
+ },
4253
+ schemaOrgRecipe: { schemaType: "Recipe", fields: recipeFields, requiredFields: ["name"] },
4254
+ schemaOrgRestaurant: {
4255
+ schemaType: "Restaurant",
4256
+ fields: restaurantFields,
4257
+ requiredFields: ["name"]
4258
+ },
4259
+ schemaOrgService: { schemaType: "Service", fields: serviceFields, requiredFields: ["name"] },
4260
+ schemaOrgSocialMediaPosting: {
4261
+ schemaType: "SocialMediaPosting",
4262
+ fields: socialMediaPostingFields,
4263
+ requiredFields: ["headline"]
4264
+ }
4265
+ };
4266
+ function buildSchemaOrgJsonLd(item) {
4267
+ const type = item._type;
4268
+ if (!type) return null;
4269
+ if (type === "schemaOrgWebsite") {
4270
+ return buildWebsiteJsonLd(item);
4271
+ }
4272
+ if (type === "schemaOrgOrganization") {
4273
+ return buildOrganizationJsonLd(item);
4274
+ }
4275
+ const entry = GENERIC_TYPES[type];
4276
+ if (!entry) return null;
4277
+ return buildGenericJsonLd(entry.schemaType, item, entry.fields, entry.requiredFields);
4278
+ }
4279
+ function buildSchemaOrgJsonLds(data) {
4280
+ if (!(data == null ? void 0 : data.length)) return [];
4281
+ return data.map((item) => buildSchemaOrgJsonLd(item)).filter((jsonLd) => jsonLd !== null);
4282
+ }
4283
+ function SchemaOrgScripts({ data }) {
4284
+ if (!(data == null ? void 0 : data.length)) return null;
4285
+ const scripts = buildSchemaOrgJsonLds(data);
4286
+ if (!scripts.length) return null;
4287
+ return /* @__PURE__ */ jsx4(Fragment, { children: scripts.map((jsonLd, idx) => (
4288
+ // static server-rendered scripts — order is stable, index key is safe
4289
+ // eslint-disable-next-line react/no-array-index-key
4290
+ /* @__PURE__ */ jsx4(SchemaOrgScript, { jsonLd }, `${idx}-${jsonLd["@type"]}`)
4291
+ )) });
4292
+ }
4293
+
4294
+ // src/schema/components/SchemaOrgJsonLdPreview.tsx
4295
+ import { jsx as jsx5, jsxs } from "react/jsx-runtime";
4296
+ function normalizeDocument(document) {
4297
+ var _a, _b;
4298
+ if (!document) return {};
4299
+ if ("displayed" in document || "draft" in document || "published" in document) {
4300
+ const viewDocument = document;
4301
+ const resolved = (_b = (_a = viewDocument.displayed) != null ? _a : viewDocument.draft) != null ? _b : viewDocument.published;
4302
+ if (resolved) return resolved;
4303
+ return {};
4304
+ }
4305
+ return document;
4306
+ }
4307
+ function getPathValue(source, path) {
4308
+ return path.split(".").reduce((current, part) => {
4309
+ if (!current || typeof current !== "object") return void 0;
4310
+ return current[part];
4311
+ }, source);
4312
+ }
4313
+ function resolveSlug(document, slugField) {
4314
+ const raw = getPathValue(document, slugField);
4315
+ if (typeof raw === "string") return raw;
4316
+ if (raw && typeof raw === "object" && "current" in raw) {
4317
+ const current = raw.current;
4318
+ return typeof current === "string" ? current : "";
4319
+ }
4320
+ return "";
4321
+ }
4322
+ function normalizePathSegment(value) {
4323
+ return value.replace(/^\/+|\/+$/g, "");
4324
+ }
4325
+ function resolveDocumentUrl(document, options) {
4326
+ if (options.urlBuilder) return options.urlBuilder(document);
4327
+ const baseUrl = (options.baseUrl || "https://www.example.com").replace(/\/+$/, "");
4328
+ const slug = normalizePathSegment(resolveSlug(document, options.slugField || "slug"));
4329
+ const prefix = typeof options.pathPrefix === "function" ? options.pathPrefix(document) : options.pathPrefix || "";
4330
+ const prefixSegment = normalizePathSegment(prefix);
4331
+ const path = [prefixSegment, slug].filter(Boolean).join("/");
4332
+ return path ? `${baseUrl}/${path}` : baseUrl;
4333
+ }
4334
+ function isSafeGroqPath(path) {
4335
+ return /^[A-Za-z0-9_.]+$/.test(path);
4336
+ }
4337
+ function buildDefaultSlugQuery(slugField, titleField) {
4338
+ if (!isSafeGroqPath(slugField) || !isSafeGroqPath(titleField)) return null;
4339
+ const slugExpression = slugField.endsWith(".current") ? slugField : `${slugField}.current`;
4340
+ return `*[_type == $type && defined(${slugExpression}) && !(_id in path("drafts.**"))] | order(${slugExpression} asc)[0...$limit]{
4341
+ _id,
4342
+ _type,
4343
+ "title": ${titleField},
4344
+ "slug": ${slugExpression}
4345
+ }`;
4346
+ }
4347
+ function normalizeSchemaOrgValue(value, document, schemaOrgField, schemaTypeName) {
4348
+ const raw = value != null ? value : getPathValue(document, schemaOrgField);
4349
+ if (Array.isArray(raw)) {
4350
+ return raw.filter((item) => !!item && typeof item === "object");
4351
+ }
4352
+ if (raw && typeof raw === "object") {
4353
+ const item = raw;
4354
+ return [__spreadValues(__spreadValues({}, schemaTypeName && !item._type ? { _type: schemaTypeName } : {}), item)];
4355
+ }
4356
+ return [];
4357
+ }
4358
+ function formatJson(value) {
4359
+ return JSON.stringify(value, null, 2);
4360
+ }
4361
+ function JsonLdCodeBlock({
4362
+ jsonLdItems,
4363
+ fieldPreview,
4364
+ scheme
4365
+ }) {
4366
+ const isDark = scheme === "dark";
4367
+ const codeBg = isDark ? "#161b22" : "#f6f8fa";
4368
+ const codeBorder = isDark ? "#30363d" : "#d0d7de";
4369
+ const headerBg = isDark ? "#21262d" : "#f0f2f4";
4370
+ const headerBorder = isDark ? "#30363d" : "#d0d7de";
4371
+ const headerText = isDark ? "#e6edf3" : "#24292f";
4372
+ const [copyLabel, setCopyLabel] = useState("Copy");
4373
+ const raw = formatJson(jsonLdItems.length === 1 ? jsonLdItems[0] : jsonLdItems);
4374
+ const tokens = useMemo(() => tokenizeJson(raw, scheme), [raw, scheme]);
4375
+ const handleCopy = () => {
4376
+ navigator.clipboard.writeText(raw).then(() => {
4377
+ setCopyLabel("Copied!");
4378
+ setTimeout(() => setCopyLabel("Copy"), 2e3);
4379
+ });
4380
+ };
4381
+ if (!jsonLdItems.length) {
4382
+ return /* @__PURE__ */ jsx5(Card, { border: true, radius: 2, padding: 0, style: { overflow: "hidden" }, children: /* @__PURE__ */ jsx5(Box, { padding: 3, children: /* @__PURE__ */ jsx5(Text, { size: 1, muted: true, children: "Fill the required Schema.org fields to generate JSON-LD." }) }) });
4383
+ }
4384
+ return /* @__PURE__ */ jsxs("div", { style: { borderRadius: 6, border: `1px solid ${codeBorder}`, overflow: "hidden" }, children: [
4385
+ /* @__PURE__ */ jsxs(
4386
+ "div",
4387
+ {
4388
+ style: {
4389
+ background: headerBg,
4390
+ borderBottom: `1px solid ${headerBorder}`,
4391
+ padding: "6px 14px",
4392
+ display: "flex",
4393
+ alignItems: "center",
4394
+ justifyContent: "space-between"
4395
+ },
4396
+ children: [
4397
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
4398
+ /* @__PURE__ */ jsx5(
4399
+ "span",
4400
+ {
4401
+ style: {
4402
+ width: 8,
4403
+ height: 8,
4404
+ borderRadius: "50%",
4405
+ background: isDark ? "#388bfd" : "#0550ae",
4406
+ display: "inline-block"
4407
+ }
4408
+ }
4409
+ ),
4410
+ /* @__PURE__ */ jsx5("span", { style: { fontSize: 11, color: headerText, fontFamily: "monospace" }, children: "JSON-LD" })
4411
+ ] }),
4412
+ /* @__PURE__ */ jsx5(
4413
+ "button",
4414
+ {
4415
+ type: "button",
4416
+ onClick: handleCopy,
4417
+ style: {
4418
+ background: "none",
4419
+ border: `1px solid ${headerBorder}`,
4420
+ borderRadius: 4,
4421
+ padding: "2px 8px",
4422
+ cursor: "pointer",
4423
+ fontSize: 11,
4424
+ color: headerText
4425
+ },
4426
+ children: copyLabel
4427
+ }
4428
+ )
4429
+ ]
4430
+ }
4431
+ ),
4432
+ /* @__PURE__ */ jsx5(
4433
+ Box,
4434
+ {
4435
+ as: "pre",
4436
+ padding: 3,
4437
+ style: {
4438
+ margin: 0,
4439
+ maxHeight: fieldPreview ? 360 : 520,
4440
+ overflow: "auto",
4441
+ fontSize: 12,
4442
+ fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
4443
+ lineHeight: 1.6,
4444
+ whiteSpace: "pre-wrap",
4445
+ wordBreak: "break-word",
4446
+ backgroundColor: codeBg
4447
+ },
4448
+ children: tokens.map((token, idx) => /* @__PURE__ */ jsx5("span", { style: { color: token.color }, children: token.text }, idx))
4449
+ }
4450
+ )
4451
+ ] });
4452
+ }
4453
+ function SchemaOrgJsonLdPreview({
4454
+ value,
4455
+ document,
4456
+ documentId,
4457
+ schemaType,
4458
+ schemaTypeName,
4459
+ fieldPreview = false,
4460
+ baseUrl,
4461
+ slugField = "slug",
4462
+ schemaOrgField = "schemaOrg",
4463
+ pathPrefix,
4464
+ urlBuilder,
4465
+ apiVersion = "2024-01-01",
4466
+ slugQuery,
4467
+ showSlugList,
4468
+ maxSlugItems = 25,
4469
+ titleField = "title"
4470
+ }) {
4471
+ const { scheme } = useColorScheme();
4472
+ const client = useClient({ apiVersion });
4473
+ const initialDocument = useMemo(() => normalizeDocument(document), [document]);
4474
+ const [fetchedDocument, setFetchedDocument] = useState(null);
4475
+ const [existingSlugs, setExistingSlugs] = useState([]);
4476
+ const [slugListError, setSlugListError] = useState("");
4477
+ useEffect(() => {
4478
+ if (initialDocument._id || !documentId) {
4479
+ setFetchedDocument(null);
4480
+ return;
4481
+ }
4482
+ client.fetch(`*[_id == $id][0]`, { id: documentId }).then((result) => setFetchedDocument(result)).catch(() => setFetchedDocument(null));
4483
+ }, [client, documentId, initialDocument._id]);
4484
+ const currentDocument = useMemo(
4485
+ () => __spreadValues(__spreadValues({}, fetchedDocument != null ? fetchedDocument : initialDocument), schemaType && !(fetchedDocument != null ? fetchedDocument : initialDocument)._type ? { _type: schemaType } : {}),
4486
+ [fetchedDocument, initialDocument, schemaType]
4487
+ );
4488
+ const resolvedUrl = useMemo(
4489
+ () => resolveDocumentUrl(currentDocument, { baseUrl, slugField, pathPrefix, urlBuilder }),
4490
+ [currentDocument, baseUrl, slugField, pathPrefix, urlBuilder]
4491
+ );
4492
+ const items = useMemo(
4493
+ () => normalizeSchemaOrgValue(value, currentDocument, schemaOrgField, schemaTypeName),
4494
+ [value, currentDocument, schemaOrgField, schemaTypeName]
4495
+ );
4496
+ const jsonLdItems = useMemo(() => {
4497
+ if (Array.isArray(value != null ? value : getPathValue(currentDocument, schemaOrgField))) {
4498
+ return buildSchemaOrgJsonLds(items);
4499
+ }
4500
+ return items.map((item) => buildSchemaOrgJsonLd(item)).filter((jsonLd) => jsonLd !== null);
4501
+ }, [currentDocument, items, schemaOrgField, value]);
4502
+ const shouldShowSlugList = showSlugList != null ? showSlugList : !fieldPreview;
4503
+ const documentType = currentDocument._type;
4504
+ useEffect(() => {
4505
+ if (!shouldShowSlugList || !documentType) {
4506
+ setExistingSlugs([]);
4507
+ setSlugListError("");
4508
+ return;
4509
+ }
4510
+ const query = slugQuery != null ? slugQuery : buildDefaultSlugQuery(slugField, titleField);
4511
+ if (!query) {
4512
+ setExistingSlugs([]);
4513
+ setSlugListError("Slug list disabled because slugField/titleField is not a safe GROQ path.");
4514
+ return;
4515
+ }
4516
+ client.fetch(query, { type: documentType, limit: maxSlugItems }).then((result) => {
4517
+ setExistingSlugs(Array.isArray(result) ? result : []);
4518
+ setSlugListError("");
4519
+ }).catch(() => {
4520
+ setExistingSlugs([]);
4521
+ setSlugListError("Could not fetch existing slugs.");
4522
+ });
4523
+ }, [client, documentType, maxSlugItems, shouldShowSlugList, slugField, slugQuery, titleField]);
4524
+ return /* @__PURE__ */ jsx5(Card, { border: true, radius: 2, padding: 3, tone: "transparent", children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
4525
+ /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", gap: 3, children: [
4526
+ /* @__PURE__ */ jsx5(Text, { size: 1, weight: "semibold", children: "Live JSON-LD Preview" }),
4527
+ /* @__PURE__ */ jsx5(Text, { size: 0, muted: true, children: jsonLdItems.length ? `${jsonLdItems.length} item${jsonLdItems.length > 1 ? "s" : ""}` : "No output" })
4528
+ ] }),
4529
+ /* @__PURE__ */ jsx5(Card, { border: true, radius: 2, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
4530
+ /* @__PURE__ */ jsx5(Text, { size: 0, muted: true, children: "Resolved document URL" }),
4531
+ /* @__PURE__ */ jsx5(Text, { size: 1, style: { wordBreak: "break-word" }, children: resolvedUrl })
4532
+ ] }) }),
4533
+ /* @__PURE__ */ jsx5(JsonLdCodeBlock, { jsonLdItems, fieldPreview, scheme }),
4534
+ shouldShowSlugList && /* @__PURE__ */ jsx5(Card, { border: true, radius: 2, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
4535
+ /* @__PURE__ */ jsxs(Text, { size: 1, weight: "semibold", children: [
4536
+ "Existing slugs",
4537
+ documentType ? ` for ${documentType}` : ""
4538
+ ] }),
4539
+ slugListError && /* @__PURE__ */ jsx5(Text, { size: 1, muted: true, children: slugListError }),
4540
+ !slugListError && existingSlugs.length > 0 && /* @__PURE__ */ jsx5(Stack, { space: 2, children: existingSlugs.map((item) => /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", gap: 3, children: [
4541
+ /* @__PURE__ */ jsx5(Text, { size: 1, style: { minWidth: 0 }, children: item.title || item.slug || item._id }),
4542
+ /* @__PURE__ */ jsx5(Text, { size: 0, muted: true, style: { wordBreak: "break-word", textAlign: "right" }, children: item.slug })
4543
+ ] }, item._id)) }),
4544
+ !slugListError && existingSlugs.length === 0 && /* @__PURE__ */ jsx5(Text, { size: 1, muted: true, children: "No existing slugs found." })
4545
+ ] }) })
4546
+ ] }) });
4547
+ }
4548
+ function SchemaOrgJsonLdPreviewInput(props) {
4549
+ var _a, _b;
4550
+ const { renderDefault, schemaType } = props;
4551
+ const rootDocument = (_a = useFormValue([])) != null ? _a : {};
4552
+ const options = (_b = schemaType.options) == null ? void 0 : _b.schemaOrgJsonLdPreview;
4553
+ const value = props.value;
4554
+ return /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
4555
+ /* @__PURE__ */ jsx5(
4556
+ SchemaOrgJsonLdPreview,
4557
+ __spreadProps(__spreadValues({}, options), {
4558
+ value: value != null ? value : null,
4559
+ document: rootDocument,
4560
+ schemaTypeName: schemaType.name,
4561
+ fieldPreview: true
4562
+ })
4563
+ ),
4564
+ renderDefault(props)
4565
+ ] });
4566
+ }
4567
+
4568
+ // src/schema/generator.ts
4569
+ function buildField(fieldDef, validation) {
4570
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4571
+ if (fieldDef.type === "select" && ((_a = fieldDef.variants) == null ? void 0 : _a.length)) {
4572
+ const variants = fieldDef.variants;
4573
+ const defaultVariant = (_b = fieldDef.defaultVariant) != null ? _b : variants[0].value;
4574
+ const innerFields = [
4575
+ {
4576
+ name: "variant",
4577
+ title: "Type",
4578
+ type: "string",
4579
+ description: "Choose how to provide this value.",
4580
+ initialValue: defaultVariant,
4581
+ options: variants.map((v) => ({ title: v.title, value: v.value })),
4582
+ layout: "radio"
4583
+ },
4584
+ ...variants.map((v) => {
4585
+ if (v.fields.length === 1 && v.fields[0].name === v.value) {
4586
+ return v.fields[0];
4587
+ }
4588
+ return {
4589
+ name: v.value,
4590
+ title: v.title,
4591
+ type: "object",
4592
+ jsonLdType: v.jsonLdType,
4593
+ fields: v.fields
4594
+ };
4595
+ })
4596
+ ];
4597
+ const base2 = {
4598
+ name: fieldDef.name,
4599
+ title: fieldDef.title,
4600
+ type: "object",
4601
+ fields: innerFields.map((child) => {
4602
+ const built = buildField(child, validation);
4603
+ if (child.name !== "variant") {
4604
+ const dv = defaultVariant;
4605
+ built.hidden = ({ parent }) => {
4606
+ var _a2;
4607
+ return ((_a2 = parent == null ? void 0 : parent.variant) != null ? _a2 : dv) !== child.name;
4608
+ };
4609
+ }
4610
+ return built;
4611
+ })
4612
+ };
4613
+ if (fieldDef.description) base2.description = fieldDef.description;
4614
+ return defineField(base2);
4615
+ }
4616
+ if (fieldDef.type === "copyrightYear") {
4617
+ const base2 = {
4618
+ name: fieldDef.name,
4619
+ title: fieldDef.title,
4620
+ type: "object",
4621
+ description: (_c = fieldDef.description) != null ? _c : 'Copyright year. Toggle "Use current year" to emit the current year dynamically.',
4622
+ fields: [
4623
+ defineField({
4624
+ name: "useDynamicYear",
4625
+ title: "Use current year (dynamic)",
4626
+ type: "boolean",
4627
+ initialValue: false
4628
+ }),
4629
+ defineField({
4630
+ name: "year",
4631
+ title: "Static year",
4632
+ type: "number",
4633
+ hidden: ({ parent }) => (parent == null ? void 0 : parent.useDynamicYear) === true
4634
+ })
4635
+ ]
4636
+ };
4637
+ return defineField(base2);
4638
+ }
4639
+ const base = {
4640
+ name: fieldDef.name,
4641
+ title: fieldDef.title,
4642
+ type: fieldDef.type
4643
+ };
4644
+ if (fieldDef.description) base.description = fieldDef.description;
4645
+ if (fieldDef.initialValue !== void 0) base.initialValue = fieldDef.initialValue;
4646
+ if (fieldDef.rows) base.rows = fieldDef.rows;
4647
+ if (fieldDef.options) {
4648
+ base.options = __spreadValues({ list: fieldDef.options }, fieldDef.layout && { layout: fieldDef.layout });
4649
+ }
4650
+ if (fieldDef.type === "array" && ((_d = fieldDef.fields) == null ? void 0 : _d.length) && !fieldDef.of) {
4651
+ base.of = [
4652
+ {
4653
+ type: "object",
4654
+ fields: fieldDef.fields.map((child) => buildField(child, validation))
4655
+ }
4656
+ ];
4657
+ } else if (fieldDef.of) {
4658
+ base.of = fieldDef.of;
4659
+ }
4660
+ if (fieldDef.type !== "array" && ((_e = fieldDef.fields) == null ? void 0 : _e.length)) {
4661
+ base.fields = fieldDef.fields.map((child) => buildField(child, validation));
4662
+ }
4663
+ if (fieldDef.type === "url" && (fieldDef.required || fieldDef.urlValidation)) {
4664
+ const required = fieldDef.required;
4665
+ const requiredMsg = required ? (_f = validation == null ? void 0 : validation[required.key]) != null ? _f : required.message : void 0;
4666
+ const schemes = (_h = (_g = fieldDef.urlValidation) == null ? void 0 : _g.schemes) != null ? _h : ["http", "https"];
4667
+ const allowRelative = (_j = (_i = fieldDef.urlValidation) == null ? void 0 : _i.allowRelative) != null ? _j : false;
4668
+ base.validation = (Rule) => {
4669
+ const checks = [];
4670
+ if (requiredMsg) checks.push(Rule.required().error(requiredMsg));
4671
+ checks.push(
4672
+ Rule.uri({ scheme: schemes, allowRelative }).error(
4673
+ `Must be a valid URL (${schemes.join(", ")}).`
4674
+ )
4675
+ );
4676
+ return checks;
4677
+ };
4678
+ } else if (fieldDef.required) {
4679
+ const msg = (_k = validation == null ? void 0 : validation[fieldDef.required.key]) != null ? _k : fieldDef.required.message;
4680
+ base.validation = (Rule) => Rule.required().error(msg);
4681
+ }
4682
+ return defineField(base);
4683
+ }
4684
+ function mapNameToSameValue(...items) {
4685
+ return items.reduce(
4686
+ (acc, item) => {
4687
+ acc[item.name] = item.name;
4688
+ return acc;
4689
+ },
4690
+ {}
4691
+ );
4692
+ }
4693
+ function generateSchemaType(def, config = {}) {
4694
+ const previewOptions = config.jsonLdPreview;
4695
+ const previewEnabled = previewOptions !== false;
4696
+ const previewConfig = typeof previewOptions === "object" ? previewOptions : void 0;
4697
+ return defineType(__spreadProps(__spreadValues(__spreadValues({
4698
+ name: def.name,
4699
+ title: def.title,
4700
+ type: "object"
4701
+ }, def.icon && { icon: def.icon }), previewEnabled && {
4702
+ components: { input: SchemaOrgJsonLdPreviewInput },
4703
+ options: { schemaOrgJsonLdPreview: previewConfig }
4704
+ }), {
4705
+ fields: def.fields.map((f) => buildField(f, config.validation)),
4706
+ preview: {
4707
+ select: mapNameToSameValue(...def.fields),
4708
+ prepare(selection) {
4709
+ return __spreadValues({
4710
+ title: def.title,
4711
+ subtitle: (def == null ? void 0 : def.customPrepareSubtitle) ? def.customPrepareSubtitle(selection) : `@type: ${def.title}`
4712
+ }, def.icon && { media: def.icon });
4713
+ }
4714
+ }
4715
+ }));
4716
+ }
4717
+
4718
+ export {
4719
+ tokenizeHtml,
4720
+ polymorphicImage,
4721
+ polymorphicAuthor,
4722
+ polymorphicPublisher,
4723
+ polymorphicGenre,
4724
+ polymorphicKeywords,
4725
+ polymorphicAdditionalType,
4726
+ polymorphicContributor,
4727
+ polymorphicCreator,
4728
+ polymorphicMaintainer,
4729
+ polymorphicFunder,
4730
+ polymorphicCopyrightHolder,
4731
+ polymorphicIdentifier,
4732
+ polymorphicOwner,
4733
+ polymorphicCitation,
4734
+ polymorphicContentRating,
4735
+ polymorphicArchivedAt,
4736
+ polymorphicIsBasedOn,
4737
+ polymorphicIsPartOf,
4738
+ polymorphicLicense,
4739
+ polymorphicLocationCreated,
4740
+ polymorphicMaterial,
4741
+ IETF_LANGUAGE_OPTIONS,
4742
+ inLanguageField,
4743
+ nameField,
4744
+ potentialActionSearch,
4745
+ descriptionField,
4746
+ urlField,
4747
+ headlineField,
4748
+ datePublishedField,
4749
+ withThingCommons,
4750
+ withCreativeWorkCommons,
4751
+ issnField,
4752
+ buildGenericJsonLd,
4753
+ generateSchemaType,
4754
+ SchemaOrgIcons,
4755
+ aggregateRatingFields,
4756
+ schemaOrgAggregateRating,
4757
+ articleFields,
4758
+ schemaOrgArticle,
4759
+ blogPostingFields,
4760
+ schemaOrgBlogPosting,
4761
+ bookFields,
4762
+ schemaOrgBook,
4763
+ brandFields,
4764
+ schemaOrgBrand,
4765
+ breadcrumbListFields,
4766
+ schemaOrgBreadcrumbList,
4767
+ contactPointFields,
4768
+ schemaOrgContactPoint,
4769
+ countryFields,
4770
+ schemaOrgCountry,
4771
+ courseFields,
4772
+ schemaOrgCourse,
4773
+ eventFields,
4774
+ schemaOrgEvent,
4775
+ faqPageFields,
4776
+ schemaOrgFAQPage,
4777
+ howToFields,
4778
+ schemaOrgHowTo,
4779
+ imageObjectFields,
4780
+ schemaOrgImageObject,
4781
+ itemListFields,
4782
+ schemaOrgItemList,
4783
+ jobPostingFields,
4784
+ schemaOrgJobPosting,
4785
+ legalServiceFields,
4786
+ schemaOrgLegalService,
4787
+ localBusinessFields,
4788
+ schemaOrgLocalBusiness,
4789
+ movieFields,
4790
+ schemaOrgMovie,
4791
+ musicAlbumFields,
4792
+ schemaOrgMusicAlbum,
4793
+ musicRecordingFields,
4794
+ schemaOrgMusicRecording,
4795
+ newsArticleFields,
4796
+ schemaOrgNewsArticle,
4797
+ offerFields,
4798
+ schemaOrgOffer,
4799
+ opinionNewsArticleFields,
4800
+ schemaOrgOpinionNewsArticle,
4801
+ SchemaOrgScript,
4802
+ buildOrganizationJsonLd,
4803
+ OrganizationSchema,
4804
+ personFields,
4805
+ schemaOrgPerson,
4806
+ placeFields,
4807
+ schemaOrgPlace,
4808
+ postalAddressFields,
4809
+ schemaOrgPostalAddress,
4810
+ productFields,
4811
+ schemaOrgProduct,
4812
+ profilePageFields,
4813
+ schemaOrgProfilePage,
4814
+ recipeFields,
4815
+ schemaOrgRecipe,
4816
+ restaurantFields,
4817
+ schemaOrgRestaurant,
4818
+ reviewFields,
4819
+ schemaOrgReview,
4820
+ serviceFields,
4821
+ schemaOrgService,
4822
+ socialMediaPostingFields,
4823
+ schemaOrgSocialMediaPosting,
4824
+ softwareApplicationFields,
4825
+ schemaOrgSoftwareApplication,
4826
+ videoObjectFields,
4827
+ schemaOrgVideoObject,
4828
+ webApplicationFields,
4829
+ schemaOrgWebApplication,
4830
+ webPageFields,
4831
+ schemaOrgWebPage,
4832
+ buildWebsiteJsonLd,
4833
+ WebsiteSchema,
4834
+ buildSchemaOrgJsonLd,
4835
+ buildSchemaOrgJsonLds,
4836
+ SchemaOrgScripts,
4837
+ SchemaOrgJsonLdPreview,
4838
+ SchemaOrgJsonLdPreviewInput
4839
+ };
4840
+ //# sourceMappingURL=chunk-XZKQWV2H.js.map