@jaredwray/fumanchu 4.2.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,11 +1,2428 @@
1
- "use strict";var Ln=Object.create;var H=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Un=Object.getOwnPropertyNames;var In=Object.getPrototypeOf,vn=Object.prototype.hasOwnProperty;var Jn=(n,e)=>{for(var r in e)H(n,r,{get:e[r],enumerable:!0})},B=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Un(e))!vn.call(n,o)&&o!==r&&H(n,o,{get:()=>e[o],enumerable:!(t=Pn(e,o))||t.enumerable});return n};var a=(n,e,r)=>(r=n!=null?Ln(In(n)):{},B(e||!n||!n.__esModule?H(r,"default",{value:n,enumerable:!0}):r,n)),qn=n=>B(H({},"__esModule",{value:!0}),n);var Ut={};Jn(Ut,{Handlebars:()=>Mt,HelperRegistry:()=>d,createHandlebars:()=>Lt,fumanchu:()=>Pt,handlebars:()=>Ct,helpers:()=>zt});module.exports=qn(Ut);var y=a(require("handlebars"),1);var Dn=(n,e)=>Array.isArray(n)?n.slice(e):[],Wn=(n,e)=>Array.isArray(n)?n.slice(0,-e):[],f=n=>n==null?[]:Array.isArray(n)?n:[n],Gn=(n,e)=>{if(Array.isArray(n))return typeof e!="number"?n[0]:n.slice(0,e)},Yn=(n,e)=>{if(!Array.isArray(n)&&typeof n!="string")return;if(typeof e!="number"){let t=n;return t[t.length-1]}let r=Math.abs(e);return n.slice(-r)},Qn=n=>n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n).length:typeof n=="string"||Array.isArray(n)?n.length:0,Zn=(n,e=", ")=>typeof n=="string"?n:Array.isArray(n)?n.join(e):"",Kn=function(n,e){if(!Array.isArray(n)||!e||typeof e.fn!="function")return e?.inverse?e.inverse(this)??"":"";if(n.length===0)return e.inverse?e.inverse(this)??"":"";let r=n.length,t=e.hash??{},o=e.data?{...e.data}:void 0,s="";for(let i=0;i<r;i++){let p=n[i],g={index:i,total:r,isFirst:i===0,isLast:i===r-1},zn={...o?{...o}:{},...t,...g},R;p!=null&&typeof p=="object"?R={...p,...t,...g}:R={value:p,...t,...g},s+=e.fn(R,{data:zn})}return s},_=[{name:"after",category:"array",compatibility:["browser","nodejs"],fn:Dn},{name:"before",category:"array",compatibility:["browser","nodejs"],fn:Wn},{name:"arrayify",category:"array",compatibility:["browser","nodejs"],fn:f},{name:"first",category:"array",compatibility:["browser","nodejs"],fn:Gn},{name:"last",category:"array",compatibility:["browser","nodejs"],fn:Yn},{name:"length",category:"array",compatibility:["browser","nodejs"],fn:Qn},{name:"join",category:"array",compatibility:["browser","nodejs"],fn:Zn},{name:"forEach",category:"array",compatibility:["browser","nodejs"],fn:Kn}];var M=a(require("fs"),1),C=a(require("path"),1),S=a(require("html-tag"),1),z=a(require("to-gfm-code-block"),1),Vn=(n,e)=>{let r=typeof e=="string"?e:C.default.extname(n).slice(1),t=M.default.readFileSync(n,"utf8");return(r==="markdown"||r==="md")&&(r="markdown",t=t.split("`").join("&#x60")),`${(0,z.default)(t,r).trim()}
2
- `},Xn=n=>(0,S.default)("script",{src:`https://gist.github.com/${n}.js`}),ne=n=>{if(!n||!n.id)throw new Error("jsfiddle helper expects an `id`");let{id:e,width:r="100%",height:t="300",skin:o="/presentation/",tabs:s="result,js,html,css",allowfullscreen:i="allowfullscreen",frameborder:p="0"}=n,g=`http://jsfiddle.net/${e}/embedded/${s}${o}`;return(0,S.default)("iframe",{width:r,height:t,src:g,allowfullscreen:i,frameborder:p})},L=[{name:"embed",category:"code",compatibility:["nodejs"],fn:Vn},{name:"gist",category:"code",compatibility:["browser","nodejs"],fn:Xn},{name:"jsfiddle",category:"code",compatibility:["browser","nodejs"],fn:ne}];var ee=n=>n==null?!0:Array.isArray(n)?n.length===0:typeof n=="object"?Object.keys(n).length===0:!1,re=(n,e,r)=>{if(Array.isArray(n)){let t="";for(let o=0;o<n.length;o++)t+=e(n[o],o);return t}if(n&&typeof n=="object"){let t="";for(let o of Object.keys(n))t+=e(n[o],o);return t}return r?r():""},P=[{name:"isEmpty",category:"collection",compatibility:["browser","nodejs"],fn:ee},{name:"iterate",category:"collection",compatibility:["browser","nodejs"],fn:re}];var te=(...n)=>n.every(Boolean),oe=(n,e,r)=>{switch(e){case"==":return n==r;case"===":return n===r;case"!=":return n!=r;case"!==":return n!==r;case"<":return n<r;case">":return n>r;case"<=":return n<=r;case">=":return n>=r;case"typeof":return typeof n===r;default:throw new Error(`helper {{compare}}: invalid operator: '${e}'`)}},se=(n,e,r=0)=>n==null?!1:typeof n=="string"||Array.isArray(n)?n.indexOf(e,r)>-1:typeof n=="object"?e in n:!1,ie=(...n)=>{for(let e of n)if(e!=null)return e;return""},ae=(n,e)=>n===e,ce=(n,e)=>n>e,pe=(n,e)=>n>=e,me=(n,e)=>n==null||e==null?!1:Array.isArray(n)||typeof n=="string"?n.indexOf(e)>-1:typeof n=="object"?e in n:!1,U=(n,e)=>{if(!n)return!0;let r=Array.isArray(e)?e:e!=null?[e]:["0","false","nada","nil","nay","nah","negative","no","none","nope","nul","null","nix","nyet","uh-uh","veto","zero"],t=typeof n=="string"?n.toLowerCase():null;for(let o of r)if(o===n||t!=null&&o===t)return!0;return!1},le=n=>U(n),ye=n=>!U(n),ge=n=>typeof n=="number"&&n%2===0,fe=(n,e)=>typeof n=="number"&&typeof e=="number"&&e%n===0,ue=n=>typeof n=="number"&&Math.abs(n%2)===1,be=(n,e)=>n==e,de=(n,e)=>n!=e,he=(n,e)=>n<e,we=(n,e)=>n<=e,je=(n,e)=>!n&&!e,ke=n=>!n,He=(...n)=>n.some(Boolean),xe=(n,e)=>n!==e,Oe=(n,e)=>n<=e,Ae=(n,e)=>n>=e,Ne=(n,e)=>n<e,$e=(n,e)=>n>e,I=[{name:"and",category:"comparison",compatibility:["browser","nodejs"],fn:te},{name:"compare",category:"comparison",compatibility:["browser","nodejs"],fn:oe},{name:"contains",category:"comparison",compatibility:["browser","nodejs"],fn:se},{name:"default",category:"comparison",compatibility:["browser","nodejs"],fn:ie},{name:"eq",category:"comparison",compatibility:["browser","nodejs"],fn:ae},{name:"gt",category:"comparison",compatibility:["browser","nodejs"],fn:ce},{name:"gte",category:"comparison",compatibility:["browser","nodejs"],fn:pe},{name:"has",category:"comparison",compatibility:["browser","nodejs"],fn:me},{name:"isFalsey",category:"comparison",compatibility:["browser","nodejs"],fn:le},{name:"isTruthy",category:"comparison",compatibility:["browser","nodejs"],fn:ye},{name:"ifEven",category:"comparison",compatibility:["browser","nodejs"],fn:ge},{name:"ifNth",category:"comparison",compatibility:["browser","nodejs"],fn:fe},{name:"ifOdd",category:"comparison",compatibility:["browser","nodejs"],fn:ue},{name:"is",category:"comparison",compatibility:["browser","nodejs"],fn:be},{name:"isnt",category:"comparison",compatibility:["browser","nodejs"],fn:de},{name:"lt",category:"comparison",compatibility:["browser","nodejs"],fn:he},{name:"lte",category:"comparison",compatibility:["browser","nodejs"],fn:we},{name:"neither",category:"comparison",compatibility:["browser","nodejs"],fn:je},{name:"not",category:"comparison",compatibility:["browser","nodejs"],fn:ke},{name:"or",category:"comparison",compatibility:["browser","nodejs"],fn:He},{name:"unlessEq",category:"comparison",compatibility:["browser","nodejs"],fn:xe},{name:"unlessGt",category:"comparison",compatibility:["browser","nodejs"],fn:Oe},{name:"unlessLt",category:"comparison",compatibility:["browser","nodejs"],fn:Ae},{name:"unlessGteq",category:"comparison",compatibility:["browser","nodejs"],fn:Ne},{name:"unlessLteq",category:"comparison",compatibility:["browser","nodejs"],fn:$e}];var J=require("chrono-node"),q=a(require("dayjs"),1),Re=()=>new Date().getFullYear().toString(),v=(n,e)=>{let r=(0,J.parseDate)(n);if(!r)throw new Error(`Unable to parse date: ${n}`);return(0,q.default)(r).format(e)},D=[{name:"year",category:"date",compatibility:["browser","nodejs"],fn:Re},{name:"date",category:"date",compatibility:["browser","nodejs"],fn:v},{name:"moment",category:"date",compatibility:["browser","nodejs"],fn:v}];var x=a(require("fs"),1),W=a(require("path"),1),G=a(require("is-glob"),1),Y=a(require("micromatch"),1),Se=(n,e)=>{if(n==null)return"0 B";let r=typeof n=="number"?n:n.length??0;if(!r)return"0 B";let t=typeof e=="number"?e:2,o=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],s=10**t,i=o.length-1;do{let p=10**(i*3);if(p<=r+1)return`${Math.round(r*s/p)/s} ${o[i]}`}while(--i>=0);return`${r} B`},Ee=n=>x.default.readFileSync(n,"utf8"),Fe=n=>!!(n&&typeof n=="object"&&"hash"in n),Te=(n,e)=>{let r=x.default.readdirSync(n).map(o=>W.default.join(n,o)),t=Fe(e)?void 0:e;if(typeof t=="function")return t(r);if(t instanceof RegExp)return r.filter(o=>t.test(o));if(typeof t=="string"){if((0,G.default)(t))return(0,Y.default)(r,t);if(t==="isFile"||t==="isDirectory")return r.filter(o=>{let s=x.default.statSync(o);return t==="isFile"?s.isFile():s.isDirectory()})}return r},Q=[{name:"fileSize",category:"fs",compatibility:["nodejs"],fn:Se},{name:"read",category:"fs",compatibility:["nodejs"],fn:Ee},{name:"readdir",category:"fs",compatibility:["nodejs"],fn:Te}];var O=a(require("path"),1),E=a(require("html-tag"),1),Z=a(require("striptags"),1);var u=(n={})=>Object.keys(n).map(e=>`${e}="${String(n[e]).replace(/^['"]|["']$/g,"")}"`).join(" "),Be=n=>{let e=u(n?.hash??{});return e.trim()?` ${e}`:""},_e=function(n,e){arguments.length<2&&(e=n,n=[]);let r=f(n??[]),t="";return this&&this.options&&(t=this.options.assets||""),e?.hash?.href&&(r=f(e.hash.href)),r.map(o=>{let s=O.default.extname(o),i=o;return/(^\/\/)|(:\/\/)/.test(o)||(i=O.default.posix.join(t,o)),s===".less"?`<link type="text/css" rel="stylesheet/less" href="${i}">`:`<link type="text/css" rel="stylesheet" href="${i}">`}).join(`
3
- `)},Me=n=>{if(n&&typeof n=="object"&&!Array.isArray(n)){let r=u(n.hash??{});return`<script${r?` ${r}`:""}></script>`}return typeof n=="string"?`<script src="${n}"></script>`:f(n).map(r=>O.default.extname(r)===".coffee"?(0,E.default)("script",{type:"text/coffeescript",src:r}):(0,E.default)("script",{src:r})).join(`
4
- `)},Ce=n=>typeof n!="string"?"":(0,Z.default)(n).trim(),ze=(n,e)=>{let r=u(e.hash??{}),t=n.map(s=>typeof s=="string"?s:e.fn(s));return`${r?`<ul ${r}>`:"<ul>"}${t.map(s=>`<li>${s}</li>`).join(`
5
- `)}</ul>`},Le=(n,e)=>{let r=u(e.hash??{}),t=n.map(s=>typeof s=="string"?s:e.fn(s));return`${r?`<ol ${r}>`:"<ol>"}${t.map(s=>`<li>${s}</li>`).join(`
6
- `)}</ol>`},Pe=n=>{let e="",r="",t=n.full||!1,o={alt:n.alt,src:n.thumbnail,width:n.size.width,height:n.size.height},s={id:`image-${n.id}`},i={href:t,rel:"thumbnail"};return n.classes&&(n.classes.image&&(o.class=n.classes.image.join(" ")),n.classes.figure&&(s.class=n.classes.figure.join(" ")),n.classes.link&&(i.class=n.classes.link.join(" "))),e+=`<figure ${u(s)}>
7
- `,r+=`<img ${u(o)}>
8
- `,t?e+=`<a ${u(i)}>
9
- ${r}</a>
10
- `:e+=r,n.caption&&(e+=`<figcaption>${n.caption}</figcaption>
11
- `),e+="</figure>",e},K=[{name:"attr",category:"html",compatibility:["browser","nodejs"],fn:Be},{name:"css",category:"html",compatibility:["nodejs"],fn:_e},{name:"js",category:"html",compatibility:["nodejs"],fn:Me},{name:"sanitize",category:"html",compatibility:["browser","nodejs"],fn:Ce},{name:"ul",category:"html",compatibility:["browser","nodejs"],fn:ze},{name:"ol",category:"html",compatibility:["browser","nodejs"],fn:Le},{name:"thumbnailImage",category:"html",compatibility:["browser","nodejs"],fn:Pe}];var h=(n,e)=>{if(!n||typeof n!="object")return;let r=Array.isArray(e)?e:e.split("."),t=n;for(let o of r){if(t==null||typeof t!="object")return;t=t[o]}return t},F=(n,e)=>{if(!n||typeof n!="object")return;let r=Array.isArray(e)?e:e.split(".");if(r.length===0)return;let t=n;for(let s=0;s<r.length-1;s++){if(t==null||typeof t!="object")return;t=t[r[s]]}let o=r[r.length-1];if(!(t==null||typeof t!="object"||!(o in t)))return{[o]:t[o]}};var Ue=function(n,e,r){if(e&&typeof e=="object"&&"hash"in e&&r===void 0&&(r=e,e={}),typeof n!="string")throw new Error('{{i18n}} helper expected "key" to be a string');let t={...this,...e,...r?.hash??{}},o=t.language||t.lang;if(typeof o!="string")throw new TypeError('{{i18n}} helper expected "language" to be a string');let s=t[o];if(typeof s>"u")throw new Error(`{{i18n}} helper cannot find language "${o}"`);let i=h(s,n);if(typeof i>"u")throw new Error('{{i18n}} helper cannot find property "'+String(n)+'" for language "'+o+'"');return String(i)},V=[{name:"i18n",category:"i18n",compatibility:["browser","nodejs"],fn:Ue}];var Ie=(n,e,r,t)=>{let o=n>1||n===0?r:e;return t?`${n} ${o}`:o},ve=n=>{let e=Math.abs(Math.round(Number(n))),r=String(n),t=e%100;if([11,12,13].includes(t))return`${r}th`;switch(e%10){case 1:return`${r}st`;case 2:return`${r}nd`;case 3:return`${r}rd`;default:return`${r}th`}},X=[{name:"inflect",category:"inflection",compatibility:["browser","nodejs"],fn:Ie},{name:"ordinalize",category:"inflection",compatibility:["browser","nodejs"],fn:ve}];var nn=a(require("logging-helpers"),1),{log:Je,ok:qe,success:De,info:We,warning:Ge,warn:Ye,error:Qe,danger:Ze,bold:Ke,_debug:Ve,_inspect:Xe}=nn.default,en=[{name:"log",category:"logging",compatibility:["nodejs"],fn:Je},{name:"ok",category:"logging",compatibility:["nodejs"],fn:qe},{name:"success",category:"logging",compatibility:["nodejs"],fn:De},{name:"info",category:"logging",compatibility:["nodejs"],fn:We},{name:"warning",category:"logging",compatibility:["nodejs"],fn:Ge},{name:"warn",category:"logging",compatibility:["nodejs"],fn:Ye},{name:"error",category:"logging",compatibility:["nodejs"],fn:Qe},{name:"danger",category:"logging",compatibility:["nodejs"],fn:Ze},{name:"bold",category:"logging",compatibility:["nodejs"],fn:Ke},{name:"_debug",category:"logging",compatibility:["nodejs"],fn:Ve},{name:"_inspect",category:"logging",compatibility:["nodejs"],fn:Xe}];var T=a(require("micromatch"),1),rn=(n,e,r)=>{let t=typeof e=="string"?e.split(/, */):e;return(0,T.default)(n,t,r)},nr=(n,e,r)=>T.default.isMatch(n,e,r),er=(...n)=>(console.log("the {{mm}} helper is depcrecated and will be removed"),console.log("in handlebars-helpers v1.0.0, please use the {{match}}"),console.log("helper instead."),rn(...n)),tn=[{name:"match",category:"match",compatibility:["browser","nodejs"],fn:rn},{name:"isMatch",category:"match",compatibility:["browser","nodejs"],fn:nr},{name:"mm",category:"match",compatibility:["browser","nodejs"],fn:er}];var A=n=>typeof n=="number"&&!Number.isNaN(n)||typeof n=="string"&&n.trim()!==""&&!Number.isNaN(Number(n)),c=(n,e="expected a number")=>{if(A(n))return Number(n);throw new TypeError(e)},rr=n=>{let e=c(n);return Math.abs(e)},tr=(n,e)=>A(n)&&A(e)?Number(n)+Number(e):"",or=(...n)=>{let e=n.flat().map(r=>Number(r));return sn(e)/e.length},sr=n=>{let e=c(n);return Math.ceil(e)},ir=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r/t},ar=n=>{let e=c(n);return Math.floor(e)},cr=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r-t},pr=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r%t},on=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r*t},mr=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r+t},lr=(n,e)=>{let r=c(n,"expected minimum to be a number"),t=c(e,"expected maximum to be a number");return r+Math.floor(Math.random()*(t-r+1))},yr=(n,e)=>n%e,gr=n=>{let e=c(n);return Math.round(e)},fr=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r-t},sn=(...n)=>{let e=n.flat(),r=0;for(let t of e)A(t)&&(r+=Number(t));return r},ur=(n,e)=>on(n,e),an=[{name:"abs",category:"math",compatibility:["browser","nodejs"],fn:rr},{name:"add",category:"math",compatibility:["browser","nodejs"],fn:tr},{name:"avg",category:"math",compatibility:["browser","nodejs"],fn:or},{name:"ceil",category:"math",compatibility:["browser","nodejs"],fn:sr},{name:"divide",category:"math",compatibility:["browser","nodejs"],fn:ir},{name:"floor",category:"math",compatibility:["browser","nodejs"],fn:ar},{name:"minus",category:"math",compatibility:["browser","nodejs"],fn:cr},{name:"modulo",category:"math",compatibility:["browser","nodejs"],fn:pr},{name:"multiply",category:"math",compatibility:["browser","nodejs"],fn:on},{name:"plus",category:"math",compatibility:["browser","nodejs"],fn:mr},{name:"random",category:"math",compatibility:["browser","nodejs"],fn:lr},{name:"remainder",category:"math",compatibility:["browser","nodejs"],fn:yr},{name:"round",category:"math",compatibility:["browser","nodejs"],fn:gr},{name:"subtract",category:"math",compatibility:["browser","nodejs"],fn:fr},{name:"sum",category:"math",compatibility:["browser","nodejs"],fn:sn},{name:"times",category:"math",compatibility:["browser","nodejs"],fn:ur}];var N=a(require("fs"),1),pn=a(require("path"),1),mn=a(require("process"),1),ln=a(require("ent"),1),yn=a(require("handlebars"),1),gn=require("remarkable"),cn=function(n,e){typeof n=="object"&&n&&"fn"in n&&typeof n.fn=="function"?(e=n,n=n.fn(this)):typeof n!="string"&&(n="");let r={cwd:mn.default.cwd(),...e},t=new gn.Remarkable({breaks:!0,html:!0,langPrefix:"lang-",typographer:!1,xhtmlOut:!1}),o=n;if(o&&o.length>0){let s=pn.default.resolve(r.cwd,o);N.default.existsSync(s)&&N.default.statSync(s).isFile()&&(o=N.default.readFileSync(s,"utf8"))}return new yn.default.SafeString(ln.default.decode(t.render(o)))},fn=[{name:"md",category:"markdown",compatibility:["nodejs"],fn:cn},{name:"markdown",category:"markdown",compatibility:["nodejs"],fn:cn}];var un=a(require("handlebars-helper-create-frame"),1),bn=a(require("handlebars-utils"),1),dn=a(require("kind-of"),1);var br=un.default;function dr(n,e,r){return h(bn.default.options(this,e,r),n)}function hr(n){return n.fn(this)}var wr=dn.default;function jr(n){return n.hash&&Object.keys(n.hash).length?n.fn(n.hash):n.inverse(this)}var hn=[{name:"frame",category:"misc",compatibility:["browser","nodejs"],fn:br},{name:"option",category:"misc",compatibility:["browser","nodejs"],fn:dr},{name:"noop",category:"misc",compatibility:["browser","nodejs"],fn:hr},{name:"typeOf",category:"misc",compatibility:["browser","nodejs"],fn:wr},{name:"withHash",category:"misc",compatibility:["browser","nodejs"],fn:jr}];var j=n=>typeof n=="number"&&!Number.isNaN(n),kr=(n,e)=>{if(n==null)return"0 B";let r;if(typeof n=="string"){if(r=n.length,!r)return"0 B"}else if(j(n))r=Number(n);else if(typeof n.length=="number"){if(r=n.length,!r)return"0 B"}else return"0 B";let t=typeof e=="number"&&!Number.isNaN(e)?e:2,o=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],s=10**t;for(let i=o.length-1;i>=0;i--){let p=10**(i*3);if(p<=r+1)return`${Math.round(r*s/p)/s} ${o[i]}`}return`${r}`},Hr=n=>n.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,"),xr=n=>{let e=n.toString();return`(${e.substr(0,3)}) ${e.substr(3,3)}-${e.substr(6,4)}`},Or=(n,e)=>{let r=j(n)?Number(n):0,o=10**(typeof e=="number"&&!Number.isNaN(e)?e:2),s=["k","m","b","t","q"];for(let i=s.length-1;i>=0;i--){let p=10**((i+1)*3);if(p<=r+1)return`${Math.round(r*o/p)/o}${s[i]}`}return`${r}`},Ar=(n,e)=>{let r=j(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:0;return Number(r).toExponential(t)},Nr=(n,e)=>{let r=j(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:0;return Number(r).toFixed(t)},$r=n=>parseFloat(String(n)),Rr=n=>parseInt(String(n),10),Sr=(n,e)=>{let r=j(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:1;return Number(r).toPrecision(t)},wn=[{name:"bytes",category:"number",compatibility:["browser","nodejs"],fn:kr},{name:"addCommas",category:"number",compatibility:["browser","nodejs"],fn:Hr},{name:"phoneNumber",category:"number",compatibility:["browser","nodejs"],fn:xr},{name:"toAbbr",category:"number",compatibility:["browser","nodejs"],fn:Or},{name:"toExponential",category:"number",compatibility:["browser","nodejs"],fn:Ar},{name:"toFixed",category:"number",compatibility:["browser","nodejs"],fn:Nr},{name:"toFloat",category:"number",compatibility:["browser","nodejs"],fn:$r},{name:"toInt",category:"number",compatibility:["browser","nodejs"],fn:Rr},{name:"toPrecision",category:"number",compatibility:["browser","nodejs"],fn:Sr}];var $=n=>!!(n&&typeof n=="object"&&"hash"in n),jn=(n,e)=>({...n?.data||{},...e}),Er=(...n)=>{let e=[...n];if(e.length&&$(e[e.length-1])){let t=e.pop();e.push(t.hash)}let r={};for(let t of e)t&&typeof t=="object"&&!Array.isArray(t)&&Object.assign(r,t);return r},Fr=(n,e)=>{if(!$(e))return e?.inverse?.(n)??"";let r=jn(e,e.hash||{}),t="";for(let o in n)r.key=o,t+=e.fn(n[o],{data:r});return t},Tr=(n,e)=>{if(!$(e))return e?.inverse?.(n)??"";let r=jn(e,e.hash||{}),t="";for(let o in n)Object.hasOwn(n,o)&&(r.key=o,t+=e.fn(n[o],{data:r}));return t},Br=(...n)=>{let e=[];for(let r of n)(typeof r=="string"||typeof r=="number")&&e.push(r);return e.join(".")},_r=(n,e,r)=>{let t=h(e,n);return r&&typeof r.fn=="function"?t?r.fn(t):r.inverse?.(e):t},Mr=(n,e)=>F(e,n),Cr=(n,e)=>Object.hasOwn(n,e),zr=n=>!!n&&typeof n=="object"&&!Array.isArray(n),kn=n=>JSON.parse(n),Hn=(n,e)=>JSON.stringify(n,null,typeof e=="number"?e:0),Lr=(n,...e)=>{let r=[n,...e];if(r.length&&$(r[r.length-1])){let t=r.pop();r.push(t.hash)}return Object.assign(...r)},Pr=kn,Ur=Hn,Ir=(n,e,r)=>{let t=f(n),o={};for(let s of t)o=Object.assign({},o,F(e,s));return r&&typeof r.fn=="function"?Object.keys(o).length?r.fn(o):r.inverse?.(e):o},xn=[{name:"extend",category:"object",compatibility:["browser","nodejs"],fn:Er},{name:"forIn",category:"object",compatibility:["browser","nodejs"],fn:Fr},{name:"forOwn",category:"object",compatibility:["browser","nodejs"],fn:Tr},{name:"toPath",category:"object",compatibility:["browser","nodejs"],fn:Br},{name:"get",category:"object",compatibility:["browser","nodejs"],fn:_r},{name:"getObject",category:"object",compatibility:["browser","nodejs"],fn:Mr},{name:"hasOwn",category:"object",compatibility:["browser","nodejs"],fn:Cr},{name:"isObject",category:"object",compatibility:["browser","nodejs"],fn:zr},{name:"JSONparse",category:"object",compatibility:["browser","nodejs"],fn:kn},{name:"JSONstringify",category:"object",compatibility:["browser","nodejs"],fn:Hn},{name:"merge",category:"object",compatibility:["browser","nodejs"],fn:Lr},{name:"parseJSON",category:"object",compatibility:["browser","nodejs"],fn:Pr},{name:"pick",category:"object",compatibility:["browser","nodejs"],fn:Ir},{name:"stringify",category:"object",compatibility:["browser","nodejs"],fn:Ur}];var m=a(require("path"),1),vr=(n,e,r)=>{let t=Object.prototype.toString.call(r).slice(8,-1).toLowerCase();return`Expected ${n} to be of type ${e}, but got ${t}`},l=(n,e)=>{if(typeof e!="string")throw new TypeError(vr(n,"string",e));return e},Jr=function(n,e){let r=l("filepath",n),t=e?.data?.root?.cwd??this?.cwd??process.cwd();return m.default.resolve(t,r)},qr=n=>{let e=l("filepath",n);return m.default.dirname(e)},Dr=(n,e)=>{let r=l("first path",n),t=l("second path",e);return m.default.relative(m.default.dirname(r),t)},Wr=n=>{let e=l("filepath",n);return m.default.basename(e)},Gr=n=>{let e=l("filepath",n);return m.default.basename(e,m.default.extname(e))},Yr=n=>{let e=l("filepath",n);return m.default.extname(e)},Qr=function(n,...e){let r,t=e[e.length-1];typeof t=="object"&&t&&"data"in t&&(r=e.pop());let s=[r?.data?.root?.cwd??this?.cwd??process.cwd(),l("filepath",n),...e.map((i,p)=>l(`path${p}`,i))];return m.default.resolve(...s)},Zr=(n,e,r)=>{let t=l("filepath",n),o=Number(e),s=Number(r);return t.split(/[\\/]+/).slice(o,s).join("/")},On=[{name:"absolute",category:"path",compatibility:["nodejs"],fn:Jr},{name:"dirname",category:"path",compatibility:["nodejs"],fn:qr},{name:"relative",category:"path",compatibility:["nodejs"],fn:Dr},{name:"basename",category:"path",compatibility:["nodejs"],fn:Wr},{name:"stem",category:"path",compatibility:["nodejs"],fn:Gr},{name:"extname",category:"path",compatibility:["nodejs"],fn:Yr},{name:"resolve",category:"path",compatibility:["nodejs"],fn:Qr},{name:"segments",category:"path",compatibility:["nodejs"],fn:Zr}];var An=a(require("handlebars-utils"),1),Kr=(n,e,r)=>{let t=An.default.options({},e,r);return new RegExp(n,t.flags)},Vr=(n,e)=>{if(typeof n!="string")return!1;if(!(e instanceof RegExp))throw new TypeError("expected a regular expression");return e.test(n)},Nn=[{name:"toRegex",category:"regex",compatibility:["browser","nodejs"],fn:Kr},{name:"test",category:"regex",compatibility:["browser","nodejs"],fn:Vr}];var $n=n=>n.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g,""),w=(n,e)=>n.length===1?n.toLowerCase():$n(n).toLowerCase().replace(/[-_.\W\s]+(\w|$)/g,(t,o)=>e(o)),Xr=(n,e)=>typeof n=="string"&&typeof e=="string"?n+e:n,nt=n=>typeof n=="string"?w(n,e=>e.toUpperCase()):"",Rn=n=>typeof n!="string"||n.length===0?"":n.charAt(0).toUpperCase()+n.slice(1),et=n=>typeof n!="string"?"":n.replace(/\w\S*/g,e=>Rn(e)),rt=(n,e)=>{if(typeof n!="string")return"";let r="";for(let t=0;t<e;t++)r+="&nbsp;";return r+n+r},tt=n=>typeof n=="string"?$n(n):"",ot=n=>typeof n=="string"?w(n,e=>`-${e}`):"",st=n=>typeof n=="string"?w(n,e=>`.${e}`):"",Sn=(n,e,r)=>typeof n=="string"?(typeof r!="string"&&(r=""),n.length>e?n.slice(0,e-r.length)+r:n):"",it=(n,e)=>typeof n=="string"?n.length<=e?n:`${Sn(n,e)}\u2026`:"",at=n=>typeof n=="string"?n.split(" ").join("-"):"",ct=n=>typeof n=="string",En=n=>typeof n=="object"&&n!==null&&"fn"in n&&typeof n.fn=="function"?String(n.fn()).toLowerCase():typeof n!="string"?"":n.toLowerCase(),pt=(...n)=>En(...n),mt=(n,e)=>{if(typeof n!="string")return"";let r=e.length,t=n.indexOf(e,0),o=0;for(;t>-1;)o++,t=n.indexOf(e,t+r);return o},lt=n=>{if(typeof n!="string")return"";let e=w(n,r=>r.toUpperCase());return e.charAt(0).toUpperCase()+e.slice(1)},yt=n=>typeof n=="string"?w(n,e=>`/${e}`):"",gt=(n,e)=>typeof n!="string"?"":(typeof e!="string"&&(e=" "),n.split(e).join("+")),ft=(n,e)=>typeof n=="string"&&typeof e=="string"?e+n:n,ut=(n,e)=>typeof n!="string"?"":typeof e!="string"?n:n.split(e).join(""),bt=(n,e)=>typeof n!="string"?"":typeof e!="string"?n:n.replace(e,""),dt=(n,e,r)=>typeof n!="string"?"":typeof e!="string"?n:(typeof r!="string"&&(r=""),n.split(e).join(r)),ht=(n,e,r)=>typeof n!="string"?"":typeof e!="string"?n:(typeof r!="string"&&(r=""),n.replace(e,r)),wt=n=>typeof n=="string"?n.split("").reverse().join(""):"",jt=n=>typeof n!="string"?"":n.replace(/((?:\S[^.?!]*)[.?!]*)/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()),kt=n=>typeof n=="string"?w(n,e=>`_${e}`):"",Ht=n=>typeof n=="string"?n.trim():"",xt=n=>typeof n=="string"?n.replace(/^\s+/,""):"",Ot=n=>typeof n=="string"?n.replace(/\s+$/,""):"",At=(n,e,r)=>{if(typeof n=="string"&&typeof e=="number"&&Number.isFinite(e)){typeof r!="string"&&(r="...");let t=Math.trunc(e),o=n.split(" ");return t<o.length&&(o=o.slice(0,t)),o.join(" ").trim()+r}return""},Nt=At,Fn=n=>typeof n=="object"&&n!==null&&"fn"in n&&typeof n.fn=="function"?String(n.fn()).toUpperCase():typeof n!="string"?"":n.toUpperCase(),$t=(...n)=>Fn(...n),Tn=[{name:"append",category:"string",compatibility:["browser","nodejs"],fn:Xr},{name:"camelcase",category:"string",compatibility:["browser","nodejs"],fn:nt},{name:"capitalize",category:"string",compatibility:["browser","nodejs"],fn:Rn},{name:"capitalizeAll",category:"string",compatibility:["browser","nodejs"],fn:et},{name:"center",category:"string",compatibility:["browser","nodejs"],fn:rt},{name:"chop",category:"string",compatibility:["browser","nodejs"],fn:tt},{name:"dashcase",category:"string",compatibility:["browser","nodejs"],fn:ot},{name:"dotcase",category:"string",compatibility:["browser","nodejs"],fn:st},{name:"ellipsis",category:"string",compatibility:["browser","nodejs"],fn:it},{name:"hyphenate",category:"string",compatibility:["browser","nodejs"],fn:at},{name:"isString",category:"string",compatibility:["browser","nodejs"],fn:ct},{name:"lowercase",category:"string",compatibility:["browser","nodejs"],fn:En},{name:"downcase",category:"string",compatibility:["browser","nodejs"],fn:pt},{name:"occurrences",category:"string",compatibility:["browser","nodejs"],fn:mt},{name:"pascalcase",category:"string",compatibility:["browser","nodejs"],fn:lt},{name:"pathcase",category:"string",compatibility:["browser","nodejs"],fn:yt},{name:"plusify",category:"string",compatibility:["browser","nodejs"],fn:gt},{name:"prepend",category:"string",compatibility:["browser","nodejs"],fn:ft},{name:"remove",category:"string",compatibility:["browser","nodejs"],fn:ut},{name:"removeFirst",category:"string",compatibility:["browser","nodejs"],fn:bt},{name:"replace",category:"string",compatibility:["browser","nodejs"],fn:dt},{name:"replaceFirst",category:"string",compatibility:["browser","nodejs"],fn:ht},{name:"reverse",category:"string",compatibility:["browser","nodejs"],fn:wt},{name:"sentence",category:"string",compatibility:["browser","nodejs"],fn:jt},{name:"snakecase",category:"string",compatibility:["browser","nodejs"],fn:kt},{name:"trim",category:"string",compatibility:["browser","nodejs"],fn:Ht},{name:"trimLeft",category:"string",compatibility:["browser","nodejs"],fn:xt},{name:"trimRight",category:"string",compatibility:["browser","nodejs"],fn:Ot},{name:"truncate",category:"string",compatibility:["browser","nodejs"],fn:Sn},{name:"truncateWords",category:"string",compatibility:["browser","nodejs"],fn:Nt},{name:"uppercase",category:"string",compatibility:["browser","nodejs"],fn:Fn},{name:"upcase",category:"string",compatibility:["browser","nodejs"],fn:$t}];var Bn=require("querystring"),b=require("url"),k=["browser","nodejs"],_n=n=>{if(typeof n=="string")return encodeURIComponent(n)},Rt=n=>{if(typeof n=="string")return(0,Bn.escape)(n)},Mn=n=>{if(typeof n=="string")return decodeURIComponent(n)};function St(...n){return _n.apply(this,n)}function Et(...n){return Mn.apply(this,n)}var Ft=(n,e)=>(0,b.resolve)(String(n),String(e)),Tt=n=>(0,b.parse)(String(n)),Bt=n=>{if(typeof n=="string")return n.split("?")[0]},_t=n=>{if(typeof n=="string"){let e=(0,b.parse)(n);return e.protocol="",(0,b.format)(e)}},Cn=[{name:"encodeURI",category:"url",compatibility:k,fn:_n},{name:"escape",category:"url",compatibility:["nodejs"],fn:Rt},{name:"decodeURI",category:"url",compatibility:k,fn:Mn},{name:"url_encode",category:"url",compatibility:k,fn:St},{name:"url_decode",category:"url",compatibility:k,fn:Et},{name:"urlResolve",category:"url",compatibility:["nodejs"],fn:Ft},{name:"urlParse",category:"url",compatibility:["nodejs"],fn:Tt},{name:"stripQuerystring",category:"url",compatibility:k,fn:Bt},{name:"stripProtocol",category:"url",compatibility:["nodejs"],fn:_t}];var d=class{_helpers=[];constructor(){this.init()}get helpers(){return this._helpers}init(){this.registerHelpers(_),this.registerHelpers(P),this.registerHelpers(D),this.registerHelpers(Q),this.registerHelpers(L),this.registerHelpers(fn),this.registerHelpers(K),this.registerHelpers(I),this.registerHelpers(V),this.registerHelpers(X),this.registerHelpers(en),this.registerHelpers(tn),this.registerHelpers(an),this.registerHelpers(hn),this.registerHelpers(wn),this.registerHelpers(On),this.registerHelpers(Nn),this.registerHelpers(Tn),this.registerHelpers(Cn),this.registerHelpers(xn)}register(e){return this.has(e.name)||this._helpers.push(e),!1}registerHelpers(e){for(let r of e)this.register(r)}has(e){return this._helpers.some(r=>r.name===e)}filter(e){let r=this._helpers;return e.names&&(r=r.filter(t=>e.names?.includes(t.name))),e.categories&&(r=r.filter(t=>e.categories?.includes(t.category))),e.compatibility&&(r=r.filter(t=>t.compatibility?.some(o=>e.compatibility?.includes(o)))),r}load(e,r){let t=this._helpers;r&&(t=this.filter(r));for(let o of t)e.registerHelper(o.name,o.fn)}swap(e){for(let r of this._helpers)e.unregisterHelper(r.name),e.registerHelper(r.name,r.fn)}};var Mt=y.default,Ct=y.default.create();function zt(n){new d().load(n.handlebars??n.hbs)}async function Lt(){let n=new d,e=y.default.create();return Object.keys(y.default.partials).length>0&&e.registerPartial(y.default.partials),n.load(e),process.env.NODE_ENV==="development"&&console.warn("createHandlebars will be deprecated in future versions, use `fumanchu` instead."),e}function Pt(n){let e=new d,r=y.default.create();return n?.handlebars?r=n.handlebars:Object.keys(y.default.partials).length>0&&r.registerPartial(y.default.partials),e.load(r),r}0&&(module.exports={Handlebars,HelperRegistry,createHandlebars,fumanchu,handlebars,helpers});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all2) => {
9
+ for (var name in all2)
10
+ __defProp(target, name, { get: all2[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Handlebars: () => Handlebars3,
34
+ HelperRegistry: () => HelperRegistry,
35
+ createHandlebars: () => createHandlebars,
36
+ fumanchu: () => fumanchu,
37
+ handlebars: () => handlebars,
38
+ helpers: () => helpers21
39
+ });
40
+ module.exports = __toCommonJS(index_exports);
41
+ var import_handlebars3 = __toESM(require("handlebars"), 1);
42
+
43
+ // src/helpers/array.ts
44
+ var after = (array, n) => {
45
+ if (!Array.isArray(array)) return [];
46
+ return array.slice(n);
47
+ };
48
+ var before = (array, n) => {
49
+ if (!Array.isArray(array)) return [];
50
+ return array.slice(0, -n);
51
+ };
52
+ var arrayify = (value) => {
53
+ if (value == null) return [];
54
+ return Array.isArray(value) ? value : [value];
55
+ };
56
+ var first = (array, n) => {
57
+ if (!Array.isArray(array)) return void 0;
58
+ if (typeof n !== "number") {
59
+ return array[0];
60
+ }
61
+ return array.slice(0, n);
62
+ };
63
+ var last = (value, n) => {
64
+ if (!Array.isArray(value) && typeof value !== "string") {
65
+ return void 0;
66
+ }
67
+ if (typeof n !== "number") {
68
+ const array = value;
69
+ return array[array.length - 1];
70
+ }
71
+ const start = Math.abs(n);
72
+ if (typeof value === "string") {
73
+ return value.slice(-start);
74
+ }
75
+ return value.slice(-start);
76
+ };
77
+ var length = (value) => {
78
+ if (value && typeof value === "object" && !Array.isArray(value)) {
79
+ return Object.keys(value).length;
80
+ }
81
+ if (typeof value === "string" || Array.isArray(value)) {
82
+ return value.length;
83
+ }
84
+ return 0;
85
+ };
86
+ var join = (array, separator = ", ") => {
87
+ if (typeof array === "string") return array;
88
+ if (!Array.isArray(array)) return "";
89
+ return array.join(separator);
90
+ };
91
+ var forEach = function(collection, options) {
92
+ if (!Array.isArray(collection) || !options || typeof options.fn !== "function") {
93
+ return options?.inverse ? options.inverse(this) ?? "" : "";
94
+ }
95
+ if (collection.length === 0) {
96
+ return options.inverse ? options.inverse(this) ?? "" : "";
97
+ }
98
+ const total = collection.length;
99
+ const hash = options.hash ?? {};
100
+ const baseData = options.data ? { ...options.data } : void 0;
101
+ let result = "";
102
+ for (let index = 0; index < total; index++) {
103
+ const value = collection[index];
104
+ const meta = {
105
+ index,
106
+ total,
107
+ isFirst: index === 0,
108
+ isLast: index === total - 1
109
+ };
110
+ const data = {
111
+ ...baseData ? { ...baseData } : {},
112
+ ...hash,
113
+ ...meta
114
+ };
115
+ let context;
116
+ if (value != null && typeof value === "object") {
117
+ context = { ...value, ...hash, ...meta };
118
+ } else {
119
+ context = { value, ...hash, ...meta };
120
+ }
121
+ result += options.fn(context, { data });
122
+ }
123
+ return result;
124
+ };
125
+ var helpers = [
126
+ {
127
+ name: "after",
128
+ category: "array",
129
+ compatibility: ["browser", "nodejs"],
130
+ fn: after
131
+ },
132
+ {
133
+ name: "before",
134
+ category: "array",
135
+ compatibility: ["browser", "nodejs"],
136
+ fn: before
137
+ },
138
+ {
139
+ name: "arrayify",
140
+ category: "array",
141
+ compatibility: ["browser", "nodejs"],
142
+ fn: arrayify
143
+ },
144
+ {
145
+ name: "first",
146
+ category: "array",
147
+ compatibility: ["browser", "nodejs"],
148
+ fn: first
149
+ },
150
+ {
151
+ name: "last",
152
+ category: "array",
153
+ compatibility: ["browser", "nodejs"],
154
+ fn: last
155
+ },
156
+ {
157
+ name: "length",
158
+ category: "array",
159
+ compatibility: ["browser", "nodejs"],
160
+ fn: length
161
+ },
162
+ {
163
+ name: "join",
164
+ category: "array",
165
+ compatibility: ["browser", "nodejs"],
166
+ fn: join
167
+ },
168
+ {
169
+ name: "forEach",
170
+ category: "array",
171
+ compatibility: ["browser", "nodejs"],
172
+ fn: forEach
173
+ }
174
+ ];
175
+
176
+ // src/helpers/code.ts
177
+ var import_node_fs = __toESM(require("fs"), 1);
178
+ var import_node_path = __toESM(require("path"), 1);
179
+ var import_html_tag = __toESM(require("html-tag"), 1);
180
+ var import_to_gfm_code_block = __toESM(require("to-gfm-code-block"), 1);
181
+ var embed = (filepath, language) => {
182
+ let ext = typeof language === "string" ? language : import_node_path.default.extname(filepath).slice(1);
183
+ let code = import_node_fs.default.readFileSync(filepath, "utf8");
184
+ if (ext === "markdown" || ext === "md") {
185
+ ext = "markdown";
186
+ code = code.split("`").join("&#x60");
187
+ }
188
+ return `${(0, import_to_gfm_code_block.default)(code, ext).trim()}
189
+ `;
190
+ };
191
+ var gist = (id) => {
192
+ return (0, import_html_tag.default)("script", { src: `https://gist.github.com/${id}.js` });
193
+ };
194
+ var jsfiddle = (options) => {
195
+ if (!options || !options.id) {
196
+ throw new Error("jsfiddle helper expects an `id`");
197
+ }
198
+ const {
199
+ id,
200
+ width = "100%",
201
+ height = "300",
202
+ skin = "/presentation/",
203
+ tabs = "result,js,html,css",
204
+ allowfullscreen = "allowfullscreen",
205
+ frameborder = "0"
206
+ } = options;
207
+ const src = `http://jsfiddle.net/${id}/embedded/${tabs}${skin}`;
208
+ return (0, import_html_tag.default)("iframe", { width, height, src, allowfullscreen, frameborder });
209
+ };
210
+ var helpers2 = [
211
+ {
212
+ name: "embed",
213
+ category: "code",
214
+ compatibility: ["nodejs"],
215
+ fn: embed
216
+ },
217
+ {
218
+ name: "gist",
219
+ category: "code",
220
+ compatibility: ["browser", "nodejs"],
221
+ fn: gist
222
+ },
223
+ {
224
+ name: "jsfiddle",
225
+ category: "code",
226
+ compatibility: ["browser", "nodejs"],
227
+ fn: jsfiddle
228
+ }
229
+ ];
230
+
231
+ // src/helpers/collection.ts
232
+ var isEmpty = (collection) => {
233
+ if (collection == null) return true;
234
+ if (Array.isArray(collection)) return collection.length === 0;
235
+ if (typeof collection === "object")
236
+ return Object.keys(collection).length === 0;
237
+ return false;
238
+ };
239
+ var iterate = (collection, fn, inverse) => {
240
+ if (Array.isArray(collection)) {
241
+ let result = "";
242
+ for (let i = 0; i < collection.length; i++) {
243
+ result += fn(collection[i], i);
244
+ }
245
+ return result;
246
+ }
247
+ if (collection && typeof collection === "object") {
248
+ let result = "";
249
+ for (const key of Object.keys(collection)) {
250
+ result += fn(collection[key], key);
251
+ }
252
+ return result;
253
+ }
254
+ return inverse ? inverse() : "";
255
+ };
256
+ var helpers3 = [
257
+ {
258
+ name: "isEmpty",
259
+ category: "collection",
260
+ compatibility: ["browser", "nodejs"],
261
+ fn: isEmpty
262
+ },
263
+ {
264
+ name: "iterate",
265
+ category: "collection",
266
+ compatibility: ["browser", "nodejs"],
267
+ fn: iterate
268
+ }
269
+ ];
270
+
271
+ // src/helpers/comparison.ts
272
+ var and = (...values) => values.every(Boolean);
273
+ var compare = (a, operator, b) => {
274
+ switch (operator) {
275
+ case "==":
276
+ return a == b;
277
+ case "===":
278
+ return a === b;
279
+ case "!=":
280
+ return a != b;
281
+ case "!==":
282
+ return a !== b;
283
+ case "<":
284
+ return a < b;
285
+ case ">":
286
+ return a > b;
287
+ case "<=":
288
+ return a <= b;
289
+ case ">=":
290
+ return a >= b;
291
+ case "typeof":
292
+ return typeof a === b;
293
+ default:
294
+ throw new Error(`helper {{compare}}: invalid operator: '${operator}'`);
295
+ }
296
+ };
297
+ var contains = (collection, value, startIndex = 0) => {
298
+ if (collection == null) return false;
299
+ if (typeof collection === "string" || Array.isArray(collection)) {
300
+ return collection.indexOf(value, startIndex) > -1;
301
+ }
302
+ if (typeof collection === "object") {
303
+ return value in collection;
304
+ }
305
+ return false;
306
+ };
307
+ var defaultHelper = (...values) => {
308
+ for (const val of values) {
309
+ if (val != null) return val;
310
+ }
311
+ return "";
312
+ };
313
+ var eq = (a, b) => a === b;
314
+ var gt = (a, b) => a > b;
315
+ var gte = (a, b) => a >= b;
316
+ var has = (value, pattern) => {
317
+ if (value == null || pattern == null) return false;
318
+ if (Array.isArray(value) || typeof value === "string") {
319
+ return value.indexOf(pattern) > -1;
320
+ }
321
+ if (typeof value === "object") {
322
+ return pattern in value;
323
+ }
324
+ return false;
325
+ };
326
+ var falsey = (val, keywords) => {
327
+ if (!val) return true;
328
+ const words = Array.isArray(keywords) ? keywords : keywords != null ? [keywords] : [
329
+ "0",
330
+ "false",
331
+ "nada",
332
+ "nil",
333
+ "nay",
334
+ "nah",
335
+ "negative",
336
+ "no",
337
+ "none",
338
+ "nope",
339
+ "nul",
340
+ "null",
341
+ "nix",
342
+ "nyet",
343
+ "uh-uh",
344
+ "veto",
345
+ "zero"
346
+ ];
347
+ const lower = typeof val === "string" ? val.toLowerCase() : null;
348
+ for (const word of words) {
349
+ if (word === val) return true;
350
+ if (lower != null && word === lower) return true;
351
+ }
352
+ return false;
353
+ };
354
+ var isFalsey = (val) => falsey(val);
355
+ var isTruthy = (val) => !falsey(val);
356
+ var ifEven = (num) => typeof num === "number" && num % 2 === 0;
357
+ var ifNth = (a, b) => typeof a === "number" && typeof b === "number" && b % a === 0;
358
+ var ifOdd = (val) => typeof val === "number" && Math.abs(val % 2) === 1;
359
+ var is = (a, b) => a == b;
360
+ var isnt = (a, b) => a != b;
361
+ var lt = (a, b) => a < b;
362
+ var lte = (a, b) => a <= b;
363
+ var neither = (a, b) => !a && !b;
364
+ var not = (val) => !val;
365
+ var or = (...values) => values.some(Boolean);
366
+ var unlessEq = (a, b) => a !== b;
367
+ var unlessGt = (a, b) => a <= b;
368
+ var unlessLt = (a, b) => a >= b;
369
+ var unlessGteq = (a, b) => a < b;
370
+ var unlessLteq = (a, b) => a > b;
371
+ var helpers4 = [
372
+ {
373
+ name: "and",
374
+ category: "comparison",
375
+ compatibility: ["browser", "nodejs"],
376
+ fn: and
377
+ },
378
+ {
379
+ name: "compare",
380
+ category: "comparison",
381
+ compatibility: ["browser", "nodejs"],
382
+ fn: compare
383
+ },
384
+ {
385
+ name: "contains",
386
+ category: "comparison",
387
+ compatibility: ["browser", "nodejs"],
388
+ fn: contains
389
+ },
390
+ {
391
+ name: "default",
392
+ category: "comparison",
393
+ compatibility: ["browser", "nodejs"],
394
+ fn: defaultHelper
395
+ },
396
+ {
397
+ name: "eq",
398
+ category: "comparison",
399
+ compatibility: ["browser", "nodejs"],
400
+ fn: eq
401
+ },
402
+ {
403
+ name: "gt",
404
+ category: "comparison",
405
+ compatibility: ["browser", "nodejs"],
406
+ fn: gt
407
+ },
408
+ {
409
+ name: "gte",
410
+ category: "comparison",
411
+ compatibility: ["browser", "nodejs"],
412
+ fn: gte
413
+ },
414
+ {
415
+ name: "has",
416
+ category: "comparison",
417
+ compatibility: ["browser", "nodejs"],
418
+ fn: has
419
+ },
420
+ {
421
+ name: "isFalsey",
422
+ category: "comparison",
423
+ compatibility: ["browser", "nodejs"],
424
+ fn: isFalsey
425
+ },
426
+ {
427
+ name: "isTruthy",
428
+ category: "comparison",
429
+ compatibility: ["browser", "nodejs"],
430
+ fn: isTruthy
431
+ },
432
+ {
433
+ name: "ifEven",
434
+ category: "comparison",
435
+ compatibility: ["browser", "nodejs"],
436
+ fn: ifEven
437
+ },
438
+ {
439
+ name: "ifNth",
440
+ category: "comparison",
441
+ compatibility: ["browser", "nodejs"],
442
+ fn: ifNth
443
+ },
444
+ {
445
+ name: "ifOdd",
446
+ category: "comparison",
447
+ compatibility: ["browser", "nodejs"],
448
+ fn: ifOdd
449
+ },
450
+ {
451
+ name: "is",
452
+ category: "comparison",
453
+ compatibility: ["browser", "nodejs"],
454
+ fn: is
455
+ },
456
+ {
457
+ name: "isnt",
458
+ category: "comparison",
459
+ compatibility: ["browser", "nodejs"],
460
+ fn: isnt
461
+ },
462
+ {
463
+ name: "lt",
464
+ category: "comparison",
465
+ compatibility: ["browser", "nodejs"],
466
+ fn: lt
467
+ },
468
+ {
469
+ name: "lte",
470
+ category: "comparison",
471
+ compatibility: ["browser", "nodejs"],
472
+ fn: lte
473
+ },
474
+ {
475
+ name: "neither",
476
+ category: "comparison",
477
+ compatibility: ["browser", "nodejs"],
478
+ fn: neither
479
+ },
480
+ {
481
+ name: "not",
482
+ category: "comparison",
483
+ compatibility: ["browser", "nodejs"],
484
+ fn: not
485
+ },
486
+ {
487
+ name: "or",
488
+ category: "comparison",
489
+ compatibility: ["browser", "nodejs"],
490
+ fn: or
491
+ },
492
+ {
493
+ name: "unlessEq",
494
+ category: "comparison",
495
+ compatibility: ["browser", "nodejs"],
496
+ fn: unlessEq
497
+ },
498
+ {
499
+ name: "unlessGt",
500
+ category: "comparison",
501
+ compatibility: ["browser", "nodejs"],
502
+ fn: unlessGt
503
+ },
504
+ {
505
+ name: "unlessLt",
506
+ category: "comparison",
507
+ compatibility: ["browser", "nodejs"],
508
+ fn: unlessLt
509
+ },
510
+ {
511
+ name: "unlessGteq",
512
+ category: "comparison",
513
+ compatibility: ["browser", "nodejs"],
514
+ fn: unlessGteq
515
+ },
516
+ {
517
+ name: "unlessLteq",
518
+ category: "comparison",
519
+ compatibility: ["browser", "nodejs"],
520
+ fn: unlessLteq
521
+ }
522
+ ];
523
+
524
+ // src/helpers/date.ts
525
+ var import_chrono_node = require("chrono-node");
526
+ var import_dayjs = __toESM(require("dayjs"), 1);
527
+ var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
528
+ var convertFormatString = (format2) => {
529
+ return format2.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/dd/g, "DD").replace(/mm/g, "MM").replace(/hh/g, "HH").replace(/ss/g, "SS");
530
+ };
531
+ var date = (humanReadableDate, formatString) => {
532
+ const parsedDate = (0, import_chrono_node.parseDate)(humanReadableDate);
533
+ if (!parsedDate) {
534
+ throw new Error(`Unable to parse date: ${humanReadableDate}`);
535
+ }
536
+ const convertedFormat = convertFormatString(formatString);
537
+ return (0, import_dayjs.default)(parsedDate).format(convertedFormat);
538
+ };
539
+ var helpers5 = [
540
+ {
541
+ name: "year",
542
+ category: "date",
543
+ compatibility: ["browser", "nodejs"],
544
+ fn: year
545
+ },
546
+ {
547
+ name: "date",
548
+ category: "date",
549
+ compatibility: ["browser", "nodejs"],
550
+ fn: date
551
+ },
552
+ {
553
+ /* Adding this in for legacy support */
554
+ name: "moment",
555
+ category: "date",
556
+ compatibility: ["browser", "nodejs"],
557
+ fn: date
558
+ }
559
+ ];
560
+
561
+ // src/helpers/fs.ts
562
+ var import_node_fs2 = __toESM(require("fs"), 1);
563
+ var import_node_path2 = __toESM(require("path"), 1);
564
+ var import_is_glob = __toESM(require("is-glob"), 1);
565
+ var import_micromatch = __toESM(require("micromatch"), 1);
566
+ var fileSize = (value, precision) => {
567
+ if (value == null) return "0 B";
568
+ const number = typeof value === "number" ? value : value.length ?? 0;
569
+ if (!number) return "0 B";
570
+ const precisionNumber = typeof precision === "number" ? precision : 2;
571
+ const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
572
+ const factor = 10 ** precisionNumber;
573
+ let i = abbr.length - 1;
574
+ do {
575
+ const size = 10 ** (i * 3);
576
+ if (size <= number + 1) {
577
+ const num = Math.round(number * factor / size) / factor;
578
+ return `${num} ${abbr[i]}`;
579
+ }
580
+ } while (--i >= 0);
581
+ return `${number} B`;
582
+ };
583
+ var read = (filepath) => {
584
+ return import_node_fs2.default.readFileSync(filepath, "utf8");
585
+ };
586
+ var isOptions = (value) => {
587
+ return Boolean(
588
+ value && typeof value === "object" && "hash" in value
589
+ );
590
+ };
591
+ var readdir = (dir, filter) => {
592
+ const files = import_node_fs2.default.readdirSync(dir).map((fp) => import_node_path2.default.join(dir, fp));
593
+ const filterArg = isOptions(filter) ? void 0 : filter;
594
+ if (typeof filterArg === "function") {
595
+ return filterArg(files);
596
+ }
597
+ if (filterArg instanceof RegExp) {
598
+ return files.filter((fp) => filterArg.test(fp));
599
+ }
600
+ if (typeof filterArg === "string") {
601
+ if ((0, import_is_glob.default)(filterArg)) {
602
+ return (0, import_micromatch.default)(files, filterArg);
603
+ }
604
+ if (filterArg === "isFile" || filterArg === "isDirectory") {
605
+ return files.filter((fp) => {
606
+ const stat = import_node_fs2.default.statSync(fp);
607
+ return filterArg === "isFile" ? stat.isFile() : stat.isDirectory();
608
+ });
609
+ }
610
+ }
611
+ return files;
612
+ };
613
+ var helpers6 = [
614
+ {
615
+ name: "fileSize",
616
+ category: "fs",
617
+ compatibility: ["nodejs"],
618
+ fn: fileSize
619
+ },
620
+ {
621
+ name: "read",
622
+ category: "fs",
623
+ compatibility: ["nodejs"],
624
+ fn: read
625
+ },
626
+ {
627
+ name: "readdir",
628
+ category: "fs",
629
+ compatibility: ["nodejs"],
630
+ fn: readdir
631
+ }
632
+ ];
633
+
634
+ // src/helpers/html.ts
635
+ var import_node_path3 = __toESM(require("path"), 1);
636
+ var import_html_tag2 = __toESM(require("html-tag"), 1);
637
+ var import_striptags = __toESM(require("striptags"), 1);
638
+ var parseAttributes = (hash = {}) => Object.keys(hash).map((key) => `${key}="${String(hash[key]).replace(/^['"]|["']$/g, "")}"`).join(" ");
639
+ var attr = (options) => {
640
+ const val = parseAttributes(options?.hash ?? {});
641
+ return val.trim() ? ` ${val}` : "";
642
+ };
643
+ var css = function(list, options) {
644
+ if (arguments.length < 2) {
645
+ options = list;
646
+ list = [];
647
+ }
648
+ let styles = arrayify(list ?? []);
649
+ let assets = "";
650
+ if (this && this.options) {
651
+ assets = this.options.assets || "";
652
+ }
653
+ if (options?.hash?.href) {
654
+ styles = arrayify(options.hash.href);
655
+ }
656
+ return styles.map((item) => {
657
+ const ext = import_node_path3.default.extname(item);
658
+ let fp = item;
659
+ if (!/(^\/\/)|(:\/\/)/.test(item)) {
660
+ fp = import_node_path3.default.posix.join(assets, item);
661
+ }
662
+ if (ext === ".less") {
663
+ return `<link type="text/css" rel="stylesheet/less" href="${fp}">`;
664
+ }
665
+ return `<link type="text/css" rel="stylesheet" href="${fp}">`;
666
+ }).join("\n");
667
+ };
668
+ var js = (context) => {
669
+ if (context && typeof context === "object" && !Array.isArray(context)) {
670
+ const attrStr = parseAttributes(context.hash ?? {});
671
+ return `<script${attrStr ? ` ${attrStr}` : ""}></script>`;
672
+ }
673
+ if (typeof context === "string") {
674
+ return `<script src="${context}"></script>`;
675
+ }
676
+ const items = arrayify(context);
677
+ return items.map(
678
+ (fp) => import_node_path3.default.extname(fp) === ".coffee" ? (0, import_html_tag2.default)("script", { type: "text/coffeescript", src: fp }) : (0, import_html_tag2.default)("script", { src: fp })
679
+ ).join("\n");
680
+ };
681
+ var sanitize = (str) => {
682
+ if (typeof str !== "string") return "";
683
+ return (0, import_striptags.default)(str).trim();
684
+ };
685
+ var ul = (context, options) => {
686
+ const attrs = parseAttributes(options.hash ?? {});
687
+ const items = context.map(
688
+ (item) => typeof item === "string" ? item : options.fn(item)
689
+ );
690
+ const open = attrs ? `<ul ${attrs}>` : "<ul>";
691
+ return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ul>`;
692
+ };
693
+ var ol = (context, options) => {
694
+ const attrs = parseAttributes(options.hash ?? {});
695
+ const items = context.map(
696
+ (item) => typeof item === "string" ? item : options.fn(item)
697
+ );
698
+ const open = attrs ? `<ol ${attrs}>` : "<ol>";
699
+ return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ol>`;
700
+ };
701
+ var thumbnailImage = (context) => {
702
+ let figure = "";
703
+ let image = "";
704
+ const link = context.full || false;
705
+ const imageAttributes = {
706
+ alt: context.alt,
707
+ src: context.thumbnail,
708
+ width: context.size.width,
709
+ height: context.size.height
710
+ };
711
+ const figureAttributes = { id: `image-${context.id}` };
712
+ const linkAttributes = { href: link, rel: "thumbnail" };
713
+ if (context.classes) {
714
+ if (context.classes.image) {
715
+ imageAttributes.class = context.classes.image.join(" ");
716
+ }
717
+ if (context.classes.figure) {
718
+ figureAttributes.class = context.classes.figure.join(" ");
719
+ }
720
+ if (context.classes.link) {
721
+ linkAttributes.class = context.classes.link.join(" ");
722
+ }
723
+ }
724
+ figure += `<figure ${parseAttributes(figureAttributes)}>
725
+ `;
726
+ image += `<img ${parseAttributes(imageAttributes)}>
727
+ `;
728
+ if (link) {
729
+ figure += `<a ${parseAttributes(linkAttributes)}>
730
+ ${image}</a>
731
+ `;
732
+ } else {
733
+ figure += image;
734
+ }
735
+ if (context.caption) {
736
+ figure += `<figcaption>${context.caption}</figcaption>
737
+ `;
738
+ }
739
+ figure += "</figure>";
740
+ return figure;
741
+ };
742
+ var helpers7 = [
743
+ {
744
+ name: "attr",
745
+ category: "html",
746
+ compatibility: ["browser", "nodejs"],
747
+ fn: attr
748
+ },
749
+ {
750
+ name: "css",
751
+ category: "html",
752
+ compatibility: ["nodejs"],
753
+ fn: css
754
+ },
755
+ {
756
+ name: "js",
757
+ category: "html",
758
+ compatibility: ["nodejs"],
759
+ fn: js
760
+ },
761
+ {
762
+ name: "sanitize",
763
+ category: "html",
764
+ compatibility: ["browser", "nodejs"],
765
+ fn: sanitize
766
+ },
767
+ {
768
+ name: "ul",
769
+ category: "html",
770
+ compatibility: ["browser", "nodejs"],
771
+ fn: ul
772
+ },
773
+ {
774
+ name: "ol",
775
+ category: "html",
776
+ compatibility: ["browser", "nodejs"],
777
+ fn: ol
778
+ },
779
+ {
780
+ name: "thumbnailImage",
781
+ category: "html",
782
+ compatibility: ["browser", "nodejs"],
783
+ fn: thumbnailImage
784
+ }
785
+ ];
786
+
787
+ // src/utils.ts
788
+ var get = (object, path6) => {
789
+ if (!object || typeof object !== "object") return void 0;
790
+ const keys = Array.isArray(path6) ? path6 : path6.split(".");
791
+ let result = object;
792
+ for (const key of keys) {
793
+ if (result == null || typeof result !== "object") return void 0;
794
+ result = result[key];
795
+ }
796
+ return result;
797
+ };
798
+ var getObject = (object, path6) => {
799
+ if (!object || typeof object !== "object") return void 0;
800
+ const keys = Array.isArray(path6) ? path6 : path6.split(".");
801
+ if (keys.length === 0) return void 0;
802
+ let current = object;
803
+ for (let i = 0; i < keys.length - 1; i++) {
804
+ if (current == null || typeof current !== "object") return void 0;
805
+ current = current[keys[i]];
806
+ }
807
+ const finalKey = keys[keys.length - 1];
808
+ if (current == null || typeof current !== "object" || !(finalKey in current)) {
809
+ return void 0;
810
+ }
811
+ return { [finalKey]: current[finalKey] };
812
+ };
813
+
814
+ // src/helpers/i18n.ts
815
+ var i18n = function(prop, locals, options) {
816
+ if (locals && typeof locals === "object" && "hash" in locals && options === void 0) {
817
+ options = locals;
818
+ locals = {};
819
+ }
820
+ if (typeof prop !== "string") {
821
+ throw new Error('{{i18n}} helper expected "key" to be a string');
822
+ }
823
+ const context = {
824
+ ...this,
825
+ ...locals,
826
+ ...options?.hash ?? {}
827
+ };
828
+ const lang = context.language || context.lang;
829
+ if (typeof lang !== "string") {
830
+ throw new TypeError('{{i18n}} helper expected "language" to be a string');
831
+ }
832
+ const cache = context[lang];
833
+ if (typeof cache === "undefined") {
834
+ throw new Error(`{{i18n}} helper cannot find language "${lang}"`);
835
+ }
836
+ const result = get(cache, prop);
837
+ if (typeof result === "undefined") {
838
+ throw new Error(
839
+ '{{i18n}} helper cannot find property "' + String(prop) + '" for language "' + lang + '"'
840
+ );
841
+ }
842
+ return String(result);
843
+ };
844
+ var helpers8 = [
845
+ {
846
+ name: "i18n",
847
+ category: "i18n",
848
+ compatibility: ["browser", "nodejs"],
849
+ fn: i18n
850
+ }
851
+ ];
852
+
853
+ // src/helpers/inflection.ts
854
+ var inflect = (count, singular, plural, includeCount) => {
855
+ const word = count > 1 || count === 0 ? plural : singular;
856
+ return includeCount ? `${count} ${word}` : word;
857
+ };
858
+ var ordinalize = (value) => {
859
+ const num = Math.abs(Math.round(Number(value)));
860
+ const str = String(value);
861
+ const res = num % 100;
862
+ if ([11, 12, 13].includes(res)) {
863
+ return `${str}th`;
864
+ }
865
+ switch (num % 10) {
866
+ case 1:
867
+ return `${str}st`;
868
+ case 2:
869
+ return `${str}nd`;
870
+ case 3:
871
+ return `${str}rd`;
872
+ default:
873
+ return `${str}th`;
874
+ }
875
+ };
876
+ var helpers9 = [
877
+ {
878
+ name: "inflect",
879
+ category: "inflection",
880
+ compatibility: ["browser", "nodejs"],
881
+ fn: inflect
882
+ },
883
+ {
884
+ name: "ordinalize",
885
+ category: "inflection",
886
+ compatibility: ["browser", "nodejs"],
887
+ fn: ordinalize
888
+ }
889
+ ];
890
+
891
+ // src/helpers/logging.ts
892
+ var colors = {
893
+ green: (str) => `\x1B[32m${str}\x1B[0m`,
894
+ cyan: (str) => `\x1B[36m${str}\x1B[0m`,
895
+ yellow: (str) => `\x1B[33m${str}\x1B[0m`,
896
+ red: (str) => `\x1B[31m${str}\x1B[0m`,
897
+ bold: (str) => `\x1B[1m${str}\x1B[0m`
898
+ };
899
+ function cleanArgs(args) {
900
+ const last2 = args[args.length - 1];
901
+ if (args.length > 1 && typeof last2 === "object" && last2 !== null && "hash" in last2) {
902
+ return args.slice(0, -1);
903
+ }
904
+ return args;
905
+ }
906
+ function log(...args) {
907
+ const cleanedArgs = cleanArgs(args);
908
+ console.log(...cleanedArgs);
909
+ return "";
910
+ }
911
+ function ok(...args) {
912
+ const cleanedArgs = cleanArgs(args);
913
+ const message = cleanedArgs.join(" ");
914
+ console.log(colors.green(`\u2713 ${message}`));
915
+ return "";
916
+ }
917
+ function success(...args) {
918
+ const cleanedArgs = cleanArgs(args);
919
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
920
+ console.log(colors.green(message));
921
+ return "";
922
+ }
923
+ function info(...args) {
924
+ const cleanedArgs = cleanArgs(args);
925
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
926
+ console.log(colors.cyan(message));
927
+ return "";
928
+ }
929
+ function warning(...args) {
930
+ const cleanedArgs = cleanArgs(args);
931
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
932
+ console.error(colors.yellow(message));
933
+ return "";
934
+ }
935
+ var warn = warning;
936
+ function error(...args) {
937
+ const cleanedArgs = cleanArgs(args);
938
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
939
+ console.error(colors.red(message));
940
+ return "";
941
+ }
942
+ var danger = error;
943
+ function bold(...args) {
944
+ const cleanedArgs = cleanArgs(args);
945
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
946
+ console.error(colors.bold(message));
947
+ return "";
948
+ }
949
+ function _debug(...args) {
950
+ const separator = "\u2500".repeat(50);
951
+ console.error(colors.cyan(separator));
952
+ if (args.length > 0) {
953
+ const cleanedArgs = cleanArgs(args);
954
+ console.error(colors.cyan("VALUE:"), cleanedArgs[0]);
955
+ }
956
+ if (this && Object.keys(this).length > 0) {
957
+ console.error(colors.cyan("CONTEXT:"), this);
958
+ }
959
+ console.error(colors.cyan(separator));
960
+ return "";
961
+ }
962
+ function _inspect(context, options) {
963
+ const val = JSON.stringify(context, null, 2);
964
+ const type = options?.hash?.type || "html";
965
+ return switchOutput(type, val);
966
+ }
967
+ function switchOutput(type, json) {
968
+ if (type[0] === ".") {
969
+ type = type.slice(1);
970
+ }
971
+ switch (type) {
972
+ case "md":
973
+ return `
974
+ \`\`\`json
975
+ ${json}
976
+ \`\`\`
977
+ `;
978
+ case "html":
979
+ return `<div class="highlight highlight-json">
980
+ <pre><code>
981
+ ${json}</code></pre></div>`;
982
+ default:
983
+ return json;
984
+ }
985
+ }
986
+ var helpers10 = [
987
+ {
988
+ name: "log",
989
+ category: "logging",
990
+ compatibility: ["nodejs"],
991
+ fn: log
992
+ },
993
+ {
994
+ name: "ok",
995
+ category: "logging",
996
+ compatibility: ["nodejs"],
997
+ fn: ok
998
+ },
999
+ {
1000
+ name: "success",
1001
+ category: "logging",
1002
+ compatibility: ["nodejs"],
1003
+ fn: success
1004
+ },
1005
+ {
1006
+ name: "info",
1007
+ category: "logging",
1008
+ compatibility: ["nodejs"],
1009
+ fn: info
1010
+ },
1011
+ {
1012
+ name: "warning",
1013
+ category: "logging",
1014
+ compatibility: ["nodejs"],
1015
+ fn: warning
1016
+ },
1017
+ {
1018
+ name: "warn",
1019
+ category: "logging",
1020
+ compatibility: ["nodejs"],
1021
+ fn: warn
1022
+ },
1023
+ {
1024
+ name: "error",
1025
+ category: "logging",
1026
+ compatibility: ["nodejs"],
1027
+ fn: error
1028
+ },
1029
+ {
1030
+ name: "danger",
1031
+ category: "logging",
1032
+ compatibility: ["nodejs"],
1033
+ fn: danger
1034
+ },
1035
+ {
1036
+ name: "bold",
1037
+ category: "logging",
1038
+ compatibility: ["nodejs"],
1039
+ fn: bold
1040
+ },
1041
+ {
1042
+ name: "_debug",
1043
+ category: "logging",
1044
+ compatibility: ["nodejs"],
1045
+ fn: _debug
1046
+ },
1047
+ {
1048
+ name: "_inspect",
1049
+ category: "logging",
1050
+ compatibility: ["nodejs"],
1051
+ fn: _inspect
1052
+ }
1053
+ ];
1054
+
1055
+ // src/helpers/match.ts
1056
+ var import_micromatch2 = __toESM(require("micromatch"), 1);
1057
+ var match = (files, patterns, options) => {
1058
+ const pats = typeof patterns === "string" ? patterns.split(/, */) : patterns;
1059
+ return (0, import_micromatch2.default)(files, pats, options);
1060
+ };
1061
+ var isMatch = (filepath, pattern, options) => {
1062
+ return import_micromatch2.default.isMatch(filepath, pattern, options);
1063
+ };
1064
+ var mm = (...args) => {
1065
+ console.log("the {{mm}} helper is depcrecated and will be removed");
1066
+ console.log("in handlebars-helpers v1.0.0, please use the {{match}}");
1067
+ console.log("helper instead.");
1068
+ return match(...args);
1069
+ };
1070
+ var helpers11 = [
1071
+ {
1072
+ name: "match",
1073
+ category: "match",
1074
+ compatibility: ["browser", "nodejs"],
1075
+ fn: match
1076
+ },
1077
+ {
1078
+ name: "isMatch",
1079
+ category: "match",
1080
+ compatibility: ["browser", "nodejs"],
1081
+ fn: isMatch
1082
+ },
1083
+ {
1084
+ name: "mm",
1085
+ category: "match",
1086
+ compatibility: ["browser", "nodejs"],
1087
+ fn: mm
1088
+ }
1089
+ ];
1090
+
1091
+ // src/helpers/math.ts
1092
+ var isNumeric = (value) => typeof value === "number" && !Number.isNaN(value) || typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value));
1093
+ var toNumber = (value, message = "expected a number") => {
1094
+ if (isNumeric(value)) {
1095
+ return Number(value);
1096
+ }
1097
+ throw new TypeError(message);
1098
+ };
1099
+ var abs = (value) => {
1100
+ const num = toNumber(value);
1101
+ return Math.abs(num);
1102
+ };
1103
+ var add = (a, b) => {
1104
+ if (isNumeric(a) && isNumeric(b)) {
1105
+ return Number(a) + Number(b);
1106
+ }
1107
+ return "";
1108
+ };
1109
+ var avg = (...values) => {
1110
+ const flat = values.flat().map((n) => Number(n));
1111
+ return sum(flat) / flat.length;
1112
+ };
1113
+ var ceil = (value) => {
1114
+ const num = toNumber(value);
1115
+ return Math.ceil(num);
1116
+ };
1117
+ var divide = (a, b) => {
1118
+ const numA = toNumber(a, "expected the first argument to be a number");
1119
+ const numB = toNumber(b, "expected the second argument to be a number");
1120
+ return numA / numB;
1121
+ };
1122
+ var floor = (value) => {
1123
+ const num = toNumber(value);
1124
+ return Math.floor(num);
1125
+ };
1126
+ var minus = (a, b) => {
1127
+ const numA = toNumber(a, "expected the first argument to be a number");
1128
+ const numB = toNumber(b, "expected the second argument to be a number");
1129
+ return numA - numB;
1130
+ };
1131
+ var modulo = (a, b) => {
1132
+ const numA = toNumber(a, "expected the first argument to be a number");
1133
+ const numB = toNumber(b, "expected the second argument to be a number");
1134
+ return numA % numB;
1135
+ };
1136
+ var multiply = (a, b) => {
1137
+ const numA = toNumber(a, "expected the first argument to be a number");
1138
+ const numB = toNumber(b, "expected the second argument to be a number");
1139
+ return numA * numB;
1140
+ };
1141
+ var plus = (a, b) => {
1142
+ const numA = toNumber(a, "expected the first argument to be a number");
1143
+ const numB = toNumber(b, "expected the second argument to be a number");
1144
+ return numA + numB;
1145
+ };
1146
+ var random = (min, max) => {
1147
+ const minNum = toNumber(min, "expected minimum to be a number");
1148
+ const maxNum = toNumber(max, "expected maximum to be a number");
1149
+ return minNum + Math.floor(Math.random() * (maxNum - minNum + 1));
1150
+ };
1151
+ var remainder = (a, b) => a % b;
1152
+ var round = (value) => {
1153
+ const num = toNumber(value);
1154
+ return Math.round(num);
1155
+ };
1156
+ var subtract = (a, b) => {
1157
+ const numA = toNumber(a, "expected the first argument to be a number");
1158
+ const numB = toNumber(b, "expected the second argument to be a number");
1159
+ return numA - numB;
1160
+ };
1161
+ var sum = (...values) => {
1162
+ const flat = values.flat();
1163
+ let total = 0;
1164
+ for (const value of flat) {
1165
+ if (isNumeric(value)) {
1166
+ total += Number(value);
1167
+ }
1168
+ }
1169
+ return total;
1170
+ };
1171
+ var times = (a, b) => multiply(a, b);
1172
+ var helpers12 = [
1173
+ {
1174
+ name: "abs",
1175
+ category: "math",
1176
+ compatibility: ["browser", "nodejs"],
1177
+ fn: abs
1178
+ },
1179
+ {
1180
+ name: "add",
1181
+ category: "math",
1182
+ compatibility: ["browser", "nodejs"],
1183
+ fn: add
1184
+ },
1185
+ {
1186
+ name: "avg",
1187
+ category: "math",
1188
+ compatibility: ["browser", "nodejs"],
1189
+ fn: avg
1190
+ },
1191
+ {
1192
+ name: "ceil",
1193
+ category: "math",
1194
+ compatibility: ["browser", "nodejs"],
1195
+ fn: ceil
1196
+ },
1197
+ {
1198
+ name: "divide",
1199
+ category: "math",
1200
+ compatibility: ["browser", "nodejs"],
1201
+ fn: divide
1202
+ },
1203
+ {
1204
+ name: "floor",
1205
+ category: "math",
1206
+ compatibility: ["browser", "nodejs"],
1207
+ fn: floor
1208
+ },
1209
+ {
1210
+ name: "minus",
1211
+ category: "math",
1212
+ compatibility: ["browser", "nodejs"],
1213
+ fn: minus
1214
+ },
1215
+ {
1216
+ name: "modulo",
1217
+ category: "math",
1218
+ compatibility: ["browser", "nodejs"],
1219
+ fn: modulo
1220
+ },
1221
+ {
1222
+ name: "multiply",
1223
+ category: "math",
1224
+ compatibility: ["browser", "nodejs"],
1225
+ fn: multiply
1226
+ },
1227
+ {
1228
+ name: "plus",
1229
+ category: "math",
1230
+ compatibility: ["browser", "nodejs"],
1231
+ fn: plus
1232
+ },
1233
+ {
1234
+ name: "random",
1235
+ category: "math",
1236
+ compatibility: ["browser", "nodejs"],
1237
+ fn: random
1238
+ },
1239
+ {
1240
+ name: "remainder",
1241
+ category: "math",
1242
+ compatibility: ["browser", "nodejs"],
1243
+ fn: remainder
1244
+ },
1245
+ {
1246
+ name: "round",
1247
+ category: "math",
1248
+ compatibility: ["browser", "nodejs"],
1249
+ fn: round
1250
+ },
1251
+ {
1252
+ name: "subtract",
1253
+ category: "math",
1254
+ compatibility: ["browser", "nodejs"],
1255
+ fn: subtract
1256
+ },
1257
+ {
1258
+ name: "sum",
1259
+ category: "math",
1260
+ compatibility: ["browser", "nodejs"],
1261
+ fn: sum
1262
+ },
1263
+ {
1264
+ name: "times",
1265
+ category: "math",
1266
+ compatibility: ["browser", "nodejs"],
1267
+ fn: times
1268
+ }
1269
+ ];
1270
+
1271
+ // src/helpers/md.ts
1272
+ var import_node_fs3 = __toESM(require("fs"), 1);
1273
+ var import_node_path4 = __toESM(require("path"), 1);
1274
+ var import_node_process = __toESM(require("process"), 1);
1275
+ var import_ent = __toESM(require("ent"), 1);
1276
+ var import_handlebars = __toESM(require("handlebars"), 1);
1277
+ var import_remarkable = require("remarkable");
1278
+ var renderMarkdown = function(input, options) {
1279
+ if (typeof input === "object" && input && "fn" in input && typeof input.fn === "function") {
1280
+ options = input;
1281
+ input = input.fn(this);
1282
+ } else if (typeof input !== "string") {
1283
+ input = "";
1284
+ }
1285
+ const options_ = { cwd: import_node_process.default.cwd(), ...options };
1286
+ const md = new import_remarkable.Remarkable({
1287
+ breaks: true,
1288
+ html: true,
1289
+ langPrefix: "lang-",
1290
+ typographer: false,
1291
+ xhtmlOut: false
1292
+ });
1293
+ let string_ = input;
1294
+ if (string_ && string_.length > 0) {
1295
+ const filepath = import_node_path4.default.resolve(options_.cwd, string_);
1296
+ if (import_node_fs3.default.existsSync(filepath) && import_node_fs3.default.statSync(filepath).isFile()) {
1297
+ string_ = import_node_fs3.default.readFileSync(filepath, "utf8");
1298
+ }
1299
+ }
1300
+ return new import_handlebars.default.SafeString(import_ent.default.decode(md.render(string_)));
1301
+ };
1302
+ var helpers13 = [
1303
+ {
1304
+ name: "md",
1305
+ category: "markdown",
1306
+ compatibility: ["nodejs"],
1307
+ fn: renderMarkdown
1308
+ },
1309
+ {
1310
+ name: "markdown",
1311
+ category: "markdown",
1312
+ compatibility: ["nodejs"],
1313
+ fn: renderMarkdown
1314
+ }
1315
+ ];
1316
+
1317
+ // src/helpers/misc.ts
1318
+ var import_handlebars2 = __toESM(require("handlebars"), 1);
1319
+ var import_handlebars_utils = __toESM(require("handlebars-utils"), 1);
1320
+ var import_kind_of = __toESM(require("kind-of"), 1);
1321
+ function frame(context, options) {
1322
+ if (typeof context === "object" && context !== null && "hash" in context) {
1323
+ options = context;
1324
+ context = options.data;
1325
+ }
1326
+ const data = import_handlebars2.default.createFrame(context || {});
1327
+ if (typeof options !== "object" || options === null) {
1328
+ options = {};
1329
+ }
1330
+ if (options.hash && typeof options.hash === "object") {
1331
+ Object.assign(data, options.hash);
1332
+ }
1333
+ return options.fn(this, { data });
1334
+ }
1335
+ function option(prop, locals, options) {
1336
+ return get(import_handlebars_utils.default.options(this, locals, options), prop);
1337
+ }
1338
+ function noop(options) {
1339
+ return options.fn(this);
1340
+ }
1341
+ var typeOf = import_kind_of.default;
1342
+ function withHash(options) {
1343
+ if (options.hash && Object.keys(options.hash).length) {
1344
+ return options.fn(options.hash);
1345
+ }
1346
+ return options.inverse(this);
1347
+ }
1348
+ var helpers14 = [
1349
+ {
1350
+ name: "frame",
1351
+ category: "misc",
1352
+ compatibility: ["browser", "nodejs"],
1353
+ fn: frame
1354
+ },
1355
+ {
1356
+ name: "option",
1357
+ category: "misc",
1358
+ compatibility: ["browser", "nodejs"],
1359
+ fn: option
1360
+ },
1361
+ {
1362
+ name: "noop",
1363
+ category: "misc",
1364
+ compatibility: ["browser", "nodejs"],
1365
+ fn: noop
1366
+ },
1367
+ {
1368
+ name: "typeOf",
1369
+ category: "misc",
1370
+ compatibility: ["browser", "nodejs"],
1371
+ fn: typeOf
1372
+ },
1373
+ {
1374
+ name: "withHash",
1375
+ category: "misc",
1376
+ compatibility: ["browser", "nodejs"],
1377
+ fn: withHash
1378
+ }
1379
+ ];
1380
+
1381
+ // src/helpers/number.ts
1382
+ var isNumeric2 = (value) => typeof value === "number" && !Number.isNaN(value);
1383
+ var bytes = (value, precision) => {
1384
+ if (value == null) return "0 B";
1385
+ let num;
1386
+ if (typeof value === "string") {
1387
+ num = value.length;
1388
+ if (!num) return "0 B";
1389
+ } else if (isNumeric2(value)) {
1390
+ num = Number(value);
1391
+ } else if (typeof value.length === "number") {
1392
+ num = value.length;
1393
+ if (!num) return "0 B";
1394
+ } else {
1395
+ return "0 B";
1396
+ }
1397
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
1398
+ const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
1399
+ const factor = 10 ** prec;
1400
+ for (let i = abbr.length - 1; i >= 0; i--) {
1401
+ const size = 10 ** (i * 3);
1402
+ if (size <= num + 1) {
1403
+ const val = Math.round(num * factor / size) / factor;
1404
+ return `${val} ${abbr[i]}`;
1405
+ }
1406
+ }
1407
+ return `${num}`;
1408
+ };
1409
+ var addCommas = (num) => num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
1410
+ var phoneNumber = (num) => {
1411
+ const str = num.toString();
1412
+ return `(${str.substr(0, 3)}) ${str.substr(3, 3)}-${str.substr(6, 4)}`;
1413
+ };
1414
+ var toAbbr = (value, precision) => {
1415
+ const num = isNumeric2(value) ? Number(value) : 0;
1416
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
1417
+ const factor = 10 ** prec;
1418
+ const abbr = ["k", "m", "b", "t", "q"];
1419
+ for (let i = abbr.length - 1; i >= 0; i--) {
1420
+ const size = 10 ** ((i + 1) * 3);
1421
+ if (size <= num + 1) {
1422
+ const val = Math.round(num * factor / size) / factor;
1423
+ return `${val}${abbr[i]}`;
1424
+ }
1425
+ }
1426
+ return `${num}`;
1427
+ };
1428
+ var toExponential = (value, digits) => {
1429
+ const num = isNumeric2(value) ? Number(value) : 0;
1430
+ const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
1431
+ return Number(num).toExponential(d);
1432
+ };
1433
+ var toFixed = (value, digits) => {
1434
+ const num = isNumeric2(value) ? Number(value) : 0;
1435
+ const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
1436
+ return Number(num).toFixed(d);
1437
+ };
1438
+ var toFloat = (value) => parseFloat(String(value));
1439
+ var toInt = (value) => parseInt(String(value), 10);
1440
+ var toPrecision = (value, precision) => {
1441
+ const num = isNumeric2(value) ? Number(value) : 0;
1442
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 1;
1443
+ return Number(num).toPrecision(prec);
1444
+ };
1445
+ var helpers15 = [
1446
+ {
1447
+ name: "bytes",
1448
+ category: "number",
1449
+ compatibility: ["browser", "nodejs"],
1450
+ fn: bytes
1451
+ },
1452
+ {
1453
+ name: "addCommas",
1454
+ category: "number",
1455
+ compatibility: ["browser", "nodejs"],
1456
+ fn: addCommas
1457
+ },
1458
+ {
1459
+ name: "phoneNumber",
1460
+ category: "number",
1461
+ compatibility: ["browser", "nodejs"],
1462
+ fn: phoneNumber
1463
+ },
1464
+ {
1465
+ name: "toAbbr",
1466
+ category: "number",
1467
+ compatibility: ["browser", "nodejs"],
1468
+ fn: toAbbr
1469
+ },
1470
+ {
1471
+ name: "toExponential",
1472
+ category: "number",
1473
+ compatibility: ["browser", "nodejs"],
1474
+ fn: toExponential
1475
+ },
1476
+ {
1477
+ name: "toFixed",
1478
+ category: "number",
1479
+ compatibility: ["browser", "nodejs"],
1480
+ fn: toFixed
1481
+ },
1482
+ {
1483
+ name: "toFloat",
1484
+ category: "number",
1485
+ compatibility: ["browser", "nodejs"],
1486
+ fn: toFloat
1487
+ },
1488
+ {
1489
+ name: "toInt",
1490
+ category: "number",
1491
+ compatibility: ["browser", "nodejs"],
1492
+ fn: toInt
1493
+ },
1494
+ {
1495
+ name: "toPrecision",
1496
+ category: "number",
1497
+ compatibility: ["browser", "nodejs"],
1498
+ fn: toPrecision
1499
+ }
1500
+ ];
1501
+
1502
+ // src/helpers/object.ts
1503
+ var isOptions2 = (value) => {
1504
+ return Boolean(value && typeof value === "object" && "hash" in value);
1505
+ };
1506
+ var createFrame = (options, hash) => ({
1507
+ ...options?.data || {},
1508
+ ...hash
1509
+ });
1510
+ var extend = (...objects) => {
1511
+ const args = [...objects];
1512
+ if (args.length && isOptions2(args[args.length - 1])) {
1513
+ const opts = args.pop();
1514
+ args.push(opts.hash);
1515
+ }
1516
+ const result = {};
1517
+ for (const obj of args) {
1518
+ if (obj && typeof obj === "object" && !Array.isArray(obj)) {
1519
+ Object.assign(result, obj);
1520
+ }
1521
+ }
1522
+ return result;
1523
+ };
1524
+ var forIn = (obj, options) => {
1525
+ if (!isOptions2(options)) {
1526
+ return options?.inverse?.(obj) ?? "";
1527
+ }
1528
+ const data = createFrame(options, options.hash || {});
1529
+ let result = "";
1530
+ for (const key in obj) {
1531
+ data.key = key;
1532
+ result += options.fn(obj[key], { data });
1533
+ }
1534
+ return result;
1535
+ };
1536
+ var forOwn = (obj, options) => {
1537
+ if (!isOptions2(options)) {
1538
+ return options?.inverse?.(obj) ?? "";
1539
+ }
1540
+ const data = createFrame(options, options.hash || {});
1541
+ let result = "";
1542
+ for (const key in obj) {
1543
+ if (Object.hasOwn(obj, key)) {
1544
+ data.key = key;
1545
+ result += options.fn(obj[key], { data });
1546
+ }
1547
+ }
1548
+ return result;
1549
+ };
1550
+ var toPath = (...prop) => {
1551
+ const parts = [];
1552
+ for (const p of prop) {
1553
+ if (typeof p === "string" || typeof p === "number") {
1554
+ parts.push(p);
1555
+ }
1556
+ }
1557
+ return parts.join(".");
1558
+ };
1559
+ var getHelper = (prop, context, options) => {
1560
+ const val = get(context, prop);
1561
+ if (options && typeof options.fn === "function") {
1562
+ return val ? options.fn(val) : options.inverse?.(context);
1563
+ }
1564
+ return val;
1565
+ };
1566
+ var getObjectHelper = (prop, context) => {
1567
+ return getObject(context, prop);
1568
+ };
1569
+ var hasOwn = (context, key) => {
1570
+ return Object.hasOwn(context, key);
1571
+ };
1572
+ var isObject = (value) => {
1573
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1574
+ };
1575
+ var JSONparse = (str) => {
1576
+ return JSON.parse(str);
1577
+ };
1578
+ var JSONstringify = (obj, indent) => {
1579
+ const ind = typeof indent === "number" ? indent : 0;
1580
+ return JSON.stringify(obj, null, ind);
1581
+ };
1582
+ var merge = (context, ...objects) => {
1583
+ const args = [context, ...objects];
1584
+ if (args.length && isOptions2(args[args.length - 1])) {
1585
+ const opts = args.pop();
1586
+ args.push(opts.hash);
1587
+ }
1588
+ return Object.assign(...args);
1589
+ };
1590
+ var parseJSON = JSONparse;
1591
+ var stringify = JSONstringify;
1592
+ var pick = (props, context, options) => {
1593
+ const keys = arrayify(props);
1594
+ let result = {};
1595
+ for (const key of keys) {
1596
+ result = Object.assign({}, result, getObject(context, key));
1597
+ }
1598
+ if (options && typeof options.fn === "function") {
1599
+ if (Object.keys(result).length) {
1600
+ return options.fn(result);
1601
+ }
1602
+ return options.inverse?.(context);
1603
+ }
1604
+ return result;
1605
+ };
1606
+ var helpers16 = [
1607
+ {
1608
+ name: "extend",
1609
+ category: "object",
1610
+ compatibility: ["browser", "nodejs"],
1611
+ fn: extend
1612
+ },
1613
+ {
1614
+ name: "forIn",
1615
+ category: "object",
1616
+ compatibility: ["browser", "nodejs"],
1617
+ fn: forIn
1618
+ },
1619
+ {
1620
+ name: "forOwn",
1621
+ category: "object",
1622
+ compatibility: ["browser", "nodejs"],
1623
+ fn: forOwn
1624
+ },
1625
+ {
1626
+ name: "toPath",
1627
+ category: "object",
1628
+ compatibility: ["browser", "nodejs"],
1629
+ fn: toPath
1630
+ },
1631
+ {
1632
+ name: "get",
1633
+ category: "object",
1634
+ compatibility: ["browser", "nodejs"],
1635
+ fn: getHelper
1636
+ },
1637
+ {
1638
+ name: "getObject",
1639
+ category: "object",
1640
+ compatibility: ["browser", "nodejs"],
1641
+ fn: getObjectHelper
1642
+ },
1643
+ {
1644
+ name: "hasOwn",
1645
+ category: "object",
1646
+ compatibility: ["browser", "nodejs"],
1647
+ fn: hasOwn
1648
+ },
1649
+ {
1650
+ name: "isObject",
1651
+ category: "object",
1652
+ compatibility: ["browser", "nodejs"],
1653
+ fn: isObject
1654
+ },
1655
+ {
1656
+ name: "JSONparse",
1657
+ category: "object",
1658
+ compatibility: ["browser", "nodejs"],
1659
+ fn: JSONparse
1660
+ },
1661
+ {
1662
+ name: "JSONstringify",
1663
+ category: "object",
1664
+ compatibility: ["browser", "nodejs"],
1665
+ fn: JSONstringify
1666
+ },
1667
+ {
1668
+ name: "merge",
1669
+ category: "object",
1670
+ compatibility: ["browser", "nodejs"],
1671
+ fn: merge
1672
+ },
1673
+ {
1674
+ name: "parseJSON",
1675
+ category: "object",
1676
+ compatibility: ["browser", "nodejs"],
1677
+ fn: parseJSON
1678
+ },
1679
+ {
1680
+ name: "pick",
1681
+ category: "object",
1682
+ compatibility: ["browser", "nodejs"],
1683
+ fn: pick
1684
+ },
1685
+ {
1686
+ name: "stringify",
1687
+ category: "object",
1688
+ compatibility: ["browser", "nodejs"],
1689
+ fn: stringify
1690
+ }
1691
+ ];
1692
+
1693
+ // src/helpers/path.ts
1694
+ var import_node_path5 = __toESM(require("path"), 1);
1695
+ var expectedType = (variableName, expectedType2, variableValue) => {
1696
+ const actualType = Object.prototype.toString.call(variableValue).slice(8, -1).toLowerCase();
1697
+ return `Expected ${variableName} to be of type ${expectedType2}, but got ${actualType}`;
1698
+ };
1699
+ var assertString = (name, value) => {
1700
+ if (typeof value !== "string") {
1701
+ throw new TypeError(expectedType(name, "string", value));
1702
+ }
1703
+ return value;
1704
+ };
1705
+ var absolute = function(filepath, options) {
1706
+ const fp = assertString("filepath", filepath);
1707
+ const cwd = options?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
1708
+ return import_node_path5.default.resolve(cwd, fp);
1709
+ };
1710
+ var dirname = (filepath) => {
1711
+ const fp = assertString("filepath", filepath);
1712
+ return import_node_path5.default.dirname(fp);
1713
+ };
1714
+ var relative = (a, b) => {
1715
+ const from = assertString("first path", a);
1716
+ const to = assertString("second path", b);
1717
+ return import_node_path5.default.relative(import_node_path5.default.dirname(from), to);
1718
+ };
1719
+ var basename = (filepath) => {
1720
+ const fp = assertString("filepath", filepath);
1721
+ return import_node_path5.default.basename(fp);
1722
+ };
1723
+ var stem = (filepath) => {
1724
+ const fp = assertString("filepath", filepath);
1725
+ return import_node_path5.default.basename(fp, import_node_path5.default.extname(fp));
1726
+ };
1727
+ var extname = (filepath) => {
1728
+ const fp = assertString("filepath", filepath);
1729
+ return import_node_path5.default.extname(fp);
1730
+ };
1731
+ var resolveFn = function(filepath, ...paths) {
1732
+ let options;
1733
+ const last2 = paths[paths.length - 1];
1734
+ if (typeof last2 === "object" && last2 && "data" in last2) {
1735
+ options = paths.pop();
1736
+ }
1737
+ const cwd = options?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
1738
+ const all2 = [
1739
+ cwd,
1740
+ assertString("filepath", filepath),
1741
+ ...paths.map((p, i) => assertString(`path${i}`, p))
1742
+ ];
1743
+ return import_node_path5.default.resolve(...all2);
1744
+ };
1745
+ var segments = (filepath, a, b) => {
1746
+ const fp = assertString("filepath", filepath);
1747
+ const start = Number(a);
1748
+ const end = Number(b);
1749
+ const segmentsArr = fp.split(/[\\/]+/);
1750
+ return segmentsArr.slice(start, end).join("/");
1751
+ };
1752
+ var helpers17 = [
1753
+ {
1754
+ name: "absolute",
1755
+ category: "path",
1756
+ compatibility: ["nodejs"],
1757
+ fn: absolute
1758
+ },
1759
+ {
1760
+ name: "dirname",
1761
+ category: "path",
1762
+ compatibility: ["nodejs"],
1763
+ fn: dirname
1764
+ },
1765
+ {
1766
+ name: "relative",
1767
+ category: "path",
1768
+ compatibility: ["nodejs"],
1769
+ fn: relative
1770
+ },
1771
+ {
1772
+ name: "basename",
1773
+ category: "path",
1774
+ compatibility: ["nodejs"],
1775
+ fn: basename
1776
+ },
1777
+ {
1778
+ name: "stem",
1779
+ category: "path",
1780
+ compatibility: ["nodejs"],
1781
+ fn: stem
1782
+ },
1783
+ {
1784
+ name: "extname",
1785
+ category: "path",
1786
+ compatibility: ["nodejs"],
1787
+ fn: extname
1788
+ },
1789
+ {
1790
+ name: "resolve",
1791
+ category: "path",
1792
+ compatibility: ["nodejs"],
1793
+ fn: resolveFn
1794
+ },
1795
+ {
1796
+ name: "segments",
1797
+ category: "path",
1798
+ compatibility: ["nodejs"],
1799
+ fn: segments
1800
+ }
1801
+ ];
1802
+
1803
+ // src/helpers/regex.ts
1804
+ var import_handlebars_utils2 = __toESM(require("handlebars-utils"), 1);
1805
+ var toRegex = (str, locals, options) => {
1806
+ const opts = import_handlebars_utils2.default.options({}, locals, options);
1807
+ return new RegExp(str, opts.flags);
1808
+ };
1809
+ var test = (str, regex) => {
1810
+ if (typeof str !== "string") {
1811
+ return false;
1812
+ }
1813
+ if (!(regex instanceof RegExp)) {
1814
+ throw new TypeError("expected a regular expression");
1815
+ }
1816
+ return regex.test(str);
1817
+ };
1818
+ var helpers18 = [
1819
+ {
1820
+ name: "toRegex",
1821
+ category: "regex",
1822
+ compatibility: ["browser", "nodejs"],
1823
+ fn: toRegex
1824
+ },
1825
+ {
1826
+ name: "test",
1827
+ category: "regex",
1828
+ compatibility: ["browser", "nodejs"],
1829
+ fn: test
1830
+ }
1831
+ ];
1832
+
1833
+ // src/helpers/string.ts
1834
+ var chop = (str) => str.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g, "");
1835
+ var changecase = (str, fn) => {
1836
+ if (str.length === 1) return str.toLowerCase();
1837
+ const res = chop(str).toLowerCase();
1838
+ return res.replace(/[-_.\W\s]+(\w|$)/g, (_, ch) => fn(ch));
1839
+ };
1840
+ var append = (str, suffix) => {
1841
+ if (typeof str === "string" && typeof suffix === "string") {
1842
+ return str + suffix;
1843
+ }
1844
+ return str;
1845
+ };
1846
+ var camelcase = (str) => typeof str === "string" ? changecase(str, (ch) => ch.toUpperCase()) : "";
1847
+ var capitalize = (str) => {
1848
+ if (typeof str !== "string" || str.length === 0) return "";
1849
+ return str.charAt(0).toUpperCase() + str.slice(1);
1850
+ };
1851
+ var capitalizeAll = (str) => {
1852
+ if (typeof str !== "string") return "";
1853
+ return str.replace(/\w\S*/g, (word) => capitalize(word));
1854
+ };
1855
+ var center = (str, spaces) => {
1856
+ if (typeof str !== "string") return "";
1857
+ let space = "";
1858
+ for (let i = 0; i < spaces; i++) {
1859
+ space += "&nbsp;";
1860
+ }
1861
+ return space + str + space;
1862
+ };
1863
+ var chopStr = (str) => typeof str === "string" ? chop(str) : "";
1864
+ var dashcase = (str) => typeof str === "string" ? changecase(str, (ch) => `-${ch}`) : "";
1865
+ var dotcase = (str) => typeof str === "string" ? changecase(str, (ch) => `.${ch}`) : "";
1866
+ var truncate = (str, limit, suffix) => {
1867
+ if (typeof str === "string") {
1868
+ if (typeof suffix !== "string") {
1869
+ suffix = "";
1870
+ }
1871
+ if (str.length > limit) {
1872
+ return str.slice(0, limit - suffix.length) + suffix;
1873
+ }
1874
+ return str;
1875
+ }
1876
+ return "";
1877
+ };
1878
+ var ellipsis = (str, limit) => {
1879
+ if (typeof str === "string") {
1880
+ if (str.length <= limit) {
1881
+ return str;
1882
+ }
1883
+ return `${truncate(str, limit)}\u2026`;
1884
+ }
1885
+ return "";
1886
+ };
1887
+ var hyphenate = (str) => typeof str === "string" ? str.split(" ").join("-") : "";
1888
+ var isString = (value) => typeof value === "string";
1889
+ var lowercase = (str) => {
1890
+ if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
1891
+ return String(str.fn()).toLowerCase();
1892
+ }
1893
+ if (typeof str !== "string") return "";
1894
+ return str.toLowerCase();
1895
+ };
1896
+ var downcase = (str) => lowercase(str);
1897
+ var occurrences = (str, substring) => {
1898
+ if (typeof str !== "string") return "";
1899
+ const len = substring.length;
1900
+ let pos = str.indexOf(substring, 0);
1901
+ let n = 0;
1902
+ while (pos > -1) {
1903
+ n++;
1904
+ pos = str.indexOf(substring, pos + len);
1905
+ }
1906
+ return n;
1907
+ };
1908
+ var pascalcase = (str) => {
1909
+ if (typeof str !== "string") return "";
1910
+ const res = changecase(str, (ch) => ch.toUpperCase());
1911
+ return res.charAt(0).toUpperCase() + res.slice(1);
1912
+ };
1913
+ var pathcase = (str) => typeof str === "string" ? changecase(str, (ch) => `/${ch}`) : "";
1914
+ var plusify = (str, ch) => {
1915
+ if (typeof str !== "string") return "";
1916
+ if (typeof ch !== "string") ch = " ";
1917
+ return str.split(ch).join("+");
1918
+ };
1919
+ var prepend = (str, prefix) => {
1920
+ return typeof str === "string" && typeof prefix === "string" ? prefix + str : str;
1921
+ };
1922
+ var remove = (str, ch) => {
1923
+ if (typeof str !== "string") return "";
1924
+ if (typeof ch !== "string") return str;
1925
+ return str.split(ch).join("");
1926
+ };
1927
+ var removeFirst = (str, ch) => {
1928
+ if (typeof str !== "string") return "";
1929
+ if (typeof ch !== "string") return str;
1930
+ return str.replace(ch, "");
1931
+ };
1932
+ var replace = (str, a, b) => {
1933
+ if (typeof str !== "string") return "";
1934
+ if (typeof a !== "string") return str;
1935
+ if (typeof b !== "string") b = "";
1936
+ return str.split(a).join(b);
1937
+ };
1938
+ var replaceFirst = (str, a, b) => {
1939
+ if (typeof str !== "string") return "";
1940
+ if (typeof a !== "string") return str;
1941
+ if (typeof b !== "string") b = "";
1942
+ return str.replace(a, b);
1943
+ };
1944
+ var reverse = (str) => typeof str === "string" ? str.split("").reverse().join("") : "";
1945
+ var sentence = (str) => {
1946
+ if (typeof str !== "string") return "";
1947
+ return str.replace(
1948
+ /((?:\S[^.?!]*)[.?!]*)/g,
1949
+ (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
1950
+ );
1951
+ };
1952
+ var snakecase = (str) => typeof str === "string" ? changecase(str, (ch) => `_${ch}`) : "";
1953
+ var trim = (str) => typeof str === "string" ? str.trim() : "";
1954
+ var trimLeft = (str) => typeof str === "string" ? str.replace(/^\s+/, "") : "";
1955
+ var trimRight = (str) => typeof str === "string" ? str.replace(/\s+$/, "") : "";
1956
+ var truncateWords = (str, count, suffix) => {
1957
+ if (typeof str === "string" && typeof count === "number" && Number.isFinite(count)) {
1958
+ if (typeof suffix !== "string") {
1959
+ suffix = "...";
1960
+ }
1961
+ const num = Math.trunc(count);
1962
+ let arr = str.split(" ");
1963
+ if (num < arr.length) {
1964
+ arr = arr.slice(0, num);
1965
+ }
1966
+ const val = arr.join(" ").trim();
1967
+ return val + suffix;
1968
+ }
1969
+ return "";
1970
+ };
1971
+ var truncateWordsAlias = truncateWords;
1972
+ var uppercase = (str) => {
1973
+ if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
1974
+ return String(str.fn()).toUpperCase();
1975
+ }
1976
+ if (typeof str !== "string") return "";
1977
+ return str.toUpperCase();
1978
+ };
1979
+ var upcase = (str) => uppercase(str);
1980
+ var helpers19 = [
1981
+ {
1982
+ name: "append",
1983
+ category: "string",
1984
+ compatibility: ["browser", "nodejs"],
1985
+ fn: append
1986
+ },
1987
+ {
1988
+ name: "camelcase",
1989
+ category: "string",
1990
+ compatibility: ["browser", "nodejs"],
1991
+ fn: camelcase
1992
+ },
1993
+ {
1994
+ name: "capitalize",
1995
+ category: "string",
1996
+ compatibility: ["browser", "nodejs"],
1997
+ fn: capitalize
1998
+ },
1999
+ {
2000
+ name: "capitalizeAll",
2001
+ category: "string",
2002
+ compatibility: ["browser", "nodejs"],
2003
+ fn: capitalizeAll
2004
+ },
2005
+ {
2006
+ name: "center",
2007
+ category: "string",
2008
+ compatibility: ["browser", "nodejs"],
2009
+ fn: center
2010
+ },
2011
+ {
2012
+ name: "chop",
2013
+ category: "string",
2014
+ compatibility: ["browser", "nodejs"],
2015
+ fn: chopStr
2016
+ },
2017
+ {
2018
+ name: "dashcase",
2019
+ category: "string",
2020
+ compatibility: ["browser", "nodejs"],
2021
+ fn: dashcase
2022
+ },
2023
+ {
2024
+ name: "dotcase",
2025
+ category: "string",
2026
+ compatibility: ["browser", "nodejs"],
2027
+ fn: dotcase
2028
+ },
2029
+ {
2030
+ name: "ellipsis",
2031
+ category: "string",
2032
+ compatibility: ["browser", "nodejs"],
2033
+ fn: ellipsis
2034
+ },
2035
+ {
2036
+ name: "hyphenate",
2037
+ category: "string",
2038
+ compatibility: ["browser", "nodejs"],
2039
+ fn: hyphenate
2040
+ },
2041
+ {
2042
+ name: "isString",
2043
+ category: "string",
2044
+ compatibility: ["browser", "nodejs"],
2045
+ fn: isString
2046
+ },
2047
+ {
2048
+ name: "lowercase",
2049
+ category: "string",
2050
+ compatibility: ["browser", "nodejs"],
2051
+ fn: lowercase
2052
+ },
2053
+ {
2054
+ name: "downcase",
2055
+ category: "string",
2056
+ compatibility: ["browser", "nodejs"],
2057
+ fn: downcase
2058
+ },
2059
+ {
2060
+ name: "occurrences",
2061
+ category: "string",
2062
+ compatibility: ["browser", "nodejs"],
2063
+ fn: occurrences
2064
+ },
2065
+ {
2066
+ name: "pascalcase",
2067
+ category: "string",
2068
+ compatibility: ["browser", "nodejs"],
2069
+ fn: pascalcase
2070
+ },
2071
+ {
2072
+ name: "pathcase",
2073
+ category: "string",
2074
+ compatibility: ["browser", "nodejs"],
2075
+ fn: pathcase
2076
+ },
2077
+ {
2078
+ name: "plusify",
2079
+ category: "string",
2080
+ compatibility: ["browser", "nodejs"],
2081
+ fn: plusify
2082
+ },
2083
+ {
2084
+ name: "prepend",
2085
+ category: "string",
2086
+ compatibility: ["browser", "nodejs"],
2087
+ fn: prepend
2088
+ },
2089
+ {
2090
+ name: "remove",
2091
+ category: "string",
2092
+ compatibility: ["browser", "nodejs"],
2093
+ fn: remove
2094
+ },
2095
+ {
2096
+ name: "removeFirst",
2097
+ category: "string",
2098
+ compatibility: ["browser", "nodejs"],
2099
+ fn: removeFirst
2100
+ },
2101
+ {
2102
+ name: "replace",
2103
+ category: "string",
2104
+ compatibility: ["browser", "nodejs"],
2105
+ fn: replace
2106
+ },
2107
+ {
2108
+ name: "replaceFirst",
2109
+ category: "string",
2110
+ compatibility: ["browser", "nodejs"],
2111
+ fn: replaceFirst
2112
+ },
2113
+ {
2114
+ name: "reverse",
2115
+ category: "string",
2116
+ compatibility: ["browser", "nodejs"],
2117
+ fn: reverse
2118
+ },
2119
+ {
2120
+ name: "sentence",
2121
+ category: "string",
2122
+ compatibility: ["browser", "nodejs"],
2123
+ fn: sentence
2124
+ },
2125
+ {
2126
+ name: "snakecase",
2127
+ category: "string",
2128
+ compatibility: ["browser", "nodejs"],
2129
+ fn: snakecase
2130
+ },
2131
+ {
2132
+ name: "trim",
2133
+ category: "string",
2134
+ compatibility: ["browser", "nodejs"],
2135
+ fn: trim
2136
+ },
2137
+ {
2138
+ name: "trimLeft",
2139
+ category: "string",
2140
+ compatibility: ["browser", "nodejs"],
2141
+ fn: trimLeft
2142
+ },
2143
+ {
2144
+ name: "trimRight",
2145
+ category: "string",
2146
+ compatibility: ["browser", "nodejs"],
2147
+ fn: trimRight
2148
+ },
2149
+ {
2150
+ name: "truncate",
2151
+ category: "string",
2152
+ compatibility: ["browser", "nodejs"],
2153
+ fn: truncate
2154
+ },
2155
+ {
2156
+ name: "truncateWords",
2157
+ category: "string",
2158
+ compatibility: ["browser", "nodejs"],
2159
+ fn: truncateWordsAlias
2160
+ },
2161
+ {
2162
+ name: "uppercase",
2163
+ category: "string",
2164
+ compatibility: ["browser", "nodejs"],
2165
+ fn: uppercase
2166
+ },
2167
+ {
2168
+ name: "upcase",
2169
+ category: "string",
2170
+ compatibility: ["browser", "nodejs"],
2171
+ fn: upcase
2172
+ }
2173
+ ];
2174
+
2175
+ // src/helpers/url.ts
2176
+ var import_node_querystring = require("querystring");
2177
+ var import_node_url = require("url");
2178
+ var all = ["browser", "nodejs"];
2179
+ var encodeUri = (str) => {
2180
+ if (typeof str === "string") {
2181
+ return encodeURIComponent(str);
2182
+ }
2183
+ };
2184
+ var escapeFn = (str) => {
2185
+ if (typeof str === "string") {
2186
+ return (0, import_node_querystring.escape)(str);
2187
+ }
2188
+ };
2189
+ var decodeUri = (str) => {
2190
+ if (typeof str === "string") {
2191
+ return decodeURIComponent(str);
2192
+ }
2193
+ };
2194
+ function urlEncode(...args) {
2195
+ return encodeUri.apply(this, args);
2196
+ }
2197
+ function urlDecode(...args) {
2198
+ return decodeUri.apply(this, args);
2199
+ }
2200
+ var urlResolve = (base, href) => (0, import_node_url.resolve)(String(base), String(href));
2201
+ var urlParse = (str) => (0, import_node_url.parse)(String(str));
2202
+ var stripQuerystring = (str) => {
2203
+ if (typeof str === "string") {
2204
+ return str.split("?")[0];
2205
+ }
2206
+ };
2207
+ var stripProtocol = (str) => {
2208
+ if (typeof str === "string") {
2209
+ const parsed = (0, import_node_url.parse)(str);
2210
+ parsed.protocol = "";
2211
+ return (0, import_node_url.format)(parsed);
2212
+ }
2213
+ };
2214
+ var helpers20 = [
2215
+ {
2216
+ name: "encodeURI",
2217
+ category: "url",
2218
+ compatibility: all,
2219
+ fn: encodeUri
2220
+ },
2221
+ {
2222
+ name: "escape",
2223
+ category: "url",
2224
+ compatibility: ["nodejs"],
2225
+ fn: escapeFn
2226
+ },
2227
+ {
2228
+ name: "decodeURI",
2229
+ category: "url",
2230
+ compatibility: all,
2231
+ fn: decodeUri
2232
+ },
2233
+ {
2234
+ name: "url_encode",
2235
+ category: "url",
2236
+ compatibility: all,
2237
+ fn: urlEncode
2238
+ },
2239
+ {
2240
+ name: "url_decode",
2241
+ category: "url",
2242
+ compatibility: all,
2243
+ fn: urlDecode
2244
+ },
2245
+ {
2246
+ name: "urlResolve",
2247
+ category: "url",
2248
+ compatibility: ["nodejs"],
2249
+ fn: urlResolve
2250
+ },
2251
+ {
2252
+ name: "urlParse",
2253
+ category: "url",
2254
+ compatibility: ["nodejs"],
2255
+ fn: urlParse
2256
+ },
2257
+ {
2258
+ name: "stripQuerystring",
2259
+ category: "url",
2260
+ compatibility: all,
2261
+ fn: stripQuerystring
2262
+ },
2263
+ {
2264
+ name: "stripProtocol",
2265
+ category: "url",
2266
+ compatibility: ["nodejs"],
2267
+ fn: stripProtocol
2268
+ }
2269
+ ];
2270
+
2271
+ // src/helper-registry.ts
2272
+ var HelperRegistry = class {
2273
+ _helpers = [];
2274
+ constructor() {
2275
+ this.init();
2276
+ }
2277
+ /**
2278
+ * Get all registered helpers.
2279
+ * @returns {Helper[]} The array of registered helpers.
2280
+ */
2281
+ get helpers() {
2282
+ return this._helpers;
2283
+ }
2284
+ /**
2285
+ * Initialize the helper registry. This is performed during the construction of the registry such as new HelperRegistry().
2286
+ */
2287
+ init() {
2288
+ this.registerHelpers(helpers);
2289
+ this.registerHelpers(helpers3);
2290
+ this.registerHelpers(helpers5);
2291
+ this.registerHelpers(helpers6);
2292
+ this.registerHelpers(helpers2);
2293
+ this.registerHelpers(helpers13);
2294
+ this.registerHelpers(helpers7);
2295
+ this.registerHelpers(helpers4);
2296
+ this.registerHelpers(helpers8);
2297
+ this.registerHelpers(helpers9);
2298
+ this.registerHelpers(helpers10);
2299
+ this.registerHelpers(helpers11);
2300
+ this.registerHelpers(helpers12);
2301
+ this.registerHelpers(helpers14);
2302
+ this.registerHelpers(helpers15);
2303
+ this.registerHelpers(helpers17);
2304
+ this.registerHelpers(helpers18);
2305
+ this.registerHelpers(helpers19);
2306
+ this.registerHelpers(helpers20);
2307
+ this.registerHelpers(helpers16);
2308
+ }
2309
+ /**
2310
+ * Register a helper.
2311
+ * @param {Helper} helper The helper to register.
2312
+ * @returns True if the helper was registered, false otherwise.
2313
+ */
2314
+ register(helper) {
2315
+ const result = false;
2316
+ if (!this.has(helper.name)) {
2317
+ this._helpers.push(helper);
2318
+ }
2319
+ return result;
2320
+ }
2321
+ /**
2322
+ * Register multiple helpers.
2323
+ * @param {Helper[]} helpers The array of helpers to register.
2324
+ */
2325
+ registerHelpers(helpers22) {
2326
+ for (const helper of helpers22) {
2327
+ this.register(helper);
2328
+ }
2329
+ }
2330
+ /**
2331
+ * Check if a helper is registered.
2332
+ * @param name The name of the helper.
2333
+ * @returns True if the helper is registered, false otherwise.
2334
+ */
2335
+ has(name) {
2336
+ return this._helpers.some((helper) => helper.name === name);
2337
+ }
2338
+ /**
2339
+ * Filter helpers by the given criteria.
2340
+ * @param filter The filter criteria.
2341
+ * @returns The filtered helpers.
2342
+ */
2343
+ filter(filter) {
2344
+ let result = this._helpers;
2345
+ if (filter.names) {
2346
+ result = result.filter((helper) => filter.names?.includes(helper.name));
2347
+ }
2348
+ if (filter.categories) {
2349
+ result = result.filter(
2350
+ (helper) => filter.categories?.includes(helper.category)
2351
+ );
2352
+ }
2353
+ if (filter.compatibility) {
2354
+ result = result.filter(
2355
+ (helper) => helper.compatibility?.some((c) => filter.compatibility?.includes(c))
2356
+ );
2357
+ }
2358
+ return result;
2359
+ }
2360
+ /**
2361
+ * Load Handlebars helpers.
2362
+ * @param {Handlebars} handlebars The Handlebars instance.
2363
+ * @returns {void}
2364
+ */
2365
+ load(handlebars2, filters) {
2366
+ let helpers22 = this._helpers;
2367
+ if (filters) {
2368
+ helpers22 = this.filter(filters);
2369
+ }
2370
+ for (const helper of helpers22) {
2371
+ handlebars2.registerHelper(helper.name, helper.fn);
2372
+ }
2373
+ }
2374
+ /**
2375
+ * Swap Handlebars helpers. This is used when you want to swap out legacy helpers for fumanchu helpers.
2376
+ * @param handlebars The Handlebars instance.
2377
+ * @returns {void}
2378
+ */
2379
+ swap(handlebars2) {
2380
+ for (const helper of this._helpers) {
2381
+ handlebars2.unregisterHelper(helper.name);
2382
+ handlebars2.registerHelper(helper.name, helper.fn);
2383
+ }
2384
+ }
2385
+ };
2386
+
2387
+ // src/index.ts
2388
+ var Handlebars3 = import_handlebars3.default;
2389
+ var handlebars = import_handlebars3.default.create();
2390
+ function helpers21(options) {
2391
+ const registry = new HelperRegistry();
2392
+ registry.load(options.handlebars ?? options.hbs);
2393
+ }
2394
+ async function createHandlebars() {
2395
+ const registry = new HelperRegistry();
2396
+ const handlebars2 = import_handlebars3.default.create();
2397
+ if (Object.keys(import_handlebars3.default.partials).length > 0) {
2398
+ handlebars2.registerPartial(import_handlebars3.default.partials);
2399
+ }
2400
+ registry.load(handlebars2);
2401
+ if (process.env.NODE_ENV === "development") {
2402
+ console.warn(
2403
+ "createHandlebars will be deprecated in future versions, use `fumanchu` instead."
2404
+ );
2405
+ }
2406
+ return handlebars2;
2407
+ }
2408
+ function fumanchu(options) {
2409
+ const registry = new HelperRegistry();
2410
+ let handlebars2 = import_handlebars3.default.create();
2411
+ if (options?.handlebars) {
2412
+ handlebars2 = options.handlebars;
2413
+ } else if (Object.keys(import_handlebars3.default.partials).length > 0) {
2414
+ handlebars2.registerPartial(import_handlebars3.default.partials);
2415
+ }
2416
+ registry.load(handlebars2);
2417
+ return handlebars2;
2418
+ }
2419
+ // Annotate the CommonJS export names for ESM import in node:
2420
+ 0 && (module.exports = {
2421
+ Handlebars,
2422
+ HelperRegistry,
2423
+ createHandlebars,
2424
+ fumanchu,
2425
+ handlebars,
2426
+ helpers
2427
+ });
2428
+ /* c8 ignore next -- @preserve */