prismic 1.28.0 → 1.29.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.
- package/dist/{adapters-_6OwtgCL.mjs → adapters-C-tqRizJ.mjs} +12 -12
- package/dist/index.mjs +100 -95
- package/dist/{nextjs-CiU-wONg.mjs → nextjs-Cydao8so.mjs} +1 -1
- package/dist/{nuxt-BNM57THK.mjs → nuxt-DZlxcDTY.mjs} +10 -10
- package/dist/package-CR69YEZ6.mjs +1 -0
- package/dist/{segment-BW5d22g2.mjs → segment-B2JRNROf.mjs} +1 -1
- package/dist/subprocesses/sendSegmentEvents.mjs +1 -1
- package/dist/subprocesses/updateVersionState.mjs +1 -1
- package/dist/sveltekit-B3tYQDoW.mjs +1 -0
- package/dist/{sveltekit-BvwbM55F.mjs → sveltekit-DCytYnBb.mjs} +1 -1
- package/dist/{sveltekit2-CVfxQ2tH.mjs → sveltekit2-DbVLruSc.mjs} +1 -1
- package/dist/{update-notifier-CaPWDsNo.mjs → update-notifier-BGQNWIvh.mjs} +1 -1
- package/package.json +5 -5
- package/dist/package-DPO7tnYd.mjs +0 -1
- package/dist/sveltekit-C5og1T-S.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./package-
|
|
1
|
+
import{n as e}from"./package-CR69YEZ6.mjs";import{$ as t,A as n,B as r,D as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,N as f,O as p,P as m,Q as h,R as g,S as _,T as v,U as ee,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,at as E,b as D,et as O,g as te,h as ne,it as k,j as A,l as re,m as j,nt as M,p as N,q as P,r as F,rt as I,t as L,tt as R,w as z,y as B,z as V}from"./packageJson-Du_fIYqH.mjs";import{i as H,r as U,t as ie}from"./segment-B2JRNROf.mjs";import{parseArgs as ae}from"node:util";import{chmod as W,lstat as oe,mkdir as G,open as se,readFile as ce,realpath as le,rename as ue,rm as de,stat as fe,utimes as pe,writeFile as me}from"node:fs/promises";import{sep as he}from"node:path";import{fileURLToPath as ge,pathToFileURL as _e}from"node:url";import*as ve from"node:crypto";import{createCipheriv as ye,createDecipheriv as be,createHash as xe,randomBytes as Se,randomUUID as Ce}from"node:crypto";import*as we from"fs";import{readdir as Te,readdirSync as Ee,realpath as De,realpathSync as Oe,stat as ke,statSync as Ae}from"fs";import{basename as je,dirname as Me,isAbsolute as Ne,normalize as Pe,posix as Fe,relative as Ie,resolve as Le,sep as Re}from"path";import{fileURLToPath as ze}from"url";import{createRequire as Be}from"module";import{homedir as Ve,hostname as He,release as Ue}from"node:os";import{setTimeout as We}from"node:timers/promises";import{constants as Ge,existsSync as Ke}from"node:fs";import{exec as qe,spawn as Je}from"node:child_process";var Ye=Object.create,Xe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Qe=Object.getOwnPropertyNames,$e=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty,tt=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),nt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Qe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!et.call(e,s)&&s!==n&&Xe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ze(t,s))||r.enumerable});return e},rt=(e,t,n)=>(n=e==null?{}:Ye($e(e)),nt(t||!e||!e.__esModule||!et.call(e,`default`)?Xe(n,`default`,{value:e,enumerable:!0}):n,e));const it=/([\p{Ll}\d])(\p{Lu})/gu,at=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,ot=/(\d)\p{Ll}|(\p{L})\d/u,st=/[^\p{L}\d]+/giu,ct=`$1\0$2`;function lt(e){let t=e.trim();t=t.replace(it,ct).replace(at,ct),t=t.replace(st,`\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 ut(e){let t=lt(e);for(let e=0;e<t.length;e++){let n=t[e],r=ot.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 dt(e,t){let[n,r,i]=bt(e,t);return n+r.map(gt(t?.locale)).join(t?.delimiter??` `)+i}function ft(e,t){let[n,r,i]=bt(e,t),a=gt(t?.locale),o=_t(t?.locale),s=t?.mergeAmbiguousCharacters?vt(a,o):yt(a,o);return n+r.map((e,t)=>t===0?a(e):s(e,t)).join(t?.delimiter??``)+i}function pt(e,t){let[n,r,i]=bt(e,t),a=gt(t?.locale),o=_t(t?.locale),s=t?.mergeAmbiguousCharacters?vt(a,o):yt(a,o);return n+r.map(s).join(t?.delimiter??``)+i}function mt(e,t){let[n,r,i]=bt(e,t),a=gt(t?.locale),o=_t(t?.locale);return n+r.map(vt(a,o)).join(t?.delimiter??` `)+i}function ht(e,t){return dt(e,{delimiter:`_`,...t})}function gt(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function _t(e){return e===!1?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function vt(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function yt(e,t){return(n,r)=>{let i=n[0];return(r>0&&i>=`0`&&i<=`9`?`_`+i:t(i))+e(n.slice(1))}}function bt(e,t={}){let n=t.split??(t.separateNumbers?ut:lt),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 xt(e,t){return(!e||e.endsWith(`
|
|
2
2
|
`))&&!t?.force?e:e+`
|
|
3
3
|
`}function K(e,t){return xt(t)+e}function St(e,t){return(!e||e.endsWith(`
|
|
4
4
|
|
|
@@ -179,19 +179,19 @@ if(!n)throw Error(`Please specify a glob function to use glob matching.`);var r=
|
|
|
179
179
|
/* node:coverage ignore next 2 */
|
|
180
180
|
const hr=/^[A-Z]:\/$/i,gr=fr?e=>hr.test(e):e=>e===`/`;function _r(e,t,n){if(e===t||t.startsWith(`${e}/`)){if(n){let t=e.length+ +!gr(e);return(e,n)=>e.slice(t,n?-1:void 0)||`.`}let r=t.slice(e.length+1);return r?(e,t)=>{if(e===`.`)return r;let n=`${r}/${e}`;return t?n.slice(0,-1):n}:(e,t)=>t&&e!==`.`?e.slice(0,-1):e}return n?t=>Fe.relative(e,t)||`.`:n=>Fe.relative(e,`${t}/${n}`)||`.`}function vr(e,t){if(t.startsWith(`${e}/`)){let n=t.slice(e.length+1);return e=>`${n}/${e}`}return n=>{let r=Fe.relative(e,`${t}/${n}`);return n[n.length-1]===`/`&&r!==``?`${r}/`:r||`.`}}function yr(e){return e.replace(dr,e=>`${e}/`)}const br={parts:!0};function xr(e){let t=cr.default.scan(e,br);return t.parts?.length?t.parts:[e]}const Sr=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,Cr=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,wr=fr?e=>e.replace(Cr,`\\$&`):e=>e.replace(Sr,`\\$&`);function Tr(e,t){if(t?.caseSensitiveMatch===!1)return!0;let n=cr.default.scan(e);return n.isGlob||n.negated}function Er(...e){console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString(`es`)}]`,...e)}function Dr(e){return typeof e==`string`?[e]:e??[]}const Or=/^(\/?\.\.)+/,kr=/\\(?=[()[\]{}!*+?@|])/g;function Ar(e,t,n,r){let i=t.cwd,a=e;e[e.length-1]===`/`&&(a=e.slice(0,-1)),a[a.length-1]!==`*`&&t.expandDirectories&&(a+=`/**`);let o=wr(i);a=Ne(a.replace(kr,``))?Fe.relative(o,a):Fe.normalize(a);let s=Or.exec(a)?.[0],c=xr(a);if(s){let e=(s.length+1)/3,t=0,r=o.split(`/`);for(;t<e&&c[t+e]===r[r.length+t-e];)a=a.slice(0,(e-t-1)*3)+a.slice((e-t)*3+c[t+e].length+1)||`.`,t++;let l=Fe.join(i,s.slice(t*3));l[0]!==`.`&&n.root.length>l.length&&(n.root=yr(l),n.depthOffset=-e+t)}if(!r&&n.depthOffset>=0){n.commonPath??=c;let e=[],t=Math.min(n.commonPath.length,c.length);for(let r=0;r<t;r++){let t=c[r];if(t===`**`&&!c[r+1]){e.pop();break}if(r===c.length-1||t!==n.commonPath[r]||Tr(t))break;e.push(t)}n.depthOffset=e.length,n.commonPath=e,n.root=yr(e.length>0?Fe.join(i,...e):i)}return a}function jr(e,t,n){let r=[],i=[];for(let t of e.ignore)t&&(t[0]!==`!`||t[1]===`(`)&&i.push(Ar(t,e,n,!0));for(let a of t)a&&(a[0]!==`!`||a[1]===`(`?r.push(Ar(a,e,n,!1)):(a[1]!==`!`||a[2]===`(`)&&i.push(Ar(a.slice(1),e,n,!0)));return{match:r,ignore:i}}function Mr(e,t){let n=e.cwd,r={root:n,depthOffset:0},i=jr(e,t,r);e.debug&&Er(`internal processing patterns:`,i);let{absolute:a,caseSensitiveMatch:o,debug:s,dot:c,followSymbolicLinks:l,onlyDirectories:u}=e,d=r.root.replace(ur,``),f={dot:c,nobrace:e.braceExpansion===!1,nocase:!o,noextglob:e.extglob===!1,noglobstar:e.globstar===!1,posix:!0},p=(0,cr.default)(i.match,f),m=(0,cr.default)(i.ignore,f),h=mr(i.match,f),g=_r(n,d,a),_=a?g:_r(n,d,!0),v=(e,t)=>{let n=_(t,!0);return n!==`.`&&!h(n)||m(n)},ee;e.deep!==void 0&&(ee=Math.round(e.deep-r.depthOffset));let y=new nr({filters:[s?(e,t)=>{let n=g(e,t),r=p(n)&&!m(n);return r&&Er(`matched ${n}`),r}:(e,t)=>{let n=g(e,t);return p(n)&&!m(n)}],exclude:s?(e,t)=>{let n=v(e,t);return Er(`${n?`skipped`:`crawling`} ${t}`),n}:v,fs:e.fs,pathSeparator:`/`,relativePaths:!a,resolvePaths:a,includeBasePath:a,resolveSymlinks:l,excludeSymlinks:!l,excludeFiles:u,includeDirs:u||!e.onlyFiles,maxDepth:ee,signal:e.signal}).crawl(d);return e.debug&&Er(`internal properties:`,{...r,root:d}),[y,n!==d&&!a&&vr(n,d)]}function Nr(e,t){if(t)for(let n=e.length-1;n>=0;n--)e[n]=t(e[n]);return e}const Pr={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function Fr(e){let t=Object.assign({},e);for(let e in Pr)t[e]===void 0&&Object.assign(t,{[e]:Pr[e]});return t.cwd=(t.cwd instanceof URL?ze(t.cwd):Le(t.cwd||process.cwd())).replace(ur,`/`),t.ignore=Dr(t.ignore),t.fs&&={readdir:t.fs.readdir||Te,readdirSync:t.fs.readdirSync||Ee,realpath:t.fs.realpath||De,realpathSync:t.fs.realpathSync||Oe,stat:t.fs.stat||ke,statSync:t.fs.statSync||Ae},t.debug&&Er(`globbing with options:`,t),t}function Ir(e,t={}){if(e&&t?.patterns)throw Error(`Cannot pass patterns as both an argument and an option`);let n=lr(e)||typeof e==`string`,r=Dr((n?e:e.patterns)??`**/*`),i=Fr(n?t:e);return r.length>0?Mr(i,r):[]}async function Lr(e,t){let[n,r]=Ir(e,t);return n?Nr(await n.withPromise(),r):[]}// @__NO_SIDE_EFFECTS__
|
|
181
181
|
function Rr(e){return R(m,e)}const zr=`prismic.io`,Br=P({PROD:C(),PRISMIC_SENTRY_DSN:c(y(),`https://e1886b1775bd397cd1afc60bfd2ebfc8@o146123.ingest.us.sentry.io/4510445143588864`),PRISMIC_SENTRY_ENVIRONMENT:l(x()),PRISMIC_SENTRY_ENABLED:l(C()),PRISMIC_TELEMETRY_ENABLED:l(C()),PRISMIC_HOST:l(x()),PRISMIC_TOKEN:l(x()),PRISMIC_DOCS_HOST:l(x()),PRISMIC_CONFIG_DIR:l(x()),PRISMIC_TYPE_BUILDER_ENABLED:l(C()),PRISMIC_SYNC_POLL_MS:l((/* @__PURE__ */ Rr()).check(M(100))),PRISMIC_AUTH0_DOMAIN:l(x()),PRISMIC_AUTH0_CLIENT_ID:l(x()),PRISMIC_AGENT_WAIT_MS:a(l((/* @__PURE__ */ Rr()).check(M(1))),void 0)}),Vr=I(Br,{...process.env,PROD:`true`});function Hr(e,t){if(t)return A(_e(t));if(process.platform===`win32`){let t=process.env.APPDATA;if(t)return new URL(`${e}/`,A(_e(t)))}if(process.platform!==`darwin`){let t=process.env.XDG_CONFIG_HOME;if(t)return new URL(`${e}/`,A(_e(t)))}let n=A(_e(Ve()));return new URL(`.config/${e}/`,n)}const X=Hr(`prismic`,Vr.PRISMIC_CONFIG_DIR),Ur=new URL(`credentials.json`,X),Wr=new URL(`credentials.enc`,X),Gr=new URL(`credentials.lock`,X),Kr=new URL(`login.lock`,X),qr=new URL(`update-notifier.json`,X),Jr=new URL(`analytics.json`,X),Yr=1e4,Xr={"User-Agent":`prismic-cli/${e} (${process.platform})`},Zr=P({auth0Domain:x(),clientId:x(),deviceCode:x(),userCode:x(),verificationUri:x(),verificationUriComplete:l(x()),expiresAt:u(),intervalMs:u(),startedAt:u()}),Qr=P({device_code:x(),user_code:x(),verification_uri:x(),verification_uri_complete:l(x()),expires_in:u(),interval:l(u())});async function $r(e,t){let r=new URL(`oauth/device/code`,ai(t.auth0Domain)),i=await n(r,{method:`POST`,body:new URLSearchParams({client_id:t.clientId,...e}),headers:Xr,signal:AbortSignal.timeout(Yr),schema:Qr}).catch(e=>{let t=oi(e)??(si(e)?`unavailable`:void 0);throw t?new di(t,e):e});return{auth0Domain:t.auth0Domain,clientId:t.clientId,deviceCode:i.device_code,userCode:i.user_code,verificationUri:i.verification_uri,verificationUriComplete:i.verification_uri_complete,expiresAt:Date.now()+i.expires_in*1e3,intervalMs:i.interval===void 0?5e3:i.interval*1e3,startedAt:Date.now()}}const ei=P({access_token:x(),refresh_token:x(),expires_in:u()});async function ti(e,t){let{signal:r,onUpdate:i}=t,a=e,o=a.intervalMs;for(;;){if(r?.throwIfAborted(),Date.now()>=a.expiresAt)throw new di(`expired`);try{let e=new URL(`oauth/token`,ai(a.auth0Domain)),t=await n(e,{method:`POST`,body:new URLSearchParams({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:a.deviceCode,client_id:a.clientId}),headers:Xr,signal:AbortSignal.timeout(Yr),schema:ei});return{accessToken:t.access_token,refreshToken:t.refresh_token,expiresAt:Date.now()+t.expires_in*1e3}}catch(e){let t=ui(e),n=li(e)?.error;if(n===`authorization_pending`)o=Math.max(a.intervalMs,t);else if(n===`slow_down`)a={...a,intervalMs:a.intervalMs+5e3},await i(a),o=Math.max(a.intervalMs,t);else{let n=oi(e);if(n)throw new di(n,e);if(!si(e))throw e;let r=Math.min(6e4,Math.max(o,1e3)*2);o=Math.max(a.intervalMs,r,t)}}let e=Math.min(o,a.expiresAt-Date.now());e>0&&await We(e,void 0,{signal:r}).catch(()=>r?.throwIfAborted())}}const ni=P({access_token:x(),refresh_token:l(x()),expires_in:u()});async function ri(e,t){let r=new URL(`oauth/token`,ai(t.auth0Domain)),i=await n(r,{method:`POST`,body:new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:t.clientId}),headers:Xr,signal:AbortSignal.timeout(Yr),schema:ni}).catch(e=>{let t=li(e)?.error;if(t!==`invalid_grant`&&t!==`access_denied`)throw new di(si(e)?`unavailable`:`misconfigured`,e)});if(i)return{accessToken:i.access_token,refreshToken:i.refresh_token??e,expiresAt:Date.now()+i.expires_in*1e3}}async function ii(e,t){let r=new URL(`oauth/revoke`,ai(t.auth0Domain));await n(r,{method:`POST`,body:new URLSearchParams({client_id:t.clientId,token:e}),headers:Xr,signal:AbortSignal.timeout(Yr)}).catch(e=>{throw new di(si(e)?`unavailable`:`misconfigured`,e)})}function ai(e){return new URL(/^https?:\/\//.test(e)?e:`https://${e}/`)}function oi(e){if(e instanceof i){let t=li(e);switch(t?.error){case`expired_token`:return`expired`;case`access_denied`:return t?.error_description===`email_verification_failed`?`email-unverified`:`declined`;case`invalid_grant`:return`invalid-grant`}return si(e)?void 0:`misconfigured`}if(e instanceof E)return`misconfigured`}function si(e){return e instanceof i?e.status===429||e.status>=500:e instanceof v||e instanceof DOMException&&e.name===`TimeoutError`}const ci=P({error:x(),error_description:l(x())});function li(e){if(e instanceof i)return k(ci,e.body).data}function ui(e){let t=e instanceof i?e.response.headers.get(`Retry-After`):null;if(!t)return 0;let n=Number(t);if(Number.isFinite(n))return Math.max(0,n*1e3);let r=Date.parse(t);return Number.isFinite(r)?Math.max(0,r-Date.now()):0}var di=class extends Error{name=`DeviceFlowError`;reason;detail;constructor(e,t){let n=t===void 0?void 0:fi(t);super(n?`${e} (${n})`:e),this.reason=e,this.detail=n}};function fi(e){return e instanceof i?li(e)?.error??`HTTP ${e.status}`:e instanceof DOMException&&e.name===`TimeoutError`?`timeout`:e instanceof v?`network error`:`unexpected response`}const pi=[36,51];var mi=class extends Error{name=`KeyringError`;reason;constructor(e,t){super(`Keychain error: ${e}`,t),this.reason=e}};const hi={async get(e,t,n){return(await gi([`find-generic-password`,`-s`,e,`-a`,t,`-w`],void 0,n))?.replace(/\n$/,``)},async set(e,t,n,r){if(![e,t,n].every(e=>/^[^\s"'\\]+$/.test(e)))throw TypeError(`Keychain values can't contain spaces, quotes or backslashes.`);await gi([`-i`],`add-generic-password -U -s ${e} -a ${t} -w ${n}\n`,r)},async delete(e,t,n){await gi([`delete-generic-password`,`-s`,e,`-a`,t],void 0,n)}};function gi(e,t,n){return new Promise((r,i)=>{let a=Je(`/usr/bin/security`,e,{detached:!0,signal:AbortSignal.timeout(n.timeoutMs),stdio:[`pipe`,`pipe`,`ignore`]}),o=``;a.stdout.setEncoding(`utf8`).on(`data`,e=>o+=e),a.on(`error`,e=>{i(new mi(e.name===`AbortError`?`timeout`:`unavailable`,{cause:e}))}),a.on(`close`,e=>{e===0?r(o):e===44?r(void 0):i(new mi(pi.includes(e??0)?`locked`:`rejected`))}),a.stdin.end(t)})}const _i={async get(e,t,n){return await vi(e,t,n,(e,t)=>e.getPassword(t))??void 0},async set(e,t,n,r){await vi(e,t,r,(e,t)=>e.setPassword(n,t))},async delete(e,t,n){await vi(e,t,n,(e,t)=>e.deleteCredential(t))}};async function vi(e,t,n,r){let i;try{({AsyncEntry:i}=await import(`@napi-rs/keyring`))}catch(e){throw new mi(`module-missing`,{cause:e})}let a=AbortSignal.timeout(n.timeoutMs);try{return await r(new i(e,t,{linux:{store:`secret-service`}}),a)}catch(e){if(a.aborted)throw new mi(`timeout`,{cause:e});let t=e instanceof Error?e.message:``;throw/locked/i.test(t)?new mi(`locked`,{cause:e}):new mi(process.platform===`linux`?`unavailable`:`rejected`,{cause:e})}}const yi=process.platform===`darwin`?hi:_i;async function bi(e,t){let{timeoutMs:n}=t,r={id:Ce(),pid:process.pid,hostname:He()},i=Date.now()+n,a=25;for(;!await Si(e,r);)if(!await Ci(e)){if(Date.now()>=i)throw new xi(`Timed out waiting for the lock at ${ge(e)}.`);await We(a*(.5+Math.random())),a=Math.min(a*2,500)}let o=!1,s=async()=>!o&&(await wi(e))?.id===r.id,c=setInterval(async()=>{if(!await s())return;let t=/* @__PURE__ */ new Date;await pe(Ti(e),t,t).catch(()=>{})},2e3);return c.unref(),{isHeld:s,async release(){clearInterval(c);let t=await s();o=!0,t&&await de(e,{recursive:!0,force:!0})}}}var xi=class extends Error{name=`LockTimeoutError`};async function Si(e,t){try{await G(e)}catch(e){if(e.code===`EEXIST`)return!1;throw e}try{return await me(Ti(e),JSON.stringify(t),{flag:`wx`}),!0}catch(e){let{code:t}=e;if(t===`EEXIST`||t===`ENOENT`)return!1;throw e}}async function Ci(e){let t=await wi(e),n=await fe(Ti(e)).catch(()=>fe(e)).catch(()=>void 0);if(!n)return!0;let r=Date.now()-n.mtimeMs,i=r>1e4,a=!t&&r>1e3,o=t?.hostname===He()&&!Ei(t.pid);if(!i&&!a&&!o)return!1;let s=new URL(`${e.href}.stale-${Ce()}`);try{await ue(e,s)}catch{return!1}let c=await wi(s);if(c&&c.id!==t?.id)try{return await ue(s,e),!1}catch{}return await de(s,{recursive:!0,force:!0}),!0}async function wi(e){try{return JSON.parse(await ce(Ti(e),`utf8`))}catch{return}}function Ti(e){return new URL(`${e.href}/owner.json`)}function Ei(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}const Di=`prismic-cli`,Oi=`cli:${xe(`sha256`).update(ge(X)).digest(`hex`).slice(0,16)}`,ki=5e3,Ai=3e4,ji=Buffer.from([1]),Mi=P({host:x(),auth0Domain:x(),clientId:x(),accessToken:l(x()),refreshToken:l(x()),expiresAt:l(u()),pendingLogin:l(r(Zr,{host:x()}))}),Ni=d([`wsl`,`secret-service-missing`,`locked`,`write-rejected`,`timeout`,`module-missing`]),Pi=d([`keyring`,`file`]),Fi=P({version:l(t()),host:a(l(x()),void 0),store:a(l(Pi),void 0),storeReason:a(l(Ni),void 0),expiresAt:a(l(u()),void 0)});let Ii,Li=!1;async function Ri(){let e=aa(await ia(Ur)),{version:t,store:n,storeReason:r}=k(Fi,e).data??{};if(t===void 0)return{};if(t!==2)throw new Z("Your Prismic login was saved by a newer version of the CLI. Update the CLI, or run `prismic login` again.");if(!n)throw Zi();let i=k(Mi,n===`file`?e:aa(await Yi()));if(!i.success)throw Zi();return{login:{store:n,storeReason:r,session:i.data}}}async function zi(){let e=aa(await ia(Ur).catch(()=>void 0));return k(Fi,e).data??{}}const Bi={"module-missing":`module-missing`,unavailable:`secret-service-missing`,locked:`locked`,rejected:`write-rejected`,timeout:`timeout`};async function Vi(e){if(process.platform===`linux`&&/microsoft/i.test(Ue()))return{store:`file`,storeReason:`wsl`};try{if(Ii=void 0,!await qi(ki)){let t=Se(32);await Qi(e),await yi.set(Di,Oi,t.toString(`base64`),{timeoutMs:ki}),Ii=t}return{store:`keyring`}}catch(e){if(!(e instanceof mi))throw e;return{store:`file`,storeReason:Bi[e.reason]}}}async function Hi(e,t){let{store:n,storeReason:r,session:i}=t,a;if(n===`keyring`){let{host:t,expiresAt:r,auth0Domain:o,clientId:s}=i;a=await na(e,[[Wr,$i(JSON.stringify(i),await Ji())],[Ur,N({version:2,host:t,expiresAt:r,store:n,auth0Domain:o,clientId:s})]])}else a=await na(e,[[Ur,N({version:2,store:n,storeReason:r,...i})]]),await ra(e,Wr);a||Li||(Li=!0,console.warn(`Can't make ${ge(Ur)} readable only by you on this disk. Set PRISMIC_CONFIG_DIR to a private folder on another disk.`))}async function Ui(e){let{host:t,store:n}=await zi(),r=n===`keyring`||await j(Wr);t?await na(e,[[Ur,N({host:t})]]):await ra(e,Ur),await ra(e,Wr),r&&(Ii=void 0,await Qi(e),await yi.delete(Di,Oi,{timeoutMs:Ai}).catch(e=>{if(!(e instanceof mi))throw e;console.warn(`Can't delete your Prismic key from the keychain. Your next login reuses it.`)}))}async function Wi(e){let t=await Ki(Gr,{timeoutMs:3e4}).catch(e=>{throw e instanceof xi?new Z(`Another Prismic command is still using your login. Run the command again.`):e});try{return await e(t)}finally{await t.release()}}async function Gi(e){return Ki(Kr,e)}async function Ki(e,t){try{return await ta(),await bi(e,t)}catch(e){let t=e.code;throw t!==`EACCES`&&t!==`EPERM`&&t!==`EROFS`?e:new Z(`Can't write to ${ge(X).replace(/[/\\]$/,``)}. Set PRISMIC_CONFIG_DIR to a private folder outside your project.`,{cause:e})}}var Z=class extends Error{name=`CredentialsError`};async function qi(e){if(Ii)return Ii;let t=await yi.get(Di,Oi,{timeoutMs:e}),n=t?Buffer.from(t,`base64`):void 0;return n?.length===32&&(Ii=n),Ii}async function Ji(){let e=await qi(Ai).catch(e=>{throw e instanceof mi?new Z(`Can't read your Prismic key because ${Xi[e.reason]??`the keychain isn't available. Try again`}, or run \`prismic login\` again.`,{cause:e}):e});if(!e)throw Zi();return e}async function Yi(){let e=await ia(Wr),t=Ii!==void 0,n=ea(e,await Ji());return n||!t?n:(Ii=void 0,ea(e,await Ji()))}const Xi={locked:`the keychain is locked in this session. Unlock it and try again`,timeout:`the keychain didn't respond. Try again`};function Zi(){return new Z("Your Prismic login can't be decrypted. Run `prismic login` again.")}async function Qi(e){if(!await e.isHeld())throw new Z(`Another Prismic command took over the login while this one stalled. Run the command again.`)}function $i(e,t){let n=Se(12),r=ye(`aes-256-gcm`,t,n);r.setAAD(ji);let i=Buffer.concat([r.update(e,`utf8`),r.final()]);return Buffer.concat([ji,n,r.getAuthTag(),i])}function ea(e,t){if(!(!e||e.length<29||e[0]!==ji[0]))try{let n=be(`aes-256-gcm`,t,e.subarray(1,13));return n.setAAD(ji),n.setAuthTag(e.subarray(13,29)),Buffer.concat([n.update(e.subarray(29)),n.final()]).toString(`utf8`)}catch{return}}async function ta(){await G(X,{recursive:!0,mode:448}),process.platform!==`win32`&&(await fe(X)).mode&63&&await W(X,448)}async function na(e,t){let n=!0;for(let[r,i]of t){let t=new URL(`${r.href}.${Ce()}.tmp`);try{let n=await se(t,`wx`,384);try{await n.writeFile(i),await n.sync()}finally{await n.close()}await Qi(e),await ue(t,r)}catch(e){throw await de(t,{force:!0}),e}if(process.platform===`win32`)continue;let a=await oe(r);((a.mode&511)!=384||a.uid!==process.getuid?.())&&(n=!1)}return n}async function ra(e,t){await Qi(e),await de(t,{force:!0})}async function ia(e){let t=t=>new Z(`Refusing to read ${ge(e)} because ${t}. Delete it and run \`prismic login\` again.`),n;try{if(process.platform===`win32`&&(await oe(e)).isSymbolicLink())throw t(`it's a symbolic link`);n=await se(e,Ge.O_RDONLY|(Ge.O_NOFOLLOW??0))}catch(n){let{code:r}=n;if(r===`ENOENT`)return;throw r===`ELOOP`?t(`it's a symbolic link`):r===`EACCES`||r===`EPERM`?new Z(`Can't read ${ge(e)}. Delete it and run \`prismic login\` again.`):n}try{let e=await n.stat();if(!e.isFile())throw t(`it isn't a regular file`);if(process.platform===`win32`)return await n.readFile();if(e.uid!==process.getuid?.())throw t(`it belongs to another user`);return e.mode&63&&await n.chmod(384).catch(()=>{}),await n.readFile()}finally{await n.close()}}function aa(e){try{return e&&JSON.parse(e.toString())}catch{return}}function oa(){if(process.env.AI_AGENT?.toLowerCase().startsWith(`claude-code_`))return`claude-code`;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`&&Ke(`/opt/.devin`))return`devin`;if(process.env.IS_SANDBOX===`yes`)return`unknown-sandbox`}function sa(e){let t=process.platform===`darwin`?`open`:process.platform===`win32`?`start ""`:`xdg-open`;qe(`${t} "${e.toString()}"`)}const ca=kt.withOptions({alignValues:!0});function la(e,...t){if(typeof e==`string`)return ca(e);let n=Array.from(e);return ca(Object.assign(n,{raw:n}),...t)}function ua(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e)}function da(e,t){let n=t?.headers?[t.headers,...e]:e,r=[];for(let e of n)for(let t=0;t<e.length;t++)r[t]=Math.max(r[t]??0,e[t].length);return n.map(e=>e.map((t,n)=>n<e.length-1?t.padEnd(r[n]):t).join(` `).trimEnd()).join(`
|
|
182
|
-
`)}const fa=oa()!==void 0,pa={"user-intent":{type:`string`,description:`The user's overall task in one short US English sentence. Paraphrase their original request, not what this command does. Pass the same value on every command for the same task. Used for analytics only.`},"task-id":{type:`string`,description:`Groups the commands of one user request. One id covers the whole request, not one per command. Get a new id from the task-id command when the user asks for something new. Used for analytics only.`},"analytics-intent":{type:`string`,hidden:!0,description:`Renamed to --user-intent.`},"analytics-task-id":{type:`string`,hidden:!0,description:`Renamed to --task-id.`}};function ma(e,t){return async function(){let{positionals:n={},options:r={}}=e,i;try{i=ae({args:process.argv.slice(1+e.name.split(` `).length),options:{...r,...pa,help:{type:`boolean`,short:`h`}},allowPositionals:Object.keys(n).length>0,strict:!0})}catch(e){throw e instanceof TypeError&&`code`in e&&typeof e.code==`string`&&e.code.startsWith(`ERR_PARSE_ARGS_`)?new Q(e.message):e}if(i.values.help){let t=Object.keys(n),i={USAGE:` ${[e.name,...t.map(e=>`<${e}>`),`[options]`].join(` `)}`};t.length>0&&(i.ARGUMENTS=da(Object.entries(n).map(([e,t])=>[` <${e}>`,t.description+(t.required?` (required)`:``)]))),i.OPTIONS=da(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
`)}const fa=oa()!==void 0,pa={"user-intent":{type:`string`,description:`The user's overall task in one short US English sentence. Paraphrase their original request, not what this command does. Pass the same value on every command for the same task. Used for analytics only.`},"task-id":{type:`string`,description:`Groups the commands of one user request. One id covers the whole request, not one per command. Get a new id from the task-id command when the user asks for something new. Used for analytics only.`},"analytics-intent":{type:`string`,hidden:!0,description:`Renamed to --user-intent.`},"analytics-task-id":{type:`string`,hidden:!0,description:`Renamed to --task-id.`}};function ma(e,t){return async function(){let{positionals:n={},options:r={}}=e,i;try{i=ae({args:process.argv.slice(1+e.name.split(` `).length),options:{...r,...pa,help:{type:`boolean`,short:`h`}},allowPositionals:Object.keys(n).length>0,strict:!0})}catch(e){throw e instanceof TypeError&&`code`in e&&typeof e.code==`string`&&e.code.startsWith(`ERR_PARSE_ARGS_`)?new Q(e.message):e}if(i.values.help){let t=Object.keys(n),i={...ga(e.name,e.agents),USAGE:` ${[e.name,...t.map(e=>`<${e}>`),`[options]`].join(` `)}`};t.length>0&&(i.ARGUMENTS=da(Object.entries(n).map(([e,t])=>[` <${e}>`,t.description+(t.required?` (required)`:``)]))),i.OPTIONS=da(_a(r)),console.info(va(e.description,i,e.name.split(` `)[0],e.sections))}else{for(let[e,[t,r]]of Object.entries(n).entries())if(r.required&&!i.positionals[e])throw new Q(`Missing required argument: <${t}>`);for(let[e,t]of Object.entries(r)){if(t.required&&!(e in i.values))throw new Q(`Missing required option: --${e}`);if(e in i.values&&(t.deprecated&&console.warn(`--${e} is deprecated. ${t.deprecated}`),t.dependsOn&&!(t.dependsOn in i.values)))throw new Q(`--${e} can only be used with --${t.dependsOn}.`)}await t(i)}}}function ha(e){return async function(){let{positionals:[t]}=ae({args:process.argv.slice(1+e.name.split(` `).length),options:{...pa,help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});if(t){let n=e.commands[t];if(!n)throw new Q(`Unknown command: ${t}`);await n.handler();return}let n={...ga(e.name),USAGE:` ${e.name} <command> [options]`,COMMANDS:da(Object.entries(e.commands).filter(([,e])=>!e.hidden).map(([e,t])=>[` ${e}`,t.description])),OPTIONS:da(_a({}))};console.info(va(e.description,n,e.name,e.sections))}}function ga(e,t){if(!fa)return{};let n=la`
|
|
183
|
+
Every command except --help, read-only ones included, needs the same
|
|
184
|
+
--task-id and the same --user-intent, the user's request in one sentence, for
|
|
185
|
+
as long as you work on that request. Get the id first: run \`${e.split(` `)[0]} task-id\`
|
|
186
|
+
on its own and wait for its output before you run any other command, as
|
|
187
|
+
commands without the id fail. All the steps of one request share the id, and
|
|
188
|
+
the next request gets a new one. The id and intent are used for analytics
|
|
189
|
+
only.
|
|
190
|
+
`;return{AGENTS:(t?`${n}\n\n${la(t)}`:n).replace(/^(?=.)/gm,` `)}}function _a(e){let t=fa?{...e,...pa}: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 va(e,t,n,r={}){let i=[la(e)];for(let[e,n]of Object.entries(t))i.push(``,e,n);for(let[e,t]of Object.entries(r))i.push(``,e,...la(t).split(`
|
|
191
191
|
`).map(e=>e?` ${e}`:``));return i.push(``,`LEARN MORE`,` Use \`${n} <command> --help\` for more information about a command.`),i.join(`
|
|
192
|
-
`)}function va(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 ya(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 ba=h([P({type:s(`USER`),email:x(),shortId:x()}),P({type:s(`Machine2Machine`),domain:x(),appName:x()})]);async function xa(e,t){let r=new URL(`validate`,Sa(t.host));return n(r,{headers:e?{Authorization:`Bearer ${e}`}:void 0,schema:ba})}function Sa(e){return new URL(`https://auth.${e}/`)}const Ca=P({email:x(),shortId:x(),intercomHash:x()}),wa=P({domain:x(),name:l(x()),role:l(h([x(),S(x(),x())]))});async function Ta(e){let t=new URL(`user/profile`,Da(e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:Ca,unknownErrorMessage:`Failed to load your profile`})}async function Ea(e){let t=new URL(`user/repositories`,Da(e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({repositories:g(wa)}),unknownErrorMessage:`Failed to load your repositories`})}function Da(e){return new URL(`https://api.internal.${e}/`)}const Oa=P({name:l(x()),starter:o(P({id:x(),revision:x(),framework:x(),deploymentUrl:O()})),framework:l(x()),quotas:l(P({sliceMachineEnabled:V()}))});async function ka(e){let t=new URL(``,Pa(e.host));return t.searchParams.set(`repository`,e.repo),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`,repository:e.repo},onUnauthorized:e.onUnauthorized,schema:Oa,notFoundMessage:`Repository not found: ${e.repo}`})}async function Aa(e,t){let r=new URL(`type-builder`,Pa(t.host));r.searchParams.set(`repository`,t.repo),await n(r,{method:`PATCH`,json:{framework:e},headers:{Authorization:`Bearer ${await t.getToken()}`,repository:t.repo},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`})}const ja=P({completedSteps:g(x())});async function Ma(e){let t=new URL(`onboarding`,Pa(e.host));return t.searchParams.set(`repository`,e.repo),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:ja})}async function Na(e,t){let r=new URL(`onboarding/${encodeURIComponent(e)}/toggle`,Pa(t.host));return r.searchParams.set(`repository`,t.repo),n(r,{method:`PATCH`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:ja})}function Pa(e){return new URL(`https://api.internal.${e}/repository/`)}async function Fa(e){let t=new URL(`customtypes`,Ra(e.host));return e.releaseId&&t.searchParams.set(`release`,e.releaseId),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`,repository:e.repo},onUnauthorized:e.onUnauthorized,notFoundMessage:`Repository not found: ${e.repo}`})}async function Ia(e){let t=new URL(`slices`,Ra(e.host));return e.releaseId&&t.searchParams.set(`release`,e.releaseId),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`,repository:e.repo},onUnauthorized:e.onUnauthorized,notFoundMessage:`Repository not found: ${e.repo}`})}async function La(e,t){let r=new URL(`bulk-update`,Ra(t.host));t.releaseId&&r.searchParams.set(`release`,t.releaseId),await n(r,{method:`POST`,json:{changes:e},headers:{Authorization:`Bearer ${await t.getToken()}`,repository:t.repo},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to update models`})}function Ra(e){return new URL(`https://customtypes.${e}/`)}const za=P({values:P({url:x(),fields:S(x(),x())}),imgixEndpoint:x()}),Ba={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`};async function Va(e,t){let r=new URL(`delete`,Ga(t.host));r.searchParams.set(`repository`,t.repo),await n(r,{method:`POST`,json:{sliceId:e},headers:{Authorization:`Bearer ${await t.getToken()}`,repository:t.repo},onUnauthorized:t.onUnauthorized})}async function Ha(e,t){let{sliceId:r,variationId:i,repo:a}=t,o=e.type;if(!(o in Ba))throw new Wa(o);let s=await Ua(t),c=Ba[o],l=`${a}/shared-slices/${r}/${i}/${xe(`sha1`).update(new Uint8Array(await e.arrayBuffer())).digest(`hex`)}${c}`,u=new FormData;for(let[e,t]of Object.entries(s.values.fields))u.append(e,t);u.set(`key`,l),u.set(`Content-Type`,o),u.set(`file`,e),await n(s.values.url,{method:`POST`,body:u});let d=new URL(l,A(s.imgixEndpoint));return d.searchParams.set(`auto`,`compress,format`),d}async function Ua(e){let t=new URL(`presigned-url`,Ga(e.host));return t.searchParams.set(`repository`,e.repo),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`,repository:e.repo},onUnauthorized:e.onUnauthorized,schema:za})}var Wa=class extends Error{name=`UnsupportedFileTypeError`;constructor(e){let t=Object.keys(Ba);super(`Unsupported file type: ${e||`unknown`}. Supported: ${t.join(`, `)}`)}};function Ga(e){return new URL(`https://api.internal.${e}/screenshot/`)}const Ka=P({id:x(),label:x(),customName:b(x()),isMaster:V()});async function qa(e){let t=new URL(`repository/locales`,Xa(e.host));return t.searchParams.set(`repository`,e.repo),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({results:g(Ka)}),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load locales`})}async function Ja(e,t){let r=new URL(`repository/locales`,Xa(t.host));return r.searchParams.set(`repository`,t.repo),n(r,{method:`POST`,json:{id:e.id,isMaster:e.isMaster??!1,...e.customName?{customName:e.customName}:{}},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:Ka,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to save locale`})}async function Ya(e,t){let r=new URL(`repository/locales/${encodeURIComponent(e)}`,Xa(t.host));r.searchParams.set(`repository`,t.repo),await n(r,{method:`DELETE`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Locale not found: ${e}`,unknownErrorMessage:`Failed to remove locale`})}function Xa(e){return new URL(`https://api.internal.${e}/locale/`)}const Za=P({id:x(),label:x(),url:x()});async function Qa(e){let t=new URL(`core/repository/preview_configs`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({results:g(Za)}),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load previews`})}async function $a(e,t){let r=new URL(`previews/new`,$(t.repo,t.host));await n(r,{method:`POST`,json:{name:e.name,websiteURL:e.websiteURL,resolverPath:e.resolverPath},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to add preview`})}async function eo(e,t){let r=new URL(`previews/delete/${encodeURIComponent(e)}`,$(t.repo,t.host));await n(r,{method:`POST`,json:{},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Preview not found: ${e}`,unknownErrorMessage:`Failed to remove preview`})}const to=P({kind:d([`prod`,`stage`,`dev`]),name:x(),domain:x(),users:g(P({id:x()}))});async function no(e){let t=new URL(`core/environments`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({results:g(to)}),notFoundMessage:`Repository not found: ${e.repo}`})}async function ro(e){let t=new URL(`core/repository`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({simulator_url:l(x())}),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load simulator URL`})}async function io(e,t){let r=new URL(`core/repository`,$(t.repo,t.host));await n(r,{method:`PATCH`,json:{simulator_url:e},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to set simulator URL`})}async function ao(e,t){let r=new URL(`core/documents/search`,$(t.repo,t.host));return n(r,{method:`POST`,json:{customTypes:[e],limit:0},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:P({total:u()}),notFoundMessage:`Repository not found: ${t.repo}`})}async function oo(e,t){let r=new URL(`core/releases`,$(t.repo,t.host));return n(r,{method:`POST`,json:e,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:ee({id:x()}),notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to create a release`})}async function so(e,t){let r=new URL(`core/releases/${encodeURIComponent(e)}`,$(t.repo,t.host));await n(r,{method:`DELETE`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Release not found: ${e}`,unknownErrorMessage:`Failed to delete the release`})}const co=P({documentsPublished:V(),documentsUnpublished:V(),releasesCreated:V(),releasesUpdated:V(),tagsCreated:V(),tagsDeleted:V()}),lo=Object.keys(co.shape),uo=P({config:r(co,{_id:x(),url:x(),active:V(),name:b(x()),secret:b(x()),headers:S(x(),x())})});async function fo(e){let t=new URL(`app/settings/webhooks`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:g(uo),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load webhooks`})}async function po(e,t){let r=go({...e,active:!0,headers:{}}),i=new URL(`app/settings/webhooks/create`,$(t.repo,t.host));await n(i,{method:`POST`,body:r,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to create webhook`})}async function mo(e,t,r){let i=go(t),a=new URL(`app/settings/webhooks/${encodeURIComponent(e)}`,$(r.repo,r.host));await n(a,{method:`POST`,body:i,headers:{Authorization:`Bearer ${await r.getToken()}`},onUnauthorized:r.onUnauthorized,notFoundMessage:`Webhook not found: ${e}`,unknownErrorMessage:`Failed to update webhook`})}async function ho(e,t){let r=new URL(`app/settings/webhooks/${encodeURIComponent(e)}/delete`,$(t.repo,t.host));await n(r,{method:`POST`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Webhook not found: ${e}`,unknownErrorMessage:`Failed to delete webhook`})}function go(e){let t=new FormData;return t.set(`url`,e.url),t.set(`name`,e.name??``),t.set(`secret`,e.secret??``),t.set(`headers`,JSON.stringify(e.headers??{})),t.set(`active`,e.active?`on`:`off`),t.set(`documentsPublished`,e.documentsPublished.toString()),t.set(`documentsUnpublished`,e.documentsUnpublished.toString()),t.set(`releasesCreated`,e.releasesCreated.toString()),t.set(`releasesUpdated`,e.releasesUpdated.toString()),t.set(`tagsCreated`,e.tagsCreated.toString()),t.set(`tagsDeleted`,e.tagsDeleted.toString()),t}const _o=P({id:x(),scope:x(),token:x(),created_at:P({$date:u()})}),vo=P({id:x(),name:x(),wroom_auths:g(_o)}),yo=P({app_name:x(),token:x(),timestamp:u()}),bo=P({max_tokens:u(),tokens:g(yo)});async function xo(e){let t=new URL(`settings/security/contentapi`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:g(vo),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load OAuth apps`})}async function So(e,t){let r=new URL(`settings/security/oauthapp`,$(t.repo,t.host));return n(r,{method:`POST`,json:{app_name:e},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:vo,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to create OAuth app`})}async function Co(e,t,r){let i=new URL(`settings/security/authorizations`,$(r.repo,r.host));return n(i,{method:`POST`,json:{app:e,scope:t},headers:{Authorization:`Bearer ${await r.getToken()}`},onUnauthorized:r.onUnauthorized,schema:_o,notFoundMessage:`Repository not found: ${r.repo}`,unknownErrorMessage:`Failed to create token`})}async function wo(e,t){let r=new URL(`settings/security/authorizations/${encodeURIComponent(e)}`,$(t.repo,t.host));await n(r,{method:`DELETE`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Token not found: ${e}`,unknownErrorMessage:`Failed to delete token`})}async function To(e){let t=new URL(`settings/security/customtypesapi`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:bo,notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load write tokens`})}async function Eo(e,t){let r=new URL(`settings/security/token`,$(t.repo,t.host));return n(r,{method:`POST`,json:{app_name:e},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:yo,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to create write token`})}async function Do(e,t){let r=new URL(`settings/security/token/${encodeURIComponent(e)}`,$(t.repo,t.host));await n(r,{method:`DELETE`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Token not found`,unknownErrorMessage:`Failed to delete write token`})}async function Oo(e){let t=new URL(`syncState`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({repository:P({api_access:x()})}),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load repository access`})}async function ko(e,t){let r=new URL(`settings/security/apiaccess`,$(t.repo,t.host));await n(r,{method:`POST`,json:{api_access:e},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to set repository access`})}async function Ao(e,t){let r=new FormData;r.set(`displayname`,e);let i=new URL(`app/settings/repository`,$(t.repo,t.host));return n(i,{method:`POST`,body:r,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:P({repository:P({name:x()})}),notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to set repository name`})}function $(e,t){return new URL(`https://${e}.${t}/`)}async function jo(e){let t=new URL(`app/dashboard/repositories/${encodeURIComponent(e.domain)}/exists`,No(e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:V()})}async function Mo(e){let{domain:t,name:r,framework:i,agent:a,host:o}=e,s=new URL(`app/dashboard/repositories`,No(o));s.searchParams.set(`app`,`cli`),a&&s.searchParams.set(`agent`,a),await n(s,{method:`POST`,json:{domain:t,name:r,framework:i,plan:`personal`},headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,unknownErrorMessage:`Failed to create repository`})}function No(e){return new URL(`https://${e}/`)}const Po=P({path:x(),title:x(),description:l(x())}),Fo=P({path:x(),title:x(),description:l(x()),anchors:g(P({slug:x(),excerpt:x()}))});async function Io(e){let t=new URL(`api/index/`,zo(e.host));return n(t,{schema:g(Po),unknownErrorMessage:`Failed to fetch documentation index`})}async function Lo(e,t){let r=new URL(`api/index/${e}`,zo(t.host));return n(r,{schema:Fo,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function Ro(e,t){let r=new URL(e,zo(t.host));return n(r,{headers:{Accept:`text/markdown`,...t.headers},schema:x(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function zo(e=`prismic.io`){return new URL(`https://${e}/docs/`)}const Bo=ee({exp:l(u()),type:l(x())});function Vo(e){try{let[,t]=e.split(`.`);if(!t)return;let n=JSON.parse(Buffer.from(t,`base64url`).toString());return I(Bo,n)}catch{return}}const Ho=P({anonymousId:x(),userId:l(x())}),Uo=!Vr.PRISMIC_TOKEN;let Wo=!1,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs;async function is(e){let{host:t,repo:n}=e;n&&(Go=n),Xo=e.userIntent,Zo=e.taskId,Qo=e.store,$o=e.storeReason;let r=t===`prismic.io`?`cGjidifKefYb6EPaGaqpt8rQXkv5TD6P`:`Ng5oKJHCGpSWplZ9ymB7Pu7rm0sTDeiG`;Ko=oa(),qo=ls(e.loggedIn),{runtime:Jo,runtimeProvider:Yo}=us();let i=await ps();ns=i??{anonymousId:crypto.randomUUID()},i||await ms(ns),ie({writeKey:r,anonymousId:ns.anonymousId,userId:os()})}function as(e){H({userId:e.shortId,intercomHash:e.intercomHash}),Uo&&!Wo&&ns&&(ns.userId=e.shortId,ms(ns))}function os(){return Uo?ns?.userId:void 0}function ss(){if(!ns)return{};let e=os();return{"Prismic-Anonymous-Id":ns.anonymousId,...e?{"Prismic-User-Id":e}:{}}}async function cs(){Wo=!0;let e=await ps();e?.userId&&await ms({anonymousId:e.anonymousId})}function ls(e){if(!Vr.PRISMIC_TOKEN)return e?`login`:`none`;let t=Vo(Vr.PRISMIC_TOKEN);return t?t.type===`machine2machine`?`write-token`:`user-token`:`unknown-token`}function us(){let e=ds();if(e)return{runtime:`cloud`,runtimeProvider:e};let t=fs();return t||process.env.CI?{runtime:`ci`,runtimeProvider:t}:Ke(`/.dockerenv`)||Ke(`/run/.containerenv`)||process.env.KUBERNETES_SERVICE_HOST?{runtime:`container`}:process.platform!==`linux`||process.env.WSL_DISTRO_NAME?{runtime:`local`}:{runtime:`unknown`}}function ds(){if(process.env.CLAUDE_CODE_REMOTE===`true`)return`claude-code`;if(process.env.CODEX_EXEC_SERVER_REMOTE_BASE_URL)return`codex`;if(process.env.CURSOR_AGENT&&process.env.CLOUD_AGENT_ALL_SECRET_NAMES!==void 0)return`cursor`;if(process.env.CODESPACES===`true`)return`codespaces`;if(process.env.GITPOD_WORKSPACE_ID)return`gitpod`;if(process.versions.webcontainer)return`stackblitz`;if(process.env.REPL_ID)return`replit`;if(process.env.CODESANDBOX_HOST)return`codesandbox`;if(process.env.MODAL_SANDBOX_ID)return`modal`;if(process.env.E2B_SANDBOX)return`e2b`;if(Ke(`/opt/.devin`))return`devin`}function fs(){if(process.env.GITHUB_ACTIONS===`true`)return`github-actions`;if(process.env.GITLAB_CI)return`gitlab`;if(process.env.CIRCLECI)return`circleci`;if(process.env.BITBUCKET_BUILD_NUMBER)return`bitbucket`;if(process.env.TF_BUILD)return`azure-pipelines`;if(process.env.JENKINS_URL)return`jenkins`;if(process.env.BUILDKITE)return`buildkite`;if(process.env.CODEBUILD_BUILD_ID)return`codebuild`;if(process.env.TEAMCITY_VERSION)return`teamcity`;if(process.env.VERCEL&&process.env.CI)return`vercel`;if(process.env.NETLIFY)return`netlify`;if(process.env.CF_PAGES)return`cloudflare-pages`}async function ps(){return w(Jr,{schema:Ho}).catch(()=>void 0)}async function ms(e){await _(Jr,N(e)).catch(()=>{})}function hs(e,t={}){let{watch:n}=t;rs={type:e,watch:n},U(`Prismic CLI Start`,{properties:{commandType:e,fullCommand:process.argv.join(` `),repository:Go,watch:n,agent:Ko,auth:qo,runtime:Jo,runtimeProvider:Yo,userIntent:Xo,taskId:Zo},groupId:Go?{Repository:Go}:void 0})}function gs(e={}){if(!rs)return;let{type:t,watch:n}=rs;rs=void 0;let{error:r}=e,i=r?r instanceof Error?r.message:String(r):void 0;U(`Prismic CLI End`,{properties:{commandType:t,fullCommand:process.argv.join(` `),success:!process.exitCode,repository:Go,watch:n,error:i?.slice(0,512),agent:Ko,auth:qo,store:Qo,storeReason:$o,loginResult:es?.result,loginResumed:es?.resumed,loginDurationS:es?.durationS,revoked:ts,runtime:Jo,runtimeProvider:Yo,userIntent:Xo,taskId:Zo},groupId:Go?{Repository:Go}:void 0})}function _s(e){let{result:t,resumed:n,startedAt:r}=e;es={result:t,resumed:n,durationS:Math.round((Date.now()-r)/1e3)},e.store&&({store:Qo,storeReason:$o}=e)}function vs(e){ts=e.revoked}const ys={expired:`expired`,declined:`declined`,"email-unverified":`email-unverified`,"invalid-grant":`error`,misconfigured:`error`,unavailable:`error`};function bs(e){return e instanceof di?ys[e.reason]:`error`}const xs=P({telemetry:V()});async function Ss(){try{return!(await Cs(Ve())||await Cs(process.cwd()))}catch{return!0}}async function Cs(e){return(await w(new URL(`.prismicrc`,A(_e(e))),{schema:xs}).catch(()=>void 0))?.telemetry===!1}const ws=3e5,Ts=1e3,Es={audience:`prismic.io`,scope:`openid profile email offline_access`},Ds=new URL(`.prismic`,A(_e(Ve())));let Os,ks=!1,As,js;async function Ms(){return Vr.PRISMIC_TOKEN||Ps()}async function Ns(){return Vr.PRISMIC_HOST?Vr.PRISMIC_HOST:(js??=zi().then(e=>e.host),await js||`prismic.io`)}async function Ps(e={}){let{forceRefresh:t=!1}=e,n=(await Ri()).login?.session;if(!n?.refreshToken||n.host!==await Ns())return;let r=Is(n,ws);if(r&&!t)return r;Os??=Wi(async e=>{let{login:t}=await Ri();return Fs(e,t,n.accessToken,{canRetry:!0})}).finally(()=>Os=void 0);try{return await Os}catch(e){let r=Is(n);if((e instanceof di||e instanceof Z)&&r&&!t)return r;throw e}}async function Fs(e,t,n,r){let i=t?.session;if(!t||!i?.refreshToken||i.host!==await Ns())return;let a=Is(i,ws);if(a&&a!==n)return a;let{refreshToken:o,auth0Domain:s,clientId:c,host:l}=i,u=await ri(o,i);if(u)return await Hi(e,{...t,session:{...i,...u}}),u.accessToken;let d=(await Ri()).login;if(r.canRetry&&d?.session.refreshToken!==o&&await e.isHeld())return Fs(e,d,n,{canRetry:!1});await Hi(e,{...t,session:{host:l,auth0Domain:s,clientId:c,pendingLogin:i.pendingLogin}}),ks=!0}function Is(e,t=0){let{accessToken:n,expiresAt:r}=e;if(n&&r&&r-t>Date.now())return n}async function Ls(e,t){if(Vr.PRISMIC_TOKEN||process.env.CI)return;let n=await Ms();if(n&&t.get(`Authorization`)!==`Bearer ${n}`)return e({headers:{Authorization:`Bearer ${n}`}});if(As||await Rs(n))return As??=zs().finally(()=>As=void 0),e({headers:{Authorization:`Bearer ${await As}`}})}async function Rs(e){try{return await xa(e,{host:await Ns()}),!1}catch(e){return e instanceof p||e instanceof z}}async function zs(e={}){return await Ps({forceRefresh:!0})||(console.error(ks?`Your login expired.`:`You are not logged in.`),Bs(e))}async function Bs(e={}){let{browser:t=!1}=e,n=await Ns(),r=Vs(n);if(!r)throw new Q(`Login isn't available for ${n}. Use PRISMIC_TOKEN.`);let i=oa()===void 0&&process.stdin.isTTY===!0&&process.stderr.isTTY===!0,a={host:n,auth0:r,deadline:i?1/0:Date.now()+9e4,startedAt:Date.now(),resumed:!1,waited:!1,tokenBefore:(await Ri().catch(()=>void 0))?.login?.session.accessToken},o=process.rawListeners(`SIGINT`);process.removeAllListeners(`SIGINT`),process.once(`SIGINT`,async()=>{a.cancelled=!0,console.error(),a.pending&&await Ys(a.pending,void 0);let{resumed:e,startedAt:t,saved:n}=a;_s({result:n?`success`:`cancelled`,resumed:e,startedAt:t,store:n?.store,storeReason:n?.storeReason}),await Hs(n?`Logged in to Prismic.`:`Login cancelled.`,130)});let s;try{s=await Us(a,{browser:t&&i})}catch(e){throw _s({result:bs(e),resumed:a.resumed,startedAt:a.startedAt}),e}finally{process.removeAllListeners(`SIGINT`);for(let e of o)process.on(`SIGINT`,e)}let{resumed:c,startedAt:l}=a;if(s.status===`wait-limit`)return _s({result:`wait-limit`,resumed:c,startedAt:l}),Hs(`Waiting for approval. After the user approves, run the same command again. It continues this login.`,1);if(s.status===`logged-out`)throw _s({result:`cancelled`,resumed:c,startedAt:l}),new Q(`A logout cancelled this login. Run the command again to log in.`);let{token:u,email:d,store:f,storeReason:p}=s;return a.pending&&_s({result:`success`,resumed:c,startedAt:l,store:f,storeReason:p}),console.error(`Logged in to Prismic as ${d}`),u}function Vs(e){if(e===`prismic.io`)return{auth0Domain:`auth0.prismic.io`,clientId:`V1yuPKJOHhuHNMR4Oeo2fj5uTCfVebny`};if(e===`wroom.io`||e===`devops-wroom.com`)return{auth0Domain:`auth0.wroom.io`,clientId:`UKxsYw8EcAspkUPRvoFkrO1aj9cA3zkd`};if(/^[a-z0-9-]+-wroom\.com$/.test(e))return{auth0Domain:`auth0.platform-wroom.com`,clientId:`Opbx7JjftGb5sgjIWKVx0XDBSrW37say`}}async function Hs(e,t){process.exitCode=t,gs({error:e}),await new Promise(t=>process.stderr.write(`${e}\n`,t)),process.exit()}async function Us(e,t){let n=await Ws(e);if(!n)return{status:`wait-limit`};let r;try{let n=await Gs(e);if(n.status===`logged-out`)return n;if(n.status===`saved`)r=n;else{let{pending:i}=n;i.deviceCode!==e.shown?.deviceCode&&qs(i);let a=i.verificationUriComplete??i.verificationUri;t.browser&&/^https:\/\/[\w\-.:/?=&~+]+$/.test(a)&&URL.canParse(a)&&sa(new URL(a));let o=await Js(e,i);if(`status`in o)return o;let s=await Xs(e,i,o);if(!s)return{status:`logged-out`};r=s}}finally{await n.release()}await cs();let{email:i}=await Ta({getToken:async()=>r.token,host:e.host});return{...r,status:`logged-in`,email:i}}async function Ws(e){let t=Math.min(e.deadline,Date.now()+9e5);for(;;){let n=e.shown?t-Date.now():0;try{return await Gi({timeoutMs:n})}catch(n){if(!(n instanceof xi))throw n;if(Date.now()>=e.deadline)return;if(Date.now()>=t)throw new di(`expired`)}e.waited=!0;let r=(await Ri().catch(()=>void 0))?.login?.session;e.shown=r&&Ks(r,e),e.shown?qs(e.shown):await We(Ts)}}async function Gs(e){return Wi(async t=>{let n=await Ri().catch(()=>void 0);if(e.shown&&n&&!n.login)return{status:`logged-out`};let r=n?.login,i=r&&Ks(r.session,e);if(i)return e.pending=i,e.startedAt=i.startedAt,e.resumed=!0,{status:`pending`,pending:i};let a=r?.session.host===e.host?r:void 0,o=a&&Is(a.session);if(e.waited&&o&&o!==e.tokenBefore)return{status:`saved`,token:o,store:a.store,storeReason:a.storeReason};let s={...await $r(Es,e.auth0),host:e.host};e.pending=s,e.startedAt=s.startedAt;let c=await Vi(t),l=r?.session??{host:(await zi()).host??e.host,...e.auth0};return await Hi(t,{...c,session:{...l,pendingLogin:s}}),{status:`pending`,pending:s}})}function Ks(e,t){let{pendingLogin:n}=e;if(n&&n.host===t.host&&n.auth0Domain===t.auth0.auth0Domain&&n.clientId===t.auth0.clientId&&n.expiresAt>Date.now())return n}function qs(e){let{userCode:t,verificationUri:n,verificationUriComplete:r}=e,i=Math.max(1,Math.ceil((e.expiresAt-Date.now())/6e4));console.error(la`
|
|
192
|
+
`)}function ya(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 ba(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 xa=h([P({type:s(`USER`),email:x(),shortId:x()}),P({type:s(`Machine2Machine`),domain:x(),appName:x()})]);async function Sa(e,t){let r=new URL(`validate`,Ca(t.host));return n(r,{headers:e?{Authorization:`Bearer ${e}`}:void 0,schema:xa})}function Ca(e){return new URL(`https://auth.${e}/`)}const wa=P({email:x(),shortId:x(),intercomHash:x()}),Ta=P({domain:x(),name:l(x()),role:l(h([x(),S(x(),x())]))});async function Ea(e){let t=new URL(`user/profile`,Oa(e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:wa,unknownErrorMessage:`Failed to load your profile`})}async function Da(e){let t=new URL(`user/repositories`,Oa(e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({repositories:g(Ta)}),unknownErrorMessage:`Failed to load your repositories`})}function Oa(e){return new URL(`https://api.internal.${e}/`)}const ka=P({name:l(x()),starter:o(P({id:x(),revision:x(),framework:x(),deploymentUrl:O()})),framework:l(x()),quotas:l(P({sliceMachineEnabled:V()}))});async function Aa(e){let t=new URL(``,Fa(e.host));return t.searchParams.set(`repository`,e.repo),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`,repository:e.repo},onUnauthorized:e.onUnauthorized,schema:ka,notFoundMessage:`Repository not found: ${e.repo}`})}async function ja(e,t){let r=new URL(`type-builder`,Fa(t.host));r.searchParams.set(`repository`,t.repo),await n(r,{method:`PATCH`,json:{framework:e},headers:{Authorization:`Bearer ${await t.getToken()}`,repository:t.repo},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`})}const Ma=P({completedSteps:g(x())});async function Na(e){let t=new URL(`onboarding`,Fa(e.host));return t.searchParams.set(`repository`,e.repo),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:Ma})}async function Pa(e,t){let r=new URL(`onboarding/${encodeURIComponent(e)}/toggle`,Fa(t.host));return r.searchParams.set(`repository`,t.repo),n(r,{method:`PATCH`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:Ma})}function Fa(e){return new URL(`https://api.internal.${e}/repository/`)}async function Ia(e){let t=new URL(`customtypes`,za(e.host));return e.releaseId&&t.searchParams.set(`release`,e.releaseId),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`,repository:e.repo},onUnauthorized:e.onUnauthorized,notFoundMessage:`Repository not found: ${e.repo}`})}async function La(e){let t=new URL(`slices`,za(e.host));return e.releaseId&&t.searchParams.set(`release`,e.releaseId),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`,repository:e.repo},onUnauthorized:e.onUnauthorized,notFoundMessage:`Repository not found: ${e.repo}`})}async function Ra(e,t){let r=new URL(`bulk-update`,za(t.host));t.releaseId&&r.searchParams.set(`release`,t.releaseId),await n(r,{method:`POST`,json:{changes:e},headers:{Authorization:`Bearer ${await t.getToken()}`,repository:t.repo},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to update models`})}function za(e){return new URL(`https://customtypes.${e}/`)}const Ba=P({values:P({url:x(),fields:S(x(),x())}),imgixEndpoint:x()}),Va={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`};async function Ha(e,t){let r=new URL(`delete`,Ka(t.host));r.searchParams.set(`repository`,t.repo),await n(r,{method:`POST`,json:{sliceId:e},headers:{Authorization:`Bearer ${await t.getToken()}`,repository:t.repo},onUnauthorized:t.onUnauthorized})}async function Ua(e,t){let{sliceId:r,variationId:i,repo:a}=t,o=e.type;if(!(o in Va))throw new Ga(o);let s=await Wa(t),c=Va[o],l=`${a}/shared-slices/${r}/${i}/${xe(`sha1`).update(new Uint8Array(await e.arrayBuffer())).digest(`hex`)}${c}`,u=new FormData;for(let[e,t]of Object.entries(s.values.fields))u.append(e,t);u.set(`key`,l),u.set(`Content-Type`,o),u.set(`file`,e),await n(s.values.url,{method:`POST`,body:u});let d=new URL(l,A(s.imgixEndpoint));return d.searchParams.set(`auto`,`compress,format`),d}async function Wa(e){let t=new URL(`presigned-url`,Ka(e.host));return t.searchParams.set(`repository`,e.repo),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`,repository:e.repo},onUnauthorized:e.onUnauthorized,schema:Ba})}var Ga=class extends Error{name=`UnsupportedFileTypeError`;constructor(e){let t=Object.keys(Va);super(`Unsupported file type: ${e||`unknown`}. Supported: ${t.join(`, `)}`)}};function Ka(e){return new URL(`https://api.internal.${e}/screenshot/`)}const qa=P({id:x(),label:x(),customName:b(x()),isMaster:V()});async function Ja(e){let t=new URL(`repository/locales`,Za(e.host));return t.searchParams.set(`repository`,e.repo),n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({results:g(qa)}),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load locales`})}async function Ya(e,t){let r=new URL(`repository/locales`,Za(t.host));return r.searchParams.set(`repository`,t.repo),n(r,{method:`POST`,json:{id:e.id,isMaster:e.isMaster??!1,...e.customName?{customName:e.customName}:{}},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:qa,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to save locale`})}async function Xa(e,t){let r=new URL(`repository/locales/${encodeURIComponent(e)}`,Za(t.host));r.searchParams.set(`repository`,t.repo),await n(r,{method:`DELETE`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Locale not found: ${e}`,unknownErrorMessage:`Failed to remove locale`})}function Za(e){return new URL(`https://api.internal.${e}/locale/`)}const Qa=P({id:x(),label:x(),url:x()});async function $a(e){let t=new URL(`core/repository/preview_configs`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({results:g(Qa)}),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load previews`})}async function eo(e,t){let r=new URL(`previews/new`,$(t.repo,t.host));await n(r,{method:`POST`,json:{name:e.name,websiteURL:e.websiteURL,resolverPath:e.resolverPath},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to add preview`})}async function to(e,t){let r=new URL(`previews/delete/${encodeURIComponent(e)}`,$(t.repo,t.host));await n(r,{method:`POST`,json:{},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Preview not found: ${e}`,unknownErrorMessage:`Failed to remove preview`})}const no=P({kind:d([`prod`,`stage`,`dev`]),name:x(),domain:x(),users:g(P({id:x()}))});async function ro(e){let t=new URL(`core/environments`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({results:g(no)}),notFoundMessage:`Repository not found: ${e.repo}`})}async function io(e){let t=new URL(`core/repository`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({simulator_url:l(x())}),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load simulator URL`})}async function ao(e,t){let r=new URL(`core/repository`,$(t.repo,t.host));await n(r,{method:`PATCH`,json:{simulator_url:e},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to set simulator URL`})}async function oo(e,t){let r=new URL(`core/documents/search`,$(t.repo,t.host));return n(r,{method:`POST`,json:{customTypes:[e],limit:0},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:P({total:u()}),notFoundMessage:`Repository not found: ${t.repo}`})}async function so(e,t){let r=new URL(`core/releases`,$(t.repo,t.host));return n(r,{method:`POST`,json:e,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:ee({id:x()}),notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to create a release`})}async function co(e,t){let r=new URL(`core/releases/${encodeURIComponent(e)}`,$(t.repo,t.host));await n(r,{method:`DELETE`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Release not found: ${e}`,unknownErrorMessage:`Failed to delete the release`})}const lo=P({documentsPublished:V(),documentsUnpublished:V(),releasesCreated:V(),releasesUpdated:V(),tagsCreated:V(),tagsDeleted:V()}),uo=Object.keys(lo.shape),fo=P({config:r(lo,{_id:x(),url:x(),active:V(),name:b(x()),secret:b(x()),headers:S(x(),x())})});async function po(e){let t=new URL(`app/settings/webhooks`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:g(fo),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load webhooks`})}async function mo(e,t){let r=_o({...e,active:!0,headers:{}}),i=new URL(`app/settings/webhooks/create`,$(t.repo,t.host));await n(i,{method:`POST`,body:r,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to create webhook`})}async function ho(e,t,r){let i=_o(t),a=new URL(`app/settings/webhooks/${encodeURIComponent(e)}`,$(r.repo,r.host));await n(a,{method:`POST`,body:i,headers:{Authorization:`Bearer ${await r.getToken()}`},onUnauthorized:r.onUnauthorized,notFoundMessage:`Webhook not found: ${e}`,unknownErrorMessage:`Failed to update webhook`})}async function go(e,t){let r=new URL(`app/settings/webhooks/${encodeURIComponent(e)}/delete`,$(t.repo,t.host));await n(r,{method:`POST`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Webhook not found: ${e}`,unknownErrorMessage:`Failed to delete webhook`})}function _o(e){let t=new FormData;return t.set(`url`,e.url),t.set(`name`,e.name??``),t.set(`secret`,e.secret??``),t.set(`headers`,JSON.stringify(e.headers??{})),t.set(`active`,e.active?`on`:`off`),t.set(`documentsPublished`,e.documentsPublished.toString()),t.set(`documentsUnpublished`,e.documentsUnpublished.toString()),t.set(`releasesCreated`,e.releasesCreated.toString()),t.set(`releasesUpdated`,e.releasesUpdated.toString()),t.set(`tagsCreated`,e.tagsCreated.toString()),t.set(`tagsDeleted`,e.tagsDeleted.toString()),t}const vo=P({id:x(),scope:x(),token:x(),created_at:P({$date:u()})}),yo=P({id:x(),name:x(),wroom_auths:g(vo)}),bo=P({app_name:x(),token:x(),timestamp:u()}),xo=P({max_tokens:u(),tokens:g(bo)});async function So(e){let t=new URL(`settings/security/contentapi`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:g(yo),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load OAuth apps`})}async function Co(e,t){let r=new URL(`settings/security/oauthapp`,$(t.repo,t.host));return n(r,{method:`POST`,json:{app_name:e},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:yo,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to create OAuth app`})}async function wo(e,t,r){let i=new URL(`settings/security/authorizations`,$(r.repo,r.host));return n(i,{method:`POST`,json:{app:e,scope:t},headers:{Authorization:`Bearer ${await r.getToken()}`},onUnauthorized:r.onUnauthorized,schema:vo,notFoundMessage:`Repository not found: ${r.repo}`,unknownErrorMessage:`Failed to create token`})}async function To(e,t){let r=new URL(`settings/security/authorizations/${encodeURIComponent(e)}`,$(t.repo,t.host));await n(r,{method:`DELETE`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Token not found: ${e}`,unknownErrorMessage:`Failed to delete token`})}async function Eo(e){let t=new URL(`settings/security/customtypesapi`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:xo,notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load write tokens`})}async function Do(e,t){let r=new URL(`settings/security/token`,$(t.repo,t.host));return n(r,{method:`POST`,json:{app_name:e},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:bo,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to create write token`})}async function Oo(e,t){let r=new URL(`settings/security/token/${encodeURIComponent(e)}`,$(t.repo,t.host));await n(r,{method:`DELETE`,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Token not found`,unknownErrorMessage:`Failed to delete write token`})}async function ko(e){let t=new URL(`syncState`,$(e.repo,e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:P({repository:P({api_access:x()})}),notFoundMessage:`Repository not found: ${e.repo}`,unknownErrorMessage:`Failed to load repository access`})}async function Ao(e,t){let r=new URL(`settings/security/apiaccess`,$(t.repo,t.host));await n(r,{method:`POST`,json:{api_access:e},headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to set repository access`})}async function jo(e,t){let r=new FormData;r.set(`displayname`,e);let i=new URL(`app/settings/repository`,$(t.repo,t.host));return n(i,{method:`POST`,body:r,headers:{Authorization:`Bearer ${await t.getToken()}`},onUnauthorized:t.onUnauthorized,schema:P({repository:P({name:x()})}),notFoundMessage:`Repository not found: ${t.repo}`,unknownErrorMessage:`Failed to set repository name`})}function $(e,t){return new URL(`https://${e}.${t}/`)}async function Mo(e){let t=new URL(`app/dashboard/repositories/${encodeURIComponent(e.domain)}/exists`,Po(e.host));return n(t,{headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,schema:V()})}async function No(e){let{domain:t,name:r,framework:i,agent:a,host:o}=e,s=new URL(`app/dashboard/repositories`,Po(o));s.searchParams.set(`app`,`cli`),a&&s.searchParams.set(`agent`,a),await n(s,{method:`POST`,json:{domain:t,name:r,framework:i,plan:`personal`},headers:{Authorization:`Bearer ${await e.getToken()}`},onUnauthorized:e.onUnauthorized,unknownErrorMessage:`Failed to create repository`})}function Po(e){return new URL(`https://${e}/`)}const Fo=P({path:x(),title:x(),description:l(x())}),Io=P({path:x(),title:x(),description:l(x()),anchors:g(P({slug:x(),excerpt:x()}))});async function Lo(e){let t=new URL(`api/index/`,Bo(e.host));return n(t,{schema:g(Fo),unknownErrorMessage:`Failed to fetch documentation index`})}async function Ro(e,t){let r=new URL(`api/index/${e}`,Bo(t.host));return n(r,{schema:Io,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function zo(e,t){let r=new URL(e,Bo(t.host));return n(r,{headers:{Accept:`text/markdown`,...t.headers},schema:x(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function Bo(e=`prismic.io`){return new URL(`https://${e}/docs/`)}const Vo=ee({exp:l(u()),type:l(x())});function Ho(e){try{let[,t]=e.split(`.`);if(!t)return;let n=JSON.parse(Buffer.from(t,`base64url`).toString());return I(Vo,n)}catch{return}}const Uo=P({anonymousId:x(),userId:l(x())}),Wo=!Vr.PRISMIC_TOKEN;let Go=!1,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs;const is=crypto.randomUUID();let as;async function os(e){let{host:t,repo:n}=e;n&&(Ko=n),Zo=e.userIntent,Qo=e.taskId,$o=e.store,es=e.storeReason;let r=t===`prismic.io`?`cGjidifKefYb6EPaGaqpt8rQXkv5TD6P`:`Ng5oKJHCGpSWplZ9ymB7Pu7rm0sTDeiG`;qo=oa(),Jo=ds(e.loggedIn),{runtime:Yo,runtimeProvider:Xo}=fs();let i=await hs();rs=i??{anonymousId:crypto.randomUUID()},i||await gs(rs),ie({writeKey:r,anonymousId:rs.anonymousId,userId:cs()})}function ss(e){H({userId:e.shortId,intercomHash:e.intercomHash}),Wo&&!Go&&rs&&(rs.userId=e.shortId,gs(rs))}function cs(){return Wo?rs?.userId:void 0}function ls(){if(!rs)return{};let e=cs();return{"Prismic-Anonymous-Id":rs.anonymousId,...e?{"Prismic-User-Id":e}:{}}}async function us(){Go=!0;let e=await hs();e?.userId&&await gs({anonymousId:e.anonymousId})}function ds(e){if(!Vr.PRISMIC_TOKEN)return e?`login`:`none`;let t=Ho(Vr.PRISMIC_TOKEN);return t?t.type===`machine2machine`?`write-token`:`user-token`:`unknown-token`}function fs(){let e=ps();if(e)return{runtime:`cloud`,runtimeProvider:e};let t=ms();return t||process.env.CI?{runtime:`ci`,runtimeProvider:t}:Ke(`/.dockerenv`)||Ke(`/run/.containerenv`)||process.env.KUBERNETES_SERVICE_HOST?{runtime:`container`}:process.platform!==`linux`||process.env.WSL_DISTRO_NAME?{runtime:`local`}:{runtime:`unknown`}}function ps(){if(process.env.CLAUDE_CODE_REMOTE===`true`)return`claude-code`;if(process.env.CODEX_EXEC_SERVER_REMOTE_BASE_URL)return`codex`;if(process.env.CURSOR_AGENT&&process.env.CLOUD_AGENT_ALL_SECRET_NAMES!==void 0)return`cursor`;if(process.env.CODESPACES===`true`)return`codespaces`;if(process.env.GITPOD_WORKSPACE_ID)return`gitpod`;if(process.versions.webcontainer)return`stackblitz`;if(process.env.REPL_ID)return`replit`;if(process.env.CODESANDBOX_HOST)return`codesandbox`;if(process.env.MODAL_SANDBOX_ID)return`modal`;if(process.env.E2B_SANDBOX)return`e2b`;if(Ke(`/opt/.devin`))return`devin`}function ms(){if(process.env.GITHUB_ACTIONS===`true`)return`github-actions`;if(process.env.GITLAB_CI)return`gitlab`;if(process.env.CIRCLECI)return`circleci`;if(process.env.BITBUCKET_BUILD_NUMBER)return`bitbucket`;if(process.env.TF_BUILD)return`azure-pipelines`;if(process.env.JENKINS_URL)return`jenkins`;if(process.env.BUILDKITE)return`buildkite`;if(process.env.CODEBUILD_BUILD_ID)return`codebuild`;if(process.env.TEAMCITY_VERSION)return`teamcity`;if(process.env.VERCEL&&process.env.CI)return`vercel`;if(process.env.NETLIFY)return`netlify`;if(process.env.CF_PAGES)return`cloudflare-pages`}async function hs(){return w(Jr,{schema:Uo}).catch(()=>void 0)}async function gs(e){await _(Jr,N(e)).catch(()=>{})}function _s(e,t={}){let{watch:n}=t;as={type:e,watch:n},U(`Prismic CLI Start`,{properties:{commandType:e,invocationId:is,fullCommand:process.argv.join(` `),repository:Ko,watch:n,agent:qo,auth:Jo,runtime:Yo,runtimeProvider:Xo,userIntent:Zo,taskId:Qo},groupId:Ko?{Repository:Ko}:void 0})}function vs(e={}){if(!as)return;let{type:t,watch:n}=as;as=void 0;let{error:r}=e,i=r?r instanceof Error?r.message:String(r):void 0;U(`Prismic CLI End`,{properties:{commandType:t,invocationId:is,fullCommand:process.argv.join(` `),success:!process.exitCode,repository:Ko,watch:n,error:i?.slice(0,512),agent:qo,auth:Jo,store:$o,storeReason:es,loginResult:ts?.result,loginResumed:ts?.resumed,loginDurationS:ts?.durationS,revoked:ns,runtime:Yo,runtimeProvider:Xo,userIntent:Zo,taskId:Qo},groupId:Ko?{Repository:Ko}:void 0})}function ys(e){let{result:t,resumed:n,startedAt:r}=e;ts={result:t,resumed:n,durationS:Math.round((Date.now()-r)/1e3)},e.store&&({store:$o,storeReason:es}=e)}function bs(e){ns=e.revoked}const xs={expired:`expired`,declined:`declined`,"email-unverified":`email-unverified`,"invalid-grant":`error`,misconfigured:`error`,unavailable:`error`};function Ss(e){return e instanceof di?xs[e.reason]:`error`}const Cs=P({telemetry:V()});async function ws(){try{return!(await Ts(Ve())||await Ts(process.cwd()))}catch{return!0}}async function Ts(e){return(await w(new URL(`.prismicrc`,A(_e(e))),{schema:Cs}).catch(()=>void 0))?.telemetry===!1}const Es=3e5,Ds=1e3,Os={audience:`prismic.io`,scope:`openid profile email offline_access`},ks=new URL(`.prismic`,A(_e(Ve())));let As,js=!1,Ms,Ns;async function Ps(){return Vr.PRISMIC_TOKEN||Is()}async function Fs(){return Vr.PRISMIC_HOST?Vr.PRISMIC_HOST:(Ns??=zi().then(e=>e.host),await Ns||`prismic.io`)}async function Is(e={}){let{forceRefresh:t=!1}=e,n=(await Ri()).login?.session;if(!n?.refreshToken||n.host!==await Fs())return;let r=Rs(n,Es);if(r&&!t)return r;As??=Wi(async e=>{let{login:t}=await Ri();return Ls(e,t,n.accessToken,{canRetry:!0})}).finally(()=>As=void 0);try{return await As}catch(e){let r=Rs(n);if((e instanceof di||e instanceof Z)&&r&&!t)return r;throw e}}async function Ls(e,t,n,r){let i=t?.session;if(!t||!i?.refreshToken||i.host!==await Fs())return;let a=Rs(i,Es);if(a&&a!==n)return a;let{refreshToken:o,auth0Domain:s,clientId:c,host:l}=i,u=await ri(o,i);if(u)return await Hi(e,{...t,session:{...i,...u}}),u.accessToken;let d=(await Ri()).login;if(r.canRetry&&d?.session.refreshToken!==o&&await e.isHeld())return Ls(e,d,n,{canRetry:!1});await Hi(e,{...t,session:{host:l,auth0Domain:s,clientId:c,pendingLogin:i.pendingLogin}}),js=!0}function Rs(e,t=0){let{accessToken:n,expiresAt:r}=e;if(n&&r&&r-t>Date.now())return n}async function zs(e,t){if(Vr.PRISMIC_TOKEN||process.env.CI)return;let n=await Ps();if(n&&t.get(`Authorization`)!==`Bearer ${n}`)return e({headers:{Authorization:`Bearer ${n}`}});if(Ms||await Bs(n))return Ms??=Vs().finally(()=>Ms=void 0),e({headers:{Authorization:`Bearer ${await Ms}`}})}async function Bs(e){try{return await Sa(e,{host:await Fs()}),!1}catch(e){return e instanceof p||e instanceof z}}async function Vs(e={}){return await Is({forceRefresh:!0})||(console.error(js?`Your login expired.`:`You are not logged in.`),Hs(e))}async function Hs(e={}){let{browser:t=!1}=e,n=await Fs(),r=Us(n);if(!r)throw new Q(`Login isn't available for ${n}. Use PRISMIC_TOKEN.`);let i=oa()===void 0&&process.stdin.isTTY===!0&&process.stderr.isTTY===!0,a={host:n,auth0:r,deadline:i?1/0:Date.now()+9e4,startedAt:Date.now(),resumed:!1,waited:!1,tokenBefore:(await Ri().catch(()=>void 0))?.login?.session.accessToken},o=process.rawListeners(`SIGINT`);process.removeAllListeners(`SIGINT`),process.once(`SIGINT`,async()=>{a.cancelled=!0,console.error(),a.pending&&await Zs(a.pending,void 0);let{resumed:e,startedAt:t,saved:n}=a;ys({result:n?`success`:`cancelled`,resumed:e,startedAt:t,store:n?.store,storeReason:n?.storeReason}),await Ws(n?`Logged in to Prismic.`:`Login cancelled.`,130)});let s;try{s=await Gs(a,{browser:t&&i})}catch(e){throw ys({result:Ss(e),resumed:a.resumed,startedAt:a.startedAt}),e}finally{process.removeAllListeners(`SIGINT`);for(let e of o)process.on(`SIGINT`,e)}let{resumed:c,startedAt:l}=a;if(s.status===`wait-limit`)return ys({result:`wait-limit`,resumed:c,startedAt:l}),Ws(`Waiting for approval. After the user approves, run the same command again. It continues this login.`,1);if(s.status===`logged-out`)throw ys({result:`cancelled`,resumed:c,startedAt:l}),new Q(`A logout cancelled this login. Run the command again to log in.`);let{token:u,email:d,store:f,storeReason:p}=s;return a.pending&&ys({result:`success`,resumed:c,startedAt:l,store:f,storeReason:p}),console.error(`Logged in to Prismic as ${d}`),u}function Us(e){if(e===`prismic.io`)return{auth0Domain:`auth0.prismic.io`,clientId:`V1yuPKJOHhuHNMR4Oeo2fj5uTCfVebny`};if(e===`wroom.io`||e===`devops-wroom.com`)return{auth0Domain:`auth0.wroom.io`,clientId:`UKxsYw8EcAspkUPRvoFkrO1aj9cA3zkd`};if(/^[a-z0-9-]+-wroom\.com$/.test(e))return{auth0Domain:`auth0.platform-wroom.com`,clientId:`Opbx7JjftGb5sgjIWKVx0XDBSrW37say`}}async function Ws(e,t){process.exitCode=t,vs({error:e}),await new Promise(t=>process.stderr.write(`${e}\n`,t)),process.exit()}async function Gs(e,t){let n=await Ks(e);if(!n)return{status:`wait-limit`};let r;try{let n=await qs(e);if(n.status===`logged-out`)return n;if(n.status===`saved`)r=n;else{let{pending:i}=n;i.deviceCode!==e.shown?.deviceCode&&Ys(i);let a=i.verificationUriComplete??i.verificationUri;t.browser&&/^https:\/\/[\w\-.:/?=&~+]+$/.test(a)&&URL.canParse(a)&&sa(new URL(a));let o=await Xs(e,i);if(`status`in o)return o;let s=await Qs(e,i,o);if(!s)return{status:`logged-out`};r=s}}finally{await n.release()}await us();let{email:i}=await Ea({getToken:async()=>r.token,host:e.host});return{...r,status:`logged-in`,email:i}}async function Ks(e){let t=Math.min(e.deadline,Date.now()+9e5);for(;;){let n=e.shown?t-Date.now():0;try{return await Gi({timeoutMs:n})}catch(n){if(!(n instanceof xi))throw n;if(Date.now()>=e.deadline)return;if(Date.now()>=t)throw new di(`expired`)}e.waited=!0;let r=(await Ri().catch(()=>void 0))?.login?.session;e.shown=r&&Js(r,e),e.shown?Ys(e.shown):await We(Ds)}}async function qs(e){return Wi(async t=>{let n=await Ri().catch(()=>void 0);if(e.shown&&n&&!n.login)return{status:`logged-out`};let r=n?.login,i=r&&Js(r.session,e);if(i)return e.pending=i,e.startedAt=i.startedAt,e.resumed=!0,{status:`pending`,pending:i};let a=r?.session.host===e.host?r:void 0,o=a&&Rs(a.session);if(e.waited&&o&&o!==e.tokenBefore)return{status:`saved`,token:o,store:a.store,storeReason:a.storeReason};let s={...await $r(Os,e.auth0),host:e.host};e.pending=s,e.startedAt=s.startedAt;let c=await Vi(t),l=r?.session??{host:(await zi()).host??e.host,...e.auth0};return await Hi(t,{...c,session:{...l,pendingLogin:s}}),{status:`pending`,pending:s}})}function Js(e,t){let{pendingLogin:n}=e;if(n&&n.host===t.host&&n.auth0Domain===t.auth0.auth0Domain&&n.clientId===t.auth0.clientId&&n.expiresAt>Date.now())return n}function Ys(e){let{userCode:t,verificationUri:n,verificationUriComplete:r}=e,i=Math.max(1,Math.ceil((e.expiresAt-Date.now())/6e4));console.error(la`
|
|
193
193
|
Open this URL on any device to log in:
|
|
194
194
|
${r??n}
|
|
195
195
|
${r===void 0?`Enter the code ${t}.`:`Check that the page shows the code ${t}.`}
|
|
196
196
|
Waiting for the login (the code expires in ${i} ${i===1?`minute`:`minutes`})...
|
|
197
|
-
`)}async function Js(e,t){let n=new AbortController,r=setInterval(async()=>{let r=await Ri().catch(()=>void 0);e.cancelled||r&&r.login?.session.pendingLogin?.deviceCode!==t.deviceCode&&n.abort()},Ts),i=Number.isFinite(e.deadline)?AbortSignal.timeout(Math.max(0,e.deadline-Date.now())):void 0;try{return await ti(t,{signal:i?AbortSignal.any([i,n.signal]):n.signal,onUpdate:n=>Ys(t,{...n,host:e.host})})}catch(e){if(e instanceof di)throw await Ys(t,void 0),e;if(n.signal.aborted)return{status:`logged-out`};if(i?.aborted)return{status:`wait-limit`};throw e}finally{clearInterval(r)}}async function Ys(e,t){await Wi(async n=>{let r=(await Ri()).login;r?.session.pendingLogin?.deviceCode===e.deviceCode&&await Hi(n,{...r,session:{...r.session,pendingLogin:t}})}).catch(()=>{})}async function Xs(e,t,n){return Wi(async r=>{let i=await Ri().catch(()=>void 0);if(i&&i.login?.session.pendingLogin?.deviceCode!==t.deviceCode){await ii(n.refreshToken,t).catch(()=>{});return}let a=i?.login?{store:i.login.store,storeReason:i.login.storeReason}:await Vi(r),o={host:e.host,...e.auth0,...n};await Hi(r,{...a,session:o}),e.saved={...a,token:n.accessToken};let s=i?.login?.session;return s?.refreshToken&&await ii(s.refreshToken,s).catch(()=>{}),e.saved})}async function Zs(){let e;try{e=await ce(Ds,`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 de(Ds,{force:!0})}catch{}}function Qs(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 $s(e){return e.insert.length+e.update.length+e.delete.length>0}const ec=[`Slices`,`UID`,`Choice`];function tc(e,t,n){if(t in e)throw new gc(t);e[t]=n}function nc(e,t){let n=e[t];if(!n)throw new _c(t);return n}function rc(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=r.get(t);if(!i)throw new yc(`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 yc(`Field "${e}" does not exist on type "${n}".`);let c=o.filter(Boolean);if(c.length===0){if(ec.includes(s.type)||e===`uid`)throw new yc(`Field "${e}" cannot be fetched from a content relationship.`);if(s.type===`Group`)throw new yc(`Field "${e}" is a group. Select specific subfields.`);return e}if(c.length!==o.length)throw new yc(`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 yc(`Content relationships cannot be nested more than once.`);let t=s.config?.customtypes;if(!t||t.length!==1)throw new yc(`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 yc(`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 yc(`Field "${e}" is not a group or content relationship field.`)})};return a(e,Object.assign({},...Object.values(i.json)),i.id,!0)}function ic(e,t,n){let r;if(n){if(r=t.json[n],!r)throw new bc(n,t.id)}else{let[n]=e.split(`.`);if(r=Object.values(t.json).find(e=>n in e),!r)throw new _c(n)}return mc(e,r)}function ac(e,t,n){let r=t.variations.find(e=>e.id===n);if(!r)throw new xc(n,t.id);return r.primary??={},mc(e,r.primary)}async function oc(e){let[t,n]=await Promise.all([Fa(e),Ia(e)]);return{customTypes:t,slices:n}}async function sc({customTypes:e,slices:t},n){let r=(e,t)=>({type:e,id:t.id,payload:t}),i=[...e.insert.map(e=>r(`CUSTOM_TYPE_INSERT`,e)),...e.update.map(e=>r(`CUSTOM_TYPE_UPDATE`,e)),...e.delete.map(({id:e})=>r(`CUSTOM_TYPE_DELETE`,{id:e})),...t.insert.map(e=>r(`SLICE_INSERT`,e)),...t.update.map(e=>r(`SLICE_UPDATE`,e)),...t.delete.map(({id:e})=>r(`SLICE_DELETE`,{id:e}))];i.length>0&&await La(i,n)}function cc(e,t,n={}){let{treatNonCanonicalAsChanged:r=!1}=n;return{customTypes:Qs(e.customTypes,t.customTypes,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(lc(e))===JSON.stringify(r?t:lc(t))}),slices:Qs(e.slices,t.slices,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(uc(e))===JSON.stringify(r?t:uc(t))})}}function lc(e){return{...pc(e),json:Object.fromEntries(Object.entries(e.json).map(([e,t])=>[e,dc(t)]))}}function uc(e){return{...pc(e),variations:e.variations.map(e=>{let t=pc(e);return e.primary&&(t.primary=dc(e.primary)),e.items&&(t.items=dc(e.items)),t})}}function dc(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=pc(t);return t.type===`Group`&&t.config?.fields&&n.type===`Group`&&n.config?.fields&&(n.config.fields=dc(t.config.fields)),t.type===`Slices`&&t.config?.choices&&n.type===`Slices`&&n.config?.choices&&(n.config.choices=fc(t.config.choices)),[e,n]}))}function fc(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=pc(t);return t.type===`Slice`&&n.type===`Slice`&&(t[`non-repeat`]&&(n[`non-repeat`]=dc(t[`non-repeat`])),t.repeat&&(n.repeat=dc(t.repeat))),[e,n]}))}function pc(e){return Array.isArray(e)?e.map(pc):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,pc(t)]))}function mc(e,t){let[n,...r]=e.split(`.`);if(r.length===0)return{fields:t,fieldId:n};let i=nc(t,n);if(i.type!==`Group`)throw new vc(n);return i.config??={},i.config.fields??={},mc(r.join(`.`),i.config.fields)}function hc(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 gc=class extends Error{name=`FieldExistsError`;constructor(e){super(`Field "${e}" already exists.`)}},_c=class extends Error{name=`FieldNotFoundError`;constructor(e){super(`Field "${e}" does not exist.`)}},vc=class extends Error{name=`UnsupportedNestedFieldError`;constructor(e){super(`Field "${e}" does not support nested fields.`)}},yc=class extends Error{name=`FieldSelectionError`},bc=class extends Error{name=`TabNotFoundError`;constructor(e,t){super(`Tab "${e}" does not exist on type "${t}".`)}},xc=class extends Error{name=`SliceVariationNotFoundError`;constructor(e,t){super(`Variation "${e}" does not exist on slice "${t}".`)}};const Sc=`prismic.config.json`,Cc=P({type:x(),path:x(),uid:l(x()),lang:l(x()),resolvers:l(S(x(),x()))}),wc=P({repositoryName:x(),documentAPIEndpoint:l(O()),libraries:l(g(x())),routes:l(g(Cc))});async function Tc(e){let t=await jc();return await me(t,N(e)),t}async function Ec(){let e=await kc();try{return await w(e,{schema:wc})}catch{throw new Dc}}var Dc=class extends Error{name=`InvalidPrismicConfigError`;message=`${Sc} is invalid. Run \`prismic init\` to re-create a config.`};async function Oc(e){let t=await kc(),n={...await Ec(),...e};return await me(t,N(n)),n}async function kc(){let e=await ne(Sc,{stop:`package.json`});if(!e)throw new Ac;return e}var Ac=class extends Error{name=`MissingPrismicConfigError`;message=`Could not find a ${Sc} file. Run \`prismic init\` to create a config.`};async function jc(){try{let e=await F();return new URL(Sc,e)}catch(e){throw e instanceof L?new Mc({cause:e}):e}}var Mc=class extends Error{name=`UnknownProjectRootError`;constructor(e){super(`Could not find your project root.`,e)}};async function Nc(e){let{routes:t=[]}=await Ec();if(t.some(t=>t.type===e.id))return;let n=Lc(e),r={type:e.id,path:n};await Oc({routes:[...t,r].sort((e,t)=>e.type.localeCompare(t.type))})}async function Pc(e){e.format===`page`?await Nc(e):await Fc(e.id)}async function Fc(e){let{routes:t=[]}=await Ec(),n=t.filter(t=>t.type!==e);t.length!==n.length&&await Oc({routes:n})}function Ic(e,t){return e.find(e=>e.type===t&&!e.uid&&!/[?*+]/.test(e.path))}function Lc(e){let{id:t,repeatable:n}=e,r=t.replaceAll(`_`,`-`).toLowerCase();return n?t===`page`?`/:uid`:`/${r}/:uid`:t===`homepage`?`/`:`/${r}`}const Rc=`slicemachine.config.json`,zc=P({repositoryName:x(),libraries:l(g(x()))});async function Bc(){let e=await Uc();try{return await w(e,{schema:zc})}catch{throw new Vc}}var Vc=class extends Error{name=`InvalidLegacySliceMachineConfigError`;message=`${Rc} is invalid.`};async function Hc(){let e=await Uc();await de(e)}async function Uc(){let e=await ne(Rc,{stop:`package.json`});if(!e)throw new Wc;return e}var Wc=class extends Error{name=`MissingLegacySliceMachineConfigError`;message=`Could not find a ${Rc} file.`};async function Gc(){let e;try{e=await kc()}catch(t){if(t instanceof Ac)e=await jc();else throw t}let t=new URL(`.`,e);return A(_e(await le(ge(t))))}async function Kc(){try{return(await Ec()).repositoryName}catch(e){if(e instanceof Ac)try{return(await Bc()).repositoryName}catch{}throw e}}async function qc(){let e=(await Ec()).libraries;if(!e||e.length<1)return;let t=await Gc();return e.map(e=>A(new URL(e.replace(/^\//,``),t)))}async function Jc(){let e=await Gc();return j(new URL(`tsconfig.json`,e))}const Yc=[`next`,`nuxt`,`sveltekit`];async function Xc(){let{dependencies:e,devDependencies:t,peerDependencies:n}=await re(),r={...e,...t,...n};if(`next`in r){let{NextJsAdapter:e}=await import(`./nextjs-CiU-wONg.mjs`);return new e}if(`nuxt`in r){let{NuxtAdapter:e}=await import(`./nuxt-BNM57THK.mjs`);return new e}if(`@sveltejs/kit`in r){if(await T(`@sveltejs/kit`)<3){let{SvelteKit2Adapter:e}=await import(`./sveltekit2-CVfxQ2tH.mjs`);return new e}let{SvelteKitAdapter:e}=await import(`./sveltekit-C5og1T-S.mjs`);return new e}throw new Zc}var Zc=class extends Error{name=`NoSupportedFrameworkError`;message=`No supported framework found. Run this command in a Next.js, Nuxt, or SvelteKit project.`},Qc=class extends Error{name=`ModelExistsError`},$c=class extends Error{name=`SliceNotFoundError`;constructor(e){super(`Slice "${e}" does not exist. Run \`prismic slice list\` to see available IDs.`)}},el=class extends Error{name=`CustomTypeNotFoundError`;constructor(e){super(`Type "${e}" does not exist. Run \`prismic type list\` to see available IDs.`)}};async function tl(e,t,n,r){let i=r.find(e=>e.model.id===t||e.directory.href===n.href);if(!i&&!await j(n))return;let a=f(await Gc(),i?.directory??n),o=i?` (id: ${i.model.id})`:``;throw new Qc(`A ${e} already exists at ${a}${he}${o}.`)}async function nl(){return await(await Xc()).getEnvironment()??await Kc()}async function rl(e){let t=await Lr(`**/*.{js,jsx,mjs,ts,tsx,mts,svelte}`,{cwd:ge(await Gc()),absolute:!0,ignore:`**/{node_modules,build,dist,out}/**`});for(let n of t)try{if((await ce(n,`utf8`)).includes(e))return!0}catch{}return!1}async function il(e,t){await j(e)||await _(e,t)}async function al(){return await Jc()?`ts`:`js`}var ol=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 Kc(),getToken:Ms,host:await Ns()};(await ro(t)).simulator_url||await io(this.localSimulatorUrl,t),(await Qa(t)).results.length===0&&await $a(this.localPreviewConfig,t)}async getSliceLibraries(){return await qc()??[await this.getDefaultSliceLibrary()]}async getSlices(){return cl(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=hc((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 new $c(e)}async createSlice(e){let[t]=await this.getSliceLibraries(),n=A(new URL(pt(e.name),A(t)));await tl(`slice`,e.id,n,await this.getSlices()),await _(new URL(`model.json`,n),N(uc(e))),await this.createSliceIndexFile(t),await this.createSliceComponent(e,n)}async updateSlice(e){let t=await this.getSlice(e.id);await _(t.modelPath,N(uc(e))),await this.createSliceIndexFile(t.library)}async deleteSlice(e){let t=await this.getSlice(e);await de(t.directory,{recursive:!0}),await this.createSliceIndexFile(t.library)}async getCustomTypeLibraries(){return[new URL(`customtypes/`,await Gc())]}async getCustomTypes(){return cl(await this.getCustomTypeLibraries(),`*/index.json`)}async getCustomType(e){let t=(await this.getCustomTypes()).find(t=>t.model.id===e);if(!t)throw new el(e);return t}async createCustomType(e){let[t]=await this.getCustomTypeLibraries(),n=A(new URL(e.id,A(t)));if(await tl(`type`,e.id,n,await this.getCustomTypes()),await _(new URL(`index.json`,n),N(lc(e))),e.format!==`page`)return[];await Nc(e);let r=await Gc();return(await this.writePageFiles(e)).map(({path:t})=>`Skipped ${f(r,t)} (already exists). Run \`prismic gen page ${e.id}\` to get the code.`)}async writePageFiles(e){let{routes:t=[]}=await Ec(),n=(Ic(t,e.id)?.path??Lc(e)).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),r=[];for(let t of await this.getPageFiles(e,n))await j(t.path)?r.push(t):await _(t.path,t.contents);return r}async updateCustomType(e){let t=await this.getCustomType(e.id);await _(t.modelPath,N(lc(e))),await Pc(e)}async deleteCustomType(e){let t=await this.getCustomType(e);await de(t.directory,{recursive:!0}),await Fc(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 Gc()),t=Xt({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 _(e,t),e}async getEnvironment(){let e=await sl();if(await j(e))return(await te(e))[this.environmentEnvVarName]||void 0}async setEnvironment(e){await B(await sl(),this.environmentEnvVarName,e)}async unsetEnvironment(){await D(await sl(),this.environmentEnvVarName)}};async function sl(){return new URL(`.env.local`,await Gc())}async function cl(e,t){let n=[];for(let r of e){let e=await Lr(t,{absolute:!0,cwd:r}),i=await Promise.all(e.map(async e=>{let t=_e(e),n=await w(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{Ss as $,da as $t,bc as A,Qa as At,ac as B,io as Bt,Ec as C,Ro as Ct,_c as D,qa as Dt,gc as E,no as Et,cc as F,Ea as Ft,Ms as G,xa as Gt,$s as H,mo as Ht,hc as I,fo as It,zs as J,ha as Jt,Bs as K,Q as Kt,oc as L,To as Lt,tc as M,Oo as Mt,lc as N,ro as Nt,yc as O,xo as Ot,uc as P,Ta as Pt,is as Q,ua as Qt,rc as R,ko as Rt,Kc as S,Io as St,Oc as T,ao as Tt,Zs as U,Ha as Ut,sc as V,Na as Vt,Ns as W,Ja as Wt,ss as X,ya as Xt,cs as Y,va as Yt,os as Z,la as Zt,Jc as _,so as _t,Zc as a,zi as an,lo as at,Ic as b,Do as bt,nl as c,ii as cn,So as ct,il as d,zr as dn,Mo as dt,sa as en,vs as et,Vc as f,Vr as fn,po as ft,Lc as g,ht as gn,eo as gt,Mc as h,pt as hn,wo as ht,Qc as i,Ri as in,Wa as it,vc as j,ka as jt,xc as k,Ma as kt,Xc as l,X as ln,Co as lt,Ac as m,mt as mn,Ya as mt,el as n,Z as nn,hs as nt,$c as o,Wi as on,$a as ot,Dc as p,ft as pn,Eo as pt,Ls as q,ma as qt,Yc as r,Ui as rn,as as rt,rl as s,di as sn,jo as st,ol as t,oa as tn,gs as tt,al as u,qr as un,oo as ut,Tc as v,Va as vt,Bc as w,Lo as wt,Gc as x,Aa as xt,Hc as y,ho as yt,ic as z,Ao as zt};
|
|
197
|
+
`)}async function Xs(e,t){let n=new AbortController,r=setInterval(async()=>{let r=await Ri().catch(()=>void 0);e.cancelled||r&&r.login?.session.pendingLogin?.deviceCode!==t.deviceCode&&n.abort()},Ds),i=Number.isFinite(e.deadline)?AbortSignal.timeout(Math.max(0,e.deadline-Date.now())):void 0;try{return await ti(t,{signal:i?AbortSignal.any([i,n.signal]):n.signal,onUpdate:n=>Zs(t,{...n,host:e.host})})}catch(e){if(e instanceof di)throw await Zs(t,void 0),e;if(n.signal.aborted)return{status:`logged-out`};if(i?.aborted)return{status:`wait-limit`};throw e}finally{clearInterval(r)}}async function Zs(e,t){await Wi(async n=>{let r=(await Ri()).login;r?.session.pendingLogin?.deviceCode===e.deviceCode&&await Hi(n,{...r,session:{...r.session,pendingLogin:t}})}).catch(()=>{})}async function Qs(e,t,n){return Wi(async r=>{let i=await Ri().catch(()=>void 0);if(i&&i.login?.session.pendingLogin?.deviceCode!==t.deviceCode){await ii(n.refreshToken,t).catch(()=>{});return}let a=i?.login?{store:i.login.store,storeReason:i.login.storeReason}:await Vi(r),o={host:e.host,...e.auth0,...n};await Hi(r,{...a,session:o}),e.saved={...a,token:n.accessToken};let s=i?.login?.session;return s?.refreshToken&&await ii(s.refreshToken,s).catch(()=>{}),e.saved})}async function $s(){let e;try{e=await ce(ks,`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 de(ks,{force:!0})}catch{}}function ec(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 tc(e){return e.insert.length+e.update.length+e.delete.length>0}const nc=[`Slices`,`UID`,`Choice`];function rc(e,t,n){if(t in e)throw new vc(t);e[t]=n}function ic(e,t){let n=e[t];if(!n)throw new yc(t);return n}function ac(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=r.get(t);if(!i)throw new xc(`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 xc(`Field "${e}" does not exist on type "${n}".`);let c=o.filter(Boolean);if(c.length===0){if(nc.includes(s.type)||e===`uid`)throw new xc(`Field "${e}" cannot be fetched from a content relationship.`);if(s.type===`Group`)throw new xc(`Field "${e}" is a group. Select specific subfields.`);return e}if(c.length!==o.length)throw new xc(`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 xc(`Content relationships cannot be nested more than once.`);let t=s.config?.customtypes;if(!t||t.length!==1)throw new xc(`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 xc(`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 xc(`Field "${e}" is not a group or content relationship field.`)})};return a(e,Object.assign({},...Object.values(i.json)),i.id,!0)}function oc(e,t,n){let r;if(n){if(r=t.json[n],!r)throw new Sc(n,t.id)}else{let[n]=e.split(`.`);if(r=Object.values(t.json).find(e=>n in e),!r)throw new yc(n)}return gc(e,r)}function sc(e,t,n,r=!1){let i=t.variations.find(e=>e.id===n);if(!i)throw new Cc(n,t.id);if(r){if(!i.items||Object.keys(i.items).length===0)throw new wc(n,t.id);return gc(e,i.items)}return i.primary??={},gc(e,i.primary)}async function cc(e){let[t,n]=await Promise.all([Ia(e),La(e)]);return{customTypes:t,slices:n}}async function lc({customTypes:e,slices:t},n){let r=(e,t)=>({type:e,id:t.id,payload:t}),i=[...e.insert.map(e=>r(`CUSTOM_TYPE_INSERT`,e)),...e.update.map(e=>r(`CUSTOM_TYPE_UPDATE`,e)),...e.delete.map(({id:e})=>r(`CUSTOM_TYPE_DELETE`,{id:e})),...t.insert.map(e=>r(`SLICE_INSERT`,e)),...t.update.map(e=>r(`SLICE_UPDATE`,e)),...t.delete.map(({id:e})=>r(`SLICE_DELETE`,{id:e}))];i.length>0&&await Ra(i,n)}function uc(e,t,n={}){let{treatNonCanonicalAsChanged:r=!1}=n;return{customTypes:ec(e.customTypes,t.customTypes,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(dc(e))===JSON.stringify(r?t:dc(t))}),slices:ec(e.slices,t.slices,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(fc(e))===JSON.stringify(r?t:fc(t))})}}function dc(e){return{...hc(e),json:Object.fromEntries(Object.entries(e.json).map(([e,t])=>[e,pc(t)]))}}function fc(e){return{...hc(e),variations:e.variations.map(e=>{let t=hc(e);return e.primary&&(t.primary=pc(e.primary)),e.items&&(t.items=pc(e.items)),t})}}function pc(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=hc(t);return t.type===`Group`&&t.config?.fields&&n.type===`Group`&&n.config?.fields&&(n.config.fields=pc(t.config.fields)),t.type===`Slices`&&t.config?.choices&&n.type===`Slices`&&n.config?.choices&&(n.config.choices=mc(t.config.choices)),[e,n]}))}function mc(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=hc(t);return t.type===`Slice`&&n.type===`Slice`&&(t[`non-repeat`]&&(n[`non-repeat`]=pc(t[`non-repeat`])),t.repeat&&(n.repeat=pc(t.repeat))),[e,n]}))}function hc(e){return Array.isArray(e)?e.map(hc):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,hc(t)]))}function gc(e,t){let[n,...r]=e.split(`.`);if(r.length===0)return{fields:t,fieldId:n};let i=ic(t,n);if(i.type!==`Group`)throw new bc(n);return i.config??={},i.config.fields??={},gc(r.join(`.`),i.config.fields)}function _c(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 vc=class extends Error{name=`FieldExistsError`;constructor(e){super(`Field "${e}" already exists.`)}},yc=class extends Error{name=`FieldNotFoundError`;constructor(e){super(`Field "${e}" does not exist.`)}},bc=class extends Error{name=`UnsupportedNestedFieldError`;constructor(e){super(`Field "${e}" does not support nested fields.`)}},xc=class extends Error{name=`FieldSelectionError`},Sc=class extends Error{name=`TabNotFoundError`;constructor(e,t){super(`Tab "${e}" does not exist on type "${t}".`)}},Cc=class extends Error{name=`SliceVariationNotFoundError`;constructor(e,t){super(`Variation "${e}" does not exist on slice "${t}".`)}},wc=class extends Error{name=`SliceItemsNotFoundError`;constructor(e,t){super(`Variation "${e}" of slice "${t}" has no legacy items zone. To add repeatable fields, add a repeatable group to the slice.`)}};const Tc=`prismic.config.json`,Ec=P({type:x(),path:x(),uid:l(x()),lang:l(x()),resolvers:l(S(x(),x()))}),Dc=P({repositoryName:x(),documentAPIEndpoint:l(O()),libraries:l(g(x())),routes:l(g(Ec))});async function Oc(e){let t=await Pc();return await me(t,N(e)),t}async function kc(){let e=await Mc();try{return await w(e,{schema:Dc})}catch{throw new Ac}}var Ac=class extends Error{name=`InvalidPrismicConfigError`;message=`${Tc} is invalid. Run \`prismic init\` to re-create a config.`};async function jc(e){let t=await Mc(),n={...await kc(),...e};return await me(t,N(n)),n}async function Mc(){let e=await ne(Tc,{stop:`package.json`});if(!e)throw new Nc;return e}var Nc=class extends Error{name=`MissingPrismicConfigError`;message=`Could not find a ${Tc} file. Run \`prismic init\` to create a config.`};async function Pc(){try{let e=await F();return new URL(Tc,e)}catch(e){throw e instanceof L?new Fc({cause:e}):e}}var Fc=class extends Error{name=`UnknownProjectRootError`;constructor(e){super(`Could not find your project root.`,e)}};async function Ic(e){let{routes:t=[]}=await kc();if(t.some(t=>t.type===e.id))return;let n=Bc(e),r={type:e.id,path:n};await jc({routes:[...t,r].sort((e,t)=>e.type.localeCompare(t.type))})}async function Lc(e){e.format===`page`?await Ic(e):await Rc(e.id)}async function Rc(e){let{routes:t=[]}=await kc(),n=t.filter(t=>t.type!==e);t.length!==n.length&&await jc({routes:n})}function zc(e,t){return e.find(e=>e.type===t&&!e.uid&&!/[?*+]/.test(e.path))}function Bc(e){let{id:t,repeatable:n}=e,r=t.replaceAll(`_`,`-`).toLowerCase();return n?t===`page`?`/:uid`:`/${r}/:uid`:t===`homepage`?`/`:`/${r}`}const Vc=`slicemachine.config.json`,Hc=P({repositoryName:x(),libraries:l(g(x()))});async function Uc(){let e=await Kc();try{return await w(e,{schema:Hc})}catch{throw new Wc}}var Wc=class extends Error{name=`InvalidLegacySliceMachineConfigError`;message=`${Vc} is invalid.`};async function Gc(){let e=await Kc();await de(e)}async function Kc(){let e=await ne(Vc,{stop:`package.json`});if(!e)throw new qc;return e}var qc=class extends Error{name=`MissingLegacySliceMachineConfigError`;message=`Could not find a ${Vc} file.`};async function Jc(){let e;try{e=await Mc()}catch(t){if(t instanceof Nc)e=await Pc();else throw t}let t=new URL(`.`,e);return A(_e(await le(ge(t))))}async function Yc(){try{return(await kc()).repositoryName}catch(e){if(e instanceof Nc)try{return(await Uc()).repositoryName}catch{}throw e}}async function Xc(){let e=(await kc()).libraries;if(!e||e.length<1)return;let t=await Jc();return e.map(e=>A(new URL(e.replace(/^\//,``),t)))}async function Zc(){let e=await Jc();return j(new URL(`tsconfig.json`,e))}const Qc=[`next`,`nuxt`,`sveltekit`];async function $c(){let{dependencies:e,devDependencies:t,peerDependencies:n}=await re(),r={...e,...t,...n};if(`next`in r){let{NextJsAdapter:e}=await import(`./nextjs-Cydao8so.mjs`);return new e}if(`nuxt`in r){let{NuxtAdapter:e}=await import(`./nuxt-DZlxcDTY.mjs`);return new e}if(`@sveltejs/kit`in r){if(await T(`@sveltejs/kit`)<3){let{SvelteKit2Adapter:e}=await import(`./sveltekit2-DbVLruSc.mjs`);return new e}let{SvelteKitAdapter:e}=await import(`./sveltekit-B3tYQDoW.mjs`);return new e}throw new el}var el=class extends Error{name=`NoSupportedFrameworkError`;message=`No supported framework found. Run this command in a Next.js, Nuxt, or SvelteKit project.`},tl=class extends Error{name=`ModelExistsError`},nl=class extends Error{name=`SliceNotFoundError`;constructor(e){super(`Slice "${e}" does not exist. Run \`prismic slice list\` to see available IDs.`)}},rl=class extends Error{name=`CustomTypeNotFoundError`;constructor(e){super(`Type "${e}" does not exist. Run \`prismic type list\` to see available IDs.`)}};async function il(e,t,n,r){let i=r.find(e=>e.model.id===t||e.directory.href===n.href);if(!i&&!await j(n))return;let a=f(await Jc(),i?.directory??n),o=i?` (id: ${i.model.id})`:``;throw new tl(`A ${e} already exists at ${a}${he}${o}.`)}async function al(){return await(await $c()).getEnvironment()??await Yc()}async function ol(e){let t=await Lr(`**/*.{js,jsx,mjs,ts,tsx,mts,svelte}`,{cwd:ge(await Jc()),absolute:!0,ignore:`**/{node_modules,build,dist,out}/**`});for(let n of t)try{if((await ce(n,`utf8`)).includes(e))return!0}catch{}return!1}async function sl(e,t){await j(e)||await _(e,t)}async function cl(){return await Zc()?`ts`:`js`}var ll=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 Yc(),getToken:Ps,host:await Fs()};(await io(t)).simulator_url||await ao(this.localSimulatorUrl,t),(await $a(t)).results.length===0&&await eo(this.localPreviewConfig,t)}async getSliceLibraries(){return await Xc()??[await this.getDefaultSliceLibrary()]}async getSlices(){return dl(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=_c((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 new nl(e)}async createSlice(e){let[t]=await this.getSliceLibraries(),n=A(new URL(pt(e.name),A(t)));await il(`slice`,e.id,n,await this.getSlices()),await _(new URL(`model.json`,n),N(fc(e))),await this.createSliceIndexFile(t),await this.createSliceComponent(e,n)}async updateSlice(e){let t=await this.getSlice(e.id);await _(t.modelPath,N(fc(e))),await this.createSliceIndexFile(t.library)}async deleteSlice(e){let t=await this.getSlice(e);await de(t.directory,{recursive:!0}),await this.createSliceIndexFile(t.library)}async getCustomTypeLibraries(){return[new URL(`customtypes/`,await Jc())]}async getCustomTypes(){return dl(await this.getCustomTypeLibraries(),`*/index.json`)}async getCustomType(e){let t=(await this.getCustomTypes()).find(t=>t.model.id===e);if(!t)throw new rl(e);return t}async createCustomType(e){let[t]=await this.getCustomTypeLibraries(),n=A(new URL(e.id,A(t)));if(await il(`type`,e.id,n,await this.getCustomTypes()),await _(new URL(`index.json`,n),N(dc(e))),e.format!==`page`)return[];await Ic(e);let r=await Jc();return(await this.writePageFiles(e)).map(({path:t})=>`Skipped ${f(r,t)} (already exists). Run \`prismic gen page ${e.id}\` to get the code.`)}async writePageFiles(e){let{routes:t=[]}=await kc(),n=(zc(t,e.id)?.path??Bc(e)).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),r=[];for(let t of await this.getPageFiles(e,n))await j(t.path)?r.push(t):await _(t.path,t.contents);return r}async updateCustomType(e){let t=await this.getCustomType(e.id);await _(t.modelPath,N(dc(e))),await Lc(e)}async deleteCustomType(e){let t=await this.getCustomType(e);await de(t.directory,{recursive:!0}),await Rc(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 Jc()),t=Xt({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 _(e,t),e}async getEnvironment(){let e=await ul();if(await j(e))return(await te(e))[this.environmentEnvVarName]||void 0}async setEnvironment(e){await B(await ul(),this.environmentEnvVarName,e)}async unsetEnvironment(){await D(await ul(),this.environmentEnvVarName)}};async function ul(){return new URL(`.env.local`,await Jc())}async function dl(e,t){let n=[];for(let r of e){let e=await Lr(t,{absolute:!0,cwd:r}),i=await Promise.all(e.map(async e=>{let t=_e(e),n=await w(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{os as $,ua as $t,Cc as A,Na as At,oc as B,jo as Bt,kc as C,Lo as Ct,yc as D,ro as Dt,vc as E,oo as Et,fc as F,Ea as Ft,Fs as G,Ya as Gt,lc as H,Pa as Ht,uc as I,Da as It,zs as J,ma as Jt,Ps as K,Sa as Kt,_c as L,po as Lt,bc as M,Aa as Mt,rc as N,ko as Nt,xc as O,Ja as Ot,dc as P,io as Pt,cs as Q,la as Qt,cc as R,Eo as Rt,Yc as S,ja as St,jc as T,Ro as Tt,tc as U,ho as Ut,sc as V,ao as Vt,$s as W,Ua as Wt,us as X,ya as Xt,Vs as Y,ha as Yt,ls as Z,ba as Zt,Zc as _,ht as _n,to as _t,el as a,Ri as an,Ga as at,zc as b,go as bt,al as c,di as cn,Mo as ct,sl as d,qr as dn,so as dt,da as en,ws as et,Wc as f,zr as fn,No as ft,Bc as g,pt as gn,To as gt,Fc as h,mt as hn,Xa as ht,tl as i,Ui as in,ss as it,Sc as j,$a as jt,wc as k,So as kt,$c as l,ii as ln,Co as lt,Nc as m,ft as mn,Do as mt,rl as n,oa as nn,vs as nt,nl as o,zi as on,uo as ot,Ac as p,Vr as pn,mo as pt,Hs as q,Q as qt,Qc as r,Z as rn,_s as rt,ol as s,Wi as sn,eo as st,ll as t,sa as tn,bs as tt,cl as u,X as un,wo as ut,Oc as v,co as vt,Uc as w,zo as wt,Jc as x,Oo as xt,Gc as y,Ha as yt,ac as z,Ao as zt};
|