@hammerstone/refine-vue2-dev
Advanced tools
Comparing version 1.0.1672935453 to 1.0.1673095096
@@ -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=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),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((()=>({...n.attrs??{},...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,"data-flavor":t.component},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:"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)};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)}))}},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}},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 K=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};K._withStripped=!0;const U=v({render:K,staticRenderFns:[]},undefined,Y,undefined,false,undefined,!1,void 0,void 0,void 0);const Q=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 W={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 J=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))};J._withStripped=!0;const X=v({render:J,staticRenderFns:[]},undefined,W,undefined,false,undefined,!1,void 0,void 0,void 0);const Z={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:X,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,Z,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:X,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:X,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:()=>({})}},watch:{blueprint(){console.log("watcher")}},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 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,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)]}}])})};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"},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=U,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=Q,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");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((()=>({...n.attrs??{},...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,"data-flavor":t.component},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:"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)};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)}))}},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}},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 K=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};K._withStripped=!0;const U=v({render:K,staticRenderFns:[]},undefined,Y,undefined,false,undefined,!1,void 0,void 0,void 0);const Q=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 W={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,W,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,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}])})};$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:{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 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,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)]}}])})};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"},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=U,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=Q,exports.QueryBuilder=qe,exports.Selector=M,exports.SelectorOption=G,exports.linearFlavor=Ve,exports.tailwindFlavor=Fe; | ||
//# 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=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),i&&(console.log("onchange"),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((()=>({...i.attrs??{},...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,"data-flavor":t.component},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:"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)};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)}))}},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}},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 K=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};K._withStripped=!0;const U=m({render:K,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),Q=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),W={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 J=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))};J._withStripped=!0;const X=m({render:J,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={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:X,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,Z,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:X,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:X,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:()=>({})}},watch:{blueprint(){console.log("watcher")}},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 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,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)]}}])})};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"},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=U,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=Q,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"),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},u=(e,t)=>n(e,r(t)),c=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:c()}},f=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:c()}},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)?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 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(u(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,u=a&&l;n||r?u&&s?i.splice(e-1,2):u&&!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:c()}}()),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 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 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((()=>({...i.attrs??{},...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,"data-flavor":t.component},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:"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)};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)}))}},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}},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 K=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};K._withStripped=!0;const U=m({render:K,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),Q=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),W={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,W,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 ue=m({render:de,staticRenderFns:[]},void 0,ae,void 0,!1,void 0,!1,void 0,void 0,void 0),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,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,ce,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:ue,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:ue,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,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}])})};$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:{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 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,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)]}}])})};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"},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=U,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=Q,exports.QueryBuilder=qe,exports.Selector=M,exports.SelectorOption=G,exports.linearFlavor=Ve,exports.tailwindFlavor=Fe; | ||
//# 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=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),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((()=>({...t.attrs??{},...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,"data-flavor":e.component},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:"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)};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 K=k({render:Y,staticRenderFns:[]},undefined,G,undefined,false,undefined,!1,void 0,void 0,void 0);var U={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)}))}},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: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}},Q={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)},W={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)},J={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 X={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 Z=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)};Z._withStripped=!0;const ee=k({render:Z,staticRenderFns:[]},undefined,X,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:K}};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:K,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:K,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:W,SelectorOption:ee,Selector:K,...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:J,Selector:K,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:K,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:()=>({})}},watch:{blueprint(){console.log("watcher")}},methods:{templateKey:e=>n?{}:{key:e},templateChildKey:e=>n?{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,o(q,t)},components:{Criterion:k({render:Ae,staticRenderFns:[]},undefined,De,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:E,RenderlessCondition:Q,RenderlessQueryBuilder:U}};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,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)]}}])})};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"},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,K as Selector,ee as SelectorOption,Ye as linearFlavor,Le as tailwindFlavor}; | ||
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((()=>({...t.attrs??{},...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,"data-flavor":e.component},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:"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)};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 K=k({render:Y,staticRenderFns:[]},undefined,G,undefined,false,undefined,!1,void 0,void 0,void 0);var U={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)}))}},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: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}},Q={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)},W={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:K}};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:K,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:K,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:W,SelectorOption:ee,Selector:K,...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:K,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:K,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,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}])})};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:{templateKey:e=>n?{}:{key:e},templateChildKey:e=>n?{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,o(q,t)},components:{Criterion:k({render:Ae,staticRenderFns:[]},undefined,De,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:E,RenderlessCondition:Q,RenderlessQueryBuilder:U}};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,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)]}}])})};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"},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,K as Selector,ee as SelectorOption,Ye as linearFlavor,Le 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=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),i&&(console.log("onchange"),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((()=>({...t.attrs??{},...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,"data-flavor":e.component},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:"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)};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 K=k({render:Y,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0);var U={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)}))}},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: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}},Q={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)},W={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)},J={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 X={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 Z=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)};Z._withStripped=!0;const ee=k({render:Z,staticRenderFns:[]},void 0,X,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:K}};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:K,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:K,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:W,SelectorOption:ee,Selector:K,...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:J,Selector:K,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:K,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:()=>({})}},watch:{blueprint(){console.log("watcher")}},methods:{templateKey:e=>i?{}:{key:e},templateChildKey:e=>i?{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,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:Q,RenderlessQueryBuilder:U}};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,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)]}}])})};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"},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,K as Selector,ee as SelectorOption,Ye as linearFlavor,Le as tailwindFlavor}; | ||
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((()=>({...t.attrs??{},...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,"data-flavor":e.component},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:"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)};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 K=k({render:Y,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0);var U={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)}))}},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: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}},Q={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)},W={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:K}};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:K,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:K,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:W,SelectorOption:ee,Selector:K,...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:K,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:K,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,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}])})};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:{templateKey:e=>i?{}:{key:e},templateChildKey:e=>i?{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,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:Q,RenderlessQueryBuilder:U}};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,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)]}}])})};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"},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,K as Selector,ee as SelectorOption,Ye as linearFlavor,Le 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=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),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((()=>({...n.attrs??{},...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,"data-flavor":t.component},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 N=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((()=>[N])),_: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 I={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);I.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((()=>[$])),_: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"])},I.__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:I,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 P={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:R}};P.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"])},P.__file="src/components/base/condition-selector/condition-selector.vue";var T={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 K={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 G=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);K.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((()=>[G])),_: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"])},K.__file="src/components/base/inputs/date-picker.vue";var U={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:K},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:K,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 J={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}}};J.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"])},J.__file="src/components/base/inputs/option-input.vue";var Z={RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:J,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:Z,RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:J,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:{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 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: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((()=>[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,((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(c,t.normalizeProps(t.guardReactiveProps(p({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(a,{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((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_: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((()=>[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"},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=P,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=T,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");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,p=(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},d=(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:p({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=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),n([...this.blueprint]))},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?d(p({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||u()}):d(p({},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(d(p({},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,p=a&&l;!o&&!i?this.blueprint=[]:p&&s?t.splice(e-1,2):p&&!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=p({},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=p({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((()=>({...n.attrs??{},...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]?.())),p=e.isVue2?e.h(i.component,{scopedSlots:l,attrs:{...n.attrs,"data-flavor":t.component},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(p):p}}});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 N=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((()=>[N])),_: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 I={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);I.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((()=>[$])),_: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"])},I.__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:I,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"),p=t.resolveComponent("selector-listbox"),d=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(d,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(d,{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(p,{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(d,{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)}))}},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}},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 P={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:R}};P.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"])},P.__file="src/components/base/condition-selector/condition-selector.vue";var T={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 K={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 G=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);K.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((()=>[G])),_: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"])},K.__file="src/components/base/inputs/date-picker.vue";var U={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:K},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:K,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 J={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}}};J.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"])},J.__file="src/components/base/inputs/option-input.vue";var Z={RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:J,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:Z,RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:J,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"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(p,{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"),p=t.resolveComponent("selector-option"),d=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(d,{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(p,{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:()=>({})}},watch:{blueprint(){console.log("watcher")}},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 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"),p=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(p,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:p,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,((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(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=>p(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: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((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_: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((()=>[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",pe="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",de=`${ce} ${pe} 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} ${pe} block w-full pl-3 py-2 pr-0`},relative:{class:`${de} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:de,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:de}}},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"},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=P,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=T,exports.QueryBuilder=oe,exports.Selector=R,exports.SelectorOption=F,exports.linearFlavor=fe,exports.tailwindFlavor=ue; | ||
//# 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,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=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),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?d&&s?t.splice(e-1,2):d&&!o||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: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((()=>({...n.attrs??{},...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,"data-flavor":t.component},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"},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 N=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((()=>[N])),_: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 I={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);I.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((()=>[$])),_: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"])},I.__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:I,RenderlessSelector:g,SelectorListItem:V,SelectorButton:k,SelectorListbox:_,RefineFlavor:O},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})},__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),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}}},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"},P={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"},T={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"),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})},__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"},K={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 G=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);K.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((()=>[G])),_: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"])},K.__file="src/components/base/inputs/date-picker.vue";var U={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:K},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:K,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"),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})},__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"),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})},__file:"src/components/base/inputs/relative-date-input.vue"},J={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"),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"])},__file:"src/components/base/inputs/option-input.vue"},Z={RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:J,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:Z,RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:J,RefineRelativeDateInput:Q,RefineTextInput:z})},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)},__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"),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"])},__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"),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:{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 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: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((()=>[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,((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(c,t.normalizeProps(t.guardReactiveProps(p({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(a,{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((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_: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((()=>[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"},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=P,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=T,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"),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,p=(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},d=(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:p({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=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),n([...this.blueprint]))},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?d(p({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||u()}):d(p({},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(d(p({},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,p=a&&l;o||i?p&&s?t.splice(e-1,2):p&&!o||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: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=p({},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=p({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((()=>({...n.attrs??{},...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]?.())),p=e.isVue2?e.h(i.component,{scopedSlots:l,attrs:{...n.attrs,"data-flavor":t.component},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(p):p}}});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 N=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((()=>[N])),_: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 I={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);I.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((()=>[$])),_: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"])},I.__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:I,RenderlessSelector:g,SelectorListItem:V,SelectorButton:k,SelectorListbox:_,RefineFlavor:O},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"),p=t.resolveComponent("selector-listbox"),d=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(d,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(d,{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(p,{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(d,{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)}))}},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}},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}}},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"},P={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"},T={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"),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})},__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"},K={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 G=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);K.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((()=>[G])),_: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"])},K.__file="src/components/base/inputs/date-picker.vue";var U={name:"refine-date-input",props:{date1:{type:String,required:!1}},emits:["input"],components:{DatePicker:K},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:K,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"),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})},__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"),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})},__file:"src/components/base/inputs/relative-date-input.vue"},J={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"),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"])},__file:"src/components/base/inputs/option-input.vue"},Z={RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:J,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:Z,RefineDateInput:U,RefineDoubleDateInput:W,RefineDoubleNumberInput:H,RefineNumberInput:L,RefineOptionInput:J,RefineRelativeDateInput:Q,RefineTextInput:z})},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)},__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"),a=t.resolveComponent("renderless-refinement"),c=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(p,{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"])},__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"),a=t.resolveComponent("clause"),c=t.resolveComponent("refinements"),p=t.resolveComponent("selector-option"),d=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(d,{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(p,{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:()=>({})}},watch:{blueprint(){console.log("watcher")}},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 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"),p=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(p,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:p,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,((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(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=>p(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: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((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_: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((()=>[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",pe="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",de=`${ce} ${pe} 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} ${pe} block w-full pl-3 py-2 pr-0`},relative:{class:`${de} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:de,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:de}}},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"},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=P,exports.DatePickerPlugin={install:(e,{DatePicker:t})=>{e.component("refine-date-picker",t)}},exports.Query=T,exports.QueryBuilder=oe,exports.Selector=R,exports.SelectorOption=F,exports.linearFlavor=fe,exports.tailwindFlavor=ue; | ||
//# 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,N=Object.prototype.hasOwnProperty,F=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={}))N.call(t,n)&&T(e,n,t[n]);if(H)for(var n of H(t))F.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()}},K=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:L()}},Y=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),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)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)=>{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,K(),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,K(),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 J=1;var Z={beforeCreate(){this.uid=J.toString(),J+=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((()=>({...t.attrs??{},...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,"data-flavor":e.component},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:[Z],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:"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]=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:[Z],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 Y(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 Y(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:[Z],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:{templateKey:e=>n?{}:{key:e},templateChildKey:e=>n?{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,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' ");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:u,conditionFor:d})=>[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,((o,h)=>(p(),S(_,null,[b(s,q({as:"div",component:"group"},r.templateChildKey(`group-${h}`)),{default:m((()=>[y(" This really should be named criterion, as that's what it is. "),(p(!0),S(_,null,I(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:m((()=>[b(a,B(R(d({id:e.condition_id,...e}))),{default:m((({switchClause:i})=>[b(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)),b(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:m((()=>[b(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.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},1040),y(" Divider between groups. Blank by default, but used in Nova. "),b(s,q({as:"template",component:"group.divider",index:h,total:e.length},r.templateChildKey(`separator-${h}`)),null,16,["index","total"])],64)))),256)),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"])},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",Ke=`${Ge} 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"},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:`${Ke} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ke} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ke}}};export{be as ConditionSelector,A as DatePickerPlugin,ye as Query,De as QueryBuilder,ce as Selector,ve as SelectorOption,Ye as linearFlavor,Le as tailwindFlavor}; | ||
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,N=Object.prototype.hasOwnProperty,F=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={}))N.call(t,n)&&T(e,n,t[n]);if(H)for(var n of H(t))F.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()}},K=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:L()}},Y=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),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)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)=>{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,K(),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,K(),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 J=1;var Z={beforeCreate(){this.uid=J.toString(),J+=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((()=>({...t.attrs??{},...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,"data-flavor":e.component},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:[Z],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:"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]=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:[Z],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 Y(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: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 Y(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:[Z],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:()=>({})}},watch:{blueprint(){console.log("watcher")}},methods:{templateKey:e=>n?{}:{key:e},templateChildKey:e=>n?{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,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' ");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:u,conditionFor:d})=>[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,((o,h)=>(p(),S(_,null,[b(s,q({as:"div",component:"group"},r.templateChildKey(`group-${h}`)),{default:m((()=>[y(" This really should be named criterion, as that's what it is. "),(p(!0),S(_,null,I(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:m((()=>[b(a,B(R(d({id:e.condition_id,...e}))),{default:m((({switchClause:i})=>[b(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)),b(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:m((()=>[b(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.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},1040),y(" Divider between groups. Blank by default, but used in Nova. "),b(s,q({as:"template",component:"group.divider",index:h,total:e.length},r.templateChildKey(`separator-${h}`)),null,16,["index","total"])],64)))),256)),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"])},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",Ke=`${Ge} 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"},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:`${Ke} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ke} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ke}}};export{be as ConditionSelector,A as DatePickerPlugin,ye as Query,De as QueryBuilder,ce as Selector,ve as SelectorOption,Ye as linearFlavor,Le 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,N=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,T=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))H.call(t,n)&&T(e,n,t[n]);if(N)for(var n of N(t))F.call(t,n)&&T(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:P({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()}},K=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:L()}},Y=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),n([...this.blueprint]))},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?z(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||L()}):z(P({},e),{id:void 0,uid:L()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)H.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&N)for(var i of N(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(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: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,K(),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,K(),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=P({},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=P({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 J=1;var Z={beforeCreate(){this.uid=J.toString(),J+=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((()=>({...t.attrs??{},...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,"data-flavor":e.component},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:[Z],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:"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]=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:[Z],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 Y(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 Y(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:[Z],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:{templateKey:e=>n?{}:{key:e},templateChildKey:e=>n?{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,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 "),Ne=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),He=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:u,conditionFor:d})=>[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,((o,h)=>(p(),S(_,null,[b(s,q({as:"div",component:"group"},r.templateChildKey(`group-${h}`)),{default:m((()=>[y(" This really should be named criterion, as that's what it is. "),(p(!0),S(_,null,I(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:m((()=>[b(a,B(R(d({id:e.condition_id,...e}))),{default:m((({switchClause:i})=>[b(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)),b(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:m((()=>[b(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.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((()=>[Ne])),_:1}),b(s,{as:"span",component:"group.addCriterionButton.text"},{default:m((()=>[He])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),y(" Divider between groups. Blank by default, but used in Nova. "),b(s,q({as:"template",component:"group.divider",index:h,total:e.length},r.templateChildKey(`separator-${h}`)),null,16,["index","total"])],64)))),256)),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 Te="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Pe="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",ze=`${Te} ${Pe} 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} ${Pe} 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",Ke=`${Ge} 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"},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:`${Ke} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ke} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ke}}};export{be as ConditionSelector,A as DatePickerPlugin,ye as Query,Me as QueryBuilder,ce as Selector,ve as SelectorOption,Ye as linearFlavor,Le as tailwindFlavor}; | ||
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,N=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,T=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))H.call(t,n)&&T(e,n,t[n]);if(N)for(var n of N(t))F.call(t,n)&&T(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:P({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()}},K=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:L()}},Y=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{console.log("blueprint changed",JSON.parse(JSON.stringify(this.blueprint))),n&&(console.log("onchange"),n([...this.blueprint]))},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?z(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||L()}):z(P({},e),{id:void 0,uid:L()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)H.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&N)for(var i of N(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(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: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,K(),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,K(),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=P({},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=P({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 J=1;var Z={beforeCreate(){this.uid=J.toString(),J+=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((()=>({...t.attrs??{},...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,"data-flavor":e.component},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:[Z],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:"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]=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:[Z],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 Y(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: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 Y(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:[Z],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:()=>({})}},watch:{blueprint(){console.log("watcher")}},methods:{templateKey:e=>n?{}:{key:e},templateChildKey:e=>n?{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,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 "),Ne=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),He=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:u,conditionFor:d})=>[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,((o,h)=>(p(),S(_,null,[b(s,q({as:"div",component:"group"},r.templateChildKey(`group-${h}`)),{default:m((()=>[y(" This really should be named criterion, as that's what it is. "),(p(!0),S(_,null,I(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:m((()=>[b(a,B(R(d({id:e.condition_id,...e}))),{default:m((({switchClause:i})=>[b(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)),b(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:m((()=>[b(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.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((()=>[Ne])),_:1}),b(s,{as:"span",component:"group.addCriterionButton.text"},{default:m((()=>[He])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),y(" Divider between groups. Blank by default, but used in Nova. "),b(s,q({as:"template",component:"group.divider",index:h,total:e.length},r.templateChildKey(`separator-${h}`)),null,16,["index","total"])],64)))),256)),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 Te="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Pe="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",ze=`${Te} ${Pe} 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} ${Pe} 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",Ke=`${Ge} 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"},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:`${Ke} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ke} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ke}}};export{be as ConditionSelector,A as DatePickerPlugin,ye as Query,Me as QueryBuilder,ce as Selector,ve as SelectorOption,Ye as linearFlavor,Le as tailwindFlavor}; | ||
//# sourceMappingURL=refine-vue.esm.min.js.map |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "1.0.1672935453", | ||
"version": "1.0.1673095096", | ||
"scripts": { | ||
@@ -24,0 +24,0 @@ "test": "jest ./tests", |
import { BlueprintStore } from 'refine-core'; | ||
import { isVue2 } from 'vue-demi'; | ||
export default { | ||
@@ -40,2 +41,5 @@ 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: { | ||
@@ -42,0 +46,0 @@ deep: true, |
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
1689354
3247