@hammerstone/refine-vue2
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();let n={};var i={init(e){n=e},get:(e,t=null)=>n?.[e]??t,set(e,t){n[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(n,r){let o=i.get("showLocators");const s=function(n,i,r=e.computed((()=>({})))){const o=e.inject(t),s=e.computed((()=>n(o)??{})),l=e.computed((()=>{const e={},t=r.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),d=e.computed((()=>{const e={},t=r.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e.computed((()=>({component:s.value.component??i.value,props:d,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e.computed((()=>n.as)),e.computed((()=>({...r.attrs??{},...n.flavorOptions??{}}))));return()=>{const t=s.value,i=t.extra.value.order??n.order,l=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(n,["as","component","order"]),d=r.slots;let a="string"==typeof t.component&&t.component.includes("-"),u=a?d:i.map((e=>d?.[e]?.())),c=e.isVue2?e.h(t.component,{scopedSlots:d,attrs:{...o&&{"data-locator":n.component},...r.attrs},props:l,on:r.listeners,...t.props.value},u):e.h(t.component,{...o&&{"data-locator":n.component},...r.attrs,...l,...t.props.value},u);return t.extra.value.wrap?t.extra.value.wrap(c):c}}});function o(e,t,n,i,r,o,s,l,d,a){"boolean"!=typeof s&&(d=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,d(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,a(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:r}};var l=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};l._withStripped=!0;const d=o({render:l,staticRenderFns:[]},undefined,s,undefined,false,undefined,!1,void 0,void 0,void 0);const a={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:d,RefineFlavor:r}};var u=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};u._withStripped=!0;const c=o({render:u,staticRenderFns:[]},undefined,a,undefined,false,undefined,!1,void 0,void 0,void 0);const p={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};var f=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};f._withStripped=!0;const h=o({render:f,staticRenderFns:[]},undefined,p,undefined,false,undefined,!1,void 0,void 0,void 0);const m={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};var v=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};v._withStripped=!0;const g=o({render:v,staticRenderFns:[]},undefined,m,undefined,false,undefined,!1,void 0,void 0,void 0);const y={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var b=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};b._withStripped=!0;const w=o({render:b,staticRenderFns:[]},undefined,y,undefined,false,undefined,!1,void 0,void 0,void 0);var x=e=>"conjunction"===(null==e?void 0:e.type),O=Object.defineProperty,_=Object.defineProperties,C=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,R=(e,t,n)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))S.call(t,n)&&R(e,n,t[n]);if(k)for(var n of k(t))$.call(t,n)&&R(e,n,t[n]);return e},q=(e,t)=>_(e,C(t)),B=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},j=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:I({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:B()}},E=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:B()}},F=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?q(I({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||B()}):q(I({},e),{id:void 0,uid:B()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)S.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&k)for(var i of k(e))t.indexOf(i)<0&&$.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{x(t)?"or"===t.word&&e.push([]):e[e.length-1].push(q(I({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=j(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=x(i)&&"or"===i.word,o=x(n)&&"or"===n.word,s=r||!i,l=o||!n,d=l&&!s,a=l&&s;!n&&!i?this.blueprint=[]:a&&o?t.splice(e-1,2):a&&!n||d?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:B()}}()),e.push(j(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=j(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,E(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,E(),j(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=I({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},A=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=I({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const D=o({},undefined,{name:"renderless-selector",data:()=>({selector:e.reactive(new A),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:d,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:d,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),V={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let P=1;var N={beforeCreate(){this.uid=P.toString(),P+=1}};const M={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};var T=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};T._withStripped=!0;const L=o({render:T,staticRenderFns:[]},undefined,M,undefined,false,undefined,!1,void 0,void 0,void 0);const G={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};var z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};z._withStripped=!0;const H=o({render:z,staticRenderFns:[]},undefined,G,undefined,false,undefined,!1,void 0,void 0,void 0);const K={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};var U=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};U._withStripped=!0;const Q=o({render:U,staticRenderFns:[]},undefined,K,undefined,false,undefined,!1,void 0,void 0,void 0);const W={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};var X=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};X._withStripped=!0;const Y=o({render:X,staticRenderFns:[]},undefined,W,undefined,false,undefined,!1,void 0,void 0,void 0);const Z={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:Y,RenderlessSelector:D,SelectorListItem:Q,SelectorButton:L,SelectorListbox:H,RefineFlavor:r}};var J=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,d=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,d,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(d,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};J._withStripped=!0;const ee=o({render:J,staticRenderFns:[]},undefined,Z,undefined,false,undefined,!1,void 0,void 0,void 0);var te={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:i,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:i,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},ne={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!i)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(n.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),d=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>i.slots.default?i.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:d}):null})(t.id,t,n)},ie={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...r.input}):null})(t.clause,t,n)},re={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const oe={name:"selector-option",mixins:[V],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[V],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};se._withStripped=!0;const le=o({render:se,staticRenderFns:[]},undefined,oe,undefined,false,undefined,!1,void 0,void 0,void 0);const de={name:"refine-date-input",components:{Selector:ee,SelectorOption:le,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ae._withStripped=!0;const ue=o({render:ae,staticRenderFns:[]},undefined,de,undefined,false,undefined,!1,void 0,void 0,void 0);const ce={name:"refine-option-input",components:{Selector:ee,SelectorOption:le},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};pe._withStripped=!0;const fe=o({render:pe,staticRenderFns:[]},undefined,ce,undefined,false,undefined,!1,void 0,void 0,void 0);const he={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var me=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};me._withStripped=!0;const ve=o({render:me,staticRenderFns:[]},undefined,he,undefined,false,undefined,!1,void 0,void 0,void 0);var ge={RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:d,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:ve},ye=Object.freeze({__proto__:null,default:ge,RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:d,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:ve}),be={install:(e,t={})=>{t={DatePicker:ve,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,i.init(t)}},we={install:(e,t={})=>{be.install(e,t)}};const xe={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ee}};var Oe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Oe._withStripped=!0;const _e=o({render:Oe,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);const Ce=o({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const ke={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ie,SelectorOption:le,Selector:ee,...ye}};var Se=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Se._withStripped=!0;const $e=o({render:Se,staticRenderFns:[]},undefined,ke,undefined,false,undefined,!1,void 0,void 0,void 0);const Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:$e,RenderlessRefinement:re,Selector:ee,SelectorOption:le},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Ie=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Ie._withStripped=!0;const qe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:$e,Refinements:o({render:Ie,staticRenderFns:[]},undefined,Re,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:le,Selector:ee,RefineFlavor:r}};var Be=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Be._withStripped=!0;const je={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(n){var i;i=n.flavor,e.provide(t,i)},components:{Criterion:o({render:Be,staticRenderFns:[]},undefined,qe,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:r,RenderlessCondition:ne,RenderlessQueryBuilder:te}};var Ee=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,d=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,d(e))}}})]}}],null,!0)},"renderless-condition",d(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ee._withStripped=!0;const Fe=o({render:Ee,staticRenderFns:[]},undefined,je,undefined,false,undefined,!1,void 0,void 0,void 0),Ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",De="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ve=`${Ae} ${De} w-60 pl-3 py-2`,Pe={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ae} ${De} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ve} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ve,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ve}},Ne="bg-white relative text-left cursor-default",Me=`${Ne} focus:outline-none pl-3 py-1`,Te={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Me}}};exports.ConditionSelector=_e,exports.DatePickerPlugin=we,exports.Query=Ce,exports.QueryBuilder=Fe,exports.RefinePlugin=be,exports.Selector=ee,exports.SelectorOption=le,exports.linearFlavor=Te,exports.tailwindFlavor=Pe; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();let n={};var i={init(e){n=e},get:(e,t=null)=>n?.[e]??t,set(e,t){n[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(n,r){let o=i.get("showLocators");const s=function(n,i,r=e.computed((()=>({})))){const o=e.inject(t),s=e.computed((()=>n(o)??{})),l=e.computed((()=>{const e={},t=r.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),d=e.computed((()=>{const e={},t=r.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e.computed((()=>({component:s.value.component??i.value,props:d,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e.computed((()=>n.as)),e.computed((()=>({...r.attrs??{},...n.flavorOptions??{}}))));return()=>{const t=s.value,i=t.extra.value.order??n.order,l=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(n,["as","component","order"]),d=r.slots;let a="string"==typeof t.component&&t.component.includes("-"),u=a?d:i.map((e=>d?.[e]?.())),c=e.isVue2?e.h(t.component,{scopedSlots:d,attrs:{...o&&{"data-locator":n.component},...r.attrs},props:l,on:r.listeners,...t.props.value},u):e.h(t.component,{...o&&{"data-locator":n.component},...r.attrs,...l,...t.props.value},u);return t.extra.value.wrap?t.extra.value.wrap(c):c}}});function o(e,t,n,i,r,o,s,l,d,a){"boolean"!=typeof s&&(d=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,d(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,a(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:r}};var l=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};l._withStripped=!0;const d=o({render:l,staticRenderFns:[]},undefined,s,undefined,false,undefined,!1,void 0,void 0,void 0);const a={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:d,RefineFlavor:r}};var u=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};u._withStripped=!0;const c=o({render:u,staticRenderFns:[]},undefined,a,undefined,false,undefined,!1,void 0,void 0,void 0);const p={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};var f=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};f._withStripped=!0;const h=o({render:f,staticRenderFns:[]},undefined,p,undefined,false,undefined,!1,void 0,void 0,void 0);const m={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};var v=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};v._withStripped=!0;const g=o({render:v,staticRenderFns:[]},undefined,m,undefined,false,undefined,!1,void 0,void 0,void 0);const y={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var b=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};b._withStripped=!0;const w=o({render:b,staticRenderFns:[]},undefined,y,undefined,false,undefined,!1,void 0,void 0,void 0);var x=e=>"conjunction"===(null==e?void 0:e.type),O=Object.defineProperty,_=Object.defineProperties,C=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,R=(e,t,n)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))S.call(t,n)&&R(e,n,t[n]);if(k)for(var n of k(t))$.call(t,n)&&R(e,n,t[n]);return e},q=(e,t)=>_(e,C(t)),B=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},j=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:I({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:B()}},E=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:B()}},F=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?q(I({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||B()}):q(I({},e),{id:void 0,uid:B()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)S.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&k)for(var i of k(e))t.indexOf(i)<0&&$.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{x(t)?"or"===t.word&&e.push([]):e[e.length-1].push(q(I({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=j(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=x(i)&&"or"===i.word,o=x(n)&&"or"===n.word,s=r||!i,l=o||!n,d=l&&!s,a=l&&s;!n&&!i?this.blueprint=[]:a&&o?t.splice(e-1,2):a&&!n||d?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:B()}}()),e.push(j(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=j(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,E(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,E(),j(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=I({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},A=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=I({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const D=o({},undefined,{name:"renderless-selector",data:()=>({selector:e.reactive(new A),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:d,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:d,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),V={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let P=1;var N={beforeCreate(){this.uid=P.toString(),P+=1}};const M={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};var T=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};T._withStripped=!0;const L=o({render:T,staticRenderFns:[]},undefined,M,undefined,false,undefined,!1,void 0,void 0,void 0);const G={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};var z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};z._withStripped=!0;const H=o({render:z,staticRenderFns:[]},undefined,G,undefined,false,undefined,!1,void 0,void 0,void 0);const K={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};var U=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};U._withStripped=!0;const Q=o({render:U,staticRenderFns:[]},undefined,K,undefined,false,undefined,!1,void 0,void 0,void 0);const W={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};var X=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};X._withStripped=!0;const Y=o({render:X,staticRenderFns:[]},undefined,W,undefined,false,undefined,!1,void 0,void 0,void 0);const Z={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs["opt-"+e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:Y,RenderlessSelector:D,SelectorListItem:Q,SelectorButton:L,SelectorListbox:H,RefineFlavor:r}};var J=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,d=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,d,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(d,(function(t){return n("selector-list-item",{key:t.id,ref:"opt-"+t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};J._withStripped=!0;const ee=o({render:J,staticRenderFns:[]},undefined,Z,undefined,false,undefined,!1,void 0,void 0,void 0);var te={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:i,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:i,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},ne={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!i)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(n.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),d=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>i.slots.default?i.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:d}):null})(t.id,t,n)},ie={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...r.input}):null})(t.clause,t,n)},re={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const oe={name:"selector-option",mixins:[V],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[V],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};se._withStripped=!0;const le=o({render:se,staticRenderFns:[]},undefined,oe,undefined,false,undefined,!1,void 0,void 0,void 0);const de={name:"refine-date-input",components:{Selector:ee,SelectorOption:le,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ae._withStripped=!0;const ue=o({render:ae,staticRenderFns:[]},undefined,de,undefined,false,undefined,!1,void 0,void 0,void 0);const ce={name:"refine-option-input",components:{Selector:ee,SelectorOption:le},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};pe._withStripped=!0;const fe=o({render:pe,staticRenderFns:[]},undefined,ce,undefined,false,undefined,!1,void 0,void 0,void 0);const he={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var me=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};me._withStripped=!0;const ve=o({render:me,staticRenderFns:[]},undefined,he,undefined,false,undefined,!1,void 0,void 0,void 0);var ge={RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:d,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:ve},ye=Object.freeze({__proto__:null,default:ge,RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:d,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:ve}),be={install:(e,t={})=>{t={DatePicker:ve,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,i.init(t)}},we={install:(e,t={})=>{be.install(e,t)}};const xe={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ee}};var Oe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Oe._withStripped=!0;const _e=o({render:Oe,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);const Ce=o({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const ke={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ie,SelectorOption:le,Selector:ee,...ye}};var Se=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Se._withStripped=!0;const $e=o({render:Se,staticRenderFns:[]},undefined,ke,undefined,false,undefined,!1,void 0,void 0,void 0);const Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:$e,RenderlessRefinement:re,Selector:ee,SelectorOption:le},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Ie=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Ie._withStripped=!0;const qe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:$e,Refinements:o({render:Ie,staticRenderFns:[]},undefined,Re,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:le,Selector:ee,RefineFlavor:r}};var Be=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Be._withStripped=!0;const je={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(n){var i;i=n.flavor,e.provide(t,i)},components:{Criterion:o({render:Be,staticRenderFns:[]},undefined,qe,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:r,RenderlessCondition:ne,RenderlessQueryBuilder:te}};var Ee=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,d=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,d(e))}}})]}}],null,!0)},"renderless-condition",d(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ee._withStripped=!0;const Fe=o({render:Ee,staticRenderFns:[]},undefined,je,undefined,false,undefined,!1,void 0,void 0,void 0),Ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",De="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ve=`${Ae} ${De} w-60 pl-3 py-2`,Pe={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ae} ${De} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ve} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ve,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ve}},Ne="bg-white relative text-left cursor-default",Me=`${Ne} focus:outline-none pl-3 py-1`,Te={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Me}}};exports.ConditionSelector=_e,exports.DatePickerPlugin=we,exports.Query=Ce,exports.QueryBuilder=Fe,exports.RefinePlugin=be,exports.Selector=ee,exports.SelectorOption=le,exports.linearFlavor=Te,exports.tailwindFlavor=Pe; | ||
//# sourceMappingURL=refine-vue.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();let i={};var n={init(e){i=e},get:(e,t=null)=>i?.[e]??t,set(e,t){i[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(i,r){let o=n.get("showLocators");const s=function(i,n,r=e.computed((()=>({})))){const o=e.inject(t),s=e.computed((()=>i(o)??{})),l=e.computed((()=>{const e={},t=r.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=e.computed((()=>{const e={},t=r.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const n=s.value.style;return n&&(e.style="function"==typeof n?n(t):n),e}));return e.computed((()=>({component:s.value.component??n.value,props:a,extra:l})))}((e=>{const t=i.component.split(".");let n=e;for(const e of t)n=n?.[e];return"string"!=typeof n&&"function"!=typeof n||(n={class:n}),n}),e.computed((()=>i.as)),e.computed((()=>({...r.attrs??{},...i.flavorOptions??{}}))));return()=>{const t=s.value,n=t.extra.value.order??i.order,l=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(i,["as","component","order"]),a=r.slots;let d="string"==typeof t.component&&t.component.includes("-")?a:n.map((e=>a?.[e]?.())),u=e.isVue2?e.h(t.component,{scopedSlots:a,attrs:{...o&&{"data-locator":i.component},...r.attrs},props:l,on:r.listeners,...t.props.value},d):e.h(t.component,{...o&&{"data-locator":i.component},...r.attrs,...l,...t.props.value},d);return t.extra.value.wrap?t.extra.value.wrap(u):u}}});function o(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof i?i.options:i;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),n&&(u._scopeId=n),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,i){return c.call(i),e(t,i)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return i}const s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:r}};var l=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};l._withStripped=!0;const a=o({render:l,staticRenderFns:[]},void 0,s,void 0,!1,void 0,!1,void 0,void 0,void 0),d={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:a,RefineFlavor:r}};var u=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};u._withStripped=!0;const c=o({render:u,staticRenderFns:[]},void 0,d,void 0,!1,void 0,!1,void 0,void 0,void 0),p={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};var f=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};f._withStripped=!0;const h=o({render:f,staticRenderFns:[]},void 0,p,void 0,!1,void 0,!1,void 0,void 0,void 0),v={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};var m=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};m._withStripped=!0;const g=o({render:m,staticRenderFns:[]},void 0,v,void 0,!1,void 0,!1,void 0,void 0,void 0),y={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var b=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};b._withStripped=!0;const w=o({render:b,staticRenderFns:[]},void 0,y,void 0,!1,void 0,!1,void 0,void 0,void 0);var x=e=>"conjunction"===(null==e?void 0:e.type),O=Object.defineProperty,_=Object.defineProperties,C=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,R=(e,t,i)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,I=(e,t)=>{for(var i in t||(t={}))S.call(t,i)&&R(e,i,t[i]);if(k)for(var i of k(t))$.call(t,i)&&R(e,i,t[i]);return e},q=(e,t)=>_(e,C(t)),B=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},j=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:I({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:B()}},E=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:B()}},F=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?q(I({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||B()}):q(I({},e),{id:void 0,uid:B()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)S.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&k)for(var n of k(e))t.indexOf(n)<0&&$.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{x(t)?"or"===t.word&&e.push([]):e[e.length-1].push(q(I({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=j(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=x(n)&&"or"===n.word,o=x(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:B()}}()),e.push(j(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=j(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,E(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,E(),j(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=I({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},A=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=I({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const D=o({},void 0,{name:"renderless-selector",data:()=>({selector:e.reactive(new A),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),V={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let P=1;var N={beforeCreate(){this.uid=P.toString(),P+=1}};const M={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};var T=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};T._withStripped=!0;const L=o({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),G={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};var z=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};z._withStripped=!0;const H=o({render:z,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};var U=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};U._withStripped=!0;const Q=o({render:U,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};var X=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};X._withStripped=!0;const Y=o({render:X,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:Y,RenderlessSelector:D,SelectorListItem:Q,SelectorButton:L,SelectorListbox:H,RefineFlavor:r}};var J=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};J._withStripped=!0;const ee=o({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0);var te={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:t,addGroup:i,blueprintStore:n,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:i,blueprint:n,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},ie={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!n)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(i.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),a=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",i.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let d=null;return i?.condition?.meta?.clauses&&(d=i.condition.meta.clauses.map((e=>e.component))),()=>n.slots.default?n.slots.default({clauses:d,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,i)},ne={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:a,...r.input}):null})(t.clause,t,i)},re={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const oe={name:"selector-option",mixins:[V],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[V],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i&&t?i():null}}}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};se._withStripped=!0;const le=o({render:se,staticRenderFns:[]},void 0,oe,void 0,!1,void 0,!1,void 0,void 0,void 0),ae={name:"refine-date-input",components:{Selector:ee,SelectorOption:le,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var de=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};de._withStripped=!0;const ue=o({render:de,staticRenderFns:[]},void 0,ae,void 0,!1,void 0,!1,void 0,void 0,void 0),ce={name:"refine-option-input",components:{Selector:ee,SelectorOption:le},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};pe._withStripped=!0;const fe=o({render:pe,staticRenderFns:[]},void 0,ce,void 0,!1,void 0,!1,void 0,void 0,void 0),he={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var ve=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};ve._withStripped=!0;const me=o({render:ve,staticRenderFns:[]},void 0,he,void 0,!1,void 0,!1,void 0,void 0,void 0);var ge={RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:a,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:me},ye=Object.freeze({__proto__:null,default:ge,RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:a,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:me}),be={install:(e,t={})=>{t={DatePicker:me,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,n.init(t)}},we={install:(e,t={})=>{be.install(e,t)}};const xe={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ee}};var Oe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Oe._withStripped=!0;const _e=o({render:Oe,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0),Ce=o({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i?i({blueprint:t}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),ke={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ne,SelectorOption:le,Selector:ee,...ye}};var Se=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Se._withStripped=!0;const $e=o({render:Se,staticRenderFns:[]},void 0,ke,void 0,!1,void 0,!1,void 0,void 0,void 0),Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:$e,RenderlessRefinement:re,Selector:ee,SelectorOption:le},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Ie=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Ie._withStripped=!0;const qe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:$e,Refinements:o({render:Ie,staticRenderFns:[]},void 0,Re,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:le,Selector:ee,RefineFlavor:r}};var Be=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Be._withStripped=!0;const je={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(i){var n;n=i.flavor,e.provide(t,n)},components:{Criterion:o({render:Be,staticRenderFns:[]},void 0,qe,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:r,RenderlessCondition:ie,RenderlessQueryBuilder:te}};var Ee=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,s){return[i("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),i("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:n.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ee._withStripped=!0;const Fe=o({render:Ee,staticRenderFns:[]},void 0,je,void 0,!1,void 0,!1,void 0,void 0,void 0),Ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",De="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ve=`${Ae} ${De} w-60 pl-3 py-2`,Pe={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ae} ${De} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ve} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ve,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ve}},Ne="bg-white relative text-left cursor-default",Me=`${Ne} focus:outline-none pl-3 py-1`,Te={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Me}}};exports.ConditionSelector=_e,exports.DatePickerPlugin=we,exports.Query=Ce,exports.QueryBuilder=Fe,exports.RefinePlugin=be,exports.Selector=ee,exports.SelectorOption=le,exports.linearFlavor=Te,exports.tailwindFlavor=Pe; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();let i={};var n={init(e){i=e},get:(e,t=null)=>i?.[e]??t,set(e,t){i[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(i,r){let o=n.get("showLocators");const s=function(i,n,r=e.computed((()=>({})))){const o=e.inject(t),s=e.computed((()=>i(o)??{})),l=e.computed((()=>{const e={},t=r.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=e.computed((()=>{const e={},t=r.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const n=s.value.style;return n&&(e.style="function"==typeof n?n(t):n),e}));return e.computed((()=>({component:s.value.component??n.value,props:a,extra:l})))}((e=>{const t=i.component.split(".");let n=e;for(const e of t)n=n?.[e];return"string"!=typeof n&&"function"!=typeof n||(n={class:n}),n}),e.computed((()=>i.as)),e.computed((()=>({...r.attrs??{},...i.flavorOptions??{}}))));return()=>{const t=s.value,n=t.extra.value.order??i.order,l=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(i,["as","component","order"]),a=r.slots;let d="string"==typeof t.component&&t.component.includes("-")?a:n.map((e=>a?.[e]?.())),u=e.isVue2?e.h(t.component,{scopedSlots:a,attrs:{...o&&{"data-locator":i.component},...r.attrs},props:l,on:r.listeners,...t.props.value},d):e.h(t.component,{...o&&{"data-locator":i.component},...r.attrs,...l,...t.props.value},d);return t.extra.value.wrap?t.extra.value.wrap(u):u}}});function o(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof i?i.options:i;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),n&&(u._scopeId=n),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,i){return c.call(i),e(t,i)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return i}const s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:r}};var l=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};l._withStripped=!0;const a=o({render:l,staticRenderFns:[]},void 0,s,void 0,!1,void 0,!1,void 0,void 0,void 0),d={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:a,RefineFlavor:r}};var u=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};u._withStripped=!0;const c=o({render:u,staticRenderFns:[]},void 0,d,void 0,!1,void 0,!1,void 0,void 0,void 0),p={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};var f=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};f._withStripped=!0;const h=o({render:f,staticRenderFns:[]},void 0,p,void 0,!1,void 0,!1,void 0,void 0,void 0),v={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};var m=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};m._withStripped=!0;const g=o({render:m,staticRenderFns:[]},void 0,v,void 0,!1,void 0,!1,void 0,void 0,void 0),y={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var b=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};b._withStripped=!0;const w=o({render:b,staticRenderFns:[]},void 0,y,void 0,!1,void 0,!1,void 0,void 0,void 0);var x=e=>"conjunction"===(null==e?void 0:e.type),O=Object.defineProperty,_=Object.defineProperties,C=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,R=(e,t,i)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,I=(e,t)=>{for(var i in t||(t={}))S.call(t,i)&&R(e,i,t[i]);if(k)for(var i of k(t))$.call(t,i)&&R(e,i,t[i]);return e},q=(e,t)=>_(e,C(t)),B=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},j=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:I({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:B()}},E=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:B()}},F=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?q(I({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||B()}):q(I({},e),{id:void 0,uid:B()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)S.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&k)for(var n of k(e))t.indexOf(n)<0&&$.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{x(t)?"or"===t.word&&e.push([]):e[e.length-1].push(q(I({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=j(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=x(n)&&"or"===n.word,o=x(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:B()}}()),e.push(j(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=j(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,E(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,E(),j(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=I({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},A=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=I({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const D=o({},void 0,{name:"renderless-selector",data:()=>({selector:e.reactive(new A),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),V={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let P=1;var N={beforeCreate(){this.uid=P.toString(),P+=1}};const M={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};var T=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};T._withStripped=!0;const L=o({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),G={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};var z=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};z._withStripped=!0;const H=o({render:z,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};var U=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};U._withStripped=!0;const Q=o({render:U,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};var X=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};X._withStripped=!0;const Y=o({render:X,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs["opt-"+e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:Y,RenderlessSelector:D,SelectorListItem:Q,SelectorButton:L,SelectorListbox:H,RefineFlavor:r}};var J=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:"opt-"+t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};J._withStripped=!0;const ee=o({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0);var te={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:t,addGroup:i,blueprintStore:n,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:i,blueprint:n,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},ie={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!n)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(i.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),a=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",i.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let d=null;return i?.condition?.meta?.clauses&&(d=i.condition.meta.clauses.map((e=>e.component))),()=>n.slots.default?n.slots.default({clauses:d,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,i)},ne={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:a,...r.input}):null})(t.clause,t,i)},re={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const oe={name:"selector-option",mixins:[V],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[V],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i&&t?i():null}}}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};se._withStripped=!0;const le=o({render:se,staticRenderFns:[]},void 0,oe,void 0,!1,void 0,!1,void 0,void 0,void 0),ae={name:"refine-date-input",components:{Selector:ee,SelectorOption:le,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var de=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};de._withStripped=!0;const ue=o({render:de,staticRenderFns:[]},void 0,ae,void 0,!1,void 0,!1,void 0,void 0,void 0),ce={name:"refine-option-input",components:{Selector:ee,SelectorOption:le},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};pe._withStripped=!0;const fe=o({render:pe,staticRenderFns:[]},void 0,ce,void 0,!1,void 0,!1,void 0,void 0,void 0),he={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var ve=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};ve._withStripped=!0;const me=o({render:ve,staticRenderFns:[]},void 0,he,void 0,!1,void 0,!1,void 0,void 0,void 0);var ge={RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:a,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:me},ye=Object.freeze({__proto__:null,default:ge,RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:a,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:me}),be={install:(e,t={})=>{t={DatePicker:me,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,n.init(t)}},we={install:(e,t={})=>{be.install(e,t)}};const xe={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ee}};var Oe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Oe._withStripped=!0;const _e=o({render:Oe,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0),Ce=o({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i?i({blueprint:t}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),ke={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ne,SelectorOption:le,Selector:ee,...ye}};var Se=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Se._withStripped=!0;const $e=o({render:Se,staticRenderFns:[]},void 0,ke,void 0,!1,void 0,!1,void 0,void 0,void 0),Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:$e,RenderlessRefinement:re,Selector:ee,SelectorOption:le},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Ie=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Ie._withStripped=!0;const qe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:$e,Refinements:o({render:Ie,staticRenderFns:[]},void 0,Re,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:le,Selector:ee,RefineFlavor:r}};var Be=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Be._withStripped=!0;const je={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(i){var n;n=i.flavor,e.provide(t,n)},components:{Criterion:o({render:Be,staticRenderFns:[]},void 0,qe,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:r,RenderlessCondition:ie,RenderlessQueryBuilder:te}};var Ee=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,s){return[i("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),i("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:n.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ee._withStripped=!0;const Fe=o({render:Ee,staticRenderFns:[]},void 0,je,void 0,!1,void 0,!1,void 0,void 0,void 0),Ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",De="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ve=`${Ae} ${De} w-60 pl-3 py-2`,Pe={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ae} ${De} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ve} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ve,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ve}},Ne="bg-white relative text-left cursor-default",Me=`${Ne} focus:outline-none pl-3 py-1`,Te={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Me}}};exports.ConditionSelector=_e,exports.DatePickerPlugin=we,exports.Query=Ce,exports.QueryBuilder=Fe,exports.RefinePlugin=be,exports.Selector=ee,exports.SelectorOption=le,exports.linearFlavor=Te,exports.tailwindFlavor=Pe; | ||
//# sourceMappingURL=refine-vue.cjs.min.js.map |
@@ -1,2 +0,2 @@ | ||
import{computed as e,inject as t,provide as n,defineComponent as i,isVue2 as r,h as o,reactive as s,nextTick as l,onUnmounted as a}from"vue-demi";const d=Symbol();let u={};var c={init(e){u=e},get:(e,t=null)=>u?.[e]??t,set(e,t){u[e]=t}};const p=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(n,i){let s=c.get("showLocators");const l=function(n,i,r=e((()=>({})))){const o=t(d),s=e((()=>n(o)??{})),l=e((()=>{const e={},t=r.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=r.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e((()=>n.as)),e((()=>({...i.attrs??{},...n.flavorOptions??{}}))));return()=>{const e=l.value,t=e.extra.value.order??n.order,a=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(n,["as","component","order"]),d=i.slots;let u="string"==typeof e.component&&e.component.includes("-"),c=u?d:t.map((e=>d?.[e]?.())),p=o(e.component,r?{scopedSlots:d,attrs:{...s&&{"data-locator":n.component},...i.attrs},props:a,on:i.listeners,...e.props.value}:{...s&&{"data-locator":n.component},...i.attrs,...a,...e.props.value},c);return e.extra.value.wrap?e.extra.value.wrap(p):p}}});function f(e,t,n,i,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const h={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:p}};var m=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};m._withStripped=!0;const v=f({render:m,staticRenderFns:[]},undefined,h,undefined,false,undefined,!1,void 0,void 0,void 0);const g={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:v,RefineFlavor:p}};var y=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};y._withStripped=!0;const b=f({render:y,staticRenderFns:[]},undefined,g,undefined,false,undefined,!1,void 0,void 0,void 0);const w={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:p}};var O=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};O._withStripped=!0;const x=f({render:O,staticRenderFns:[]},undefined,w,undefined,false,undefined,!1,void 0,void 0,void 0);const _={name:"refine-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1}}};var C=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};C._withStripped=!0;const S=f({render:C,staticRenderFns:[]},undefined,_,undefined,false,undefined,!1,void 0,void 0,void 0);const k={name:"refine-double-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var $=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};$._withStripped=!0;const R=f({render:$,staticRenderFns:[]},undefined,k,undefined,false,undefined,!1,void 0,void 0,void 0);var I=e=>"conjunction"===(null==e?void 0:e.type),q=Object.defineProperty,B=Object.defineProperties,j=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,D=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))F.call(t,n)&&D(e,n,t[n]);if(E)for(var n of E(t))A.call(t,n)&&D(e,n,t[n]);return e},N=(e,t)=>B(e,j(t)),V=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},M=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:P({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:V()}},T=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:V()}},L=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?N(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||V()}):N(P({},e),{id:void 0,uid:V()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)F.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&E)for(var i of E(e))t.indexOf(i)<0&&A.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{I(t)?"or"===t.word&&e.push([]):e[e.length-1].push(N(P({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=M(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=I(i)&&"or"===i.word,o=I(n)&&"or"===n.word,s=r||!i,l=o||!n,a=l&&!s,d=l&&s;!n&&!i?this.blueprint=[]:d&&o?t.splice(e-1,2):d&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:V()}}()),e.push(M(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=M(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,T(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,T(),M(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=P({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},G=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=P({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const z=f({},undefined,{name:"renderless-selector",data:()=>({selector:s(new G),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return l().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return r&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),H={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let K=1;var U={beforeCreate(){this.uid=K.toString(),K+=1}};const Q={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:p}};var W=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};W._withStripped=!0;const X=f({render:W,staticRenderFns:[]},undefined,Q,undefined,false,undefined,!1,void 0,void 0,void 0);const Y={name:"selector-listbox",mixins:[U],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:p}};var Z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};Z._withStripped=!0;const J=f({render:Z,staticRenderFns:[]},undefined,Y,undefined,false,undefined,!1,void 0,void 0,void 0);const ee={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:p}};var te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};te._withStripped=!0;const ne=f({render:te,staticRenderFns:[]},undefined,ee,undefined,false,undefined,!1,void 0,void 0,void 0);const ie={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:p}};var re=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};re._withStripped=!0;const oe=f({render:re,staticRenderFns:[]},undefined,ie,undefined,false,undefined,!1,void 0,void 0,void 0);const se={name:"selector",mixins:[U],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:oe,RenderlessSelector:z,SelectorListItem:ne,SelectorButton:X,SelectorListbox:J,RefineFlavor:p}};var le=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,a,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};le._withStripped=!0;const ae=f({render:le,staticRenderFns:[]},undefined,se,undefined,false,undefined,!1,void 0,void 0,void 0);var de={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return r&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},ue={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,r)=>{const o=t("blueprint"),s=t("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!r)throw new Error("useCondition requires a Vue context.");if(!o)throw new Error("Conditions must be rendered within a query.");let l;l=s?o.findCriterion(i.uid):o.addCriterion({id:e,depth:0});const d=(e,t)=>o.updateInput(l,e,t),u=e=>o.switchClause(l,e);n("criterion",l),n("criterionMeta",i.meta),n("updateInput",d),n("switchRefinement",((e,t)=>{o.switchRefinement(l,e,t)})),n("refinementId",null),a((()=>{s||o.removeCriterion(o.indexOfCriterion(l))}));let c=null;return i?.condition?.meta?.clauses&&(c=i.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,i)},ce={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,n)=>((e,n,i)=>{const r=t("criterion"),o=t("updateInput"),s=t("refinementId"),l=t("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:t,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return a((()=>{l||r.input.clause===e&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...r.input}):null})(e.clause,e,n)},pe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(r&&(e=this.$scopedSlots?.default),e)return e()}};const fe={name:"selector-option",mixins:[H],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[H],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var he=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};he._withStripped=!0;const me=f({render:he,staticRenderFns:[]},undefined,fe,undefined,false,undefined,!1,void 0,void 0,void 0);const ve={name:"refine-date-input",components:{Selector:ae,SelectorOption:me,RefineFlavor:p},mixins:[U],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ge=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ge._withStripped=!0;const ye=f({render:ge,staticRenderFns:[]},undefined,ve,undefined,false,undefined,!1,void 0,void 0,void 0);const be={name:"refine-option-input",components:{Selector:ae,SelectorOption:me},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};we._withStripped=!0;const Oe=f({render:we,staticRenderFns:[]},undefined,be,undefined,false,undefined,!1,void 0,void 0,void 0);const xe={emits:["input"],components:{RefineFlavor:p},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var _e=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};_e._withStripped=!0;const Ce=f({render:_e,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);var Se={RefineDateInput:S,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:v,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce},ke=Object.freeze({__proto__:null,default:Se,RefineDateInput:S,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:v,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,c.init(t)}},Re={install:(e,t={})=>{$e.install(e,t)}};const Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ae}};var qe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};qe._withStripped=!0;const Be=f({render:qe,staticRenderFns:[]},undefined,Ie,undefined,false,undefined,!1,void 0,void 0,void 0);const je=f({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const Ee={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ce,SelectorOption:me,Selector:ae,...ke}};var Fe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Fe._withStripped=!0;const Ae=f({render:Fe,staticRenderFns:[]},undefined,Ee,undefined,false,undefined,!1,void 0,void 0,void 0);const De={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ae,RenderlessRefinement:pe,Selector:ae,SelectorOption:me},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Pe._withStripped=!0;const Ne={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ae,Refinements:f({render:Pe,staticRenderFns:[]},undefined,De,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:me,Selector:ae,RefineFlavor:p}};var Ve=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ve._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>r?{}:{key:e},templateChildKey:e=>r?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,n(d,t)},components:{Criterion:f({render:Ve,staticRenderFns:[]},undefined,Ne,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:p,RenderlessCondition:ue,RenderlessQueryBuilder:de}};var Te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Te._withStripped=!0;const Le=f({render:Te,staticRenderFns:[]},undefined,Me,undefined,false,undefined,!1,void 0,void 0,void 0),Ge="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",He=`${Ge} ${ze} w-60 pl-3 py-2`,Ke={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ge} ${ze} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${He} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:He,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:He}},Ue="bg-white relative text-left cursor-default",Qe=`${Ue} focus:outline-none pl-3 py-1`,We={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ue} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Qe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Qe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Qe}}};export{Be as ConditionSelector,Re as DatePickerPlugin,je as Query,Le as QueryBuilder,$e as RefinePlugin,ae as Selector,me as SelectorOption,We as linearFlavor,Ke as tailwindFlavor}; | ||
import{computed as e,inject as t,provide as n,defineComponent as i,isVue2 as r,h as o,reactive as s,nextTick as l,onUnmounted as a}from"vue-demi";const d=Symbol();let u={};var c={init(e){u=e},get:(e,t=null)=>u?.[e]??t,set(e,t){u[e]=t}};const p=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(n,i){let s=c.get("showLocators");const l=function(n,i,r=e((()=>({})))){const o=t(d),s=e((()=>n(o)??{})),l=e((()=>{const e={},t=r.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=r.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e((()=>n.as)),e((()=>({...i.attrs??{},...n.flavorOptions??{}}))));return()=>{const e=l.value,t=e.extra.value.order??n.order,a=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(n,["as","component","order"]),d=i.slots;let u="string"==typeof e.component&&e.component.includes("-"),c=u?d:t.map((e=>d?.[e]?.())),p=o(e.component,r?{scopedSlots:d,attrs:{...s&&{"data-locator":n.component},...i.attrs},props:a,on:i.listeners,...e.props.value}:{...s&&{"data-locator":n.component},...i.attrs,...a,...e.props.value},c);return e.extra.value.wrap?e.extra.value.wrap(p):p}}});function f(e,t,n,i,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const h={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:p}};var m=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};m._withStripped=!0;const v=f({render:m,staticRenderFns:[]},undefined,h,undefined,false,undefined,!1,void 0,void 0,void 0);const g={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:v,RefineFlavor:p}};var y=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};y._withStripped=!0;const b=f({render:y,staticRenderFns:[]},undefined,g,undefined,false,undefined,!1,void 0,void 0,void 0);const w={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:p}};var O=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};O._withStripped=!0;const x=f({render:O,staticRenderFns:[]},undefined,w,undefined,false,undefined,!1,void 0,void 0,void 0);const _={name:"refine-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1}}};var C=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};C._withStripped=!0;const S=f({render:C,staticRenderFns:[]},undefined,_,undefined,false,undefined,!1,void 0,void 0,void 0);const k={name:"refine-double-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var $=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};$._withStripped=!0;const R=f({render:$,staticRenderFns:[]},undefined,k,undefined,false,undefined,!1,void 0,void 0,void 0);var I=e=>"conjunction"===(null==e?void 0:e.type),q=Object.defineProperty,B=Object.defineProperties,j=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,D=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))F.call(t,n)&&D(e,n,t[n]);if(E)for(var n of E(t))A.call(t,n)&&D(e,n,t[n]);return e},N=(e,t)=>B(e,j(t)),V=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},M=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:P({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:V()}},T=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:V()}},L=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?N(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||V()}):N(P({},e),{id:void 0,uid:V()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)F.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&E)for(var i of E(e))t.indexOf(i)<0&&A.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{I(t)?"or"===t.word&&e.push([]):e[e.length-1].push(N(P({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=M(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=I(i)&&"or"===i.word,o=I(n)&&"or"===n.word,s=r||!i,l=o||!n,a=l&&!s,d=l&&s;!n&&!i?this.blueprint=[]:d&&o?t.splice(e-1,2):d&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:V()}}()),e.push(M(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=M(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,T(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,T(),M(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=P({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},G=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=P({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const z=f({},undefined,{name:"renderless-selector",data:()=>({selector:s(new G),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return l().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return r&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),H={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let K=1;var U={beforeCreate(){this.uid=K.toString(),K+=1}};const Q={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:p}};var W=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};W._withStripped=!0;const X=f({render:W,staticRenderFns:[]},undefined,Q,undefined,false,undefined,!1,void 0,void 0,void 0);const Y={name:"selector-listbox",mixins:[U],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:p}};var Z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};Z._withStripped=!0;const J=f({render:Z,staticRenderFns:[]},undefined,Y,undefined,false,undefined,!1,void 0,void 0,void 0);const ee={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:p}};var te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};te._withStripped=!0;const ne=f({render:te,staticRenderFns:[]},undefined,ee,undefined,false,undefined,!1,void 0,void 0,void 0);const ie={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:p}};var re=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};re._withStripped=!0;const oe=f({render:re,staticRenderFns:[]},undefined,ie,undefined,false,undefined,!1,void 0,void 0,void 0);const se={name:"selector",mixins:[U],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs["opt-"+e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:oe,RenderlessSelector:z,SelectorListItem:ne,SelectorButton:X,SelectorListbox:J,RefineFlavor:p}};var le=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,a,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return n("selector-list-item",{key:t.id,ref:"opt-"+t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};le._withStripped=!0;const ae=f({render:le,staticRenderFns:[]},undefined,se,undefined,false,undefined,!1,void 0,void 0,void 0);var de={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return r&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},ue={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,r)=>{const o=t("blueprint"),s=t("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!r)throw new Error("useCondition requires a Vue context.");if(!o)throw new Error("Conditions must be rendered within a query.");let l;l=s?o.findCriterion(i.uid):o.addCriterion({id:e,depth:0});const d=(e,t)=>o.updateInput(l,e,t),u=e=>o.switchClause(l,e);n("criterion",l),n("criterionMeta",i.meta),n("updateInput",d),n("switchRefinement",((e,t)=>{o.switchRefinement(l,e,t)})),n("refinementId",null),a((()=>{s||o.removeCriterion(o.indexOfCriterion(l))}));let c=null;return i?.condition?.meta?.clauses&&(c=i.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,i)},ce={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,n)=>((e,n,i)=>{const r=t("criterion"),o=t("updateInput"),s=t("refinementId"),l=t("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:t,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return a((()=>{l||r.input.clause===e&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...r.input}):null})(e.clause,e,n)},pe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(r&&(e=this.$scopedSlots?.default),e)return e()}};const fe={name:"selector-option",mixins:[H],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[H],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var he=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};he._withStripped=!0;const me=f({render:he,staticRenderFns:[]},undefined,fe,undefined,false,undefined,!1,void 0,void 0,void 0);const ve={name:"refine-date-input",components:{Selector:ae,SelectorOption:me,RefineFlavor:p},mixins:[U],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ge=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ge._withStripped=!0;const ye=f({render:ge,staticRenderFns:[]},undefined,ve,undefined,false,undefined,!1,void 0,void 0,void 0);const be={name:"refine-option-input",components:{Selector:ae,SelectorOption:me},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};we._withStripped=!0;const Oe=f({render:we,staticRenderFns:[]},undefined,be,undefined,false,undefined,!1,void 0,void 0,void 0);const xe={emits:["input"],components:{RefineFlavor:p},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var _e=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};_e._withStripped=!0;const Ce=f({render:_e,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);var Se={RefineDateInput:S,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:v,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce},ke=Object.freeze({__proto__:null,default:Se,RefineDateInput:S,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:v,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,c.init(t)}},Re={install:(e,t={})=>{$e.install(e,t)}};const Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ae}};var qe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};qe._withStripped=!0;const Be=f({render:qe,staticRenderFns:[]},undefined,Ie,undefined,false,undefined,!1,void 0,void 0,void 0);const je=f({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const Ee={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ce,SelectorOption:me,Selector:ae,...ke}};var Fe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Fe._withStripped=!0;const Ae=f({render:Fe,staticRenderFns:[]},undefined,Ee,undefined,false,undefined,!1,void 0,void 0,void 0);const De={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ae,RenderlessRefinement:pe,Selector:ae,SelectorOption:me},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Pe._withStripped=!0;const Ne={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ae,Refinements:f({render:Pe,staticRenderFns:[]},undefined,De,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:me,Selector:ae,RefineFlavor:p}};var Ve=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ve._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>r?{}:{key:e},templateChildKey:e=>r?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,n(d,t)},components:{Criterion:f({render:Ve,staticRenderFns:[]},undefined,Ne,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:p,RenderlessCondition:ue,RenderlessQueryBuilder:de}};var Te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Te._withStripped=!0;const Le=f({render:Te,staticRenderFns:[]},undefined,Me,undefined,false,undefined,!1,void 0,void 0,void 0),Ge="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",He=`${Ge} ${ze} w-60 pl-3 py-2`,Ke={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ge} ${ze} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${He} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:He,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:He}},Ue="bg-white relative text-left cursor-default",Qe=`${Ue} focus:outline-none pl-3 py-1`,We={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ue} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Qe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Qe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Qe}}};export{Be as ConditionSelector,Re as DatePickerPlugin,je as Query,Le as QueryBuilder,$e as RefinePlugin,ae as Selector,me as SelectorOption,We as linearFlavor,Ke as tailwindFlavor}; | ||
//# sourceMappingURL=refine-vue.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import{computed as e,inject as t,provide as i,defineComponent as n,isVue2 as r,h as o,reactive as s,nextTick as l,onUnmounted as a}from"vue-demi";const d=Symbol();let u={};var c={init(e){u=e},get:(e,t=null)=>u?.[e]??t,set(e,t){u[e]=t}};const p=n({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(i,n){let s=c.get("showLocators");const l=function(i,n,r=e((()=>({})))){const o=t(d),s=e((()=>i(o)??{})),l=e((()=>{const e={},t=r.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=r.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const n=s.value.style;return n&&(e.style="function"==typeof n?n(t):n),e}));return e((()=>({component:s.value.component??n.value,props:a,extra:l})))}((e=>{const t=i.component.split(".");let n=e;for(const e of t)n=n?.[e];return"string"!=typeof n&&"function"!=typeof n||(n={class:n}),n}),e((()=>i.as)),e((()=>({...n.attrs??{},...i.flavorOptions??{}}))));return()=>{const e=l.value,t=e.extra.value.order??i.order,a=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(i,["as","component","order"]),d=n.slots;let u="string"==typeof e.component&&e.component.includes("-")?d:t.map((e=>d?.[e]?.())),c=o(e.component,r?{scopedSlots:d,attrs:{...s&&{"data-locator":i.component},...n.attrs},props:a,on:n.listeners,...e.props.value}:{...s&&{"data-locator":i.component},...n.attrs,...a,...e.props.value},u);return e.extra.value.wrap?e.extra.value.wrap(c):c}}});function f(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof i?i.options:i;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),n&&(u._scopeId=n),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,i){return c.call(i),e(t,i)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return i}const h={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:p}};var v=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};v._withStripped=!0;const m=f({render:v,staticRenderFns:[]},void 0,h,void 0,!1,void 0,!1,void 0,void 0,void 0),g={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:m,RefineFlavor:p}};var y=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};y._withStripped=!0;const b=f({render:y,staticRenderFns:[]},void 0,g,void 0,!1,void 0,!1,void 0,void 0,void 0),w={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:p}};var O=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};O._withStripped=!0;const x=f({render:O,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),_={name:"refine-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1}}};var C=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};C._withStripped=!0;const k=f({render:C,staticRenderFns:[]},void 0,_,void 0,!1,void 0,!1,void 0,void 0,void 0),S={name:"refine-double-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var $=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};$._withStripped=!0;const R=f({render:$,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0);var I=e=>"conjunction"===(null==e?void 0:e.type),q=Object.defineProperty,B=Object.defineProperties,j=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,D=(e,t,i)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t)=>{for(var i in t||(t={}))F.call(t,i)&&D(e,i,t[i]);if(E)for(var i of E(t))A.call(t,i)&&D(e,i,t[i]);return e},V=(e,t)=>B(e,j(t)),N=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},M=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:P({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:N()}},T=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:N()}},L=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?V(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||N()}):V(P({},e),{id:void 0,uid:N()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)F.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&E)for(var n of E(e))t.indexOf(n)<0&&A.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{I(t)?"or"===t.word&&e.push([]):e[e.length-1].push(V(P({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=M(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=I(n)&&"or"===n.word,o=I(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:N()}}()),e.push(M(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=M(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,T(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,T(),M(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=P({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},G=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=P({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const z=f({},void 0,{name:"renderless-selector",data:()=>({selector:s(new G),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return l().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return r&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),H={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let K=1;var U={beforeCreate(){this.uid=K.toString(),K+=1}};const Q={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:p}};var W=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};W._withStripped=!0;const X=f({render:W,staticRenderFns:[]},void 0,Q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"selector-listbox",mixins:[U],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:p}};var Z=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};Z._withStripped=!0;const J=f({render:Z,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),ee={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:p}};var te=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};te._withStripped=!0;const ie=f({render:te,staticRenderFns:[]},void 0,ee,void 0,!1,void 0,!1,void 0,void 0,void 0),ne={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:p}};var re=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};re._withStripped=!0;const oe=f({render:re,staticRenderFns:[]},void 0,ne,void 0,!1,void 0,!1,void 0,void 0,void 0),se={name:"selector",mixins:[U],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:oe,RenderlessSelector:z,SelectorListItem:ie,SelectorButton:X,SelectorListbox:J,RefineFlavor:p}};var le=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};le._withStripped=!0;const ae=f({render:le,staticRenderFns:[]},void 0,se,void 0,!1,void 0,!1,void 0,void 0,void 0);var de={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:i,conditionFor:n,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return r&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:i,conditionFor:n,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},ue={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,n)=>((e,n,r)=>{const o=t("blueprint"),s=t("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!r)throw new Error("useCondition requires a Vue context.");if(!o)throw new Error("Conditions must be rendered within a query.");let l;l=s?o.findCriterion(n.uid):o.addCriterion({id:e,depth:0});const d=(e,t)=>o.updateInput(l,e,t),u=e=>o.switchClause(l,e);i("criterion",l),i("criterionMeta",n.meta),i("updateInput",d),i("switchRefinement",((e,t)=>{o.switchRefinement(l,e,t)})),i("refinementId",null),a((()=>{s||o.removeCriterion(o.indexOfCriterion(l))}));let c=null;return n?.condition?.meta?.clauses&&(c=n.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,n)},ce={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,i)=>((e,i,n)=>{const r=t("criterion"),o=t("updateInput"),s=t("refinementId"),l=t("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:t,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return a((()=>{l||r.input.clause===e&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:d,...r.input}):null})(e.clause,e,i)},pe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(r&&(e=this.$scopedSlots?.default),e)return e()}};const fe={name:"selector-option",mixins:[H],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[H],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var he=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};he._withStripped=!0;const ve=f({render:he,staticRenderFns:[]},void 0,fe,void 0,!1,void 0,!1,void 0,void 0,void 0),me={name:"refine-date-input",components:{Selector:ae,SelectorOption:ve,RefineFlavor:p},mixins:[U],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ge=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ge._withStripped=!0;const ye=f({render:ge,staticRenderFns:[]},void 0,me,void 0,!1,void 0,!1,void 0,void 0,void 0),be={name:"refine-option-input",components:{Selector:ae,SelectorOption:ve},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var we=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};we._withStripped=!0;const Oe=f({render:we,staticRenderFns:[]},void 0,be,void 0,!1,void 0,!1,void 0,void 0,void 0),xe={emits:["input"],components:{RefineFlavor:p},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var _e=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};_e._withStripped=!0;const Ce=f({render:_e,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0);var ke={RefineDateInput:k,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:m,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce},Se=Object.freeze({__proto__:null,default:ke,RefineDateInput:k,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:m,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,c.init(t)}},Re={install:(e,t={})=>{$e.install(e,t)}};const Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ae}};var qe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};qe._withStripped=!0;const Be=f({render:qe,staticRenderFns:[]},void 0,Ie,void 0,!1,void 0,!1,void 0,void 0,void 0),je=f({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),Ee={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ce,SelectorOption:ve,Selector:ae,...Se}};var Fe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Fe._withStripped=!0;const Ae=f({render:Fe,staticRenderFns:[]},void 0,Ee,void 0,!1,void 0,!1,void 0,void 0,void 0),De={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ae,RenderlessRefinement:pe,Selector:ae,SelectorOption:ve},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Pe._withStripped=!0;const Ve={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ae,Refinements:f({render:Pe,staticRenderFns:[]},void 0,De,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:ve,Selector:ae,RefineFlavor:p}};var Ne=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ne._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>r?{}:{key:e},templateChildKey:e=>r?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,i(d,t)},components:{Criterion:f({render:Ne,staticRenderFns:[]},void 0,Ve,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:p,RenderlessCondition:ue,RenderlessQueryBuilder:de}};var Te=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,s){return[i("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),i("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:n.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Te._withStripped=!0;const Le=f({render:Te,staticRenderFns:[]},void 0,Me,void 0,!1,void 0,!1,void 0,void 0,void 0),Ge="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",He=`${Ge} ${ze} w-60 pl-3 py-2`,Ke={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ge} ${ze} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${He} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:He,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:He}},Ue="bg-white relative text-left cursor-default",Qe=`${Ue} focus:outline-none pl-3 py-1`,We={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ue} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Qe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Qe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Qe}}};export{Be as ConditionSelector,Re as DatePickerPlugin,je as Query,Le as QueryBuilder,$e as RefinePlugin,ae as Selector,ve as SelectorOption,We as linearFlavor,Ke as tailwindFlavor}; | ||
import{computed as e,inject as t,provide as i,defineComponent as n,isVue2 as r,h as o,reactive as s,nextTick as l,onUnmounted as a}from"vue-demi";const d=Symbol();let u={};var c={init(e){u=e},get:(e,t=null)=>u?.[e]??t,set(e,t){u[e]=t}};const p=n({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(i,n){let s=c.get("showLocators");const l=function(i,n,r=e((()=>({})))){const o=t(d),s=e((()=>i(o)??{})),l=e((()=>{const e={},t=r.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=r.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const n=s.value.style;return n&&(e.style="function"==typeof n?n(t):n),e}));return e((()=>({component:s.value.component??n.value,props:a,extra:l})))}((e=>{const t=i.component.split(".");let n=e;for(const e of t)n=n?.[e];return"string"!=typeof n&&"function"!=typeof n||(n={class:n}),n}),e((()=>i.as)),e((()=>({...n.attrs??{},...i.flavorOptions??{}}))));return()=>{const e=l.value,t=e.extra.value.order??i.order,a=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(i,["as","component","order"]),d=n.slots;let u="string"==typeof e.component&&e.component.includes("-")?d:t.map((e=>d?.[e]?.())),c=o(e.component,r?{scopedSlots:d,attrs:{...s&&{"data-locator":i.component},...n.attrs},props:a,on:n.listeners,...e.props.value}:{...s&&{"data-locator":i.component},...n.attrs,...a,...e.props.value},u);return e.extra.value.wrap?e.extra.value.wrap(c):c}}});function f(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof i?i.options:i;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),n&&(u._scopeId=n),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,i){return c.call(i),e(t,i)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return i}const h={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:p}};var v=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};v._withStripped=!0;const m=f({render:v,staticRenderFns:[]},void 0,h,void 0,!1,void 0,!1,void 0,void 0,void 0),g={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:m,RefineFlavor:p}};var y=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};y._withStripped=!0;const b=f({render:y,staticRenderFns:[]},void 0,g,void 0,!1,void 0,!1,void 0,void 0,void 0),w={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:p}};var O=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};O._withStripped=!0;const x=f({render:O,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),_={name:"refine-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1}}};var C=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};C._withStripped=!0;const k=f({render:C,staticRenderFns:[]},void 0,_,void 0,!1,void 0,!1,void 0,void 0,void 0),S={name:"refine-double-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var $=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};$._withStripped=!0;const R=f({render:$,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0);var I=e=>"conjunction"===(null==e?void 0:e.type),q=Object.defineProperty,B=Object.defineProperties,j=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,D=(e,t,i)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t)=>{for(var i in t||(t={}))F.call(t,i)&&D(e,i,t[i]);if(E)for(var i of E(t))A.call(t,i)&&D(e,i,t[i]);return e},V=(e,t)=>B(e,j(t)),N=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},M=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:P({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:N()}},T=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:N()}},L=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?V(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||N()}):V(P({},e),{id:void 0,uid:N()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)F.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&E)for(var n of E(e))t.indexOf(n)<0&&A.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{I(t)?"or"===t.word&&e.push([]):e[e.length-1].push(V(P({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=M(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=I(n)&&"or"===n.word,o=I(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:N()}}()),e.push(M(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=M(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,T(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,T(),M(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=P({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},G=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=P({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const z=f({},void 0,{name:"renderless-selector",data:()=>({selector:s(new G),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return l().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return r&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),H={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let K=1;var U={beforeCreate(){this.uid=K.toString(),K+=1}};const Q={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:p}};var W=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};W._withStripped=!0;const X=f({render:W,staticRenderFns:[]},void 0,Q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"selector-listbox",mixins:[U],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:p}};var Z=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};Z._withStripped=!0;const J=f({render:Z,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),ee={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:p}};var te=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};te._withStripped=!0;const ie=f({render:te,staticRenderFns:[]},void 0,ee,void 0,!1,void 0,!1,void 0,void 0,void 0),ne={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:p}};var re=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};re._withStripped=!0;const oe=f({render:re,staticRenderFns:[]},void 0,ne,void 0,!1,void 0,!1,void 0,void 0,void 0),se={name:"selector",mixins:[U],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs["opt-"+e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:oe,RenderlessSelector:z,SelectorListItem:ie,SelectorButton:X,SelectorListbox:J,RefineFlavor:p}};var le=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:"opt-"+t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};le._withStripped=!0;const ae=f({render:le,staticRenderFns:[]},void 0,se,void 0,!1,void 0,!1,void 0,void 0,void 0);var de={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:i,conditionFor:n,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return r&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:i,conditionFor:n,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},ue={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,n)=>((e,n,r)=>{const o=t("blueprint"),s=t("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!r)throw new Error("useCondition requires a Vue context.");if(!o)throw new Error("Conditions must be rendered within a query.");let l;l=s?o.findCriterion(n.uid):o.addCriterion({id:e,depth:0});const d=(e,t)=>o.updateInput(l,e,t),u=e=>o.switchClause(l,e);i("criterion",l),i("criterionMeta",n.meta),i("updateInput",d),i("switchRefinement",((e,t)=>{o.switchRefinement(l,e,t)})),i("refinementId",null),a((()=>{s||o.removeCriterion(o.indexOfCriterion(l))}));let c=null;return n?.condition?.meta?.clauses&&(c=n.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,n)},ce={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,i)=>((e,i,n)=>{const r=t("criterion"),o=t("updateInput"),s=t("refinementId"),l=t("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:t,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return a((()=>{l||r.input.clause===e&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:d,...r.input}):null})(e.clause,e,i)},pe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(r&&(e=this.$scopedSlots?.default),e)return e()}};const fe={name:"selector-option",mixins:[H],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[H],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var he=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};he._withStripped=!0;const ve=f({render:he,staticRenderFns:[]},void 0,fe,void 0,!1,void 0,!1,void 0,void 0,void 0),me={name:"refine-date-input",components:{Selector:ae,SelectorOption:ve,RefineFlavor:p},mixins:[U],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ge=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ge._withStripped=!0;const ye=f({render:ge,staticRenderFns:[]},void 0,me,void 0,!1,void 0,!1,void 0,void 0,void 0),be={name:"refine-option-input",components:{Selector:ae,SelectorOption:ve},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var we=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};we._withStripped=!0;const Oe=f({render:we,staticRenderFns:[]},void 0,be,void 0,!1,void 0,!1,void 0,void 0,void 0),xe={emits:["input"],components:{RefineFlavor:p},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var _e=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};_e._withStripped=!0;const Ce=f({render:_e,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0);var ke={RefineDateInput:k,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:m,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce},Se=Object.freeze({__proto__:null,default:ke,RefineDateInput:k,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:m,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,c.init(t)}},Re={install:(e,t={})=>{$e.install(e,t)}};const Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ae}};var qe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};qe._withStripped=!0;const Be=f({render:qe,staticRenderFns:[]},void 0,Ie,void 0,!1,void 0,!1,void 0,void 0,void 0),je=f({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),Ee={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ce,SelectorOption:ve,Selector:ae,...Se}};var Fe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Fe._withStripped=!0;const Ae=f({render:Fe,staticRenderFns:[]},void 0,Ee,void 0,!1,void 0,!1,void 0,void 0,void 0),De={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ae,RenderlessRefinement:pe,Selector:ae,SelectorOption:ve},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Pe._withStripped=!0;const Ve={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ae,Refinements:f({render:Pe,staticRenderFns:[]},void 0,De,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:ve,Selector:ae,RefineFlavor:p}};var Ne=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ne._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>r?{}:{key:e},templateChildKey:e=>r?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,i(d,t)},components:{Criterion:f({render:Ne,staticRenderFns:[]},void 0,Ve,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:p,RenderlessCondition:ue,RenderlessQueryBuilder:de}};var Te=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,s){return[i("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),i("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:n.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Te._withStripped=!0;const Le=f({render:Te,staticRenderFns:[]},void 0,Me,void 0,!1,void 0,!1,void 0,void 0,void 0),Ge="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",He=`${Ge} ${ze} w-60 pl-3 py-2`,Ke={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ge} ${ze} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${He} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:He,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:He}},Ue="bg-white relative text-left cursor-default",Qe=`${Ue} focus:outline-none pl-3 py-1`,We={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ue} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Qe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Qe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Qe}}};export{Be as ConditionSelector,Re as DatePickerPlugin,je as Query,Le as QueryBuilder,$e as RefinePlugin,ae as Selector,ve as SelectorOption,We as linearFlavor,Ke as tailwindFlavor}; | ||
//# sourceMappingURL=refine-vue.esm.min.js.map |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"scripts": { | ||
@@ -24,0 +24,0 @@ "test": "jest ./tests", |
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
816366