@angeloashmore/prismic-cli-poc 0.0.0-pr.9.92b6b39 → 0.0.0-pr.9.e40beab

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 (38) hide show
  1. package/dist/index.mjs +134 -107
  2. package/package.json +1 -1
  3. package/src/docs-fetch.ts +146 -0
  4. package/src/docs-list.ts +131 -0
  5. package/src/docs.ts +26 -121
  6. package/src/index.ts +1 -1
  7. package/src/page-type-add-field-boolean.ts +1 -1
  8. package/src/page-type-add-field-color.ts +1 -1
  9. package/src/page-type-add-field-date.ts +1 -1
  10. package/src/page-type-add-field-embed.ts +1 -1
  11. package/src/page-type-add-field-geo-point.ts +1 -1
  12. package/src/page-type-add-field-group.ts +1 -1
  13. package/src/page-type-add-field-image.ts +1 -1
  14. package/src/page-type-add-field-key-text.ts +1 -1
  15. package/src/page-type-add-field-link.ts +1 -1
  16. package/src/page-type-add-field-number.ts +1 -1
  17. package/src/page-type-add-field-rich-text.ts +1 -1
  18. package/src/page-type-add-field-select.ts +1 -1
  19. package/src/page-type-add-field-timestamp.ts +1 -1
  20. package/src/page-type-add-field-uid.ts +1 -1
  21. package/src/page-type-create.ts +1 -1
  22. package/src/repo-create.ts +1 -1
  23. package/src/skill-install.ts +2 -2
  24. package/src/skill-uninstall.ts +1 -1
  25. package/src/slice-add-field-boolean.ts +1 -1
  26. package/src/slice-add-field-color.ts +1 -1
  27. package/src/slice-add-field-date.ts +1 -1
  28. package/src/slice-add-field-embed.ts +1 -1
  29. package/src/slice-add-field-geo-point.ts +1 -1
  30. package/src/slice-add-field-group.ts +1 -1
  31. package/src/slice-add-field-image.ts +1 -1
  32. package/src/slice-add-field-key-text.ts +1 -1
  33. package/src/slice-add-field-link.ts +1 -1
  34. package/src/slice-add-field-number.ts +1 -1
  35. package/src/slice-add-field-rich-text.ts +1 -1
  36. package/src/slice-add-field-select.ts +1 -1
  37. package/src/slice-add-field-timestamp.ts +1 -1
  38. package/src/status.ts +1 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as r,readdir as i,rename as a,rm as o,rmdir as s,writeFile as c}from"node:fs/promises";import*as l from"node:crypto";import{createHash as u}from"node:crypto";import{homedir as d}from"node:os";import{fileURLToPath as f,pathToFileURL as p}from"node:url";import{exec as m}from"node:child_process";import{createServer as h}from"node:http";import{extname as g}from"node:path";var _=Object.defineProperty,v=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,b=Object.prototype.hasOwnProperty,x=(e,t)=>()=>(e&&(t=e(e=0)),t),S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ee=(e,t)=>{let n={};for(var r in e)_(n,r,{get:e[r],enumerable:!0});return t&&_(n,Symbol.toStringTag,{value:`Module`}),n},te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=y(t),a=0,o=i.length,s;a<o;a++)s=i[a],!b.call(e,s)&&s!==n&&_(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=v(t,s))||r.enumerable});return e},ne=e=>b.call(e,`module.exports`)?e[`module.exports`]:te(_({},`__esModule`,{value:!0}),e),C=`0.0.0-pr.9.92b6b39`,re=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),r=i([``,``],[``,``]);function i(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(){var t=this,n=[...arguments];return a(this,e),this.tag=function(e){var n=[...arguments].slice(1);return typeof e==`function`?t.interimTag.bind(t,e):typeof e==`string`?t.transformEndResult(e):(e=e.map(t.transformString.bind(t)),t.transformEndResult(e.reduce(t.processSubstitutions.bind(t,n))))},n.length>0&&Array.isArray(n[0])&&(n=n[0]),this.transformers=n.map(function(e){return typeof e==`function`?e():e}),this.tag}return n(e,[{key:`interimTag`,value:function(e,t){var n=[...arguments].slice(2);return this.tag(r,e.apply(void 0,[t].concat(n)))}},{key:`processSubstitutions`,value:function(e,t,n){return`${t}${this.transformSubstitution(e.shift(),t)}${n}`}},{key:`transformString`,value:function(e){return this.transformers.reduce(function(e,t){return t.onString?t.onString(e):e},e)}},{key:`transformSubstitution`,value:function(e,t){return this.transformers.reduce(function(e,n){return n.onSubstitution?n.onSubstitution(e,t):e},e)}},{key:`transformEndResult`,value:function(e){return this.transformers.reduce(function(e,t){return t.onEndResult?t.onEndResult(e):e},e)}}]),e}(),t.exports=e.default})),w=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(re());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ie=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``;return{onEndResult:function(t){if(e===``)return t.trim();if(e=e.toLowerCase(),e===`start`||e===`left`)return t.replace(/^\s*/,``);if(e===`end`||e===`right`)return t.replace(/\s*$/,``);throw Error(`Side not supported: `+e)}}},t.exports=e.default})),T=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ie());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ae=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`initial`;return{onEndResult:function(t){if(e===`initial`){var r=t.match(/^[^\S\n]*(?=\S)/gm),i=r&&Math.min.apply(Math,n(r.map(function(e){return e.length})));if(i){var a=RegExp(`^.{`+i+`}`,`gm`);return t.replace(a,``)}return t}if(e===`all`)return t.replace(/^[^\S\n]+/gm,``);throw Error(`Unknown type: `+e)}}},t.exports=e.default})),oe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ae());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),se=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onEndResult:function(n){if(e==null||t==null)throw Error(`replaceResultTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),ce=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(se());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),le=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onSubstitution:function(n,r){if(e==null||t==null)throw Error(`replaceSubstitutionTransformer requires at least 2 arguments.`);return n==null?n:n.toString().replace(e,t)}}},t.exports=e.default})),ue=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(le());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),de=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onString:function(n){if(e==null||t==null)throw Error(`replaceStringTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),fe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(de());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),pe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n={separator:``,conjunction:``,serial:!1};e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:n;return{onSubstitution:function(t,n){if(Array.isArray(t)){var r=t.length,i=e.separator,a=e.conjunction,o=e.serial,s=n.match(/(\n?[^\S\n]+)$/);if(t=s?t.join(i+s[1]):t.join(i+` `),a&&r>1){var c=t.lastIndexOf(i);t=t.slice(0,c)+(o?i:``)+` `+a+t.slice(c+1)}}return t}}},t.exports=e.default})),me=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(pe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),he=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e){return{onSubstitution:function(t,n){if(e!=null&&typeof e==`string`)typeof t==`string`&&t.includes(e)&&(t=t.split(e));else throw Error(`You need to specify a string character to split by.`);return t}}},t.exports=e.default})),ge=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(he());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),_e=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(e){return e!=null&&!Number.isNaN(e)&&typeof e!=`boolean`};e.default=function(){return{onSubstitution:function(e){return Array.isArray(e)?e.filter(n):n(e)?e:``}}},t.exports=e.default})),ve=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(_e());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ye=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(oe()),i=o(me()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`}),r.default,a.default),t.exports=e.default})),be=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ye());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),xe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(oe()),i=o(me()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`and`}),r.default,a.default),t.exports=e.default})),Se=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(xe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ce=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(oe()),i=o(me()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`or`}),r.default,a.default),t.exports=e.default})),we=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ce());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Te=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(w()),r=c(oe()),i=c(me()),a=c(T()),o=c(ge()),s=c(ve());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
2
+ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as r,readdir as i,rename as a,rm as o,rmdir as s,writeFile as c}from"node:fs/promises";import*as l from"node:crypto";import{createHash as u}from"node:crypto";import{homedir as d}from"node:os";import{fileURLToPath as f,pathToFileURL as p}from"node:url";import{exec as m}from"node:child_process";import{createServer as h}from"node:http";import{extname as g}from"node:path";var _=Object.defineProperty,v=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,b=Object.prototype.hasOwnProperty,x=(e,t)=>()=>(e&&(t=e(e=0)),t),S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ee=(e,t)=>{let n={};for(var r in e)_(n,r,{get:e[r],enumerable:!0});return t&&_(n,Symbol.toStringTag,{value:`Module`}),n},te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=y(t),a=0,o=i.length,s;a<o;a++)s=i[a],!b.call(e,s)&&s!==n&&_(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=v(t,s))||r.enumerable});return e},ne=e=>b.call(e,`module.exports`)?e[`module.exports`]:te(_({},`__esModule`,{value:!0}),e),C=`0.0.0-pr.9.e40beab`,re=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),r=i([``,``],[``,``]);function i(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(){var t=this,n=[...arguments];return a(this,e),this.tag=function(e){var n=[...arguments].slice(1);return typeof e==`function`?t.interimTag.bind(t,e):typeof e==`string`?t.transformEndResult(e):(e=e.map(t.transformString.bind(t)),t.transformEndResult(e.reduce(t.processSubstitutions.bind(t,n))))},n.length>0&&Array.isArray(n[0])&&(n=n[0]),this.transformers=n.map(function(e){return typeof e==`function`?e():e}),this.tag}return n(e,[{key:`interimTag`,value:function(e,t){var n=[...arguments].slice(2);return this.tag(r,e.apply(void 0,[t].concat(n)))}},{key:`processSubstitutions`,value:function(e,t,n){return`${t}${this.transformSubstitution(e.shift(),t)}${n}`}},{key:`transformString`,value:function(e){return this.transformers.reduce(function(e,t){return t.onString?t.onString(e):e},e)}},{key:`transformSubstitution`,value:function(e,t){return this.transformers.reduce(function(e,n){return n.onSubstitution?n.onSubstitution(e,t):e},e)}},{key:`transformEndResult`,value:function(e){return this.transformers.reduce(function(e,t){return t.onEndResult?t.onEndResult(e):e},e)}}]),e}(),t.exports=e.default})),w=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(re());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ie=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``;return{onEndResult:function(t){if(e===``)return t.trim();if(e=e.toLowerCase(),e===`start`||e===`left`)return t.replace(/^\s*/,``);if(e===`end`||e===`right`)return t.replace(/\s*$/,``);throw Error(`Side not supported: `+e)}}},t.exports=e.default})),T=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ie());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ae=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`initial`;return{onEndResult:function(t){if(e===`initial`){var r=t.match(/^[^\S\n]*(?=\S)/gm),i=r&&Math.min.apply(Math,n(r.map(function(e){return e.length})));if(i){var a=RegExp(`^.{`+i+`}`,`gm`);return t.replace(a,``)}return t}if(e===`all`)return t.replace(/^[^\S\n]+/gm,``);throw Error(`Unknown type: `+e)}}},t.exports=e.default})),oe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ae());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),se=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onEndResult:function(n){if(e==null||t==null)throw Error(`replaceResultTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),ce=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(se());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),le=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onSubstitution:function(n,r){if(e==null||t==null)throw Error(`replaceSubstitutionTransformer requires at least 2 arguments.`);return n==null?n:n.toString().replace(e,t)}}},t.exports=e.default})),ue=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(le());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),de=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onString:function(n){if(e==null||t==null)throw Error(`replaceStringTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),fe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(de());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),pe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n={separator:``,conjunction:``,serial:!1};e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:n;return{onSubstitution:function(t,n){if(Array.isArray(t)){var r=t.length,i=e.separator,a=e.conjunction,o=e.serial,s=n.match(/(\n?[^\S\n]+)$/);if(t=s?t.join(i+s[1]):t.join(i+` `),a&&r>1){var c=t.lastIndexOf(i);t=t.slice(0,c)+(o?i:``)+` `+a+t.slice(c+1)}}return t}}},t.exports=e.default})),me=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(pe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),he=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e){return{onSubstitution:function(t,n){if(e!=null&&typeof e==`string`)typeof t==`string`&&t.includes(e)&&(t=t.split(e));else throw Error(`You need to specify a string character to split by.`);return t}}},t.exports=e.default})),ge=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(he());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),_e=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(e){return e!=null&&!Number.isNaN(e)&&typeof e!=`boolean`};e.default=function(){return{onSubstitution:function(e){return Array.isArray(e)?e.filter(n):n(e)?e:``}}},t.exports=e.default})),ve=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(_e());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ye=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(oe()),i=o(me()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`}),r.default,a.default),t.exports=e.default})),be=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ye());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),xe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(oe()),i=o(me()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`and`}),r.default,a.default),t.exports=e.default})),Se=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(xe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ce=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(oe()),i=o(me()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`or`}),r.default,a.default),t.exports=e.default})),we=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ce());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Te=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(w()),r=c(oe()),i=c(me()),a=c(T()),o=c(ge()),s=c(ve());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
3
3
  `),s.default,i.default,r.default,a.default),t.exports=e.default})),Ee=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Te());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),De=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ee());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Oe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ee());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ke=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(w()),r=c(oe()),i=c(me()),a=c(T()),o=c(ge()),s=c(ue());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
4
4
  `),i.default,r.default,a.default,(0,s.default)(/&/g,`&amp;`),(0,s.default)(/</g,`&lt;`),(0,s.default)(/>/g,`&gt;`),(0,s.default)(/"/g,`&quot;`),(0,s.default)(/'/g,`&#x27;`),(0,s.default)(/`/g,`&#x60;`)),t.exports=e.default})),Ae=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ke());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),je=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(w()),r=a(T()),i=a(ce());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n(?:\s*))+/g,` `),r.default),t.exports=e.default})),Me=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(je());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ne=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(w()),r=a(T()),i=a(ce());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n\s*)/g,``),r.default),t.exports=e.default})),Pe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ne());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Fe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(me()),i=o(T()),a=o(ce());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Ie=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Fe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Le=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(me()),i=o(T()),a=o(ce());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`or`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Re=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Le());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ze=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(me()),i=o(T()),a=o(ce());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`and`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Be=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ze());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ve=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(oe()),i=o(me()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(i.default,r.default,a.default),t.exports=e.default})),He=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ve());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ue=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(w()),r=o(me()),i=o(T()),a=o(ce());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),We=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ue());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ge=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(w()),r=a(oe()),i=a(T());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,i.default),t.exports=e.default})),Ke=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ge());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),qe=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(w()),r=a(oe()),i=a(T());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)(`all`),i.default),t.exports=e.default})),Je=S(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(qe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),E=S((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.stripIndents=e.stripIndent=e.oneLineInlineLists=e.inlineLists=e.oneLineCommaListsAnd=e.oneLineCommaListsOr=e.oneLineCommaLists=e.oneLineTrim=e.oneLine=e.safeHtml=e.source=e.codeBlock=e.html=e.commaListsOr=e.commaListsAnd=e.commaLists=e.removeNonPrintingValuesTransformer=e.splitStringTransformer=e.inlineArrayTransformer=e.replaceStringTransformer=e.replaceSubstitutionTransformer=e.replaceResultTransformer=e.stripIndentTransformer=e.trimResultTransformer=e.TemplateTag=void 0;var t=C(w()),n=C(T()),r=C(oe()),i=C(ce()),a=C(ue()),o=C(fe()),s=C(me()),c=C(ge()),l=C(ve()),u=C(be()),d=C(Se()),f=C(we()),p=C(Ee()),m=C(De()),h=C(Oe()),g=C(Ae()),_=C(Me()),v=C(Pe()),y=C(Ie()),b=C(Re()),x=C(Be()),S=C(He()),ee=C(We()),te=C(Ke()),ne=C(Je());function C(e){return e&&e.__esModule?e:{default:e}}e.TemplateTag=t.default,e.trimResultTransformer=n.default,e.stripIndentTransformer=r.default,e.replaceResultTransformer=i.default,e.replaceSubstitutionTransformer=a.default,e.replaceStringTransformer=o.default,e.inlineArrayTransformer=s.default,e.splitStringTransformer=c.default,e.removeNonPrintingValuesTransformer=l.default,e.commaLists=u.default,e.commaListsAnd=d.default,e.commaListsOr=f.default,e.html=p.default,e.codeBlock=m.default,e.source=h.default,e.safeHtml=g.default,e.oneLine=_.default,e.oneLineTrim=v.default,e.oneLineCommaLists=y.default,e.oneLineCommaListsOr=b.default,e.oneLineCommaListsAnd=x.default,e.inlineLists=S.default,e.oneLineInlineLists=ee.default,e.stripIndent=te.default,e.stripIndents=ne.default}))(),Ye=class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge==`number`&&e.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||1/0,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction==`function`)for(let[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return typeof t.expiry==`number`&&t.expiry<=Date.now()?(typeof this.onEviction==`function`&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){let n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield e)}for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield e)}}get(e){if(this.cache.has(e)){let t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){let t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){let r=typeof n==`number`&&n!==1/0?Date.now()+n:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:r}):this._set(e,{value:t,expiry:r}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){let t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.cache.has(n)||this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(let t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};function Xe(e,t){return(!e||e.endsWith(`
5
5
  `))&&!t?.force?e:e+`
@@ -690,7 +690,7 @@ LEARN MORE
690
690
  Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const Kr=`Fetch and display documentation from Prismic's docs site.
691
691
 
692
692
  USAGE
693
- prismic docs <path> [flags]
693
+ prismic docs fetch <path> [flags]
694
694
 
695
695
  ARGUMENTS
696
696
  path Documentation path with optional anchor (e.g., "nextjs" or "nextjs#set-up-a-prismic-client")
@@ -699,13 +699,40 @@ FLAGS
699
699
  -h, --help Show help for command
700
700
 
701
701
  EXAMPLES
702
- prismic docs nextjs
703
- prismic docs nextjs#set-up-a-prismic-client
702
+ prismic docs fetch nextjs
703
+ prismic docs fetch nextjs#set-up-a-prismic-client
704
704
 
705
705
  LEARN MORE
706
706
  Visit https://prismic.io/docs for the full documentation.`;function qr(e){let t=e.indexOf(`#`);return t===-1?{path:e}:{path:e.slice(0,t),anchor:e.slice(t+1)}}async function Jr(e){try{let t=await fetch(e);return t.status===404?{ok:!1,error:`Documentation not found: ${e}`}:t.ok?{ok:!0,content:await t.text()}:{ok:!1,error:`Failed to fetch documentation: ${t.status}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:String(e)}`}}}function Yr(e){let t=e.split(`-`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`[\\s-]+`);return RegExp(`^(#{1,6})\\s+${t}\\s*$`,`im`)}function Xr(e,t){let n=e.split(`
707
707
  `),r=Yr(t),i=-1,a=0;for(let e=0;e<n.length;e++){let t=n[e].match(r);if(t){i=e,a=t[1].length;break}}if(i===-1)return{ok:!1,error:`Anchor not found: #${t}`};let o=n.length;for(let e=i+1;e<n.length;e++){let t=n[e].match(/^(#{1,6})\s/);if(t&&t[1].length<=a){o=e;break}}return{ok:!0,content:n.slice(i,o).join(`
708
- `).trim()}}async function Zr(){let{positionals:[t],values:{help:n}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(Kr);return}if(!t){console.info(Kr);return}let{path:r,anchor:i}=qr(t),a=await Jr(`https://prismic.io/docs/${r}.md`);if(!a.ok){console.error(a.error),process.exitCode=1;return}let o=a.content;if(i){let e=Xr(o,i);if(!e.ok){console.error(e.error),process.exitCode=1;return}o=e.content}console.info(o)}const Qr=`prismic.config.json`,$r=N({repositoryName:I(),apiEndpoint:P(Sn(I(),hn())),localSliceMachineSimulatorURL:P(Sn(I(),hn())),libraries:P(j(I())),adapter:P(I()),labs:P(N({legacySliceUpgrader:P(M())}))});async function ei(e,t=p(process.cwd())){let n=await ai(t);return n.ok?(await c(n.path,J(e)),{ok:!0,config:e}):n}async function X(e=p(process.cwd())){let t=await ti(e);if(t.ok)return t.config.repositoryName}async function ti(e=p(process.cwd())){let t=await ii(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=R($r,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new ni(n.issues)}}catch{return{ok:!1,error:new ni}}}var ni=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function ri(e,t=p(process.cwd())){let n=await ii(t);if(!n.ok)return n;let r=await ti(t);if(!r.ok)return r;let i={...r.config,...e};return await c(n.path,J(i)),{ok:!0,config:i}}async function ii(e=p(process.cwd())){let t=await V(Qr,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new oi}}async function ai(e=p(process.cwd())){let t=await V(`package.json`,{start:e});return t?{ok:!0,path:new URL(Qr,t)}:{ok:!1,error:new si}}var oi=class extends Error{message=`Could not find a prismic.config.json file.`},si=class extends Error{message=`Could not find a package.json file.`};async function ci(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`}}});if(t.help){console.info(`Initialize a Prismic project by creating a prismic.config.json file.
708
+ `).trim()}}async function Zr(){let{positionals:[t],values:{help:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(Kr);return}if(!t){console.info(Kr);return}let{path:r,anchor:i}=qr(t),a=await Jr(`https://prismic.io/docs/${r}.md`);if(!a.ok){console.error(a.error),process.exitCode=1;return}let o=a.content;if(i){let e=Xr(o,i);if(!e.ok){console.error(e.error),process.exitCode=1;return}o=e.content}console.info(o)}const Qr=`https://prismic.io/docs/sitemap.xml`;function $r(e){return e.replaceAll(`&amp;`,`&`).replaceAll(`&lt;`,`<`).replaceAll(`&gt;`,`>`).replaceAll(`&quot;`,`"`).replaceAll(`&apos;`,`'`)}function ei(e){let t=/<loc>(.*?)<\/loc>/g,n=[],r=t.exec(e);for(;r;)n.push($r(r[1]).trim()),r=t.exec(e);return n.filter(Boolean)}async function ti(e){try{let t=await fetch(e);return t.ok?{ok:!0,xml:await t.text()}:{ok:!1,error:`Failed to fetch sitemap: ${t.status} (${e})`}}catch(t){return{ok:!1,error:`Network error while fetching sitemap ${e}: ${t instanceof Error?t.message:String(t)}`}}}function ni(e){try{let t=new URL(e);return t.hostname!==`prismic.io`||!t.pathname.startsWith(`/docs/`)?null:t.pathname.replace(/^\/docs\//,``).replace(/^\/+|\/+$/g,``)}catch{return null}}async function ri(){let{values:{help:t}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List documentation pages from Prismic's docs site.
709
+
710
+ USAGE
711
+ prismic docs list [flags]
712
+
713
+ FLAGS
714
+ -h, --help Show help for command
715
+
716
+ EXAMPLES
717
+ prismic docs list`);return}let n=await ti(Qr);if(!n.ok){console.error(n.error),process.exitCode=1;return}let r=ei(n.xml);if(r.length===0){console.error(`No nested sitemaps found in ${Qr}`),process.exitCode=1;return}let i=await Promise.all(r.map(e=>ti(e))),a=i.find(e=>!e.ok);if(a&&!a.ok){console.error(a.error),process.exitCode=1;return}let o=new Set;for(let e of i)if(e.ok)for(let t of ei(e.xml)){let e=ni(t);e&&o.add(e)}for(let e of[...o].sort((e,t)=>e.localeCompare(t)))console.info(e)}async function ii(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`fetch`:await Zr();break;case`list`:await ri();break;default:t&&(console.error(`Unknown docs subcommand: ${t}\n`),process.exitCode=1),console.info(`Fetch and list documentation from Prismic's docs site.
718
+
719
+ USAGE
720
+ prismic docs <command> [flags]
721
+
722
+ COMMANDS
723
+ fetch Fetch and display a documentation page
724
+ list List documentation pages
725
+
726
+ FLAGS
727
+ -h, --help Show help for command
728
+
729
+ EXAMPLES
730
+ prismic docs fetch nextjs
731
+ prismic docs fetch nextjs#set-up-a-prismic-client
732
+ prismic docs list
733
+
734
+ LEARN MORE
735
+ Use \`prismic docs <command> --help\` for more information about a command.`)}}const ai=`prismic.config.json`,oi=N({repositoryName:I(),apiEndpoint:P(Sn(I(),hn())),localSliceMachineSimulatorURL:P(Sn(I(),hn())),libraries:P(j(I())),adapter:P(I()),labs:P(N({legacySliceUpgrader:P(M())}))});async function si(e,t=p(process.cwd())){let n=await fi(t);return n.ok?(await c(n.path,J(e)),{ok:!0,config:e}):n}async function X(e=p(process.cwd())){let t=await ci(e);if(t.ok)return t.config.repositoryName}async function ci(e=p(process.cwd())){let t=await di(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=R(oi,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new li(n.issues)}}catch{return{ok:!1,error:new li}}}var li=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function ui(e,t=p(process.cwd())){let n=await di(t);if(!n.ok)return n;let r=await ci(t);if(!r.ok)return r;let i={...r.config,...e};return await c(n.path,J(i)),{ok:!0,config:i}}async function di(e=p(process.cwd())){let t=await V(ai,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new pi}}async function fi(e=p(process.cwd())){let t=await V(`package.json`,{start:e});return t?{ok:!0,path:new URL(ai,t)}:{ok:!1,error:new mi}}var pi=class extends Error{message=`Could not find a prismic.config.json file.`},mi=class extends Error{message=`Could not find a package.json file.`};async function hi(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`}}});if(t.help){console.info(`Initialize a Prismic project by creating a prismic.config.json file.
709
736
 
710
737
  Use this command to connect an existing Prismic repository to your project.
711
738
  To create a new repository, use \`prismic repo create\` instead.
@@ -718,7 +745,7 @@ FLAGS
718
745
  -h, --help Show help for command
719
746
 
720
747
  LEARN MORE
721
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!t.repo){console.error(`Missing required flag: --repo`),process.exitCode=1;return}if((await ti()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await ei({repositoryName:t.repo});if(!n.ok){n.error instanceof si?console.error(`Could not find a package.json file. Run this command from a project directory.`):console.error(`Failed to create config file.`),process.exitCode=1;return}console.info(`Created prismic.config.json for repository "${t.repo}"`)}async function Z(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await kn();e&&r.set(`Cookie`,`SESSION=fake_session; prismic-auth=${e}`)}!r.has(`Content-Type`)&&t.body&&r.set(`Content-Type`,`application/json`),t.body instanceof FormData&&r.delete(`Content-Type`);let i=r.get(`Content-Type`)===`application/json`?JSON.stringify(t.body):t.body,a=await fetch(e,{...t,body:i,headers:r}),o=await a.clone().json().catch(()=>a.clone().text());if(a.ok){if(!t?.schema)return{ok:!0,value:o};try{return{ok:!0,value:xn(t.schema,o)}}catch(e){if(A(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new ui(a)};else if(a.status===403)return{ok:!1,value:o,error:new Q(a)};else return{ok:!1,value:o,error:new li(a)}}var li=class extends Error{name=`RequestError`;response;constructor(e){super(`fetch failed: ${e.url}`),this.response=e}async text(){return this.response.clone().text()}async json(){return this.response.clone().json()}get status(){return this.response.status}get statusText(){return this.response.statusText}},Q=class extends li{},ui=class extends li{};async function di(){let{values:{help:t,name:n,repo:r=await X()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new locale to a Prismic repository.
748
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!t.repo){console.error(`Missing required flag: --repo`),process.exitCode=1;return}if((await ci()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await si({repositoryName:t.repo});if(!n.ok){n.error instanceof mi?console.error(`Could not find a package.json file. Run this command from a project directory.`):console.error(`Failed to create config file.`),process.exitCode=1;return}console.info(`Created prismic.config.json for repository "${t.repo}"`)}async function Z(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await kn();e&&r.set(`Cookie`,`SESSION=fake_session; prismic-auth=${e}`)}!r.has(`Content-Type`)&&t.body&&r.set(`Content-Type`,`application/json`),t.body instanceof FormData&&r.delete(`Content-Type`);let i=r.get(`Content-Type`)===`application/json`?JSON.stringify(t.body):t.body,a=await fetch(e,{...t,body:i,headers:r}),o=await a.clone().json().catch(()=>a.clone().text());if(a.ok){if(!t?.schema)return{ok:!0,value:o};try{return{ok:!0,value:xn(t.schema,o)}}catch(e){if(A(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new _i(a)};else if(a.status===403)return{ok:!1,value:o,error:new Q(a)};else return{ok:!1,value:o,error:new gi(a)}}var gi=class extends Error{name=`RequestError`;response;constructor(e){super(`fetch failed: ${e.url}`),this.response=e}async text(){return this.response.clone().text()}async json(){return this.response.clone().json()}get status(){return this.response.status}get statusText(){return this.response.statusText}},Q=class extends gi{},_i=class extends gi{};async function vi(){let{values:{help:t,name:n,repo:r=await X()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new locale to a Prismic repository.
722
749
 
723
750
  By default, this command reads the repository from prismic.config.json at the
724
751
  project root.
@@ -735,7 +762,7 @@ FLAGS
735
762
  -h, --help Show help for command
736
763
 
737
764
  LEARN MORE
738
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){mi();return}let a=n?await pi(r,i,n):await fi(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof Q?mi():(console.error(`Failed to add locale: ${J(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function fi(e,t){return await Z(new URL(`/app/settings/multilanguages`,await z(e)),{method:`POST`,body:{languages:[t]}})}async function pi(e,t,n){let[r,i]=t.split(`-`);return await Z(new URL(`/app/settings/multilanguages/custom`,await z(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function mi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function hi(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all locales in a Prismic repository.
765
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){xi();return}let a=n?await bi(r,i,n):await yi(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof Q?xi():(console.error(`Failed to add locale: ${J(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function yi(e,t){return await Z(new URL(`/app/settings/multilanguages`,await z(e)),{method:`POST`,body:{languages:[t]}})}async function bi(e,t,n){let[r,i]=t.split(`-`);return await Z(new URL(`/app/settings/multilanguages/custom`,await z(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function xi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Si(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all locales in a Prismic repository.
739
766
 
740
767
  By default, this command reads the repository from prismic.config.json at the
741
768
  project root.
@@ -749,7 +776,7 @@ FLAGS
749
776
  -h, --help Show help for command
750
777
 
751
778
  LEARN MORE
752
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){vi();return}let i=await _i(n);if(!i.ok){i.error instanceof Q?vi():A(i.error)?(console.error(`Failed to list locales: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(J(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const gi=N({results:j(N({id:I(),label:I(),customName:yn(I()),isMaster:M()}))});async function _i(e){let t=new URL(`/locale/repository/locales`,await Cn());return t.searchParams.set(`repository`,e),await Z(t,{schema:gi})}function vi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yi(){let{values:{repo:t=await X(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
779
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Ti();return}let i=await wi(n);if(!i.ok){i.error instanceof Q?Ti():A(i.error)?(console.error(`Failed to list locales: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(J(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const Ci=N({results:j(N({id:I(),label:I(),customName:yn(I()),isMaster:M()}))});async function wi(e){let t=new URL(`/locale/repository/locales`,await Cn());return t.searchParams.set(`repository`,e),await Z(t,{schema:Ci})}function Ti(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ei(){let{values:{repo:t=await X(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
753
780
 
754
781
  By default, this command reads the repository from prismic.config.json at the
755
782
  project root.
@@ -765,7 +792,7 @@ FLAGS
765
792
  -h, --help Show help for command
766
793
 
767
794
  LEARN MORE
768
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){xi();return}let i=await bi(t,r);if(!i.ok){i.error instanceof Q?xi():(console.error(`Failed to remove locale: ${J(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function bi(e,t){let n=new URL(`/locale/repository/locales/${t}`,await Cn());return n.searchParams.set(`repository`,e),await Z(n,{method:`DELETE`})}function xi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Si(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the default locale for a Prismic repository.
795
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Oi();return}let i=await Di(t,r);if(!i.ok){i.error instanceof Q?Oi():(console.error(`Failed to remove locale: ${J(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function Di(e,t){let n=new URL(`/locale/repository/locales/${t}`,await Cn());return n.searchParams.set(`repository`,e),await Z(n,{method:`DELETE`})}function Oi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ki(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the default locale for a Prismic repository.
769
796
 
770
797
  By default, this command reads the repository from prismic.config.json at the
771
798
  project root.
@@ -781,7 +808,7 @@ FLAGS
781
808
  -h, --help Show help for command
782
809
 
783
810
  LEARN MORE
784
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){wi();return}let i=await _i(n);if(!i.ok){i.error instanceof Q?wi():A(i.error)?(console.error(`Failed to set default locale: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results,o=a.find(e=>e.id===r);if(!o){console.error(`Locale "${r}" not found in repository. Available locales: ${a.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.isMaster){console.error(`Locale "${r}" is already the default.`),process.exitCode=1;return}let s=await Ci(n,o);if(!s.ok){s.error instanceof Q?wi():(console.error(`Failed to set default locale: ${J(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function Ci(e,t){let n=new URL(`/locale/repository/locales`,await Cn());return n.searchParams.set(`repository`,e),await Z(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function wi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ti(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await di();break;case`list`:await hi();break;case`remove`:await yi();break;case`set-default`:await Si();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
811
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ji();return}let i=await wi(n);if(!i.ok){i.error instanceof Q?ji():A(i.error)?(console.error(`Failed to set default locale: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results,o=a.find(e=>e.id===r);if(!o){console.error(`Locale "${r}" not found in repository. Available locales: ${a.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.isMaster){console.error(`Locale "${r}" is already the default.`),process.exitCode=1;return}let s=await Ai(n,o);if(!s.ok){s.error instanceof Q?ji():(console.error(`Failed to set default locale: ${J(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function Ai(e,t){let n=new URL(`/locale/repository/locales`,await Cn());return n.searchParams.set(`repository`,e),await Z(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function ji(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Mi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await vi();break;case`list`:await Si();break;case`remove`:await Ei();break;case`set-default`:await ki();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
785
812
 
786
813
  USAGE
787
814
  prismic locale <command> [flags]
@@ -796,7 +823,7 @@ FLAGS
796
823
  -h, --help Show help for command
797
824
 
798
825
  LEARN MORE
799
- Use \`prismic locale <command> --help\` for more information about a command.`)}}const Ei=`https://prismic.io`;async function Di(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log in to Prismic via browser.
826
+ Use \`prismic locale <command> --help\` for more information about a command.`)}}const Ni=`https://prismic.io`;async function Pi(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log in to Prismic via browser.
800
827
 
801
828
  USAGE
802
829
  prismic login [flags]
@@ -805,7 +832,7 @@ FLAGS
805
832
  -h, --help Show help for command
806
833
 
807
834
  LEARN MORE
808
- Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=h((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":Ei,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":Ei,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await On(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":Ei,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":Ei,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),r=setTimeout(()=>{n.close(),t(Error(`Login timed out. Please try again.`))},18e4),i=()=>{let e=n.address();if(!e||typeof e==`string`){clearTimeout(r),n.close(),t(Error(`Failed to start login server`));return}let i=e.port,a=Oi(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),ki(a)};n.on(`error`,e=>{e.code===`EADDRINUSE`&&n.listening===!1?n.listen(0,`0.0.0.0`,i):(clearTimeout(r),t(e))}),n.listen(5555,`0.0.0.0`,i)})}function Oi(e){let t=new URL(`https://prismic.io/dashboard/cli/login`);return t.searchParams.set(`source`,`slice-machine`),t.searchParams.set(`port`,e.toString()),t}function ki(e){m(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Ai(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log out of Prismic.
835
+ Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=h((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":Ni,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":Ni,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await On(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":Ni,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":Ni,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),r=setTimeout(()=>{n.close(),t(Error(`Login timed out. Please try again.`))},18e4),i=()=>{let e=n.address();if(!e||typeof e==`string`){clearTimeout(r),n.close(),t(Error(`Failed to start login server`));return}let i=e.port,a=Fi(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),Ii(a)};n.on(`error`,e=>{e.code===`EADDRINUSE`&&n.listening===!1?n.listen(0,`0.0.0.0`,i):(clearTimeout(r),t(e))}),n.listen(5555,`0.0.0.0`,i)})}function Fi(e){let t=new URL(`https://prismic.io/dashboard/cli/login`);return t.searchParams.set(`source`,`slice-machine`),t.searchParams.set(`port`,e.toString()),t}function Ii(e){m(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Li(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log out of Prismic.
809
836
 
810
837
  USAGE
811
838
  prismic logout [flags]
@@ -814,7 +841,7 @@ FLAGS
814
841
  -h, --help Show help for command
815
842
 
816
843
  LEARN MORE
817
- Use \`prismic <command> --help\` for more information about a command.`);return}await Mn()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const ji=N({dependencies:P(F(I(),I())),devDependencies:P(F(I(),I()))});async function $(){let e=await V(`package.json`);if(!e)return;let t=new URL(`.`,e),n;try{let t=await r(e,`utf8`),{dependencies:i={},devDependencies:a={}}=xn(ji,JSON.parse(t)),o={...i,...a};`next`in o?n=`next`:`nuxt`in o?n=`nuxt`:`@sveltejs/kit`in o&&(n=`sveltekit`)}catch{}let i=!1;return n===`next`||n===`sveltekit`?i=await Nn(new URL(`src/`,t)):n===`nuxt`&&(i=await Nn(new URL(`app/`,t))),{framework:n,hasSrcDir:i,projectRoot:t}}function Mi(e){switch(e){case`next`:return[`@prismicio/client`,`@prismicio/react`,`@prismicio/next`];case`nuxt`:return[`@nuxtjs/prismic`];case`sveltekit`:return[`@prismicio/client`,`@prismicio/svelte`];default:return[`@prismicio/client`]}}function Ni(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/prismicio.ts`:`prismicio.ts`;case`nuxt`:return null;case`sveltekit`:return`src/lib/prismicio.ts`;default:return`prismicio.ts`}}function Pi(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/slices/`:`slices/`;case`nuxt`:return e.hasSrcDir?`app/slices/`:`slices/`;case`sveltekit`:return`src/lib/slices/`;default:return`slices/`}}function Fi(e){switch(e){case`next`:return[`.tsx`,`.ts`,`.jsx`,`.js`];case`nuxt`:return[`.vue`];case`sveltekit`:return[`.svelte`];default:return[`.tsx`,`.ts`,`.jsx`,`.js`]}}function Ii(e,t){switch(e.framework){case`next`:{let n=e.hasSrcDir?`src/app`:`app`;return t===`/slice-simulator`?{path:`${n}/slice-simulator/page`,extensions:[`.tsx`,`.ts`,`.jsx`,`.js`]}:t===`/api/preview`?{path:`${n}/api/preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/exit-preview`?{path:`${n}/api/exit-preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/revalidate`?{path:`${n}/api/revalidate/route`,extensions:[`.ts`,`.js`]}:null}case`nuxt`:return t===`/slice-simulator`?{path:`pages/slice-simulator`,extensions:[`.vue`]}:null;case`sveltekit`:return t===`/slice-simulator`?{path:`src/routes/slice-simulator/+page`,extensions:[`.svelte`]}:t===`/api/preview`?{path:`src/routes/api/preview/+server`,extensions:[`.ts`,`.js`]}:null;default:return null}}const Li=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Ri(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function zi(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":s,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
844
+ Use \`prismic <command> --help\` for more information about a command.`);return}await Mn()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const Ri=N({dependencies:P(F(I(),I())),devDependencies:P(F(I(),I()))});async function $(){let e=await V(`package.json`);if(!e)return;let t=new URL(`.`,e),n;try{let t=await r(e,`utf8`),{dependencies:i={},devDependencies:a={}}=xn(Ri,JSON.parse(t)),o={...i,...a};`next`in o?n=`next`:`nuxt`in o?n=`nuxt`:`@sveltejs/kit`in o&&(n=`sveltekit`)}catch{}let i=!1;return n===`next`||n===`sveltekit`?i=await Nn(new URL(`src/`,t)):n===`nuxt`&&(i=await Nn(new URL(`app/`,t))),{framework:n,hasSrcDir:i,projectRoot:t}}function zi(e){switch(e){case`next`:return[`@prismicio/client`,`@prismicio/react`,`@prismicio/next`];case`nuxt`:return[`@nuxtjs/prismic`];case`sveltekit`:return[`@prismicio/client`,`@prismicio/svelte`];default:return[`@prismicio/client`]}}function Bi(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/prismicio.ts`:`prismicio.ts`;case`nuxt`:return null;case`sveltekit`:return`src/lib/prismicio.ts`;default:return`prismicio.ts`}}function Vi(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/slices/`:`slices/`;case`nuxt`:return e.hasSrcDir?`app/slices/`:`slices/`;case`sveltekit`:return`src/lib/slices/`;default:return`slices/`}}function Hi(e){switch(e){case`next`:return[`.tsx`,`.ts`,`.jsx`,`.js`];case`nuxt`:return[`.vue`];case`sveltekit`:return[`.svelte`];default:return[`.tsx`,`.ts`,`.jsx`,`.js`]}}function Ui(e,t){switch(e.framework){case`next`:{let n=e.hasSrcDir?`src/app`:`app`;return t===`/slice-simulator`?{path:`${n}/slice-simulator/page`,extensions:[`.tsx`,`.ts`,`.jsx`,`.js`]}:t===`/api/preview`?{path:`${n}/api/preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/exit-preview`?{path:`${n}/api/exit-preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/revalidate`?{path:`${n}/api/revalidate/route`,extensions:[`.ts`,`.js`]}:null}case`nuxt`:return t===`/slice-simulator`?{path:`pages/slice-simulator`,extensions:[`.vue`]}:null;case`sveltekit`:return t===`/slice-simulator`?{path:`src/routes/slice-simulator/+page`,extensions:[`.svelte`]}:t===`/api/preview`?{path:`src/routes/api/preview/+server`,extensions:[`.ts`,`.js`]}:null;default:return null}}const Wi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Gi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ki(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":s,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
818
845
 
819
846
  USAGE
820
847
  prismic page-type add-field boolean <type-id> <field-id> [flags]
@@ -837,7 +864,7 @@ EXAMPLES
837
864
  prismic page-type add-field boolean article published --default
838
865
  prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!u){console.error(`Missing required argument: type-id
839
866
  `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
840
- `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(Li,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Boolean`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{default_value:!0},...o&&{placeholder_true:o},...s&&{placeholder_false:s}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await c(h,J(g))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Boolean) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Boolean) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await $();if(b?.framework){let e=Ri(b.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Bi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Vi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Hi(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
867
+ `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(Wi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Boolean`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{default_value:!0},...o&&{placeholder_true:o},...s&&{placeholder_false:s}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await c(h,J(g))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Boolean) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Boolean) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await $();if(b?.framework){let e=Gi(b.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const qi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Ji(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Yi(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
841
868
 
842
869
  USAGE
843
870
  prismic page-type add-field color <type-id> <field-id> [flags]
@@ -858,7 +885,7 @@ EXAMPLES
858
885
  prismic page-type add-field color homepage accent --tab "Design"
859
886
  prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!s){console.error(`Missing required argument: type-id
860
887
  `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
861
- `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(Bi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Color`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Color) to group "${u.groupId}" in ${s}`):console.info(`Added field "${l}" (Color) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=Vi(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Ui=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Wi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Gi(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:s},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
888
+ `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(qi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Color`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Color) to group "${u.groupId}" in ${s}`):console.info(`Added field "${l}" (Color) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=Ji(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const Xi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Zi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Qi(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:s},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
862
889
 
863
890
  USAGE
864
891
  prismic page-type add-field date <type-id> <field-id> [flags]
@@ -880,7 +907,7 @@ EXAMPLES
880
907
  prismic page-type add-field date event start_date --tab "Schedule"
881
908
  prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!l){console.error(`Missing required argument: type-id
882
909
  `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
883
- `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(Ui,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Date`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await c(m,J(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Date) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Date) to "${_}" tab in ${l}`);try{await U({output:s}),console.info(`Updated types in ${s??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await $();if(y?.framework){let e=Wi(y.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Ki=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function qi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ji(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
910
+ `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(Xi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Date`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await c(m,J(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Date) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Date) to "${_}" tab in ${l}`);try{await U({output:s}),console.info(`Updated types in ${s??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await $();if(y?.framework){let e=Zi(y.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const $i=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ea(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ta(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
884
911
 
885
912
  USAGE
886
913
  prismic page-type add-field embed <type-id> <field-id> [flags]
@@ -901,7 +928,7 @@ EXAMPLES
901
928
  prismic page-type add-field embed homepage youtube --tab "Media"
902
929
  prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!s){console.error(`Missing required argument: type-id
903
930
  `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
904
- `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(Ki,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Embed`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Embed) to group "${u.groupId}" in ${s}`):console.info(`Added field "${l}" (Embed) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=qi(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Yi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Xi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Zi(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
931
+ `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R($i,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Embed`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Embed) to group "${u.groupId}" in ${s}`):console.info(`Added field "${l}" (Embed) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=ea(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const na=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ra(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ia(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
905
932
 
906
933
  USAGE
907
934
  prismic page-type add-field geo-point <type-id> <field-id> [flags]
@@ -921,7 +948,7 @@ EXAMPLES
921
948
  prismic page-type add-field geo-point store address --tab "Details"
922
949
  prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!o){console.error(`Missing required argument: type-id
923
950
  `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!s){console.error(`Missing required argument: field-id
924
- `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await V(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${o}/index.json`,d),p;try{let e=await r(f,`utf8`),t=R(Yi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});let g={type:`GeoPoint`,config:{label:i??Y(l.type===`nested`?l.nestedFieldId:s)}};if(l.type===`nested`){let e=K(p.json[h],l.groupId,h);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=g}else{for(let[e,t]of Object.entries(p.json)){if(t[s]){console.error(`Field "${s}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[s]){console.error(`Field "${s}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}p.json[h][s]=g}try{await c(f,J(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (GeoPoint) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (GeoPoint) to "${h}" tab in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let _=await $();if(_?.framework){let e=Xi(_.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Qi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function $i(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ea(){let{values:{help:t,tab:n,label:i,"non-repeatable":a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing page type.
951
+ `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await V(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${o}/index.json`,d),p;try{let e=await r(f,`utf8`),t=R(na,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});let g={type:`GeoPoint`,config:{label:i??Y(l.type===`nested`?l.nestedFieldId:s)}};if(l.type===`nested`){let e=K(p.json[h],l.groupId,h);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=g}else{for(let[e,t]of Object.entries(p.json)){if(t[s]){console.error(`Field "${s}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[s]){console.error(`Field "${s}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}p.json[h][s]=g}try{await c(f,J(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (GeoPoint) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (GeoPoint) to "${h}" tab in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let _=await $();if(_?.framework){let e=ra(_.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const aa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function oa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function sa(){let{values:{help:t,tab:n,label:i,"non-repeatable":a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing page type.
925
952
 
926
953
  USAGE
927
954
  prismic page-type add-field group <type-id> <field-id> [flags]
@@ -942,7 +969,7 @@ EXAMPLES
942
969
  prismic page-type add-field group article authors --non-repeatable
943
970
  prismic page-type add-field group product variants --tab "Content"`);return}if(!s){console.error(`Missing required argument: type-id
944
971
  `),console.error(`Usage: prismic page-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
945
- `),console.error(`Usage: prismic page-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(l.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let u=await V(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${s}/index.json`,u),f;try{let e=await r(d,`utf8`),t=R(Qi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Group`,config:{label:i??Y(l),repeat:!a,fields:{}}};f.json[m][l]=h;try{await c(d,J(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Group) to "${m}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic page-type add-field <type> ${s} ${l}.<field-id>\``);let g=await $();if(g?.framework){let e=$i(g.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ta=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function na(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ra(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
972
+ `),console.error(`Usage: prismic page-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(l.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let u=await V(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${s}/index.json`,u),f;try{let e=await r(d,`utf8`),t=R(aa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Group`,config:{label:i??Y(l),repeat:!a,fields:{}}};f.json[m][l]=h;try{await c(d,J(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Group) to "${m}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic page-type add-field <type> ${s} ${l}.<field-id>\``);let g=await $();if(g?.framework){let e=oa(g.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const ca=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function la(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ua(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
946
973
 
947
974
  USAGE
948
975
  prismic page-type add-field image <type-id> <field-id> [flags]
@@ -963,7 +990,7 @@ EXAMPLES
963
990
  prismic page-type add-field image article thumbnail --tab "Media"
964
991
  prismic page-type add-field image product photo --label "Product Photo"`);return}if(!s){console.error(`Missing required argument: type-id
965
992
  `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
966
- `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ta,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Image`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Image) to group "${u.groupId}" in ${s}`):console.info(`Added field "${l}" (Image) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=na(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ia=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function aa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function oa(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing page type.
993
+ `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ca,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Image`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Image) to group "${u.groupId}" in ${s}`):console.info(`Added field "${l}" (Image) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=la(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const da=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function fa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function pa(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing page type.
967
994
 
968
995
  USAGE
969
996
  prismic page-type add-field key-text <type-id> <field-id> [flags]
@@ -984,7 +1011,7 @@ EXAMPLES
984
1011
  prismic page-type add-field key-text homepage meta_title --tab "SEO"
985
1012
  prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!s){console.error(`Missing required argument: type-id
986
1013
  `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
987
- `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ia,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Text`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Text) to group "${u.groupId}" in ${s}`):console.info(`Added field "${l}" (Text) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=aa(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const sa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ca(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function la(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":s,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
1014
+ `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(da,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Text`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Text) to group "${u.groupId}" in ${s}`):console.info(`Added field "${l}" (Text) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=fa(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const ma=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ha(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ga(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":s,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
988
1015
 
989
1016
  USAGE
990
1017
  prismic page-type add-field link <type-id> <field-id> [flags]
@@ -1010,7 +1037,7 @@ EXAMPLES
1010
1037
  prismic page-type add-field link homepage cta --variation Primary --variation Secondary
1011
1038
  prismic page-type add-field link homepage links --repeatable`);return}if(!f){console.error(`Missing required argument: type-id
1012
1039
  `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!p){console.error(`Missing required argument: field-id
1013
- `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=W(p),h=q(m);if(!h.ok){console.error(h.error),process.exitCode=1;return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${f}/index.json`,g),v;try{let e=await r(_,`utf8`),t=R(sa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${_.href}`),process.exitCode=1;return}v=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${f}\n`),console.error(`Create it first with: prismic page-type create ${f}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});let x={type:`Link`,config:{label:i??Y(m.type===`nested`?m.nestedFieldId:p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...s&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};if(m.type===`nested`){let e=K(v.json[b],m.groupId,b);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[m.nestedFieldId]){console.error(`Field "${m.nestedFieldId}" already exists in group "${m.groupId}"`),process.exitCode=1;return}e.group.config.fields[m.nestedFieldId]=x}else{for(let[e,t]of Object.entries(v.json)){if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[p]){console.error(`Field "${p}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}v.json[b][p]=x}try{await c(_,J(v))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}m.type===`nested`?console.info(`Added field "${m.nestedFieldId}" (Link) to group "${m.groupId}" in ${f}`):console.info(`Added field "${p}" (Link) to "${b}" tab in ${f}`);try{await U({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let S=await $();if(S?.framework){let e=ca(S.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ua=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function da(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function fa(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:s,step:l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
1040
+ `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=W(p),h=q(m);if(!h.ok){console.error(h.error),process.exitCode=1;return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${f}/index.json`,g),v;try{let e=await r(_,`utf8`),t=R(ma,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${_.href}`),process.exitCode=1;return}v=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${f}\n`),console.error(`Create it first with: prismic page-type create ${f}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});let x={type:`Link`,config:{label:i??Y(m.type===`nested`?m.nestedFieldId:p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...s&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};if(m.type===`nested`){let e=K(v.json[b],m.groupId,b);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[m.nestedFieldId]){console.error(`Field "${m.nestedFieldId}" already exists in group "${m.groupId}"`),process.exitCode=1;return}e.group.config.fields[m.nestedFieldId]=x}else{for(let[e,t]of Object.entries(v.json)){if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[p]){console.error(`Field "${p}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}v.json[b][p]=x}try{await c(_,J(v))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}m.type===`nested`?console.info(`Added field "${m.nestedFieldId}" (Link) to group "${m.groupId}" in ${f}`):console.info(`Added field "${p}" (Link) to "${b}" tab in ${f}`);try{await U({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let S=await $();if(S?.framework){let e=ha(S.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const _a=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function va(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ya(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:s,step:l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
1014
1041
 
1015
1042
  USAGE
1016
1043
  prismic page-type add-field number <type-id> <field-id> [flags]
@@ -1034,7 +1061,7 @@ EXAMPLES
1034
1061
  prismic page-type add-field number product quantity --min 0 --max 100
1035
1062
  prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!d){console.error(`Missing required argument: type-id
1036
1063
  `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
1037
- `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=o===void 0?void 0:Number(o),g=s===void 0?void 0:Number(s),_=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(h)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(s!==void 0&&Number.isNaN(g)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(_)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let v=await V(`package.json`);if(!v){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let y=new URL(`customtypes/${d}/index.json`,v),b;try{let e=await r(y,`utf8`),t=R(ua,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${y.href}`),process.exitCode=1;return}b=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let x=Object.keys(b.json),S=n??x[0]??`Main`;b.json[S]||(b.json[S]={});let ee={type:`Number`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...h!==void 0&&{min:h},...g!==void 0&&{max:g},..._!==void 0&&{step:_}}};if(p.type===`nested`){let e=K(b.json[S],p.groupId,S);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=ee}else{for(let[e,t]of Object.entries(b.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}b.json[S][f]=ee}try{await c(y,J(b))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (Number) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (Number) to "${S}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let te=await $();if(te?.framework){let e=da(te.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const pa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ma(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ha(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:s,"allow-target-blank":l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
1064
+ `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=o===void 0?void 0:Number(o),g=s===void 0?void 0:Number(s),_=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(h)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(s!==void 0&&Number.isNaN(g)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(_)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let v=await V(`package.json`);if(!v){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let y=new URL(`customtypes/${d}/index.json`,v),b;try{let e=await r(y,`utf8`),t=R(_a,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${y.href}`),process.exitCode=1;return}b=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let x=Object.keys(b.json),S=n??x[0]??`Main`;b.json[S]||(b.json[S]={});let ee={type:`Number`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...h!==void 0&&{min:h},...g!==void 0&&{max:g},..._!==void 0&&{step:_}}};if(p.type===`nested`){let e=K(b.json[S],p.groupId,S);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=ee}else{for(let[e,t]of Object.entries(b.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}b.json[S][f]=ee}try{await c(y,J(b))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (Number) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (Number) to "${S}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let te=await $();if(te?.framework){let e=va(te.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const ba=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function xa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Sa(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:s,"allow-target-blank":l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
1038
1065
 
1039
1066
  USAGE
1040
1067
  prismic page-type add-field rich-text <type-id> <field-id> [flags]
@@ -1064,7 +1091,7 @@ EXAMPLES
1064
1091
  prismic page-type add-field rich-text page tagline --single "heading1"
1065
1092
  prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!d){console.error(`Missing required argument: type-id
1066
1093
  `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
1067
- `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=await V(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${d}/index.json`,h),_;try{let e=await r(g,`utf8`),t=R(pa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});let b={type:`StructuredText`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...o&&{single:o},...s&&{multi:s},...l&&{allowTargetBlank:!0}}};if(p.type===`nested`){let e=K(_.json[y],p.groupId,y);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=b}else{for(let[e,t]of Object.entries(_.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}_.json[y][f]=b}try{await c(g,J(_))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (StructuredText) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (StructuredText) to "${y}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let x=await $();if(x?.framework){let e=ma(x.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ga=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function _a(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function va(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:s,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
1094
+ `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=await V(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${d}/index.json`,h),_;try{let e=await r(g,`utf8`),t=R(ba,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});let b={type:`StructuredText`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...o&&{single:o},...s&&{multi:s},...l&&{allowTargetBlank:!0}}};if(p.type===`nested`){let e=K(_.json[y],p.groupId,y);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=b}else{for(let[e,t]of Object.entries(_.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}_.json[y][f]=b}try{await c(g,J(_))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (StructuredText) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (StructuredText) to "${y}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let x=await $();if(x?.framework){let e=xa(x.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const Ca=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function wa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ta(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:s,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
1068
1095
 
1069
1096
  USAGE
1070
1097
  prismic page-type add-field select <type-id> <field-id> [flags]
@@ -1087,7 +1114,7 @@ EXAMPLES
1087
1114
  prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
1088
1115
  prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!u){console.error(`Missing required argument: type-id
1089
1116
  `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
1090
- `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(ga,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Select`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...s&&{default_value:s}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await c(h,J(g))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Select) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Select) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await $();if(b?.framework){let e=_a(b.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ya=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ba(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function xa(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:s},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing page type.
1117
+ `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(Ca,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Select`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...s&&{default_value:s}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await c(h,J(g))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Select) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Select) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await $();if(b?.framework){let e=wa(b.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const Ea=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Da(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Oa(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:s},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing page type.
1091
1118
 
1092
1119
  USAGE
1093
1120
  prismic page-type add-field timestamp <type-id> <field-id> [flags]
@@ -1109,7 +1136,7 @@ EXAMPLES
1109
1136
  prismic page-type add-field timestamp event start --tab "Schedule"
1110
1137
  prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!l){console.error(`Missing required argument: type-id
1111
1138
  `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
1112
- `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(ya,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Timestamp`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await c(m,J(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Timestamp) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Timestamp) to "${_}" tab in ${l}`);try{await U({output:s}),console.info(`Updated types in ${s??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await $();if(y?.framework){let e=ba(y.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Sa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Ca(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function wa(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
1139
+ `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(Ea,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Timestamp`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await c(m,J(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Timestamp) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Timestamp) to "${_}" tab in ${l}`);try{await U({output:s}),console.info(`Updated types in ${s??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await $();if(y?.framework){let e=Da(y.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const ka=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Aa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ja(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[s,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
1113
1140
 
1114
1141
  USAGE
1115
1142
  prismic page-type add-field uid <type-id> <field-id> [flags]
@@ -1130,7 +1157,7 @@ EXAMPLES
1130
1157
  prismic page-type add-field uid article slug --label "URL Slug"
1131
1158
  prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!s){console.error(`Missing required argument: type-id
1132
1159
  `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
1133
- `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}if(u.type===`nested`){console.error(`UID fields cannot be nested inside groups`),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(Sa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`UID`,config:{label:i??Y(l),...a&&{placeholder:a}}};m.json[g][l]=_;try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (UID) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=Ca(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}async function Ta(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await zi();break;case`color`:await Hi();break;case`date`:await Gi();break;case`embed`:await Ji();break;case`geo-point`:await Zi();break;case`group`:await ea();break;case`image`:await ra();break;case`key-text`:await oa();break;case`link`:await la();break;case`number`:await fa();break;case`rich-text`:await ha();break;case`select`:await va();break;case`timestamp`:await xa();break;case`uid`:await wa();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
1160
+ `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}if(u.type===`nested`){console.error(`UID fields cannot be nested inside groups`),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${s}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ka,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${s}\n`),console.error(`Create it first with: prismic page-type create ${s}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`UID`,config:{label:i??Y(l),...a&&{placeholder:a}}};m.json[g][l]=_;try{await c(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (UID) to "${g}" tab in ${s}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=Aa(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}async function Ma(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Ki();break;case`color`:await Yi();break;case`date`:await Qi();break;case`embed`:await ta();break;case`geo-point`:await ia();break;case`group`:await sa();break;case`image`:await ua();break;case`key-text`:await pa();break;case`link`:await ga();break;case`number`:await ya();break;case`rich-text`:await Sa();break;case`select`:await Ta();break;case`timestamp`:await Oa();break;case`uid`:await ja();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
1134
1161
 
1135
1162
  USAGE
1136
1163
  prismic page-type add-field <field-type> <type-id> <field-id> [flags]
@@ -1161,7 +1188,7 @@ EXAMPLES
1161
1188
  prismic page-type add-field key-text homepage meta_title --tab "SEO"
1162
1189
  prismic page-type add-field link homepage button --allow-text
1163
1190
  prismic page-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
1164
- prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Ea=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Da(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
1191
+ prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Na=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Pa(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
1165
1192
 
1166
1193
  USAGE
1167
1194
  prismic page-type connect-slice <type-id> <slice-id> [flags]
@@ -1180,7 +1207,7 @@ EXAMPLES
1180
1207
  prismic page-type connect-slice homepage CallToAction --slice-zone slices
1181
1208
  prismic page-type connect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
1182
1209
  `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
1183
- `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let s=await H(o);if(!s.ok){console.error(s.error),process.exitCode=1;return}let l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=R(Ea,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in page type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;try{await c(u,J(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function Oa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ka(e){return`#write-page-components`}async function Aa(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
1210
+ `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let s=await H(o);if(!s.ok){console.error(s.error),process.exitCode=1;return}let l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=R(Na,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in page type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;try{await c(u,J(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function Fa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ia(e){return`#write-page-components`}async function La(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
1184
1211
 
1185
1212
  USAGE
1186
1213
  prismic page-type create <id> [flags]
@@ -1195,7 +1222,7 @@ FLAGS
1195
1222
  -h, --help Show help for command
1196
1223
 
1197
1224
  LEARN MORE
1198
- Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let s={id:o,label:r??ja(o),repeatable:!i,status:!0,format:`page`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}},l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await c(f,J(s))}catch(e){e instanceof Error?console.error(`Failed to create page type: ${e.message}`):console.error(`Failed to create page type`),process.exitCode=1;return}console.info(`Created page type at ${f.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic page-type add-field`");let p=await $();if(p?.framework){let e=Oa(p.framework),t=ka(p.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement a page file`)}}function ja(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ma=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Na(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
1225
+ Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let s={id:o,label:r??Ra(o),repeatable:!i,status:!0,format:`page`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}},l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await c(f,J(s))}catch(e){e instanceof Error?console.error(`Failed to create page type: ${e.message}`):console.error(`Failed to create page type`),process.exitCode=1;return}console.info(`Created page type at ${f.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic page-type add-field`");let p=await $();if(p?.framework){let e=Fa(p.framework),t=Ia(p.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement a page file`)}}function Ra(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const za=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Ba(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
1199
1226
 
1200
1227
  USAGE
1201
1228
  prismic page-type disconnect-slice <type-id> <slice-id> [flags]
@@ -1214,7 +1241,7 @@ EXAMPLES
1214
1241
  prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
1215
1242
  prismic page-type disconnect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
1216
1243
  `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
1217
- `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,s),u;try{let e=await r(l,`utf8`),t=R(Ma,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){console.error(`Slice zone "${d}" not found in page type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];try{await c(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Pa=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Fa(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all page types in a Prismic project.
1244
+ `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,s),u;try{let e=await r(l,`utf8`),t=R(za,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){console.error(`Slice zone "${d}" not found in page type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];try{await c(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Va=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ha(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all page types in a Prismic project.
1218
1245
 
1219
1246
  USAGE
1220
1247
  prismic page-type list [flags]
@@ -1225,7 +1252,7 @@ FLAGS
1225
1252
 
1226
1253
  EXAMPLES
1227
1254
  prismic page-type list
1228
- prismic page-type list --json`);return}let a=await V(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=R(Pa,JSON.parse(e));n.success&&n.output.format===`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Ia=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function La(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
1255
+ prismic page-type list --json`);return}let a=await V(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=R(Va,JSON.parse(e));n.success&&n.output.format===`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Ua=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Wa(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
1229
1256
 
1230
1257
  USAGE
1231
1258
  prismic page-type remove <type-id> [flags]
@@ -1241,7 +1268,7 @@ FLAGS
1241
1268
  EXAMPLES
1242
1269
  prismic page-type remove homepage
1243
1270
  prismic page-type remove homepage -y`);return}if(!a){console.error(`Missing required argument: type-id
1244
- `),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=R(Ia,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove page type: ${e.message}`):console.error(`Failed to remove page type`),process.exitCode=1;return}console.info(`Removed page type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ra=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function za(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
1271
+ `),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=R(Ua,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove page type: ${e.message}`):console.error(`Failed to remove page type`),process.exitCode=1;return}console.info(`Removed page type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ga=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ka(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
1245
1272
 
1246
1273
  USAGE
1247
1274
  prismic page-type remove-field <type-id> <field-id> [flags]
@@ -1259,7 +1286,7 @@ EXAMPLES
1259
1286
  prismic page-type remove-field homepage title
1260
1287
  prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!a){console.error(`Missing required argument: type-id
1261
1288
  `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1262
- `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,s),u;try{let e=await r(l,`utf8`),t=R(Ra,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in page type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of page type "${a}"`),process.exitCode=1;return}}try{await c(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Removed field "${o}" from tab "${d}" in page type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ba=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Va(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
1289
+ `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,s),u;try{let e=await r(l,`utf8`),t=R(Ga,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in page type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of page type "${a}"`),process.exitCode=1;return}}try{await c(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Removed field "${o}" from tab "${d}" in page type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const qa=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ja(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
1263
1290
 
1264
1291
  USAGE
1265
1292
  prismic page-type set-name <type-id> <new-name> [flags]
@@ -1276,7 +1303,7 @@ EXAMPLES
1276
1303
  prismic page-type set-name homepage "Home Page"
1277
1304
  prismic page-type set-name blog_post "Blog Post"`);return}if(!i){console.error(`Missing required argument: type-id
1278
1305
  `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: new-name
1279
- `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await V(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(s,`utf8`),t=R(Ba,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${s.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}l.label=a;try{await c(s,J(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Renamed page type "${i}" to "${a}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ha=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ua(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
1306
+ `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await V(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(s,`utf8`),t=R(qa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${s.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}l.label=a;try{await c(s,J(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Renamed page type "${i}" to "${a}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ya=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Xa(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
1280
1307
 
1281
1308
  USAGE
1282
1309
  prismic page-type set-repeatable <type-id> <true|false> [flags]
@@ -1293,7 +1320,7 @@ EXAMPLES
1293
1320
  prismic page-type set-repeatable homepage true
1294
1321
  prismic page-type set-repeatable settings false`);return}if(!i){console.error(`Missing required argument: type-id
1295
1322
  `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: true|false
1296
- `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(a!==`true`&&a!==`false`){console.error(`Invalid value: "${a}". Must be "true" or "false".`),process.exitCode=1;return}let o=a===`true`,s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,s),u;try{let e=await r(l,`utf8`),t=R(Ha,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${i}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}u.repeatable=o;try{await c(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}let d=o?`repeatable`:`singleton`;console.info(`Set page type "${i}" to ${d}`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Wa=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ga(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific page type.
1323
+ `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(a!==`true`&&a!==`false`){console.error(`Invalid value: "${a}". Must be "true" or "false".`),process.exitCode=1;return}let o=a===`true`,s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,s),u;try{let e=await r(l,`utf8`),t=R(Ya,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${i}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}u.repeatable=o;try{await c(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}let d=o?`repeatable`:`singleton`;console.info(`Set page type "${i}" to ${d}`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Za=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Qa(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific page type.
1297
1324
 
1298
1325
  USAGE
1299
1326
  prismic page-type view <type-id> [flags]
@@ -1308,7 +1335,7 @@ FLAGS
1308
1335
  EXAMPLES
1309
1336
  prismic page-type view homepage
1310
1337
  prismic page-type view homepage --json`);return}if(!i){console.error(`Missing required argument: type-id
1311
- `),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await V(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=R(Wa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(s.format!==`page`){console.error(`"${i}" is not a page type (format: ${s.format??`custom`})`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function Ka(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Aa();break;case`list`:await Fa();break;case`view`:await Ga();break;case`remove`:await La();break;case`set-name`:await Va();break;case`set-repeatable`:await Ua();break;case`add-field`:await Ta();break;case`remove-field`:await za();break;case`connect-slice`:await Da();break;case`disconnect-slice`:await Na();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
1338
+ `),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await V(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=R(Za,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(s.format!==`page`){console.error(`"${i}" is not a page type (format: ${s.format??`custom`})`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function $a(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await La();break;case`list`:await Ha();break;case`view`:await Qa();break;case`remove`:await Wa();break;case`set-name`:await Ja();break;case`set-repeatable`:await Xa();break;case`add-field`:await Ma();break;case`remove-field`:await Ka();break;case`connect-slice`:await Pa();break;case`disconnect-slice`:await Ba();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
1312
1339
 
1313
1340
  USAGE
1314
1341
  prismic page-type <command> [flags]
@@ -1329,7 +1356,7 @@ FLAGS
1329
1356
  -h, --help Show help for command
1330
1357
 
1331
1358
  LEARN MORE
1332
- Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function qa(){let{values:{help:t,name:n,repo:r=await X()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a preview configuration to a Prismic repository.
1359
+ Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function eo(){let{values:{help:t,name:n,repo:r=await X()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a preview configuration to a Prismic repository.
1333
1360
 
1334
1361
  By default, this command reads the repository from prismic.config.json at the
1335
1362
  project root.
@@ -1346,7 +1373,7 @@ FLAGS
1346
1373
  -h, --help Show help for command
1347
1374
 
1348
1375
  LEARN MORE
1349
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Xa();return}let a=Ja(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await Ya(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof Q?Xa():(console.error(`Failed to add preview: ${J(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function Ja(e){try{let t=new URL(e);return{websiteURL:`${t.protocol}//${t.host}`,resolverPath:t.pathname===`/`?void 0:t.pathname,hostname:t.hostname}}catch{return}}async function Ya(e,t){return await Z(new URL(`/previews/new`,await z(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function Xa(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Za(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the slice simulator URL for a Prismic repository.
1376
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ro();return}let a=to(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await no(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof Q?ro():(console.error(`Failed to add preview: ${J(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function to(e){try{let t=new URL(e);return{websiteURL:`${t.protocol}//${t.host}`,resolverPath:t.pathname===`/`?void 0:t.pathname,hostname:t.hostname}}catch{return}}async function no(e,t){return await Z(new URL(`/previews/new`,await z(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function ro(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function io(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the slice simulator URL for a Prismic repository.
1350
1377
 
1351
1378
  By default, this command reads the repository from prismic.config.json at the
1352
1379
  project root.
@@ -1360,7 +1387,7 @@ FLAGS
1360
1387
  -h, --help Show help for command
1361
1388
 
1362
1389
  LEARN MORE
1363
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){eo();return}let i=await $a(n);if(!i.ok){i.error instanceof Q?eo():A(i.error)?(console.error(`Failed to get simulator URL: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to get simulator URL: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.simulator_url;if(!a){r?console.info(J({simulator_url:null})):console.info(`No simulator URL configured.`);return}r?console.info(J({simulator_url:a})):console.info(a)}const Qa=N({simulator_url:P(I())});async function $a(e){return await Z(new URL(`/core/repository`,await z(e)),{schema:Qa})}function eo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function to(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all preview configurations in a Prismic repository.
1390
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){so();return}let i=await oo(n);if(!i.ok){i.error instanceof Q?so():A(i.error)?(console.error(`Failed to get simulator URL: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to get simulator URL: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.simulator_url;if(!a){r?console.info(J({simulator_url:null})):console.info(`No simulator URL configured.`);return}r?console.info(J({simulator_url:a})):console.info(a)}const ao=N({simulator_url:P(I())});async function oo(e){return await Z(new URL(`/core/repository`,await z(e)),{schema:ao})}function so(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function co(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all preview configurations in a Prismic repository.
1364
1391
 
1365
1392
  By default, this command reads the repository from prismic.config.json at the
1366
1393
  project root.
@@ -1374,7 +1401,7 @@ FLAGS
1374
1401
  -h, --help Show help for command
1375
1402
 
1376
1403
  LEARN MORE
1377
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){io();return}let i=await ro(n);if(!i.ok){i.error instanceof Q?io():A(i.error)?(console.error(`Failed to list previews: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(J(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const no=N({results:j(N({id:I(),label:I(),url:I()}))});async function ro(e){return await Z(new URL(`/core/repository/preview_configs`,await z(e)),{schema:no})}function io(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ao(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a preview configuration from a Prismic repository.
1404
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){fo();return}let i=await uo(n);if(!i.ok){i.error instanceof Q?fo():A(i.error)?(console.error(`Failed to list previews: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(J(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const lo=N({results:j(N({id:I(),label:I(),url:I()}))});async function uo(e){return await Z(new URL(`/core/repository/preview_configs`,await z(e)),{schema:lo})}function fo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function po(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a preview configuration from a Prismic repository.
1378
1405
 
1379
1406
  By default, this command reads the repository from prismic.config.json at the
1380
1407
  project root.
@@ -1390,7 +1417,7 @@ FLAGS
1390
1417
  -h, --help Show help for command
1391
1418
 
1392
1419
  LEARN MORE
1393
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){so();return}let i=await ro(n);if(!i.ok){i.error instanceof Q?so():(console.error(`Failed to fetch previews: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results.find(e=>e.url===r);if(!a){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let o=await oo(n,a.id);if(!o.ok){o.error instanceof Q?so():(console.error(`Failed to remove preview: ${J(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function oo(e,t){return await Z(new URL(`/previews/delete/${t}`,await z(e)),{method:`POST`,body:{}})}function so(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function co(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Remove the slice simulator URL from a Prismic repository.
1420
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ho();return}let i=await uo(n);if(!i.ok){i.error instanceof Q?ho():(console.error(`Failed to fetch previews: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results.find(e=>e.url===r);if(!a){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let o=await mo(n,a.id);if(!o.ok){o.error instanceof Q?ho():(console.error(`Failed to remove preview: ${J(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function mo(e,t){return await Z(new URL(`/previews/delete/${t}`,await z(e)),{method:`POST`,body:{}})}function ho(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function go(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Remove the slice simulator URL from a Prismic repository.
1394
1421
 
1395
1422
  By default, this command reads the repository from prismic.config.json at the
1396
1423
  project root.
@@ -1403,7 +1430,7 @@ FLAGS
1403
1430
  -h, --help Show help for command
1404
1431
 
1405
1432
  LEARN MORE
1406
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){uo();return}let r=await lo(n);if(!r.ok){r.error instanceof Q?uo():(console.error(`Failed to remove simulator URL: ${J(r.value)}`),process.exitCode=1);return}console.info(`Simulator URL removed.`)}async function lo(e){return await Z(new URL(`/core/repository`,await z(e)),{method:`PATCH`,body:{simulator_url:``}})}function uo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function fo(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update the name of a preview configuration.
1433
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){vo();return}let r=await _o(n);if(!r.ok){r.error instanceof Q?vo():(console.error(`Failed to remove simulator URL: ${J(r.value)}`),process.exitCode=1);return}console.info(`Simulator URL removed.`)}async function _o(e){return await Z(new URL(`/core/repository`,await z(e)),{method:`PATCH`,body:{simulator_url:``}})}function vo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yo(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update the name of a preview configuration.
1407
1434
 
1408
1435
  By default, this command reads the repository from prismic.config.json at the
1409
1436
  project root.
@@ -1420,7 +1447,7 @@ FLAGS
1420
1447
  -h, --help Show help for command
1421
1448
 
1422
1449
  LEARN MORE
1423
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){mo();return}let a=Ja(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await ro(n);if(!o.ok){o.error instanceof Q?mo():(console.error(`Failed to fetch previews: ${J(o.value)}`),process.exitCode=1);return}let s=o.value.results.find(e=>e.url===r);if(!s){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let c=await po(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof Q?mo():(console.error(`Failed to update preview: ${J(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function po(e,t,n){return await Z(new URL(`/previews/save/${t}`,await z(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function mo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ho(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the slice simulator URL for a Prismic repository.
1450
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){xo();return}let a=to(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await uo(n);if(!o.ok){o.error instanceof Q?xo():(console.error(`Failed to fetch previews: ${J(o.value)}`),process.exitCode=1);return}let s=o.value.results.find(e=>e.url===r);if(!s){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let c=await bo(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof Q?xo():(console.error(`Failed to update preview: ${J(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function bo(e,t,n){return await Z(new URL(`/previews/save/${t}`,await z(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function xo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function So(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the slice simulator URL for a Prismic repository.
1424
1451
 
1425
1452
  If the URL pathname does not end with /slice-simulator, it is appended
1426
1453
  automatically.
@@ -1443,7 +1470,7 @@ EXAMPLES
1443
1470
  prismic preview set-simulator http://localhost:3000/slice-simulator
1444
1471
 
1445
1472
  LEARN MORE
1446
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){vo();return}let i=go(r);if(!i){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let a=await _o(n,i);if(!a.ok){a.error instanceof Q?vo():(console.error(`Failed to set simulator URL: ${J(a.value)}`),process.exitCode=1);return}console.info(`Simulator URL set: ${i}`)}function go(e){try{let t=new URL(e);return t.pathname.endsWith(`/slice-simulator`)||(t.pathname=t.pathname.replace(/\/+$/,``)+`/slice-simulator`),t.toString()}catch{return}}async function _o(e,t){return await Z(new URL(`/core/repository`,await z(e)),{method:`PATCH`,body:{simulator_url:t}})}function vo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await qa();break;case`list`:await to();break;case`remove`:await ao();break;case`set-name`:await fo();break;case`set-simulator`:await ho();break;case`get-simulator`:await Za();break;case`remove-simulator`:await co();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
1473
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){To();return}let i=Co(r);if(!i){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let a=await wo(n,i);if(!a.ok){a.error instanceof Q?To():(console.error(`Failed to set simulator URL: ${J(a.value)}`),process.exitCode=1);return}console.info(`Simulator URL set: ${i}`)}function Co(e){try{let t=new URL(e);return t.pathname.endsWith(`/slice-simulator`)||(t.pathname=t.pathname.replace(/\/+$/,``)+`/slice-simulator`),t.toString()}catch{return}}async function wo(e,t){return await Z(new URL(`/core/repository`,await z(e)),{method:`PATCH`,body:{simulator_url:t}})}function To(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Eo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await eo();break;case`list`:await co();break;case`remove`:await po();break;case`set-name`:await yo();break;case`set-simulator`:await So();break;case`get-simulator`:await io();break;case`remove-simulator`:await go();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
1447
1474
 
1448
1475
  USAGE
1449
1476
  prismic preview <command> [flags]
@@ -1461,7 +1488,7 @@ FLAGS
1461
1488
  -h, --help Show help for command
1462
1489
 
1463
1490
  LEARN MORE
1464
- Use \`prismic preview <command> --help\` for more information about a command.`)}}async function bo(){let{values:{help:t,repo:r=await X(),"dry-run":i,"types-only":a,"slices-only":o,json:s,types:l}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},json:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Pull custom types and slices from Prismic to local files.
1491
+ Use \`prismic preview <command> --help\` for more information about a command.`)}}async function Do(){let{values:{help:t,repo:r=await X(),"dry-run":i,"types-only":a,"slices-only":o,json:s,types:l}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},json:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Pull custom types and slices from Prismic to local files.
1465
1492
 
1466
1493
  By default, this command reads the repository from prismic.config.json at the
1467
1494
  project root.
@@ -1482,9 +1509,9 @@ EXAMPLES
1482
1509
  prismic pull
1483
1510
  prismic pull --repo my-repo
1484
1511
  prismic pull --dry-run
1485
- prismic pull --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}s||console.info(`Pulling from repository: ${r}\n`);let u=!o,d=!a,[f,p]=await Promise.all([u?Vn(r):Promise.resolve({ok:!0,value:[]}),d?Hn(r):Promise.resolve({ok:!0,value:[]})]);if(!f.ok){console.error(`Failed to fetch custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch slices: ${p.error}`),process.exitCode=1;return}let m=f.value,h=p.value;if(s||(u&&console.info(`Fetching custom types... ${m.length} types`),d&&console.info(`Fetching slices... ${h.length} slices`)),i){if(s)console.info(J({customTypes:m,slices:h}));else{if(console.info(``),u&&m.length>0){console.info(`Would write custom types:`);for(let e of m)console.info(` customtypes/${e.id}/index.json`)}if(d&&h.length>0){let e=xo(await Fn());console.info(`Would write slices:`);for(let t of h)console.info(` ${e}${Rn(t.name)}/model.json`)}console.info(`\nDry run complete: ${m.length} custom types, ${h.length} slices`)}return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`.`,g),v=[],y=[];if(u&&m.length>0){s||console.info(`
1512
+ prismic pull --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}s||console.info(`Pulling from repository: ${r}\n`);let u=!o,d=!a,[f,p]=await Promise.all([u?Vn(r):Promise.resolve({ok:!0,value:[]}),d?Hn(r):Promise.resolve({ok:!0,value:[]})]);if(!f.ok){console.error(`Failed to fetch custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch slices: ${p.error}`),process.exitCode=1;return}let m=f.value,h=p.value;if(s||(u&&console.info(`Fetching custom types... ${m.length} types`),d&&console.info(`Fetching slices... ${h.length} slices`)),i){if(s)console.info(J({customTypes:m,slices:h}));else{if(console.info(``),u&&m.length>0){console.info(`Would write custom types:`);for(let e of m)console.info(` customtypes/${e.id}/index.json`)}if(d&&h.length>0){let e=Oo(await Fn());console.info(`Would write slices:`);for(let t of h)console.info(` ${e}${Rn(t.name)}/model.json`)}console.info(`\nDry run complete: ${m.length} custom types, ${h.length} slices`)}return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`.`,g),v=[],y=[];if(u&&m.length>0){s||console.info(`
1486
1513
  Writing custom types:`);let e=new URL(`customtypes/`,_);for(let t of m){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await c(i,J(t));let e=`customtypes/${t.id}/index.json`;v.push(e),s||console.info(` ${e}`)}catch(e){console.error(`Failed to write custom type ${t.id}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(d&&h.length>0){s||console.info(`
1487
- Writing slices:`);let e=await Fn();for(let t of h){let r=new URL(`${Rn(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await c(i,J(t));let a=`${xo(e)}${Rn(t.name)}/model.json`;y.push(a),s||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(s?console.info(J({writtenTypes:v,writtenSlices:y})):console.info(`\nPull complete: ${v.length} custom types, ${y.length} slices`),!s)try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function xo(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function So(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[],a=[],o=[];for(let t of e){let e=r.get(t.id);e?JSON.stringify(t)!==JSON.stringify(e)&&a.push(t):i.push(t)}for(let e of t)n.has(e.id)||o.push(e.id);return{toInsert:i,toUpdate:a,toDelete:o}}async function Co(){let{values:{help:t,repo:n=await X(),"dry-run":r,"types-only":i,"slices-only":a,delete:o,json:s}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},delete:{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Push custom types and slices to Prismic from local files.
1514
+ Writing slices:`);let e=await Fn();for(let t of h){let r=new URL(`${Rn(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await c(i,J(t));let a=`${Oo(e)}${Rn(t.name)}/model.json`;y.push(a),s||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(s?console.info(J({writtenTypes:v,writtenSlices:y})):console.info(`\nPull complete: ${v.length} custom types, ${y.length} slices`),!s)try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function Oo(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function ko(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[],a=[],o=[];for(let t of e){let e=r.get(t.id);e?JSON.stringify(t)!==JSON.stringify(e)&&a.push(t):i.push(t)}for(let e of t)n.has(e.id)||o.push(e.id);return{toInsert:i,toUpdate:a,toDelete:o}}async function Ao(){let{values:{help:t,repo:n=await X(),"dry-run":r,"types-only":i,"slices-only":a,delete:o,json:s}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},delete:{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Push custom types and slices to Prismic from local files.
1488
1515
 
1489
1516
  By default, this command reads the repository from prismic.config.json at the
1490
1517
  project root.
@@ -1506,10 +1533,10 @@ EXAMPLES
1506
1533
  prismic push --repo my-repo
1507
1534
  prismic push --dry-run
1508
1535
  prismic push --types-only
1509
- prismic push --delete`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}s||console.info(`Pushing to repository: ${n}\n`);let c=!a,l=!i,[u,d,f,p]=await Promise.all([c?Un():Promise.resolve({ok:!0,value:[]}),l?Wn():Promise.resolve({ok:!0,value:[]}),c?Vn(n):Promise.resolve({ok:!0,value:[]}),l?Hn(n):Promise.resolve({ok:!0,value:[]})]);if(!u.ok){console.error(`Failed to read local custom types: ${u.error}`),process.exitCode=1;return}if(!d.ok){console.error(`Failed to read local slices: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch remote custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch remote slices: ${p.error}`),process.exitCode=1;return}let m=u.value,h=d.value,g=f.value,_=p.value;s||(c&&(console.info(`Local custom types: ${m.length}`),console.info(`Remote custom types: ${g.length}`)),l&&(console.info(`Local slices: ${h.length}`),console.info(`Remote slices: ${_.length}`)));let v=c?So([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?So([...h],[..._]):{toInsert:[],toUpdate:[],toDelete:[]};o||(v.toDelete=[],y.toDelete=[]);let b=v.toInsert.length+v.toUpdate.length+v.toDelete.length+y.toInsert.length+y.toUpdate.length+y.toDelete.length;if(b===0){s?console.info(J({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
1536
+ prismic push --delete`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}s||console.info(`Pushing to repository: ${n}\n`);let c=!a,l=!i,[u,d,f,p]=await Promise.all([c?Un():Promise.resolve({ok:!0,value:[]}),l?Wn():Promise.resolve({ok:!0,value:[]}),c?Vn(n):Promise.resolve({ok:!0,value:[]}),l?Hn(n):Promise.resolve({ok:!0,value:[]})]);if(!u.ok){console.error(`Failed to read local custom types: ${u.error}`),process.exitCode=1;return}if(!d.ok){console.error(`Failed to read local slices: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch remote custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch remote slices: ${p.error}`),process.exitCode=1;return}let m=u.value,h=d.value,g=f.value,_=p.value;s||(c&&(console.info(`Local custom types: ${m.length}`),console.info(`Remote custom types: ${g.length}`)),l&&(console.info(`Local slices: ${h.length}`),console.info(`Remote slices: ${_.length}`)));let v=c?ko([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?ko([...h],[..._]):{toInsert:[],toUpdate:[],toDelete:[]};o||(v.toDelete=[],y.toDelete=[]);let b=v.toInsert.length+v.toUpdate.length+v.toDelete.length+y.toInsert.length+y.toUpdate.length+y.toDelete.length;if(b===0){s?console.info(J({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
1510
1537
  No changes to push.`);return}if(r){if(s)console.info(J({customTypes:{toInsert:v.toInsert.map(e=>e.id),toUpdate:v.toUpdate.map(e=>e.id),toDelete:v.toDelete},slices:{toInsert:y.toInsert.map(e=>e.id),toUpdate:y.toUpdate.map(e=>e.id),toDelete:y.toDelete}}));else{if(console.info(``),c){if(v.toInsert.length>0){console.info(`Would insert custom types:`);for(let e of v.toInsert)console.info(` + ${e.id}`)}if(v.toUpdate.length>0){console.info(`Would update custom types:`);for(let e of v.toUpdate)console.info(` ~ ${e.id}`)}if(v.toDelete.length>0){console.info(`Would delete custom types:`);for(let e of v.toDelete)console.info(` - ${e}`)}}if(l){if(y.toInsert.length>0){console.info(`Would insert slices:`);for(let e of y.toInsert)console.info(` + ${e.id}`)}if(y.toUpdate.length>0){console.info(`Would update slices:`);for(let e of y.toUpdate)console.info(` ~ ${e.id}`)}if(y.toDelete.length>0){console.info(`Would delete slices:`);for(let e of y.toDelete)console.info(` - ${e}`)}}console.info(`\nDry run complete: ${b} changes would be made`)}return}let x={customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}};if(c){!s&&(v.toInsert.length>0||v.toUpdate.length>0||v.toDelete.length>0)&&console.info(`
1511
1538
  Pushing custom types:`);for(let e of v.toInsert){let t=await Gn(n,e);if(!t.ok){console.error(`Failed to insert custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of v.toUpdate){let t=await Kn(n,e);if(!t.ok){console.error(`Failed to update custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of v.toDelete){let t=await qn(n,e);if(!t.ok){console.error(`Failed to delete custom type ${e}: ${t.error}`),process.exitCode=1;return}x.customTypes.deleted.push(e),s||console.info(` - ${e}`)}}if(l){!s&&(y.toInsert.length>0||y.toUpdate.length>0||y.toDelete.length>0)&&console.info(`
1512
- Pushing slices:`);for(let e of y.toInsert){let t=await Jn(n,e);if(!t.ok){console.error(`Failed to insert slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of y.toUpdate){let t=await Yn(n,e);if(!t.ok){console.error(`Failed to update slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of y.toDelete){let t=await Xn(n,e);if(!t.ok){console.error(`Failed to delete slice ${e}: ${t.error}`),process.exitCode=1;return}x.slices.deleted.push(e),s||console.info(` - ${e}`)}}if(s)console.info(J(x));else{let e=x.customTypes.inserted.length+x.customTypes.updated.length+x.customTypes.deleted.length+x.slices.inserted.length+x.slices.updated.length+x.slices.deleted.length;console.info(`\nPush complete: ${e} changes`)}}const wo=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;function To(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Eo(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}async function Do(){let{values:{help:t,name:n,"no-config":r,replace:i},positionals:[a]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},name:{type:`string`,short:`n`},"no-config":{type:`boolean`},replace:{type:`boolean`}},allowPositionals:!0});if(t){console.info(`Create a new Prismic repository.
1539
+ Pushing slices:`);for(let e of y.toInsert){let t=await Jn(n,e);if(!t.ok){console.error(`Failed to insert slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of y.toUpdate){let t=await Yn(n,e);if(!t.ok){console.error(`Failed to update slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of y.toDelete){let t=await Xn(n,e);if(!t.ok){console.error(`Failed to delete slice ${e}: ${t.error}`),process.exitCode=1;return}x.slices.deleted.push(e),s||console.info(` - ${e}`)}}if(s)console.info(J(x));else{let e=x.customTypes.inserted.length+x.customTypes.updated.length+x.customTypes.deleted.length+x.slices.inserted.length+x.slices.updated.length+x.slices.deleted.length;console.info(`\nPush complete: ${e} changes`)}}const jo=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;function Mo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function No(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}async function Po(){let{values:{help:t,name:n,"no-config":r,replace:i},positionals:[a]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},name:{type:`string`,short:`n`},"no-config":{type:`boolean`},replace:{type:`boolean`}},allowPositionals:!0});if(t){console.info(`Create a new Prismic repository.
1513
1540
 
1514
1541
  Creates prismic.config.json in the current directory. If a config file already
1515
1542
  exists, use --replace to update it with the new repository.
@@ -1528,7 +1555,7 @@ FLAGS
1528
1555
  -h, --help Show help for command
1529
1556
 
1530
1557
  LEARN MORE
1531
- Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!wo.test(a)){console.error(`Invalid domain format.`),console.error(`Must be at least 4 characters, start and end with alphanumeric, and contain only alphanumerics and hyphens.`),process.exitCode=1;return}if(!await B()){Ao();return}let o=await ti();if(!r&&o.ok&&!i){console.error(`This project already has a repository: ${o.config.repositoryName}`),console.error(`Use --replace to replace it, or --no-config to skip config creation.`),process.exitCode=1;return}let s=await Oo(a);if(!s.ok){s.error instanceof Q?Ao():(console.error(`Failed to check domain availability: ${J(s.error)}`),process.exitCode=1);return}if(!s.value){console.error(`Repository name "${a}" is already taken.`),process.exitCode=1;return}let c=await ko(a,n);if(!c.ok){c.error instanceof Q?Ao():(console.error(`Failed to create repository: ${J(c.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await ri({repositoryName:a});e.ok?console.info(`Updated prismic.config.json`):console.warn(`Could not update prismic.config.json: `+e.error.message)}else{let e=await ei({repositoryName:a});e.ok?console.info(`Created prismic.config.json`):console.warn(`Could not create prismic.config.json: `+e.error.message)}console.info(`Repository created: ${a}`),console.info(`URL: ${await z(a)}`);let l=await $();if(l?.framework){let e=To(l.framework),t=Eo(l.framework),n=Ni(l),r=n?`creating ${n}`:`configuring Prismic`;console.info(),console.info(`Next: Run \`prismic docs ${e}${t}\` for instructions on ${r}`)}}async function Oo(e){let t=await Z(new URL(`/app/dashboard/repositories/${e}/exists`,await An()));return t.ok?{ok:!0,value:t.value===`true`}:t}async function ko(e,t=e){return await Z(new URL(`/app/dashboard/repositories`,await An()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function Ao(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const jo=N({repository:N({api_access:I()})});async function Mo(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Get the Content API access level of a Prismic repository.
1558
+ Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!jo.test(a)){console.error(`Invalid domain format.`),console.error(`Must be at least 4 characters, start and end with alphanumeric, and contain only alphanumerics and hyphens.`),process.exitCode=1;return}if(!await B()){Lo();return}let o=await ci();if(!r&&o.ok&&!i){console.error(`This project already has a repository: ${o.config.repositoryName}`),console.error(`Use --replace to replace it, or --no-config to skip config creation.`),process.exitCode=1;return}let s=await Fo(a);if(!s.ok){s.error instanceof Q?Lo():(console.error(`Failed to check domain availability: ${J(s.error)}`),process.exitCode=1);return}if(!s.value){console.error(`Repository name "${a}" is already taken.`),process.exitCode=1;return}let c=await Io(a,n);if(!c.ok){c.error instanceof Q?Lo():(console.error(`Failed to create repository: ${J(c.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await ui({repositoryName:a});e.ok?console.info(`Updated prismic.config.json`):console.warn(`Could not update prismic.config.json: `+e.error.message)}else{let e=await si({repositoryName:a});e.ok?console.info(`Created prismic.config.json`):console.warn(`Could not create prismic.config.json: `+e.error.message)}console.info(`Repository created: ${a}`),console.info(`URL: ${await z(a)}`);let l=await $();if(l?.framework){let e=Mo(l.framework),t=No(l.framework),n=Bi(l),r=n?`creating ${n}`:`configuring Prismic`;console.info(),console.info(`Next: Run \`prismic docs fetch ${e}${t}\` for instructions on ${r}`)}}async function Fo(e){let t=await Z(new URL(`/app/dashboard/repositories/${e}/exists`,await An()));return t.ok?{ok:!0,value:t.value===`true`}:t}async function Io(e,t=e){return await Z(new URL(`/app/dashboard/repositories`,await An()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function Lo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ro=N({repository:N({api_access:I()})});async function zo(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Get the Content API access level of a Prismic repository.
1532
1559
 
1533
1560
  By default, this command reads the repository from prismic.config.json at the
1534
1561
  project root.
@@ -1541,7 +1568,7 @@ FLAGS
1541
1568
  -h, --help Show help for command
1542
1569
 
1543
1570
  LEARN MORE
1544
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Po();return}let r=await No(n);if(!r.ok){r.error instanceof Q?Po():(console.error(`Failed to get repository access: ${J(r.value)}`),process.exitCode=1);return}console.info(r.value.repository.api_access)}async function No(e){let t=await z(e);return await Z(new URL(`syncState`,t),{schema:jo})}function Po(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Fo=N({repositories:j(N({domain:I(),name:P(I()),role:I()}))});async function Io(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},json:{type:`boolean`}}});if(t){console.info(`List all Prismic repositories.
1571
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Vo();return}let r=await Bo(n);if(!r.ok){r.error instanceof Q?Vo():(console.error(`Failed to get repository access: ${J(r.value)}`),process.exitCode=1);return}console.info(r.value.repository.api_access)}async function Bo(e){let t=await z(e);return await Z(new URL(`syncState`,t),{schema:Ro})}function Vo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ho=N({repositories:j(N({domain:I(),name:P(I()),role:I()}))});async function Uo(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},json:{type:`boolean`}}});if(t){console.info(`List all Prismic repositories.
1545
1572
 
1546
1573
  USAGE
1547
1574
  prismic repo list [flags]
@@ -1551,7 +1578,7 @@ FLAGS
1551
1578
  -h, --help Show help for command
1552
1579
 
1553
1580
  LEARN MORE
1554
- Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await B()){Ro();return}let r=await Lo();if(!r.ok){r.error instanceof Q?Ro():(console.error(`Failed to fetch repositories: ${J(r.value)}`),process.exitCode=1);return}let i=r.value.repositories;if(n){let e=await Promise.all(i.map(async e=>({domain:e.domain,name:e.name||null,role:e.role,url:(await z(e.domain)).toString()})));console.info(J(e));return}if(i.length===0){console.info(`No repositories found.`);return}for(let e of i){let t=e.name||`(no name)`;console.info(`${e.domain} ${t} ${e.role}`)}}async function Lo(){return await Z(new URL(`profile`,await wn()),{schema:Fo})}function Ro(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const zo=[`private`,`public`,`open`];async function Bo(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the Content API access level of a Prismic repository.
1581
+ Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await B()){Go();return}let r=await Wo();if(!r.ok){r.error instanceof Q?Go():(console.error(`Failed to fetch repositories: ${J(r.value)}`),process.exitCode=1);return}let i=r.value.repositories;if(n){let e=await Promise.all(i.map(async e=>({domain:e.domain,name:e.name||null,role:e.role,url:(await z(e.domain)).toString()})));console.info(J(e));return}if(i.length===0){console.info(`No repositories found.`);return}for(let e of i){let t=e.name||`(no name)`;console.info(`${e.domain} ${t} ${e.role}`)}}async function Wo(){return await Z(new URL(`profile`,await wn()),{schema:Ho})}function Go(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ko=[`private`,`public`,`open`];async function qo(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the Content API access level of a Prismic repository.
1555
1582
 
1556
1583
  By default, this command reads the repository from prismic.config.json at the
1557
1584
  project root.
@@ -1567,7 +1594,7 @@ FLAGS
1567
1594
  -h, --help Show help for command
1568
1595
 
1569
1596
  LEARN MORE
1570
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <level>`),process.exitCode=1;return}if(!zo.includes(r)){console.error(`Invalid access level: ${r}. Must be one of: ${zo.join(`, `)}`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Ho();return}let i=await Vo(n,r);if(!i.ok){i.error instanceof Q?Ho():(console.error(`Failed to set repository access: ${J(i.value)}`),process.exitCode=1);return}console.info(`Repository access set to: ${r}`)}async function Vo(e,t){let n=await z(e);return await Z(new URL(`settings/security/apiaccess`,n),{method:`POST`,body:{api_access:t}})}function Ho(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Uo(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the display name of a Prismic repository.
1597
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <level>`),process.exitCode=1;return}if(!Ko.includes(r)){console.error(`Invalid access level: ${r}. Must be one of: ${Ko.join(`, `)}`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Yo();return}let i=await Jo(n,r);if(!i.ok){i.error instanceof Q?Yo():(console.error(`Failed to set repository access: ${J(i.value)}`),process.exitCode=1);return}console.info(`Repository access set to: ${r}`)}async function Jo(e,t){let n=await z(e);return await Z(new URL(`settings/security/apiaccess`,n),{method:`POST`,body:{api_access:t}})}function Yo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Xo(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the display name of a Prismic repository.
1571
1598
 
1572
1599
  By default, this command reads the repository from prismic.config.json at the
1573
1600
  project root.
@@ -1583,7 +1610,7 @@ FLAGS
1583
1610
  -h, --help Show help for command
1584
1611
 
1585
1612
  LEARN MORE
1586
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Go();return}let i=await Wo(n,r);if(!i.ok){i.error instanceof Q?Go():A(i.error)?(console.error(`Failed to set repository name: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${J(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function Wo(e,t){let n=await z(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await Z(r,{method:`POST`,body:i,schema:N({repository:N({name:I()})})})}function Go(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ko=N({repositories:j(N({domain:I(),name:P(I())}))});async function qo(){let{values:{help:t,repo:n=await X(),web:r}}=e({args:process.argv.slice(4),options:{web:{type:`boolean`,short:`w`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}}});if(t){console.info(`View a Prismic repository.
1613
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Qo();return}let i=await Zo(n,r);if(!i.ok){i.error instanceof Q?Qo():A(i.error)?(console.error(`Failed to set repository name: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${J(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function Zo(e,t){let n=await z(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await Z(r,{method:`POST`,body:i,schema:N({repository:N({name:I()})})})}function Qo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const $o=N({repositories:j(N({domain:I(),name:P(I())}))});async function es(){let{values:{help:t,repo:n=await X(),web:r}}=e({args:process.argv.slice(4),options:{web:{type:`boolean`,short:`w`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}}});if(t){console.info(`View a Prismic repository.
1587
1614
 
1588
1615
  By default, this command reads the repository from prismic.config.json at the
1589
1616
  project root.
@@ -1597,7 +1624,7 @@ FLAGS
1597
1624
  -h, --help Show help for command
1598
1625
 
1599
1626
  LEARN MORE
1600
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await z(n);if(r){Yo(i.toString()),console.info(`Opening ${i}`);return}if(!await B()){Xo();return}let a=await Jo();if(!a.ok){a.error instanceof Q?Xo():(console.error(`Failed to fetch repository info: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.repositories.find(e=>e.domain===n);if(!o){console.error(`Repository not found: ${n}`),process.exitCode=1;return}let s=o.name||`(no name)`;console.info(`Name: ${s}`),console.info(`URL: ${i}`)}async function Jo(){return await Z(new URL(`profile`,await wn()),{schema:Ko})}function Yo(e){m(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function Xo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Zo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Do();break;case`list`:await Io();break;case`view`:await qo();break;case`get-access`:await Mo();break;case`set-access`:await Bo();break;case`set-name`:await Uo();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
1627
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await z(n);if(r){ns(i.toString()),console.info(`Opening ${i}`);return}if(!await B()){rs();return}let a=await ts();if(!a.ok){a.error instanceof Q?rs():(console.error(`Failed to fetch repository info: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.repositories.find(e=>e.domain===n);if(!o){console.error(`Repository not found: ${n}`),process.exitCode=1;return}let s=o.name||`(no name)`;console.info(`Name: ${s}`),console.info(`URL: ${i}`)}async function ts(){return await Z(new URL(`profile`,await wn()),{schema:$o})}function ns(e){m(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function rs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function is(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Po();break;case`list`:await Uo();break;case`view`:await es();break;case`get-access`:await zo();break;case`set-access`:await qo();break;case`set-name`:await Xo();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
1601
1628
 
1602
1629
  USAGE
1603
1630
  prismic repo <command> [flags]
@@ -1614,7 +1641,7 @@ FLAGS
1614
1641
  -h, --help Show help for command
1615
1642
 
1616
1643
  LEARN MORE
1617
- Use \`prismic repo <command> --help\` for more information about a command.`)}}function Qo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function $o(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function es(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o,types:s},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
1644
+ Use \`prismic repo <command> --help\` for more information about a command.`)}}function as(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function os(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ss(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o,types:s},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
1618
1645
 
1619
1646
  USAGE
1620
1647
  prismic slice add-field boolean <slice-id> <field-id> [flags]
@@ -1637,7 +1664,7 @@ EXAMPLES
1637
1664
  prismic slice add-field boolean hero show_overlay --default
1638
1665
  prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: slice-id
1639
1666
  `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
1640
- `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await H(l);if(!p.ok){console.error(p.error),process.exitCode=1;return}let{model:m,modelPath:h}=p;if(m.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let g=n?m.variations.find(e=>e.id===n):m.variations[0];if(!g){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${m.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}g.primary||={};let _={type:`Boolean`,config:{label:r??Y(d.type===`nested`?d.nestedFieldId:u),...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};if(d.type===`nested`){let e=$n(g.primary,d.groupId,g.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=_}else{for(let e of m.variations){if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[u]){console.error(`Field "${u}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}g.primary[u]=_}try{await c(h,J(m))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Boolean) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Boolean) to "${g.id}" variation in ${l}`);try{await U({output:s}),console.info(`Updated types in ${s??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let v=await $();if(v?.framework){let e=Qo(v.framework),t=$o(v.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ts(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ns(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function rs(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
1667
+ `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await H(l);if(!p.ok){console.error(p.error),process.exitCode=1;return}let{model:m,modelPath:h}=p;if(m.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let g=n?m.variations.find(e=>e.id===n):m.variations[0];if(!g){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${m.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}g.primary||={};let _={type:`Boolean`,config:{label:r??Y(d.type===`nested`?d.nestedFieldId:u),...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};if(d.type===`nested`){let e=$n(g.primary,d.groupId,g.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=_}else{for(let e of m.variations){if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[u]){console.error(`Field "${u}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}g.primary[u]=_}try{await c(h,J(m))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Boolean) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Boolean) to "${g.id}" variation in ${l}`);try{await U({output:s}),console.info(`Updated types in ${s??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let v=await $();if(v?.framework){let e=as(v.framework),t=os(v.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function cs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ls(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function us(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
1641
1668
 
1642
1669
  USAGE
1643
1670
  prismic slice add-field color <slice-id> <field-id> [flags]
@@ -1658,7 +1685,7 @@ EXAMPLES
1658
1685
  prismic slice add-field color hero accent --label "Accent Color"
1659
1686
  prismic slice add-field color banner theme_color --variation "dark"`);return}if(!o){console.error(`Missing required argument: slice-id
1660
1687
  `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!s){console.error(`Missing required argument: field-id
1661
- `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Color`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Color) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Color) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=ts(g.framework),t=ns(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function is(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function as(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function os(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
1688
+ `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Color`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Color) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Color) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=cs(g.framework),t=ls(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function ds(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function fs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ps(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
1662
1689
 
1663
1690
  USAGE
1664
1691
  prismic slice add-field date <slice-id> <field-id> [flags]
@@ -1679,7 +1706,7 @@ EXAMPLES
1679
1706
  prismic slice add-field date event start_date --label "Start Date"
1680
1707
  prismic slice add-field date promo end_date --variation "countdown"`);return}if(!o){console.error(`Missing required argument: slice-id
1681
1708
  `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!s){console.error(`Missing required argument: field-id
1682
- `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Date`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Date) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Date) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=is(g.framework),t=as(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ss(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function cs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ls(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
1709
+ `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Date`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Date) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Date) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=ds(g.framework),t=fs(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function ms(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function hs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function gs(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
1683
1710
 
1684
1711
  USAGE
1685
1712
  prismic slice add-field embed <slice-id> <field-id> [flags]
@@ -1700,7 +1727,7 @@ EXAMPLES
1700
1727
  prismic slice add-field embed gallery media --label "Media Embed"
1701
1728
  prismic slice add-field embed social tweet --variation "twitter"`);return}if(!o){console.error(`Missing required argument: slice-id
1702
1729
  `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!s){console.error(`Missing required argument: field-id
1703
- `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Embed`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Embed) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Embed) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=ss(g.framework),t=cs(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function us(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ds(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function fs(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
1730
+ `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Embed`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Embed) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Embed) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=ms(g.framework),t=hs(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function _s(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function vs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ys(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
1704
1731
 
1705
1732
  USAGE
1706
1733
  prismic slice add-field geo-point <slice-id> <field-id> [flags]
@@ -1720,7 +1747,7 @@ EXAMPLES
1720
1747
  prismic slice add-field geo-point store coordinates --label "Store Location"
1721
1748
  prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!a){console.error(`Missing required argument: slice-id
1722
1749
  `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1723
- `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let s=W(o),l=q(s);if(!l.ok){console.error(l.error),process.exitCode=1;return}let u=await H(a);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};let m={type:`GeoPoint`,config:{label:r??Y(s.type===`nested`?s.nestedFieldId:o)}};if(s.type===`nested`){let e=$n(p.primary,s.groupId,p.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[s.nestedFieldId]){console.error(`Field "${s.nestedFieldId}" already exists in group "${s.groupId}"`),process.exitCode=1;return}e.group.config.fields[s.nestedFieldId]=m}else{for(let e of d.variations){if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[o]){console.error(`Field "${o}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}p.primary[o]=m}try{await c(f,J(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}s.type===`nested`?console.info(`Added field "${s.nestedFieldId}" (GeoPoint) to group "${s.groupId}" in ${a}`):console.info(`Added field "${o}" (GeoPoint) to "${p.id}" variation in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let h=await $();if(h?.framework){let e=us(h.framework),t=ds(h.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ps(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ms(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function hs(){let{values:{help:t,variation:n,label:r,"non-repeatable":i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing slice.
1750
+ `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let s=W(o),l=q(s);if(!l.ok){console.error(l.error),process.exitCode=1;return}let u=await H(a);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};let m={type:`GeoPoint`,config:{label:r??Y(s.type===`nested`?s.nestedFieldId:o)}};if(s.type===`nested`){let e=$n(p.primary,s.groupId,p.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[s.nestedFieldId]){console.error(`Field "${s.nestedFieldId}" already exists in group "${s.groupId}"`),process.exitCode=1;return}e.group.config.fields[s.nestedFieldId]=m}else{for(let e of d.variations){if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[o]){console.error(`Field "${o}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}p.primary[o]=m}try{await c(f,J(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}s.type===`nested`?console.info(`Added field "${s.nestedFieldId}" (GeoPoint) to group "${s.groupId}" in ${a}`):console.info(`Added field "${o}" (GeoPoint) to "${p.id}" variation in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let h=await $();if(h?.framework){let e=_s(h.framework),t=vs(h.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function bs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function xs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ss(){let{values:{help:t,variation:n,label:r,"non-repeatable":i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing slice.
1724
1751
 
1725
1752
  USAGE
1726
1753
  prismic slice add-field group <slice-id> <field-id> [flags]
@@ -1741,7 +1768,7 @@ EXAMPLES
1741
1768
  prismic slice add-field group hero ctas --non-repeatable
1742
1769
  prismic slice add-field group product variants --variation "withImage"`);return}if(!o){console.error(`Missing required argument: slice-id
1743
1770
  `),console.error(`Usage: prismic slice add-field group <slice-id> <field-id>`),process.exitCode=1;return}if(!s){console.error(`Missing required argument: field-id
1744
- `),console.error(`Usage: prismic slice add-field group <slice-id> <field-id>`),process.exitCode=1;return}if(s.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let l=await H(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Group`,config:{label:r??Y(s),repeat:!i,fields:{}}};f.primary[s]=p;try{await c(d,J(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${s}" (Group) to "${f.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic slice add-field <type> ${o} ${s}.<field-id>\``);let m=await $();if(m?.framework){let e=ps(m.framework),t=ms(m.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function gs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function _s(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function vs(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
1771
+ `),console.error(`Usage: prismic slice add-field group <slice-id> <field-id>`),process.exitCode=1;return}if(s.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let l=await H(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Group`,config:{label:r??Y(s),repeat:!i,fields:{}}};f.primary[s]=p;try{await c(d,J(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${s}" (Group) to "${f.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic slice add-field <type> ${o} ${s}.<field-id>\``);let m=await $();if(m?.framework){let e=bs(m.framework),t=xs(m.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Cs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ws(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ts(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
1745
1772
 
1746
1773
  USAGE
1747
1774
  prismic slice add-field image <slice-id> <field-id> [flags]
@@ -1761,7 +1788,7 @@ EXAMPLES
1761
1788
  prismic slice add-field image hero banner --label "Hero Banner"
1762
1789
  prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!a){console.error(`Missing required argument: slice-id
1763
1790
  `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1764
- `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let s=W(o),l=q(s);if(!l.ok){console.error(l.error),process.exitCode=1;return}let u=await H(a);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};let m={type:`Image`,config:{label:r??Y(s.type===`nested`?s.nestedFieldId:o)}};if(s.type===`nested`){let e=$n(p.primary,s.groupId,p.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[s.nestedFieldId]){console.error(`Field "${s.nestedFieldId}" already exists in group "${s.groupId}"`),process.exitCode=1;return}e.group.config.fields[s.nestedFieldId]=m}else{for(let e of d.variations){if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[o]){console.error(`Field "${o}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}p.primary[o]=m}try{await c(f,J(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}s.type===`nested`?console.info(`Added field "${s.nestedFieldId}" (Image) to group "${s.groupId}" in ${a}`):console.info(`Added field "${o}" (Image) to "${p.id}" variation in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let h=await $();if(h?.framework){let e=gs(h.framework),t=_s(h.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ys(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function bs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function xs(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
1791
+ `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let s=W(o),l=q(s);if(!l.ok){console.error(l.error),process.exitCode=1;return}let u=await H(a);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};let m={type:`Image`,config:{label:r??Y(s.type===`nested`?s.nestedFieldId:o)}};if(s.type===`nested`){let e=$n(p.primary,s.groupId,p.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[s.nestedFieldId]){console.error(`Field "${s.nestedFieldId}" already exists in group "${s.groupId}"`),process.exitCode=1;return}e.group.config.fields[s.nestedFieldId]=m}else{for(let e of d.variations){if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[o]){console.error(`Field "${o}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}p.primary[o]=m}try{await c(f,J(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}s.type===`nested`?console.info(`Added field "${s.nestedFieldId}" (Image) to group "${s.groupId}" in ${a}`):console.info(`Added field "${o}" (Image) to "${p.id}" variation in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let h=await $();if(h?.framework){let e=Cs(h.framework),t=ws(h.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Es(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ds(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Os(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
1765
1792
 
1766
1793
  USAGE
1767
1794
  prismic slice add-field key-text <slice-id> <field-id> [flags]
@@ -1782,7 +1809,7 @@ EXAMPLES
1782
1809
  prismic slice add-field key-text hero heading --label "Heading"
1783
1810
  prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!o){console.error(`Missing required argument: slice-id
1784
1811
  `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!s){console.error(`Missing required argument: field-id
1785
- `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Text`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Text) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Text) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=ys(g.framework),t=bs(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Ss(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Cs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ws(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:s,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
1812
+ `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Text`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Text) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Text) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=Es(g.framework),t=Ds(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function ks(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function As(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function js(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:s,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
1786
1813
 
1787
1814
  USAGE
1788
1815
  prismic slice add-field link <slice-id> <field-id> [flags]
@@ -1807,7 +1834,7 @@ EXAMPLES
1807
1834
  prismic slice add-field link navigation links --repeatable
1808
1835
  prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!u){console.error(`Missing required argument: slice-id
1809
1836
  `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
1810
- `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await H(u);if(!m.ok){console.error(m.error),process.exitCode=1;return}let{model:h,modelPath:g}=m;if(h.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let _=n?h.variations.find(e=>e.id===n):h.variations[0];if(!_){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${h.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}_.primary||={};let v={type:`Link`,config:{label:r??Y(f.type===`nested`?f.nestedFieldId:d),...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...s&&{repeat:!0}}};if(f.type===`nested`){let e=$n(_.primary,f.groupId,_.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=v}else{for(let e of h.variations){if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[d]){console.error(`Field "${d}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}_.primary[d]=v}try{await c(g,J(h))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Link) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Link) to "${_.id}" variation in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let y=await $();if(y?.framework){let e=Ss(y.framework),t=Cs(y.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Ts(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Es(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ds(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
1837
+ `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await H(u);if(!m.ok){console.error(m.error),process.exitCode=1;return}let{model:h,modelPath:g}=m;if(h.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let _=n?h.variations.find(e=>e.id===n):h.variations[0];if(!_){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${h.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}_.primary||={};let v={type:`Link`,config:{label:r??Y(f.type===`nested`?f.nestedFieldId:d),...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...s&&{repeat:!0}}};if(f.type===`nested`){let e=$n(_.primary,f.groupId,_.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=v}else{for(let e of h.variations){if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[d]){console.error(`Field "${d}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}_.primary[d]=v}try{await c(g,J(h))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Link) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Link) to "${_.id}" variation in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let y=await $();if(y?.framework){let e=ks(y.framework),t=As(y.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Ms(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ns(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ps(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
1811
1838
 
1812
1839
  USAGE
1813
1840
  prismic slice add-field number <slice-id> <field-id> [flags]
@@ -1828,7 +1855,7 @@ EXAMPLES
1828
1855
  prismic slice add-field number product quantity --label "Quantity"
1829
1856
  prismic slice add-field number stats count --variation "detailed"`);return}if(!o){console.error(`Missing required argument: slice-id
1830
1857
  `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!s){console.error(`Missing required argument: field-id
1831
- `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Number`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Number) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Number) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=Ts(g.framework),t=Es(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Os(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ks(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function As(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":s,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
1858
+ `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Number`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Number) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Number) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=Ms(g.framework),t=Ns(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Fs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Is(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ls(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":s,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
1832
1859
 
1833
1860
  USAGE
1834
1861
  prismic slice add-field rich-text <slice-id> <field-id> [flags]
@@ -1858,7 +1885,7 @@ EXAMPLES
1858
1885
  prismic slice add-field rich-text hero tagline --single "heading1"
1859
1886
  prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: slice-id
1860
1887
  `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
1861
- `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await H(u);if(!m.ok){console.error(m.error),process.exitCode=1;return}let{model:h,modelPath:g}=m;if(h.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let _=n?h.variations.find(e=>e.id===n):h.variations[0];if(!_){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${h.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}_.primary||={};let v={type:`StructuredText`,config:{label:r??Y(f.type===`nested`?f.nestedFieldId:d),...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...s&&{allowTargetBlank:!0}}};if(f.type===`nested`){let e=$n(_.primary,f.groupId,_.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=v}else{for(let e of h.variations){if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[d]){console.error(`Field "${d}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}_.primary[d]=v}try{await c(g,J(h))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (StructuredText) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (StructuredText) to "${_.id}" variation in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let y=await $();if(y?.framework){let e=Os(y.framework),t=ks(y.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function js(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ms(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ns(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o,types:s},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
1888
+ `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await H(u);if(!m.ok){console.error(m.error),process.exitCode=1;return}let{model:h,modelPath:g}=m;if(h.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let _=n?h.variations.find(e=>e.id===n):h.variations[0];if(!_){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${h.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}_.primary||={};let v={type:`StructuredText`,config:{label:r??Y(f.type===`nested`?f.nestedFieldId:d),...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...s&&{allowTargetBlank:!0}}};if(f.type===`nested`){let e=$n(_.primary,f.groupId,_.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=v}else{for(let e of h.variations){if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[d]){console.error(`Field "${d}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}_.primary[d]=v}try{await c(g,J(h))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (StructuredText) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (StructuredText) to "${_.id}" variation in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let y=await $();if(y?.framework){let e=Fs(y.framework),t=Is(y.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Rs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function zs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Bs(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o,types:s},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
1862
1889
 
1863
1890
  USAGE
1864
1891
  prismic slice add-field select <slice-id> <field-id> [flags]
@@ -1881,7 +1908,7 @@ EXAMPLES
1881
1908
  prismic slice add-field select hero style --option "light" --option "dark" --default "light"
1882
1909
  prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!l){console.error(`Missing required argument: slice-id
1883
1910
  `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
1884
- `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await H(l);if(!p.ok){console.error(p.error),process.exitCode=1;return}let{model:m,modelPath:h}=p;if(m.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let g=n?m.variations.find(e=>e.id===n):m.variations[0];if(!g){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${m.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}g.primary||={};let _={type:`Select`,config:{label:r??Y(d.type===`nested`?d.nestedFieldId:u),...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};if(d.type===`nested`){let e=$n(g.primary,d.groupId,g.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=_}else{for(let e of m.variations){if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[u]){console.error(`Field "${u}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}g.primary[u]=_}try{await c(h,J(m))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Select) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Select) to "${g.id}" variation in ${l}`);try{await U({output:s}),console.info(`Updated types in ${s??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let v=await $();if(v?.framework){let e=js(v.framework),t=Ms(v.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Ps(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Fs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Is(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
1911
+ `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await H(l);if(!p.ok){console.error(p.error),process.exitCode=1;return}let{model:m,modelPath:h}=p;if(m.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let g=n?m.variations.find(e=>e.id===n):m.variations[0];if(!g){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${m.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}g.primary||={};let _={type:`Select`,config:{label:r??Y(d.type===`nested`?d.nestedFieldId:u),...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};if(d.type===`nested`){let e=$n(g.primary,d.groupId,g.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=_}else{for(let e of m.variations){if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[u]){console.error(`Field "${u}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}g.primary[u]=_}try{await c(h,J(m))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Select) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Select) to "${g.id}" variation in ${l}`);try{await U({output:s}),console.info(`Updated types in ${s??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let v=await $();if(v?.framework){let e=Rs(v.framework),t=zs(v.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Vs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Hs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Us(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,s]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
1885
1912
 
1886
1913
  USAGE
1887
1914
  prismic slice add-field timestamp <slice-id> <field-id> [flags]
@@ -1902,7 +1929,7 @@ EXAMPLES
1902
1929
  prismic slice add-field timestamp event start_time --label "Event Start"
1903
1930
  prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!o){console.error(`Missing required argument: slice-id
1904
1931
  `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!s){console.error(`Missing required argument: field-id
1905
- `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Timestamp`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Timestamp) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Timestamp) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=Ps(g.framework),t=Fs(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}async function Ls(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await es();break;case`color`:await rs();break;case`date`:await os();break;case`embed`:await ls();break;case`geo-point`:await fs();break;case`group`:await hs();break;case`image`:await vs();break;case`key-text`:await xs();break;case`link`:await ws();break;case`number`:await Ds();break;case`rich-text`:await As();break;case`select`:await Ns();break;case`timestamp`:await Is();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
1932
+ `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let l=W(s),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Timestamp`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:s),...i&&{placeholder:i}}};if(l.type===`nested`){let e=$n(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[s]){console.error(`Field "${s}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[s]){console.error(`Field "${s}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[s]=h}try{await c(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Timestamp) to group "${l.groupId}" in ${o}`):console.info(`Added field "${s}" (Timestamp) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=Vs(g.framework),t=Hs(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}async function Ws(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await ss();break;case`color`:await us();break;case`date`:await ps();break;case`embed`:await gs();break;case`geo-point`:await ys();break;case`group`:await Ss();break;case`image`:await Ts();break;case`key-text`:await Os();break;case`link`:await js();break;case`number`:await Ps();break;case`rich-text`:await Ls();break;case`select`:await Bs();break;case`timestamp`:await Us();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
1906
1933
 
1907
1934
  USAGE
1908
1935
  prismic slice add-field <field-type> <slice-id> <field-id> [flags]
@@ -1932,7 +1959,7 @@ EXAMPLES
1932
1959
  prismic slice add-field key-text my_slice title --label "Title"
1933
1960
  prismic slice add-field link my_slice cta --allow-text
1934
1961
  prismic slice add-field rich-text my_slice body --multi "paragraph,heading2,strong,em"
1935
- prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function Rs(){let{values:{help:t,name:n,"copy-from":r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
1962
+ prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function Gs(){let{values:{help:t,name:n,"copy-from":r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
1936
1963
 
1937
1964
  USAGE
1938
1965
  prismic slice add-variation <slice-id> <variation-id> [flags]
@@ -1952,7 +1979,7 @@ EXAMPLES
1952
1979
  prismic slice add-variation MySlice withImage --name "With Image"
1953
1980
  prismic slice add-variation MySlice withImage --copy-from default`);return}if(!a){console.error(`Missing required argument: slice-id
1954
1981
  `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: variation-id
1955
- `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let s=await H(a);if(!s.ok){console.error(s.error),process.exitCode=1;return}let{model:l,modelPath:u}=s;if(l.variations.some(e=>e.id===o)){console.error(`Variation "${o}" already exists in slice "${a}"`),process.exitCode=1;return}let d;if(r){let e=l.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d={...structuredClone(e),id:o,name:n??Rn(o)}}else d={id:o,name:n??Rn(o),description:o,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let f={...l,variations:[...l.variations,d]};try{await c(u,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added variation "${o}" to slice "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const zs=N({uploadEndpoint:I(),requiredFormDataFields:F(I(),I()),imgixEndpoint:I()});async function Bs(e){let{data:t,repo:n,sliceId:r,variationId:i,filename:a}=e,o=await Z(`https://acl-provider.prismic.io/create`,{method:`POST`,body:{},schema:zs});if(!o.ok)throw Error(`Failed to get upload credentials from Prismic`);let{uploadEndpoint:s,requiredFormDataFields:c,imgixEndpoint:l}=o.value,d=u(`md5`).update(t).digest(`hex`),f=g(a).toLowerCase().slice(1)||`png`,p=`${n}/shared-slices/${r}/${i}/${d}.${f}`,m=new FormData;for(let[e,t]of Object.entries(c))m.append(e,t);m.append(`key`,p),m.append(`Content-Type`,Vs(f)),m.append(`file`,new Blob([new Uint8Array(t)],{type:Vs(f)}),a);let h=await fetch(s,{method:`POST`,body:m});if(!h.ok){let e=await h.text();throw Error(`Failed to upload screenshot: ${e}`)}return`${l}/${p}?auto=compress,format`}function Vs(e){switch(e){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;default:return`image/png`}}async function Hs(){let{values:{help:t,variation:n,repo:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,short:`v`,default:`default`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set a screenshot for a slice variation.
1982
+ `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let s=await H(a);if(!s.ok){console.error(s.error),process.exitCode=1;return}let{model:l,modelPath:u}=s;if(l.variations.some(e=>e.id===o)){console.error(`Variation "${o}" already exists in slice "${a}"`),process.exitCode=1;return}let d;if(r){let e=l.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d={...structuredClone(e),id:o,name:n??Rn(o)}}else d={id:o,name:n??Rn(o),description:o,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let f={...l,variations:[...l.variations,d]};try{await c(u,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added variation "${o}" to slice "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ks=N({uploadEndpoint:I(),requiredFormDataFields:F(I(),I()),imgixEndpoint:I()});async function qs(e){let{data:t,repo:n,sliceId:r,variationId:i,filename:a}=e,o=await Z(`https://acl-provider.prismic.io/create`,{method:`POST`,body:{},schema:Ks});if(!o.ok)throw Error(`Failed to get upload credentials from Prismic`);let{uploadEndpoint:s,requiredFormDataFields:c,imgixEndpoint:l}=o.value,d=u(`md5`).update(t).digest(`hex`),f=g(a).toLowerCase().slice(1)||`png`,p=`${n}/shared-slices/${r}/${i}/${d}.${f}`,m=new FormData;for(let[e,t]of Object.entries(c))m.append(e,t);m.append(`key`,p),m.append(`Content-Type`,Js(f)),m.append(`file`,new Blob([new Uint8Array(t)],{type:Js(f)}),a);let h=await fetch(s,{method:`POST`,body:m});if(!h.ok){let e=await h.text();throw Error(`Failed to upload screenshot: ${e}`)}return`${l}/${p}?auto=compress,format`}function Js(e){switch(e){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;default:return`image/png`}}async function Ys(){let{values:{help:t,variation:n,repo:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,short:`v`,default:`default`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set a screenshot for a slice variation.
1956
1983
 
1957
1984
  USAGE
1958
1985
  prismic slice set-screenshot <slice-id> <image-path> [flags]
@@ -1971,7 +1998,7 @@ EXAMPLES
1971
1998
  prismic slice set-screenshot MySlice ./screenshot.png --variation dark
1972
1999
  prismic slice set-screenshot MySlice ./screenshot.png --repo my-repo`);return}if(!a){console.error(`Missing required argument: slice-id
1973
2000
  `),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: image-path
1974
- `),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!await B()){console.error(`You must be logged in to set a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let s=i??await X();if(!s){console.error(`Could not determine repository.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let l=await H(a);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l,f=u.variations.findIndex(e=>e.id===n);if(f===-1){console.error(`Variation "${n}" not found in slice "${a}"`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let p;try{p=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read image file: ${e.message}`):console.error(`Failed to read image file`),process.exitCode=1;return}let m;try{m=await Bs({data:p,repo:s,sliceId:a,variationId:n??`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}u.variations[f].imageUrl=m;try{await c(d,J(u))}catch(e){e instanceof Error?console.error(`Failed to update slice model: ${e.message}`):console.error(`Failed to update slice model`),process.exitCode=1;return}console.info(`Screenshot set for slice "${a}" variation "${n}"`),console.info(`URL: ${m}`)}async function Us(){let{values:{help:t,name:i,types:a,screenshot:o,repo:s},positionals:[l]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},screenshot:{type:`string`},repo:{type:`string`,short:`r`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
2001
+ `),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!await B()){console.error(`You must be logged in to set a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let s=i??await X();if(!s){console.error(`Could not determine repository.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let l=await H(a);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l,f=u.variations.findIndex(e=>e.id===n);if(f===-1){console.error(`Variation "${n}" not found in slice "${a}"`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let p;try{p=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read image file: ${e.message}`):console.error(`Failed to read image file`),process.exitCode=1;return}let m;try{m=await qs({data:p,repo:s,sliceId:a,variationId:n??`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}u.variations[f].imageUrl=m;try{await c(d,J(u))}catch(e){e instanceof Error?console.error(`Failed to update slice model: ${e.message}`):console.error(`Failed to update slice model`),process.exitCode=1;return}console.info(`Screenshot set for slice "${a}" variation "${n}"`),console.info(`URL: ${m}`)}async function Xs(){let{values:{help:t,name:i,types:a,screenshot:o,repo:s},positionals:[l]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},screenshot:{type:`string`},repo:{type:`string`,short:`r`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
1975
2002
 
1976
2003
  USAGE
1977
2004
  prismic slice create <id> [flags]
@@ -1987,7 +2014,7 @@ FLAGS
1987
2014
  -h, --help Show help for command
1988
2015
 
1989
2016
  LEARN MORE
1990
- Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!l){console.error(`Missing required argument: id`),process.exitCode=1;return}let u;if(o){if(!await B()){console.error(`You must be logged in to upload a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let e=s??await X();if(!e){console.error(`Could not determine repository for screenshot upload.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let t;try{t=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read screenshot file: ${e.message}`):console.error(`Failed to read screenshot file`),process.exitCode=1;return}try{u=await Bs({data:t,repo:e,sliceId:l,variationId:`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}}let d={id:l,type:`SharedSlice`,name:i??qs(l),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:u??``,docURL:``,version:`initial`,primary:{},items:{}}]},f=await Ws(),p=new URL(qs(d.name)+`/`,f),m=new URL(`model.json`,p);try{await n(new URL(`.`,m),{recursive:!0}),await c(m,J(d))}catch(e){e instanceof Error?console.error(`Failed to create slice: ${e.message}`):console.error(`Failed to create slice`),process.exitCode=1;return}console.info(`Created slice at ${m.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic slice add-field`")}async function Ws(){let e=await Ks(),t=await V(`package.json`);switch(e){case`next`:if(await Nn(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await Nn(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const Gs=N({dependencies:P(F(I(),I()))});async function Ks(){let e=await V(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=xn(Gs,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function qs(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Js(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all slices in a Prismic project.
2017
+ Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!l){console.error(`Missing required argument: id`),process.exitCode=1;return}let u;if(o){if(!await B()){console.error(`You must be logged in to upload a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let e=s??await X();if(!e){console.error(`Could not determine repository for screenshot upload.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let t;try{t=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read screenshot file: ${e.message}`):console.error(`Failed to read screenshot file`),process.exitCode=1;return}try{u=await qs({data:t,repo:e,sliceId:l,variationId:`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}}let d={id:l,type:`SharedSlice`,name:i??ec(l),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:u??``,docURL:``,version:`initial`,primary:{},items:{}}]},f=await Zs(),p=new URL(ec(d.name)+`/`,f),m=new URL(`model.json`,p);try{await n(new URL(`.`,m),{recursive:!0}),await c(m,J(d))}catch(e){e instanceof Error?console.error(`Failed to create slice: ${e.message}`):console.error(`Failed to create slice`),process.exitCode=1;return}console.info(`Created slice at ${m.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic slice add-field`")}async function Zs(){let e=await $s(),t=await V(`package.json`);switch(e){case`next`:if(await Nn(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await Nn(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const Qs=N({dependencies:P(F(I(),I()))});async function $s(){let e=await V(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=xn(Qs,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function ec(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function tc(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all slices in a Prismic project.
1991
2018
 
1992
2019
  USAGE
1993
2020
  prismic slice list [flags]
@@ -1998,7 +2025,7 @@ FLAGS
1998
2025
 
1999
2026
  EXAMPLES
2000
2027
  prismic slice list
2001
- prismic slice list --json`);return}let a=await Fn(),o;try{o=await i(a,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}let s=[];for(let e of o){let t=new URL(`${e}/model.json`,a);try{let e=await r(t,`utf8`),n=R(Pn,JSON.parse(e));n.success&&s.push({id:n.output.id,name:n.output.name})}catch{}}if(s.length===0){n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}if(n)console.info(JSON.stringify(s,null,2));else{console.info(`ID NAME`);for(let e of s)console.info(`${e.id}\t${e.name}`)}}async function Ys(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all variations for a slice.
2028
+ prismic slice list --json`);return}let a=await Fn(),o;try{o=await i(a,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}let s=[];for(let e of o){let t=new URL(`${e}/model.json`,a);try{let e=await r(t,`utf8`),n=R(Pn,JSON.parse(e));n.success&&s.push({id:n.output.id,name:n.output.name})}catch{}}if(s.length===0){n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}if(n)console.info(JSON.stringify(s,null,2));else{console.info(`ID NAME`);for(let e of s)console.info(`${e.id}\t${e.name}`)}}async function nc(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all variations for a slice.
2002
2029
 
2003
2030
  USAGE
2004
2031
  prismic slice list-variations <slice-id> [flags]
@@ -2013,7 +2040,7 @@ FLAGS
2013
2040
  EXAMPLES
2014
2041
  prismic slice list-variations MySlice
2015
2042
  prismic slice list-variations MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
2016
- `),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await H(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i,o=a.variations.map(e=>({id:e.id,name:e.name}));if(n){console.info(JSON.stringify(o,null,2));return}console.info(`ID NAME`);for(let e of o)console.info(`${e.id}\t${e.name}`)}async function Xs(){let{values:{help:t,y:n,types:r},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
2043
+ `),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await H(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i,o=a.variations.map(e=>({id:e.id,name:e.name}));if(n){console.info(JSON.stringify(o,null,2));return}console.info(`ID NAME`);for(let e of o)console.info(`${e.id}\t${e.name}`)}async function rc(){let{values:{help:t,y:n,types:r},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
2017
2044
 
2018
2045
  USAGE
2019
2046
  prismic slice remove <slice-id> [flags]
@@ -2029,7 +2056,7 @@ FLAGS
2029
2056
  EXAMPLES
2030
2057
  prismic slice remove MySlice
2031
2058
  prismic slice remove MySlice -y`);return}if(!i){console.error(`Missing required argument: slice-id
2032
- `),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let a=await H(i);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{modelPath:s}=a,c=new URL(`.`,s);if(!n){console.error(`Refusing to remove slice "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${i}"`);try{await U({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Zs(){let{values:{help:t,variation:n,zone:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
2059
+ `),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let a=await H(i);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{modelPath:s}=a,c=new URL(`.`,s);if(!n){console.error(`Refusing to remove slice "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${i}"`);try{await U({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function ic(){let{values:{help:t,variation:n,zone:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
2033
2060
 
2034
2061
  USAGE
2035
2062
  prismic slice remove-field <slice-id> <field-id> [flags]
@@ -2049,7 +2076,7 @@ EXAMPLES
2049
2076
  prismic slice remove-field MySlice title --variation withImage
2050
2077
  prismic slice remove-field MySlice item_title --zone items`);return}if(!a){console.error(`Missing required argument: slice-id
2051
2078
  `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
2052
- `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let s=await H(a);if(!s.ok){console.error(s.error),process.exitCode=1;return}let{model:l,modelPath:u}=s,d=l.variations.find(e=>e.id===n);if(!d){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let f=r===`primary`?d.primary:d.items;if(!f||!(o in f)){console.error(`Field "${o}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete f[o];try{await c(u,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed field "${o}" from ${r} zone in variation "${n}" of slice "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Qs(){let{values:{help:t,types:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
2079
+ `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let s=await H(a);if(!s.ok){console.error(s.error),process.exitCode=1;return}let{model:l,modelPath:u}=s,d=l.variations.find(e=>e.id===n);if(!d){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let f=r===`primary`?d.primary:d.items;if(!f||!(o in f)){console.error(`Field "${o}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete f[o];try{await c(u,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed field "${o}" from ${r} zone in variation "${n}" of slice "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function ac(){let{values:{help:t,types:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
2053
2080
 
2054
2081
  USAGE
2055
2082
  prismic slice remove-variation <slice-id> <variation-id> [flags]
@@ -2065,7 +2092,7 @@ FLAGS
2065
2092
  EXAMPLES
2066
2093
  prismic slice remove-variation MySlice withImage`);return}if(!r){console.error(`Missing required argument: slice-id
2067
2094
  `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: variation-id
2068
- `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let a=await H(r);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{model:o,modelPath:s}=a;if(!o.variations.some(e=>e.id===i)){console.error(`Variation not found: ${i}`),console.error(`Available variations: ${o.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let l={...o,variations:o.variations.filter(e=>e.id!==i)};try{await c(s,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed variation "${i}" from slice "${r}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function $s(){let{values:{help:t,id:n,types:r},positionals:[i,o]}=e({args:process.argv.slice(4),options:{id:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
2095
+ `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let a=await H(r);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{model:o,modelPath:s}=a;if(!o.variations.some(e=>e.id===i)){console.error(`Variation not found: ${i}`),console.error(`Available variations: ${o.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let l={...o,variations:o.variations.filter(e=>e.id!==i)};try{await c(s,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed variation "${i}" from slice "${r}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function oc(){let{values:{help:t,id:n,types:r},positionals:[i,o]}=e({args:process.argv.slice(4),options:{id:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
2069
2096
 
2070
2097
  USAGE
2071
2098
  prismic slice rename <slice-id> <new-name> [flags]
@@ -2083,7 +2110,7 @@ EXAMPLES
2083
2110
  prismic slice rename MySlice "My New Name"
2084
2111
  prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!i){console.error(`Missing required argument: slice-id
2085
2112
  `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: new-name
2086
- `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let s=await H(i);if(!s.ok){console.error(s.error),process.exitCode=1;return}let{model:l,modelPath:u}=s;l.name=o,n&&(l.id=n);try{await c(u,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}if(n){let e=await Fn(),t=new URL(`.`,u),r=new URL(Rn(o)+`/`,e);if(t.href!==r.href)try{await a(t,r),console.info(`Renamed slice "${i}" to "${n}" (${o})`),console.info(`Moved directory to ${r.href}`)}catch(e){e instanceof Error?console.error(`Failed to rename directory: ${e.message}`):console.error(`Failed to rename directory`),process.exitCode=1;return}else console.info(`Renamed slice "${i}" to "${n}" (${o})`)}else console.info(`Renamed slice "${i}" to "${o}"`);try{await U({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function ec(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific slice.
2113
+ `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let s=await H(i);if(!s.ok){console.error(s.error),process.exitCode=1;return}let{model:l,modelPath:u}=s;l.name=o,n&&(l.id=n);try{await c(u,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}if(n){let e=await Fn(),t=new URL(`.`,u),r=new URL(Rn(o)+`/`,e);if(t.href!==r.href)try{await a(t,r),console.info(`Renamed slice "${i}" to "${n}" (${o})`),console.info(`Moved directory to ${r.href}`)}catch(e){e instanceof Error?console.error(`Failed to rename directory: ${e.message}`):console.error(`Failed to rename directory`),process.exitCode=1;return}else console.info(`Renamed slice "${i}" to "${n}" (${o})`)}else console.info(`Renamed slice "${i}" to "${o}"`);try{await U({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function sc(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific slice.
2087
2114
 
2088
2115
  USAGE
2089
2116
  prismic slice view <slice-id> [flags]
@@ -2099,7 +2126,7 @@ EXAMPLES
2099
2126
  prismic slice view MySlice
2100
2127
  prismic slice view MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
2101
2128
  `),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await H(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i;if(n){console.info(JSON.stringify(a,null,2));return}console.info(`ID: ${a.id}`),console.info(`Name: ${a.name}`),a.description&&console.info(`Description: ${a.description}`),console.info(`Variations: ${a.variations.length}`),console.info(`
2102
- Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`),e.imageUrl&&console.info(` Screenshot: ${e.imageUrl}`)}}async function tc(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Us();break;case`list`:await Js();break;case`view`:await ec();break;case`rename`:await $s();break;case`remove`:await Xs();break;case`add-field`:await Ls();break;case`remove-field`:await Zs();break;case`add-variation`:await Rs();break;case`remove-variation`:await Qs();break;case`list-variations`:await Ys();break;case`set-screenshot`:await Hs();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
2129
+ Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`),e.imageUrl&&console.info(` Screenshot: ${e.imageUrl}`)}}async function cc(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Xs();break;case`list`:await tc();break;case`view`:await sc();break;case`rename`:await oc();break;case`remove`:await rc();break;case`add-field`:await Ws();break;case`remove-field`:await ic();break;case`add-variation`:await Gs();break;case`remove-variation`:await ac();break;case`list-variations`:await nc();break;case`set-screenshot`:await Ys();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
2103
2130
 
2104
2131
  USAGE
2105
2132
  prismic slice <command> [flags]
@@ -2121,7 +2148,7 @@ FLAGS
2121
2148
  -h, --help Show help for command
2122
2149
 
2123
2150
  LEARN MORE
2124
- Use \`prismic slice <command> --help\` for more information about a command.`)}}async function nc(e){let t=Tn(p(e?.homeDir??d())),n=new URL(`.codex/`,t),r=[oc(`Claude`,new URL(`.claude/`,t),new URL(`.claude/skills/`,t)),oc(`Cursor`,new URL(`.cursor/`,t),new URL(`.cursor/skills/`,t)),oc(`Gemini`,new URL(`.gemini/`,t),new URL(`.gemini/skills/`,t)),oc(`OpenCode`,new URL(`.config/opencode/`,t),new URL(`.config/opencode/skill/`,t)),oc(`Codex`,n,new URL(`skills/`,n))],i=[];for(let e of r)await Nn(e.baseDir)&&i.push(e);return i}async function rc(){let{values:{dryRun:t,help:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},"dry-run":{type:`boolean`,short:`n`}},allowPositionals:!0,strict:!1});if(n){console.info(`Install the Prismic skill into supported global AI tool skill directories.
2151
+ Use \`prismic slice <command> --help\` for more information about a command.`)}}async function lc(e){let t=Tn(p(e?.homeDir??d())),n=new URL(`.codex/`,t),r=[pc(`Claude`,new URL(`.claude/`,t),new URL(`.claude/skills/`,t)),pc(`Cursor`,new URL(`.cursor/`,t),new URL(`.cursor/skills/`,t)),pc(`Gemini`,new URL(`.gemini/`,t),new URL(`.gemini/skills/`,t)),pc(`OpenCode`,new URL(`.config/opencode/`,t),new URL(`.config/opencode/skill/`,t)),pc(`Codex`,n,new URL(`skills/`,n))],i=[];for(let e of r)await Nn(e.baseDir)&&i.push(e);return i}async function uc(){let{values:{"dry-run":t,help:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},"dry-run":{type:`boolean`,short:`n`}},allowPositionals:!0,strict:!1});if(n){console.info(`Install the Prismic skill into supported global AI tool skill directories.
2125
2152
 
2126
2153
  USAGE
2127
2154
  prismic skill install [flags]
@@ -2131,7 +2158,7 @@ FLAGS
2131
2158
  -n, --dry-run Preview actions without writing files
2132
2159
 
2133
2160
  LEARN MORE
2134
- This command currently installs to global/user tool directories only.`);return}let r=await nc();if(r.length===0){console.error(`No supported global AI tool directories were detected (Claude, Cursor, Gemini, OpenCode, Codex).`),process.exitCode=1;return}let i=[];if(i.push(...await ic(r)),i.length>0){console.error(`Skill already exists in one or more targets:`);for(let e of i)console.error(`- ${f(e.skillFile)}`);console.error(`Nothing was installed. Remove existing files and retry.`),process.exitCode=1;return}if(t){for(let e of r)console.info(`Installed: ${f(e.skillFile)}`);console.info(`Installed ${r.length} Prismic skill file(s).`);return}let a=await ac(`---
2161
+ This command currently installs to global/user tool directories only.`);return}let r=await lc();if(r.length===0){console.error(`No supported global AI tool directories were detected (Claude, Cursor, Gemini, OpenCode, Codex).`),process.exitCode=1;return}let i=[];if(i.push(...await dc(r)),i.length>0){console.error(`Skill already exists in one or more targets:`);for(let e of i)console.error(`- ${f(e.skillFile)}`);console.error(`Nothing was installed. Remove existing files and retry.`),process.exitCode=1;return}if(t){for(let e of r)console.info(`Installed: ${f(e.skillFile)}`);console.info(`Installed ${r.length} Prismic skill file(s).`);return}let a=await fc(`---
2135
2162
  name: prismic
2136
2163
  description: Use when a task involves Prismic setup, repository configuration, content modeling, content type or slice changes, localization, previews, API tokens, webhooks, syncing local models, or reading Prismic documentation.
2137
2164
  allowed-tools: Bash(prismic *)
@@ -2143,9 +2170,9 @@ For Prismic-related tasks, use the \`prismic\` CLI first.
2143
2170
 
2144
2171
  1. Discover capabilities with \`prismic --help\`.
2145
2172
  2. Inspect details with \`prismic <command> --help\`.
2146
- 3. Use \`prismic docs <path>\` when documentation is needed.
2173
+ 3. Use \`prismic docs list\` to discover docs paths, then \`prismic docs fetch <path>\` when documentation is needed.
2147
2174
  4. Prefer CLI workflows over direct API/manual changes.
2148
- 5. If the CLI does not support a required operation, state that explicitly, then use the next-best fallback.`,r);if(!a.ok){console.error(`Failed to install skill for ${a.target.tool}: ${a.error}`),console.error(`Path: ${f(a.target.skillFile)}`),process.exitCode=1;return}let o=a.installedPaths;for(let e of o)console.info(`Installed: ${e}`);console.info(`Installed ${o.length} Prismic skill file(s).`)}async function ic(e){let t=[];for(let n of e)await Nn(n.skillFile)&&t.push(n);return t}async function ac(e,t){let r=[];for(let i of t)try{await n(i.skillDir,{recursive:!0}),await c(i.skillFile,e),r.push(f(i.skillFile))}catch(e){return{ok:!1,target:i,error:e instanceof Error?e.message:String(e)}}return{ok:!0,installedPaths:r}}function oc(e,t,n){let r=new URL(`prismic/`,n);return{tool:e,baseDir:t,skillsDir:n,skillDir:r,skillFile:new URL(`SKILL.md`,r)}}async function sc(){let{values:{dryRun:t,help:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},"dry-run":{type:`boolean`,short:`n`}},allowPositionals:!0,strict:!1});if(n){console.info(`Uninstall the Prismic skill from supported global AI tool skill directories.
2175
+ 5. If the CLI does not support a required operation, state that explicitly, then use the next-best fallback.`,r);if(!a.ok){console.error(`Failed to install skill for ${a.target.tool}: ${a.error}`),console.error(`Path: ${f(a.target.skillFile)}`),process.exitCode=1;return}let o=a.installedPaths;for(let e of o)console.info(`Installed: ${e}`);console.info(`Installed ${o.length} Prismic skill file(s).`)}async function dc(e){let t=[];for(let n of e)await Nn(n.skillFile)&&t.push(n);return t}async function fc(e,t){let r=[];for(let i of t)try{await n(i.skillDir,{recursive:!0}),await c(i.skillFile,e),r.push(f(i.skillFile))}catch(e){return{ok:!1,target:i,error:e instanceof Error?e.message:String(e)}}return{ok:!0,installedPaths:r}}function pc(e,t,n){let r=new URL(`prismic/`,n);return{tool:e,baseDir:t,skillsDir:n,skillDir:r,skillFile:new URL(`SKILL.md`,r)}}async function mc(){let{values:{"dry-run":t,help:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},"dry-run":{type:`boolean`,short:`n`}},allowPositionals:!0,strict:!1});if(n){console.info(`Uninstall the Prismic skill from supported global AI tool skill directories.
2149
2176
 
2150
2177
  USAGE
2151
2178
  prismic skill uninstall [flags]
@@ -2155,7 +2182,7 @@ FLAGS
2155
2182
  -n, --dry-run Preview actions without removing files
2156
2183
 
2157
2184
  LEARN MORE
2158
- This command currently uninstalls from global/user tool directories only.`);return}let r=await nc(),i=[];for(let e of r)if(await Nn(e.skillFile)&&(i.push(f(e.skillFile)),!t)){try{await o(e.skillFile)}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`Failed to remove skill for ${e.tool}: ${n}`),console.error(`Path: ${f(e.skillFile)}`),process.exitCode=1;return}try{await s(e.skillDir)}catch(t){if(t&&typeof t==`object`&&`code`in t){let e=String(t.code);if(e===`ENOTEMPTY`||e===`ENOENT`)continue}let n=t instanceof Error?t.message:String(t);console.error(`Failed to clean up skill directory for ${e.tool}: ${n}`),console.error(`Path: ${f(e.skillDir)}`),process.exitCode=1;return}}if(i.length===0){console.info(`No Prismic skill installation found. Nothing to uninstall.`);return}for(let e of i)console.info(`Removed: ${e}`);console.info(`Uninstalled ${i.length} Prismic skill file(s).`)}async function cc(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`install`:await rc();break;case`uninstall`:await sc();break;default:t&&(console.error(`Unknown skill subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic skills in supported AI tool directories.
2185
+ This command currently uninstalls from global/user tool directories only.`);return}let r=await lc(),i=[];for(let e of r)if(await Nn(e.skillFile)&&(i.push(f(e.skillFile)),!t)){try{await o(e.skillFile)}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`Failed to remove skill for ${e.tool}: ${n}`),console.error(`Path: ${f(e.skillFile)}`),process.exitCode=1;return}try{await s(e.skillDir)}catch(t){if(t&&typeof t==`object`&&`code`in t){let e=String(t.code);if(e===`ENOTEMPTY`||e===`ENOENT`)continue}let n=t instanceof Error?t.message:String(t);console.error(`Failed to clean up skill directory for ${e.tool}: ${n}`),console.error(`Path: ${f(e.skillDir)}`),process.exitCode=1;return}}if(i.length===0){console.info(`No Prismic skill installation found. Nothing to uninstall.`);return}for(let e of i)console.info(`Removed: ${e}`);console.info(`Uninstalled ${i.length} Prismic skill file(s).`)}async function hc(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`install`:await uc();break;case`uninstall`:await mc();break;default:t&&(console.error(`Unknown skill subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic skills in supported AI tool directories.
2159
2186
 
2160
2187
  USAGE
2161
2188
  prismic skill <command> [flags]
@@ -2168,7 +2195,7 @@ FLAGS
2168
2195
  -h, --help Show help for command
2169
2196
 
2170
2197
  LEARN MORE
2171
- Use \`prismic skill <command> --help\` for more information about a command.`)}}const lc={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function uc(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a webhook in a Prismic repository.
2198
+ Use \`prismic skill <command> --help\` for more information about a command.`)}}const gc={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function _c(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a webhook in a Prismic repository.
2172
2199
 
2173
2200
  By default, this command reads the repository from prismic.config.json at the
2174
2201
  project root.
@@ -2184,7 +2211,7 @@ FLAGS
2184
2211
  -h, --help Show help for command
2185
2212
 
2186
2213
  LEARN MORE
2187
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){dc();return}let i=await pc(n);if(!i.ok){i.error instanceof Q?dc():(console.error(`Failed to view webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let{config:o}=a;console.info(`URL: ${o.url}`),console.info(`Name: ${o.name||`(none)`}`),console.info(`Status: ${o.active?`enabled`:`disabled`}`),console.info(`Secret: ${o.secret?`(set)`:`(none)`}`);let s=[];for(let[e,t]of Object.entries(lc))o[e]&&s.push(t);if(console.info(`Triggers: ${s.length>0?s.join(`, `):`(none)`}`),Object.keys(o.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(o.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}function dc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const fc=N({config:N({_id:I(),url:I(),active:M(),name:yn(I()),secret:yn(I()),headers:F(I(),I()),documentsPublished:M(),documentsUnpublished:M(),releasesCreated:M(),releasesUpdated:M(),tagsCreated:M(),tagsDeleted:M()})});async function pc(e){return await Z(new URL(`/app/settings/webhooks`,await z(e)),{schema:j(fc)})}function mc(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`;default:return``}}function hc(e,t){return e?`\`prismic docs ${t?`${e}${t}`:e}\``:``}function gc(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}function _c(e){switch(e){case`next`:return`#set-up-previews-in-next-js`;case`sveltekit`:return`#set-up-previews-in-sveltekit`;default:return``}}function vc(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}function yc(e,t){let n=[],r=mc(t.framework),i=e.filter(e=>!e.done&&e.hint===`not installed`);if(i.length>0){let e=i.map(e=>e.label).join(` `);n.push({action:`Install dependencies: Run \`npm install ${e}\``})}if(e.find(e=>!e.done&&e.hint?.includes(`client`))){let e=hc(r,gc(t.framework));n.push({action:`Create Prismic client file: Run ${e} and create the file as shown`})}return n}function bc(e){let t=[],n=e.some(e=>e.status===`to_push`),r=e.some(e=>e.status===`to_pull`);return n&&t.push({action:"Push local models to Prismic: Run `prismic push`"}),r&&t.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),t}function xc(e,t,n,r){let i=[],a=mc(r.framework);if(t.length>0){let e=hc(a,vc(r.framework));i.push({action:`Implement slice components: Run ${e} and create each component file`})}let o=e.some(e=>e.status===`to_pull`),s=e.some(e=>e.status===`to_push`);if(o&&i.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),n.length>0){let e=[...n].sort()[0];i.push({action:`Connect slice to page type: Run \`prismic page-type connect-slice <type-id> ${e}\``})}return s&&i.push({action:"Push local models to Prismic: Run `prismic push`"}),i}function Sc(e,t){let n=[],r=mc(t.framework);if(e.find(e=>e.label===`/slice-simulator route`&&!e.done)){let e=hc(r,`#set-up-live-previewing`);n.push({action:`Create /slice-simulator route: Run ${e} and create the route file as shown`})}e.find(e=>e.label===`Slice simulator URL`&&!e.done)&&n.push({action:"Configure slice simulator URL: Run `prismic preview set-simulator`"});let i=e.find(e=>e.label===`/api/preview endpoint`&&!e.done),a=e.find(e=>e.label===`/api/exit-preview endpoint`&&!e.done);if(i||a){let e=hc(r,_c(t.framework));n.push({action:`Create preview endpoints: Run ${e} and create the endpoint files as shown`})}return e.find(e=>e.label===`Preview environment`&&!e.done)&&n.push({action:"Add preview environment: Run `prismic preview add`"}),n}function Cc(e,t){let n=[],r=mc(t.framework);if(e.find(e=>e.label===`/api/revalidate endpoint`&&!e.done)){let e=hc(r,`#handle-content-changes`);n.push({action:`Create /api/revalidate endpoint: Run ${e} and create the endpoint as shown`})}return e.find(e=>e.label===`Revalidation webhook`&&!e.done)&&n.push({action:"Create revalidation webhook: Run `prismic webhook create`"}),n}async function wc(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the status of the current Prismic project.
2214
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){vc();return}let i=await bc(n);if(!i.ok){i.error instanceof Q?vc():(console.error(`Failed to view webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let{config:o}=a;console.info(`URL: ${o.url}`),console.info(`Name: ${o.name||`(none)`}`),console.info(`Status: ${o.active?`enabled`:`disabled`}`),console.info(`Secret: ${o.secret?`(set)`:`(none)`}`);let s=[];for(let[e,t]of Object.entries(gc))o[e]&&s.push(t);if(console.info(`Triggers: ${s.length>0?s.join(`, `):`(none)`}`),Object.keys(o.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(o.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}function vc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const yc=N({config:N({_id:I(),url:I(),active:M(),name:yn(I()),secret:yn(I()),headers:F(I(),I()),documentsPublished:M(),documentsUnpublished:M(),releasesCreated:M(),releasesUpdated:M(),tagsCreated:M(),tagsDeleted:M()})});async function bc(e){return await Z(new URL(`/app/settings/webhooks`,await z(e)),{schema:j(yc)})}function xc(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`;default:return``}}function Sc(e,t){return e?`\`prismic docs fetch ${t?`${e}${t}`:e}\``:``}function Cc(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}function wc(e){switch(e){case`next`:return`#set-up-previews-in-next-js`;case`sveltekit`:return`#set-up-previews-in-sveltekit`;default:return``}}function Tc(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}function Ec(e,t){let n=[],r=xc(t.framework),i=e.filter(e=>!e.done&&e.hint===`not installed`);if(i.length>0){let e=i.map(e=>e.label).join(` `);n.push({action:`Install dependencies: Run \`npm install ${e}\``})}if(e.find(e=>!e.done&&e.hint?.includes(`client`))){let e=Sc(r,Cc(t.framework));n.push({action:`Create Prismic client file: Run ${e} and create the file as shown`})}return n}function Dc(e){let t=[],n=e.some(e=>e.status===`to_push`),r=e.some(e=>e.status===`to_pull`);return n&&t.push({action:"Push local models to Prismic: Run `prismic push`"}),r&&t.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),t}function Oc(e,t,n,r){let i=[],a=xc(r.framework);if(t.length>0){let e=Sc(a,Tc(r.framework));i.push({action:`Implement slice components: Run ${e} and create each component file`})}let o=e.some(e=>e.status===`to_pull`),s=e.some(e=>e.status===`to_push`);if(o&&i.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),n.length>0){let e=[...n].sort()[0];i.push({action:`Connect slice to page type: Run \`prismic page-type connect-slice <type-id> ${e}\``})}return s&&i.push({action:"Push local models to Prismic: Run `prismic push`"}),i}function kc(e,t){let n=[],r=xc(t.framework);if(e.find(e=>e.label===`/slice-simulator route`&&!e.done)){let e=Sc(r,`#set-up-live-previewing`);n.push({action:`Create /slice-simulator route: Run ${e} and create the route file as shown`})}e.find(e=>e.label===`Slice simulator URL`&&!e.done)&&n.push({action:"Configure slice simulator URL: Run `prismic preview set-simulator`"});let i=e.find(e=>e.label===`/api/preview endpoint`&&!e.done),a=e.find(e=>e.label===`/api/exit-preview endpoint`&&!e.done);if(i||a){let e=Sc(r,wc(t.framework));n.push({action:`Create preview endpoints: Run ${e} and create the endpoint files as shown`})}return e.find(e=>e.label===`Preview environment`&&!e.done)&&n.push({action:"Add preview environment: Run `prismic preview add`"}),n}function Ac(e,t){let n=[],r=xc(t.framework);if(e.find(e=>e.label===`/api/revalidate endpoint`&&!e.done)){let e=Sc(r,`#handle-content-changes`);n.push({action:`Create /api/revalidate endpoint: Run ${e} and create the endpoint as shown`})}return e.find(e=>e.label===`Revalidation webhook`&&!e.done)&&n.push({action:"Create revalidation webhook: Run `prismic webhook create`"}),n}async function jc(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the status of the current Prismic project.
2188
2215
 
2189
2216
  Each section with incomplete items includes "Next steps:" with actionable
2190
2217
  instructions.
@@ -2200,7 +2227,7 @@ FLAGS
2200
2227
  -h, --help Show help for command
2201
2228
 
2202
2229
  LEARN MORE
2203
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}let r=await $();if(!r){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let[i,a,o,s,c,l,u,d]=await Promise.all([Dc(n),kc(n),pc(n),Un(),Vn(n),Wn(),Hn(n),jc(r)]),f=await z(n);console.info(`Repository: ${n}`),console.info(`URL: ${f.href}`),console.info(``);let p=[],m=await Mc(r,d);if(m.nextSteps=yc(m.items,r),p.push(m),s.ok&&c.ok){let{pageTypes:e,customTypes:t,pageTypeStatuses:n,customTypeStatuses:r}=Fc(s.value,c.value);e.nextSteps=bc(n),t.nextSteps=bc(r),p.push(e),p.push(t)}if(l.ok&&u.ok){let{section:e,statuses:t,missingComponents:n,slicesReadyToConnect:i}=await zc(l.value,u.value,r,s.ok?s.value:[]);e.nextSteps=xc(t,n,i,r),p.push(e)}let h=await Hc(r,a.ok?a.value:void 0,i.ok?i.value.simulator_url:void 0);if(h.nextSteps=Sc(h.items,r),p.push(h),r.framework===`next`){let e=await Wc(r,o.ok?o.value:[]);e.nextSteps=Cc(e.items,r),p.push(e)}for(let e of p)Tc(e)}function Tc(e){let t=e.items.filter(e=>!e.done).length,n=t>0?`${e.title} (${t} remaining)`:e.title;console.info(n);let r=e.items.filter(e=>e.done),i=e.items.filter(e=>!e.done);if(r.length>0)if(r.length===1){let e=r[0],t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ✓ ${e.label}${t}`)}else{let e=r.map(e=>e.label).join(`, `),t=r.every(e=>e.hint===r[0].hint)&&r[0].hint?` \u2014 ${r[0].hint}`:``;console.info(` ✓ ${e}${t}`)}for(let e of i){let t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ○ ${e.label}${t}`)}if(e.nextSteps&&e.nextSteps.length>0){console.info(``),console.info(` Next steps:`);for(let t of e.nextSteps)console.info(` - ${t.action}`)}console.info(``)}const Ec=N({simulator_url:P(I())});async function Dc(e){let t=await Z(new URL(`/core/repository`,await z(e)),{schema:Ec});return t.ok?{ok:!0,value:t.value}:{ok:!1}}const Oc=N({results:j(N({id:I(),label:I(),url:I()}))});async function kc(e){let t=await Z(new URL(`/core/repository/preview_configs`,await z(e)),{schema:Oc});return t.ok?{ok:!0,value:t.value.results}:{ok:!1}}const Ac=N({dependencies:P(F(I(),I())),devDependencies:P(F(I(),I()))});async function jc(e){let t=new URL(`package.json`,e.projectRoot);try{let e=await r(t,`utf8`),{dependencies:n={},devDependencies:i={}}=xn(Ac,JSON.parse(e));return new Set([...Object.keys(n),...Object.keys(i)])}catch{return new Set}}async function Mc(e,t){let n=[],r=Mi(e.framework);for(let e of r)n.push({done:t.has(e),label:e,hint:t.has(e)?`installed`:`not installed`});let i=Ni(e);if(i){let t=await Nn(new URL(i,e.projectRoot));n.push({done:t,label:i,hint:t?void 0:`create Prismic client file`})}else if(e.framework===`nuxt`){let t=await Nc(e);n.push({done:t,label:`nuxt.config.ts`,hint:t?`prismic configured`:`add @nuxtjs/prismic to modules`})}return{title:`Setup`,items:n}}async function Nc(e){let t=new URL(`nuxt.config.ts`,e.projectRoot);try{let e=await r(t,`utf8`);return e.includes(`@nuxtjs/prismic`)||e.includes(`prismic:`)}catch{return!1}}function Pc(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e){let e=t.label||t.id,n=r.get(t.id);n&&JSON.stringify(t)===JSON.stringify(n)?i.push({id:t.id,label:e,status:`in_sync`}):i.push({id:t.id,label:e,status:`to_push`})}for(let e of t)if(!n.has(e.id)){let t=e.label||e.id;i.push({id:e.id,label:t,status:`to_pull`})}return i}function Fc(e,t){let n=Pc(e,t),r=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return a&&a.format===`page`}),i=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return!a||a.format!==`page`}),a=r.map(e=>({done:e.status===`in_sync`,label:e.label,hint:Ic(e.status)})),o=i.map(e=>({done:e.status===`in_sync`,label:e.label,hint:Ic(e.status)}));return{pageTypes:{title:`Page Types`,items:a},customTypes:{title:`Custom Types`,items:o},pageTypeStatuses:r,customTypeStatuses:i}}function Ic(e){switch(e){case`in_sync`:return`in sync`;case`to_push`:return`to push`;case`to_pull`:return`to pull`}}function Lc(e){for(let t of e.variations){let e=Object.keys(t.primary??{}),n=Object.keys(t.items??{});if(e.length>0||n.length>0)return!0}return!1}function Rc(e,t){for(let n of t)for(let t of Object.values(n.json))for(let n of Object.values(t)){let t=n;if(t.type===`Slices`&&t.config?.choices?.[e])return!0}return!1}async function zc(e,t,n,r){let i=Pc(e,t),a=[],o=[],s=[],c=Pi(n),l=Fi(n.framework);for(let t of i){let i=e.find(e=>e.id===t.id);if(i){let e=Lc(i),n=Rc(t.id,r);e&&!n&&s.push(t.label)}let u=await Bc(n,c,t.id,l);t.status===`in_sync`&&u?a.push({done:!0,label:t.label,hint:`component implemented`}):t.status===`in_sync`&&!u?(a.push({done:!1,label:t.label,hint:`missing component`}),o.push(t.label)):a.push({done:!1,label:t.label,hint:Ic(t.status)})}return{section:{title:`Slices`,items:a},statuses:i,missingComponents:o,slicesReadyToConnect:s}}async function Bc(e,t,n,r){let i=Vc(n);for(let n of r)if(await Nn(new URL(`${t}${i}/index${n}`,e.projectRoot)))return!0;return!1}function Vc(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Hc(e,t,n){let r=[];r.push({done:!!n,label:`Slice simulator URL`,hint:n?`configured`:"run `prismic preview set-simulator`"});let i=Ii(e,`/slice-simulator`);if(i){let t=await Uc(e,i);r.push({done:t,label:`/slice-simulator route`,hint:t?void 0:`create route for Page Builder`})}let a=t&&t.length>0;if(r.push({done:!!a,label:`Preview environment`,hint:a?void 0:"run `prismic preview add`"}),e.framework!==`nuxt`){let t=Ii(e,`/api/preview`);if(t){let n=await Uc(e,t);r.push({done:n,label:`/api/preview endpoint`,hint:n?void 0:`create preview endpoint`})}}if(e.framework===`next`){let t=Ii(e,`/api/exit-preview`);if(t){let n=await Uc(e,t);r.push({done:n,label:`/api/exit-preview endpoint`,hint:n?void 0:`create exit-preview endpoint`})}}return{title:`Preview`,items:r}}async function Uc(e,t){for(let n of t.extensions)if(await Nn(new URL(`${t.path}${n}`,e.projectRoot)))return!0;return!1}async function Wc(e,t){let n=[],r=Ii(e,`/api/revalidate`);if(r){let t=await Uc(e,r);n.push({done:t,label:`/api/revalidate endpoint`,hint:t?void 0:`create for ISR`})}let i=t.some(e=>e.config.active&&e.config.url.toLowerCase().includes(`revalidate`));return n.push({done:i,label:`Revalidation webhook`,hint:i?`configured`:"run `prismic webhook create`"}),{title:`Deployment`,items:n}}async function Gc(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
2230
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}let r=await $();if(!r){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let[i,a,o,s,c,l,u,d]=await Promise.all([Pc(n),Ic(n),bc(n),Un(),Vn(n),Wn(),Hn(n),Rc(r)]),f=await z(n);console.info(`Repository: ${n}`),console.info(`URL: ${f.href}`),console.info(``);let p=[],m=await zc(r,d);if(m.nextSteps=Ec(m.items,r),p.push(m),s.ok&&c.ok){let{pageTypes:e,customTypes:t,pageTypeStatuses:n,customTypeStatuses:r}=Hc(s.value,c.value);e.nextSteps=Dc(n),t.nextSteps=Dc(r),p.push(e),p.push(t)}if(l.ok&&u.ok){let{section:e,statuses:t,missingComponents:n,slicesReadyToConnect:i}=await Kc(l.value,u.value,r,s.ok?s.value:[]);e.nextSteps=Oc(t,n,i,r),p.push(e)}let h=await Yc(r,a.ok?a.value:void 0,i.ok?i.value.simulator_url:void 0);if(h.nextSteps=kc(h.items,r),p.push(h),r.framework===`next`){let e=await Zc(r,o.ok?o.value:[]);e.nextSteps=Ac(e.items,r),p.push(e)}for(let e of p)Mc(e)}function Mc(e){let t=e.items.filter(e=>!e.done).length,n=t>0?`${e.title} (${t} remaining)`:e.title;console.info(n);let r=e.items.filter(e=>e.done),i=e.items.filter(e=>!e.done);if(r.length>0)if(r.length===1){let e=r[0],t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ✓ ${e.label}${t}`)}else{let e=r.map(e=>e.label).join(`, `),t=r.every(e=>e.hint===r[0].hint)&&r[0].hint?` \u2014 ${r[0].hint}`:``;console.info(` ✓ ${e}${t}`)}for(let e of i){let t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ○ ${e.label}${t}`)}if(e.nextSteps&&e.nextSteps.length>0){console.info(``),console.info(` Next steps:`);for(let t of e.nextSteps)console.info(` - ${t.action}`)}console.info(``)}const Nc=N({simulator_url:P(I())});async function Pc(e){let t=await Z(new URL(`/core/repository`,await z(e)),{schema:Nc});return t.ok?{ok:!0,value:t.value}:{ok:!1}}const Fc=N({results:j(N({id:I(),label:I(),url:I()}))});async function Ic(e){let t=await Z(new URL(`/core/repository/preview_configs`,await z(e)),{schema:Fc});return t.ok?{ok:!0,value:t.value.results}:{ok:!1}}const Lc=N({dependencies:P(F(I(),I())),devDependencies:P(F(I(),I()))});async function Rc(e){let t=new URL(`package.json`,e.projectRoot);try{let e=await r(t,`utf8`),{dependencies:n={},devDependencies:i={}}=xn(Lc,JSON.parse(e));return new Set([...Object.keys(n),...Object.keys(i)])}catch{return new Set}}async function zc(e,t){let n=[],r=zi(e.framework);for(let e of r)n.push({done:t.has(e),label:e,hint:t.has(e)?`installed`:`not installed`});let i=Bi(e);if(i){let t=await Nn(new URL(i,e.projectRoot));n.push({done:t,label:i,hint:t?void 0:`create Prismic client file`})}else if(e.framework===`nuxt`){let t=await Bc(e);n.push({done:t,label:`nuxt.config.ts`,hint:t?`prismic configured`:`add @nuxtjs/prismic to modules`})}return{title:`Setup`,items:n}}async function Bc(e){let t=new URL(`nuxt.config.ts`,e.projectRoot);try{let e=await r(t,`utf8`);return e.includes(`@nuxtjs/prismic`)||e.includes(`prismic:`)}catch{return!1}}function Vc(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e){let e=t.label||t.id,n=r.get(t.id);n&&JSON.stringify(t)===JSON.stringify(n)?i.push({id:t.id,label:e,status:`in_sync`}):i.push({id:t.id,label:e,status:`to_push`})}for(let e of t)if(!n.has(e.id)){let t=e.label||e.id;i.push({id:e.id,label:t,status:`to_pull`})}return i}function Hc(e,t){let n=Vc(e,t),r=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return a&&a.format===`page`}),i=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return!a||a.format!==`page`}),a=r.map(e=>({done:e.status===`in_sync`,label:e.label,hint:Uc(e.status)})),o=i.map(e=>({done:e.status===`in_sync`,label:e.label,hint:Uc(e.status)}));return{pageTypes:{title:`Page Types`,items:a},customTypes:{title:`Custom Types`,items:o},pageTypeStatuses:r,customTypeStatuses:i}}function Uc(e){switch(e){case`in_sync`:return`in sync`;case`to_push`:return`to push`;case`to_pull`:return`to pull`}}function Wc(e){for(let t of e.variations){let e=Object.keys(t.primary??{}),n=Object.keys(t.items??{});if(e.length>0||n.length>0)return!0}return!1}function Gc(e,t){for(let n of t)for(let t of Object.values(n.json))for(let n of Object.values(t)){let t=n;if(t.type===`Slices`&&t.config?.choices?.[e])return!0}return!1}async function Kc(e,t,n,r){let i=Vc(e,t),a=[],o=[],s=[],c=Vi(n),l=Hi(n.framework);for(let t of i){let i=e.find(e=>e.id===t.id);if(i){let e=Wc(i),n=Gc(t.id,r);e&&!n&&s.push(t.label)}let u=await qc(n,c,t.id,l);t.status===`in_sync`&&u?a.push({done:!0,label:t.label,hint:`component implemented`}):t.status===`in_sync`&&!u?(a.push({done:!1,label:t.label,hint:`missing component`}),o.push(t.label)):a.push({done:!1,label:t.label,hint:Uc(t.status)})}return{section:{title:`Slices`,items:a},statuses:i,missingComponents:o,slicesReadyToConnect:s}}async function qc(e,t,n,r){let i=Jc(n);for(let n of r)if(await Nn(new URL(`${t}${i}/index${n}`,e.projectRoot)))return!0;return!1}function Jc(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Yc(e,t,n){let r=[];r.push({done:!!n,label:`Slice simulator URL`,hint:n?`configured`:"run `prismic preview set-simulator`"});let i=Ui(e,`/slice-simulator`);if(i){let t=await Xc(e,i);r.push({done:t,label:`/slice-simulator route`,hint:t?void 0:`create route for Page Builder`})}let a=t&&t.length>0;if(r.push({done:!!a,label:`Preview environment`,hint:a?void 0:"run `prismic preview add`"}),e.framework!==`nuxt`){let t=Ui(e,`/api/preview`);if(t){let n=await Xc(e,t);r.push({done:n,label:`/api/preview endpoint`,hint:n?void 0:`create preview endpoint`})}}if(e.framework===`next`){let t=Ui(e,`/api/exit-preview`);if(t){let n=await Xc(e,t);r.push({done:n,label:`/api/exit-preview endpoint`,hint:n?void 0:`create exit-preview endpoint`})}}return{title:`Preview`,items:r}}async function Xc(e,t){for(let n of t.extensions)if(await Nn(new URL(`${t.path}${n}`,e.projectRoot)))return!0;return!1}async function Zc(e,t){let n=[],r=Ui(e,`/api/revalidate`);if(r){let t=await Xc(e,r);n.push({done:t,label:`/api/revalidate endpoint`,hint:t?void 0:`create for ISR`})}let i=t.some(e=>e.config.active&&e.config.url.toLowerCase().includes(`revalidate`));return n.push({done:i,label:`Revalidation webhook`,hint:i?`configured`:"run `prismic webhook create`"}),{title:`Deployment`,items:n}}async function Qc(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
2204
2231
 
2205
2232
  By default, this command reads the repository from prismic.config.json at the
2206
2233
  project root.
@@ -2214,7 +2241,7 @@ FLAGS
2214
2241
  -h, --help Show help for command
2215
2242
 
2216
2243
  LEARN MORE
2217
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){nl();return}let[i,a]=await Promise.all([Qc(n),$c(n)]);if(!i.ok){i.error instanceof Q||i.error instanceof ui?nl():A(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Q||a.error instanceof ui?nl():A(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(a.value)}`),process.exitCode=1);return}let o=i.value.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,appId:e.id,authId:t.id,scope:t.scope,token:t.token,createdAt:t.created_at.$date}))),s=a.value.tokens;if(r)console.info(J({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=el(e.token),n=tl(e.createdAt);console.info(` ${e.name} ${e.scope} ${t} ${n}`)}}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),s.length>0){console.info(`WRITE TOKENS`);for(let e of s){let t=el(e.token),n=tl(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Kc=N({$date:bn()}),qc=N({id:I(),origin:I(),domain:I(),app:I(),scope:I(),expired_at:Kc,created_at:Kc,owner:yn(I()),token:I()}),Jc=N({id:I(),secret:I(),name:I(),owner:I(),created_at:Kc,authorized_domains:j(I()),wroom_auths:j(qc)}),Yc=N({app_name:I(),token:I(),timestamp:bn()}),Xc=N({max_tokens:bn(),tokens:j(Yc)}),Zc=j(Jc);async function Qc(e){return await Z(new URL(`settings/security/contentapi`,await z(e)),{schema:Zc})}async function $c(e){return await Z(new URL(`settings/security/customtypesapi`,await z(e)),{schema:Xc})}function el(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function tl(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function nl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function rl(){let{values:{help:t,repo:n=await X(),json:r,write:i,name:a=`Prismic CLI`,"allow-releases":o}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`},write:{type:`boolean`,short:`w`},name:{type:`string`,short:`n`},"allow-releases":{type:`boolean`}},allowPositionals:!1});if(t){console.info(`Create a new API token for a Prismic repository.
2244
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ll();return}let[i,a]=await Promise.all([al(n),ol(n)]);if(!i.ok){i.error instanceof Q||i.error instanceof _i?ll():A(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Q||a.error instanceof _i?ll():A(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(a.value)}`),process.exitCode=1);return}let o=i.value.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,appId:e.id,authId:t.id,scope:t.scope,token:t.token,createdAt:t.created_at.$date}))),s=a.value.tokens;if(r)console.info(J({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=sl(e.token),n=cl(e.createdAt);console.info(` ${e.name} ${e.scope} ${t} ${n}`)}}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),s.length>0){console.info(`WRITE TOKENS`);for(let e of s){let t=sl(e.token),n=cl(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const $c=N({$date:bn()}),el=N({id:I(),origin:I(),domain:I(),app:I(),scope:I(),expired_at:$c,created_at:$c,owner:yn(I()),token:I()}),tl=N({id:I(),secret:I(),name:I(),owner:I(),created_at:$c,authorized_domains:j(I()),wroom_auths:j(el)}),nl=N({app_name:I(),token:I(),timestamp:bn()}),rl=N({max_tokens:bn(),tokens:j(nl)}),il=j(tl);async function al(e){return await Z(new URL(`settings/security/contentapi`,await z(e)),{schema:il})}async function ol(e){return await Z(new URL(`settings/security/customtypesapi`,await z(e)),{schema:rl})}function sl(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function cl(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function ll(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ul(){let{values:{help:t,repo:n=await X(),json:r,write:i,name:a=`Prismic CLI`,"allow-releases":o}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`},write:{type:`boolean`,short:`w`},name:{type:`string`,short:`n`},"allow-releases":{type:`boolean`}},allowPositionals:!1});if(t){console.info(`Create a new API token for a Prismic repository.
2218
2245
 
2219
2246
  By default, this command reads the repository from prismic.config.json at the
2220
2247
  project root.
@@ -2231,7 +2258,7 @@ FLAGS
2231
2258
  -h, --help Show help for command
2232
2259
 
2233
2260
  LEARN MORE
2234
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await B()){ol();return}if(i){let e=await il(n,a);if(!e.ok){e.error instanceof Q||e.error instanceof ui?ol():A(e.error)?(console.error(`Failed to create write token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${J(e.value)}`),process.exitCode=1);return}r?console.info(J(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await al(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof Q||e.error instanceof ui?ol():A(e.error)?(console.error(`Failed to create access token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${J(e.value)}`),process.exitCode=1);return}r?console.info(J(e.value)):console.info(`Token created: ${e.value.token}`)}}async function il(e,t){return await Z(new URL(`settings/security/token`,await z(e)),{method:`POST`,body:{app_name:t},schema:Yc})}async function al(e,t,n){let r=await Qc(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await Z(new URL(`settings/security/oauthapp`,await z(e)),{method:`POST`,body:{app_name:t},schema:Jc});if(!n.ok)return n;i=n.value}return await Z(new URL(`settings/security/authorizations`,await z(e)),{method:`POST`,body:{app:i.id,scope:n},schema:qc})}function ol(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function sl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a token from a Prismic repository.
2261
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await B()){pl();return}if(i){let e=await dl(n,a);if(!e.ok){e.error instanceof Q||e.error instanceof _i?pl():A(e.error)?(console.error(`Failed to create write token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${J(e.value)}`),process.exitCode=1);return}r?console.info(J(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await fl(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof Q||e.error instanceof _i?pl():A(e.error)?(console.error(`Failed to create access token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${J(e.value)}`),process.exitCode=1);return}r?console.info(J(e.value)):console.info(`Token created: ${e.value.token}`)}}async function dl(e,t){return await Z(new URL(`settings/security/token`,await z(e)),{method:`POST`,body:{app_name:t},schema:nl})}async function fl(e,t,n){let r=await al(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await Z(new URL(`settings/security/oauthapp`,await z(e)),{method:`POST`,body:{app_name:t},schema:tl});if(!n.ok)return n;i=n.value}return await Z(new URL(`settings/security/authorizations`,await z(e)),{method:`POST`,body:{app:i.id,scope:n},schema:el})}function pl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ml(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a token from a Prismic repository.
2235
2262
 
2236
2263
  By default, this command reads the repository from prismic.config.json at the
2237
2264
  project root.
@@ -2247,7 +2274,7 @@ FLAGS
2247
2274
  -h, --help Show help for command
2248
2275
 
2249
2276
  LEARN MORE
2250
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){cl();return}let[i,a]=await Promise.all([Qc(n),$c(n)]);if(!i.ok){i.error instanceof Q||i.error instanceof ui?cl():A(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Q||a.error instanceof ui?cl():A(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(a.value)}`),process.exitCode=1);return}let o;for(let e of i.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){o=t;break}if(o)break}if(o){let e=await Z(new URL(`settings/security/authorizations/${o.id}`,await z(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Q||e.error instanceof ui?cl():(console.error(`Failed to delete token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}let s=a.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r));if(s){let e=await Z(new URL(`settings/security/token/${s.token}`,await z(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Q||e.error instanceof ui?cl():(console.error(`Failed to delete token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function cl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ll(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the name of a token in a Prismic repository.
2277
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){hl();return}let[i,a]=await Promise.all([al(n),ol(n)]);if(!i.ok){i.error instanceof Q||i.error instanceof _i?hl():A(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Q||a.error instanceof _i?hl():A(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(a.value)}`),process.exitCode=1);return}let o;for(let e of i.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){o=t;break}if(o)break}if(o){let e=await Z(new URL(`settings/security/authorizations/${o.id}`,await z(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Q||e.error instanceof _i?hl():(console.error(`Failed to delete token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}let s=a.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r));if(s){let e=await Z(new URL(`settings/security/token/${s.token}`,await z(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Q||e.error instanceof _i?hl():(console.error(`Failed to delete token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function hl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function gl(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the name of a token in a Prismic repository.
2251
2278
 
2252
2279
  Note: Only access tokens can be renamed. Write tokens cannot be renamed without
2253
2280
  changing the token value.
@@ -2267,7 +2294,7 @@ FLAGS
2267
2294
  -h, --help Show help for command
2268
2295
 
2269
2296
  LEARN MORE
2270
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ul();return}let[a,o]=await Promise.all([Qc(n),$c(n)]);if(!a.ok){a.error instanceof Q||a.error instanceof ui?ul():A(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof Q||o.error instanceof ui?ul():A(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(o.value)}`),process.exitCode=1);return}let s;for(let e of a.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){s=e;break}if(s)break}if(s){let e=await Z(new URL(`settings/security/oauthapp/${s.id}`,await z(n)),{method:`POST`,body:{name:i},schema:Jc});if(!e.ok){e.error instanceof Q||e.error instanceof ui?ul():A(e.error)?(console.error(`Failed to rename token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token renamed to: ${i}`);return}if(o.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r))){console.error(`Write tokens cannot be renamed. Delete and create a new token with the desired name.`),process.exitCode=1;return}console.error(`Token not found: ${r}`),process.exitCode=1}function ul(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function dl(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Gc();break;case`create`:await rl();break;case`set-name`:await ll();break;case`delete`:await sl();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
2297
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){_l();return}let[a,o]=await Promise.all([al(n),ol(n)]);if(!a.ok){a.error instanceof Q||a.error instanceof _i?_l():A(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof Q||o.error instanceof _i?_l():A(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(o.value)}`),process.exitCode=1);return}let s;for(let e of a.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){s=e;break}if(s)break}if(s){let e=await Z(new URL(`settings/security/oauthapp/${s.id}`,await z(n)),{method:`POST`,body:{name:i},schema:tl});if(!e.ok){e.error instanceof Q||e.error instanceof _i?_l():A(e.error)?(console.error(`Failed to rename token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token renamed to: ${i}`);return}if(o.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r))){console.error(`Write tokens cannot be renamed. Delete and create a new token with the desired name.`),process.exitCode=1;return}console.error(`Token not found: ${r}`),process.exitCode=1}function _l(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function vl(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Qc();break;case`create`:await ul();break;case`set-name`:await gl();break;case`delete`:await ml();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
2271
2298
 
2272
2299
  USAGE
2273
2300
  prismic token <command> [flags]
@@ -2282,7 +2309,7 @@ FLAGS
2282
2309
  -h, --help Show help for command
2283
2310
 
2284
2311
  LEARN MORE
2285
- Use \`prismic token <command> --help\` for more information about a command.`)}}async function fl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Enable a webhook in a Prismic repository.
2312
+ Use \`prismic token <command> --help\` for more information about a command.`)}}async function yl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Enable a webhook in a Prismic repository.
2286
2313
 
2287
2314
  By default, this command reads the repository from prismic.config.json at the
2288
2315
  project root.
@@ -2298,7 +2325,7 @@ FLAGS
2298
2325
  -h, --help Show help for command
2299
2326
 
2300
2327
  LEARN MORE
2301
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ml();return}let i=await pc(n);if(!i.ok){i.error instanceof Q?ml():(console.error(`Failed to enable webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(a.config.active){console.info(`Webhook already enabled: ${r}`);return}let o=structuredClone(a.config);o.active=!0;let s=await pl(n,a.config._id,o);if(!s.ok){s.error instanceof Q?ml():(console.error(`Failed to enable webhook: ${J(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function pl(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await z(e)),i=new FormData;return i.set(`url`,n.url),i.set(`name`,n.name??``),i.set(`secret`,n.secret??``),i.set(`headers`,JSON.stringify(n.headers??{})),i.set(`active`,n.active?`on`:`off`),i.set(`documentsPublished`,n.documentsUnpublished.toString()),i.set(`documentsUnpublished`,n.documentsUnpublished.toString()),i.set(`releasesCreated`,n.documentsUnpublished.toString()),i.set(`releasesUpdated`,n.documentsUnpublished.toString()),i.set(`tagsCreated`,n.documentsUnpublished.toString()),i.set(`documentsPublished`,n.documentsUnpublished.toString()),await Z(r,{method:`POST`,body:i})}function ml(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function hl(){let{values:{help:t,repo:n=await X()},positionals:[r,i,a]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a custom HTTP header to a webhook.
2328
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){xl();return}let i=await bc(n);if(!i.ok){i.error instanceof Q?xl():(console.error(`Failed to enable webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(a.config.active){console.info(`Webhook already enabled: ${r}`);return}let o=structuredClone(a.config);o.active=!0;let s=await bl(n,a.config._id,o);if(!s.ok){s.error instanceof Q?xl():(console.error(`Failed to enable webhook: ${J(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function bl(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await z(e)),i=new FormData;return i.set(`url`,n.url),i.set(`name`,n.name??``),i.set(`secret`,n.secret??``),i.set(`headers`,JSON.stringify(n.headers??{})),i.set(`active`,n.active?`on`:`off`),i.set(`documentsPublished`,n.documentsUnpublished.toString()),i.set(`documentsUnpublished`,n.documentsUnpublished.toString()),i.set(`releasesCreated`,n.documentsUnpublished.toString()),i.set(`releasesUpdated`,n.documentsUnpublished.toString()),i.set(`tagsCreated`,n.documentsUnpublished.toString()),i.set(`documentsPublished`,n.documentsUnpublished.toString()),await Z(r,{method:`POST`,body:i})}function xl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Sl(){let{values:{help:t,repo:n=await X()},positionals:[r,i,a]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a custom HTTP header to a webhook.
2302
2329
 
2303
2330
  By default, this command reads the repository from prismic.config.json at the
2304
2331
  project root.
@@ -2316,7 +2343,7 @@ FLAGS
2316
2343
  -h, --help Show help for command
2317
2344
 
2318
2345
  LEARN MORE
2319
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){gl();return}let o=await pc(n);if(!o.ok){o.error instanceof Q?gl():(console.error(`Failed to add header: ${J(o.value)}`),process.exitCode=1);return}let s=o.value.find(e=>e.config.url===r);if(!s){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let c=structuredClone(s.config);c.headers[i]=a;let l=await pl(n,s.config._id,c);if(!l.ok){l.error instanceof Q?gl():(console.error(`Failed to add header: ${J(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function gl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const _l=Object.values(lc);async function vl(){let{values:{help:t,repo:n=await X(),name:r,secret:i,trigger:a=[]},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},secret:{type:`string`,short:`s`},trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new webhook in a Prismic repository.
2346
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Cl();return}let o=await bc(n);if(!o.ok){o.error instanceof Q?Cl():(console.error(`Failed to add header: ${J(o.value)}`),process.exitCode=1);return}let s=o.value.find(e=>e.config.url===r);if(!s){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let c=structuredClone(s.config);c.headers[i]=a;let l=await bl(n,s.config._id,c);if(!l.ok){l.error instanceof Q?Cl():(console.error(`Failed to add header: ${J(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function Cl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const wl=Object.values(gc);async function Tl(){let{values:{help:t,repo:n=await X(),name:r,secret:i,trigger:a=[]},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},secret:{type:`string`,short:`s`},trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new webhook in a Prismic repository.
2320
2347
 
2321
2348
  By default, this command reads the repository from prismic.config.json at the
2322
2349
  project root.
@@ -2345,7 +2372,7 @@ TRIGGERS
2345
2372
  If no triggers specified, all are enabled.
2346
2373
 
2347
2374
  LEARN MORE
2348
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!_l.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${_l.join(`, `)}`),process.exitCode=1;return}if(!await B()){bl();return}let s=!(a.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of a){let[t]=Object.entries(lc).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await yl(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof Q?bl():(console.error(`Failed to create webhook: ${J(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function yl(e,t){let n=new URL(`/app/settings/webhooks/create`,await z(e)),r=new FormData;return r.set(`url`,t.url),r.set(`name`,t.name??``),r.set(`secret`,t.secret??``),r.set(`headers`,JSON.stringify({})),r.set(`active`,`on`),r.set(`documentsPublished`,t.documentsUnpublished.toString()),r.set(`documentsUnpublished`,t.documentsUnpublished.toString()),r.set(`releasesCreated`,t.documentsUnpublished.toString()),r.set(`releasesUpdated`,t.documentsUnpublished.toString()),r.set(`tagsCreated`,t.documentsUnpublished.toString()),r.set(`documentsPublished`,t.documentsUnpublished.toString()),await Z(n,{method:`POST`,body:r})}function bl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function xl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disable a webhook in a Prismic repository.
2375
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!wl.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${wl.join(`, `)}`),process.exitCode=1;return}if(!await B()){Dl();return}let s=!(a.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of a){let[t]=Object.entries(gc).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await El(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof Q?Dl():(console.error(`Failed to create webhook: ${J(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function El(e,t){let n=new URL(`/app/settings/webhooks/create`,await z(e)),r=new FormData;return r.set(`url`,t.url),r.set(`name`,t.name??``),r.set(`secret`,t.secret??``),r.set(`headers`,JSON.stringify({})),r.set(`active`,`on`),r.set(`documentsPublished`,t.documentsUnpublished.toString()),r.set(`documentsUnpublished`,t.documentsUnpublished.toString()),r.set(`releasesCreated`,t.documentsUnpublished.toString()),r.set(`releasesUpdated`,t.documentsUnpublished.toString()),r.set(`tagsCreated`,t.documentsUnpublished.toString()),r.set(`documentsPublished`,t.documentsUnpublished.toString()),await Z(n,{method:`POST`,body:r})}function Dl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ol(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disable a webhook in a Prismic repository.
2349
2376
 
2350
2377
  By default, this command reads the repository from prismic.config.json at the
2351
2378
  project root.
@@ -2361,7 +2388,7 @@ FLAGS
2361
2388
  -h, --help Show help for command
2362
2389
 
2363
2390
  LEARN MORE
2364
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Sl();return}let i=await pc(n);if(!i.ok){i.error instanceof Q?Sl():(console.error(`Failed to disable webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!a.config.active){console.info(`Webhook already disabled: ${r}`);return}let o=structuredClone(a.config);o.active=!1;let s=await pl(n,a.config._id,o);if(!s.ok){s.error instanceof Q?Sl():(console.error(`Failed to disable webhook: ${J(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function Sl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Cl(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all webhooks in a Prismic repository.
2391
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){kl();return}let i=await bc(n);if(!i.ok){i.error instanceof Q?kl():(console.error(`Failed to disable webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!a.config.active){console.info(`Webhook already disabled: ${r}`);return}let o=structuredClone(a.config);o.active=!1;let s=await bl(n,a.config._id,o);if(!s.ok){s.error instanceof Q?kl():(console.error(`Failed to disable webhook: ${J(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function kl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Al(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all webhooks in a Prismic repository.
2365
2392
 
2366
2393
  By default, this command reads the repository from prismic.config.json at the
2367
2394
  project root.
@@ -2375,7 +2402,7 @@ FLAGS
2375
2402
  -h, --help Show help for command
2376
2403
 
2377
2404
  LEARN MORE
2378
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){wl();return}let i=await pc(n);if(!i.ok){i.error instanceof Q?wl():A(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${J(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(J(a.map(e=>e.config)));else{if(a.length===0){console.info(`No webhooks configured.`);return}for(let e of a){let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;console.info(`${e.config.url}${n} [${t}]`)}}}function wl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Tl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a webhook from a Prismic repository.
2405
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){jl();return}let i=await bc(n);if(!i.ok){i.error instanceof Q?jl():A(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${J(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(J(a.map(e=>e.config)));else{if(a.length===0){console.info(`No webhooks configured.`);return}for(let e of a){let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;console.info(`${e.config.url}${n} [${t}]`)}}}function jl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ml(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a webhook from a Prismic repository.
2379
2406
 
2380
2407
  By default, this command reads the repository from prismic.config.json at the
2381
2408
  project root.
@@ -2391,7 +2418,7 @@ FLAGS
2391
2418
  -h, --help Show help for command
2392
2419
 
2393
2420
  LEARN MORE
2394
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Dl();return}let i=await pc(n);if(!i.ok){i.error instanceof Q?Dl():(console.error(`Failed to remove webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await El(n,a.config._id);if(!o.ok){o.error instanceof Q?Dl():(console.error(`Failed to remove webhook: ${J(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function El(e,t){return await Z(new URL(`/app/settings/webhooks/${t}/delete`,await z(e)),{method:`POST`})}function Dl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ol(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom HTTP header from a webhook.
2421
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Pl();return}let i=await bc(n);if(!i.ok){i.error instanceof Q?Pl():(console.error(`Failed to remove webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await Nl(n,a.config._id);if(!o.ok){o.error instanceof Q?Pl():(console.error(`Failed to remove webhook: ${J(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function Nl(e,t){return await Z(new URL(`/app/settings/webhooks/${t}/delete`,await z(e)),{method:`POST`})}function Pl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Fl(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom HTTP header from a webhook.
2395
2422
 
2396
2423
  By default, this command reads the repository from prismic.config.json at the
2397
2424
  project root.
@@ -2408,7 +2435,7 @@ FLAGS
2408
2435
  -h, --help Show help for command
2409
2436
 
2410
2437
  LEARN MORE
2411
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){kl();return}let a=await pc(n);if(!a.ok){a.error instanceof Q?kl():(console.error(`Failed to remove header: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===r);if(!o){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!(i in o.config.headers)){console.error(`Header not found: ${i}`),process.exitCode=1;return}let s=structuredClone(o.config);delete s.headers[i];let c=await pl(n,o.config._id,s);if(!c.ok){c.error instanceof Q?kl():(console.error(`Failed to remove header: ${J(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function kl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Al=Object.values(lc);async function jl(){let{values:{help:t,repo:n=await X(),trigger:r},positionals:[i]}=e({args:process.argv.slice(4),options:{trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update which events trigger a webhook.
2438
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Il();return}let a=await bc(n);if(!a.ok){a.error instanceof Q?Il():(console.error(`Failed to remove header: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===r);if(!o){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!(i in o.config.headers)){console.error(`Header not found: ${i}`),process.exitCode=1;return}let s=structuredClone(o.config);delete s.headers[i];let c=await bl(n,o.config._id,s);if(!c.ok){c.error instanceof Q?Il():(console.error(`Failed to remove header: ${J(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function Il(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ll=Object.values(gc);async function Rl(){let{values:{help:t,repo:n=await X(),trigger:r},positionals:[i]}=e({args:process.argv.slice(4),options:{trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update which events trigger a webhook.
2412
2439
 
2413
2440
  By default, this command reads the repository from prismic.config.json at the
2414
2441
  project root.
@@ -2433,7 +2460,7 @@ TRIGGERS
2433
2460
  tag.deleted When a tag is deleted
2434
2461
 
2435
2462
  LEARN MORE
2436
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!Al.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${Al.join(`, `)}`),process.exitCode=1;return}if(!await B()){Ml();return}let a=await pc(n);if(!a.ok){a.error instanceof Q?Ml():(console.error(`Failed to update webhook triggers: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===i);if(!o){console.error(`Webhook not found: ${i}`),process.exitCode=1;return}let s=!(r.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of r){let[t]=Object.entries(lc).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await pl(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof Q?Ml():(console.error(`Failed to update webhook triggers: ${J(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Ml(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Nl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Show the enabled/disabled status of a webhook.
2463
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!Ll.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${Ll.join(`, `)}`),process.exitCode=1;return}if(!await B()){zl();return}let a=await bc(n);if(!a.ok){a.error instanceof Q?zl():(console.error(`Failed to update webhook triggers: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===i);if(!o){console.error(`Webhook not found: ${i}`),process.exitCode=1;return}let s=!(r.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of r){let[t]=Object.entries(gc).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await bl(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof Q?zl():(console.error(`Failed to update webhook triggers: ${J(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function zl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Bl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Show the enabled/disabled status of a webhook.
2437
2464
 
2438
2465
  By default, this command reads the repository from prismic.config.json at the
2439
2466
  project root.
@@ -2449,7 +2476,7 @@ FLAGS
2449
2476
  -h, --help Show help for command
2450
2477
 
2451
2478
  LEARN MORE
2452
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Pl();return}let i=await pc(n);if(!i.ok){i.error instanceof Q?Pl():(console.error(`Failed to get webhook status: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=a.config.active?`enabled`:`disabled`;console.info(o)}function Pl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Fl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Trigger a test webhook in a Prismic repository.
2479
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Vl();return}let i=await bc(n);if(!i.ok){i.error instanceof Q?Vl():(console.error(`Failed to get webhook status: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=a.config.active?`enabled`:`disabled`;console.info(o)}function Vl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Hl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Trigger a test webhook in a Prismic repository.
2453
2480
 
2454
2481
  By default, this command reads the repository from prismic.config.json at the
2455
2482
  project root.
@@ -2465,7 +2492,7 @@ FLAGS
2465
2492
  -h, --help Show help for command
2466
2493
 
2467
2494
  LEARN MORE
2468
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Ll();return}let i=await pc(n);if(!i.ok){i.error instanceof Q?Ll():(console.error(`Failed to test webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await Il(n,a.config._id);if(!o.ok){o.error instanceof Q?Ll():(console.error(`Failed to test webhook: ${J(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Il(e,t){return await Z(new URL(`/app/settings/webhooks/${t}/trigger`,await z(e)),{method:`POST`})}function Ll(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Rl(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Cl();break;case`create`:await vl();break;case`view`:await uc();break;case`remove`:await Tl();break;case`test`:await Fl();break;case`enable`:await fl();break;case`disable`:await xl();break;case`status`:await Nl();break;case`add-header`:await hl();break;case`remove-header`:await Ol();break;case`set-triggers`:await jl();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
2495
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Wl();return}let i=await bc(n);if(!i.ok){i.error instanceof Q?Wl():(console.error(`Failed to test webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await Ul(n,a.config._id);if(!o.ok){o.error instanceof Q?Wl():(console.error(`Failed to test webhook: ${J(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Ul(e,t){return await Z(new URL(`/app/settings/webhooks/${t}/trigger`,await z(e)),{method:`POST`})}function Wl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Gl(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Al();break;case`create`:await Tl();break;case`view`:await _c();break;case`remove`:await Ml();break;case`test`:await Hl();break;case`enable`:await yl();break;case`disable`:await Ol();break;case`status`:await Bl();break;case`add-header`:await Sl();break;case`remove-header`:await Fl();break;case`set-triggers`:await Rl();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
2469
2496
 
2470
2497
  USAGE
2471
2498
  prismic webhook <command> [flags]
@@ -2487,7 +2514,7 @@ FLAGS
2487
2514
  -h, --help Show help for command
2488
2515
 
2489
2516
  LEARN MORE
2490
- Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function zl(){let{values:{help:t}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t){console.info(`Show the currently logged in user.
2517
+ Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function Kl(){let{values:{help:t}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t){console.info(`Show the currently logged in user.
2491
2518
 
2492
2519
  USAGE
2493
2520
  prismic whoami [flags]
@@ -2496,7 +2523,7 @@ FLAGS
2496
2523
  -h, --help Show help for command
2497
2524
 
2498
2525
  LEARN MORE
2499
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!await B()){Vl();return}let n=await Bl();if(!n.ok){n.error instanceof Q?Vl():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function Bl(){return await Z(new URL(`profile`,await wn()),{schema:N({email:I()})})}function Vl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Hl,values:{version:Ul}}=e({options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}},allowPositionals:!0,strict:!1});if(Ul)console.info(C);else switch(Hl[0]){case`init`:await ci();break;case`login`:await Di();break;case`logout`:await Ai();break;case`whoami`:await zl();break;case`status`:await wc();break;case`repo`:await Zo();break;case`locale`:await Ti();break;case`page-type`:await Ka();break;case`custom-type`:await Gr();break;case`slice`:await tc();break;case`pull`:await bo();break;case`push`:await Co();break;case`codegen`:await Qn();break;case`docs`:await Zr();break;case`skill`:await cc();break;case`preview`:await yo();break;case`token`:await dl();break;case`webhook`:await Rl();break;default:Hl[0]&&(console.error(`Unknown command: ${Hl[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
2526
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!await B()){Jl();return}let n=await ql();if(!n.ok){n.error instanceof Q?Jl():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function ql(){return await Z(new URL(`profile`,await wn()),{schema:N({email:I()})})}function Jl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Yl,values:{version:Xl}}=e({options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}},allowPositionals:!0,strict:!1});if(Xl)console.info(C);else switch(Yl[0]){case`init`:await hi();break;case`login`:await Pi();break;case`logout`:await Li();break;case`whoami`:await Kl();break;case`status`:await jc();break;case`repo`:await is();break;case`locale`:await Mi();break;case`page-type`:await $a();break;case`custom-type`:await Gr();break;case`slice`:await cc();break;case`pull`:await Do();break;case`push`:await Ao();break;case`codegen`:await Qn();break;case`docs`:await ii();break;case`skill`:await hc();break;case`preview`:await Eo();break;case`token`:await vl();break;case`webhook`:await Gl();break;default:Yl[0]&&(console.error(`Unknown command: ${Yl[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
2500
2527
 
2501
2528
  USAGE
2502
2529
  prismic <command> [flags]
@@ -2515,7 +2542,7 @@ COMMANDS
2515
2542
  pull Pull types and slices from Prismic
2516
2543
  push Push types and slices to Prismic
2517
2544
  codegen Generate code from Prismic models
2518
- docs Fetch documentation from Prismic
2545
+ docs Fetch and list documentation from Prismic
2519
2546
  skill Manage Prismic AI skills
2520
2547
  preview Manage preview configurations
2521
2548
  token Manage API tokens in a repository