@sleekcms/client 3.1.1 → 3.2.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/README.md +12 -1
- package/index.cjs +9 -8
- package/index.d.cts +6 -3
- package/index.d.ts +6 -3
- package/index.global.js +9 -8
- package/index.global.js.map +1 -1
- package/index.global.min.js +1 -1
- package/index.global.min.js.map +1 -1
- package/index.mjs +9 -8
- package/package.json +1 -1
package/index.global.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var SleekCMS=(()=>{var We=Object.create;var oe=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var tt=(c,a)=>()=>(a||c((a={exports:{}}).exports,a),a.exports),rt=(c,a)=>{for(var u in a)oe(c,u,{get:a[u],enumerable:!0})},Ke=(c,a,u,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let _ of Ze(a))!et.call(c,_)&&_!==u&&oe(c,_,{get:()=>a[_],enumerable:!(p=Xe(a,_))||p.enumerable});return c};var nt=(c,a,u)=>(u=c!=null?We(Ve(c)):{},Ke(a||!c||!c.__esModule?oe(u,"default",{value:c,enumerable:!0}):u,c)),it=c=>Ke(oe({},"__esModule",{value:!0}),c);var Ae=tt(ce=>{(function(c){"use strict";function a(e){return e!==null?Object.prototype.toString.call(e)==="[object Array]":!1}function u(e){return e!==null?Object.prototype.toString.call(e)==="[object Object]":!1}function p(e,t){if(e===t)return!0;var r=Object.prototype.toString.call(e);if(r!==Object.prototype.toString.call(t))return!1;if(a(e)===!0){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(p(e[n],t[n])===!1)return!1;return!0}if(u(e)===!0){var i={};for(var s in e)if(hasOwnProperty.call(e,s)){if(p(e[s],t[s])===!1)return!1;i[s]=!0}for(var f in t)if(hasOwnProperty.call(t,f)&&i[f]!==!0)return!1;return!0}return!1}function _(e){if(e===""||e===!1||e===null)return!0;if(a(e)&&e.length===0)return!0;if(u(e)){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}else return!1}function E(e){for(var t=Object.keys(e),r=[],n=0;n<t.length;n++)r.push(e[t[n]]);return r}function d(e,t){var r={};for(var n in e)r[n]=e[n];for(var i in t)r[i]=t[i];return r}var R;typeof String.prototype.trimLeft=="function"?R=function(e){return e.trimLeft()}:R=function(e){return e.match(/^\s*(.*)/)[1]};var S=0,C=1,l=2,y=3,k=4,w=5,x=6,B=7,v=8,m=9,D={0:"number",1:"any",2:"string",3:"array",4:"object",5:"boolean",6:"expression",7:"null",8:"Array<number>",9:"Array<string>"},H="EOF",J="UnquotedIdentifier",$="QuotedIdentifier",P="Rbracket",Y="Rparen",j="Comma",A="Colon",ee="Rbrace",q="Number",I="Current",z="Expref",Q="Pipe",le="Or",fe="And",te="EQ",re="GT",ne="LT",ie="GTE",se="LTE",ae="NE",K="Flatten",F="Star",G="Filter",W="Dot",pe="Not",X="Lbrace",U="Lbracket",Z="Lparen",_e="Literal",Oe={".":W,"*":F,",":j,":":A,"{":X,"}":ee,"]":P,"(":Z,")":Y,"@":I},He={"<":!0,">":!0,"=":!0,"!":!0},Je={" ":!0," ":!0,"\n":!0};function Ye(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function Ce(e){return e>="0"&&e<="9"||e==="-"}function $e(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="_"}function ve(){}ve.prototype={tokenize:function(e){var t=[];this._current=0;for(var r,n,i;this._current<e.length;)if(Ye(e[this._current]))r=this._current,n=this._consumeUnquotedIdentifier(e),t.push({type:J,value:n,start:r});else if(Oe[e[this._current]]!==void 0)t.push({type:Oe[e[this._current]],value:e[this._current],start:this._current}),this._current++;else if(Ce(e[this._current]))i=this._consumeNumber(e),t.push(i);else if(e[this._current]==="[")i=this._consumeLBracket(e),t.push(i);else if(e[this._current]==='"')r=this._current,n=this._consumeQuotedIdentifier(e),t.push({type:$,value:n,start:r});else if(e[this._current]==="'")r=this._current,n=this._consumeRawStringLiteral(e),t.push({type:_e,value:n,start:r});else if(e[this._current]==="`"){r=this._current;var s=this._consumeLiteral(e);t.push({type:_e,value:s,start:r})}else if(He[e[this._current]]!==void 0)t.push(this._consumeOperator(e));else if(Je[e[this._current]]!==void 0)this._current++;else if(e[this._current]==="&")r=this._current,this._current++,e[this._current]==="&"?(this._current++,t.push({type:fe,value:"&&",start:r})):t.push({type:z,value:"&",start:r});else if(e[this._current]==="|")r=this._current,this._current++,e[this._current]==="|"?(this._current++,t.push({type:le,value:"||",start:r})):t.push({type:Q,value:"|",start:r});else{var f=new Error("Unknown character:"+e[this._current]);throw f.name="LexerError",f}return t},_consumeUnquotedIdentifier:function(e){var t=this._current;for(this._current++;this._current<e.length&&$e(e[this._current]);)this._current++;return e.slice(t,this._current)},_consumeQuotedIdentifier:function(e){var t=this._current;this._current++;for(var r=e.length;e[this._current]!=='"'&&this._current<r;){var n=this._current;e[n]==="\\"&&(e[n+1]==="\\"||e[n+1]==='"')?n+=2:n++,this._current=n}return this._current++,JSON.parse(e.slice(t,this._current))},_consumeRawStringLiteral:function(e){var t=this._current;this._current++;for(var r=e.length;e[this._current]!=="'"&&this._current<r;){var n=this._current;e[n]==="\\"&&(e[n+1]==="\\"||e[n+1]==="'")?n+=2:n++,this._current=n}this._current++;var i=e.slice(t+1,this._current-1);return i.replace("\\'","'")},_consumeNumber:function(e){var t=this._current;this._current++;for(var r=e.length;Ce(e[this._current])&&this._current<r;)this._current++;var n=parseInt(e.slice(t,this._current));return{type:q,value:n,start:t}},_consumeLBracket:function(e){var t=this._current;return this._current++,e[this._current]==="?"?(this._current++,{type:G,value:"[?",start:t}):e[this._current]==="]"?(this._current++,{type:K,value:"[]",start:t}):{type:U,value:"[",start:t}},_consumeOperator:function(e){var t=this._current,r=e[t];if(this._current++,r==="!")return e[this._current]==="="?(this._current++,{type:ae,value:"!=",start:t}):{type:pe,value:"!",start:t};if(r==="<")return e[this._current]==="="?(this._current++,{type:se,value:"<=",start:t}):{type:ne,value:"<",start:t};if(r===">")return e[this._current]==="="?(this._current++,{type:ie,value:">=",start:t}):{type:re,value:">",start:t};if(r==="="&&e[this._current]==="=")return this._current++,{type:te,value:"==",start:t}},_consumeLiteral:function(e){this._current++;for(var t=this._current,r=e.length,n;e[this._current]!=="`"&&this._current<r;){var i=this._current;e[i]==="\\"&&(e[i+1]==="\\"||e[i+1]==="`")?i+=2:i++,this._current=i}var s=R(e.slice(t,this._current));return s=s.replace("\\`","`"),this._looksLikeJSON(s)?n=JSON.parse(s):n=JSON.parse('"'+s+'"'),this._current++,n},_looksLikeJSON:function(e){var t='[{"',r=["true","false","null"],n="-0123456789";if(e==="")return!1;if(t.indexOf(e[0])>=0)return!0;if(r.indexOf(e)>=0)return!0;if(n.indexOf(e[0])>=0)try{return JSON.parse(e),!0}catch{return!1}else return!1}};var h={};h[H]=0,h[J]=0,h[$]=0,h[P]=0,h[Y]=0,h[j]=0,h[ee]=0,h[q]=0,h[I]=0,h[z]=0,h[Q]=1,h[le]=2,h[fe]=3,h[te]=5,h[re]=5,h[ne]=5,h[ie]=5,h[se]=5,h[ae]=5,h[K]=9,h[F]=20,h[G]=21,h[W]=40,h[pe]=45,h[X]=50,h[U]=55,h[Z]=60;function ye(){}ye.prototype={parse:function(e){this._loadTokens(e),this.index=0;var t=this.expression(0);if(this._lookahead(0)!==H){var r=this._lookaheadToken(0),n=new Error("Unexpected token type: "+r.type+", value: "+r.value);throw n.name="ParserError",n}return t},_loadTokens:function(e){var t=new ve,r=t.tokenize(e);r.push({type:H,value:"",start:e.length}),this.tokens=r},expression:function(e){var t=this._lookaheadToken(0);this._advance();for(var r=this.nud(t),n=this._lookahead(0);e<h[n];)this._advance(),r=this.led(n,r),n=this._lookahead(0);return r},_lookahead:function(e){return this.tokens[this.index+e].type},_lookaheadToken:function(e){return this.tokens[this.index+e]},_advance:function(){this.index++},nud:function(e){var t,r,n;switch(e.type){case _e:return{type:"Literal",value:e.value};case J:return{type:"Field",name:e.value};case $:var i={type:"Field",name:e.value};if(this._lookahead(0)===Z)throw new Error("Quoted identifier not allowed for function names.");return i;case pe:return r=this.expression(h.Not),{type:"NotExpression",children:[r]};case F:return t={type:"Identity"},r=null,this._lookahead(0)===P?r={type:"Identity"}:r=this._parseProjectionRHS(h.Star),{type:"ValueProjection",children:[t,r]};case G:return this.led(e.type,{type:"Identity"});case X:return this._parseMultiselectHash();case K:return t={type:K,children:[{type:"Identity"}]},r=this._parseProjectionRHS(h.Flatten),{type:"Projection",children:[t,r]};case U:return this._lookahead(0)===q||this._lookahead(0)===A?(r=this._parseIndexExpression(),this._projectIfSlice({type:"Identity"},r)):this._lookahead(0)===F&&this._lookahead(1)===P?(this._advance(),this._advance(),r=this._parseProjectionRHS(h.Star),{type:"Projection",children:[{type:"Identity"},r]}):this._parseMultiselectList();case I:return{type:I};case z:return n=this.expression(h.Expref),{type:"ExpressionReference",children:[n]};case Z:for(var s=[];this._lookahead(0)!==Y;)this._lookahead(0)===I?(n={type:I},this._advance()):n=this.expression(0),s.push(n);return this._match(Y),s[0];default:this._errorToken(e)}},led:function(e,t){var r;switch(e){case W:var n=h.Dot;return this._lookahead(0)!==F?(r=this._parseDotRHS(n),{type:"Subexpression",children:[t,r]}):(this._advance(),r=this._parseProjectionRHS(n),{type:"ValueProjection",children:[t,r]});case Q:return r=this.expression(h.Pipe),{type:Q,children:[t,r]};case le:return r=this.expression(h.Or),{type:"OrExpression",children:[t,r]};case fe:return r=this.expression(h.And),{type:"AndExpression",children:[t,r]};case Z:for(var i=t.name,s=[],f,g;this._lookahead(0)!==Y;)this._lookahead(0)===I?(f={type:I},this._advance()):f=this.expression(0),this._lookahead(0)===j&&this._match(j),s.push(f);return this._match(Y),g={type:"Function",name:i,children:s},g;case G:var O=this.expression(0);return this._match(P),this._lookahead(0)===K?r={type:"Identity"}:r=this._parseProjectionRHS(h.Filter),{type:"FilterProjection",children:[t,r,O]};case K:var M={type:K,children:[t]},T=this._parseProjectionRHS(h.Flatten);return{type:"Projection",children:[M,T]};case te:case ae:case re:case ie:case ne:case se:return this._parseComparator(t,e);case U:var o=this._lookaheadToken(0);return o.type===q||o.type===A?(r=this._parseIndexExpression(),this._projectIfSlice(t,r)):(this._match(F),this._match(P),r=this._parseProjectionRHS(h.Star),{type:"Projection",children:[t,r]});default:this._errorToken(this._lookaheadToken(0))}},_match:function(e){if(this._lookahead(0)===e)this._advance();else{var t=this._lookaheadToken(0),r=new Error("Expected "+e+", got: "+t.type);throw r.name="ParserError",r}},_errorToken:function(e){var t=new Error("Invalid token ("+e.type+'): "'+e.value+'"');throw t.name="ParserError",t},_parseIndexExpression:function(){if(this._lookahead(0)===A||this._lookahead(1)===A)return this._parseSliceExpression();var e={type:"Index",value:this._lookaheadToken(0).value};return this._advance(),this._match(P),e},_projectIfSlice:function(e,t){var r={type:"IndexExpression",children:[e,t]};return t.type==="Slice"?{type:"Projection",children:[r,this._parseProjectionRHS(h.Star)]}:r},_parseSliceExpression:function(){for(var e=[null,null,null],t=0,r=this._lookahead(0);r!==P&&t<3;){if(r===A)t++,this._advance();else if(r===q)e[t]=this._lookaheadToken(0).value,this._advance();else{var n=this._lookahead(0),i=new Error("Syntax error, unexpected token: "+n.value+"("+n.type+")");throw i.name="Parsererror",i}r=this._lookahead(0)}return this._match(P),{type:"Slice",children:e}},_parseComparator:function(e,t){var r=this.expression(h[t]);return{type:"Comparator",name:t,children:[e,r]}},_parseDotRHS:function(e){var t=this._lookahead(0),r=[J,$,F];if(r.indexOf(t)>=0)return this.expression(e);if(t===U)return this._match(U),this._parseMultiselectList();if(t===X)return this._match(X),this._parseMultiselectHash()},_parseProjectionRHS:function(e){var t;if(h[this._lookahead(0)]<10)t={type:"Identity"};else if(this._lookahead(0)===U)t=this.expression(e);else if(this._lookahead(0)===G)t=this.expression(e);else if(this._lookahead(0)===W)this._match(W),t=this._parseDotRHS(e);else{var r=this._lookaheadToken(0),n=new Error("Sytanx error, unexpected token: "+r.value+"("+r.type+")");throw n.name="ParserError",n}return t},_parseMultiselectList:function(){for(var e=[];this._lookahead(0)!==P;){var t=this.expression(0);if(e.push(t),this._lookahead(0)===j&&(this._match(j),this._lookahead(0)===P))throw new Error("Unexpected token Rbracket")}return this._match(P),{type:"MultiSelectList",children:e}},_parseMultiselectHash:function(){for(var e=[],t=[J,$],r,n,i,s;;){if(r=this._lookaheadToken(0),t.indexOf(r.type)<0)throw new Error("Expecting an identifier token, got: "+r.type);if(n=r.value,this._advance(),this._match(A),i=this.expression(0),s={type:"KeyValuePair",name:n,value:i},e.push(s),this._lookahead(0)===j)this._match(j);else if(this._lookahead(0)===ee){this._match(ee);break}}return{type:"MultiSelectHash",children:e}}};function Pe(e){this.runtime=e}Pe.prototype={search:function(e,t){return this.visit(e,t)},visit:function(e,t){var r,n,i,s,f,g,O,M,T,o;switch(e.type){case"Field":return t!==null&&u(t)?(g=t[e.name],g===void 0?null:g):null;case"Subexpression":for(i=this.visit(e.children[0],t),o=1;o<e.children.length;o++)if(i=this.visit(e.children[1],i),i===null)return null;return i;case"IndexExpression":return O=this.visit(e.children[0],t),M=this.visit(e.children[1],O),M;case"Index":if(!a(t))return null;var b=e.value;return b<0&&(b=t.length+b),i=t[b],i===void 0&&(i=null),i;case"Slice":if(!a(t))return null;var Ge=e.children.slice(0),ge=this.computeSliceParams(t.length,Ge),Re=ge[0],Ie=ge[1],de=ge[2];if(i=[],de>0)for(o=Re;o<Ie;o+=de)i.push(t[o]);else for(o=Re;o>Ie;o+=de)i.push(t[o]);return i;case"Projection":var N=this.visit(e.children[0],t);if(!a(N))return null;for(T=[],o=0;o<N.length;o++)n=this.visit(e.children[1],N[o]),n!==null&&T.push(n);return T;case"ValueProjection":if(N=this.visit(e.children[0],t),!u(N))return null;T=[];var Me=E(N);for(o=0;o<Me.length;o++)n=this.visit(e.children[1],Me[o]),n!==null&&T.push(n);return T;case"FilterProjection":if(N=this.visit(e.children[0],t),!a(N))return null;var ke=[],be=[];for(o=0;o<N.length;o++)r=this.visit(e.children[2],N[o]),_(r)||ke.push(N[o]);for(var Se=0;Se<ke.length;Se++)n=this.visit(e.children[1],ke[Se]),n!==null&&be.push(n);return be;case"Comparator":switch(s=this.visit(e.children[0],t),f=this.visit(e.children[1],t),e.name){case te:i=p(s,f);break;case ae:i=!p(s,f);break;case re:i=s>f;break;case ie:i=s>=f;break;case ne:i=s<f;break;case se:i=s<=f;break;default:throw new Error("Unknown comparator: "+e.name)}return i;case K:var Te=this.visit(e.children[0],t);if(!a(Te))return null;var ue=[];for(o=0;o<Te.length;o++)n=Te[o],a(n)?ue.push.apply(ue,n):ue.push(n);return ue;case"Identity":return t;case"MultiSelectList":if(t===null)return null;for(T=[],o=0;o<e.children.length;o++)T.push(this.visit(e.children[o],t));return T;case"MultiSelectHash":if(t===null)return null;T={};var Ee;for(o=0;o<e.children.length;o++)Ee=e.children[o],T[Ee.name]=this.visit(Ee.value,t);return T;case"OrExpression":return r=this.visit(e.children[0],t),_(r)&&(r=this.visit(e.children[1],t)),r;case"AndExpression":return s=this.visit(e.children[0],t),_(s)===!0?s:this.visit(e.children[1],t);case"NotExpression":return s=this.visit(e.children[0],t),_(s);case"Literal":return e.value;case Q:return O=this.visit(e.children[0],t),this.visit(e.children[1],O);case I:return t;case"Function":var Le=[];for(o=0;o<e.children.length;o++)Le.push(this.visit(e.children[o],t));return this.runtime.callFunction(e.name,Le);case"ExpressionReference":var je=e.children[0];return je.jmespathType=z,je;default:throw new Error("Unknown node type: "+e.type)}},computeSliceParams:function(e,t){var r=t[0],n=t[1],i=t[2],s=[null,null,null];if(i===null)i=1;else if(i===0){var f=new Error("Invalid slice, step cannot be 0");throw f.name="RuntimeError",f}var g=i<0;return r===null?r=g?e-1:0:r=this.capSliceRange(e,r,i),n===null?n=g?-1:e:n=this.capSliceRange(e,n,i),s[0]=r,s[1]=n,s[2]=i,s},capSliceRange:function(e,t,r){return t<0?(t+=e,t<0&&(t=r<0?-1:0)):t>=e&&(t=r<0?e-1:e),t}};function Ne(e){this._interpreter=e,this.functionTable={abs:{_func:this._functionAbs,_signature:[{types:[S]}]},avg:{_func:this._functionAvg,_signature:[{types:[v]}]},ceil:{_func:this._functionCeil,_signature:[{types:[S]}]},contains:{_func:this._functionContains,_signature:[{types:[l,y]},{types:[C]}]},ends_with:{_func:this._functionEndsWith,_signature:[{types:[l]},{types:[l]}]},floor:{_func:this._functionFloor,_signature:[{types:[S]}]},length:{_func:this._functionLength,_signature:[{types:[l,y,k]}]},map:{_func:this._functionMap,_signature:[{types:[x]},{types:[y]}]},max:{_func:this._functionMax,_signature:[{types:[v,m]}]},merge:{_func:this._functionMerge,_signature:[{types:[k],variadic:!0}]},max_by:{_func:this._functionMaxBy,_signature:[{types:[y]},{types:[x]}]},sum:{_func:this._functionSum,_signature:[{types:[v]}]},starts_with:{_func:this._functionStartsWith,_signature:[{types:[l]},{types:[l]}]},min:{_func:this._functionMin,_signature:[{types:[v,m]}]},min_by:{_func:this._functionMinBy,_signature:[{types:[y]},{types:[x]}]},type:{_func:this._functionType,_signature:[{types:[C]}]},keys:{_func:this._functionKeys,_signature:[{types:[k]}]},values:{_func:this._functionValues,_signature:[{types:[k]}]},sort:{_func:this._functionSort,_signature:[{types:[m,v]}]},sort_by:{_func:this._functionSortBy,_signature:[{types:[y]},{types:[x]}]},join:{_func:this._functionJoin,_signature:[{types:[l]},{types:[m]}]},reverse:{_func:this._functionReverse,_signature:[{types:[l,y]}]},to_array:{_func:this._functionToArray,_signature:[{types:[C]}]},to_string:{_func:this._functionToString,_signature:[{types:[C]}]},to_number:{_func:this._functionToNumber,_signature:[{types:[C]}]},not_null:{_func:this._functionNotNull,_signature:[{types:[C],variadic:!0}]}}}Ne.prototype={callFunction:function(e,t){var r=this.functionTable[e];if(r===void 0)throw new Error("Unknown function: "+e+"()");return this._validateArgs(e,t,r._signature),r._func.call(this,t)},_validateArgs:function(e,t,r){var n;if(r[r.length-1].variadic){if(t.length<r.length)throw n=r.length===1?" argument":" arguments",new Error("ArgumentError: "+e+"() takes at least"+r.length+n+" but received "+t.length)}else if(t.length!==r.length)throw n=r.length===1?" argument":" arguments",new Error("ArgumentError: "+e+"() takes "+r.length+n+" but received "+t.length);for(var i,s,f,g=0;g<r.length;g++){f=!1,i=r[g].types,s=this._getTypeName(t[g]);for(var O=0;O<i.length;O++)if(this._typeMatches(s,i[O],t[g])){f=!0;break}if(!f){var M=i.map(function(T){return D[T]}).join(",");throw new Error("TypeError: "+e+"() expected argument "+(g+1)+" to be type "+M+" but received type "+D[s]+" instead.")}}},_typeMatches:function(e,t,r){if(t===C)return!0;if(t===m||t===v||t===y){if(t===y)return e===y;if(e===y){var n;t===v?n=S:t===m&&(n=l);for(var i=0;i<r.length;i++)if(!this._typeMatches(this._getTypeName(r[i]),n,r[i]))return!1;return!0}}else return e===t},_getTypeName:function(e){switch(Object.prototype.toString.call(e)){case"[object String]":return l;case"[object Number]":return S;case"[object Array]":return y;case"[object Boolean]":return w;case"[object Null]":return B;case"[object Object]":return e.jmespathType===z?x:k}},_functionStartsWith:function(e){return e[0].lastIndexOf(e[1])===0},_functionEndsWith:function(e){var t=e[0],r=e[1];return t.indexOf(r,t.length-r.length)!==-1},_functionReverse:function(e){var t=this._getTypeName(e[0]);if(t===l){for(var r=e[0],n="",i=r.length-1;i>=0;i--)n+=r[i];return n}else{var s=e[0].slice(0);return s.reverse(),s}},_functionAbs:function(e){return Math.abs(e[0])},_functionCeil:function(e){return Math.ceil(e[0])},_functionAvg:function(e){for(var t=0,r=e[0],n=0;n<r.length;n++)t+=r[n];return t/r.length},_functionContains:function(e){return e[0].indexOf(e[1])>=0},_functionFloor:function(e){return Math.floor(e[0])},_functionLength:function(e){return u(e[0])?Object.keys(e[0]).length:e[0].length},_functionMap:function(e){for(var t=[],r=this._interpreter,n=e[0],i=e[1],s=0;s<i.length;s++)t.push(r.visit(n,i[s]));return t},_functionMerge:function(e){for(var t={},r=0;r<e.length;r++){var n=e[r];for(var i in n)t[i]=n[i]}return t},_functionMax:function(e){if(e[0].length>0){var t=this._getTypeName(e[0][0]);if(t===S)return Math.max.apply(Math,e[0]);for(var r=e[0],n=r[0],i=1;i<r.length;i++)n.localeCompare(r[i])<0&&(n=r[i]);return n}else return null},_functionMin:function(e){if(e[0].length>0){var t=this._getTypeName(e[0][0]);if(t===S)return Math.min.apply(Math,e[0]);for(var r=e[0],n=r[0],i=1;i<r.length;i++)r[i].localeCompare(n)<0&&(n=r[i]);return n}else return null},_functionSum:function(e){for(var t=0,r=e[0],n=0;n<r.length;n++)t+=r[n];return t},_functionType:function(e){switch(this._getTypeName(e[0])){case S:return"number";case l:return"string";case y:return"array";case k:return"object";case w:return"boolean";case x:return"expref";case B:return"null"}},_functionKeys:function(e){return Object.keys(e[0])},_functionValues:function(e){for(var t=e[0],r=Object.keys(t),n=[],i=0;i<r.length;i++)n.push(t[r[i]]);return n},_functionJoin:function(e){var t=e[0],r=e[1];return r.join(t)},_functionToArray:function(e){return this._getTypeName(e[0])===y?e[0]:[e[0]]},_functionToString:function(e){return this._getTypeName(e[0])===l?e[0]:JSON.stringify(e[0])},_functionToNumber:function(e){var t=this._getTypeName(e[0]),r;return t===S?e[0]:t===l&&(r=+e[0],!isNaN(r))?r:null},_functionNotNull:function(e){for(var t=0;t<e.length;t++)if(this._getTypeName(e[t])!==B)return e[t];return null},_functionSort:function(e){var t=e[0].slice(0);return t.sort(),t},_functionSortBy:function(e){var t=e[0].slice(0);if(t.length===0)return t;var r=this._interpreter,n=e[1],i=this._getTypeName(r.visit(n,t[0]));if([S,l].indexOf(i)<0)throw new Error("TypeError");for(var s=this,f=[],g=0;g<t.length;g++)f.push([g,t[g]]);f.sort(function(M,T){var o=r.visit(n,M[1]),b=r.visit(n,T[1]);if(s._getTypeName(o)!==i)throw new Error("TypeError: expected "+i+", received "+s._getTypeName(o));if(s._getTypeName(b)!==i)throw new Error("TypeError: expected "+i+", received "+s._getTypeName(b));return o>b?1:o<b?-1:M[0]-T[0]});for(var O=0;O<f.length;O++)t[O]=f[O][1];return t},_functionMaxBy:function(e){for(var t=e[1],r=e[0],n=this.createKeyFunction(t,[S,l]),i=-1/0,s,f,g=0;g<r.length;g++)f=n(r[g]),f>i&&(i=f,s=r[g]);return s},_functionMinBy:function(e){for(var t=e[1],r=e[0],n=this.createKeyFunction(t,[S,l]),i=1/0,s,f,g=0;g<r.length;g++)f=n(r[g]),f<i&&(i=f,s=r[g]);return s},createKeyFunction:function(e,t){var r=this,n=this._interpreter,i=function(s){var f=n.visit(e,s);if(t.indexOf(r._getTypeName(f))<0){var g="TypeError: expected one of "+t+", received "+r._getTypeName(f);throw new Error(g)}return f};return i}};function qe(e){var t=new ye,r=t.parse(e);return r}function ze(e){var t=new ve;return t.tokenize(e)}function Qe(e,t){var r=new ye,n=new Ne,i=new Pe(n);n._interpreter=i;var s=r.parse(t);return i.search(s,e)}c.tokenize=ze,c.compile=qe,c.search=Qe,c.strictDeepEqual=p})(typeof ce>"u"?ce.jmespath={}:ce)});var ut={};rt(ut,{createAsyncClient:()=>at,createSyncClient:()=>De});var Ue=nt(Ae(),1),Fe=new Map;function st(c,a){let[u,p,..._]=c.split("-");if(a==="production")return`https://pub.sleekcms.com/${p}`;if(a==="development")return`https://pub.sleekcms.net/${p}`;if(a==="localhost")return`http://localhost:9001/localhost/${p}`;throw new Error(`[SleekCMS] Unknown devEnv: ${a}`)}function Be(c,a){return a?Ue.search(c,a):c}function V({siteToken:c,env:a,search:u,lang:p,devEnv:_="production"}){let E=st(c,_).replace(/\/$/,""),d=new URL(`${E}/${a??"latest"}`);return u&&d.searchParams.append("search",u),p&&d.searchParams.append("lang",p),d.toString()}async function me({siteToken:c,env:a}){let u=V({siteToken:c,env:a});try{let p=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c}});if(p.ok){let _=await p.json();if(_.tag)return _.tag}}catch{console.error("[SleekCMS] Unable to resolve env tag.")}return a}async function L(c){let{siteToken:a,env:u="latest",resolveEnv:p=!1,search:_,lang:E,cache:d,cacheMinutes:R}=c,S=V({siteToken:a,env:u,search:_,lang:E});if(p){let y=`${a}:${u}`,k=Fe.get(y);try{k||(k=await me({siteToken:a,env:u}),Fe.set(y,k)),S=V({siteToken:a,env:k,search:_,lang:E})}catch{console.warn("[SleekCMS] Failed to resolve env tag, using cached content instead.")}}let C=S,l=async()=>{let y=await fetch(S,{method:"GET",headers:{"Content-Type":"application/json",Authorization:a}});if(!y.ok){let w=y.statusText;try{let x=await y.json();x&&x.message&&(w=x.message)}catch{}throw new Error(`[SleekCMS] Request failed (${y.status}): ${w}`)}let k=await y.json();if(d)try{let w={data:k,_ts:Date.now()};await Promise.resolve(d.setItem(C,JSON.stringify(w)))}catch(w){console.warn("[SleekCMS] Cache write failed:",w)}return k};if(d)try{let y=await Promise.resolve(d.getItem(C));if(y)try{let k=JSON.parse(y);if(k._ts!==void 0){if(R){let w=Date.now(),x=R*60*1e3;if(w-k._ts>=x)try{return await l()}catch(v){console.warn("[SleekCMS] Fetch failed, using expired cache:",v)}}return k.data}else return k}catch{}}catch(y){console.warn("[SleekCMS] Cache read failed:",y)}return await l()}function we(c,a){let u=[],p=c??[];for(let _ of p)(typeof _._path=="string"?_._path:"").startsWith(a)&&"_slug"in _&&typeof _._slug=="string"&&u.push(_._slug);return u}function xe(c,a){return(c??[]).filter(p=>(typeof p._path=="string"?p._path:"").startsWith(a))}var he=class{cache=new Map;getItem(a){return this.cache.get(a)??null}setItem(a,u){this.cache.set(a,u)}};async function De(c){let a=c.cache??new he,u=await L({...c,cache:a});function p(l){return Be(u,l)}function _(l){if(!l)throw new Error("[SleekCMS] path is required for getPages");return xe(u.pages,l)}function E(l){if(!l)throw new Error("[SleekCMS] path is required for getPage");return(u.pages??[]).find(w=>(typeof w._path=="string"?w._path:"")===l)??null}function d(l){if(!l)throw new Error("[SleekCMS] handle is required for getEntry");return(u.entries??{})[l]??null}function R(l){if(!l)throw new Error("[SleekCMS] path is required for getSlugs");return we(u.pages,l)}function S(l){return l&&u.images?u.images[l]:null}function C(l){if(!l)return null;let k=(u.options??{})[l];return Array.isArray(k)?k:null}return{getContent:p,getPages:_,getPage:E,getEntry:d,getSlugs:R,getImage:S,getOptions:C}}function at(c){let{siteToken:a,env:u="latest",resolveEnv:p,lang:_}=c,E=c.cache??new he,d=null;async function R(v){return!v&&!d&&(d=await De({siteToken:a,env:u,resolveEnv:p,lang:_,cache:E})),d?d.getContent(v):v?await L({siteToken:a,env:u,search:v,lang:_,cache:E,resolveEnv:p}):null}async function S(v){if(d)return d.getPages(v);let m=await L({siteToken:a,env:u,search:"pages",lang:_,cache:E,resolveEnv:p});return v?xe(m,v):m}async function C(v){return d?d.getPage(v):(await L({siteToken:a,env:u,search:"pages",lang:_,cache:E,resolveEnv:p}))?.find(H=>(typeof H._path=="string"?H._path:"")===v)??null}async function l(v){if(d)return d.getEntry(v);let m=`entries.${v}`;return await L({siteToken:a,env:u,search:m,lang:_,cache:E,resolveEnv:p})}async function y(v){if(d)return d.getSlugs(v);let m=await L({siteToken:a,env:u,search:"pages",lang:_,cache:E,resolveEnv:p});return we(m,v)}async function k(v){if(d)return d.getImage(v);let m=await L({siteToken:a,env:u,search:"images",lang:_,cache:E,resolveEnv:p});return m?m[v]:null}async function w(v){if(d)return d.getOptions(v);let D=(await L({siteToken:a,env:u,search:"options",lang:_,cache:E,resolveEnv:p}))[v];return Array.isArray(D)?D:null}async function x(){return await me({siteToken:a,env:u})}function B(){return V(c)}return{getContent:R,getPages:S,getPage:C,getEntry:l,getSlugs:y,getImage:k,getOptions:w,_getFetchUrl:B,_getEnvTag:x}}return it(ut);})();
|
|
1
|
+
var SleekCMS=(()=>{var We=Object.create;var oe=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var tt=(c,s)=>()=>(s||c((s={exports:{}}).exports,s),s.exports),rt=(c,s)=>{for(var u in s)oe(c,u,{get:s[u],enumerable:!0})},Ke=(c,s,u,_)=>{if(s&&typeof s=="object"||typeof s=="function")for(let p of Ze(s))!et.call(c,p)&&p!==u&&oe(c,p,{get:()=>s[p],enumerable:!(_=Xe(s,p))||_.enumerable});return c};var nt=(c,s,u)=>(u=c!=null?We(Ve(c)):{},Ke(s||!c||!c.__esModule?oe(u,"default",{value:c,enumerable:!0}):u,c)),it=c=>Ke(oe({},"__esModule",{value:!0}),c);var Ae=tt(ce=>{(function(c){"use strict";function s(e){return e!==null?Object.prototype.toString.call(e)==="[object Array]":!1}function u(e){return e!==null?Object.prototype.toString.call(e)==="[object Object]":!1}function _(e,t){if(e===t)return!0;var r=Object.prototype.toString.call(e);if(r!==Object.prototype.toString.call(t))return!1;if(s(e)===!0){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(_(e[n],t[n])===!1)return!1;return!0}if(u(e)===!0){var i={};for(var a in e)if(hasOwnProperty.call(e,a)){if(_(e[a],t[a])===!1)return!1;i[a]=!0}for(var f in t)if(hasOwnProperty.call(t,f)&&i[f]!==!0)return!1;return!0}return!1}function p(e){if(e===""||e===!1||e===null)return!0;if(s(e)&&e.length===0)return!0;if(u(e)){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}else return!1}function S(e){for(var t=Object.keys(e),r=[],n=0;n<t.length;n++)r.push(e[t[n]]);return r}function d(e,t){var r={};for(var n in e)r[n]=e[n];for(var i in t)r[i]=t[i];return r}var R;typeof String.prototype.trimLeft=="function"?R=function(e){return e.trimLeft()}:R=function(e){return e.match(/^\s*(.*)/)[1]};var T=0,P=1,l=2,v=3,k=4,w=5,O=6,D=7,y=8,m=9,j={0:"number",1:"any",2:"string",3:"array",4:"object",5:"boolean",6:"expression",7:"null",8:"Array<number>",9:"Array<string>"},H="EOF",J="UnquotedIdentifier",$="QuotedIdentifier",C="Rbracket",Y="Rparen",K="Comma",F="Colon",ee="Rbrace",G="Number",I="Current",q="Expref",z="Pipe",le="Or",fe="And",te="EQ",re="GT",ne="LT",ie="GTE",se="LTE",ae="NE",A="Flatten",U="Star",Q="Filter",W="Dot",pe="Not",X="Lbrace",B="Lbracket",Z="Lparen",_e="Literal",xe={".":W,"*":U,",":K,":":F,"{":X,"}":ee,"]":C,"(":Z,")":Y,"@":I},He={"<":!0,">":!0,"=":!0,"!":!0},Je={" ":!0," ":!0,"\n":!0};function Ye(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function Pe(e){return e>="0"&&e<="9"||e==="-"}function $e(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="_"}function ve(){}ve.prototype={tokenize:function(e){var t=[];this._current=0;for(var r,n,i;this._current<e.length;)if(Ye(e[this._current]))r=this._current,n=this._consumeUnquotedIdentifier(e),t.push({type:J,value:n,start:r});else if(xe[e[this._current]]!==void 0)t.push({type:xe[e[this._current]],value:e[this._current],start:this._current}),this._current++;else if(Pe(e[this._current]))i=this._consumeNumber(e),t.push(i);else if(e[this._current]==="[")i=this._consumeLBracket(e),t.push(i);else if(e[this._current]==='"')r=this._current,n=this._consumeQuotedIdentifier(e),t.push({type:$,value:n,start:r});else if(e[this._current]==="'")r=this._current,n=this._consumeRawStringLiteral(e),t.push({type:_e,value:n,start:r});else if(e[this._current]==="`"){r=this._current;var a=this._consumeLiteral(e);t.push({type:_e,value:a,start:r})}else if(He[e[this._current]]!==void 0)t.push(this._consumeOperator(e));else if(Je[e[this._current]]!==void 0)this._current++;else if(e[this._current]==="&")r=this._current,this._current++,e[this._current]==="&"?(this._current++,t.push({type:fe,value:"&&",start:r})):t.push({type:q,value:"&",start:r});else if(e[this._current]==="|")r=this._current,this._current++,e[this._current]==="|"?(this._current++,t.push({type:le,value:"||",start:r})):t.push({type:z,value:"|",start:r});else{var f=new Error("Unknown character:"+e[this._current]);throw f.name="LexerError",f}return t},_consumeUnquotedIdentifier:function(e){var t=this._current;for(this._current++;this._current<e.length&&$e(e[this._current]);)this._current++;return e.slice(t,this._current)},_consumeQuotedIdentifier:function(e){var t=this._current;this._current++;for(var r=e.length;e[this._current]!=='"'&&this._current<r;){var n=this._current;e[n]==="\\"&&(e[n+1]==="\\"||e[n+1]==='"')?n+=2:n++,this._current=n}return this._current++,JSON.parse(e.slice(t,this._current))},_consumeRawStringLiteral:function(e){var t=this._current;this._current++;for(var r=e.length;e[this._current]!=="'"&&this._current<r;){var n=this._current;e[n]==="\\"&&(e[n+1]==="\\"||e[n+1]==="'")?n+=2:n++,this._current=n}this._current++;var i=e.slice(t+1,this._current-1);return i.replace("\\'","'")},_consumeNumber:function(e){var t=this._current;this._current++;for(var r=e.length;Pe(e[this._current])&&this._current<r;)this._current++;var n=parseInt(e.slice(t,this._current));return{type:G,value:n,start:t}},_consumeLBracket:function(e){var t=this._current;return this._current++,e[this._current]==="?"?(this._current++,{type:Q,value:"[?",start:t}):e[this._current]==="]"?(this._current++,{type:A,value:"[]",start:t}):{type:B,value:"[",start:t}},_consumeOperator:function(e){var t=this._current,r=e[t];if(this._current++,r==="!")return e[this._current]==="="?(this._current++,{type:ae,value:"!=",start:t}):{type:pe,value:"!",start:t};if(r==="<")return e[this._current]==="="?(this._current++,{type:se,value:"<=",start:t}):{type:ne,value:"<",start:t};if(r===">")return e[this._current]==="="?(this._current++,{type:ie,value:">=",start:t}):{type:re,value:">",start:t};if(r==="="&&e[this._current]==="=")return this._current++,{type:te,value:"==",start:t}},_consumeLiteral:function(e){this._current++;for(var t=this._current,r=e.length,n;e[this._current]!=="`"&&this._current<r;){var i=this._current;e[i]==="\\"&&(e[i+1]==="\\"||e[i+1]==="`")?i+=2:i++,this._current=i}var a=R(e.slice(t,this._current));return a=a.replace("\\`","`"),this._looksLikeJSON(a)?n=JSON.parse(a):n=JSON.parse('"'+a+'"'),this._current++,n},_looksLikeJSON:function(e){var t='[{"',r=["true","false","null"],n="-0123456789";if(e==="")return!1;if(t.indexOf(e[0])>=0)return!0;if(r.indexOf(e)>=0)return!0;if(n.indexOf(e[0])>=0)try{return JSON.parse(e),!0}catch{return!1}else return!1}};var h={};h[H]=0,h[J]=0,h[$]=0,h[C]=0,h[Y]=0,h[K]=0,h[ee]=0,h[G]=0,h[I]=0,h[q]=0,h[z]=1,h[le]=2,h[fe]=3,h[te]=5,h[re]=5,h[ne]=5,h[ie]=5,h[se]=5,h[ae]=5,h[A]=9,h[U]=20,h[Q]=21,h[W]=40,h[pe]=45,h[X]=50,h[B]=55,h[Z]=60;function ye(){}ye.prototype={parse:function(e){this._loadTokens(e),this.index=0;var t=this.expression(0);if(this._lookahead(0)!==H){var r=this._lookaheadToken(0),n=new Error("Unexpected token type: "+r.type+", value: "+r.value);throw n.name="ParserError",n}return t},_loadTokens:function(e){var t=new ve,r=t.tokenize(e);r.push({type:H,value:"",start:e.length}),this.tokens=r},expression:function(e){var t=this._lookaheadToken(0);this._advance();for(var r=this.nud(t),n=this._lookahead(0);e<h[n];)this._advance(),r=this.led(n,r),n=this._lookahead(0);return r},_lookahead:function(e){return this.tokens[this.index+e].type},_lookaheadToken:function(e){return this.tokens[this.index+e]},_advance:function(){this.index++},nud:function(e){var t,r,n;switch(e.type){case _e:return{type:"Literal",value:e.value};case J:return{type:"Field",name:e.value};case $:var i={type:"Field",name:e.value};if(this._lookahead(0)===Z)throw new Error("Quoted identifier not allowed for function names.");return i;case pe:return r=this.expression(h.Not),{type:"NotExpression",children:[r]};case U:return t={type:"Identity"},r=null,this._lookahead(0)===C?r={type:"Identity"}:r=this._parseProjectionRHS(h.Star),{type:"ValueProjection",children:[t,r]};case Q:return this.led(e.type,{type:"Identity"});case X:return this._parseMultiselectHash();case A:return t={type:A,children:[{type:"Identity"}]},r=this._parseProjectionRHS(h.Flatten),{type:"Projection",children:[t,r]};case B:return this._lookahead(0)===G||this._lookahead(0)===F?(r=this._parseIndexExpression(),this._projectIfSlice({type:"Identity"},r)):this._lookahead(0)===U&&this._lookahead(1)===C?(this._advance(),this._advance(),r=this._parseProjectionRHS(h.Star),{type:"Projection",children:[{type:"Identity"},r]}):this._parseMultiselectList();case I:return{type:I};case q:return n=this.expression(h.Expref),{type:"ExpressionReference",children:[n]};case Z:for(var a=[];this._lookahead(0)!==Y;)this._lookahead(0)===I?(n={type:I},this._advance()):n=this.expression(0),a.push(n);return this._match(Y),a[0];default:this._errorToken(e)}},led:function(e,t){var r;switch(e){case W:var n=h.Dot;return this._lookahead(0)!==U?(r=this._parseDotRHS(n),{type:"Subexpression",children:[t,r]}):(this._advance(),r=this._parseProjectionRHS(n),{type:"ValueProjection",children:[t,r]});case z:return r=this.expression(h.Pipe),{type:z,children:[t,r]};case le:return r=this.expression(h.Or),{type:"OrExpression",children:[t,r]};case fe:return r=this.expression(h.And),{type:"AndExpression",children:[t,r]};case Z:for(var i=t.name,a=[],f,g;this._lookahead(0)!==Y;)this._lookahead(0)===I?(f={type:I},this._advance()):f=this.expression(0),this._lookahead(0)===K&&this._match(K),a.push(f);return this._match(Y),g={type:"Function",name:i,children:a},g;case Q:var x=this.expression(0);return this._match(C),this._lookahead(0)===A?r={type:"Identity"}:r=this._parseProjectionRHS(h.Filter),{type:"FilterProjection",children:[t,r,x]};case A:var M={type:A,children:[t]},E=this._parseProjectionRHS(h.Flatten);return{type:"Projection",children:[M,E]};case te:case ae:case re:case ie:case ne:case se:return this._parseComparator(t,e);case B:var o=this._lookaheadToken(0);return o.type===G||o.type===F?(r=this._parseIndexExpression(),this._projectIfSlice(t,r)):(this._match(U),this._match(C),r=this._parseProjectionRHS(h.Star),{type:"Projection",children:[t,r]});default:this._errorToken(this._lookaheadToken(0))}},_match:function(e){if(this._lookahead(0)===e)this._advance();else{var t=this._lookaheadToken(0),r=new Error("Expected "+e+", got: "+t.type);throw r.name="ParserError",r}},_errorToken:function(e){var t=new Error("Invalid token ("+e.type+'): "'+e.value+'"');throw t.name="ParserError",t},_parseIndexExpression:function(){if(this._lookahead(0)===F||this._lookahead(1)===F)return this._parseSliceExpression();var e={type:"Index",value:this._lookaheadToken(0).value};return this._advance(),this._match(C),e},_projectIfSlice:function(e,t){var r={type:"IndexExpression",children:[e,t]};return t.type==="Slice"?{type:"Projection",children:[r,this._parseProjectionRHS(h.Star)]}:r},_parseSliceExpression:function(){for(var e=[null,null,null],t=0,r=this._lookahead(0);r!==C&&t<3;){if(r===F)t++,this._advance();else if(r===G)e[t]=this._lookaheadToken(0).value,this._advance();else{var n=this._lookahead(0),i=new Error("Syntax error, unexpected token: "+n.value+"("+n.type+")");throw i.name="Parsererror",i}r=this._lookahead(0)}return this._match(C),{type:"Slice",children:e}},_parseComparator:function(e,t){var r=this.expression(h[t]);return{type:"Comparator",name:t,children:[e,r]}},_parseDotRHS:function(e){var t=this._lookahead(0),r=[J,$,U];if(r.indexOf(t)>=0)return this.expression(e);if(t===B)return this._match(B),this._parseMultiselectList();if(t===X)return this._match(X),this._parseMultiselectHash()},_parseProjectionRHS:function(e){var t;if(h[this._lookahead(0)]<10)t={type:"Identity"};else if(this._lookahead(0)===B)t=this.expression(e);else if(this._lookahead(0)===Q)t=this.expression(e);else if(this._lookahead(0)===W)this._match(W),t=this._parseDotRHS(e);else{var r=this._lookaheadToken(0),n=new Error("Sytanx error, unexpected token: "+r.value+"("+r.type+")");throw n.name="ParserError",n}return t},_parseMultiselectList:function(){for(var e=[];this._lookahead(0)!==C;){var t=this.expression(0);if(e.push(t),this._lookahead(0)===K&&(this._match(K),this._lookahead(0)===C))throw new Error("Unexpected token Rbracket")}return this._match(C),{type:"MultiSelectList",children:e}},_parseMultiselectHash:function(){for(var e=[],t=[J,$],r,n,i,a;;){if(r=this._lookaheadToken(0),t.indexOf(r.type)<0)throw new Error("Expecting an identifier token, got: "+r.type);if(n=r.value,this._advance(),this._match(F),i=this.expression(0),a={type:"KeyValuePair",name:n,value:i},e.push(a),this._lookahead(0)===K)this._match(K);else if(this._lookahead(0)===ee){this._match(ee);break}}return{type:"MultiSelectHash",children:e}}};function Ce(e){this.runtime=e}Ce.prototype={search:function(e,t){return this.visit(e,t)},visit:function(e,t){var r,n,i,a,f,g,x,M,E,o;switch(e.type){case"Field":return t!==null&&u(t)?(g=t[e.name],g===void 0?null:g):null;case"Subexpression":for(i=this.visit(e.children[0],t),o=1;o<e.children.length;o++)if(i=this.visit(e.children[1],i),i===null)return null;return i;case"IndexExpression":return x=this.visit(e.children[0],t),M=this.visit(e.children[1],x),M;case"Index":if(!s(t))return null;var b=e.value;return b<0&&(b=t.length+b),i=t[b],i===void 0&&(i=null),i;case"Slice":if(!s(t))return null;var Qe=e.children.slice(0),ge=this.computeSliceParams(t.length,Qe),Re=ge[0],Ie=ge[1],de=ge[2];if(i=[],de>0)for(o=Re;o<Ie;o+=de)i.push(t[o]);else for(o=Re;o>Ie;o+=de)i.push(t[o]);return i;case"Projection":var N=this.visit(e.children[0],t);if(!s(N))return null;for(E=[],o=0;o<N.length;o++)n=this.visit(e.children[1],N[o]),n!==null&&E.push(n);return E;case"ValueProjection":if(N=this.visit(e.children[0],t),!u(N))return null;E=[];var Me=S(N);for(o=0;o<Me.length;o++)n=this.visit(e.children[1],Me[o]),n!==null&&E.push(n);return E;case"FilterProjection":if(N=this.visit(e.children[0],t),!s(N))return null;var ke=[],be=[];for(o=0;o<N.length;o++)r=this.visit(e.children[2],N[o]),p(r)||ke.push(N[o]);for(var Se=0;Se<ke.length;Se++)n=this.visit(e.children[1],ke[Se]),n!==null&&be.push(n);return be;case"Comparator":switch(a=this.visit(e.children[0],t),f=this.visit(e.children[1],t),e.name){case te:i=_(a,f);break;case ae:i=!_(a,f);break;case re:i=a>f;break;case ie:i=a>=f;break;case ne:i=a<f;break;case se:i=a<=f;break;default:throw new Error("Unknown comparator: "+e.name)}return i;case A:var Te=this.visit(e.children[0],t);if(!s(Te))return null;var ue=[];for(o=0;o<Te.length;o++)n=Te[o],s(n)?ue.push.apply(ue,n):ue.push(n);return ue;case"Identity":return t;case"MultiSelectList":if(t===null)return null;for(E=[],o=0;o<e.children.length;o++)E.push(this.visit(e.children[o],t));return E;case"MultiSelectHash":if(t===null)return null;E={};var Ee;for(o=0;o<e.children.length;o++)Ee=e.children[o],E[Ee.name]=this.visit(Ee.value,t);return E;case"OrExpression":return r=this.visit(e.children[0],t),p(r)&&(r=this.visit(e.children[1],t)),r;case"AndExpression":return a=this.visit(e.children[0],t),p(a)===!0?a:this.visit(e.children[1],t);case"NotExpression":return a=this.visit(e.children[0],t),p(a);case"Literal":return e.value;case z:return x=this.visit(e.children[0],t),this.visit(e.children[1],x);case I:return t;case"Function":var Le=[];for(o=0;o<e.children.length;o++)Le.push(this.visit(e.children[o],t));return this.runtime.callFunction(e.name,Le);case"ExpressionReference":var je=e.children[0];return je.jmespathType=q,je;default:throw new Error("Unknown node type: "+e.type)}},computeSliceParams:function(e,t){var r=t[0],n=t[1],i=t[2],a=[null,null,null];if(i===null)i=1;else if(i===0){var f=new Error("Invalid slice, step cannot be 0");throw f.name="RuntimeError",f}var g=i<0;return r===null?r=g?e-1:0:r=this.capSliceRange(e,r,i),n===null?n=g?-1:e:n=this.capSliceRange(e,n,i),a[0]=r,a[1]=n,a[2]=i,a},capSliceRange:function(e,t,r){return t<0?(t+=e,t<0&&(t=r<0?-1:0)):t>=e&&(t=r<0?e-1:e),t}};function Ne(e){this._interpreter=e,this.functionTable={abs:{_func:this._functionAbs,_signature:[{types:[T]}]},avg:{_func:this._functionAvg,_signature:[{types:[y]}]},ceil:{_func:this._functionCeil,_signature:[{types:[T]}]},contains:{_func:this._functionContains,_signature:[{types:[l,v]},{types:[P]}]},ends_with:{_func:this._functionEndsWith,_signature:[{types:[l]},{types:[l]}]},floor:{_func:this._functionFloor,_signature:[{types:[T]}]},length:{_func:this._functionLength,_signature:[{types:[l,v,k]}]},map:{_func:this._functionMap,_signature:[{types:[O]},{types:[v]}]},max:{_func:this._functionMax,_signature:[{types:[y,m]}]},merge:{_func:this._functionMerge,_signature:[{types:[k],variadic:!0}]},max_by:{_func:this._functionMaxBy,_signature:[{types:[v]},{types:[O]}]},sum:{_func:this._functionSum,_signature:[{types:[y]}]},starts_with:{_func:this._functionStartsWith,_signature:[{types:[l]},{types:[l]}]},min:{_func:this._functionMin,_signature:[{types:[y,m]}]},min_by:{_func:this._functionMinBy,_signature:[{types:[v]},{types:[O]}]},type:{_func:this._functionType,_signature:[{types:[P]}]},keys:{_func:this._functionKeys,_signature:[{types:[k]}]},values:{_func:this._functionValues,_signature:[{types:[k]}]},sort:{_func:this._functionSort,_signature:[{types:[m,y]}]},sort_by:{_func:this._functionSortBy,_signature:[{types:[v]},{types:[O]}]},join:{_func:this._functionJoin,_signature:[{types:[l]},{types:[m]}]},reverse:{_func:this._functionReverse,_signature:[{types:[l,v]}]},to_array:{_func:this._functionToArray,_signature:[{types:[P]}]},to_string:{_func:this._functionToString,_signature:[{types:[P]}]},to_number:{_func:this._functionToNumber,_signature:[{types:[P]}]},not_null:{_func:this._functionNotNull,_signature:[{types:[P],variadic:!0}]}}}Ne.prototype={callFunction:function(e,t){var r=this.functionTable[e];if(r===void 0)throw new Error("Unknown function: "+e+"()");return this._validateArgs(e,t,r._signature),r._func.call(this,t)},_validateArgs:function(e,t,r){var n;if(r[r.length-1].variadic){if(t.length<r.length)throw n=r.length===1?" argument":" arguments",new Error("ArgumentError: "+e+"() takes at least"+r.length+n+" but received "+t.length)}else if(t.length!==r.length)throw n=r.length===1?" argument":" arguments",new Error("ArgumentError: "+e+"() takes "+r.length+n+" but received "+t.length);for(var i,a,f,g=0;g<r.length;g++){f=!1,i=r[g].types,a=this._getTypeName(t[g]);for(var x=0;x<i.length;x++)if(this._typeMatches(a,i[x],t[g])){f=!0;break}if(!f){var M=i.map(function(E){return j[E]}).join(",");throw new Error("TypeError: "+e+"() expected argument "+(g+1)+" to be type "+M+" but received type "+j[a]+" instead.")}}},_typeMatches:function(e,t,r){if(t===P)return!0;if(t===m||t===y||t===v){if(t===v)return e===v;if(e===v){var n;t===y?n=T:t===m&&(n=l);for(var i=0;i<r.length;i++)if(!this._typeMatches(this._getTypeName(r[i]),n,r[i]))return!1;return!0}}else return e===t},_getTypeName:function(e){switch(Object.prototype.toString.call(e)){case"[object String]":return l;case"[object Number]":return T;case"[object Array]":return v;case"[object Boolean]":return w;case"[object Null]":return D;case"[object Object]":return e.jmespathType===q?O:k}},_functionStartsWith:function(e){return e[0].lastIndexOf(e[1])===0},_functionEndsWith:function(e){var t=e[0],r=e[1];return t.indexOf(r,t.length-r.length)!==-1},_functionReverse:function(e){var t=this._getTypeName(e[0]);if(t===l){for(var r=e[0],n="",i=r.length-1;i>=0;i--)n+=r[i];return n}else{var a=e[0].slice(0);return a.reverse(),a}},_functionAbs:function(e){return Math.abs(e[0])},_functionCeil:function(e){return Math.ceil(e[0])},_functionAvg:function(e){for(var t=0,r=e[0],n=0;n<r.length;n++)t+=r[n];return t/r.length},_functionContains:function(e){return e[0].indexOf(e[1])>=0},_functionFloor:function(e){return Math.floor(e[0])},_functionLength:function(e){return u(e[0])?Object.keys(e[0]).length:e[0].length},_functionMap:function(e){for(var t=[],r=this._interpreter,n=e[0],i=e[1],a=0;a<i.length;a++)t.push(r.visit(n,i[a]));return t},_functionMerge:function(e){for(var t={},r=0;r<e.length;r++){var n=e[r];for(var i in n)t[i]=n[i]}return t},_functionMax:function(e){if(e[0].length>0){var t=this._getTypeName(e[0][0]);if(t===T)return Math.max.apply(Math,e[0]);for(var r=e[0],n=r[0],i=1;i<r.length;i++)n.localeCompare(r[i])<0&&(n=r[i]);return n}else return null},_functionMin:function(e){if(e[0].length>0){var t=this._getTypeName(e[0][0]);if(t===T)return Math.min.apply(Math,e[0]);for(var r=e[0],n=r[0],i=1;i<r.length;i++)r[i].localeCompare(n)<0&&(n=r[i]);return n}else return null},_functionSum:function(e){for(var t=0,r=e[0],n=0;n<r.length;n++)t+=r[n];return t},_functionType:function(e){switch(this._getTypeName(e[0])){case T:return"number";case l:return"string";case v:return"array";case k:return"object";case w:return"boolean";case O:return"expref";case D:return"null"}},_functionKeys:function(e){return Object.keys(e[0])},_functionValues:function(e){for(var t=e[0],r=Object.keys(t),n=[],i=0;i<r.length;i++)n.push(t[r[i]]);return n},_functionJoin:function(e){var t=e[0],r=e[1];return r.join(t)},_functionToArray:function(e){return this._getTypeName(e[0])===v?e[0]:[e[0]]},_functionToString:function(e){return this._getTypeName(e[0])===l?e[0]:JSON.stringify(e[0])},_functionToNumber:function(e){var t=this._getTypeName(e[0]),r;return t===T?e[0]:t===l&&(r=+e[0],!isNaN(r))?r:null},_functionNotNull:function(e){for(var t=0;t<e.length;t++)if(this._getTypeName(e[t])!==D)return e[t];return null},_functionSort:function(e){var t=e[0].slice(0);return t.sort(),t},_functionSortBy:function(e){var t=e[0].slice(0);if(t.length===0)return t;var r=this._interpreter,n=e[1],i=this._getTypeName(r.visit(n,t[0]));if([T,l].indexOf(i)<0)throw new Error("TypeError");for(var a=this,f=[],g=0;g<t.length;g++)f.push([g,t[g]]);f.sort(function(M,E){var o=r.visit(n,M[1]),b=r.visit(n,E[1]);if(a._getTypeName(o)!==i)throw new Error("TypeError: expected "+i+", received "+a._getTypeName(o));if(a._getTypeName(b)!==i)throw new Error("TypeError: expected "+i+", received "+a._getTypeName(b));return o>b?1:o<b?-1:M[0]-E[0]});for(var x=0;x<f.length;x++)t[x]=f[x][1];return t},_functionMaxBy:function(e){for(var t=e[1],r=e[0],n=this.createKeyFunction(t,[T,l]),i=-1/0,a,f,g=0;g<r.length;g++)f=n(r[g]),f>i&&(i=f,a=r[g]);return a},_functionMinBy:function(e){for(var t=e[1],r=e[0],n=this.createKeyFunction(t,[T,l]),i=1/0,a,f,g=0;g<r.length;g++)f=n(r[g]),f<i&&(i=f,a=r[g]);return a},createKeyFunction:function(e,t){var r=this,n=this._interpreter,i=function(a){var f=n.visit(e,a);if(t.indexOf(r._getTypeName(f))<0){var g="TypeError: expected one of "+t+", received "+r._getTypeName(f);throw new Error(g)}return f};return i}};function Ge(e){var t=new ye,r=t.parse(e);return r}function qe(e){var t=new ve;return t.tokenize(e)}function ze(e,t){var r=new ye,n=new Ne,i=new Ce(n);n._interpreter=i;var a=r.parse(t);return i.search(a,e)}c.tokenize=qe,c.compile=Ge,c.search=ze,c.strictDeepEqual=_})(typeof ce>"u"?ce.jmespath={}:ce)});var ut={};rt(ut,{createAsyncClient:()=>at,createSyncClient:()=>De});var Ue=nt(Ae(),1),Fe=new Map;function st(c,s){let[u,_,...p]=c.split("-");if(s==="production")return`https://pub.sleekcms.com/${_}`;if(s==="development")return`https://pub.sleekcms.net/${_}`;if(s==="localhost")return`http://localhost:9001/localhost/${_}`;throw new Error(`[SleekCMS] Unknown devEnv: ${s}`)}function Be(c,s){return s?Ue.search(c,s):c}function V({siteToken:c,env:s,search:u,lang:_,devEnv:p="production"}){let S=st(c,p).replace(/\/$/,""),d=new URL(`${S}/${s??"latest"}`);return u&&d.searchParams.append("search",u),_&&d.searchParams.append("lang",_),d.toString()}async function me({siteToken:c,env:s}){let u=V({siteToken:c,env:s});try{let _=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c}});if(_.ok){let p=await _.json();if(p.tag)return p.tag}}catch{console.error("[SleekCMS] Unable to resolve env tag.")}return s}async function L(c){let{siteToken:s,env:u="latest",resolveEnv:_=!1,search:p,lang:S,cache:d,cacheMinutes:R}=c,T=V({siteToken:s,env:u,search:p,lang:S});if(_){let v=`${s}:${u}`,k=Fe.get(v);try{k||(k=await me({siteToken:s,env:u}),Fe.set(v,k)),T=V({siteToken:s,env:k,search:p,lang:S})}catch{console.warn("[SleekCMS] Failed to resolve env tag, using cached content instead.")}}let P=T,l=async()=>{let v=await fetch(T,{method:"GET",headers:{"Content-Type":"application/json",Authorization:s}});if(!v.ok){let w=v.statusText;try{let O=await v.json();O&&O.message&&(w=O.message)}catch{}throw new Error(`[SleekCMS] Request failed (${v.status}): ${w}`)}let k=await v.json();if(d)try{let w={data:k,_ts:Date.now()};await Promise.resolve(d.setItem(P,JSON.stringify(w)))}catch(w){console.warn("[SleekCMS] Cache write failed:",w)}return k};if(d)try{let v=await Promise.resolve(d.getItem(P));if(v)try{let k=JSON.parse(v);if(k._ts!==void 0){if(R){let w=Date.now(),O=R*60*1e3;if(w-k._ts>=O)try{return await l()}catch(y){console.warn("[SleekCMS] Fetch failed, using expired cache:",y)}}return k.data}else return k}catch{}}catch(v){console.warn("[SleekCMS] Cache read failed:",v)}return await l()}function we(c,s){let u=[],_=c??[];for(let p of _)(typeof p._path=="string"?p._path:"").startsWith(s)&&"_slug"in p&&typeof p._slug=="string"&&u.push(p._slug);return u}function Oe(c,s,u){return(c??[]).filter(p=>{let S=typeof p._path=="string"?p._path:"";return!(s&&!S.startsWith(s)||u?.collection&&!("_slug"in p))})}var he=class{cache=new Map;getItem(s){return this.cache.get(s)??null}setItem(s,u){this.cache.set(s,u)}};async function De(c){let s=c.cache??new he,u=await L({...c,cache:s});function _(l){return Be(u,l)}function p(l,v){if(!l)throw new Error("[SleekCMS] path is required for getPages");return Oe(u.pages,l,v)}function S(l){if(!l)throw new Error("[SleekCMS] path is required for getPage");return(u.pages??[]).find(w=>(typeof w._path=="string"?w._path:"")===l)??null}function d(l){if(!l)throw new Error("[SleekCMS] handle is required for getEntry");return(u.entries??{})[l]??null}function R(l){if(!l)throw new Error("[SleekCMS] path is required for getSlugs");return we(u.pages,l)}function T(l){return l&&u.images?u.images[l]:null}function P(l){if(!l)return null;let k=(u.options??{})[l];return Array.isArray(k)?k:null}return{getContent:_,getPages:p,getPage:S,getEntry:d,getSlugs:R,getImage:T,getOptions:P}}function at(c){let{siteToken:s,env:u="latest",resolveEnv:_,lang:p}=c,S=c.cache??new he,d=null;async function R(y){return!y&&!d&&(d=await De({siteToken:s,env:u,resolveEnv:_,lang:p,cache:S})),d?d.getContent(y):y?await L({siteToken:s,env:u,search:y,lang:p,cache:S,resolveEnv:_}):null}async function T(y,m){if(d)return d.getPages(y,m);let j=await L({siteToken:s,env:u,search:"pages",lang:p,cache:S,resolveEnv:_});return Oe(j,y,m)}async function P(y){return d?d.getPage(y):(await L({siteToken:s,env:u,search:"pages",lang:p,cache:S,resolveEnv:_}))?.find(H=>(typeof H._path=="string"?H._path:"")===y)??null}async function l(y){if(d)return d.getEntry(y);let m=`entries.${y}`;return await L({siteToken:s,env:u,search:m,lang:p,cache:S,resolveEnv:_})}async function v(y){if(d)return d.getSlugs(y);let m=await L({siteToken:s,env:u,search:"pages",lang:p,cache:S,resolveEnv:_});return we(m,y)}async function k(y){if(d)return d.getImage(y);let m=await L({siteToken:s,env:u,search:"images",lang:p,cache:S,resolveEnv:_});return m?m[y]:null}async function w(y){if(d)return d.getOptions(y);let j=(await L({siteToken:s,env:u,search:"options",lang:p,cache:S,resolveEnv:_}))[y];return Array.isArray(j)?j:null}async function O(){return await me({siteToken:s,env:u})}function D(){return V(c)}return{getContent:R,getPages:T,getPage:P,getEntry:l,getSlugs:v,getImage:k,getOptions:w,_getFetchUrl:D,_getEnvTag:O}}return it(ut);})();
|
|
2
2
|
//# sourceMappingURL=index.global.min.js.map
|