Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hammerstone/refine-vue3

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hammerstone/refine-vue3 - npm Package Compare versions

Comparing version 0.2.4 to 0.3.1

CHANGELOG.md

2

dist/vue2/refine-vue.cjs.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");var t=e=>"conjunction"===(null==e?void 0:e.type),n=Object.defineProperty,i=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,a=(e,t,i)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,d=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&a(e,n,t[n]);if(o)for(var n of o(t))l.call(t,n)&&a(e,n,t[n]);return e},u=(e,t)=>i(e,r(t)),c=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},p=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:d({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:c()}},f=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:c()}},h=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?u(d({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||c()}):u(d({},e),{id:void 0,uid:c()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)s.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&o)for(var i of o(e))t.indexOf(i)<0&&l.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((n,i)=>{t(n)?"or"===n.word&&e.push([]):e[e.length-1].push(u(d({},n),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=p(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:n}=this,i=n[e-1],r=n[e+1],o=t(r)&&"or"===r.word,s=t(i)&&"or"===i.word,l=o||!r,a=s||!i,d=a&&!l,u=a&&l;!i&&!r?this.blueprint=[]:u&&s?n.splice(e-1,2):u&&!i||d?n.splice(e,2):n.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:c()}}()),e.push(p(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=p(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,f(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,f(),p(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=d({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},m=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=d({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};function v(e,t,n,i,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const g=v({},undefined,{name:"renderless-selector",data:()=>({selector:e.reactive(new m),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),y={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let b=1;var w={beforeCreate(){this.uid=b.toString(),b+=1}};const x=Symbol();function O(t,n,i=e.computed((()=>({})))){const r=e.inject(x),o=e.computed((()=>t(r)??{})),s=e.computed((()=>{const e={},t=i.value??{};let n=o.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=o.value.wrap,e})),l=e.computed((()=>{const e={},t=i.value??{},n=o.value.class;n&&(e.class="function"==typeof n?n(t):n);const r=o.value.style;return r&&(e.style="function"==typeof r?r(t):r),e}));return e.computed((()=>({component:o.value.component??n.value,props:l,extra:s})))}const _=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,n){const i=O((e=>{const n=t.component.split(".");let i=e;for(const e of n)i=i?.[e];return i}),e.computed((()=>t.as)),e.computed((()=>t.flavorOptions)));return()=>{const r=i.value,o=r.extra.value.order??t.order,s=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),l=n.slots;let a="string"==typeof r.component&&r.component.includes("-"),d=a?l:o.map((e=>l?.[e]?.())),u=e.isVue2?e.h(r.component,{scopedSlots:l,attrs:n.attrs,props:s,on:n.listeners,...r.props.value},d):e.h(r.component,{...n.attrs,"data-flavor":t.component,...s,...r.props.value},d);return r.extra.value.wrap?r.extra.value.wrap(u):u}}});const C={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:_}};var k=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};k._withStripped=!0;const S=v({render:k,staticRenderFns:[]},undefined,C,undefined,false,undefined,!1,void 0,void 0,void 0);const $={name:"selector-listbox",mixins:[w],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:_}};var I=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};I._withStripped=!0;const R=v({render:I,staticRenderFns:[]},undefined,$,undefined,false,undefined,!1,void 0,void 0,void 0);const q={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:_}};var B=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};B._withStripped=!0;const j=v({render:B,staticRenderFns:[]},undefined,q,undefined,false,undefined,!1,void 0,void 0,void 0);const E={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:_}};var F=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"div",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};F._withStripped=!0;const D=v({render:F,staticRenderFns:[]},undefined,E,undefined,false,undefined,!1,void 0,void 0,void 0);const A={name:"selector",mixins:[w],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:D,RenderlessSelector:g,SelectorListItem:j,SelectorButton:S,SelectorListbox:R,RefineFlavor:_}};var V=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,a,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};V._withStripped=!0;const M=v({render:V,staticRenderFns:[]},undefined,A,undefined,false,undefined,!1,void 0,void 0,void 0);var P={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new h(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:i,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:i,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},N={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!i)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(n.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),a=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let d=null;return n?.condition?.meta?.clauses&&(d=n.condition.meta.clauses.map((e=>e.component))),()=>i.slots.default?i.slots.default({clauses:d,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,n)},T={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:a,...r.input}):null})(t.clause,t,n)},z={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const L={name:"selector-option",mixins:[y],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[y],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};var H=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};H._withStripped=!0;const G=v({render:H,staticRenderFns:[]},undefined,L,undefined,false,undefined,!1,void 0,void 0,void 0);const Y={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:M}};var U=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};U._withStripped=!0;const Q=v({render:U,staticRenderFns:[]},undefined,Y,undefined,false,undefined,!1,void 0,void 0,void 0);const W=v({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new h(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const K={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:_}};var X=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};X._withStripped=!0;const Z=v({render:X,staticRenderFns:[]},undefined,K,undefined,false,undefined,!1,void 0,void 0,void 0);const J={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:Z,RefineFlavor:_}};var ee=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};ee._withStripped=!0;const te=v({render:ee,staticRenderFns:[]},undefined,J,undefined,false,undefined,!1,void 0,void 0,void 0);const ne={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:_}};var ie=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};ie._withStripped=!0;const re=v({render:ie,staticRenderFns:[]},undefined,ne,undefined,false,undefined,!1,void 0,void 0,void 0);const oe={setup(){var t,n;return{flavor:(t="inputs.date.pickerInput",O((e=>{const n=t.split(".");let i=e;for(const e of n)i=i?.[e];return i}),"",e.computed((()=>n)))?.value)}},props:{date:{type:String,required:!1},format:{type:String,required:!1,default:"MM/DD/YYYY"}},emits:["input"],data(){const{date:e}=this;return{time:e,hasError:!1,inputClass:this.flavor.props.value?.class,errorClass:this.flavor.props.value?.class}},methods:{handleInputError:function(){this.hasError=!0},handleInput:function(){this.hasError=!1,this.$emit("input",{date:this.time})}},components:{RefineFlavor:_}};var se=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date","value-type":"YYYY-MM-DD",format:e.format,"input-class":e.hasError?e.inputClass+e.errorClass:e.inputClass},on:{input:e.handleInput,change:e.handleInput,"input-error":e.handleInputError},scopedSlots:e._u([{key:"icon-calendar",fn:function(){return[e.hasError?e._e():n("refine-flavor",{attrs:{as:"svg",component:"input.date.calendar.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z","clip-rule":"evenodd"}})]),e._v(" "),e.hasError?n("refine-flavor",{attrs:{as:"svg",component:"input.date.error.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"}})]):e._e()]},proxy:!0}]),model:{value:e.time,callback:function(t){e.time=t},expression:"time"}},"refine-flavor",e.$attrs,!1))};se._withStripped=!0;const le=v({render:se,staticRenderFns:[]},undefined,oe,undefined,false,undefined,!1,void 0,void 0,void 0);const ae={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:le},methods:{handleInput:function({date:e}){this.$emit("input",{date1:e})}}};var de=function(){var e=this,t=e.$createElement;return(e._self._c||t)("date-picker",e._b({attrs:{date:e.date1},on:{input:e.handleInput}},"date-picker",e.$attrs,!1))};de._withStripped=!0;const ue=v({render:de,staticRenderFns:[]},undefined,ae,undefined,false,undefined,!1,void 0,void 0,void 0);const ce={name:"refine-double-date-input",components:{DatePicker:le,RefineFlavor:_},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},methods:{updateFirstDate:function({date:e}){this.$emit("input",{date1:e})},updateSecondDate:function({date:e}){this.$emit("input",{date2:e})}}};var pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("date-picker",e._b({attrs:{date:e.date1},on:{input:e.updateFirstDate}},"date-picker",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("date-picker",e._b({attrs:{date:e.date2},on:{input:e.updateSecondDate}},"date-picker",e.$attrs,!1))],1)};pe._withStripped=!0;const fe=v({render:pe,staticRenderFns:[]},undefined,ce,undefined,false,undefined,!1,void 0,void 0,void 0);const he={name:"refine-date-input",components:{Selector:M,SelectorOption:G,RefineFlavor:_},mixins:[w],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var me=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};me._withStripped=!0;const ve=v({render:me,staticRenderFns:[]},undefined,he,undefined,false,undefined,!1,void 0,void 0,void 0);const ge={name:"refine-option-input",components:{Selector:M,SelectorOption:G},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var ye=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};ye._withStripped=!0;const be=v({render:ye,staticRenderFns:[]},undefined,ge,undefined,false,undefined,!1,void 0,void 0,void 0);var we={RefineDateInput:ue,RefineDoubleDateInput:fe,RefineDoubleNumberInput:te,RefineNumberInput:Z,RefineOptionInput:be,RefineRelativeDateInput:ve,RefineTextInput:re};const xe={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:T,SelectorOption:G,Selector:M,...Object.freeze({__proto__:null,default:we,RefineDateInput:ue,RefineDoubleDateInput:fe,RefineDoubleNumberInput:te,RefineNumberInput:Z,RefineOptionInput:be,RefineRelativeDateInput:ve,RefineTextInput:re})}};var Oe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Oe._withStripped=!0;const _e=v({render:Oe,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);const Ce={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:_e,RenderlessRefinement:z,Selector:M,SelectorOption:G},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var ke=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};ke._withStripped=!0;const Se={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:_e,Refinements:v({render:ke,staticRenderFns:[]},undefined,Ce,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:G,Selector:M,RefineFlavor:_}};var $e=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t.id,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t.message)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};$e._withStripped=!0;const Ie={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var n;n=t.flavor,e.provide(x,n)},components:{Criterion:v({render:$e,staticRenderFns:[]},undefined,Se,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:_,RenderlessCondition:N,RenderlessQueryBuilder:P}};var Re=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,i){return n("refine-flavor",{key:i,attrs:{as:"div",component:"group"}},[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And ")])],1)],1)],2)})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Re._withStripped=!0;const qe=v({render:Re,staticRenderFns:[]},undefined,Ie,undefined,false,undefined,!1,void 0,void 0,void 0),Be="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",je="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ee=`${Be} ${je} w-60 pl-3 py-2`,Fe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Be} ${je} block w-full pl-3 py-2 pr-0`},relative:{class:`${Ee} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Ee,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ee}}},De="bg-white relative text-left cursor-default",Ae=`${De} focus:outline-none pl-3 py-1`,Ve={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${De} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ae} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ae} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ae}}};exports.ConditionSelector=Q,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=W,exports.QueryBuilder=qe,exports.Selector=M,exports.SelectorOption=G,exports.linearFlavor=Ve,exports.tailwindFlavor=Fe;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();let n={};var i={init(e){n=e},get:(e,t=null)=>n?.[e]??t,set(e,t){n[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(n,r){let o=i.get("showLocators");const s=function(n,i,r=e.computed((()=>({})))){const o=e.inject(t),s=e.computed((()=>n(o)??{})),l=e.computed((()=>{const e={},t=r.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),d=e.computed((()=>{const e={},t=r.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e.computed((()=>({component:s.value.component??i.value,props:d,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e.computed((()=>n.as)),e.computed((()=>({...r.attrs??{},...n.flavorOptions??{}}))));return()=>{const t=s.value,i=t.extra.value.order??n.order,l=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(n,["as","component","order"]),d=r.slots;let a="string"==typeof t.component&&t.component.includes("-"),u=a?d:i.map((e=>d?.[e]?.())),c=e.isVue2?e.h(t.component,{scopedSlots:d,attrs:{...o&&{"data-locator":n.component},...r.attrs},props:l,on:r.listeners,...t.props.value},u):e.h(t.component,{...o&&{"data-locator":n.component},...r.attrs,...l,...t.props.value},u);return t.extra.value.wrap?t.extra.value.wrap(c):c}}});function o(e,t,n,i,r,o,s,l,d,a){"boolean"!=typeof s&&(d=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,d(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,a(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:r}};var l=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};l._withStripped=!0;const d=o({render:l,staticRenderFns:[]},undefined,s,undefined,false,undefined,!1,void 0,void 0,void 0);const a={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:d,RefineFlavor:r}};var u=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};u._withStripped=!0;const c=o({render:u,staticRenderFns:[]},undefined,a,undefined,false,undefined,!1,void 0,void 0,void 0);const p={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};var f=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};f._withStripped=!0;const h=o({render:f,staticRenderFns:[]},undefined,p,undefined,false,undefined,!1,void 0,void 0,void 0);const m={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};var v=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};v._withStripped=!0;const g=o({render:v,staticRenderFns:[]},undefined,m,undefined,false,undefined,!1,void 0,void 0,void 0);const y={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var b=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};b._withStripped=!0;const w=o({render:b,staticRenderFns:[]},undefined,y,undefined,false,undefined,!1,void 0,void 0,void 0);var x=e=>"conjunction"===(null==e?void 0:e.type),O=Object.defineProperty,_=Object.defineProperties,C=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,R=(e,t,n)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))S.call(t,n)&&R(e,n,t[n]);if(k)for(var n of k(t))$.call(t,n)&&R(e,n,t[n]);return e},q=(e,t)=>_(e,C(t)),B=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},j=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:I({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:B()}},E=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:B()}},F=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?q(I({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||B()}):q(I({},e),{id:void 0,uid:B()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)S.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&k)for(var i of k(e))t.indexOf(i)<0&&$.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{x(t)?"or"===t.word&&e.push([]):e[e.length-1].push(q(I({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=j(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=x(i)&&"or"===i.word,o=x(n)&&"or"===n.word,s=r||!i,l=o||!n,d=l&&!s,a=l&&s;!n&&!i?this.blueprint=[]:a&&o?t.splice(e-1,2):a&&!n||d?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:B()}}()),e.push(j(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=j(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,E(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,E(),j(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=I({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},A=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=I({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const D=o({},undefined,{name:"renderless-selector",data:()=>({selector:e.reactive(new A),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:d,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:d,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),V={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let P=1;var N={beforeCreate(){this.uid=P.toString(),P+=1}};const M={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};var T=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};T._withStripped=!0;const L=o({render:T,staticRenderFns:[]},undefined,M,undefined,false,undefined,!1,void 0,void 0,void 0);const G={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};var z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};z._withStripped=!0;const H=o({render:z,staticRenderFns:[]},undefined,G,undefined,false,undefined,!1,void 0,void 0,void 0);const K={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};var U=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};U._withStripped=!0;const Q=o({render:U,staticRenderFns:[]},undefined,K,undefined,false,undefined,!1,void 0,void 0,void 0);const W={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};var X=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};X._withStripped=!0;const Y=o({render:X,staticRenderFns:[]},undefined,W,undefined,false,undefined,!1,void 0,void 0,void 0);const Z={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:Y,RenderlessSelector:D,SelectorListItem:Q,SelectorButton:L,SelectorListbox:H,RefineFlavor:r}};var J=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,d=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,d,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(d,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};J._withStripped=!0;const ee=o({render:J,staticRenderFns:[]},undefined,Z,undefined,false,undefined,!1,void 0,void 0,void 0);var te={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:i,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:i,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},ne={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!i)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(n.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),d=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>i.slots.default?i.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:d}):null})(t.id,t,n)},ie={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...r.input}):null})(t.clause,t,n)},re={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const oe={name:"selector-option",mixins:[V],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[V],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};se._withStripped=!0;const le=o({render:se,staticRenderFns:[]},undefined,oe,undefined,false,undefined,!1,void 0,void 0,void 0);const de={name:"refine-date-input",components:{Selector:ee,SelectorOption:le,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ae._withStripped=!0;const ue=o({render:ae,staticRenderFns:[]},undefined,de,undefined,false,undefined,!1,void 0,void 0,void 0);const ce={name:"refine-option-input",components:{Selector:ee,SelectorOption:le},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};pe._withStripped=!0;const fe=o({render:pe,staticRenderFns:[]},undefined,ce,undefined,false,undefined,!1,void 0,void 0,void 0);const he={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var me=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};me._withStripped=!0;const ve=o({render:me,staticRenderFns:[]},undefined,he,undefined,false,undefined,!1,void 0,void 0,void 0);var ge={RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:d,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:ve},ye=Object.freeze({__proto__:null,default:ge,RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:d,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:ve}),be={install:(e,t={})=>{t={DatePicker:ve,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,i.init(t)}},we={install:(e,t={})=>{be.install(e,t)}};const xe={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ee}};var Oe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Oe._withStripped=!0;const _e=o({render:Oe,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);const Ce=o({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const ke={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ie,SelectorOption:le,Selector:ee,...ye}};var Se=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Se._withStripped=!0;const $e=o({render:Se,staticRenderFns:[]},undefined,ke,undefined,false,undefined,!1,void 0,void 0,void 0);const Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:$e,RenderlessRefinement:re,Selector:ee,SelectorOption:le},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Ie=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Ie._withStripped=!0;const qe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:$e,Refinements:o({render:Ie,staticRenderFns:[]},undefined,Re,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:le,Selector:ee,RefineFlavor:r}};var Be=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Be._withStripped=!0;const je={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(n){var i;i=n.flavor,e.provide(t,i)},components:{Criterion:o({render:Be,staticRenderFns:[]},undefined,qe,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:r,RenderlessCondition:ne,RenderlessQueryBuilder:te}};var Ee=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,d=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,d(e))}}})]}}],null,!0)},"renderless-condition",d(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ee._withStripped=!0;const Fe=o({render:Ee,staticRenderFns:[]},undefined,je,undefined,false,undefined,!1,void 0,void 0,void 0),Ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",De="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ve=`${Ae} ${De} w-60 pl-3 py-2`,Pe={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ae} ${De} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ve} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ve,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ve}},Ne="bg-white relative text-left cursor-default",Me=`${Ne} focus:outline-none pl-3 py-1`,Te={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Me}}};exports.ConditionSelector=_e,exports.DatePickerPlugin=we,exports.Query=Ce,exports.QueryBuilder=Fe,exports.RefinePlugin=be,exports.Selector=ee,exports.SelectorOption=le,exports.linearFlavor=Te,exports.tailwindFlavor=Pe;
//# sourceMappingURL=refine-vue.cjs.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=e=>"conjunction"===(null==e?void 0:e.type),i=Object.defineProperty,n=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,a=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var i in t||(t={}))s.call(t,i)&&a(e,i,t[i]);if(o)for(var i of o(t))l.call(t,i)&&a(e,i,t[i]);return e},c=(e,t)=>n(e,r(t)),u=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},p=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:d({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:u()}},f=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:u()}},h=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?c(d({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||u()}):c(d({},e),{id:void 0,uid:u()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)s.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&o)for(var n of o(e))t.indexOf(n)<0&&l.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((i,n)=>{t(i)?"or"===i.word&&e.push([]):e[e.length-1].push(c(d({},i),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=p(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:i}=this,n=i[e-1],r=i[e+1],o=t(r)&&"or"===r.word,s=t(n)&&"or"===n.word,l=o||!r,a=s||!n,d=a&&!l,c=a&&l;n||r?c&&s?i.splice(e-1,2):c&&!n||d?i.splice(e,2):i.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:u()}}()),e.push(p(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=p(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,f(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,f(),p(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=d({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},v=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=d({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};function m(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const c="function"==typeof i?i.options:i;let u;if(e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),n&&(c._scopeId=n),o?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=u):t&&(u=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),u)if(c.functional){const e=c.render;c.render=function(t,i){return u.call(i),e(t,i)}}else{const e=c.beforeCreate;c.beforeCreate=e?[].concat(e,u):[u]}return i}const g=m({},void 0,{name:"renderless-selector",data:()=>({selector:e.reactive(new v),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),y={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let b=1;var w={beforeCreate(){this.uid=b.toString(),b+=1}};const x=Symbol();function O(t,i,n=e.computed((()=>({})))){const r=e.inject(x),o=e.computed((()=>t(r)??{})),s=e.computed((()=>{const e={},t=n.value??{};let i=o.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=o.value.wrap,e})),l=e.computed((()=>{const e={},t=n.value??{},i=o.value.class;i&&(e.class="function"==typeof i?i(t):i);const r=o.value.style;return r&&(e.style="function"==typeof r?r(t):r),e}));return e.computed((()=>({component:o.value.component??i.value,props:l,extra:s})))}const _=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,i){const n=O((e=>{const i=t.component.split(".");let n=e;for(const e of i)n=n?.[e];return n}),e.computed((()=>t.as)),e.computed((()=>t.flavorOptions)));return()=>{const r=n.value,o=r.extra.value.order??t.order,s=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(t,["as","component","order"]),l=i.slots;let a="string"==typeof r.component&&r.component.includes("-")?l:o.map((e=>l?.[e]?.())),d=e.isVue2?e.h(r.component,{scopedSlots:l,attrs:i.attrs,props:s,on:i.listeners,...r.props.value},a):e.h(r.component,{...i.attrs,"data-flavor":t.component,...s,...r.props.value},a);return r.extra.value.wrap?r.extra.value.wrap(d):d}}}),C={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:_}};var k=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};k._withStripped=!0;const S=m({render:k,staticRenderFns:[]},void 0,C,void 0,!1,void 0,!1,void 0,void 0,void 0),$={name:"selector-listbox",mixins:[w],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:_}};var I=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};I._withStripped=!0;const R=m({render:I,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0),q={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:_}};var B=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};B._withStripped=!0;const j=m({render:B,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),E={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:_}};var F=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"div",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};F._withStripped=!0;const D=m({render:F,staticRenderFns:[]},void 0,E,void 0,!1,void 0,!1,void 0,void 0,void 0),A={name:"selector",mixins:[w],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:D,RenderlessSelector:g,SelectorListItem:j,SelectorButton:S,SelectorListbox:R,RefineFlavor:_}};var V=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};V._withStripped=!0;const M=m({render:V,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0);var P={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new h(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:t,addGroup:i,blueprintStore:n,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:i,blueprint:n,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},N={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!n)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(i.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),a=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",i.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let d=null;return i?.condition?.meta?.clauses&&(d=i.condition.meta.clauses.map((e=>e.component))),()=>n.slots.default?n.slots.default({clauses:d,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,i)},T={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:a,...r.input}):null})(t.clause,t,i)},z={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const L={name:"selector-option",mixins:[y],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[y],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i&&t?i():null}}}};var H=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};H._withStripped=!0;const G=m({render:H,staticRenderFns:[]},void 0,L,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:M}};var U=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};U._withStripped=!0;const Q=m({render:U,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),W=m({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new h(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i?i({blueprint:t}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),K={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:_}};var X=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};X._withStripped=!0;const Z=m({render:X,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:Z,RefineFlavor:_}};var ee=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};ee._withStripped=!0;const te=m({render:ee,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),ie={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:_}};var ne=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};ne._withStripped=!0;const re=m({render:ne,staticRenderFns:[]},void 0,ie,void 0,!1,void 0,!1,void 0,void 0,void 0),oe={setup:()=>({flavor:("inputs.date.pickerInput",O((e=>{const t="inputs.date.pickerInput".split(".");let i=e;for(const e of t)i=i?.[e];return i}),"",e.computed((()=>{})))?.value)}),props:{date:{type:String,required:!1},format:{type:String,required:!1,default:"MM/DD/YYYY"}},emits:["input"],data(){const{date:e}=this;return{time:e,hasError:!1,inputClass:this.flavor.props.value?.class,errorClass:this.flavor.props.value?.class}},methods:{handleInputError:function(){this.hasError=!0},handleInput:function(){this.hasError=!1,this.$emit("input",{date:this.time})}},components:{RefineFlavor:_}};var se=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date","value-type":"YYYY-MM-DD",format:e.format,"input-class":e.hasError?e.inputClass+e.errorClass:e.inputClass},on:{input:e.handleInput,change:e.handleInput,"input-error":e.handleInputError},scopedSlots:e._u([{key:"icon-calendar",fn:function(){return[e.hasError?e._e():i("refine-flavor",{attrs:{as:"svg",component:"input.date.calendar.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z","clip-rule":"evenodd"}})]),e._v(" "),e.hasError?i("refine-flavor",{attrs:{as:"svg",component:"input.date.error.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"}})]):e._e()]},proxy:!0}]),model:{value:e.time,callback:function(t){e.time=t},expression:"time"}},"refine-flavor",e.$attrs,!1))};se._withStripped=!0;const le=m({render:se,staticRenderFns:[]},void 0,oe,void 0,!1,void 0,!1,void 0,void 0,void 0),ae={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:le},methods:{handleInput:function({date:e}){this.$emit("input",{date1:e})}}};var de=function(){var e=this,t=e.$createElement;return(e._self._c||t)("date-picker",e._b({attrs:{date:e.date1},on:{input:e.handleInput}},"date-picker",e.$attrs,!1))};de._withStripped=!0;const ce=m({render:de,staticRenderFns:[]},void 0,ae,void 0,!1,void 0,!1,void 0,void 0,void 0),ue={name:"refine-double-date-input",components:{DatePicker:le,RefineFlavor:_},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},methods:{updateFirstDate:function({date:e}){this.$emit("input",{date1:e})},updateSecondDate:function({date:e}){this.$emit("input",{date2:e})}}};var pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("date-picker",e._b({attrs:{date:e.date1},on:{input:e.updateFirstDate}},"date-picker",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("date-picker",e._b({attrs:{date:e.date2},on:{input:e.updateSecondDate}},"date-picker",e.$attrs,!1))],1)};pe._withStripped=!0;const fe=m({render:pe,staticRenderFns:[]},void 0,ue,void 0,!1,void 0,!1,void 0,void 0,void 0),he={name:"refine-date-input",components:{Selector:M,SelectorOption:G,RefineFlavor:_},mixins:[w],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ve=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ve._withStripped=!0;const me=m({render:ve,staticRenderFns:[]},void 0,he,void 0,!1,void 0,!1,void 0,void 0,void 0),ge={name:"refine-option-input",components:{Selector:M,SelectorOption:G},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var ye=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};ye._withStripped=!0;const be=m({render:ye,staticRenderFns:[]},void 0,ge,void 0,!1,void 0,!1,void 0,void 0,void 0);var we={RefineDateInput:ce,RefineDoubleDateInput:fe,RefineDoubleNumberInput:te,RefineNumberInput:Z,RefineOptionInput:be,RefineRelativeDateInput:me,RefineTextInput:re};const xe={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:T,SelectorOption:G,Selector:M,...Object.freeze({__proto__:null,default:we,RefineDateInput:ce,RefineDoubleDateInput:fe,RefineDoubleNumberInput:te,RefineNumberInput:Z,RefineOptionInput:be,RefineRelativeDateInput:me,RefineTextInput:re})}};var Oe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Oe._withStripped=!0;const _e=m({render:Oe,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0),Ce={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:_e,RenderlessRefinement:z,Selector:M,SelectorOption:G},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var ke=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};ke._withStripped=!0;const Se={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:_e,Refinements:m({render:ke,staticRenderFns:[]},void 0,Ce,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:G,Selector:M,RefineFlavor:_}};var $e=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t.id,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t.message)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};$e._withStripped=!0;const Ie={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var i;i=t.flavor,e.provide(x,i)},components:{Criterion:m({render:$e,staticRenderFns:[]},void 0,Se,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:_,RenderlessCondition:N,RenderlessQueryBuilder:P}};var Re=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,n){return i("refine-flavor",{key:n,attrs:{as:"div",component:"group"}},[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And ")])],1)],1)],2)})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Re._withStripped=!0;const qe=m({render:Re,staticRenderFns:[]},void 0,Ie,void 0,!1,void 0,!1,void 0,void 0,void 0),Be="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",je="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ee=`${Be} ${je} w-60 pl-3 py-2`,Fe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Be} ${je} block w-full pl-3 py-2 pr-0`},relative:{class:`${Ee} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Ee,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ee}}},De="bg-white relative text-left cursor-default",Ae=`${De} focus:outline-none pl-3 py-1`,Ve={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${De} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ae} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ae} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ae}}};exports.ConditionSelector=Q,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=W,exports.QueryBuilder=qe,exports.Selector=M,exports.SelectorOption=G,exports.linearFlavor=Ve,exports.tailwindFlavor=Fe;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();let i={};var n={init(e){i=e},get:(e,t=null)=>i?.[e]??t,set(e,t){i[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(i,r){let o=n.get("showLocators");const s=function(i,n,r=e.computed((()=>({})))){const o=e.inject(t),s=e.computed((()=>i(o)??{})),l=e.computed((()=>{const e={},t=r.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=e.computed((()=>{const e={},t=r.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const n=s.value.style;return n&&(e.style="function"==typeof n?n(t):n),e}));return e.computed((()=>({component:s.value.component??n.value,props:a,extra:l})))}((e=>{const t=i.component.split(".");let n=e;for(const e of t)n=n?.[e];return"string"!=typeof n&&"function"!=typeof n||(n={class:n}),n}),e.computed((()=>i.as)),e.computed((()=>({...r.attrs??{},...i.flavorOptions??{}}))));return()=>{const t=s.value,n=t.extra.value.order??i.order,l=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(i,["as","component","order"]),a=r.slots;let d="string"==typeof t.component&&t.component.includes("-")?a:n.map((e=>a?.[e]?.())),u=e.isVue2?e.h(t.component,{scopedSlots:a,attrs:{...o&&{"data-locator":i.component},...r.attrs},props:l,on:r.listeners,...t.props.value},d):e.h(t.component,{...o&&{"data-locator":i.component},...r.attrs,...l,...t.props.value},d);return t.extra.value.wrap?t.extra.value.wrap(u):u}}});function o(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof i?i.options:i;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),n&&(u._scopeId=n),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,i){return c.call(i),e(t,i)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return i}const s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:r}};var l=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};l._withStripped=!0;const a=o({render:l,staticRenderFns:[]},void 0,s,void 0,!1,void 0,!1,void 0,void 0,void 0),d={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:a,RefineFlavor:r}};var u=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};u._withStripped=!0;const c=o({render:u,staticRenderFns:[]},void 0,d,void 0,!1,void 0,!1,void 0,void 0,void 0),p={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};var f=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};f._withStripped=!0;const h=o({render:f,staticRenderFns:[]},void 0,p,void 0,!1,void 0,!1,void 0,void 0,void 0),v={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};var m=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};m._withStripped=!0;const g=o({render:m,staticRenderFns:[]},void 0,v,void 0,!1,void 0,!1,void 0,void 0,void 0),y={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var b=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};b._withStripped=!0;const w=o({render:b,staticRenderFns:[]},void 0,y,void 0,!1,void 0,!1,void 0,void 0,void 0);var x=e=>"conjunction"===(null==e?void 0:e.type),O=Object.defineProperty,_=Object.defineProperties,C=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,R=(e,t,i)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,I=(e,t)=>{for(var i in t||(t={}))S.call(t,i)&&R(e,i,t[i]);if(k)for(var i of k(t))$.call(t,i)&&R(e,i,t[i]);return e},q=(e,t)=>_(e,C(t)),B=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},j=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:I({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:B()}},E=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:B()}},F=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?q(I({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||B()}):q(I({},e),{id:void 0,uid:B()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)S.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&k)for(var n of k(e))t.indexOf(n)<0&&$.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{x(t)?"or"===t.word&&e.push([]):e[e.length-1].push(q(I({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=j(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=x(n)&&"or"===n.word,o=x(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:B()}}()),e.push(j(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=j(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,E(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,E(),j(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=I({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},A=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=I({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const D=o({},void 0,{name:"renderless-selector",data:()=>({selector:e.reactive(new A),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),V={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let P=1;var N={beforeCreate(){this.uid=P.toString(),P+=1}};const M={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};var T=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};T._withStripped=!0;const L=o({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),G={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};var z=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};z._withStripped=!0;const H=o({render:z,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};var U=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};U._withStripped=!0;const Q=o({render:U,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};var X=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};X._withStripped=!0;const Y=o({render:X,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:Y,RenderlessSelector:D,SelectorListItem:Q,SelectorButton:L,SelectorListbox:H,RefineFlavor:r}};var J=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};J._withStripped=!0;const ee=o({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0);var te={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:t,addGroup:i,blueprintStore:n,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:i,blueprint:n,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},ie={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!n)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(i.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),a=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",i.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let d=null;return i?.condition?.meta?.clauses&&(d=i.condition.meta.clauses.map((e=>e.component))),()=>n.slots.default?n.slots.default({clauses:d,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,i)},ne={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:a,...r.input}):null})(t.clause,t,i)},re={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const oe={name:"selector-option",mixins:[V],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[V],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i&&t?i():null}}}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};se._withStripped=!0;const le=o({render:se,staticRenderFns:[]},void 0,oe,void 0,!1,void 0,!1,void 0,void 0,void 0),ae={name:"refine-date-input",components:{Selector:ee,SelectorOption:le,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var de=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};de._withStripped=!0;const ue=o({render:de,staticRenderFns:[]},void 0,ae,void 0,!1,void 0,!1,void 0,void 0,void 0),ce={name:"refine-option-input",components:{Selector:ee,SelectorOption:le},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};pe._withStripped=!0;const fe=o({render:pe,staticRenderFns:[]},void 0,ce,void 0,!1,void 0,!1,void 0,void 0,void 0),he={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var ve=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};ve._withStripped=!0;const me=o({render:ve,staticRenderFns:[]},void 0,he,void 0,!1,void 0,!1,void 0,void 0,void 0);var ge={RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:a,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:me},ye=Object.freeze({__proto__:null,default:ge,RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:a,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:me}),be={install:(e,t={})=>{t={DatePicker:me,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,n.init(t)}},we={install:(e,t={})=>{be.install(e,t)}};const xe={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ee}};var Oe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Oe._withStripped=!0;const _e=o({render:Oe,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0),Ce=o({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i?i({blueprint:t}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),ke={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ne,SelectorOption:le,Selector:ee,...ye}};var Se=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Se._withStripped=!0;const $e=o({render:Se,staticRenderFns:[]},void 0,ke,void 0,!1,void 0,!1,void 0,void 0,void 0),Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:$e,RenderlessRefinement:re,Selector:ee,SelectorOption:le},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Ie=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Ie._withStripped=!0;const qe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:$e,Refinements:o({render:Ie,staticRenderFns:[]},void 0,Re,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:le,Selector:ee,RefineFlavor:r}};var Be=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Be._withStripped=!0;const je={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(i){var n;n=i.flavor,e.provide(t,n)},components:{Criterion:o({render:Be,staticRenderFns:[]},void 0,qe,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:r,RenderlessCondition:ie,RenderlessQueryBuilder:te}};var Ee=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,s){return[i("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),i("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:n.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ee._withStripped=!0;const Fe=o({render:Ee,staticRenderFns:[]},void 0,je,void 0,!1,void 0,!1,void 0,void 0,void 0),Ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",De="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ve=`${Ae} ${De} w-60 pl-3 py-2`,Pe={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ae} ${De} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ve} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ve,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ve}},Ne="bg-white relative text-left cursor-default",Me=`${Ne} focus:outline-none pl-3 py-1`,Te={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Me}}};exports.ConditionSelector=_e,exports.DatePickerPlugin=we,exports.Query=Ce,exports.QueryBuilder=Fe,exports.RefinePlugin=be,exports.Selector=ee,exports.SelectorOption=le,exports.linearFlavor=Te,exports.tailwindFlavor=Pe;
//# sourceMappingURL=refine-vue.cjs.min.js.map

