croct 0.16.2 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +2 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2435,7 +2435,7 @@ ${i}`}static hasKeyword(e){let r=e.toLowerCase();return t.INCLUDE_KEYWORDS.some(
2435
2435
  ${r}
2436
2436
  [Window]::SetForegroundWindow(${i})
2437
2437
  [Window]::ShowWindow(${i}, 9)
2438
- `;this.runCommand({name:"powershell",arguments:["-Command",`& {${s}}`]});}}runCommand(e){let{commandExecutor:r,timeout:n}=this.configuration;try{let i=r.runSync(e,{timeout:n});return i.exitCode!==0?null:i.output.trim()}catch{return null}}};var TP=class{constructor(e){this.detector=e.detector,this.templates=e.templates;}async generate(e){let r=await this.detector.detect(e.recipient);return r===null||this.templates[r]===void 0?null:this.templates[r].generate(e)}};var DP=class{constructor(...e){this.detectors=e;}async detect(e){for(let r of this.detectors){let n=await r.detect(e);if(n!==null)return n}return null}};var PP=class t{static{this.DEFAULT_DOMAINS={google:["gmail.com","googlemail.com","google.com"],yahoo:[/yahoo\.com(?:\.\w+)?/,"yahoo.co.uk","yahoo.fr","yahoo.it","ymail.com","rocketmail.com"],microsoft:["outlook.com","live.com","hotmail.com","msn.com","passport.com","passport.net"],proton:["proton.me","protonmail.com"],icloud:["icloud.com"]};}constructor(e=t.DEFAULT_DOMAINS){this.domains=e;}detect(e){let r=e.toLowerCase().split("@")[1];for(let[n,i]of Object.entries(this.domains))if(i.some(o=>typeof o=="string"?o===r:o.test(r)))return Promise.resolve(n);return Promise.resolve(null)}};var CP=class t{static{this.DEFAULT_DOMAINS={google:["google.com"],microsoft:["outlook.com"]};}constructor(e=t.DEFAULT_DOMAINS){this.domains=e;}async detect(e){let r=e.toLowerCase().split("@")[1],n=await this.lookup(r);for(let[i,s]of Object.entries(this.domains))for(let o of s)for(let a of n)if(a.endsWith(`.${o}.`))return i;return null}async lookup(e){let r=new URL("https://dns.google.com/resolve");r.searchParams.set("type","MX"),r.searchParams.set("name",e);let n;try{n=await fetch(r).then(i=>{if(!i.ok)throw new Error("Failed to lookup domain");return i.json()});}catch{return []}return n.Answer===void 0?[]:n.Answer.map(i=>i.data)}};var $m=me(Mu()),wP=class t{generate(e){return new URL(`https://mail.google.com/mail${t.formatFilters(e)}`)}static formatFilters(e){let r=[`to:${e.recipient}`],n=`/u/${e.recipient}`;if(e.sender!==void 0&&r.push(`from:${e.sender}`),e.subject!==void 0&&r.push(`subject:${e.subject}`),e.timestamp!==void 0){let i=$m.TimeZone.of(Intl.DateTimeFormat().resolvedOptions().timeZone),s=$m.Instant.ofEpochSecond(e.timestamp),o=$m.LocalDateTime.ofInstant(s,i).getLocalDate();r.push(`after:${o}`);}return r.push("in:anywhere"),n+=`/#search/${r.map(i=>encodeURIComponent(i)).join("+")}`,n}};var AP=class{generate(e){return new URL("https://www.icloud.com/mail")}};var IP=class{generate(e){let r=new URL("https://outlook.live.com/mail");return e.recipient!==void 0&&r.searchParams.append("login_hint",e.recipient),r}};var OP=class t{generate(e){return new URL(`https://mail.proton.me/u/0/all-mail${t.formatFilters(e)}`)}static formatFilters(e){let r=new URLSearchParams;return r.set("to",e.recipient),e.sender!==void 0&&r.set("from",e.sender),e.timestamp!==void 0&&r.set("begin",e.timestamp.toFixed(0)),e.subject!==void 0&&r.set("keyword",e.subject),`#${r.toString()}`}};var _P=class t{generate(e){return new URL(`https://mail.yahoo.com/d/search${t.formatFilters(e)}`)}static formatFilters(e){let r=[`to:${e.recipient}`];return e.sender!==void 0&&r.push(`from:${e.sender}`),e.subject!==void 0&&r.push(`subject:${e.subject}`),e.timestamp!==void 0&&r.push(`after:"${new Date(e.timestamp*1e3).toISOString().split("T")[0]}"`),r.length===0?"":`/keyword=${r.join(" ")}`}};var fb=class{constructor(e){this.config=e;}async execute(e){let{fileSystem:r,io:n}=this.config,i=await this.createTemplate(e.empty??false),s=e.file??r.joinPaths(".","template.json5");try{let o=!1;await r.exists(s)&&(o=await n.input?.confirm({message:`Overwrite existing file at \`${s}\`?`,default:!1})??!1),await r.writeTextFile(s,JSON.stringify(i,null,2),{overwrite:o});}catch(o){throw new V("Failed to write template file",{reason:"other",cause:o})}n.output.confirm(`Template created at \`${s}\``);}async createTemplate(e){return {$schema:"https://schema.croct.com/json/v1/template.json",title:"My template",description:"My template description",actions:e?[{name:"print",semantics:"info",title:"Empty template",message:"Edit this template to define your actions."}]:[{name:"create-resource",resources:await this.exportResources()}]}}async exportResources(){let{configurationManager:e,templateForm:r}=this.config,n=await e.load(),i=await r.handle({organizationSlug:n.organization,workspaceSlug:n.workspace}),s={audiences:Object.fromEntries(i.audiences.map(o=>[o.slug,{name:o.name,criteria:o.criteria}])),components:Object.fromEntries(i.components.map(o=>[o.slug,{name:o.name,description:o.description,schema:o.definition}])),slots:Object.fromEntries(i.slots.map(o=>[o.slug,{name:o.name,component:o.component?.slug??"",content:o.content}])),experiences:i.experiences.map(o=>{let{experiment:a}=o,l=a!==void 0?{name:a.name??"",goalId:a.goalId,crossDevice:a.crossDevice,traffic:a.traffic??1,variants:a.variants.map(u=>({name:u.name??"",content:u.content,baseline:u.baseline,allocation:u.allocation??1e3/a.variants.length}))}:void 0;return {name:o.name,draft:o.status==="DRAFT",audiences:o.audiences,slots:o.slots,content:o.content,...l!==void 0?{experiment:l}:{}}})};for(let[o,a]of Object.entries(s))typeof a=="object"&&a!==null&&(Array.isArray(a)&&a.length===0||Object.keys(a).length===0)&&delete s[o];return s}};var kP=class{constructor(e){this.config=e;}async handle(e){let{input:r,form:n}=this.config,i={components:[],slots:[],audiences:[],experiences:[]},s=new Set,o=new Set,a=await n.experience.handle({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug,confirmation:"Do you want to include experiences?"});if(a.length>0){for(let u of a.flatMap(c=>c.audiences))s.add(u);for(let u of a.flatMap(c=>c.slots))o.add(u);i.experiences=a,a.some(u=>u.experiment!==void 0)&&(await r.confirm({message:"Include experiments?",default:false})||(i.experiences=i.experiences.map(u=>{let{experiment:c,...p}=u;return p})));}i.slots=await n.slot.handle({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug,selected:[...o],selectionConfirmation:{message:o.size>0?"Do you want to include other slots?":"Do you want to include slots?",default:false}});let l=new Set(i.slots.map(u=>u.component?.slug??""));return i.components=await n.component.handle({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug,includeDependencies:true,selected:[...l],selectionConfirmation:{message:l.size>0?"Do you want to include other components?":"Do you want to include components?",default:false}}),i.audiences=await n.audience.handle({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug,selected:[...s],selectionConfirmation:{message:s.size>0?"Do you want to include other audiences?":"Do you want to include audiences?",default:false}}),i}};var NP=class{constructor(e){this.config=e;}async handle(e){let{output:r,input:n,workspaceApi:i}=this.config,s=r.notify("Loading experiences"),o=await i.getExperiences({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug});s.stop();let{confirmation:a}=e;if(o.length===0||a!==void 0&&!await n.confirm({message:a}))return [];let l=await n.selectMultiple({message:"Select experiences",options:o.map(c=>({value:c,label:c.name}))});s=r.notify("Loading details");let u=await Promise.all(l.flatMap(async({id:c})=>{let p=await i.getExperience({experienceId:c,organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug});return p===null?[]:[p]}));return s.stop(),u.flat()}};var FP=class{constructor(e){this.config=e;}async handle(e){let{output:r,input:n}=this.config,i=r.notify("Loading audiences"),s=await this.getAudiences(e,e.allowed);i.stop();let o=e.preselected??[];if(o.length>0)return s.filter(({slug:l})=>o.includes(l));let a=e.selected??[];return s.length===0||a.length>0&&s.every(({slug:l})=>a.includes(l))?s.filter(({slug:l})=>a.includes(l)):e.selectionConfirmation!==void 0&&!await n.confirm(e.selectionConfirmation)?s.filter(({slug:u})=>a.includes(u)):n.selectMultiple({message:"Select audiences",options:s.map(l=>{let u=a.includes(l.slug);return {value:l,label:l.name,disabled:u,selected:u}})})}async getAudiences(e,r){let{workspaceApi:n}=this.config,i=await n.getAudiences({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug});return r===void 0?i:i.filter(({slug:s})=>r.includes(s))}};var De=class t extends V{constructor(e,{tracing:r,...n}={}){super(e,n),this.tracing=r??[],Object.setPrototypeOf(this,t.prototype);}static fromCause(e,r={}){let{message:n,...i}=r;if(!(e instanceof Error))return new t(n??V.formatMessage(e),{...i,cause:e});let s=new t(n??e.message,{cause:e,...e instanceof V?e.help:{},...i,tracing:[...i.tracing??[],...e instanceof t?e.tracing:[]]});return s.stack=e.stack,s}};var Um=class{constructor(e){this.variables={};this.input=e.input,this.output=e.output,this.baseUrl=e.baseUrl;}getVariables(){return structuredClone(this.variables)}set(e,r){this.variables[e]=r;}};var RP=class{constructor(e){this.config=e;}async getOptions(e){let{templateProvider:r}=this.config;return (await r.get(await this.resolveUrl(e))).value.options??{}}async execute(e){let{action:r,io:n}=this.config,{template:i,options:s}=e,o=await this.resolveUrl(i);return r.execute({template:o.toString(),options:s},new Um({input:n.input,output:n.output,baseUrl:o}))}async resolveUrl(e){let{fileSystem:r}=this.config,n=e;if(URL.canParse(e)){let i=new URL(e.replace(/(?<=^[a-z]+:\/*)([^/.:]+)/i,s=>s.replace(/@/g,"%40")));if(i.protocol!=="file:")return i;n=r.normalizeSeparators(i.pathname);}try{return new URL(`file://${await r.getRealPath(n)}`)}catch(i){throw new De(`Template file not found at \`${n}\`.`,{reason:"invalid_input",cause:i,suggestions:["Check the file path and try again."]})}}};var $3=(t,e,r)=>{let n=t instanceof RegExp?hse(t,r):t,i=e instanceof RegExp?hse(e,r):e,s=n!==null&&i!=null&&xat(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},hse=(t,e)=>{let r=e.match(t);return r?r[0]:null},xat=(t,e,r)=>{let n,i,s,o,a,l=r.indexOf(t),u=r.indexOf(e,l+1),c=l;if(l>=0&&u>0){if(t===e)return [l,u];for(n=[],s=r.length;c>=0&&!a;){if(c===l)n.push(c),l=r.indexOf(t,c+1);else if(n.length===1){let p=n.pop();p!==void 0&&(a=[p,u]);}else i=n.pop(),i!==void 0&&i<s&&(s=i,o=u),u=r.indexOf(e,c+1);c=l<u&&l>=0?l:u;}n.length&&o!==void 0&&(a=[s,o]);}return a};var yse="\0SLASH"+Math.random()+"\0",gse="\0OPEN"+Math.random()+"\0",q3="\0CLOSE"+Math.random()+"\0",bse="\0COMMA"+Math.random()+"\0",Sse="\0PERIOD"+Math.random()+"\0",Tat=new RegExp(yse,"g"),Dat=new RegExp(gse,"g"),Pat=new RegExp(q3,"g"),Cat=new RegExp(bse,"g"),wat=new RegExp(Sse,"g"),Aat=/\\\\/g,Iat=/\\{/g,Oat=/\\}/g,_at=/\\,/g,kat=/\\\./g,Nat=1e5;function U3(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function Fat(t){return t.replace(Aat,yse).replace(Iat,gse).replace(Oat,q3).replace(_at,bse).replace(kat,Sse)}function Rat(t){return t.replace(Tat,"\\").replace(Dat,"{").replace(Pat,"}").replace(Cat,",").replace(wat,".")}function Ese(t){if(!t)return [""];let e=[],r=$3("{","}",t);if(!r)return t.split(",");let{pre:n,body:i,post:s}=r,o=n.split(",");o[o.length-1]+="{"+i+"}";let a=Ese(s);return s.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),e.push.apply(e,o),e}function vse(t,e={}){if(!t)return [];let{max:r=Nat}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),mb(Fat(t),r,true).map(Rat)}function Mat(t){return "{"+t+"}"}function Lat(t){return /^-?0\d/.test(t)}function jat(t,e){return t<=e}function Bat(t,e){return t>=e}function mb(t,e,r){let n=[],i=$3("{","}",t);if(!i)return [t];let s=i.pre,o=i.post.length?mb(i.post,e,false):[""];if(/\$$/.test(i.pre))for(let a=0;a<o.length&&a<e;a++){let l=s+"{"+i.body+"}"+o[a];n.push(l);}else {let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),u=a||l,c=i.body.indexOf(",")>=0;if(!u&&!c)return i.post.match(/,(?!,).*\}/)?(t=i.pre+"{"+i.body+q3+i.post,mb(t,e,true)):[t];let p;if(u)p=i.body.split(/\.\./);else if(p=Ese(i.body),p.length===1&&p[0]!==void 0&&(p=mb(p[0],e,false).map(Mat),p.length===1))return o.map(f=>i.pre+p[0]+f);let d;if(u&&p[0]!==void 0&&p[1]!==void 0){let f=U3(p[0]),h=U3(p[1]),m=Math.max(p[0].length,p[1].length),y=p.length===3&&p[2]!==void 0?Math.max(Math.abs(U3(p[2])),1):1,b=jat;h<f&&(y*=-1,b=Bat);let T=p.some(Lat);d=[];for(let D=f;b(D,h)&&d.length<e;D+=y){let C;if(l)C=String.fromCharCode(D),C==="\\"&&(C="");else if(C=String(D),T){let L=m-C.length;if(L>0){let R=new Array(L+1).join("0");D<0?C="-"+R+C.slice(1):C=R+C;}}d.push(C);}}else {d=[];for(let f=0;f<p.length;f++)d.push.apply(d,mb(p[f],e,false));}for(let f=0;f<d.length;f++)for(let h=0;h<o.length&&n.length<e;h++){let m=s+d[f]+o[h];(!r||u||m)&&n.push(m);}}return n}var hb=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var $at={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",true],"[:alpha:]":["\\p{L}\\p{Nl}",true],"[:ascii:]":["\\x00-\\x7f",false],"[:blank:]":["\\p{Zs}\\t",true],"[:cntrl:]":["\\p{Cc}",true],"[:digit:]":["\\p{Nd}",true],"[:graph:]":["\\p{Z}\\p{C}",true,true],"[:lower:]":["\\p{Ll}",true],"[:print:]":["\\p{C}",true],"[:punct:]":["\\p{P}",true],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",true],"[:upper:]":["\\p{Lu}",true],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",true],"[:xdigit:]":["A-Fa-f0-9",false]},yb=t=>t.replace(/[[\]\\-]/g,"\\$&"),Uat=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),xse=t=>t.join(""),Tse=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=false,a=false,l=false,u=false,c=r,p="";e:for(;s<t.length;){let m=t.charAt(s);if((m==="!"||m==="^")&&s===r+1){u=true,s++;continue}if(m==="]"&&o&&!l){c=s+1;break}if(o=true,m==="\\"&&!l){l=true,s++;continue}if(m==="["&&!l){for(let[y,[b,v,T]]of Object.entries($at))if(t.startsWith(y,s)){if(p)return ["$.",false,t.length-r,true];s+=y.length,T?i.push(b):n.push(b),a=a||v;continue e}}if(l=false,p){m>p?n.push(yb(p)+"-"+yb(m)):m===p&&n.push(yb(m)),p="",s++;continue}if(t.startsWith("-]",s+1)){n.push(yb(m+"-")),s+=2;continue}if(t.startsWith("-",s+1)){p=m,s+=2;continue}n.push(yb(m)),s++;}if(c<s)return ["",false,0,false];if(!n.length&&!i.length)return ["$.",false,t.length-r,true];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let m=n[0].length===2?n[0].slice(-1):n[0];return [Uat(m),false,c-r,false]}let d="["+(u?"^":"")+xse(n)+"]",f="["+(u?"":"^")+xse(i)+"]";return [n.length&&i.length?"("+d+"|"+f+")":n.length?d:f,a,c-r,true]};var Ac=(t,{windowsPathsNoEscape:e=false,magicalBraces:r=true}={})=>r?e?t.replace(/\[([^/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?t.replace(/\[([^/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var Js,qat=new Set(["!","?","+","*","@"]),V3=t=>qat.has(t),Dse=t=>V3(t.type),Vat=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),zat=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Wat=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Pse=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Gat="(?!(?:^|/)\\.\\.?(?:$|/))",MP="(?!\\.)",Hat=new Set(["[","."]),Kat=new Set(["..","."]),Jat=new Set("().*{}+?[]^$\\!"),Yat=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z3="[^/]",Cse=z3+"*?",wse=z3+"+?",Xat=0,od=class{type;#i;#r;#t=false;#e=[];#n;#s;#o;#l=false;#a;#u;#c=false;id=++Xat;get depth(){return (this.#n?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return {"@@type":"AST",id:this.id,type:this.type,root:this.#i.id,parent:this.#n?.id,depth:this.depth,partsLength:this.#e.length,parts:this.#e}}constructor(e,r,n={}){this.type=e,e&&(this.#r=true),this.#n=r,this.#i=this.#n?this.#n.#i:this,this.#a=this.#i===this?n:this.#i.#a,this.#o=this.#i===this?[]:this.#i.#o,e==="!"&&!this.#i.#l&&this.#o.push(this),this.#s=this.#n?this.#n.#e.length:0;}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let e of this.#e)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#r=true;return this.#r}toString(){return this.#u!==void 0?this.#u:this.type?this.#u=this.type+"("+this.#e.map(e=>String(e)).join("|")+")":this.#u=this.#e.map(e=>String(e)).join("")}#g(){if(this!==this.#i)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=true;let e;for(;e=this.#o.pop();){if(e.type!=="!")continue;let r=e,n=r.#n;for(;n;){for(let i=r.#s+1;!n.type&&i<n.#e.length;i++)for(let s of e.#e){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#e[i]);}r=n,n=r.#n;}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof Js&&r.#n===this))throw new Error("invalid part: "+r);this.#e.push(r);}}toJSON(){let e=this.type===null?this.#e.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#e.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#i||this.#i.#l&&this.#n?.type==="!")&&e.push({}),e}isStart(){if(this.#i===this)return true;if(!this.#n?.isStart())return false;if(this.#s===0)return true;let e=this.#n;for(let r=0;r<this.#s;r++){let n=e.#e[r];if(!(n instanceof Js&&n.type==="!"))return false}return true}isEnd(){if(this.#i===this||this.#n?.type==="!")return true;if(!this.#n?.isEnd())return false;if(!this.type)return this.#n?.isEnd();let e=this.#n?this.#n.#e.length:0;return this.#s===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this));}clone(e){let r=new Js(this.type,e);for(let n of this.#e)r.copyIn(n);return r}static#p(e,r,n,i,s){let o=i.maxExtglobRecursion??2,a=false,l=false,u=-1,c=false;if(r.type===null){let m=n,y="";for(;m<e.length;){let b=e.charAt(m++);if(a||b==="\\"){a=!a,y+=b;continue}if(l){m===u+1?(b==="^"||b==="!")&&(c=true):b==="]"&&!(m===u+2&&c)&&(l=false),y+=b;continue}else if(b==="["){l=true,u=m,c=false,y+=b;continue}if(!i.noext&&V3(b)&&e.charAt(m)==="("&&s<=o){r.push(y),y="";let T=new Js(b,r);m=Js.#p(e,T,m,i,s+1),r.push(T);continue}y+=b;}return r.push(y),m}let p=n+1,d=new Js(null,r),f=[],h="";for(;p<e.length;){let m=e.charAt(p++);if(a||m==="\\"){a=!a,h+=m;continue}if(l){p===u+1?(m==="^"||m==="!")&&(c=true):m==="]"&&!(p===u+2&&c)&&(l=false),h+=m;continue}else if(m==="["){l=true,u=p,c=false,h+=m;continue}if(!i.noext&&V3(m)&&e.charAt(p)==="("&&(s<=o||r&&r.#d(m))){let b=r&&r.#d(m)?0:1;d.push(h),h="";let v=new Js(m,d);d.push(v),p=Js.#p(e,v,p,i,s+b);continue}if(m==="|"){d.push(h),h="",f.push(d),d=new Js(null,r);continue}if(m===")")return h===""&&r.#e.length===0&&(r.#c=true),d.push(h),h="",r.push(...f,d),p;h+=m;}return r.type=null,r.#r=void 0,r.#e=[e.substring(n-1)],p}#b(e){return this.#m(e,zat)}#m(e,r=Vat){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null)return false;let n=e.#e[0];return !n||typeof n!="object"||n.type===null?false:this.#d(n.type,r)}#d(e,r=Wat){return !!r.get(this.type)?.includes(e)}#S(e,r){let n=e.#e[0],i=new Js(null,n,this.options);i.#e.push(""),n.push(i),this.#h(e,r);}#h(e,r){let n=e.#e[0];this.#e.splice(r,1,...n.#e);for(let i of n.#e)typeof i=="object"&&(i.#n=this);this.#u=void 0;}#E(e){return !!Pse.get(this.type)?.has(e)}#v(e){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null||this.#e.length!==1)return false;let r=e.#e[0];return !r||typeof r!="object"||r.type===null?false:this.#E(r.type)}#x(e){let r=Pse.get(this.type),n=e.#e[0],i=r?.get(n.type);if(!i)return false;this.#e=n.#e;for(let s of this.#e)typeof s=="object"&&(s.#n=this);this.type=i,this.#u=void 0,this.#c=false;}static fromGlob(e,r={}){let n=new Js(null,void 0,r);return Js.#p(e,n,0,r,0),n}toMMPattern(){if(this!==this.#i)return this.#i.toMMPattern();let e=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#a}toRegExpSource(e){let r=e??!!this.#a.dot;if(this.#i===this&&(this.#f(),this.#g()),!Dse(this)){let l=this.isStart()&&this.isEnd()&&!this.#e.some(f=>typeof f!="string"),u=this.#e.map(f=>{let[h,m,y,b]=typeof f=="string"?Js.#T(f,this.#r,l):f.toRegExpSource(e);return this.#r=this.#r||y,this.#t=this.#t||b,h}).join(""),c="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Kat.has(this.#e[0]))){let h=Hat,m=r&&h.has(u.charAt(0))||u.startsWith("\\.")&&h.has(u.charAt(2))||u.startsWith("\\.\\.")&&h.has(u.charAt(4)),y=!r&&!e&&h.has(u.charAt(0));c=m?Gat:y?MP:"";}let p="";return this.isEnd()&&this.#i.#l&&this.#n?.type==="!"&&(p="(?:$|\\/)"),[c+u+p,Ac(u),this.#r=!!this.#r,this.#t]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#y(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let l=this.toString(),u=this;return u.#e=[l],u.type=null,u.#r=void 0,[l,Ac(this.toString()),false,false]}let o=!n||e||r||!MP?"":this.#y(true);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!r?MP:"")+wse;else {let l=this.type==="!"?"))"+(this.isStart()&&!r&&!e?MP:"")+Cse+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+l;}return [a,Ac(s),this.#r=!!this.#r,this.#t]}#f(){if(Dse(this)){let e=0,r=false;do{r=true;for(let n=0;n<this.#e.length;n++){let i=this.#e[n];typeof i=="object"&&(i.#f(),this.#m(i)?(r=false,this.#h(i,n)):this.#b(i)?(r=false,this.#S(i,n)):this.#v(i)&&(r=false,this.#x(i)));}}while(!r&&++e<10)}else for(let e of this.#e)typeof e=="object"&&e.#f();this.#u=void 0;}#y(e){return this.#e.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(e);return this.#t=this.#t||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#T(e,r,n=false){let i=false,s="",o=false,a=false;for(let l=0;l<e.length;l++){let u=e.charAt(l);if(i){i=false,s+=(Jat.has(u)?"\\":"")+u;continue}if(u==="*"){if(a)continue;a=true,s+=n&&/^[*]+$/.test(e)?wse:Cse,r=true;continue}else a=false;if(u==="\\"){l===e.length-1?s+="\\\\":i=true;continue}if(u==="["){let[c,p,d,f]=Tse(e,l);if(d){s+=c,o=o||p,l+=d-1,r=r||f;continue}}if(u==="?"){s+=z3,r=true;continue}s+=Yat(u);}return [s,Ac(e),!!r,o]}};Js=od;var W3=(t,{windowsPathsNoEscape:e=false,magicalBraces:r=false}={})=>r?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var Gi=(t,e,r={})=>(hb(e),!r.nocomment&&e.charAt(0)==="#"?false:new As(e,r).match(t)),Zat=/^\*+([^+@!?*[(]*)$/,Qat=t=>e=>!e.startsWith(".")&&e.endsWith(t),elt=t=>e=>e.endsWith(t),tlt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),rlt=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),nlt=/^\*+\.\*+$/,ilt=t=>!t.startsWith(".")&&t.includes("."),slt=t=>t!=="."&&t!==".."&&t.includes("."),olt=/^\.\*+$/,alt=t=>t!=="."&&t!==".."&&t.startsWith("."),llt=/^\*+$/,ult=t=>t.length!==0&&!t.startsWith("."),clt=t=>t.length!==0&&t!=="."&&t!=="..",plt=/^\?+([^+@!?*[(]*)?$/,dlt=([t,e=""])=>{let r=Ose([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},flt=([t,e=""])=>{let r=_se([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},mlt=([t,e=""])=>{let r=_se([t]);return e?n=>r(n)&&n.endsWith(e):r},hlt=([t,e=""])=>{let r=Ose([t]);return e?n=>r(n)&&n.endsWith(e):r},Ose=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},_se=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},kse=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ase={win32:{sep:"\\"},posix:{sep:"/"}},ylt=kse==="win32"?Ase.win32.sep:Ase.posix.sep;Gi.sep=ylt;var ss=Symbol("globstar **");Gi.GLOBSTAR=ss;var glt="[^/]",blt=glt+"*?",Slt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Elt="(?:(?!(?:\\/|^)\\.).)*?",vlt=(t,e={})=>r=>Gi(r,t,e);Gi.filter=vlt;var Qo=(t,e={})=>Object.assign({},t,e),xlt=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return Gi;let e=Gi;return Object.assign((n,i,s={})=>e(n,i,Qo(t,s)),{Minimatch:class extends e.Minimatch{constructor(i,s={}){super(i,Qo(t,s));}static defaults(i){return e.defaults(Qo(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,s,o={}){super(i,s,Qo(t,o));}static fromGlob(i,s={}){return e.AST.fromGlob(i,Qo(t,s))}},unescape:(n,i={})=>e.unescape(n,Qo(t,i)),escape:(n,i={})=>e.escape(n,Qo(t,i)),filter:(n,i={})=>e.filter(n,Qo(t,i)),defaults:n=>e.defaults(Qo(t,n)),makeRe:(n,i={})=>e.makeRe(n,Qo(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,Qo(t,i)),match:(n,i,s={})=>e.match(n,i,Qo(t,s)),sep:e.sep,GLOBSTAR:ss})};Gi.defaults=xlt;var Nse=(t,e={})=>(hb(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:vse(t,{max:e.braceExpandMax}));Gi.braceExpand=Nse;var Tlt=(t,e={})=>new As(t,e).makeRe();Gi.makeRe=Tlt;var Dlt=(t,e,r={})=>{let n=new As(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};Gi.match=Dlt;var Ise=/[?*]|[+@!]\(.*?\)|\[|\]/,Plt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),As=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,r={}){hb(e),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=e,this.platform=r.platform||kse,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!r.nonegate,this.comment=false,this.empty=false,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make();}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return true;for(let e of this.set)for(let r of e)if(typeof r!="string")return true;return false}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=s[0]===""&&s[1]===""&&(s[2]==="?"||!Ise.test(s[2]))&&!Ise.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(l)return [...s.slice(0,4),...s.slice(4).map(c=>this.parse(c))];if(u)return [s[0],...s.slice(1).map(c=>this.parse(c))]}return s.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(false)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?");}this.debug(this.pattern,this.set);}preprocess(e){if(this.options.noglobstar)for(let n of e)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n);}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=false;do{if(r=false,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(r=true,e.splice(i,1),i--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=true,e.pop());}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=true,e.splice(n-1,2),n-=2);}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=false;do{r=false;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],l=n[i+2],u=n[i+3];if(a!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;r=true,n.splice(i,1);let c=n.slice(0);c[i]="**",e.push(c),i--;}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=true,n.splice(o,1),o--);}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=true,n.pop());}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=true;let l=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...l),n.length===0&&n.push(""),s-=2;}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=false){let i=0,s=0,o=[],a="";for(;i<e.length&&s<r.length;)if(e[i]===r[s])o.push(a==="b"?r[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&r[s]===e[i+1])o.push(e[i]),i++;else if(n&&r[s]==="**"&&e[i]===r[s+1])o.push(r[s]),s++;else if(e[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return false;a="a",o.push(e[i]),i++,s++;}else if(r[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return false;a="b",o.push(r[s]),i++,s++;}else return false;return e.length===r.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=false,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r;}matchOne(e,r,n=false){let i=0,s=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),l=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),u=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),c=!u&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),p=l?3:a?0:void 0,d=c?3:u?0:void 0;if(typeof p=="number"&&typeof d=="number"){let[f,h]=[e[p],r[d]];f.toLowerCase()===h.toLowerCase()&&(r[d]=f,s=d,i=p);}}let{optimizationLevel:o=1}=this.options;return o>=2&&(e=this.levelTwoFileOptimize(e)),r.includes(ss)?this.#i(e,r,n,i,s):this.#t(e,r,n,i,s)}#i(e,r,n,i,s){let o=r.indexOf(ss,s),a=r.lastIndexOf(ss),[l,u,c]=n?[r.slice(s,o),r.slice(o+1),[]]:[r.slice(s,o),r.slice(o+1,a),r.slice(a+1)];if(l.length){let v=e.slice(i,i+l.length);if(!this.#t(v,l,n,0,0))return false;i+=l.length,s+=l.length;}let p=0;if(c.length){if(c.length+i>e.length)return false;let v=e.length-c.length;if(this.#t(e,c,n,v,0))p=c.length;else {if(e[e.length-1]!==""||i+c.length===e.length||(v--,!this.#t(e,c,n,v,0)))return false;p=c.length+1;}}if(!u.length){let v=!!p;for(let T=i;T<e.length-p;T++){let D=String(e[T]);if(v=true,D==="."||D===".."||!this.options.dot&&D.startsWith("."))return false}return n||v}let d=[[[],0]],f=d[0],h=0,m=[0];for(let v of u)v===ss?(m.push(h),f=[[],0],d.push(f)):(f[0].push(v),h++);let y=d.length-1,b=e.length-p;for(let v of d)v[1]=b-(m[y--]+v[0].length);return !!this.#r(e,d,i,0,n,0,!!p)}#r(e,r,n,i,s,o,a){let l=r[i];if(!l){for(let p=n;p<e.length;p++){a=true;let d=e[p];if(d==="."||d===".."||!this.options.dot&&d.startsWith("."))return false}return a}let[u,c]=l;for(;n<=c;){if(this.#t(e.slice(0,n+u.length),u,s,n,0)&&o<this.maxGlobstarRecursion){let f=this.#r(e,r,n+u.length,i+1,s,o+1,a);if(f!==false)return f}let d=e[n];if(d==="."||d===".."||!this.options.dot&&d.startsWith("."))return false;n++;}return s||null}#t(e,r,n,i,s){let o,a,l,u;for(o=i,a=s,u=e.length,l=r.length;o<u&&a<l;o++,a++){this.debug("matchOne loop");let c=r[a],p=e[o];if(this.debug(r,c,p),c===false||c===ss)return false;let d;if(typeof c=="string"?(d=p===c,this.debug("string match",c,p,d)):(d=c.test(p),this.debug("pattern match",c,p,d)),!d)return false}if(o===u&&a===l)return true;if(o===u)return n;if(a===l)return o===u-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return Nse(this.pattern,this.options)}parse(e){hb(e);let r=this.options;if(e==="**")return ss;if(e==="")return "";let n,i=null;(n=e.match(llt))?i=r.dot?clt:ult:(n=e.match(Zat))?i=(r.nocase?r.dot?rlt:tlt:r.dot?elt:Qat)(n[1]):(n=e.match(plt))?i=(r.nocase?r.dot?flt:dlt:r.dot?mlt:hlt)(n):(n=e.match(nlt))?i=r.dot?slt:ilt:(n=e.match(olt))&&(i=alt);let s=od.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let e=this.set;if(!e.length)return this.regexp=false,this.regexp;let r=this.options,n=r.noglobstar?blt:r.dot?Slt:Elt,i=new Set(r.nocase?["i"]:[]),s=e.map(l=>{let u=l.map(p=>{if(p instanceof RegExp)for(let d of p.flags.split(""))i.add(d);return typeof p=="string"?Plt(p):p===ss?ss:p._src});u.forEach((p,d)=>{let f=u[d+1],h=u[d-1];p!==ss||h===ss||(h===void 0?f!==void 0&&f!==ss?u[d+1]="(?:\\/|"+n+"\\/)?"+f:u[d]=n:f===void 0?u[d-1]=h+"(?:\\/|\\/"+n+")?":f!==ss&&(u[d-1]=h+"(?:\\/|\\/"+n+"\\/)"+f,u[d+1]=ss));});let c=u.filter(p=>p!==ss);if(this.partial&&c.length>=1){let p=[];for(let d=1;d<=c.length;d++)p.push(c.slice(0,d).join("/"));return "(?:"+p.join("|")+")"}return c.join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+a+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return false;if(this.empty)return e==="";if(e==="/"&&r)return true;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a of s){let l=i;if(n.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,r))return n.flipNegate?true:!this.negate}return n.flipNegate?false:this.negate}static defaults(e){return Gi.defaults(e).Minimatch}};Gi.AST=od;Gi.Minimatch=As;Gi.escape=W3;Gi.unescape=Ac;function ad(t,e){if(URL.canParse(t))return new URL(t);let r=new URL(e.href.replace(/^(.*:)(?!\/)/,"$1/"));return new URL(t,r)}var LP=class{constructor(e){this.config=e;}async execute(e,r){let{fileSystem:n}=this.config,{input:i}=r,s=ad(e.source,r.baseUrl);if(s.protocol==="file:"&&r.baseUrl.protocol!=="file:")throw new De("File URL is not allowed from remote sources for security reasons.",{reason:"precondition",details:[`Source URL: ${s}`]});let o=n.normalizeSeparators(e.destination),{output:a}=r,l=a?.notify("Downloading sources");try{await this.download(s,{...e,destination:o},i);}finally{l?.stop();}e.result?.destination!==void 0&&r.set(e.result.destination,o);}async download(e,r,n){let{provider:i,fileSystem:s,codemod:o}=this.config,{destination:a,overwrite:l=false}=r,u=r.filter!==void 0?new As(r.filter):void 0,{value:c}=await i.get(e),p=[],d=Object.fromEntries(Object.entries(r.mapping??{}).map(([f,h])=>[s.normalizeSeparators(f),s.normalizeSeparators(h)]));for await(let f of c){let h=this.resolvePath(s.normalizeSeparators(f.name),d);if(s.isAbsolutePath(h))throw new De("Path to downloaded file cannot be absolute.",{reason:"precondition",details:[`Path: ${h}`],suggestions:["Use relative paths"]});if(!(u!==void 0&&!u.match(h))){if(f.name=s.joinPaths(a,h),f.type==="link"||f.type==="symlink"){let m=s.normalizeSeparators(f.target);if(s.isAbsolutePath(m)||!s.isSubPath(a,m))continue;f.target=m;}p.push(f);}}if(p.length===0)throw new De("No matching files found for download.",{reason:"unexpected_result",details:[`Source: ${e}`,`Filter: ${r.filter??"none"}`]});await this.createDirectory(p,a,l,n);for(let f of p)await s.createDirectory(s.getDirectoryName(f.name),{recursive:true}),await s.create(f);for(let f of p)f.type==="file"&&await o.apply(await s.getRealPath(f.name));}resolvePath(e,r){if(e in r)return r[e];let{fileSystem:n}=this.config,i="",s=e,o=n.getSeparator();for(let[a,l]of Object.entries(r)){let u=a.endsWith(o)?a:a+o;e.startsWith(u)&&u.length>i.length&&(i=u,s=n.joinPaths(l,e.slice(u.length)));}return s}async createDirectory(e,r,n,i){let{fileSystem:s}=this.config;if(!await s.exists(r))return s.createDirectory(r,{recursive:true});if(e.length===1&&e[0].type==="file"){if(!n&&await s.exists(e[0].name)&&await i?.confirm({message:`File ${e[0].name} already exists. Do you want to overwrite it?`,default:false})!==true)throw new De("Destination file already exists.",{reason:"precondition",details:[`File: ${e[0].name}`],suggestions:["Delete the file"]});return}if(await s.isDirectory(r)){if(!n&&!await s.isEmptyDirectory(r)&&await i?.confirm({message:`Directory ${r} is not empty. Do you want to clear it?`,default:false})!==true)throw new De("Destination directory is not empty.",{reason:"precondition",details:[`Directory: ${r}`],suggestions:["Clear the directory"]})}else if(await i?.confirm({message:`Destination ${r} is not a directory. Do you want to delete it?`,default:false})!==true)throw new De("Destination is not a directory.",{reason:"precondition",details:[`Path: ${r}`],suggestions:["Delete the file"]});await s.delete(r,{recursive:true}),await s.createDirectory(r,{recursive:true});}};var jP=class{constructor({packageManager:e}){this.packageManager=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Installing dependencies");try{await this.packageManager.addDependencies(e.dependencies,{dev:e.development??!1,logger:new wi({status:"Installing dependencies",notifier:i})});}catch(s){throw De.fromCause(s)}finally{i?.stop();}}};var qm=class t{constructor(e){this.matcher=e;}static fromPattern(e){return new t(new As(e.replace(/^\.\//,"").replace(/\\/g,"/")))}test(e){return Promise.resolve(this.matcher.match(e))}};var BP=class{constructor({projectDirectory:e,fileSystem:r,scanFilter:n}){this.projectDirectory=e,this.fileSystem=r,this.scanFilter=n;}async execute(e,r){let{output:n}=r,i=n?.notify("Locating files");try{await this.findMatches(e,r);}finally{i?.stop();}}async findMatches(e,r){r.set(e.result,await this.findMatch(e.path,e));}async findMatch(e,r){let n=(o,a)=>r.depth!==void 0&&a>r.depth?false:this.scanFilter!==void 0?this.scanFilter(o,a):true,i=[],s=qm.fromPattern(e);for await(let o of this.fileSystem.list(this.projectDirectory.get(),n))if(await s.test(o.name)){if(r.matcher===void 0)i.push(o.name);else if(o.type==="file"){let a=await new Response(o.content).text();this.matches(a,r.matcher)&&i.push(o.name);}if(r.limit!==void 0&&i.length>=r.limit)break}return i}matches(e,r){if("pattern"in r)return new RegExp(r.pattern,r.caseSensitive===true?"i":void 0).test(e);switch(r.type){case "and":return r.matchers.every(n=>this.matches(e,n));case "or":return r.matchers.some(n=>this.matches(e,n))}}};var $P=class{constructor({fileSystem:e}){this.fileSystem=e;}async execute(e,r){let{output:n}=r,i=n.notify("Replacing file content");try{await this.replaceFiles(e);}finally{i.stop();}}async replaceFiles(e){let r=false;for(let{path:n,replacements:i}of e.files){let s=this.fileSystem.normalizeSeparators(n);if(await this.fileSystem.exists(s)){r=true;try{await this.fileSystem.writeTextFile(s,this.replaceContent(await this.fileSystem.readTextFile(s),i),{overwrite:!0});}catch(o){throw De.fromCause(o)}}}if(!r)throw new De("No files matched for content replacement.",{reason:"unexpected_result"})}replaceContent(e,r){let n=e;for(let{pattern:i,caseSensitive:s,value:o}of r){let a=s===true?"gi":"g";n=n.replace(new RegExp(i,a),`${o}`);}return n}};var UP=class{constructor({installer:e}){this.installer=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Installing slots");try{await this.installer(e.slots,e.example===!0);}catch(s){throw De.fromCause(s)}finally{i?.stop();}}};var qP=class{constructor({installer:e}){this.installer=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Installing components");try{await this.installer(e.components);}catch(s){throw De.fromCause(s)}finally{i?.stop();}}};var VP=class{constructor(e){this.runner=e;}async execute(e,r){try{await this.run(e.action,r);}catch(n){if(e.else===void 0)throw e.help===void 0?n:De.fromCause(n,{...e.help,reason:"precondition"});await this.run(e.else,r);}finally{e.finally!==void 0&&await this.run(e.finally,r);}}run(e,r){return this.runner.execute({actions:e},r)}};var Gn=class t extends V{constructor(e,r={}){super(e,r),Object.setPrototypeOf(this,t.prototype);}};var Ic=class{constructor(e){this.provider=e;}get action(){return Promise.resolve(this.provider.get()).catch(e=>{throw e instanceof Gn?new De(e.message,e.help):e})}async execute(e,r){return (await this.action).execute(e,r)}};var zP=class{constructor(e){this.manager=e;}isInitialized(e){return this.manager.isInitialized(e)}load(){return this.configuration===void 0&&(this.configuration=this.manager.load()),this.configuration}loadPartial(){return this.manager.loadPartial()}update(e){return this.configuration=this.manager.update(e),this.configuration}};var G3;(i=>{function t(s){let o=new Set(Object.values(s.slots??{}).map(p=>p.component)??[]),a=new Set(s.experiences?.flatMap(p=>p.slots)??[]),l=new Set(s.experiences?.flatMap(p=>p.audiences)??[]),u=(s.experiences??[]).map(p=>({name:p.name,maximumAudiencesPerExperience:p.audiences.length,crossDevice:p.experiment?.crossDevice===true,...e(p)})),c=new Set;for(let p of Object.values(s.slots??{}))for(let d of Object.keys(p.content))c.add(d);for(let p of u){for(let d of p.locales)c.add(d);for(let d of p.audiences)l.add(d);for(let d of p.slots)a.add(d);}return {components:o,slots:a,audiences:l,locales:c,experiences:u}}i.analyze=t;function e(s){let o=r(s.content);for(let a of s.experiment?.variants??[]){let l=r(a.content);l.audiences.forEach(u=>o.audiences.add(u)),l.slots.forEach(u=>o.slots.add(u));}return {...o}}function r(s){let o=new Set,a=new Set,l=0;for(let[p,d]of Object.entries(s.default??{})){o.add(p);for(let[f,h]of Object.entries(d))a.add(f),l=Math.max(l,n(h));}let u=new Set,c=0;for(let p of s.segmented??[]){for(let d of p.audiences)u.add(d);c=Math.max(c,p.audiences.length);for(let[d,f]of Object.entries(p.content)){o.add(d);for(let[h,m]of Object.entries(f))a.add(h),l=Math.max(l,n(m));}}return {slots:o,audiences:u,locales:a,audiencesPerExperience:c,dynamicContentPerContent:l}}function n(s){switch(s.type){case "boolean":case "text":case "number":return s.value.type==="dynamic"?1:0;case "structure":return Object.values(s.attributes).map(n).reduce((o,a)=>o+a,0);case "list":return s.items.map(n).reduce((o,a)=>o+a,0)}}})(G3||={});var WP=class{constructor(e){this.refactoring=e;}refactor(e){return {components:Object.fromEntries(Object.entries(e.components??{}).map(([r,n])=>[this.refactoring.componentMapping[r]??r,{...n,schema:this.refactorSchema(n.schema)}])),slots:Object.fromEntries(Object.entries(e.slots??{}).map(([r,n])=>[this.refactoring.slotMapping[r]??r,this.refactorSlotContent(n)])),audiences:Object.fromEntries(Object.entries(e.audiences??{}).map(([r,n])=>[this.refactoring.audienceMapping[r]??r,n])),experiences:e.experiences?.map(r=>this.refactorExperience(r))??[]}}refactorSchema(e){switch(e.type){case "boolean":case "text":case "number":return e;case "structure":return {...e,attributes:Object.fromEntries(Object.entries(e.attributes).map(([r,n])=>[r,{...n,type:this.refactorSchema(n.type)}]))};case "list":return {...e,items:this.refactorSchema(e.items)};case "union":return {...e,types:Object.fromEntries(Object.entries(e.types).map(([r,n])=>[r,this.refactorSchema(n)]))};case "reference":return {...e,id:this.refactoring.componentMapping[e.id]??e.id}}}refactorSlotContent(e){return {...e,component:this.refactoring.componentMapping[e.component]??e.component,content:this.refactorLocalizedContentMap(e.content)}}refactorExperience(e){let r=e.audiences.slice(0,this.refactoring.maximumAudiencePerExperience),{experiment:n}=e;return {...e,audiences:e.audiences.map(i=>this.refactoring.audienceMapping[i]??i),slots:e.slots.map(i=>this.refactoring.slotMapping[i]??i),experiment:n!==void 0?{...n,variants:n.variants.map(i=>({...i,content:this.refactorPersonalizedContent(i.content,r)})),crossDevice:(n.crossDevice??false)&&this.refactoring.isCrossDeviceFeatureEnabled}:void 0,content:this.refactorPersonalizedContent(e.content,r)}}refactorPersonalizedContent(e,r){return {default:this.refactorSlotContentMap(e.default??{}),segmented:(e.segmented??[]).flatMap(n=>{let i=n.audiences.filter(s=>r.includes(s));return i.length===0?[]:{audiences:i,content:this.refactorSlotContentMap(n.content)}})}}refactorSlotContentMap(e){return Object.fromEntries(Object.entries(e).map(([r,n])=>[this.refactoring.slotMapping[r]??r,this.refactorLocalizedContentMap(n)]))}refactorLocalizedContentMap(e){return Object.fromEntries(Object.entries(e).flatMap(([r,n])=>{let i=this.refactoring.localeMapping[r];return i===null||i!==void 0&&e[i]!==void 0?[]:[[i??r,this.refactorContent(n,{dynamicAttributesPerContent:this.refactoring.dynamicAttributesPerContent})]]}))}refactorContent(e,r){switch(e.type){case "boolean":case "text":case "number":return e.value.type==="dynamic"&&r.dynamicAttributesPerContent>0&&r.dynamicAttributesPerContent--,e.value.type==="static"||r.dynamicAttributesPerContent>0?e:{...e,value:{type:"static",value:e.value.default}};case "structure":return {...e,attributes:Object.fromEntries(Object.entries(e.attributes).map(([n,i])=>[n,this.refactorContent(i,r)]))};case "list":return {...e,items:e.items.map(n=>this.refactorContent(n,r))}}}};var GP=class t{constructor(e){this.config=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Analyzing resources"),s=G3.analyze(e.resources),{configurationManager:o,api:{workspace:a}}=this.config,l=await o.load(),u=await this.getProjectInfo(l);await this.checkMissingResources({...s,locales:new Set},e.resources,u);let c=await this.createPlan(e.resources,s,u);i?.update("Creating resources");let p=await a.createResources({organizationSlug:l.organization,workspaceSlug:l.workspace,...c.resources});if(i?.stop(),n!==void 0){let d=t.getWarnings(s,u.workspace);if(d.length>0)for(let f of d)n.warn(`${f}`);}e.result!==void 0&&t.setVariables(e.result,c,p,r);}async createPlan(e,r,n){let{mappingForm:i,matcher:s}=this.config,o=await s.match({resources:e,workspaceSlug:n.configuration.workspace,organizationSlug:n.configuration.organization}),a=Object.entries(o.audiences).filter(h=>!("id"in h[1])),l=Object.entries(o.components).filter(h=>!("id"in h[1])),u=Object.entries(o.slots).filter(h=>!("id"in h[1])),c=o.experiences.filter(h=>!("id"in h));await this.checkRequiredQuota(n,{components:l.length,slots:u.length,audiences:a.length,experiences:c.length});let p=await i.handle({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace,resources:{audiences:a.map(([h])=>h),components:l.map(([h])=>h),slots:u.map(([h])=>h)}}),d={},{workspace:f}=n;for(let h of r.locales)f.locales.includes(h)||(d[h]=f.defaultLocale);return {matches:o,mapping:p,resources:new WP({componentMapping:p.components,audienceMapping:p.audiences,slotMapping:p.slots,dynamicAttributesPerContent:f.quotas.dynamicAttributesPerContent,maximumAudiencePerExperience:f.quotas.audiencesPerExperience,isCrossDeviceFeatureEnabled:f.features.crossDevice,localeMapping:d}).refactor({components:Object.fromEntries(l),slots:Object.fromEntries(u),audiences:Object.fromEntries(a),experiences:c})}}async getProjectInfo(e){let{api:r}=this.config,[n,i]=await Promise.all([r.organization.getWorkspace({organizationSlug:e.organization,workspaceSlug:e.workspace}),r.workspace.getFeatures({organizationSlug:e.organization,workspaceSlug:e.workspace})]);if(n==null||i==null)throw new V("Workspace not found",{title:"Invalid configuration",reason:"invalid_configuration",details:["The workspace defined in the configuration does not exist"],suggestions:["Check the configuration file"]});return {configuration:e,workspace:{...n,...i}}}async checkRequiredQuota(e,r){let{api:{user:n}}=this.config;for(let[i,s]of Object.entries(r)){let o=t.getRemainingQuota(e.workspace,i);if(o<s){let a=await n.getUser().catch(()=>({email:void 0})),l=new URL("https://croct.com/contact/support");throw l.searchParams.set("subject","limit-increase"),l.searchParams.set("organization",e.configuration.organization),l.searchParams.set("message",`I need more quota for ${i}`),a.email!==void 0&&l.searchParams.set("email",a.email),new V(`Not enough ${i} quota available in your workspace.`,{title:"Insufficient quota",reason:"precondition",links:[{label:"Request more quota",url:l.toString()}],details:[`Available: ${o}`,`Required: ${s}`],suggestions:[`Free up quota by removing unused ${i}`,"Request additional quota from support"]})}}}async checkMissingResources(e,r,n){let i=await this.findMissingResources(e,r,n);for(let[s,o]of Object.entries(i))if(o.size>0)throw new V(`Some ${s} referenced in the template are missing`,{title:"Invalid template",reason:"invalid_input",details:[`Missing ${s}: ${Array.from(o).join(", ")}`],suggestions:["Report this issue to the template author"]})}async findMissingResources(e,r,n){let i=new Set(e.components),s=new Set(e.slots),o=new Set(e.audiences),a=new Set(e.locales);for(let u of Object.keys(r.components??{}))i.delete(u);for(let u of Object.keys(r.slots??{}))s.delete(u);for(let u of Object.keys(r.audiences??{}))o.delete(u);let{api:l}=this.config;return await Promise.all([...[...i].map(async u=>{await l.workspace.getComponent({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace,componentSlug:u})!==null&&i.delete(u);}),...[...s].map(async u=>{await l.workspace.getSlot({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace,slotSlug:u})!==null&&s.delete(u);}),...[...o].map(async u=>{await l.workspace.getAudience({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace,audienceSlug:u})!==null&&o.delete(u);}),(async()=>{if(a.size===0)return;let u=await l.organization.getWorkspace({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace});for(let c of u?.locales??[])a.delete(c);})()]),{components:i,slots:s,audiences:o,locales:a}}static getRemainingQuota(e,r){let n=r.charAt(0).toUpperCase()+r.slice(1);return e.quotas[`remaining${n}`]}static getWarnings(e,r){let n=[];return Math.max(...e.experiences.map(a=>a.dynamicContentPerContent))>r.quotas.dynamicAttributesPerContent&&n.push("Some dynamic values have been removed from the content to fit the workspace quota"),Math.max(...e.experiences.map(a=>a.audiencesPerExperience))>r.quotas.audiencesPerExperience&&n.push("Some audiences have been removed from the experiences to fit the workspace quota"),Array.from(e.locales).filter(a=>!r.locales.includes(a)).length>0&&n.push("Content in unsupported locales have been mapped to default or dropped"),!r.features.crossDevice&&e.experiences.some(a=>a.crossDevice)&&n.push("Cross-device experiments have been disabled "),n}static setVariables(e,r,n,i){if(e.audiences!==void 0)for(let[a]of Object.entries(r.matches.audiences??{}))e.audiences[a]!==void 0&&i.set(e.audiences[a],r.mapping.audiences[a]??a);if(e.components!==void 0)for(let[a]of Object.entries(r.matches.components??{})){let l=e.components[a];if(l!==void 0){let u=r.mapping.components[a]??a,c=r.matches.components[a]??{};l.id!==void 0&&i.set(l.id,u),l.version!==void 0&&i.set(l.version,"version"in c?c.version.major:1);}}if(e.slots!==void 0)for(let[a]of Object.entries(r.matches.slots??{})){let l=e.slots[a];if(l!==void 0){let u=r.mapping.slots[a]??a,c=r.matches.slots[a]??{};l.id!==void 0&&i.set(l.id,u),l.version!==void 0&&i.set(l.version,"version"in c?c.version.major:1);}}let{experiences:s}=r.matches,o=0;for(let[a,l]of s.entries()){if(e.experiences?.[a]!==void 0&&i.set(e.experiences[a],"id"in l&&l.id!==void 0?l.id:n.experiences[o].experienceId),e.experiments?.[a]!==void 0){let{experiment:u}=l,c=u!==void 0&&"id"in u&&u.id!==void 0?u.id:n.experiences[o].experimentId;c!==void 0&&i.set(e.experiments[a],c);}(!("id"in l)||l.id===void 0)&&o++;}}};var Vm=class t{constructor(e){this.config=e;}static prompt(e){return new t(e).handle()}handle(){let{input:e,unavailableSlugs:r=[]}=this.config;return e.prompt({message:this.config.label,default:this.config.default,initial:this.config.initial,validate:n=>/^[a-z]+(-?[a-z0-9]+)*$/i.test(n)?r.includes(n)?"The entered slug is already in use.":true:"The slug must start with a letter and contain only letters, numbers, and hyphens."})}};var HP=class{constructor(e){this.config=e;}async handle(e){let{input:r,workspaceApi:n}=this.config,{resources:i,...s}=e,o=i.slots??[],a=i.components??[],l=i.audiences??[],[u,c,p]=await Promise.all([o.length>0?n.getSlots(s):new Array,a.length>0?n.getComponents(s):new Array,l.length>0?n.getAudiences(s):new Array]),d=a.filter(v=>c.some(T=>T.slug===v)),f={};if(d.length>0){let v=c.map(T=>T.slug);for(let T of d){let D=await Vm.prompt({input:r,initial:T,unavailableSlugs:v,label:`Component \`${T}\` already exists, enter a new component ID:`});v.push(D),f[T]=D;}}let h=o.filter(v=>u.some(T=>T.slug===v)),m={};if(h.length>0){let v=u.map(T=>T.slug);for(let T of h){let D=await Vm.prompt({input:r,initial:T,unavailableSlugs:v,label:`Slot \`${T}\` already exists, enter a new slot ID:`});v.push(D),m[T]=D;}}let y=l.filter(v=>p.some(T=>T.slug===v)),b={};if(y.length>0){let v=p.map(T=>T.slug);for(let T of y){let D=await Vm.prompt({input:r,initial:T,unavailableSlugs:v,label:`Audience \`${T}\` already exists, enter a new audience ID:`});v.push(D),b[T]=D;}}return {components:f,slots:m,audiences:b}}};var{getOwnPropertyNames:Clt,getOwnPropertySymbols:wlt}=Object,{hasOwnProperty:Alt}=Object.prototype;function H3(t,e){return function(n,i,s){return t(n,i,s)&&e(n,i,s)}}function KP(t){return function(r,n,i){if(!r||!n||typeof r!="object"||typeof n!="object")return t(r,n,i);let{cache:s}=i,o=s.get(r),a=s.get(n);if(o&&a)return o===n&&a===r;s.set(r,n),s.set(n,r);let l=t(r,n,i);return s.delete(r),s.delete(n),l}}function Ilt(t){return t?.[Symbol.toStringTag]}function Fse(t){return Clt(t).concat(wlt(t))}var Olt=Object.hasOwn||((t,e)=>Alt.call(t,e));function ld(t,e){return t===e||!t&&!e&&t!==t&&e!==e}var _lt="__v",klt="__o",Nlt="_owner",{getOwnPropertyDescriptor:Rse,keys:Mse}=Object;function Flt(t,e){return t.byteLength===e.byteLength&&JP(new Uint8Array(t),new Uint8Array(e))}function Rlt(t,e,r){let n=t.length;if(e.length!==n)return false;for(;n-- >0;)if(!r.equals(t[n],e[n],n,n,t,e,r))return false;return true}function Mlt(t,e){return t.byteLength===e.byteLength&&JP(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Llt(t,e){return ld(t.getTime(),e.getTime())}function jlt(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function Blt(t,e){return t===e}function Lse(t,e,r){let n=t.size;if(n!==e.size)return false;if(!n)return true;let i=new Array(n),s=t.entries(),o,a,l=0;for(;(o=s.next())&&!o.done;){let u=e.entries(),c=false,p=0;for(;(a=u.next())&&!a.done;){if(i[p]){p++;continue}let d=o.value,f=a.value;if(r.equals(d[0],f[0],l,p,t,e,r)&&r.equals(d[1],f[1],d[0],f[0],t,e,r)){c=i[p]=true;break}p++;}if(!c)return false;l++;}return true}var $lt=ld;function Ult(t,e,r){let n=Mse(t),i=n.length;if(Mse(e).length!==i)return false;for(;i-- >0;)if(!Bse(t,e,r,n[i]))return false;return true}function gb(t,e,r){let n=Fse(t),i=n.length;if(Fse(e).length!==i)return false;let s,o,a;for(;i-- >0;)if(s=n[i],!Bse(t,e,r,s)||(o=Rse(t,s),a=Rse(e,s),(o||a)&&(!o||!a||o.configurable!==a.configurable||o.enumerable!==a.enumerable||o.writable!==a.writable)))return false;return true}function qlt(t,e){return ld(t.valueOf(),e.valueOf())}function Vlt(t,e){return t.source===e.source&&t.flags===e.flags}function jse(t,e,r){let n=t.size;if(n!==e.size)return false;if(!n)return true;let i=new Array(n),s=t.values(),o,a;for(;(o=s.next())&&!o.done;){let l=e.values(),u=false,c=0;for(;(a=l.next())&&!a.done;){if(!i[c]&&r.equals(o.value,a.value,o.value,a.value,t,e,r)){u=i[c]=true;break}c++;}if(!u)return false}return true}function JP(t,e){let r=t.byteLength;if(e.byteLength!==r||t.byteOffset!==e.byteOffset)return false;for(;r-- >0;)if(t[r]!==e[r])return false;return true}function zlt(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Bse(t,e,r,n){return (n===Nlt||n===klt||n===_lt)&&(t.$$typeof||e.$$typeof)?true:Olt(e,n)&&r.equals(t[n],e[n],n,n,t,e,r)}var Wlt="[object ArrayBuffer]",Glt="[object Arguments]",Hlt="[object Boolean]",Klt="[object DataView]",Jlt="[object Date]",Ylt="[object Error]",Xlt="[object Map]",Zlt="[object Number]",Qlt="[object Object]",eut="[object RegExp]",tut="[object Set]",rut="[object String]",nut={"[object Int8Array]":true,"[object Uint8Array]":true,"[object Uint8ClampedArray]":true,"[object Int16Array]":true,"[object Uint16Array]":true,"[object Int32Array]":true,"[object Uint32Array]":true,"[object Float16Array]":true,"[object Float32Array]":true,"[object Float64Array]":true,"[object BigInt64Array]":true,"[object BigUint64Array]":true},iut="[object URL]",sut=Object.prototype.toString;function out({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:o,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:u,areRegExpsEqual:c,areSetsEqual:p,areTypedArraysEqual:d,areUrlsEqual:f,unknownTagComparators:h}){return function(y,b,v){if(y===b)return true;if(y==null||b==null)return false;let T=typeof y;if(T!==typeof b)return false;if(T!=="object")return T==="number"?a(y,b,v):T==="function"?s(y,b,v):false;let D=y.constructor;if(D!==b.constructor)return false;if(D===Object)return l(y,b,v);if(Array.isArray(y))return e(y,b,v);if(D===Date)return n(y,b,v);if(D===RegExp)return c(y,b,v);if(D===Map)return o(y,b,v);if(D===Set)return p(y,b,v);let C=sut.call(y);if(C===Jlt)return n(y,b,v);if(C===eut)return c(y,b,v);if(C===Xlt)return o(y,b,v);if(C===tut)return p(y,b,v);if(C===Qlt)return typeof y.then!="function"&&typeof b.then!="function"&&l(y,b,v);if(C===iut)return f(y,b,v);if(C===Ylt)return i(y,b,v);if(C===Glt)return l(y,b,v);if(nut[C])return d(y,b,v);if(C===Wlt)return t(y,b,v);if(C===Klt)return r(y,b,v);if(C===Hlt||C===Zlt||C===rut)return u(y,b,v);if(h){let L=h[C];if(!L){let R=Ilt(y);R&&(L=h[R]);}if(L)return L(y,b,v)}return false}}function aut({circular:t,createCustomConfig:e,strict:r}){let n={areArrayBuffersEqual:Flt,areArraysEqual:r?gb:Rlt,areDataViewsEqual:Mlt,areDatesEqual:Llt,areErrorsEqual:jlt,areFunctionsEqual:Blt,areMapsEqual:r?H3(Lse,gb):Lse,areNumbersEqual:$lt,areObjectsEqual:r?gb:Ult,arePrimitiveWrappersEqual:qlt,areRegExpsEqual:Vlt,areSetsEqual:r?H3(jse,gb):jse,areTypedArraysEqual:r?H3(JP,gb):JP,areUrlsEqual:zlt,unknownTagComparators:void 0};if(e&&(n=Object.assign({},n,e(n))),t){let i=KP(n.areArraysEqual),s=KP(n.areMapsEqual),o=KP(n.areObjectsEqual),a=KP(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:i,areMapsEqual:s,areObjectsEqual:o,areSetsEqual:a});}return n}function lut(t){return function(e,r,n,i,s,o,a){return t(e,r,a)}}function uut({circular:t,comparator:e,createState:r,equals:n,strict:i}){if(r)return function(a,l){let{cache:u=t?new WeakMap:void 0,meta:c}=r();return e(a,l,{cache:u,equals:n,meta:c,strict:i})};if(t)return function(a,l){return e(a,l,{cache:new WeakMap,equals:n,meta:void 0,strict:i})};let s={cache:void 0,equals:n,meta:void 0,strict:i};return function(a,l){return e(a,l,s)}}var Tl=Oc();Oc({strict:true});Oc({circular:true});Oc({circular:true,strict:true});Oc({createInternalComparator:()=>ld});Oc({strict:true,createInternalComparator:()=>ld});Oc({circular:true,createInternalComparator:()=>ld});Oc({circular:true,createInternalComparator:()=>ld,strict:true});function Oc(t={}){let{circular:e=false,createInternalComparator:r,createState:n,strict:i=false}=t,s=aut(t),o=out(s),a=r?r(o):lut(o);return uut({circular:e,comparator:o,createState:n,equals:a,strict:i})}var YP=class t{constructor(e){this.config=e;}async match(e){let{resources:r,...n}=e,[i,s,o,a]=await Promise.all([this.mapComponents(r.components??{},n),this.mapSlots(r.slots??{},n),this.mapAudiences(r.audiences??{},n),this.mapExperiences(r.experiences??[],n)]);return {components:i,slots:s,audiences:o,experiences:a}}async mapAudiences(e,r){let{workspaceApi:n}=this.config,i=await Promise.all(Object.keys(e).map(async o=>[o,await n.getAudience({...r,audienceSlug:o})])),s={};for(let[o,a]of i)s[o]=a===null||!t.isSimilarAudience(e[o],a)?e[o]:a;return s}async mapComponents(e,r){let{workspaceApi:n}=this.config,i=await Promise.all(Object.keys(e).map(async o=>[o,await n.getComponent({...r,componentSlug:o})])),s={};for(let[o,a]of i)s[o]=a===null||!t.isSimilarComponent(e[o],a)?e[o]:a;return s}async mapSlots(e,r){let{workspaceApi:n}=this.config,i=await Promise.all(Object.keys(e).map(async o=>[o,await n.getSlot({...r,slotSlug:o})])),s={};for(let[o,a]of i)s[o]=a===null||!t.isSimilarSlot(e[o],a)?e[o]:a;return s}async mapExperiences(e,r){let{workspaceApi:n}=this.config,s=(await n.getExperiences({...r,status:["ACTIVE","PAUSED","DRAFT"]})).map(o=>{let a=null;function l(){return a===null&&(a=n.getExperience({...r,experienceId:o.id})),a}return {...o,details:{get content(){return l().then(u=>u?.content??null)},get experiment(){return l().then(u=>u?.experiment??null)}}}});return Promise.all(e.map(async o=>{for(let a of s)if(await this.matchesExperience(o,a)){let{details:l,...u}=a;return u}return o}))}async matchesExperience(e,r){if((e.draft===true?"DRAFT":"ACTIVE")!==r.status||!Tl(e.audiences,r.audiences)||!Tl(e.slots,r.slots)||e.experiment!==void 0&&r.experiment===void 0)return false;let[i,s=null]=await Promise.all([r.details.content,r.details.experiment]);return e.experiment!==void 0&&(s===null||e.experiment.goalId!==s.goalId||e.experiment.traffic!==s.traffic||e.experiment.crossDevice!==s.crossDevice||!t.isSimilarExperimentContent(e.experiment.variants,s.variants))?false:t.isSimilarPersonalizedContent(e.content,i??{default:{},segmented:[]})}static isSimilarAudience(e,r){return e.criteria===r.criteria}static isSimilarComponent(e,r){return Tl(e.schema,r.definition)}static isSimilarSlot(e,r){return e.component===r.component?.slug&&Object.values(e.content).some(n=>Object.values(r.content).some(i=>Tl(n,i)))}static isSimilarExperimentContent(e,r){return e.length!==r.length?false:e.some((n,i)=>Tl(n,r[i]))}static isSimilarPersonalizedContent(e,r){if(t.isSimilarSlotContent(e.default??{},r.default??{}))return true;for(let n of e.segmented??[])for(let i of r.segmented??[])if(Tl(n.audiences,i.audiences)&&t.isSimilarSlotContent(n.content,i.content))return true;return false}static isSimilarSlotContent(e,r){for(let[n,i]of Object.entries(e)){let s=r[n];if(s!==void 0){for(let o of Object.values(i))if(Object.values(s).some(a=>Tl(o,a)))return true}}return false}};var jr=class t extends Gn{constructor(e,{url:r,...n}){super(e,n),Object.setPrototypeOf(this,t.prototype),this.url=r;}},Dl=class t extends jr{constructor(e,r){super(e,{...r,reason:r.reason??"not_found"}),Object.setPrototypeOf(this,t.prototype);}};var XP=class t{constructor(e={}){this.configuration=e;}async get(e){if(!["http:","https:"].includes(e.protocol))throw new jr("Unsupported protocol.",{reason:"not_supported",url:e});return {url:e,value:await this.fetch(e)}}async fetch(e,r=0){let n=await fetch(e);if(n.status===404)throw new Dl("Resource not found.",{url:e});let{maxAttempts:i=0,delay:s=1e3}=this.configuration.retry??{};if(t.isSuccessful(n))return n;if(t.isRetryableCode(n.status)&&r<i)return await new Promise(o=>{setTimeout(o,s);}),this.fetch(e,r+1);throw new jr(n.statusText,{url:e})}static isSuccessful(e){return e.ok&&e.body!==null}static isRetryableCode(e){return e>=500||[429,408].includes(e)}};var ZP=class{constructor({packageManager:e}){this.packageManager=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Checking dependencies"),s;try{s=await Promise.all(e.dependencies.map(a=>this.checkRequirement(a)));}finally{i?.stop();}let o=[];for(let a of s){if(e?.result?.[a.dependency]!==void 0){r.set(e.result[a.dependency],a.satisfied);continue}a.issue!==void 0&&o.push(a);}if(o.length>0){let{message:a,...l}=e.help??{};throw new De(a??"Missing required dependencies.",{...l,details:o.map(({dependency:u,issue:c})=>`\`${u}\`: ${c}`)})}}async checkRequirement(e){let{name:r,version:n,optional:i=false}=e;if(n===void 0){let o=await this.packageManager.hasDirectDependency(r);if(o||i)return {dependency:r,satisfied:o}}else {let o=await this.packageManager.hasDirectDependency(r,n);if(o||i)return {dependency:r,satisfied:o}}let s=await this.packageManager.getDependency(r);return {dependency:r,satisfied:false,issue:s===null?"not installed":`${n!==void 0?`version \`${n}\` is required`:""}found \`${s.version??"unknown"}\``}}};var ud=class{constructor({dataProvider:e,registryProvider:r,baseUrl:n}){this.dataProvider=e,this.registryProvider=r,this.baseUrl=n;}async get(e){return this.dataProvider.get(await this.resolveUrl(e))}async resolveUrl(e){for(let{pattern:r,destination:n}of await this.loadMappings(e)){let i=e.href.match(typeof r=="string"?new RegExp(r):r);if(i!==null)return n instanceof URL?n:new URL(n.replace(/\$([0-9]+)/g,(s,o)=>i[Number.parseInt(o,10)]),this.baseUrl)}return e}async loadMappings(e){let r=await this.registryProvider.get(e);return Array.isArray(r)?r:r.value}};var Pl=class t{static{this.DEFAULT_EXPECTED_ERRORS=["not_supported","not_found","other"];}constructor({providers:e,expectedErrors:r}){this.providers=e,this.expectedErrors=r??t.DEFAULT_EXPECTED_ERRORS;}async get(e){for(let r of this.providers)try{return await r.get(e)}catch(n){if(!this.isExpectedError(n))throw n}throw new Dl("Resource not found.",{url:e})}isExpectedError(e){return e instanceof jr&&this.expectedErrors.includes(e.reason)}};var QP=class t{constructor(e,r){this.fileSystem=e,this.filter=r;}get(e){if(!t.supportsUrl(e))throw new jr(`Unsupported protocol "${e.protocol}".`,{reason:"not_supported",url:e});return Promise.resolve({url:e,value:this.fileSystem.list(this.fileSystem.normalizeSeparators(e.pathname),this.filter)})}static supportsUrl(e){return e.protocol==="file:"}};var $se=me(DE());var eC=class t{static{this.MAX_DOWNLOAD_FILES=50;}static{this.PROTOCOL="github:";}static{this.API_HOST="api.github.com";}static{this.RAW_HOST="raw.github.com";}static{this.MAIN_HOST="github.com";}constructor({cache:e,provider:r}){this.provider=r,this.cache=e??new $se.NoopCache;}async get(e){let r=this.parseUrl(e);if(r===null)throw new jr("Unsupported GitHub URL.",{reason:"not_supported",url:e});let n=await this.resolveFiles(r),i=await Promise.all(n.map(async s=>({url:s,response:(await this.provider.get(s)).value})));return {url:r.canonicalUrl,value:this.yieldFiles(i,r.path??"")}}async*yieldFiles(e,r){let n=new Set;for(let{url:i,response:s}of e){let o=i.pathname.split("/"),a=o.slice(4),l=a.join("/")===r&&e.length===1?o.slice(-1):a.slice(r.split("/").length);if(l.length>1){let u=l.slice(0,-1);for(let c=0;c<u.length;c++){let p=u.slice(0,c+1).join("/");n.has(p)||(n.add(p),yield {type:"directory",name:p});}}yield {type:"file",name:l.join("/"),content:Readable.fromWeb(s.body)};}}async resolveFiles(e){let{username:r,repository:n,path:i}=e,s=l=>{let u=new URL(`https://${t.RAW_HOST}`);return u.pathname=`/${r}/${n}/${e.ref??"HEAD"}/${l}`,u},o=await this.loadGitTree(e),a=[];if(i===null)a.push(...o.map(l=>s(l.path)));else {let l=o.find(u=>u.path===i);if(l===void 0)throw new jr("File not found.",{reason:"not_found",url:e.canonicalUrl});l.type==="tree"?a.push(...o.filter(u=>u.path.startsWith(i)&&u.type==="blob").map(u=>s(u.path))):a.push(s(i));}if(a.length>t.MAX_DOWNLOAD_FILES)throw new jr(`The number of files to download exceeds the limit of ${t.MAX_DOWNLOAD_FILES}.`,{reason:"precondition",url:e.canonicalUrl});return a}parseUrl(e){if(!t.isUrlSupported(e))return null;let r,n,i=null,s,o=((e.protocol===t.PROTOCOL?e.hostname:"")+e.pathname).replace(/^\/+/,"").split("/"),a=null;return e.hostname===t.MAIN_HOST?(a=e,[r=null,n=null,,i=null,...s]=o):[r=null,n=null,...s]=o,r===null||n===null?null:(a===null&&(a=new URL(`https://${t.MAIN_HOST}`),a.pathname=`/${r}/${n}/blob/master/${s.join("/")}`),{canonicalUrl:a,username:r,repository:n,ref:i,path:s!==void 0&&s.length>0?s.join("/"):null})}loadGitTree({username:e,repository:r,ref:n}){let i=new URL(`https://${t.API_HOST}`);return i.pathname=`repos/${e}/${r}/git/trees/${n??"HEAD"}`,i.searchParams.set("recursive","true"),this.cache.get(i.toString(),()=>this.provider.get(i).then(s=>s.value.json()).then(({tree:s})=>s))}static isUrlSupported(e){return e.protocol==="https:"?e.hostname===t.MAIN_HOST:e.protocol===t.PROTOCOL}};var bb=class t{constructor(e){this.provider=e;}async get(e){if(!t.supportsUrl(e))throw new jr("Unsupported URL.",{reason:"not_supported",url:e});let{value:r,...n}=await this.provider.get(e);return {...n,value:this.yield(r,e)}}static supportsUrl(e){return e.pathname!=="/"}async*yield(e,r){yield {type:"file",name:r.pathname.split("/").pop(),content:Readable.fromWeb(e.body)};}};var g={};Ah(g,{BRAND:()=>Lut,DIRTY:()=>cd,EMPTY_PATH:()=>hut,INVALID:()=>ut,NEVER:()=>vct,OK:()=>os,ParseStatus:()=>Hi,Schema:()=>Nt,ZodAny:()=>wl,ZodArray:()=>Ba,ZodBigInt:()=>dd,ZodBoolean:()=>fd,ZodBranded:()=>Eb,ZodCatch:()=>Td,ZodDate:()=>md,ZodDefault:()=>xd,ZodDiscriminatedUnion:()=>Jm,ZodEffects:()=>Zs,ZodEnum:()=>Ed,ZodError:()=>Ys,ZodFirstPartyTypeKind:()=>ft,ZodFunction:()=>nC,ZodIntersection:()=>gd,ZodIssueCode:()=>he,ZodLazy:()=>bd,ZodLiteral:()=>Sd,ZodMap:()=>Xm,ZodNaN:()=>Qm,ZodNativeEnum:()=>vd,ZodNever:()=>ja,ZodNull:()=>yd,ZodNullable:()=>Il,ZodNumber:()=>pd,ZodObject:()=>as,ZodOptional:()=>Xs,ZodParsedType:()=>Ne,ZodPipeline:()=>Dd,ZodPromise:()=>Al,ZodReadonly:()=>Pd,ZodRecord:()=>Ym,ZodSchema:()=>Nt,ZodSet:()=>Zm,ZodString:()=>kc,ZodSymbol:()=>Hm,ZodTransformer:()=>Zs,ZodTuple:()=>ta,ZodType:()=>Nt,ZodUndefined:()=>hd,ZodUnion:()=>vu,ZodUnknown:()=>Eu,ZodVoid:()=>Km,addIssueToContext:()=>Oe,any:()=>Gut,array:()=>Yut,bigint:()=>Uut,boolean:()=>Xse,coerce:()=>Ect,custom:()=>Kse,date:()=>qut,datetimeRegex:()=>Gse,defaultErrorMap:()=>bu,discriminatedUnion:()=>ect,effect:()=>dct,enum:()=>uct,function:()=>oct,getErrorMap:()=>zm,getParsedType:()=>Cl,instanceof:()=>But,intersection:()=>tct,isAborted:()=>tC,isAsync:()=>Wm,isDirty:()=>rC,isValid:()=>_c,late:()=>jut,lazy:()=>act,literal:()=>lct,makeIssue:()=>Sb,map:()=>ict,nan:()=>$ut,nativeEnum:()=>cct,never:()=>Kut,null:()=>Wut,nullable:()=>mct,number:()=>Yse,object:()=>Xut,objectUtil:()=>K3,oboolean:()=>Sct,onumber:()=>bct,optional:()=>fct,ostring:()=>gct,pipeline:()=>yct,preprocess:()=>hct,promise:()=>pct,quotelessJson:()=>dut,record:()=>nct,set:()=>sct,setErrorMap:()=>mut,strictObject:()=>Zut,string:()=>Jse,symbol:()=>Vut,transformer:()=>dct,tuple:()=>rct,undefined:()=>zut,union:()=>Qut,unknown:()=>Hut,util:()=>Yt,void:()=>Jut});var Yt;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},t.getValidEnumValues=i=>{let s=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(let a of s)o[a]=i[a];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},t.find=(i,s)=>{for(let o of i)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s;})(Yt||(Yt={}));var K3;(function(t){t.mergeShapes=(e,r)=>({...e,...r});})(K3||(K3={}));var Ne=Yt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Cl=t=>{switch(typeof t){case "undefined":return Ne.undefined;case "string":return Ne.string;case "number":return Number.isNaN(t)?Ne.nan:Ne.number;case "boolean":return Ne.boolean;case "function":return Ne.function;case "bigint":return Ne.bigint;case "symbol":return Ne.symbol;case "object":return Array.isArray(t)?Ne.array:t===null?Ne.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Ne.promise:typeof Map<"u"&&t instanceof Map?Ne.map:typeof Set<"u"&&t instanceof Set?Ne.set:typeof Date<"u"&&t instanceof Date?Ne.date:Ne.object;default:return Ne.unknown}};var he=Yt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),dut=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ys=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n];},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n];};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e;}format(e){let r=e||function(s){return s.message},n={_errors:[]},i=s=>{for(let o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else {let a=n,l=0;for(;l<o.path.length;){let u=o.path[l];l===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],l++;}}};return i(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Yt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];r[s]=r[s]||[],r[s].push(e(i));}else n.push(e(i));return {formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ys.create=t=>new Ys(t);var fut=(t,e)=>{let r;switch(t.code){case he.invalid_type:t.received===Ne.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case he.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Yt.jsonStringifyReplacer)}`;break;case he.unrecognized_keys:r=`Unrecognized key(s) in object: ${Yt.joinValues(t.keys,", ")}`;break;case he.invalid_union:r="Invalid input";break;case he.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Yt.joinValues(t.options)}`;break;case he.invalid_enum_value:r=`Invalid enum value. Expected ${Yt.joinValues(t.options)}, received '${t.received}'`;break;case he.invalid_arguments:r="Invalid function arguments";break;case he.invalid_return_type:r="Invalid function return type";break;case he.invalid_date:r="Invalid date";break;case he.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Yt.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case he.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case he.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case he.custom:r="Invalid input";break;case he.invalid_intersection_types:r="Intersection results could not be merged";break;case he.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case he.not_finite:r="Number must be finite";break;default:r=e.defaultError,Yt.assertNever(t);}return {message:r}},bu=fut;var Use=bu;function mut(t){Use=t;}function zm(){return Use}var Sb=t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,s=[...r,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return {...i,path:s,message:i.message};let a="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)a=u(o,{data:e,defaultError:a}).message;return {...i,path:s,message:a}},hut=[];function Oe(t,e){let r=zm(),n=Sb({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===bu?void 0:bu].filter(i=>!!i)});t.common.issues.push(n);}var Hi=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,r){let n=[];for(let i of r){if(i.status==="aborted")return ut;i.status==="dirty"&&e.dirty(),n.push(i.value);}return {status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let i of r){let s=await i.key,o=await i.value;n.push({key:s,value:o});}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let i of r){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return ut;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value);}return {status:e.value,value:n}}},ut=Object.freeze({status:"aborted"}),cd=t=>({status:"dirty",value:t}),os=t=>({status:"valid",value:t}),tC=t=>t.status==="aborted",rC=t=>t.status==="dirty",_c=t=>t.status==="valid",Wm=t=>typeof Promise<"u"&&t instanceof Promise;var Xe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(Xe||(Xe={}));var ea=class{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i;}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},qse=(t,e)=>{if(_c(e))return {success:true,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let r=new Ys(t.common.issues);return this._error=r,this._error}}};function Ct(t){if(!t)return {};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??r??a.defaultError}},description:i}}var Nt=class{get description(){return this._def.description}_getType(e){return Cl(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Cl(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new Hi,ctx:{common:e.parent.common,data:e.data,parsedType:Cl(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Wm(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??false,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cl(e)},i=this._parseSync({data:e,path:n.path,parent:n});return qse(n,i)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cl(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return _c(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),r.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:r}).then(n=>_c(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:true},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cl(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Wm(i)?i:Promise.resolve(i));return qse(n,s)}refine(e,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{let o=e(i),a=()=>s.addIssue({code:he.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?true:(a(),false)):o?true:(a(),false)})}refinement(e,r){return this._refinement((n,i)=>e(n)?true:(i.addIssue(typeof r=="function"?r(n,i):r),false))}_refinement(e){return new Zs({schema:this,typeName:ft.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)};}optional(){return Xs.create(this,this._def)}nullable(){return Il.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ba.create(this)}promise(){return Al.create(this,this._def)}or(e){return vu.create([this,e],this._def)}and(e){return gd.create(this,e,this._def)}transform(e){return new Zs({...Ct(this._def),schema:this,typeName:ft.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new xd({...Ct(this._def),innerType:this,defaultValue:r,typeName:ft.ZodDefault})}brand(){return new Eb({typeName:ft.ZodBranded,type:this,...Ct(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Td({...Ct(this._def),innerType:this,catchValue:r,typeName:ft.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Dd.create(this,e)}readonly(){return Pd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},yut=/^c[^\s-]{8,}$/i,gut=/^[0-9a-z]+$/,but=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Sut=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Eut=/^[a-z0-9_-]{21}$/i,vut=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xut=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Tut=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Dut="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",J3,Put=/^(?:(?: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])$/,Cut=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,wut=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Aut=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Iut=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Out=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zse="((\\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])))",_ut=new RegExp(`^${zse}$`);function Wse(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function kut(t){return new RegExp(`^${Wse(t)}$`)}function Gse(t){let e=`${zse}T${Wse(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Nut(t,e){return !!((e==="v4"||!e)&&Put.test(t)||(e==="v6"||!e)&&wut.test(t))}function Fut(t,e){if(!vut.test(t))return false;try{let[r]=t.split(".");if(!r)return !1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return !(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return false}}function Rut(t,e){return !!((e==="v4"||!e)&&Cut.test(t)||(e==="v6"||!e)&&Aut.test(t))}var kc=class t extends Nt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ne.string){let s=this._getOrReturnCtx(e);return Oe(s,{code:he.invalid_type,expected:Ne.string,received:s.parsedType}),ut}let n=new Hi,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.too_small,minimum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.too_big,maximum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),n.dirty());else if(s.kind==="length"){let o=e.data.length>s.value,a=e.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(e,i),o?Oe(i,{code:he.too_big,maximum:s.value,type:"string",inclusive:true,exact:true,message:s.message}):a&&Oe(i,{code:he.too_small,minimum:s.value,type:"string",inclusive:true,exact:true,message:s.message}),n.dirty());}else if(s.kind==="email")Tut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"email",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")J3||(J3=new RegExp(Dut,"u")),J3.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"emoji",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Sut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"uuid",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Eut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"nanoid",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")yut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"cuid",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")gut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"cuid2",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")but.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"ulid",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data);}catch{i=this._getOrReturnCtx(e,i),Oe(i,{validation:"url",code:he.invalid_string,message:s.message}),n.dirty();}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"regex",code:he.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Gse(s).test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?_ut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?kut(s).test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?xut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"duration",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Nut(e.data,s.version)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"ip",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?Fut(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"jwt",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?Rut(e.data,s.version)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"cidr",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Iut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"base64",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?Out.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"base64url",code:he.invalid_string,message:s.message}),n.dirty()):Yt.assertNever(s);return {status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:he.invalid_string,...Xe.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Xe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Xe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Xe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Xe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Xe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Xe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Xe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Xe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Xe.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Xe.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Xe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Xe.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Xe.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...Xe.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Xe.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Xe.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Xe.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Xe.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Xe.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Xe.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Xe.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Xe.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Xe.errToObj(r)})}nonempty(e){return this.min(1,Xe.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return !!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return !!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};kc.create=t=>new kc({checks:[],typeName:ft.ZodString,coerce:t?.coerce??false,...Ct(t)});function Mut(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,s=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return s%o/10**i}var pd=class t extends Nt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Ne.number){let s=this._getOrReturnCtx(e);return Oe(s,{code:he.invalid_type,expected:Ne.number,received:s.parsedType}),ut}let n,i=new Hi;for(let s of this._def.checks)s.kind==="int"?Yt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),i.dirty()):s.kind==="multipleOf"?Mut(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.not_finite,message:s.message}),i.dirty()):Yt.assertNever(s);return {status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,true,Xe.toString(r))}gt(e,r){return this.setLimit("min",e,false,Xe.toString(r))}lte(e,r){return this.setLimit("max",e,true,Xe.toString(r))}lt(e,r){return this.setLimit("max",e,false,Xe.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Xe.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Xe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:Xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:Xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:Xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:Xe.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Xe.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Xe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:Xe.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:Xe.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Yt.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return true;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);}return Number.isFinite(r)&&Number.isFinite(e)}};pd.create=t=>new pd({checks:[],typeName:ft.ZodNumber,coerce:t?.coerce||false,...Ct(t)});var dd=class t extends Nt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data);}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Ne.bigint)return this._getInvalidInput(e);let n,i=new Hi;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Yt.assertNever(s);return {status:i.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return Oe(r,{code:he.invalid_type,expected:Ne.bigint,received:r.parsedType}),ut}gte(e,r){return this.setLimit("min",e,true,Xe.toString(r))}gt(e,r){return this.setLimit("min",e,false,Xe.toString(r))}lte(e,r){return this.setLimit("max",e,true,Xe.toString(r))}lt(e,r){return this.setLimit("max",e,false,Xe.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Xe.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:Xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:Xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:Xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:Xe.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Xe.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};dd.create=t=>new dd({checks:[],typeName:ft.ZodBigInt,coerce:t?.coerce??false,...Ct(t)});var fd=class extends Nt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ne.boolean){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.boolean,received:n.parsedType}),ut}return os(e.data)}};fd.create=t=>new fd({typeName:ft.ZodBoolean,coerce:t?.coerce||false,...Ct(t)});var md=class t extends Nt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ne.date){let s=this._getOrReturnCtx(e);return Oe(s,{code:he.invalid_type,expected:Ne.date,received:s.parsedType}),ut}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return Oe(s,{code:he.invalid_date}),ut}let n=new Hi,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.too_small,message:s.message,inclusive:true,exact:false,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.too_big,message:s.message,inclusive:true,exact:false,maximum:s.value,type:"date"}),n.dirty()):Yt.assertNever(s);return {status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Xe.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Xe.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};md.create=t=>new md({checks:[],coerce:t?.coerce||false,typeName:ft.ZodDate,...Ct(t)});var Hm=class extends Nt{_parse(e){if(this._getType(e)!==Ne.symbol){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.symbol,received:n.parsedType}),ut}return os(e.data)}};Hm.create=t=>new Hm({typeName:ft.ZodSymbol,...Ct(t)});var hd=class extends Nt{_parse(e){if(this._getType(e)!==Ne.undefined){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.undefined,received:n.parsedType}),ut}return os(e.data)}};hd.create=t=>new hd({typeName:ft.ZodUndefined,...Ct(t)});var yd=class extends Nt{_parse(e){if(this._getType(e)!==Ne.null){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.null,received:n.parsedType}),ut}return os(e.data)}};yd.create=t=>new yd({typeName:ft.ZodNull,...Ct(t)});var wl=class extends Nt{constructor(){super(...arguments),this._any=true;}_parse(e){return os(e.data)}};wl.create=t=>new wl({typeName:ft.ZodAny,...Ct(t)});var Eu=class extends Nt{constructor(){super(...arguments),this._unknown=true;}_parse(e){return os(e.data)}};Eu.create=t=>new Eu({typeName:ft.ZodUnknown,...Ct(t)});var ja=class extends Nt{_parse(e){let r=this._getOrReturnCtx(e);return Oe(r,{code:he.invalid_type,expected:Ne.never,received:r.parsedType}),ut}};ja.create=t=>new ja({typeName:ft.ZodNever,...Ct(t)});var Km=class extends Nt{_parse(e){if(this._getType(e)!==Ne.undefined){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.void,received:n.parsedType}),ut}return os(e.data)}};Km.create=t=>new Km({typeName:ft.ZodVoid,...Ct(t)});var Ba=class t extends Nt{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==Ne.array)return Oe(r,{code:he.invalid_type,expected:Ne.array,received:r.parsedType}),ut;if(i.exactLength!==null){let o=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(o||a)&&(Oe(r,{code:o?he.too_big:he.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:i.exactLength.message}),n.dirty());}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Oe(r,{code:he.too_small,minimum:i.minLength.value,type:"array",inclusive:true,exact:false,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Oe(r,{code:he.too_big,maximum:i.maxLength.value,type:"array",inclusive:true,exact:false,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>i.type._parseAsync(new ea(r,o,r.path,a)))).then(o=>Hi.mergeArray(n,o));let s=[...r.data].map((o,a)=>i.type._parseSync(new ea(r,o,r.path,a)));return Hi.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:Xe.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:Xe.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:Xe.toString(r)}})}nonempty(e){return this.min(1,e)}};Ba.create=(t,e)=>new Ba({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ft.ZodArray,...Ct(e)});function Gm(t){if(t instanceof as){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Xs.create(Gm(n));}return new as({...t._def,shape:()=>e})}else return t instanceof Ba?new Ba({...t._def,type:Gm(t.element)}):t instanceof Xs?Xs.create(Gm(t.unwrap())):t instanceof Il?Il.create(Gm(t.unwrap())):t instanceof ta?ta.create(t.items.map(e=>Gm(e))):t}var as=class t extends Nt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend;}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Yt.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Ne.object){let u=this._getOrReturnCtx(e);return Oe(u,{code:he.invalid_type,expected:Ne.object,received:u.parsedType}),ut}let{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof ja&&this._def.unknownKeys==="strip"))for(let u in i.data)o.includes(u)||a.push(u);let l=[];for(let u of o){let c=s[u],p=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ea(i,p,i.path,u)),alwaysSet:u in i.data});}if(this._def.catchall instanceof ja){let u=this._def.unknownKeys;if(u==="passthrough")for(let c of a)l.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(u==="strict")a.length>0&&(Oe(i,{code:he.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let u=this._def.catchall;for(let c of a){let p=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ea(i,p,i.path,c)),alwaysSet:c in i.data});}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let c of l){let p=await c.key,d=await c.value;u.push({key:p,value:d,alwaysSet:c.alwaysSet});}return u}).then(u=>Hi.mergeObjectSync(n,u)):Hi.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return Xe.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Xe.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ft.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of Yt.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of Yt.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Gm(this)}partial(e){let r={};for(let n of Yt.objectKeys(this.shape)){let i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional();}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of Yt.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else {let s=this.shape[n];for(;s instanceof Xs;)s=s._def.innerType;r[n]=s;}return new t({...this._def,shape:()=>r})}keyof(){return Hse(Yt.objectKeys(this.shape))}};as.create=(t,e)=>new as({shape:()=>t,unknownKeys:"strip",catchall:ja.create(),typeName:ft.ZodObject,...Ct(e)});as.strictCreate=(t,e)=>new as({shape:()=>t,unknownKeys:"strict",catchall:ja.create(),typeName:ft.ZodObject,...Ct(e)});as.lazycreate=(t,e)=>new as({shape:t,unknownKeys:"strip",catchall:ja.create(),typeName:ft.ZodObject,...Ct(e)});var vu=class extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function i(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let o=s.map(a=>new Ys(a.ctx.common.issues));return Oe(r,{code:he.invalid_union,unionErrors:o}),ut}if(r.common.async)return Promise.all(n.map(async s=>{let o={...r,common:{...r.common,issues:[]},parent:null};return {result:await s._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(i);{let s,o=[];for(let l of n){let u={...r,common:{...r.common,issues:[]},parent:null},c=l._parseSync({data:r.data,path:r.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!s&&(s={result:c,ctx:u}),u.common.issues.length&&o.push(u.common.issues);}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(l=>new Ys(l));return Oe(r,{code:he.invalid_union,unionErrors:a}),ut}}get options(){return this._def.options}};vu.create=(t,e)=>new vu({options:t,typeName:ft.ZodUnion,...Ct(e)});var Su=t=>t instanceof bd?Su(t.schema):t instanceof Zs?Su(t.innerType()):t instanceof Sd?[t.value]:t instanceof Ed?t.options:t instanceof vd?Yt.objectValues(t.enum):t instanceof xd?Su(t._def.innerType):t instanceof hd?[void 0]:t instanceof yd?[null]:t instanceof Xs?[void 0,...Su(t.unwrap())]:t instanceof Il?[null,...Su(t.unwrap())]:t instanceof Eb||t instanceof Pd?Su(t.unwrap()):t instanceof Td?Su(t._def.innerType):[],Jm=class t extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.object)return Oe(r,{code:he.invalid_type,expected:Ne.object,received:r.parsedType}),ut;let n=this.discriminator,i=r.data[n],s=this.optionsMap.get(i);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(Oe(r,{code:he.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ut)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let i=new Map;for(let s of r){let o=Su(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,s);}}return new t({typeName:ft.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...Ct(n)})}};function Y3(t,e){let r=Cl(t),n=Cl(e);if(t===e)return {valid:true,data:t};if(r===Ne.object&&n===Ne.object){let i=Yt.objectKeys(e),s=Yt.objectKeys(t).filter(a=>i.indexOf(a)!==-1),o={...t,...e};for(let a of s){let l=Y3(t[a],e[a]);if(!l.valid)return {valid:false};o[a]=l.data;}return {valid:true,data:o}}else if(r===Ne.array&&n===Ne.array){if(t.length!==e.length)return {valid:false};let i=[];for(let s=0;s<t.length;s++){let o=t[s],a=e[s],l=Y3(o,a);if(!l.valid)return {valid:false};i.push(l.data);}return {valid:true,data:i}}else return r===Ne.date&&n===Ne.date&&+t==+e?{valid:true,data:t}:{valid:false}}var gd=class extends Nt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(tC(s)||tC(o))return ut;let a=Y3(s.value,o.value);return a.valid?((rC(s)||rC(o))&&r.dirty(),{status:r.value,value:a.data}):(Oe(n,{code:he.invalid_intersection_types}),ut)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};gd.create=(t,e,r)=>new gd({left:t,right:e,typeName:ft.ZodIntersection,...Ct(r)});var ta=class t extends Nt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.array)return Oe(n,{code:he.invalid_type,expected:Ne.array,received:n.parsedType}),ut;if(n.data.length<this._def.items.length)return Oe(n,{code:he.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),ut;!this._def.rest&&n.data.length>this._def.items.length&&(Oe(n,{code:he.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),r.dirty());let s=[...n.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new ea(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>Hi.mergeArray(r,o)):Hi.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ta.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ta({items:t,typeName:ft.ZodTuple,rest:null,...Ct(e)})};var Ym=class t extends Nt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.object)return Oe(n,{code:he.invalid_type,expected:Ne.object,received:n.parsedType}),ut;let i=[],s=this._def.keyType,o=this._def.valueType;for(let a in n.data)i.push({key:s._parse(new ea(n,a,n.path,a)),value:o._parse(new ea(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Hi.mergeObjectAsync(r,i):Hi.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof Nt?new t({keyType:e,valueType:r,typeName:ft.ZodRecord,...Ct(n)}):new t({keyType:kc.create(),valueType:e,typeName:ft.ZodRecord,...Ct(r)})}},Xm=class extends Nt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.map)return Oe(n,{code:he.invalid_type,expected:Ne.map,received:n.parsedType}),ut;let i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([a,l],u)=>({key:i._parse(new ea(n,a,n.path,[u,"key"])),value:s._parse(new ea(n,l,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let u=await l.key,c=await l.value;if(u.status==="aborted"||c.status==="aborted")return ut;(u.status==="dirty"||c.status==="dirty")&&r.dirty(),a.set(u.value,c.value);}return {status:r.value,value:a}})}else {let a=new Map;for(let l of o){let u=l.key,c=l.value;if(u.status==="aborted"||c.status==="aborted")return ut;(u.status==="dirty"||c.status==="dirty")&&r.dirty(),a.set(u.value,c.value);}return {status:r.value,value:a}}}};Xm.create=(t,e,r)=>new Xm({valueType:e,keyType:t,typeName:ft.ZodMap,...Ct(r)});var Zm=class t extends Nt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.set)return Oe(n,{code:he.invalid_type,expected:Ne.set,received:n.parsedType}),ut;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(Oe(n,{code:he.too_small,minimum:i.minSize.value,type:"set",inclusive:true,exact:false,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(Oe(n,{code:he.too_big,maximum:i.maxSize.value,type:"set",inclusive:true,exact:false,message:i.maxSize.message}),r.dirty());let s=this._def.valueType;function o(l){let u=new Set;for(let c of l){if(c.status==="aborted")return ut;c.status==="dirty"&&r.dirty(),u.add(c.value);}return {status:r.value,value:u}}let a=[...n.data.values()].map((l,u)=>s._parse(new ea(n,l,n.path,u)));return n.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:Xe.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:Xe.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Zm.create=(t,e)=>new Zm({valueType:t,minSize:null,maxSize:null,typeName:ft.ZodSet,...Ct(e)});var nC=class t extends Nt{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.function)return Oe(r,{code:he.invalid_type,expected:Ne.function,received:r.parsedType}),ut;function n(a,l){return Sb({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,zm(),bu].filter(u=>!!u),issueData:{code:he.invalid_arguments,argumentsError:l}})}function i(a,l){return Sb({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,zm(),bu].filter(u=>!!u),issueData:{code:he.invalid_return_type,returnTypeError:l}})}let s={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Al){let a=this;return os(async function(...l){let u=new Ys([]),c=await a._def.args.parseAsync(l,s).catch(f=>{throw u.addIssue(n(l,f)),u}),p=await Reflect.apply(o,this,c);return await a._def.returns._def.type.parseAsync(p,s).catch(f=>{throw u.addIssue(i(p,f)),u})})}else {let a=this;return os(function(...l){let u=a._def.args.safeParse(l,s);if(!u.success)throw new Ys([n(l,u.error)]);let c=Reflect.apply(o,this,u.data),p=a._def.returns.safeParse(c,s);if(!p.success)throw new Ys([i(c,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ta.create(e).rest(Eu.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||ta.create([]).rest(Eu.create()),returns:r||Eu.create(),typeName:ft.ZodFunction,...Ct(n)})}},bd=class extends Nt{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};bd.create=(t,e)=>new bd({getter:t,typeName:ft.ZodLazy,...Ct(e)});var Sd=class extends Nt{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return Oe(r,{received:r.data,code:he.invalid_literal,expected:this._def.value}),ut}return {status:"valid",value:e.data}}get value(){return this._def.value}};Sd.create=(t,e)=>new Sd({value:t,typeName:ft.ZodLiteral,...Ct(e)});function Hse(t,e){return new Ed({values:t,typeName:ft.ZodEnum,...Ct(e)})}var Ed=class t extends Nt{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return Oe(r,{expected:Yt.joinValues(n),received:r.parsedType,code:he.invalid_type}),ut}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return Oe(r,{received:r.data,code:he.invalid_enum_value,options:n}),ut}return os(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Ed.create=Hse;var vd=class extends Nt{_parse(e){let r=Yt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Ne.string&&n.parsedType!==Ne.number){let i=Yt.objectValues(r);return Oe(n,{expected:Yt.joinValues(i),received:n.parsedType,code:he.invalid_type}),ut}if(this._cache||(this._cache=new Set(Yt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=Yt.objectValues(r);return Oe(n,{received:n.data,code:he.invalid_enum_value,options:i}),ut}return os(e.data)}get enum(){return this._def.values}};vd.create=(t,e)=>new vd({values:t,typeName:ft.ZodNativeEnum,...Ct(e)});var Al=class extends Nt{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.promise&&r.common.async===false)return Oe(r,{code:he.invalid_type,expected:Ne.promise,received:r.parsedType}),ut;let n=r.parsedType===Ne.promise?r.data:Promise.resolve(r.data);return os(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Al.create=(t,e)=>new Al({type:t,typeName:ft.ZodPromise,...Ct(e)});var Zs=class extends Nt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ft.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{Oe(n,o),o.fatal?r.abort():r.dirty();},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return ut;let l=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return l.status==="aborted"?ut:l.status==="dirty"?cd(l.value):r.value==="dirty"?cd(l.value):l});{if(r.value==="aborted")return ut;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?ut:a.status==="dirty"?cd(a.value):r.value==="dirty"?cd(a.value):a}}if(i.type==="refinement"){let o=a=>{let l=i.refinement(a,s);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===false){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?ut:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?ut:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===false){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!_c(o))return ut;let a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>_c(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:r.value,value:a})):ut);Yt.assertNever(i);}};Zs.create=(t,e,r)=>new Zs({schema:t,typeName:ft.ZodEffects,effect:e,...Ct(r)});Zs.createWithPreprocess=(t,e,r)=>new Zs({schema:e,effect:{type:"preprocess",transform:t},typeName:ft.ZodEffects,...Ct(r)});var Xs=class extends Nt{_parse(e){return this._getType(e)===Ne.undefined?os(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xs.create=(t,e)=>new Xs({innerType:t,typeName:ft.ZodOptional,...Ct(e)});var Il=class extends Nt{_parse(e){return this._getType(e)===Ne.null?os(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Il.create=(t,e)=>new Il({innerType:t,typeName:ft.ZodNullable,...Ct(e)});var xd=class extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===Ne.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};xd.create=(t,e)=>new xd({innerType:t,typeName:ft.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ct(e)});var Td=class extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Wm(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ys(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ys(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Td.create=(t,e)=>new Td({innerType:t,typeName:ft.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ct(e)});var Qm=class extends Nt{_parse(e){if(this._getType(e)!==Ne.nan){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.nan,received:n.parsedType}),ut}return {status:"valid",value:e.data}}};Qm.create=t=>new Qm({typeName:ft.ZodNaN,...Ct(t)});var Lut=Symbol("zod_brand"),Eb=class extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Dd=class t extends Nt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return (async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ut:s.status==="dirty"?(r.dirty(),cd(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ut:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:ft.ZodPipeline})}},Pd=class extends Nt{_parse(e){let r=this._def.innerType._parse(e),n=i=>(_c(i)&&(i.value=Object.freeze(i.value)),i);return Wm(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Pd.create=(t,e)=>new Pd({innerType:t,typeName:ft.ZodReadonly,...Ct(e)});function Vse(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Kse(t,e={},r){return t?wl.create().superRefine((n,i)=>{let s=t(n);if(s instanceof Promise)return s.then(o=>{if(!o){let a=Vse(e,n),l=a.fatal??r??true;i.addIssue({code:"custom",...a,fatal:l});}});if(!s){let o=Vse(e,n),a=o.fatal??r??true;i.addIssue({code:"custom",...o,fatal:a});}}):wl.create()}var jut={object:as.lazycreate},ft;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly";})(ft||(ft={}));var But=(t,e={message:`Input not instance of ${t.name}`})=>Kse(r=>r instanceof t,e),Jse=kc.create,Yse=pd.create,$ut=Qm.create,Uut=dd.create,Xse=fd.create,qut=md.create,Vut=Hm.create,zut=hd.create,Wut=yd.create,Gut=wl.create,Hut=Eu.create,Kut=ja.create,Jut=Km.create,Yut=Ba.create,Xut=as.create,Zut=as.strictCreate,Qut=vu.create,ect=Jm.create,tct=gd.create,rct=ta.create,nct=Ym.create,ict=Xm.create,sct=Zm.create,oct=nC.create,act=bd.create,lct=Sd.create,uct=Ed.create,cct=vd.create,pct=Al.create,dct=Zs.create,fct=Xs.create,mct=Il.create,hct=Zs.createWithPreprocess,yct=Dd.create,gct=()=>Jse().optional(),bct=()=>Yse().optional(),Sct=()=>Xse().optional(),Ect={string:(t=>kc.create({...t,coerce:true})),number:(t=>pd.create({...t,coerce:true})),boolean:(t=>fd.create({...t,coerce:true})),bigint:(t=>dd.create({...t,coerce:true})),date:(t=>md.create({...t,coerce:true}))};var vct=ut;var In=class{constructor(e){this.schema=e;}async validate(e){let r=await this.schema.safeParseAsync(e);if(r.success)return {valid:true,data:r.data};let{error:n}=r;return {valid:false,violations:n.issues.map(i=>({path:i.path.reduce((s,o)=>typeof o=="string"?s===""?o:`${s}.${o}`:`${s}[${o}]`,""),message:i.message}))}}};var xct=g.object({name:g.string(),version:g.string().optional(),dependencies:g.record(g.string()).optional(),devDependencies:g.record(g.string()).optional(),bin:g.record(g.string()).optional(),scripts:g.record(g.string()).optional(),packageManager:g.string().optional()}),vb=class extends In{constructor(){super(xct);}};var Nc=g.string().regex(/^[a-z]+(-?[a-z0-9]+)*$/i,"An identifier must start with a letter and contain only letters, numbers, and hyphens."),iC=g.string().regex(/^[a-z]{2,3}([-_][a-z]{2,3})?$/i,"Locale must be in the form of en, en_US, or en-US."),sC=g.string().refine(rr.isValid,"Version must be exact (1), range (1 - 2), or set (1, 2).").refine(t=>{try{return rr.parse(t).getCardinality()<=5}catch{return false}},"Version range must not exceed 5 major versions.");function ls(t){return t.optional().catch(void 0)}var Tct=g.object({$schema:ls(g.string()),organization:ls(Nc),workspace:ls(Nc),applications:ls(g.object({development:ls(Nc),production:ls(Nc)})),locales:ls(g.array(iC).min(1)),defaultLocale:ls(iC),slots:ls(g.record(sC)),components:ls(g.record(sC)),paths:ls(g.object({source:ls(g.string()),utilities:ls(g.string()),components:ls(g.string()),examples:ls(g.string()),content:ls(g.string())}))}),Dct=g.strictObject({$schema:g.string().optional(),organization:Nc,workspace:Nc,applications:g.strictObject({development:Nc,production:Nc.optional()}),locales:g.array(iC).min(1),defaultLocale:iC,slots:g.record(sC).default({}),components:g.record(sC).default({}),paths:g.strictObject({source:g.string().optional(),utilities:g.string().optional(),components:g.string().optional(),examples:g.string().optional(),content:g.string().optional()}).optional()}).refine(t=>t.locales.includes(t.defaultLocale),{message:"The default locale is not included in the list of locales.",path:["defaultLocale"]}),oC=class extends In{constructor(){super(Dct);}},aC=class extends In{constructor(){super(Tct);}};var eh=class{constructor({provider:e,validator:r}){this.provider=e,this.validator=r;}async get(e){let{value:r,...n}=await this.provider.get(e),i=await this.validator.validate(r);if(!i.valid){let s=i.violations.map(o=>` \u2022 **${o.path}**: ${o.message}`).join(`
2438
+ `;this.runCommand({name:"powershell",arguments:["-Command",`& {${s}}`]});}}runCommand(e){let{commandExecutor:r,timeout:n}=this.configuration;try{let i=r.runSync(e,{timeout:n});return i.exitCode!==0?null:i.output.trim()}catch{return null}}};var TP=class{constructor(e){this.detector=e.detector,this.templates=e.templates;}async generate(e){let r=await this.detector.detect(e.recipient);return r===null||this.templates[r]===void 0?null:this.templates[r].generate(e)}};var DP=class{constructor(...e){this.detectors=e;}async detect(e){for(let r of this.detectors){let n=await r.detect(e);if(n!==null)return n}return null}};var PP=class t{static{this.DEFAULT_DOMAINS={google:["gmail.com","googlemail.com","google.com"],yahoo:[/yahoo\.com(?:\.\w+)?/,"yahoo.co.uk","yahoo.fr","yahoo.it","ymail.com","rocketmail.com"],microsoft:["outlook.com","live.com","hotmail.com","msn.com","passport.com","passport.net"],proton:["proton.me","protonmail.com"],icloud:["icloud.com"]};}constructor(e=t.DEFAULT_DOMAINS){this.domains=e;}detect(e){let r=e.toLowerCase().split("@")[1];for(let[n,i]of Object.entries(this.domains))if(i.some(o=>typeof o=="string"?o===r:o.test(r)))return Promise.resolve(n);return Promise.resolve(null)}};var CP=class t{static{this.DEFAULT_DOMAINS={google:["google.com"],microsoft:["outlook.com"]};}constructor(e=t.DEFAULT_DOMAINS){this.domains=e;}async detect(e){let r=e.toLowerCase().split("@")[1],n=await this.lookup(r);for(let[i,s]of Object.entries(this.domains))for(let o of s)for(let a of n)if(a.endsWith(`.${o}.`))return i;return null}async lookup(e){let r=new URL("https://dns.google.com/resolve");r.searchParams.set("type","MX"),r.searchParams.set("name",e);let n;try{n=await fetch(r).then(i=>{if(!i.ok)throw new Error("Failed to lookup domain");return i.json()});}catch{return []}return n.Answer===void 0?[]:n.Answer.map(i=>i.data)}};var $m=me(Mu()),wP=class t{generate(e){return new URL(`https://mail.google.com/mail${t.formatFilters(e)}`)}static formatFilters(e){let r=[`to:${e.recipient}`],n=`/u/${e.recipient}`;if(e.sender!==void 0&&r.push(`from:${e.sender}`),e.subject!==void 0&&r.push(`subject:${e.subject}`),e.timestamp!==void 0){let i=$m.TimeZone.of(Intl.DateTimeFormat().resolvedOptions().timeZone),s=$m.Instant.ofEpochSecond(e.timestamp),o=$m.LocalDateTime.ofInstant(s,i).getLocalDate();r.push(`after:${o}`);}return r.push("in:anywhere"),n+=`/#search/${r.map(i=>encodeURIComponent(i)).join("+")}`,n}};var AP=class{generate(e){return new URL("https://www.icloud.com/mail")}};var IP=class{generate(e){let r=new URL("https://outlook.live.com/mail");return e.recipient!==void 0&&r.searchParams.append("login_hint",e.recipient),r}};var OP=class t{generate(e){return new URL(`https://mail.proton.me/u/0/all-mail${t.formatFilters(e)}`)}static formatFilters(e){let r=new URLSearchParams;return r.set("to",e.recipient),e.sender!==void 0&&r.set("from",e.sender),e.timestamp!==void 0&&r.set("begin",e.timestamp.toFixed(0)),e.subject!==void 0&&r.set("keyword",e.subject),`#${r.toString()}`}};var _P=class t{generate(e){return new URL(`https://mail.yahoo.com/d/search${t.formatFilters(e)}`)}static formatFilters(e){let r=[`to:${e.recipient}`];return e.sender!==void 0&&r.push(`from:${e.sender}`),e.subject!==void 0&&r.push(`subject:${e.subject}`),e.timestamp!==void 0&&r.push(`after:"${new Date(e.timestamp*1e3).toISOString().split("T")[0]}"`),r.length===0?"":`/keyword=${r.join(" ")}`}};var fb=class{constructor(e){this.config=e;}async execute(e){let{fileSystem:r,io:n}=this.config,i=await this.createTemplate(e.empty??false),s=e.file??r.joinPaths(".","template.json5");try{let o=!1;await r.exists(s)&&(o=await n.input?.confirm({message:`Overwrite existing file at \`${s}\`?`,default:!1})??!1),await r.writeTextFile(s,JSON.stringify(i,null,2),{overwrite:o});}catch(o){throw new V("Failed to write template file",{reason:"other",cause:o})}n.output.confirm(`Template created at \`${s}\``);}async createTemplate(e){return {$schema:"https://schema.croct.com/json/v1/template.json",title:"My template",description:"My template description",actions:e?[{name:"print",semantics:"info",title:"Empty template",message:"Edit this template to define your actions."}]:[{name:"create-resource",resources:await this.exportResources()}]}}async exportResources(){let{configurationManager:e,templateForm:r}=this.config,n=await e.load(),i=await r.handle({organizationSlug:n.organization,workspaceSlug:n.workspace}),s={audiences:Object.fromEntries(i.audiences.map(o=>[o.slug,{name:o.name,criteria:o.criteria}])),components:Object.fromEntries(i.components.map(o=>[o.slug,{name:o.name,description:o.description,schema:o.definition}])),slots:Object.fromEntries(i.slots.map(o=>[o.slug,{name:o.name,component:o.component?.slug??"",content:o.content}])),experiences:i.experiences.map(o=>{let{experiment:a}=o,l=a!==void 0?{name:a.name??"",goalId:a.goalId,crossDevice:a.crossDevice,traffic:a.traffic??1,variants:a.variants.map(u=>({name:u.name??"",content:{...u.content,segmented:u.content.segmented.map(({id:c,...p})=>p)},baseline:u.baseline,allocation:u.allocation??1e3/a.variants.length}))}:void 0;return {name:o.name,draft:o.status==="DRAFT",audiences:o.audiences,slots:o.slots,content:{...o.content,segmented:o.content.segmented.map(({id:u,...c})=>c)},...l!==void 0?{experiment:l}:{}}})};for(let[o,a]of Object.entries(s))typeof a=="object"&&a!==null&&(Array.isArray(a)&&a.length===0||Object.keys(a).length===0)&&delete s[o];return s}};var kP=class{constructor(e){this.config=e;}async handle(e){let{input:r,form:n}=this.config,i={components:[],slots:[],audiences:[],experiences:[]},s=new Set,o=new Set,a=await n.experience.handle({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug,confirmation:"Do you want to include experiences?"});if(a.length>0){for(let u of a.flatMap(c=>c.audiences))s.add(u);for(let u of a.flatMap(c=>c.slots))o.add(u);i.experiences=a,a.some(u=>u.experiment!==void 0)&&(await r.confirm({message:"Include experiments?",default:false})||(i.experiences=i.experiences.map(u=>{let{experiment:c,...p}=u;return p})));}i.slots=await n.slot.handle({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug,selected:[...o],selectionConfirmation:{message:o.size>0?"Do you want to include other slots?":"Do you want to include slots?",default:false}});let l=new Set(i.slots.map(u=>u.component?.slug??""));return i.components=await n.component.handle({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug,includeDependencies:true,selected:[...l],selectionConfirmation:{message:l.size>0?"Do you want to include other components?":"Do you want to include components?",default:false}}),i.audiences=await n.audience.handle({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug,selected:[...s],selectionConfirmation:{message:s.size>0?"Do you want to include other audiences?":"Do you want to include audiences?",default:false}}),i}};var NP=class{constructor(e){this.config=e;}async handle(e){let{output:r,input:n,workspaceApi:i}=this.config,s=r.notify("Loading experiences"),o=await i.getExperiences({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug});s.stop();let{confirmation:a}=e;if(o.length===0||a!==void 0&&!await n.confirm({message:a}))return [];let l=await n.selectMultiple({message:"Select experiences",options:o.map(c=>({value:c,label:c.name}))});s=r.notify("Loading details");let u=await Promise.all(l.flatMap(async({id:c})=>{let p=await i.getExperience({experienceId:c,organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug});return p===null?[]:[p]}));return s.stop(),u.flat()}};var FP=class{constructor(e){this.config=e;}async handle(e){let{output:r,input:n}=this.config,i=r.notify("Loading audiences"),s=await this.getAudiences(e,e.allowed);i.stop();let o=e.preselected??[];if(o.length>0)return s.filter(({slug:l})=>o.includes(l));let a=e.selected??[];return s.length===0||a.length>0&&s.every(({slug:l})=>a.includes(l))?s.filter(({slug:l})=>a.includes(l)):e.selectionConfirmation!==void 0&&!await n.confirm(e.selectionConfirmation)?s.filter(({slug:u})=>a.includes(u)):n.selectMultiple({message:"Select audiences",options:s.map(l=>{let u=a.includes(l.slug);return {value:l,label:l.name,disabled:u,selected:u}})})}async getAudiences(e,r){let{workspaceApi:n}=this.config,i=await n.getAudiences({organizationSlug:e.organizationSlug,workspaceSlug:e.workspaceSlug});return r===void 0?i:i.filter(({slug:s})=>r.includes(s))}};var De=class t extends V{constructor(e,{tracing:r,...n}={}){super(e,n),this.tracing=r??[],Object.setPrototypeOf(this,t.prototype);}static fromCause(e,r={}){let{message:n,...i}=r;if(!(e instanceof Error))return new t(n??V.formatMessage(e),{...i,cause:e});let s=new t(n??e.message,{cause:e,...e instanceof V?e.help:{},...i,tracing:[...i.tracing??[],...e instanceof t?e.tracing:[]]});return s.stack=e.stack,s}};var Um=class{constructor(e){this.variables={};this.input=e.input,this.output=e.output,this.baseUrl=e.baseUrl;}getVariables(){return structuredClone(this.variables)}set(e,r){this.variables[e]=r;}};var RP=class{constructor(e){this.config=e;}async getOptions(e){let{templateProvider:r}=this.config;return (await r.get(await this.resolveUrl(e))).value.options??{}}async execute(e){let{action:r,io:n}=this.config,{template:i,options:s}=e,o=await this.resolveUrl(i);return r.execute({template:o.toString(),options:s},new Um({input:n.input,output:n.output,baseUrl:o}))}async resolveUrl(e){let{fileSystem:r}=this.config,n=e;if(URL.canParse(e)){let i=new URL(e.replace(/(?<=^[a-z]+:\/*)([^/.:]+)/i,s=>s.replace(/@/g,"%40")));if(i.protocol!=="file:")return i;n=r.normalizeSeparators(i.pathname);}try{return new URL(`file://${await r.getRealPath(n)}`)}catch(i){throw new De(`Template file not found at \`${n}\`.`,{reason:"invalid_input",cause:i,suggestions:["Check the file path and try again."]})}}};var $3=(t,e,r)=>{let n=t instanceof RegExp?hse(t,r):t,i=e instanceof RegExp?hse(e,r):e,s=n!==null&&i!=null&&xat(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},hse=(t,e)=>{let r=e.match(t);return r?r[0]:null},xat=(t,e,r)=>{let n,i,s,o,a,l=r.indexOf(t),u=r.indexOf(e,l+1),c=l;if(l>=0&&u>0){if(t===e)return [l,u];for(n=[],s=r.length;c>=0&&!a;){if(c===l)n.push(c),l=r.indexOf(t,c+1);else if(n.length===1){let p=n.pop();p!==void 0&&(a=[p,u]);}else i=n.pop(),i!==void 0&&i<s&&(s=i,o=u),u=r.indexOf(e,c+1);c=l<u&&l>=0?l:u;}n.length&&o!==void 0&&(a=[s,o]);}return a};var yse="\0SLASH"+Math.random()+"\0",gse="\0OPEN"+Math.random()+"\0",q3="\0CLOSE"+Math.random()+"\0",bse="\0COMMA"+Math.random()+"\0",Sse="\0PERIOD"+Math.random()+"\0",Tat=new RegExp(yse,"g"),Dat=new RegExp(gse,"g"),Pat=new RegExp(q3,"g"),Cat=new RegExp(bse,"g"),wat=new RegExp(Sse,"g"),Aat=/\\\\/g,Iat=/\\{/g,Oat=/\\}/g,_at=/\\,/g,kat=/\\\./g,Nat=1e5;function U3(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function Fat(t){return t.replace(Aat,yse).replace(Iat,gse).replace(Oat,q3).replace(_at,bse).replace(kat,Sse)}function Rat(t){return t.replace(Tat,"\\").replace(Dat,"{").replace(Pat,"}").replace(Cat,",").replace(wat,".")}function Ese(t){if(!t)return [""];let e=[],r=$3("{","}",t);if(!r)return t.split(",");let{pre:n,body:i,post:s}=r,o=n.split(",");o[o.length-1]+="{"+i+"}";let a=Ese(s);return s.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),e.push.apply(e,o),e}function vse(t,e={}){if(!t)return [];let{max:r=Nat}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),mb(Fat(t),r,true).map(Rat)}function Mat(t){return "{"+t+"}"}function Lat(t){return /^-?0\d/.test(t)}function jat(t,e){return t<=e}function Bat(t,e){return t>=e}function mb(t,e,r){let n=[],i=$3("{","}",t);if(!i)return [t];let s=i.pre,o=i.post.length?mb(i.post,e,false):[""];if(/\$$/.test(i.pre))for(let a=0;a<o.length&&a<e;a++){let l=s+"{"+i.body+"}"+o[a];n.push(l);}else {let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),u=a||l,c=i.body.indexOf(",")>=0;if(!u&&!c)return i.post.match(/,(?!,).*\}/)?(t=i.pre+"{"+i.body+q3+i.post,mb(t,e,true)):[t];let p;if(u)p=i.body.split(/\.\./);else if(p=Ese(i.body),p.length===1&&p[0]!==void 0&&(p=mb(p[0],e,false).map(Mat),p.length===1))return o.map(f=>i.pre+p[0]+f);let d;if(u&&p[0]!==void 0&&p[1]!==void 0){let f=U3(p[0]),h=U3(p[1]),m=Math.max(p[0].length,p[1].length),y=p.length===3&&p[2]!==void 0?Math.max(Math.abs(U3(p[2])),1):1,b=jat;h<f&&(y*=-1,b=Bat);let T=p.some(Lat);d=[];for(let D=f;b(D,h)&&d.length<e;D+=y){let C;if(l)C=String.fromCharCode(D),C==="\\"&&(C="");else if(C=String(D),T){let L=m-C.length;if(L>0){let R=new Array(L+1).join("0");D<0?C="-"+R+C.slice(1):C=R+C;}}d.push(C);}}else {d=[];for(let f=0;f<p.length;f++)d.push.apply(d,mb(p[f],e,false));}for(let f=0;f<d.length;f++)for(let h=0;h<o.length&&n.length<e;h++){let m=s+d[f]+o[h];(!r||u||m)&&n.push(m);}}return n}var hb=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var $at={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",true],"[:alpha:]":["\\p{L}\\p{Nl}",true],"[:ascii:]":["\\x00-\\x7f",false],"[:blank:]":["\\p{Zs}\\t",true],"[:cntrl:]":["\\p{Cc}",true],"[:digit:]":["\\p{Nd}",true],"[:graph:]":["\\p{Z}\\p{C}",true,true],"[:lower:]":["\\p{Ll}",true],"[:print:]":["\\p{C}",true],"[:punct:]":["\\p{P}",true],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",true],"[:upper:]":["\\p{Lu}",true],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",true],"[:xdigit:]":["A-Fa-f0-9",false]},yb=t=>t.replace(/[[\]\\-]/g,"\\$&"),Uat=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),xse=t=>t.join(""),Tse=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=false,a=false,l=false,u=false,c=r,p="";e:for(;s<t.length;){let m=t.charAt(s);if((m==="!"||m==="^")&&s===r+1){u=true,s++;continue}if(m==="]"&&o&&!l){c=s+1;break}if(o=true,m==="\\"&&!l){l=true,s++;continue}if(m==="["&&!l){for(let[y,[b,v,T]]of Object.entries($at))if(t.startsWith(y,s)){if(p)return ["$.",false,t.length-r,true];s+=y.length,T?i.push(b):n.push(b),a=a||v;continue e}}if(l=false,p){m>p?n.push(yb(p)+"-"+yb(m)):m===p&&n.push(yb(m)),p="",s++;continue}if(t.startsWith("-]",s+1)){n.push(yb(m+"-")),s+=2;continue}if(t.startsWith("-",s+1)){p=m,s+=2;continue}n.push(yb(m)),s++;}if(c<s)return ["",false,0,false];if(!n.length&&!i.length)return ["$.",false,t.length-r,true];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let m=n[0].length===2?n[0].slice(-1):n[0];return [Uat(m),false,c-r,false]}let d="["+(u?"^":"")+xse(n)+"]",f="["+(u?"":"^")+xse(i)+"]";return [n.length&&i.length?"("+d+"|"+f+")":n.length?d:f,a,c-r,true]};var Ac=(t,{windowsPathsNoEscape:e=false,magicalBraces:r=true}={})=>r?e?t.replace(/\[([^/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?t.replace(/\[([^/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var Js,qat=new Set(["!","?","+","*","@"]),V3=t=>qat.has(t),Dse=t=>V3(t.type),Vat=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),zat=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Wat=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Pse=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Gat="(?!(?:^|/)\\.\\.?(?:$|/))",MP="(?!\\.)",Hat=new Set(["[","."]),Kat=new Set(["..","."]),Jat=new Set("().*{}+?[]^$\\!"),Yat=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z3="[^/]",Cse=z3+"*?",wse=z3+"+?",Xat=0,od=class{type;#i;#r;#t=false;#e=[];#n;#s;#o;#l=false;#a;#u;#c=false;id=++Xat;get depth(){return (this.#n?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return {"@@type":"AST",id:this.id,type:this.type,root:this.#i.id,parent:this.#n?.id,depth:this.depth,partsLength:this.#e.length,parts:this.#e}}constructor(e,r,n={}){this.type=e,e&&(this.#r=true),this.#n=r,this.#i=this.#n?this.#n.#i:this,this.#a=this.#i===this?n:this.#i.#a,this.#o=this.#i===this?[]:this.#i.#o,e==="!"&&!this.#i.#l&&this.#o.push(this),this.#s=this.#n?this.#n.#e.length:0;}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let e of this.#e)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#r=true;return this.#r}toString(){return this.#u!==void 0?this.#u:this.type?this.#u=this.type+"("+this.#e.map(e=>String(e)).join("|")+")":this.#u=this.#e.map(e=>String(e)).join("")}#g(){if(this!==this.#i)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=true;let e;for(;e=this.#o.pop();){if(e.type!=="!")continue;let r=e,n=r.#n;for(;n;){for(let i=r.#s+1;!n.type&&i<n.#e.length;i++)for(let s of e.#e){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#e[i]);}r=n,n=r.#n;}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof Js&&r.#n===this))throw new Error("invalid part: "+r);this.#e.push(r);}}toJSON(){let e=this.type===null?this.#e.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#e.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#i||this.#i.#l&&this.#n?.type==="!")&&e.push({}),e}isStart(){if(this.#i===this)return true;if(!this.#n?.isStart())return false;if(this.#s===0)return true;let e=this.#n;for(let r=0;r<this.#s;r++){let n=e.#e[r];if(!(n instanceof Js&&n.type==="!"))return false}return true}isEnd(){if(this.#i===this||this.#n?.type==="!")return true;if(!this.#n?.isEnd())return false;if(!this.type)return this.#n?.isEnd();let e=this.#n?this.#n.#e.length:0;return this.#s===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this));}clone(e){let r=new Js(this.type,e);for(let n of this.#e)r.copyIn(n);return r}static#p(e,r,n,i,s){let o=i.maxExtglobRecursion??2,a=false,l=false,u=-1,c=false;if(r.type===null){let m=n,y="";for(;m<e.length;){let b=e.charAt(m++);if(a||b==="\\"){a=!a,y+=b;continue}if(l){m===u+1?(b==="^"||b==="!")&&(c=true):b==="]"&&!(m===u+2&&c)&&(l=false),y+=b;continue}else if(b==="["){l=true,u=m,c=false,y+=b;continue}if(!i.noext&&V3(b)&&e.charAt(m)==="("&&s<=o){r.push(y),y="";let T=new Js(b,r);m=Js.#p(e,T,m,i,s+1),r.push(T);continue}y+=b;}return r.push(y),m}let p=n+1,d=new Js(null,r),f=[],h="";for(;p<e.length;){let m=e.charAt(p++);if(a||m==="\\"){a=!a,h+=m;continue}if(l){p===u+1?(m==="^"||m==="!")&&(c=true):m==="]"&&!(p===u+2&&c)&&(l=false),h+=m;continue}else if(m==="["){l=true,u=p,c=false,h+=m;continue}if(!i.noext&&V3(m)&&e.charAt(p)==="("&&(s<=o||r&&r.#d(m))){let b=r&&r.#d(m)?0:1;d.push(h),h="";let v=new Js(m,d);d.push(v),p=Js.#p(e,v,p,i,s+b);continue}if(m==="|"){d.push(h),h="",f.push(d),d=new Js(null,r);continue}if(m===")")return h===""&&r.#e.length===0&&(r.#c=true),d.push(h),h="",r.push(...f,d),p;h+=m;}return r.type=null,r.#r=void 0,r.#e=[e.substring(n-1)],p}#b(e){return this.#m(e,zat)}#m(e,r=Vat){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null)return false;let n=e.#e[0];return !n||typeof n!="object"||n.type===null?false:this.#d(n.type,r)}#d(e,r=Wat){return !!r.get(this.type)?.includes(e)}#S(e,r){let n=e.#e[0],i=new Js(null,n,this.options);i.#e.push(""),n.push(i),this.#h(e,r);}#h(e,r){let n=e.#e[0];this.#e.splice(r,1,...n.#e);for(let i of n.#e)typeof i=="object"&&(i.#n=this);this.#u=void 0;}#E(e){return !!Pse.get(this.type)?.has(e)}#v(e){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null||this.#e.length!==1)return false;let r=e.#e[0];return !r||typeof r!="object"||r.type===null?false:this.#E(r.type)}#x(e){let r=Pse.get(this.type),n=e.#e[0],i=r?.get(n.type);if(!i)return false;this.#e=n.#e;for(let s of this.#e)typeof s=="object"&&(s.#n=this);this.type=i,this.#u=void 0,this.#c=false;}static fromGlob(e,r={}){let n=new Js(null,void 0,r);return Js.#p(e,n,0,r,0),n}toMMPattern(){if(this!==this.#i)return this.#i.toMMPattern();let e=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#a}toRegExpSource(e){let r=e??!!this.#a.dot;if(this.#i===this&&(this.#f(),this.#g()),!Dse(this)){let l=this.isStart()&&this.isEnd()&&!this.#e.some(f=>typeof f!="string"),u=this.#e.map(f=>{let[h,m,y,b]=typeof f=="string"?Js.#T(f,this.#r,l):f.toRegExpSource(e);return this.#r=this.#r||y,this.#t=this.#t||b,h}).join(""),c="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Kat.has(this.#e[0]))){let h=Hat,m=r&&h.has(u.charAt(0))||u.startsWith("\\.")&&h.has(u.charAt(2))||u.startsWith("\\.\\.")&&h.has(u.charAt(4)),y=!r&&!e&&h.has(u.charAt(0));c=m?Gat:y?MP:"";}let p="";return this.isEnd()&&this.#i.#l&&this.#n?.type==="!"&&(p="(?:$|\\/)"),[c+u+p,Ac(u),this.#r=!!this.#r,this.#t]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#y(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let l=this.toString(),u=this;return u.#e=[l],u.type=null,u.#r=void 0,[l,Ac(this.toString()),false,false]}let o=!n||e||r||!MP?"":this.#y(true);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!r?MP:"")+wse;else {let l=this.type==="!"?"))"+(this.isStart()&&!r&&!e?MP:"")+Cse+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+l;}return [a,Ac(s),this.#r=!!this.#r,this.#t]}#f(){if(Dse(this)){let e=0,r=false;do{r=true;for(let n=0;n<this.#e.length;n++){let i=this.#e[n];typeof i=="object"&&(i.#f(),this.#m(i)?(r=false,this.#h(i,n)):this.#b(i)?(r=false,this.#S(i,n)):this.#v(i)&&(r=false,this.#x(i)));}}while(!r&&++e<10)}else for(let e of this.#e)typeof e=="object"&&e.#f();this.#u=void 0;}#y(e){return this.#e.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(e);return this.#t=this.#t||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#T(e,r,n=false){let i=false,s="",o=false,a=false;for(let l=0;l<e.length;l++){let u=e.charAt(l);if(i){i=false,s+=(Jat.has(u)?"\\":"")+u;continue}if(u==="*"){if(a)continue;a=true,s+=n&&/^[*]+$/.test(e)?wse:Cse,r=true;continue}else a=false;if(u==="\\"){l===e.length-1?s+="\\\\":i=true;continue}if(u==="["){let[c,p,d,f]=Tse(e,l);if(d){s+=c,o=o||p,l+=d-1,r=r||f;continue}}if(u==="?"){s+=z3,r=true;continue}s+=Yat(u);}return [s,Ac(e),!!r,o]}};Js=od;var W3=(t,{windowsPathsNoEscape:e=false,magicalBraces:r=false}={})=>r?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var Gi=(t,e,r={})=>(hb(e),!r.nocomment&&e.charAt(0)==="#"?false:new As(e,r).match(t)),Zat=/^\*+([^+@!?*[(]*)$/,Qat=t=>e=>!e.startsWith(".")&&e.endsWith(t),elt=t=>e=>e.endsWith(t),tlt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),rlt=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),nlt=/^\*+\.\*+$/,ilt=t=>!t.startsWith(".")&&t.includes("."),slt=t=>t!=="."&&t!==".."&&t.includes("."),olt=/^\.\*+$/,alt=t=>t!=="."&&t!==".."&&t.startsWith("."),llt=/^\*+$/,ult=t=>t.length!==0&&!t.startsWith("."),clt=t=>t.length!==0&&t!=="."&&t!=="..",plt=/^\?+([^+@!?*[(]*)?$/,dlt=([t,e=""])=>{let r=Ose([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},flt=([t,e=""])=>{let r=_se([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},mlt=([t,e=""])=>{let r=_se([t]);return e?n=>r(n)&&n.endsWith(e):r},hlt=([t,e=""])=>{let r=Ose([t]);return e?n=>r(n)&&n.endsWith(e):r},Ose=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},_se=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},kse=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ase={win32:{sep:"\\"},posix:{sep:"/"}},ylt=kse==="win32"?Ase.win32.sep:Ase.posix.sep;Gi.sep=ylt;var ss=Symbol("globstar **");Gi.GLOBSTAR=ss;var glt="[^/]",blt=glt+"*?",Slt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Elt="(?:(?!(?:\\/|^)\\.).)*?",vlt=(t,e={})=>r=>Gi(r,t,e);Gi.filter=vlt;var Qo=(t,e={})=>Object.assign({},t,e),xlt=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return Gi;let e=Gi;return Object.assign((n,i,s={})=>e(n,i,Qo(t,s)),{Minimatch:class extends e.Minimatch{constructor(i,s={}){super(i,Qo(t,s));}static defaults(i){return e.defaults(Qo(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,s,o={}){super(i,s,Qo(t,o));}static fromGlob(i,s={}){return e.AST.fromGlob(i,Qo(t,s))}},unescape:(n,i={})=>e.unescape(n,Qo(t,i)),escape:(n,i={})=>e.escape(n,Qo(t,i)),filter:(n,i={})=>e.filter(n,Qo(t,i)),defaults:n=>e.defaults(Qo(t,n)),makeRe:(n,i={})=>e.makeRe(n,Qo(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,Qo(t,i)),match:(n,i,s={})=>e.match(n,i,Qo(t,s)),sep:e.sep,GLOBSTAR:ss})};Gi.defaults=xlt;var Nse=(t,e={})=>(hb(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:vse(t,{max:e.braceExpandMax}));Gi.braceExpand=Nse;var Tlt=(t,e={})=>new As(t,e).makeRe();Gi.makeRe=Tlt;var Dlt=(t,e,r={})=>{let n=new As(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};Gi.match=Dlt;var Ise=/[?*]|[+@!]\(.*?\)|\[|\]/,Plt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),As=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,r={}){hb(e),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=e,this.platform=r.platform||kse,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!r.nonegate,this.comment=false,this.empty=false,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make();}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return true;for(let e of this.set)for(let r of e)if(typeof r!="string")return true;return false}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=s[0]===""&&s[1]===""&&(s[2]==="?"||!Ise.test(s[2]))&&!Ise.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(l)return [...s.slice(0,4),...s.slice(4).map(c=>this.parse(c))];if(u)return [s[0],...s.slice(1).map(c=>this.parse(c))]}return s.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(false)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?");}this.debug(this.pattern,this.set);}preprocess(e){if(this.options.noglobstar)for(let n of e)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n);}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=false;do{if(r=false,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(r=true,e.splice(i,1),i--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=true,e.pop());}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=true,e.splice(n-1,2),n-=2);}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=false;do{r=false;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],l=n[i+2],u=n[i+3];if(a!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;r=true,n.splice(i,1);let c=n.slice(0);c[i]="**",e.push(c),i--;}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=true,n.splice(o,1),o--);}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=true,n.pop());}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=true;let l=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...l),n.length===0&&n.push(""),s-=2;}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=false){let i=0,s=0,o=[],a="";for(;i<e.length&&s<r.length;)if(e[i]===r[s])o.push(a==="b"?r[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&r[s]===e[i+1])o.push(e[i]),i++;else if(n&&r[s]==="**"&&e[i]===r[s+1])o.push(r[s]),s++;else if(e[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return false;a="a",o.push(e[i]),i++,s++;}else if(r[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return false;a="b",o.push(r[s]),i++,s++;}else return false;return e.length===r.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=false,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r;}matchOne(e,r,n=false){let i=0,s=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),l=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),u=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),c=!u&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),p=l?3:a?0:void 0,d=c?3:u?0:void 0;if(typeof p=="number"&&typeof d=="number"){let[f,h]=[e[p],r[d]];f.toLowerCase()===h.toLowerCase()&&(r[d]=f,s=d,i=p);}}let{optimizationLevel:o=1}=this.options;return o>=2&&(e=this.levelTwoFileOptimize(e)),r.includes(ss)?this.#i(e,r,n,i,s):this.#t(e,r,n,i,s)}#i(e,r,n,i,s){let o=r.indexOf(ss,s),a=r.lastIndexOf(ss),[l,u,c]=n?[r.slice(s,o),r.slice(o+1),[]]:[r.slice(s,o),r.slice(o+1,a),r.slice(a+1)];if(l.length){let v=e.slice(i,i+l.length);if(!this.#t(v,l,n,0,0))return false;i+=l.length,s+=l.length;}let p=0;if(c.length){if(c.length+i>e.length)return false;let v=e.length-c.length;if(this.#t(e,c,n,v,0))p=c.length;else {if(e[e.length-1]!==""||i+c.length===e.length||(v--,!this.#t(e,c,n,v,0)))return false;p=c.length+1;}}if(!u.length){let v=!!p;for(let T=i;T<e.length-p;T++){let D=String(e[T]);if(v=true,D==="."||D===".."||!this.options.dot&&D.startsWith("."))return false}return n||v}let d=[[[],0]],f=d[0],h=0,m=[0];for(let v of u)v===ss?(m.push(h),f=[[],0],d.push(f)):(f[0].push(v),h++);let y=d.length-1,b=e.length-p;for(let v of d)v[1]=b-(m[y--]+v[0].length);return !!this.#r(e,d,i,0,n,0,!!p)}#r(e,r,n,i,s,o,a){let l=r[i];if(!l){for(let p=n;p<e.length;p++){a=true;let d=e[p];if(d==="."||d===".."||!this.options.dot&&d.startsWith("."))return false}return a}let[u,c]=l;for(;n<=c;){if(this.#t(e.slice(0,n+u.length),u,s,n,0)&&o<this.maxGlobstarRecursion){let f=this.#r(e,r,n+u.length,i+1,s,o+1,a);if(f!==false)return f}let d=e[n];if(d==="."||d===".."||!this.options.dot&&d.startsWith("."))return false;n++;}return s||null}#t(e,r,n,i,s){let o,a,l,u;for(o=i,a=s,u=e.length,l=r.length;o<u&&a<l;o++,a++){this.debug("matchOne loop");let c=r[a],p=e[o];if(this.debug(r,c,p),c===false||c===ss)return false;let d;if(typeof c=="string"?(d=p===c,this.debug("string match",c,p,d)):(d=c.test(p),this.debug("pattern match",c,p,d)),!d)return false}if(o===u&&a===l)return true;if(o===u)return n;if(a===l)return o===u-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return Nse(this.pattern,this.options)}parse(e){hb(e);let r=this.options;if(e==="**")return ss;if(e==="")return "";let n,i=null;(n=e.match(llt))?i=r.dot?clt:ult:(n=e.match(Zat))?i=(r.nocase?r.dot?rlt:tlt:r.dot?elt:Qat)(n[1]):(n=e.match(plt))?i=(r.nocase?r.dot?flt:dlt:r.dot?mlt:hlt)(n):(n=e.match(nlt))?i=r.dot?slt:ilt:(n=e.match(olt))&&(i=alt);let s=od.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let e=this.set;if(!e.length)return this.regexp=false,this.regexp;let r=this.options,n=r.noglobstar?blt:r.dot?Slt:Elt,i=new Set(r.nocase?["i"]:[]),s=e.map(l=>{let u=l.map(p=>{if(p instanceof RegExp)for(let d of p.flags.split(""))i.add(d);return typeof p=="string"?Plt(p):p===ss?ss:p._src});u.forEach((p,d)=>{let f=u[d+1],h=u[d-1];p!==ss||h===ss||(h===void 0?f!==void 0&&f!==ss?u[d+1]="(?:\\/|"+n+"\\/)?"+f:u[d]=n:f===void 0?u[d-1]=h+"(?:\\/|\\/"+n+")?":f!==ss&&(u[d-1]=h+"(?:\\/|\\/"+n+"\\/)"+f,u[d+1]=ss));});let c=u.filter(p=>p!==ss);if(this.partial&&c.length>=1){let p=[];for(let d=1;d<=c.length;d++)p.push(c.slice(0,d).join("/"));return "(?:"+p.join("|")+")"}return c.join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+a+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return false;if(this.empty)return e==="";if(e==="/"&&r)return true;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a of s){let l=i;if(n.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,r))return n.flipNegate?true:!this.negate}return n.flipNegate?false:this.negate}static defaults(e){return Gi.defaults(e).Minimatch}};Gi.AST=od;Gi.Minimatch=As;Gi.escape=W3;Gi.unescape=Ac;function ad(t,e){if(URL.canParse(t))return new URL(t);let r=new URL(e.href.replace(/^(.*:)(?!\/)/,"$1/"));return new URL(t,r)}var LP=class{constructor(e){this.config=e;}async execute(e,r){let{fileSystem:n}=this.config,{input:i}=r,s=ad(e.source,r.baseUrl);if(s.protocol==="file:"&&r.baseUrl.protocol!=="file:")throw new De("File URL is not allowed from remote sources for security reasons.",{reason:"precondition",details:[`Source URL: ${s}`]});let o=n.normalizeSeparators(e.destination),{output:a}=r,l=a?.notify("Downloading sources");try{await this.download(s,{...e,destination:o},i);}finally{l?.stop();}e.result?.destination!==void 0&&r.set(e.result.destination,o);}async download(e,r,n){let{provider:i,fileSystem:s,codemod:o}=this.config,{destination:a,overwrite:l=false}=r,u=r.filter!==void 0?new As(r.filter):void 0,{value:c}=await i.get(e),p=[],d=Object.fromEntries(Object.entries(r.mapping??{}).map(([f,h])=>[s.normalizeSeparators(f),s.normalizeSeparators(h)]));for await(let f of c){let h=this.resolvePath(s.normalizeSeparators(f.name),d);if(s.isAbsolutePath(h))throw new De("Path to downloaded file cannot be absolute.",{reason:"precondition",details:[`Path: ${h}`],suggestions:["Use relative paths"]});if(!(u!==void 0&&!u.match(h))){if(f.name=s.joinPaths(a,h),f.type==="link"||f.type==="symlink"){let m=s.normalizeSeparators(f.target);if(s.isAbsolutePath(m)||!s.isSubPath(a,m))continue;f.target=m;}p.push(f);}}if(p.length===0)throw new De("No matching files found for download.",{reason:"unexpected_result",details:[`Source: ${e}`,`Filter: ${r.filter??"none"}`]});await this.createDirectory(p,a,l,n);for(let f of p)await s.createDirectory(s.getDirectoryName(f.name),{recursive:true}),await s.create(f);for(let f of p)f.type==="file"&&await o.apply(await s.getRealPath(f.name));}resolvePath(e,r){if(e in r)return r[e];let{fileSystem:n}=this.config,i="",s=e,o=n.getSeparator();for(let[a,l]of Object.entries(r)){let u=a.endsWith(o)?a:a+o;e.startsWith(u)&&u.length>i.length&&(i=u,s=n.joinPaths(l,e.slice(u.length)));}return s}async createDirectory(e,r,n,i){let{fileSystem:s}=this.config;if(!await s.exists(r))return s.createDirectory(r,{recursive:true});if(e.length===1&&e[0].type==="file"){if(!n&&await s.exists(e[0].name)&&await i?.confirm({message:`File ${e[0].name} already exists. Do you want to overwrite it?`,default:false})!==true)throw new De("Destination file already exists.",{reason:"precondition",details:[`File: ${e[0].name}`],suggestions:["Delete the file"]});return}if(await s.isDirectory(r)){if(!n&&!await s.isEmptyDirectory(r)&&await i?.confirm({message:`Directory ${r} is not empty. Do you want to clear it?`,default:false})!==true)throw new De("Destination directory is not empty.",{reason:"precondition",details:[`Directory: ${r}`],suggestions:["Clear the directory"]})}else if(await i?.confirm({message:`Destination ${r} is not a directory. Do you want to delete it?`,default:false})!==true)throw new De("Destination is not a directory.",{reason:"precondition",details:[`Path: ${r}`],suggestions:["Delete the file"]});await s.delete(r,{recursive:true}),await s.createDirectory(r,{recursive:true});}};var jP=class{constructor({packageManager:e}){this.packageManager=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Installing dependencies");try{await this.packageManager.addDependencies(e.dependencies,{dev:e.development??!1,logger:new wi({status:"Installing dependencies",notifier:i})});}catch(s){throw De.fromCause(s)}finally{i?.stop();}}};var qm=class t{constructor(e){this.matcher=e;}static fromPattern(e){return new t(new As(e.replace(/^\.\//,"").replace(/\\/g,"/")))}test(e){return Promise.resolve(this.matcher.match(e))}};var BP=class{constructor({projectDirectory:e,fileSystem:r,scanFilter:n}){this.projectDirectory=e,this.fileSystem=r,this.scanFilter=n;}async execute(e,r){let{output:n}=r,i=n?.notify("Locating files");try{await this.findMatches(e,r);}finally{i?.stop();}}async findMatches(e,r){r.set(e.result,await this.findMatch(e.path,e));}async findMatch(e,r){let n=(o,a)=>r.depth!==void 0&&a>r.depth?false:this.scanFilter!==void 0?this.scanFilter(o,a):true,i=[],s=qm.fromPattern(e);for await(let o of this.fileSystem.list(this.projectDirectory.get(),n))if(await s.test(o.name)){if(r.matcher===void 0)i.push(o.name);else if(o.type==="file"){let a=await new Response(o.content).text();this.matches(a,r.matcher)&&i.push(o.name);}if(r.limit!==void 0&&i.length>=r.limit)break}return i}matches(e,r){if("pattern"in r)return new RegExp(r.pattern,r.caseSensitive===true?"i":void 0).test(e);switch(r.type){case "and":return r.matchers.every(n=>this.matches(e,n));case "or":return r.matchers.some(n=>this.matches(e,n))}}};var $P=class{constructor({fileSystem:e}){this.fileSystem=e;}async execute(e,r){let{output:n}=r,i=n.notify("Replacing file content");try{await this.replaceFiles(e);}finally{i.stop();}}async replaceFiles(e){let r=false;for(let{path:n,replacements:i}of e.files){let s=this.fileSystem.normalizeSeparators(n);if(await this.fileSystem.exists(s)){r=true;try{await this.fileSystem.writeTextFile(s,this.replaceContent(await this.fileSystem.readTextFile(s),i),{overwrite:!0});}catch(o){throw De.fromCause(o)}}}if(!r)throw new De("No files matched for content replacement.",{reason:"unexpected_result"})}replaceContent(e,r){let n=e;for(let{pattern:i,caseSensitive:s,value:o}of r){let a=s===true?"gi":"g";n=n.replace(new RegExp(i,a),`${o}`);}return n}};var UP=class{constructor({installer:e}){this.installer=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Installing slots");try{await this.installer(e.slots,e.example===!0);}catch(s){throw De.fromCause(s)}finally{i?.stop();}}};var qP=class{constructor({installer:e}){this.installer=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Installing components");try{await this.installer(e.components);}catch(s){throw De.fromCause(s)}finally{i?.stop();}}};var VP=class{constructor(e){this.runner=e;}async execute(e,r){try{await this.run(e.action,r);}catch(n){if(e.else===void 0)throw e.help===void 0?n:De.fromCause(n,{...e.help,reason:"precondition"});await this.run(e.else,r);}finally{e.finally!==void 0&&await this.run(e.finally,r);}}run(e,r){return this.runner.execute({actions:e},r)}};var Gn=class t extends V{constructor(e,r={}){super(e,r),Object.setPrototypeOf(this,t.prototype);}};var Ic=class{constructor(e){this.provider=e;}get action(){return Promise.resolve(this.provider.get()).catch(e=>{throw e instanceof Gn?new De(e.message,e.help):e})}async execute(e,r){return (await this.action).execute(e,r)}};var zP=class{constructor(e){this.manager=e;}isInitialized(e){return this.manager.isInitialized(e)}load(){return this.configuration===void 0&&(this.configuration=this.manager.load()),this.configuration}loadPartial(){return this.manager.loadPartial()}update(e){return this.configuration=this.manager.update(e),this.configuration}};var G3;(i=>{function t(s){let o=new Set(Object.values(s.slots??{}).map(p=>p.component)??[]),a=new Set(s.experiences?.flatMap(p=>p.slots)??[]),l=new Set(s.experiences?.flatMap(p=>p.audiences)??[]),u=(s.experiences??[]).map(p=>({name:p.name,maximumAudiencesPerExperience:p.audiences.length,crossDevice:p.experiment?.crossDevice===true,...e(p)})),c=new Set;for(let p of Object.values(s.slots??{}))for(let d of Object.keys(p.content))c.add(d);for(let p of u){for(let d of p.locales)c.add(d);for(let d of p.audiences)l.add(d);for(let d of p.slots)a.add(d);}return {components:o,slots:a,audiences:l,locales:c,experiences:u}}i.analyze=t;function e(s){let o=r(s.content);for(let a of s.experiment?.variants??[]){let l=r(a.content);l.audiences.forEach(u=>o.audiences.add(u)),l.slots.forEach(u=>o.slots.add(u));}return {...o}}function r(s){let o=new Set,a=new Set,l=0;for(let[p,d]of Object.entries(s.default??{})){o.add(p);for(let[f,h]of Object.entries(d))a.add(f),l=Math.max(l,n(h));}let u=new Set,c=0;for(let p of s.segmented??[]){for(let d of p.audiences)u.add(d);c=Math.max(c,p.audiences.length);for(let[d,f]of Object.entries(p.content)){o.add(d);for(let[h,m]of Object.entries(f))a.add(h),l=Math.max(l,n(m));}}return {slots:o,audiences:u,locales:a,audiencesPerExperience:c,dynamicContentPerContent:l}}function n(s){switch(s.type){case "boolean":case "text":case "number":return s.value.type==="dynamic"?1:0;case "structure":return Object.values(s.attributes).map(n).reduce((o,a)=>o+a,0);case "list":return s.items.map(n).reduce((o,a)=>o+a,0)}}})(G3||={});var WP=class{constructor(e){this.refactoring=e;}refactor(e){return {components:Object.fromEntries(Object.entries(e.components??{}).map(([r,n])=>[this.refactoring.componentMapping[r]??r,{...n,schema:this.refactorSchema(n.schema)}])),slots:Object.fromEntries(Object.entries(e.slots??{}).map(([r,n])=>[this.refactoring.slotMapping[r]??r,this.refactorSlotContent(n)])),audiences:Object.fromEntries(Object.entries(e.audiences??{}).map(([r,n])=>[this.refactoring.audienceMapping[r]??r,n])),experiences:e.experiences?.map(r=>this.refactorExperience(r))??[]}}refactorSchema(e){switch(e.type){case "boolean":case "text":case "number":return e;case "structure":return {...e,attributes:Object.fromEntries(Object.entries(e.attributes).map(([r,n])=>[r,{...n,type:this.refactorSchema(n.type)}]))};case "list":return {...e,items:this.refactorSchema(e.items)};case "union":return {...e,types:Object.fromEntries(Object.entries(e.types).map(([r,n])=>[r,this.refactorSchema(n)]))};case "reference":return {...e,id:this.refactoring.componentMapping[e.id]??e.id}}}refactorSlotContent(e){return {...e,component:this.refactoring.componentMapping[e.component]??e.component,content:this.refactorLocalizedContentMap(e.content)}}refactorExperience(e){let r=e.audiences.slice(0,this.refactoring.maximumAudiencePerExperience),{experiment:n}=e;return {...e,audiences:e.audiences.map(i=>this.refactoring.audienceMapping[i]??i),slots:e.slots.map(i=>this.refactoring.slotMapping[i]??i),experiment:n!==void 0?{...n,variants:n.variants.map(i=>({...i,content:this.refactorPersonalizedContent(i.content,r)})),crossDevice:(n.crossDevice??false)&&this.refactoring.isCrossDeviceFeatureEnabled}:void 0,content:this.refactorPersonalizedContent(e.content,r)}}refactorPersonalizedContent(e,r){return {default:this.refactorSlotContentMap(e.default??{}),segmented:(e.segmented??[]).flatMap(n=>{let i=n.audiences.filter(s=>r.includes(s));return i.length===0?[]:{audiences:i,content:this.refactorSlotContentMap(n.content)}})}}refactorSlotContentMap(e){return Object.fromEntries(Object.entries(e).map(([r,n])=>[this.refactoring.slotMapping[r]??r,this.refactorLocalizedContentMap(n)]))}refactorLocalizedContentMap(e){return Object.fromEntries(Object.entries(e).flatMap(([r,n])=>{let i=this.refactoring.localeMapping[r];return i===null||i!==void 0&&e[i]!==void 0?[]:[[i??r,this.refactorContent(n,{dynamicAttributesPerContent:this.refactoring.dynamicAttributesPerContent})]]}))}refactorContent(e,r){switch(e.type){case "boolean":case "text":case "number":return e.value.type==="dynamic"&&r.dynamicAttributesPerContent>0&&r.dynamicAttributesPerContent--,e.value.type==="static"||r.dynamicAttributesPerContent>0?e:{...e,value:{type:"static",value:e.value.default}};case "structure":return {...e,attributes:Object.fromEntries(Object.entries(e.attributes).map(([n,i])=>[n,this.refactorContent(i,r)]))};case "list":return {...e,items:e.items.map(n=>this.refactorContent(n,r))}}}};var GP=class t{constructor(e){this.config=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Analyzing resources"),s=G3.analyze(e.resources),{configurationManager:o,api:{workspace:a}}=this.config,l=await o.load(),u=await this.getProjectInfo(l);await this.checkMissingResources({...s,locales:new Set},e.resources,u);let c=await this.createPlan(e.resources,s,u);i?.update("Creating resources");let p=await a.createResources({organizationSlug:l.organization,workspaceSlug:l.workspace,...c.resources});if(i?.stop(),n!==void 0){let d=t.getWarnings(s,u.workspace);if(d.length>0)for(let f of d)n.warn(`${f}`);}e.result!==void 0&&t.setVariables(e.result,c,p,r);}async createPlan(e,r,n){let{mappingForm:i,matcher:s}=this.config,o=await s.match({resources:e,workspaceSlug:n.configuration.workspace,organizationSlug:n.configuration.organization}),a=Object.entries(o.audiences).filter(h=>!("id"in h[1])),l=Object.entries(o.components).filter(h=>!("id"in h[1])),u=Object.entries(o.slots).filter(h=>!("id"in h[1])),c=o.experiences.filter(h=>!("id"in h));await this.checkRequiredQuota(n,{components:l.length,slots:u.length,audiences:a.length,experiences:c.length});let p=await i.handle({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace,resources:{audiences:a.map(([h])=>h),components:l.map(([h])=>h),slots:u.map(([h])=>h)}}),d={},{workspace:f}=n;for(let h of r.locales)f.locales.includes(h)||(d[h]=f.defaultLocale);return {matches:o,mapping:p,resources:new WP({componentMapping:p.components,audienceMapping:p.audiences,slotMapping:p.slots,dynamicAttributesPerContent:f.quotas.dynamicAttributesPerContent,maximumAudiencePerExperience:f.quotas.audiencesPerExperience,isCrossDeviceFeatureEnabled:f.features.crossDevice,localeMapping:d}).refactor({components:Object.fromEntries(l),slots:Object.fromEntries(u),audiences:Object.fromEntries(a),experiences:c})}}async getProjectInfo(e){let{api:r}=this.config,[n,i]=await Promise.all([r.organization.getWorkspace({organizationSlug:e.organization,workspaceSlug:e.workspace}),r.workspace.getFeatures({organizationSlug:e.organization,workspaceSlug:e.workspace})]);if(n==null||i==null)throw new V("Workspace not found",{title:"Invalid configuration",reason:"invalid_configuration",details:["The workspace defined in the configuration does not exist"],suggestions:["Check the configuration file"]});return {configuration:e,workspace:{...n,...i}}}async checkRequiredQuota(e,r){let{api:{user:n}}=this.config;for(let[i,s]of Object.entries(r)){let o=t.getRemainingQuota(e.workspace,i);if(o<s){let a=await n.getUser().catch(()=>({email:void 0})),l=new URL("https://croct.com/contact/support");throw l.searchParams.set("subject","limit-increase"),l.searchParams.set("organization",e.configuration.organization),l.searchParams.set("message",`I need more quota for ${i}`),a.email!==void 0&&l.searchParams.set("email",a.email),new V(`Not enough ${i} quota available in your workspace.`,{title:"Insufficient quota",reason:"precondition",links:[{label:"Request more quota",url:l.toString()}],details:[`Available: ${o}`,`Required: ${s}`],suggestions:[`Free up quota by removing unused ${i}`,"Request additional quota from support"]})}}}async checkMissingResources(e,r,n){let i=await this.findMissingResources(e,r,n);for(let[s,o]of Object.entries(i))if(o.size>0)throw new V(`Some ${s} referenced in the template are missing`,{title:"Invalid template",reason:"invalid_input",details:[`Missing ${s}: ${Array.from(o).join(", ")}`],suggestions:["Report this issue to the template author"]})}async findMissingResources(e,r,n){let i=new Set(e.components),s=new Set(e.slots),o=new Set(e.audiences),a=new Set(e.locales);for(let u of Object.keys(r.components??{}))i.delete(u);for(let u of Object.keys(r.slots??{}))s.delete(u);for(let u of Object.keys(r.audiences??{}))o.delete(u);let{api:l}=this.config;return await Promise.all([...[...i].map(async u=>{await l.workspace.getComponent({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace,componentSlug:u})!==null&&i.delete(u);}),...[...s].map(async u=>{await l.workspace.getSlot({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace,slotSlug:u})!==null&&s.delete(u);}),...[...o].map(async u=>{await l.workspace.getAudience({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace,audienceSlug:u})!==null&&o.delete(u);}),(async()=>{if(a.size===0)return;let u=await l.organization.getWorkspace({organizationSlug:n.configuration.organization,workspaceSlug:n.configuration.workspace});for(let c of u?.locales??[])a.delete(c);})()]),{components:i,slots:s,audiences:o,locales:a}}static getRemainingQuota(e,r){let n=r.charAt(0).toUpperCase()+r.slice(1);return e.quotas[`remaining${n}`]}static getWarnings(e,r){let n=[];return Math.max(...e.experiences.map(a=>a.dynamicContentPerContent))>r.quotas.dynamicAttributesPerContent&&n.push("Some dynamic values have been removed from the content to fit the workspace quota"),Math.max(...e.experiences.map(a=>a.audiencesPerExperience))>r.quotas.audiencesPerExperience&&n.push("Some audiences have been removed from the experiences to fit the workspace quota"),Array.from(e.locales).filter(a=>!r.locales.includes(a)).length>0&&n.push("Content in unsupported locales have been mapped to default or dropped"),!r.features.crossDevice&&e.experiences.some(a=>a.crossDevice)&&n.push("Cross-device experiments have been disabled "),n}static setVariables(e,r,n,i){if(e.audiences!==void 0)for(let[a]of Object.entries(r.matches.audiences??{}))e.audiences[a]!==void 0&&i.set(e.audiences[a],r.mapping.audiences[a]??a);if(e.components!==void 0)for(let[a]of Object.entries(r.matches.components??{})){let l=e.components[a];if(l!==void 0){let u=r.mapping.components[a]??a,c=r.matches.components[a]??{};l.id!==void 0&&i.set(l.id,u),l.version!==void 0&&i.set(l.version,"version"in c?c.version.major:1);}}if(e.slots!==void 0)for(let[a]of Object.entries(r.matches.slots??{})){let l=e.slots[a];if(l!==void 0){let u=r.mapping.slots[a]??a,c=r.matches.slots[a]??{};l.id!==void 0&&i.set(l.id,u),l.version!==void 0&&i.set(l.version,"version"in c?c.version.major:1);}}let{experiences:s}=r.matches,o=0;for(let[a,l]of s.entries()){if(e.experiences?.[a]!==void 0&&i.set(e.experiences[a],"id"in l&&l.id!==void 0?l.id:n.experiences[o].experienceId),e.experiments?.[a]!==void 0){let{experiment:u}=l,c=u!==void 0&&"id"in u&&u.id!==void 0?u.id:n.experiences[o].experimentId;c!==void 0&&i.set(e.experiments[a],c);}(!("id"in l)||l.id===void 0)&&o++;}}};var Vm=class t{constructor(e){this.config=e;}static prompt(e){return new t(e).handle()}handle(){let{input:e,unavailableSlugs:r=[]}=this.config;return e.prompt({message:this.config.label,default:this.config.default,initial:this.config.initial,validate:n=>/^[a-z]+(-?[a-z0-9]+)*$/i.test(n)?r.includes(n)?"The entered slug is already in use.":true:"The slug must start with a letter and contain only letters, numbers, and hyphens."})}};var HP=class{constructor(e){this.config=e;}async handle(e){let{input:r,workspaceApi:n}=this.config,{resources:i,...s}=e,o=i.slots??[],a=i.components??[],l=i.audiences??[],[u,c,p]=await Promise.all([o.length>0?n.getSlots(s):new Array,a.length>0?n.getComponents(s):new Array,l.length>0?n.getAudiences(s):new Array]),d=a.filter(v=>c.some(T=>T.slug===v)),f={};if(d.length>0){let v=c.map(T=>T.slug);for(let T of d){let D=await Vm.prompt({input:r,initial:T,unavailableSlugs:v,label:`Component \`${T}\` already exists, enter a new component ID:`});v.push(D),f[T]=D;}}let h=o.filter(v=>u.some(T=>T.slug===v)),m={};if(h.length>0){let v=u.map(T=>T.slug);for(let T of h){let D=await Vm.prompt({input:r,initial:T,unavailableSlugs:v,label:`Slot \`${T}\` already exists, enter a new slot ID:`});v.push(D),m[T]=D;}}let y=l.filter(v=>p.some(T=>T.slug===v)),b={};if(y.length>0){let v=p.map(T=>T.slug);for(let T of y){let D=await Vm.prompt({input:r,initial:T,unavailableSlugs:v,label:`Audience \`${T}\` already exists, enter a new audience ID:`});v.push(D),b[T]=D;}}return {components:f,slots:m,audiences:b}}};var{getOwnPropertyNames:Clt,getOwnPropertySymbols:wlt}=Object,{hasOwnProperty:Alt}=Object.prototype;function H3(t,e){return function(n,i,s){return t(n,i,s)&&e(n,i,s)}}function KP(t){return function(r,n,i){if(!r||!n||typeof r!="object"||typeof n!="object")return t(r,n,i);let{cache:s}=i,o=s.get(r),a=s.get(n);if(o&&a)return o===n&&a===r;s.set(r,n),s.set(n,r);let l=t(r,n,i);return s.delete(r),s.delete(n),l}}function Ilt(t){return t?.[Symbol.toStringTag]}function Fse(t){return Clt(t).concat(wlt(t))}var Olt=Object.hasOwn||((t,e)=>Alt.call(t,e));function ld(t,e){return t===e||!t&&!e&&t!==t&&e!==e}var _lt="__v",klt="__o",Nlt="_owner",{getOwnPropertyDescriptor:Rse,keys:Mse}=Object;function Flt(t,e){return t.byteLength===e.byteLength&&JP(new Uint8Array(t),new Uint8Array(e))}function Rlt(t,e,r){let n=t.length;if(e.length!==n)return false;for(;n-- >0;)if(!r.equals(t[n],e[n],n,n,t,e,r))return false;return true}function Mlt(t,e){return t.byteLength===e.byteLength&&JP(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Llt(t,e){return ld(t.getTime(),e.getTime())}function jlt(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function Blt(t,e){return t===e}function Lse(t,e,r){let n=t.size;if(n!==e.size)return false;if(!n)return true;let i=new Array(n),s=t.entries(),o,a,l=0;for(;(o=s.next())&&!o.done;){let u=e.entries(),c=false,p=0;for(;(a=u.next())&&!a.done;){if(i[p]){p++;continue}let d=o.value,f=a.value;if(r.equals(d[0],f[0],l,p,t,e,r)&&r.equals(d[1],f[1],d[0],f[0],t,e,r)){c=i[p]=true;break}p++;}if(!c)return false;l++;}return true}var $lt=ld;function Ult(t,e,r){let n=Mse(t),i=n.length;if(Mse(e).length!==i)return false;for(;i-- >0;)if(!Bse(t,e,r,n[i]))return false;return true}function gb(t,e,r){let n=Fse(t),i=n.length;if(Fse(e).length!==i)return false;let s,o,a;for(;i-- >0;)if(s=n[i],!Bse(t,e,r,s)||(o=Rse(t,s),a=Rse(e,s),(o||a)&&(!o||!a||o.configurable!==a.configurable||o.enumerable!==a.enumerable||o.writable!==a.writable)))return false;return true}function qlt(t,e){return ld(t.valueOf(),e.valueOf())}function Vlt(t,e){return t.source===e.source&&t.flags===e.flags}function jse(t,e,r){let n=t.size;if(n!==e.size)return false;if(!n)return true;let i=new Array(n),s=t.values(),o,a;for(;(o=s.next())&&!o.done;){let l=e.values(),u=false,c=0;for(;(a=l.next())&&!a.done;){if(!i[c]&&r.equals(o.value,a.value,o.value,a.value,t,e,r)){u=i[c]=true;break}c++;}if(!u)return false}return true}function JP(t,e){let r=t.byteLength;if(e.byteLength!==r||t.byteOffset!==e.byteOffset)return false;for(;r-- >0;)if(t[r]!==e[r])return false;return true}function zlt(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Bse(t,e,r,n){return (n===Nlt||n===klt||n===_lt)&&(t.$$typeof||e.$$typeof)?true:Olt(e,n)&&r.equals(t[n],e[n],n,n,t,e,r)}var Wlt="[object ArrayBuffer]",Glt="[object Arguments]",Hlt="[object Boolean]",Klt="[object DataView]",Jlt="[object Date]",Ylt="[object Error]",Xlt="[object Map]",Zlt="[object Number]",Qlt="[object Object]",eut="[object RegExp]",tut="[object Set]",rut="[object String]",nut={"[object Int8Array]":true,"[object Uint8Array]":true,"[object Uint8ClampedArray]":true,"[object Int16Array]":true,"[object Uint16Array]":true,"[object Int32Array]":true,"[object Uint32Array]":true,"[object Float16Array]":true,"[object Float32Array]":true,"[object Float64Array]":true,"[object BigInt64Array]":true,"[object BigUint64Array]":true},iut="[object URL]",sut=Object.prototype.toString;function out({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:o,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:u,areRegExpsEqual:c,areSetsEqual:p,areTypedArraysEqual:d,areUrlsEqual:f,unknownTagComparators:h}){return function(y,b,v){if(y===b)return true;if(y==null||b==null)return false;let T=typeof y;if(T!==typeof b)return false;if(T!=="object")return T==="number"?a(y,b,v):T==="function"?s(y,b,v):false;let D=y.constructor;if(D!==b.constructor)return false;if(D===Object)return l(y,b,v);if(Array.isArray(y))return e(y,b,v);if(D===Date)return n(y,b,v);if(D===RegExp)return c(y,b,v);if(D===Map)return o(y,b,v);if(D===Set)return p(y,b,v);let C=sut.call(y);if(C===Jlt)return n(y,b,v);if(C===eut)return c(y,b,v);if(C===Xlt)return o(y,b,v);if(C===tut)return p(y,b,v);if(C===Qlt)return typeof y.then!="function"&&typeof b.then!="function"&&l(y,b,v);if(C===iut)return f(y,b,v);if(C===Ylt)return i(y,b,v);if(C===Glt)return l(y,b,v);if(nut[C])return d(y,b,v);if(C===Wlt)return t(y,b,v);if(C===Klt)return r(y,b,v);if(C===Hlt||C===Zlt||C===rut)return u(y,b,v);if(h){let L=h[C];if(!L){let R=Ilt(y);R&&(L=h[R]);}if(L)return L(y,b,v)}return false}}function aut({circular:t,createCustomConfig:e,strict:r}){let n={areArrayBuffersEqual:Flt,areArraysEqual:r?gb:Rlt,areDataViewsEqual:Mlt,areDatesEqual:Llt,areErrorsEqual:jlt,areFunctionsEqual:Blt,areMapsEqual:r?H3(Lse,gb):Lse,areNumbersEqual:$lt,areObjectsEqual:r?gb:Ult,arePrimitiveWrappersEqual:qlt,areRegExpsEqual:Vlt,areSetsEqual:r?H3(jse,gb):jse,areTypedArraysEqual:r?H3(JP,gb):JP,areUrlsEqual:zlt,unknownTagComparators:void 0};if(e&&(n=Object.assign({},n,e(n))),t){let i=KP(n.areArraysEqual),s=KP(n.areMapsEqual),o=KP(n.areObjectsEqual),a=KP(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:i,areMapsEqual:s,areObjectsEqual:o,areSetsEqual:a});}return n}function lut(t){return function(e,r,n,i,s,o,a){return t(e,r,a)}}function uut({circular:t,comparator:e,createState:r,equals:n,strict:i}){if(r)return function(a,l){let{cache:u=t?new WeakMap:void 0,meta:c}=r();return e(a,l,{cache:u,equals:n,meta:c,strict:i})};if(t)return function(a,l){return e(a,l,{cache:new WeakMap,equals:n,meta:void 0,strict:i})};let s={cache:void 0,equals:n,meta:void 0,strict:i};return function(a,l){return e(a,l,s)}}var Tl=Oc();Oc({strict:true});Oc({circular:true});Oc({circular:true,strict:true});Oc({createInternalComparator:()=>ld});Oc({strict:true,createInternalComparator:()=>ld});Oc({circular:true,createInternalComparator:()=>ld});Oc({circular:true,createInternalComparator:()=>ld,strict:true});function Oc(t={}){let{circular:e=false,createInternalComparator:r,createState:n,strict:i=false}=t,s=aut(t),o=out(s),a=r?r(o):lut(o);return uut({circular:e,comparator:o,createState:n,equals:a,strict:i})}var YP=class t{constructor(e){this.config=e;}async match(e){let{resources:r,...n}=e,[i,s,o,a]=await Promise.all([this.mapComponents(r.components??{},n),this.mapSlots(r.slots??{},n),this.mapAudiences(r.audiences??{},n),this.mapExperiences(r.experiences??[],n)]);return {components:i,slots:s,audiences:o,experiences:a}}async mapAudiences(e,r){let{workspaceApi:n}=this.config,i=await Promise.all(Object.keys(e).map(async o=>[o,await n.getAudience({...r,audienceSlug:o})])),s={};for(let[o,a]of i)s[o]=a===null||!t.isSimilarAudience(e[o],a)?e[o]:a;return s}async mapComponents(e,r){let{workspaceApi:n}=this.config,i=await Promise.all(Object.keys(e).map(async o=>[o,await n.getComponent({...r,componentSlug:o})])),s={};for(let[o,a]of i)s[o]=a===null||!t.isSimilarComponent(e[o],a)?e[o]:a;return s}async mapSlots(e,r){let{workspaceApi:n}=this.config,i=await Promise.all(Object.keys(e).map(async o=>[o,await n.getSlot({...r,slotSlug:o})])),s={};for(let[o,a]of i)s[o]=a===null||!t.isSimilarSlot(e[o],a)?e[o]:a;return s}async mapExperiences(e,r){let{workspaceApi:n}=this.config,s=(await n.getExperiences({...r,status:["ACTIVE","PAUSED","DRAFT"]})).map(o=>{let a=null;function l(){return a===null&&(a=n.getExperience({...r,experienceId:o.id})),a}return {...o,details:{get content(){return l().then(u=>u?.content??null)},get experiment(){return l().then(u=>u?.experiment??null)}}}});return Promise.all(e.map(async o=>{for(let a of s)if(await this.matchesExperience(o,a)){let{details:l,...u}=a;return u}return o}))}async matchesExperience(e,r){if((e.draft===true?"DRAFT":"ACTIVE")!==r.status||!Tl(e.audiences,r.audiences)||!Tl(e.slots,r.slots)||e.experiment!==void 0&&r.experiment===void 0)return false;let[i,s=null]=await Promise.all([r.details.content,r.details.experiment]);return e.experiment!==void 0&&(s===null||e.experiment.goalId!==s.goalId||e.experiment.traffic!==s.traffic||e.experiment.crossDevice!==s.crossDevice||!t.isSimilarExperimentContent(e.experiment.variants,s.variants))?false:t.isSimilarPersonalizedContent(e.content,i??{default:{},segmented:[]})}static isSimilarAudience(e,r){return e.criteria===r.criteria}static isSimilarComponent(e,r){return Tl(e.schema,r.definition)}static isSimilarSlot(e,r){return e.component===r.component?.slug&&Object.values(e.content).some(n=>Object.values(r.content).some(i=>Tl(n,i)))}static isSimilarExperimentContent(e,r){return e.length!==r.length?false:e.some((n,i)=>Tl(n,r[i]))}static isSimilarPersonalizedContent(e,r){if(t.isSimilarSlotContent(e.default??{},r.default??{}))return true;for(let n of e.segmented??[])for(let i of r.segmented??[])if(Tl(n.audiences,i.audiences)&&t.isSimilarSlotContent(n.content,i.content))return true;return false}static isSimilarSlotContent(e,r){for(let[n,i]of Object.entries(e)){let s=r[n];if(s!==void 0){for(let o of Object.values(i))if(Object.values(s).some(a=>Tl(o,a)))return true}}return false}};var jr=class t extends Gn{constructor(e,{url:r,...n}){super(e,n),Object.setPrototypeOf(this,t.prototype),this.url=r;}},Dl=class t extends jr{constructor(e,r){super(e,{...r,reason:r.reason??"not_found"}),Object.setPrototypeOf(this,t.prototype);}};var XP=class t{constructor(e={}){this.configuration=e;}async get(e){if(!["http:","https:"].includes(e.protocol))throw new jr("Unsupported protocol.",{reason:"not_supported",url:e});return {url:e,value:await this.fetch(e)}}async fetch(e,r=0){let n=await fetch(e);if(n.status===404)throw new Dl("Resource not found.",{url:e});let{maxAttempts:i=0,delay:s=1e3}=this.configuration.retry??{};if(t.isSuccessful(n))return n;if(t.isRetryableCode(n.status)&&r<i)return await new Promise(o=>{setTimeout(o,s);}),this.fetch(e,r+1);throw new jr(n.statusText,{url:e})}static isSuccessful(e){return e.ok&&e.body!==null}static isRetryableCode(e){return e>=500||[429,408].includes(e)}};var ZP=class{constructor({packageManager:e}){this.packageManager=e;}async execute(e,r){let{output:n}=r,i=n?.notify("Checking dependencies"),s;try{s=await Promise.all(e.dependencies.map(a=>this.checkRequirement(a)));}finally{i?.stop();}let o=[];for(let a of s){if(e?.result?.[a.dependency]!==void 0){r.set(e.result[a.dependency],a.satisfied);continue}a.issue!==void 0&&o.push(a);}if(o.length>0){let{message:a,...l}=e.help??{};throw new De(a??"Missing required dependencies.",{...l,details:o.map(({dependency:u,issue:c})=>`\`${u}\`: ${c}`)})}}async checkRequirement(e){let{name:r,version:n,optional:i=false}=e;if(n===void 0){let o=await this.packageManager.hasDirectDependency(r);if(o||i)return {dependency:r,satisfied:o}}else {let o=await this.packageManager.hasDirectDependency(r,n);if(o||i)return {dependency:r,satisfied:o}}let s=await this.packageManager.getDependency(r);return {dependency:r,satisfied:false,issue:s===null?"not installed":`${n!==void 0?`version \`${n}\` is required`:""}found \`${s.version??"unknown"}\``}}};var ud=class{constructor({dataProvider:e,registryProvider:r,baseUrl:n}){this.dataProvider=e,this.registryProvider=r,this.baseUrl=n;}async get(e){return this.dataProvider.get(await this.resolveUrl(e))}async resolveUrl(e){for(let{pattern:r,destination:n}of await this.loadMappings(e)){let i=e.href.match(typeof r=="string"?new RegExp(r):r);if(i!==null)return n instanceof URL?n:new URL(n.replace(/\$([0-9]+)/g,(s,o)=>i[Number.parseInt(o,10)]),this.baseUrl)}return e}async loadMappings(e){let r=await this.registryProvider.get(e);return Array.isArray(r)?r:r.value}};var Pl=class t{static{this.DEFAULT_EXPECTED_ERRORS=["not_supported","not_found","other"];}constructor({providers:e,expectedErrors:r}){this.providers=e,this.expectedErrors=r??t.DEFAULT_EXPECTED_ERRORS;}async get(e){for(let r of this.providers)try{return await r.get(e)}catch(n){if(!this.isExpectedError(n))throw n}throw new Dl("Resource not found.",{url:e})}isExpectedError(e){return e instanceof jr&&this.expectedErrors.includes(e.reason)}};var QP=class t{constructor(e,r){this.fileSystem=e,this.filter=r;}get(e){if(!t.supportsUrl(e))throw new jr(`Unsupported protocol "${e.protocol}".`,{reason:"not_supported",url:e});return Promise.resolve({url:e,value:this.fileSystem.list(this.fileSystem.normalizeSeparators(e.pathname),this.filter)})}static supportsUrl(e){return e.protocol==="file:"}};var $se=me(DE());var eC=class t{static{this.MAX_DOWNLOAD_FILES=50;}static{this.PROTOCOL="github:";}static{this.API_HOST="api.github.com";}static{this.RAW_HOST="raw.github.com";}static{this.MAIN_HOST="github.com";}constructor({cache:e,provider:r}){this.provider=r,this.cache=e??new $se.NoopCache;}async get(e){let r=this.parseUrl(e);if(r===null)throw new jr("Unsupported GitHub URL.",{reason:"not_supported",url:e});let n=await this.resolveFiles(r),i=await Promise.all(n.map(async s=>({url:s,response:(await this.provider.get(s)).value})));return {url:r.canonicalUrl,value:this.yieldFiles(i,r.path??"")}}async*yieldFiles(e,r){let n=new Set;for(let{url:i,response:s}of e){let o=i.pathname.split("/"),a=o.slice(4),l=a.join("/")===r&&e.length===1?o.slice(-1):a.slice(r.split("/").length);if(l.length>1){let u=l.slice(0,-1);for(let c=0;c<u.length;c++){let p=u.slice(0,c+1).join("/");n.has(p)||(n.add(p),yield {type:"directory",name:p});}}yield {type:"file",name:l.join("/"),content:Readable.fromWeb(s.body)};}}async resolveFiles(e){let{username:r,repository:n,path:i}=e,s=l=>{let u=new URL(`https://${t.RAW_HOST}`);return u.pathname=`/${r}/${n}/${e.ref??"HEAD"}/${l}`,u},o=await this.loadGitTree(e),a=[];if(i===null)a.push(...o.map(l=>s(l.path)));else {let l=o.find(u=>u.path===i);if(l===void 0)throw new jr("File not found.",{reason:"not_found",url:e.canonicalUrl});l.type==="tree"?a.push(...o.filter(u=>u.path.startsWith(i)&&u.type==="blob").map(u=>s(u.path))):a.push(s(i));}if(a.length>t.MAX_DOWNLOAD_FILES)throw new jr(`The number of files to download exceeds the limit of ${t.MAX_DOWNLOAD_FILES}.`,{reason:"precondition",url:e.canonicalUrl});return a}parseUrl(e){if(!t.isUrlSupported(e))return null;let r,n,i=null,s,o=((e.protocol===t.PROTOCOL?e.hostname:"")+e.pathname).replace(/^\/+/,"").split("/"),a=null;return e.hostname===t.MAIN_HOST?(a=e,[r=null,n=null,,i=null,...s]=o):[r=null,n=null,...s]=o,r===null||n===null?null:(a===null&&(a=new URL(`https://${t.MAIN_HOST}`),a.pathname=`/${r}/${n}/blob/master/${s.join("/")}`),{canonicalUrl:a,username:r,repository:n,ref:i,path:s!==void 0&&s.length>0?s.join("/"):null})}loadGitTree({username:e,repository:r,ref:n}){let i=new URL(`https://${t.API_HOST}`);return i.pathname=`repos/${e}/${r}/git/trees/${n??"HEAD"}`,i.searchParams.set("recursive","true"),this.cache.get(i.toString(),()=>this.provider.get(i).then(s=>s.value.json()).then(({tree:s})=>s))}static isUrlSupported(e){return e.protocol==="https:"?e.hostname===t.MAIN_HOST:e.protocol===t.PROTOCOL}};var bb=class t{constructor(e){this.provider=e;}async get(e){if(!t.supportsUrl(e))throw new jr("Unsupported URL.",{reason:"not_supported",url:e});let{value:r,...n}=await this.provider.get(e);return {...n,value:this.yield(r,e)}}static supportsUrl(e){return e.pathname!=="/"}async*yield(e,r){yield {type:"file",name:r.pathname.split("/").pop(),content:Readable.fromWeb(e.body)};}};var g={};Ah(g,{BRAND:()=>Lut,DIRTY:()=>cd,EMPTY_PATH:()=>hut,INVALID:()=>ut,NEVER:()=>vct,OK:()=>os,ParseStatus:()=>Hi,Schema:()=>Nt,ZodAny:()=>wl,ZodArray:()=>Ba,ZodBigInt:()=>dd,ZodBoolean:()=>fd,ZodBranded:()=>Eb,ZodCatch:()=>Td,ZodDate:()=>md,ZodDefault:()=>xd,ZodDiscriminatedUnion:()=>Jm,ZodEffects:()=>Zs,ZodEnum:()=>Ed,ZodError:()=>Ys,ZodFirstPartyTypeKind:()=>ft,ZodFunction:()=>nC,ZodIntersection:()=>gd,ZodIssueCode:()=>he,ZodLazy:()=>bd,ZodLiteral:()=>Sd,ZodMap:()=>Xm,ZodNaN:()=>Qm,ZodNativeEnum:()=>vd,ZodNever:()=>ja,ZodNull:()=>yd,ZodNullable:()=>Il,ZodNumber:()=>pd,ZodObject:()=>as,ZodOptional:()=>Xs,ZodParsedType:()=>Ne,ZodPipeline:()=>Dd,ZodPromise:()=>Al,ZodReadonly:()=>Pd,ZodRecord:()=>Ym,ZodSchema:()=>Nt,ZodSet:()=>Zm,ZodString:()=>kc,ZodSymbol:()=>Hm,ZodTransformer:()=>Zs,ZodTuple:()=>ta,ZodType:()=>Nt,ZodUndefined:()=>hd,ZodUnion:()=>vu,ZodUnknown:()=>Eu,ZodVoid:()=>Km,addIssueToContext:()=>Oe,any:()=>Gut,array:()=>Yut,bigint:()=>Uut,boolean:()=>Xse,coerce:()=>Ect,custom:()=>Kse,date:()=>qut,datetimeRegex:()=>Gse,defaultErrorMap:()=>bu,discriminatedUnion:()=>ect,effect:()=>dct,enum:()=>uct,function:()=>oct,getErrorMap:()=>zm,getParsedType:()=>Cl,instanceof:()=>But,intersection:()=>tct,isAborted:()=>tC,isAsync:()=>Wm,isDirty:()=>rC,isValid:()=>_c,late:()=>jut,lazy:()=>act,literal:()=>lct,makeIssue:()=>Sb,map:()=>ict,nan:()=>$ut,nativeEnum:()=>cct,never:()=>Kut,null:()=>Wut,nullable:()=>mct,number:()=>Yse,object:()=>Xut,objectUtil:()=>K3,oboolean:()=>Sct,onumber:()=>bct,optional:()=>fct,ostring:()=>gct,pipeline:()=>yct,preprocess:()=>hct,promise:()=>pct,quotelessJson:()=>dut,record:()=>nct,set:()=>sct,setErrorMap:()=>mut,strictObject:()=>Zut,string:()=>Jse,symbol:()=>Vut,transformer:()=>dct,tuple:()=>rct,undefined:()=>zut,union:()=>Qut,unknown:()=>Hut,util:()=>Yt,void:()=>Jut});var Yt;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},t.getValidEnumValues=i=>{let s=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(let a of s)o[a]=i[a];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},t.find=(i,s)=>{for(let o of i)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s;})(Yt||(Yt={}));var K3;(function(t){t.mergeShapes=(e,r)=>({...e,...r});})(K3||(K3={}));var Ne=Yt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Cl=t=>{switch(typeof t){case "undefined":return Ne.undefined;case "string":return Ne.string;case "number":return Number.isNaN(t)?Ne.nan:Ne.number;case "boolean":return Ne.boolean;case "function":return Ne.function;case "bigint":return Ne.bigint;case "symbol":return Ne.symbol;case "object":return Array.isArray(t)?Ne.array:t===null?Ne.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Ne.promise:typeof Map<"u"&&t instanceof Map?Ne.map:typeof Set<"u"&&t instanceof Set?Ne.set:typeof Date<"u"&&t instanceof Date?Ne.date:Ne.object;default:return Ne.unknown}};var he=Yt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),dut=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ys=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n];},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n];};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e;}format(e){let r=e||function(s){return s.message},n={_errors:[]},i=s=>{for(let o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else {let a=n,l=0;for(;l<o.path.length;){let u=o.path[l];l===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],l++;}}};return i(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Yt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];r[s]=r[s]||[],r[s].push(e(i));}else n.push(e(i));return {formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ys.create=t=>new Ys(t);var fut=(t,e)=>{let r;switch(t.code){case he.invalid_type:t.received===Ne.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case he.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Yt.jsonStringifyReplacer)}`;break;case he.unrecognized_keys:r=`Unrecognized key(s) in object: ${Yt.joinValues(t.keys,", ")}`;break;case he.invalid_union:r="Invalid input";break;case he.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Yt.joinValues(t.options)}`;break;case he.invalid_enum_value:r=`Invalid enum value. Expected ${Yt.joinValues(t.options)}, received '${t.received}'`;break;case he.invalid_arguments:r="Invalid function arguments";break;case he.invalid_return_type:r="Invalid function return type";break;case he.invalid_date:r="Invalid date";break;case he.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Yt.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case he.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case he.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case he.custom:r="Invalid input";break;case he.invalid_intersection_types:r="Intersection results could not be merged";break;case he.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case he.not_finite:r="Number must be finite";break;default:r=e.defaultError,Yt.assertNever(t);}return {message:r}},bu=fut;var Use=bu;function mut(t){Use=t;}function zm(){return Use}var Sb=t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,s=[...r,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return {...i,path:s,message:i.message};let a="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)a=u(o,{data:e,defaultError:a}).message;return {...i,path:s,message:a}},hut=[];function Oe(t,e){let r=zm(),n=Sb({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===bu?void 0:bu].filter(i=>!!i)});t.common.issues.push(n);}var Hi=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,r){let n=[];for(let i of r){if(i.status==="aborted")return ut;i.status==="dirty"&&e.dirty(),n.push(i.value);}return {status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let i of r){let s=await i.key,o=await i.value;n.push({key:s,value:o});}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let i of r){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return ut;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value);}return {status:e.value,value:n}}},ut=Object.freeze({status:"aborted"}),cd=t=>({status:"dirty",value:t}),os=t=>({status:"valid",value:t}),tC=t=>t.status==="aborted",rC=t=>t.status==="dirty",_c=t=>t.status==="valid",Wm=t=>typeof Promise<"u"&&t instanceof Promise;var Xe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(Xe||(Xe={}));var ea=class{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i;}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},qse=(t,e)=>{if(_c(e))return {success:true,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let r=new Ys(t.common.issues);return this._error=r,this._error}}};function Ct(t){if(!t)return {};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??r??a.defaultError}},description:i}}var Nt=class{get description(){return this._def.description}_getType(e){return Cl(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Cl(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new Hi,ctx:{common:e.parent.common,data:e.data,parsedType:Cl(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Wm(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??false,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cl(e)},i=this._parseSync({data:e,path:n.path,parent:n});return qse(n,i)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cl(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return _c(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),r.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:r}).then(n=>_c(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:true},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cl(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Wm(i)?i:Promise.resolve(i));return qse(n,s)}refine(e,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{let o=e(i),a=()=>s.addIssue({code:he.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?true:(a(),false)):o?true:(a(),false)})}refinement(e,r){return this._refinement((n,i)=>e(n)?true:(i.addIssue(typeof r=="function"?r(n,i):r),false))}_refinement(e){return new Zs({schema:this,typeName:ft.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)};}optional(){return Xs.create(this,this._def)}nullable(){return Il.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ba.create(this)}promise(){return Al.create(this,this._def)}or(e){return vu.create([this,e],this._def)}and(e){return gd.create(this,e,this._def)}transform(e){return new Zs({...Ct(this._def),schema:this,typeName:ft.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new xd({...Ct(this._def),innerType:this,defaultValue:r,typeName:ft.ZodDefault})}brand(){return new Eb({typeName:ft.ZodBranded,type:this,...Ct(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Td({...Ct(this._def),innerType:this,catchValue:r,typeName:ft.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Dd.create(this,e)}readonly(){return Pd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},yut=/^c[^\s-]{8,}$/i,gut=/^[0-9a-z]+$/,but=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Sut=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Eut=/^[a-z0-9_-]{21}$/i,vut=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xut=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Tut=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Dut="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",J3,Put=/^(?:(?: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])$/,Cut=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,wut=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Aut=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Iut=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Out=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zse="((\\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])))",_ut=new RegExp(`^${zse}$`);function Wse(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function kut(t){return new RegExp(`^${Wse(t)}$`)}function Gse(t){let e=`${zse}T${Wse(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Nut(t,e){return !!((e==="v4"||!e)&&Put.test(t)||(e==="v6"||!e)&&wut.test(t))}function Fut(t,e){if(!vut.test(t))return false;try{let[r]=t.split(".");if(!r)return !1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return !(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return false}}function Rut(t,e){return !!((e==="v4"||!e)&&Cut.test(t)||(e==="v6"||!e)&&Aut.test(t))}var kc=class t extends Nt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ne.string){let s=this._getOrReturnCtx(e);return Oe(s,{code:he.invalid_type,expected:Ne.string,received:s.parsedType}),ut}let n=new Hi,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.too_small,minimum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.too_big,maximum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),n.dirty());else if(s.kind==="length"){let o=e.data.length>s.value,a=e.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(e,i),o?Oe(i,{code:he.too_big,maximum:s.value,type:"string",inclusive:true,exact:true,message:s.message}):a&&Oe(i,{code:he.too_small,minimum:s.value,type:"string",inclusive:true,exact:true,message:s.message}),n.dirty());}else if(s.kind==="email")Tut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"email",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")J3||(J3=new RegExp(Dut,"u")),J3.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"emoji",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Sut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"uuid",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Eut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"nanoid",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")yut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"cuid",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")gut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"cuid2",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")but.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"ulid",code:he.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data);}catch{i=this._getOrReturnCtx(e,i),Oe(i,{validation:"url",code:he.invalid_string,message:s.message}),n.dirty();}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"regex",code:he.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Gse(s).test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?_ut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?kut(s).test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?xut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"duration",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Nut(e.data,s.version)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"ip",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?Fut(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"jwt",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?Rut(e.data,s.version)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"cidr",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Iut.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"base64",code:he.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?Out.test(e.data)||(i=this._getOrReturnCtx(e,i),Oe(i,{validation:"base64url",code:he.invalid_string,message:s.message}),n.dirty()):Yt.assertNever(s);return {status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:he.invalid_string,...Xe.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Xe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Xe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Xe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Xe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Xe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Xe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Xe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Xe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Xe.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Xe.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Xe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Xe.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Xe.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...Xe.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Xe.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Xe.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Xe.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Xe.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Xe.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Xe.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Xe.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Xe.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Xe.errToObj(r)})}nonempty(e){return this.min(1,Xe.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return !!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return !!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};kc.create=t=>new kc({checks:[],typeName:ft.ZodString,coerce:t?.coerce??false,...Ct(t)});function Mut(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,s=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return s%o/10**i}var pd=class t extends Nt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Ne.number){let s=this._getOrReturnCtx(e);return Oe(s,{code:he.invalid_type,expected:Ne.number,received:s.parsedType}),ut}let n,i=new Hi;for(let s of this._def.checks)s.kind==="int"?Yt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),i.dirty()):s.kind==="multipleOf"?Mut(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.not_finite,message:s.message}),i.dirty()):Yt.assertNever(s);return {status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,true,Xe.toString(r))}gt(e,r){return this.setLimit("min",e,false,Xe.toString(r))}lte(e,r){return this.setLimit("max",e,true,Xe.toString(r))}lt(e,r){return this.setLimit("max",e,false,Xe.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Xe.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Xe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:Xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:Xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:Xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:Xe.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Xe.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Xe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:Xe.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:Xe.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Yt.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return true;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);}return Number.isFinite(r)&&Number.isFinite(e)}};pd.create=t=>new pd({checks:[],typeName:ft.ZodNumber,coerce:t?.coerce||false,...Ct(t)});var dd=class t extends Nt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data);}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Ne.bigint)return this._getInvalidInput(e);let n,i=new Hi;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),Oe(n,{code:he.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Yt.assertNever(s);return {status:i.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return Oe(r,{code:he.invalid_type,expected:Ne.bigint,received:r.parsedType}),ut}gte(e,r){return this.setLimit("min",e,true,Xe.toString(r))}gt(e,r){return this.setLimit("min",e,false,Xe.toString(r))}lte(e,r){return this.setLimit("max",e,true,Xe.toString(r))}lt(e,r){return this.setLimit("max",e,false,Xe.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Xe.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:Xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:Xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:Xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:Xe.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Xe.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};dd.create=t=>new dd({checks:[],typeName:ft.ZodBigInt,coerce:t?.coerce??false,...Ct(t)});var fd=class extends Nt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ne.boolean){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.boolean,received:n.parsedType}),ut}return os(e.data)}};fd.create=t=>new fd({typeName:ft.ZodBoolean,coerce:t?.coerce||false,...Ct(t)});var md=class t extends Nt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ne.date){let s=this._getOrReturnCtx(e);return Oe(s,{code:he.invalid_type,expected:Ne.date,received:s.parsedType}),ut}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return Oe(s,{code:he.invalid_date}),ut}let n=new Hi,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.too_small,message:s.message,inclusive:true,exact:false,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),Oe(i,{code:he.too_big,message:s.message,inclusive:true,exact:false,maximum:s.value,type:"date"}),n.dirty()):Yt.assertNever(s);return {status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Xe.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Xe.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};md.create=t=>new md({checks:[],coerce:t?.coerce||false,typeName:ft.ZodDate,...Ct(t)});var Hm=class extends Nt{_parse(e){if(this._getType(e)!==Ne.symbol){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.symbol,received:n.parsedType}),ut}return os(e.data)}};Hm.create=t=>new Hm({typeName:ft.ZodSymbol,...Ct(t)});var hd=class extends Nt{_parse(e){if(this._getType(e)!==Ne.undefined){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.undefined,received:n.parsedType}),ut}return os(e.data)}};hd.create=t=>new hd({typeName:ft.ZodUndefined,...Ct(t)});var yd=class extends Nt{_parse(e){if(this._getType(e)!==Ne.null){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.null,received:n.parsedType}),ut}return os(e.data)}};yd.create=t=>new yd({typeName:ft.ZodNull,...Ct(t)});var wl=class extends Nt{constructor(){super(...arguments),this._any=true;}_parse(e){return os(e.data)}};wl.create=t=>new wl({typeName:ft.ZodAny,...Ct(t)});var Eu=class extends Nt{constructor(){super(...arguments),this._unknown=true;}_parse(e){return os(e.data)}};Eu.create=t=>new Eu({typeName:ft.ZodUnknown,...Ct(t)});var ja=class extends Nt{_parse(e){let r=this._getOrReturnCtx(e);return Oe(r,{code:he.invalid_type,expected:Ne.never,received:r.parsedType}),ut}};ja.create=t=>new ja({typeName:ft.ZodNever,...Ct(t)});var Km=class extends Nt{_parse(e){if(this._getType(e)!==Ne.undefined){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.void,received:n.parsedType}),ut}return os(e.data)}};Km.create=t=>new Km({typeName:ft.ZodVoid,...Ct(t)});var Ba=class t extends Nt{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==Ne.array)return Oe(r,{code:he.invalid_type,expected:Ne.array,received:r.parsedType}),ut;if(i.exactLength!==null){let o=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(o||a)&&(Oe(r,{code:o?he.too_big:he.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:i.exactLength.message}),n.dirty());}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Oe(r,{code:he.too_small,minimum:i.minLength.value,type:"array",inclusive:true,exact:false,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Oe(r,{code:he.too_big,maximum:i.maxLength.value,type:"array",inclusive:true,exact:false,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>i.type._parseAsync(new ea(r,o,r.path,a)))).then(o=>Hi.mergeArray(n,o));let s=[...r.data].map((o,a)=>i.type._parseSync(new ea(r,o,r.path,a)));return Hi.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:Xe.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:Xe.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:Xe.toString(r)}})}nonempty(e){return this.min(1,e)}};Ba.create=(t,e)=>new Ba({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ft.ZodArray,...Ct(e)});function Gm(t){if(t instanceof as){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Xs.create(Gm(n));}return new as({...t._def,shape:()=>e})}else return t instanceof Ba?new Ba({...t._def,type:Gm(t.element)}):t instanceof Xs?Xs.create(Gm(t.unwrap())):t instanceof Il?Il.create(Gm(t.unwrap())):t instanceof ta?ta.create(t.items.map(e=>Gm(e))):t}var as=class t extends Nt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend;}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Yt.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Ne.object){let u=this._getOrReturnCtx(e);return Oe(u,{code:he.invalid_type,expected:Ne.object,received:u.parsedType}),ut}let{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof ja&&this._def.unknownKeys==="strip"))for(let u in i.data)o.includes(u)||a.push(u);let l=[];for(let u of o){let c=s[u],p=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ea(i,p,i.path,u)),alwaysSet:u in i.data});}if(this._def.catchall instanceof ja){let u=this._def.unknownKeys;if(u==="passthrough")for(let c of a)l.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(u==="strict")a.length>0&&(Oe(i,{code:he.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let u=this._def.catchall;for(let c of a){let p=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ea(i,p,i.path,c)),alwaysSet:c in i.data});}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let c of l){let p=await c.key,d=await c.value;u.push({key:p,value:d,alwaysSet:c.alwaysSet});}return u}).then(u=>Hi.mergeObjectSync(n,u)):Hi.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return Xe.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Xe.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ft.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of Yt.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of Yt.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Gm(this)}partial(e){let r={};for(let n of Yt.objectKeys(this.shape)){let i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional();}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of Yt.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else {let s=this.shape[n];for(;s instanceof Xs;)s=s._def.innerType;r[n]=s;}return new t({...this._def,shape:()=>r})}keyof(){return Hse(Yt.objectKeys(this.shape))}};as.create=(t,e)=>new as({shape:()=>t,unknownKeys:"strip",catchall:ja.create(),typeName:ft.ZodObject,...Ct(e)});as.strictCreate=(t,e)=>new as({shape:()=>t,unknownKeys:"strict",catchall:ja.create(),typeName:ft.ZodObject,...Ct(e)});as.lazycreate=(t,e)=>new as({shape:t,unknownKeys:"strip",catchall:ja.create(),typeName:ft.ZodObject,...Ct(e)});var vu=class extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function i(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let o=s.map(a=>new Ys(a.ctx.common.issues));return Oe(r,{code:he.invalid_union,unionErrors:o}),ut}if(r.common.async)return Promise.all(n.map(async s=>{let o={...r,common:{...r.common,issues:[]},parent:null};return {result:await s._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(i);{let s,o=[];for(let l of n){let u={...r,common:{...r.common,issues:[]},parent:null},c=l._parseSync({data:r.data,path:r.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!s&&(s={result:c,ctx:u}),u.common.issues.length&&o.push(u.common.issues);}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(l=>new Ys(l));return Oe(r,{code:he.invalid_union,unionErrors:a}),ut}}get options(){return this._def.options}};vu.create=(t,e)=>new vu({options:t,typeName:ft.ZodUnion,...Ct(e)});var Su=t=>t instanceof bd?Su(t.schema):t instanceof Zs?Su(t.innerType()):t instanceof Sd?[t.value]:t instanceof Ed?t.options:t instanceof vd?Yt.objectValues(t.enum):t instanceof xd?Su(t._def.innerType):t instanceof hd?[void 0]:t instanceof yd?[null]:t instanceof Xs?[void 0,...Su(t.unwrap())]:t instanceof Il?[null,...Su(t.unwrap())]:t instanceof Eb||t instanceof Pd?Su(t.unwrap()):t instanceof Td?Su(t._def.innerType):[],Jm=class t extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.object)return Oe(r,{code:he.invalid_type,expected:Ne.object,received:r.parsedType}),ut;let n=this.discriminator,i=r.data[n],s=this.optionsMap.get(i);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(Oe(r,{code:he.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ut)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let i=new Map;for(let s of r){let o=Su(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,s);}}return new t({typeName:ft.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...Ct(n)})}};function Y3(t,e){let r=Cl(t),n=Cl(e);if(t===e)return {valid:true,data:t};if(r===Ne.object&&n===Ne.object){let i=Yt.objectKeys(e),s=Yt.objectKeys(t).filter(a=>i.indexOf(a)!==-1),o={...t,...e};for(let a of s){let l=Y3(t[a],e[a]);if(!l.valid)return {valid:false};o[a]=l.data;}return {valid:true,data:o}}else if(r===Ne.array&&n===Ne.array){if(t.length!==e.length)return {valid:false};let i=[];for(let s=0;s<t.length;s++){let o=t[s],a=e[s],l=Y3(o,a);if(!l.valid)return {valid:false};i.push(l.data);}return {valid:true,data:i}}else return r===Ne.date&&n===Ne.date&&+t==+e?{valid:true,data:t}:{valid:false}}var gd=class extends Nt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(tC(s)||tC(o))return ut;let a=Y3(s.value,o.value);return a.valid?((rC(s)||rC(o))&&r.dirty(),{status:r.value,value:a.data}):(Oe(n,{code:he.invalid_intersection_types}),ut)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};gd.create=(t,e,r)=>new gd({left:t,right:e,typeName:ft.ZodIntersection,...Ct(r)});var ta=class t extends Nt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.array)return Oe(n,{code:he.invalid_type,expected:Ne.array,received:n.parsedType}),ut;if(n.data.length<this._def.items.length)return Oe(n,{code:he.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),ut;!this._def.rest&&n.data.length>this._def.items.length&&(Oe(n,{code:he.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),r.dirty());let s=[...n.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new ea(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>Hi.mergeArray(r,o)):Hi.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ta.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ta({items:t,typeName:ft.ZodTuple,rest:null,...Ct(e)})};var Ym=class t extends Nt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.object)return Oe(n,{code:he.invalid_type,expected:Ne.object,received:n.parsedType}),ut;let i=[],s=this._def.keyType,o=this._def.valueType;for(let a in n.data)i.push({key:s._parse(new ea(n,a,n.path,a)),value:o._parse(new ea(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Hi.mergeObjectAsync(r,i):Hi.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof Nt?new t({keyType:e,valueType:r,typeName:ft.ZodRecord,...Ct(n)}):new t({keyType:kc.create(),valueType:e,typeName:ft.ZodRecord,...Ct(r)})}},Xm=class extends Nt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.map)return Oe(n,{code:he.invalid_type,expected:Ne.map,received:n.parsedType}),ut;let i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([a,l],u)=>({key:i._parse(new ea(n,a,n.path,[u,"key"])),value:s._parse(new ea(n,l,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let u=await l.key,c=await l.value;if(u.status==="aborted"||c.status==="aborted")return ut;(u.status==="dirty"||c.status==="dirty")&&r.dirty(),a.set(u.value,c.value);}return {status:r.value,value:a}})}else {let a=new Map;for(let l of o){let u=l.key,c=l.value;if(u.status==="aborted"||c.status==="aborted")return ut;(u.status==="dirty"||c.status==="dirty")&&r.dirty(),a.set(u.value,c.value);}return {status:r.value,value:a}}}};Xm.create=(t,e,r)=>new Xm({valueType:e,keyType:t,typeName:ft.ZodMap,...Ct(r)});var Zm=class t extends Nt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.set)return Oe(n,{code:he.invalid_type,expected:Ne.set,received:n.parsedType}),ut;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(Oe(n,{code:he.too_small,minimum:i.minSize.value,type:"set",inclusive:true,exact:false,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(Oe(n,{code:he.too_big,maximum:i.maxSize.value,type:"set",inclusive:true,exact:false,message:i.maxSize.message}),r.dirty());let s=this._def.valueType;function o(l){let u=new Set;for(let c of l){if(c.status==="aborted")return ut;c.status==="dirty"&&r.dirty(),u.add(c.value);}return {status:r.value,value:u}}let a=[...n.data.values()].map((l,u)=>s._parse(new ea(n,l,n.path,u)));return n.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:Xe.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:Xe.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Zm.create=(t,e)=>new Zm({valueType:t,minSize:null,maxSize:null,typeName:ft.ZodSet,...Ct(e)});var nC=class t extends Nt{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.function)return Oe(r,{code:he.invalid_type,expected:Ne.function,received:r.parsedType}),ut;function n(a,l){return Sb({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,zm(),bu].filter(u=>!!u),issueData:{code:he.invalid_arguments,argumentsError:l}})}function i(a,l){return Sb({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,zm(),bu].filter(u=>!!u),issueData:{code:he.invalid_return_type,returnTypeError:l}})}let s={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Al){let a=this;return os(async function(...l){let u=new Ys([]),c=await a._def.args.parseAsync(l,s).catch(f=>{throw u.addIssue(n(l,f)),u}),p=await Reflect.apply(o,this,c);return await a._def.returns._def.type.parseAsync(p,s).catch(f=>{throw u.addIssue(i(p,f)),u})})}else {let a=this;return os(function(...l){let u=a._def.args.safeParse(l,s);if(!u.success)throw new Ys([n(l,u.error)]);let c=Reflect.apply(o,this,u.data),p=a._def.returns.safeParse(c,s);if(!p.success)throw new Ys([i(c,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ta.create(e).rest(Eu.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||ta.create([]).rest(Eu.create()),returns:r||Eu.create(),typeName:ft.ZodFunction,...Ct(n)})}},bd=class extends Nt{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};bd.create=(t,e)=>new bd({getter:t,typeName:ft.ZodLazy,...Ct(e)});var Sd=class extends Nt{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return Oe(r,{received:r.data,code:he.invalid_literal,expected:this._def.value}),ut}return {status:"valid",value:e.data}}get value(){return this._def.value}};Sd.create=(t,e)=>new Sd({value:t,typeName:ft.ZodLiteral,...Ct(e)});function Hse(t,e){return new Ed({values:t,typeName:ft.ZodEnum,...Ct(e)})}var Ed=class t extends Nt{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return Oe(r,{expected:Yt.joinValues(n),received:r.parsedType,code:he.invalid_type}),ut}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return Oe(r,{received:r.data,code:he.invalid_enum_value,options:n}),ut}return os(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Ed.create=Hse;var vd=class extends Nt{_parse(e){let r=Yt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Ne.string&&n.parsedType!==Ne.number){let i=Yt.objectValues(r);return Oe(n,{expected:Yt.joinValues(i),received:n.parsedType,code:he.invalid_type}),ut}if(this._cache||(this._cache=new Set(Yt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=Yt.objectValues(r);return Oe(n,{received:n.data,code:he.invalid_enum_value,options:i}),ut}return os(e.data)}get enum(){return this._def.values}};vd.create=(t,e)=>new vd({values:t,typeName:ft.ZodNativeEnum,...Ct(e)});var Al=class extends Nt{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.promise&&r.common.async===false)return Oe(r,{code:he.invalid_type,expected:Ne.promise,received:r.parsedType}),ut;let n=r.parsedType===Ne.promise?r.data:Promise.resolve(r.data);return os(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Al.create=(t,e)=>new Al({type:t,typeName:ft.ZodPromise,...Ct(e)});var Zs=class extends Nt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ft.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{Oe(n,o),o.fatal?r.abort():r.dirty();},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return ut;let l=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return l.status==="aborted"?ut:l.status==="dirty"?cd(l.value):r.value==="dirty"?cd(l.value):l});{if(r.value==="aborted")return ut;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?ut:a.status==="dirty"?cd(a.value):r.value==="dirty"?cd(a.value):a}}if(i.type==="refinement"){let o=a=>{let l=i.refinement(a,s);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===false){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?ut:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?ut:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===false){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!_c(o))return ut;let a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>_c(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:r.value,value:a})):ut);Yt.assertNever(i);}};Zs.create=(t,e,r)=>new Zs({schema:t,typeName:ft.ZodEffects,effect:e,...Ct(r)});Zs.createWithPreprocess=(t,e,r)=>new Zs({schema:e,effect:{type:"preprocess",transform:t},typeName:ft.ZodEffects,...Ct(r)});var Xs=class extends Nt{_parse(e){return this._getType(e)===Ne.undefined?os(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xs.create=(t,e)=>new Xs({innerType:t,typeName:ft.ZodOptional,...Ct(e)});var Il=class extends Nt{_parse(e){return this._getType(e)===Ne.null?os(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Il.create=(t,e)=>new Il({innerType:t,typeName:ft.ZodNullable,...Ct(e)});var xd=class extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===Ne.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};xd.create=(t,e)=>new xd({innerType:t,typeName:ft.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ct(e)});var Td=class extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Wm(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ys(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ys(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Td.create=(t,e)=>new Td({innerType:t,typeName:ft.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ct(e)});var Qm=class extends Nt{_parse(e){if(this._getType(e)!==Ne.nan){let n=this._getOrReturnCtx(e);return Oe(n,{code:he.invalid_type,expected:Ne.nan,received:n.parsedType}),ut}return {status:"valid",value:e.data}}};Qm.create=t=>new Qm({typeName:ft.ZodNaN,...Ct(t)});var Lut=Symbol("zod_brand"),Eb=class extends Nt{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Dd=class t extends Nt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return (async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ut:s.status==="dirty"?(r.dirty(),cd(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ut:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:ft.ZodPipeline})}},Pd=class extends Nt{_parse(e){let r=this._def.innerType._parse(e),n=i=>(_c(i)&&(i.value=Object.freeze(i.value)),i);return Wm(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Pd.create=(t,e)=>new Pd({innerType:t,typeName:ft.ZodReadonly,...Ct(e)});function Vse(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Kse(t,e={},r){return t?wl.create().superRefine((n,i)=>{let s=t(n);if(s instanceof Promise)return s.then(o=>{if(!o){let a=Vse(e,n),l=a.fatal??r??true;i.addIssue({code:"custom",...a,fatal:l});}});if(!s){let o=Vse(e,n),a=o.fatal??r??true;i.addIssue({code:"custom",...o,fatal:a});}}):wl.create()}var jut={object:as.lazycreate},ft;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly";})(ft||(ft={}));var But=(t,e={message:`Input not instance of ${t.name}`})=>Kse(r=>r instanceof t,e),Jse=kc.create,Yse=pd.create,$ut=Qm.create,Uut=dd.create,Xse=fd.create,qut=md.create,Vut=Hm.create,zut=hd.create,Wut=yd.create,Gut=wl.create,Hut=Eu.create,Kut=ja.create,Jut=Km.create,Yut=Ba.create,Xut=as.create,Zut=as.strictCreate,Qut=vu.create,ect=Jm.create,tct=gd.create,rct=ta.create,nct=Ym.create,ict=Xm.create,sct=Zm.create,oct=nC.create,act=bd.create,lct=Sd.create,uct=Ed.create,cct=vd.create,pct=Al.create,dct=Zs.create,fct=Xs.create,mct=Il.create,hct=Zs.createWithPreprocess,yct=Dd.create,gct=()=>Jse().optional(),bct=()=>Yse().optional(),Sct=()=>Xse().optional(),Ect={string:(t=>kc.create({...t,coerce:true})),number:(t=>pd.create({...t,coerce:true})),boolean:(t=>fd.create({...t,coerce:true})),bigint:(t=>dd.create({...t,coerce:true})),date:(t=>md.create({...t,coerce:true}))};var vct=ut;var In=class{constructor(e){this.schema=e;}async validate(e){let r=await this.schema.safeParseAsync(e);if(r.success)return {valid:true,data:r.data};let{error:n}=r;return {valid:false,violations:n.issues.map(i=>({path:i.path.reduce((s,o)=>typeof o=="string"?s===""?o:`${s}.${o}`:`${s}[${o}]`,""),message:i.message}))}}};var xct=g.object({name:g.string(),version:g.string().optional(),dependencies:g.record(g.string()).optional(),devDependencies:g.record(g.string()).optional(),bin:g.record(g.string()).optional(),scripts:g.record(g.string()).optional(),packageManager:g.string().optional()}),vb=class extends In{constructor(){super(xct);}};var Nc=g.string().regex(/^[a-z]+(-?[a-z0-9]+)*$/i,"An identifier must start with a letter and contain only letters, numbers, and hyphens."),iC=g.string().regex(/^[a-z]{2,3}([-_][a-z]{2,3})?$/i,"Locale must be in the form of en, en_US, or en-US."),sC=g.string().refine(rr.isValid,"Version must be exact (1), range (1 - 2), or set (1, 2).").refine(t=>{try{return rr.parse(t).getCardinality()<=5}catch{return false}},"Version range must not exceed 5 major versions.");function ls(t){return t.optional().catch(void 0)}var Tct=g.object({$schema:ls(g.string()),organization:ls(Nc),workspace:ls(Nc),applications:ls(g.object({development:ls(Nc),production:ls(Nc)})),locales:ls(g.array(iC).min(1)),defaultLocale:ls(iC),slots:ls(g.record(sC)),components:ls(g.record(sC)),paths:ls(g.object({source:ls(g.string()),utilities:ls(g.string()),components:ls(g.string()),examples:ls(g.string()),content:ls(g.string())}))}),Dct=g.strictObject({$schema:g.string().optional(),organization:Nc,workspace:Nc,applications:g.strictObject({development:Nc,production:Nc.optional()}),locales:g.array(iC).min(1),defaultLocale:iC,slots:g.record(sC).default({}),components:g.record(sC).default({}),paths:g.strictObject({source:g.string().optional(),utilities:g.string().optional(),components:g.string().optional(),examples:g.string().optional(),content:g.string().optional()}).optional()}).refine(t=>t.locales.includes(t.defaultLocale),{message:"The default locale is not included in the list of locales.",path:["defaultLocale"]}),oC=class extends In{constructor(){super(Dct);}},aC=class extends In{constructor(){super(Tct);}};var eh=class{constructor({provider:e,validator:r}){this.provider=e,this.validator=r;}async get(e){let{value:r,...n}=await this.provider.get(e),i=await this.validator.validate(r);if(!i.valid){let s=i.violations.map(o=>` \u2022 **${o.path}**: ${o.message}`).join(`
2439
2439
 
2440
2440
  `);throw new jr(`The response data is invalid:
2441
2441
 
@@ -2541,4 +2541,4 @@ tell application "System Events" to get value of property list item "CFBundleNam
2541
2541
  `);return new V(`${e.message}
2542
2542
 
2543
2543
  \u25B6\uFE0F **Trace**
2544
- ${r}`,e.help)}break;case e instanceof Fa:return new V(e.message,{...e.help,suggestions:["Run `init` to create a new configuration."]})}return e}static getSourceLocation(e){return e.url.protocol==="file:"?`${e.url}:${e.start.line}:${e.start.column}`:e.url.hostname==="github.com"?`${e.url}#L${e.start.line}-L${e.end.line}`:`${e.url}#${e.start.line}:${e.start.column}-${e.end.line}:${e.end.column}`}};var B8={version:"0.16.2"};function bfe(t){let e=new lq().name("croct").description("Manage your Croct projects").enablePositionalOptions().option("--cwd <path>","The working directory.",v=>{try{return realpathSync(v)}catch{throw new ua("The path does not exist.")}}).addOption(new xi("--api-key <key>","The API key to use for authentication.").env("CROCT_API_KEY").argParser(v=>{try{return cq.parse(v)}catch{throw new ua("The API key is malformed.")}}).conflicts("token")).addOption(new xi("--token <token>","The JWT-formatted token to use for authentication.").env("CROCT_TOKEN").argParser(v=>{let T;try{T=Hc.parse(v);}catch{throw new ua("The token is malformed.")}if(!T.isValidNow())throw new ua("The token is expired.");return T})).option("--registry <url>","The template registry.",v=>{if(!URL.canParse(v))throw new ua("Malformed URL.");return v}).option("--no-interaction","Run the CLI in non-interactive mode.").option("--config <path>","Path to the configuration file.").addOption(new xi("--stateless","Run the CLI without saving any state locally.").env("CROCT_STATELESS").default(false)).addOption(new xi("--dnd","Run the CLI with minimal interaction and interruption.").env("CROCT_DND").default(false)).addOption(new xi("-q, --quiet","Disable output messages.").default(false).implies({interaction:false})).option("--debug","Enable debug mode.").version(B8.version,"-v, --version","Display the version number.").helpOption("-h, --help","Display help for a command.").helpCommand("help [command]","Display help for a command.");e.command("open <url>").description("Open a deep link.").action(async v=>{await t.cli?.open({url:v});});let r=e.command("login").description("Authenticate your user."),n=new xi("-u, --username <username>","The email."),i=new xi("-p, --password <password>","The password.");r.command("credentials",{isDefault:true}).description("Authenticate using credentials.").addOption(t.interactive?n:n.makeOptionMandatory()).addOption(t.interactive?i:i.makeOptionMandatory()).action(async v=>{await t.cli?.login({method:"credentials",username:v.username,password:v.password});}),e.command("logout").description("Logout the current user.").action(async()=>{await t.cli?.logout();}),e.command("admin").argument("[page...]","The name of the page or path to open.").description("Log in and open the admin panel.").action(async v=>{await t.cli?.admin({page:v!==void 0?v.join(" "):t.interactive?void 0:"/"});});let s=new xi("--wor <workspace-slug>","The workspace slug."),o=new xi("--org <organization-slug>","The organization slug."),a=new xi("--dev-app <application-slug>","The development application slug."),l=new xi("--prod-app <application-slug>","The production application slug.");e.command("init").description("Configure the project.").option("-o, --override","Override any existing configuration.").addOption(new xi("-n, --new <resource>","The resources to create.").choices(["organization","org","workspace","wor","application","app"])).addOption(new xi("-s, --sdk <platform>","The SDK to use.").choices(["javascript","react","next"])).addOption(new xi("--skip-api-key-setup","Opt-out of API key setup.").default(false).env("CROCT_SKIP_API_KEY_SETUP")).addOption(t.interactive?o:o.makeOptionMandatory()).addOption(t.interactive?s:s.makeOptionMandatory()).addOption(t.interactive?a:a.makeOptionMandatory()).addOption(l).action(async v=>{await t.cli?.init({override:v.override,new:(()=>{switch(v.new){case "organization":case "org":return "organization";case "workspace":case "wor":return "workspace";case "application":case "app":return "application";default:return}})(),sdk:v.sdk,organization:v.org,workspace:v.wor,devApplication:v.devApp,prodApplication:v.prodApp,skipApiKeySetup:v.skipApiKeySetup});}),e.command("install").description("Install content and types.").action(async()=>{await t.cli?.install({});}),e.command("update").description("Update content and types.").action(async()=>{await t.cli?.install({clean:true});}),e.command("upgrade").description("Upgrade components and slots to the latest version.").option("-s, --slots <slots...>","The slots to upgrade.").option("-c, --components <components...>","The components to upgrade.").action(async v=>{await t.cli?.upgrade({slots:v.slots??(v.components!==void 0?[]:void 0),components:v.components??(v.slots!==void 0?[]:void 0)});});let u=e.command("add").description("Add a resource to your project.");u.command("slot").description("Add a slot to your project.").argument(t.interactive?"[slots...]":"<slots...>").option("-e, --example","Generate an implementation example.").action(async(v,T)=>{await t.cli?.addSlot({slots:v,example:T.example});}),u.command("component").description("Add a component to your project.").argument(t.interactive?"[components...]":"<components...>").action(async v=>{await t.cli?.addComponent({components:v});});let c=e.command("remove").description("Remove a resource from your project.");c.command("slot").description("Remove a slot from your project.").argument(t.interactive?"[slots...]":"<slots...>").action(async v=>{await t.cli?.removeSlot({slots:v});}),c.command("component").description("Remove a component from your project.").argument(t.interactive?"[components...]":"<components...>").action(async v=>{await t.cli?.removeComponent({components:v});});let p=e.command("create").description("Create a resource in your project.");p.command("template").description("Create a template from your project.").addArgument(new uq("<path>","The path to the file.").argOptional()).option("-e, --empty","Create an empty template.").action(async(v,T)=>{await t.cli?.createTemplate({file:v,empty:T.empty});});let d=new xi("--permissions <permissions...>","The permissions of the API key.").argParser(v=>v.split(",").map(T=>{try{return zi.fromValue(T)}catch{throw new ua(`Unknown permission "${T}".`)}})),f=new xi("--env <environment>","The environment of the API key.").choices(["prod","dev"]).argParser(v=>v==="prod"?"PRODUCTION":"DEVELOPMENT");p.command("api-key").description("Create an API key.").option("--name <name>","The name of the API key.").addOption(t.interactive?d:d.makeOptionMandatory()).addOption(t.interactive?f:f.makeOptionMandatory()).option("-c, --copy","Copy the API key to the clipboard.").action(async v=>{await t.cli?.createApiKey({name:v.name,permissions:v.permissions,environment:v.env,copy:v.copy});});let h={},m=e.command("use").description("Use a template.").argument("template","The path to the template.").passThroughOptions(t.cli===void 0).allowUnknownOption(t.cli===void 0||t.template===null).action(async(v,T)=>{await t.cli?.useTemplate({template:v,options:Object.fromEntries(Object.entries(T).map(([D,C])=>[h[D],C]))});});for(let[v,T]of Object.entries(t.template??{})){let D=`--${v}${T.type!=="boolean"?" <value>":""}`,C=new xi(D,T.description).makeOptionMandatory(T.required===true);switch(T.type){case "string":T.choices!==void 0&&T.choices.length>0&&C.choices(T.choices);break;case "number":C.argParser(L=>{let R=Number.parseFloat(L);if(Number.isNaN(R))throw new ua("The value must be a number.");return R});break;case "array":C.argParser(L=>{let R;try{R=JSON.parse(L);}catch{}if(R===void 0||!Array.isArray(R))throw new ua("The value must be a JSON array.");return R});break;case "object":C.argParser(L=>{let R;try{R=JSON.parse(L);}catch{throw new ua("The JSON is malformed.")}if(typeof R!="object"||R===null)throw new ua("The value must be a JSON object.")});break}h[C.attributeName()]=v,m.addOption(C);}return e.command("enable").description("Enable a feature.").command("deep-link").description("Enable deep link support.").action(async()=>{await t.cli?.deepLink({operation:"enable"});}),e.command("disable").description("Disable a feature.").command("deep-link").description("Disable deep link support.").action(async()=>{await t.cli?.deepLink({operation:"disable"});}),e}function Nxt(t){let e=["use","help use"];for(let r of e){let n=r.split(" ").length;if(t.length>n&&t.slice(0,n).join(" ")===r&&(t[n]??"")!=="")return t[n]}return null}function Fxt(t){return t.length>=2&&["enable","disable"].includes(t[0])&&t[1]==="deep-link"}async function $8(t=process.argv,e=true){let r=bfe({interactive:true}).parse(t),n=r.opts(),i=oO.fromDefaults({program:l=>$8(r.args.slice(0,2).concat(l)),version:B8.version,quiet:n.quiet,debug:n.debug,interactive:n.interaction?void 0:false,stateless:n.stateless,apiKey:n.apiKey,token:n.token,dnd:n.dnd,templateRegistryUrl:n.registry===void 0?void 0:new URL(n.registry),configurationFile:n.config}),s=Nxt(r.args),o=s!==null?await i.getTemplateOptions(s).catch(()=>null):void 0,a=bfe({cli:i,interactive:n.interaction,template:o});e&&await i.welcome({skipDeepLinkCheck:Fxt(r.args)}),await a.parseAsync(t);}$8();
2544
+ ${r}`,e.help)}break;case e instanceof Fa:return new V(e.message,{...e.help,suggestions:["Run `init` to create a new configuration."]})}return e}static getSourceLocation(e){return e.url.protocol==="file:"?`${e.url}:${e.start.line}:${e.start.column}`:e.url.hostname==="github.com"?`${e.url}#L${e.start.line}-L${e.end.line}`:`${e.url}#${e.start.line}:${e.start.column}-${e.end.line}:${e.end.column}`}};var B8={version:"0.16.3"};function bfe(t){let e=new lq().name("croct").description("Manage your Croct projects").enablePositionalOptions().option("--cwd <path>","The working directory.",v=>{try{return realpathSync(v)}catch{throw new ua("The path does not exist.")}}).addOption(new xi("--api-key <key>","The API key to use for authentication.").env("CROCT_API_KEY").argParser(v=>{try{return cq.parse(v)}catch{throw new ua("The API key is malformed.")}}).conflicts("token")).addOption(new xi("--token <token>","The JWT-formatted token to use for authentication.").env("CROCT_TOKEN").argParser(v=>{let T;try{T=Hc.parse(v);}catch{throw new ua("The token is malformed.")}if(!T.isValidNow())throw new ua("The token is expired.");return T})).option("--registry <url>","The template registry.",v=>{if(!URL.canParse(v))throw new ua("Malformed URL.");return v}).option("--no-interaction","Run the CLI in non-interactive mode.").option("--config <path>","Path to the configuration file.").addOption(new xi("--stateless","Run the CLI without saving any state locally.").env("CROCT_STATELESS").default(false)).addOption(new xi("--dnd","Run the CLI with minimal interaction and interruption.").env("CROCT_DND").default(false)).addOption(new xi("-q, --quiet","Disable output messages.").default(false).implies({interaction:false})).option("--debug","Enable debug mode.").version(B8.version,"-v, --version","Display the version number.").helpOption("-h, --help","Display help for a command.").helpCommand("help [command]","Display help for a command.");e.command("open <url>").description("Open a deep link.").action(async v=>{await t.cli?.open({url:v});});let r=e.command("login").description("Authenticate your user."),n=new xi("-u, --username <username>","The email."),i=new xi("-p, --password <password>","The password.");r.command("credentials",{isDefault:true}).description("Authenticate using credentials.").addOption(t.interactive?n:n.makeOptionMandatory()).addOption(t.interactive?i:i.makeOptionMandatory()).action(async v=>{await t.cli?.login({method:"credentials",username:v.username,password:v.password});}),e.command("logout").description("Logout the current user.").action(async()=>{await t.cli?.logout();}),e.command("admin").argument("[page...]","The name of the page or path to open.").description("Log in and open the admin panel.").action(async v=>{await t.cli?.admin({page:v!==void 0?v.join(" "):t.interactive?void 0:"/"});});let s=new xi("--wor <workspace-slug>","The workspace slug."),o=new xi("--org <organization-slug>","The organization slug."),a=new xi("--dev-app <application-slug>","The development application slug."),l=new xi("--prod-app <application-slug>","The production application slug.");e.command("init").description("Configure the project.").option("-o, --override","Override any existing configuration.").addOption(new xi("-n, --new <resource>","The resources to create.").choices(["organization","org","workspace","wor","application","app"])).addOption(new xi("-s, --sdk <platform>","The SDK to use.").choices(["javascript","react","next"])).addOption(new xi("--skip-api-key-setup","Opt-out of API key setup.").default(false).env("CROCT_SKIP_API_KEY_SETUP")).addOption(t.interactive?o:o.makeOptionMandatory()).addOption(t.interactive?s:s.makeOptionMandatory()).addOption(t.interactive?a:a.makeOptionMandatory()).addOption(l).action(async v=>{await t.cli?.init({override:v.override,new:(()=>{switch(v.new){case "organization":case "org":return "organization";case "workspace":case "wor":return "workspace";case "application":case "app":return "application";default:return}})(),sdk:v.sdk,organization:v.org,workspace:v.wor,devApplication:v.devApp,prodApplication:v.prodApp,skipApiKeySetup:v.skipApiKeySetup});}),e.command("install").description("Install content and types.").action(async()=>{await t.cli?.install({});}),e.command("update").description("Update content and types.").action(async()=>{await t.cli?.install({clean:true});}),e.command("upgrade").description("Upgrade components and slots to the latest version.").option("-s, --slots <slots...>","The slots to upgrade.").option("-c, --components <components...>","The components to upgrade.").action(async v=>{await t.cli?.upgrade({slots:v.slots??(v.components!==void 0?[]:void 0),components:v.components??(v.slots!==void 0?[]:void 0)});});let u=e.command("add").description("Add a resource to your project.");u.command("slot").description("Add a slot to your project.").argument(t.interactive?"[slots...]":"<slots...>").option("-e, --example","Generate an implementation example.").action(async(v,T)=>{await t.cli?.addSlot({slots:v,example:T.example});}),u.command("component").description("Add a component to your project.").argument(t.interactive?"[components...]":"<components...>").action(async v=>{await t.cli?.addComponent({components:v});});let c=e.command("remove").description("Remove a resource from your project.");c.command("slot").description("Remove a slot from your project.").argument(t.interactive?"[slots...]":"<slots...>").action(async v=>{await t.cli?.removeSlot({slots:v});}),c.command("component").description("Remove a component from your project.").argument(t.interactive?"[components...]":"<components...>").action(async v=>{await t.cli?.removeComponent({components:v});});let p=e.command("create").description("Create a resource in your project.");p.command("template").description("Create a template from your project.").addArgument(new uq("<path>","The path to the file.").argOptional()).option("-e, --empty","Create an empty template.").action(async(v,T)=>{await t.cli?.createTemplate({file:v,empty:T.empty});});let d=new xi("--permissions <permissions...>","The permissions of the API key.").argParser(v=>v.split(",").map(T=>{try{return zi.fromValue(T)}catch{throw new ua(`Unknown permission "${T}".`)}})),f=new xi("--env <environment>","The environment of the API key.").choices(["prod","dev"]).argParser(v=>v==="prod"?"PRODUCTION":"DEVELOPMENT");p.command("api-key").description("Create an API key.").option("--name <name>","The name of the API key.").addOption(t.interactive?d:d.makeOptionMandatory()).addOption(t.interactive?f:f.makeOptionMandatory()).option("-c, --copy","Copy the API key to the clipboard.").action(async v=>{await t.cli?.createApiKey({name:v.name,permissions:v.permissions,environment:v.env,copy:v.copy});});let h={},m=e.command("use").description("Use a template.").argument("template","The path to the template.").passThroughOptions(t.cli===void 0).allowUnknownOption(t.cli===void 0||t.template===null).action(async(v,T)=>{await t.cli?.useTemplate({template:v,options:Object.fromEntries(Object.entries(T).map(([D,C])=>[h[D],C]))});});for(let[v,T]of Object.entries(t.template??{})){let D=`--${v}${T.type!=="boolean"?" <value>":""}`,C=new xi(D,T.description).makeOptionMandatory(T.required===true);switch(T.type){case "string":T.choices!==void 0&&T.choices.length>0&&C.choices(T.choices);break;case "number":C.argParser(L=>{let R=Number.parseFloat(L);if(Number.isNaN(R))throw new ua("The value must be a number.");return R});break;case "array":C.argParser(L=>{let R;try{R=JSON.parse(L);}catch{}if(R===void 0||!Array.isArray(R))throw new ua("The value must be a JSON array.");return R});break;case "object":C.argParser(L=>{let R;try{R=JSON.parse(L);}catch{throw new ua("The JSON is malformed.")}if(typeof R!="object"||R===null)throw new ua("The value must be a JSON object.")});break}h[C.attributeName()]=v,m.addOption(C);}return e.command("enable").description("Enable a feature.").command("deep-link").description("Enable deep link support.").action(async()=>{await t.cli?.deepLink({operation:"enable"});}),e.command("disable").description("Disable a feature.").command("deep-link").description("Disable deep link support.").action(async()=>{await t.cli?.deepLink({operation:"disable"});}),e}function Nxt(t){let e=["use","help use"];for(let r of e){let n=r.split(" ").length;if(t.length>n&&t.slice(0,n).join(" ")===r&&(t[n]??"")!=="")return t[n]}return null}function Fxt(t){return t.length>=2&&["enable","disable"].includes(t[0])&&t[1]==="deep-link"}async function $8(t=process.argv,e=true){let r=bfe({interactive:true}).parse(t),n=r.opts(),i=oO.fromDefaults({program:l=>$8(r.args.slice(0,2).concat(l)),version:B8.version,quiet:n.quiet,debug:n.debug,interactive:n.interaction?void 0:false,stateless:n.stateless,apiKey:n.apiKey,token:n.token,dnd:n.dnd,templateRegistryUrl:n.registry===void 0?void 0:new URL(n.registry),configurationFile:n.config}),s=Nxt(r.args),o=s!==null?await i.getTemplateOptions(s).catch(()=>null):void 0,a=bfe({cli:i,interactive:n.interaction,template:o});e&&await i.welcome({skipDeepLinkCheck:Fxt(r.args)}),await a.parseAsync(t);}$8();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "croct",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "A command-line interface (CLI) for managing projects using Croct.",
5
5
  "author": {
6
6
  "name": "Croct",