@sequenzy/cli 0.0.147 → 0.0.148
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/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -259,7 +259,7 @@ Check the top-level render call using <`+Ue+">."}return ye}}function Si(O,ye){{i
|
|
|
259
259
|
<%s {...props} />
|
|
260
260
|
React keys must be passed directly to JSX without using spread:
|
|
261
261
|
let props = %s;
|
|
262
|
-
<%s key={someKey} {...props} />`,Ps,oa,Os,oa),Tc[oa+Ps]=!0}}if(O===n)di(Qn);else bo(Qn);return Qn}}var Jr=Yu;SWe.Fragment=n,SWe.jsxDEV=Jr})()});var i1={};Hge(i1,{program:()=>LF,createCommand:()=>MF,createOption:()=>UF,createArgument:()=>$F,Command:()=>qF,Option:()=>QF,Argument:()=>zF,Help:()=>jF,CommanderError:()=>HF,InvalidArgumentError:()=>GF,InvalidOptionArgumentError:()=>VF},{program:(Stt)=>LF=Stt,createCommand:(Stt)=>MF=Stt,createOption:(Stt)=>UF=Stt,createArgument:(Stt)=>$F=Stt,Command:(Stt)=>qF=Stt,Option:(Stt)=>QF=Stt,Argument:(Stt)=>zF=Stt,Help:(Stt)=>jF=Stt,CommanderError:(Stt)=>HF=Stt,InvalidArgumentError:(Stt)=>GF=Stt,InvalidOptionArgumentError:(Stt)=>VF=Stt});var{Argument:NF}=Sh(),{Command:r1}=FF(),{CommanderError:b0e,InvalidArgumentError:PF}=Jg(),{Help:C0e}=YI(),{Option:OF}=ZI();var LF=new r1,MF=(e)=>new r1(e),UF=(e,t)=>new OF(e,t),$F=(e,t)=>new NF(e,t),qF=r1,QF=OF,zF=NF,jF=C0e,HF=b0e,GF=PF,VF=PF;var{program:vtt,createCommand:_tt,createArgument:Itt,createOption:Dtt,CommanderError:WF,InvalidArgumentError:wtt,InvalidOptionArgumentError:Ttt,Command:KF,Argument:ktt,Option:Rtt,Help:Ftt}=i1;var Bh={name:"@sequenzy/cli",version:"0.0.147",description:"Sequenzy CLI for email marketing from the terminal",type:"module",bin:{sequenzy:"./dist/index.js"},main:"./src/index.tsx",types:"./src/index.tsx",exports:{".":"./src/index.tsx"},scripts:{dev:"bun --watch src/index.tsx",build:"bun ../../scripts/build-ink-cli.ts",start:"node dist/index.js",lint:"eslint src","type-check":"tsc --noEmit",test:"sh ../../scripts/run-package-tests.sh src","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{commander:"^12.1.0",ink:"^5.0.1","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0","ink-select-input":"^6.0.0","ink-table":"^3.1.0",open:"^10.1.0",react:"^18.3.1",conf:"^13.0.0"},devDependencies:{"@emailer/shared":"workspace:*","@types/bun":"latest","@types/node":"^22.0.0","@types/react":"^18.3.0","bun-types":"latest",typescript:"^7.0.2"},files:["dist"],keywords:["sequenzy","email","cli","marketing"],license:"MIT",repository:{type:"git",url:"https://github.com/sequenzy/sequenzy"}};import{isDeepStrictEqual as v1e}from"node:util";import v$ from"node:process";import Td from"node:fs";import _$ from"node:path";import R0 from"node:crypto";import _1e from"node:assert";var yd=(e)=>{let t=typeof e;return e!==null&&(t==="object"||t==="function")};var o1=new Set(["__proto__","prototype","constructor"]),B0e=new Set("0123456789");function vh(e){let t=[],n="",r="start",i=!1;for(let o of e)switch(o){case"\\":{if(r==="index")throw Error("Invalid character in an index");if(r==="indexEnd")throw Error("Invalid character after an index");if(i)n+=o;r="property",i=!i;break}case".":{if(r==="index")throw Error("Invalid character in an index");if(r==="indexEnd"){r="property";break}if(i){i=!1,n+=o;break}if(o1.has(n))return[];t.push(n),n="",r="property";break}case"[":{if(r==="index")throw Error("Invalid character in an index");if(r==="indexEnd"){r="index";break}if(i){i=!1,n+=o;break}if(r==="property"){if(o1.has(n))return[];t.push(n),n=""}r="index";break}case"]":{if(r==="index"){t.push(Number.parseInt(n,10)),n="",r="indexEnd";break}if(r==="indexEnd")throw Error("Invalid character after an index")}default:{if(r==="index"&&!B0e.has(o))throw Error("Invalid character in an index");if(r==="indexEnd")throw Error("Invalid character after an index");if(r==="start")r="property";if(i)i=!1,n+="\\";n+=o}}if(i)n+="\\";switch(r){case"property":{if(o1.has(n))return[];t.push(n);break}case"index":throw Error("Index was not closed");case"start":{t.push("");break}}return t}function a1(e,t){if(typeof t!=="number"&&Array.isArray(e)){let n=Number.parseInt(t,10);return Number.isInteger(n)&&e[n]===e[t]}return!1}function JF(e,t){if(a1(e,t))throw Error("Cannot use string index")}function YF(e,t,n){if(!yd(e)||typeof t!=="string")return n===void 0?e:n;let r=vh(t);if(r.length===0)return n;for(let i=0;i<r.length;i++){let o=r[i];if(a1(e,o))e=i===r.length-1?void 0:null;else e=e[o];if(e===void 0||e===null){if(i!==r.length-1)return n;break}}return e===void 0?n:e}function s1(e,t,n){if(!yd(e)||typeof t!=="string")return e;let r=e,i=vh(t);for(let o=0;o<i.length;o++){let a=i[o];if(JF(e,a),o===i.length-1)e[a]=n;else if(!yd(e[a]))e[a]=typeof i[o+1]==="number"?[]:{};e=e[a]}return r}function ZF(e,t){if(!yd(e)||typeof t!=="string")return!1;let n=vh(t);for(let r=0;r<n.length;r++){let i=n[r];if(JF(e,i),r===n.length-1)return delete e[i],!0;if(e=e[i],!yd(e))return!1}}function XF(e,t){if(!yd(e)||typeof t!=="string")return!1;let n=vh(t);if(n.length===0)return!1;for(let r of n){if(!yd(e)||!(r in e)||a1(e,r))return!1;e=e[r]}return!0}import Fr from"node:path";import eN from"node:os";import l1 from"node:process";var Jc=eN.homedir(),c1=eN.tmpdir(),{env:pm}=l1,v0e=(e)=>{let t=Fr.join(Jc,"Library");return{data:Fr.join(t,"Application Support",e),config:Fr.join(t,"Preferences",e),cache:Fr.join(t,"Caches",e),log:Fr.join(t,"Logs",e),temp:Fr.join(c1,e)}},_0e=(e)=>{let t=pm.APPDATA||Fr.join(Jc,"AppData","Roaming"),n=pm.LOCALAPPDATA||Fr.join(Jc,"AppData","Local");return{data:Fr.join(n,e,"Data"),config:Fr.join(t,e,"Config"),cache:Fr.join(n,e,"Cache"),log:Fr.join(n,e,"Log"),temp:Fr.join(c1,e)}},I0e=(e)=>{let t=Fr.basename(Jc);return{data:Fr.join(pm.XDG_DATA_HOME||Fr.join(Jc,".local","share"),e),config:Fr.join(pm.XDG_CONFIG_HOME||Fr.join(Jc,".config"),e),cache:Fr.join(pm.XDG_CACHE_HOME||Fr.join(Jc,".cache"),e),log:Fr.join(pm.XDG_STATE_HOME||Fr.join(Jc,".local","state"),e),temp:Fr.join(c1,t,e)}};function u1(e,{suffix:t="nodejs"}={}){if(typeof e!=="string")throw TypeError(`Expected a string, got ${typeof e}`);if(t)e+=`-${t}`;if(l1.platform==="darwin")return v0e(e);if(l1.platform==="win32")return _0e(e);return I0e(e)}import P0e from"node:path";import Fn from"node:fs";import{promisify as lo}from"node:util";var D0e=(e,t)=>{let{onError:n}=t;return function(...i){return e.apply(void 0,i).catch(n)}},ol=D0e;var w0e=(e,t)=>{let{onError:n}=t;return function(...i){try{return e.apply(void 0,i)}catch(o){return n(o)}}},ls=w0e;var tN=250;var T0e=(e,t)=>{let{isRetriable:n}=t;return function(i){let{timeout:o}=i,a=i.interval??tN,c=Date.now()+o;return function u(...p){return e.apply(void 0,p).catch((g)=>{if(!n(g))throw g;if(Date.now()>=c)throw g;let x=Math.round(a*Math.random());if(x>0)return new Promise((b)=>setTimeout(b,x)).then(()=>u.apply(void 0,p));else return u.apply(void 0,p)})}}},al=T0e;var k0e=(e,t)=>{let{isRetriable:n}=t;return function(i){let{timeout:o}=i,a=Date.now()+o;return function(...u){while(!0)try{return e.apply(void 0,u)}catch(p){if(!n(p))throw p;if(Date.now()>=a)throw p;continue}}}},sl=k0e;import rN from"node:process";var Yg={isChangeErrorOk:(e)=>{if(!Yg.isNodeError(e))return!1;let{code:t}=e;if(t==="ENOSYS")return!0;if(!nN&&(t==="EINVAL"||t==="EPERM"))return!0;return!1},isNodeError:(e)=>e instanceof Error,isRetriableError:(e)=>{if(!Yg.isNodeError(e))return!1;let{code:t}=e;if(t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM")return!0;return!1},onChangeError:(e)=>{if(!Yg.isNodeError(e))throw e;if(Yg.isChangeErrorOk(e))return;throw e}},d1=Yg;var Zg={onError:d1.onChangeError},Go={onError:()=>{return}},nN=rN.getuid?!rN.getuid():!1,Wi={isRetriable:d1.isRetriableError};var R0e={attempt:{chmod:ol(lo(Fn.chmod),Zg),chown:ol(lo(Fn.chown),Zg),close:ol(lo(Fn.close),Go),fsync:ol(lo(Fn.fsync),Go),mkdir:ol(lo(Fn.mkdir),Go),realpath:ol(lo(Fn.realpath),Go),stat:ol(lo(Fn.stat),Go),unlink:ol(lo(Fn.unlink),Go),chmodSync:ls(Fn.chmodSync,Zg),chownSync:ls(Fn.chownSync,Zg),closeSync:ls(Fn.closeSync,Go),existsSync:ls(Fn.existsSync,Go),fsyncSync:ls(Fn.fsync,Go),mkdirSync:ls(Fn.mkdirSync,Go),realpathSync:ls(Fn.realpathSync,Go),statSync:ls(Fn.statSync,Go),unlinkSync:ls(Fn.unlinkSync,Go)},retry:{close:al(lo(Fn.close),Wi),fsync:al(lo(Fn.fsync),Wi),open:al(lo(Fn.open),Wi),readFile:al(lo(Fn.readFile),Wi),rename:al(lo(Fn.rename),Wi),stat:al(lo(Fn.stat),Wi),write:al(lo(Fn.write),Wi),writeFile:al(lo(Fn.writeFile),Wi),closeSync:sl(Fn.closeSync,Wi),fsyncSync:sl(Fn.fsyncSync,Wi),openSync:sl(Fn.openSync,Wi),readFileSync:sl(Fn.readFileSync,Wi),renameSync:sl(Fn.renameSync,Wi),statSync:sl(Fn.statSync,Wi),writeSync:sl(Fn.writeSync,Wi),writeFileSync:sl(Fn.writeFileSync,Wi)}},wi=R0e;import bd from"node:process";var iN="utf8",p1=438,oN=511;var aN={},sN=bd.geteuid?bd.geteuid():-1,lN=bd.getegid?bd.getegid():-1;var cN=1000,uN=!!bd.getuid,unt=bd.getuid?!bd.getuid():!1,m1=128;var dN=(e)=>e instanceof Error&&("code"in e);var f1=(e)=>typeof e==="string",_h=(e)=>e===void 0;import N0e from"node:path";import mm from"node:process";import pN from"node:process";var mN=pN.platform==="linux",Ih=pN.platform==="win32";var g1=["SIGHUP","SIGINT","SIGTERM"];if(!Ih)g1.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(mN)g1.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var fN=g1;class gN{constructor(){this.callbacks=new Set,this.exited=!1,this.exit=(e)=>{if(this.exited)return;this.exited=!0;for(let t of this.callbacks)t();if(e)if(Ih&&(e!=="SIGINT"&&e!=="SIGTERM"&&e!=="SIGKILL"))mm.kill(mm.pid,"SIGTERM");else mm.kill(mm.pid,e)},this.hook=()=>{mm.once("exit",()=>this.exit());for(let e of fN)try{mm.once(e,()=>this.exit(e))}catch{}},this.register=(e)=>(this.callbacks.add(e),()=>{this.callbacks.delete(e)}),this.hook()}}var AN=new gN;var F0e=AN.register,xN=F0e;var ma={store:{},create:(e)=>{let t=`000000${Math.floor(Math.random()*16777215).toString(16)}`.slice(-6),n=Date.now().toString().slice(-10),r="tmp-",i=`.tmp-${n}${t}`;return`${e}${i}`},get:(e,t,n=!0)=>{let r=ma.truncate(t(e));if(r in ma.store)return ma.get(e,t,n);return ma.store[r]=n,[r,()=>delete ma.store[r]]},purge:(e)=>{if(!ma.store[e])return;delete ma.store[e],wi.attempt.unlink(e)},purgeSync:(e)=>{if(!ma.store[e])return;delete ma.store[e],wi.attempt.unlinkSync(e)},purgeSyncAll:()=>{for(let e in ma.store)ma.purgeSync(e)},truncate:(e)=>{let t=N0e.basename(e);if(t.length<=m1)return e;let n=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(t);if(!n)return e;let r=t.length-m1;return`${e.slice(0,-t.length)}${n[1]}${n[2].slice(0,-r)}${n[3]}`}};xN(ma.purgeSyncAll);var Xg=ma;function A1(e,t,n=aN){if(f1(n))return A1(e,t,{encoding:n});let i={timeout:n.timeout??cN},o=null,a=null,c=null;try{let u=wi.attempt.realpathSync(e),p=!!u;e=u||e,[a,o]=Xg.get(e,n.tmpCreate||Xg.create,n.tmpPurge!==!1);let g=uN&&_h(n.chown),x=_h(n.mode);if(p&&(g||x)){let h=wi.attempt.statSync(e);if(h){if(n={...n},g)n.chown={uid:h.uid,gid:h.gid};if(x)n.mode=h.mode}}if(!p){let h=P0e.dirname(e);wi.attempt.mkdirSync(h,{mode:oN,recursive:!0})}if(c=wi.retry.openSync(i)(a,"w",n.mode||p1),n.tmpCreated)n.tmpCreated(a);if(f1(t))wi.retry.writeSync(i)(c,t,0,n.encoding||iN);else if(!_h(t))wi.retry.writeSync(i)(c,t,0,t.length,0);if(n.fsync!==!1)if(n.fsyncWait!==!1)wi.retry.fsyncSync(i)(c);else wi.attempt.fsync(c);if(wi.retry.closeSync(i)(c),c=null,n.chown&&(n.chown.uid!==sN||n.chown.gid!==lN))wi.attempt.chownSync(a,n.chown.uid,n.chown.gid);if(n.mode&&n.mode!==p1)wi.attempt.chmodSync(a,n.mode);try{wi.retry.renameSync(i)(a,e)}catch(h){if(!dN(h))throw h;if(h.code!=="ENAMETOOLONG")throw h;wi.retry.renameSync(i)(a,Xg.truncate(e))}o(),a=null}finally{if(c)wi.attempt.closeSync(c);if(a)Xg.purge(a)}}var D$=Nt(cM(),1),w$=Nt(kM(),1);var Eve=(e,t,n,r)=>{if(n==="length"||n==="prototype")return;if(n==="arguments"||n==="caller")return;let i=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);if(!hve(i,o)&&r)return;Object.defineProperty(e,n,o)},hve=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},yve=(e,t)=>{let n=Object.getPrototypeOf(t);if(n===Object.getPrototypeOf(e))return;Object.setPrototypeOf(e,n)},bve=(e,t)=>`/* Wrapped ${e}*/
|
|
262
|
+
<%s key={someKey} {...props} />`,Ps,oa,Os,oa),Tc[oa+Ps]=!0}}if(O===n)di(Qn);else bo(Qn);return Qn}}var Jr=Yu;SWe.Fragment=n,SWe.jsxDEV=Jr})()});var i1={};Hge(i1,{program:()=>LF,createCommand:()=>MF,createOption:()=>UF,createArgument:()=>$F,Command:()=>qF,Option:()=>QF,Argument:()=>zF,Help:()=>jF,CommanderError:()=>HF,InvalidArgumentError:()=>GF,InvalidOptionArgumentError:()=>VF},{program:(Stt)=>LF=Stt,createCommand:(Stt)=>MF=Stt,createOption:(Stt)=>UF=Stt,createArgument:(Stt)=>$F=Stt,Command:(Stt)=>qF=Stt,Option:(Stt)=>QF=Stt,Argument:(Stt)=>zF=Stt,Help:(Stt)=>jF=Stt,CommanderError:(Stt)=>HF=Stt,InvalidArgumentError:(Stt)=>GF=Stt,InvalidOptionArgumentError:(Stt)=>VF=Stt});var{Argument:NF}=Sh(),{Command:r1}=FF(),{CommanderError:b0e,InvalidArgumentError:PF}=Jg(),{Help:C0e}=YI(),{Option:OF}=ZI();var LF=new r1,MF=(e)=>new r1(e),UF=(e,t)=>new OF(e,t),$F=(e,t)=>new NF(e,t),qF=r1,QF=OF,zF=NF,jF=C0e,HF=b0e,GF=PF,VF=PF;var{program:vtt,createCommand:_tt,createArgument:Itt,createOption:Dtt,CommanderError:WF,InvalidArgumentError:wtt,InvalidOptionArgumentError:Ttt,Command:KF,Argument:ktt,Option:Rtt,Help:Ftt}=i1;var Bh={name:"@sequenzy/cli",version:"0.0.148",description:"Sequenzy CLI for email marketing from the terminal",type:"module",bin:{sequenzy:"./dist/index.js"},main:"./src/index.tsx",types:"./src/index.tsx",exports:{".":"./src/index.tsx"},scripts:{dev:"bun --watch src/index.tsx",build:"bun ../../scripts/build-ink-cli.ts",start:"node dist/index.js",lint:"eslint src","type-check":"tsc --noEmit",test:"sh ../../scripts/run-package-tests.sh src","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{commander:"^12.1.0",ink:"^5.0.1","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0","ink-select-input":"^6.0.0","ink-table":"^3.1.0",open:"^10.1.0",react:"^18.3.1",conf:"^13.0.0"},devDependencies:{"@emailer/shared":"workspace:*","@types/bun":"latest","@types/node":"^22.0.0","@types/react":"^18.3.0","bun-types":"latest",typescript:"^7.0.2"},files:["dist"],keywords:["sequenzy","email","cli","marketing"],license:"MIT",repository:{type:"git",url:"https://github.com/sequenzy/sequenzy"}};import{isDeepStrictEqual as v1e}from"node:util";import v$ from"node:process";import Td from"node:fs";import _$ from"node:path";import R0 from"node:crypto";import _1e from"node:assert";var yd=(e)=>{let t=typeof e;return e!==null&&(t==="object"||t==="function")};var o1=new Set(["__proto__","prototype","constructor"]),B0e=new Set("0123456789");function vh(e){let t=[],n="",r="start",i=!1;for(let o of e)switch(o){case"\\":{if(r==="index")throw Error("Invalid character in an index");if(r==="indexEnd")throw Error("Invalid character after an index");if(i)n+=o;r="property",i=!i;break}case".":{if(r==="index")throw Error("Invalid character in an index");if(r==="indexEnd"){r="property";break}if(i){i=!1,n+=o;break}if(o1.has(n))return[];t.push(n),n="",r="property";break}case"[":{if(r==="index")throw Error("Invalid character in an index");if(r==="indexEnd"){r="index";break}if(i){i=!1,n+=o;break}if(r==="property"){if(o1.has(n))return[];t.push(n),n=""}r="index";break}case"]":{if(r==="index"){t.push(Number.parseInt(n,10)),n="",r="indexEnd";break}if(r==="indexEnd")throw Error("Invalid character after an index")}default:{if(r==="index"&&!B0e.has(o))throw Error("Invalid character in an index");if(r==="indexEnd")throw Error("Invalid character after an index");if(r==="start")r="property";if(i)i=!1,n+="\\";n+=o}}if(i)n+="\\";switch(r){case"property":{if(o1.has(n))return[];t.push(n);break}case"index":throw Error("Index was not closed");case"start":{t.push("");break}}return t}function a1(e,t){if(typeof t!=="number"&&Array.isArray(e)){let n=Number.parseInt(t,10);return Number.isInteger(n)&&e[n]===e[t]}return!1}function JF(e,t){if(a1(e,t))throw Error("Cannot use string index")}function YF(e,t,n){if(!yd(e)||typeof t!=="string")return n===void 0?e:n;let r=vh(t);if(r.length===0)return n;for(let i=0;i<r.length;i++){let o=r[i];if(a1(e,o))e=i===r.length-1?void 0:null;else e=e[o];if(e===void 0||e===null){if(i!==r.length-1)return n;break}}return e===void 0?n:e}function s1(e,t,n){if(!yd(e)||typeof t!=="string")return e;let r=e,i=vh(t);for(let o=0;o<i.length;o++){let a=i[o];if(JF(e,a),o===i.length-1)e[a]=n;else if(!yd(e[a]))e[a]=typeof i[o+1]==="number"?[]:{};e=e[a]}return r}function ZF(e,t){if(!yd(e)||typeof t!=="string")return!1;let n=vh(t);for(let r=0;r<n.length;r++){let i=n[r];if(JF(e,i),r===n.length-1)return delete e[i],!0;if(e=e[i],!yd(e))return!1}}function XF(e,t){if(!yd(e)||typeof t!=="string")return!1;let n=vh(t);if(n.length===0)return!1;for(let r of n){if(!yd(e)||!(r in e)||a1(e,r))return!1;e=e[r]}return!0}import Fr from"node:path";import eN from"node:os";import l1 from"node:process";var Jc=eN.homedir(),c1=eN.tmpdir(),{env:pm}=l1,v0e=(e)=>{let t=Fr.join(Jc,"Library");return{data:Fr.join(t,"Application Support",e),config:Fr.join(t,"Preferences",e),cache:Fr.join(t,"Caches",e),log:Fr.join(t,"Logs",e),temp:Fr.join(c1,e)}},_0e=(e)=>{let t=pm.APPDATA||Fr.join(Jc,"AppData","Roaming"),n=pm.LOCALAPPDATA||Fr.join(Jc,"AppData","Local");return{data:Fr.join(n,e,"Data"),config:Fr.join(t,e,"Config"),cache:Fr.join(n,e,"Cache"),log:Fr.join(n,e,"Log"),temp:Fr.join(c1,e)}},I0e=(e)=>{let t=Fr.basename(Jc);return{data:Fr.join(pm.XDG_DATA_HOME||Fr.join(Jc,".local","share"),e),config:Fr.join(pm.XDG_CONFIG_HOME||Fr.join(Jc,".config"),e),cache:Fr.join(pm.XDG_CACHE_HOME||Fr.join(Jc,".cache"),e),log:Fr.join(pm.XDG_STATE_HOME||Fr.join(Jc,".local","state"),e),temp:Fr.join(c1,t,e)}};function u1(e,{suffix:t="nodejs"}={}){if(typeof e!=="string")throw TypeError(`Expected a string, got ${typeof e}`);if(t)e+=`-${t}`;if(l1.platform==="darwin")return v0e(e);if(l1.platform==="win32")return _0e(e);return I0e(e)}import P0e from"node:path";import Fn from"node:fs";import{promisify as lo}from"node:util";var D0e=(e,t)=>{let{onError:n}=t;return function(...i){return e.apply(void 0,i).catch(n)}},ol=D0e;var w0e=(e,t)=>{let{onError:n}=t;return function(...i){try{return e.apply(void 0,i)}catch(o){return n(o)}}},ls=w0e;var tN=250;var T0e=(e,t)=>{let{isRetriable:n}=t;return function(i){let{timeout:o}=i,a=i.interval??tN,c=Date.now()+o;return function u(...p){return e.apply(void 0,p).catch((g)=>{if(!n(g))throw g;if(Date.now()>=c)throw g;let x=Math.round(a*Math.random());if(x>0)return new Promise((b)=>setTimeout(b,x)).then(()=>u.apply(void 0,p));else return u.apply(void 0,p)})}}},al=T0e;var k0e=(e,t)=>{let{isRetriable:n}=t;return function(i){let{timeout:o}=i,a=Date.now()+o;return function(...u){while(!0)try{return e.apply(void 0,u)}catch(p){if(!n(p))throw p;if(Date.now()>=a)throw p;continue}}}},sl=k0e;import rN from"node:process";var Yg={isChangeErrorOk:(e)=>{if(!Yg.isNodeError(e))return!1;let{code:t}=e;if(t==="ENOSYS")return!0;if(!nN&&(t==="EINVAL"||t==="EPERM"))return!0;return!1},isNodeError:(e)=>e instanceof Error,isRetriableError:(e)=>{if(!Yg.isNodeError(e))return!1;let{code:t}=e;if(t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM")return!0;return!1},onChangeError:(e)=>{if(!Yg.isNodeError(e))throw e;if(Yg.isChangeErrorOk(e))return;throw e}},d1=Yg;var Zg={onError:d1.onChangeError},Go={onError:()=>{return}},nN=rN.getuid?!rN.getuid():!1,Wi={isRetriable:d1.isRetriableError};var R0e={attempt:{chmod:ol(lo(Fn.chmod),Zg),chown:ol(lo(Fn.chown),Zg),close:ol(lo(Fn.close),Go),fsync:ol(lo(Fn.fsync),Go),mkdir:ol(lo(Fn.mkdir),Go),realpath:ol(lo(Fn.realpath),Go),stat:ol(lo(Fn.stat),Go),unlink:ol(lo(Fn.unlink),Go),chmodSync:ls(Fn.chmodSync,Zg),chownSync:ls(Fn.chownSync,Zg),closeSync:ls(Fn.closeSync,Go),existsSync:ls(Fn.existsSync,Go),fsyncSync:ls(Fn.fsync,Go),mkdirSync:ls(Fn.mkdirSync,Go),realpathSync:ls(Fn.realpathSync,Go),statSync:ls(Fn.statSync,Go),unlinkSync:ls(Fn.unlinkSync,Go)},retry:{close:al(lo(Fn.close),Wi),fsync:al(lo(Fn.fsync),Wi),open:al(lo(Fn.open),Wi),readFile:al(lo(Fn.readFile),Wi),rename:al(lo(Fn.rename),Wi),stat:al(lo(Fn.stat),Wi),write:al(lo(Fn.write),Wi),writeFile:al(lo(Fn.writeFile),Wi),closeSync:sl(Fn.closeSync,Wi),fsyncSync:sl(Fn.fsyncSync,Wi),openSync:sl(Fn.openSync,Wi),readFileSync:sl(Fn.readFileSync,Wi),renameSync:sl(Fn.renameSync,Wi),statSync:sl(Fn.statSync,Wi),writeSync:sl(Fn.writeSync,Wi),writeFileSync:sl(Fn.writeFileSync,Wi)}},wi=R0e;import bd from"node:process";var iN="utf8",p1=438,oN=511;var aN={},sN=bd.geteuid?bd.geteuid():-1,lN=bd.getegid?bd.getegid():-1;var cN=1000,uN=!!bd.getuid,unt=bd.getuid?!bd.getuid():!1,m1=128;var dN=(e)=>e instanceof Error&&("code"in e);var f1=(e)=>typeof e==="string",_h=(e)=>e===void 0;import N0e from"node:path";import mm from"node:process";import pN from"node:process";var mN=pN.platform==="linux",Ih=pN.platform==="win32";var g1=["SIGHUP","SIGINT","SIGTERM"];if(!Ih)g1.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(mN)g1.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var fN=g1;class gN{constructor(){this.callbacks=new Set,this.exited=!1,this.exit=(e)=>{if(this.exited)return;this.exited=!0;for(let t of this.callbacks)t();if(e)if(Ih&&(e!=="SIGINT"&&e!=="SIGTERM"&&e!=="SIGKILL"))mm.kill(mm.pid,"SIGTERM");else mm.kill(mm.pid,e)},this.hook=()=>{mm.once("exit",()=>this.exit());for(let e of fN)try{mm.once(e,()=>this.exit(e))}catch{}},this.register=(e)=>(this.callbacks.add(e),()=>{this.callbacks.delete(e)}),this.hook()}}var AN=new gN;var F0e=AN.register,xN=F0e;var ma={store:{},create:(e)=>{let t=`000000${Math.floor(Math.random()*16777215).toString(16)}`.slice(-6),n=Date.now().toString().slice(-10),r="tmp-",i=`.tmp-${n}${t}`;return`${e}${i}`},get:(e,t,n=!0)=>{let r=ma.truncate(t(e));if(r in ma.store)return ma.get(e,t,n);return ma.store[r]=n,[r,()=>delete ma.store[r]]},purge:(e)=>{if(!ma.store[e])return;delete ma.store[e],wi.attempt.unlink(e)},purgeSync:(e)=>{if(!ma.store[e])return;delete ma.store[e],wi.attempt.unlinkSync(e)},purgeSyncAll:()=>{for(let e in ma.store)ma.purgeSync(e)},truncate:(e)=>{let t=N0e.basename(e);if(t.length<=m1)return e;let n=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(t);if(!n)return e;let r=t.length-m1;return`${e.slice(0,-t.length)}${n[1]}${n[2].slice(0,-r)}${n[3]}`}};xN(ma.purgeSyncAll);var Xg=ma;function A1(e,t,n=aN){if(f1(n))return A1(e,t,{encoding:n});let i={timeout:n.timeout??cN},o=null,a=null,c=null;try{let u=wi.attempt.realpathSync(e),p=!!u;e=u||e,[a,o]=Xg.get(e,n.tmpCreate||Xg.create,n.tmpPurge!==!1);let g=uN&&_h(n.chown),x=_h(n.mode);if(p&&(g||x)){let h=wi.attempt.statSync(e);if(h){if(n={...n},g)n.chown={uid:h.uid,gid:h.gid};if(x)n.mode=h.mode}}if(!p){let h=P0e.dirname(e);wi.attempt.mkdirSync(h,{mode:oN,recursive:!0})}if(c=wi.retry.openSync(i)(a,"w",n.mode||p1),n.tmpCreated)n.tmpCreated(a);if(f1(t))wi.retry.writeSync(i)(c,t,0,n.encoding||iN);else if(!_h(t))wi.retry.writeSync(i)(c,t,0,t.length,0);if(n.fsync!==!1)if(n.fsyncWait!==!1)wi.retry.fsyncSync(i)(c);else wi.attempt.fsync(c);if(wi.retry.closeSync(i)(c),c=null,n.chown&&(n.chown.uid!==sN||n.chown.gid!==lN))wi.attempt.chownSync(a,n.chown.uid,n.chown.gid);if(n.mode&&n.mode!==p1)wi.attempt.chmodSync(a,n.mode);try{wi.retry.renameSync(i)(a,e)}catch(h){if(!dN(h))throw h;if(h.code!=="ENAMETOOLONG")throw h;wi.retry.renameSync(i)(a,Xg.truncate(e))}o(),a=null}finally{if(c)wi.attempt.closeSync(c);if(a)Xg.purge(a)}}var D$=Nt(cM(),1),w$=Nt(kM(),1);var Eve=(e,t,n,r)=>{if(n==="length"||n==="prototype")return;if(n==="arguments"||n==="caller")return;let i=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);if(!hve(i,o)&&r)return;Object.defineProperty(e,n,o)},hve=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},yve=(e,t)=>{let n=Object.getPrototypeOf(t);if(n===Object.getPrototypeOf(e))return;Object.setPrototypeOf(e,n)},bve=(e,t)=>`/* Wrapped ${e}*/
|
|
263
263
|
${t}`,Cve=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Sve=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Bve=(e,t,n)=>{let r=n===""?"":`with ${n.trim()}() `,i=bve.bind(null,r,t.toString());Object.defineProperty(i,"name",Sve);let{writable:o,enumerable:a,configurable:c}=Cve;Object.defineProperty(e,"toString",{value:i,writable:o,enumerable:a,configurable:c})};function k2(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let i of Reflect.ownKeys(t))Eve(e,t,i,n);return yve(e,t),Bve(e,t,r),e}var vve=(e,t={})=>{if(typeof e!=="function")throw TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);let{wait:n=0,maxWait:r=Number.POSITIVE_INFINITY,before:i=!1,after:o=!0}=t;if(n<0||r<0)throw RangeError("`wait` and `maxWait` must not be negative.");if(!i&&!o)throw Error("Both `before` and `after` are false, function wouldn't be called.");let a,c,u,p=function(...g){let x=this,h=()=>{if(a=void 0,c)clearTimeout(c),c=void 0;if(o)u=e.apply(x,g)},b=()=>{if(c=void 0,a)clearTimeout(a),a=void 0;if(o)u=e.apply(x,g)},I=i&&!a;if(clearTimeout(a),a=setTimeout(h,n),r>0&&r!==Number.POSITIVE_INFINITY&&!c)c=setTimeout(b,r);if(I)u=e.apply(x,g);return u};return k2(p,e),p.cancel=()=>{if(a)clearTimeout(a),a=void 0;if(c)clearTimeout(c),c=void 0},p},R2=vve;var kd=Nt(b$(),1);var E1e=Object.prototype.toString;function S$(e,t,n){if(!e)return!1;if(e.constructor===t)return!0;return E1e.call(e)===n}function B$(e){return S$(e,Uint8Array,"[object Uint8Array]")}function h1e(e){return S$(e,ArrayBuffer,"[object ArrayBuffer]")}function y1e(e){return B$(e)||h1e(e)}function b1e(e){if(!B$(e))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}function C1e(e){if(!y1e(e))throw TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``)}function W2(e,t){if(e.length===0)return new Uint8Array(0);t??=e.reduce((i,o)=>i+o.length,0);let n=new Uint8Array(t),r=0;for(let i of e)b1e(i),n.set(i,r),r+=i.length;return n}var C$={utf8:new globalThis.TextDecoder("utf8")};function K2(e,t="utf8"){return C1e(e),C$[t]??=new globalThis.TextDecoder(t),C$[t].decode(e)}function S1e(e){if(typeof e!=="string")throw TypeError(`Expected \`string\`, got \`${typeof e}\``)}var B1e=new globalThis.TextEncoder;function vy(e){return S1e(e),B1e.encode(e)}var Yot=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));var I1e=w$.default.default,I$="aes-256-cbc",wm=()=>Object.create(null),D1e=(e)=>e!==void 0&&e!==null,w1e=(e,t)=>{let n=new Set(["undefined","symbol","function"]),r=typeof t;if(n.has(r))throw TypeError(`Setting a value of type \`${r}\` for key \`${e}\` is not allowed as it's not supported by JSON`)},_y="__internal__",J2=`${_y}.migrations.version`;class Iy{path;events;#r;#t;#e;#n={};constructor(e={}){let t={configName:"config",fileExtension:"json",projectSuffix:"nodejs",clearInvalidConfig:!1,accessPropertiesByDotNotation:!0,configFileMode:438,...e};if(!t.cwd){if(!t.projectName)throw Error("Please specify the `projectName` option.");t.cwd=u1(t.projectName,{suffix:t.projectSuffix}).config}if(this.#e=t,t.schema??t.ajvOptions??t.rootSchema){if(t.schema&&typeof t.schema!=="object")throw TypeError("The `schema` option must be an object.");let o=new D$.Ajv2020({allErrors:!0,useDefaults:!0,...t.ajvOptions});I1e(o);let a={...t.rootSchema,type:"object",properties:t.schema};this.#r=o.compile(a);for(let[c,u]of Object.entries(t.schema??{}))if(u?.default)this.#n[c]=u.default}if(t.defaults)this.#n={...this.#n,...t.defaults};if(t.serialize)this._serialize=t.serialize;if(t.deserialize)this._deserialize=t.deserialize;this.events=new EventTarget,this.#t=t.encryptionKey;let n=t.fileExtension?`.${t.fileExtension}`:"";this.path=_$.resolve(t.cwd,`${t.configName??"config"}${n}`);let r=this.store,i=Object.assign(wm(),t.defaults,r);if(t.migrations){if(!t.projectVersion)throw Error("Please specify the `projectVersion` option.");this._migrate(t.migrations,t.projectVersion,t.beforeEachMigration)}this._validate(i);try{_1e.deepEqual(r,i)}catch{this.store=i}if(t.watch)this._watch()}get(e,t){if(this.#e.accessPropertiesByDotNotation)return this._get(e,t);let{store:n}=this;return e in n?n[e]:t}set(e,t){if(typeof e!=="string"&&typeof e!=="object")throw TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof e}`);if(typeof e!=="object"&&t===void 0)throw TypeError("Use `delete()` to clear values");if(this._containsReservedKey(e))throw TypeError(`Please don't use the ${_y} key, as it's used to manage this module internal operations.`);let{store:n}=this,r=(i,o)=>{if(w1e(i,o),this.#e.accessPropertiesByDotNotation)s1(n,i,o);else n[i]=o};if(typeof e==="object"){let i=e;for(let[o,a]of Object.entries(i))r(o,a)}else r(e,t);this.store=n}has(e){if(this.#e.accessPropertiesByDotNotation)return XF(this.store,e);return e in this.store}reset(...e){for(let t of e)if(D1e(this.#n[t]))this.set(t,this.#n[t])}delete(e){let{store:t}=this;if(this.#e.accessPropertiesByDotNotation)ZF(t,e);else delete t[e];this.store=t}clear(){this.store=wm();for(let e of Object.keys(this.#n))this.reset(e)}onDidChange(e,t){if(typeof e!=="string")throw TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof e}`);if(typeof t!=="function")throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof t}`);return this._handleChange(()=>this.get(e),t)}onDidAnyChange(e){if(typeof e!=="function")throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof e}`);return this._handleChange(()=>this.store,e)}get size(){return Object.keys(this.store).length}get store(){try{let e=Td.readFileSync(this.path,this.#t?null:"utf8"),t=this._encryptData(e),n=this._deserialize(t);return this._validate(n),Object.assign(wm(),n)}catch(e){if(e?.code==="ENOENT")return this._ensureDirectory(),wm();if(this.#e.clearInvalidConfig&&e.name==="SyntaxError")return wm();throw e}}set store(e){this._ensureDirectory(),this._validate(e),this._write(e),this.events.dispatchEvent(new Event("change"))}*[Symbol.iterator](){for(let[e,t]of Object.entries(this.store))yield[e,t]}_encryptData(e){if(!this.#t)return typeof e==="string"?e:K2(e);try{let t=e.slice(0,16),n=R0.pbkdf2Sync(this.#t,t.toString(),1e4,32,"sha512"),r=R0.createDecipheriv(I$,n,t),i=e.slice(17),o=typeof i==="string"?vy(i):i;return K2(W2([r.update(o),r.final()]))}catch{}return e.toString()}_handleChange(e,t){let n=e(),r=()=>{let i=n,o=e();if(v1e(o,i))return;n=o,t.call(this,o,i)};return this.events.addEventListener("change",r),()=>{this.events.removeEventListener("change",r)}}_deserialize=(e)=>JSON.parse(e);_serialize=(e)=>JSON.stringify(e,void 0,"\t");_validate(e){if(!this.#r)return;if(this.#r(e)||!this.#r.errors)return;let n=this.#r.errors.map(({instancePath:r,message:i=""})=>`\`${r.slice(1)}\` ${i}`);throw Error("Config schema violation: "+n.join("; "))}_ensureDirectory(){Td.mkdirSync(_$.dirname(this.path),{recursive:!0})}_write(e){let t=this._serialize(e);if(this.#t){let n=R0.randomBytes(16),r=R0.pbkdf2Sync(this.#t,n.toString(),1e4,32,"sha512"),i=R0.createCipheriv(I$,r,n);t=W2([n,vy(":"),i.update(vy(t)),i.final()])}if(v$.env.SNAP)Td.writeFileSync(this.path,t,{mode:this.#e.configFileMode});else try{A1(this.path,t,{mode:this.#e.configFileMode})}catch(n){if(n?.code==="EXDEV"){Td.writeFileSync(this.path,t,{mode:this.#e.configFileMode});return}throw n}}_watch(){if(this._ensureDirectory(),!Td.existsSync(this.path))this._write(wm());if(v$.platform==="win32")Td.watch(this.path,{persistent:!1},R2(()=>{this.events.dispatchEvent(new Event("change"))},{wait:100}));else Td.watchFile(this.path,{persistent:!1},R2(()=>{this.events.dispatchEvent(new Event("change"))},{wait:5000}))}_migrate(e,t,n){let r=this._get(J2,"0.0.0"),i=Object.keys(e).filter((a)=>this._shouldPerformMigration(a,r,t)),o={...this.store};for(let a of i)try{if(n)n(this,{fromVersion:r,toVersion:a,finalVersion:t,versions:i});let c=e[a];c?.(this),this._set(J2,a),r=a,o={...this.store}}catch(c){throw this.store=o,Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${c}`)}if(this._isVersionInRangeFormat(r)||!kd.default.eq(r,t))this._set(J2,t)}_containsReservedKey(e){if(typeof e==="object"){if(Object.keys(e)[0]===_y)return!0}if(typeof e!=="string")return!1;if(this.#e.accessPropertiesByDotNotation){if(e.startsWith(`${_y}.`))return!0;return!1}return!1}_isVersionInRangeFormat(e){return kd.default.clean(e)===null}_shouldPerformMigration(e,t,n){if(this._isVersionInRangeFormat(e)){if(t!=="0.0.0"&&kd.default.satisfies(t,e))return!1;return kd.default.satisfies(n,e)}if(kd.default.lte(e,t))return!1;if(kd.default.gt(e,n))return!1;return!0}_get(e,t){return YF(this.store,e,t)}_set(e,t){let{store:n}=this;s1(n,e,t),this.store=n}}var Y2="com.sequenzy.cli",Z2="api-key",X2=typeof globalThis.Bun<"u",ou=new Iy({projectName:"sequenzy",schema:{userId:{type:"string"},userEmail:{type:"string"},_apiKey:{type:"string"}}});async function eD(){let e=process.env.SEQUENZY_API_KEY;if(e)return e;if(X2)try{let t=await globalThis.Bun.secrets.get({service:Y2,name:Z2});if(t)return t}catch{}return ou.get("_apiKey")}async function T$(e){if(X2)try{await globalThis.Bun.secrets.set({service:Y2,name:Z2,value:e,allowUnrestrictedAccess:!1});return}catch{}ou.set("_apiKey",e)}async function k$(){if(X2)try{await globalThis.Bun.secrets.delete({service:Y2,name:Z2})}catch{}ou.delete("_apiKey")}async function le(){return!!await eD()}function Dy(){return{userId:ou.get("userId"),userEmail:ou.get("userEmail")}}function R$(e){if(e.userId!==void 0)ou.set("userId",e.userId);if(e.userEmail!==void 0)ou.set("userEmail",e.userEmail)}function F$(){ou.clear()}function N$(e,t=Date.now()){if(!e?.trim())return;let n=e.trim();if(/^\d+$/.test(n)){let i=Number(n);return Number.isSafeInteger(i)?i:void 0}if(!/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} [A-Z][a-z]{2} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(n))return;let r=Date.parse(n);if(!Number.isFinite(r)||new Date(r).toUTCString().slice(5)!==n.slice(5))return;return Math.max(0,Math.ceil((r-t)/1000))}function P$(e,t,n){if(e&&/^[A-Z][A-Z0-9_]{1,95}$/.test(e))return e;switch(t){case 0:return"NETWORK_ERROR";case 400:case 422:return"VALIDATION_ERROR";case 401:return"UNAUTHORIZED";case 403:return"FORBIDDEN";case 404:return"NOT_FOUND";case 409:return"CONFLICT";case 429:return"RATE_LIMITED";default:return t!==void 0?t>=500?"SERVER_ERROR":"HTTP_ERROR":n}}var T1e=process.env.SEQUENZY_API_URL??"https://api.sequenzy.com";class E extends Error{statusCode;rawDetails;code;retryAfterSeconds;constructor(e,t,n,r,i){super(e);this.statusCode=t;this.rawDetails=n;this.code=r;this.retryAfterSeconds=i;this.name="ApiError"}}function k1e(e,t){if(typeof e!=="string")return;if(typeof t!=="string"||t==="root")return e;let n=t.slice(1).replaceAll("/",".");return e.includes(`'${n}'`)?e:`${n}: ${e}`}function R1e(e){if(!e.trim())return{message:"Request failed"};try{let t=JSON.parse(e);if(typeof t==="string")return{message:t};if(!t||typeof t!=="object"||Array.isArray(t))return{message:"Request failed"};let n=t,r=n.error&&typeof n.error==="object"?n.error:void 0,i=r?.code??n.code,o=n.type==="validation"?k1e(n.summary,n.property):void 0,a=typeof n.error==="string"?n.error:typeof o==="string"?o:r?.message??n.message;return{message:typeof a==="string"?a:"Request failed",...typeof i==="string"?{code:i}:{}}}catch{return{message:e}}}async function w(e,t,n,r,i){let o=await eD();if(!o)throw new E("Not logged in. Run `sequenzy login` first.",401);let a={"Content-Type":"application/json",Authorization:`Bearer ${o}`,"x-sequenzy-client":`cli/${Bh.version}`};if(r)a["x-company-id"]=r;Object.assign(a,i);let c;try{c=await fetch(`${T1e}${t}`,{method:e,headers:a,body:n?JSON.stringify(n):void 0})}catch(u){throw new E(u instanceof Error?u.message:"Failed to reach Sequenzy API",0,void 0,"NETWORK_ERROR")}if(!c.ok){let u=await c.text(),p=R1e(u);throw new E(p.message,c.status,u,p.code,N$(c.headers.get("Retry-After")))}return c.json()}var O$=!1;function tD(e){O$=e}function wy(){return O$}var rD="https://docs.sequenzy.com",Xl=`${rD}/concepts/cli`,nD=`${rD}/authentication`,L$="https://sequenzy.com/dashboard";function M$(e){if(e instanceof E)return{message:e.message,statusCode:e.statusCode,code:e.code,rawDetails:e.rawDetails};if(e instanceof Error)return{message:e.message};return{message:String(e)}}function F1e(e){let t=e.match(/api key is missing required scopes?:\s*(.+)$/i);if(!t?.[1])return[];return[...new Set(t[1].match(/[a-z_]+:[a-z_]+/gi)??[])]}function U$(e){let t=M$(e),n=t.message.trim()||"Unknown error",r=n.toLowerCase(),i=t.rawDetails?.trim()||n;if(t.code==="CLI_AUTH_REQUIRED"||r.includes("not logged in"))return{title:"Authentication required",description:"This command needs a Sequenzy API key, but the CLI could not find one in your local login state or environment.",howToFix:"Run `sequenzy login` and approve the session, or set `SEQUENZY_API_KEY` for non-interactive environments.",docsUrl:Xl,details:i};if(r.includes("already logged in"))return{title:"CLI already authenticated",description:"The CLI already has a saved Sequenzy login for this machine.",howToFix:"Run `sequenzy logout` first if you want to switch accounts, then run `sequenzy login` again.",docsUrl:Xl,details:i};if(t.statusCode===401||t.code==="UNAUTHORIZED")return{title:"Authentication failed",description:"The request reached Sequenzy, but the current API key was rejected.",howToFix:"Run `sequenzy login` again, or replace the key with a valid personal API key that still has access to your account.",docsUrl:nD,details:i};if(t.code==="COMPANY_CREATE_REQUIRES_PERSONAL_KEY")return{title:"Personal account key required",description:"Company creation is account-level and cannot be performed with a company/workspace-scoped API key.",howToFix:"Create or use a personal account key beginning with `seq_user_` from Account → API Keys, replace `SEQUENZY_API_KEY`, and retry the same command; alternatively, create the company in the Sequenzy dashboard. Widening the current company key or switching companies will not fix this restriction.",docsUrl:nD,details:i};let o=F1e(n);if(o.length>0){let a=o.map((p)=>`\`${p}\``).join(", "),c=o.every((p)=>p.endsWith(":read"))?"the Read-only or Safer agent access preset":"Safer agent access when it covers the task, or Custom permissions",u=o.includes("api_keys:manage")?` This command manages API keys, so the missing scope cannot be granted through the API by the key that is missing it. If the active key has \`account:read\`, run \`sequenzy api-keys handoff\` (add \`--replaces current\` when rotating) to get a dashboard link that opens the create-key form prefilled, then give it to the workspace owner. It creates nothing and never prints a key. If handoff is also denied because \`account:read\` is missing, open ${L$} directly and choose the matching API Keys page.`:"";return{title:"API key permission required",description:`The current API key is valid, but this operation requires the missing ${o.length===1?"scope":"scopes"}: ${a}.`,howToFix:`Permissions can be widened on the key you are already using - no new key and no re-login. Run \`sequenzy account\` to see the active key, its type, and its API Keys settings URL, then have the key owner enable ${a} there. Personal keys open Account → API Keys; company keys open workspace Settings → API Keys. If account metadata is unavailable, open ${L$} directly and choose the matching API Keys page. When the active key type is \`company\` and it holds \`api_keys:manage\`, run \`sequenzy api-keys list --json\` and then \`sequenzy api-keys update <api-key-id> --scopes\` with the current scopes plus ${a}, or \`--preset\` covering all of them (${c}). Personal keys cannot be changed through \`sequenzy api-keys update\`. Both options replace the whole selection rather than merging. Retry the same command once the key is updated. Issuing a replacement key and swapping \`SEQUENZY_API_KEY\` also works but is not required.${u}`,docsUrl:Xl,details:i}}if(t.statusCode===403||r.includes("access denied"))return{title:"Access denied",description:"The current API key is valid, but it does not have permission to perform this action or access the requested company.",howToFix:"Use an API key with access to the target company, or switch to a company you can access before retrying.",docsUrl:nD,details:i};if(t.statusCode===404||r.includes("not found"))return{title:"Requested resource not found",description:"Sequenzy could not find the company, template, campaign, sequence, or subscriber you asked for.",howToFix:"Double-check the ID or email value and list the resource first before retrying the command.",docsUrl:Xl,details:i};if(t.statusCode===429||r.includes("rate limit"))return{title:"Rate limited",description:"Sequenzy temporarily slowed this request because too many requests were sent in a short period.",howToFix:"Wait a moment and retry. If an agent is looping, reduce the retry frequency before calling the CLI again.",docsUrl:Xl,details:i};if(t.code==="AB_TEST_VARIANT_CONTENT_EDIT"||r.includes("update_ab_test_variant")&&(r.includes("a/b test")||r.includes("ab test")))return{title:"A/B variant copy cannot be edited here",description:n,howToFix:"Use `sequenzy ab-tests update-variant` with the `abTestId` and `variantId` from `sequenzy sequences get` or `sequenzy ab-tests get`. Repeat once per variant for a whole-step rewrite. If the sequence is live or the test has activity, pass `--confirm-live-change`. Do not retry with `sequenzy templates update` or `sequenzy sequences update-node`.",docsUrl:`${rD}/concepts/cli#editing-the-copy-of-a-sequence-ab-step`,details:i};if(r.includes("--subject")||r.includes("--template")||r.includes("is required"))return{title:"Invalid command input",description:"The CLI command arguments are incomplete or incompatible for this action.",howToFix:"Review the flags you passed, add the missing values, and run the command again.",docsUrl:Xl,details:i};if(t.code==="NETWORK_ERROR"||r.includes("fetch failed")||r.includes("failed to initiate login"))return{title:"Network or configuration error",description:"The CLI could not reach the Sequenzy API or app URL from this environment.",howToFix:"Check your network connection and verify `SEQUENZY_API_URL` or `SEQUENZY_APP_URL` if you override them locally.",docsUrl:Xl,details:i};if(t.statusCode&&t.statusCode>=500)return{title:"Sequenzy server error",description:"The request reached Sequenzy, but the server could not complete it successfully.",howToFix:"Retry once. If the error persists, keep the details below and check the docs before escalating.",docsUrl:Xl,details:i};return{title:"Command failed",description:"The CLI could not complete the requested operation.",howToFix:"Review the details below, adjust the command or credentials, and retry.",docsUrl:Xl,details:i}}function ce(){return new E("Not logged in. Run `sequenzy login` first.",401,void 0,"CLI_AUTH_REQUIRED")}function F0(e){let t=U$(e);return[`Sequenzy CLI error: ${t.title}`,`Description: ${t.description}`,`How to fix: ${t.howToFix}`,`Docs: ${t.docsUrl}`,`Details: ${t.details}`].join(`
|
|
264
264
|
`)}function N1e(e){let t=M$(e),n=U$(e),r=(t.rawDetails===t.message?n.description:t.message.trim())||n.description;return{success:!1,error:{code:P$(t.code,t.statusCode,"CLI_ERROR"),message:r.replace(/\bBearer\s+[^\s]+/gi,"Bearer [redacted]").replace(/\bseq_(?:user_)?[A-Za-z0-9_-]{8,}\b/g,"[redacted key]"),...t.statusCode!==void 0?{statusCode:t.statusCode}:{},howToFix:n.howToFix,docsUrl:n.docsUrl,...e instanceof E&&e.retryAfterSeconds!==void 0?{retryAfterSeconds:e.retryAfterSeconds}:{}}}}function L(e,t={}){console.error(t.json??wy()?JSON.stringify(N1e(e)):F0(e))}import{readFileSync as P1e}from"node:fs";import{isatty as $$}from"node:tty";var au;function q$(){au=void 0}function iD(e){if(new Set(e).size>1)throw new E("Only one text input may read stdin (-) per command. Use regular files for the other inputs.",400,void 0,"CLI_INVALID_INPUT")}async function Q$(){if($$(0))throw new E("Pipe text into stdin when using a text file '-'.",400,void 0,"CLI_INVALID_INPUT");try{process.stdin.setEncoding("utf8");let e="";for await(let t of process.stdin)e+=String(t);au={text:e}}catch(e){throw new E(`Failed to read stdin: ${e instanceof Error?e.message:"Unknown error"}`,400,void 0,"CLI_INPUT_READ_FAILED")}}function z$(e,t){if(e==="-"){if(au){if(au.field)iD([au.field,t]);return au.field=t,au.text}if($$(0))throw new E(`Pipe text into stdin when using ${t} file '-'.`,400,void 0,"CLI_INVALID_INPUT")}try{let n=P1e(e==="-"?0:e,"utf8");if(e==="-")au={field:t,text:n};return n}catch(n){throw new E(`Failed to read ${t} file '${e}': ${n instanceof Error?n.message:"Unknown error"}`,400,void 0,"CLI_INPUT_READ_FAILED")}}function Ty(e){return e.optsWithGlobals().json===!0||e.commands.some(Ty)}async function O1e(e){tD(e.optsWithGlobals().json===!0),q$();let t=Object.entries(e.optsWithGlobals()).filter(([n,r])=>r==="-"&&n.endsWith("File")||n==="audienceJson"&&r==="@-").map(([n])=>n);if(e.parent?.name()==="subscribers"&&["import","events-import"].includes(e.name())&&e.args[0]==="-")t.push("subscriber import");if(iD(t),t.length>0)await Q$()}function j$(e){let t=e.configureOutput().writeErr;e.configureOutput({writeErr:(n)=>{if(!Ty(e))t?.(n)}}),e.exitOverride(),e.hook("preAction",(n,r)=>O1e(r))}async function H$(e,t){tD(!1);try{await e.parseAsync(t)}catch(n){if(n instanceof WF){if(n.exitCode===0)return;if(Ty(e))L(new E(n.message,400,void 0,"CLI_INVALID_INPUT"),{json:!0});process.exitCode=n.exitCode;return}L(n,{json:Ty(e)}),process.exitCode=1}}var ky="Variant copy is edited with `sequenzy ab-tests update-variant`, not with `sequenzy sequences update-node`.";import{createInterface as L1e}from"node:readline/promises";function T(e){console.log(JSON.stringify(e,null,2))}function Nr(e){if(typeof e!=="object"||e===null)return;let t=e.warnings;if(!Array.isArray(t)||t.length===0)return;for(let n of t)if(typeof n==="string")console.warn(`Warning: ${n}`)}function pe(e){if(!e)return"None";let t=e instanceof Date?e:new Date(e);if(Number.isNaN(t.getTime()))return String(e);return t.toISOString()}function As(e){if(e==="branded")return"Branded";if(e==="minimal")return"Minimal";if(e===null)return"Raw HTML";return"Unknown"}function G$(e){if(!e)return"Company default";let t=[`Override: ${e.presetId??"custom"}`];if(e.colors?.background)t.push(`background ${e.colors.background}`);if(e.colors?.content)t.push(`content ${e.colors.content}`);if(e.colors?.primary)t.push(`primary ${e.colors.primary}`);return t.join(", ")}function Pr(e,t,n){if(e&&t)throw new E(`Provide either --${n} or --${n}-file, not both`,400);if(!t)return e;return z$(t,n)}function rt(e,t,n){let r=Pr(e,t,n);if(!r)return;try{return JSON.parse(r)}catch(i){throw new E(`Invalid ${n} JSON: ${i instanceof Error?i.message:"Unknown error"}`,400)}}function ec(e){let t=Pr(e.html,e.htmlFile,"html"),n=rt(e.blocksJson,e.blocksFile,"blocks");if(t!==void 0&&n!==void 0)throw new E("Provide either --html/--html-file or --blocks-json/--blocks-file, not both",400);if(n!==void 0&&!Array.isArray(n))throw new E("blocks JSON must be an array",400);if(e.required&&t===void 0&&n===void 0)throw new E(e.requiredMessage??"Provide either --html/--html-file or --blocks-json/--blocks-file",400);return{...t!==void 0&&{html:t},...n!==void 0&&{blocks:n}}}function N0(e,t){if(!t)return{};let n;try{n=JSON.parse(t)}catch{throw new E(`${e} must be valid JSON`,400)}if(typeof n!=="object"||n===null||Array.isArray(n))throw new E(`${e} must be a JSON object`,400);return n}function Ut(e,t){if(e===void 0)return;let n=e.trim();if(!/^[+-]?\d+$/.test(n))throw new E(`${t} must be an integer`,400);let r=Number(n);if(!Number.isInteger(r))throw new E(`${t} must be an integer`,400);return r}function fa(e,t){if(e===void 0)return;let n=e.trim().toLowerCase();if(["on","true","yes","enabled"].includes(n))return!0;if(["off","false","no","disabled"].includes(n))return!1;throw new E(`${t} must be "on" or "off"`,400)}async function Tn(e,t){if(t.yes===!0)return!0;if(!process.stdin.isTTY)throw new E(`${e} Confirmation is required: re-run with --yes when stdin is not interactive`,400);let n=L1e({input:process.stdin,output:process.stdout});try{let r=(await n.question(`${e} [y/N] `)).trim().toLowerCase();return r==="y"||r==="yes"}finally{n.close()}}function pl(e,t){if(!e||e.trim()==="")throw new E(`${t} is required`,400);return e}var Ry=["reactivate","double_opt_in"];function Fy(e){if(typeof e!=="object"||e===null)return null;let t=e.settings;if(typeof t!=="object"||t===null)return null;let n=t.resubscribeBehavior;if(n==="double_opt_in")return"Unsubscribed contacts: confirm by email to resubscribe (double_opt_in)";if(n==="reactivate")return"Unsubscribed contacts: resubscribed on submit (reactivate)";return null}var V$=new Set(["open_rate","click_rate"]);function M1e(e,t){if(typeof e!=="object"||e===null)throw new E(`${t} must be an object with a subject field`,400);let n=e;if(typeof n.subject!=="string"||n.subject.trim()==="")throw new E(`${t}.subject must be a non-empty string`,400);if(n.previewText!==void 0&&typeof n.previewText!=="string")throw new E(`${t}.previewText must be a string`,400);if(n.blocks!==void 0&&!Array.isArray(n.blocks))throw new E(`${t}.blocks must be an array`,400);return{subject:n.subject,...n.previewText!==void 0&&{previewText:n.previewText},...Array.isArray(n.blocks)&&{blocks:n.blocks}}}function U1e(e){if(Boolean(e.campaignId)===Boolean(e.automationNodeId))throw new E("Provide exactly one campaign ID or --automation-node",400);let t=Ut(e.testPercentage,"--test-percentage");if(t!==void 0&&(t<5||t>50))throw new E("--test-percentage must be an integer between 5 and 50",400);if(e.testType!==void 0&&e.testType!=="subject"&&e.testType!=="content")throw new E("--test-type must be subject or content",400);let n=Ut(e.winnerThreshold,"--winner-threshold");if(n!==void 0&&(n<10||n>1000))throw new E("--winner-threshold must be an integer between 10 and 1000",400);let r=Ut(e.durationMinutes,"--duration-minutes");if(r!==void 0&&(r<15||r>1440))throw new E("--duration-minutes must be an integer between 15 and 1440",400);if(e.winnerCriteria!==void 0&&!V$.has(e.winnerCriteria))throw new E("--winner-criteria must be open_rate or click_rate",400);let i=rt(e.variantsJson,e.variantsFile,"variants"),o;if(i!==void 0){if(!Array.isArray(i))throw new E("variants JSON must be an array",400);o=i.map((a,c)=>M1e(a,`variants[${c}]`))}if(e.automationNodeId&&(o?.length??0)===0)throw new E("Sequence A/B tests need at least one variant in addition to control variant A; provide --variants-json or --variants-file",400);return{...e.campaignId!==void 0&&{campaignId:e.campaignId},...e.automationNodeId!==void 0&&{automationNodeId:e.automationNodeId},...e.confirmLiveChange===!0&&{confirmLiveChange:!0},...e.name!==void 0&&{name:e.name},...t!==void 0&&{testPercentage:t},...r!==void 0&&{testDurationMinutes:r},...e.winnerCriteria!==void 0&&{winnerCriteria:e.winnerCriteria},...e.testType!==void 0&&{testType:e.testType},...n!==void 0&&{winnerThreshold:n},...o!==void 0&&{variants:o}}}function $1e(e){let t=Ut(e.testPercentage,"--test-percentage");if(t!==void 0&&(t<5||t>50))throw new E("--test-percentage must be an integer between 5 and 50",400);let n=Ut(e.durationMinutes,"--duration-minutes");if(n!==void 0&&(n<15||n>1440))throw new E("--duration-minutes must be an integer between 15 and 1440",400);if(e.winnerCriteria!==void 0&&!V$.has(e.winnerCriteria))throw new E("--winner-criteria must be open_rate or click_rate",400);if(e.testType!==void 0&&e.testType!=="subject"&&e.testType!=="content")throw new E("--test-type must be subject or content",400);let r=Ut(e.winnerThreshold,"--winner-threshold");if(r!==void 0&&(r<10||r>1000))throw new E("--winner-threshold must be an integer between 10 and 1000",400);let i={...e.cancelSampleUpdate===!0&&{cancelSampleUpdate:!0},...e.expectedUpdatedAt!==void 0&&{expectedUpdatedAt:e.expectedUpdatedAt},...e.name!==void 0&&{name:e.name},...t!==void 0&&{testPercentage:t},...n!==void 0&&{testDurationMinutes:n},...e.winnerCriteria!==void 0&&{winnerCriteria:e.winnerCriteria},...e.testType!==void 0&&{testType:e.testType},...r!==void 0&&{winnerThreshold:r},...e.autoSelectWinner!==void 0&&{autoSelectWinner:e.autoSelectWinner},...e.confirmLiveChange===!0&&{confirmLiveChange:!0}};if(Object.keys(i).every((o)=>o==="confirmLiveChange"||o==="expectedUpdatedAt"))throw new E("Provide at least one A/B test setting to update",400);return i}function q1e(e){if(!e.subject||e.subject.trim()==="")throw new E("--subject is required",400);let t=rt(e.blocksJson,e.blocksFile,"blocks");if(t!==void 0&&!Array.isArray(t))throw new E("blocks JSON must be an array",400);return{subject:e.subject,...e.previewText!==void 0&&{previewText:e.previewText},...t!==void 0&&{blocks:t},...e.confirmLiveChange===!0&&{confirmLiveChange:!0}}}function Q1e(e){let t=e.isWinner?" winner":"";return` - Variant ${e.label} [${e.id}]${t}`}function su(e){if(console.log(`${e.name??"A/B Test"} [${e.id}]`),console.log(`Status: ${e.status}`),console.log(`Winner criteria: ${e.winnerCriteria}`),e.automationNodeId){if(e.testType)console.log(`Test type: ${e.testType}`);if(e.autoSelectWinner===!1)console.log("Winner selection: manual (testing was resumed)");else if(e.winnerThreshold!==void 0)console.log(`Winner threshold: ${e.winnerThreshold} recipients`)}else{if(console.log(`Test audience: ${e.testPercentage}%`),console.log(`Test duration: ${e.testDurationMinutes} minutes from the original start`),e.testStartedAt)console.log(`Test started: ${pe(e.testStartedAt)}`);if(e.testEndsAt)console.log(`Winner selection: ${pe(e.testEndsAt)}`);if(e.progress)console.log(`Delivery: ${e.progress.campaignStatus}; ${e.progress.sent} sent; ${e.progress.remaining??"unknown"} remaining`),console.log(`Full audience: ${e.progress.audienceSize??"unknown"}; minimum sample: ${e.progress.minimumTestPercentage??"unknown"}%`);if(e.pendingSampleUpdate)console.log(`Sample change: ${e.testPercentage}% -> ${e.pendingSampleUpdate.testPercentage}% (${e.pendingSampleUpdate.error??"pending"})`)}if(console.log(`Updated: ${pe(e.updatedAt)}`),e.campaignId)console.log(`Campaign: ${e.campaignId}`);if(e.automationNodeId)console.log(`Automation node: ${e.automationNodeId}`);console.log(`Variants: ${e.variants.length}`);for(let t of e.variants)console.log(Q1e(t)),console.log(` Email: ${t.emailId}`),console.log(` Subject: ${t.subject||"(no subject)"}`),console.log(` Preview: ${t.previewText??"None"}`),console.log(` Blocks: ${t.blocks.length}`)}function Ny(e){return`${e.toFixed(1)}%`}function z1e(e){let t=e.period??(e.start&&e.end?`${e.start} - ${e.end}`:"all time");console.log(`A/B test stats (${t})`),console.log(`Sent: ${e.stats.sent.toLocaleString()}`),console.log(`Delivered: ${e.stats.delivered.toLocaleString()}`),console.log(`Opened: ${e.stats.opened.toLocaleString()} (${Ny(e.stats.openRate)})`),console.log(`Clicked: ${e.stats.clicked.toLocaleString()} (${Ny(e.stats.clickRate)})`),console.log(),console.log("Variants:");for(let n of e.variants){let r=n.isWinner?" winner":"";console.log(`- Variant ${n.label} [${n.id}]${r}`),console.log(` Subject: ${n.subject||"(no subject)"}`),console.log(` Sent ${n.stats.sent.toLocaleString()}, opened ${n.stats.opened.toLocaleString()} (${Ny(n.stats.openRate)}), clicked ${n.stats.clicked.toLocaleString()} (${Ny(n.stats.clickRate)})`)}}function j1e(e){return{variantId:e.variantId,...e.confirmLiveChange===!0&&{confirmLiveChange:!0}}}function H1e(e){return e.confirmLiveChange===!0?{confirmLiveChange:!0}:{}}function G1e(e,t){return e?.automationNodeId?`Selected winner ${t}; future contacts reaching this sequence step get it`:`Selected winner ${t}; remaining-audience delivery queued`}async function ga(e,t){if(!await le())L(ce()),process.exit(1);try{if(e==="list"){let i=new URLSearchParams;if(t.sequence)i.set("sequenceId",t.sequence);let o=await w("GET",`/api/v1/ab-tests${i.size>0?`?${i.toString()}`:""}`,void 0,t.company);if(t.json){T(o);return}console.log(`A/B tests (${o.abTests.length})`);for(let a of o.abTests)console.log(`- ${a.name??"A/B Test"} [${a.id}]`),console.log(` Status: ${a.status}`),console.log(` Variants: ${a.variants.length}`);return}if(e==="create"){let i=await w("POST","/api/v1/ab-tests",U1e(t),t.company);if(t.json){T(i);return}if(Nr(i),console.log("Created A/B test"),su(i.abTest),i.abTest.automationNodeId)console.log(ky);return}if(!t.id)throw new E("A/B test ID is required",400);if(e==="update"){let i=await w("PATCH",`/api/v1/ab-tests/${t.id}`,$1e(t),t.company);if(t.json){T(i);return}console.log(`Updated A/B test ${t.id}`),su(i.abTest);return}if(e==="add-variant"){let i=await w("POST",`/api/v1/ab-tests/${t.id}/variants`,q1e(t),t.company);if(t.json){T(i);return}Nr(i),console.log(`Added variant to A/B test ${t.id}`),su(i.abTest);return}if(e==="delete-variant"){if(!t.variantId)throw new E("Variant ID is required",400);if(!await Tn(`Delete variant ${t.variantId} from A/B test ${t.id}?`,t)){console.log("Aborted.");return}let i=t.confirmLiveChange===!0?"?confirmLiveChange=true":"",o=await w("DELETE",`/api/v1/ab-tests/${t.id}/variants/${t.variantId}${i}`,void 0,t.company);if(t.json){T(o);return}console.log(`Removed variant ${t.variantId}`),su(o.abTest);return}if(e==="delete"){if(!await Tn(`Delete A/B test ${t.id}?`,t)){console.log("Aborted.");return}let i=await w("DELETE",`/api/v1/ab-tests/${t.id}`,void 0,t.company);if(t.json){T(i);return}console.log(`Deleted A/B test: ${t.id}`);return}if(e==="get"){let i=await w("GET",`/api/v1/ab-tests/${t.id}`,void 0,t.company);if(t.json){T(i);return}su(i.abTest);return}if(e==="stats"){let i=new URLSearchParams;if(t.period)i.set("period",t.period);if(t.start)i.set("start",t.start);if(t.end)i.set("end",t.end);if(t.includeBots)i.set("includeMachineEngagement","true");let o=await w("GET",`/api/v1/ab-tests/${t.id}/stats${i.size>0?`?${i.toString()}`:""}`,void 0,t.company);if(t.json){T(o);return}z1e(o);return}if(e==="resume"){let i=await w("POST",`/api/v1/ab-tests/${t.id}/resume`,H1e(t),t.company);if(t.json){T(i);return}console.log("Testing resumed; contacts are split across variants until you select a winner"),su(i.abTest);return}if(e==="restart"){if(t.testType!==void 0&&t.testType!=="subject"&&t.testType!=="content")throw new E("--test-type must be subject or content",400);let i=t.testType,o;if(t.variantCount!==void 0)o=Number.parseInt(t.variantCount,10);let a;if(t.winnerThreshold!==void 0)a=Number.parseInt(t.winnerThreshold,10);if(o!==void 0&&(!Number.isInteger(o)||o<2||o>4))throw new E("--variant-count must be an integer from 2 to 4",400);if(a!==void 0&&(!Number.isInteger(a)||a<10||a>1000))throw new E("--winner-threshold must be an integer from 10 to 1000",400);let c=await w("POST",`/api/v1/ab-tests/${t.id}/restart`,{sourceVariantId:t.sourceVariant,testType:i,winnerThreshold:a,variantCount:o},t.company);if(t.json){T(c);return}console.log(`Started new A/B test: ${c.abTest.id}`),console.log(`Previous test: ${c.previousAbTestId}`),console.log(`Control variant: ${c.sourceVariantId}`),su(c.abTest);return}if(e==="select-winner"){if(!t.variantId)throw new E("Variant ID is required",400);let i=await w("POST",`/api/v1/ab-tests/${t.id}/select-winner`,j1e({variantId:t.variantId,confirmLiveChange:t.confirmLiveChange}),t.company);if(t.json){T(i);return}console.log(G1e(i.abTest,t.variantId)),su(i.abTest);return}if(!t.variantId)throw new E("Variant ID is required",400);let n=ec({html:t.html,htmlFile:t.htmlFile,blocksJson:t.blocksJson,blocksFile:t.blocksFile});if(t.subject===void 0&&t.previewText===void 0&&n.html===void 0&&n.blocks===void 0)throw new E("Provide at least one of: --subject, --preview-text, --html, --html-file, --blocks-json, --blocks-file",400);let r=await w("PATCH",`/api/v1/ab-tests/${t.id}/variants/${t.variantId}`,{subject:t.subject,previewText:t.previewText,html:n.html,blocks:n.blocks,...t.confirmLiveChange===!0&&{confirmLiveChange:!0}},t.company);if(t.json){T(r);return}Nr(r),console.log(`Updated variant ${r.variant.label}`),console.log(`ID: ${r.variant.id}`),console.log(`Email: ${r.variant.emailId}`),console.log(`Subject: ${r.variant.subject}`)}catch(n){L(n instanceof E?n:n),process.exit(1)}}var W$;function re(e,t,n){function r(c,u){if(!c._zod)Object.defineProperty(c,"_zod",{value:{def:u,constr:a,traits:new Set},enumerable:!1});if(c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);let p=a.prototype,g=Object.keys(p);for(let x=0;x<g.length;x++){let h=g[x];if(!(h in c))c[h]=p[h].bind(c)}}let i=n?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function a(c){var u;let p=n?.Parent?new o:this;r(p,c),(u=p._zod).deferred??(u.deferred=[]);for(let g of p._zod.deferred)g();return p}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:(c)=>{if(n?.Parent&&c instanceof n.Parent)return!0;return c?._zod?.traits?.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}var Gat=Symbol("zod_brand");class tc extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class P0 extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(W$=globalThis).__zod_globalConfig??(W$.__zod_globalConfig={});var Tm=globalThis.__zod_globalConfig;function xs(e){if(e)Object.assign(Tm,e);return Tm}function Oy(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function O0(e,t){if(typeof t==="bigint")return t.toString();return t}function L0(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw Error("cached value already set")}}}function Ly(e){return e===null||e===void 0}function My(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function J$(e,t){let n=e/t,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<i)return 0;return n-r}var K$=Symbol("evaluating");function Bn(e,t,n){let r=void 0;Object.defineProperty(e,t,{get(){if(r===K$)return;if(r===void 0)r=K$,r=n();return r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Rd(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function lu(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function aD(e){return JSON.stringify(e)}function Y$(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var sD="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function km(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Z$=L0(()=>{if(Tm.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Fd(e){if(km(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(km(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function lD(e){if(Fd(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var X$=new Set(["string","number","symbol"]);function cu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ml(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function At(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function eq(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var tq={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function V1e(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let o=lu(e._zod.def,{get shape(){let a={};for(let c in t){if(!(c in n.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;a[c]=n.shape[c]}return Rd(this,"shape",a),a},checks:[]});return ml(e,o)}function W1e(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let o=lu(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let c in t){if(!(c in n.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;delete a[c]}return Rd(this,"shape",a),a},checks:[]});return ml(e,o)}function K1e(e,t){if(!Fd(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let o=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(o,a)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=lu(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Rd(this,"shape",o),o}});return ml(e,i)}function J1e(e,t){if(!Fd(t))throw Error("Invalid input to safeExtend: expected a plain object");let n=lu(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return Rd(this,"shape",r),r}});return ml(e,n)}function Y1e(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n=lu(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Rd(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ml(e,n)}function Z1e(e,t,n){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let a=lu(t._zod.def,{get shape(){let c=t._zod.def.shape,u={...c};if(n)for(let p in n){if(!(p in c))throw Error(`Unrecognized key: "${p}"`);if(!n[p])continue;u[p]=e?new e({type:"optional",innerType:c[p]}):c[p]}else for(let p in c)u[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return Rd(this,"shape",u),u},checks:[]});return ml(t,a)}function X1e(e,t,n){let r=lu(t._zod.def,{get shape(){let i=t._zod.def.shape,o={...i};if(n)for(let a in n){if(!(a in o))throw Error(`Unrecognized key: "${a}"`);if(!n[a])continue;o[a]=new e({type:"nonoptional",innerType:i[a]})}else for(let a in i)o[a]=new e({type:"nonoptional",innerType:i[a]});return Rd(this,"shape",o),o}});return ml(t,r)}function Nd(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function nq(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function uu(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Py(e){return typeof e==="string"?e:e?.message}function Es(e,t,n){let r=e.message?e.message:Py(e.inst?._zod.def?.error?.(e))??Py(t?.error?.(e))??Py(n.customError?.(e))??Py(n.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:a,...c}=e;if(c.path??(c.path=[]),c.message=r,t?.reportInput)c.input=a;return c}function Uy(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Pd(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}var rq=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,O0,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$y=re("$ZodError",rq),cD=re("$ZodError",rq,{Parent:Error});function iq(e,t=(n)=>n.message){let n={},r=[];for(let i of e.issues)if(i.path.length>0)n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i));else r.push(t(i));return{formErrors:r,fieldErrors:n}}function oq(e,t=(n)=>n.message){let n={_errors:[]},r=(i,o=[])=>{for(let a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((c)=>r({issues:c},[...o,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...o,...a.path]);else{let c=[...o,...a.path];if(c.length===0)n._errors.push(t(a));else{let u=n,p=0;while(p<c.length){let g=c[p];if(p!==c.length-1)u[g]=u[g]||{_errors:[]};else u[g]=u[g]||{_errors:[]},u[g]._errors.push(t(a));u=u[g],p++}}}};return r(e),n}var qy=(e)=>(t,n,r,i)=>{let o=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new tc;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Es(u,o,xs())));throw sD(c,i?.callee),c}return a.value};var Qy=(e)=>async(t,n,r,i)=>{let o=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Es(u,o,xs())));throw sD(c,i?.callee),c}return a.value};var M0=(e)=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new tc;return o.issues.length?{success:!1,error:new(e??$y)(o.issues.map((a)=>Es(a,i,xs())))}:{success:!0,data:o.value}},aq=M0(cD),U0=(e)=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)o=await o;return o.issues.length?{success:!1,error:new e(o.issues.map((a)=>Es(a,i,xs())))}:{success:!0,data:o.value}},sq=U0(cD),lq=(e)=>(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return qy(e)(t,n,i)};var cq=(e)=>(t,n,r)=>qy(e)(t,n,r);var uq=(e)=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return Qy(e)(t,n,i)};var dq=(e)=>async(t,n,r)=>Qy(e)(t,n,r);var pq=(e)=>(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return M0(e)(t,n,i)};var mq=(e)=>(t,n,r)=>M0(e)(t,n,r);var fq=(e)=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return U0(e)(t,n,i)};var gq=(e)=>async(t,n,r)=>U0(e)(t,n,r);var Aq=/^[cC][0-9a-z]{6,}$/,xq=/^[0-9a-z]+$/,Eq=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hq=/^[0-9a-vA-V]{20}$/,yq=/^[A-Za-z0-9]{27}$/,bq=/^[a-zA-Z0-9_-]{21}$/,Cq=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Sq=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uD=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Bq=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var t2e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function vq(){return new RegExp(t2e,"u")}var _q=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Iq=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Dq=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,wq=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Tq=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dD=/^[A-Za-z0-9_-]*$/;var kq=/^https?$/,Rq=/^\+[1-9]\d{6,14}$/,Fq="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Nq=new RegExp(`^${Fq}$`);function Pq(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Oq(e){return new RegExp(`^${Pq(e)}$`)}function Lq(e){let t=Pq({precision:e.precision}),n=["Z"];if(e.local)n.push("");if(e.offset)n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Fq}T(?:${r})$`)}var Mq=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Uq=/^-?\d+$/,pD=/^-?\d+(?:\.\d+)?$/,$q=/^(?:true|false)$/i;var qq=/^[^A-Z]*$/,Qq=/^[^a-z]*$/;var Ji=re("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),zq={number:"number",bigint:"bigint",object:"date"},mD=re("$ZodCheckLessThan",(e,t)=>{Ji.init(e,t);let n=zq[typeof t.value];e._zod.onattach.push((r)=>{let i=r._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<o)if(t.inclusive)i.maximum=t.value;else i.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fD=re("$ZodCheckGreaterThan",(e,t)=>{Ji.init(e,t);let n=zq[typeof t.value];e._zod.onattach.push((r)=>{let i=r._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>o)if(t.inclusive)i.minimum=t.value;else i.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),jq=re("$ZodCheckMultipleOf",(e,t)=>{Ji.init(e,t),e._zod.onattach.push((n)=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?n.value%t.value===BigInt(0):J$(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Hq=re("$ZodCheckNumberFormat",(e,t)=>{Ji.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[i,o]=tq[t.format];e._zod.onattach.push((a)=>{let c=a._zod.bag;if(c.format=t.format,c.minimum=i,c.maximum=o,n)c.pattern=Uq}),e._zod.check=(a)=>{let c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(c<i)a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort});if(c>o)a.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var Gq=re("$ZodCheckMaxLength",(e,t)=>{var n;Ji.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let i=r.value;return!Ly(i)&&i.length!==void 0}),e._zod.onattach.push((r)=>{let i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<i)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let i=r.value;if(i.length<=t.maximum)return;let a=Uy(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Vq=re("$ZodCheckMinLength",(e,t)=>{var n;Ji.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let i=r.value;return!Ly(i)&&i.length!==void 0}),e._zod.onattach.push((r)=>{let i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>i)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let i=r.value;if(i.length>=t.minimum)return;let a=Uy(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Wq=re("$ZodCheckLengthEquals",(e,t)=>{var n;Ji.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let i=r.value;return!Ly(i)&&i.length!==void 0}),e._zod.onattach.push((r)=>{let i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=(r)=>{let i=r.value,o=i.length;if(o===t.length)return;let a=Uy(i),c=o>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),$0=re("$ZodCheckStringFormat",(e,t)=>{var n,r;if(Ji.init(e,t),e._zod.onattach.push((i)=>{let o=i._zod.bag;if(o.format=t.format,t.pattern)o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern)}),t.pattern)(n=e._zod).check??(n.check=(i)=>{if(t.pattern.lastIndex=0,t.pattern.test(i.value))return;i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),Kq=re("$ZodCheckRegex",(e,t)=>{$0.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Jq=re("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=qq),$0.init(e,t)}),Yq=re("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Qq),$0.init(e,t)}),Zq=re("$ZodCheckIncludes",(e,t)=>{Ji.init(e,t);let n=cu(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push((i)=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=(i)=>{if(i.value.includes(t.includes,t.position))return;i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Xq=re("$ZodCheckStartsWith",(e,t)=>{Ji.init(e,t);let n=new RegExp(`^${cu(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((r)=>{let i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),eQ=re("$ZodCheckEndsWith",(e,t)=>{Ji.init(e,t);let n=new RegExp(`.*${cu(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((r)=>{let i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var tQ=re("$ZodCheckOverwrite",(e,t)=>{Ji.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class gD{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
265
265
|
`).filter((o)=>o),r=Math.min(...n.map((o)=>o.length-o.trimStart().length)),i=n.map((o)=>o.slice(r)).map((o)=>" ".repeat(this.indent*2)+o);for(let o of i)this.content.push(o)}compile(){let e=Function,t=this?.args,r=[...(this?.content??[""]).map((i)=>` ${i}`)];return new e(...t,r.join(`
|