1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[702],{16496:function(t,e,n){n.d(e,{t:function(){return a}});var r=["Value","Copy","Blank","ReturnIntoArray","ReturnIntoObject","ReturnIntoObjectSameKey","PushField","PushElement","PushParent","Pop","PushFieldCopy","PushFieldBlank","PushElementCopy","PushElementBlank","ReturnIntoObjectPop","ReturnIntoObjectSameKeyPop","ReturnIntoArrayPop","ObjectSetFieldValue","ObjectCopyField","ObjectDeleteField","ArrayAppendValue","ArrayAppendSlice","StringAppendString","StringAppendSlice"],a=function(){function t(t,e,n){this.i=0,this.inputStack=[],this.outputStack=[],this.model=t,this.root=e,this.patch=n}return t.prototype.read=function(){return this.patch[this.i++]},t.prototype.process=function(){for(this.inputStack.push({value:this.root}),this.outputStack.push({value:this.root});this.i<this.patch.length;){var t=this.read(),e=r[t];if(!e)throw new Error("Unknown opcode: "+t);this["process"+e].apply(this)}var n=this.outputStack.pop();return this.finalizeOutput(n)},t.prototype.inputEntry=function(){return this.inputStack[this.inputStack.length-1]},t.prototype.inputKey=function(t,e){return t.keys||(t.keys=this.model.objectGetKeys(t.value).sort()),t.keys[e]},t.prototype.outputEntry=function(){return this.outputStack[this.outputStack.length-1]},t.prototype.outputArray=function(){var t=this.outputEntry();return t.writeValue||(t.writeValue=this.model.copyArray(t.value)),t.writeValue},t.prototype.outputObject=function(){var t=this.outputEntry();return t.writeValue||(t.writeValue=this.model.copyObject(t.value)),t.writeValue},t.prototype.outputString=function(){var t=this.outputEntry();return t.writeValue||(t.writeValue=this.model.copyString(t.value)),t.writeValue},t.prototype.finalizeOutput=function(t){return t.writeValue?this.model.finalize(t.writeValue):t.value},t.prototype.processValue=function(){var t=this.model.wrap(this.read());this.outputStack.push({value:t})},t.prototype.processCopy=function(){var t=this.inputEntry();this.outputStack.push({value:t.value})},t.prototype.processBlank=function(){this.outputStack.push({value:null})},t.prototype.processReturnIntoArray=function(){var t=this.outputStack.pop(),e=this.finalizeOutput(t),n=this.outputArray();this.model.arrayAppendValue(n,e)},t.prototype.processReturnIntoObject=function(){var t=this.read(),e=this.outputStack.pop(),n=this.finalizeOutput(e);n=this.model.markChanged(n);var r=this.outputObject();this.model.objectSetField(r,t,n)},t.prototype.processReturnIntoObjectSameKey=function(){var t=this.inputEntry(),e=this.outputStack.pop(),n=this.finalizeOutput(e),r=this.outputObject();this.model.objectSetField(r,t.key,n)},t.prototype.processPushField=function(){var t=this.read(),e=this.inputEntry(),n=this.inputKey(e,t),r=this.model.objectGetField(e.value,n);this.inputStack.push({value:r,key:n})},t.prototype.processPushElement=function(){var t=this.read(),e=this.inputEntry(),n=this.model.arrayGetElement(e.value,t);this.inputStack.push({value:n})},t.prototype.processPop=function(){this.inputStack.pop()},t.prototype.processPushFieldCopy=function(){this.processPushField(),this.processCopy()},t.prototype.processPushFieldBlank=function(){this.processPushField(),this.processBlank()},t.prototype.processPushElementCopy=function(){this.processPushElement(),this.processCopy()},t.prototype.processPushElementBlank=function(){this.processPushElement(),this.processBlank()},t.prototype.processReturnIntoObjectPop=function(){this.processReturnIntoObject(),this.processPop()},t.prototype.processReturnIntoObjectSameKeyPop=function(){this.processReturnIntoObjectSameKey(),this.processPop()},t.prototype.processReturnIntoArrayPop=function(){this.processReturnIntoArray(),this.processPop()},t.prototype.processObjectSetFieldValue=function(){this.processValue(),this.processReturnIntoObject()},t.prototype.processObjectCopyField=function(){this.processPushField(),this.processCopy(),this.processReturnIntoObjectSameKey(),this.processPop()},t.prototype.processObjectDeleteField=function(){var t=this.read(),e=this.inputEntry(),n=this.inputKey(e,t),r=this.outputObject();this.model.objectDeleteField(r,n)},t.prototype.processArrayAppendValue=function(){var t=this.model.wrap(this.read()),e=this.outputArray();this.model.arrayAppendValue(e,t)},t.prototype.processArrayAppendSlice=function(){var t=this.read(),e=this.read(),n=this.outputArray(),r=this.inputEntry().value;this.model.arrayAppendSlice(n,r,t,e)},t.prototype.processStringAppendString=function(){var t=this.model.wrap(this.read()),e=this.outputString();this.model.stringAppendValue(e,t)},t.prototype.processStringAppendSlice=function(){var t=this.read(),e=this.read(),n=this.outputString(),r=this.inputEntry().value;this.model.stringAppendSlice(n,r,t,e)},t}()},65104:function(t,e,n){n.d(e,{a:function(){return s}});var r=n(16496),a=n(47438),o={wrap:function(t){return t},finalize:function(t){return Array.isArray(t)?t:t.data},markChanged:function(t){return t},objectGetKeys:function(t){return Object.keys(t)},objectGetField:function(t,e){return t[e]},arrayGetElement:function(t,e){return t[e]},copyObject:function(t){var e={type:"object",data:{}};if(null!==t)for(var n=0,r=Object.entries(t);n<r.length;n++){var a=r[n],o=a[0],s=a[1];e.data[o]=s}return e},copyArray:function(t){return null===t?[]:t.slice()},copyString:function(t){return{type:"string",data:null===t?"":t}},objectSetField:function(t,e,n){t.data[e]=n},objectDeleteField:function(t,e){delete t.data[e]},arrayAppendValue:function(t,e){t.push(e)},arrayAppendSlice:function(t,e,n,r){t.push.apply(t,e.slice(n,r))}
1,stringAppendSlice:function(t,e,n,r){var o=e,s=(0,a.D4)(o,n),i=(0,a.D4)(o,r,s);t.data+=o.slice(s,i)},stringAppendValue:function(t,e){t.data+=e}};function s(t,e){var n=t;return new r.t(o,n,e).process()}},47438:function(t,e,n){function r(t){return t>>16?4:t>>11?3:t>>7?2:1}function a(t){for(var e=0,n=0;n<t.length;n++){var a=r(t.codePointAt(n));4==a&&n++,e+=a}return e}function o(t,e,n){void 0===n&&(n=0);var a=n,o=0;for(o=n;a<e;o++){var s=r(t.codePointAt(o));4===s&&o++,a+=s}return o}function s(t,e){for(var n=Math.min(t.length,e.length),a=0,o=0;o<n;){var s=t.codePointAt(o);if(s!==e.codePointAt(o))return a;var i=r(s);a+=i,o+=4===i?2:1}return a}function i(t,e,n){void 0===n&&(n=0);for(var a=Math.min(t.length,e.length)-n,o=0,s=0;s<a;){var i=t.codePointAt(t.length-1-s);if(i!==e.codePointAt(e.length-1-s))return o;var c=r(i);o+=c,s+=4===c?2:1}return o}n.d(e,{D4:function(){return o},W:function(){return a},lK:function(){return s},rO:function(){return r},zA:function(){return i}})},34167:function(t,e,n){n.d(e,{Q:function(){return jt},k:function(){return F}});class r{constructor(t){this.pattern=t,this.patternRe=function(t){const e=[];for(const n of t.split("."))"*"===n?e.push("[^.]+"):"**"===n?e.push(".*"):e.push(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp("^".concat(e.join("."),"$"))}(t)}matches(t){return this.patternRe.test(t)}toJSON(){return this.pattern}}class a{constructor(t){this.type="stream",this.generator=t,this.ticker=null,this.isDone=!1,this.data=[]}isArray(){return!0}async get(){const t=[];for await(const e of this)t.push(await e.get());return t}async*[Symbol.asyncIterator](){let t=0;for(;;){for(;t<this.data.length;t++)yield this.data[t];if(this.isDone)return;await this._nextTick()}}_nextTick(){if(this.ticker)return this.ticker;let t;const e=()=>{this.ticker=new Promise((e=>{t=e}))},n=()=>{t(),e()};return e(),(async()=>{for await(const t of this.generator())this.data.push(t),n();this.isDone=!0,n()})(),this.ticker}}const o=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|([-+]\d{2}:\d{2}))$/;function s(t,e){let n=t.toString();for(;n.length<e;)n="0".concat(n);return n}class i{constructor(t,e){this.data=t,this.type=e}isArray(){return"array"===this.type}async get(){return this.data}[Symbol.asyncIterator](){if(Array.isArray(this.data))return function*(t){for(const e of t)yield h(e)}(this.data);throw new Error("Cannot iterate over: ".concat(this.type))}}const c=new i(null,"null"),u=new i(!0,"boolean"),p=new i(!1,"boolean");class l{constructor(t){this.date=t}static parseToValue(t){const e=function(t){return o.test(t)?new Date(t):null}(t);return e?new i(new l(e),"datetime"):c}equals(t){return this.date.getTime()==t.date.getTime()}add(t){const e=new Date(this.date.getTime());return e.setTime(e.getTime()+1e3*t),new l(e)}difference(t){return(this.date.getTime()-t.date.getTime())/1e3}compareTo(t){return this.date.getTime()-t.date.getTime()}toString(){return function(t){const e=s(t.getUTCFullYear(),4),n=s(t.getUTCMonth()+1,2),r=s(t.getUTCDate(),2),a=s(t.getUTCHours(),2),o=s(t.getUTCMinutes(),2),i=s(t.getUTCSeconds(),2);let c="";const u=t.getMilliseconds();return 0!=u&&(c=".".concat(s(u,3))),"".concat(e,"-").concat(n,"-").concat(r,"T").concat(a,":").concat(o,":").concat(i).concat(c,"Z")}(this.date)}toJSON(){return this.toString()}}function f(t){return Number.isFinite(t)?new i(t,"number"):c}function y(t){return new i(t,"string")}function d(t){return new i(t,"datetime")}function h(t){return(e=t)&&"function"===typeof e.next?new a((async function*(){for await(const e of t)yield h(e)})):null===t||void 0===t?c:new i(t,m(t));var e}function m(t){return null===t||"undefined"===typeof t?"null":Array.isArray(t)?"array":t instanceof r?"path":t instanceof l?"datetime":typeof t}function b(t,e){return"string"===t.type&&"string"===e.type||"boolean"===t.type&&"boolean"===e.type||"null"===t.type&&"null"===e.type||"number"===t.type&&"number"===e.type?t.data===e.data:"datetime"===t.type&&"datetime"===e.type&&t.data.equals(e.data)}const w=/([^!@#$%^&*(),\\/?";:{}|[\]+<>\s-])+/g,g=/([^!@#$%^&(),\\/?";:{}|[\]+<>\s-])+/g,k=/(\b\.+|\.+\b)/g;function v(t){return t.replace(k,"").match(w)||[]}function A(t){return(t.replace(k,"").match(g)||[]).map((t=>new RegExp("^".concat(t.slice(0,1024).replace(/\*/g,".*"),"$"),"i")))}async function x(t,e){if("string"===t.type)return e(t.data),!0;if(t.isArray()){let n=!0;for await(const r of t)"string"===r.type?e(r.data):n=!1;return n}return!1}const _={datetime:1,number:2,string:3,boolean:4};function E(t,e){const n=m(t);if(n!==m(e))return null;switch(n){case"number":case"boolean":return t-e;case"string":return t<e?-1:t>e?1:0;case"datetime":return t.compareTo(e);default:return null}}function S(t,e){const n=m(t),r=m(e),a=_[n]||100,o=_[r]||100;if(a!==o)return a-o;let s=E(t,e);return null===s&&(s=0),s}const j={"==":function(t,e){return b(t,e)?u:p},"!=":function(t,e){return b(t,e)?p:u},">":function(t,e){if("stream"===t.type||"stream"===e.type)return c;const n=E(t.data,e.data);return null===n?c:n>0?u:p},">=":function(t,e){if("stream"===t.type||"stream"===e.type)return c;const n=E(t.data,e.data);return null===n?c:n>=0?u:p},"<":function(t,e){if("stream"===t.type||"stream"===e.type)return c;const n=E(t.data,e.data);return null===n?c:n<0?u:p},"<=":function(t,e){if("stream"===t.type||"stream"===e.type)return c;const n=E(t.data,e.data);return null===n?c:n<=0?u:p},in:async function(t,e){if("path"===e.type)return"string"!==t.type?c:e.data.matches(t.data)?u:p;if(e.isArray()){for await(const n of e)if(b(t,n))return u;return p}return c},match:async function(t,e){let n=[],r=[];await x(t,(t=>
1{n=n.concat(v(t))}));const a=await x(e,(t=>{r=r.concat(A(t).map((t=>e=>e.some((e=>t.test(e))))))}));if(!a)return p;const o=function(t,e){return 0!==t.length&&0!==e.length&&e.every((e=>e(t)))}(n,r);return o?u:p},"+":function(t,e){return"datetime"===t.type&&"number"===e.type?d(t.data.add(e.data)):"number"===t.type&&"number"===e.type?f(t.data+e.data):"string"===t.type&&"string"===e.type?y(t.data+e.data):"object"===t.type&&"object"===e.type?h({...t.data,...e.data}):"array"===t.type&&"array"===e.type?h(t.data.concat(e.data)):t.isArray()&&e.isArray()?new a((async function*(){for await(const e of t)yield e;for await(const t of e)yield t})):c},"-":function(t,e){return"datetime"===t.type&&"number"===e.type?d(t.data.add(-e.data)):"datetime"===t.type&&"datetime"===e.type?f(t.data.difference(e.data)):"number"===t.type&&"number"===e.type?f(t.data-e.data):c},"*":O(((t,e)=>t*e)),"/":O(((t,e)=>t/e)),"%":O(((t,e)=>t%e)),"**":O(((t,e)=>Math.pow(t,e)))};function O(t){return function(e,n){if("number"===e.type&&"number"===n.type){return f(t(e.data,n.data))}return c}}class I{constructor(t,e,n,r,a){this.isHidden=!1,this.params=t,this.source=e,this.value=n,this.context=r,this.parent=a}createNested(t){return this.isHidden?new I(this.params,this.source,t,this.context,this.parent):new I(this.params,this.source,t,this.context,this)}createHidden(t){const e=this.createNested(t);return e.isHidden=!0,e}}function P(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:P;const r=V[t.type];return r(t,e,n)}function C(t,e){return"then"in t?t.then(e):e(t)}const V={This:(t,e)=>e.value,Selector(){throw new Error("Selectors can not be evaluated")},Everything:(t,e)=>e.source,Parameter(t,e){let{name:n}=t;return h(e.params[n])},Context(t,e){let{key:n}=t;if("before"===n||"after"===n){return e.context[n]||c}throw new Error("unknown context key: ".concat(n))},Parent(t,e){let{n:n}=t,r=e;for(let a=0;a<n;a++){if(!r.parent)return c;r=r.parent}return r.value},OpCall(t,e,n){let{op:r,left:a,right:o}=t;const s=j[r];if(!s)throw new Error("Unknown operator: ".concat(r));const i=n(a,e),c=n(o,e);return"then"in i||"then"in c?(async()=>s(await i,await c))():s(i,c)},async Select(t,e,n){let{alternatives:r,fallback:a}=t;for(const o of r){const t=await n(o.condition,e);if("boolean"===t.type&&!0===t.data)return n(o.value,e)}return a?n(a,e):c},async InRange(t,e,n){let{base:r,left:a,right:o,isInclusive:s}=t;const i=await n(r,e),l=await n(a,e),f=await n(o,e),y=E(await i.get(),await l.get());if(null===y)return c;const d=E(await i.get(),await f.get());return null===d?c:s?y>=0&&d<=0?u:p:y>=0&&d<0?u:p},async Filter(t,e,n){let{base:r,expr:o}=t;const s=await n(r,e);return s.isArray()?new a((async function*(){for await(const t of s){const r=e.createNested(t),a=await n(o,r);"boolean"===a.type&&!0===a.data&&(yield t)}})):c},async Projection(t,e,n){let{base:r,expr:a}=t;const o=await n(r,e);if("object"!==o.type)return c;return n(a,e.createNested(o))},FuncCall(t,e,n){let{func:r,args:a}=t;return r(a,e,n)},async PipeFuncCall(t,e,n){let{func:r,base:a,args:o}=t;return r(await n(a,e),o,e,n)},async AccessAttribute(t,e,n){let{base:r,name:a}=t,o=e.value;return r&&(o=await n(r,e)),"object"===o.type&&o.data.hasOwnProperty(a)?h(o.data[a]):c},async AccessElement(t,e,n){let{base:r,index:a}=t;const o=await n(r,e);if(!o.isArray())return c;const s=await o.get();return h(s[a<0?a+s.length:a])},async Slice(t,e,n){let{base:r,left:a,right:o,isInclusive:s}=t;const i=await n(r,e);if(!i.isArray())return c;const u=await i.get();let p=a,l=o;return p<0&&(p=u.length+p),l<0&&(l=u.length+l),s&&l++,p<0&&(p=0),l<0&&(l=0),h(u.slice(p,l))},async Deref(t,e,n){let{base:r}=t;const a=await n(r,e);if(!e.source.isArray())return c;if("object"!==a.type)return c;const o=a.data._ref;if("string"!==typeof o)return c;for await(const s of e.source)if("object"===s.type&&o===s.data._id)return s;return c},Value(t){let{value:e}=t;return h(e)},Group(t,e,n){let{base:r}=t;return n(r,e)},async Object(t,e,n){let{attributes:r}=t;const a={};for(const o of r){const t=o.type;switch(o.type){case"ObjectAttributeValue":{const t=await n(o.value,e);a[o.name]=await t.get();break}case"ObjectConditionalSplat":{const t=await n(o.condition,e);if("boolean"!==t.type||!1===t.data)continue;const r=await n(o.value,e);"object"===r.type&&Object.assign(a,r.data);break}case"ObjectSplat":{const t=await n(o.value,e);"object"===t.type&&Object.assign(a,t.data);break}default:throw new Error("Unknown node type: ".concat(t))}}return h(a)},Array(t,e,n){let{elements:r}=t;return new a((async function*(){for(const t of r){const r=await n(t.value,e);if(t.isSplat){if(r.isArray())for await(const t of r)yield t}else yield r}}))},Tuple(){throw new Error("tuples can not be evaluated")},async Or(t,e,n){let{left:r,right:a}=t;const o=await n(r,e),s=await n(a,e);return"boolean"===o.type&&!0===o.data||"boolean"===s.type&&!0===s.data?u:"boolean"!==o.type||"boolean"!==s.type?c:p},async And(t,e,n){let{left:r,right:a}=t;const o=await n(r,e),s=await n(a,e);return"boolean"===o.type&&!1===o.data||"boolean"===s.type&&!1===s.data?p:"boolean"!==o.type||"boolean"!==s.type?c:u},async Not(t,e,n){let{base:r}=t;const a=await n(r,e);return"boolean"!==a.type?c:a.data?p:u},Neg(t,e,n){let{base:r}=t;return C(n(r,e),(t=>"number"!==t.type?c:f(-t.data)))},Pos(t,e,n){let{base:r}=t;return C(n(r,e),(t=>"number"!==t.type?c:f(t.data)))},Asc:()=>c,Desc:()=>c,async ArrayCoerce(t,e,n){let{base:r}=t;const a=await n(r,e);return a.isArray()?a:c},async Map(t,e,n){let{base:r,expr:o}=t;const s=await n(r,e);return s.isArray()?new a((async function*(){for await(const t of s){const r=e.createHidden(t);yield await n(o,r)}})):c},async FlatMap(t,e,n){let{base:r,expr:o}=t;const s=await n(r,e);return s.isArray()?new a((async function*(){for await(const t of s){const r=e.createHidden(t),a=await n(o,r);if(a.isArray())for await(const t of a)yield t;else yield a}})):c}};function F(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=h(e.root),r=h(e.dataset),a={...e.params},o=new I(a,r,n,{timestamp:e.timestamp||new Date,identity:void 0===e.identity?"me":e.identity,sanity:e.sanity,after:e.after?h(e.after):null,before:e.before?h(e.before):null},null);return P(t,o)}function M(t){switch(t.type){case"Group":case"Value":case"Parameter":return!0;case"Pos":case"Neg":return M(t.base);case"OpCall":switch(t.op){case"+":case"-":case"*":case"/":case"%":case"**":return M(t.left)&&M(t.right);default:return!1}default:return!1}}const T=new I({},c,c,{timestamp:new Date(0),identity:"me",before:null,after:null},null);function R(t){return M(t)?D(t):null}function D(t){const e=P(t,T,D);if("then"in e)throw new Error("BUG: constant evaluate should never return a promise");return e}async function N(t){if("object"===t.type)return B(t.data);if(t.isArray()){const e=await U(t);if(e.length>0)return e.join("\n\n")}return null}async function U(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for await(const n of t)if("object"===n.type){const t=B(n.data);null!==t&&e.push(t)}else n.isArray()&&await U(n,e);return e}function B(t){if("string"!==typeof t._type)return null;const e=t.children;if(!Array.isArray(e))return null;let n="";for(const r of e)r&&"object"===typeof r&&"string"===typeof r._type&&"span"===r._type&&"string"===typeof r.text&&(n+=r.text);return n}const G=1.2;async function K(t,e,n){if("OpCall"===t.type&&"match"===t.op)return async function(t,e,n,r){const a=await r(t,n),o=await r(e,n);let s=[],i=[];await x(a,(t=>{s=s.concat(v(t))}));if(!(await x(o,(t=>{i=i.concat(A(t))}))))return 0;if(0===s.length||0===i.length)return 0;let c=0;for(const u of i){const t=s.reduce(((t,e)=>t+(u.test(e)?1:0)),0);c+=2.2*t/(t+G)}return c}(t.left,t.right,e,n);if("FuncCall"===t.type&&"boost"===t.name){const r=await K(t.args[0],e,n),a=await n(t.args[1],e);return"number"===a.type&&r>0?r+a.data:0}switch(t.type){case"Or":return await K(t.left,e,n)+await K(t.right,e,n);case"And":{const r=await K(t.left,e,n),a=await K(t.right,e,n);return 0===r||0===a?0:r+a}default:{const r=await n(t,e);return"boolean"===r.type&&!0===r.data?1:0}}}function z(t,e){switch(m(t)){case"array":for(const n of t)if(z(n,e))return!0;break;case"object":if(t._ref)return e.has(t._ref);for(const n of Object.values(t))if(z(n,e))return!0}return!1}
1const q={anywhere:async function(){throw new Error("not implemented")}};q.anywhere.arity=1,q.coalesce=async function(t,e,n){for(const r of t){const t=await n(r,e);if("null"!==t.type)return t}return c},q.count=async function(t,e,n){const r=await n(t[0],e);if(!r.isArray())return c;let a=0;for await(const o of r)a++;return f(a)},q.count.arity=1,q.dateTime=async function(t,e,n){const r=await n(t[0],e);return"datetime"===r.type?r:"string"!==r.type?c:l.parseToValue(r.data)},q.dateTime.arity=1,q.defined=async function(t,e,n){return"null"===(await n(t[0],e)).type?p:u},q.defined.arity=1,q.identity=async function(t,e){return y(e.context.identity)},q.identity.arity=0,q.length=async function(t,e,n){const r=await n(t[0],e);if("string"===r.type)return f(function(t){let e=0;for(let n=0;n<t.length;n++){const r=t.charCodeAt(n);r>=55296&&r<=56319||e++}return e}(r.data));if(r.isArray()){let t=0;for await(const e of r)t++;return f(t)}return c},q.length.arity=1,q.path=async function(t,e,n){const a=await n(t[0],e);return"string"!==a.type?c:function(t){return new i(t,"path")}(new r(a.data))},q.path.arity=1,q.string=async function(t,e,n){const r=await n(t[0],e);switch(r.type){case"number":case"string":case"boolean":case"datetime":return y("".concat(r.data));default:return c}},q.string.arity=1,q.references=async function(t,e,n){const r=new Set;for(const a of t){const t=await n(a,e);if("string"===t.type)r.add(t.data);else if(t.isArray())for await(const e of t)"string"===e.type&&r.add(e.data)}
1if(0===r.size)return p;return z(await e.value.get(),r)?u:p},q.references.arity=t=>t>=1,q.round=async function(t,e,n){const r=await n(t[0],e);if("number"!==r.type)return c;const a=r.data;let o=0;if(2===t.length){const r=await n(t[1],e);if("number"!==r.type||r.data<0||!Number.isInteger(r.data))return c;o=r.data}return f(0===o?a<0?-Math.round(-a):Math.round(a):Number(a.toFixed(o)))},q.round.arity=t=>t>=1&&t<=2,q.now=async function(t,e){return y(e.context.timestamp.toISOString())},q.now.arity=0,q.boost=async function(){throw new Error("unexpected boost call")},q.boost.arity=2;const $={lower:async function(t,e,n){const r=await n(t[0],e);return"string"!==r.type?c:y(r.data.toLowerCase())}};$.lower.arity=1,$.upper=async function(t,e,n){const r=await n(t[0],e);return"string"!==r.type?c:y(r.data.toUpperCase())},$.upper.arity=1,$.split=async function(t,e,n){const r=await n(t[0],e);if("string"!==r.type)return c;const a=await n(t[1],e);return"string"!==a.type?c:0===r.data.length?h([]):0===a.data.length?h(Array.from(r.data)):h(r.data.split(a.data))},$.split.arity=2,q.lower=$.lower,q.upper=$.upper,$.startsWith=async function(t,e,n){const r=await n(t[0],e);if("string"!==r.type)return c;const a=await n(t[1],e);return"string"!==a.type?c:r.data.startsWith(a.data)?u:p},$.startsWith.arity=2;const H={join:async function(t,e,n){const r=await n(t[0],e);if(!r.isArray())return c;const a=await n(t[1],e);if("string"!==a.type)return c;let o="",s=!1;for await(const i of r){switch(s&&(o+=a.data),i.type){case"number":case"string":case"boolean":case"datetime":o+="".concat(i.data);break;default:return c}s=!0}return h(o)}};H.join.arity=2,H.compact=async function(t,e,n){const r=await n(t[0],e);return r.isArray()?new a((async function*(){for await(const t of r)"null"!==t.type&&(yield t)})):c},H.compact.arity=1,H.unique=async function(t,e,n){const r=await n(t[0],e);return r.isArray()?new a((async function*(){const t=new Set;for await(const e of r)switch(e.type){case"number":case"string":case"boolean":case"datetime":t.has(e.data)||(t.add(e.data),yield e);break;default:yield e}})):c},H.unique.arity=1;const W={text:async function(t,e,n){const r=await n(t[0],e),a=await N(r);return null===a?c:y(a)}};W.text.arity=1;const Z={projectId:async function(t,e){return e.context.sanity?y(e.context.sanity.projectId):c},dataset:async function(t,e){return e.context.sanity?y(e.context.sanity.dataset):c}},Q={order:async function(t,e,n,r){if(await!0,!t.isArray())return c;const a=[],o=[];let s=0;for(let c of e){let t="asc";"Desc"===c.type?(t="desc",c=c.base):"Asc"===c.type&&(c=c.base),a.push(c),o.push(t),s++}const i=[];let u=0;for await(const c of t){const t=n.createNested(c),e=[await c.get(),u];for(let n=0;n<s;n++){const o=await r(a[n],t);e.push(await o.get())}i.push(e),u++}return i.sort(((t,e)=>{for(let n=0;n<s;n++){let r=S(t[n+2],e[n+2]);if("desc"===o[n]&&(r=-r),0!==r)return r}return t[1]-e[1]})),h(i.map((t=>t[0])))}};Q.order.arity=t=>t>=1,Q.score=async function(t,e,n,r){if(!t.isArray())return c;const a=[],o=[];for await(const s of t){if("object"!==s.type){a.push(await s.get());continue}const t=n.createNested(s);let i="number"===typeof s.data._score?s.data._score:0;for(const n of e)i+=await K(n,t,r);const c=Object.assign({},s.data,{_score:i});o.push(c)}return o.sort(((t,e)=>e._score-t._score)),h(o)},Q.score.arity=t=>t>=1;const J={operation:async function(t,e){const n=null!==e.context.before,r=null!==e.context.after;return n&&r?y("update"):r?y("create"):n?y("delete"):c},changedAny:()=>{throw new Error("not implemented")}};J.changedAny.arity=1,J.changedAny.mode="delta",J.changedOnly=()=>{throw new Error("not implemented")},J.changedOnly.arity=1,J.changedOnly.mode="delta";const L={changedAny:()=>{throw new Error("not implemented")}};L.changedAny.arity=3,L.changedOnly=()=>{throw new Error("not implemented")},L.changedOnly.arity=3;const Y={min:async function(t,e,n){const r=await n(t[0],e);if(!r.isArray())return c;let a;for await(const o of r)if("null"!==o.type){if("number"!==o.type)return c;(void 0===a||o.data<a)&&(a=o.data)}return h(a)}};Y.min.arity=1,Y.max=async function(t,e,n){const r=await n(t[0],e);if(!r.isArray())return c;let a;for await(const o of r)if("null"!==o.type){if("number"!==o.type)return c;(void 0===a||o.data>
1a)&&(a=o.data)}return h(a)},Y.max.arity=1,Y.sum=async function(t,e,n){const r=await n(t[0],e);if(!r.isArray())return c;let a=0;for await(const o of r)if("null"!==o.type){if("number"!==o.type)return c;a+=o.data}return h(a)},Y.sum.arity=1,Y.avg=async function(t,e,n){const r=await n(t[0],e);if(!r.isArray())return c;let a=0,o=0;for await(const s of r)if("null"!==s.type){if("number"!==s.type)return c;a+=s.data,o++}return 0===o?c:h(a/o)},Y.avg.arity=1;const X={global:q,string:$,array:H,pt:W,delta:J,diff:L,sanity:Z,math:Y};class tt{constructor(t,e,n){this.allowBoost=!1,this.string=t,this.marks=e,this.index=0,this.parseOptions=n}hasMark(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.index+t<this.marks.length}getMark(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.marks[this.index+t]}shift(){this.index+=1}process(t){const e=this.marks[this.index];this.shift();const n=t[e.name];if(!n)throw new Error("Unknown handler: ".concat(e.name));return n.call(t,this,e)}processString(){return this.shift(),this.processStringEnd()}processStringEnd(){const t=this.marks[this.index-1],e=this.marks[this.index];return this.shift(),this.string.slice(t.position,e.position)}slice(t){const e=this.marks[this.index].position;return this.string.slice(e,e+t)}}const et=/^([\t\n\v\f\r \u0085\u00A0]|(\/\/[^\n]*\n))+/,nt=/^\d+/,rt=/^[a-zA-Z_][a-zA-Z_0-9]*/;function at(t){let e=0;e=ut(t,e);let n=ot(t,e,0);return"error"===n.type?n:(e=ut(t,n.position),e!==t.length?(n.failPosition&&(e=n.failPosition-1),{type:"error",position:e}):(delete n.position,delete n.failPosition,n))}function ot(t,e,n){let r,a=e;switch(t[e]){case"+":{let n=ot(t,ut(t,e+1),10);if("error"===n.type)return n;r=[{name:"pos",position:a}].concat(n.marks),e=n.position;break}case"-":{let n=ot(t,ut(t,e+1),8);if("error"===n.type)return n;r=[{name:"neg",position:a}].concat(n.marks),e=n.position;break}case"(":{let n=ot(t,ut(t,e+1),0);if("error"===n.type)return n;switch(t[e=ut(t,n.position)]){case",":for(r=[{name:"tuple",position:a}].concat(n.marks),e=ut(t,e+1);;){if(n=ot(t,e,0),"error"===n.type)return n;if(","!==t[e=ut(t,n.position)])break;e=ut(t,e+1)}if(")"!==t[e])return{type:"error",position:e};e++,r.push({name:"tuple_end",position:e});break;case")":e++,r=[{name:"group",position:a}].concat(n.marks);break;default:return{type:"error",position:e}}break}case"!":{let n=ot(t,ut(t,e+1),10);if("error"===n.type)return n;r=[{name:"not",position:a}].concat(n.marks),e=n.position;break}case"{":{let n=ct(t,e);if("error"===n.type)return n;r=n.marks,e=n.position;break}case"[":if(r=[{name:"array",position:e}],"]"!==t[e=ut(t,e+1)])for(;;){"..."===t.slice(e,e+3)&&(r.push({name:"array_splat",position:e}),e=ut(t,e+3));let n=ot(t,e,0);if("error"===n.type)return n;if(r=r.concat(n.marks),","!==t[e=ut(t,e=n.position)])break;if("]"===t[e=ut(t,e+1)])break}if("]"!==t[e])return{type:"error",position:e};e++,r.push({name:"array_end",position:e});break;case"'":case'"':{let n=function(t,e){let n=t[e];const r=[{name:"str",position:e+=1}];t:for(;;e++){if(e>t.length)return{type:"error",position:e};switch(t[e]){case n:r.push({name:"str_end",position:e}),e++;break t;case"\\":r.push({name:"str_pause",position:e}),"u"===t[e+1]?"{"===t[e+2]?(r.push({name:"unicode_hex",position:e+3}),e=t.indexOf("}",e+3),r.push({name:"unicode_hex_end",position:e})):(r.push({name:"unicode_hex",position:e+2}),r.push({name:"unicode_hex_end",position:e+6}),e+=5):(r.push({name:"single_escape",position:e+1}),e+=1),r.push({name:"str_start",position:e+1})}}return{type:"success",marks:r,position:e}}(t,e);if("error"===n.type)return n;r=n.marks,e=n.position;break}case"^":for(e++,r=[];"."===t[e]&&"^"===t[e+1];)r.push({name:"dblparent",position:a}),e+=2;r.push({name:"parent",position:a});break;case"@":r=[{name:"this",position:a}],e++;break;case"*":r=[{name:"everything",position:a}],e++;break;case"$":{let n=pt(t,e+1,rt);n&&(r=[{name:"param",position:a},{name:"ident",position:a+1},{name:"ident_end",position:e+=1+n}]);break}default:{let n=pt(t,e,nt);if(n){let o="integer";if("."===t[e+=n]){let n=pt(t,e+1,nt);n&&(o="float",e+=1+n)}if("e"===t[e]||"E"===t[e]){o="sci","+"!==t[++e]&&"-"!==t[e]||e++;let n=pt(t,e,nt);if(!n)return{type:"error",position:e};e+=n}r=[{name:o,position:a},{name:o+"_end",position:e}];break}let o=pt(t,e,rt);
1if(o){switch(t[e+=o]){case":":case"(":{let n=it(t,a,e);if("error"===n.type)return n;r=n.marks,e=n.position;break}default:r=[{name:"this_attr",position:a},{name:"ident",position:a},{name:"ident_end",position:e}]}break}}}if(!r)return{type:"error",position:e};let o,s=12;t:for(;;){let i=ut(t,e);if(i===t.length){e=i;break}if(o=st(t,i),"success"!==o.type)switch(t[i]){case"=":switch(t[i+1]){case">":{if(n>1||s<=1)break t;let o=ot(t,ut(t,i+2),1);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"pair",position:a}),e=o.position,s=1;break}case"=":{if(n>4||s<=4)break t;let o=ot(t,ut(t,i+2),5);if("error"===o.type)return o;r.unshift({name:"comp",position:a}),r.push({name:"op",position:i},{name:"op_end",position:i+2}),r=r.concat(o.marks),e=o.position,s=4;break}default:break t}break;case"+":{if(n>6||s<6)break t;let o=ot(t,ut(t,i+1),7);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"add",position:a}),e=o.position,s=6;break}case"-":{if(n>6||s<6)break t;let o=ot(t,ut(t,i+1),7);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"sub",position:a}),e=o.position,s=6;break}case"*":{if("*"===t[i+1]){if(n>8||s<=8)break t;let o=ot(t,ut(t,i+2),8);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"pow",position:a}),e=o.position,s=8;break}if(n>7||s<7)break t;let o=ot(t,ut(t,i+1),8);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"mul",position:a}),e=o.position,s=7;break}case"/":{if(n>7||s<7)break t;let o=ot(t,ut(t,i+1),8);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"div",position:a}),e=o.position,s=7;break}case"%":{if(n>7||s<7)break t;let o=ot(t,ut(t,i+1),8);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"mod",position:a}),e=o.position,s=7;break}case"<":case">":{if(n>4||s<=4)break t;let o=i+1;"="===t[o]&&o++;let c=ot(t,ut(t,o),5);if("error"===c.type)return c;r.unshift({name:"comp",position:a}),r.push({name:"op",position:i},{name:"op_end",position:o}),r=r.concat(c.marks),e=c.position,s=4;break}case"|":if("|"===t[i+1]){if(n>2||s<2)break t;let o=ot(t,ut(t,i+2),3);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"or",position:a}),e=o.position,s=2}else{if(n>11||s<11)break t;let o=ut(t,i+1),c=pt(t,o,rt);if(!c)return{type:"error",position:o};if("("===t[e=o+c]||":"===t[e]){let n=it(t,o,e);if("error"===n.type)return n;r=r.concat(n.marks),r.unshift({name:"pipecall",position:a}),e=n.position,s=11}}break;case"&":{if("&"!=t[i+1])break t;if(n>3||s<3)break t;let o=ot(t,ut(t,i+2),4);if("error"===o.type)return o;r=r.concat(o.marks),r.unshift({name:"and",position:a}),e=o.position,s=3;break}case"!":{if("="!==t[i+1])break t;if(n>4||s<4)break t;let o=ot(t,ut(t,i+2),5);if("error"===o.type)return o;r.unshift({name:"comp",position:a}),r.push({name:"op",position:i},{name:"op_end",position:i+2}),r=r.concat(o.marks),e=o.position,s=4;break}case"d":if("desc"!==t.slice(i,i+4))break t;if(n>4||s<4)break t;r.unshift({name:"desc",position:a}),e=i+4,s=4;break;case"a":if("asc"!==t.slice(i,i+3))break t;if(n>4||s<4)break t;r.unshift({name:"asc",position:a}),e=i+3,s=4;break;default:switch(lt(t,i,rt)){case"in":{if(n>4||s<=4)break t;let o=!1;"("===t[e=ut(t,i+2)]&&(o=!0,e=ut(t,e+1));let c=e,u=ot(t,e,5);if("error"===u.type)return u;if("."===t[e=ut(t,u.position)]&&"."===t[e+1]){let n="inc_range";"."===t[e+2]?(n="exc_range",e=ut(t,e+3)):e=ut(t,e+2);let o=ot(t,e,5);if("error"===o.type)return o;r.unshift({name:"in_range",position:a}),r=r.concat({name:n,position:c},u.marks,o.marks),e=o.position}else r.unshift({name:"comp",position:a}),r.push({name:"op",position:i},{name:"op_end",position:i+2}),r=r.concat(u.marks);if(o){if(")"!==t[e=ut(t,e)])return{type:"error",position:e};e++}s=4;break}case"match":{if(n>4||s<=4)break t;let o=ot(t,ut(t,i+5),5);if("error"===o.type)return o;r.unshift({name:"comp",position:a}),r.push({name:"op",position:i},{name:"op_end",position:i+5}),r=r.concat(o.marks),e=o.position,s=4;break}default:break t}}else{for(r.unshift({name:"traverse",position:a});"success"===o.type;)r=r.concat(o.marks),o=st(t,ut(t,e=o.position));r.push({name:"traversal_end",position:e})}}return{type:"success",marks:r,position:e,failPosition:"error"===(null==o?void 0:o.type)&&o.position}}function st(t,e){let n=e;switch(t[e]){case".":{let r=e=ut(t,e+1),a=pt(t,e,rt);return a?{type:"success",marks:[{name:"attr_access",position:n},{name:"ident",position:r},{name:"ident_end",position:e+=a}],position:e}:{type:"error",position:e}}case"-":if(">"!==t[e+1])return{type:"error",position:e};let r=[{name:"deref",position:n}],a=ut(t,e+=2),o=pt(t,a,rt);return o&&(e=a+o,r.push({name:"deref_attr",position:a},{name:"ident",position:a},{name:"ident_end",position:e})),{type:"success",marks:r,position:e};case"[":{if("]"===t[e=ut(t,e+1)])return{type:"success",marks:[{name:"array_postfix",position:n}],position:e+1};let r=e,a=ot(t,e,0);if("error"===a.type)return a;
1if("."===t[e=ut(t,a.position)]&&"."===t[e+1]){let o="inc_range";"."===t[e+2]?(o="exc_range",e+=3):e+=2;let s=ot(t,e=ut(t,e),0);return"error"===s.type?s:"]"!==t[e=ut(t,s.position)]?{type:"error",position:e}:{type:"success",marks:[{name:"slice",position:n},{name:o,position:r}].concat(a.marks,s.marks),position:e+1}}return"]"!==t[e]?{type:"error",position:e}:{type:"success",marks:[{name:"square_bracket",position:n}].concat(a.marks),position:e+1}}case"|":if("{"===t[e=ut(t,e+1)]){let r=ct(t,e);return"error"===r.type||r.marks.unshift({name:"projection",position:n}),r}break;case"{":{let r=ct(t,e);return"error"===r.type||r.marks.unshift({name:"projection",position:n}),r}}return{type:"error",position:e}}function it(t,e,n){let r=[];if(r.push({name:"func_call",position:e}),":"===t[n]&&":"===t[n+1]){r.push({name:"namespace",position:e}),r.push({name:"ident",position:e},{name:"ident_end",position:n});let a=pt(t,n=ut(t,n+2),rt);if(!a)return{type:"error",position:n};if(r.push({name:"ident",position:n},{name:"ident_end",position:n+a}),"("!==t[n=ut(t,n+a)])return{type:"error",position:n};n=ut(t,++n)}else r.push({name:"ident",position:e},{name:"ident_end",position:n}),n=ut(t,n+1);let a=n;if(")"!==t[n])for(;;){let e=ot(t,n,0);if("error"===e.type)return e;if(r=r.concat(e.marks),a=e.position,","!==t[n=ut(t,e.position)])break;if(")"===t[n=ut(t,n+1)])break}return")"!==t[n]?{type:"error",position:n}:(r.push({name:"func_args_end",position:a}),{type:"success",marks:r,position:n+1})}function ct(t,e){let n=[{name:"object",position:e}];for(e=ut(t,e+1);"}"!==t[e];){let r=e;if("..."===t.slice(e,e+3))if("}"!==t[e=ut(t,e+3)]&&","!==t[e]){let a=ot(t,e,0);if("error"===a.type)return a;n.push({name:"object_splat",position:r}),n=n.concat(a.marks),e=a.position}else n.push({name:"object_splat_this",position:r});else{let a=ot(t,e,0);if("error"===a.type)return a;let o=ut(t,a.position);if("str"===a.marks[0].name&&":"===t[o]){let s=ot(t,ut(t,o+1),0);if("error"===s.type)return s;n.push({name:"object_pair",position:r}),n=n.concat(a.marks,s.marks),e=s.position}else n=n.concat({name:"object_expr",position:e},a.marks),e=a.position}if(","!==t[e=ut(t,e)])break;e=ut(t,e+1)}return"}"!==t[e]?{type:"error",position:e}:(e++,n.push({name:"object_end",position:e}),{type:"success",marks:n,position:e})}function ut(t,e){return e+pt(t,e,et)}function pt(t,e,n){let r=n.exec(t.slice(e));return r?r[0].length:0}function lt(t,e,n){let r=n.exec(t.slice(e));return r?r[0]:null}function ft(t,e){return n=>e(t(n))}function yt(t){return e=>({type:"Map",base:e,expr:t({type:"This"})})}function dt(t,e){if(!e)return{type:"a-a",build:t};switch(e.type){case"a-a":return{type:"a-a",build:ft(t,e.build)};case"a-b":return{type:"a-b",build:ft(t,e.build)};case"b-b":return{type:"a-a",build:ft(t,yt(e.build))};case"b-a":return{type:"a-a",build:ft(t,(n=e.build,t=>({type:"FlatMap",base:t,expr:n({type:"This"})})))};default:throw new Error("unknown type: ".concat(e.type))}var n}function ht(t,e){if(!e)return{type:"b-b",build:t};switch(e.type){case"a-a":case"b-a":return{type:"b-a",build:ft(t,e.build)};case"a-b":case"b-b":return{type:"b-b",build:ft(t,e.build)};default:throw new Error("unknown type: ".concat(e.type))}}const mt={"'":"'",'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function bt(t){const e=parseInt(t,16);return String.fromCharCode(e)}class wt extends Error{constructor(){super(...arguments),this.name="GroqQueryError"}}const gt={group:t=>({type:"Group",base:t.process(gt)}),everything:()=>({type:"Everything"}),this:()=>({type:"This"}),parent:()=>({type:"Parent",n:1}),dblparent:t=>({type:"Parent",n:t.process(gt).n+1}),traverse(t){const e=t.process(gt),n=[];for(;"traversal_end"!==t.getMark().name;)n.push(t.process(vt));t.shift();let r=null;for(let a=n.length-1;a>=0;a--)r=n[a](r);if("Everything"!==e.type&&"Array"!==e.type&&"PipeFuncCall"!==e.type||(r=dt((t=>t),r)),null===r)throw new Error("BUG: unexpected empty traversal");return r.build(e)},this_attr(t){const e=t.processString();return"null"===e?{type:"Value",value:null}:"true"===e?{type:"Value",value:!0}:"false"===e?{type:"Value",value:!1}:{type:"AccessAttribute",name:e}},neg:t=>({type:"Neg",base:t.process(gt)}),pos:t=>({type:"Pos",base:t.process(gt)}),add:t=>({type:"OpCall",op:"+",left:t.process(gt),right:t.process(gt)}),sub:t=>({type:"OpCall",op:"-",left:t.process(gt),right:t.process(gt)}),mul:t=>({type:"OpCall",op:"*",left:t.process(gt),right:t.process(gt)}),div:t=>({type:"OpCall",op:"/",left:t.process(gt),right:t.process(gt)}),mod:t=>({type:"OpCall",op:"%",left:t.process(gt),right:t.process(gt)}),pow:t=>({type:"OpCall",op:"**",left:t.process(gt),right:t.process(gt)}),comp(t){const e=t.process(gt);
1return{type:"OpCall",op:t.processString(),left:e,right:t.process(gt)}},in_range(t){const e=t.process(gt),n="inc_range"===t.getMark().name;t.shift();return{type:"InRange",base:e,left:t.process(gt),right:t.process(gt),isInclusive:n}},str(t){let e="";t:for(;t.hasMark();){const n=t.getMark();switch(n.name){case"str_end":e+=t.processStringEnd();break t;case"str_pause":e+=t.processStringEnd();break;case"str_start":t.shift();break;case"single_escape":{const n=t.slice(1);t.shift(),e+=mt[n];break}case"unicode_hex":t.shift(),e+=bt(t.processStringEnd());break;default:throw new Error("unexpected mark: ".concat(n.name))}}return{type:"Value",value:e}},integer(t){const e=t.processStringEnd();return{type:"Value",value:Number(e)}},float(t){const e=t.processStringEnd();return{type:"Value",value:Number(e)}},sci(t){const e=t.processStringEnd();return{type:"Value",value:Number(e)}},object(t){const e=[];for(;"object_end"!==t.getMark().name;)e.push(t.process(kt));return t.shift(),{type:"Object",attributes:e}},array(t){const e=[];for(;"array_end"!==t.getMark().name;){let n=!1;"array_splat"===t.getMark().name&&(n=!0,t.shift());const r=t.process(gt);e.push({type:"ArrayElement",value:r,isSplat:n})}return t.shift(),{type:"Array",elements:e}},tuple(t){const e=[];for(;"tuple_end"!==t.getMark().name;)e.push(t.process(gt));return t.shift(),{type:"Tuple",members:e}},func_call(t){let e="global";"namespace"===t.getMark().name&&(t.shift(),e=t.processString());const n=t.processString();if("global"===e&&"select"===n){const e={type:"Select",alternatives:[]};for(;"func_args_end"!==t.getMark().name;)if("pair"===t.getMark().name){if(e.fallback)throw new wt("unexpected argument to select()");t.shift();const n=t.process(gt),r=t.process(gt);e.alternatives.push({type:"SelectAlternative",condition:n,value:r})}else{if(e.fallback)throw new wt("unexpected argument to select()");const n=t.process(gt);e.fallback=n}return t.shift(),e}const r=[];for(;"func_args_end"!==t.getMark().name;)Et(e,n,r.length)?(t.process(At),r.push({type:"Selector"})):r.push(t.process(gt));if(t.shift(),"global"===e&&("before"===n||"after"===n)&&"delta"===t.parseOptions.mode)return{type:"Context",key:n};if("global"===e&&"boost"===n&&!t.allowBoost)throw new wt("unexpected boost");const a=X[e];if(!a)throw new wt("Undefined namespace: ".concat(e));const o=a[n];if(!o)throw new wt("Undefined function: ".concat(n));if(void 0!==o.arity&&_t(n,o.arity,r.length),void 0!==o.mode&&o.mode!==t.parseOptions.mode)throw new wt("Undefined function: ".concat(n));return{type:"FuncCall",func:o,name:n,args:r}},pipecall(t){const e=t.process(gt);t.shift();let n="global";if("namespace"===t.getMark().name&&(t.shift(),n=t.processString()),"global"!==n)throw new wt("Undefined namespace: ".concat(n));const r=t.processString(),a=[],o=t.allowBoost;for("score"===r&&(t.allowBoost=!0);;){const e=t.getMark().name;if("func_args_end"===e)break;if("order"===r){if("asc"===e){t.shift(),a.push({type:"Asc",base:t.process(gt)});continue}if("desc"===e){t.shift(),a.push({type:"Desc",base:t.process(gt)});continue}}a.push(t.process(gt))}t.shift(),t.allowBoost=o;const s=Q[r];if(!s)throw new wt("Undefined pipe function: ".concat(r));return s.arity&&_t(r,s.arity,a.length),{type:"PipeFuncCall",func:s,base:e,name:r,args:a}},pair(t){throw new wt("unexpected =>")},and:t=>({type:"And",left:t.process(gt),right:t.process(gt)}),or:t=>({type:"Or",left:t.process(gt),right:t.process(gt)}),not:t=>({type:"Not",base:t.process(gt)}),asc(t){throw new wt("unexpected asc")},desc(t){throw new wt("unexpected desc")},param(t){const e=t.processString();return t.parseOptions.params&&t.parseOptions.params.hasOwnProperty(e)?{type:"Value",value:t.parseOptions.params[e]}:{type:"Parameter",name:e}}},kt={object_expr(t){if("pair"===t.getMark().name){t.shift();return{type:"ObjectConditionalSplat",condition:t.process(gt),value:t.process(gt)}}const e=t.process(gt);return{type:"ObjectAttributeValue",name:xt(e),value:e}},object_pair(t){const e=t.process(gt);if("Value"!==e.type)throw new Error("name must be string");const n=t.process(gt);return{type:"ObjectAttributeValue",name:e.value,value:n}},object_splat:t=>({type:"ObjectSplat",value:t.process(gt)}),object_splat_this:()=>({type:"ObjectSplat",value:{type:"This"}})},vt={square_bracket(t){const e=t.process(gt),n=R(e);return n&&"number"===n.type?t=>function(t,e){if(!e)return{type:"a-b",build:t};switch(e.type){case"a-a":case"b-a":return{type:"a-a",build:ft(t,e.build)};case"a-b":case"b-b":return{type:"a-b",build:ft(t,e.build)};default:throw new Error("unknown type: ".concat(e.type))}}((t=>({type:"AccessElement",base:t,index:n.data})),t):n&&"string"===n.type?t=>ht((t=>({type:"AccessAttribute",base:t,name:n.data})),t):t=>dt((t=>({type:"Filter",base:t,expr:e})),t)},slice(t){const e="inc_range"===t.getMark().name;t.shift();const n=t.process(gt),r=t.process(gt),a=R(n),o=R(r);if(!a||!o||"number"!==a.type||"number"!==o.type)throw new wt("slicing must use constant numbers");return t=>dt((t=>({type:"Slice",base:t,left:a.data,right:o.data,isInclusive:e})),t)},projection(t){const e=t.process(gt);return t=>function(t,e){if(!e)return{type:"b-b",build:t};switch(e.type){case"a-a":return{type:"a-a",build:ft(yt(t),e.build)};case"a-b":return{type:"a-b",build:ft(yt(t),e.build)};case"b-a":return{type:"b-a",build:ft(t,e.build)};case"b-b":return{type:"b-b",build:ft(t,e.build)};default:throw new Error("unknown type: ".concat(e.type))}}((t=>({type:"Projection",base:t,expr:e})),t)},attr_access(t){const e=t.processString();return t=>ht((t=>({type:"AccessAttribute",base:t,name:e})),t)},deref(t){let e=null;"deref_attr"===t.getMark().name&&(t.shift(),e=t.processString());return t=>ht((t=>(t=>e?{type:"AccessAttribute",base:t,name:e}:t)({type:"Deref",base:t})),t)},array_postfix:t=>t=>dt((t=>({type:"ArrayCoerce",base:t})),t)},At={group:t=>(t.process(At),null),everything(){throw new Error("Invalid selector syntax")},this(){throw new Error("Invalid selector syntax")},parent(){throw new Error("Invalid selector syntax")},dblparent(t){throw new Error("Invalid selector syntax")},traverse(t){for(t.process(At);"traversal_end"!==t.getMark().name;)t.process(vt);return t.shift(),null},this_attr:t=>(t.processString(),null),neg(t){throw new Error("Invalid selector syntax")},pos(t){throw new Error("Invalid selector syntax")},add(t){throw new Error("Invalid selector syntax")},sub(t){throw new Error("Invalid selector syntax")},mul(t){throw new Error("Invalid selector syntax")},div(t){throw new Error("Invalid selector syntax")},mod(t){throw new Error("Invalid selector syntax")},pow(t){throw new Error("Invalid selector syntax")},comp(t){throw new Error("Invalid selector syntax")},in_range(t){throw new Error("Invalid selector syntax")},str(t){throw new Error("Invalid selector syntax")},integer(t){throw new Error("Invalid selector syntax")},float(t){throw new Error("Invalid selector syntax")},sci(t){throw new Error("Invalid selector syntax")},object(t){throw new Error("Invalid selector syntax")},array(t){throw new Error("Invalid selector syntax")},tuple(t){throw new Error("Invalid selector syntax")},func_call(t,e){const n=gt.func_call(t,e);if("anywhere"===n.name&&1===n.args.length)return null;throw new Error("Invalid selector syntax")},pipecall(t){throw new Error("Invalid selector syntax")},pair(t){throw new Error("Invalid selector syntax")},and(t){throw new Error("Invalid selector syntax")},or(t){throw new Error("Invalid selector syntax")},not(t){throw new Error("Invalid selector syntax")},asc(t){throw new Error("Invalid selector syntax")},desc(t){throw new Error("Invalid selector syntax")},param(t){throw new Error("Invalid selector syntax")}};function xt(t){if("AccessAttribute"===t.type&&!t.base)return t.name;if("Deref"===t.type||"Map"===t.type||"Projection"===t.type||"Slice"===t.type||"Filter"===t.type||"AccessElement"===t.type||"ArrayCoerce"===t.type)return xt(t.base);throw new wt("Cannot determine property key for type: ".concat(t.type))}function _t(t,e,n){if("number"===typeof e){if(n!==e)throw new wt("Incorrect number of arguments to function ".concat(t,"(). Expected ").concat(e,", got ").concat(n,"."))}else if(e&&!e(n))throw new wt("Incorrect number of arguments to function ".concat(t,"()."))}function Et(t,e,n){return"diff"==t&&2==n&&["changedAny","changedOnly"].includes(e)}
1class St extends Error{constructor(t){super("Syntax error in GROQ query at position ".concat(t)),this.name="GroqSyntaxError",this.position=t}}function jt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=at(t);if("error"===n.type)throw new St(n.position);const r=new tt(t,n.marks,e);return r.process(gt)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.