@homedev/objector 1.2.53 → 1.2.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var at=Object.create;var{getPrototypeOf:lt,defineProperty:X,getOwnPropertyNames:
|
|
|
6
6
|
`))L+=`
|
|
7
7
|
`;let Ve=a.lastIndexOf(`
|
|
8
8
|
`,f-1),He=Ve===-1?0:Ve+1,qe=a.slice(He,f).trim().length===0?He:f;a=a.slice(0,qe)+L+a.slice(w),i+=L.length-(w-qe),m.content=a}return[a,l]},or=(e)=>{let r=[],t=0;while(t<e.length)if(e[t]==="$"&&e[t+1]==="("&&(t===0||e[t-1]!=="\\")){let n=t;t+=2;let o=1;for(;t<e.length;t++)if(e[t]==="(")o++;else if(e[t]===")"){if(o--,o===0){r.push([n,t]);break}}if(o!==0)throw Error(`Unmatched opening $( at position ${n.toString()}`);t++}else t++;return r},Fe=Symbol.for("@homedev/fields:OverrideResult"),Ut=(e)=>({[Fe]:!0,value:e}),It=(e)=>{return e!==null&&typeof e==="object"&&Fe in e&&e[Fe]===!0},sr=async(e,r,t)=>{for(let n=r.length-1;n>=0;n--){let[o,s]=r[n],a=e.slice(o+2,s),i=await sr(a,or(a),t);if(typeof i==="object")return i;let l=await t(i,e);if(It(l))return l.value;e=e.slice(0,o)+l+e.slice(s+1)}return e},_t=async(e,r)=>sr(e,or(e),r),Tt=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Yt=/([\w\d.-_/]+):(.+)/,Bt=async(e,r,t,n)=>{let o=await(async()=>{let s=Yt.exec(e);if(!s)return await V(r,e);let[a,i,l]=s,m=H(n.sources,i),y=pe(l,m,r);return await m.fn({args:y.parsedArgs,rawArgs:y.rawArgs,tags:y.tags,key:i,options:n,root:r,path:t,value:null})})();if(o===null||o===void 0)return"";if(typeof o==="object")return Ut(o);return o},ir=async(e,r,t,n)=>{let o=await _t(r,(s)=>Bt(s,t,e,n));if(Tt(o))return o;if(o===r)return E.Explore();if(typeof o==="string"){let s=await ir(e,o,t,n);if(s.action!==U.Explore)return s;return E.ReplaceItem(o)}return E.ReplaceItem(o)},F=async(e,r)=>{return r??={},await bt(e,async(t)=>{let n=[...t.path,t.key].join(".");if(r?.filters?.length&&r.filters.some((i)=>i.test(n)))return E.NoExplore();let o=t.path.length===0,s=t.parents.length>0?t.parents.toReversed():[];if(o){if(s.length>0)throw Error("Root object should not have a parent");s=r?.root?.parents?[r.root.parent,...r.root.parents.toReversed()]:[]}let a={...e,...r.root,this:t.parent,parent:s.length>0?s[0]:null,parents:s};try{if(t.key.startsWith("$"))return E.NoExplore();let i=E.Explore();if(typeof t.value==="string"){let l=t.value,m=!1;while(!0){let[y,g]=await Lt(l,r,n,a);if(m=m||g,i=await ir(n,y,a,r),i.action===U.ReplaceItem&&typeof i.by==="string"){l=i.by;continue}if(i.action===U.Explore&&g&&y!==l)i=E.ReplaceItem(y);break}if(i.action===U.Explore&&l!==t.value)i=E.ReplaceItem(l);switch(i.action){case U.Explore:break;case U.ReplaceItem:t.value=i.by;break;default:return i}}if(Nt(t,r))i=await Ct(t,n,a,r);return i}catch(i){throw Error(`${i.message}
|
|
9
|
-
(${n})`)}}),e},q=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),De=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,q(t,r?.types?.[t.name])])),D=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,q(e[t],r?.types?.[t])]));var Ce={};$(Ce,{writeOutputs:()=>z,writeOutput:()=>ce,writeFormat:()=>fe,locate:()=>I,loadFormat:()=>P,importList:()=>me,importGlob:()=>Ne,globMap:()=>Z,exists:()=>Y});import ar from"fs/promises";import Re from"path";import Jt from"fs/promises";import Qt from"path";import Kt from"fs/promises";import Gt from"fs/promises";import pr from"fs/promises";import lr from"path";import xt from"fs/promises";import je from"path";import ur from"path";var Y=async(e)=>{try{return await ar.access(e,ar.constants.R_OK),!0}catch{return!1}},I=async(e,r)=>{let t=!Re.isAbsolute(e)&&r?["",...r]:[""];for(let n of t){let o=Re.join(n,e);if(await Y(o))return Re.resolve(o)}throw Error(`File not found: "${e}"`)},P=async(e,r)=>{let t=await I(e,r?.dirs),n=await Jt.readFile(t,"utf-8"),o=Qt.dirname(t),s={text:{fn:(i)=>i,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...r?.parsers},a=r?.format?s[r.format]:Object.values(s).find((i)=>i.matching?.some((l)=>new RegExp(l).test(e)));if(!a)throw Error(`Unsupported format for file "${e}" and no matching parser found`);return{content:await a.fn(n),fullPath:t,folderPath:o}},fe=async(e,r,t)=>{let n={text:{fn:(s)=>s,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...t?.encoders},o=t?.format?n[t.format]:Object.values(n).find((s)=>s.matching?.some((a)=>new RegExp(a).test(e)));if(!o)throw Error(`Unsupported format for file "${e}" and no matching encoder found`);await Kt.writeFile(e,await o.fn(r))},Z=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(Gt.glob(e,{cwd:r.cwd})),n=r.filter?t.filter(r.filter):t;return await Promise.all(n.map(r.map))},z=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await pr.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await ce(t,r)},ce=async(e,r)=>{let t=lr.join(r?.targetDirectory??".",e.name),n=lr.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await pr.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${t}": ${o.message}`)}try{await fe(t,e.value,{format:e.type??"text"})}catch(o){throw Error(`Failed to write output "${t}": ${o.message}`)}},We=(e)=>e?ur.isAbsolute(e)?e:ur.join(process.cwd(),e):process.cwd(),me=async(e,r)=>{let t=[];for(let n of e)try{let o=!je.isAbsolute(n)?je.join(We(r?.cwd),n):n;if(r?.filter?.(o)===!1)continue;let s=await import(o);if(r?.resolveDefault==="only"&&!s.default)throw Error(`Module ${n} does not have a default export`);let a=r?.resolveDefault?s.default??s:s,i=r?.map?await r.map(a,n):a;if(i!==void 0)t.push(i)}catch(o){if(r?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return t},Ne=async(e,r)=>{let t=[];for(let n of e){let o=(await Array.fromAsync(xt.glob(n,{cwd:We(r?.cwd)}))).map((s)=>je.join(We(r?.cwd),s));t.push(...await me(o,r))}return t};var Ye={};$(Ye,{toObjectWithKey:()=>Le,toObject:()=>ee,toList:()=>_,sortBy:()=>_e,nonNullMap:()=>Ue,defined:()=>Ie,deepClone:()=>R,asyncMap:()=>Te});var _=(e,r="name")=>Object.entries(e).map(([t,n])=>({[r]:t,...n})),Le=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),ee=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:n,...o}=t;return[n,o]})),Ue=(e,r)=>{if(!e)return[];let t=[],n=0;for(let o of e)if(o!==null&&o!==void 0)t.push(r(o,n,e)),n++;return t},Ie=(e,r="Value is undefined")=>{if(e===void 0||e===null)throw Error(r);return e},_e=(e,r,t=(n,o)=>n-o)=>e.slice().sort((n,o)=>t(r(n),r(o))),Te=async(e,r)=>Promise.all(e.map(r)),R=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var Zr={};$(Zr,{defaultProcessors:()=>Ge});var fr={};$(fr,{navigate:()=>ye,find:()=>Be,NavigateResult:()=>b,NavigateAction:()=>ge});var ge;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(ge||={});class b{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new b(0);static _noExplore=new b(2);static _skipSiblings=new b(1);static _deleteParent=new b(4);static ReplaceParent(e,r){return new b(3,e,void 0,r)}static SkipSiblings(){return b._skipSiblings}static Explore(){return b._explore}static NoExplore(){return b._noExplore}static DeleteParent(){return b._deleteParent}static MergeParent(e){return new b(5,e)}static ReplaceItem(e,r){return new b(6,e,r)}static DeleteItem(e){return new b(7,void 0,e)}}var ye=async(e,r)=>{let t=new WeakSet,n=[],o=[],s=async(i,l,m)=>{let y=i===null,g=y?b.Explore():await r({key:i,value:l,path:n,parent:m,parents:o});if(l&&typeof l==="object"&&g.action===0){if(t.has(l))return g;if(t.add(l),!y)n.push(i),o.push(m);let u=l;while(await a(u,i,m))u=m[i];if(!y)o.pop(),n.pop()}return g},a=async(i,l,m)=>{let y=Object.keys(i),g=y.length;for(let u=0;u<g;u++){let c=y[u],h=i[c],f=await s(c,h,i),w=f.action;if(w===0||w===2)continue;if(w===6){if(i[c]=f.by,f.skipSiblings)return;continue}if(w===7){if(delete i[c],f.skipSiblings)return;continue}if(w===1)return;if(w===3){if(l===null)throw Error("Cannot replace root object");if(m[l]=f.by,f.reexplore)return!0;return}if(w===4){if(l===null)throw Error("Cannot delete root object");delete m[l];return}if(w===5)delete i[c],Object.assign(i,f.by)}};await s(null,e,null)},Be=async(e,r)=>{let t=[];return await ye(e,(n)=>{if(r([...n.path,n.key].join("."),n.value))t.push(n.value);return b.Explore()}),t};var cr=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return b.SkipSiblings()}});import Xt from"path";var mr=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:n}of Array.isArray(r.value)?r.value:[r.value]){if(!n)throw Error("File reference required");await e.load(n,t.file&&Xt.dirname(t.file))}return b.DeleteItem()}});var gr={};$(gr,{mergeAll:()=>B,merge:()=>N});var N=(e,r,t)=>{for(let n of Object.keys(r)){if(e[n]===void 0)continue;let o=r[n],s=e[n];if(typeof s!==typeof o||Array.isArray(s)!==Array.isArray(o)){let i=t?.mismatch?.(n,s,o,e,r);if(i!==void 0){r[n]=i;continue}throw Error(`Type mismatch: ${n}`)}let a=t?.mode?.(n,s,o,e,r)??r[".merge"]??"merge";switch(a){case"source":r[n]=s;continue;case"target":continue;case"skip":delete r[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${a}`)}if(typeof s==="object")if(Array.isArray(s))o.push(...s);else{if(t?.navigate?.(n,s,o,e,r)===!1)continue;N(s,o,t)}else{if(s===o)continue;let i=t?.conflict?.(n,s,o,e,r);r[n]=i===void 0?o:i}}for(let n of Object.keys(e))if(r[n]===void 0)r[n]=e[n]},B=(e,r)=>{let t={};for(let n of e.toReversed())N(n,t,r);return t};var yr={};$(yr,{CacheManager:()=>de});class de{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,n]of this.cache.entries())if(n.timestamp<r)r=n.timestamp,e=t;if(e)this.cache.delete(e)}}}var wr={};$(wr,{select:()=>O});var Vt=Object.create,{getPrototypeOf:Ht,defineProperty:dr,getOwnPropertyNames:qt}=Object,Pt=Object.prototype.hasOwnProperty,Zt=(e,r,t)=>{t=e!=null?Vt(Ht(e)):{};let n=r||!e||!e.__esModule?dr(t,"default",{value:e,enumerable:!0}):t;for(let o of qt(e))if(!Pt.call(n,o))dr(n,o,{get:()=>e[o],enumerable:!0});return n},zt=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),en=zt((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,s=Object.prototype.hasOwnProperty,a=new WeakMap,i=(u)=>{var c=a.get(u),h;if(c)return c;if(c=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((f)=>!s.call(c,f)&&t(c,f,{get:()=>u[f],enumerable:!(h=o(u,f))||h.enumerable}));return a.set(u,c),c},l=(u,c)=>{for(var h in c)t(u,h,{get:c[h],enumerable:!0,configurable:!0,set:(f)=>c[h]=()=>f})},m={};l(m,{splitWithQuotes:()=>g,splitNested:()=>y}),r.exports=i(m);var y=(u,c,h="(",f=")")=>{let w=0,p="",v=[];for(let d of u){if(p+=d,d===h)w++;if(d===f)w--;if(w===0&&d===c)v.push(p.slice(0,-1)),p=""}if(p)v.push(p);return v},g=(u,c=",")=>{let h=[],f=u.length,w=c.length,p=0,v=(d)=>{if(d+w>f)return!1;for(let M=0;M<w;M++)if(u[d+M]!==c[M])return!1;return!0};while(p<f){while(p<f&&u[p]===" ")p++;if(p>=f)break;let d="",M=u[p]==='"'||u[p]==="'";if(M){let k=u[p++];while(p<f&&u[p]!==k)d+=u[p++];if(p<f)p++}else{while(p<f&&!v(p)){let k=u[p];if(k==='"'||k==="'"){d+=k,p++;while(p<f&&u[p]!==k)d+=u[p++];if(p<f)d+=u[p++]}else d+=u[p++]}d=d.trim()}if(d)h.push({value:d,quoted:M});if(v(p))p+=w}return h}}),rn=Zt(en(),1),tn=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,nn=/^([^[\]]*)\[([^\]]*)]$/,Je=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return O(r,o,t)?.toString()}return n?e:void 0},on=(e,r,t,n)=>{let o=Je(r,t,n);if(o)return O(e,o,n);let s=tn.exec(r);if(s){let[,i,l,m]=s,y=Je(i.trim(),t,n,!0),g=Je(m.trim(),t,n,!0);if(Array.isArray(e)&&(l==="="||l==="==")&&y)return e.find((u)=>u?.[y]==g)}let a=nn.exec(r);if(a){let[,i,l]=a;return e?.[i]?.[l]}return e?.[r]},O=(e,r,t)=>{let n=void 0,o=void 0,s=r??"",a=(g)=>{if(!g)return[g,!1];return g.endsWith("?")?[g.substring(0,g.length-1),!0]:[g,!1]},i=(g,u)=>{let[c,h]=a(u.pop());if(!c){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return g}let f=on(g,c,e,t);if(f===void 0){if(h||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${c}" in "${s}"`)}return n=g,o=c,i(f,u)},l=rn.splitNested(s,t?.separator??".","{","}"),m=void 0;if(l.length>0&&l[l.length-1].startsWith("?="))m=l.pop()?.substring(2);l.reverse();let y=i(e,l);if(y===void 0)return m??t?.defaultValue;return y};var we=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return O(e.root,r);return r};var he=(e)=>{if(typeof e.value==="string")return O(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return O(e.root,r.from);return r.from};var be=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let n=JSON.parse(JSON.stringify(t.selector));return await F(n,{...e.options,root:{...e.root,result:r}}),n}return await O({...e.root,result:r},t.selector)};var hr={};$(hr,{PathManager:()=>T});import J from"path";class T{constructor(){}static normalize(e){return J.normalize(J.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),n=J.isAbsolute(e)?e:J.join(t,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(J.isAbsolute(e))return e;return J.join(r??process.cwd(),e)}}var br={};$(br,{conditionPredicatesTypes:()=>re,conditionPredicates:()=>j});var j={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!j.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},re={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var vr=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await he(e),n=await we(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)n=B([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let o=[];for(let s=0;s<t.length;s++){let a=R(n);if(await F(a,{...e.options,root:{...e.root,index:s,item:t[s],instance:a}}),r.extend?.result){let i=r.extend.result;a=B([a,...Array.isArray(i)?i:[i]])}o.push(await be(e,a))}return o}}});var Mr=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let r=await he(e),t=await we(e);if(!Array.isArray(r))throw Error('Key "map" requires a source list');if(t===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<r.length;o++){let s=R(t);await F(s,{...e.options,root:{...e.root,index:o,item:r[o],instance:s}}),n.push(await be(e,s))}return n}}});var Or=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await O(e.root,t));return r.filter((t)=>t!==void 0)}});var Er=()=>({extends:async(e)=>{let r=async(t,n)=>{for(let o of Array.isArray(n)?n:[n]){let s=await O(e.root,o),a=R(s);if(a[e.key])await r(a,a[e.key]);await F(a,{...e.options}),N(a,t),delete t[e.key]}};return await r(e.parent,e.value),b.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:n,...o}=t;return t.items.forEach((s)=>r.push({...o,...s})),b.DeleteParent()}});var Ar=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?b.DeleteParent():b.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),b.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],n=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(n!==void 0)delete r.parent[".else"];let o=r.value?t:n;if(o===void 0)return b.DeleteItem();if(typeof o==="string")return(await F({value:o},{...r.options,root:{...r.root}})).value;return b.ReplaceParent(o,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return b.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return b.ReplaceParent(t.default,!0);return b.DeleteParent()}});var kr=()=>({from:async({root:e,parent:r,value:t})=>{let n=await O(e,t);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(n))return[...n,...r.content];return N(n,r.content),r.content}return n}});import Sr from"node:vm";var Fr=(e)=>({modules:async(r)=>{for(let[t,n]of Object.entries(r.value)){let o=Sr.createContext({console,objector:e,document:r.root}),s=new Sr.SourceTextModule(n,{identifier:t,context:o});await s.link((a)=>{throw Error(`Module ${a} is not allowed`)}),await s.evaluate(),e.sources(Object.fromEntries(Object.entries(s.namespace).map(([a,i])=>[`${t}.${a}`,(l)=>i(l,...l.args)])))}return b.DeleteItem()}});var Dr=()=>({try:{fn:(e)=>{let r=e.parent[".catch"];if(r!==void 0)delete e.parent[".catch"];try{return e.value}catch(t){if(r!==void 0)return r;return b.DeleteItem()}}}});var $r=()=>({let:{fn:(e)=>{let r=e.value;return Object.assign(e.root,r),b.DeleteItem()}}});var Rr=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});var sn=Object.getPrototypeOf(async function(){}).constructor,jr=async(e)=>{let r=[],t={write:(s)=>r.push(s)},o=await new sn("document",e.section.content)({...e.root,...t});if(typeof o<"u")return o;if(r.length===0)return!1;return r.join("")};var Wr=()=>({script:jr});import Nr from"fs/promises";import te from"path";var Cr=(e)=>({include:async(r)=>{let{file:t}=r.options.globalContext;return await Z(r.args[0],{cwd:te.dirname(t),filter:(n)=>te.basename(t)!==n,map:async(n)=>e.load(n,te.dirname(t),r.root)})},exists:async({args:[r]})=>await Y(r),file:async(r)=>await Nr.readFile(await I(r.args[0],e.getIncludeDirectories())).then((t)=>t.toString()),scan:async(r)=>{let t=[],o=(()=>{let i=r.args[2]??["**/node_modules/**"],l=typeof i==="string"?i.split(",").map((m)=>m.trim()):i;if(!Array.isArray(l))throw Error("Scan exclusion must be a list");return l})(),{file:s}=r.options.globalContext,a=r.args[1]?await I(r.args[1],e.getIncludeDirectories()):te.dirname(s);for await(let i of Nr.glob(r.args[0],{cwd:a,exclude:(l)=>o.some((m)=>te.matchesGlob(l,m))}))t.push(i);return t}});var Lr=()=>D({env:(e)=>process.env[e]});var Ur={};$(Ur,{tokenize:()=>Qe,stripIndent:()=>Ke,snake:()=>K,pascal:()=>Q,padBlock:()=>C,changeCase:()=>G,capital:()=>ne,camel:()=>oe});var Q=(e)=>e.replace(/((?:[_ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()).replace(/[_ ]/g,""),ne=(e)=>e.replace(/((?:[ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()),oe=(e)=>{let r=Q(e);return r.charAt(0).toLowerCase()+r.slice(1)},K=(e,r="_")=>e.replace(/([a-z])([A-Z])/g,`$1${r}$2`).replace(/\s+/g,r).toLowerCase(),G=(e,r)=>{switch(r){case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();default:return e}},C=(e,r,t=`
|
|
9
|
+
(${n})`)}}),e},q=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),De=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,q(t,r?.types?.[t.name])])),D=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,q(e[t],r?.types?.[t])]));var Ce={};$(Ce,{writeOutputs:()=>z,writeOutput:()=>ce,writeFormat:()=>fe,locate:()=>I,loadFormat:()=>P,importList:()=>me,importGlob:()=>Ne,globMap:()=>Z,exists:()=>Y});import ar from"fs/promises";import Re from"path";import Jt from"fs/promises";import Qt from"path";import Kt from"fs/promises";import Gt from"fs/promises";import pr from"fs/promises";import lr from"path";import xt from"fs/promises";import je from"path";import ur from"path";var Y=async(e)=>{try{return await ar.access(e,ar.constants.R_OK),!0}catch{return!1}},I=async(e,r)=>{let t=!Re.isAbsolute(e)&&r?["",...r]:[""];for(let n of t){let o=Re.join(n,e);if(await Y(o))return Re.resolve(o)}throw Error(`File not found: "${e}"`)},P=async(e,r)=>{let t=await I(e,r?.dirs),n=await Jt.readFile(t,"utf-8"),o=Qt.dirname(t),s={text:{fn:(i)=>i,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...r?.parsers},a=r?.format?s[r.format]:Object.values(s).find((i)=>i.matching?.some((l)=>new RegExp(l).test(e)));if(!a)throw Error(`Unsupported format for file "${e}" and no matching parser found`);return{content:await a.fn(n),fullPath:t,folderPath:o}},fe=async(e,r,t)=>{let n={text:{fn:(s)=>s,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...t?.encoders},o=t?.format?n[t.format]:Object.values(n).find((s)=>s.matching?.some((a)=>new RegExp(a).test(e)));if(!o)throw Error(`Unsupported format for file "${e}" and no matching encoder found`);await Kt.writeFile(e,await o.fn(r))},Z=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(Gt.glob(e,{cwd:r.cwd})),n=r.filter?t.filter(r.filter):t;return await Promise.all(n.map(r.map))},z=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await pr.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await ce(t,r)},ce=async(e,r)=>{let t=lr.join(r?.targetDirectory??".",e.name),n=lr.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await pr.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${t}": ${o.message}`)}try{await fe(t,e.value,{format:e.type??"text"})}catch(o){throw Error(`Failed to write output "${t}": ${o.message}`)}},We=(e)=>e?ur.isAbsolute(e)?e:ur.join(process.cwd(),e):process.cwd(),me=async(e,r)=>{let t=[];for(let n of e)try{let o=!je.isAbsolute(n)?je.join(We(r?.cwd),n):n;if(r?.filter?.(o)===!1)continue;let s=await import(o);if(r?.resolveDefault==="only"&&!s.default)throw Error(`Module ${n} does not have a default export`);let a=r?.resolveDefault?s.default??s:s,i=r?.map?await r.map(a,n):a;if(i!==void 0)t.push(i)}catch(o){if(r?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return t},Ne=async(e,r)=>{let t=[];for(let n of e){let o=(await Array.fromAsync(xt.glob(n,{cwd:We(r?.cwd)}))).map((s)=>je.join(We(r?.cwd),s));t.push(...await me(o,r))}return t};var Ye={};$(Ye,{toObjectWithKey:()=>Le,toObject:()=>ee,toList:()=>_,sortBy:()=>_e,nonNullMap:()=>Ue,defined:()=>Ie,deepClone:()=>R,asyncMap:()=>Te});var _=(e,r="name")=>Object.entries(e).map(([t,n])=>({[r]:t,...n})),Le=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),ee=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:n,...o}=t;return[n,o]})),Ue=(e,r)=>{if(!e)return[];let t=[],n=0;for(let o of e)if(o!==null&&o!==void 0)t.push(r(o,n,e)),n++;return t},Ie=(e,r="Value is undefined")=>{if(e===void 0||e===null)throw Error(r);return e},_e=(e,r,t=(n,o)=>n-o)=>e.slice().sort((n,o)=>t(r(n),r(o))),Te=async(e,r)=>Promise.all(e.map(r)),R=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var Zr={};$(Zr,{defaultProcessors:()=>Ge});var fr={};$(fr,{navigate:()=>ye,find:()=>Be,NavigateResult:()=>b,NavigateAction:()=>ge});var ge;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(ge||={});class b{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new b(0);static _noExplore=new b(2);static _skipSiblings=new b(1);static _deleteParent=new b(4);static ReplaceParent(e,r){return new b(3,e,void 0,r)}static SkipSiblings(){return b._skipSiblings}static Explore(){return b._explore}static NoExplore(){return b._noExplore}static DeleteParent(){return b._deleteParent}static MergeParent(e){return new b(5,e)}static ReplaceItem(e,r){return new b(6,e,r)}static DeleteItem(e){return new b(7,void 0,e)}}var ye=async(e,r)=>{let t=new WeakSet,n=[],o=[],s=async(i,l,m)=>{let y=i===null,g=y?b.Explore():await r({key:i,value:l,path:n,parent:m,parents:o});if(l&&typeof l==="object"&&g.action===0){if(t.has(l))return g;if(t.add(l),!y)n.push(i),o.push(m);let u=l;while(await a(u,i,m))u=m[i];if(!y)o.pop(),n.pop()}return g},a=async(i,l,m)=>{let y=Object.keys(i),g=y.length;for(let u=0;u<g;u++){let c=y[u],h=i[c],f=await s(c,h,i),w=f.action;if(w===0||w===2)continue;if(w===6){if(i[c]=f.by,f.skipSiblings)return;continue}if(w===7){if(delete i[c],f.skipSiblings)return;continue}if(w===1)return;if(w===3){if(l===null)throw Error("Cannot replace root object");if(m[l]=f.by,f.reexplore)return!0;return}if(w===4){if(l===null)throw Error("Cannot delete root object");delete m[l];return}if(w===5)delete i[c],Object.assign(i,f.by)}};await s(null,e,null)},Be=async(e,r)=>{let t=[];return await ye(e,(n)=>{if(r([...n.path,n.key].join("."),n.value))t.push(n.value);return b.Explore()}),t};var cr=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return b.SkipSiblings()}});import Xt from"path";var mr=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:n}of Array.isArray(r.value)?r.value:[r.value]){if(!n)throw Error("File reference required");await e.load(n,t.file&&Xt.dirname(t.file))}return b.DeleteItem()}});var gr={};$(gr,{mergeAll:()=>B,merge:()=>N});var N=(e,r,t)=>{for(let n of Object.keys(r)){if(e[n]===void 0)continue;let o=r[n],s=e[n];if(typeof s!==typeof o||Array.isArray(s)!==Array.isArray(o)){let i=t?.mismatch?.(n,s,o,e,r);if(i!==void 0){r[n]=i;continue}throw Error(`Type mismatch: ${n}`)}let a=t?.mode?.(n,s,o,e,r)??r[".merge"]??"merge";switch(a){case"source":r[n]=s;continue;case"target":continue;case"skip":delete r[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${a}`)}if(typeof s==="object")if(Array.isArray(s))o.push(...s);else{if(t?.navigate?.(n,s,o,e,r)===!1)continue;N(s,o,t)}else{if(s===o)continue;let i=t?.conflict?.(n,s,o,e,r);r[n]=i===void 0?o:i}}for(let n of Object.keys(e))if(r[n]===void 0)r[n]=e[n]},B=(e,r)=>{let t={};for(let n of e.toReversed())N(n,t,r);return t};var yr={};$(yr,{CacheManager:()=>de});class de{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,n]of this.cache.entries())if(n.timestamp<r)r=n.timestamp,e=t;if(e)this.cache.delete(e)}}}var wr={};$(wr,{select:()=>O});var Vt=Object.create,{getPrototypeOf:Ht,defineProperty:dr,getOwnPropertyNames:qt}=Object,Pt=Object.prototype.hasOwnProperty,Zt=(e,r,t)=>{t=e!=null?Vt(Ht(e)):{};let n=r||!e||!e.__esModule?dr(t,"default",{value:e,enumerable:!0}):t;for(let o of qt(e))if(!Pt.call(n,o))dr(n,o,{get:()=>e[o],enumerable:!0});return n},zt=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),en=zt((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,s=Object.prototype.hasOwnProperty,a=new WeakMap,i=(u)=>{var c=a.get(u),h;if(c)return c;if(c=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((f)=>!s.call(c,f)&&t(c,f,{get:()=>u[f],enumerable:!(h=o(u,f))||h.enumerable}));return a.set(u,c),c},l=(u,c)=>{for(var h in c)t(u,h,{get:c[h],enumerable:!0,configurable:!0,set:(f)=>c[h]=()=>f})},m={};l(m,{splitWithQuotes:()=>g,splitNested:()=>y}),r.exports=i(m);var y=(u,c,h="(",f=")")=>{let w=0,p="",v=[];for(let d of u){if(p+=d,d===h)w++;if(d===f)w--;if(w===0&&d===c)v.push(p.slice(0,-1)),p=""}if(p)v.push(p);return v},g=(u,c=",")=>{let h=[],f=u.length,w=c.length,p=0,v=(d)=>{if(d+w>f)return!1;for(let M=0;M<w;M++)if(u[d+M]!==c[M])return!1;return!0};while(p<f){while(p<f&&u[p]===" ")p++;if(p>=f)break;let d="",M=u[p]==='"'||u[p]==="'";if(M){let k=u[p++];while(p<f&&u[p]!==k)d+=u[p++];if(p<f)p++}else{while(p<f&&!v(p)){let k=u[p];if(k==='"'||k==="'"){d+=k,p++;while(p<f&&u[p]!==k)d+=u[p++];if(p<f)d+=u[p++]}else d+=u[p++]}d=d.trim()}if(d)h.push({value:d,quoted:M});if(v(p))p+=w}return h}}),rn=Zt(en(),1),tn=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,nn=/^([^[\]]*)\[([^\]]*)]$/,Je=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return O(r,o,t)?.toString()}return n?e:void 0},on=(e,r,t,n)=>{let o=Je(r,t,n);if(o)return O(e,o,n);let s=tn.exec(r);if(s){let[,i,l,m]=s,y=Je(i.trim(),t,n,!0),g=Je(m.trim(),t,n,!0);if(Array.isArray(e)&&(l==="="||l==="==")&&y)return e.find((u)=>u?.[y]==g)}let a=nn.exec(r);if(a){let[,i,l]=a;return e?.[i]?.[l]}return e?.[r]},O=(e,r,t)=>{let n=void 0,o=void 0,s=r??"",a=(g)=>{if(!g)return[g,!1];return g.endsWith("?")?[g.substring(0,g.length-1),!0]:[g,!1]},i=(g,u)=>{let[c,h]=a(u.pop());if(!c){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return g}let f=on(g,c,e,t);if(f===void 0){if(h||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${c}" in "${s}"`)}return n=g,o=c,i(f,u)},l=rn.splitNested(s,t?.separator??".","{","}"),m=void 0;if(l.length>0&&l[l.length-1].startsWith("?="))m=l.pop()?.substring(2);l.reverse();let y=i(e,l);if(y===void 0)return m??t?.defaultValue;return y};var we=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return O(e.root,r);return r};var he=(e)=>{if(typeof e.value==="string")return O(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return O(e.root,r.from);return r.from};var be=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let n=JSON.parse(JSON.stringify(t.selector));return await F(n,{...e.options,root:{...e.root,result:r}}),n}return await O({...e.root,result:r},t.selector)};var hr={};$(hr,{PathManager:()=>T});import J from"path";class T{constructor(){}static normalize(e){return J.normalize(J.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),n=J.isAbsolute(e)?e:J.join(t,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(J.isAbsolute(e))return e;return J.join(r??process.cwd(),e)}}var br={};$(br,{conditionPredicatesTypes:()=>re,conditionPredicates:()=>j});var j={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!j.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},re={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var vr=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await he(e),n=await we(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)n=B([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let o=[];for(let s=0;s<t.length;s++){let a=R(n);if(await F(a,{...e.options,root:{...e.root,index:s,item:t[s],instance:a}}),r.extend?.result){let i=r.extend.result;a=B([a,...Array.isArray(i)?i:[i]])}o.push(await be(e,a))}return o}}});var Mr=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let r=await he(e),t=await we(e);if(!Array.isArray(r))throw Error('Key "map" requires a source list');if(t===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<r.length;o++){let s=R(t);await F(s,{...e.options,root:{...e.root,index:o,item:r[o],instance:s}}),n.push(await be(e,s))}return n}}});var Or=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await O(e.root,t));return r.filter((t)=>t!==void 0)}});var Er=()=>({extends:async(e)=>{let r=async(t,n)=>{for(let o of Array.isArray(n)?n:[n]){let s=await O(e.root,o),a=R(s);if(a[e.key])await r(a,a[e.key]);await F(a,{...e.options}),N(a,t),delete t[e.key]}};return await r(e.parent,e.value),b.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:n,...o}=t;return t.items.forEach((s)=>r.push({...o,...s})),b.DeleteParent()}});var Ar=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?b.DeleteParent():b.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),b.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],n=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(n!==void 0)delete r.parent[".else"];let o=r.value?t:n;if(o===void 0)return b.DeleteItem();if(typeof o==="string")return(await F({value:o},{...r.options,root:{...r.root}})).value;return b.ReplaceParent(o,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return b.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return b.ReplaceParent(t.default,!0);return b.DeleteParent()}});var kr=()=>({from:async({root:e,parent:r,value:t})=>{let n=await O(e,t);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(n))return[...n,...r.content];return N(n,r.content),r.content}return n}});import Sr from"node:vm";var Fr=(e)=>({modules:async(r)=>{for(let[t,n]of Object.entries(r.value)){let o=Sr.createContext({console,objector:e,document:r.root}),s=new Sr.SourceTextModule(n,{identifier:t,context:o});await s.link((a)=>{throw Error(`Module ${a} is not allowed`)}),await s.evaluate(),e.sources(Object.fromEntries(Object.entries(s.namespace).map(([a,i])=>[`${t}.${a}`,(l)=>i(l,...l.args)])))}return b.DeleteItem()}});var Dr=()=>({try:{fn:(e)=>{let r=e.parent[".catch"];if(r!==void 0)delete e.parent[".catch"];try{return e.value}catch(t){if(r!==void 0)return r;return b.DeleteItem()}}}});var $r=()=>({let:{fn:(e)=>{let r=e.value;return Object.assign(e.root,r),b.DeleteItem()}}});var Rr=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});var sn=Object.getPrototypeOf(async function(){}).constructor,jr=async(e)=>{let r=[],t={write:(s)=>r.push(s)},o=await new sn("section",e.section.content)({...e.root,...t});if(typeof o<"u")return o;if(r.length===0)return!1;return r.join("")};var Wr=()=>({script:jr});import Nr from"fs/promises";import te from"path";var Cr=(e)=>({include:async(r)=>{let{file:t}=r.options.globalContext;return await Z(r.args[0],{cwd:te.dirname(t),filter:(n)=>te.basename(t)!==n,map:async(n)=>e.load(n,te.dirname(t),r.root)})},exists:async({args:[r]})=>await Y(r),file:async(r)=>await Nr.readFile(await I(r.args[0],e.getIncludeDirectories())).then((t)=>t.toString()),scan:async(r)=>{let t=[],o=(()=>{let i=r.args[2]??["**/node_modules/**"],l=typeof i==="string"?i.split(",").map((m)=>m.trim()):i;if(!Array.isArray(l))throw Error("Scan exclusion must be a list");return l})(),{file:s}=r.options.globalContext,a=r.args[1]?await I(r.args[1],e.getIncludeDirectories()):te.dirname(s);for await(let i of Nr.glob(r.args[0],{cwd:a,exclude:(l)=>o.some((m)=>te.matchesGlob(l,m))}))t.push(i);return t}});var Lr=()=>D({env:(e)=>process.env[e]});var Ur={};$(Ur,{tokenize:()=>Qe,stripIndent:()=>Ke,snake:()=>K,pascal:()=>Q,padBlock:()=>C,changeCase:()=>G,capital:()=>ne,camel:()=>oe});var Q=(e)=>e.replace(/((?:[_ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()).replace(/[_ ]/g,""),ne=(e)=>e.replace(/((?:[ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()),oe=(e)=>{let r=Q(e);return r.charAt(0).toLowerCase()+r.slice(1)},K=(e,r="_")=>e.replace(/([a-z])([A-Z])/g,`$1${r}$2`).replace(/\s+/g,r).toLowerCase(),G=(e,r)=>{switch(r){case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();default:return e}},C=(e,r,t=`
|
|
10
10
|
`,n=" ")=>{let o=n.repeat(r);return e.split(t).map((s)=>o+s).join(t)},Qe=(e,r,t=/\${([^}]+)}/g)=>{return e.replace(t,(n,o)=>{let s=r[o];if(s===null||s===void 0)return"";if(typeof s==="string")return s;if(typeof s==="number"||typeof s==="boolean")return String(s);return String(s)})},Ke=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
|
|
11
11
|
`)};var Ir=(e)=>({substring:{types:{0:"ref",1:"number",2:"number"},fn:(r)=>r.args[0].substring(r.args[1],r.args[2])},repeat:{types:{0:"ref",1:"number"},fn:({args:[r,t]})=>r.repeat(t)},uuid:(r)=>crypto.randomUUID(),pad:{types:{0:"ref",1:"number",2:"string"},fn:({args:[r,t],tags:n})=>{let o=n.join?.[0]??`
|
|
12
12
|
`,s=n.padChar?.[0]??" ";return C(r,t??2,o,s)}},formatAs:{fn:({args:[r,t],tags:n})=>{let o=e.getEncoder(t);if(!o)throw Error("Unsupported format: "+String(t));let s=[];if(o.options?.includeTags)s=[n];return o.fn(r,...s)}},...D({pascal:Q,camel:oe,capital:ne,concat:(...r)=>r.join(""),len:(r)=>r.length,reverse:(r)=>r.split("").reverse().join(""),trim:(r)=>r.trim(),ltrim:(r)=>r.trimStart(),rtrim:(r)=>r.trimEnd(),lower:(r)=>r.toLowerCase(),upper:(r)=>r.toUpperCase(),snake:(r,t)=>G(K(r,"_"),t),kebab:(r,t)=>G(K(r,"-"),t),encode:(r,t)=>Buffer.from(r).toString(t??"base64"),decode:(r,t)=>Buffer.from(r,t??"base64").toString()})});var ve=(e,r=0,t)=>{let n=" ".repeat(r),o=" ".repeat(r+1);if(e===null||e===void 0)return"null";else if(typeof e==="boolean")return String(e);else if(typeof e==="number")return String(e);else if(typeof e==="string")return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;else if(Array.isArray(e)){if(e.length===0)return"[]";return`[
|