prismic 1.22.0-pr.391.f4f92e5 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{A as e,L as t,M as n,N as r,P as i,S as a,c as o,d as s,g as c,h as l,j as u,l as d,m as f,o as p,p as m,s as h,u as g,v as ee,x as _}from"./request-DozpYv-V.mjs";import{m as v,r as y}from"./auth-BlIfsyue.mjs";import{c as b,r as x,t as S}from"./packageJson-Bvm9nRNl.mjs";import{createRequire as C}from"node:module";import{parseArgs as w}from"node:util";import{readFile as T,realpath as E,rm as D,writeFile as O}from"node:fs/promises";import{sep as te}from"node:path";import{fileURLToPath as ne,pathToFileURL as k}from"node:url";import*as A from"node:crypto";import{createHash as re}from"node:crypto";import*as ie from"fs";import{readdir as j,readdirSync as M,realpath as N,realpathSync as P,stat as ae,statSync as F}from"fs";import{basename as I,dirname as L,isAbsolute as R,normalize as z,posix as B,relative as V,resolve as oe,sep as se}from"path";import{fileURLToPath as H}from"url";import{createRequire as ce}from"module";var U=Object.create,le=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyNames,fe=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty,me=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},W=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),he=(e,t)=>{let n={};for(var r in e)le(n,r,{get:e[r],enumerable:!0});return t||le(n,Symbol.toStringTag,{value:`Module`}),n},ge=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=de(t),a=0,o=i.length,s;a<o;a++)s=i[a],!pe.call(e,s)&&s!==n&&le(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ue(t,s))||r.enumerable});return e},_e=(e,t,n)=>(n=e==null?{}:U(fe(e)),ge(t||!e||!e.__esModule||!pe.call(e,`default`)?le(n,`default`,{value:e,enumerable:!0}):n,e)),ve=e=>pe.call(e,`module.exports`)?e[`module.exports`]:ge(le({},`__esModule`,{value:!0}),e);const ye=/([\p{Ll}\d])(\p{Lu})/gu,be=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,xe=/(\d)\p{Ll}|(\p{L})\d/u,Se=/[^\p{L}\d]+/giu,Ce=`$1\0$2`;function we(e){let t=e.trim();t=t.replace(ye,Ce).replace(be,Ce),t=t.replace(Se,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}function Te(e){let t=we(e);for(let e=0;e<t.length;e++){let n=t[e],r=xe.exec(n);if(r){let i=r.index+(r[1]??r[2]).length;t.splice(e,1,n.slice(0,i),n.slice(i))}}return t}function Ee(e,t){let[n,r,i]=Fe(e,t);return n+r.map(je(t?.locale)).join(t?.delimiter??` `)+i}function De(e,t){let[n,r,i]=Fe(e,t),a=je(t?.locale),o=Me(t?.locale),s=t?.mergeAmbiguousCharacters?Ne(a,o):Pe(a,o);return n+r.map((e,t)=>t===0?a(e):s(e,t)).join(t?.delimiter??``)+i}function Oe(e,t){let[n,r,i]=Fe(e,t),a=je(t?.locale),o=Me(t?.locale),s=t?.mergeAmbiguousCharacters?Ne(a,o):Pe(a,o);return n+r.map(s).join(t?.delimiter??``)+i}function ke(e,t){let[n,r,i]=Fe(e,t),a=je(t?.locale),o=Me(t?.locale);return n+r.map(Ne(a,o)).join(t?.delimiter??` `)+i}function Ae(e,t){return Ee(e,{delimiter:`_`,...t})}function je(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function Me(e){return e===!1?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function Ne(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function Pe(e,t){return(n,r)=>{let i=n[0];return(r>0&&i>=`0`&&i<=`9`?`_`+i:t(i))+e(n.slice(1))}}function Fe(e,t={}){let n=t.split??(t.separateNumbers?Te:we),r=t.prefixCharacters??``,i=t.suffixCharacters??``,a=0,o=e.length;for(;a<e.length;){let t=e.charAt(a);if(!r.includes(t))break;a++}for(;o>a;){let t=o-1,n=e.charAt(t);if(!i.includes(n))break;o=t}return[e.slice(0,a),n(e.slice(a,o)),e.slice(o)]}function Ie(e,t){return(!e||e.endsWith(`
1
+ import{A as e,L as t,M as n,N as r,P as i,S as a,c as o,d as s,g as c,h as l,j as u,l as d,m as f,o as p,p as m,s as h,u as g,v as ee,x as _}from"./request-DozpYv-V.mjs";import{m as v,r as y}from"./auth-D17Z0IuK.mjs";import{c as b,r as x,t as S}from"./packageJson-Bvm9nRNl.mjs";import{createRequire as C}from"node:module";import{parseArgs as w}from"node:util";import{readFile as T,realpath as E,rm as D,writeFile as O}from"node:fs/promises";import{sep as te}from"node:path";import{fileURLToPath as ne,pathToFileURL as k}from"node:url";import*as A from"node:crypto";import{createHash as re}from"node:crypto";import*as ie from"fs";import{readdir as j,readdirSync as M,realpath as N,realpathSync as P,stat as ae,statSync as F}from"fs";import{basename as I,dirname as L,isAbsolute as R,normalize as z,posix as B,relative as V,resolve as oe,sep as se}from"path";import{fileURLToPath as H}from"url";import{createRequire as ce}from"module";var U=Object.create,le=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyNames,fe=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty,me=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},W=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),he=(e,t)=>{let n={};for(var r in e)le(n,r,{get:e[r],enumerable:!0});return t||le(n,Symbol.toStringTag,{value:`Module`}),n},ge=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=de(t),a=0,o=i.length,s;a<o;a++)s=i[a],!pe.call(e,s)&&s!==n&&le(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ue(t,s))||r.enumerable});return e},_e=(e,t,n)=>(n=e==null?{}:U(fe(e)),ge(t||!e||!e.__esModule||!pe.call(e,`default`)?le(n,`default`,{value:e,enumerable:!0}):n,e)),ve=e=>pe.call(e,`module.exports`)?e[`module.exports`]:ge(le({},`__esModule`,{value:!0}),e);const ye=/([\p{Ll}\d])(\p{Lu})/gu,be=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,xe=/(\d)\p{Ll}|(\p{L})\d/u,Se=/[^\p{L}\d]+/giu,Ce=`$1\0$2`;function we(e){let t=e.trim();t=t.replace(ye,Ce).replace(be,Ce),t=t.replace(Se,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}function Te(e){let t=we(e);for(let e=0;e<t.length;e++){let n=t[e],r=xe.exec(n);if(r){let i=r.index+(r[1]??r[2]).length;t.splice(e,1,n.slice(0,i),n.slice(i))}}return t}function Ee(e,t){let[n,r,i]=Fe(e,t);return n+r.map(je(t?.locale)).join(t?.delimiter??` `)+i}function De(e,t){let[n,r,i]=Fe(e,t),a=je(t?.locale),o=Me(t?.locale),s=t?.mergeAmbiguousCharacters?Ne(a,o):Pe(a,o);return n+r.map((e,t)=>t===0?a(e):s(e,t)).join(t?.delimiter??``)+i}function Oe(e,t){let[n,r,i]=Fe(e,t),a=je(t?.locale),o=Me(t?.locale),s=t?.mergeAmbiguousCharacters?Ne(a,o):Pe(a,o);return n+r.map(s).join(t?.delimiter??``)+i}function ke(e,t){let[n,r,i]=Fe(e,t),a=je(t?.locale),o=Me(t?.locale);return n+r.map(Ne(a,o)).join(t?.delimiter??` `)+i}function Ae(e,t){return Ee(e,{delimiter:`_`,...t})}function je(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function Me(e){return e===!1?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function Ne(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function Pe(e,t){return(n,r)=>{let i=n[0];return(r>0&&i>=`0`&&i<=`9`?`_`+i:t(i))+e(n.slice(1))}}function Fe(e,t={}){let n=t.split??(t.separateNumbers?Te:we),r=t.prefixCharacters??``,i=t.suffixCharacters??``,a=0,o=e.length;for(;a<e.length;){let t=e.charAt(a);if(!r.includes(t))break;a++}for(;o>a;){let t=o-1,n=e.charAt(t);if(!i.includes(n))break;o=t}return[e.slice(0,a),n(e.slice(a,o)),e.slice(o)]}function Ie(e,t){return(!e||e.endsWith(`
2
2
  `))&&!t?.force?e:e+`
3
3
  `}function G(e,t){return Ie(t)+e}function Le(e,t){return(!e||e.endsWith(`
4
4
 
@@ -188,4 +188,4 @@ const ti=/^[A-Z]:\/$/i,ni=Qr?e=>ti.test(e):e=>e===`/`;function ri(e,t,n){if(e===
188
188
  what the user asked for as --user-intent. Analytics only — no effect on behavior.
189
189
  `}:e.sections;console.info(Vi(e.description,n,e.name,r))}}function Bi(e){let t=Ii?{...e,...Li}:e,n=[];for(let[e,r]of Object.entries(t)){if(r.deprecated||r.hidden)continue;let t=r.short?`-${r.short}, `:` `,i=r.type===`string`?` string`:``,a=r.description+(r.required?` (required)`:``);n.push([` ${t}--${e}${i}`,a])}return n.push([` -h, --help`,`Show help for command`]),n}function Vi(e,t,n,r={}){let i=[Ni(e)];for(let[e,n]of Object.entries(t))i.push(``,e,n);for(let[e,t]of Object.entries(r))i.push(``,e,...Ni(t).split(`
190
190
  `).map(e=>e?` ${e}`:``));return i.push(``,`LEARN MORE`,` Use \`${n} <command> --help\` for more information about a command.`),i.join(`
191
- `)}function Hi(e,t){let n=t.filter(t=>t in e),r=t.map(e=>`--${String(e)}`).join(` or `);if(n.length>1)throw new Q(`Only one of ${r} can be specified.`);if(n.length===0)throw new Q(`Specify one of ${r}.`);return{key:n[0],value:e[n[0]]}}function Ui(e,t){let n=t.filter(t=>t in e),r=t.map(e=>`--${String(e)}`).join(` or `);if(n.length>1)throw new Q(`Only one of ${r} can be specified.`)}var Q=class extends Error{name=`CommandError`};const Wi=u({id:i(),label:i(),url:i()}),Gi=u({results:a(Wi)});async function Ki(e){let{repo:t,host:n}=e;return(await na(new URL(`core/repository/preview_configs`,ra(t,n)),e,{schema:Gi,unknownErrorMessage:`Failed to load previews`})).results}async function qi(e,t){let{repo:n,host:r}=t;await na(new URL(`previews/new`,ra(n,r)),t,{method:`POST`,json:{name:e.name,websiteURL:e.websiteURL,resolverPath:e.resolverPath},unknownErrorMessage:`Failed to add preview`})}async function Ji(e,t){let{repo:n,host:r}=t;await na(new URL(`previews/delete/${encodeURIComponent(e)}`,ra(n,r)),t,{method:`POST`,json:{},notFoundMessage:`Preview not found: ${e}`,unknownErrorMessage:`Failed to remove preview`})}const Yi=u({kind:_([`prod`,`stage`,`dev`]),name:i(),domain:i(),users:a(u({id:i()}))});async function Xi(e){let{repo:t,host:n}=e;return(await na(new URL(`core/environments`,ra(t,n)),e,{schema:u({results:a(Yi)})})).results}const Zi=u({simulator_url:n(i())});async function Qi(e){let{repo:t,host:n}=e;return(await na(new URL(`core/repository`,ra(t,n)),e,{schema:Zi,unknownErrorMessage:`Failed to load simulator URL`})).simulator_url}async function $i(e,t){let{repo:n,host:r}=t;await na(new URL(`core/repository`,ra(n,r)),t,{method:`PATCH`,json:{simulator_url:e},unknownErrorMessage:`Failed to set simulator URL`})}const ea=u({total:e()});async function ta(e,t){let{repo:n,host:r}=t;return(await na(new URL(`core/documents/search`,ra(n,r)),t,{method:`POST`,json:{customTypes:[e],limit:0},schema:ea})).total}function na(e,t,n={}){return p(e,{credentials:{"prismic-auth":t.token},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function ra(e,t){return new URL(`https://${e}.${t}/`)}function ia(e,t,n){let{getKey:r,equals:i=(e,t)=>JSON.stringify(e)===JSON.stringify(t)}=n,a={insert:[],update:[],delete:[]};for(let n of e){let e=t.find(e=>r(e)===r(n));e?i(n,e)||a.update.push(n):a.insert.push(n)}for(let n of t)e.some(e=>r(e)===r(n))||a.delete.push(n);return a}function aa(e){return e.insert.length+e.update.length+e.delete.length>0}function oa(e){return ma(new URL(`customtypes`,ga(e.host)),e)}function sa(e){return ma(new URL(`slices`,ga(e.host)),e)}async function ca(e,t){await ma(new URL(`bulk-update`,ga(t.host)),t,{method:`POST`,json:{changes:e},unknownErrorMessage:`Failed to update models`})}const la=u({values:u({url:i(),fields:r(i(),i())}),imgixEndpoint:i()}),ua={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`};async function da(e,t){await ha(new URL(`delete`,_a(t.host)),t,{method:`POST`,json:{sliceId:e}})}async function fa(e,t){let{sliceId:n,variationId:r,repo:i,host:a}=t,o=e.type;if(!(o in ua))throw new pa(o);let s=await ha(new URL(`presigned-url`,_a(a)),t,{schema:la}),l=ua[o],u=`${i}/shared-slices/${n}/${r}/${re(`sha1`).update(new Uint8Array(await e.arrayBuffer())).digest(`hex`)}${l}`,d=new FormData;for(let[e,t]of Object.entries(s.values.fields))d.append(e,t);d.set(`key`,u),d.set(`Content-Type`,o),d.set(`file`,e),await p(s.values.url,{method:`POST`,body:d});let f=new URL(u,c(s.imgixEndpoint));return f.searchParams.set(`auto`,`compress,format`),f}var pa=class extends Error{name=`UnsupportedFileTypeError`;constructor(e){let t=Object.keys(ua);super(`Unsupported file type: ${e||`unknown`}. Supported: ${t.join(`, `)}`)}};function ma(e,t,n={}){return p(e,{headers:{repository:t.repo,Authorization:`Bearer ${t.token}`},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function ha(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),p(r,{headers:{repository:t.repo,Authorization:`Bearer ${t.token}`},...n})}function ga(e){return new URL(`https://customtypes.${e}/`)}function _a(e){return new URL(`https://api.internal.${e}/screenshot/`)}const va=[`Slices`,`UID`,`Choice`];function ya(e,t,n){if(t in e)throw new Na(t);e[t]=n}function ba(e,t){let n=e[t];if(!n)throw new Pa(t);return n}function xa(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=r.get(t);if(!i)throw new $(`Custom type "${t}" does not exist.`);let a=(e,t,n,i)=>{let o=/* @__PURE__ */ new Map;for(let t of e){let[e,...n]=t.split(`.`),r=o.get(e)??[];r.push(n.join(`.`)),o.set(e,r)}return Array.from(o,([e,o])=>{let s=t[e];if(!s)throw new $(`Field "${e}" does not exist on type "${n}".`);let c=o.filter(Boolean);if(c.length===0){if(va.includes(s.type)||e===`uid`)throw new $(`Field "${e}" cannot be fetched from a content relationship.`);if(s.type===`Group`)throw new $(`Field "${e}" is a group. Select specific subfields.`);return e}if(c.length!==o.length)throw new $(`Field "${e}" cannot be selected both directly and through its subfields.`);if(s.type===`Group`)return{id:e,fields:a(c,s.config?.fields??{},n,i)};if(s.type===`Link`&&s.config?.select===`document`){if(!i)throw new $(`Content relationships cannot be nested more than once.`);let t=s.config?.customtypes;if(!t||t.length!==1)throw new $(`Field "${e}" must target exactly one custom type to select its fields.`);let n=typeof t[0]==`string`?t[0]:t[0].id,o=r.get(n);if(!o)throw new $(`Custom type "${n}" does not exist.`);let l=Object.assign({},...Object.values(o.json));return{id:e,customtypes:[{id:n,fields:a(c,l,n,!1)}]}}throw new $(`Field "${e}" is not a group or content relationship field.`)})};return a(e,Object.assign({},...Object.values(i.json)),i.id,!0)}function Sa(e,t,n){let r;if(n){if(r=t.json[n],!r)throw new Ia(n,t.id)}else{let[n]=e.split(`.`);if(r=Object.values(t.json).find(e=>n in e),!r)throw new Pa(n)}return ja(e,r)}function Ca(e,t,n){let r=t.variations.find(e=>e.id===n);if(!r)throw new La(n,t.id);return r.primary??={},ja(e,r.primary)}async function wa(e){let[t,n]=await Promise.all([oa(e),sa(e)]);return{customTypes:t,slices:n}}function Ta(e,t,n={}){let{treatNonCanonicalAsChanged:r=!1}=n;return{customTypes:ia(e.customTypes,t.customTypes,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(Ea(e))===JSON.stringify(r?t:Ea(t))}),slices:ia(e.slices,t.slices,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(Da(e))===JSON.stringify(r?t:Da(t))})}}function Ea(e){return{...Aa(e),json:Object.fromEntries(Object.entries(e.json).map(([e,t])=>[e,Oa(t)]))}}function Da(e){return{...Aa(e),variations:e.variations.map(e=>{let t=Aa(e);return e.primary&&(t.primary=Oa(e.primary)),e.items&&(t.items=Oa(e.items)),t})}}function Oa(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=Aa(t);return t.type===`Group`&&t.config?.fields&&n.type===`Group`&&n.config?.fields&&(n.config.fields=Oa(t.config.fields)),t.type===`Slices`&&t.config?.choices&&n.type===`Slices`&&n.config?.choices&&(n.config.choices=ka(t.config.choices)),[e,n]}))}function ka(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=Aa(t);return t.type===`Slice`&&n.type===`Slice`&&(t[`non-repeat`]&&(n[`non-repeat`]=Oa(t[`non-repeat`])),t.repeat&&(n.repeat=Oa(t.repeat))),[e,n]}))}function Aa(e){return Array.isArray(e)?e.map(Aa):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Aa(t)]))}function ja(e,t){let[n,...r]=e.split(`.`);if(r.length===0)return{fields:t,fieldId:n};let i=ba(t,n);if(i.type!==`Group`)throw new Fa(n);return i.config??={},i.config.fields??={},ja(r.join(`.`),i.config.fields)}function Ma(e){return e.flatMap(e=>Object.values(e.json).flatMap(t=>Object.entries(t).flatMap(([t,n])=>n.type===`Slices`?Object.entries(n.config?.choices??{}).flatMap(([r,i])=>i.type===`SharedSlice`?[]:[{id:r,customTypeId:e.id,sliceZoneId:t,sliceZone:n,model:i}]):[])))}var Na=class extends Error{name=`FieldExistsError`;constructor(e){super(`Field "${e}" already exists.`)}},Pa=class extends Error{name=`FieldNotFoundError`;constructor(e){super(`Field "${e}" does not exist.`)}},Fa=class extends Error{name=`UnsupportedNestedFieldError`;constructor(e){super(`Field "${e}" does not support nested fields.`)}},$=class extends Error{name=`FieldSelectionError`},Ia=class extends Error{name=`TabNotFoundError`;constructor(e,t){super(`Tab "${e}" does not exist on type "${t}".`)}},La=class extends Error{name=`SliceVariationNotFoundError`;constructor(e,t){super(`Variation "${e}" does not exist on slice "${t}".`)}};const Ra=`prismic.config.json`,za=u({type:i(),path:i(),uid:n(i()),lang:n(i()),resolvers:n(r(i(),i()))}),Ba=u({repositoryName:i(),documentAPIEndpoint:n(t()),libraries:n(a(i())),routes:n(a(za))});async function Va(e){let t=await qa();return await O(t,h(e)),t}async function Ha(){let e=await Ga();try{return await s(e,{schema:Ba})}catch{throw new Ua}}var Ua=class extends Error{name=`InvalidPrismicConfigError`;message=`${Ra} is invalid. Run \`prismic init\` to re-create a config.`};async function Wa(e){let t=await Ga(),n={...await Ha(),...e};return await O(t,h(n)),n}async function Ga(){let e=await d(Ra,{stop:`package.json`});if(!e)throw new Ka;return e}var Ka=class extends Error{name=`MissingPrismicConfigError`;message=`Could not find a ${Ra} file. Run \`prismic init\` to create a config.`};async function qa(){try{let e=await x();return new URL(Ra,e)}catch(e){throw e instanceof S?new Ja({cause:e}):e}}var Ja=class extends Error{name=`UnknownProjectRootError`;constructor(e){super(`Could not find your project root.`,e)}};async function Ya(e){let{routes:t=[]}=await Ha();if(t.some(t=>t.type===e.id))return;let n=$a(e),r={type:e.id,path:n};await Wa({routes:[...t,r].sort((e,t)=>e.type.localeCompare(t.type))})}async function Xa(e){e.format===`page`?await Ya(e):await Za(e.id)}async function Za(e){let{routes:t=[]}=await Ha(),n=t.filter(t=>t.type!==e);t.length!==n.length&&await Wa({routes:n})}function Qa(e,t){return e.find(e=>e.type===t&&!e.uid&&!/[?*+]/.test(e.path))}function $a(e){let{id:t,repeatable:n}=e,r=t.replaceAll(`_`,`-`).toLowerCase();return n?t===`page`?`/:uid`:`/${r}/:uid`:t===`homepage`?`/`:`/${r}`}const eo=`slicemachine.config.json`,to=u({repositoryName:i(),libraries:n(a(i()))});async function no(){let e=await ao();try{return await s(e,{schema:to})}catch{throw new ro}}var ro=class extends Error{name=`InvalidLegacySliceMachineConfigError`;message=`${eo} is invalid.`};async function io(){let e=await ao();await D(e)}async function ao(){let e=await d(eo,{stop:`package.json`});if(!e)throw new oo;return e}var oo=class extends Error{name=`MissingLegacySliceMachineConfigError`;message=`Could not find a ${eo} file.`};async function so(){let e;try{e=await Ga()}catch(t){if(t instanceof Ka)e=await qa();else throw t}let t=new URL(`.`,e);return c(k(await E(ne(t))))}async function co(){try{return(await Ha()).repositoryName}catch(e){if(e instanceof Ka)try{return(await no()).repositoryName}catch{}throw e}}async function lo(){let e=(await Ha()).libraries;if(!e||e.length<1)return;let t=await so();return e.map(e=>c(new URL(e.replace(/^\//,``),t)))}async function uo(){let e=await so();return o(new URL(`tsconfig.json`,e))}const fo=[`next`,`nuxt`,`sveltekit`];async function po(){let{dependencies:e,devDependencies:t,peerDependencies:n}=await b(),r={...e,...t,...n};if(`next`in r){let{NextJsAdapter:e}=await import(`./nextjs-CcFJWHE8.mjs`);return new e}if(`nuxt`in r){let{NuxtAdapter:e}=await import(`./nuxt-BozmSSro.mjs`);return new e}if(`@sveltejs/kit`in r){let{SvelteKitAdapter:e}=await import(`./sveltekit-AJKAOEm5.mjs`);return new e}throw new mo}var mo=class extends Error{name=`NoSupportedFrameworkError`;message=`No supported framework found. Run this command in a Next.js, Nuxt, or SvelteKit project.`},ho=class extends Error{name=`ModelExistsError`};async function go(e,t,n,r){let i=r.find(e=>e.model.id===t||e.directory.href===n.href);if(!i&&!await o(n))return;let a=ee(await so(),i?.directory??n),s=i?` (id: ${i.model.id})`:``;throw new ho(`A ${e} already exists at ${a}${te}${s}.`)}async function _o(){return await(await po()).getEnvironment()??await co()}async function vo(e){let t=await Ci(`**/*.{js,jsx,mjs,ts,tsx,mts,svelte}`,{cwd:ne(await so()),absolute:!0,ignore:`**/{node_modules,build,dist,out}/**`});for(let n of t)try{if((await T(n,`utf8`)).includes(e))return!0}catch{}return!1}async function yo(e,t){await o(e)||await l(e,t)}async function bo(){return await uo()?`ts`:`js`}async function xo(e){let t=C(await x());try{let{version:n}=t(`${e}/package.json`),r=Number.parseInt(n.split(`.`)[0]);return Number.isNaN(r)?1/0:r}catch{return 1/0}}var So=class{get localPreviewUrl(){return new URL(this.localPreviewConfig.resolverPath,this.localPreviewConfig.websiteURL).href}get localSimulatorUrl(){return new URL(`slice-simulator`,this.localPreviewConfig.websiteURL).href}async initProject({setup:e}){for(let e of await this.getSliceLibraries())await this.createSliceIndexFile(e);e&&await this.setupProject();let t={repo:await co(),...await y()};await Qi(t)||await $i(this.localSimulatorUrl,t),(await Ki(t)).length===0&&await qi(this.localPreviewConfig,t)}async getSliceLibraries(){return await lo()??[await this.getDefaultSliceLibrary()]}async getSlices(){return wo(await this.getSliceLibraries(),`*/model.json`)}async getSlice(e){let t=(await this.getSlices()).find(t=>t.model.id===e);if(t)return t;let n=Ma((await this.getCustomTypes()).map(e=>e.model)).find(t=>t.id===e);if(n){let{customTypeId:t,sliceZoneId:r}=n;throw new Q(`"${e}" is a legacy slice in "${t}". Upgrade it first: \`prismic slice upgrade-legacy ${e} --from ${t}${r===`body`?``:` --slice-zone ${r}`}\`.`)}throw Error(`No slice found with ID: ${e}`)}async createSlice(e){let[t]=await this.getSliceLibraries(),n=c(new URL(Oe(e.name),c(t)));await go(`slice`,e.id,n,await this.getSlices()),await l(new URL(`model.json`,n),h(Da(e))),await this.createSliceIndexFile(t),await this.createSliceComponent(e,n)}async updateSlice(e){let t=await this.getSlice(e.id);await l(t.modelPath,h(Da(e))),await this.createSliceIndexFile(t.library)}async deleteSlice(e){let t=await this.getSlice(e);await D(t.directory,{recursive:!0}),await this.createSliceIndexFile(t.library)}async getCustomTypeLibraries(){return[new URL(`customtypes/`,await so())]}async getCustomTypes(){return wo(await this.getCustomTypeLibraries(),`*/index.json`)}async getCustomType(e){let t=(await this.getCustomTypes()).find(t=>t.model.id===e);if(!t)throw Error(`No custom type found with ID: ${e}`);return t}async createCustomType(e){let[t]=await this.getCustomTypeLibraries(),n=c(new URL(e.id,c(t)));if(await go(`type`,e.id,n,await this.getCustomTypes()),await l(new URL(`index.json`,n),h(Ea(e))),e.format!==`page`)return[];await Ya(e);let r=await so();return(await this.writePageFiles(e)).map(({path:t})=>`Skipped ${ee(r,t)} (already exists). Run \`prismic gen page ${e.id}\` to get the code.`)}async writePageFiles(e){let{routes:t=[]}=await Ha(),n=(Qa(t,e.id)?.path??$a(e)).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),r=[];for(let t of await this.getPageFiles(e,n))await o(t.path)?r.push(t):await l(t.path,t.contents);return r}async updateCustomType(e){let t=await this.getCustomType(e.id);await l(t.modelPath,h(Ea(e))),await Xa(e)}async deleteCustomType(e){let t=await this.getCustomType(e);await D(t.directory,{recursive:!0}),await Za(e)}async getModels(){let[e,t]=await Promise.all([this.getCustomTypes(),this.getSlices()]);return{customTypes:e.map(e=>e.model),slices:t.map(e=>e.model)}}async writeModels(e){for(let t of e.slices.update)await this.updateSlice(t);for(let t of e.slices.delete)await this.deleteSlice(t.id);for(let t of e.slices.insert)await this.createSlice(t);for(let t of e.customTypes.update)await this.updateCustomType(t);for(let t of e.customTypes.delete)await this.deleteCustomType(t.id);let t=[];for(let n of e.customTypes.insert)t.push(...await this.createCustomType(n));return t}async generateTypes(){let e=new URL(`prismicio-types.d.ts`,await so()),t=Ln({customTypeModels:(await this.getCustomTypes()).map(({model:e})=>({...e,label:e.label??null})),sharedSliceModels:(await this.getSlices()).map(e=>e.model),clientIntegration:{includeContentNamespace:!0,includeCreateClientInterface:!0},cache:!0,typesProvider:`@prismicio/client`});return await l(e,t),e}async getEnvironment(){let e=await Co();if(await o(e))return(await g(e))[this.environmentEnvVarName]||void 0}async setEnvironment(e){await m(await Co(),this.environmentEnvVarName,e)}async unsetEnvironment(){await f(await Co(),this.environmentEnvVarName)}};async function Co(){return new URL(`.env.local`,await so())}async function wo(e,t){let n=[];for(let r of e){let e=await Ci(t,{absolute:!0,cwd:r}),i=await Promise.all(e.map(async e=>{let t=k(e),n=await s(t);return{library:r,directory:new URL(`.`,t),modelPath:t,model:n}}));n.push(...i)}return n.sort((e,t)=>e.model.id.toLowerCase().localeCompare(t.model.id.toLowerCase()))}export{Hi as $,Fa as A,da as B,no as C,$ as D,Pa as E,xa as F,Xi as G,aa as H,Sa as I,Ji as J,Ki as K,Ca as L,Ta as M,Ma as N,La as O,wa as P,zi as Q,pa as R,Ha as S,Na as T,qi as U,fa as V,ta as W,Q as X,$i as Y,Ri as Z,Va as _,vo as a,ke as at,so as b,xo as c,ro as d,Ui as et,Ua as f,uo as g,$a as h,mo as i,De as it,ya as j,Ia as k,bo as l,Ja as m,fo as n,Pi as nt,_o as o,Oe as ot,Ka as p,Qi as q,ho as r,Fi as rt,po as s,Ae as st,So as t,Ni as tt,yo as u,io as v,Wa as w,co as x,Qa as y,ca as z};
191
+ `)}function Hi(e,t){let n=t.filter(t=>t in e),r=t.map(e=>`--${String(e)}`).join(` or `);if(n.length>1)throw new Q(`Only one of ${r} can be specified.`);if(n.length===0)throw new Q(`Specify one of ${r}.`);return{key:n[0],value:e[n[0]]}}function Ui(e,t){let n=t.filter(t=>t in e),r=t.map(e=>`--${String(e)}`).join(` or `);if(n.length>1)throw new Q(`Only one of ${r} can be specified.`)}var Q=class extends Error{name=`CommandError`};const Wi=u({id:i(),label:i(),url:i()}),Gi=u({results:a(Wi)});async function Ki(e){let{repo:t,host:n}=e;return(await na(new URL(`core/repository/preview_configs`,ra(t,n)),e,{schema:Gi,unknownErrorMessage:`Failed to load previews`})).results}async function qi(e,t){let{repo:n,host:r}=t;await na(new URL(`previews/new`,ra(n,r)),t,{method:`POST`,json:{name:e.name,websiteURL:e.websiteURL,resolverPath:e.resolverPath},unknownErrorMessage:`Failed to add preview`})}async function Ji(e,t){let{repo:n,host:r}=t;await na(new URL(`previews/delete/${encodeURIComponent(e)}`,ra(n,r)),t,{method:`POST`,json:{},notFoundMessage:`Preview not found: ${e}`,unknownErrorMessage:`Failed to remove preview`})}const Yi=u({kind:_([`prod`,`stage`,`dev`]),name:i(),domain:i(),users:a(u({id:i()}))});async function Xi(e){let{repo:t,host:n}=e;return(await na(new URL(`core/environments`,ra(t,n)),e,{schema:u({results:a(Yi)})})).results}const Zi=u({simulator_url:n(i())});async function Qi(e){let{repo:t,host:n}=e;return(await na(new URL(`core/repository`,ra(t,n)),e,{schema:Zi,unknownErrorMessage:`Failed to load simulator URL`})).simulator_url}async function $i(e,t){let{repo:n,host:r}=t;await na(new URL(`core/repository`,ra(n,r)),t,{method:`PATCH`,json:{simulator_url:e},unknownErrorMessage:`Failed to set simulator URL`})}const ea=u({total:e()});async function ta(e,t){let{repo:n,host:r}=t;return(await na(new URL(`core/documents/search`,ra(n,r)),t,{method:`POST`,json:{customTypes:[e],limit:0},schema:ea})).total}function na(e,t,n={}){return p(e,{credentials:{"prismic-auth":t.token},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function ra(e,t){return new URL(`https://${e}.${t}/`)}function ia(e,t,n){let{getKey:r,equals:i=(e,t)=>JSON.stringify(e)===JSON.stringify(t)}=n,a={insert:[],update:[],delete:[]};for(let n of e){let e=t.find(e=>r(e)===r(n));e?i(n,e)||a.update.push(n):a.insert.push(n)}for(let n of t)e.some(e=>r(e)===r(n))||a.delete.push(n);return a}function aa(e){return e.insert.length+e.update.length+e.delete.length>0}function oa(e){return ma(new URL(`customtypes`,ga(e.host)),e)}function sa(e){return ma(new URL(`slices`,ga(e.host)),e)}async function ca(e,t){await ma(new URL(`bulk-update`,ga(t.host)),t,{method:`POST`,json:{changes:e},unknownErrorMessage:`Failed to update models`})}const la=u({values:u({url:i(),fields:r(i(),i())}),imgixEndpoint:i()}),ua={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`};async function da(e,t){await ha(new URL(`delete`,_a(t.host)),t,{method:`POST`,json:{sliceId:e}})}async function fa(e,t){let{sliceId:n,variationId:r,repo:i,host:a}=t,o=e.type;if(!(o in ua))throw new pa(o);let s=await ha(new URL(`presigned-url`,_a(a)),t,{schema:la}),l=ua[o],u=`${i}/shared-slices/${n}/${r}/${re(`sha1`).update(new Uint8Array(await e.arrayBuffer())).digest(`hex`)}${l}`,d=new FormData;for(let[e,t]of Object.entries(s.values.fields))d.append(e,t);d.set(`key`,u),d.set(`Content-Type`,o),d.set(`file`,e),await p(s.values.url,{method:`POST`,body:d});let f=new URL(u,c(s.imgixEndpoint));return f.searchParams.set(`auto`,`compress,format`),f}var pa=class extends Error{name=`UnsupportedFileTypeError`;constructor(e){let t=Object.keys(ua);super(`Unsupported file type: ${e||`unknown`}. Supported: ${t.join(`, `)}`)}};function ma(e,t,n={}){return p(e,{headers:{repository:t.repo,Authorization:`Bearer ${t.token}`},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function ha(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),p(r,{headers:{repository:t.repo,Authorization:`Bearer ${t.token}`},...n})}function ga(e){return new URL(`https://customtypes.${e}/`)}function _a(e){return new URL(`https://api.internal.${e}/screenshot/`)}const va=[`Slices`,`UID`,`Choice`];function ya(e,t,n){if(t in e)throw new Na(t);e[t]=n}function ba(e,t){let n=e[t];if(!n)throw new Pa(t);return n}function xa(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=r.get(t);if(!i)throw new $(`Custom type "${t}" does not exist.`);let a=(e,t,n,i)=>{let o=/* @__PURE__ */ new Map;for(let t of e){let[e,...n]=t.split(`.`),r=o.get(e)??[];r.push(n.join(`.`)),o.set(e,r)}return Array.from(o,([e,o])=>{let s=t[e];if(!s)throw new $(`Field "${e}" does not exist on type "${n}".`);let c=o.filter(Boolean);if(c.length===0){if(va.includes(s.type)||e===`uid`)throw new $(`Field "${e}" cannot be fetched from a content relationship.`);if(s.type===`Group`)throw new $(`Field "${e}" is a group. Select specific subfields.`);return e}if(c.length!==o.length)throw new $(`Field "${e}" cannot be selected both directly and through its subfields.`);if(s.type===`Group`)return{id:e,fields:a(c,s.config?.fields??{},n,i)};if(s.type===`Link`&&s.config?.select===`document`){if(!i)throw new $(`Content relationships cannot be nested more than once.`);let t=s.config?.customtypes;if(!t||t.length!==1)throw new $(`Field "${e}" must target exactly one custom type to select its fields.`);let n=typeof t[0]==`string`?t[0]:t[0].id,o=r.get(n);if(!o)throw new $(`Custom type "${n}" does not exist.`);let l=Object.assign({},...Object.values(o.json));return{id:e,customtypes:[{id:n,fields:a(c,l,n,!1)}]}}throw new $(`Field "${e}" is not a group or content relationship field.`)})};return a(e,Object.assign({},...Object.values(i.json)),i.id,!0)}function Sa(e,t,n){let r;if(n){if(r=t.json[n],!r)throw new Ia(n,t.id)}else{let[n]=e.split(`.`);if(r=Object.values(t.json).find(e=>n in e),!r)throw new Pa(n)}return ja(e,r)}function Ca(e,t,n){let r=t.variations.find(e=>e.id===n);if(!r)throw new La(n,t.id);return r.primary??={},ja(e,r.primary)}async function wa(e){let[t,n]=await Promise.all([oa(e),sa(e)]);return{customTypes:t,slices:n}}function Ta(e,t,n={}){let{treatNonCanonicalAsChanged:r=!1}=n;return{customTypes:ia(e.customTypes,t.customTypes,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(Ea(e))===JSON.stringify(r?t:Ea(t))}),slices:ia(e.slices,t.slices,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(Da(e))===JSON.stringify(r?t:Da(t))})}}function Ea(e){return{...Aa(e),json:Object.fromEntries(Object.entries(e.json).map(([e,t])=>[e,Oa(t)]))}}function Da(e){return{...Aa(e),variations:e.variations.map(e=>{let t=Aa(e);return e.primary&&(t.primary=Oa(e.primary)),e.items&&(t.items=Oa(e.items)),t})}}function Oa(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=Aa(t);return t.type===`Group`&&t.config?.fields&&n.type===`Group`&&n.config?.fields&&(n.config.fields=Oa(t.config.fields)),t.type===`Slices`&&t.config?.choices&&n.type===`Slices`&&n.config?.choices&&(n.config.choices=ka(t.config.choices)),[e,n]}))}function ka(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=Aa(t);return t.type===`Slice`&&n.type===`Slice`&&(t[`non-repeat`]&&(n[`non-repeat`]=Oa(t[`non-repeat`])),t.repeat&&(n.repeat=Oa(t.repeat))),[e,n]}))}function Aa(e){return Array.isArray(e)?e.map(Aa):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Aa(t)]))}function ja(e,t){let[n,...r]=e.split(`.`);if(r.length===0)return{fields:t,fieldId:n};let i=ba(t,n);if(i.type!==`Group`)throw new Fa(n);return i.config??={},i.config.fields??={},ja(r.join(`.`),i.config.fields)}function Ma(e){return e.flatMap(e=>Object.values(e.json).flatMap(t=>Object.entries(t).flatMap(([t,n])=>n.type===`Slices`?Object.entries(n.config?.choices??{}).flatMap(([r,i])=>i.type===`SharedSlice`?[]:[{id:r,customTypeId:e.id,sliceZoneId:t,sliceZone:n,model:i}]):[])))}var Na=class extends Error{name=`FieldExistsError`;constructor(e){super(`Field "${e}" already exists.`)}},Pa=class extends Error{name=`FieldNotFoundError`;constructor(e){super(`Field "${e}" does not exist.`)}},Fa=class extends Error{name=`UnsupportedNestedFieldError`;constructor(e){super(`Field "${e}" does not support nested fields.`)}},$=class extends Error{name=`FieldSelectionError`},Ia=class extends Error{name=`TabNotFoundError`;constructor(e,t){super(`Tab "${e}" does not exist on type "${t}".`)}},La=class extends Error{name=`SliceVariationNotFoundError`;constructor(e,t){super(`Variation "${e}" does not exist on slice "${t}".`)}};const Ra=`prismic.config.json`,za=u({type:i(),path:i(),uid:n(i()),lang:n(i()),resolvers:n(r(i(),i()))}),Ba=u({repositoryName:i(),documentAPIEndpoint:n(t()),libraries:n(a(i())),routes:n(a(za))});async function Va(e){let t=await qa();return await O(t,h(e)),t}async function Ha(){let e=await Ga();try{return await s(e,{schema:Ba})}catch{throw new Ua}}var Ua=class extends Error{name=`InvalidPrismicConfigError`;message=`${Ra} is invalid. Run \`prismic init\` to re-create a config.`};async function Wa(e){let t=await Ga(),n={...await Ha(),...e};return await O(t,h(n)),n}async function Ga(){let e=await d(Ra,{stop:`package.json`});if(!e)throw new Ka;return e}var Ka=class extends Error{name=`MissingPrismicConfigError`;message=`Could not find a ${Ra} file. Run \`prismic init\` to create a config.`};async function qa(){try{let e=await x();return new URL(Ra,e)}catch(e){throw e instanceof S?new Ja({cause:e}):e}}var Ja=class extends Error{name=`UnknownProjectRootError`;constructor(e){super(`Could not find your project root.`,e)}};async function Ya(e){let{routes:t=[]}=await Ha();if(t.some(t=>t.type===e.id))return;let n=$a(e),r={type:e.id,path:n};await Wa({routes:[...t,r].sort((e,t)=>e.type.localeCompare(t.type))})}async function Xa(e){e.format===`page`?await Ya(e):await Za(e.id)}async function Za(e){let{routes:t=[]}=await Ha(),n=t.filter(t=>t.type!==e);t.length!==n.length&&await Wa({routes:n})}function Qa(e,t){return e.find(e=>e.type===t&&!e.uid&&!/[?*+]/.test(e.path))}function $a(e){let{id:t,repeatable:n}=e,r=t.replaceAll(`_`,`-`).toLowerCase();return n?t===`page`?`/:uid`:`/${r}/:uid`:t===`homepage`?`/`:`/${r}`}const eo=`slicemachine.config.json`,to=u({repositoryName:i(),libraries:n(a(i()))});async function no(){let e=await ao();try{return await s(e,{schema:to})}catch{throw new ro}}var ro=class extends Error{name=`InvalidLegacySliceMachineConfigError`;message=`${eo} is invalid.`};async function io(){let e=await ao();await D(e)}async function ao(){let e=await d(eo,{stop:`package.json`});if(!e)throw new oo;return e}var oo=class extends Error{name=`MissingLegacySliceMachineConfigError`;message=`Could not find a ${eo} file.`};async function so(){let e;try{e=await Ga()}catch(t){if(t instanceof Ka)e=await qa();else throw t}let t=new URL(`.`,e);return c(k(await E(ne(t))))}async function co(){try{return(await Ha()).repositoryName}catch(e){if(e instanceof Ka)try{return(await no()).repositoryName}catch{}throw e}}async function lo(){let e=(await Ha()).libraries;if(!e||e.length<1)return;let t=await so();return e.map(e=>c(new URL(e.replace(/^\//,``),t)))}async function uo(){let e=await so();return o(new URL(`tsconfig.json`,e))}const fo=[`next`,`nuxt`,`sveltekit`];async function po(){let{dependencies:e,devDependencies:t,peerDependencies:n}=await b(),r={...e,...t,...n};if(`next`in r){let{NextJsAdapter:e}=await import(`./nextjs-Cj6xZEd3.mjs`);return new e}if(`nuxt`in r){let{NuxtAdapter:e}=await import(`./nuxt-BwU_wt1u.mjs`);return new e}if(`@sveltejs/kit`in r){let{SvelteKitAdapter:e}=await import(`./sveltekit-C7Mpsvl-.mjs`);return new e}throw new mo}var mo=class extends Error{name=`NoSupportedFrameworkError`;message=`No supported framework found. Run this command in a Next.js, Nuxt, or SvelteKit project.`},ho=class extends Error{name=`ModelExistsError`};async function go(e,t,n,r){let i=r.find(e=>e.model.id===t||e.directory.href===n.href);if(!i&&!await o(n))return;let a=ee(await so(),i?.directory??n),s=i?` (id: ${i.model.id})`:``;throw new ho(`A ${e} already exists at ${a}${te}${s}.`)}async function _o(){return await(await po()).getEnvironment()??await co()}async function vo(e){let t=await Ci(`**/*.{js,jsx,mjs,ts,tsx,mts,svelte}`,{cwd:ne(await so()),absolute:!0,ignore:`**/{node_modules,build,dist,out}/**`});for(let n of t)try{if((await T(n,`utf8`)).includes(e))return!0}catch{}return!1}async function yo(e,t){await o(e)||await l(e,t)}async function bo(){return await uo()?`ts`:`js`}async function xo(e){let t=C(await x());try{let{version:n}=t(`${e}/package.json`),r=Number.parseInt(n.split(`.`)[0]);return Number.isNaN(r)?1/0:r}catch{return 1/0}}var So=class{get localPreviewUrl(){return new URL(this.localPreviewConfig.resolverPath,this.localPreviewConfig.websiteURL).href}get localSimulatorUrl(){return new URL(`slice-simulator`,this.localPreviewConfig.websiteURL).href}async initProject({setup:e}){for(let e of await this.getSliceLibraries())await this.createSliceIndexFile(e);e&&await this.setupProject();let t={repo:await co(),...await y()};await Qi(t)||await $i(this.localSimulatorUrl,t),(await Ki(t)).length===0&&await qi(this.localPreviewConfig,t)}async getSliceLibraries(){return await lo()??[await this.getDefaultSliceLibrary()]}async getSlices(){return wo(await this.getSliceLibraries(),`*/model.json`)}async getSlice(e){let t=(await this.getSlices()).find(t=>t.model.id===e);if(t)return t;let n=Ma((await this.getCustomTypes()).map(e=>e.model)).find(t=>t.id===e);if(n){let{customTypeId:t,sliceZoneId:r}=n;throw new Q(`"${e}" is a legacy slice in "${t}". Upgrade it first: \`prismic slice upgrade-legacy ${e} --from ${t}${r===`body`?``:` --slice-zone ${r}`}\`.`)}throw Error(`No slice found with ID: ${e}`)}async createSlice(e){let[t]=await this.getSliceLibraries(),n=c(new URL(Oe(e.name),c(t)));await go(`slice`,e.id,n,await this.getSlices()),await l(new URL(`model.json`,n),h(Da(e))),await this.createSliceIndexFile(t),await this.createSliceComponent(e,n)}async updateSlice(e){let t=await this.getSlice(e.id);await l(t.modelPath,h(Da(e))),await this.createSliceIndexFile(t.library)}async deleteSlice(e){let t=await this.getSlice(e);await D(t.directory,{recursive:!0}),await this.createSliceIndexFile(t.library)}async getCustomTypeLibraries(){return[new URL(`customtypes/`,await so())]}async getCustomTypes(){return wo(await this.getCustomTypeLibraries(),`*/index.json`)}async getCustomType(e){let t=(await this.getCustomTypes()).find(t=>t.model.id===e);if(!t)throw Error(`No custom type found with ID: ${e}`);return t}async createCustomType(e){let[t]=await this.getCustomTypeLibraries(),n=c(new URL(e.id,c(t)));if(await go(`type`,e.id,n,await this.getCustomTypes()),await l(new URL(`index.json`,n),h(Ea(e))),e.format!==`page`)return[];await Ya(e);let r=await so();return(await this.writePageFiles(e)).map(({path:t})=>`Skipped ${ee(r,t)} (already exists). Run \`prismic gen page ${e.id}\` to get the code.`)}async writePageFiles(e){let{routes:t=[]}=await Ha(),n=(Qa(t,e.id)?.path??$a(e)).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),r=[];for(let t of await this.getPageFiles(e,n))await o(t.path)?r.push(t):await l(t.path,t.contents);return r}async updateCustomType(e){let t=await this.getCustomType(e.id);await l(t.modelPath,h(Ea(e))),await Xa(e)}async deleteCustomType(e){let t=await this.getCustomType(e);await D(t.directory,{recursive:!0}),await Za(e)}async getModels(){let[e,t]=await Promise.all([this.getCustomTypes(),this.getSlices()]);return{customTypes:e.map(e=>e.model),slices:t.map(e=>e.model)}}async writeModels(e){for(let t of e.slices.update)await this.updateSlice(t);for(let t of e.slices.delete)await this.deleteSlice(t.id);for(let t of e.slices.insert)await this.createSlice(t);for(let t of e.customTypes.update)await this.updateCustomType(t);for(let t of e.customTypes.delete)await this.deleteCustomType(t.id);let t=[];for(let n of e.customTypes.insert)t.push(...await this.createCustomType(n));return t}async generateTypes(){let e=new URL(`prismicio-types.d.ts`,await so()),t=Ln({customTypeModels:(await this.getCustomTypes()).map(({model:e})=>({...e,label:e.label??null})),sharedSliceModels:(await this.getSlices()).map(e=>e.model),clientIntegration:{includeContentNamespace:!0,includeCreateClientInterface:!0},cache:!0,typesProvider:`@prismicio/client`});return await l(e,t),e}async getEnvironment(){let e=await Co();if(await o(e))return(await g(e))[this.environmentEnvVarName]||void 0}async setEnvironment(e){await m(await Co(),this.environmentEnvVarName,e)}async unsetEnvironment(){await f(await Co(),this.environmentEnvVarName)}};async function Co(){return new URL(`.env.local`,await so())}async function wo(e,t){let n=[];for(let r of e){let e=await Ci(t,{absolute:!0,cwd:r}),i=await Promise.all(e.map(async e=>{let t=k(e),n=await s(t);return{library:r,directory:new URL(`.`,t),modelPath:t,model:n}}));n.push(...i)}return n.sort((e,t)=>e.model.id.toLowerCase().localeCompare(t.model.id.toLowerCase()))}export{Hi as $,Fa as A,da as B,no as C,$ as D,Pa as E,xa as F,Xi as G,aa as H,Sa as I,Ji as J,Ki as K,Ca as L,Ta as M,Ma as N,La as O,wa as P,zi as Q,pa as R,Ha as S,Na as T,qi as U,fa as V,ta as W,Q as X,$i as Y,Ri as Z,Va as _,vo as a,ke as at,so as b,xo as c,ro as d,Ui as et,Ua as f,uo as g,$a as h,mo as i,De as it,ya as j,Ia as k,bo as l,Ja as m,fo as n,Pi as nt,_o as o,Oe as ot,Ka as p,Qi as q,ho as r,Fi as rt,po as s,Ae as st,So as t,Ni as tt,yo as u,io as v,Wa as w,co as x,Qa as y,ca as z};
@@ -1,2 +1,2 @@
1
- import{B as e,C as t,D as n,F as r,M as i,P as a,R as o,T as s,V as c,b as l,c as ee,d as u,g as d,h as f,j as p,o as m,s as h,y as g,z as _}from"./request-DozpYv-V.mjs";import{i as v,r as y,t as b}from"./segment-B2mFer7f.mjs";import{readFile as x,rm as S}from"node:fs/promises";import{fileURLToPath as te,pathToFileURL as C}from"node:url";import{spawn as w}from"node:child_process";import{createServer as ne}from"node:http";import{homedir as T}from"node:os";import{existsSync as re}from"node:fs";// @__NO_SIDE_EFFECTS__
1
+ import{B as e,C as t,D as n,F as r,M as i,P as a,R as o,T as s,V as c,b as l,c as ee,d as u,g as d,h as f,j as p,o as m,s as h,y as g,z as _}from"./request-DozpYv-V.mjs";import{i as v,r as y,t as b}from"./segment-DiEeqnUu.mjs";import{readFile as x,rm as S}from"node:fs/promises";import{fileURLToPath as te,pathToFileURL as C}from"node:url";import{spawn as w}from"node:child_process";import{createServer as ne}from"node:http";import{homedir as T}from"node:os";import{existsSync as re}from"node:fs";// @__NO_SIDE_EFFECTS__
2
2
  function ie(e){return o(g,e)}const E=`prismic.io`,D=p({PROD:r(),PRISMIC_SENTRY_DSN:l(s(),`https://e1886b1775bd397cd1afc60bfd2ebfc8@o146123.ingest.us.sentry.io/4510445143588864`),PRISMIC_SENTRY_ENVIRONMENT:i(a()),PRISMIC_SENTRY_ENABLED:i(r()),PRISMIC_TELEMETRY_ENABLED:i(r()),PRISMIC_HOST:i(a()),PRISMIC_TOKEN:i(a()),PRISMIC_DOCS_HOST:i(a()),PRISMIC_CONFIG_DIR:i(a()),PRISMIC_TYPE_BUILDER_ENABLED:i(r()),PRISMIC_SYNC_POLL_MS:i((/* @__PURE__ */ ie()).check(_(100)))}),O=c(D,{...process.env,PROD:`true`});function k(e,t){if(t)return d(C(t));if(process.platform===`win32`){let t=process.env.APPDATA;if(t)return new URL(`${e}/`,d(C(t)))}if(process.platform!==`darwin`){let t=process.env.XDG_CONFIG_HOME;if(t)return new URL(`${e}/`,d(C(t)))}let n=d(C(T()));return new URL(`.config/${e}/`,n)}const A=k(`prismic`,O.PRISMIC_CONFIG_DIR),j=new URL(`credentials.json`,A),ae=new URL(`update-notifier.json`,A),M=new URL(`analytics.json`,A);async function oe(e,t){let n=new URL(`refreshtoken`,N(t.host));return n.searchParams.set(`token`,e),m(n,{schema:a()})}function N(e){return new URL(`https://auth.${e}/`)}function P(){if(process.env.AI_AGENT!==void 0)return process.env.AI_AGENT.toLowerCase()||void 0;if(process.env.CLAUDE_CODE_IS_COWORK===`1`||process.env.CLAUDE_CODE_IS_COWORK===`true`)return`claude-cowork`;if(process.env.CLAUDECODE===`1`||process.env.CLAUDE_CODE)return`claude-code`;if(process.env.CODEX_CI===`1`||process.env.CODEX_SANDBOX||process.env.CODEX_THREAD_ID)return`codex`;if(process.env.CURSOR_AGENT===`1`||process.env.CURSOR_EXTENSION_HOST_ROLE===`agent-exec`)return`cursor`;if(process.env.CLINE_ACTIVE===`true`)return`cline`;if(process.env.ANTIGRAVITY_AGENT)return`antigravity`;if(process.env.AUGMENT_AGENT===`1`)return`augment`;if(process.env.OPENCODE_CLIENT===`1`)return`opencode`;if(process.env.GEMINI_CLI===`1`)return`gemini-cli`;if(process.env.TRAE_AI_SHELL_ID)return`trae`;if(process.env.REPL_ID)return`replit`;if(process.env.COPILOT_MODEL||process.env.COPILOT_ALLOW_ALL||process.env.COPILOT_GITHUB_TOKEN)return`github-copilot`;let e=process.env.AGENT?.toLowerCase();if(e===`goose`||e===`amp`)return e;if(process.platform===`linux`&&re(`/opt/.devin`))return`devin`;if(process.env.IS_SANDBOX===`yes`)return`unknown-sandbox`}const F=p({anonymousId:a(),userId:i(a())}),I=!O.PRISMIC_TOKEN;let L=!1,R,z,B,V,H;async function U(e){let{host:t,repo:n}=e;n&&(R=n),B=e.userIntent,V=e.taskId;let r=t===`prismic.io`?`cGjidifKefYb6EPaGaqpt8rQXkv5TD6P`:`Ng5oKJHCGpSWplZ9ymB7Pu7rm0sTDeiG`;z=P();let i=await J();H=i??{anonymousId:crypto.randomUUID()},i||await Y(H),b({writeKey:r,anonymousId:H.anonymousId,userId:G()})}function W(e){v({userId:e.shortId,intercomHash:e.intercomHash}),I&&!L&&H&&(H.userId=e.shortId,Y(H))}function G(){return I?H?.userId:void 0}function K(){if(!H)return{};let e=G();return{"Prismic-Anonymous-Id":H.anonymousId,...e?{"Prismic-User-Id":e}:{}}}async function q(){L=!0;let e=await J();e?.userId&&await Y({anonymousId:e.anonymousId})}async function J(){return u(M,{schema:F}).catch(()=>void 0)}async function Y(e){await f(M,h(e)).catch(()=>{})}function se(e,t={}){let{watch:n}=t;y(`Prismic CLI Start`,{properties:{commandType:e,fullCommand:process.argv.join(` `),repository:R,watch:n,agent:z,userIntent:B,taskId:V},groupId:R?{Repository:R}:void 0})}function ce(e,t={}){let{watch:n,error:r}=t,i=r?r instanceof Error?r.message:String(r):void 0;y(`Prismic CLI End`,{properties:{commandType:e,fullCommand:process.argv.join(` `),success:!process.exitCode,repository:R,watch:n,error:i?.slice(0,512),agent:z,userIntent:B,taskId:V},groupId:R?{Repository:R}:void 0})}const le=p({telemetry:t()});async function ue(){try{return!(await X(T())||await X(process.cwd()))}catch{return!0}}async function X(e){return(await u(new URL(`.prismicrc`,d(C(e))),{schema:le}).catch(()=>void 0))?.telemetry===!1}const de=n({token:i(a().check(e(1))),host:i(a().check(e(1)))});async function Z(){let e=await me();return{token:O.PRISMIC_TOKEN||e?.token,host:O.PRISMIC_HOST||e?.host||`prismic.io`}}async function fe(){if(O.PRISMIC_TOKEN)return;let{token:e,host:t}=await Z();if(!e)return;let n=await oe(e,{host:t});return await Q({token:n,host:t}),n}async function pe(){if(!await ee(j))return!0;try{return await S(j,{force:!0}),await q(),!0}catch{return!1}}async function me(){return u(j,{schema:de}).catch(()=>void 0)}async function Q(e){await f(j,h(e))}async function he(e){let{host:t}=await Z(),n=`https://${t}`;return new Promise((r,i)=>{let a=ne((e,i)=>{if(e.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":n,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(e.method===`POST`){let s=(e,t)=>{i.writeHead(e,{"Access-Control-Allow-Origin":n,"Content-Type":`application/json`}),i.end(JSON.stringify(t))},c=``;e.on(`data`,e=>{c+=e.toString()}),e.on(`end`,async()=>{try{let{cookies:e,email:n}=JSON.parse(c),i=e.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!i){s(400,{error:`Invalid request`});return}await Q({token:i,host:t}),await q(),s(200,{success:!0}),clearTimeout(o),a.close(),r({email:n})}catch{s(400,{error:`Invalid request`})}});return}i.writeHead(404),i.end()}),o=setTimeout(()=>{a.close(),i(/* @__PURE__ */ Error(`Login timed out. Please try again.`))},18e4),s=async()=>{let n=a.address();if(!n||typeof n==`string`){clearTimeout(o),a.close(),i(/* @__PURE__ */ Error(`Failed to start login server`));return}let r=await _e(t,n.port);e.onReady(r)};a.on(`error`,e=>{e.code===`EADDRINUSE`&&a.listening===!1?a.listen(0,`0.0.0.0`,s):(clearTimeout(o),i(e))}),a.listen(5555,`0.0.0.0`,s)})}const $=new URL(`.prismic`,d(C(T())));async function ge(){let e;try{e=await x($,`utf-8`)}catch{return}try{let t=JSON.parse(e);if(!t||t.latestKnownVersion===void 0&&t.lastUpdateCheckAt===void 0)return}catch{return}try{await S($,{force:!0})}catch{}}async function _e(e,t){let n=new URL(`dashboard/cli/login`,`https://${e}/`);return n.searchParams.set(`source`,`prismic-cli`),n.searchParams.set(`port`,t.toString()),n}function ve(){try{let e=te(new URL(`./subprocesses/refreshToken.mjs`,import.meta.url));w(process.execPath,[e],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{O as _,fe as a,G as c,ce as d,se as f,E as g,ae as h,pe as i,U as l,P as m,he as n,ve as o,W as p,Z as r,K as s,ge as t,ue as u};
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as ee,Z as T,_ as te,at as E,b as D,d as ne,et as re,f as ie,h as ae,i as oe,it as se,j as O,k as ce,m as le,n as ue,o as k,ot as de,p as fe,q as pe,r as me,rt as A,s as j,st as he,tt as ge,v as _e,w as ve,x as M,y as ye,z as be}from"./adapters-MNdCxfbS.mjs";import{n as xe,t as Se}from"./package-MeH39gTS.mjs";import{A as Ce,C as N,D as we,E as Te,H as Ee,I as De,L as Oe,M as P,N as ke,O as Ae,P as F,S as I,V as je,_ as L,a as Me,f as Ne,g as Pe,i as Fe,j as R,k as Ie,n as z,o as B,r as Le,s as V,t as Re,v as H,w as ze}from"./request-DozpYv-V.mjs";import{_ as U,c as Be,d as Ve,f as He,h as Ue,i as We,l as Ge,m as Ke,n as qe,o as Je,p as Ye,r as W,s as Xe,t as Ze,u as Qe}from"./auth-BlIfsyue.mjs";import{a as $e,c as G,d as et,i as tt,l as nt,s as rt,t as it,u as at}from"./packageJson-Bvm9nRNl.mjs";import{t as ot}from"./update-notifier-Cp2c4p0x.mjs";import{isDeepStrictEqual as st,parseArgs as ct}from"node:util";import{realpath as lt,rm as ut}from"node:fs/promises";import{fileURLToPath as dt,pathToFileURL as ft}from"node:url";import{randomBytes as pt}from"node:crypto";import{exec as mt}from"node:child_process";import{setTimeout as ht}from"node:timers/promises";const gt=R({path:F(),title:F(),description:P(F())}),_t=R({path:F(),title:F(),description:P(F()),anchors:I(R({slug:F(),excerpt:F()}))});async function vt(e){let t=new URL(`api/index/`,xt(e.host));return B(t,{schema:I(gt),unknownErrorMessage:`Failed to fetch documentation index`})}async function yt(e,t){let n=new URL(`api/index/${e}`,xt(t.host));return B(n,{schema:_t,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function bt(e,t){let n=new URL(e,xt(t.host));return B(n,{headers:{Accept:`text/markdown`,...t.headers},schema:F(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function xt(e=`prismic.io`){return new URL(`https://${e}/docs/`)}var St=T({name:`prismic docs list`,description:`
2
+ import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as ee,Z as T,_ as te,at as E,b as D,d as ne,et as re,f as ie,h as ae,i as oe,it as se,j as O,k as ce,m as le,n as ue,o as k,ot as de,p as fe,q as pe,r as me,rt as A,s as j,st as he,tt as ge,v as _e,w as ve,x as M,y as ye,z as be}from"./adapters-DPb0t6EU.mjs";import{n as xe,t as Se}from"./package-BmR9etBQ.mjs";import{A as Ce,C as N,D as we,E as Te,H as Ee,I as De,L as Oe,M as P,N as ke,O as Ae,P as F,S as I,V as je,_ as L,a as Me,f as Ne,g as Pe,i as Fe,j as R,k as Ie,n as z,o as B,r as Le,s as V,t as Re,v as H,w as ze}from"./request-DozpYv-V.mjs";import{_ as U,c as Be,d as Ve,f as He,h as Ue,i as We,l as Ge,m as Ke,n as qe,o as Je,p as Ye,r as W,s as Xe,t as Ze,u as Qe}from"./auth-D17Z0IuK.mjs";import{a as $e,c as G,d as et,i as tt,l as nt,s as rt,t as it,u as at}from"./packageJson-Bvm9nRNl.mjs";import{t as ot}from"./update-notifier-BBo9CSjK.mjs";import{isDeepStrictEqual as st,parseArgs as ct}from"node:util";import{realpath as lt,rm as ut}from"node:fs/promises";import{fileURLToPath as dt,pathToFileURL as ft}from"node:url";import{randomBytes as pt}from"node:crypto";import{exec as mt}from"node:child_process";import{setTimeout as ht}from"node:timers/promises";const gt=R({path:F(),title:F(),description:P(F())}),_t=R({path:F(),title:F(),description:P(F()),anchors:I(R({slug:F(),excerpt:F()}))});async function vt(e){let t=new URL(`api/index/`,xt(e.host));return B(t,{schema:I(gt),unknownErrorMessage:`Failed to fetch documentation index`})}async function yt(e,t){let n=new URL(`api/index/${e}`,xt(t.host));return B(n,{schema:_t,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function bt(e,t){let n=new URL(e,xt(t.host));return B(n,{headers:{Accept:`text/markdown`,...t.headers},schema:F(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function xt(e=`prismic.io`){return new URL(`https://${e}/docs/`)}var St=T({name:`prismic docs list`,description:`
3
3
  List available documentation pages.
4
4
 
5
5
  With a path argument, list the anchors within that page.
@@ -1,4 +1,4 @@
1
- import{a as e,b as t,c as n,g as r,l as i,nt as a,ot as o,t as s,tt as c,u as l}from"./adapters-MNdCxfbS.mjs";import{c as u,h as d}from"./request-DozpYv-V.mjs";import{n as f,o as p}from"./packageJson-Bvm9nRNl.mjs";import{relative as m}from"node:path";import{fileURLToPath as h}from"node:url";const g=c`
1
+ import{a as e,b as t,c as n,g as r,l as i,nt as a,ot as o,t as s,tt as c,u as l}from"./adapters-DPb0t6EU.mjs";import{c as u,h as d}from"./request-DozpYv-V.mjs";import{n as f,o as p}from"./packageJson-Bvm9nRNl.mjs";import{relative as m}from"node:path";import{fileURLToPath as h}from"node:url";const g=c`
2
2
  return (
3
3
  <section
4
4
  data-slice-type={slice.slice_type}
@@ -1,4 +1,4 @@
1
- import{S as e,b as t,g as n,l as r,nt as i,ot as a,t as o,tt as s,u as c,w as l}from"./adapters-MNdCxfbS.mjs";import{c as u,h as d}from"./request-DozpYv-V.mjs";import{d as f,n as p,o as m}from"./packageJson-Bvm9nRNl.mjs";import{t as h}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as g,rm as _}from"node:fs/promises";import{relative as v}from"node:path";import{fileURLToPath as y}from"node:url";var b,x,S,C,w;const T=s`
1
+ import{S as e,b as t,g as n,l as r,nt as i,ot as a,t as o,tt as s,u as c,w as l}from"./adapters-DPb0t6EU.mjs";import{c as u,h as d}from"./request-DozpYv-V.mjs";import{d as f,n as p,o as m}from"./packageJson-Bvm9nRNl.mjs";import{t as h}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as g,rm as _}from"node:fs/promises";import{relative as v}from"node:path";import{fileURLToPath as y}from"node:url";var b,x,S,C,w;const T=s`
2
2
  <template>
3
3
  <section
4
4
  :data-slice-type="slice.slice_type"
@@ -0,0 +1 @@
1
+ var e=`prismic`,t=`1.22.0`;export{t as n,e as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./package-MeH39gTS.mjs";import{fileURLToPath as n}from"node:url";import{spawn as r}from"node:child_process";const i=[],a=[];let o,s;function c(e){let{writeKey:t}=e;o=e.anonymousId,s=e.userId,process.on(`exit`,()=>d({writeKey:t}))}function l(n){s=n.userId,a.push({userId:n.userId,anonymousId:o,integrations:{Intercom:{user_hash:n.intercomHash}},context:{app:{name:t,version:e}},timestamp:(/* @__PURE__ */ new Date()).toISOString()})}function u(n,r={}){let{properties:a,groupId:c}=r;i.push({event:n,properties:{nodeVersion:process.versions.node,...a},context:{app:{name:t,version:e},groupId:c},userId:s,anonymousId:o,timestamp:(/* @__PURE__ */ new Date()).toISOString()})}function d(e){let{writeKey:t}=e;if(i.length!==0||a.length!==0){try{let e=Buffer.from(JSON.stringify({trackEvents:i.map(e=>({...e,userId:e.userId||s})),identifyEvents:a,writeKey:t})).toString(`base64`),o=n(new URL(`./subprocesses/sendSegmentEvents.mjs`,import.meta.url));r(process.execPath,[o,e],{detached:!0,stdio:`ignore`}).unref()}catch{}i.length=0,a.length=0}}async function f(e,t,n){let r={"Content-Type":`application/json`,Authorization:`Basic ${btoa(n+`:`)}`};await Promise.allSettled([...e.map(e=>fetch(`https://api.segment.io/v1/track`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{})),...t.map(e=>fetch(`https://api.segment.io/v1/identify`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{}))])}export{l as i,f as n,u as r,c as t};
1
+ import{n as e,t}from"./package-BmR9etBQ.mjs";import{fileURLToPath as n}from"node:url";import{spawn as r}from"node:child_process";const i=[],a=[];let o,s;function c(e){let{writeKey:t}=e;o=e.anonymousId,s=e.userId,process.on(`exit`,()=>d({writeKey:t}))}function l(n){s=n.userId,a.push({userId:n.userId,anonymousId:o,integrations:{Intercom:{user_hash:n.intercomHash}},context:{app:{name:t,version:e}},timestamp:(/* @__PURE__ */ new Date()).toISOString()})}function u(n,r={}){let{properties:a,groupId:c}=r;i.push({event:n,properties:{nodeVersion:process.versions.node,...a},context:{app:{name:t,version:e},groupId:c},userId:s,anonymousId:o,timestamp:(/* @__PURE__ */ new Date()).toISOString()})}function d(e){let{writeKey:t}=e;if(i.length!==0||a.length!==0){try{let e=Buffer.from(JSON.stringify({trackEvents:i.map(e=>({...e,userId:e.userId||s})),identifyEvents:a,writeKey:t})).toString(`base64`),o=n(new URL(`./subprocesses/sendSegmentEvents.mjs`,import.meta.url));r(process.execPath,[o,e],{detached:!0,stdio:`ignore`}).unref()}catch{}i.length=0,a.length=0}}async function f(e,t,n){let r={"Content-Type":`application/json`,Authorization:`Basic ${btoa(n+`:`)}`};await Promise.allSettled([...e.map(e=>fetch(`https://api.segment.io/v1/track`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{})),...t.map(e=>fetch(`https://api.segment.io/v1/identify`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{}))])}export{l as i,f as n,u as r,c as t};
@@ -1 +1 @@
1
- import{a as e}from"../auth-BlIfsyue.mjs";try{await e()}catch{}export{};
1
+ import{a as e}from"../auth-D17Z0IuK.mjs";try{await e()}catch{}export{};
@@ -1 +1 @@
1
- import{n as e}from"../segment-B2mFer7f.mjs";const{trackEvents:t,identifyEvents:n,writeKey:r}=JSON.parse(Buffer.from(process.argv[2],`base64`).toString());try{await e(t,n,r)}catch{}export{};
1
+ import{n as e}from"../segment-DiEeqnUu.mjs";const{trackEvents:t,identifyEvents:n,writeKey:r}=JSON.parse(Buffer.from(process.argv[2],`base64`).toString());try{await e(t,n,r)}catch{}export{};
@@ -1 +1 @@
1
- import{n as e}from"../update-notifier-Cp2c4p0x.mjs";const[t,n]=process.argv.slice(2);try{await e(t,new URL(n))}catch{}export{};
1
+ import{n as e}from"../update-notifier-BBo9CSjK.mjs";const[t,n]=process.argv.slice(2);try{await e(t,new URL(n))}catch{}export{};
@@ -1,4 +1,4 @@
1
- import{a as e,b as t,c as n,g as r,l as i,nt as a,ot as o,t as s,tt as c,u as l}from"./adapters-MNdCxfbS.mjs";import{c as u,h as d}from"./request-DozpYv-V.mjs";import{n as f,o as p}from"./packageJson-Bvm9nRNl.mjs";import{t as m}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as h,rm as g}from"node:fs/promises";import{relative as _}from"node:path";import{fileURLToPath as v}from"node:url";var y,b,x,S,C,w,T,E,D,O;function k({typescript:e}){return e?c`
1
+ import{a as e,b as t,c as n,g as r,l as i,nt as a,ot as o,t as s,tt as c,u as l}from"./adapters-DPb0t6EU.mjs";import{c as u,h as d}from"./request-DozpYv-V.mjs";import{n as f,o as p}from"./packageJson-Bvm9nRNl.mjs";import{t as m}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as h,rm as g}from"node:fs/promises";import{relative as _}from"node:path";import{fileURLToPath as v}from"node:url";var y,b,x,S,C,w,T,E,D,O;function k({typescript:e}){return e?c`
2
2
  import { createClient as baseCreateClient } from "@prismicio/client";
3
3
  import { type CreateClientConfig, enableAutoPreviews } from '@prismicio/svelte/kit';
4
4
  import { env } from '$env/dynamic/public';
@@ -1 +1 @@
1
- import{n as e}from"./package-MeH39gTS.mjs";import{A as t,D as n,M as r,P as i,d as a,h as o,s}from"./request-DozpYv-V.mjs";import{o as c}from"./packageJson-Bvm9nRNl.mjs";import{fileURLToPath as l}from"node:url";import{spawn as u}from"node:child_process";const d=n({latestKnownVersion:r(i()),lastUpdateCheckAt:r(t())});async function f(t){try{if(p())return;let n=await m(t.statePath),r=e;if(n?.latestKnownVersion&&h(n.latestKnownVersion,r)){let e=`Update available: ${r} → ${n.latestKnownVersion}. Run \`npx ${t.npmPackageName}@latest --version\` to update.`;process.on(`exit`,()=>{try{console.error(`\n${e}`)}catch{}})}(!n?.lastUpdateCheckAt||Date.now()-n.lastUpdateCheckAt>864e5)&&process.on(`exit`,()=>{_(t.npmPackageName,t.statePath)})}catch{}}function p(){return process.env.NO_UPDATE_NOTIFIER!==`0`&&!(process.env.NO_UPDATE_NOTIFIER!==`1`&&!process.env.CI&&process.stderr.isTTY)}async function m(e){return a(e,{schema:d}).catch(()=>void 0)}function h(e,t){if(e.includes(`-`)||t.includes(`-`))return!1;let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);if(n.length!==3||r.length!==3||n.some(e=>!Number.isFinite(e))||r.some(e=>!Number.isFinite(e)))return!1;for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!1}async function g(e,t){let n=await c(e);await o(t,s({latestKnownVersion:n,lastUpdateCheckAt:Date.now()}))}function _(e,t){try{let n=l(new URL(`./subprocesses/updateVersionState.mjs`,import.meta.url));u(process.execPath,[n,e,t.href],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{g as n,f as t};
1
+ import{n as e}from"./package-BmR9etBQ.mjs";import{A as t,D as n,M as r,P as i,d as a,h as o,s}from"./request-DozpYv-V.mjs";import{o as c}from"./packageJson-Bvm9nRNl.mjs";import{fileURLToPath as l}from"node:url";import{spawn as u}from"node:child_process";const d=n({latestKnownVersion:r(i()),lastUpdateCheckAt:r(t())});async function f(t){try{if(p())return;let n=await m(t.statePath),r=e;if(n?.latestKnownVersion&&h(n.latestKnownVersion,r)){let e=`Update available: ${r} → ${n.latestKnownVersion}. Run \`npx ${t.npmPackageName}@latest --version\` to update.`;process.on(`exit`,()=>{try{console.error(`\n${e}`)}catch{}})}(!n?.lastUpdateCheckAt||Date.now()-n.lastUpdateCheckAt>864e5)&&process.on(`exit`,()=>{_(t.npmPackageName,t.statePath)})}catch{}}function p(){return process.env.NO_UPDATE_NOTIFIER!==`0`&&!(process.env.NO_UPDATE_NOTIFIER!==`1`&&!process.env.CI&&process.stderr.isTTY)}async function m(e){return a(e,{schema:d}).catch(()=>void 0)}function h(e,t){if(e.includes(`-`)||t.includes(`-`))return!1;let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);if(n.length!==3||r.length!==3||n.some(e=>!Number.isFinite(e))||r.some(e=>!Number.isFinite(e)))return!1;for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!1}async function g(e,t){let n=await c(e);await o(t,s({latestKnownVersion:n,lastUpdateCheckAt:Date.now()}))}function _(e,t){try{let n=l(new URL(`./subprocesses/updateVersionState.mjs`,import.meta.url));u(process.execPath,[n,e,t.href],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{g as n,f as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prismic",
3
- "version": "1.22.0-pr.391.f4f92e5",
3
+ "version": "1.22.0",
4
4
  "description": "Prismic's official command line tool",
5
5
  "keywords": [
6
6
  "prismic",
@@ -1 +0,0 @@
1
- var e=`prismic`,t=`1.22.0-pr.391.f4f92e5`;export{t as n,e as t};