@@ -1,2 +0,2 @@

import{reactive as e,nextTick as t,isVue2 as n,computed as i,inject as r,provide as o,defineComponent as s,h as l,onUnmounted as a}from"vue-demi";var d={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},u=e=>"conjunction"===(null==e?void 0:e.type),c=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&g(e,n,t[n]);if(h)for(var n of h(t))v.call(t,n)&&g(e,n,t[n]);return e},b=(e,t)=>p(e,f(t)),w=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},O=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:y({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:w()}},x=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:w()}},_=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?b(y({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||w()}):b(y({},e),{id:void 0,uid:w()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)m.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&h)for(var i of h(e))t.indexOf(i)<0&&v.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{u(t)?"or"===t.word&&e.push([]):e[e.length-1].push(b(y({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=O(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=u(i)&&"or"===i.word,o=u(n)&&"or"===n.word,s=r||!i,l=o||!n,a=l&&!s,d=l&&s;!n&&!i?this.blueprint=[]:d&&o?t.splice(e-1,2):d&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:w()}}()),e.push(O(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=O(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,x(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,x(),O(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=y({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},C=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=y({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};function k(e,t,n,i,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const S=k({},undefined,{name:"renderless-selector",data:()=>({selector:e(new C),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return t().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return n&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),$={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let I=1;var R={beforeCreate(){this.uid=I.toString(),I+=1}};const q=Symbol();function B(e,t,n=i((()=>({})))){const o=r(q),s=i((()=>e(o)??{})),l=i((()=>{const e={},t=n.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=i((()=>{const e={},t=n.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const r=s.value.style;return r&&(e.style="function"==typeof r?r(t):r),e}));return i((()=>({component:s.value.component??t.value,props:a,extra:l})))}const E=s({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(e,t){const r=B((t=>{const n=e.component.split(".");let i=t;for(const e of n)i=i?.[e];return i}),i((()=>e.as)),i((()=>e.flavorOptions)));return()=>{const i=r.value,o=i.extra.value.order??e.order,s=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(e,["as","component","order"]),a=t.slots;let d="string"==typeof i.component&&i.component.includes("-"),u=d?a:o.map((e=>a?.[e]?.())),c=l(i.component,n?{scopedSlots:a,attrs:t.attrs,props:s,on:t.listeners,...i.props.value}:{...t.attrs,"data-flavor":e.component,...s,...i.props.value},u);return i.extra.value.wrap?i.extra.value.wrap(c):c}}});const j={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:E}};var F=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};F._withStripped=!0;const D=k({render:F,staticRenderFns:[]},undefined,j,undefined,false,undefined,!1,void 0,void 0,void 0);const A={name:"selector-listbox",mixins:[R],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:E}};var M=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};M._withStripped=!0;const V=k({render:M,staticRenderFns:[]},undefined,A,undefined,false,undefined,!1,void 0,void 0,void 0);const P={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:E}};var N=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};N._withStripped=!0;const T=k({render:N,staticRenderFns:[]},undefined,P,undefined,false,undefined,!1,void 0,void 0,void 0);const z={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:E}};var L=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"div",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};L._withStripped=!0;const H=k({render:L,staticRenderFns:[]},undefined,z,undefined,false,undefined,!1,void 0,void 0,void 0);const G={name:"selector",mixins:[R],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:H,RenderlessSelector:S,SelectorListItem:T,SelectorButton:D,SelectorListbox:V,RefineFlavor:E}};var Y=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,a,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};Y._withStripped=!0;const U=k({render:Y,staticRenderFns:[]},undefined,G,undefined,false,undefined,!1,void 0,void 0,void 0);var Q={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new _(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:i,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return n&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:i,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},W={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,t)=>((e,t,n)=>{const i=r("blueprint"),s=r("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!n)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let l;l=s?i.findCriterion(t.uid):i.addCriterion({id:e,depth:0});const d=(e,t)=>i.updateInput(l,e,t),u=e=>i.switchClause(l,e);o("criterion",l),o("criterionMeta",t.meta),o("updateInput",d),o("switchRefinement",((e,t)=>{i.switchRefinement(l,e,t)})),o("refinementId",null),a((()=>{s||i.removeCriterion(i.indexOfCriterion(l))}));let c=null;return t?.condition?.meta?.clauses&&(c=t.condition.meta.clauses.map((e=>e.component))),()=>n.slots.default?n.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,t)},K={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,n)=>{const i=r("criterion"),o=r("updateInput"),s=r("refinementId"),l=r("builderModeActive"),d=e=>{o(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:n,...r}=i.input;Object.keys(t).length>0&&0===Object.keys(r).length&&o({...t},s)}return a((()=>{l||i.input.clause===e&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:d,...i.input}):null})(e.clause,e,t)},X={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(n&&(e=this.$scopedSlots?.default),e)return e()}};const Z={name:"selector-option",mixins:[$],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[$],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return n&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var J=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};J._withStripped=!0;const ee=k({render:J,staticRenderFns:[]},undefined,Z,undefined,false,undefined,!1,void 0,void 0,void 0);const te={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:U}};var ne=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};ne._withStripped=!0;const ie=k({render:ne,staticRenderFns:[]},undefined,te,undefined,false,undefined,!1,void 0,void 0,void 0);const re=k({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new _(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return n&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const oe={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:E}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};se._withStripped=!0;const le=k({render:se,staticRenderFns:[]},undefined,oe,undefined,false,undefined,!1,void 0,void 0,void 0);const ae={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:le,RefineFlavor:E}};var de=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};de._withStripped=!0;const ue=k({render:de,staticRenderFns:[]},undefined,ae,undefined,false,undefined,!1,void 0,void 0,void 0);const ce={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:E}};var pe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};pe._withStripped=!0;const fe=k({render:pe,staticRenderFns:[]},undefined,ce,undefined,false,undefined,!1,void 0,void 0,void 0);const he={setup(){var e,t;return{flavor:(e="inputs.date.pickerInput",B((t=>{const n=e.split(".");let i=t;for(const e of n)i=i?.[e];return i}),"",i((()=>t)))?.value)}},props:{date:{type:String,required:!1},format:{type:String,required:!1,default:"MM/DD/YYYY"}},emits:["input"],data(){const{date:e}=this;return{time:e,hasError:!1,inputClass:this.flavor.props.value?.class,errorClass:this.flavor.props.value?.class}},methods:{handleInputError:function(){this.hasError=!0},handleInput:function(){this.hasError=!1,this.$emit("input",{date:this.time})}},components:{RefineFlavor:E}};var me=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date","value-type":"YYYY-MM-DD",format:e.format,"input-class":e.hasError?e.inputClass+e.errorClass:e.inputClass},on:{input:e.handleInput,change:e.handleInput,"input-error":e.handleInputError},scopedSlots:e._u([{key:"icon-calendar",fn:function(){return[e.hasError?e._e():n("refine-flavor",{attrs:{as:"svg",component:"input.date.calendar.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z","clip-rule":"evenodd"}})]),e._v(" "),e.hasError?n("refine-flavor",{attrs:{as:"svg",component:"input.date.error.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"}})]):e._e()]},proxy:!0}]),model:{value:e.time,callback:function(t){e.time=t},expression:"time"}},"refine-flavor",e.$attrs,!1))};me._withStripped=!0;const ve=k({render:me,staticRenderFns:[]},undefined,he,undefined,false,undefined,!1,void 0,void 0,void 0);const ge={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:ve},methods:{handleInput:function({date:e}){this.$emit("input",{date1:e})}}};var ye=function(){var e=this,t=e.$createElement;return(e._self._c||t)("date-picker",e._b({attrs:{date:e.date1},on:{input:e.handleInput}},"date-picker",e.$attrs,!1))};ye._withStripped=!0;const be=k({render:ye,staticRenderFns:[]},undefined,ge,undefined,false,undefined,!1,void 0,void 0,void 0);const we={name:"refine-double-date-input",components:{DatePicker:ve,RefineFlavor:E},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},methods:{updateFirstDate:function({date:e}){this.$emit("input",{date1:e})},updateSecondDate:function({date:e}){this.$emit("input",{date2:e})}}};var Oe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("date-picker",e._b({attrs:{date:e.date1},on:{input:e.updateFirstDate}},"date-picker",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("date-picker",e._b({attrs:{date:e.date2},on:{input:e.updateSecondDate}},"date-picker",e.$attrs,!1))],1)};Oe._withStripped=!0;const xe=k({render:Oe,staticRenderFns:[]},undefined,we,undefined,false,undefined,!1,void 0,void 0,void 0);const _e={name:"refine-date-input",components:{Selector:U,SelectorOption:ee,RefineFlavor:E},mixins:[R],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var Ce=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};Ce._withStripped=!0;const ke=k({render:Ce,staticRenderFns:[]},undefined,_e,undefined,false,undefined,!1,void 0,void 0,void 0);const Se={name:"refine-option-input",components:{Selector:U,SelectorOption:ee},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var $e=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};$e._withStripped=!0;const Ie=k({render:$e,staticRenderFns:[]},undefined,Se,undefined,false,undefined,!1,void 0,void 0,void 0);var Re={RefineDateInput:be,RefineDoubleDateInput:xe,RefineDoubleNumberInput:ue,RefineNumberInput:le,RefineOptionInput:Ie,RefineRelativeDateInput:ke,RefineTextInput:fe};const qe={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:K,SelectorOption:ee,Selector:U,...Object.freeze({__proto__:null,default:Re,RefineDateInput:be,RefineDoubleDateInput:xe,RefineDoubleNumberInput:ue,RefineNumberInput:le,RefineOptionInput:Ie,RefineRelativeDateInput:ke,RefineTextInput:fe})}};var Be=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Be._withStripped=!0;const Ee=k({render:Be,staticRenderFns:[]},undefined,qe,undefined,false,undefined,!1,void 0,void 0,void 0);const je={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ee,RenderlessRefinement:X,Selector:U,SelectorOption:ee},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Fe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Fe._withStripped=!0;const De={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ee,Refinements:k({render:Fe,staticRenderFns:[]},undefined,je,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:ee,Selector:U,RefineFlavor:E}};var Ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t.id,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t.message)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ae._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,o(q,t)},components:{Criterion:k({render:Ae,staticRenderFns:[]},undefined,De,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:E,RenderlessCondition:W,RenderlessQueryBuilder:Q}};var Ve=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,i){return n("refine-flavor",{key:i,attrs:{as:"div",component:"group"}},[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And ")])],1)],1)],2)})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ve._withStripped=!0;const Pe=k({render:Ve,staticRenderFns:[]},undefined,Me,undefined,false,undefined,!1,void 0,void 0,void 0),Ne="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Te="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",ze=`${Ne} ${Te} w-60 pl-3 py-2`,Le={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} ${Te} block w-full pl-3 py-2 pr-0`},relative:{class:`${ze} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:ze,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:ze}}},He="bg-white relative text-left cursor-default",Ge=`${He} focus:outline-none pl-3 py-1`,Ye={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${He} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ge} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ge} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ge}}};export{ie as ConditionSelector,d as DatePickerPlugin,re as Query,Pe as QueryBuilder,U as Selector,ee as SelectorOption,Ye as linearFlavor,Le as tailwindFlavor};
import{computed as e,inject as t,provide as n,defineComponent as i,isVue2 as r,h as o,reactive as s,nextTick as l,onUnmounted as a}from"vue-demi";const d=Symbol();let u={};var c={init(e){u=e},get:(e,t=null)=>u?.[e]??t,set(e,t){u[e]=t}};const p=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(n,i){let s=c.get("showLocators");const l=function(n,i,r=e((()=>({})))){const o=t(d),s=e((()=>n(o)??{})),l=e((()=>{const e={},t=r.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=r.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e((()=>n.as)),e((()=>({...i.attrs??{},...n.flavorOptions??{}}))));return()=>{const e=l.value,t=e.extra.value.order??n.order,a=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(n,["as","component","order"]),d=i.slots;let u="string"==typeof e.component&&e.component.includes("-"),c=u?d:t.map((e=>d?.[e]?.())),p=o(e.component,r?{scopedSlots:d,attrs:{...s&&{"data-locator":n.component},...i.attrs},props:a,on:i.listeners,...e.props.value}:{...s&&{"data-locator":n.component},...i.attrs,...a,...e.props.value},c);return e.extra.value.wrap?e.extra.value.wrap(p):p}}});function f(e,t,n,i,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const h={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:p}};var m=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};m._withStripped=!0;const v=f({render:m,staticRenderFns:[]},undefined,h,undefined,false,undefined,!1,void 0,void 0,void 0);const g={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:v,RefineFlavor:p}};var y=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};y._withStripped=!0;const b=f({render:y,staticRenderFns:[]},undefined,g,undefined,false,undefined,!1,void 0,void 0,void 0);const w={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:p}};var O=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};O._withStripped=!0;const x=f({render:O,staticRenderFns:[]},undefined,w,undefined,false,undefined,!1,void 0,void 0,void 0);const _={name:"refine-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1}}};var C=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};C._withStripped=!0;const S=f({render:C,staticRenderFns:[]},undefined,_,undefined,false,undefined,!1,void 0,void 0,void 0);const k={name:"refine-double-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var $=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};$._withStripped=!0;const R=f({render:$,staticRenderFns:[]},undefined,k,undefined,false,undefined,!1,void 0,void 0,void 0);var I=e=>"conjunction"===(null==e?void 0:e.type),q=Object.defineProperty,B=Object.defineProperties,j=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,D=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))F.call(t,n)&&D(e,n,t[n]);if(E)for(var n of E(t))A.call(t,n)&&D(e,n,t[n]);return e},N=(e,t)=>B(e,j(t)),V=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},M=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:P({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:V()}},T=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:V()}},L=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?N(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||V()}):N(P({},e),{id:void 0,uid:V()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)F.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&E)for(var i of E(e))t.indexOf(i)<0&&A.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{I(t)?"or"===t.word&&e.push([]):e[e.length-1].push(N(P({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=M(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=I(i)&&"or"===i.word,o=I(n)&&"or"===n.word,s=r||!i,l=o||!n,a=l&&!s,d=l&&s;!n&&!i?this.blueprint=[]:d&&o?t.splice(e-1,2):d&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:V()}}()),e.push(M(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=M(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,T(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,T(),M(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=P({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},G=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=P({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const z=f({},undefined,{name:"renderless-selector",data:()=>({selector:s(new G),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return l().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return r&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),H={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let K=1;var U={beforeCreate(){this.uid=K.toString(),K+=1}};const Q={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:p}};var W=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};W._withStripped=!0;const X=f({render:W,staticRenderFns:[]},undefined,Q,undefined,false,undefined,!1,void 0,void 0,void 0);const Y={name:"selector-listbox",mixins:[U],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:p}};var Z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};Z._withStripped=!0;const J=f({render:Z,staticRenderFns:[]},undefined,Y,undefined,false,undefined,!1,void 0,void 0,void 0);const ee={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:p}};var te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};te._withStripped=!0;const ne=f({render:te,staticRenderFns:[]},undefined,ee,undefined,false,undefined,!1,void 0,void 0,void 0);const ie={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:p}};var re=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};re._withStripped=!0;const oe=f({render:re,staticRenderFns:[]},undefined,ie,undefined,false,undefined,!1,void 0,void 0,void 0);const se={name:"selector",mixins:[U],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:oe,RenderlessSelector:z,SelectorListItem:ne,SelectorButton:X,SelectorListbox:J,RefineFlavor:p}};var le=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,a,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};le._withStripped=!0;const ae=f({render:le,staticRenderFns:[]},undefined,se,undefined,false,undefined,!1,void 0,void 0,void 0);var de={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return r&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},ue={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,r)=>{const o=t("blueprint"),s=t("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!r)throw new Error("useCondition requires a Vue context.");if(!o)throw new Error("Conditions must be rendered within a query.");let l;l=s?o.findCriterion(i.uid):o.addCriterion({id:e,depth:0});const d=(e,t)=>o.updateInput(l,e,t),u=e=>o.switchClause(l,e);n("criterion",l),n("criterionMeta",i.meta),n("updateInput",d),n("switchRefinement",((e,t)=>{o.switchRefinement(l,e,t)})),n("refinementId",null),a((()=>{s||o.removeCriterion(o.indexOfCriterion(l))}));let c=null;return i?.condition?.meta?.clauses&&(c=i.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,i)},ce={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,n)=>((e,n,i)=>{const r=t("criterion"),o=t("updateInput"),s=t("refinementId"),l=t("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:t,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return a((()=>{l||r.input.clause===e&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...r.input}):null})(e.clause,e,n)},pe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(r&&(e=this.$scopedSlots?.default),e)return e()}};const fe={name:"selector-option",mixins:[H],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[H],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var he=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};he._withStripped=!0;const me=f({render:he,staticRenderFns:[]},undefined,fe,undefined,false,undefined,!1,void 0,void 0,void 0);const ve={name:"refine-date-input",components:{Selector:ae,SelectorOption:me,RefineFlavor:p},mixins:[U],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ge=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ge._withStripped=!0;const ye=f({render:ge,staticRenderFns:[]},undefined,ve,undefined,false,undefined,!1,void 0,void 0,void 0);const be={name:"refine-option-input",components:{Selector:ae,SelectorOption:me},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};we._withStripped=!0;const Oe=f({render:we,staticRenderFns:[]},undefined,be,undefined,false,undefined,!1,void 0,void 0,void 0);const xe={emits:["input"],components:{RefineFlavor:p},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var _e=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};_e._withStripped=!0;const Ce=f({render:_e,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);var Se={RefineDateInput:S,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:v,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce},ke=Object.freeze({__proto__:null,default:Se,RefineDateInput:S,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:v,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,c.init(t)}},Re={install:(e,t={})=>{$e.install(e,t)}};const Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ae}};var qe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};qe._withStripped=!0;const Be=f({render:qe,staticRenderFns:[]},undefined,Ie,undefined,false,undefined,!1,void 0,void 0,void 0);const je=f({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const Ee={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ce,SelectorOption:me,Selector:ae,...ke}};var Fe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Fe._withStripped=!0;const Ae=f({render:Fe,staticRenderFns:[]},undefined,Ee,undefined,false,undefined,!1,void 0,void 0,void 0);const De={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ae,RenderlessRefinement:pe,Selector:ae,SelectorOption:me},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Pe._withStripped=!0;const Ne={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ae,Refinements:f({render:Pe,staticRenderFns:[]},undefined,De,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:me,Selector:ae,RefineFlavor:p}};var Ve=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ve._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>r?{}:{key:e},templateChildKey:e=>r?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,n(d,t)},components:{Criterion:f({render:Ve,staticRenderFns:[]},undefined,Ne,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:p,RenderlessCondition:ue,RenderlessQueryBuilder:de}};var Te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Te._withStripped=!0;const Le=f({render:Te,staticRenderFns:[]},undefined,Me,undefined,false,undefined,!1,void 0,void 0,void 0),Ge="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",He=`${Ge} ${ze} w-60 pl-3 py-2`,Ke={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ge} ${ze} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${He} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:He,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:He}},Ue="bg-white relative text-left cursor-default",Qe=`${Ue} focus:outline-none pl-3 py-1`,We={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ue} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Qe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Qe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Qe}}};export{Be as ConditionSelector,Re as DatePickerPlugin,je as Query,Le as QueryBuilder,$e as RefinePlugin,ae as Selector,me as SelectorOption,We as linearFlavor,Ke as tailwindFlavor};
//# sourceMappingURL=refine-vue.esm.js.map

@@ -1,2 +0,2 @@

import{reactive as e,nextTick as t,isVue2 as i,computed as n,inject as r,provide as o,defineComponent as s,h as l,onUnmounted as a}from"vue-demi";var d={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},c=e=>"conjunction"===(null==e?void 0:e.type),u=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,g=(e,t,i)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,y=(e,t)=>{for(var i in t||(t={}))v.call(t,i)&&g(e,i,t[i]);if(h)for(var i of h(t))m.call(t,i)&&g(e,i,t[i]);return e},b=(e,t)=>p(e,f(t)),w=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},O=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:y({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:w()}},x=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:w()}},_=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?b(y({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||w()}):b(y({},e),{id:void 0,uid:w()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)v.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&h)for(var n of h(e))t.indexOf(n)<0&&m.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{c(t)?"or"===t.word&&e.push([]):e[e.length-1].push(b(y({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=O(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=c(n)&&"or"===n.word,o=c(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:w()}}()),e.push(O(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=O(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,x(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,x(),O(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=y({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},C=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=y({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};function k(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const c="function"==typeof i?i.options:i;let u;if(e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),n&&(c._scopeId=n),o?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=u):t&&(u=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),u)if(c.functional){const e=c.render;c.render=function(t,i){return u.call(i),e(t,i)}}else{const e=c.beforeCreate;c.beforeCreate=e?[].concat(e,u):[u]}return i}const S=k({},void 0,{name:"renderless-selector",data:()=>({selector:e(new C),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return t().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return i&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),$={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let I=1;var R={beforeCreate(){this.uid=I.toString(),I+=1}};const q=Symbol();function B(e,t,i=n((()=>({})))){const o=r(q),s=n((()=>e(o)??{})),l=n((()=>{const e={},t=i.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=n((()=>{const e={},t=i.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const r=s.value.style;return r&&(e.style="function"==typeof r?r(t):r),e}));return n((()=>({component:s.value.component??t.value,props:a,extra:l})))}const E=s({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(e,t){const r=B((t=>{const i=e.component.split(".");let n=t;for(const e of i)n=n?.[e];return n}),n((()=>e.as)),n((()=>e.flavorOptions)));return()=>{const n=r.value,o=n.extra.value.order??e.order,s=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(e,["as","component","order"]),a=t.slots;let d="string"==typeof n.component&&n.component.includes("-")?a:o.map((e=>a?.[e]?.())),c=l(n.component,i?{scopedSlots:a,attrs:t.attrs,props:s,on:t.listeners,...n.props.value}:{...t.attrs,"data-flavor":e.component,...s,...n.props.value},d);return n.extra.value.wrap?n.extra.value.wrap(c):c}}}),j={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:E}};var F=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};F._withStripped=!0;const D=k({render:F,staticRenderFns:[]},void 0,j,void 0,!1,void 0,!1,void 0,void 0,void 0),A={name:"selector-listbox",mixins:[R],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:E}};var V=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};V._withStripped=!0;const M=k({render:V,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),P={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:E}};var N=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};N._withStripped=!0;const T=k({render:N,staticRenderFns:[]},void 0,P,void 0,!1,void 0,!1,void 0,void 0,void 0),z={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:E}};var L=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"div",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};L._withStripped=!0;const H=k({render:L,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0),G={name:"selector",mixins:[R],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:H,RenderlessSelector:S,SelectorListItem:T,SelectorButton:D,SelectorListbox:M,RefineFlavor:E}};var Y=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};Y._withStripped=!0;const U=k({render:Y,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0);var Q={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new _(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return i&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},W={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,t)=>((e,t,i)=>{const n=r("blueprint"),s=r("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!i)throw new Error("useCondition requires a Vue context.");if(!n)throw new Error("Conditions must be rendered within a query.");let l;l=s?n.findCriterion(t.uid):n.addCriterion({id:e,depth:0});const d=(e,t)=>n.updateInput(l,e,t),c=e=>n.switchClause(l,e);o("criterion",l),o("criterionMeta",t.meta),o("updateInput",d),o("switchRefinement",((e,t)=>{n.switchRefinement(l,e,t)})),o("refinementId",null),a((()=>{s||n.removeCriterion(n.indexOfCriterion(l))}));let u=null;return t?.condition?.meta?.clauses&&(u=t.condition.meta.clauses.map((e=>e.component))),()=>i.slots.default?i.slots.default({clauses:u,criterion:l,updateInput:d,switchClause:c}):null})(e.id,e,t)},K={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,i)=>{const n=r("criterion"),o=r("updateInput"),s=r("refinementId"),l=r("builderModeActive"),d=e=>{o(e,s)};if(!n)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:i,...r}=n.input;Object.keys(t).length>0&&0===Object.keys(r).length&&o({...t},s)}return a((()=>{l||n.input.clause===e&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...n.input}):null})(e.clause,e,t)},X={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(i&&(e=this.$scopedSlots?.default),e)return e()}};const Z={name:"selector-option",mixins:[$],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[$],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return i&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var J=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};J._withStripped=!0;const ee=k({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),te={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:U}};var ie=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};ie._withStripped=!0;const ne=k({render:ie,staticRenderFns:[]},void 0,te,void 0,!1,void 0,!1,void 0,void 0,void 0),re=k({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new _(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return i&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),oe={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:E}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};se._withStripped=!0;const le=k({render:se,staticRenderFns:[]},void 0,oe,void 0,!1,void 0,!1,void 0,void 0,void 0),ae={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:le,RefineFlavor:E}};var de=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};de._withStripped=!0;const ce=k({render:de,staticRenderFns:[]},void 0,ae,void 0,!1,void 0,!1,void 0,void 0,void 0),ue={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:E}};var pe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};pe._withStripped=!0;const fe=k({render:pe,staticRenderFns:[]},void 0,ue,void 0,!1,void 0,!1,void 0,void 0,void 0),he={setup:()=>({flavor:("inputs.date.pickerInput",B((e=>{const t="inputs.date.pickerInput".split(".");let i=e;for(const e of t)i=i?.[e];return i}),"",n((()=>{})))?.value)}),props:{date:{type:String,required:!1},format:{type:String,required:!1,default:"MM/DD/YYYY"}},emits:["input"],data(){const{date:e}=this;return{time:e,hasError:!1,inputClass:this.flavor.props.value?.class,errorClass:this.flavor.props.value?.class}},methods:{handleInputError:function(){this.hasError=!0},handleInput:function(){this.hasError=!1,this.$emit("input",{date:this.time})}},components:{RefineFlavor:E}};var ve=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date","value-type":"YYYY-MM-DD",format:e.format,"input-class":e.hasError?e.inputClass+e.errorClass:e.inputClass},on:{input:e.handleInput,change:e.handleInput,"input-error":e.handleInputError},scopedSlots:e._u([{key:"icon-calendar",fn:function(){return[e.hasError?e._e():i("refine-flavor",{attrs:{as:"svg",component:"input.date.calendar.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z","clip-rule":"evenodd"}})]),e._v(" "),e.hasError?i("refine-flavor",{attrs:{as:"svg",component:"input.date.error.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"}})]):e._e()]},proxy:!0}]),model:{value:e.time,callback:function(t){e.time=t},expression:"time"}},"refine-flavor",e.$attrs,!1))};ve._withStripped=!0;const me=k({render:ve,staticRenderFns:[]},void 0,he,void 0,!1,void 0,!1,void 0,void 0,void 0),ge={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:me},methods:{handleInput:function({date:e}){this.$emit("input",{date1:e})}}};var ye=function(){var e=this,t=e.$createElement;return(e._self._c||t)("date-picker",e._b({attrs:{date:e.date1},on:{input:e.handleInput}},"date-picker",e.$attrs,!1))};ye._withStripped=!0;const be=k({render:ye,staticRenderFns:[]},void 0,ge,void 0,!1,void 0,!1,void 0,void 0,void 0),we={name:"refine-double-date-input",components:{DatePicker:me,RefineFlavor:E},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},methods:{updateFirstDate:function({date:e}){this.$emit("input",{date1:e})},updateSecondDate:function({date:e}){this.$emit("input",{date2:e})}}};var Oe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("date-picker",e._b({attrs:{date:e.date1},on:{input:e.updateFirstDate}},"date-picker",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("date-picker",e._b({attrs:{date:e.date2},on:{input:e.updateSecondDate}},"date-picker",e.$attrs,!1))],1)};Oe._withStripped=!0;const xe=k({render:Oe,staticRenderFns:[]},void 0,we,void 0,!1,void 0,!1,void 0,void 0,void 0),_e={name:"refine-date-input",components:{Selector:U,SelectorOption:ee,RefineFlavor:E},mixins:[R],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var Ce=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};Ce._withStripped=!0;const ke=k({render:Ce,staticRenderFns:[]},void 0,_e,void 0,!1,void 0,!1,void 0,void 0,void 0),Se={name:"refine-option-input",components:{Selector:U,SelectorOption:ee},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var $e=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};$e._withStripped=!0;const Ie=k({render:$e,staticRenderFns:[]},void 0,Se,void 0,!1,void 0,!1,void 0,void 0,void 0);var Re={RefineDateInput:be,RefineDoubleDateInput:xe,RefineDoubleNumberInput:ce,RefineNumberInput:le,RefineOptionInput:Ie,RefineRelativeDateInput:ke,RefineTextInput:fe};const qe={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:K,SelectorOption:ee,Selector:U,...Object.freeze({__proto__:null,default:Re,RefineDateInput:be,RefineDoubleDateInput:xe,RefineDoubleNumberInput:ce,RefineNumberInput:le,RefineOptionInput:Ie,RefineRelativeDateInput:ke,RefineTextInput:fe})}};var Be=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Be._withStripped=!0;const Ee=k({render:Be,staticRenderFns:[]},void 0,qe,void 0,!1,void 0,!1,void 0,void 0,void 0),je={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ee,RenderlessRefinement:X,Selector:U,SelectorOption:ee},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Fe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Fe._withStripped=!0;const De={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ee,Refinements:k({render:Fe,staticRenderFns:[]},void 0,je,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:ee,Selector:U,RefineFlavor:E}};var Ae=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t.id,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t.message)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ae._withStripped=!0;const Ve={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,o(q,t)},components:{Criterion:k({render:Ae,staticRenderFns:[]},void 0,De,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:E,RenderlessCondition:W,RenderlessQueryBuilder:Q}};var Me=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,n){return i("refine-flavor",{key:n,attrs:{as:"div",component:"group"}},[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And ")])],1)],1)],2)})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Me._withStripped=!0;const Pe=k({render:Me,staticRenderFns:[]},void 0,Ve,void 0,!1,void 0,!1,void 0,void 0,void 0),Ne="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Te="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",ze=`${Ne} ${Te} w-60 pl-3 py-2`,Le={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} ${Te} block w-full pl-3 py-2 pr-0`},relative:{class:`${ze} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:ze,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:ze}}},He="bg-white relative text-left cursor-default",Ge=`${He} focus:outline-none pl-3 py-1`,Ye={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${He} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ge} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ge} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ge}}};export{ne as ConditionSelector,d as DatePickerPlugin,re as Query,Pe as QueryBuilder,U as Selector,ee as SelectorOption,Ye as linearFlavor,Le as tailwindFlavor};
import{computed as e,inject as t,provide as i,defineComponent as n,isVue2 as r,h as o,reactive as s,nextTick as l,onUnmounted as a}from"vue-demi";const d=Symbol();let u={};var c={init(e){u=e},get:(e,t=null)=>u?.[e]??t,set(e,t){u[e]=t}};const p=n({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(i,n){let s=c.get("showLocators");const l=function(i,n,r=e((()=>({})))){const o=t(d),s=e((()=>i(o)??{})),l=e((()=>{const e={},t=r.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=r.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const n=s.value.style;return n&&(e.style="function"==typeof n?n(t):n),e}));return e((()=>({component:s.value.component??n.value,props:a,extra:l})))}((e=>{const t=i.component.split(".");let n=e;for(const e of t)n=n?.[e];return"string"!=typeof n&&"function"!=typeof n||(n={class:n}),n}),e((()=>i.as)),e((()=>({...n.attrs??{},...i.flavorOptions??{}}))));return()=>{const e=l.value,t=e.extra.value.order??i.order,a=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(i,["as","component","order"]),d=n.slots;let u="string"==typeof e.component&&e.component.includes("-")?d:t.map((e=>d?.[e]?.())),c=o(e.component,r?{scopedSlots:d,attrs:{...s&&{"data-locator":i.component},...n.attrs},props:a,on:n.listeners,...e.props.value}:{...s&&{"data-locator":i.component},...n.attrs,...a,...e.props.value},u);return e.extra.value.wrap?e.extra.value.wrap(c):c}}});function f(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof i?i.options:i;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),n&&(u._scopeId=n),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,i){return c.call(i),e(t,i)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return i}const h={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:p}};var v=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};v._withStripped=!0;const m=f({render:v,staticRenderFns:[]},void 0,h,void 0,!1,void 0,!1,void 0,void 0,void 0),g={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:m,RefineFlavor:p}};var y=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};y._withStripped=!0;const b=f({render:y,staticRenderFns:[]},void 0,g,void 0,!1,void 0,!1,void 0,void 0,void 0),w={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:p}};var O=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};O._withStripped=!0;const x=f({render:O,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),_={name:"refine-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1}}};var C=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};C._withStripped=!0;const k=f({render:C,staticRenderFns:[]},void 0,_,void 0,!1,void 0,!1,void 0,void 0,void 0),S={name:"refine-double-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var $=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};$._withStripped=!0;const R=f({render:$,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0);var I=e=>"conjunction"===(null==e?void 0:e.type),q=Object.defineProperty,B=Object.defineProperties,j=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,D=(e,t,i)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t)=>{for(var i in t||(t={}))F.call(t,i)&&D(e,i,t[i]);if(E)for(var i of E(t))A.call(t,i)&&D(e,i,t[i]);return e},V=(e,t)=>B(e,j(t)),N=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},M=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:P({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:N()}},T=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:N()}},L=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?V(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||N()}):V(P({},e),{id:void 0,uid:N()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)F.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&E)for(var n of E(e))t.indexOf(n)<0&&A.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{I(t)?"or"===t.word&&e.push([]):e[e.length-1].push(V(P({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=M(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=I(n)&&"or"===n.word,o=I(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:N()}}()),e.push(M(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=M(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,T(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,T(),M(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=P({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},G=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=P({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const z=f({},void 0,{name:"renderless-selector",data:()=>({selector:s(new G),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return l().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return r&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),H={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let K=1;var U={beforeCreate(){this.uid=K.toString(),K+=1}};const Q={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:p}};var W=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};W._withStripped=!0;const X=f({render:W,staticRenderFns:[]},void 0,Q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"selector-listbox",mixins:[U],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:p}};var Z=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};Z._withStripped=!0;const J=f({render:Z,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),ee={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:p}};var te=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};te._withStripped=!0;const ie=f({render:te,staticRenderFns:[]},void 0,ee,void 0,!1,void 0,!1,void 0,void 0,void 0),ne={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:p}};var re=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};re._withStripped=!0;const oe=f({render:re,staticRenderFns:[]},void 0,ne,void 0,!1,void 0,!1,void 0,void 0,void 0),se={name:"selector",mixins:[U],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:oe,RenderlessSelector:z,SelectorListItem:ie,SelectorButton:X,SelectorListbox:J,RefineFlavor:p}};var le=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};le._withStripped=!0;const ae=f({render:le,staticRenderFns:[]},void 0,se,void 0,!1,void 0,!1,void 0,void 0,void 0);var de={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:i,conditionFor:n,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return r&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:i,conditionFor:n,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},ue={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,n)=>((e,n,r)=>{const o=t("blueprint"),s=t("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!r)throw new Error("useCondition requires a Vue context.");if(!o)throw new Error("Conditions must be rendered within a query.");let l;l=s?o.findCriterion(n.uid):o.addCriterion({id:e,depth:0});const d=(e,t)=>o.updateInput(l,e,t),u=e=>o.switchClause(l,e);i("criterion",l),i("criterionMeta",n.meta),i("updateInput",d),i("switchRefinement",((e,t)=>{o.switchRefinement(l,e,t)})),i("refinementId",null),a((()=>{s||o.removeCriterion(o.indexOfCriterion(l))}));let c=null;return n?.condition?.meta?.clauses&&(c=n.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,n)},ce={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,i)=>((e,i,n)=>{const r=t("criterion"),o=t("updateInput"),s=t("refinementId"),l=t("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:t,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return a((()=>{l||r.input.clause===e&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:d,...r.input}):null})(e.clause,e,i)},pe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(r&&(e=this.$scopedSlots?.default),e)return e()}};const fe={name:"selector-option",mixins:[H],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[H],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var he=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};he._withStripped=!0;const ve=f({render:he,staticRenderFns:[]},void 0,fe,void 0,!1,void 0,!1,void 0,void 0,void 0),me={name:"refine-date-input",components:{Selector:ae,SelectorOption:ve,RefineFlavor:p},mixins:[U],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ge=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ge._withStripped=!0;const ye=f({render:ge,staticRenderFns:[]},void 0,me,void 0,!1,void 0,!1,void 0,void 0,void 0),be={name:"refine-option-input",components:{Selector:ae,SelectorOption:ve},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var we=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};we._withStripped=!0;const Oe=f({render:we,staticRenderFns:[]},void 0,be,void 0,!1,void 0,!1,void 0,void 0,void 0),xe={emits:["input"],components:{RefineFlavor:p},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var _e=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};_e._withStripped=!0;const Ce=f({render:_e,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0);var ke={RefineDateInput:k,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:m,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce},Se=Object.freeze({__proto__:null,default:ke,RefineDateInput:k,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:m,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,c.init(t)}},Re={install:(e,t={})=>{$e.install(e,t)}};const Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ae}};var qe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};qe._withStripped=!0;const Be=f({render:qe,staticRenderFns:[]},void 0,Ie,void 0,!1,void 0,!1,void 0,void 0,void 0),je=f({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),Ee={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ce,SelectorOption:ve,Selector:ae,...Se}};var Fe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Fe._withStripped=!0;const Ae=f({render:Fe,staticRenderFns:[]},void 0,Ee,void 0,!1,void 0,!1,void 0,void 0,void 0),De={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ae,RenderlessRefinement:pe,Selector:ae,SelectorOption:ve},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Pe._withStripped=!0;const Ve={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ae,Refinements:f({render:Pe,staticRenderFns:[]},void 0,De,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:ve,Selector:ae,RefineFlavor:p}};var Ne=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ne._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>r?{}:{key:e},templateChildKey:e=>r?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,i(d,t)},components:{Criterion:f({render:Ne,staticRenderFns:[]},void 0,Ve,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:p,RenderlessCondition:ue,RenderlessQueryBuilder:de}};var Te=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,s){return[i("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),i("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:n.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Te._withStripped=!0;const Le=f({render:Te,staticRenderFns:[]},void 0,Me,void 0,!1,void 0,!1,void 0,void 0,void 0),Ge="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",He=`${Ge} ${ze} w-60 pl-3 py-2`,Ke={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ge} ${ze} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${He} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:He,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:He}},Ue="bg-white relative text-left cursor-default",Qe=`${Ue} focus:outline-none pl-3 py-1`,We={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ue} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Qe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Qe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Qe}}};export{Be as ConditionSelector,Re as DatePickerPlugin,je as Query,Le as QueryBuilder,$e as RefinePlugin,ae as Selector,ve as SelectorOption,We as linearFlavor,Ke as tailwindFlavor};
//# sourceMappingURL=refine-vue.esm.min.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=require("vue");var n=e=>"conjunction"===(null==e?void 0:e.type),o=Object.defineProperty,i=Object.defineProperties,r=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&c(e,n,t[n]);if(s)for(var n of s(t))a.call(t,n)&&c(e,n,t[n]);return e},p=(e,t)=>i(e,r(t)),u=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},h=(e,t,n,o)=>{var i,r;const[s]=o||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:d({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(i=null==s?void 0:s.meta)?void 0:i.clauses[0])?void 0:r.id}}),uid:u()}},m=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:u()}},f=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?p(d({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||u()}):p(d({},e),{id:void 0,uid:u()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var o in e)l.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&s)for(var o of s(e))t.indexOf(o)<0&&a.call(e,o)&&(n[o]=e[o]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,o)=>{n(t)?"or"===t.word&&e.push([]):e[e.length-1].push(p(d({},t),{position:o}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:o,refinements:i}=this.findCondition(t.id),r=h(o,1,n,i);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,o=t[e-1],i=t[e+1],r=n(i)&&"or"===i.word,s=n(o)&&"or"===o.word,l=r||!i,a=s||!o,c=a&&!l,d=a&&l;!o&&!i?this.blueprint=[]:d&&s?t.splice(e-1,2):d&&!o||c?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:o,refinements:i}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:u()}}()),e.push(h(n.id,1,o,i)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:o}=this,i=h(t,n);return 0===o.length?o.push(i):o.splice(o.length,0,m(),i),this.blueprintChanged(),i}insertCriterion(e){const{blueprint:t,conditions:n}=this,o=n[0],{meta:i,refinements:r}=o;return t.splice(e+1,0,m(),h(o.id,1,i,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let o;return n.forEach((e=>{e.id===t&&(o=e)})),o}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,o){const{meta:i}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(i.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},o)}switchRefinement({uid:e,id:t},n,o){const i=this.findRefinement(t,o),r=this.findCriterion(e),s=d({},r.input);delete s[n],s[o]={clause:i.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const o=this.findCriterion(e);Object.keys(t).forEach((e=>{n?o.input[n][e]=t[e]:o.input[e]=t[e]})),this.blueprintChanged()}},v=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const o=this.options[this.options.length-1]||null,i=d({previousOption:o,nextOption:null},e);o&&(o.nextOption=i),this.options.push(i)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},g={name:"renderless-selector",data:()=>({selector:e.reactive(new v),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:c}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:c}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:o}=t.toggleOption(e);return o?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const w={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let b=1;var y={beforeCreate(){this.uid=b.toString(),b+=1}};const C=Symbol();function x(t,n,o=e.computed((()=>({})))){const i=e.inject(C),r=e.computed((()=>t(i)??{})),s=e.computed((()=>{const e={},t=o.value??{};let n=r.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=r.value.wrap,e})),l=e.computed((()=>{const e={},t=o.value??{},n=r.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=r.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e.computed((()=>({component:r.value.component??n.value,props:l,extra:s})))}const O=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,n){const o=x((e=>{const n=t.component.split(".");let o=e;for(const e of n)o=o?.[e];return o}),e.computed((()=>t.as)),e.computed((()=>t.flavorOptions)));return()=>{const i=o.value,r=i.extra.value.order??t.order,s=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),l=n.slots;let a="string"==typeof i.component&&i.component.includes("-"),c=a?l:r.map((e=>l?.[e]?.())),d=e.isVue2?e.h(i.component,{scopedSlots:l,attrs:n.attrs,props:s,on:n.listeners,...i.props.value},c):e.h(a?e.resolveComponent(i.component):i.component,{...n.attrs,"data-flavor":t.component,...s,...i.props.value},c);return i.extra.value.wrap?i.extra.value.wrap(d):d}}});var k={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:O}};const B=t.createTextVNode(" Choose an option "),S=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);k.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.button",id:o.id,type:"button","aria-haspopup":"listbox","aria-expanded":o.isOpen,"aria-label":s.label(),ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:t.withCtx((()=>[0===o.display.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.button.placeholder"},{default:t.withCtx((()=>[B])),_:1})):(t.openBlock(),t.createBlock(l,{key:1,as:"span",component:"select.button.selected"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.display),1)])),_:1})),t.createVNode(l,{as:"span",component:"select.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[S])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},k.__file="src/components/base/selector/selector-button.vue";var _={name:"selector-listbox",mixins:[y],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:O}};_.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.listbox.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:o.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":o.selectedOption?s.createItemId(o.selectedOption.id):"",ref:"listBox",onKeydown:[t.withKeys(t.withModifiers(s.clearBuffer,["stop","prevent"]),["delete"]),n[0]||(n[0]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),n[1]||(n[1]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),n[3]||(n[3]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["escape"])),n[4]||(n[4]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["tab"])),n[5]||(n[5]=e=>s.handleKeypress(e))]},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default",{createItemId:s.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},_.__file="src/components/base/selector/selector-listbox.vue";var V={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:O}};const I=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);V.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:o.isHighlighted},role:"option",key:o.optionId,ref:"listItem",onMouseenter:n[0]||(n[0]=t=>e.$emit("mouseenter")),onMouseleave:n[1]||(n[1]=t=>e.$emit("mouseleave")),onClick:n[2]||(n[2]=t=>e.$emit("selected")),"aria-label":o.optionDisplay,"aria-selected":o.selected},{default:t.withCtx((()=>[t.createVNode(l,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:o.selected}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.optionDisplay),1)])),_:1},8,["flavorOptions"]),t.createVNode(l,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:o.isHighlighted}},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: check "),t.withDirectives(t.createVNode(l,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!o.selected},{default:t.withCtx((()=>[I])),_:1},8,["aria-hidden"]),[[t.vShow,o.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},V.__file="src/components/base/selector/selector-list-item.vue";var N={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:O}};const $=t.createTextVNode(" Choose an option "),q=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),j=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);N.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.multi.button",id:o.id,"aria-haspopup":"listbox","aria-label":s.label(),"aria-expanded":o.isOpen,ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:[n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["enter"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:t.withCtx((()=>[0===o.selectedOptions.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:t.withCtx((()=>[$])),_:1})):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(o.selectedOptions,(({id:n,display:o})=>(t.openBlock(),t.createBlock(l,{as:"span",component:"select.multi.button.selected",key:n},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o)+" ",1),t.createVNode(l,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:t.withModifiers((t=>e.$emit("deselect-option",n)),["prevent"])},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[q])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),t.createVNode(l,{as:"span",component:"select.multi.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[j])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},N.__file="src/components/base/selector/multi-selector-button.vue";var R={name:"selector",mixins:[y],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:o}=n;if("function"!=typeof o)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const i=e=>{t.contains(e.target)||o()};e[t.id]=i,document.addEventListener("click",i),document.addEventListener("touchstart",i)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const o=t.find((t=>t.display.toLowerCase().includes(e)));o&&(n.highlightOption(o),this.scrollIntoView(o.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:o,toggleOption:i}=t,{isMultiSelect:r}=this;r?i(e):(n(),o(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:N,RenderlessSelector:g,SelectorListItem:V,SelectorButton:k,SelectorListbox:_,RefineFlavor:O}};R.render=function(e,n,o,i,r,s){const l=t.resolveComponent("multi-selector-button"),a=t.resolveComponent("selector-button"),c=t.resolveComponent("selector-list-item"),d=t.resolveComponent("selector-listbox"),p=t.resolveComponent("refine-flavor"),u=t.resolveComponent("renderless-selector"),h=t.resolveDirective("click-away");return t.openBlock(),t.createBlock(u,{onSelectOption:n[0]||(n[0]=t=>e.$emit("select-option",t)),onDeselectOption:n[1]||(n[1]=t=>e.$emit("deselect-option",t))},{default:t.withCtx((({actions:n,isOpen:i,isClosed:r,selectedOptions:u,highlightedOption:m,options:f})=>[t.createVNode(p,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(p,{as:"div",component:"select",class:t.normalizeClass(o.innerClass),id:`listbox-${s.selectorId}`,"aria-labelledby":s.buttonId},{default:t.withCtx((()=>[o.isMultiSelect?(t.openBlock(),t.createBlock(l,{key:0,id:s.buttonId,isOpen:i,selectedOptions:u,onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),onDeselectOption:e=>s.deselectOption(e,n),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(t.openBlock(),t.createBlock(a,{key:1,id:s.buttonId,isOpen:i,display:u[0]?u[0].display:"",onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),t.createVNode(d,{selectedOption:u[0],isClosed:r,ref:"listBox",onHighlightNextOption:e=>s.highlightNextOption(n),onHighlightPreviousOption:e=>s.highlightPreviousOption(n),onSelectOption:e=>s.selectOption(m.id,n),onBufferChanged:e=>s.updateBuffer(e,f,n),onClose:e=>s.close(n)},{default:t.withCtx((({createItemId:e})=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f,(o=>(t.openBlock(),t.createBlock(c,{id:e(o.id),key:o.id,optionId:o.id,optionDisplay:o.display,selected:s.isSelected(o,u),isHighlighted:m&&o.id===m.id,ref_for:!0,ref:o.id,onMouseenter:e=>n.highlightOption(o),onMouseleave:e=>n.highlightOption(null),onSelected:e=>s.selectOption(o.id,n)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[h,n.close]]),t.createCommentVNode(" Custom options "),t.createVNode(p,{as:"div",component:"customOptions.wrapper"},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},R.__file="src/components/base/selector/selector.vue";var E={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new f(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:o,type:i,display:r,meta:s}=this.conditionsLookup[t];return{id:o,type:i,display:r,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:o,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:o,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:o.groupedBlueprint()}):null}},M={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("blueprint"),r=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let s;s=r?i.findCriterion(n.uid):i.addCriterion({id:t,depth:0});const l=(e,t)=>i.updateInput(s,e,t),a=e=>i.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{i.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{r||i.removeCriterion(i.indexOfCriterion(s))}));let c=null;return n?.condition?.meta?.clauses&&(c=n.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:c,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,n)},D={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("criterion"),r=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{r(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:t},s);const{clause:e,...o}=i.input;Object.keys(n).length>0&&0===Object.keys(o).length&&r({...n},s)}return e.onUnmounted((()=>{l||i.input.clause===t&&r({clause:void 0},s)})),()=>o.slots.default?o.slots.default({setValue:a,...i.input}):null})(t.clause,t,n)},A={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}},F={name:"selector-option",mixins:[w],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[w],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:o}=this;o.registerOption({id:e,display:t||e,...this.$attrs}),n&&o.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};F.render=function(e,n,o,i,r,s){const l=t.resolveComponent("renderless-option");return t.openBlock(),t.createBlock(l,{id:e.id,display:e.display,selected:e.selected},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["id","display","selected"])},F.__file="src/components/base/selector/selector-option.vue";var T={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:R}};T.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{onSelectOption:s.selectOption},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["onSelectOption"])},T.__file="src/components/base/condition-selector/condition-selector.vue";var P={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new f(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null},__file:"src/components/renderless/query.vue"},L={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:O}};L.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"input",component:"inputs.number",type:"number",value:r.currentValue,onInput:s.handleInputChange},s.metaAttributes),null,16,["value","onInput"])},L.__file="src/components/base/inputs/number-input.vue";var H={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:L,RefineFlavor:O}};H.render=function(e,n,o,i,r,s){const l=t.resolveComponent("number-input"),a=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(a,{as:"div",component:"inputs.number.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{meta:o.meta,value:o.value1,onInput:s.updateFirstValue},null,8,["meta","value","onInput"]),s.joinWord?(t.openBlock(),t.createBlock(a,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(s.joinWord),1)])),_:1})):t.createCommentVNode("v-if",!0),t.createVNode(l,{meta:o.meta,value:o.value2,onInput:s.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},H.__file="src/components/base/inputs/double-number-input.vue";var z={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:O}};z.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.text",type:"text",value:o.value,onInput:n[0]||(n[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},z.__file="src/components/base/inputs/text-input.vue";var G={setup(){var t,n;return{flavor:(t="inputs.date.pickerInput",x((e=>{const n=t.split(".");let o=e;for(const e of n)o=o?.[e];return o}),"",e.computed((()=>n)))?.value)}},props:{date:{type:String,required:!1},format:{type:String,required:!1,default:"MM/DD/YYYY"}},emits:["input"],data(){const{date:e}=this;return{time:e,hasError:!1,inputClass:this.flavor.props.value?.class,errorClass:this.flavor.props.value?.class}},methods:{handleInputError:function(){this.hasError=!0},handleInput:function(){this.hasError=!1,this.$emit("input",{date:this.time})}},components:{RefineFlavor:O}};const K=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z","clip-rule":"evenodd"},null,-1),Y=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);G.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date",value:r.time,"onUpdate:value":n[0]||(n[0]=e=>r.time=e),"value-type":"YYYY-MM-DD",format:o.format},e.$attrs,{onInput:s.handleInput,onChange:s.handleInput,onInputError:s.handleInputError,"input-class":r.hasError?r.inputClass+r.errorClass:r.inputClass}),{"icon-calendar":t.withCtx((()=>[r.hasError?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock(l,{key:0,as:"svg",component:"input.date.calendar.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[K])),_:1})),r.hasError?(t.openBlock(),t.createBlock(l,{key:1,as:"svg",component:"input.date.error.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[Y])),_:1})):t.createCommentVNode("v-if",!0)])),_:1},16,["value","format","onInput","onChange","onInputError","input-class"])},G.__file="src/components/base/inputs/date-picker.vue";var U={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:G},methods:{handleInput:function({date:e}){this.$emit("input",{date1:e})}}};U.render=function(e,n,o,i,r,s){const l=t.resolveComponent("date-picker");return t.openBlock(),t.createBlock(l,t.mergeProps({onInput:s.handleInput,date:o.date1},e.$attrs),null,16,["onInput","date"])},U.__file="src/components/base/inputs/date-input.vue";var W={name:"refine-double-date-input",components:{DatePicker:G,RefineFlavor:O},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},methods:{updateFirstDate:function({date:e}){this.$emit("input",{date1:e})},updateSecondDate:function({date:e}){this.$emit("input",{date2:e})}}};W.render=function(e,n,o,i,r,s){const l=t.resolveComponent("date-picker"),a=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(a,{as:"div",component:"inputs.date.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,t.mergeProps({date:o.date1,onInput:s.updateFirstDate},e.$attrs),null,16,["date","onInput"]),t.createVNode(a,{as:"p",component:"inputs.date.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.joiner),1)])),_:1}),t.createVNode(l,t.mergeProps({date:o.date2,onInput:s.updateSecondDate},e.$attrs),null,16,["date","onInput"])])),_:1})},W.__file="src/components/base/inputs/double-date-input.vue";var Q={name:"refine-date-input",components:{Selector:R,SelectorOption:F,RefineFlavor:O},mixins:[y],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};Q.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),a=t.resolveComponent("selector-option"),c=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.relative.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:o.amount,onInput:s.updateAmount},null,8,["value","onInput"]),t.createVNode(c,{onSelectOption:s.updateUnit},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.units,(e=>(t.openBlock(),t.createBlock(a,{key:e.id,id:e.id,display:e.display,selected:e.id===o.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),t.createVNode(c,{onSelectOption:s.updateModifier},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.modifiers,(e=>(t.openBlock(),t.createBlock(a,{key:e.id,id:e.id,selected:e.id===o.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},Q.__file="src/components/base/inputs/relative-date-input.vue";var Z={name:"refine-option-input",components:{Selector:R,SelectorOption:F},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};Z.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),a=t.resolveComponent("selector");return t.openBlock(),t.createBlock(a,{isMultiSelect:o.multiple,onSelectOption:s.selectOption,onDeselectOption:s.deselectOption},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.options,(({id:e,display:n})=>(t.openBlock(),t.createBlock(l,{key:e,id:e,display:n,selected:s.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},Z.__file="src/components/base/inputs/option-input.vue";var J={RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:Z,RefineRelativeDateInput:Q,RefineTextInput:z},X={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:D,SelectorOption:F,Selector:R,...Object.freeze({__proto__:null,default:J,RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:Z,RefineRelativeDateInput:Q,RefineTextInput:z})}};X.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),a=t.resolveComponent("selector"),c=t.resolveComponent("renderless-clause");return t.openBlock(),t.createBlock(c,t.normalizeProps(t.guardReactiveProps(o.input)),{default:t.withCtx((({setValue:e})=>[t.createCommentVNode(" clause selector "),t.createVNode(a,{onSelectOption:s.switchClause,innerClass:"refine-clause-selector"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.meta.clauses,(({id:n,display:i,component:r,meta:s})=>(t.openBlock(),t.createBlock(l,{key:n,id:n,display:i,selected:o.input.clause===n},{default:t.withCtx((()=>[r?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r),t.mergeProps({key:0},{...o.meta,...s,...o.input},{onInput:e}),null,16,["onInput"])):t.createCommentVNode("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},X.__file="src/components/base/query-builder/clause.vue";var ee={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:X,RenderlessRefinement:A,Selector:R,SelectorOption:F},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};ee.render=function(e,n,o,i,r,s){const l=t.resolveComponent("clause"),a=t.resolveComponent("renderless-refinement"),c=t.resolveComponent("selector-option"),d=t.resolveComponent("selector");return t.openBlock(),t.createBlock(d,{onSelectOption:s.selectRefinement},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.refinements,(({id:e,meta:n,display:i})=>(t.openBlock(),t.createBlock(c,{key:e,id:e,display:i,selected:!!o.input[e]},{default:t.withCtx((()=>[t.createVNode(a,{id:e},{default:t.withCtx((()=>[t.createVNode(l,{meta:n,input:o.input[e],onSwitchClause:({id:t})=>s.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},ee.__file="src/components/base/query-builder/refinements.vue";var te={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:X,Refinements:ee,SelectorOption:F,Selector:R,RefineFlavor:O}};const ne=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);te.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),a=t.resolveComponent("clause"),c=t.resolveComponent("refinements"),d=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:t.withCtx((()=>[o.errors.length>0?(t.openBlock(),t.createBlock(l,{key:0,as:"ul",component:"criterion.errors"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.errors,(e=>(t.openBlock(),t.createBlock(l,{as:"li",component:"criterion.errors.error",key:e.id},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e.message),1)])),_:2},1024)))),128))])),_:1})):t.createCommentVNode("v-if",!0)])),selector:t.withCtx((()=>[t.createVNode(p,{onSelectOption:s.switchCondition},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.conditions,(({id:e,display:n,meta:i,refinements:r})=>(t.openBlock(),t.createBlock(d,{key:e,id:e,display:n,selected:o.conditionId===e},{default:t.withCtx((()=>[t.createElementVNode("div",null,[t.createVNode(a,{input:o.input,meta:i,onSwitchClause:s.switchClause},null,8,["input","meta","onSwitchClause"]),r&&r.length>0?(t.openBlock(),t.createBlock(c,{key:0,input:o.input,refinements:r},null,8,["input","refinements"])):t.createCommentVNode("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"criterion.removeCriterionButton",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[ne])),_:1})])),_:1})])),_:1})},te.__file="src/components/base/query-builder/criterion.vue";var oe={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var n;n=t.flavor,e.provide(C,n)},components:{Criterion:te,RefineFlavor:O,RenderlessCondition:M,RenderlessQueryBuilder:E}};const ie=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),re=t.createTextVNode(" Add a new condition "),se=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),le=t.createTextVNode(" And "),ae=t.createTextVNode(" Add an 'Or' ");oe.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),a=t.resolveComponent("criterion"),c=t.resolveComponent("renderless-condition"),d=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(d,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:s,conditionFor:d})=>[t.createCommentVNode(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(t.openBlock(),t.createBlock(l,t.mergeProps({key:0,as:"div",component:"emptyGroup"},{addGroup:r},{order:["button","default"]}),{button:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"emptyGroup.addCriterionButton",onClick:r,tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[ie])),_:1}),t.createVNode(l,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:t.withCtx((()=>[re])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(t.openBlock(),t.createBlock(l,{key:1,as:"div",component:"group.wrapper"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,((e,r)=>(t.openBlock(),t.createBlock(l,{as:"div",component:"group",key:r},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,(e=>(t.openBlock(),t.createBlock(l,{as:"div",component:"condition",key:e.uid},{default:t.withCtx((()=>[t.createVNode(c,t.normalizeProps(t.guardReactiveProps(d({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(a,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>s(e.position),onSwitchCondition:t=>n(e.position,d(t)),conditionId:e.condition_id,conditions:o.conditions,errors:o.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),t.createVNode(l,{as:"div",component:"group.addCriterionButton.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"group.addCriterionButton",onClick:t=>i(e[e.length-1].position),tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1024)))),128)),t.createVNode(l,{as:"button",component:"addGroupButton",onClick:r,type:"button"},{default:t.withCtx((()=>[ae])),_:2},1032,["onClick"])])),_:2},1024)),t.createCommentVNode(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},oe.__file="src/components/base/query-builder/query-builder.vue";const ce="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",de="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",pe=`${ce} ${de} w-60 pl-3 py-2`,ue={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${ce} ${de} block w-full pl-3 py-2 pr-0`},relative:{class:`${pe} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:pe,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:pe}}},he="bg-white relative text-left cursor-default",me=`${he} focus:outline-none pl-3 py-1`,fe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${he} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:me}}};exports.ConditionSelector=T,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=P,exports.QueryBuilder=oe,exports.Selector=R,exports.SelectorOption=F,exports.linearFlavor=fe,exports.tailwindFlavor=ue;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=require("vue");const n=Symbol();let o={};var i={init(e){o=e},get:(e,t=null)=>o?.[e]??t,set(e,t){o[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,o){let r=i.get("showLocators");const s=function(t,o,i=e.computed((()=>({})))){const r=e.inject(n),s=e.computed((()=>t(r)??{})),l=e.computed((()=>{const e={},t=i.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),c=e.computed((()=>{const e={},t=i.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const o=s.value.style;return o&&(e.style="function"==typeof o?o(t):o),e}));return e.computed((()=>({component:s.value.component??o.value,props:c,extra:l})))}((e=>{const n=t.component.split(".");let o=e;for(const e of n)o=o?.[e];return"string"!=typeof o&&"function"!=typeof o||(o={class:o}),o}),e.computed((()=>t.as)),e.computed((()=>({...o.attrs??{},...t.flavorOptions??{}}))));return()=>{const n=s.value,i=n.extra.value.order??t.order,l=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),c=o.slots;let a="string"==typeof n.component&&n.component.includes("-"),d=a?c:i.map((e=>c?.[e]?.())),p=e.isVue2?e.h(n.component,{scopedSlots:c,attrs:{...r&&{"data-locator":t.component},...o.attrs},props:l,on:o.listeners,...n.props.value},d):e.h(a?e.resolveComponent(n.component):n.component,{...r&&{"data-locator":t.component},...o.attrs,...l,...n.props.value},d);return n.extra.value.wrap?n.extra.value.wrap(p):p}}});var s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:r}};s.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"input",component:"inputs.number",type:"number",value:r.currentValue,onInput:s.handleInputChange},s.metaAttributes),null,16,["value","onInput"])},s.__file="src/components/base/inputs/number-input.vue";var l={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:s,RefineFlavor:r}};l.render=function(e,n,o,i,r,s){const l=t.resolveComponent("number-input"),c=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(c,{as:"div",component:"inputs.number.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{meta:o.meta,value:o.value1,onInput:s.updateFirstValue},null,8,["meta","value","onInput"]),s.joinWord?(t.openBlock(),t.createBlock(c,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(s.joinWord),1)])),_:1})):t.createCommentVNode("v-if",!0),t.createVNode(l,{meta:o.meta,value:o.value2,onInput:s.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},l.__file="src/components/base/inputs/double-number-input.vue";var c={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};c.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.text",type:"text",value:o.value,onInput:n[0]||(n[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},c.__file="src/components/base/inputs/text-input.vue";var a={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};a.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},a.__file="src/components/base/inputs/date-input.vue";var d={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};d.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),t.createVNode(l,{as:"p",component:"inputs.date.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.joiner),1)])),_:1}),t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date2,onInput:n[1]||(n[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},d.__file="src/components/base/inputs/double-date-input.vue";var p=e=>"conjunction"===(null==e?void 0:e.type),u=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))v.call(t,n)&&b(e,n,t[n]);if(f)for(var n of f(t))g.call(t,n)&&b(e,n,t[n]);return e},y=(e,t)=>h(e,m(t)),C=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},x=(e,t,n,o)=>{var i,r;const[s]=o||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:w({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(i=null==s?void 0:s.meta)?void 0:i.clauses[0])?void 0:r.id}}),uid:C()}},O=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:C()}},k=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?y(w({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||C()}):y(w({},e),{id:void 0,uid:C()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var o in e)v.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&f)for(var o of f(e))t.indexOf(o)<0&&g.call(e,o)&&(n[o]=e[o]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{p(t)?"or"===t.word&&e.push([]):e[e.length-1].push(y(w({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:o,refinements:i}=this.findCondition(t.id),r=x(o,1,n,i);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],o=t[e+1],i=p(o)&&"or"===o.word,r=p(n)&&"or"===n.word,s=i||!o,l=r||!n,c=l&&!s,a=l&&s;!n&&!o?this.blueprint=[]:a&&r?t.splice(e-1,2):a&&!n||c?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:o,refinements:i}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:C()}}()),e.push(x(n.id,1,o,i)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:o}=this,i=x(t,n);return 0===o.length?o.push(i):o.splice(o.length,0,O(),i),this.blueprintChanged(),i}insertCriterion(e){const{blueprint:t,conditions:n}=this,o=n[0],{meta:i,refinements:r}=o;return t.splice(e+1,0,O(),x(o.id,1,i,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let o;return n.forEach((e=>{e.id===t&&(o=e)})),o}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,o){const{meta:i}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(i.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},o)}switchRefinement({uid:e,id:t},n,o){const i=this.findRefinement(t,o),r=this.findCriterion(e),s=w({},r.input);delete s[n],s[o]={clause:i.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const o=this.findCriterion(e);Object.keys(t).forEach((e=>{n?o.input[n][e]=t[e]:o.input[e]=t[e]})),this.blueprintChanged()}},B=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const o=this.options[this.options.length-1]||null,i=w({previousOption:o,nextOption:null},e);o&&(o.nextOption=i),this.options.push(i)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},S={name:"renderless-selector",data:()=>({selector:e.reactive(new B),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:o}=t.toggleOption(e);return o?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const _={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let V=1;var N={beforeCreate(){this.uid=V.toString(),V+=1}},$={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};const I=t.createTextVNode(" Choose an option "),q=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);$.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.button",id:o.id,type:"button","aria-haspopup":"listbox","aria-expanded":o.isOpen,"aria-label":s.label(),ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:t.withCtx((()=>[0===o.display.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.button.placeholder"},{default:t.withCtx((()=>[I])),_:1})):(t.openBlock(),t.createBlock(l,{key:1,as:"span",component:"select.button.selected"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.display),1)])),_:1})),t.createVNode(l,{as:"span",component:"select.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[q])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},$.__file="src/components/base/selector/selector-button.vue";var R={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};R.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.listbox.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:o.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":o.selectedOption?s.createItemId(o.selectedOption.id):"",ref:"listBox",onKeydown:[t.withKeys(t.withModifiers(s.clearBuffer,["stop","prevent"]),["delete"]),n[0]||(n[0]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),n[1]||(n[1]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),n[3]||(n[3]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["escape"])),n[4]||(n[4]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["tab"])),n[5]||(n[5]=e=>s.handleKeypress(e))]},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default",{createItemId:s.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},R.__file="src/components/base/selector/selector-listbox.vue";var j={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};const M=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);j.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:o.isHighlighted},role:"option",key:o.optionId,ref:"listItem",onMouseenter:n[0]||(n[0]=t=>e.$emit("mouseenter")),onMouseleave:n[1]||(n[1]=t=>e.$emit("mouseleave")),onClick:n[2]||(n[2]=t=>e.$emit("selected")),"aria-label":o.optionDisplay,"aria-selected":o.selected},{default:t.withCtx((()=>[t.createVNode(l,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:o.selected}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.optionDisplay),1)])),_:1},8,["flavorOptions"]),t.createVNode(l,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:o.isHighlighted}},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: check "),t.withDirectives(t.createVNode(l,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!o.selected},{default:t.withCtx((()=>[M])),_:1},8,["aria-hidden"]),[[t.vShow,o.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},j.__file="src/components/base/selector/selector-list-item.vue";var E={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};const A=t.createTextVNode(" Choose an option "),D=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),P=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);E.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.multi.button",id:o.id,"aria-haspopup":"listbox","aria-label":s.label(),"aria-expanded":o.isOpen,ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:[n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["enter"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:t.withCtx((()=>[0===o.selectedOptions.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:t.withCtx((()=>[A])),_:1})):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(o.selectedOptions,(({id:n,display:o})=>(t.openBlock(),t.createBlock(l,{as:"span",component:"select.multi.button.selected",key:n},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o)+" ",1),t.createVNode(l,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:t.withModifiers((t=>e.$emit("deselect-option",n)),["prevent"])},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[D])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),t.createVNode(l,{as:"span",component:"select.multi.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[P])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},E.__file="src/components/base/selector/multi-selector-button.vue";var F={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:o}=n;if("function"!=typeof o)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const i=e=>{t.contains(e.target)||o()};e[t.id]=i,document.addEventListener("click",i),document.addEventListener("touchstart",i)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const o=t.find((t=>t.display.toLowerCase().includes(e)));o&&(n.highlightOption(o),this.scrollIntoView(o.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:o,toggleOption:i}=t,{isMultiSelect:r}=this;r?i(e):(n(),o(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:E,RenderlessSelector:S,SelectorListItem:j,SelectorButton:$,SelectorListbox:R,RefineFlavor:r}};F.render=function(e,n,o,i,r,s){const l=t.resolveComponent("multi-selector-button"),c=t.resolveComponent("selector-button"),a=t.resolveComponent("selector-list-item"),d=t.resolveComponent("selector-listbox"),p=t.resolveComponent("refine-flavor"),u=t.resolveComponent("renderless-selector"),h=t.resolveDirective("click-away");return t.openBlock(),t.createBlock(u,{onSelectOption:n[0]||(n[0]=t=>e.$emit("select-option",t)),onDeselectOption:n[1]||(n[1]=t=>e.$emit("deselect-option",t))},{default:t.withCtx((({actions:n,isOpen:i,isClosed:r,selectedOptions:u,highlightedOption:m,options:f})=>[t.createVNode(p,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(p,{as:"div",component:"select",class:t.normalizeClass(o.innerClass),id:`listbox-${s.selectorId}`,"aria-labelledby":s.buttonId},{default:t.withCtx((()=>[o.isMultiSelect?(t.openBlock(),t.createBlock(l,{key:0,id:s.buttonId,isOpen:i,selectedOptions:u,onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),onDeselectOption:e=>s.deselectOption(e,n),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(t.openBlock(),t.createBlock(c,{key:1,id:s.buttonId,isOpen:i,display:u[0]?u[0].display:"",onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),t.createVNode(d,{selectedOption:u[0],isClosed:r,ref:"listBox",onHighlightNextOption:e=>s.highlightNextOption(n),onHighlightPreviousOption:e=>s.highlightPreviousOption(n),onSelectOption:e=>s.selectOption(m.id,n),onBufferChanged:e=>s.updateBuffer(e,f,n),onClose:e=>s.close(n)},{default:t.withCtx((({createItemId:e})=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f,(o=>(t.openBlock(),t.createBlock(a,{id:e(o.id),key:o.id,optionId:o.id,optionDisplay:o.display,selected:s.isSelected(o,u),isHighlighted:m&&o.id===m.id,ref_for:!0,ref:o.id,onMouseenter:e=>n.highlightOption(o),onMouseleave:e=>n.highlightOption(null),onSelected:e=>s.selectOption(o.id,n)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[h,n.close]]),t.createCommentVNode(" Custom options "),t.createVNode(p,{as:"div",component:"customOptions.wrapper"},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},F.__file="src/components/base/selector/selector.vue";var T={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new k(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:o,type:i,display:r,meta:s}=this.conditionsLookup[t];return{id:o,type:i,display:r,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:o,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:o,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:o.groupedBlueprint()}):null}},L={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("blueprint"),r=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let s;s=r?i.findCriterion(n.uid):i.addCriterion({id:t,depth:0});const l=(e,t)=>i.updateInput(s,e,t),c=e=>i.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{i.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{r||i.removeCriterion(i.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:c}):null})(t.id,t,n)},H={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("criterion"),r=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),c=e=>{r(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:t},s);const{clause:e,...o}=i.input;Object.keys(n).length>0&&0===Object.keys(o).length&&r({...n},s)}return e.onUnmounted((()=>{l||i.input.clause===t&&r({clause:void 0},s)})),()=>o.slots.default?o.slots.default({setValue:c,...i.input}):null})(t.clause,t,n)},K={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}},z={name:"selector-option",mixins:[_],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[_],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:o}=this;o.registerOption({id:e,display:t||e,...this.$attrs}),n&&o.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};z.render=function(e,n,o,i,r,s){const l=t.resolveComponent("renderless-option");return t.openBlock(),t.createBlock(l,{id:e.id,display:e.display,selected:e.selected},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["id","display","selected"])},z.__file="src/components/base/selector/selector-option.vue";var G={name:"refine-date-input",components:{Selector:F,SelectorOption:z,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};G.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("selector-option"),a=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.relative.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:o.amount,onInput:s.updateAmount},null,8,["value","onInput"]),t.createVNode(a,{onSelectOption:s.updateUnit},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.units,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,display:e.display,selected:e.id===o.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),t.createVNode(a,{onSelectOption:s.updateModifier},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.modifiers,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,selected:e.id===o.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},G.__file="src/components/base/inputs/relative-date-input.vue";var U={name:"refine-option-input",components:{Selector:F,SelectorOption:z},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};U.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector");return t.openBlock(),t.createBlock(c,{isMultiSelect:o.multiple,onSelectOption:s.selectOption,onDeselectOption:s.deselectOption},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.options,(({id:e,display:n})=>(t.openBlock(),t.createBlock(l,{key:e,id:e,display:n,selected:s.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},U.__file="src/components/base/inputs/option-input.vue";var W={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};W.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.date",type:"date",value:o.date,onInput:s.handleInput},null,8,["value","onInput"])},W.__file="src/components/base/inputs/native-date-picker.vue";var Q={RefineDateInput:a,RefineDoubleDateInput:d,RefineDoubleNumberInput:l,RefineNumberInput:s,RefineOptionInput:U,RefineRelativeDateInput:G,RefineTextInput:c,RefineNativeDatePicker:W},Y=Object.freeze({__proto__:null,default:Q,RefineDateInput:a,RefineDoubleDateInput:d,RefineDoubleNumberInput:l,RefineNumberInput:s,RefineOptionInput:U,RefineRelativeDateInput:G,RefineTextInput:c,RefineNativeDatePicker:W}),Z={install:(e,t={})=>{t={DatePicker:W,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,i.init(t)}},J={install:(e,t={})=>{Z.install(e,t)}},X={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:F}};X.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{onSelectOption:s.selectOption},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["onSelectOption"])},X.__file="src/components/base/condition-selector/condition-selector.vue";var ee={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new k(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null},__file:"src/components/renderless/query.vue"},te={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:H,SelectorOption:z,Selector:F,...Y}};te.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector"),a=t.resolveComponent("renderless-clause");return t.openBlock(),t.createBlock(a,t.normalizeProps(t.guardReactiveProps(o.input)),{default:t.withCtx((({setValue:e})=>[t.createCommentVNode(" clause selector "),t.createVNode(c,{onSelectOption:s.switchClause,innerClass:"refine-clause-selector"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.meta.clauses,(({id:n,display:i,component:r,meta:s})=>(t.openBlock(),t.createBlock(l,{key:n,id:n,display:i,selected:o.input.clause===n},{default:t.withCtx((()=>[r?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r),t.mergeProps({key:0},{...o.meta,...s,...o.input},{onInput:e}),null,16,["onInput"])):t.createCommentVNode("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},te.__file="src/components/base/query-builder/clause.vue";var ne={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:te,RenderlessRefinement:K,Selector:F,SelectorOption:z},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};ne.render=function(e,n,o,i,r,s){const l=t.resolveComponent("clause"),c=t.resolveComponent("renderless-refinement"),a=t.resolveComponent("selector-option"),d=t.resolveComponent("selector");return t.openBlock(),t.createBlock(d,{onSelectOption:s.selectRefinement},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.refinements,(({id:e,meta:n,display:i})=>(t.openBlock(),t.createBlock(a,{key:e,id:e,display:i,selected:!!o.input[e]},{default:t.withCtx((()=>[t.createVNode(c,{id:e},{default:t.withCtx((()=>[t.createVNode(l,{meta:n,input:o.input[e],onSwitchClause:({id:t})=>s.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},ne.__file="src/components/base/query-builder/refinements.vue";var oe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:te,Refinements:ne,SelectorOption:z,Selector:F,RefineFlavor:r}};const ie=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);oe.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("clause"),a=t.resolveComponent("refinements"),d=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:t.withCtx((()=>[o.errors.length>0?(t.openBlock(),t.createBlock(l,{key:0,as:"ul",component:"criterion.errors"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.errors,(e=>(t.openBlock(),t.createBlock(l,{as:"li",component:"criterion.errors.error",key:e},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e),1)])),_:2},1024)))),128))])),_:1})):t.createCommentVNode("v-if",!0)])),selector:t.withCtx((()=>[t.createVNode(p,{onSelectOption:s.switchCondition},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.conditions,(({id:e,display:n,meta:i,refinements:r})=>(t.openBlock(),t.createBlock(d,{key:e,id:e,display:n,selected:o.conditionId===e},{default:t.withCtx((()=>[t.createElementVNode("div",null,[t.createVNode(c,{input:o.input,meta:i,onSwitchClause:s.switchClause},null,8,["input","meta","onSwitchClause"]),r&&r.length>0?(t.openBlock(),t.createBlock(a,{key:0,input:o.input,refinements:r},null,8,["input","refinements"])):t.createCommentVNode("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"criterion.removeCriterionButton",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[ie])),_:1})])),_:1})])),_:1})},oe.__file="src/components/base/query-builder/criterion.vue";var re={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var o;o=t.flavor,e.provide(n,o)},components:{Criterion:oe,RefineFlavor:r,RenderlessCondition:L,RenderlessQueryBuilder:T}};const se=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),le=t.createTextVNode(" Add a new condition "),ce=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),ae=t.createTextVNode(" And"),de=t.createTextVNode(" Add an 'Or' ");re.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("criterion"),a=t.resolveComponent("renderless-condition"),d=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(d,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:d,conditionFor:p})=>[t.createCommentVNode(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(t.openBlock(),t.createBlock(l,t.mergeProps({key:0,as:"div",component:"emptyGroup"},{addGroup:r},{order:["button","default"]}),{button:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"emptyGroup.addCriterionButton",onClick:r,tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(t.openBlock(),t.createBlock(l,{key:1,as:"div",component:"group.wrapper"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,((r,u)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(l,t.mergeProps({as:"div",component:"group"},s.templateChildKey(`group-${u}`)),{default:t.withCtx((()=>[t.createCommentVNode(" This really should be named criterion, as that's what it is. "),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r,(e=>(t.openBlock(),t.createBlock(l,{as:"div",component:"condition",key:e.uid},{default:t.withCtx((()=>[t.createVNode(a,t.normalizeProps(t.guardReactiveProps(p({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(c,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>d(e.position),onSwitchCondition:t=>n(e.position,p(t)),conditionId:e.condition_id,conditions:o.conditions,errors:o.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),t.createVNode(l,{as:"div",component:"group.addCriterionButton.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"group.addCriterionButton",onClick:e=>i(r[r.length-1].position),tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[ce])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[ae])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),t.createCommentVNode(" Divider between groups. Blank by default, but used in Nova. "),t.createVNode(l,t.mergeProps({as:"template",component:"group.divider",index:u,total:e.length},s.templateChildKey(`separator-${u}`)),null,16,["index","total"])],64)))),256)),t.createVNode(l,{as:"button",component:"addGroupButton",onClick:r,type:"button"},{default:t.withCtx((()=>[de])),_:2},1032,["onClick"])])),_:2},1024)),t.createCommentVNode(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},re.__file="src/components/base/query-builder/query-builder.vue";const pe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ue="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",he=`${pe} ${ue} w-60 pl-3 py-2`,me={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${pe} ${ue} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${he} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:he,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:he}},fe="bg-white relative text-left cursor-default",ve=`${fe} focus:outline-none pl-3 py-1`,ge={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${fe} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${ve} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${ve} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:ve}}};exports.ConditionSelector=X,exports.DatePickerPlugin=J,exports.Query=ee,exports.QueryBuilder=re,exports.RefinePlugin=Z,exports.Selector=F,exports.SelectorOption=z,exports.linearFlavor=ge,exports.tailwindFlavor=me;
//# sourceMappingURL=refine-vue.cjs.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=require("vue"),n=e=>"conjunction"===(null==e?void 0:e.type),o=Object.defineProperty,i=Object.defineProperties,r=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,a=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&a(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&a(e,n,t[n]);return e},p=(e,t)=>i(e,r(t)),u=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},h=(e,t,n,o)=>{var i,r;const[s]=o||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:d({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(i=null==s?void 0:s.meta)?void 0:i.clauses[0])?void 0:r.id}}),uid:u()}},m=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:u()}},f=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?p(d({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||u()}):p(d({},e),{id:void 0,uid:u()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var o in e)l.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&s)for(var o of s(e))t.indexOf(o)<0&&c.call(e,o)&&(n[o]=e[o]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,o)=>{n(t)?"or"===t.word&&e.push([]):e[e.length-1].push(p(d({},t),{position:o}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:o,refinements:i}=this.findCondition(t.id),r=h(o,1,n,i);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,o=t[e-1],i=t[e+1],r=n(i)&&"or"===i.word,s=n(o)&&"or"===o.word,l=r||!i,c=s||!o,a=c&&!l,d=c&&l;o||i?d&&s?t.splice(e-1,2):d&&!o||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:o,refinements:i}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:u()}}()),e.push(h(n.id,1,o,i)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:o}=this,i=h(t,n);return 0===o.length?o.push(i):o.splice(o.length,0,m(),i),this.blueprintChanged(),i}insertCriterion(e){const{blueprint:t,conditions:n}=this,o=n[0],{meta:i,refinements:r}=o;return t.splice(e+1,0,m(),h(o.id,1,i,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let o;return n.forEach((e=>{e.id===t&&(o=e)})),o}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,o){const{meta:i}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(i.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},o)}switchRefinement({uid:e,id:t},n,o){const i=this.findRefinement(t,o),r=this.findCriterion(e),s=d({},r.input);delete s[n],s[o]={clause:i.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const o=this.findCriterion(e);Object.keys(t).forEach((e=>{n?o.input[n][e]=t[e]:o.input[e]=t[e]})),this.blueprintChanged()}},v=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++)if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const o=this.options[this.options.length-1]||null,i=d({previousOption:o,nextOption:null},e);o&&(o.nextOption=i),this.options.push(i)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},g={name:"renderless-selector",data:()=>({selector:e.reactive(new v),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:o}=t.toggleOption(e);return o?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const w={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let b=1;var y={beforeCreate(){this.uid=b.toString(),b+=1}};const C=Symbol();function x(t,n,o=e.computed((()=>({})))){const i=e.inject(C),r=e.computed((()=>t(i)??{})),s=e.computed((()=>{const e={},t=o.value??{};let n=r.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=r.value.wrap,e})),l=e.computed((()=>{const e={},t=o.value??{},n=r.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=r.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e.computed((()=>({component:r.value.component??n.value,props:l,extra:s})))}const O=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,n){const o=x((e=>{const n=t.component.split(".");let o=e;for(const e of n)o=o?.[e];return o}),e.computed((()=>t.as)),e.computed((()=>t.flavorOptions)));return()=>{const i=o.value,r=i.extra.value.order??t.order,s=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),l=n.slots;let c="string"==typeof i.component&&i.component.includes("-"),a=c?l:r.map((e=>l?.[e]?.())),d=e.isVue2?e.h(i.component,{scopedSlots:l,attrs:n.attrs,props:s,on:n.listeners,...i.props.value},a):e.h(c?e.resolveComponent(i.component):i.component,{...n.attrs,"data-flavor":t.component,...s,...i.props.value},a);return i.extra.value.wrap?i.extra.value.wrap(d):d}}});var k={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:O}};const B=t.createTextVNode(" Choose an option "),S=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);k.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.button",id:o.id,type:"button","aria-haspopup":"listbox","aria-expanded":o.isOpen,"aria-label":s.label(),ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:t.withCtx((()=>[0===o.display.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.button.placeholder"},{default:t.withCtx((()=>[B])),_:1})):(t.openBlock(),t.createBlock(l,{key:1,as:"span",component:"select.button.selected"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.display),1)])),_:1})),t.createVNode(l,{as:"span",component:"select.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[S])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},k.__file="src/components/base/selector/selector-button.vue";var _={name:"selector-listbox",mixins:[y],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:O},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.listbox.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:o.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":o.selectedOption?s.createItemId(o.selectedOption.id):"",ref:"listBox",onKeydown:[t.withKeys(t.withModifiers(s.clearBuffer,["stop","prevent"]),["delete"]),n[0]||(n[0]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),n[1]||(n[1]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),n[3]||(n[3]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["escape"])),n[4]||(n[4]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["tab"])),n[5]||(n[5]=e=>s.handleKeypress(e))]},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default",{createItemId:s.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},__file:"src/components/base/selector/selector-listbox.vue"},V={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:O}};const I=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);V.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:o.isHighlighted},role:"option",key:o.optionId,ref:"listItem",onMouseenter:n[0]||(n[0]=t=>e.$emit("mouseenter")),onMouseleave:n[1]||(n[1]=t=>e.$emit("mouseleave")),onClick:n[2]||(n[2]=t=>e.$emit("selected")),"aria-label":o.optionDisplay,"aria-selected":o.selected},{default:t.withCtx((()=>[t.createVNode(l,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:o.selected}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.optionDisplay),1)])),_:1},8,["flavorOptions"]),t.createVNode(l,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:o.isHighlighted}},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: check "),t.withDirectives(t.createVNode(l,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!o.selected},{default:t.withCtx((()=>[I])),_:1},8,["aria-hidden"]),[[t.vShow,o.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},V.__file="src/components/base/selector/selector-list-item.vue";var N={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:O}};const $=t.createTextVNode(" Choose an option "),q=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),j=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);N.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.multi.button",id:o.id,"aria-haspopup":"listbox","aria-label":s.label(),"aria-expanded":o.isOpen,ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:[n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["enter"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:t.withCtx((()=>[0===o.selectedOptions.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:t.withCtx((()=>[$])),_:1})):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(o.selectedOptions,(({id:n,display:o})=>(t.openBlock(),t.createBlock(l,{as:"span",component:"select.multi.button.selected",key:n},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o)+" ",1),t.createVNode(l,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:t.withModifiers((t=>e.$emit("deselect-option",n)),["prevent"])},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[q])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),t.createVNode(l,{as:"span",component:"select.multi.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[j])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},N.__file="src/components/base/selector/multi-selector-button.vue";var R={name:"selector",mixins:[y],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:o}=n;if("function"!=typeof o)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const i=e=>{t.contains(e.target)||o()};e[t.id]=i,document.addEventListener("click",i),document.addEventListener("touchstart",i)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const o=t.find((t=>t.display.toLowerCase().includes(e)));o&&(n.highlightOption(o),this.scrollIntoView(o.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:o,toggleOption:i}=t,{isMultiSelect:r}=this;r?i(e):(n(),o(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:N,RenderlessSelector:g,SelectorListItem:V,SelectorButton:k,SelectorListbox:_,RefineFlavor:O},render:function(e,n,o,i,r,s){const l=t.resolveComponent("multi-selector-button"),c=t.resolveComponent("selector-button"),a=t.resolveComponent("selector-list-item"),d=t.resolveComponent("selector-listbox"),p=t.resolveComponent("refine-flavor"),u=t.resolveComponent("renderless-selector"),h=t.resolveDirective("click-away");return t.openBlock(),t.createBlock(u,{onSelectOption:n[0]||(n[0]=t=>e.$emit("select-option",t)),onDeselectOption:n[1]||(n[1]=t=>e.$emit("deselect-option",t))},{default:t.withCtx((({actions:n,isOpen:i,isClosed:r,selectedOptions:u,highlightedOption:m,options:f})=>[t.createVNode(p,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(p,{as:"div",component:"select",class:t.normalizeClass(o.innerClass),id:`listbox-${s.selectorId}`,"aria-labelledby":s.buttonId},{default:t.withCtx((()=>[o.isMultiSelect?(t.openBlock(),t.createBlock(l,{key:0,id:s.buttonId,isOpen:i,selectedOptions:u,onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),onDeselectOption:e=>s.deselectOption(e,n),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(t.openBlock(),t.createBlock(c,{key:1,id:s.buttonId,isOpen:i,display:u[0]?u[0].display:"",onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),t.createVNode(d,{selectedOption:u[0],isClosed:r,ref:"listBox",onHighlightNextOption:e=>s.highlightNextOption(n),onHighlightPreviousOption:e=>s.highlightPreviousOption(n),onSelectOption:e=>s.selectOption(m.id,n),onBufferChanged:e=>s.updateBuffer(e,f,n),onClose:e=>s.close(n)},{default:t.withCtx((({createItemId:e})=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f,(o=>(t.openBlock(),t.createBlock(a,{id:e(o.id),key:o.id,optionId:o.id,optionDisplay:o.display,selected:s.isSelected(o,u),isHighlighted:m&&o.id===m.id,ref_for:!0,ref:o.id,onMouseenter:e=>n.highlightOption(o),onMouseleave:e=>n.highlightOption(null),onSelected:e=>s.selectOption(o.id,n)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[h,n.close]]),t.createCommentVNode(" Custom options "),t.createVNode(p,{as:"div",component:"customOptions.wrapper"},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},__file:"src/components/base/selector/selector.vue"},E={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new f(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:o,type:i,display:r,meta:s}=this.conditionsLookup[t];return{id:o,type:i,display:r,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:o,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:o,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:o.groupedBlueprint()}):null}},M={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("blueprint"),r=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let s;s=r?i.findCriterion(n.uid):i.addCriterion({id:t,depth:0});const l=(e,t)=>i.updateInput(s,e,t),c=e=>i.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{i.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{r||i.removeCriterion(i.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:c}):null})(t.id,t,n)},D={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("criterion"),r=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),c=e=>{r(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:t},s);const{clause:e,...o}=i.input;Object.keys(n).length>0&&0===Object.keys(o).length&&r({...n},s)}return e.onUnmounted((()=>{l||i.input.clause===t&&r({clause:void 0},s)})),()=>o.slots.default?o.slots.default({setValue:c,...i.input}):null})(t.clause,t,n)},A={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}},F={name:"selector-option",mixins:[w],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[w],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:o}=this;o.registerOption({id:e,display:t||e,...this.$attrs}),n&&o.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("renderless-option");return t.openBlock(),t.createBlock(l,{id:e.id,display:e.display,selected:e.selected},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["id","display","selected"])},__file:"src/components/base/selector/selector-option.vue"},T={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:R},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{onSelectOption:s.selectOption},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["onSelectOption"])},__file:"src/components/base/condition-selector/condition-selector.vue"},P={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new f(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null},__file:"src/components/renderless/query.vue"},L={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:O},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"input",component:"inputs.number",type:"number",value:r.currentValue,onInput:s.handleInputChange},s.metaAttributes),null,16,["value","onInput"])},__file:"src/components/base/inputs/number-input.vue"},H={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:L,RefineFlavor:O},render:function(e,n,o,i,r,s){const l=t.resolveComponent("number-input"),c=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(c,{as:"div",component:"inputs.number.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{meta:o.meta,value:o.value1,onInput:s.updateFirstValue},null,8,["meta","value","onInput"]),s.joinWord?(t.openBlock(),t.createBlock(c,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(s.joinWord),1)])),_:1})):t.createCommentVNode("v-if",!0),t.createVNode(l,{meta:o.meta,value:o.value2,onInput:s.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},__file:"src/components/base/inputs/double-number-input.vue"},z={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:O},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.text",type:"text",value:o.value,onInput:n[0]||(n[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},__file:"src/components/base/inputs/text-input.vue"},G={setup:()=>({flavor:("inputs.date.pickerInput",x((e=>{const t="inputs.date.pickerInput".split(".");let n=e;for(const e of t)n=n?.[e];return n}),"",e.computed((()=>{})))?.value)}),props:{date:{type:String,required:!1},format:{type:String,required:!1,default:"MM/DD/YYYY"}},emits:["input"],data(){const{date:e}=this;return{time:e,hasError:!1,inputClass:this.flavor.props.value?.class,errorClass:this.flavor.props.value?.class}},methods:{handleInputError:function(){this.hasError=!0},handleInput:function(){this.hasError=!1,this.$emit("input",{date:this.time})}},components:{RefineFlavor:O}};const K=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z","clip-rule":"evenodd"},null,-1),Y=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);G.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date",value:r.time,"onUpdate:value":n[0]||(n[0]=e=>r.time=e),"value-type":"YYYY-MM-DD",format:o.format},e.$attrs,{onInput:s.handleInput,onChange:s.handleInput,onInputError:s.handleInputError,"input-class":r.hasError?r.inputClass+r.errorClass:r.inputClass}),{"icon-calendar":t.withCtx((()=>[r.hasError?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock(l,{key:0,as:"svg",component:"input.date.calendar.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[K])),_:1})),r.hasError?(t.openBlock(),t.createBlock(l,{key:1,as:"svg",component:"input.date.error.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[Y])),_:1})):t.createCommentVNode("v-if",!0)])),_:1},16,["value","format","onInput","onChange","onInputError","input-class"])},G.__file="src/components/base/inputs/date-picker.vue";var U={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:G},methods:{handleInput:function({date:e}){this.$emit("input",{date1:e})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("date-picker");return t.openBlock(),t.createBlock(l,t.mergeProps({onInput:s.handleInput,date:o.date1},e.$attrs),null,16,["onInput","date"])},__file:"src/components/base/inputs/date-input.vue"},W={name:"refine-double-date-input",components:{DatePicker:G,RefineFlavor:O},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},methods:{updateFirstDate:function({date:e}){this.$emit("input",{date1:e})},updateSecondDate:function({date:e}){this.$emit("input",{date2:e})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("date-picker"),c=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(c,{as:"div",component:"inputs.date.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,t.mergeProps({date:o.date1,onInput:s.updateFirstDate},e.$attrs),null,16,["date","onInput"]),t.createVNode(c,{as:"p",component:"inputs.date.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.joiner),1)])),_:1}),t.createVNode(l,t.mergeProps({date:o.date2,onInput:s.updateSecondDate},e.$attrs),null,16,["date","onInput"])])),_:1})},__file:"src/components/base/inputs/double-date-input.vue"},Q={name:"refine-date-input",components:{Selector:R,SelectorOption:F,RefineFlavor:O},mixins:[y],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("selector-option"),a=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.relative.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:o.amount,onInput:s.updateAmount},null,8,["value","onInput"]),t.createVNode(a,{onSelectOption:s.updateUnit},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.units,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,display:e.display,selected:e.id===o.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),t.createVNode(a,{onSelectOption:s.updateModifier},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.modifiers,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,selected:e.id===o.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},__file:"src/components/base/inputs/relative-date-input.vue"},Z={name:"refine-option-input",components:{Selector:R,SelectorOption:F},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector");return t.openBlock(),t.createBlock(c,{isMultiSelect:o.multiple,onSelectOption:s.selectOption,onDeselectOption:s.deselectOption},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.options,(({id:e,display:n})=>(t.openBlock(),t.createBlock(l,{key:e,id:e,display:n,selected:s.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},__file:"src/components/base/inputs/option-input.vue"},J={RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:Z,RefineRelativeDateInput:Q,RefineTextInput:z},X={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:D,SelectorOption:F,Selector:R,...Object.freeze({__proto__:null,default:J,RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:Z,RefineRelativeDateInput:Q,RefineTextInput:z})},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector"),a=t.resolveComponent("renderless-clause");return t.openBlock(),t.createBlock(a,t.normalizeProps(t.guardReactiveProps(o.input)),{default:t.withCtx((({setValue:e})=>[t.createCommentVNode(" clause selector "),t.createVNode(c,{onSelectOption:s.switchClause,innerClass:"refine-clause-selector"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.meta.clauses,(({id:n,display:i,component:r,meta:s})=>(t.openBlock(),t.createBlock(l,{key:n,id:n,display:i,selected:o.input.clause===n},{default:t.withCtx((()=>[r?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r),t.mergeProps({key:0},{...o.meta,...s,...o.input},{onInput:e}),null,16,["onInput"])):t.createCommentVNode("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},__file:"src/components/base/query-builder/clause.vue"},ee={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:X,RenderlessRefinement:A,Selector:R,SelectorOption:F},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("clause"),c=t.resolveComponent("renderless-refinement"),a=t.resolveComponent("selector-option"),d=t.resolveComponent("selector");return t.openBlock(),t.createBlock(d,{onSelectOption:s.selectRefinement},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.refinements,(({id:e,meta:n,display:i})=>(t.openBlock(),t.createBlock(a,{key:e,id:e,display:i,selected:!!o.input[e]},{default:t.withCtx((()=>[t.createVNode(c,{id:e},{default:t.withCtx((()=>[t.createVNode(l,{meta:n,input:o.input[e],onSwitchClause:({id:t})=>s.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},__file:"src/components/base/query-builder/refinements.vue"},te={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:X,Refinements:ee,SelectorOption:F,Selector:R,RefineFlavor:O}};const ne=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);te.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("clause"),a=t.resolveComponent("refinements"),d=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:t.withCtx((()=>[o.errors.length>0?(t.openBlock(),t.createBlock(l,{key:0,as:"ul",component:"criterion.errors"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.errors,(e=>(t.openBlock(),t.createBlock(l,{as:"li",component:"criterion.errors.error",key:e.id},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e.message),1)])),_:2},1024)))),128))])),_:1})):t.createCommentVNode("v-if",!0)])),selector:t.withCtx((()=>[t.createVNode(p,{onSelectOption:s.switchCondition},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.conditions,(({id:e,display:n,meta:i,refinements:r})=>(t.openBlock(),t.createBlock(d,{key:e,id:e,display:n,selected:o.conditionId===e},{default:t.withCtx((()=>[t.createElementVNode("div",null,[t.createVNode(c,{input:o.input,meta:i,onSwitchClause:s.switchClause},null,8,["input","meta","onSwitchClause"]),r&&r.length>0?(t.openBlock(),t.createBlock(a,{key:0,input:o.input,refinements:r},null,8,["input","refinements"])):t.createCommentVNode("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"criterion.removeCriterionButton",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[ne])),_:1})])),_:1})])),_:1})},te.__file="src/components/base/query-builder/criterion.vue";var oe={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var n;n=t.flavor,e.provide(C,n)},components:{Criterion:te,RefineFlavor:O,RenderlessCondition:M,RenderlessQueryBuilder:E}};const ie=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),re=t.createTextVNode(" Add a new condition "),se=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),le=t.createTextVNode(" And "),ce=t.createTextVNode(" Add an 'Or' ");oe.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("criterion"),a=t.resolveComponent("renderless-condition"),d=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(d,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:s,conditionFor:d})=>[t.createCommentVNode(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(t.openBlock(),t.createBlock(l,t.mergeProps({key:0,as:"div",component:"emptyGroup"},{addGroup:r},{order:["button","default"]}),{button:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"emptyGroup.addCriterionButton",onClick:r,tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[ie])),_:1}),t.createVNode(l,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:t.withCtx((()=>[re])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(t.openBlock(),t.createBlock(l,{key:1,as:"div",component:"group.wrapper"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,((e,r)=>(t.openBlock(),t.createBlock(l,{as:"div",component:"group",key:r},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,(e=>(t.openBlock(),t.createBlock(l,{as:"div",component:"condition",key:e.uid},{default:t.withCtx((()=>[t.createVNode(a,t.normalizeProps(t.guardReactiveProps(d({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(c,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>s(e.position),onSwitchCondition:t=>n(e.position,d(t)),conditionId:e.condition_id,conditions:o.conditions,errors:o.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),t.createVNode(l,{as:"div",component:"group.addCriterionButton.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"group.addCriterionButton",onClick:t=>i(e[e.length-1].position),tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1024)))),128)),t.createVNode(l,{as:"button",component:"addGroupButton",onClick:r,type:"button"},{default:t.withCtx((()=>[ce])),_:2},1032,["onClick"])])),_:2},1024)),t.createCommentVNode(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},oe.__file="src/components/base/query-builder/query-builder.vue";const ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",de="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",pe=`${ae} ${de} w-60 pl-3 py-2`,ue={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${ae} ${de} block w-full pl-3 py-2 pr-0`},relative:{class:`${pe} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:pe,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:pe}}},he="bg-white relative text-left cursor-default",me=`${he} focus:outline-none pl-3 py-1`,fe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${he} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:me}}};exports.ConditionSelector=T,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=P,exports.QueryBuilder=oe,exports.Selector=R,exports.SelectorOption=F,exports.linearFlavor=fe,exports.tailwindFlavor=ue;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=require("vue");const n=Symbol();let o={};var i={init(e){o=e},get:(e,t=null)=>o?.[e]??t,set(e,t){o[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,o){let r=i.get("showLocators");const s=function(t,o,i=e.computed((()=>({})))){const r=e.inject(n),s=e.computed((()=>t(r)??{})),l=e.computed((()=>{const e={},t=i.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),c=e.computed((()=>{const e={},t=i.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const o=s.value.style;return o&&(e.style="function"==typeof o?o(t):o),e}));return e.computed((()=>({component:s.value.component??o.value,props:c,extra:l})))}((e=>{const n=t.component.split(".");let o=e;for(const e of n)o=o?.[e];return"string"!=typeof o&&"function"!=typeof o||(o={class:o}),o}),e.computed((()=>t.as)),e.computed((()=>({...o.attrs??{},...t.flavorOptions??{}}))));return()=>{const n=s.value,i=n.extra.value.order??t.order,l=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),c=o.slots;let a="string"==typeof n.component&&n.component.includes("-"),d=a?c:i.map((e=>c?.[e]?.())),p=e.isVue2?e.h(n.component,{scopedSlots:c,attrs:{...r&&{"data-locator":t.component},...o.attrs},props:l,on:o.listeners,...n.props.value},d):e.h(a?e.resolveComponent(n.component):n.component,{...r&&{"data-locator":t.component},...o.attrs,...l,...n.props.value},d);return n.extra.value.wrap?n.extra.value.wrap(p):p}}});var s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"input",component:"inputs.number",type:"number",value:r.currentValue,onInput:s.handleInputChange},s.metaAttributes),null,16,["value","onInput"])},__file:"src/components/base/inputs/number-input.vue"},l={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:s,RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("number-input"),c=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(c,{as:"div",component:"inputs.number.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{meta:o.meta,value:o.value1,onInput:s.updateFirstValue},null,8,["meta","value","onInput"]),s.joinWord?(t.openBlock(),t.createBlock(c,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(s.joinWord),1)])),_:1})):t.createCommentVNode("v-if",!0),t.createVNode(l,{meta:o.meta,value:o.value2,onInput:s.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},__file:"src/components/base/inputs/double-number-input.vue"},c={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.text",type:"text",value:o.value,onInput:n[0]||(n[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},__file:"src/components/base/inputs/text-input.vue"},a={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},__file:"src/components/base/inputs/date-input.vue"},d={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),t.createVNode(l,{as:"p",component:"inputs.date.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.joiner),1)])),_:1}),t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date2,onInput:n[1]||(n[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},__file:"src/components/base/inputs/double-date-input.vue"},p=e=>"conjunction"===(null==e?void 0:e.type),u=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&b(e,n,t[n]);if(f)for(var n of f(t))v.call(t,n)&&b(e,n,t[n]);return e},y=(e,t)=>h(e,m(t)),C=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},x=(e,t,n,o)=>{var i,r;const[s]=o||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:w({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(i=null==s?void 0:s.meta)?void 0:i.clauses[0])?void 0:r.id}}),uid:C()}},O=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:C()}},k=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?y(w({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||C()}):y(w({},e),{id:void 0,uid:C()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var o in e)g.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&f)for(var o of f(e))t.indexOf(o)<0&&v.call(e,o)&&(n[o]=e[o]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{p(t)?"or"===t.word&&e.push([]):e[e.length-1].push(y(w({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:o,refinements:i}=this.findCondition(t.id),r=x(o,1,n,i);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],o=t[e+1],i=p(o)&&"or"===o.word,r=p(n)&&"or"===n.word,s=i||!o,l=r||!n,c=l&&!s,a=l&&s;n||o?a&&r?t.splice(e-1,2):a&&!n||c?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:o,refinements:i}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:C()}}()),e.push(x(n.id,1,o,i)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:o}=this,i=x(t,n);return 0===o.length?o.push(i):o.splice(o.length,0,O(),i),this.blueprintChanged(),i}insertCriterion(e){const{blueprint:t,conditions:n}=this,o=n[0],{meta:i,refinements:r}=o;return t.splice(e+1,0,O(),x(o.id,1,i,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let o;return n.forEach((e=>{e.id===t&&(o=e)})),o}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,o){const{meta:i}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(i.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},o)}switchRefinement({uid:e,id:t},n,o){const i=this.findRefinement(t,o),r=this.findCriterion(e),s=w({},r.input);delete s[n],s[o]={clause:i.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const o=this.findCriterion(e);Object.keys(t).forEach((e=>{n?o.input[n][e]=t[e]:o.input[e]=t[e]})),this.blueprintChanged()}},B=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++)if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const o=this.options[this.options.length-1]||null,i=w({previousOption:o,nextOption:null},e);o&&(o.nextOption=i),this.options.push(i)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},S={name:"renderless-selector",data:()=>({selector:e.reactive(new B),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:o}=t.toggleOption(e);return o?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const _={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let V=1;var N={beforeCreate(){this.uid=V.toString(),V+=1}},$={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};const I=t.createTextVNode(" Choose an option "),q=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);$.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.button",id:o.id,type:"button","aria-haspopup":"listbox","aria-expanded":o.isOpen,"aria-label":s.label(),ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:t.withCtx((()=>[0===o.display.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.button.placeholder"},{default:t.withCtx((()=>[I])),_:1})):(t.openBlock(),t.createBlock(l,{key:1,as:"span",component:"select.button.selected"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.display),1)])),_:1})),t.createVNode(l,{as:"span",component:"select.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[q])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},$.__file="src/components/base/selector/selector-button.vue";var R={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.listbox.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:o.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":o.selectedOption?s.createItemId(o.selectedOption.id):"",ref:"listBox",onKeydown:[t.withKeys(t.withModifiers(s.clearBuffer,["stop","prevent"]),["delete"]),n[0]||(n[0]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),n[1]||(n[1]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),n[3]||(n[3]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["escape"])),n[4]||(n[4]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["tab"])),n[5]||(n[5]=e=>s.handleKeypress(e))]},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default",{createItemId:s.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},__file:"src/components/base/selector/selector-listbox.vue"},j={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};const M=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);j.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:o.isHighlighted},role:"option",key:o.optionId,ref:"listItem",onMouseenter:n[0]||(n[0]=t=>e.$emit("mouseenter")),onMouseleave:n[1]||(n[1]=t=>e.$emit("mouseleave")),onClick:n[2]||(n[2]=t=>e.$emit("selected")),"aria-label":o.optionDisplay,"aria-selected":o.selected},{default:t.withCtx((()=>[t.createVNode(l,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:o.selected}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.optionDisplay),1)])),_:1},8,["flavorOptions"]),t.createVNode(l,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:o.isHighlighted}},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: check "),t.withDirectives(t.createVNode(l,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!o.selected},{default:t.withCtx((()=>[M])),_:1},8,["aria-hidden"]),[[t.vShow,o.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},j.__file="src/components/base/selector/selector-list-item.vue";var E={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};const A=t.createTextVNode(" Choose an option "),D=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),P=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);E.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.multi.button",id:o.id,"aria-haspopup":"listbox","aria-label":s.label(),"aria-expanded":o.isOpen,ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:[n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["enter"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:t.withCtx((()=>[0===o.selectedOptions.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:t.withCtx((()=>[A])),_:1})):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(o.selectedOptions,(({id:n,display:o})=>(t.openBlock(),t.createBlock(l,{as:"span",component:"select.multi.button.selected",key:n},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o)+" ",1),t.createVNode(l,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:t.withModifiers((t=>e.$emit("deselect-option",n)),["prevent"])},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[D])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),t.createVNode(l,{as:"span",component:"select.multi.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[P])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},E.__file="src/components/base/selector/multi-selector-button.vue";var F={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:o}=n;if("function"!=typeof o)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const i=e=>{t.contains(e.target)||o()};e[t.id]=i,document.addEventListener("click",i),document.addEventListener("touchstart",i)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const o=t.find((t=>t.display.toLowerCase().includes(e)));o&&(n.highlightOption(o),this.scrollIntoView(o.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:o,toggleOption:i}=t,{isMultiSelect:r}=this;r?i(e):(n(),o(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:E,RenderlessSelector:S,SelectorListItem:j,SelectorButton:$,SelectorListbox:R,RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("multi-selector-button"),c=t.resolveComponent("selector-button"),a=t.resolveComponent("selector-list-item"),d=t.resolveComponent("selector-listbox"),p=t.resolveComponent("refine-flavor"),u=t.resolveComponent("renderless-selector"),h=t.resolveDirective("click-away");return t.openBlock(),t.createBlock(u,{onSelectOption:n[0]||(n[0]=t=>e.$emit("select-option",t)),onDeselectOption:n[1]||(n[1]=t=>e.$emit("deselect-option",t))},{default:t.withCtx((({actions:n,isOpen:i,isClosed:r,selectedOptions:u,highlightedOption:m,options:f})=>[t.createVNode(p,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(p,{as:"div",component:"select",class:t.normalizeClass(o.innerClass),id:`listbox-${s.selectorId}`,"aria-labelledby":s.buttonId},{default:t.withCtx((()=>[o.isMultiSelect?(t.openBlock(),t.createBlock(l,{key:0,id:s.buttonId,isOpen:i,selectedOptions:u,onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),onDeselectOption:e=>s.deselectOption(e,n),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(t.openBlock(),t.createBlock(c,{key:1,id:s.buttonId,isOpen:i,display:u[0]?u[0].display:"",onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),t.createVNode(d,{selectedOption:u[0],isClosed:r,ref:"listBox",onHighlightNextOption:e=>s.highlightNextOption(n),onHighlightPreviousOption:e=>s.highlightPreviousOption(n),onSelectOption:e=>s.selectOption(m.id,n),onBufferChanged:e=>s.updateBuffer(e,f,n),onClose:e=>s.close(n)},{default:t.withCtx((({createItemId:e})=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f,(o=>(t.openBlock(),t.createBlock(a,{id:e(o.id),key:o.id,optionId:o.id,optionDisplay:o.display,selected:s.isSelected(o,u),isHighlighted:m&&o.id===m.id,ref_for:!0,ref:o.id,onMouseenter:e=>n.highlightOption(o),onMouseleave:e=>n.highlightOption(null),onSelected:e=>s.selectOption(o.id,n)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[h,n.close]]),t.createCommentVNode(" Custom options "),t.createVNode(p,{as:"div",component:"customOptions.wrapper"},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},__file:"src/components/base/selector/selector.vue"},T={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new k(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:o,type:i,display:r,meta:s}=this.conditionsLookup[t];return{id:o,type:i,display:r,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:o,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:o,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:o.groupedBlueprint()}):null}},L={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("blueprint"),r=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let s;s=r?i.findCriterion(n.uid):i.addCriterion({id:t,depth:0});const l=(e,t)=>i.updateInput(s,e,t),c=e=>i.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{i.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{r||i.removeCriterion(i.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:c}):null})(t.id,t,n)},H={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("criterion"),r=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),c=e=>{r(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:t},s);const{clause:e,...o}=i.input;Object.keys(n).length>0&&0===Object.keys(o).length&&r({...n},s)}return e.onUnmounted((()=>{l||i.input.clause===t&&r({clause:void 0},s)})),()=>o.slots.default?o.slots.default({setValue:c,...i.input}):null})(t.clause,t,n)},K={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}},z={name:"selector-option",mixins:[_],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[_],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:o}=this;o.registerOption({id:e,display:t||e,...this.$attrs}),n&&o.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("renderless-option");return t.openBlock(),t.createBlock(l,{id:e.id,display:e.display,selected:e.selected},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["id","display","selected"])},__file:"src/components/base/selector/selector-option.vue"},G={name:"refine-date-input",components:{Selector:F,SelectorOption:z,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("selector-option"),a=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.relative.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:o.amount,onInput:s.updateAmount},null,8,["value","onInput"]),t.createVNode(a,{onSelectOption:s.updateUnit},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.units,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,display:e.display,selected:e.id===o.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),t.createVNode(a,{onSelectOption:s.updateModifier},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.modifiers,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,selected:e.id===o.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},__file:"src/components/base/inputs/relative-date-input.vue"},U={name:"refine-option-input",components:{Selector:F,SelectorOption:z},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector");return t.openBlock(),t.createBlock(c,{isMultiSelect:o.multiple,onSelectOption:s.selectOption,onDeselectOption:s.deselectOption},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.options,(({id:e,display:n})=>(t.openBlock(),t.createBlock(l,{key:e,id:e,display:n,selected:s.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},__file:"src/components/base/inputs/option-input.vue"},W={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.date",type:"date",value:o.date,onInput:s.handleInput},null,8,["value","onInput"])},__file:"src/components/base/inputs/native-date-picker.vue"},Q={RefineDateInput:a,RefineDoubleDateInput:d,RefineDoubleNumberInput:l,RefineNumberInput:s,RefineOptionInput:U,RefineRelativeDateInput:G,RefineTextInput:c,RefineNativeDatePicker:W},Y=Object.freeze({__proto__:null,default:Q,RefineDateInput:a,RefineDoubleDateInput:d,RefineDoubleNumberInput:l,RefineNumberInput:s,RefineOptionInput:U,RefineRelativeDateInput:G,RefineTextInput:c,RefineNativeDatePicker:W}),Z={install:(e,t={})=>{t={DatePicker:W,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,i.init(t)}},J={install:(e,t={})=>{Z.install(e,t)}},X={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:F},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{onSelectOption:s.selectOption},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["onSelectOption"])},__file:"src/components/base/condition-selector/condition-selector.vue"},ee={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new k(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null},__file:"src/components/renderless/query.vue"},te={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:H,SelectorOption:z,Selector:F,...Y},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector"),a=t.resolveComponent("renderless-clause");return t.openBlock(),t.createBlock(a,t.normalizeProps(t.guardReactiveProps(o.input)),{default:t.withCtx((({setValue:e})=>[t.createCommentVNode(" clause selector "),t.createVNode(c,{onSelectOption:s.switchClause,innerClass:"refine-clause-selector"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.meta.clauses,(({id:n,display:i,component:r,meta:s})=>(t.openBlock(),t.createBlock(l,{key:n,id:n,display:i,selected:o.input.clause===n},{default:t.withCtx((()=>[r?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r),t.mergeProps({key:0},{...o.meta,...s,...o.input},{onInput:e}),null,16,["onInput"])):t.createCommentVNode("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},__file:"src/components/base/query-builder/clause.vue"},ne={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:te,RenderlessRefinement:K,Selector:F,SelectorOption:z},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("clause"),c=t.resolveComponent("renderless-refinement"),a=t.resolveComponent("selector-option"),d=t.resolveComponent("selector");return t.openBlock(),t.createBlock(d,{onSelectOption:s.selectRefinement},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.refinements,(({id:e,meta:n,display:i})=>(t.openBlock(),t.createBlock(a,{key:e,id:e,display:i,selected:!!o.input[e]},{default:t.withCtx((()=>[t.createVNode(c,{id:e},{default:t.withCtx((()=>[t.createVNode(l,{meta:n,input:o.input[e],onSwitchClause:({id:t})=>s.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},__file:"src/components/base/query-builder/refinements.vue"},oe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:te,Refinements:ne,SelectorOption:z,Selector:F,RefineFlavor:r}};const ie=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);oe.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("clause"),a=t.resolveComponent("refinements"),d=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:t.withCtx((()=>[o.errors.length>0?(t.openBlock(),t.createBlock(l,{key:0,as:"ul",component:"criterion.errors"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.errors,(e=>(t.openBlock(),t.createBlock(l,{as:"li",component:"criterion.errors.error",key:e},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e),1)])),_:2},1024)))),128))])),_:1})):t.createCommentVNode("v-if",!0)])),selector:t.withCtx((()=>[t.createVNode(p,{onSelectOption:s.switchCondition},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.conditions,(({id:e,display:n,meta:i,refinements:r})=>(t.openBlock(),t.createBlock(d,{key:e,id:e,display:n,selected:o.conditionId===e},{default:t.withCtx((()=>[t.createElementVNode("div",null,[t.createVNode(c,{input:o.input,meta:i,onSwitchClause:s.switchClause},null,8,["input","meta","onSwitchClause"]),r&&r.length>0?(t.openBlock(),t.createBlock(a,{key:0,input:o.input,refinements:r},null,8,["input","refinements"])):t.createCommentVNode("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"criterion.removeCriterionButton",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[ie])),_:1})])),_:1})])),_:1})},oe.__file="src/components/base/query-builder/criterion.vue";var re={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var o;o=t.flavor,e.provide(n,o)},components:{Criterion:oe,RefineFlavor:r,RenderlessCondition:L,RenderlessQueryBuilder:T}};const se=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),le=t.createTextVNode(" Add a new condition "),ce=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),ae=t.createTextVNode(" And"),de=t.createTextVNode(" Add an 'Or' ");re.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("criterion"),a=t.resolveComponent("renderless-condition"),d=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(d,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:d,conditionFor:p})=>[t.createCommentVNode(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(t.openBlock(),t.createBlock(l,t.mergeProps({key:0,as:"div",component:"emptyGroup"},{addGroup:r},{order:["button","default"]}),{button:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"emptyGroup.addCriterionButton",onClick:r,tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(t.openBlock(),t.createBlock(l,{key:1,as:"div",component:"group.wrapper"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,((r,u)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(l,t.mergeProps({as:"div",component:"group"},s.templateChildKey(`group-${u}`)),{default:t.withCtx((()=>[t.createCommentVNode(" This really should be named criterion, as that's what it is. "),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r,(e=>(t.openBlock(),t.createBlock(l,{as:"div",component:"condition",key:e.uid},{default:t.withCtx((()=>[t.createVNode(a,t.normalizeProps(t.guardReactiveProps(p({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(c,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>d(e.position),onSwitchCondition:t=>n(e.position,p(t)),conditionId:e.condition_id,conditions:o.conditions,errors:o.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),t.createVNode(l,{as:"div",component:"group.addCriterionButton.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"group.addCriterionButton",onClick:e=>i(r[r.length-1].position),tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[ce])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[ae])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),t.createCommentVNode(" Divider between groups. Blank by default, but used in Nova. "),t.createVNode(l,t.mergeProps({as:"template",component:"group.divider",index:u,total:e.length},s.templateChildKey(`separator-${u}`)),null,16,["index","total"])],64)))),256)),t.createVNode(l,{as:"button",component:"addGroupButton",onClick:r,type:"button"},{default:t.withCtx((()=>[de])),_:2},1032,["onClick"])])),_:2},1024)),t.createCommentVNode(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},re.__file="src/components/base/query-builder/query-builder.vue";const pe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ue="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",he=`${pe} ${ue} w-60 pl-3 py-2`,me={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${pe} ${ue} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${he} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:he,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:he}},fe="bg-white relative text-left cursor-default",ge=`${fe} focus:outline-none pl-3 py-1`,ve={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${fe} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${ge} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${ge} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:ge}}};exports.ConditionSelector=X,exports.DatePickerPlugin=J,exports.Query=ee,exports.QueryBuilder=re,exports.RefinePlugin=Z,exports.Selector=F,exports.SelectorOption=z,exports.linearFlavor=ve,exports.tailwindFlavor=me;
//# sourceMappingURL=refine-vue.cjs.min.js.map

@@ -1,2 +0,2 @@

import{reactive as e,nextTick as t,isVue2 as n,computed as i,provide as o,inject as r,defineComponent as s,h as l,resolveComponent as a,onUnmounted as u}from"vue-demi";import{resolveComponent as d,openBlock as p,createBlock as c,withModifiers as h,withKeys as f,withCtx as m,createTextVNode as g,toDisplayString as v,createVNode as b,createCommentVNode as y,createElementVNode as w,renderSlot as O,withDirectives as x,vShow as C,createElementBlock as S,Fragment as _,renderList as I,resolveDirective as $,normalizeClass as k,mergeProps as q,normalizeProps as B,guardReactiveProps as R,resolveDynamicComponent as j}from"vue";var A={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},M=e=>"conjunction"===(null==e?void 0:e.type),D=Object.defineProperty,E=Object.defineProperties,V=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable,T=(e,t,n)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,z=(e,t)=>{for(var n in t||(t={}))F.call(t,n)&&T(e,n,t[n]);if(H)for(var n of H(t))N.call(t,n)&&T(e,n,t[n]);return e},P=(e,t)=>E(e,V(t)),L=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},G=(e,t,n,i)=>{var o,r;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:z({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(o=null==s?void 0:s.meta)?void 0:o.clauses[0])?void 0:r.id}}),uid:L()}},Y=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:L()}},K=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?P(z({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||L()}):P(z({},e),{id:void 0,uid:L()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)F.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&H)for(var i of H(e))t.indexOf(i)<0&&N.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{M(t)?"or"===t.word&&e.push([]):e[e.length-1].push(P(z({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:o}=this.findCondition(t.id),r=G(i,1,n,o);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],o=M(i)&&"or"===i.word,r=M(n)&&"or"===n.word,s=o||!i,l=r||!n,a=l&&!s,u=l&&s;!n&&!i?this.blueprint=[]:u&&r?t.splice(e-1,2):u&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:o}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:L()}}()),e.push(G(n.id,1,i,o)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,o=G(t,n);return 0===i.length?i.push(o):i.splice(i.length,0,Y(),o),this.blueprintChanged(),o}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:o,refinements:r}=i;return t.splice(e+1,0,Y(),G(i.id,1,o,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:o}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(o.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const o=this.findRefinement(t,i),r=this.findCriterion(e),s=z({},r.input);delete s[n],s[i]={clause:o.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},W=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,o=z({previousOption:i,nextOption:null},e);i&&(i.nextOption=o),this.options.push(o)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},Q={name:"renderless-selector",data:()=>({selector:e(new W),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return t().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return n&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const U={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let Z=1;var J={beforeCreate(){this.uid=Z.toString(),Z+=1}};const X=Symbol();function ee(e,t,n=i((()=>({})))){const o=r(X),s=i((()=>e(o)??{})),l=i((()=>{const e={},t=n.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=i((()=>{const e={},t=n.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const o=s.value.style;return o&&(e.style="function"==typeof o?o(t):o),e}));return i((()=>({component:s.value.component??t.value,props:a,extra:l})))}const te=s({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(e,t){const o=ee((t=>{const n=e.component.split(".");let i=t;for(const e of n)i=i?.[e];return i}),i((()=>e.as)),i((()=>e.flavorOptions)));return()=>{const i=o.value,r=i.extra.value.order??e.order,s=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(e,["as","component","order"]),u=t.slots;let d="string"==typeof i.component&&i.component.includes("-"),p=d?u:r.map((e=>u?.[e]?.())),c=n?l(i.component,{scopedSlots:u,attrs:t.attrs,props:s,on:t.listeners,...i.props.value},p):l(d?a(i.component):i.component,{...t.attrs,"data-flavor":e.component,...s,...i.props.value},p);return i.extra.value.wrap?i.extra.value.wrap(c):c}}});var ne={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:te}};const ie=g(" Choose an option "),oe=w("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);ne.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.button",id:n.id,type:"button","aria-haspopup":"listbox","aria-expanded":n.isOpen,"aria-label":r.label(),ref:"button",onClick:t[0]||(t[0]=h((t=>e.$emit("toggle")),["prevent"])),onKeydown:t[1]||(t[1]=f(h((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:m((()=>[0===n.display.length?(p(),c(s,{key:0,as:"span",component:"select.button.placeholder"},{default:m((()=>[ie])),_:1})):(p(),c(s,{key:1,as:"span",component:"select.button.selected"},{default:m((()=>[g(v(n.display),1)])),_:1})),b(s,{as:"span",component:"select.button.icon.wrapper"},{default:m((()=>[y(" Heroicon name: selector "),b(s,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[oe])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},ne.__file="src/components/base/selector/selector-button.vue";var re={name:"selector-listbox",mixins:[J],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:te}};re.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.listbox.wrapper"},{default:m((()=>[b(s,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:n.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":n.selectedOption?r.createItemId(n.selectedOption.id):"",ref:"listBox",onKeydown:[f(h(r.clearBuffer,["stop","prevent"]),["delete"]),t[0]||(t[0]=f(h((()=>r.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),t[1]||(t[1]=f(h((()=>r.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),t[2]||(t[2]=f(h((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),t[3]||(t[3]=f(h((t=>e.$emit("close")),["stop","prevent"]),["escape"])),t[4]||(t[4]=f(h((t=>e.$emit("close")),["stop","prevent"]),["tab"])),t[5]||(t[5]=e=>r.handleKeypress(e))]},{default:m((()=>[O(e.$slots,"default",{createItemId:r.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},re.__file="src/components/base/selector/selector-listbox.vue";var se={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:te}};const le=w("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);se.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:n.isHighlighted},role:"option",key:n.optionId,ref:"listItem",onMouseenter:t[0]||(t[0]=t=>e.$emit("mouseenter")),onMouseleave:t[1]||(t[1]=t=>e.$emit("mouseleave")),onClick:t[2]||(t[2]=t=>e.$emit("selected")),"aria-label":n.optionDisplay,"aria-selected":n.selected},{default:m((()=>[b(s,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:n.selected}},{default:m((()=>[g(v(n.optionDisplay),1)])),_:1},8,["flavorOptions"]),b(s,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:n.isHighlighted}},{default:m((()=>[y(" Heroicon name: check "),x(b(s,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!n.selected},{default:m((()=>[le])),_:1},8,["aria-hidden"]),[[C,n.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},se.__file="src/components/base/selector/selector-list-item.vue";var ae={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:te}};const ue=g(" Choose an option "),de=w("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),pe=w("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);ae.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.multi.button",id:n.id,"aria-haspopup":"listbox","aria-label":r.label(),"aria-expanded":n.isOpen,ref:"button",onClick:t[0]||(t[0]=h((t=>e.$emit("toggle")),["prevent"])),onKeydown:[t[1]||(t[1]=f(h((t=>e.$emit("open")),["stop","prevent"]),["enter"])),t[2]||(t[2]=f(h((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:m((()=>[0===n.selectedOptions.length?(p(),c(s,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:m((()=>[ue])),_:1})):(p(!0),S(_,{key:1},I(n.selectedOptions,(({id:t,display:n})=>(p(),c(s,{as:"span",component:"select.multi.button.selected",key:t},{default:m((()=>[g(v(n)+" ",1),b(s,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:h((n=>e.$emit("deselect-option",t)),["prevent"])},{default:m((()=>[b(s,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:m((()=>[de])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),b(s,{as:"span",component:"select.multi.button.icon.wrapper"},{default:m((()=>[y(" Heroicon name: selector "),b(s,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[pe])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},ae.__file="src/components/base/selector/multi-selector-button.vue";var ce={name:"selector",mixins:[J],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const o=e=>{t.contains(e.target)||i()};e[t.id]=o,document.addEventListener("click",o),document.addEventListener("touchstart",o)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:o}=t,{isMultiSelect:r}=this;r?o(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:ae,RenderlessSelector:Q,SelectorListItem:se,SelectorButton:ne,SelectorListbox:re,RefineFlavor:te}};ce.render=function(e,t,n,i,o,r){const s=d("multi-selector-button"),l=d("selector-button"),a=d("selector-list-item"),u=d("selector-listbox"),h=d("refine-flavor"),f=d("renderless-selector"),g=$("click-away");return p(),c(f,{onSelectOption:t[0]||(t[0]=t=>e.$emit("select-option",t)),onDeselectOption:t[1]||(t[1]=t=>e.$emit("deselect-option",t))},{default:m((({actions:t,isOpen:i,isClosed:o,selectedOptions:d,highlightedOption:f,options:v})=>[b(h,{as:"div",component:"select.wrapper"},{default:m((()=>[y(" Select dropdown "),x((p(),c(h,{as:"div",component:"select",class:k(n.innerClass),id:`listbox-${r.selectorId}`,"aria-labelledby":r.buttonId},{default:m((()=>[n.isMultiSelect?(p(),c(s,{key:0,id:r.buttonId,isOpen:i,selectedOptions:d,onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),onDeselectOption:e=>r.deselectOption(e,t),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(p(),c(l,{key:1,id:r.buttonId,isOpen:i,display:d[0]?d[0].display:"",onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),b(u,{selectedOption:d[0],isClosed:o,ref:"listBox",onHighlightNextOption:e=>r.highlightNextOption(t),onHighlightPreviousOption:e=>r.highlightPreviousOption(t),onSelectOption:e=>r.selectOption(f.id,t),onBufferChanged:e=>r.updateBuffer(e,v,t),onClose:e=>r.close(t)},{default:m((({createItemId:e})=>[(p(!0),S(_,null,I(v,(n=>(p(),c(a,{id:e(n.id),key:n.id,optionId:n.id,optionDisplay:n.display,selected:r.isSelected(n,d),isHighlighted:f&&n.id===f.id,ref_for:!0,ref:n.id,onMouseenter:e=>t.highlightOption(n),onMouseleave:e=>t.highlightOption(null),onSelected:e=>r.selectOption(n.id,t)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[g,t.close]]),y(" Custom options "),b(h,{as:"div",component:"customOptions.wrapper"},{default:m((()=>[O(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},ce.__file="src/components/base/selector/selector.vue";var he={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new K(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:o,display:r,meta:s}=this.conditionsLookup[t];return{id:i,type:o,display:r,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:i,conditionFor:o,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return n&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:i,conditionFor:o,removeCriterion:s,replaceCriterion:r,groupedBlueprint:i.groupedBlueprint()}):null}},fe={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,t)=>((e,t,n)=>{const i=r("blueprint"),s=r("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!n)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let l;l=s?i.findCriterion(t.uid):i.addCriterion({id:e,depth:0});const a=(e,t)=>i.updateInput(l,e,t),d=e=>i.switchClause(l,e);o("criterion",l),o("criterionMeta",t.meta),o("updateInput",a),o("switchRefinement",((e,t)=>{i.switchRefinement(l,e,t)})),o("refinementId",null),u((()=>{s||i.removeCriterion(i.indexOfCriterion(l))}));let p=null;return t?.condition?.meta?.clauses&&(p=t.condition.meta.clauses.map((e=>e.component))),()=>n.slots.default?n.slots.default({clauses:p,criterion:l,updateInput:a,switchClause:d}):null})(e.id,e,t)},me={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,n)=>{const i=r("criterion"),o=r("updateInput"),s=r("refinementId"),l=r("builderModeActive"),a=e=>{o(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:n,...r}=i.input;Object.keys(t).length>0&&0===Object.keys(r).length&&o({...t},s)}return u((()=>{l||i.input.clause===e&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:a,...i.input}):null})(e.clause,e,t)},ge={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(n&&(e=this.$scopedSlots?.default),e)return e()}},ve={name:"selector-option",mixins:[U],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[U],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return n&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};ve.render=function(e,t,n,i,o,r){const s=d("renderless-option");return p(),c(s,{id:e.id,display:e.display,selected:e.selected},{default:m((()=>[O(e.$slots,"default")])),_:3},8,["id","display","selected"])},ve.__file="src/components/base/selector/selector-option.vue";var be={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ce}};be.render=function(e,t,n,i,o,r){const s=d("selector");return p(),c(s,{onSelectOption:r.selectOption},{default:m((()=>[O(e.$slots,"default")])),_:3},8,["onSelectOption"])},be.__file="src/components/base/condition-selector/condition-selector.vue";var ye={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new K(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return n&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null},__file:"src/components/renderless/query.vue"},we={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:te}};we.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,q({as:"input",component:"inputs.number",type:"number",value:o.currentValue,onInput:r.handleInputChange},r.metaAttributes),null,16,["value","onInput"])},we.__file="src/components/base/inputs/number-input.vue";var Oe={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:we,RefineFlavor:te}};Oe.render=function(e,t,n,i,o,r){const s=d("number-input"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.number.double.wrapper"},{default:m((()=>[b(s,{meta:n.meta,value:n.value1,onInput:r.updateFirstValue},null,8,["meta","value","onInput"]),r.joinWord?(p(),c(l,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:m((()=>[g(v(r.joinWord),1)])),_:1})):y("v-if",!0),b(s,{meta:n.meta,value:n.value2,onInput:r.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},Oe.__file="src/components/base/inputs/double-number-input.vue";var xe={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:te}};xe.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.text",type:"text",value:n.value,onInput:t[0]||(t[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},xe.__file="src/components/base/inputs/text-input.vue";var Ce={setup(){var e,t;return{flavor:(e="inputs.date.pickerInput",ee((t=>{const n=e.split(".");let i=t;for(const e of n)i=i?.[e];return i}),"",i((()=>t)))?.value)}},props:{date:{type:String,required:!1},format:{type:String,required:!1,default:"MM/DD/YYYY"}},emits:["input"],data(){const{date:e}=this;return{time:e,hasError:!1,inputClass:this.flavor.props.value?.class,errorClass:this.flavor.props.value?.class}},methods:{handleInputError:function(){this.hasError=!0},handleInput:function(){this.hasError=!1,this.$emit("input",{date:this.time})}},components:{RefineFlavor:te}};const Se=w("path",{"fill-rule":"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z","clip-rule":"evenodd"},null,-1),_e=w("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);Ce.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,q({as:"refine-date-picker",component:"inputs.date",value:o.time,"onUpdate:value":t[0]||(t[0]=e=>o.time=e),"value-type":"YYYY-MM-DD",format:n.format},e.$attrs,{onInput:r.handleInput,onChange:r.handleInput,onInputError:r.handleInputError,"input-class":o.hasError?o.inputClass+o.errorClass:o.inputClass}),{"icon-calendar":m((()=>[o.hasError?y("v-if",!0):(p(),c(s,{key:0,as:"svg",component:"input.date.calendar.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:m((()=>[Se])),_:1})),o.hasError?(p(),c(s,{key:1,as:"svg",component:"input.date.error.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[_e])),_:1})):y("v-if",!0)])),_:1},16,["value","format","onInput","onChange","onInputError","input-class"])},Ce.__file="src/components/base/inputs/date-picker.vue";var Ie={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:Ce},methods:{handleInput:function({date:e}){this.$emit("input",{date1:e})}}};Ie.render=function(e,t,n,i,o,r){const s=d("date-picker");return p(),c(s,q({onInput:r.handleInput,date:n.date1},e.$attrs),null,16,["onInput","date"])},Ie.__file="src/components/base/inputs/date-input.vue";var $e={name:"refine-double-date-input",components:{DatePicker:Ce,RefineFlavor:te},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},methods:{updateFirstDate:function({date:e}){this.$emit("input",{date1:e})},updateSecondDate:function({date:e}){this.$emit("input",{date2:e})}}};$e.render=function(e,t,n,i,o,r){const s=d("date-picker"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.date.double.wrapper"},{default:m((()=>[b(s,q({date:n.date1,onInput:r.updateFirstDate},e.$attrs),null,16,["date","onInput"]),b(l,{as:"p",component:"inputs.date.double.joiner"},{default:m((()=>[g(v(n.joiner),1)])),_:1}),b(s,q({date:n.date2,onInput:r.updateSecondDate},e.$attrs),null,16,["date","onInput"])])),_:1})},$e.__file="src/components/base/inputs/double-date-input.vue";var ke={name:"refine-date-input",components:{Selector:ce,SelectorOption:ve,RefineFlavor:te},mixins:[J],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};ke.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("selector-option"),a=d("selector");return p(),c(s,{as:"div",component:"inputs.date.relative.wrapper"},{default:m((()=>[b(s,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:n.amount,onInput:r.updateAmount},null,8,["value","onInput"]),b(a,{onSelectOption:r.updateUnit},{default:m((()=>[(p(!0),S(_,null,I(n.units,(e=>(p(),c(l,{key:e.id,id:e.id,display:e.display,selected:e.id===n.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),b(a,{onSelectOption:r.updateModifier},{default:m((()=>[(p(!0),S(_,null,I(n.modifiers,(e=>(p(),c(l,{key:e.id,id:e.id,selected:e.id===n.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},ke.__file="src/components/base/inputs/relative-date-input.vue";var qe={name:"refine-option-input",components:{Selector:ce,SelectorOption:ve},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};qe.render=function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector");return p(),c(l,{isMultiSelect:n.multiple,onSelectOption:r.selectOption,onDeselectOption:r.deselectOption},{default:m((()=>[(p(!0),S(_,null,I(n.options,(({id:e,display:t})=>(p(),c(s,{key:e,id:e,display:t,selected:r.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},qe.__file="src/components/base/inputs/option-input.vue";var Be={RefineDateInput:Ie,RefineDoubleDateInput:$e,RefineDoubleNumberInput:Oe,RefineNumberInput:we,RefineOptionInput:qe,RefineRelativeDateInput:ke,RefineTextInput:xe},Re={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:me,SelectorOption:ve,Selector:ce,...Object.freeze({__proto__:null,default:Be,RefineDateInput:Ie,RefineDoubleDateInput:$e,RefineDoubleNumberInput:Oe,RefineNumberInput:we,RefineOptionInput:qe,RefineRelativeDateInput:ke,RefineTextInput:xe})}};Re.render=function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector"),a=d("renderless-clause");return p(),c(a,B(R(n.input)),{default:m((({setValue:e})=>[y(" clause selector "),b(l,{onSelectOption:r.switchClause,innerClass:"refine-clause-selector"},{default:m((()=>[(p(!0),S(_,null,I(n.meta.clauses,(({id:t,display:i,component:o,meta:r})=>(p(),c(s,{key:t,id:t,display:i,selected:n.input.clause===t},{default:m((()=>[o?(p(),c(j(o),q({key:0},{...n.meta,...r,...n.input},{onInput:e}),null,16,["onInput"])):y("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},Re.__file="src/components/base/query-builder/clause.vue";var je={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Re,RenderlessRefinement:ge,Selector:ce,SelectorOption:ve},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};je.render=function(e,t,n,i,o,r){const s=d("clause"),l=d("renderless-refinement"),a=d("selector-option"),u=d("selector");return p(),c(u,{onSelectOption:r.selectRefinement},{default:m((()=>[(p(!0),S(_,null,I(n.refinements,(({id:e,meta:t,display:i})=>(p(),c(a,{key:e,id:e,display:i,selected:!!n.input[e]},{default:m((()=>[b(l,{id:e},{default:m((()=>[b(s,{meta:t,input:n.input[e],onSwitchClause:({id:t})=>r.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},je.__file="src/components/base/query-builder/refinements.vue";var Ae={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Re,Refinements:je,SelectorOption:ve,Selector:ce,RefineFlavor:te}};const Me=w("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);Ae.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("clause"),a=d("refinements"),u=d("selector-option"),f=d("selector");return p(),c(s,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:m((()=>[n.errors.length>0?(p(),c(s,{key:0,as:"ul",component:"criterion.errors"},{default:m((()=>[(p(!0),S(_,null,I(n.errors,(e=>(p(),c(s,{as:"li",component:"criterion.errors.error",key:e.id},{default:m((()=>[g(v(e.message),1)])),_:2},1024)))),128))])),_:1})):y("v-if",!0)])),selector:m((()=>[b(f,{onSelectOption:r.switchCondition},{default:m((()=>[(p(!0),S(_,null,I(n.conditions,(({id:e,display:t,meta:i,refinements:o})=>(p(),c(u,{key:e,id:e,display:t,selected:n.conditionId===e},{default:m((()=>[w("div",null,[b(l,{input:n.input,meta:i,onSwitchClause:r.switchClause},null,8,["input","meta","onSwitchClause"]),o&&o.length>0?(p(),c(a,{key:0,input:n.input,refinements:o},null,8,["input","refinements"])):y("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:m((()=>[b(s,{as:"button",component:"criterion.removeCriterionButton",onClick:t[0]||(t[0]=h((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:m((()=>[b(s,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:m((()=>[Me])),_:1})])),_:1})])),_:1})},Ae.__file="src/components/base/query-builder/criterion.vue";var De={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,o(X,t)},components:{Criterion:Ae,RefineFlavor:te,RenderlessCondition:fe,RenderlessQueryBuilder:he}};const Ee=w("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ve=g(" Add a new condition "),He=w("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Fe=g(" And "),Ne=g(" Add an 'Or' ");De.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("criterion"),a=d("renderless-condition"),u=d("renderless-query-builder");return p(),c(u,{blueprint:n.blueprint,conditions:n.conditions,onChange:r.onChange},{default:m((({groupedBlueprint:e,replaceCriterion:t,insertCriterion:i,addGroup:o,removeCriterion:r,conditionFor:u})=>[y(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(p(),c(s,q({key:0,as:"div",component:"emptyGroup"},{addGroup:o},{order:["button","default"]}),{button:m((()=>[b(s,{as:"button",component:"emptyGroup.addCriterionButton",onClick:o,tabindex:"0",type:"button"},{default:m((()=>[y(" Heroicon name: plus "),b(s,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[Ee])),_:1}),b(s,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:m((()=>[Ve])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(p(),c(s,{key:1,as:"div",component:"group.wrapper"},{default:m((()=>[(p(!0),S(_,null,I(e,((e,o)=>(p(),c(s,{as:"div",component:"group",key:o},{default:m((()=>[(p(!0),S(_,null,I(e,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:m((()=>[b(a,B(R(u({id:e.condition_id,...e}))),{default:m((({switchClause:i})=>[b(l,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>r(e.position),onSwitchCondition:n=>t(e.position,u(n)),conditionId:e.condition_id,conditions:n.conditions,errors:n.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),b(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:m((()=>[b(s,{as:"button",component:"group.addCriterionButton",onClick:t=>i(e[e.length-1].position),tabindex:"0",type:"button"},{default:m((()=>[y(" Heroicon name: plus "),b(s,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[He])),_:1}),b(s,{as:"span",component:"group.addCriterionButton.text"},{default:m((()=>[Fe])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1024)))),128)),b(s,{as:"button",component:"addGroupButton",onClick:o,type:"button"},{default:m((()=>[Ne])),_:2},1032,["onClick"])])),_:2},1024)),y(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},De.__file="src/components/base/query-builder/query-builder.vue";const Te="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Pe=`${Te} ${ze} w-60 pl-3 py-2`,Le={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Te} ${ze} block w-full pl-3 py-2 pr-0`},relative:{class:`${Pe} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Pe,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Pe}}},Ge="bg-white relative text-left cursor-default",Ye=`${Ge} focus:outline-none pl-3 py-1`,Ke={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ge} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ye} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ye} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ye}}};export{be as ConditionSelector,A as DatePickerPlugin,ye as Query,De as QueryBuilder,ce as Selector,ve as SelectorOption,Ke as linearFlavor,Le as tailwindFlavor};
import{computed as e,provide as t,inject as n,defineComponent as i,isVue2 as o,h as r,resolveComponent as s,reactive as l,nextTick as a,onUnmounted as u}from"vue-demi";import{resolveComponent as d,openBlock as p,createBlock as c,mergeProps as h,withCtx as f,createVNode as m,createTextVNode as g,toDisplayString as b,createCommentVNode as v,withModifiers as y,withKeys as w,createElementVNode as O,renderSlot as x,withDirectives as C,vShow as S,createElementBlock as _,Fragment as $,renderList as k,resolveDirective as I,normalizeClass as q,normalizeProps as B,guardReactiveProps as R,resolveDynamicComponent as j}from"vue";const A=Symbol();let M={};var D={init(e){M=e},get:(e,t=null)=>M?.[e]??t,set(e,t){M[e]=t}};const N=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,i){let l=D.get("showLocators");const a=function(t,i,o=e((()=>({})))){const r=n(A),s=e((()=>t(r)??{})),l=e((()=>{const e={},t=o.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=o.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const n=t.component.split(".");let i=e;for(const e of n)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e((()=>t.as)),e((()=>({...i.attrs??{},...t.flavorOptions??{}}))));return()=>{const e=a.value,n=e.extra.value.order??t.order,u=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),d=i.slots;let p="string"==typeof e.component&&e.component.includes("-"),c=p?d:n.map((e=>d?.[e]?.())),h=o?r(e.component,{scopedSlots:d,attrs:{...l&&{"data-locator":t.component},...i.attrs},props:u,on:i.listeners,...e.props.value},c):r(p?s(e.component):e.component,{...l&&{"data-locator":t.component},...i.attrs,...u,...e.props.value},c);return e.extra.value.wrap?e.extra.value.wrap(h):h}}});var H={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:N}};H.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"input",component:"inputs.number",type:"number",value:o.currentValue,onInput:r.handleInputChange},r.metaAttributes),null,16,["value","onInput"])},H.__file="src/components/base/inputs/number-input.vue";var V={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:H,RefineFlavor:N}};V.render=function(e,t,n,i,o,r){const s=d("number-input"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.number.double.wrapper"},{default:f((()=>[m(s,{meta:n.meta,value:n.value1,onInput:r.updateFirstValue},null,8,["meta","value","onInput"]),r.joinWord?(p(),c(l,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:f((()=>[g(b(r.joinWord),1)])),_:1})):v("v-if",!0),m(s,{meta:n.meta,value:n.value2,onInput:r.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},V.__file="src/components/base/inputs/double-number-input.vue";var P={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:N}};P.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.text",type:"text",value:n.value,onInput:t[0]||(t[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},P.__file="src/components/base/inputs/text-input.vue";var E={name:"refine-date-input",components:{RefineFlavor:N},emits:["input"],props:{date1:{type:String,required:!1}}};E.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},E.__file="src/components/base/inputs/date-input.vue";var T={name:"refine-double-date-input",components:{RefineFlavor:N},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};T.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"inputs.date.double.wrapper"},{default:f((()=>[m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),m(s,{as:"p",component:"inputs.date.double.joiner"},{default:f((()=>[g(b(n.joiner),1)])),_:1}),m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date2,onInput:t[1]||(t[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},T.__file="src/components/base/inputs/double-date-input.vue";var F=e=>"conjunction"===(null==e?void 0:e.type),L=Object.defineProperty,G=Object.defineProperties,z=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,U=(e,t,n)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Y=(e,t)=>{for(var n in t||(t={}))W.call(t,n)&&U(e,n,t[n]);if(K)for(var n of K(t))Q.call(t,n)&&U(e,n,t[n]);return e},Z=(e,t)=>G(e,z(t)),J=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},X=(e,t,n,i)=>{var o,r;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:Y({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(o=null==s?void 0:s.meta)?void 0:o.clauses[0])?void 0:r.id}}),uid:J()}},ee=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:J()}},te=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?Z(Y({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||J()}):Z(Y({},e),{id:void 0,uid:J()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)W.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&K)for(var i of K(e))t.indexOf(i)<0&&Q.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{F(t)?"or"===t.word&&e.push([]):e[e.length-1].push(Z(Y({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:o}=this.findCondition(t.id),r=X(i,1,n,o);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],o=F(i)&&"or"===i.word,r=F(n)&&"or"===n.word,s=o||!i,l=r||!n,a=l&&!s,u=l&&s;!n&&!i?this.blueprint=[]:u&&r?t.splice(e-1,2):u&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:o}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:J()}}()),e.push(X(n.id,1,i,o)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,o=X(t,n);return 0===i.length?i.push(o):i.splice(i.length,0,ee(),o),this.blueprintChanged(),o}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:o,refinements:r}=i;return t.splice(e+1,0,ee(),X(i.id,1,o,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:o}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(o.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const o=this.findRefinement(t,i),r=this.findCriterion(e),s=Y({},r.input);delete s[n],s[i]={clause:o.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},ne=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,o=Y({previousOption:i,nextOption:null},e);i&&(i.nextOption=o),this.options.push(o)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},ie={name:"renderless-selector",data:()=>({selector:l(new ne),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return a().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return o&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const oe={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let re=1;var se={beforeCreate(){this.uid=re.toString(),re+=1}},le={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:N}};const ae=g(" Choose an option "),ue=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);le.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.button",id:n.id,type:"button","aria-haspopup":"listbox","aria-expanded":n.isOpen,"aria-label":r.label(),ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:f((()=>[0===n.display.length?(p(),c(s,{key:0,as:"span",component:"select.button.placeholder"},{default:f((()=>[ae])),_:1})):(p(),c(s,{key:1,as:"span",component:"select.button.selected"},{default:f((()=>[g(b(n.display),1)])),_:1})),m(s,{as:"span",component:"select.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[ue])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},le.__file="src/components/base/selector/selector-button.vue";var de={name:"selector-listbox",mixins:[se],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:N}};de.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.listbox.wrapper"},{default:f((()=>[m(s,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:n.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":n.selectedOption?r.createItemId(n.selectedOption.id):"",ref:"listBox",onKeydown:[w(y(r.clearBuffer,["stop","prevent"]),["delete"]),t[0]||(t[0]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),t[1]||(t[1]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),t[2]||(t[2]=w(y((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),t[3]||(t[3]=w(y((t=>e.$emit("close")),["stop","prevent"]),["escape"])),t[4]||(t[4]=w(y((t=>e.$emit("close")),["stop","prevent"]),["tab"])),t[5]||(t[5]=e=>r.handleKeypress(e))]},{default:f((()=>[x(e.$slots,"default",{createItemId:r.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},de.__file="src/components/base/selector/selector-listbox.vue";var pe={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:N}};const ce=O("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);pe.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:n.isHighlighted},role:"option",key:n.optionId,ref:"listItem",onMouseenter:t[0]||(t[0]=t=>e.$emit("mouseenter")),onMouseleave:t[1]||(t[1]=t=>e.$emit("mouseleave")),onClick:t[2]||(t[2]=t=>e.$emit("selected")),"aria-label":n.optionDisplay,"aria-selected":n.selected},{default:f((()=>[m(s,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:n.selected}},{default:f((()=>[g(b(n.optionDisplay),1)])),_:1},8,["flavorOptions"]),m(s,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:n.isHighlighted}},{default:f((()=>[v(" Heroicon name: check "),C(m(s,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!n.selected},{default:f((()=>[ce])),_:1},8,["aria-hidden"]),[[S,n.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},pe.__file="src/components/base/selector/selector-list-item.vue";var he={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:N}};const fe=g(" Choose an option "),me=O("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),ge=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);he.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.multi.button",id:n.id,"aria-haspopup":"listbox","aria-label":r.label(),"aria-expanded":n.isOpen,ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:[t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["enter"])),t[2]||(t[2]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:f((()=>[0===n.selectedOptions.length?(p(),c(s,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:f((()=>[fe])),_:1})):(p(!0),_($,{key:1},k(n.selectedOptions,(({id:t,display:n})=>(p(),c(s,{as:"span",component:"select.multi.button.selected",key:t},{default:f((()=>[g(b(n)+" ",1),m(s,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:y((n=>e.$emit("deselect-option",t)),["prevent"])},{default:f((()=>[m(s,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[me])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),m(s,{as:"span",component:"select.multi.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[ge])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},he.__file="src/components/base/selector/multi-selector-button.vue";var be={name:"selector",mixins:[se],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const o=e=>{t.contains(e.target)||i()};e[t.id]=o,document.addEventListener("click",o),document.addEventListener("touchstart",o)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:o}=t,{isMultiSelect:r}=this;r?o(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:he,RenderlessSelector:ie,SelectorListItem:pe,SelectorButton:le,SelectorListbox:de,RefineFlavor:N}};be.render=function(e,t,n,i,o,r){const s=d("multi-selector-button"),l=d("selector-button"),a=d("selector-list-item"),u=d("selector-listbox"),h=d("refine-flavor"),g=d("renderless-selector"),b=I("click-away");return p(),c(g,{onSelectOption:t[0]||(t[0]=t=>e.$emit("select-option",t)),onDeselectOption:t[1]||(t[1]=t=>e.$emit("deselect-option",t))},{default:f((({actions:t,isOpen:i,isClosed:o,selectedOptions:d,highlightedOption:g,options:y})=>[m(h,{as:"div",component:"select.wrapper"},{default:f((()=>[v(" Select dropdown "),C((p(),c(h,{as:"div",component:"select",class:q(n.innerClass),id:`listbox-${r.selectorId}`,"aria-labelledby":r.buttonId},{default:f((()=>[n.isMultiSelect?(p(),c(s,{key:0,id:r.buttonId,isOpen:i,selectedOptions:d,onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),onDeselectOption:e=>r.deselectOption(e,t),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(p(),c(l,{key:1,id:r.buttonId,isOpen:i,display:d[0]?d[0].display:"",onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),m(u,{selectedOption:d[0],isClosed:o,ref:"listBox",onHighlightNextOption:e=>r.highlightNextOption(t),onHighlightPreviousOption:e=>r.highlightPreviousOption(t),onSelectOption:e=>r.selectOption(g.id,t),onBufferChanged:e=>r.updateBuffer(e,y,t),onClose:e=>r.close(t)},{default:f((({createItemId:e})=>[(p(!0),_($,null,k(y,(n=>(p(),c(a,{id:e(n.id),key:n.id,optionId:n.id,optionDisplay:n.display,selected:r.isSelected(n,d),isHighlighted:g&&n.id===g.id,ref_for:!0,ref:n.id,onMouseenter:e=>t.highlightOption(n),onMouseleave:e=>t.highlightOption(null),onSelected:e=>r.selectOption(n.id,t)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[b,t.close]]),v(" Custom options "),m(h,{as:"div",component:"customOptions.wrapper"},{default:f((()=>[x(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},be.__file="src/components/base/selector/selector.vue";var ve={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new te(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:o,display:r,meta:s}=this.conditionsLookup[t];return{id:i,type:o,display:r,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return o&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:n.groupedBlueprint()}):null}},ye={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,o)=>{const r=n("blueprint"),s=n("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let l;l=s?r.findCriterion(i.uid):r.addCriterion({id:e,depth:0});const a=(e,t)=>r.updateInput(l,e,t),d=e=>r.switchClause(l,e);t("criterion",l),t("criterionMeta",i.meta),t("updateInput",a),t("switchRefinement",((e,t)=>{r.switchRefinement(l,e,t)})),t("refinementId",null),u((()=>{s||r.removeCriterion(r.indexOfCriterion(l))}));let p=null;return i?.condition?.meta?.clauses&&(p=i.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:p,criterion:l,updateInput:a,switchClause:d}):null})(e.id,e,i)},we={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,i)=>{const o=n("criterion"),r=n("updateInput"),s=n("refinementId"),l=n("builderModeActive"),a=e=>{r(e,s)};if(!o)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:e},s);const{clause:n,...i}=o.input;Object.keys(t).length>0&&0===Object.keys(i).length&&r({...t},s)}return u((()=>{l||o.input.clause===e&&r({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:a,...o.input}):null})(e.clause,e,t)},Oe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(o&&(e=this.$scopedSlots?.default),e)return e()}},xe={name:"selector-option",mixins:[oe],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[oe],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};xe.render=function(e,t,n,i,o,r){const s=d("renderless-option");return p(),c(s,{id:e.id,display:e.display,selected:e.selected},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["id","display","selected"])},xe.__file="src/components/base/selector/selector-option.vue";var Ce={name:"refine-date-input",components:{Selector:be,SelectorOption:xe,RefineFlavor:N},mixins:[se],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};Ce.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("selector-option"),a=d("selector");return p(),c(s,{as:"div",component:"inputs.date.relative.wrapper"},{default:f((()=>[m(s,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:n.amount,onInput:r.updateAmount},null,8,["value","onInput"]),m(a,{onSelectOption:r.updateUnit},{default:f((()=>[(p(!0),_($,null,k(n.units,(e=>(p(),c(l,{key:e.id,id:e.id,display:e.display,selected:e.id===n.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),m(a,{onSelectOption:r.updateModifier},{default:f((()=>[(p(!0),_($,null,k(n.modifiers,(e=>(p(),c(l,{key:e.id,id:e.id,selected:e.id===n.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},Ce.__file="src/components/base/inputs/relative-date-input.vue";var Se={name:"refine-option-input",components:{Selector:be,SelectorOption:xe},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};Se.render=function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector");return p(),c(l,{isMultiSelect:n.multiple,onSelectOption:r.selectOption,onDeselectOption:r.deselectOption},{default:f((()=>[(p(!0),_($,null,k(n.options,(({id:e,display:t})=>(p(),c(s,{key:e,id:e,display:t,selected:r.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},Se.__file="src/components/base/inputs/option-input.vue";var _e={emits:["input"],components:{RefineFlavor:N},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};_e.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.date",type:"date",value:n.date,onInput:r.handleInput},null,8,["value","onInput"])},_e.__file="src/components/base/inputs/native-date-picker.vue";var $e={RefineDateInput:E,RefineDoubleDateInput:T,RefineDoubleNumberInput:V,RefineNumberInput:H,RefineOptionInput:Se,RefineRelativeDateInput:Ce,RefineTextInput:P,RefineNativeDatePicker:_e},ke=Object.freeze({__proto__:null,default:$e,RefineDateInput:E,RefineDoubleDateInput:T,RefineDoubleNumberInput:V,RefineNumberInput:H,RefineOptionInput:Se,RefineRelativeDateInput:Ce,RefineTextInput:P,RefineNativeDatePicker:_e}),Ie={install:(e,t={})=>{t={DatePicker:_e,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,D.init(t)}},qe={install:(e,t={})=>{Ie.install(e,t)}},Be={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:be}};Be.render=function(e,t,n,i,o,r){const s=d("selector");return p(),c(s,{onSelectOption:r.selectOption},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["onSelectOption"])},Be.__file="src/components/base/condition-selector/condition-selector.vue";var Re={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new te(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null},__file:"src/components/renderless/query.vue"},je={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:we,SelectorOption:xe,Selector:be,...ke}};je.render=function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector"),a=d("renderless-clause");return p(),c(a,B(R(n.input)),{default:f((({setValue:e})=>[v(" clause selector "),m(l,{onSelectOption:r.switchClause,innerClass:"refine-clause-selector"},{default:f((()=>[(p(!0),_($,null,k(n.meta.clauses,(({id:t,display:i,component:o,meta:r})=>(p(),c(s,{key:t,id:t,display:i,selected:n.input.clause===t},{default:f((()=>[o?(p(),c(j(o),h({key:0},{...n.meta,...r,...n.input},{onInput:e}),null,16,["onInput"])):v("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},je.__file="src/components/base/query-builder/clause.vue";var Ae={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:je,RenderlessRefinement:Oe,Selector:be,SelectorOption:xe},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};Ae.render=function(e,t,n,i,o,r){const s=d("clause"),l=d("renderless-refinement"),a=d("selector-option"),u=d("selector");return p(),c(u,{onSelectOption:r.selectRefinement},{default:f((()=>[(p(!0),_($,null,k(n.refinements,(({id:e,meta:t,display:i})=>(p(),c(a,{key:e,id:e,display:i,selected:!!n.input[e]},{default:f((()=>[m(l,{id:e},{default:f((()=>[m(s,{meta:t,input:n.input[e],onSwitchClause:({id:t})=>r.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},Ae.__file="src/components/base/query-builder/refinements.vue";var Me={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:je,Refinements:Ae,SelectorOption:xe,Selector:be,RefineFlavor:N}};const De=O("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);Me.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("clause"),a=d("refinements"),u=d("selector-option"),h=d("selector");return p(),c(s,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:f((()=>[n.errors.length>0?(p(),c(s,{key:0,as:"ul",component:"criterion.errors"},{default:f((()=>[(p(!0),_($,null,k(n.errors,(e=>(p(),c(s,{as:"li",component:"criterion.errors.error",key:e},{default:f((()=>[g(b(e),1)])),_:2},1024)))),128))])),_:1})):v("v-if",!0)])),selector:f((()=>[m(h,{onSelectOption:r.switchCondition},{default:f((()=>[(p(!0),_($,null,k(n.conditions,(({id:e,display:t,meta:i,refinements:o})=>(p(),c(u,{key:e,id:e,display:t,selected:n.conditionId===e},{default:f((()=>[O("div",null,[m(l,{input:n.input,meta:i,onSwitchClause:r.switchClause},null,8,["input","meta","onSwitchClause"]),o&&o.length>0?(p(),c(a,{key:0,input:n.input,refinements:o},null,8,["input","refinements"])):v("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:f((()=>[m(s,{as:"button",component:"criterion.removeCriterionButton",onClick:t[0]||(t[0]=y((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:f((()=>[m(s,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[De])),_:1})])),_:1})])),_:1})},Me.__file="src/components/base/query-builder/criterion.vue";var Ne={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>o?{}:{key:e},templateChildKey:e=>o?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var n;n=e.flavor,t(A,n)},components:{Criterion:Me,RefineFlavor:N,RenderlessCondition:ye,RenderlessQueryBuilder:ve}};const He=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ve=g(" Add a new condition "),Pe=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ee=g(" And"),Te=g(" Add an 'Or' ");Ne.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("criterion"),a=d("renderless-condition"),u=d("renderless-query-builder");return p(),c(u,{blueprint:n.blueprint,conditions:n.conditions,onChange:r.onChange},{default:f((({groupedBlueprint:e,replaceCriterion:t,insertCriterion:i,addGroup:o,removeCriterion:u,conditionFor:d})=>[v(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(p(),c(s,h({key:0,as:"div",component:"emptyGroup"},{addGroup:o},{order:["button","default"]}),{button:f((()=>[m(s,{as:"button",component:"emptyGroup.addCriterionButton",onClick:o,tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[He])),_:1}),m(s,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:f((()=>[Ve])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(p(),c(s,{key:1,as:"div",component:"group.wrapper"},{default:f((()=>[(p(!0),_($,null,k(e,((o,g)=>(p(),_($,null,[m(s,h({as:"div",component:"group"},r.templateChildKey(`group-${g}`)),{default:f((()=>[v(" This really should be named criterion, as that's what it is. "),(p(!0),_($,null,k(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:f((()=>[m(a,B(R(d({id:e.condition_id,...e}))),{default:f((({switchClause:i})=>[m(l,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>u(e.position),onSwitchCondition:n=>t(e.position,d(n)),conditionId:e.condition_id,conditions:n.conditions,errors:n.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),m(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:f((()=>[m(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.length-1].position),tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[Pe])),_:1}),m(s,{as:"span",component:"group.addCriterionButton.text"},{default:f((()=>[Ee])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),v(" Divider between groups. Blank by default, but used in Nova. "),m(s,h({as:"template",component:"group.divider",index:g,total:e.length},r.templateChildKey(`separator-${g}`)),null,16,["index","total"])],64)))),256)),m(s,{as:"button",component:"addGroupButton",onClick:o,type:"button"},{default:f((()=>[Te])),_:2},1032,["onClick"])])),_:2},1024)),v(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},Ne.__file="src/components/base/query-builder/query-builder.vue";const Fe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Le="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ge=`${Fe} ${Le} w-60 pl-3 py-2`,ze={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Fe} ${Le} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ge} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ge,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ge}},Ke="bg-white relative text-left cursor-default",We=`${Ke} focus:outline-none pl-3 py-1`,Qe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ke} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${We} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${We} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:We}}};export{Be as ConditionSelector,qe as DatePickerPlugin,Re as Query,Ne as QueryBuilder,Ie as RefinePlugin,be as Selector,xe as SelectorOption,Qe as linearFlavor,ze as tailwindFlavor};
//# sourceMappingURL=refine-vue.esm.js.map

@@ -1,2 +0,2 @@

import{reactive as e,nextTick as t,isVue2 as n,computed as i,provide as o,inject as r,defineComponent as s,h as l,resolveComponent as a,onUnmounted as u}from"vue-demi";import{resolveComponent as d,openBlock as p,createBlock as c,withModifiers as h,withKeys as f,withCtx as m,createTextVNode as g,toDisplayString as v,createVNode as b,createCommentVNode as y,createElementVNode as w,renderSlot as O,withDirectives as x,vShow as C,createElementBlock as S,Fragment as _,renderList as I,resolveDirective as k,normalizeClass as $,mergeProps as q,normalizeProps as B,guardReactiveProps as R,resolveDynamicComponent as j}from"vue";var A={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},D=e=>"conjunction"===(null==e?void 0:e.type),M=Object.defineProperty,E=Object.defineProperties,V=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,P=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T=(e,t)=>{for(var n in t||(t={}))N.call(t,n)&&P(e,n,t[n]);if(H)for(var n of H(t))F.call(t,n)&&P(e,n,t[n]);return e},z=(e,t)=>E(e,V(t)),L=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},G=(e,t,n,i)=>{var o,r;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:T({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(o=null==s?void 0:s.meta)?void 0:o.clauses[0])?void 0:r.id}}),uid:L()}},Y=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:L()}},K=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?z(T({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||L()}):z(T({},e),{id:void 0,uid:L()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)N.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&H)for(var i of H(e))t.indexOf(i)<0&&F.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{D(t)?"or"===t.word&&e.push([]):e[e.length-1].push(z(T({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:o}=this.findCondition(t.id),r=G(i,1,n,o);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],o=D(i)&&"or"===i.word,r=D(n)&&"or"===n.word,s=o||!i,l=r||!n,a=l&&!s,u=l&&s;n||i?u&&r?t.splice(e-1,2):u&&!n||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:o}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:L()}}()),e.push(G(n.id,1,i,o)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,o=G(t,n);return 0===i.length?i.push(o):i.splice(i.length,0,Y(),o),this.blueprintChanged(),o}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:o,refinements:r}=i;return t.splice(e+1,0,Y(),G(i.id,1,o,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:o}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(o.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const o=this.findRefinement(t,i),r=this.findCriterion(e),s=T({},r.input);delete s[n],s[i]={clause:o.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},U=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++)if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const i=this.options[this.options.length-1]||null,o=T({previousOption:i,nextOption:null},e);i&&(i.nextOption=o),this.options.push(o)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},W={name:"renderless-selector",data:()=>({selector:e(new U),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return t().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return n&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const Q={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let Z=1;var J={beforeCreate(){this.uid=Z.toString(),Z+=1}};const X=Symbol();function ee(e,t,n=i((()=>({})))){const o=r(X),s=i((()=>e(o)??{})),l=i((()=>{const e={},t=n.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=i((()=>{const e={},t=n.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const o=s.value.style;return o&&(e.style="function"==typeof o?o(t):o),e}));return i((()=>({component:s.value.component??t.value,props:a,extra:l})))}const te=s({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(e,t){const o=ee((t=>{const n=e.component.split(".");let i=t;for(const e of n)i=i?.[e];return i}),i((()=>e.as)),i((()=>e.flavorOptions)));return()=>{const i=o.value,r=i.extra.value.order??e.order,s=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(e,["as","component","order"]),u=t.slots;let d="string"==typeof i.component&&i.component.includes("-"),p=d?u:r.map((e=>u?.[e]?.())),c=n?l(i.component,{scopedSlots:u,attrs:t.attrs,props:s,on:t.listeners,...i.props.value},p):l(d?a(i.component):i.component,{...t.attrs,"data-flavor":e.component,...s,...i.props.value},p);return i.extra.value.wrap?i.extra.value.wrap(c):c}}});var ne={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:te}};const ie=g(" Choose an option "),oe=w("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);ne.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.button",id:n.id,type:"button","aria-haspopup":"listbox","aria-expanded":n.isOpen,"aria-label":r.label(),ref:"button",onClick:t[0]||(t[0]=h((t=>e.$emit("toggle")),["prevent"])),onKeydown:t[1]||(t[1]=f(h((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:m((()=>[0===n.display.length?(p(),c(s,{key:0,as:"span",component:"select.button.placeholder"},{default:m((()=>[ie])),_:1})):(p(),c(s,{key:1,as:"span",component:"select.button.selected"},{default:m((()=>[g(v(n.display),1)])),_:1})),b(s,{as:"span",component:"select.button.icon.wrapper"},{default:m((()=>[y(" Heroicon name: selector "),b(s,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[oe])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},ne.__file="src/components/base/selector/selector-button.vue";var re={name:"selector-listbox",mixins:[J],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:te},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.listbox.wrapper"},{default:m((()=>[b(s,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:n.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":n.selectedOption?r.createItemId(n.selectedOption.id):"",ref:"listBox",onKeydown:[f(h(r.clearBuffer,["stop","prevent"]),["delete"]),t[0]||(t[0]=f(h((()=>r.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),t[1]||(t[1]=f(h((()=>r.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),t[2]||(t[2]=f(h((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),t[3]||(t[3]=f(h((t=>e.$emit("close")),["stop","prevent"]),["escape"])),t[4]||(t[4]=f(h((t=>e.$emit("close")),["stop","prevent"]),["tab"])),t[5]||(t[5]=e=>r.handleKeypress(e))]},{default:m((()=>[O(e.$slots,"default",{createItemId:r.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},__file:"src/components/base/selector/selector-listbox.vue"},se={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:te}};const le=w("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);se.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:n.isHighlighted},role:"option",key:n.optionId,ref:"listItem",onMouseenter:t[0]||(t[0]=t=>e.$emit("mouseenter")),onMouseleave:t[1]||(t[1]=t=>e.$emit("mouseleave")),onClick:t[2]||(t[2]=t=>e.$emit("selected")),"aria-label":n.optionDisplay,"aria-selected":n.selected},{default:m((()=>[b(s,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:n.selected}},{default:m((()=>[g(v(n.optionDisplay),1)])),_:1},8,["flavorOptions"]),b(s,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:n.isHighlighted}},{default:m((()=>[y(" Heroicon name: check "),x(b(s,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!n.selected},{default:m((()=>[le])),_:1},8,["aria-hidden"]),[[C,n.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},se.__file="src/components/base/selector/selector-list-item.vue";var ae={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:te}};const ue=g(" Choose an option "),de=w("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),pe=w("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);ae.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.multi.button",id:n.id,"aria-haspopup":"listbox","aria-label":r.label(),"aria-expanded":n.isOpen,ref:"button",onClick:t[0]||(t[0]=h((t=>e.$emit("toggle")),["prevent"])),onKeydown:[t[1]||(t[1]=f(h((t=>e.$emit("open")),["stop","prevent"]),["enter"])),t[2]||(t[2]=f(h((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:m((()=>[0===n.selectedOptions.length?(p(),c(s,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:m((()=>[ue])),_:1})):(p(!0),S(_,{key:1},I(n.selectedOptions,(({id:t,display:n})=>(p(),c(s,{as:"span",component:"select.multi.button.selected",key:t},{default:m((()=>[g(v(n)+" ",1),b(s,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:h((n=>e.$emit("deselect-option",t)),["prevent"])},{default:m((()=>[b(s,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:m((()=>[de])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),b(s,{as:"span",component:"select.multi.button.icon.wrapper"},{default:m((()=>[y(" Heroicon name: selector "),b(s,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[pe])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},ae.__file="src/components/base/selector/multi-selector-button.vue";var ce={name:"selector",mixins:[J],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const o=e=>{t.contains(e.target)||i()};e[t.id]=o,document.addEventListener("click",o),document.addEventListener("touchstart",o)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:o}=t,{isMultiSelect:r}=this;r?o(e):(n(),i(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:ae,RenderlessSelector:W,SelectorListItem:se,SelectorButton:ne,SelectorListbox:re,RefineFlavor:te},render:function(e,t,n,i,o,r){const s=d("multi-selector-button"),l=d("selector-button"),a=d("selector-list-item"),u=d("selector-listbox"),h=d("refine-flavor"),f=d("renderless-selector"),g=k("click-away");return p(),c(f,{onSelectOption:t[0]||(t[0]=t=>e.$emit("select-option",t)),onDeselectOption:t[1]||(t[1]=t=>e.$emit("deselect-option",t))},{default:m((({actions:t,isOpen:i,isClosed:o,selectedOptions:d,highlightedOption:f,options:v})=>[b(h,{as:"div",component:"select.wrapper"},{default:m((()=>[y(" Select dropdown "),x((p(),c(h,{as:"div",component:"select",class:$(n.innerClass),id:`listbox-${r.selectorId}`,"aria-labelledby":r.buttonId},{default:m((()=>[n.isMultiSelect?(p(),c(s,{key:0,id:r.buttonId,isOpen:i,selectedOptions:d,onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),onDeselectOption:e=>r.deselectOption(e,t),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(p(),c(l,{key:1,id:r.buttonId,isOpen:i,display:d[0]?d[0].display:"",onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),b(u,{selectedOption:d[0],isClosed:o,ref:"listBox",onHighlightNextOption:e=>r.highlightNextOption(t),onHighlightPreviousOption:e=>r.highlightPreviousOption(t),onSelectOption:e=>r.selectOption(f.id,t),onBufferChanged:e=>r.updateBuffer(e,v,t),onClose:e=>r.close(t)},{default:m((({createItemId:e})=>[(p(!0),S(_,null,I(v,(n=>(p(),c(a,{id:e(n.id),key:n.id,optionId:n.id,optionDisplay:n.display,selected:r.isSelected(n,d),isHighlighted:f&&n.id===f.id,ref_for:!0,ref:n.id,onMouseenter:e=>t.highlightOption(n),onMouseleave:e=>t.highlightOption(null),onSelected:e=>r.selectOption(n.id,t)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[g,t.close]]),y(" Custom options "),b(h,{as:"div",component:"customOptions.wrapper"},{default:m((()=>[O(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},__file:"src/components/base/selector/selector.vue"},he={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new K(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:o,display:r,meta:s}=this.conditionsLookup[t];return{id:i,type:o,display:r,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:i,conditionFor:o,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return n&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:i,conditionFor:o,removeCriterion:s,replaceCriterion:r,groupedBlueprint:i.groupedBlueprint()}):null}},fe={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,t)=>((e,t,n)=>{const i=r("blueprint"),s=r("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!n)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let l;l=s?i.findCriterion(t.uid):i.addCriterion({id:e,depth:0});const a=(e,t)=>i.updateInput(l,e,t),d=e=>i.switchClause(l,e);o("criterion",l),o("criterionMeta",t.meta),o("updateInput",a),o("switchRefinement",((e,t)=>{i.switchRefinement(l,e,t)})),o("refinementId",null),u((()=>{s||i.removeCriterion(i.indexOfCriterion(l))}));let p=null;return t?.condition?.meta?.clauses&&(p=t.condition.meta.clauses.map((e=>e.component))),()=>n.slots.default?n.slots.default({clauses:p,criterion:l,updateInput:a,switchClause:d}):null})(e.id,e,t)},me={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,n)=>{const i=r("criterion"),o=r("updateInput"),s=r("refinementId"),l=r("builderModeActive"),a=e=>{o(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:n,...r}=i.input;Object.keys(t).length>0&&0===Object.keys(r).length&&o({...t},s)}return u((()=>{l||i.input.clause===e&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:a,...i.input}):null})(e.clause,e,t)},ge={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(n&&(e=this.$scopedSlots?.default),e)return e()}},ve={name:"selector-option",mixins:[Q],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[Q],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return n&&(t=this.$scopedSlots?.default),t&&e?t():null}}},render:function(e,t,n,i,o,r){const s=d("renderless-option");return p(),c(s,{id:e.id,display:e.display,selected:e.selected},{default:m((()=>[O(e.$slots,"default")])),_:3},8,["id","display","selected"])},__file:"src/components/base/selector/selector-option.vue"},be={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ce},render:function(e,t,n,i,o,r){const s=d("selector");return p(),c(s,{onSelectOption:r.selectOption},{default:m((()=>[O(e.$slots,"default")])),_:3},8,["onSelectOption"])},__file:"src/components/base/condition-selector/condition-selector.vue"},ye={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new K(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return n&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null},__file:"src/components/renderless/query.vue"},we={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:te},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,q({as:"input",component:"inputs.number",type:"number",value:o.currentValue,onInput:r.handleInputChange},r.metaAttributes),null,16,["value","onInput"])},__file:"src/components/base/inputs/number-input.vue"},Oe={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:we,RefineFlavor:te},render:function(e,t,n,i,o,r){const s=d("number-input"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.number.double.wrapper"},{default:m((()=>[b(s,{meta:n.meta,value:n.value1,onInput:r.updateFirstValue},null,8,["meta","value","onInput"]),r.joinWord?(p(),c(l,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:m((()=>[g(v(r.joinWord),1)])),_:1})):y("v-if",!0),b(s,{meta:n.meta,value:n.value2,onInput:r.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},__file:"src/components/base/inputs/double-number-input.vue"},xe={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:te},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.text",type:"text",value:n.value,onInput:t[0]||(t[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},__file:"src/components/base/inputs/text-input.vue"},Ce={setup:()=>({flavor:("inputs.date.pickerInput",ee((e=>{const t="inputs.date.pickerInput".split(".");let n=e;for(const e of t)n=n?.[e];return n}),"",i((()=>{})))?.value)}),props:{date:{type:String,required:!1},format:{type:String,required:!1,default:"MM/DD/YYYY"}},emits:["input"],data(){const{date:e}=this;return{time:e,hasError:!1,inputClass:this.flavor.props.value?.class,errorClass:this.flavor.props.value?.class}},methods:{handleInputError:function(){this.hasError=!0},handleInput:function(){this.hasError=!1,this.$emit("input",{date:this.time})}},components:{RefineFlavor:te}};const Se=w("path",{"fill-rule":"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z","clip-rule":"evenodd"},null,-1),_e=w("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);Ce.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,q({as:"refine-date-picker",component:"inputs.date",value:o.time,"onUpdate:value":t[0]||(t[0]=e=>o.time=e),"value-type":"YYYY-MM-DD",format:n.format},e.$attrs,{onInput:r.handleInput,onChange:r.handleInput,onInputError:r.handleInputError,"input-class":o.hasError?o.inputClass+o.errorClass:o.inputClass}),{"icon-calendar":m((()=>[o.hasError?y("v-if",!0):(p(),c(s,{key:0,as:"svg",component:"input.date.calendar.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:m((()=>[Se])),_:1})),o.hasError?(p(),c(s,{key:1,as:"svg",component:"input.date.error.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[_e])),_:1})):y("v-if",!0)])),_:1},16,["value","format","onInput","onChange","onInputError","input-class"])},Ce.__file="src/components/base/inputs/date-picker.vue";var Ie={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:Ce},methods:{handleInput:function({date:e}){this.$emit("input",{date1:e})}},render:function(e,t,n,i,o,r){const s=d("date-picker");return p(),c(s,q({onInput:r.handleInput,date:n.date1},e.$attrs),null,16,["onInput","date"])},__file:"src/components/base/inputs/date-input.vue"},ke={name:"refine-double-date-input",components:{DatePicker:Ce,RefineFlavor:te},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},methods:{updateFirstDate:function({date:e}){this.$emit("input",{date1:e})},updateSecondDate:function({date:e}){this.$emit("input",{date2:e})}},render:function(e,t,n,i,o,r){const s=d("date-picker"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.date.double.wrapper"},{default:m((()=>[b(s,q({date:n.date1,onInput:r.updateFirstDate},e.$attrs),null,16,["date","onInput"]),b(l,{as:"p",component:"inputs.date.double.joiner"},{default:m((()=>[g(v(n.joiner),1)])),_:1}),b(s,q({date:n.date2,onInput:r.updateSecondDate},e.$attrs),null,16,["date","onInput"])])),_:1})},__file:"src/components/base/inputs/double-date-input.vue"},$e={name:"refine-date-input",components:{Selector:ce,SelectorOption:ve,RefineFlavor:te},mixins:[J],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}},render:function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("selector-option"),a=d("selector");return p(),c(s,{as:"div",component:"inputs.date.relative.wrapper"},{default:m((()=>[b(s,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:n.amount,onInput:r.updateAmount},null,8,["value","onInput"]),b(a,{onSelectOption:r.updateUnit},{default:m((()=>[(p(!0),S(_,null,I(n.units,(e=>(p(),c(l,{key:e.id,id:e.id,display:e.display,selected:e.id===n.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),b(a,{onSelectOption:r.updateModifier},{default:m((()=>[(p(!0),S(_,null,I(n.modifiers,(e=>(p(),c(l,{key:e.id,id:e.id,selected:e.id===n.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},__file:"src/components/base/inputs/relative-date-input.vue"},qe={name:"refine-option-input",components:{Selector:ce,SelectorOption:ve},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}},render:function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector");return p(),c(l,{isMultiSelect:n.multiple,onSelectOption:r.selectOption,onDeselectOption:r.deselectOption},{default:m((()=>[(p(!0),S(_,null,I(n.options,(({id:e,display:t})=>(p(),c(s,{key:e,id:e,display:t,selected:r.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},__file:"src/components/base/inputs/option-input.vue"},Be={RefineDateInput:Ie,RefineDoubleDateInput:ke,RefineDoubleNumberInput:Oe,RefineNumberInput:we,RefineOptionInput:qe,RefineRelativeDateInput:$e,RefineTextInput:xe},Re={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:me,SelectorOption:ve,Selector:ce,...Object.freeze({__proto__:null,default:Be,RefineDateInput:Ie,RefineDoubleDateInput:ke,RefineDoubleNumberInput:Oe,RefineNumberInput:we,RefineOptionInput:qe,RefineRelativeDateInput:$e,RefineTextInput:xe})},render:function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector"),a=d("renderless-clause");return p(),c(a,B(R(n.input)),{default:m((({setValue:e})=>[y(" clause selector "),b(l,{onSelectOption:r.switchClause,innerClass:"refine-clause-selector"},{default:m((()=>[(p(!0),S(_,null,I(n.meta.clauses,(({id:t,display:i,component:o,meta:r})=>(p(),c(s,{key:t,id:t,display:i,selected:n.input.clause===t},{default:m((()=>[o?(p(),c(j(o),q({key:0},{...n.meta,...r,...n.input},{onInput:e}),null,16,["onInput"])):y("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},__file:"src/components/base/query-builder/clause.vue"},je={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Re,RenderlessRefinement:ge,Selector:ce,SelectorOption:ve},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}},render:function(e,t,n,i,o,r){const s=d("clause"),l=d("renderless-refinement"),a=d("selector-option"),u=d("selector");return p(),c(u,{onSelectOption:r.selectRefinement},{default:m((()=>[(p(!0),S(_,null,I(n.refinements,(({id:e,meta:t,display:i})=>(p(),c(a,{key:e,id:e,display:i,selected:!!n.input[e]},{default:m((()=>[b(l,{id:e},{default:m((()=>[b(s,{meta:t,input:n.input[e],onSwitchClause:({id:t})=>r.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},__file:"src/components/base/query-builder/refinements.vue"},Ae={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Re,Refinements:je,SelectorOption:ve,Selector:ce,RefineFlavor:te}};const De=w("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);Ae.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("clause"),a=d("refinements"),u=d("selector-option"),f=d("selector");return p(),c(s,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:m((()=>[n.errors.length>0?(p(),c(s,{key:0,as:"ul",component:"criterion.errors"},{default:m((()=>[(p(!0),S(_,null,I(n.errors,(e=>(p(),c(s,{as:"li",component:"criterion.errors.error",key:e.id},{default:m((()=>[g(v(e.message),1)])),_:2},1024)))),128))])),_:1})):y("v-if",!0)])),selector:m((()=>[b(f,{onSelectOption:r.switchCondition},{default:m((()=>[(p(!0),S(_,null,I(n.conditions,(({id:e,display:t,meta:i,refinements:o})=>(p(),c(u,{key:e,id:e,display:t,selected:n.conditionId===e},{default:m((()=>[w("div",null,[b(l,{input:n.input,meta:i,onSwitchClause:r.switchClause},null,8,["input","meta","onSwitchClause"]),o&&o.length>0?(p(),c(a,{key:0,input:n.input,refinements:o},null,8,["input","refinements"])):y("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:m((()=>[b(s,{as:"button",component:"criterion.removeCriterionButton",onClick:t[0]||(t[0]=h((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:m((()=>[b(s,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:m((()=>[De])),_:1})])),_:1})])),_:1})},Ae.__file="src/components/base/query-builder/criterion.vue";var Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,o(X,t)},components:{Criterion:Ae,RefineFlavor:te,RenderlessCondition:fe,RenderlessQueryBuilder:he}};const Ee=w("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ve=g(" Add a new condition "),He=w("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ne=g(" And "),Fe=g(" Add an 'Or' ");Me.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("criterion"),a=d("renderless-condition"),u=d("renderless-query-builder");return p(),c(u,{blueprint:n.blueprint,conditions:n.conditions,onChange:r.onChange},{default:m((({groupedBlueprint:e,replaceCriterion:t,insertCriterion:i,addGroup:o,removeCriterion:r,conditionFor:u})=>[y(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(p(),c(s,q({key:0,as:"div",component:"emptyGroup"},{addGroup:o},{order:["button","default"]}),{button:m((()=>[b(s,{as:"button",component:"emptyGroup.addCriterionButton",onClick:o,tabindex:"0",type:"button"},{default:m((()=>[y(" Heroicon name: plus "),b(s,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[Ee])),_:1}),b(s,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:m((()=>[Ve])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(p(),c(s,{key:1,as:"div",component:"group.wrapper"},{default:m((()=>[(p(!0),S(_,null,I(e,((e,o)=>(p(),c(s,{as:"div",component:"group",key:o},{default:m((()=>[(p(!0),S(_,null,I(e,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:m((()=>[b(a,B(R(u({id:e.condition_id,...e}))),{default:m((({switchClause:i})=>[b(l,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>r(e.position),onSwitchCondition:n=>t(e.position,u(n)),conditionId:e.condition_id,conditions:n.conditions,errors:n.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),b(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:m((()=>[b(s,{as:"button",component:"group.addCriterionButton",onClick:t=>i(e[e.length-1].position),tabindex:"0",type:"button"},{default:m((()=>[y(" Heroicon name: plus "),b(s,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:m((()=>[He])),_:1}),b(s,{as:"span",component:"group.addCriterionButton.text"},{default:m((()=>[Ne])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1024)))),128)),b(s,{as:"button",component:"addGroupButton",onClick:o,type:"button"},{default:m((()=>[Fe])),_:2},1032,["onClick"])])),_:2},1024)),y(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},Me.__file="src/components/base/query-builder/query-builder.vue";const Pe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Te="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",ze=`${Pe} ${Te} w-60 pl-3 py-2`,Le={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Pe} ${Te} block w-full pl-3 py-2 pr-0`},relative:{class:`${ze} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:ze,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:ze}}},Ge="bg-white relative text-left cursor-default",Ye=`${Ge} focus:outline-none pl-3 py-1`,Ke={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ge} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ye} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ye} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ye}}};export{be as ConditionSelector,A as DatePickerPlugin,ye as Query,Me as QueryBuilder,ce as Selector,ve as SelectorOption,Ke as linearFlavor,Le as tailwindFlavor};
import{computed as e,provide as t,inject as n,defineComponent as i,isVue2 as o,h as r,resolveComponent as s,reactive as l,nextTick as a,onUnmounted as u}from"vue-demi";import{resolveComponent as d,openBlock as p,createBlock as c,mergeProps as h,withCtx as f,createVNode as m,createTextVNode as g,toDisplayString as b,createCommentVNode as v,withModifiers as y,withKeys as w,createElementVNode as O,renderSlot as x,withDirectives as C,vShow as S,createElementBlock as _,Fragment as k,renderList as $,resolveDirective as I,normalizeClass as q,normalizeProps as B,guardReactiveProps as R,resolveDynamicComponent as j}from"vue";const A=Symbol();let D={};var M={init(e){D=e},get:(e,t=null)=>D?.[e]??t,set(e,t){D[e]=t}};const N=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,i){let l=M.get("showLocators");const a=function(t,i,o=e((()=>({})))){const r=n(A),s=e((()=>t(r)??{})),l=e((()=>{const e={},t=o.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=o.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const n=t.component.split(".");let i=e;for(const e of n)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e((()=>t.as)),e((()=>({...i.attrs??{},...t.flavorOptions??{}}))));return()=>{const e=a.value,n=e.extra.value.order??t.order,u=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),d=i.slots;let p="string"==typeof e.component&&e.component.includes("-"),c=p?d:n.map((e=>d?.[e]?.())),h=o?r(e.component,{scopedSlots:d,attrs:{...l&&{"data-locator":t.component},...i.attrs},props:u,on:i.listeners,...e.props.value},c):r(p?s(e.component):e.component,{...l&&{"data-locator":t.component},...i.attrs,...u,...e.props.value},c);return e.extra.value.wrap?e.extra.value.wrap(h):h}}});var V={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"input",component:"inputs.number",type:"number",value:o.currentValue,onInput:r.handleInputChange},r.metaAttributes),null,16,["value","onInput"])},__file:"src/components/base/inputs/number-input.vue"},P={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:V,RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("number-input"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.number.double.wrapper"},{default:f((()=>[m(s,{meta:n.meta,value:n.value1,onInput:r.updateFirstValue},null,8,["meta","value","onInput"]),r.joinWord?(p(),c(l,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:f((()=>[g(b(r.joinWord),1)])),_:1})):v("v-if",!0),m(s,{meta:n.meta,value:n.value2,onInput:r.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},__file:"src/components/base/inputs/double-number-input.vue"},E={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.text",type:"text",value:n.value,onInput:t[0]||(t[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},__file:"src/components/base/inputs/text-input.vue"},F={name:"refine-date-input",components:{RefineFlavor:N},emits:["input"],props:{date1:{type:String,required:!1}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},__file:"src/components/base/inputs/date-input.vue"},H={name:"refine-double-date-input",components:{RefineFlavor:N},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"inputs.date.double.wrapper"},{default:f((()=>[m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),m(s,{as:"p",component:"inputs.date.double.joiner"},{default:f((()=>[g(b(n.joiner),1)])),_:1}),m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date2,onInput:t[1]||(t[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},__file:"src/components/base/inputs/double-date-input.vue"},T=e=>"conjunction"===(null==e?void 0:e.type),L=Object.defineProperty,z=Object.defineProperties,G=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,U=(e,t,n)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Y=(e,t)=>{for(var n in t||(t={}))W.call(t,n)&&U(e,n,t[n]);if(K)for(var n of K(t))Q.call(t,n)&&U(e,n,t[n]);return e},Z=(e,t)=>z(e,G(t)),J=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},X=(e,t,n,i)=>{var o,r;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:Y({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(o=null==s?void 0:s.meta)?void 0:o.clauses[0])?void 0:r.id}}),uid:J()}},ee=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:J()}},te=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?Z(Y({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||J()}):Z(Y({},e),{id:void 0,uid:J()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)W.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&K)for(var i of K(e))t.indexOf(i)<0&&Q.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{T(t)?"or"===t.word&&e.push([]):e[e.length-1].push(Z(Y({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:o}=this.findCondition(t.id),r=X(i,1,n,o);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],o=T(i)&&"or"===i.word,r=T(n)&&"or"===n.word,s=o||!i,l=r||!n,a=l&&!s,u=l&&s;n||i?u&&r?t.splice(e-1,2):u&&!n||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:o}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:J()}}()),e.push(X(n.id,1,i,o)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,o=X(t,n);return 0===i.length?i.push(o):i.splice(i.length,0,ee(),o),this.blueprintChanged(),o}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:o,refinements:r}=i;return t.splice(e+1,0,ee(),X(i.id,1,o,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:o}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(o.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const o=this.findRefinement(t,i),r=this.findCriterion(e),s=Y({},r.input);delete s[n],s[i]={clause:o.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},ne=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++)if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const i=this.options[this.options.length-1]||null,o=Y({previousOption:i,nextOption:null},e);i&&(i.nextOption=o),this.options.push(o)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},ie={name:"renderless-selector",data:()=>({selector:l(new ne),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return a().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return o&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const oe={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let re=1;var se={beforeCreate(){this.uid=re.toString(),re+=1}},le={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:N}};const ae=g(" Choose an option "),ue=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);le.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.button",id:n.id,type:"button","aria-haspopup":"listbox","aria-expanded":n.isOpen,"aria-label":r.label(),ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:f((()=>[0===n.display.length?(p(),c(s,{key:0,as:"span",component:"select.button.placeholder"},{default:f((()=>[ae])),_:1})):(p(),c(s,{key:1,as:"span",component:"select.button.selected"},{default:f((()=>[g(b(n.display),1)])),_:1})),m(s,{as:"span",component:"select.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[ue])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},le.__file="src/components/base/selector/selector-button.vue";var de={name:"selector-listbox",mixins:[se],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.listbox.wrapper"},{default:f((()=>[m(s,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:n.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":n.selectedOption?r.createItemId(n.selectedOption.id):"",ref:"listBox",onKeydown:[w(y(r.clearBuffer,["stop","prevent"]),["delete"]),t[0]||(t[0]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),t[1]||(t[1]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),t[2]||(t[2]=w(y((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),t[3]||(t[3]=w(y((t=>e.$emit("close")),["stop","prevent"]),["escape"])),t[4]||(t[4]=w(y((t=>e.$emit("close")),["stop","prevent"]),["tab"])),t[5]||(t[5]=e=>r.handleKeypress(e))]},{default:f((()=>[x(e.$slots,"default",{createItemId:r.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},__file:"src/components/base/selector/selector-listbox.vue"},pe={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:N}};const ce=O("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);pe.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:n.isHighlighted},role:"option",key:n.optionId,ref:"listItem",onMouseenter:t[0]||(t[0]=t=>e.$emit("mouseenter")),onMouseleave:t[1]||(t[1]=t=>e.$emit("mouseleave")),onClick:t[2]||(t[2]=t=>e.$emit("selected")),"aria-label":n.optionDisplay,"aria-selected":n.selected},{default:f((()=>[m(s,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:n.selected}},{default:f((()=>[g(b(n.optionDisplay),1)])),_:1},8,["flavorOptions"]),m(s,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:n.isHighlighted}},{default:f((()=>[v(" Heroicon name: check "),C(m(s,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!n.selected},{default:f((()=>[ce])),_:1},8,["aria-hidden"]),[[S,n.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},pe.__file="src/components/base/selector/selector-list-item.vue";var he={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:N}};const fe=g(" Choose an option "),me=O("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),ge=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);he.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.multi.button",id:n.id,"aria-haspopup":"listbox","aria-label":r.label(),"aria-expanded":n.isOpen,ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:[t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["enter"])),t[2]||(t[2]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:f((()=>[0===n.selectedOptions.length?(p(),c(s,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:f((()=>[fe])),_:1})):(p(!0),_(k,{key:1},$(n.selectedOptions,(({id:t,display:n})=>(p(),c(s,{as:"span",component:"select.multi.button.selected",key:t},{default:f((()=>[g(b(n)+" ",1),m(s,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:y((n=>e.$emit("deselect-option",t)),["prevent"])},{default:f((()=>[m(s,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[me])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),m(s,{as:"span",component:"select.multi.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[ge])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},he.__file="src/components/base/selector/multi-selector-button.vue";var be={name:"selector",mixins:[se],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const o=e=>{t.contains(e.target)||i()};e[t.id]=o,document.addEventListener("click",o),document.addEventListener("touchstart",o)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:o}=t,{isMultiSelect:r}=this;r?o(e):(n(),i(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:he,RenderlessSelector:ie,SelectorListItem:pe,SelectorButton:le,SelectorListbox:de,RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("multi-selector-button"),l=d("selector-button"),a=d("selector-list-item"),u=d("selector-listbox"),h=d("refine-flavor"),g=d("renderless-selector"),b=I("click-away");return p(),c(g,{onSelectOption:t[0]||(t[0]=t=>e.$emit("select-option",t)),onDeselectOption:t[1]||(t[1]=t=>e.$emit("deselect-option",t))},{default:f((({actions:t,isOpen:i,isClosed:o,selectedOptions:d,highlightedOption:g,options:y})=>[m(h,{as:"div",component:"select.wrapper"},{default:f((()=>[v(" Select dropdown "),C((p(),c(h,{as:"div",component:"select",class:q(n.innerClass),id:`listbox-${r.selectorId}`,"aria-labelledby":r.buttonId},{default:f((()=>[n.isMultiSelect?(p(),c(s,{key:0,id:r.buttonId,isOpen:i,selectedOptions:d,onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),onDeselectOption:e=>r.deselectOption(e,t),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(p(),c(l,{key:1,id:r.buttonId,isOpen:i,display:d[0]?d[0].display:"",onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),m(u,{selectedOption:d[0],isClosed:o,ref:"listBox",onHighlightNextOption:e=>r.highlightNextOption(t),onHighlightPreviousOption:e=>r.highlightPreviousOption(t),onSelectOption:e=>r.selectOption(g.id,t),onBufferChanged:e=>r.updateBuffer(e,y,t),onClose:e=>r.close(t)},{default:f((({createItemId:e})=>[(p(!0),_(k,null,$(y,(n=>(p(),c(a,{id:e(n.id),key:n.id,optionId:n.id,optionDisplay:n.display,selected:r.isSelected(n,d),isHighlighted:g&&n.id===g.id,ref_for:!0,ref:n.id,onMouseenter:e=>t.highlightOption(n),onMouseleave:e=>t.highlightOption(null),onSelected:e=>r.selectOption(n.id,t)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[b,t.close]]),v(" Custom options "),m(h,{as:"div",component:"customOptions.wrapper"},{default:f((()=>[x(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},__file:"src/components/base/selector/selector.vue"},ve={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new te(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:o,display:r,meta:s}=this.conditionsLookup[t];return{id:i,type:o,display:r,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return o&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:n.groupedBlueprint()}):null}},ye={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,o)=>{const r=n("blueprint"),s=n("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let l;l=s?r.findCriterion(i.uid):r.addCriterion({id:e,depth:0});const a=(e,t)=>r.updateInput(l,e,t),d=e=>r.switchClause(l,e);t("criterion",l),t("criterionMeta",i.meta),t("updateInput",a),t("switchRefinement",((e,t)=>{r.switchRefinement(l,e,t)})),t("refinementId",null),u((()=>{s||r.removeCriterion(r.indexOfCriterion(l))}));let p=null;return i?.condition?.meta?.clauses&&(p=i.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:p,criterion:l,updateInput:a,switchClause:d}):null})(e.id,e,i)},we={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,i)=>{const o=n("criterion"),r=n("updateInput"),s=n("refinementId"),l=n("builderModeActive"),a=e=>{r(e,s)};if(!o)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:e},s);const{clause:n,...i}=o.input;Object.keys(t).length>0&&0===Object.keys(i).length&&r({...t},s)}return u((()=>{l||o.input.clause===e&&r({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:a,...o.input}):null})(e.clause,e,t)},Oe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(o&&(e=this.$scopedSlots?.default),e)return e()}},xe={name:"selector-option",mixins:[oe],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[oe],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t&&e?t():null}}},render:function(e,t,n,i,o,r){const s=d("renderless-option");return p(),c(s,{id:e.id,display:e.display,selected:e.selected},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["id","display","selected"])},__file:"src/components/base/selector/selector-option.vue"},Ce={name:"refine-date-input",components:{Selector:be,SelectorOption:xe,RefineFlavor:N},mixins:[se],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}},render:function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("selector-option"),a=d("selector");return p(),c(s,{as:"div",component:"inputs.date.relative.wrapper"},{default:f((()=>[m(s,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:n.amount,onInput:r.updateAmount},null,8,["value","onInput"]),m(a,{onSelectOption:r.updateUnit},{default:f((()=>[(p(!0),_(k,null,$(n.units,(e=>(p(),c(l,{key:e.id,id:e.id,display:e.display,selected:e.id===n.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),m(a,{onSelectOption:r.updateModifier},{default:f((()=>[(p(!0),_(k,null,$(n.modifiers,(e=>(p(),c(l,{key:e.id,id:e.id,selected:e.id===n.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},__file:"src/components/base/inputs/relative-date-input.vue"},Se={name:"refine-option-input",components:{Selector:be,SelectorOption:xe},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}},render:function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector");return p(),c(l,{isMultiSelect:n.multiple,onSelectOption:r.selectOption,onDeselectOption:r.deselectOption},{default:f((()=>[(p(!0),_(k,null,$(n.options,(({id:e,display:t})=>(p(),c(s,{key:e,id:e,display:t,selected:r.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},__file:"src/components/base/inputs/option-input.vue"},_e={emits:["input"],components:{RefineFlavor:N},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.date",type:"date",value:n.date,onInput:r.handleInput},null,8,["value","onInput"])},__file:"src/components/base/inputs/native-date-picker.vue"},ke={RefineDateInput:F,RefineDoubleDateInput:H,RefineDoubleNumberInput:P,RefineNumberInput:V,RefineOptionInput:Se,RefineRelativeDateInput:Ce,RefineTextInput:E,RefineNativeDatePicker:_e},$e=Object.freeze({__proto__:null,default:ke,RefineDateInput:F,RefineDoubleDateInput:H,RefineDoubleNumberInput:P,RefineNumberInput:V,RefineOptionInput:Se,RefineRelativeDateInput:Ce,RefineTextInput:E,RefineNativeDatePicker:_e}),Ie={install:(e,t={})=>{t={DatePicker:_e,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,M.init(t)}},qe={install:(e,t={})=>{Ie.install(e,t)}},Be={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:be},render:function(e,t,n,i,o,r){const s=d("selector");return p(),c(s,{onSelectOption:r.selectOption},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["onSelectOption"])},__file:"src/components/base/condition-selector/condition-selector.vue"},Re={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new te(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null},__file:"src/components/renderless/query.vue"},je={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:we,SelectorOption:xe,Selector:be,...$e},render:function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector"),a=d("renderless-clause");return p(),c(a,B(R(n.input)),{default:f((({setValue:e})=>[v(" clause selector "),m(l,{onSelectOption:r.switchClause,innerClass:"refine-clause-selector"},{default:f((()=>[(p(!0),_(k,null,$(n.meta.clauses,(({id:t,display:i,component:o,meta:r})=>(p(),c(s,{key:t,id:t,display:i,selected:n.input.clause===t},{default:f((()=>[o?(p(),c(j(o),h({key:0},{...n.meta,...r,...n.input},{onInput:e}),null,16,["onInput"])):v("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},__file:"src/components/base/query-builder/clause.vue"},Ae={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:je,RenderlessRefinement:Oe,Selector:be,SelectorOption:xe},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}},render:function(e,t,n,i,o,r){const s=d("clause"),l=d("renderless-refinement"),a=d("selector-option"),u=d("selector");return p(),c(u,{onSelectOption:r.selectRefinement},{default:f((()=>[(p(!0),_(k,null,$(n.refinements,(({id:e,meta:t,display:i})=>(p(),c(a,{key:e,id:e,display:i,selected:!!n.input[e]},{default:f((()=>[m(l,{id:e},{default:f((()=>[m(s,{meta:t,input:n.input[e],onSwitchClause:({id:t})=>r.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},__file:"src/components/base/query-builder/refinements.vue"},De={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:je,Refinements:Ae,SelectorOption:xe,Selector:be,RefineFlavor:N}};const Me=O("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);De.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("clause"),a=d("refinements"),u=d("selector-option"),h=d("selector");return p(),c(s,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:f((()=>[n.errors.length>0?(p(),c(s,{key:0,as:"ul",component:"criterion.errors"},{default:f((()=>[(p(!0),_(k,null,$(n.errors,(e=>(p(),c(s,{as:"li",component:"criterion.errors.error",key:e},{default:f((()=>[g(b(e),1)])),_:2},1024)))),128))])),_:1})):v("v-if",!0)])),selector:f((()=>[m(h,{onSelectOption:r.switchCondition},{default:f((()=>[(p(!0),_(k,null,$(n.conditions,(({id:e,display:t,meta:i,refinements:o})=>(p(),c(u,{key:e,id:e,display:t,selected:n.conditionId===e},{default:f((()=>[O("div",null,[m(l,{input:n.input,meta:i,onSwitchClause:r.switchClause},null,8,["input","meta","onSwitchClause"]),o&&o.length>0?(p(),c(a,{key:0,input:n.input,refinements:o},null,8,["input","refinements"])):v("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:f((()=>[m(s,{as:"button",component:"criterion.removeCriterionButton",onClick:t[0]||(t[0]=y((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:f((()=>[m(s,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[Me])),_:1})])),_:1})])),_:1})},De.__file="src/components/base/query-builder/criterion.vue";var Ne={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>o?{}:{key:e},templateChildKey:e=>o?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var n;n=e.flavor,t(A,n)},components:{Criterion:De,RefineFlavor:N,RenderlessCondition:ye,RenderlessQueryBuilder:ve}};const Ve=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Pe=g(" Add a new condition "),Ee=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Fe=g(" And"),He=g(" Add an 'Or' ");Ne.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("criterion"),a=d("renderless-condition"),u=d("renderless-query-builder");return p(),c(u,{blueprint:n.blueprint,conditions:n.conditions,onChange:r.onChange},{default:f((({groupedBlueprint:e,replaceCriterion:t,insertCriterion:i,addGroup:o,removeCriterion:u,conditionFor:d})=>[v(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(p(),c(s,h({key:0,as:"div",component:"emptyGroup"},{addGroup:o},{order:["button","default"]}),{button:f((()=>[m(s,{as:"button",component:"emptyGroup.addCriterionButton",onClick:o,tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[Ve])),_:1}),m(s,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:f((()=>[Pe])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(p(),c(s,{key:1,as:"div",component:"group.wrapper"},{default:f((()=>[(p(!0),_(k,null,$(e,((o,g)=>(p(),_(k,null,[m(s,h({as:"div",component:"group"},r.templateChildKey(`group-${g}`)),{default:f((()=>[v(" This really should be named criterion, as that's what it is. "),(p(!0),_(k,null,$(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:f((()=>[m(a,B(R(d({id:e.condition_id,...e}))),{default:f((({switchClause:i})=>[m(l,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>u(e.position),onSwitchCondition:n=>t(e.position,d(n)),conditionId:e.condition_id,conditions:n.conditions,errors:n.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),m(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:f((()=>[m(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.length-1].position),tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[Ee])),_:1}),m(s,{as:"span",component:"group.addCriterionButton.text"},{default:f((()=>[Fe])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),v(" Divider between groups. Blank by default, but used in Nova. "),m(s,h({as:"template",component:"group.divider",index:g,total:e.length},r.templateChildKey(`separator-${g}`)),null,16,["index","total"])],64)))),256)),m(s,{as:"button",component:"addGroupButton",onClick:o,type:"button"},{default:f((()=>[He])),_:2},1032,["onClick"])])),_:2},1024)),v(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},Ne.__file="src/components/base/query-builder/query-builder.vue";const Te="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Le="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",ze=`${Te} ${Le} w-60 pl-3 py-2`,Ge={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Te} ${Le} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${ze} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:ze,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:ze}},Ke="bg-white relative text-left cursor-default",We=`${Ke} focus:outline-none pl-3 py-1`,Qe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ke} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${We} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${We} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:We}}};export{Be as ConditionSelector,qe as DatePickerPlugin,Re as Query,Ne as QueryBuilder,Ie as RefinePlugin,be as Selector,xe as SelectorOption,Qe as linearFlavor,Ge as tailwindFlavor};
//# sourceMappingURL=refine-vue.esm.min.js.map

@@ -21,3 +21,3 @@ {

],
"version": "0.2.4",
"version": "0.3.1",
"scripts": {

@@ -32,2 +32,3 @@ "test": "jest ./tests",

"peerDependencies": {
"@vue/composition-api": "^1.4.2",
"vue": "*"

@@ -41,4 +42,3 @@ },

"dependencies": {
"@vue/composition-api": "^1.4.2",
"vue-demi": "^0.12.1"
"vue-demi": "^0.13.11"
},

@@ -61,2 +61,3 @@ "devDependencies": {

"rollup": "^2.61.1",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-livereload": "^2.0.5",

@@ -63,0 +64,0 @@ "rollup-plugin-postcss": "^4.0.2",

@@ -8,2 +8,3 @@ import RefineDoubleNumberInput from './double-number-input';

import RefineOptionInput from './option-input';
import RefineNativeDatePicker from './native-date-picker'

@@ -18,2 +19,3 @@ export default {

RefineTextInput,
RefineNativeDatePicker,
};

@@ -29,2 +31,3 @@

RefineTextInput,
RefineNativeDatePicker,
};
import { h, defineComponent, isVue2, computed } from 'vue-demi';
import { useFlavor } from '../../../hooks/useFlavor';
import Config from './../../../plugins/config';

@@ -9,4 +11,2 @@ // vue-demi does not export resolveComponent, which is required when using

import { useFlavor } from '../../../hooks/useFlavor';
export const RefineFlavor = defineComponent({

@@ -33,3 +33,6 @@ name: 'RefineFlavor',

inheritAttrs: false,
setup(incomingProps, bindings) {
let showLocators = Config.get('showLocators');
const flavor = useFlavor(

@@ -42,6 +45,24 @@ (flavor) => {

}
// If you just want to set the class on an element, you can use a
// string or function instead of an object with a "class" key.
if (typeof result === 'string' || typeof result === 'function') {
result = {
class: result,
};
}
return result;
},
computed(() => incomingProps.as),
computed(() => incomingProps.flavorOptions)
computed(() => {
// Originally we only passed "flavorOptions" through to the flavor `class`
// function, but it makes more sense to send them all. So now we combine
// them and pass them all through.
// @TODO It might make sense to get rid of flavorOptions altogether?
return {
...(bindings.attrs ?? {}),
...(incomingProps.flavorOptions ?? {}),
};
}),
);

@@ -62,25 +83,29 @@

? h(
resolvedFlavor.component,
{
scopedSlots: slots,
attrs: bindings.attrs,
props,
on: bindings.listeners,
...resolvedFlavor.props.value,
},
orderedSlots
)
: h(
// In Vue 3, globally registered components must be resolved before they can be used.
// https://vuejs.org/guide/extras/render-function.html#components
isComponent ? resolveComponent(resolvedFlavor.component) : resolvedFlavor.component,
{
resolvedFlavor.component,
{
scopedSlots: slots,
attrs: {
...(showLocators && { 'data-locator': incomingProps.component }),
...bindings.attrs,
'data-flavor': incomingProps.component,
...props,
...resolvedFlavor.props.value,
},
orderedSlots
);
props,
on: bindings.listeners,
...resolvedFlavor.props.value,
},
orderedSlots,
)
: h(
// In Vue 3, globally registered components must be resolved before they can be used.
// https://vuejs.org/guide/extras/render-function.html#components
isComponent ? resolveComponent(resolvedFlavor.component) : resolvedFlavor.component,
{
...(showLocators && { 'data-locator': incomingProps.component }),
...bindings.attrs,
...props,
...resolvedFlavor.props.value,
},
orderedSlots,
);
if (resolvedFlavor.extra.value.wrap) {

@@ -103,2 +128,2 @@ return resolvedFlavor.extra.value.wrap(el);

return clone;
}
}
import { BlueprintStore } from 'refine-core';
import { isVue2 } from 'vue-demi';
export default {

@@ -39,2 +40,17 @@ name: 'renderless-query-builder',

},
watch: {
// We have to watch the blueprint because it may be updated
// programmatically from the outside. This happens in
// Nova when a page is loaded with a stable ID.
blueprint: {
deep: true,
handler(newBlueprint) {
if (newBlueprint === this.internalBlueprint) {
return;
}
this.blueprintStore.updateBlueprint(newBlueprint);
},
},
},
methods: {

@@ -41,0 +57,0 @@ replaceCriterion(previousPosition, newCriterion) {

@@ -47,3 +47,3 @@ const inputBase = 'bg-white relative text-left cursor-default';

addGroupButton: {
class: 'hidden px-2 py-1 bg-blue-500 text-white rounded',
class: 'hidden',
},

@@ -50,0 +50,0 @@

@@ -12,15 +12,8 @@ const inputBase =

wrapper: {
class: 'space-y-4',
},
wrapper: 'space-y-4',
addCriterionButton: {
class: 'flex items-center rounded text-sm text-gray-600',
icon: 'h-4 w-4',
wrapper: {},
icon: {
class: 'h-4 w-4',
},
text: {},

@@ -32,15 +25,8 @@ },

class: 'flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden',
wrapper: {
class: 'space-y-4',
},
wrapper: 'space-y-4',
addCriterionButton: {
class: 'flex items-center rounded text-sm text-gray-600',
wrapper: {},
class: 'flex items-center rounded text-sm text-gray-600',
icon: {
class: 'h-4 w-4',
},
icon: 'h-4 w-4',
text: {},

@@ -50,10 +36,8 @@ },

addGroupButton: {
class: 'px-2 py-1 bg-blue-500 text-white rounded',
},
addGroupButton: 'px-2 py-1 bg-blue-500 text-white rounded',
criterion: {
wrapper: {
class: 'flex flex-wrap gap-x-2 gap-y-4',
order: ['errors', 'selector', 'remove'],
class: 'flex flex-wrap gap-x-2 gap-y-4',
},

@@ -63,5 +47,3 @@ removeCriterionButton: {

'rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto',
icon: {
class: 'h-5 w-5',
},
icon: 'h-5 w-5',
},

@@ -71,5 +53,3 @@ errors: {

'flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside',
error: {
class: 'text-red-600 font-semibold',
},
error: 'text-red-600 font-semibold',
},

@@ -79,11 +59,7 @@ },

select: {
class: ' sm:inline-block w-60',
wrapper: {
class: 'flex items-start gap-4',
},
class: 'sm:inline-block w-60',
wrapper: 'flex items-start gap-4',
customOptions: {
class: '',
wrapper: {
class: 'w-auto pt-4 md:flex md:pt-0',
},
wrapper: 'w-auto pt-4 md:flex md:pt-0',
},

@@ -97,5 +73,3 @@ listbox: {

wrapper: {
class: 'overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg',
},
wrapper: 'overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg',

@@ -110,4 +84,5 @@ item: {

text: {
class: (options) =>
`block truncate ${options.selected ? 'font-semibold' : 'font-normal'}`,
class: (options) => {
`block truncate ${options.selected ? 'font-semibold' : 'font-normal'}`;
},
},

@@ -117,8 +92,3 @@

class: 'w-5 h-5',
wrapper: {
class: (options) =>
`absolute inset-y-0 right-0 flex items-center pr-4 ${
!options.isHighlighted ? 'text-blue-600' : 'text-white'
}`,
},
wrapper: (options) => `absolute inset-y-0 right-0 flex items-center pr-4 ${!options.isHighlighted ? 'text-blue-600' : 'text-white'}`,
},

@@ -132,15 +102,9 @@ },

placeholder: {
class: 'block text-gray-300 truncate select-none',
},
placeholder: 'block text-gray-300 truncate select-none',
selected: {
class: 'block truncate',
},
selected: 'block truncate',
icon: {
class: 'w-5 h-5 text-gray-400',
wrapper: {
class: 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none',
},
wrapper: 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none',
},

@@ -154,9 +118,5 @@ },

placeholder: {
class: 'block text-gray-300 truncate select-none',
},
placeholder: 'block text-gray-300 truncate select-none',
selected: {
class: 'inline-flex p-1 mr-1 border border-gray-300 rounded',
},
selected: 'inline-flex p-1 mr-1 border border-gray-300 rounded',

@@ -167,5 +127,3 @@ deselect: {

wrapper: {
class: 'flex items-center ml-1 text-gray-500 cursor-pointer',
},
wrapper: 'flex items-center ml-1 text-gray-500 cursor-pointer',
},

@@ -177,5 +135,3 @@ },

wrapper: {
class: 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none',
},
wrapper: 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none',
},

@@ -188,18 +144,11 @@ },

date: {
pickerInput: {
class: `${inputBase} ${inputFocus} block w-full pl-3 py-2 pr-0`,
},
class: `${inputBase} ${inputFocus} h-9 py-5 px-2 leading-normal box-border`,
relative: {
class: `${inputClassName} mr-4`,
wrapper: {
class: 'flex mr-4',
},
wrapper: 'flex mr-4',
},
double: {
wrapper: {
class: 'flex items-center gap-[1ch]',
},
wrapper: 'flex items-center gap-[1ch]',
joiner: {},

@@ -211,8 +160,4 @@ },

class: inputClassName,
double: {
wrapper: {
class: 'flex items-center gap-[1ch]',
},
wrapper: 'flex items-center gap-[1ch]',
joiner: {},

@@ -222,5 +167,3 @@ },

text: {
class: inputClassName,
},
text: inputClassName,
},

@@ -227,0 +170,0 @@ };

import './directives';
import DatePickerPlugin from './plugins/date-picker';
import { default as RefinePlugin } from './plugins/refine';
/**
* @deprecated Use the RefinePlugin instead.
*/
import { default as DatePickerPlugin } from './plugins/date-picker';
export * from './components/base';
export * from './flavors';
export { DatePickerPlugin };
export { RefinePlugin, DatePickerPlugin };

@@ -0,8 +1,11 @@

import plugin from './refine';
/**
* @deprecated use the RefinePlugin instead.
*/
export default {
install: (app, { DatePicker }) => {
// vue3 recommends providing this component
// and getting it via inject, however, this works
// in both vue2 and vue3
app.component('refine-date-picker', DatePicker);
install: (app, options = {}) => {
// Defer to the new plugin.
plugin.install(app, options);
},
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc