@hammerstone/refine-vue2-dev
Advanced tools
Comparing version 1.0.1673184317 to 1.0.1673275245
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();const n=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,i){const r=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})),a=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:a,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return i}),e.computed((()=>n.as)),e.computed((()=>({...i.attrs??{},...n.flavorOptions??{}}))));return()=>{const t=r.value,o=t.extra.value.order??n.order,s=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"]),l=i.slots;let a="string"==typeof t.component&&t.component.includes("-"),d=a?l:o.map((e=>l?.[e]?.())),u=e.isVue2?e.h(t.component,{scopedSlots:l,attrs:{...i.attrs,"data-flavor":n.component},props:s,on:i.listeners,...t.props.value},d):e.h(t.component,{...i.attrs,"data-flavor":n.component,...s,...t.props.value},d);return t.extra.value.wrap?t.extra.value.wrap(u):u}}});function i(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 r={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:n}};var o=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))};o._withStripped=!0;const s=i({render:o,staticRenderFns:[]},undefined,r,undefined,false,undefined,!1,void 0,void 0,void 0);const l={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:s,RefineFlavor:n}};var a=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)};a._withStripped=!0;const d=i({render:a,staticRenderFns:[]},undefined,l,undefined,false,undefined,!1,void 0,void 0,void 0);const u={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:n}};var c=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})}}})};c._withStripped=!0;const p=i({render:c,staticRenderFns:[]},undefined,u,undefined,false,undefined,!1,void 0,void 0,void 0);const f={name:"refine-date-input",components:{RefineFlavor:n},emits:["input"],props:{date1:{type:String,required:!1}}};var h=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))};h._withStripped=!0;const m=i({render:h,staticRenderFns:[]},undefined,f,undefined,false,undefined,!1,void 0,void 0,void 0);const v={name:"refine-double-date-input",components:{RefineFlavor:n},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var g=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)};g._withStripped=!0;const y=i({render:g,staticRenderFns:[]},undefined,v,undefined,false,undefined,!1,void 0,void 0,void 0);var b=e=>"conjunction"===(null==e?void 0:e.type),w=Object.defineProperty,x=Object.defineProperties,O=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable,S=(e,t,n)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$=(e,t)=>{for(var n in t||(t={}))C.call(t,n)&&S(e,n,t[n]);if(_)for(var n of _(t))k.call(t,n)&&S(e,n,t[n]);return e},R=(e,t)=>x(e,O(t)),I=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},q=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:$({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:I()}},B=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:I()}},j=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)?R($({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||I()}):R($({},e),{id:void 0,uid:I()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)C.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&_)for(var i of _(e))t.indexOf(i)<0&&k.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)=>{b(t)?"or"===t.word&&e.push([]):e[e.length-1].push(R($({},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=q(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=b(i)&&"or"===i.word,o=b(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:I()}}()),e.push(q(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=q(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,B(),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,B(),q(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=$({},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()}},E=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=$({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 F=i({},undefined,{name:"renderless-selector",data:()=>({selector:e.reactive(new E),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),A={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let D=1;var V={beforeCreate(){this.uid=D.toString(),D+=1}};const P={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:n}};var N=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)};N._withStripped=!0;const M=i({render:N,staticRenderFns:[]},undefined,P,undefined,false,undefined,!1,void 0,void 0,void 0);const T={name:"selector-listbox",mixins:[V],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:n}};var L=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)};L._withStripped=!0;const G=i({render:L,staticRenderFns:[]},undefined,T,undefined,false,undefined,!1,void 0,void 0,void 0);const z={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:n}};var H=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)};H._withStripped=!0;const K=i({render:H,staticRenderFns:[]},undefined,z,undefined,false,undefined,!1,void 0,void 0,void 0);const U={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:n}};var Q=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)};Q._withStripped=!0;const W=i({render:Q,staticRenderFns:[]},undefined,U,undefined,false,undefined,!1,void 0,void 0,void 0);const X={name:"selector",mixins:[V],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:W,RenderlessSelector:F,SelectorListItem:K,SelectorButton:M,SelectorListbox:G,RefineFlavor:n}};var Y=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,a,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};Y._withStripped=!0;const Z=i({render:Y,staticRenderFns:[]},undefined,X,undefined,false,undefined,!1,void 0,void 0,void 0);var J={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 j(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}},ee={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!i)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(n.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),a=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let d=null;return n?.condition?.meta?.clauses&&(d=n.condition.meta.clauses.map((e=>e.component))),()=>i.slots.default?i.slots.default({clauses:d,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,n)},te={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:a,...r.input}):null})(t.clause,t,n)},ne={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 ie={name:"selector-option",mixins:[A],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[A],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 re=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)};re._withStripped=!0;const oe=i({render:re,staticRenderFns:[]},undefined,ie,undefined,false,undefined,!1,void 0,void 0,void 0);const se={name:"refine-date-input",components:{Selector:Z,SelectorOption:oe,RefineFlavor:n},mixins:[V],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 le=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)};le._withStripped=!0;const ae=i({render:le,staticRenderFns:[]},undefined,se,undefined,false,undefined,!1,void 0,void 0,void 0);const de={name:"refine-option-input",components:{Selector:Z,SelectorOption:oe},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 ue=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)};ue._withStripped=!0;const ce=i({render:ue,staticRenderFns:[]},undefined,de,undefined,false,undefined,!1,void 0,void 0,void 0);const pe={emits:["input"],components:{RefineFlavor:n},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var fe=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}})};fe._withStripped=!0;const he=i({render:fe,staticRenderFns:[]},undefined,pe,undefined,false,undefined,!1,void 0,void 0,void 0);var me={RefineDateInput:m,RefineDoubleDateInput:y,RefineDoubleNumberInput:d,RefineNumberInput:s,RefineOptionInput:ce,RefineRelativeDateInput:ae,RefineTextInput:p,RefineNativeDatePicker:he},ve=Object.freeze({__proto__:null,default:me,RefineDateInput:m,RefineDoubleDateInput:y,RefineDoubleNumberInput:d,RefineNumberInput:s,RefineOptionInput:ce,RefineRelativeDateInput:ae,RefineTextInput:p,RefineNativeDatePicker:he}),ge={install:(e,t={})=>{t={DatePicker:he,...t},e.component("refine-date-picker",t.DatePicker)}},ye={install:(e,t={})=>{ge.install(e,t)}};const be={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:Z}};var we=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};we._withStripped=!0;const xe=i({render:we,staticRenderFns:[]},undefined,be,undefined,false,undefined,!1,void 0,void 0,void 0);const Oe=i({},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 j(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 _e={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:te,SelectorOption:oe,Selector:Z,...ve}};var Ce=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))};Ce._withStripped=!0;const ke=i({render:Ce,staticRenderFns:[]},undefined,_e,undefined,false,undefined,!1,void 0,void 0,void 0);const Se={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:ke,RenderlessRefinement:ne,Selector:Z,SelectorOption:oe},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 $e=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)};$e._withStripped=!0;const Re={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:ke,Refinements:i({render:$e,staticRenderFns:[]},undefined,Se,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:oe,Selector:Z,RefineFlavor:n}};var Ie=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}])})};Ie._withStripped=!0;const qe={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:i({render:Ie,staticRenderFns:[]},undefined,Re,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:n,RenderlessCondition:ee,RenderlessQueryBuilder:J}};var Be=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)]}}])})};Be._withStripped=!0;const je=i({render:Be,staticRenderFns:[]},undefined,qe,undefined,false,undefined,!1,void 0,void 0,void 0),Ee="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Fe="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ae=`${Ee} ${Fe} w-60 pl-3 py-2`,De={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{class:`${Ee} ${Fe} h-9 h-full py-5 px-2 leading-normal box-border`,relative:{class:`${Ae} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Ae,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ae}}},Ve="bg-white relative text-left cursor-default",Pe=`${Ve} focus:outline-none pl-3 py-1`,Ne={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:`${Ve} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Pe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Pe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Pe}}};exports.ConditionSelector=xe,exports.DatePickerPlugin=ye,exports.Query=Oe,exports.QueryBuilder=je,exports.RefinePlugin=ge,exports.Selector=Z,exports.SelectorOption=oe,exports.linearFlavor=Ne,exports.tailwindFlavor=De; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();let n={};var i={init(e){n=e},get:(e,t=null)=>n?.[e]??t,set(e,t){n[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(n,r){let o=i.get("showLocators");const s=function(n,i,r=e.computed((()=>({})))){const o=e.inject(t),s=e.computed((()=>n(o)??{})),l=e.computed((()=>{const e={},t=r.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),d=e.computed((()=>{const e={},t=r.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e.computed((()=>({component:s.value.component??i.value,props:d,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e.computed((()=>n.as)),e.computed((()=>({...r.attrs??{},...n.flavorOptions??{}}))));return()=>{const t=s.value,i=t.extra.value.order??n.order,l=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(n,["as","component","order"]),d=r.slots;let a="string"==typeof t.component&&t.component.includes("-"),u=a?d:i.map((e=>d?.[e]?.())),c=e.isVue2?e.h(t.component,{scopedSlots:d,attrs:{...o&&{"data-locator":n.component},...r.attrs},props:l,on:r.listeners,...t.props.value},u):e.h(t.component,{...o&&{"data-locator":n.component},...r.attrs,...l,...t.props.value},u);return t.extra.value.wrap?t.extra.value.wrap(c):c}}});function o(e,t,n,i,r,o,s,l,d,a){"boolean"!=typeof s&&(d=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,d(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,a(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:r}};var l=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};l._withStripped=!0;const d=o({render:l,staticRenderFns:[]},undefined,s,undefined,false,undefined,!1,void 0,void 0,void 0);const a={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:d,RefineFlavor:r}};var u=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};u._withStripped=!0;const c=o({render:u,staticRenderFns:[]},undefined,a,undefined,false,undefined,!1,void 0,void 0,void 0);const p={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};var f=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};f._withStripped=!0;const h=o({render:f,staticRenderFns:[]},undefined,p,undefined,false,undefined,!1,void 0,void 0,void 0);const m={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};var v=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};v._withStripped=!0;const g=o({render:v,staticRenderFns:[]},undefined,m,undefined,false,undefined,!1,void 0,void 0,void 0);const y={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var b=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};b._withStripped=!0;const w=o({render:b,staticRenderFns:[]},undefined,y,undefined,false,undefined,!1,void 0,void 0,void 0);var x=e=>"conjunction"===(null==e?void 0:e.type),O=Object.defineProperty,_=Object.defineProperties,C=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,R=(e,t,n)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))S.call(t,n)&&R(e,n,t[n]);if(k)for(var n of k(t))$.call(t,n)&&R(e,n,t[n]);return e},q=(e,t)=>_(e,C(t)),B=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},j=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:I({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:B()}},E=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:B()}},F=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?q(I({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||B()}):q(I({},e),{id:void 0,uid:B()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)S.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&k)for(var i of k(e))t.indexOf(i)<0&&$.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{x(t)?"or"===t.word&&e.push([]):e[e.length-1].push(q(I({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=j(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=x(i)&&"or"===i.word,o=x(n)&&"or"===n.word,s=r||!i,l=o||!n,d=l&&!s,a=l&&s;!n&&!i?this.blueprint=[]:a&&o?t.splice(e-1,2):a&&!n||d?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:B()}}()),e.push(j(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=j(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,E(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,E(),j(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=I({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},A=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=I({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const D=o({},undefined,{name:"renderless-selector",data:()=>({selector:e.reactive(new A),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:d,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:d,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),V={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let P=1;var N={beforeCreate(){this.uid=P.toString(),P+=1}};const M={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};var T=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};T._withStripped=!0;const L=o({render:T,staticRenderFns:[]},undefined,M,undefined,false,undefined,!1,void 0,void 0,void 0);const G={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};var z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};z._withStripped=!0;const H=o({render:z,staticRenderFns:[]},undefined,G,undefined,false,undefined,!1,void 0,void 0,void 0);const K={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};var U=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};U._withStripped=!0;const Q=o({render:U,staticRenderFns:[]},undefined,K,undefined,false,undefined,!1,void 0,void 0,void 0);const W={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};var X=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};X._withStripped=!0;const Y=o({render:X,staticRenderFns:[]},undefined,W,undefined,false,undefined,!1,void 0,void 0,void 0);const Z={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:Y,RenderlessSelector:D,SelectorListItem:Q,SelectorButton:L,SelectorListbox:H,RefineFlavor:r}};var J=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,d=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,d,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(d,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};J._withStripped=!0;const ee=o({render:J,staticRenderFns:[]},undefined,Z,undefined,false,undefined,!1,void 0,void 0,void 0);var te={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:i,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:i,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},ne={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!i)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(n.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),d=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>i.slots.default?i.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:d}):null})(t.id,t,n)},ie={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,i)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...r.input}):null})(t.clause,t,n)},re={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const oe={name:"selector-option",mixins:[V],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[V],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};se._withStripped=!0;const le=o({render:se,staticRenderFns:[]},undefined,oe,undefined,false,undefined,!1,void 0,void 0,void 0);const de={name:"refine-date-input",components:{Selector:ee,SelectorOption:le,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ae._withStripped=!0;const ue=o({render:ae,staticRenderFns:[]},undefined,de,undefined,false,undefined,!1,void 0,void 0,void 0);const ce={name:"refine-option-input",components:{Selector:ee,SelectorOption:le},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};pe._withStripped=!0;const fe=o({render:pe,staticRenderFns:[]},undefined,ce,undefined,false,undefined,!1,void 0,void 0,void 0);const he={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var me=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};me._withStripped=!0;const ve=o({render:me,staticRenderFns:[]},undefined,he,undefined,false,undefined,!1,void 0,void 0,void 0);var ge={RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:d,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:ve},ye=Object.freeze({__proto__:null,default:ge,RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:d,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:ve}),be={install:(e,t={})=>{t={DatePicker:ve,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,i.init(t)}},we={install:(e,t={})=>{be.install(e,t)}};const xe={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ee}};var Oe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Oe._withStripped=!0;const _e=o({render:Oe,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);const Ce=o({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const ke={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ie,SelectorOption:le,Selector:ee,...ye}};var Se=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Se._withStripped=!0;const $e=o({render:Se,staticRenderFns:[]},undefined,ke,undefined,false,undefined,!1,void 0,void 0,void 0);const Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:$e,RenderlessRefinement:re,Selector:ee,SelectorOption:le},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Ie=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Ie._withStripped=!0;const qe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:$e,Refinements:o({render:Ie,staticRenderFns:[]},undefined,Re,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:le,Selector:ee,RefineFlavor:r}};var Be=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Be._withStripped=!0;const je={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(n){var i;i=n.flavor,e.provide(t,i)},components:{Criterion:o({render:Be,staticRenderFns:[]},undefined,qe,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:r,RenderlessCondition:ne,RenderlessQueryBuilder:te}};var Ee=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,d=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,d(e))}}})]}}],null,!0)},"renderless-condition",d(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ee._withStripped=!0;const Fe=o({render:Ee,staticRenderFns:[]},undefined,je,undefined,false,undefined,!1,void 0,void 0,void 0),Ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",De="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ve=`${Ae} ${De} w-60 pl-3 py-2`,Pe={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ae} ${De} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ve} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ve,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ve}},Ne="bg-white relative text-left cursor-default",Me=`${Ne} focus:outline-none pl-3 py-1`,Te={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Me}}};exports.ConditionSelector=_e,exports.DatePickerPlugin=we,exports.Query=Ce,exports.QueryBuilder=Fe,exports.RefinePlugin=be,exports.Selector=ee,exports.SelectorOption=le,exports.linearFlavor=Te,exports.tailwindFlavor=Pe; | ||
//# sourceMappingURL=refine-vue.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol(),i=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,n){const r=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 n}),e.computed((()=>i.as)),e.computed((()=>({...n.attrs??{},...i.flavorOptions??{}}))));return()=>{const t=r.value,o=t.extra.value.order??i.order,s=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"]),l=n.slots;let a="string"==typeof t.component&&t.component.includes("-")?l:o.map((e=>l?.[e]?.())),d=e.isVue2?e.h(t.component,{scopedSlots:l,attrs:{...n.attrs,"data-flavor":i.component},props:s,on:n.listeners,...t.props.value},a):e.h(t.component,{...n.attrs,"data-flavor":i.component,...s,...t.props.value},a);return t.extra.value.wrap?t.extra.value.wrap(d):d}}});function n(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 r={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:i}};var o=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))};o._withStripped=!0;const s=n({render:o,staticRenderFns:[]},void 0,r,void 0,!1,void 0,!1,void 0,void 0,void 0),l={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:s,RefineFlavor:i}};var a=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)};a._withStripped=!0;const d=n({render:a,staticRenderFns:[]},void 0,l,void 0,!1,void 0,!1,void 0,void 0,void 0),u={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:i}};var c=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})}}})};c._withStripped=!0;const p=n({render:c,staticRenderFns:[]},void 0,u,void 0,!1,void 0,!1,void 0,void 0,void 0),f={name:"refine-date-input",components:{RefineFlavor:i},emits:["input"],props:{date1:{type:String,required:!1}}};var h=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))};h._withStripped=!0;const v=n({render:h,staticRenderFns:[]},void 0,f,void 0,!1,void 0,!1,void 0,void 0,void 0),m={name:"refine-double-date-input",components:{RefineFlavor:i},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var g=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)};g._withStripped=!0;const y=n({render:g,staticRenderFns:[]},void 0,m,void 0,!1,void 0,!1,void 0,void 0,void 0);var b=e=>"conjunction"===(null==e?void 0:e.type),w=Object.defineProperty,x=Object.defineProperties,O=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable,S=(e,t,i)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,$=(e,t)=>{for(var i in t||(t={}))C.call(t,i)&&S(e,i,t[i]);if(_)for(var i of _(t))k.call(t,i)&&S(e,i,t[i]);return e},R=(e,t)=>x(e,O(t)),I=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},q=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:$({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:I()}},B=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:I()}},j=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)?R($({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||I()}):R($({},e),{id:void 0,uid:I()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)C.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&_)for(var n of _(e))t.indexOf(n)<0&&k.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)=>{b(t)?"or"===t.word&&e.push([]):e[e.length-1].push(R($({},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=q(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=b(n)&&"or"===n.word,o=b(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:I()}}()),e.push(q(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=q(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,B(),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,B(),q(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=$({},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()}},E=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=$({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 F=n({},void 0,{name:"renderless-selector",data:()=>({selector:e.reactive(new E),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),A={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let D=1;var V={beforeCreate(){this.uid=D.toString(),D+=1}};const P={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:i}};var N=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)};N._withStripped=!0;const M=n({render:N,staticRenderFns:[]},void 0,P,void 0,!1,void 0,!1,void 0,void 0,void 0),T={name:"selector-listbox",mixins:[V],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:i}};var L=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)};L._withStripped=!0;const G=n({render:L,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0),z={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:i}};var H=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)};H._withStripped=!0;const K=n({render:H,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0),U={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:i}};var Q=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)};Q._withStripped=!0;const W=n({render:Q,staticRenderFns:[]},void 0,U,void 0,!1,void 0,!1,void 0,void 0,void 0),X={name:"selector",mixins:[V],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:W,RenderlessSelector:F,SelectorListItem:K,SelectorButton:M,SelectorListbox:G,RefineFlavor:i}};var Y=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};Y._withStripped=!0;const Z=n({render:Y,staticRenderFns:[]},void 0,X,void 0,!1,void 0,!1,void 0,void 0,void 0);var J={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 j(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}},ee={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)},te={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)},ie={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 ne={name:"selector-option",mixins:[A],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[A],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 re=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)};re._withStripped=!0;const oe=n({render:re,staticRenderFns:[]},void 0,ne,void 0,!1,void 0,!1,void 0,void 0,void 0),se={name:"refine-date-input",components:{Selector:Z,SelectorOption:oe,RefineFlavor:i},mixins:[V],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 le=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)};le._withStripped=!0;const ae=n({render:le,staticRenderFns:[]},void 0,se,void 0,!1,void 0,!1,void 0,void 0,void 0),de={name:"refine-option-input",components:{Selector:Z,SelectorOption:oe},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 ue=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)};ue._withStripped=!0;const ce=n({render:ue,staticRenderFns:[]},void 0,de,void 0,!1,void 0,!1,void 0,void 0,void 0),pe={emits:["input"],components:{RefineFlavor:i},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var fe=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}})};fe._withStripped=!0;const he=n({render:fe,staticRenderFns:[]},void 0,pe,void 0,!1,void 0,!1,void 0,void 0,void 0);var ve={RefineDateInput:v,RefineDoubleDateInput:y,RefineDoubleNumberInput:d,RefineNumberInput:s,RefineOptionInput:ce,RefineRelativeDateInput:ae,RefineTextInput:p,RefineNativeDatePicker:he},me=Object.freeze({__proto__:null,default:ve,RefineDateInput:v,RefineDoubleDateInput:y,RefineDoubleNumberInput:d,RefineNumberInput:s,RefineOptionInput:ce,RefineRelativeDateInput:ae,RefineTextInput:p,RefineNativeDatePicker:he}),ge={install:(e,t={})=>{t={DatePicker:he,...t},e.component("refine-date-picker",t.DatePicker)}},ye={install:(e,t={})=>{ge.install(e,t)}};const be={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:Z}};var we=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};we._withStripped=!0;const xe=n({render:we,staticRenderFns:[]},void 0,be,void 0,!1,void 0,!1,void 0,void 0,void 0),Oe=n({},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 j(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),_e={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:te,SelectorOption:oe,Selector:Z,...me}};var Ce=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))};Ce._withStripped=!0;const ke=n({render:Ce,staticRenderFns:[]},void 0,_e,void 0,!1,void 0,!1,void 0,void 0,void 0),Se={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:ke,RenderlessRefinement:ie,Selector:Z,SelectorOption:oe},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 $e=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)};$e._withStripped=!0;const Re={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:ke,Refinements:n({render:$e,staticRenderFns:[]},void 0,Se,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:oe,Selector:Z,RefineFlavor:i}};var Ie=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}])})};Ie._withStripped=!0;const qe={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:n({render:Ie,staticRenderFns:[]},void 0,Re,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:i,RenderlessCondition:ee,RenderlessQueryBuilder:J}};var Be=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)]}}])})};Be._withStripped=!0;const je=n({render:Be,staticRenderFns:[]},void 0,qe,void 0,!1,void 0,!1,void 0,void 0,void 0),Ee="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Fe="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ae=`${Ee} ${Fe} w-60 pl-3 py-2`,De={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{class:`${Ee} ${Fe} h-9 h-full py-5 px-2 leading-normal box-border`,relative:{class:`${Ae} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Ae,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ae}}},Ve="bg-white relative text-left cursor-default",Pe=`${Ve} focus:outline-none pl-3 py-1`,Ne={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:`${Ve} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Pe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Pe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Pe}}};exports.ConditionSelector=xe,exports.DatePickerPlugin=ye,exports.Query=Oe,exports.QueryBuilder=je,exports.RefinePlugin=ge,exports.Selector=Z,exports.SelectorOption=oe,exports.linearFlavor=Ne,exports.tailwindFlavor=De; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi");const t=Symbol();let i={};var n={init(e){i=e},get:(e,t=null)=>i?.[e]??t,set(e,t){i[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(i,r){let o=n.get("showLocators");const s=function(i,n,r=e.computed((()=>({})))){const o=e.inject(t),s=e.computed((()=>i(o)??{})),l=e.computed((()=>{const e={},t=r.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=e.computed((()=>{const e={},t=r.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const n=s.value.style;return n&&(e.style="function"==typeof n?n(t):n),e}));return e.computed((()=>({component:s.value.component??n.value,props:a,extra:l})))}((e=>{const t=i.component.split(".");let n=e;for(const e of t)n=n?.[e];return"string"!=typeof n&&"function"!=typeof n||(n={class:n}),n}),e.computed((()=>i.as)),e.computed((()=>({...r.attrs??{},...i.flavorOptions??{}}))));return()=>{const t=s.value,n=t.extra.value.order??i.order,l=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(i,["as","component","order"]),a=r.slots;let d="string"==typeof t.component&&t.component.includes("-")?a:n.map((e=>a?.[e]?.())),u=e.isVue2?e.h(t.component,{scopedSlots:a,attrs:{...o&&{"data-locator":i.component},...r.attrs},props:l,on:r.listeners,...t.props.value},d):e.h(t.component,{...o&&{"data-locator":i.component},...r.attrs,...l,...t.props.value},d);return t.extra.value.wrap?t.extra.value.wrap(u):u}}});function o(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof i?i.options:i;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),n&&(u._scopeId=n),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,i){return c.call(i),e(t,i)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return i}const s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:r}};var l=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};l._withStripped=!0;const a=o({render:l,staticRenderFns:[]},void 0,s,void 0,!1,void 0,!1,void 0,void 0,void 0),d={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:a,RefineFlavor:r}};var u=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};u._withStripped=!0;const c=o({render:u,staticRenderFns:[]},void 0,d,void 0,!1,void 0,!1,void 0,void 0,void 0),p={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};var f=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};f._withStripped=!0;const h=o({render:f,staticRenderFns:[]},void 0,p,void 0,!1,void 0,!1,void 0,void 0,void 0),v={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};var m=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};m._withStripped=!0;const g=o({render:m,staticRenderFns:[]},void 0,v,void 0,!1,void 0,!1,void 0,void 0,void 0),y={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var b=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};b._withStripped=!0;const w=o({render:b,staticRenderFns:[]},void 0,y,void 0,!1,void 0,!1,void 0,void 0,void 0);var x=e=>"conjunction"===(null==e?void 0:e.type),O=Object.defineProperty,_=Object.defineProperties,C=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,R=(e,t,i)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,I=(e,t)=>{for(var i in t||(t={}))S.call(t,i)&&R(e,i,t[i]);if(k)for(var i of k(t))$.call(t,i)&&R(e,i,t[i]);return e},q=(e,t)=>_(e,C(t)),B=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},j=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:I({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:B()}},E=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:B()}},F=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?q(I({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||B()}):q(I({},e),{id:void 0,uid:B()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)S.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&k)for(var n of k(e))t.indexOf(n)<0&&$.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{x(t)?"or"===t.word&&e.push([]):e[e.length-1].push(q(I({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=j(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=x(n)&&"or"===n.word,o=x(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:B()}}()),e.push(j(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=j(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,E(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,E(),j(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=I({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},A=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=I({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const D=o({},void 0,{name:"renderless-selector",data:()=>({selector:e.reactive(new A),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),V={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let P=1;var N={beforeCreate(){this.uid=P.toString(),P+=1}};const M={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};var T=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};T._withStripped=!0;const L=o({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),G={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};var z=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};z._withStripped=!0;const H=o({render:z,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};var U=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};U._withStripped=!0;const Q=o({render:U,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};var X=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};X._withStripped=!0;const Y=o({render:X,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:Y,RenderlessSelector:D,SelectorListItem:Q,SelectorButton:L,SelectorListbox:H,RefineFlavor:r}};var J=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};J._withStripped=!0;const ee=o({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0);var te={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:t,addGroup:i,blueprintStore:n,conditionFor:r,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:i,blueprint:n,conditionFor:r,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},ie={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("blueprint"),o=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!n)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let s;s=o?r.findCriterion(i.uid):r.addCriterion({id:t,depth:0});const l=(e,t)=>r.updateInput(s,e,t),a=e=>r.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",i.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{r.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{o||r.removeCriterion(r.indexOfCriterion(s))}));let d=null;return i?.condition?.meta?.clauses&&(d=i.condition.meta.clauses.map((e=>e.component))),()=>n.slots.default?n.slots.default({clauses:d,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,i)},ne={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,i)=>((t,i,n)=>{const r=e.inject("criterion"),o=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:t},s);const{clause:e,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return e.onUnmounted((()=>{l||r.input.clause===t&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:a,...r.input}):null})(t.clause,t,i)},re={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}};const oe={name:"selector-option",mixins:[V],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[V],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i&&t?i():null}}}};var se=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};se._withStripped=!0;const le=o({render:se,staticRenderFns:[]},void 0,oe,void 0,!1,void 0,!1,void 0,void 0,void 0),ae={name:"refine-date-input",components:{Selector:ee,SelectorOption:le,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var de=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};de._withStripped=!0;const ue=o({render:de,staticRenderFns:[]},void 0,ae,void 0,!1,void 0,!1,void 0,void 0,void 0),ce={name:"refine-option-input",components:{Selector:ee,SelectorOption:le},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};pe._withStripped=!0;const fe=o({render:pe,staticRenderFns:[]},void 0,ce,void 0,!1,void 0,!1,void 0,void 0,void 0),he={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var ve=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};ve._withStripped=!0;const me=o({render:ve,staticRenderFns:[]},void 0,he,void 0,!1,void 0,!1,void 0,void 0,void 0);var ge={RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:a,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:me},ye=Object.freeze({__proto__:null,default:ge,RefineDateInput:g,RefineDoubleDateInput:w,RefineDoubleNumberInput:c,RefineNumberInput:a,RefineOptionInput:fe,RefineRelativeDateInput:ue,RefineTextInput:h,RefineNativeDatePicker:me}),be={install:(e,t={})=>{t={DatePicker:me,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,n.init(t)}},we={install:(e,t={})=>{be.install(e,t)}};const xe={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ee}};var Oe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Oe._withStripped=!0;const _e=o({render:Oe,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0),Ce=o({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new F(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let i=this.$slots?.default;return e.isVue2&&(i=this.$scopedSlots?.default),i?i({blueprint:t}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),ke={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ne,SelectorOption:le,Selector:ee,...ye}};var Se=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Se._withStripped=!0;const $e=o({render:Se,staticRenderFns:[]},void 0,ke,void 0,!1,void 0,!1,void 0,void 0,void 0),Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:$e,RenderlessRefinement:re,Selector:ee,SelectorOption:le},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Ie=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Ie._withStripped=!0;const qe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:$e,Refinements:o({render:Ie,staticRenderFns:[]},void 0,Re,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:le,Selector:ee,RefineFlavor:r}};var Be=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Be._withStripped=!0;const je={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(i){var n;n=i.flavor,e.provide(t,n)},components:{Criterion:o({render:Be,staticRenderFns:[]},void 0,qe,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:r,RenderlessCondition:ie,RenderlessQueryBuilder:te}};var Ee=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,s){return[i("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),i("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:n.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ee._withStripped=!0;const Fe=o({render:Ee,staticRenderFns:[]},void 0,je,void 0,!1,void 0,!1,void 0,void 0,void 0),Ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",De="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ve=`${Ae} ${De} w-60 pl-3 py-2`,Pe={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ae} ${De} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ve} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ve,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ve}},Ne="bg-white relative text-left cursor-default",Me=`${Ne} focus:outline-none pl-3 py-1`,Te={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ne} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Me}}};exports.ConditionSelector=_e,exports.DatePickerPlugin=we,exports.Query=Ce,exports.QueryBuilder=Fe,exports.RefinePlugin=be,exports.Selector=ee,exports.SelectorOption=le,exports.linearFlavor=Te,exports.tailwindFlavor=Pe; | ||
//# sourceMappingURL=refine-vue.cjs.min.js.map |
@@ -1,2 +0,2 @@ | ||
import{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();const u=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){const s=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 i}),e((()=>n.as)),e((()=>({...i.attrs??{},...n.flavorOptions??{}}))));return()=>{const e=s.value,t=e.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"]),a=i.slots;let d="string"==typeof e.component&&e.component.includes("-"),u=d?a:t.map((e=>a?.[e]?.())),c=o(e.component,r?{scopedSlots:a,attrs:{...i.attrs,"data-flavor":n.component},props:l,on:i.listeners,...e.props.value}:{...i.attrs,"data-flavor":n.component,...l,...e.props.value},u);return e.extra.value.wrap?e.extra.value.wrap(c):c}}});function c(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 p={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:u}};var f=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))};f._withStripped=!0;const h=c({render:f,staticRenderFns:[]},undefined,p,undefined,false,undefined,!1,void 0,void 0,void 0);const m={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:h,RefineFlavor:u}};var v=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)};v._withStripped=!0;const g=c({render:v,staticRenderFns:[]},undefined,m,undefined,false,undefined,!1,void 0,void 0,void 0);const y={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:u}};var b=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})}}})};b._withStripped=!0;const w=c({render:b,staticRenderFns:[]},undefined,y,undefined,false,undefined,!1,void 0,void 0,void 0);const O={name:"refine-date-input",components:{RefineFlavor:u},emits:["input"],props:{date1:{type:String,required:!1}}};var x=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))};x._withStripped=!0;const _=c({render:x,staticRenderFns:[]},undefined,O,undefined,false,undefined,!1,void 0,void 0,void 0);const C={name:"refine-double-date-input",components:{RefineFlavor:u},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var S=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)};S._withStripped=!0;const k=c({render:S,staticRenderFns:[]},undefined,C,undefined,false,undefined,!1,void 0,void 0,void 0);var $=e=>"conjunction"===(null==e?void 0:e.type),R=Object.defineProperty,I=Object.defineProperties,q=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,F=(e,t,n)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,A=(e,t)=>{for(var n in t||(t={}))j.call(t,n)&&F(e,n,t[n]);if(B)for(var n of B(t))E.call(t,n)&&F(e,n,t[n]);return e},D=(e,t)=>I(e,q(t)),P=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},N=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:A({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:P()}},V=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:P()}},M=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)?D(A({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||P()}):D(A({},e),{id:void 0,uid:P()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)j.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&B)for(var i of B(e))t.indexOf(i)<0&&E.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{$(t)?"or"===t.word&&e.push([]):e[e.length-1].push(D(A({},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=N(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)&&"or"===i.word,o=$(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:P()}}()),e.push(N(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=N(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,V(),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,V(),N(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=A({},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()}},T=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=A({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 L=c({},undefined,{name:"renderless-selector",data:()=>({selector:s(new T),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),G={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let z=1;var H={beforeCreate(){this.uid=z.toString(),z+=1}};const K={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:u}};var U=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)};U._withStripped=!0;const Q=c({render:U,staticRenderFns:[]},undefined,K,undefined,false,undefined,!1,void 0,void 0,void 0);const W={name:"selector-listbox",mixins:[H],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:u}};var X=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)};X._withStripped=!0;const Y=c({render:X,staticRenderFns:[]},undefined,W,undefined,false,undefined,!1,void 0,void 0,void 0);const Z={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:u}};var J=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)};J._withStripped=!0;const ee=c({render:J,staticRenderFns:[]},undefined,Z,undefined,false,undefined,!1,void 0,void 0,void 0);const te={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:u}};var ne=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)};ne._withStripped=!0;const ie=c({render:ne,staticRenderFns:[]},undefined,te,undefined,false,undefined,!1,void 0,void 0,void 0);const re={name:"selector",mixins:[H],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:ie,RenderlessSelector:L,SelectorListItem:ee,SelectorButton:Q,SelectorListbox:Y,RefineFlavor:u}};var oe=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)})};oe._withStripped=!0;const se=c({render:oe,staticRenderFns:[]},undefined,re,undefined,false,undefined,!1,void 0,void 0,void 0);var le={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 M(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}},ae={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)},de={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)},ue={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 ce={name:"selector-option",mixins:[G],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[G],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 pe=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)};pe._withStripped=!0;const fe=c({render:pe,staticRenderFns:[]},undefined,ce,undefined,false,undefined,!1,void 0,void 0,void 0);const he={name:"refine-date-input",components:{Selector:se,SelectorOption:fe,RefineFlavor:u},mixins:[H],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var me=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};me._withStripped=!0;const ve=c({render:me,staticRenderFns:[]},undefined,he,undefined,false,undefined,!1,void 0,void 0,void 0);const ge={name:"refine-option-input",components:{Selector:se,SelectorOption:fe},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var ye=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};ye._withStripped=!0;const be=c({render:ye,staticRenderFns:[]},undefined,ge,undefined,false,undefined,!1,void 0,void 0,void 0);const we={emits:["input"],components:{RefineFlavor:u},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var Oe=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}})};Oe._withStripped=!0;const xe=c({render:Oe,staticRenderFns:[]},undefined,we,undefined,false,undefined,!1,void 0,void 0,void 0);var _e={RefineDateInput:_,RefineDoubleDateInput:k,RefineDoubleNumberInput:g,RefineNumberInput:h,RefineOptionInput:be,RefineRelativeDateInput:ve,RefineTextInput:w,RefineNativeDatePicker:xe},Ce=Object.freeze({__proto__:null,default:_e,RefineDateInput:_,RefineDoubleDateInput:k,RefineDoubleNumberInput:g,RefineNumberInput:h,RefineOptionInput:be,RefineRelativeDateInput:ve,RefineTextInput:w,RefineNativeDatePicker:xe}),Se={install:(e,t={})=>{t={DatePicker:xe,...t},e.component("refine-date-picker",t.DatePicker)}},ke={install:(e,t={})=>{Se.install(e,t)}};const $e={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:se}};var Re=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Re._withStripped=!0;const Ie=c({render:Re,staticRenderFns:[]},undefined,$e,undefined,false,undefined,!1,void 0,void 0,void 0);const qe=c({},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 M(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 Be={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:de,SelectorOption:fe,Selector:se,...Ce}};var je=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))};je._withStripped=!0;const Ee=c({render:je,staticRenderFns:[]},undefined,Be,undefined,false,undefined,!1,void 0,void 0,void 0);const Fe={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ee,RenderlessRefinement:ue,Selector:se,SelectorOption:fe},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 Ae=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)};Ae._withStripped=!0;const De={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ee,Refinements:c({render:Ae,staticRenderFns:[]},undefined,Fe,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:fe,Selector:se,RefineFlavor:u}};var Pe=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}])})};Pe._withStripped=!0;const Ne={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>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:c({render:Pe,staticRenderFns:[]},undefined,De,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:u,RenderlessCondition:ae,RenderlessQueryBuilder:le}};var Ve=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Ve._withStripped=!0;const Me=c({render:Ve,staticRenderFns:[]},undefined,Ne,undefined,false,undefined,!1,void 0,void 0,void 0),Te="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Le="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ge=`${Te} ${Le} w-60 pl-3 py-2`,ze={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{class:`${Te} ${Le} h-9 h-full py-5 px-2 leading-normal box-border`,relative:{class:`${Ge} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Ge,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ge}}},He="bg-white relative text-left cursor-default",Ke=`${He} focus:outline-none pl-3 py-1`,Ue={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${He} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ke} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ke} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ke}}};export{Ie as ConditionSelector,ke as DatePickerPlugin,qe as Query,Me as QueryBuilder,Se as RefinePlugin,se as Selector,fe as SelectorOption,Ue as linearFlavor,ze as tailwindFlavor}; | ||
import{computed as e,inject as t,provide as n,defineComponent as i,isVue2 as r,h as o,reactive as s,nextTick as l,onUnmounted as a}from"vue-demi";const d=Symbol();let u={};var c={init(e){u=e},get:(e,t=null)=>u?.[e]??t,set(e,t){u[e]=t}};const p=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(n,i){let s=c.get("showLocators");const l=function(n,i,r=e((()=>({})))){const o=t(d),s=e((()=>n(o)??{})),l=e((()=>{const e={},t=r.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=r.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const t=n.component.split(".");let i=e;for(const e of t)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e((()=>n.as)),e((()=>({...i.attrs??{},...n.flavorOptions??{}}))));return()=>{const e=l.value,t=e.extra.value.order??n.order,a=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(n,["as","component","order"]),d=i.slots;let u="string"==typeof e.component&&e.component.includes("-"),c=u?d:t.map((e=>d?.[e]?.())),p=o(e.component,r?{scopedSlots:d,attrs:{...s&&{"data-locator":n.component},...i.attrs},props:a,on:i.listeners,...e.props.value}:{...s&&{"data-locator":n.component},...i.attrs,...a,...e.props.value},c);return e.extra.value.wrap?e.extra.value.wrap(p):p}}});function f(e,t,n,i,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof n?n.options:n;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),i&&(u._scopeId=i),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,n){return c.call(n),e(t,n)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return n}const h={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:p}};var m=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};m._withStripped=!0;const v=f({render:m,staticRenderFns:[]},undefined,h,undefined,false,undefined,!1,void 0,void 0,void 0);const g={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:v,RefineFlavor:p}};var y=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[n("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?n("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),n("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};y._withStripped=!0;const b=f({render:y,staticRenderFns:[]},undefined,g,undefined,false,undefined,!1,void 0,void 0,void 0);const w={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:p}};var O=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};O._withStripped=!0;const x=f({render:O,staticRenderFns:[]},undefined,w,undefined,false,undefined,!1,void 0,void 0,void 0);const _={name:"refine-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1}}};var C=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};C._withStripped=!0;const S=f({render:C,staticRenderFns:[]},undefined,_,undefined,false,undefined,!1,void 0,void 0,void 0);const k={name:"refine-double-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var $=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),n("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),n("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};$._withStripped=!0;const R=f({render:$,staticRenderFns:[]},undefined,k,undefined,false,undefined,!1,void 0,void 0,void 0);var I=e=>"conjunction"===(null==e?void 0:e.type),q=Object.defineProperty,B=Object.defineProperties,j=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,D=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))F.call(t,n)&&D(e,n,t[n]);if(E)for(var n of E(t))A.call(t,n)&&D(e,n,t[n]);return e},N=(e,t)=>B(e,j(t)),V=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},M=(e,t,n,i)=>{var r,o;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:P({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:V()}},T=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:V()}},L=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?N(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||V()}):N(P({},e),{id:void 0,uid:V()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)F.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&E)for(var i of E(e))t.indexOf(i)<0&&A.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{I(t)?"or"===t.word&&e.push([]):e[e.length-1].push(N(P({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:r}=this.findCondition(t.id),o=M(i,1,n,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],r=I(i)&&"or"===i.word,o=I(n)&&"or"===n.word,s=r||!i,l=o||!n,a=l&&!s,d=l&&s;!n&&!i?this.blueprint=[]:d&&o?t.splice(e-1,2):d&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:r}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:V()}}()),e.push(M(n.id,1,i,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,r=M(t,n);return 0===i.length?i.push(r):i.splice(i.length,0,T(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:r,refinements:o}=i;return t.splice(e+1,0,T(),M(i.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const r=this.findRefinement(t,i),o=this.findCriterion(e),s=P({},o.input);delete s[n],s[i]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},G=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,r=P({previousOption:i,nextOption:null},e);i&&(i.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const z=f({},undefined,{name:"renderless-selector",data:()=>({selector:s(new G),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return l().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return r&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0),H={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let K=1;var U={beforeCreate(){this.uid=K.toString(),K+=1}};const Q={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:p}};var W=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?n("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):n("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};W._withStripped=!0;const X=f({render:W,staticRenderFns:[]},undefined,Q,undefined,false,undefined,!1,void 0,void 0,void 0);const Y={name:"selector-listbox",mixins:[U],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:p}};var Z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[n("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};Z._withStripped=!0;const J=f({render:Z,staticRenderFns:[]},undefined,Y,undefined,false,undefined,!1,void 0,void 0,void 0);const ee={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:p}};var te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[n("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};te._withStripped=!0;const ne=f({render:te,staticRenderFns:[]},undefined,ee,undefined,false,undefined,!1,void 0,void 0,void 0);const ie={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:p}};var re=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var i=t.id,r=t.display;return n("refine-flavor",{key:i,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",i)}}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[n("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};re._withStripped=!0;const oe=f({render:re,staticRenderFns:[]},undefined,ie,undefined,false,undefined,!1,void 0,void 0,void 0);const se={name:"selector",mixins:[U],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||i()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:oe,RenderlessSelector:z,SelectorListItem:ne,SelectorButton:X,SelectorListbox:J,RefineFlavor:p}};var le=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[n("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[n("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:i.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?n("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)},"deselect-option":function(t){return e.deselectOption(t,i)}}}):n("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(i)},open:function(t){return e.open(i)}}}),e._v(" "),n("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(i)},"highlight-previous-option":function(t){return e.highlightPreviousOption(i)},"select-option":function(t){return e.selectOption(l.id,i)},"buffer-changed":function(t){return e.updateBuffer(t,a,i)},close:function(t){return e.close(i)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return n("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return i.highlightOption(t)},mouseleave:function(e){return i.highlightOption(null)},selected:function(n){return e.selectOption(t.id,i)}}})}))}}],null,!0)})],1),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};le._withStripped=!0;const ae=f({render:le,staticRenderFns:[]},undefined,se,undefined,false,undefined,!1,void 0,void 0,void 0);var de={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:i,type:r,display:o,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return r&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:o,groupedBlueprint:n.groupedBlueprint()}):null}},ue={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,r)=>{const o=t("blueprint"),s=t("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!r)throw new Error("useCondition requires a Vue context.");if(!o)throw new Error("Conditions must be rendered within a query.");let l;l=s?o.findCriterion(i.uid):o.addCriterion({id:e,depth:0});const d=(e,t)=>o.updateInput(l,e,t),u=e=>o.switchClause(l,e);n("criterion",l),n("criterionMeta",i.meta),n("updateInput",d),n("switchRefinement",((e,t)=>{o.switchRefinement(l,e,t)})),n("refinementId",null),a((()=>{s||o.removeCriterion(o.indexOfCriterion(l))}));let c=null;return i?.condition?.meta?.clauses&&(c=i.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,i)},ce={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,n)=>((e,n,i)=>{const r=t("criterion"),o=t("updateInput"),s=t("refinementId"),l=t("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:t,...i}=r.input;Object.keys(n).length>0&&0===Object.keys(i).length&&o({...n},s)}return a((()=>{l||r.input.clause===e&&o({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:d,...r.input}):null})(e.clause,e,n)},pe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(r&&(e=this.$scopedSlots?.default),e)return e()}};const fe={name:"selector-option",mixins:[H],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[H],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var he=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};he._withStripped=!0;const me=f({render:he,staticRenderFns:[]},undefined,fe,undefined,false,undefined,!1,void 0,void 0,void 0);const ve={name:"refine-date-input",components:{Selector:ae,SelectorOption:me,RefineFlavor:p},mixins:[U],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ge=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[n("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),n("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),n("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return n("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ge._withStripped=!0;const ye=f({render:ge,staticRenderFns:[]},undefined,ve,undefined,false,undefined,!1,void 0,void 0,void 0);const be={name:"refine-option-input",components:{Selector:ae,SelectorOption:me},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};var we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var i=t.id,r=t.display;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.isSelected(i)}})})),1)};we._withStripped=!0;const Oe=f({render:we,staticRenderFns:[]},undefined,be,undefined,false,undefined,!1,void 0,void 0,void 0);const xe={emits:["input"],components:{RefineFlavor:p},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var _e=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};_e._withStripped=!0;const Ce=f({render:_e,staticRenderFns:[]},undefined,xe,undefined,false,undefined,!1,void 0,void 0,void 0);var Se={RefineDateInput:S,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:v,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce},ke=Object.freeze({__proto__:null,default:Se,RefineDateInput:S,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:v,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,c.init(t)}},Re={install:(e,t={})=>{$e.install(e,t)}};const Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ae}};var qe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};qe._withStripped=!0;const Be=f({render:qe,staticRenderFns:[]},undefined,Ie,undefined,false,undefined,!1,void 0,void 0,void 0);const je=f({},undefined,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},undefined,undefined,undefined,!1,void 0,void 0,void 0);const Ee={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ce,SelectorOption:me,Selector:ae,...ke}};var Fe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var i=t.setValue;return[n("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return n("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?n(s,e._b({tag:"component",on:{input:i}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Fe._withStripped=!0;const Ae=f({render:Fe,staticRenderFns:[]},undefined,Ee,undefined,false,undefined,!1,void 0,void 0,void 0);const De={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ae,RenderlessRefinement:pe,Selector:ae,SelectorOption:me},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var i=t.id,r=t.meta,o=t.display;return n("selector-option",{key:i,attrs:{id:i,display:o,selected:!!e.input[i]}},[n("renderless-refinement",{attrs:{id:i}},[n("clause",{attrs:{meta:r,input:e.input[i]},on:{"switch-clause":function(t){var n=t.id;return e.updateInput({clause:n},i)}}})],1)],1)})),1)};Pe._withStripped=!0;const Ne={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ae,Refinements:f({render:Pe,staticRenderFns:[]},undefined,De,undefined,false,undefined,!1,void 0,void 0,void 0),SelectorOption:me,Selector:ae,RefineFlavor:p}};var Ve=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?n("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return n("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[n("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var i=t.id,r=t.display,o=t.meta,s=t.refinements;return n("selector-option",{key:i,attrs:{id:i,display:r,selected:e.conditionId===i}},[n("div",[n("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?n("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[n("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ve._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>r?{}:{key:e},templateChildKey:e=>r?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,n(d,t)},components:{Criterion:f({render:Ve,staticRenderFns:[]},undefined,Ne,undefined,false,undefined,!1,void 0,void 0,void 0),RefineFlavor:p,RenderlessCondition:ue,RenderlessQueryBuilder:de}};var Te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===i.length?n("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[n("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[n("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):n("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(i,(function(t,s){return[n("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return n("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[n("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(i){var o=i.switchClause;return[n("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),n("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[n("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[n("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[n("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),n("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),n("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:i.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),n("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Te._withStripped=!0;const Le=f({render:Te,staticRenderFns:[]},undefined,Me,undefined,false,undefined,!1,void 0,void 0,void 0),Ge="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",He=`${Ge} ${ze} w-60 pl-3 py-2`,Ke={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ge} ${ze} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${He} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:He,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:He}},Ue="bg-white relative text-left cursor-default",Qe=`${Ue} focus:outline-none pl-3 py-1`,We={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ue} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Qe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Qe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Qe}}};export{Be as ConditionSelector,Re as DatePickerPlugin,je as Query,Le as QueryBuilder,$e as RefinePlugin,ae as Selector,me as SelectorOption,We as linearFlavor,Ke as tailwindFlavor}; | ||
//# sourceMappingURL=refine-vue.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import{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(),c=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){const s=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 n}),e((()=>i.as)),e((()=>({...n.attrs??{},...i.flavorOptions??{}}))));return()=>{const e=s.value,t=e.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=n.slots;let d="string"==typeof e.component&&e.component.includes("-")?a:t.map((e=>a?.[e]?.())),c=o(e.component,r?{scopedSlots:a,attrs:{...n.attrs,"data-flavor":i.component},props:l,on:n.listeners,...e.props.value}:{...n.attrs,"data-flavor":i.component,...l,...e.props.value},d);return e.extra.value.wrap?e.extra.value.wrap(c):c}}});function u(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const c="function"==typeof i?i.options:i;let u;if(e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),n&&(c._scopeId=n),o?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=u):t&&(u=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),u)if(c.functional){const e=c.render;c.render=function(t,i){return u.call(i),e(t,i)}}else{const e=c.beforeCreate;c.beforeCreate=e?[].concat(e,u):[u]}return i}const p={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:c}};var f=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))};f._withStripped=!0;const h=u({render:f,staticRenderFns:[]},void 0,p,void 0,!1,void 0,!1,void 0,void 0,void 0),v={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:h,RefineFlavor:c}};var m=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)};m._withStripped=!0;const g=u({render:m,staticRenderFns:[]},void 0,v,void 0,!1,void 0,!1,void 0,void 0,void 0),y={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:c}};var b=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})}}})};b._withStripped=!0;const w=u({render:b,staticRenderFns:[]},void 0,y,void 0,!1,void 0,!1,void 0,void 0,void 0),O={name:"refine-date-input",components:{RefineFlavor:c},emits:["input"],props:{date1:{type:String,required:!1}}};var x=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))};x._withStripped=!0;const _=u({render:x,staticRenderFns:[]},void 0,O,void 0,!1,void 0,!1,void 0,void 0,void 0),C={name:"refine-double-date-input",components:{RefineFlavor:c},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var k=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)};k._withStripped=!0;const S=u({render:k,staticRenderFns:[]},void 0,C,void 0,!1,void 0,!1,void 0,void 0,void 0);var $=e=>"conjunction"===(null==e?void 0:e.type),R=Object.defineProperty,I=Object.defineProperties,q=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,F=(e,t,i)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,A=(e,t)=>{for(var i in t||(t={}))j.call(t,i)&&F(e,i,t[i]);if(B)for(var i of B(t))E.call(t,i)&&F(e,i,t[i]);return e},D=(e,t)=>I(e,q(t)),P=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},V=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:A({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:P()}},N=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:P()}},M=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)?D(A({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||P()}):D(A({},e),{id:void 0,uid:P()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)j.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&B)for(var n of B(e))t.indexOf(n)<0&&E.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)=>{$(t)?"or"===t.word&&e.push([]):e[e.length-1].push(D(A({},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=V(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=$(n)&&"or"===n.word,o=$(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:P()}}()),e.push(V(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=V(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,N(),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,N(),V(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=A({},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()}},T=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=A({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 L=u({},void 0,{name:"renderless-selector",data:()=>({selector:s(new T),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),G={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let z=1;var H={beforeCreate(){this.uid=z.toString(),z+=1}};const K={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:c}};var U=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)};U._withStripped=!0;const Q=u({render:U,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"selector-listbox",mixins:[H],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:c}};var X=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)};X._withStripped=!0;const Y=u({render:X,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={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:c}};var J=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)};J._withStripped=!0;const ee=u({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),te={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:c}};var ie=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)};ie._withStripped=!0;const ne=u({render:ie,staticRenderFns:[]},void 0,te,void 0,!1,void 0,!1,void 0,void 0,void 0),re={name:"selector",mixins:[H],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:ne,RenderlessSelector:L,SelectorListItem:ee,SelectorButton:Q,SelectorListbox:Y,RefineFlavor:c}};var oe=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)})};oe._withStripped=!0;const se=u({render:oe,staticRenderFns:[]},void 0,re,void 0,!1,void 0,!1,void 0,void 0,void 0);var le={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 M(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}},ae={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),c=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 u=null;return n?.condition?.meta?.clauses&&(u=n.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:u,criterion:l,updateInput:d,switchClause:c}):null})(e.id,e,n)},de={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)},ce={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 ue={name:"selector-option",mixins:[G],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[G],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 pe=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)};pe._withStripped=!0;const fe=u({render:pe,staticRenderFns:[]},void 0,ue,void 0,!1,void 0,!1,void 0,void 0,void 0),he={name:"refine-date-input",components:{Selector:se,SelectorOption:fe,RefineFlavor:c},mixins:[H],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ve=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ve._withStripped=!0;const me=u({render:ve,staticRenderFns:[]},void 0,he,void 0,!1,void 0,!1,void 0,void 0,void 0),ge={name:"refine-option-input",components:{Selector:se,SelectorOption:fe},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var ye=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};ye._withStripped=!0;const be=u({render:ye,staticRenderFns:[]},void 0,ge,void 0,!1,void 0,!1,void 0,void 0,void 0),we={emits:["input"],components:{RefineFlavor:c},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var Oe=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}})};Oe._withStripped=!0;const xe=u({render:Oe,staticRenderFns:[]},void 0,we,void 0,!1,void 0,!1,void 0,void 0,void 0);var _e={RefineDateInput:_,RefineDoubleDateInput:S,RefineDoubleNumberInput:g,RefineNumberInput:h,RefineOptionInput:be,RefineRelativeDateInput:me,RefineTextInput:w,RefineNativeDatePicker:xe},Ce=Object.freeze({__proto__:null,default:_e,RefineDateInput:_,RefineDoubleDateInput:S,RefineDoubleNumberInput:g,RefineNumberInput:h,RefineOptionInput:be,RefineRelativeDateInput:me,RefineTextInput:w,RefineNativeDatePicker:xe}),ke={install:(e,t={})=>{t={DatePicker:xe,...t},e.component("refine-date-picker",t.DatePicker)}},Se={install:(e,t={})=>{ke.install(e,t)}};const $e={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:se}};var Re=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};Re._withStripped=!0;const Ie=u({render:Re,staticRenderFns:[]},void 0,$e,void 0,!1,void 0,!1,void 0,void 0,void 0),qe=u({},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 M(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),Be={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:de,SelectorOption:fe,Selector:se,...Ce}};var je=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))};je._withStripped=!0;const Ee=u({render:je,staticRenderFns:[]},void 0,Be,void 0,!1,void 0,!1,void 0,void 0,void 0),Fe={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ee,RenderlessRefinement:ce,Selector:se,SelectorOption:fe},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 Ae=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)};Ae._withStripped=!0;const De={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ee,Refinements:u({render:Ae,staticRenderFns:[]},void 0,Fe,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:fe,Selector:se,RefineFlavor:c}};var Pe=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}])})};Pe._withStripped=!0;const Ve={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>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:u({render:Pe,staticRenderFns:[]},void 0,De,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:c,RenderlessCondition:ae,RenderlessQueryBuilder:le}};var Ne=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)]}}])})};Ne._withStripped=!0;const Me=u({render:Ne,staticRenderFns:[]},void 0,Ve,void 0,!1,void 0,!1,void 0,void 0,void 0),Te="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Le="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ge=`${Te} ${Le} w-60 pl-3 py-2`,ze={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{class:`${Te} ${Le} h-9 h-full py-5 px-2 leading-normal box-border`,relative:{class:`${Ge} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Ge,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ge}}},He="bg-white relative text-left cursor-default",Ke=`${He} focus:outline-none pl-3 py-1`,Ue={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${He} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ke} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ke} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ke}}};export{Ie as ConditionSelector,Se as DatePickerPlugin,qe as Query,Me as QueryBuilder,ke as RefinePlugin,se as Selector,fe as SelectorOption,Ue as linearFlavor,ze as tailwindFlavor}; | ||
import{computed as e,inject as t,provide as i,defineComponent as n,isVue2 as r,h as o,reactive as s,nextTick as l,onUnmounted as a}from"vue-demi";const d=Symbol();let u={};var c={init(e){u=e},get:(e,t=null)=>u?.[e]??t,set(e,t){u[e]=t}};const p=n({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(i,n){let s=c.get("showLocators");const l=function(i,n,r=e((()=>({})))){const o=t(d),s=e((()=>i(o)??{})),l=e((()=>{const e={},t=r.value??{};let i=s.value.order;return i&&(e.order="function"==typeof i?i(t):i),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=r.value??{},i=s.value.class;i&&(e.class="function"==typeof i?i(t):i);const n=s.value.style;return n&&(e.style="function"==typeof n?n(t):n),e}));return e((()=>({component:s.value.component??n.value,props:a,extra:l})))}((e=>{const t=i.component.split(".");let n=e;for(const e of t)n=n?.[e];return"string"!=typeof n&&"function"!=typeof n||(n={class:n}),n}),e((()=>i.as)),e((()=>({...n.attrs??{},...i.flavorOptions??{}}))));return()=>{const e=l.value,t=e.extra.value.order??i.order,a=function(e,t=[]){const i=Object.assign({},e);for(const e of t)e in i&&delete i[e];return i}(i,["as","component","order"]),d=n.slots;let u="string"==typeof e.component&&e.component.includes("-")?d:t.map((e=>d?.[e]?.())),c=o(e.component,r?{scopedSlots:d,attrs:{...s&&{"data-locator":i.component},...n.attrs},props:a,on:n.listeners,...e.props.value}:{...s&&{"data-locator":i.component},...n.attrs,...a,...e.props.value},u);return e.extra.value.wrap?e.extra.value.wrap(c):c}}});function f(e,t,i,n,r,o,s,l,a,d){"boolean"!=typeof s&&(a=l,l=s,s=!1);const u="function"==typeof i?i.options:i;let c;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),n&&(u._scopeId=n),o?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=c):t&&(c=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){const e=u.render;u.render=function(t,i){return c.call(i),e(t,i)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,c):[c]}return i}const h={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,i=Number(t);isNaN(i)?this.currentValue=t:(this.currentValue=i,this.$emit("input",{value1:i}))}},components:{RefineFlavor:p}};var v=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"input",component:"inputs.number",type:"number",value:e.currentValue},on:{input:e.handleInputChange}},"refine-flavor",e.metaAttributes,!1))};v._withStripped=!0;const m=f({render:v,staticRenderFns:[]},void 0,h,void 0,!1,void 0,!1,void 0,void 0,void 0),g={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:m,RefineFlavor:p}};var y=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.number.double.wrapper"}},[i("number-input",{attrs:{meta:e.meta,value:e.value1},on:{input:e.updateFirstValue}}),e._v(" "),e.joinWord?i("refine-flavor",{attrs:{as:"span",component:"inputs.number.double.joiner"}},[e._v(e._s(e.joinWord)+"\n ")]):e._e(),e._v(" "),i("number-input",{attrs:{meta:e.meta,value:e.value2},on:{input:e.updateSecondValue}})],1)};y._withStripped=!0;const b=f({render:y,staticRenderFns:[]},void 0,g,void 0,!1,void 0,!1,void 0,void 0,void 0),w={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:p}};var O=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.text",type:"text",value:e.value},on:{input:function(t){return e.$emit("input",{value:t.target.value})}}})};O._withStripped=!0;const x=f({render:O,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),_={name:"refine-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1}}};var C=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1))};C._withStripped=!0;const k=f({render:C,staticRenderFns:[]},void 0,_,void 0,!1,void 0,!1,void 0,void 0,void 0),S={name:"refine-double-date-input",components:{RefineFlavor:p},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};var $=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.double.wrapper"}},[i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date1},on:{input:function(t){return e.$emit("input",{date1:t.value})}}},"refine-flavor",e.$attrs,!1)),e._v(" "),i("refine-flavor",{attrs:{as:"p",component:"inputs.date.double.joiner"}},[e._v(e._s(e.joiner))]),e._v(" "),i("refine-flavor",e._b({attrs:{as:"refine-date-picker",component:"inputs.date",date:e.date2},on:{input:function(t){return e.$emit("input",{date2:t.value})}}},"refine-flavor",e.$attrs,!1))],1)};$._withStripped=!0;const R=f({render:$,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0);var I=e=>"conjunction"===(null==e?void 0:e.type),q=Object.defineProperty,B=Object.defineProperties,j=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,D=(e,t,i)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t)=>{for(var i in t||(t={}))F.call(t,i)&&D(e,i,t[i]);if(E)for(var i of E(t))A.call(t,i)&&D(e,i,t[i]);return e},V=(e,t)=>B(e,j(t)),N=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},M=(e,t,i,n)=>{var r,o;const[s]=n||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:P({clause:null==i?void 0:i.clauses[0].id},s&&{[s.id]:{clause:null==(o=null==(r=null==s?void 0:s.meta)?void 0:r.clauses[0])?void 0:o.id}}),uid:N()}},T=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:N()}},L=class{constructor(e,t,i){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{i&&i([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?V(P({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||N()}):V(P({},e),{id:void 0,uid:N()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var i={};for(var n in e)F.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&E)for(var n of E(e))t.indexOf(n)<0&&A.call(e,n)&&(i[n]=e[n]);return i})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,i)=>{I(t)?"or"===t.word&&e.push([]):e[e.length-1].push(V(P({},t),{position:i}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let i=0;i<this.blueprint.length;i++)if(this.blueprint[i].uid===e){t=i;break}return t}replaceCriterion(e,t){const{meta:i,id:n,refinements:r}=this.findCondition(t.id),o=M(n,1,i,r);this.blueprint.splice(e,1,o),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,i=t[e-1],n=t[e+1],r=I(n)&&"or"===n.word,o=I(i)&&"or"===i.word,s=r||!n,l=o||!i,a=l&&!s,d=l&&s;i||n?d&&o?t.splice(e-1,2):d&&!i||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,i=t[0],{meta:n,refinements:r}=i;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:N()}}()),e.push(M(i.id,1,n,r)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:i}=e,{blueprint:n}=this,r=M(t,i);return 0===n.length?n.push(r):n.splice(n.length,0,T(),r),this.blueprintChanged(),r}insertCriterion(e){const{blueprint:t,conditions:i}=this,n=i[0],{meta:r,refinements:o}=n;return t.splice(e+1,0,T(),M(n.id,1,r,o)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:i}=this.findCondition(e);let n;return i.forEach((e=>{e.id===t&&(n=e)})),n}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((i=>{i.id===e&&(t=i)})),t}switchClause({uid:e,id:t},i,n){const{meta:r}=this.findCondition(t),o=this.findCriterion(e);Array.isArray(r.options)?o.input={clause:i}:this.updateInput({uid:e},{clause:i},n)}switchRefinement({uid:e,id:t},i,n){const r=this.findRefinement(t,n),o=this.findCriterion(e),s=P({},o.input);delete s[i],s[n]={clause:r.meta.clauses[0].id},o.input=s}updateInput({uid:e},t,i){const n=this.findCriterion(e);Object.keys(t).forEach((e=>{i?n.input[i][e]=t[e]:n.input[e]=t[e]})),this.blueprintChanged()}},G=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var i=0;i<this.options.length;i++)if(this.options[i].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const n=this.options[this.options.length-1]||null,r=P({previousOption:n,nextOption:null},e);n&&(n.nextOption=r),this.options.push(r)}isSelected(e){let t=!1;return this.selectedOptions.forEach((i=>{i.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const i=this.options[t];if(i.id===e)return i}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}};const z=f({},void 0,{name:"renderless-selector",data:()=>({selector:s(new G),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}=this;return{clearOptions:e,close:t,highlightNextOption:i,highlightPreviousOption:n,highlightOption:r,open:o,selectOption:s,selectedOptions:l,toggle:a,toggleOption:d}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n}=this;return{isClosed:e,isOpen:t,selectedOptions:i,highlightedOption:n,options:this.selector.options}}},methods:{nextTick(){return l().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:i}=this,{selectedOption:n}=t.toggleOption(e);return n?this.selectOption(e):this.deselectOption(e),i(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return r&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),H={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let K=1;var U={beforeCreate(){this.uid=K.toString(),K+=1}};const Q={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:p}};var W=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.button",id:e.id,type:"button","aria-haspopup":"listbox","aria-expanded":e.isOpen,"aria-label":e.label()},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}}},[0===e.display.length?i("refine-flavor",{attrs:{as:"span",component:"select.button.placeholder"}},[e._v("\n Choose an option\n ")]):i("refine-flavor",{attrs:{as:"span",component:"select.button.selected"}},[e._v("\n "+e._s(e.display)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)};W._withStripped=!0;const X=f({render:W,staticRenderFns:[]},void 0,Q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"selector-listbox",mixins:[U],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:p}};var Z=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"select.listbox.wrapper"}},[i("refine-flavor",{ref:"listBox",attrs:{as:"ul",component:"select.listbox",flavorOptions:{isClosed:e.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":e.selectedOption?e.createItemId(e.selectedOption.id):""},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.stopPropagation(),t.preventDefault(),e.clearBuffer.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-next-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-up",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),function(){return e.preserveBuffer()&&e.$emit("highlight-previous-option")}.apply(null,arguments))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("select-option"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"tab",9,t.key,"Tab")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("close"))},function(t){return e.handleKeypress(t)}]}},[e._t("default",null,{createItemId:e.createItemId})],2)],1)};Z._withStripped=!0;const J=f({render:Z,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),ee={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:p}};var te=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{key:e.optionId,ref:"listItem",attrs:{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:e.isHighlighted},role:"option","aria-label":e.optionDisplay,"aria-selected":e.selected},on:{mouseenter:function(t){return e.$emit("mouseenter")},mouseleave:function(t){return e.$emit("mouseleave")},click:function(t){return e.$emit("selected")}}},[i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:e.selected}}},[e._v("\n "+e._s(e.optionDisplay)+"\n ")]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:e.isHighlighted}}},[i("refine-flavor",{directives:[{name:"show",rawName:"v-show",value:e.selected,expression:"selected"}],attrs:{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!e.selected}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"}})])],1)],1)};te._withStripped=!0;const ie=f({render:te,staticRenderFns:[]},void 0,ee,void 0,!1,void 0,!1,void 0,void 0,void 0),ne={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:p}};var re=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{ref:"button",attrs:{as:"button",component:"select.multi.button",id:e.id,"aria-haspopup":"listbox","aria-label":e.label(),"aria-expanded":e.isOpen,tabindex:"0"},on:{click:function(t){return t.preventDefault(),e.$emit("toggle")},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"arrow-down",void 0,t.key,void 0)?null:(t.stopPropagation(),t.preventDefault(),e.$emit("open"))}]}},[0===e.selectedOptions.length?i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.placeholder"}},[e._v("\n Choose an option\n ")]):e._l(e.selectedOptions,(function(t){var n=t.id,r=t.display;return i("refine-flavor",{key:n,attrs:{as:"span",component:"select.multi.button.selected"}},[e._v("\n "+e._s(r)+"\n "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.deselect.icon.wrapper"},on:{click:function(t){return t.preventDefault(),e.$emit("deselect-option",n)}}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"select.multi.button.icon.wrapper"}},[i("refine-flavor",{attrs:{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"}})])],1)],2)};re._withStripped=!0;const oe=f({render:re,staticRenderFns:[]},void 0,ne,void 0,!1,void 0,!1,void 0,void 0,void 0),se={name:"selector",mixins:[U],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,i){const{value:n}=i;if("function"!=typeof n)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const r=e=>{t.contains(e.target)||n()};e[t.id]=r,document.addEventListener("click",r),document.addEventListener("touchstart",r)},i=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:i,unmount:i}}},methods:{updateBuffer(e,t,i){if(!e)return;const n=t.find((t=>t.display.toLowerCase().includes(e)));n&&(i.highlightOption(n),this.scrollIntoView(n.id))},isSelected(e,t){let i=!1;return t.forEach((t=>{e.id===t.id&&(i=!0)})),i},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:i,selectOption:n,toggleOption:r}=t,{isMultiSelect:o}=this;o?r(e):(i(),n(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:i}=await e();t&&this.scrollIntoView(i?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:oe,RenderlessSelector:z,SelectorListItem:ie,SelectorButton:X,SelectorListbox:J,RefineFlavor:p}};var le=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-selector",{on:{"select-option":function(t){return e.$emit("select-option",t)},"deselect-option":function(t){return e.$emit("deselect-option",t)}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.actions,r=t.isOpen,o=t.isClosed,s=t.selectedOptions,l=t.highlightedOption,a=t.options;return[i("refine-flavor",{attrs:{as:"div",component:"select.wrapper"}},[i("refine-flavor",{directives:[{name:"click-away",rawName:"v-click-away",value:n.close,expression:"actions.close"}],class:e.innerClass,attrs:{as:"div",component:"select",id:"listbox-"+e.selectorId,"aria-labelledby":e.buttonId}},[e.isMultiSelect?i("multi-selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,selectedOptions:s},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)},"deselect-option":function(t){return e.deselectOption(t,n)}}}):i("selector-button",{ref:"button",attrs:{id:e.buttonId,isOpen:r,display:s[0]?s[0].display:""},on:{toggle:function(t){return e.toggle(n)},open:function(t){return e.open(n)}}}),e._v(" "),i("selector-listbox",{ref:"listBox",attrs:{selectedOption:s[0],isClosed:o},on:{"highlight-next-option":function(t){return e.highlightNextOption(n)},"highlight-previous-option":function(t){return e.highlightPreviousOption(n)},"select-option":function(t){return e.selectOption(l.id,n)},"buffer-changed":function(t){return e.updateBuffer(t,a,n)},close:function(t){return e.close(n)}},scopedSlots:e._u([{key:"default",fn:function(t){var r=t.createItemId;return e._l(a,(function(t){return i("selector-list-item",{key:t.id,ref:t.id,refInFor:!0,attrs:{id:r(t.id),optionId:t.id,optionDisplay:t.display,selected:e.isSelected(t,s),isHighlighted:l&&t.id===l.id},on:{mouseenter:function(e){return n.highlightOption(t)},mouseleave:function(e){return n.highlightOption(null)},selected:function(i){return e.selectOption(t.id,n)}}})}))}}],null,!0)})],1),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"customOptions.wrapper"}},[e._t("default")],2)],1)]}}],null,!0)})};le._withStripped=!0;const ae=f({render:le,staticRenderFns:[]},void 0,se,void 0,!1,void 0,!1,void 0,void 0,void 0);var de={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:i}=e,{id:n,type:r,display:o,meta:s}=this.conditionsLookup[t];return{id:n,type:r,display:o,uid:i,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:i,conditionFor:n,replaceCriterion:o,removeCriterion:s}=this;let l=this.$slots?.default;return r&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:i,conditionFor:n,removeCriterion:s,replaceCriterion:o,groupedBlueprint:i.groupedBlueprint()}):null}},ue={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,n)=>((e,n,r)=>{const o=t("blueprint"),s=t("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!r)throw new Error("useCondition requires a Vue context.");if(!o)throw new Error("Conditions must be rendered within a query.");let l;l=s?o.findCriterion(n.uid):o.addCriterion({id:e,depth:0});const d=(e,t)=>o.updateInput(l,e,t),u=e=>o.switchClause(l,e);i("criterion",l),i("criterionMeta",n.meta),i("updateInput",d),i("switchRefinement",((e,t)=>{o.switchRefinement(l,e,t)})),i("refinementId",null),a((()=>{s||o.removeCriterion(o.indexOfCriterion(l))}));let c=null;return n?.condition?.meta?.clauses&&(c=n.condition.meta.clauses.map((e=>e.component))),()=>r.slots.default?r.slots.default({clauses:c,criterion:l,updateInput:d,switchClause:u}):null})(e.id,e,n)},ce={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,i)=>((e,i,n)=>{const r=t("criterion"),o=t("updateInput"),s=t("refinementId"),l=t("builderModeActive"),d=e=>{o(e,s)};if(!r)throw new Error("A clause must be used within a criterion.");if(!l){o({clause:e},s);const{clause:t,...n}=r.input;Object.keys(i).length>0&&0===Object.keys(n).length&&o({...i},s)}return a((()=>{l||r.input.clause===e&&o({clause:void 0},s)})),()=>n.slots.default?n.slots.default({setValue:d,...r.input}):null})(e.clause,e,i)},pe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(r&&(e=this.$scopedSlots?.default),e)return e()}};const fe={name:"selector-option",mixins:[H],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[H],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:i,selector:n}=this;n.registerOption({id:e,display:t||e,...this.$attrs}),i&&n.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};var he=function(){var e=this,t=e.$createElement;return(e._self._c||t)("renderless-option",{attrs:{id:e.id,display:e.display,selected:e.selected}},[e._t("default")],2)};he._withStripped=!0;const ve=f({render:he,staticRenderFns:[]},void 0,fe,void 0,!1,void 0,!1,void 0,void 0,void 0),me={name:"refine-date-input",components:{Selector:ae,SelectorOption:ve,RefineFlavor:p},mixins:[U],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};var ge=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{as:"div",component:"inputs.date.relative.wrapper"}},[i("refine-flavor",{attrs:{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:e.amount},on:{input:e.updateAmount}}),e._v(" "),i("selector",{on:{"select-option":e.updateUnit}},e._l(e.units,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,display:t.display,selected:t.id===e.unit}})})),1),e._v(" "),i("selector",{on:{"select-option":e.updateModifier}},e._l(e.modifiers,(function(t){return i("selector-option",{key:t.id,attrs:{id:t.id,selected:t.id===e.modifier,display:t.display}})})),1)],1)};ge._withStripped=!0;const ye=f({render:ge,staticRenderFns:[]},void 0,me,void 0,!1,void 0,!1,void 0,void 0,void 0),be={name:"refine-option-input",components:{Selector:ae,SelectorOption:ve},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((i=>{i===e&&(t=!0)})),t}}};var we=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{attrs:{isMultiSelect:e.multiple},on:{"select-option":e.selectOption,"deselect-option":e.deselectOption}},e._l(e.options,(function(t){var n=t.id,r=t.display;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.isSelected(n)}})})),1)};we._withStripped=!0;const Oe=f({render:we,staticRenderFns:[]},void 0,be,void 0,!1,void 0,!1,void 0,void 0,void 0),xe={emits:["input"],components:{RefineFlavor:p},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};var _e=function(){var e=this,t=e.$createElement;return(e._self._c||t)("refine-flavor",{attrs:{as:"input",component:"inputs.date",type:"date",value:e.date},on:{input:e.handleInput}})};_e._withStripped=!0;const Ce=f({render:_e,staticRenderFns:[]},void 0,xe,void 0,!1,void 0,!1,void 0,void 0,void 0);var ke={RefineDateInput:k,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:m,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce},Se=Object.freeze({__proto__:null,default:ke,RefineDateInput:k,RefineDoubleDateInput:R,RefineDoubleNumberInput:b,RefineNumberInput:m,RefineOptionInput:Oe,RefineRelativeDateInput:ye,RefineTextInput:x,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,c.init(t)}},Re={install:(e,t={})=>{$e.install(e,t)}};const Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:ae}};var qe=function(){var e=this,t=e.$createElement;return(e._self._c||t)("selector",{on:{"select-option":e.selectOption}},[e._t("default")],2)};qe._withStripped=!0;const Be=f({render:qe,staticRenderFns:[]},void 0,Ie,void 0,!1,void 0,!1,void 0,void 0,void 0),je=f({},void 0,{props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new L(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return r&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null}},void 0,void 0,void 0,!1,void 0,void 0,void 0),Ee={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:ce,SelectorOption:ve,Selector:ae,...Se}};var Fe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-clause",e._b({scopedSlots:e._u([{key:"default",fn:function(t){var n=t.setValue;return[i("selector",{attrs:{innerClass:"refine-clause-selector"},on:{"select-option":e.switchClause}},e._l(e.meta.clauses,(function(t){var r=t.id,o=t.display,s=t.component,l=t.meta;return i("selector-option",{key:r,attrs:{id:r,display:o,selected:e.input.clause===r}},[s?i(s,e._b({tag:"component",on:{input:n}},"component",Object.assign({},e.meta,l,e.input),!1)):e._e()],1)})),1)]}}])},"renderless-clause",e.input,!1))};Fe._withStripped=!0;const Ae=f({render:Fe,staticRenderFns:[]},void 0,Ee,void 0,!1,void 0,!1,void 0,void 0,void 0),De={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Ae,RenderlessRefinement:pe,Selector:ae,SelectorOption:ve},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};var Pe=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("selector",{on:{"select-option":e.selectRefinement}},e._l(e.refinements,(function(t){var n=t.id,r=t.meta,o=t.display;return i("selector-option",{key:n,attrs:{id:n,display:o,selected:!!e.input[n]}},[i("renderless-refinement",{attrs:{id:n}},[i("clause",{attrs:{meta:r,input:e.input[n]},on:{"switch-clause":function(t){var i=t.id;return e.updateInput({clause:i},n)}}})],1)],1)})),1)};Pe._withStripped=!0;const Ve={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:Ae,Refinements:f({render:Pe,staticRenderFns:[]},void 0,De,void 0,!1,void 0,!1,void 0,void 0,void 0),SelectorOption:ve,Selector:ae,RefineFlavor:p}};var Ne=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("refine-flavor",{attrs:{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},scopedSlots:e._u([{key:"errors",fn:function(){return[e.errors.length>0?i("refine-flavor",{attrs:{as:"ul",component:"criterion.errors"}},e._l(e.errors,(function(t){return i("refine-flavor",{key:t,attrs:{as:"li",component:"criterion.errors.error"}},[e._v("\n "+e._s(t)+"\n ")])})),1):e._e()]},proxy:!0},{key:"selector",fn:function(){return[i("selector",{on:{"select-option":e.switchCondition}},e._l(e.conditions,(function(t){var n=t.id,r=t.display,o=t.meta,s=t.refinements;return i("selector-option",{key:n,attrs:{id:n,display:r,selected:e.conditionId===n}},[i("div",[i("clause",{attrs:{input:e.input,meta:o},on:{"switch-clause":e.switchClause}}),e._v(" "),s&&s.length>0?i("refinements",{attrs:{input:e.input,refinements:s}}):e._e()],1)])})),1)]},proxy:!0},{key:"remove",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"criterion.removeCriterionButton",type:"button"},on:{click:function(t){return t.preventDefault(),e.$emit("remove-condition")}}},[i("refine-flavor",{attrs:{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}})])],1)]},proxy:!0}])})};Ne._withStripped=!0;const Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>r?{}:{key:e},templateChildKey:e=>r?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var t;t=e.flavor,i(d,t)},components:{Criterion:f({render:Ne,staticRenderFns:[]},void 0,Ve,void 0,!1,void 0,!1,void 0,void 0,void 0),RefineFlavor:p,RenderlessCondition:ue,RenderlessQueryBuilder:de}};var Te=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("renderless-query-builder",{attrs:{blueprint:e.blueprint,conditions:e.conditions},on:{change:e.onChange},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.groupedBlueprint,r=t.replaceCriterion,o=t.insertCriterion,s=t.addGroup,l=t.removeCriterion,a=t.conditionFor;return[0===n.length?i("refine-flavor",e._b({attrs:{as:"div",component:"emptyGroup",order:["button","default"]},scopedSlots:e._u([{key:"button",fn:function(){return[i("refine-flavor",{attrs:{as:"button",component:"emptyGroup.addCriterionButton",tabindex:"0",type:"button"},on:{click:s}},[i("refine-flavor",{attrs:{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"emptyGroup.addCriterionButton.text"}},[e._v("\n Add a new condition\n ")])],1)]},proxy:!0}],null,!0)},"refine-flavor",{addGroup:s},!1)):i("refine-flavor",{attrs:{as:"div",component:"group.wrapper"}},[e._l(n,(function(t,s){return[i("refine-flavor",e._b({attrs:{as:"div",component:"group"}},"refine-flavor",e.templateChildKey("group-"+s),!1),[e._l(t,(function(t){return i("refine-flavor",{key:t.uid,attrs:{as:"div",component:"condition"}},[i("renderless-condition",e._b({scopedSlots:e._u([{key:"default",fn:function(n){var o=n.switchClause;return[i("criterion",{attrs:{conditionId:t.condition_id,conditions:e.conditions,errors:e.errors[t.uid],input:t.input},on:{"switch-clause":function(e){var t=e.id;return o(t)},"remove-condition":function(e){return l(t.position)},"switch-condition":function(e){return r(t.position,a(e))}}})]}}],null,!0)},"renderless-condition",a(Object.assign({},{id:t.condition_id},t)),!1))],1)})),e._v(" "),i("refine-flavor",{attrs:{as:"div",component:"group.addCriterionButton.wrapper"}},[i("refine-flavor",{attrs:{as:"button",component:"group.addCriterionButton",tabindex:"0",type:"button"},on:{click:function(e){return o(t[t.length-1].position)}}},[i("refine-flavor",{attrs:{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"}},[i("path",{attrs:{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"}})]),e._v(" "),i("refine-flavor",{attrs:{as:"span",component:"group.addCriterionButton.text"}},[e._v(" And")])],1)],1)],2),e._v(" "),i("refine-flavor",e._b({attrs:{as:"template",component:"group.divider",index:s,total:n.length}},"refine-flavor",e.templateChildKey("separator-"+s),!1))]})),e._v(" "),i("refine-flavor",{attrs:{as:"button",component:"addGroupButton",type:"button"},on:{click:s}},[e._v("\n Add an 'Or'\n ")])],2)]}}])})};Te._withStripped=!0;const Le=f({render:Te,staticRenderFns:[]},void 0,Me,void 0,!1,void 0,!1,void 0,void 0,void 0),Ge="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ze="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",He=`${Ge} ${ze} w-60 pl-3 py-2`,Ke={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Ge} ${ze} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${He} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:He,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:He}},Ue="bg-white relative text-left cursor-default",Qe=`${Ue} focus:outline-none pl-3 py-1`,We={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ue} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Qe} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Qe} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Qe}}};export{Be as ConditionSelector,Re as DatePickerPlugin,je as Query,Le as QueryBuilder,$e as RefinePlugin,ae as Selector,ve as SelectorOption,We as linearFlavor,Ke as tailwindFlavor}; | ||
//# sourceMappingURL=refine-vue.esm.min.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=require("vue");const n=Symbol();const o=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,o){const i=function(t,o,i=e.computed((()=>({})))){const r=e.inject(n),s=e.computed((()=>t(r)??{})),l=e.computed((()=>{const e={},t=i.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e.computed((()=>{const e={},t=i.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const o=s.value.style;return o&&(e.style="function"==typeof o?o(t):o),e}));return e.computed((()=>({component:s.value.component??o.value,props:a,extra:l})))}((e=>{const n=t.component.split(".");let o=e;for(const e of n)o=o?.[e];return o}),e.computed((()=>t.as)),e.computed((()=>({...o.attrs??{},...t.flavorOptions??{}}))));return()=>{const n=i.value,r=n.extra.value.order??t.order,s=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),l=o.slots;let a="string"==typeof n.component&&n.component.includes("-"),c=a?l:r.map((e=>l?.[e]?.())),d=e.isVue2?e.h(n.component,{scopedSlots:l,attrs:{...o.attrs,"data-flavor":t.component},props:s,on:o.listeners,...n.props.value},c):e.h(a?e.resolveComponent(n.component):n.component,{...o.attrs,"data-flavor":t.component,...s,...n.props.value},c);return n.extra.value.wrap?n.extra.value.wrap(d):d}}});var i={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:o}};i.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"input",component:"inputs.number",type:"number",value:r.currentValue,onInput:s.handleInputChange},s.metaAttributes),null,16,["value","onInput"])},i.__file="src/components/base/inputs/number-input.vue";var r={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:i,RefineFlavor:o}};r.render=function(e,n,o,i,r,s){const l=t.resolveComponent("number-input"),a=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(a,{as:"div",component:"inputs.number.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{meta:o.meta,value:o.value1,onInput:s.updateFirstValue},null,8,["meta","value","onInput"]),s.joinWord?(t.openBlock(),t.createBlock(a,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(s.joinWord),1)])),_:1})):t.createCommentVNode("v-if",!0),t.createVNode(l,{meta:o.meta,value:o.value2,onInput:s.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},r.__file="src/components/base/inputs/double-number-input.vue";var s={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:o}};s.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.text",type:"text",value:o.value,onInput:n[0]||(n[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},s.__file="src/components/base/inputs/text-input.vue";var l={name:"refine-date-input",components:{RefineFlavor:o},emits:["input"],props:{date1:{type:String,required:!1}}};l.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},l.__file="src/components/base/inputs/date-input.vue";var a={name:"refine-double-date-input",components:{RefineFlavor:o},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};a.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),t.createVNode(l,{as:"p",component:"inputs.date.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.joiner),1)])),_:1}),t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date2,onInput:n[1]||(n[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},a.__file="src/components/base/inputs/double-date-input.vue";var c=e=>"conjunction"===(null==e?void 0:e.type),d=Object.defineProperty,p=Object.defineProperties,u=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,v=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&v(e,n,t[n]);if(h)for(var n of h(t))f.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>p(e,u(t)),w=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},y=(e,t,n,o)=>{var i,r;const[s]=o||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:g({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(i=null==s?void 0:s.meta)?void 0:i.clauses[0])?void 0:r.id}}),uid:w()}},C=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:w()}},x=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?b(g({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||w()}):b(g({},e),{id:void 0,uid:w()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var o in e)m.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&h)for(var o of h(e))t.indexOf(o)<0&&f.call(e,o)&&(n[o]=e[o]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{c(t)?"or"===t.word&&e.push([]):e[e.length-1].push(b(g({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:o,refinements:i}=this.findCondition(t.id),r=y(o,1,n,i);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],o=t[e+1],i=c(o)&&"or"===o.word,r=c(n)&&"or"===n.word,s=i||!o,l=r||!n,a=l&&!s,d=l&&s;!n&&!o?this.blueprint=[]:d&&r?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:o,refinements:i}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:w()}}()),e.push(y(n.id,1,o,i)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:o}=this,i=y(t,n);return 0===o.length?o.push(i):o.splice(o.length,0,C(),i),this.blueprintChanged(),i}insertCriterion(e){const{blueprint:t,conditions:n}=this,o=n[0],{meta:i,refinements:r}=o;return t.splice(e+1,0,C(),y(o.id,1,i,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let o;return n.forEach((e=>{e.id===t&&(o=e)})),o}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,o){const{meta:i}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(i.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},o)}switchRefinement({uid:e,id:t},n,o){const i=this.findRefinement(t,o),r=this.findCriterion(e),s=g({},r.input);delete s[n],s[o]={clause:i.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const o=this.findCriterion(e);Object.keys(t).forEach((e=>{n?o.input[n][e]=t[e]:o.input[e]=t[e]})),this.blueprintChanged()}},O=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const o=this.options[this.options.length-1]||null,i=g({previousOption:o,nextOption:null},e);o&&(o.nextOption=i),this.options.push(i)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},k={name:"renderless-selector",data:()=>({selector:e.reactive(new O),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:c}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:c}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:o}=t.toggleOption(e);return o?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const B={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let S=1;var _={beforeCreate(){this.uid=S.toString(),S+=1}},V={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:o}};const N=t.createTextVNode(" Choose an option "),$=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);V.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.button",id:o.id,type:"button","aria-haspopup":"listbox","aria-expanded":o.isOpen,"aria-label":s.label(),ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:t.withCtx((()=>[0===o.display.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.button.placeholder"},{default:t.withCtx((()=>[N])),_:1})):(t.openBlock(),t.createBlock(l,{key:1,as:"span",component:"select.button.selected"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.display),1)])),_:1})),t.createVNode(l,{as:"span",component:"select.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[$])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},V.__file="src/components/base/selector/selector-button.vue";var I={name:"selector-listbox",mixins:[_],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:o}};I.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.listbox.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:o.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":o.selectedOption?s.createItemId(o.selectedOption.id):"",ref:"listBox",onKeydown:[t.withKeys(t.withModifiers(s.clearBuffer,["stop","prevent"]),["delete"]),n[0]||(n[0]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),n[1]||(n[1]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),n[3]||(n[3]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["escape"])),n[4]||(n[4]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["tab"])),n[5]||(n[5]=e=>s.handleKeypress(e))]},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default",{createItemId:s.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},I.__file="src/components/base/selector/selector-listbox.vue";var q={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:o}};const R=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);q.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:o.isHighlighted},role:"option",key:o.optionId,ref:"listItem",onMouseenter:n[0]||(n[0]=t=>e.$emit("mouseenter")),onMouseleave:n[1]||(n[1]=t=>e.$emit("mouseleave")),onClick:n[2]||(n[2]=t=>e.$emit("selected")),"aria-label":o.optionDisplay,"aria-selected":o.selected},{default:t.withCtx((()=>[t.createVNode(l,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:o.selected}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.optionDisplay),1)])),_:1},8,["flavorOptions"]),t.createVNode(l,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:o.isHighlighted}},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: check "),t.withDirectives(t.createVNode(l,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!o.selected},{default:t.withCtx((()=>[R])),_:1},8,["aria-hidden"]),[[t.vShow,o.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},q.__file="src/components/base/selector/selector-list-item.vue";var j={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:o}};const M=t.createTextVNode(" Choose an option "),E=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),A=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);j.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.multi.button",id:o.id,"aria-haspopup":"listbox","aria-label":s.label(),"aria-expanded":o.isOpen,ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:[n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["enter"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:t.withCtx((()=>[0===o.selectedOptions.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:t.withCtx((()=>[M])),_:1})):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(o.selectedOptions,(({id:n,display:o})=>(t.openBlock(),t.createBlock(l,{as:"span",component:"select.multi.button.selected",key:n},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o)+" ",1),t.createVNode(l,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:t.withModifiers((t=>e.$emit("deselect-option",n)),["prevent"])},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[E])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),t.createVNode(l,{as:"span",component:"select.multi.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[A])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},j.__file="src/components/base/selector/multi-selector-button.vue";var D={name:"selector",mixins:[_],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:o}=n;if("function"!=typeof o)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const i=e=>{t.contains(e.target)||o()};e[t.id]=i,document.addEventListener("click",i),document.addEventListener("touchstart",i)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const o=t.find((t=>t.display.toLowerCase().includes(e)));o&&(n.highlightOption(o),this.scrollIntoView(o.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:o,toggleOption:i}=t,{isMultiSelect:r}=this;r?i(e):(n(),o(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:j,RenderlessSelector:k,SelectorListItem:q,SelectorButton:V,SelectorListbox:I,RefineFlavor:o}};D.render=function(e,n,o,i,r,s){const l=t.resolveComponent("multi-selector-button"),a=t.resolveComponent("selector-button"),c=t.resolveComponent("selector-list-item"),d=t.resolveComponent("selector-listbox"),p=t.resolveComponent("refine-flavor"),u=t.resolveComponent("renderless-selector"),h=t.resolveDirective("click-away");return t.openBlock(),t.createBlock(u,{onSelectOption:n[0]||(n[0]=t=>e.$emit("select-option",t)),onDeselectOption:n[1]||(n[1]=t=>e.$emit("deselect-option",t))},{default:t.withCtx((({actions:n,isOpen:i,isClosed:r,selectedOptions:u,highlightedOption:m,options:f})=>[t.createVNode(p,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(p,{as:"div",component:"select",class:t.normalizeClass(o.innerClass),id:`listbox-${s.selectorId}`,"aria-labelledby":s.buttonId},{default:t.withCtx((()=>[o.isMultiSelect?(t.openBlock(),t.createBlock(l,{key:0,id:s.buttonId,isOpen:i,selectedOptions:u,onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),onDeselectOption:e=>s.deselectOption(e,n),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(t.openBlock(),t.createBlock(a,{key:1,id:s.buttonId,isOpen:i,display:u[0]?u[0].display:"",onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),t.createVNode(d,{selectedOption:u[0],isClosed:r,ref:"listBox",onHighlightNextOption:e=>s.highlightNextOption(n),onHighlightPreviousOption:e=>s.highlightPreviousOption(n),onSelectOption:e=>s.selectOption(m.id,n),onBufferChanged:e=>s.updateBuffer(e,f,n),onClose:e=>s.close(n)},{default:t.withCtx((({createItemId:e})=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f,(o=>(t.openBlock(),t.createBlock(c,{id:e(o.id),key:o.id,optionId:o.id,optionDisplay:o.display,selected:s.isSelected(o,u),isHighlighted:m&&o.id===m.id,ref_for:!0,ref:o.id,onMouseenter:e=>n.highlightOption(o),onMouseleave:e=>n.highlightOption(null),onSelected:e=>s.selectOption(o.id,n)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[h,n.close]]),t.createCommentVNode(" Custom options "),t.createVNode(p,{as:"div",component:"customOptions.wrapper"},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},D.__file="src/components/base/selector/selector.vue";var F={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 x(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:o,type:i,display:r,meta:s}=this.conditionsLookup[t];return{id:o,type:i,display:r,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:o,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:o,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:o.groupedBlueprint()}):null}},P={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("blueprint"),r=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let s;s=r?i.findCriterion(n.uid):i.addCriterion({id:t,depth:0});const l=(e,t)=>i.updateInput(s,e,t),a=e=>i.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{i.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{r||i.removeCriterion(i.indexOfCriterion(s))}));let c=null;return n?.condition?.meta?.clauses&&(c=n.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:c,criterion:s,updateInput:l,switchClause:a}):null})(t.id,t,n)},T={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("criterion"),r=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),a=e=>{r(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:t},s);const{clause:e,...o}=i.input;Object.keys(n).length>0&&0===Object.keys(o).length&&r({...n},s)}return e.onUnmounted((()=>{l||i.input.clause===t&&r({clause:void 0},s)})),()=>o.slots.default?o.slots.default({setValue:a,...i.input}):null})(t.clause,t,n)},L={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()}},H={name:"selector-option",mixins:[B],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[B],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:o}=this;o.registerOption({id:e,display:t||e,...this.$attrs}),n&&o.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};H.render=function(e,n,o,i,r,s){const l=t.resolveComponent("renderless-option");return t.openBlock(),t.createBlock(l,{id:e.id,display:e.display,selected:e.selected},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["id","display","selected"])},H.__file="src/components/base/selector/selector-option.vue";var K={name:"refine-date-input",components:{Selector:D,SelectorOption:H,RefineFlavor:o},mixins:[_],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]})}}};K.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),a=t.resolveComponent("selector-option"),c=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.relative.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:o.amount,onInput:s.updateAmount},null,8,["value","onInput"]),t.createVNode(c,{onSelectOption:s.updateUnit},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.units,(e=>(t.openBlock(),t.createBlock(a,{key:e.id,id:e.id,display:e.display,selected:e.id===o.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),t.createVNode(c,{onSelectOption:s.updateModifier},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.modifiers,(e=>(t.openBlock(),t.createBlock(a,{key:e.id,id:e.id,selected:e.id===o.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},K.__file="src/components/base/inputs/relative-date-input.vue";var z={name:"refine-option-input",components:{Selector:D,SelectorOption:H},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};z.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),a=t.resolveComponent("selector");return t.openBlock(),t.createBlock(a,{isMultiSelect:o.multiple,onSelectOption:s.selectOption,onDeselectOption:s.deselectOption},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.options,(({id:e,display:n})=>(t.openBlock(),t.createBlock(l,{key:e,id:e,display:n,selected:s.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},z.__file="src/components/base/inputs/option-input.vue";var G={emits:["input"],components:{RefineFlavor:o},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};G.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.date",type:"date",value:o.date,onInput:s.handleInput},null,8,["value","onInput"])},G.__file="src/components/base/inputs/native-date-picker.vue";var U={RefineDateInput:l,RefineDoubleDateInput:a,RefineDoubleNumberInput:r,RefineNumberInput:i,RefineOptionInput:z,RefineRelativeDateInput:K,RefineTextInput:s,RefineNativeDatePicker:G},W=Object.freeze({__proto__:null,default:U,RefineDateInput:l,RefineDoubleDateInput:a,RefineDoubleNumberInput:r,RefineNumberInput:i,RefineOptionInput:z,RefineRelativeDateInput:K,RefineTextInput:s,RefineNativeDatePicker:G}),Q={install:(e,t={})=>{t={DatePicker:G,...t},e.component("refine-date-picker",t.DatePicker)}},Y={install:(e,t={})=>{Q.install(e,t)}},Z={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:D}};Z.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{onSelectOption:s.selectOption},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["onSelectOption"])},Z.__file="src/components/base/condition-selector/condition-selector.vue";var J={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 x(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null},__file:"src/components/renderless/query.vue"},X={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:T,SelectorOption:H,Selector:D,...W}};X.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),a=t.resolveComponent("selector"),c=t.resolveComponent("renderless-clause");return t.openBlock(),t.createBlock(c,t.normalizeProps(t.guardReactiveProps(o.input)),{default:t.withCtx((({setValue:e})=>[t.createCommentVNode(" clause selector "),t.createVNode(a,{onSelectOption:s.switchClause,innerClass:"refine-clause-selector"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.meta.clauses,(({id:n,display:i,component:r,meta:s})=>(t.openBlock(),t.createBlock(l,{key:n,id:n,display:i,selected:o.input.clause===n},{default:t.withCtx((()=>[r?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r),t.mergeProps({key:0},{...o.meta,...s,...o.input},{onInput:e}),null,16,["onInput"])):t.createCommentVNode("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},X.__file="src/components/base/query-builder/clause.vue";var ee={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:X,RenderlessRefinement:L,Selector:D,SelectorOption:H},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};ee.render=function(e,n,o,i,r,s){const l=t.resolveComponent("clause"),a=t.resolveComponent("renderless-refinement"),c=t.resolveComponent("selector-option"),d=t.resolveComponent("selector");return t.openBlock(),t.createBlock(d,{onSelectOption:s.selectRefinement},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.refinements,(({id:e,meta:n,display:i})=>(t.openBlock(),t.createBlock(c,{key:e,id:e,display:i,selected:!!o.input[e]},{default:t.withCtx((()=>[t.createVNode(a,{id:e},{default:t.withCtx((()=>[t.createVNode(l,{meta:n,input:o.input[e],onSwitchClause:({id:t})=>s.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},ee.__file="src/components/base/query-builder/refinements.vue";var te={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:X,Refinements:ee,SelectorOption:H,Selector:D,RefineFlavor:o}};const ne=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);te.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),a=t.resolveComponent("clause"),c=t.resolveComponent("refinements"),d=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:t.withCtx((()=>[o.errors.length>0?(t.openBlock(),t.createBlock(l,{key:0,as:"ul",component:"criterion.errors"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.errors,(e=>(t.openBlock(),t.createBlock(l,{as:"li",component:"criterion.errors.error",key:e},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e),1)])),_:2},1024)))),128))])),_:1})):t.createCommentVNode("v-if",!0)])),selector:t.withCtx((()=>[t.createVNode(p,{onSelectOption:s.switchCondition},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.conditions,(({id:e,display:n,meta:i,refinements:r})=>(t.openBlock(),t.createBlock(d,{key:e,id:e,display:n,selected:o.conditionId===e},{default:t.withCtx((()=>[t.createElementVNode("div",null,[t.createVNode(a,{input:o.input,meta:i,onSwitchClause:s.switchClause},null,8,["input","meta","onSwitchClause"]),r&&r.length>0?(t.openBlock(),t.createBlock(c,{key:0,input:o.input,refinements:r},null,8,["input","refinements"])):t.createCommentVNode("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"criterion.removeCriterionButton",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[ne])),_:1})])),_:1})])),_:1})},te.__file="src/components/base/query-builder/criterion.vue";var oe={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var o;o=t.flavor,e.provide(n,o)},components:{Criterion:te,RefineFlavor:o,RenderlessCondition:P,RenderlessQueryBuilder:F}};const ie=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),re=t.createTextVNode(" Add a new condition "),se=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),le=t.createTextVNode(" And"),ae=t.createTextVNode(" Add an 'Or' ");oe.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),a=t.resolveComponent("criterion"),c=t.resolveComponent("renderless-condition"),d=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(d,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:d,conditionFor:p})=>[t.createCommentVNode(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(t.openBlock(),t.createBlock(l,t.mergeProps({key:0,as:"div",component:"emptyGroup"},{addGroup:r},{order:["button","default"]}),{button:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"emptyGroup.addCriterionButton",onClick:r,tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[ie])),_:1}),t.createVNode(l,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:t.withCtx((()=>[re])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(t.openBlock(),t.createBlock(l,{key:1,as:"div",component:"group.wrapper"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,((r,u)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(l,t.mergeProps({as:"div",component:"group"},s.templateChildKey(`group-${u}`)),{default:t.withCtx((()=>[t.createCommentVNode(" This really should be named criterion, as that's what it is. "),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r,(e=>(t.openBlock(),t.createBlock(l,{as:"div",component:"condition",key:e.uid},{default:t.withCtx((()=>[t.createVNode(c,t.normalizeProps(t.guardReactiveProps(p({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(a,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>d(e.position),onSwitchCondition:t=>n(e.position,p(t)),conditionId:e.condition_id,conditions:o.conditions,errors:o.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),t.createVNode(l,{as:"div",component:"group.addCriterionButton.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"group.addCriterionButton",onClick:e=>i(r[r.length-1].position),tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),t.createCommentVNode(" Divider between groups. Blank by default, but used in Nova. "),t.createVNode(l,t.mergeProps({as:"template",component:"group.divider",index:u,total:e.length},s.templateChildKey(`separator-${u}`)),null,16,["index","total"])],64)))),256)),t.createVNode(l,{as:"button",component:"addGroupButton",onClick:r,type:"button"},{default:t.withCtx((()=>[ae])),_:2},1032,["onClick"])])),_:2},1024)),t.createCommentVNode(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},oe.__file="src/components/base/query-builder/query-builder.vue";const ce="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",de="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",pe=`${ce} ${de} w-60 pl-3 py-2`,ue={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{class:`${ce} ${de} h-9 h-full py-5 px-2 leading-normal box-border`,relative:{class:`${pe} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:pe,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:pe}}},he="bg-white relative text-left cursor-default",me=`${he} focus:outline-none pl-3 py-1`,fe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${he} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:me}}};exports.ConditionSelector=Z,exports.DatePickerPlugin=Y,exports.Query=J,exports.QueryBuilder=oe,exports.RefinePlugin=Q,exports.Selector=D,exports.SelectorOption=H,exports.linearFlavor=fe,exports.tailwindFlavor=ue; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=require("vue");const n=Symbol();let o={};var i={init(e){o=e},get:(e,t=null)=>o?.[e]??t,set(e,t){o[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,o){let r=i.get("showLocators");const s=function(t,o,i=e.computed((()=>({})))){const r=e.inject(n),s=e.computed((()=>t(r)??{})),l=e.computed((()=>{const e={},t=i.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),c=e.computed((()=>{const e={},t=i.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const o=s.value.style;return o&&(e.style="function"==typeof o?o(t):o),e}));return e.computed((()=>({component:s.value.component??o.value,props:c,extra:l})))}((e=>{const n=t.component.split(".");let o=e;for(const e of n)o=o?.[e];return"string"!=typeof o&&"function"!=typeof o||(o={class:o}),o}),e.computed((()=>t.as)),e.computed((()=>({...o.attrs??{},...t.flavorOptions??{}}))));return()=>{const n=s.value,i=n.extra.value.order??t.order,l=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),c=o.slots;let a="string"==typeof n.component&&n.component.includes("-"),d=a?c:i.map((e=>c?.[e]?.())),p=e.isVue2?e.h(n.component,{scopedSlots:c,attrs:{...r&&{"data-locator":t.component},...o.attrs},props:l,on:o.listeners,...n.props.value},d):e.h(a?e.resolveComponent(n.component):n.component,{...r&&{"data-locator":t.component},...o.attrs,...l,...n.props.value},d);return n.extra.value.wrap?n.extra.value.wrap(p):p}}});var s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:r}};s.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"input",component:"inputs.number",type:"number",value:r.currentValue,onInput:s.handleInputChange},s.metaAttributes),null,16,["value","onInput"])},s.__file="src/components/base/inputs/number-input.vue";var l={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:s,RefineFlavor:r}};l.render=function(e,n,o,i,r,s){const l=t.resolveComponent("number-input"),c=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(c,{as:"div",component:"inputs.number.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{meta:o.meta,value:o.value1,onInput:s.updateFirstValue},null,8,["meta","value","onInput"]),s.joinWord?(t.openBlock(),t.createBlock(c,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(s.joinWord),1)])),_:1})):t.createCommentVNode("v-if",!0),t.createVNode(l,{meta:o.meta,value:o.value2,onInput:s.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},l.__file="src/components/base/inputs/double-number-input.vue";var c={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r}};c.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.text",type:"text",value:o.value,onInput:n[0]||(n[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},c.__file="src/components/base/inputs/text-input.vue";var a={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}}};a.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},a.__file="src/components/base/inputs/date-input.vue";var d={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};d.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),t.createVNode(l,{as:"p",component:"inputs.date.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.joiner),1)])),_:1}),t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date2,onInput:n[1]||(n[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},d.__file="src/components/base/inputs/double-date-input.vue";var p=e=>"conjunction"===(null==e?void 0:e.type),u=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))v.call(t,n)&&b(e,n,t[n]);if(f)for(var n of f(t))g.call(t,n)&&b(e,n,t[n]);return e},y=(e,t)=>h(e,m(t)),C=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},x=(e,t,n,o)=>{var i,r;const[s]=o||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:w({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(i=null==s?void 0:s.meta)?void 0:i.clauses[0])?void 0:r.id}}),uid:C()}},O=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:C()}},k=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?y(w({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||C()}):y(w({},e),{id:void 0,uid:C()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var o in e)v.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&f)for(var o of f(e))t.indexOf(o)<0&&g.call(e,o)&&(n[o]=e[o]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{p(t)?"or"===t.word&&e.push([]):e[e.length-1].push(y(w({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:o,refinements:i}=this.findCondition(t.id),r=x(o,1,n,i);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],o=t[e+1],i=p(o)&&"or"===o.word,r=p(n)&&"or"===n.word,s=i||!o,l=r||!n,c=l&&!s,a=l&&s;!n&&!o?this.blueprint=[]:a&&r?t.splice(e-1,2):a&&!n||c?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:o,refinements:i}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:C()}}()),e.push(x(n.id,1,o,i)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:o}=this,i=x(t,n);return 0===o.length?o.push(i):o.splice(o.length,0,O(),i),this.blueprintChanged(),i}insertCriterion(e){const{blueprint:t,conditions:n}=this,o=n[0],{meta:i,refinements:r}=o;return t.splice(e+1,0,O(),x(o.id,1,i,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let o;return n.forEach((e=>{e.id===t&&(o=e)})),o}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,o){const{meta:i}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(i.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},o)}switchRefinement({uid:e,id:t},n,o){const i=this.findRefinement(t,o),r=this.findCriterion(e),s=w({},r.input);delete s[n],s[o]={clause:i.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const o=this.findCriterion(e);Object.keys(t).forEach((e=>{n?o.input[n][e]=t[e]:o.input[e]=t[e]})),this.blueprintChanged()}},B=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const o=this.options[this.options.length-1]||null,i=w({previousOption:o,nextOption:null},e);o&&(o.nextOption=i),this.options.push(i)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},S={name:"renderless-selector",data:()=>({selector:e.reactive(new B),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:o}=t.toggleOption(e);return o?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const _={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let V=1;var N={beforeCreate(){this.uid=V.toString(),V+=1}},$={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};const I=t.createTextVNode(" Choose an option "),q=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);$.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.button",id:o.id,type:"button","aria-haspopup":"listbox","aria-expanded":o.isOpen,"aria-label":s.label(),ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:t.withCtx((()=>[0===o.display.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.button.placeholder"},{default:t.withCtx((()=>[I])),_:1})):(t.openBlock(),t.createBlock(l,{key:1,as:"span",component:"select.button.selected"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.display),1)])),_:1})),t.createVNode(l,{as:"span",component:"select.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[q])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},$.__file="src/components/base/selector/selector-button.vue";var R={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r}};R.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.listbox.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:o.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":o.selectedOption?s.createItemId(o.selectedOption.id):"",ref:"listBox",onKeydown:[t.withKeys(t.withModifiers(s.clearBuffer,["stop","prevent"]),["delete"]),n[0]||(n[0]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),n[1]||(n[1]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),n[3]||(n[3]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["escape"])),n[4]||(n[4]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["tab"])),n[5]||(n[5]=e=>s.handleKeypress(e))]},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default",{createItemId:s.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},R.__file="src/components/base/selector/selector-listbox.vue";var j={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};const M=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);j.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:o.isHighlighted},role:"option",key:o.optionId,ref:"listItem",onMouseenter:n[0]||(n[0]=t=>e.$emit("mouseenter")),onMouseleave:n[1]||(n[1]=t=>e.$emit("mouseleave")),onClick:n[2]||(n[2]=t=>e.$emit("selected")),"aria-label":o.optionDisplay,"aria-selected":o.selected},{default:t.withCtx((()=>[t.createVNode(l,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:o.selected}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.optionDisplay),1)])),_:1},8,["flavorOptions"]),t.createVNode(l,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:o.isHighlighted}},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: check "),t.withDirectives(t.createVNode(l,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!o.selected},{default:t.withCtx((()=>[M])),_:1},8,["aria-hidden"]),[[t.vShow,o.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},j.__file="src/components/base/selector/selector-list-item.vue";var E={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};const A=t.createTextVNode(" Choose an option "),D=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),P=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);E.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.multi.button",id:o.id,"aria-haspopup":"listbox","aria-label":s.label(),"aria-expanded":o.isOpen,ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:[n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["enter"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:t.withCtx((()=>[0===o.selectedOptions.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:t.withCtx((()=>[A])),_:1})):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(o.selectedOptions,(({id:n,display:o})=>(t.openBlock(),t.createBlock(l,{as:"span",component:"select.multi.button.selected",key:n},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o)+" ",1),t.createVNode(l,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:t.withModifiers((t=>e.$emit("deselect-option",n)),["prevent"])},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[D])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),t.createVNode(l,{as:"span",component:"select.multi.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[P])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},E.__file="src/components/base/selector/multi-selector-button.vue";var F={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:o}=n;if("function"!=typeof o)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const i=e=>{t.contains(e.target)||o()};e[t.id]=i,document.addEventListener("click",i),document.addEventListener("touchstart",i)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const o=t.find((t=>t.display.toLowerCase().includes(e)));o&&(n.highlightOption(o),this.scrollIntoView(o.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:o,toggleOption:i}=t,{isMultiSelect:r}=this;r?i(e):(n(),o(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:E,RenderlessSelector:S,SelectorListItem:j,SelectorButton:$,SelectorListbox:R,RefineFlavor:r}};F.render=function(e,n,o,i,r,s){const l=t.resolveComponent("multi-selector-button"),c=t.resolveComponent("selector-button"),a=t.resolveComponent("selector-list-item"),d=t.resolveComponent("selector-listbox"),p=t.resolveComponent("refine-flavor"),u=t.resolveComponent("renderless-selector"),h=t.resolveDirective("click-away");return t.openBlock(),t.createBlock(u,{onSelectOption:n[0]||(n[0]=t=>e.$emit("select-option",t)),onDeselectOption:n[1]||(n[1]=t=>e.$emit("deselect-option",t))},{default:t.withCtx((({actions:n,isOpen:i,isClosed:r,selectedOptions:u,highlightedOption:m,options:f})=>[t.createVNode(p,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(p,{as:"div",component:"select",class:t.normalizeClass(o.innerClass),id:`listbox-${s.selectorId}`,"aria-labelledby":s.buttonId},{default:t.withCtx((()=>[o.isMultiSelect?(t.openBlock(),t.createBlock(l,{key:0,id:s.buttonId,isOpen:i,selectedOptions:u,onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),onDeselectOption:e=>s.deselectOption(e,n),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(t.openBlock(),t.createBlock(c,{key:1,id:s.buttonId,isOpen:i,display:u[0]?u[0].display:"",onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),t.createVNode(d,{selectedOption:u[0],isClosed:r,ref:"listBox",onHighlightNextOption:e=>s.highlightNextOption(n),onHighlightPreviousOption:e=>s.highlightPreviousOption(n),onSelectOption:e=>s.selectOption(m.id,n),onBufferChanged:e=>s.updateBuffer(e,f,n),onClose:e=>s.close(n)},{default:t.withCtx((({createItemId:e})=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f,(o=>(t.openBlock(),t.createBlock(a,{id:e(o.id),key:o.id,optionId:o.id,optionDisplay:o.display,selected:s.isSelected(o,u),isHighlighted:m&&o.id===m.id,ref_for:!0,ref:o.id,onMouseenter:e=>n.highlightOption(o),onMouseleave:e=>n.highlightOption(null),onSelected:e=>s.selectOption(o.id,n)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[h,n.close]]),t.createCommentVNode(" Custom options "),t.createVNode(p,{as:"div",component:"customOptions.wrapper"},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},F.__file="src/components/base/selector/selector.vue";var T={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new k(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:o,type:i,display:r,meta:s}=this.conditionsLookup[t];return{id:o,type:i,display:r,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:o,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:o,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:o.groupedBlueprint()}):null}},L={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("blueprint"),r=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let s;s=r?i.findCriterion(n.uid):i.addCriterion({id:t,depth:0});const l=(e,t)=>i.updateInput(s,e,t),c=e=>i.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{i.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{r||i.removeCriterion(i.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:c}):null})(t.id,t,n)},H={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("criterion"),r=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),c=e=>{r(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:t},s);const{clause:e,...o}=i.input;Object.keys(n).length>0&&0===Object.keys(o).length&&r({...n},s)}return e.onUnmounted((()=>{l||i.input.clause===t&&r({clause:void 0},s)})),()=>o.slots.default?o.slots.default({setValue:c,...i.input}):null})(t.clause,t,n)},K={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}},z={name:"selector-option",mixins:[_],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[_],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:o}=this;o.registerOption({id:e,display:t||e,...this.$attrs}),n&&o.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}}};z.render=function(e,n,o,i,r,s){const l=t.resolveComponent("renderless-option");return t.openBlock(),t.createBlock(l,{id:e.id,display:e.display,selected:e.selected},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["id","display","selected"])},z.__file="src/components/base/selector/selector-option.vue";var G={name:"refine-date-input",components:{Selector:F,SelectorOption:z,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};G.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("selector-option"),a=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.relative.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:o.amount,onInput:s.updateAmount},null,8,["value","onInput"]),t.createVNode(a,{onSelectOption:s.updateUnit},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.units,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,display:e.display,selected:e.id===o.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),t.createVNode(a,{onSelectOption:s.updateModifier},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.modifiers,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,selected:e.id===o.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},G.__file="src/components/base/inputs/relative-date-input.vue";var U={name:"refine-option-input",components:{Selector:F,SelectorOption:z},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};U.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector");return t.openBlock(),t.createBlock(c,{isMultiSelect:o.multiple,onSelectOption:s.selectOption,onDeselectOption:s.deselectOption},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.options,(({id:e,display:n})=>(t.openBlock(),t.createBlock(l,{key:e,id:e,display:n,selected:s.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},U.__file="src/components/base/inputs/option-input.vue";var W={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};W.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.date",type:"date",value:o.date,onInput:s.handleInput},null,8,["value","onInput"])},W.__file="src/components/base/inputs/native-date-picker.vue";var Q={RefineDateInput:a,RefineDoubleDateInput:d,RefineDoubleNumberInput:l,RefineNumberInput:s,RefineOptionInput:U,RefineRelativeDateInput:G,RefineTextInput:c,RefineNativeDatePicker:W},Y=Object.freeze({__proto__:null,default:Q,RefineDateInput:a,RefineDoubleDateInput:d,RefineDoubleNumberInput:l,RefineNumberInput:s,RefineOptionInput:U,RefineRelativeDateInput:G,RefineTextInput:c,RefineNativeDatePicker:W}),Z={install:(e,t={})=>{t={DatePicker:W,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,i.init(t)}},J={install:(e,t={})=>{Z.install(e,t)}},X={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:F}};X.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{onSelectOption:s.selectOption},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["onSelectOption"])},X.__file="src/components/base/condition-selector/condition-selector.vue";var ee={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new k(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null},__file:"src/components/renderless/query.vue"},te={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:H,SelectorOption:z,Selector:F,...Y}};te.render=function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector"),a=t.resolveComponent("renderless-clause");return t.openBlock(),t.createBlock(a,t.normalizeProps(t.guardReactiveProps(o.input)),{default:t.withCtx((({setValue:e})=>[t.createCommentVNode(" clause selector "),t.createVNode(c,{onSelectOption:s.switchClause,innerClass:"refine-clause-selector"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.meta.clauses,(({id:n,display:i,component:r,meta:s})=>(t.openBlock(),t.createBlock(l,{key:n,id:n,display:i,selected:o.input.clause===n},{default:t.withCtx((()=>[r?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r),t.mergeProps({key:0},{...o.meta,...s,...o.input},{onInput:e}),null,16,["onInput"])):t.createCommentVNode("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},te.__file="src/components/base/query-builder/clause.vue";var ne={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:te,RenderlessRefinement:K,Selector:F,SelectorOption:z},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};ne.render=function(e,n,o,i,r,s){const l=t.resolveComponent("clause"),c=t.resolveComponent("renderless-refinement"),a=t.resolveComponent("selector-option"),d=t.resolveComponent("selector");return t.openBlock(),t.createBlock(d,{onSelectOption:s.selectRefinement},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.refinements,(({id:e,meta:n,display:i})=>(t.openBlock(),t.createBlock(a,{key:e,id:e,display:i,selected:!!o.input[e]},{default:t.withCtx((()=>[t.createVNode(c,{id:e},{default:t.withCtx((()=>[t.createVNode(l,{meta:n,input:o.input[e],onSwitchClause:({id:t})=>s.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},ne.__file="src/components/base/query-builder/refinements.vue";var oe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:te,Refinements:ne,SelectorOption:z,Selector:F,RefineFlavor:r}};const ie=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);oe.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("clause"),a=t.resolveComponent("refinements"),d=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:t.withCtx((()=>[o.errors.length>0?(t.openBlock(),t.createBlock(l,{key:0,as:"ul",component:"criterion.errors"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.errors,(e=>(t.openBlock(),t.createBlock(l,{as:"li",component:"criterion.errors.error",key:e},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e),1)])),_:2},1024)))),128))])),_:1})):t.createCommentVNode("v-if",!0)])),selector:t.withCtx((()=>[t.createVNode(p,{onSelectOption:s.switchCondition},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.conditions,(({id:e,display:n,meta:i,refinements:r})=>(t.openBlock(),t.createBlock(d,{key:e,id:e,display:n,selected:o.conditionId===e},{default:t.withCtx((()=>[t.createElementVNode("div",null,[t.createVNode(c,{input:o.input,meta:i,onSwitchClause:s.switchClause},null,8,["input","meta","onSwitchClause"]),r&&r.length>0?(t.openBlock(),t.createBlock(a,{key:0,input:o.input,refinements:r},null,8,["input","refinements"])):t.createCommentVNode("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"criterion.removeCriterionButton",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[ie])),_:1})])),_:1})])),_:1})},oe.__file="src/components/base/query-builder/criterion.vue";var re={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var o;o=t.flavor,e.provide(n,o)},components:{Criterion:oe,RefineFlavor:r,RenderlessCondition:L,RenderlessQueryBuilder:T}};const se=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),le=t.createTextVNode(" Add a new condition "),ce=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),ae=t.createTextVNode(" And"),de=t.createTextVNode(" Add an 'Or' ");re.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("criterion"),a=t.resolveComponent("renderless-condition"),d=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(d,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:d,conditionFor:p})=>[t.createCommentVNode(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(t.openBlock(),t.createBlock(l,t.mergeProps({key:0,as:"div",component:"emptyGroup"},{addGroup:r},{order:["button","default"]}),{button:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"emptyGroup.addCriterionButton",onClick:r,tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(t.openBlock(),t.createBlock(l,{key:1,as:"div",component:"group.wrapper"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,((r,u)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(l,t.mergeProps({as:"div",component:"group"},s.templateChildKey(`group-${u}`)),{default:t.withCtx((()=>[t.createCommentVNode(" This really should be named criterion, as that's what it is. "),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r,(e=>(t.openBlock(),t.createBlock(l,{as:"div",component:"condition",key:e.uid},{default:t.withCtx((()=>[t.createVNode(a,t.normalizeProps(t.guardReactiveProps(p({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(c,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>d(e.position),onSwitchCondition:t=>n(e.position,p(t)),conditionId:e.condition_id,conditions:o.conditions,errors:o.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),t.createVNode(l,{as:"div",component:"group.addCriterionButton.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"group.addCriterionButton",onClick:e=>i(r[r.length-1].position),tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[ce])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[ae])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),t.createCommentVNode(" Divider between groups. Blank by default, but used in Nova. "),t.createVNode(l,t.mergeProps({as:"template",component:"group.divider",index:u,total:e.length},s.templateChildKey(`separator-${u}`)),null,16,["index","total"])],64)))),256)),t.createVNode(l,{as:"button",component:"addGroupButton",onClick:r,type:"button"},{default:t.withCtx((()=>[de])),_:2},1032,["onClick"])])),_:2},1024)),t.createCommentVNode(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},re.__file="src/components/base/query-builder/query-builder.vue";const pe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ue="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",he=`${pe} ${ue} w-60 pl-3 py-2`,me={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${pe} ${ue} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${he} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:he,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:he}},fe="bg-white relative text-left cursor-default",ve=`${fe} focus:outline-none pl-3 py-1`,ge={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${fe} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${ve} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${ve} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:ve}}};exports.ConditionSelector=X,exports.DatePickerPlugin=J,exports.Query=ee,exports.QueryBuilder=re,exports.RefinePlugin=Z,exports.Selector=F,exports.SelectorOption=z,exports.linearFlavor=ge,exports.tailwindFlavor=me; | ||
//# sourceMappingURL=refine-vue.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=require("vue");const n=Symbol(),o=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,o){const i=function(t,o,i=e.computed((()=>({})))){const r=e.inject(n),s=e.computed((()=>t(r)??{})),l=e.computed((()=>{const e={},t=i.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),c=e.computed((()=>{const e={},t=i.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const o=s.value.style;return o&&(e.style="function"==typeof o?o(t):o),e}));return e.computed((()=>({component:s.value.component??o.value,props:c,extra:l})))}((e=>{const n=t.component.split(".");let o=e;for(const e of n)o=o?.[e];return o}),e.computed((()=>t.as)),e.computed((()=>({...o.attrs??{},...t.flavorOptions??{}}))));return()=>{const n=i.value,r=n.extra.value.order??t.order,s=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),l=o.slots;let c="string"==typeof n.component&&n.component.includes("-"),a=c?l:r.map((e=>l?.[e]?.())),d=e.isVue2?e.h(n.component,{scopedSlots:l,attrs:{...o.attrs,"data-flavor":t.component},props:s,on:o.listeners,...n.props.value},a):e.h(c?e.resolveComponent(n.component):n.component,{...o.attrs,"data-flavor":t.component,...s,...n.props.value},a);return n.extra.value.wrap?n.extra.value.wrap(d):d}}});var i={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:o},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"input",component:"inputs.number",type:"number",value:r.currentValue,onInput:s.handleInputChange},s.metaAttributes),null,16,["value","onInput"])},__file:"src/components/base/inputs/number-input.vue"},r={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:i,RefineFlavor:o},render:function(e,n,o,i,r,s){const l=t.resolveComponent("number-input"),c=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(c,{as:"div",component:"inputs.number.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{meta:o.meta,value:o.value1,onInput:s.updateFirstValue},null,8,["meta","value","onInput"]),s.joinWord?(t.openBlock(),t.createBlock(c,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(s.joinWord),1)])),_:1})):t.createCommentVNode("v-if",!0),t.createVNode(l,{meta:o.meta,value:o.value2,onInput:s.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},__file:"src/components/base/inputs/double-number-input.vue"},s={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:o},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.text",type:"text",value:o.value,onInput:n[0]||(n[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},__file:"src/components/base/inputs/text-input.vue"},l={name:"refine-date-input",components:{RefineFlavor:o},emits:["input"],props:{date1:{type:String,required:!1}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},__file:"src/components/base/inputs/date-input.vue"},c={name:"refine-double-date-input",components:{RefineFlavor:o},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),t.createVNode(l,{as:"p",component:"inputs.date.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.joiner),1)])),_:1}),t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date2,onInput:n[1]||(n[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},__file:"src/components/base/inputs/double-date-input.vue"},a=e=>"conjunction"===(null==e?void 0:e.type),d=Object.defineProperty,p=Object.defineProperties,u=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,v=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&v(e,n,t[n]);if(h)for(var n of h(t))f.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>p(e,u(t)),w=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},y=(e,t,n,o)=>{var i,r;const[s]=o||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:g({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(i=null==s?void 0:s.meta)?void 0:i.clauses[0])?void 0:r.id}}),uid:w()}},C=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:w()}},x=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?b(g({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||w()}):b(g({},e),{id:void 0,uid:w()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var o in e)m.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&h)for(var o of h(e))t.indexOf(o)<0&&f.call(e,o)&&(n[o]=e[o]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{a(t)?"or"===t.word&&e.push([]):e[e.length-1].push(b(g({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:o,refinements:i}=this.findCondition(t.id),r=y(o,1,n,i);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],o=t[e+1],i=a(o)&&"or"===o.word,r=a(n)&&"or"===n.word,s=i||!o,l=r||!n,c=l&&!s,d=l&&s;n||o?d&&r?t.splice(e-1,2):d&&!n||c?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:o,refinements:i}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:w()}}()),e.push(y(n.id,1,o,i)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:o}=this,i=y(t,n);return 0===o.length?o.push(i):o.splice(o.length,0,C(),i),this.blueprintChanged(),i}insertCriterion(e){const{blueprint:t,conditions:n}=this,o=n[0],{meta:i,refinements:r}=o;return t.splice(e+1,0,C(),y(o.id,1,i,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let o;return n.forEach((e=>{e.id===t&&(o=e)})),o}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,o){const{meta:i}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(i.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},o)}switchRefinement({uid:e,id:t},n,o){const i=this.findRefinement(t,o),r=this.findCriterion(e),s=g({},r.input);delete s[n],s[o]={clause:i.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const o=this.findCriterion(e);Object.keys(t).forEach((e=>{n?o.input[n][e]=t[e]:o.input[e]=t[e]})),this.blueprintChanged()}},O=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++)if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const o=this.options[this.options.length-1]||null,i=g({previousOption:o,nextOption:null},e);o&&(o.nextOption=i),this.options.push(i)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},k={name:"renderless-selector",data:()=>({selector:e.reactive(new O),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:o}=t.toggleOption(e);return o?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const B={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let S=1;var _={beforeCreate(){this.uid=S.toString(),S+=1}},V={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:o}};const N=t.createTextVNode(" Choose an option "),$=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);V.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.button",id:o.id,type:"button","aria-haspopup":"listbox","aria-expanded":o.isOpen,"aria-label":s.label(),ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:t.withCtx((()=>[0===o.display.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.button.placeholder"},{default:t.withCtx((()=>[N])),_:1})):(t.openBlock(),t.createBlock(l,{key:1,as:"span",component:"select.button.selected"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.display),1)])),_:1})),t.createVNode(l,{as:"span",component:"select.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[$])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},V.__file="src/components/base/selector/selector-button.vue";var I={name:"selector-listbox",mixins:[_],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:o},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.listbox.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:o.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":o.selectedOption?s.createItemId(o.selectedOption.id):"",ref:"listBox",onKeydown:[t.withKeys(t.withModifiers(s.clearBuffer,["stop","prevent"]),["delete"]),n[0]||(n[0]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),n[1]||(n[1]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),n[3]||(n[3]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["escape"])),n[4]||(n[4]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["tab"])),n[5]||(n[5]=e=>s.handleKeypress(e))]},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default",{createItemId:s.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},__file:"src/components/base/selector/selector-listbox.vue"},q={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:o}};const R=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);q.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:o.isHighlighted},role:"option",key:o.optionId,ref:"listItem",onMouseenter:n[0]||(n[0]=t=>e.$emit("mouseenter")),onMouseleave:n[1]||(n[1]=t=>e.$emit("mouseleave")),onClick:n[2]||(n[2]=t=>e.$emit("selected")),"aria-label":o.optionDisplay,"aria-selected":o.selected},{default:t.withCtx((()=>[t.createVNode(l,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:o.selected}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.optionDisplay),1)])),_:1},8,["flavorOptions"]),t.createVNode(l,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:o.isHighlighted}},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: check "),t.withDirectives(t.createVNode(l,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!o.selected},{default:t.withCtx((()=>[R])),_:1},8,["aria-hidden"]),[[t.vShow,o.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},q.__file="src/components/base/selector/selector-list-item.vue";var j={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:o}};const M=t.createTextVNode(" Choose an option "),E=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),A=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);j.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.multi.button",id:o.id,"aria-haspopup":"listbox","aria-label":s.label(),"aria-expanded":o.isOpen,ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:[n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["enter"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:t.withCtx((()=>[0===o.selectedOptions.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:t.withCtx((()=>[M])),_:1})):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(o.selectedOptions,(({id:n,display:o})=>(t.openBlock(),t.createBlock(l,{as:"span",component:"select.multi.button.selected",key:n},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o)+" ",1),t.createVNode(l,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:t.withModifiers((t=>e.$emit("deselect-option",n)),["prevent"])},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[E])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),t.createVNode(l,{as:"span",component:"select.multi.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[A])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},j.__file="src/components/base/selector/multi-selector-button.vue";var D={name:"selector",mixins:[_],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:o}=n;if("function"!=typeof o)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const i=e=>{t.contains(e.target)||o()};e[t.id]=i,document.addEventListener("click",i),document.addEventListener("touchstart",i)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const o=t.find((t=>t.display.toLowerCase().includes(e)));o&&(n.highlightOption(o),this.scrollIntoView(o.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:o,toggleOption:i}=t,{isMultiSelect:r}=this;r?i(e):(n(),o(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:j,RenderlessSelector:k,SelectorListItem:q,SelectorButton:V,SelectorListbox:I,RefineFlavor:o},render:function(e,n,o,i,r,s){const l=t.resolveComponent("multi-selector-button"),c=t.resolveComponent("selector-button"),a=t.resolveComponent("selector-list-item"),d=t.resolveComponent("selector-listbox"),p=t.resolveComponent("refine-flavor"),u=t.resolveComponent("renderless-selector"),h=t.resolveDirective("click-away");return t.openBlock(),t.createBlock(u,{onSelectOption:n[0]||(n[0]=t=>e.$emit("select-option",t)),onDeselectOption:n[1]||(n[1]=t=>e.$emit("deselect-option",t))},{default:t.withCtx((({actions:n,isOpen:i,isClosed:r,selectedOptions:u,highlightedOption:m,options:f})=>[t.createVNode(p,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(p,{as:"div",component:"select",class:t.normalizeClass(o.innerClass),id:`listbox-${s.selectorId}`,"aria-labelledby":s.buttonId},{default:t.withCtx((()=>[o.isMultiSelect?(t.openBlock(),t.createBlock(l,{key:0,id:s.buttonId,isOpen:i,selectedOptions:u,onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),onDeselectOption:e=>s.deselectOption(e,n),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(t.openBlock(),t.createBlock(c,{key:1,id:s.buttonId,isOpen:i,display:u[0]?u[0].display:"",onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),t.createVNode(d,{selectedOption:u[0],isClosed:r,ref:"listBox",onHighlightNextOption:e=>s.highlightNextOption(n),onHighlightPreviousOption:e=>s.highlightPreviousOption(n),onSelectOption:e=>s.selectOption(m.id,n),onBufferChanged:e=>s.updateBuffer(e,f,n),onClose:e=>s.close(n)},{default:t.withCtx((({createItemId:e})=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f,(o=>(t.openBlock(),t.createBlock(a,{id:e(o.id),key:o.id,optionId:o.id,optionDisplay:o.display,selected:s.isSelected(o,u),isHighlighted:m&&o.id===m.id,ref_for:!0,ref:o.id,onMouseenter:e=>n.highlightOption(o),onMouseleave:e=>n.highlightOption(null),onSelected:e=>s.selectOption(o.id,n)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[h,n.close]]),t.createCommentVNode(" Custom options "),t.createVNode(p,{as:"div",component:"customOptions.wrapper"},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},__file:"src/components/base/selector/selector.vue"},F={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 x(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:o,type:i,display:r,meta:s}=this.conditionsLookup[t];return{id:o,type:i,display:r,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:o,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:o,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:o.groupedBlueprint()}):null}},P={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("blueprint"),r=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let s;s=r?i.findCriterion(n.uid):i.addCriterion({id:t,depth:0});const l=(e,t)=>i.updateInput(s,e,t),c=e=>i.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{i.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{r||i.removeCriterion(i.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:c}):null})(t.id,t,n)},T={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("criterion"),r=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),c=e=>{r(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:t},s);const{clause:e,...o}=i.input;Object.keys(n).length>0&&0===Object.keys(o).length&&r({...n},s)}return e.onUnmounted((()=>{l||i.input.clause===t&&r({clause:void 0},s)})),()=>o.slots.default?o.slots.default({setValue:c,...i.input}):null})(t.clause,t,n)},L={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()}},H={name:"selector-option",mixins:[B],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[B],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:o}=this;o.registerOption({id:e,display:t||e,...this.$attrs}),n&&o.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("renderless-option");return t.openBlock(),t.createBlock(l,{id:e.id,display:e.display,selected:e.selected},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["id","display","selected"])},__file:"src/components/base/selector/selector-option.vue"},K={name:"refine-date-input",components:{Selector:D,SelectorOption:H,RefineFlavor:o},mixins:[_],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("selector-option"),a=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.relative.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:o.amount,onInput:s.updateAmount},null,8,["value","onInput"]),t.createVNode(a,{onSelectOption:s.updateUnit},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.units,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,display:e.display,selected:e.id===o.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),t.createVNode(a,{onSelectOption:s.updateModifier},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.modifiers,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,selected:e.id===o.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},__file:"src/components/base/inputs/relative-date-input.vue"},z={name:"refine-option-input",components:{Selector:D,SelectorOption:H},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector");return t.openBlock(),t.createBlock(c,{isMultiSelect:o.multiple,onSelectOption:s.selectOption,onDeselectOption:s.deselectOption},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.options,(({id:e,display:n})=>(t.openBlock(),t.createBlock(l,{key:e,id:e,display:n,selected:s.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},__file:"src/components/base/inputs/option-input.vue"},G={emits:["input"],components:{RefineFlavor:o},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.date",type:"date",value:o.date,onInput:s.handleInput},null,8,["value","onInput"])},__file:"src/components/base/inputs/native-date-picker.vue"},U={RefineDateInput:l,RefineDoubleDateInput:c,RefineDoubleNumberInput:r,RefineNumberInput:i,RefineOptionInput:z,RefineRelativeDateInput:K,RefineTextInput:s,RefineNativeDatePicker:G},W=Object.freeze({__proto__:null,default:U,RefineDateInput:l,RefineDoubleDateInput:c,RefineDoubleNumberInput:r,RefineNumberInput:i,RefineOptionInput:z,RefineRelativeDateInput:K,RefineTextInput:s,RefineNativeDatePicker:G}),Q={install:(e,t={})=>{t={DatePicker:G,...t},e.component("refine-date-picker",t.DatePicker)}},Y={install:(e,t={})=>{Q.install(e,t)}},Z={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:D},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{onSelectOption:s.selectOption},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["onSelectOption"])},__file:"src/components/base/condition-selector/condition-selector.vue"},J={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 x(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null},__file:"src/components/renderless/query.vue"},X={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:T,SelectorOption:H,Selector:D,...W},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector"),a=t.resolveComponent("renderless-clause");return t.openBlock(),t.createBlock(a,t.normalizeProps(t.guardReactiveProps(o.input)),{default:t.withCtx((({setValue:e})=>[t.createCommentVNode(" clause selector "),t.createVNode(c,{onSelectOption:s.switchClause,innerClass:"refine-clause-selector"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.meta.clauses,(({id:n,display:i,component:r,meta:s})=>(t.openBlock(),t.createBlock(l,{key:n,id:n,display:i,selected:o.input.clause===n},{default:t.withCtx((()=>[r?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r),t.mergeProps({key:0},{...o.meta,...s,...o.input},{onInput:e}),null,16,["onInput"])):t.createCommentVNode("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},__file:"src/components/base/query-builder/clause.vue"},ee={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:X,RenderlessRefinement:L,Selector:D,SelectorOption:H},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("clause"),c=t.resolveComponent("renderless-refinement"),a=t.resolveComponent("selector-option"),d=t.resolveComponent("selector");return t.openBlock(),t.createBlock(d,{onSelectOption:s.selectRefinement},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.refinements,(({id:e,meta:n,display:i})=>(t.openBlock(),t.createBlock(a,{key:e,id:e,display:i,selected:!!o.input[e]},{default:t.withCtx((()=>[t.createVNode(c,{id:e},{default:t.withCtx((()=>[t.createVNode(l,{meta:n,input:o.input[e],onSwitchClause:({id:t})=>s.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},__file:"src/components/base/query-builder/refinements.vue"},te={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:X,Refinements:ee,SelectorOption:H,Selector:D,RefineFlavor:o}};const ne=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);te.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("clause"),a=t.resolveComponent("refinements"),d=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:t.withCtx((()=>[o.errors.length>0?(t.openBlock(),t.createBlock(l,{key:0,as:"ul",component:"criterion.errors"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.errors,(e=>(t.openBlock(),t.createBlock(l,{as:"li",component:"criterion.errors.error",key:e},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e),1)])),_:2},1024)))),128))])),_:1})):t.createCommentVNode("v-if",!0)])),selector:t.withCtx((()=>[t.createVNode(p,{onSelectOption:s.switchCondition},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.conditions,(({id:e,display:n,meta:i,refinements:r})=>(t.openBlock(),t.createBlock(d,{key:e,id:e,display:n,selected:o.conditionId===e},{default:t.withCtx((()=>[t.createElementVNode("div",null,[t.createVNode(c,{input:o.input,meta:i,onSwitchClause:s.switchClause},null,8,["input","meta","onSwitchClause"]),r&&r.length>0?(t.openBlock(),t.createBlock(a,{key:0,input:o.input,refinements:r},null,8,["input","refinements"])):t.createCommentVNode("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"criterion.removeCriterionButton",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[ne])),_:1})])),_:1})])),_:1})},te.__file="src/components/base/query-builder/criterion.vue";var oe={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var o;o=t.flavor,e.provide(n,o)},components:{Criterion:te,RefineFlavor:o,RenderlessCondition:P,RenderlessQueryBuilder:F}};const ie=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),re=t.createTextVNode(" Add a new condition "),se=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),le=t.createTextVNode(" And"),ce=t.createTextVNode(" Add an 'Or' ");oe.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("criterion"),a=t.resolveComponent("renderless-condition"),d=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(d,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:d,conditionFor:p})=>[t.createCommentVNode(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(t.openBlock(),t.createBlock(l,t.mergeProps({key:0,as:"div",component:"emptyGroup"},{addGroup:r},{order:["button","default"]}),{button:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"emptyGroup.addCriterionButton",onClick:r,tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[ie])),_:1}),t.createVNode(l,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:t.withCtx((()=>[re])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(t.openBlock(),t.createBlock(l,{key:1,as:"div",component:"group.wrapper"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,((r,u)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(l,t.mergeProps({as:"div",component:"group"},s.templateChildKey(`group-${u}`)),{default:t.withCtx((()=>[t.createCommentVNode(" This really should be named criterion, as that's what it is. "),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r,(e=>(t.openBlock(),t.createBlock(l,{as:"div",component:"condition",key:e.uid},{default:t.withCtx((()=>[t.createVNode(a,t.normalizeProps(t.guardReactiveProps(p({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(c,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>d(e.position),onSwitchCondition:t=>n(e.position,p(t)),conditionId:e.condition_id,conditions:o.conditions,errors:o.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),t.createVNode(l,{as:"div",component:"group.addCriterionButton.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"group.addCriterionButton",onClick:e=>i(r[r.length-1].position),tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),t.createCommentVNode(" Divider between groups. Blank by default, but used in Nova. "),t.createVNode(l,t.mergeProps({as:"template",component:"group.divider",index:u,total:e.length},s.templateChildKey(`separator-${u}`)),null,16,["index","total"])],64)))),256)),t.createVNode(l,{as:"button",component:"addGroupButton",onClick:r,type:"button"},{default:t.withCtx((()=>[ce])),_:2},1032,["onClick"])])),_:2},1024)),t.createCommentVNode(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},oe.__file="src/components/base/query-builder/query-builder.vue";const ae="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",de="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",pe=`${ae} ${de} w-60 pl-3 py-2`,ue={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{class:`${ae} ${de} h-9 h-full py-5 px-2 leading-normal box-border`,relative:{class:`${pe} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:pe,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:pe}}},he="bg-white relative text-left cursor-default",me=`${he} focus:outline-none pl-3 py-1`,fe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${he} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${me} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${me} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:me}}};exports.ConditionSelector=Z,exports.DatePickerPlugin=Y,exports.Query=J,exports.QueryBuilder=oe,exports.RefinePlugin=Q,exports.Selector=D,exports.SelectorOption=H,exports.linearFlavor=fe,exports.tailwindFlavor=ue; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-demi"),t=require("vue");const n=Symbol();let o={};var i={init(e){o=e},get:(e,t=null)=>o?.[e]??t,set(e,t){o[e]=t}};const r=e.defineComponent({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,o){let r=i.get("showLocators");const s=function(t,o,i=e.computed((()=>({})))){const r=e.inject(n),s=e.computed((()=>t(r)??{})),l=e.computed((()=>{const e={},t=i.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),c=e.computed((()=>{const e={},t=i.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const o=s.value.style;return o&&(e.style="function"==typeof o?o(t):o),e}));return e.computed((()=>({component:s.value.component??o.value,props:c,extra:l})))}((e=>{const n=t.component.split(".");let o=e;for(const e of n)o=o?.[e];return"string"!=typeof o&&"function"!=typeof o||(o={class:o}),o}),e.computed((()=>t.as)),e.computed((()=>({...o.attrs??{},...t.flavorOptions??{}}))));return()=>{const n=s.value,i=n.extra.value.order??t.order,l=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),c=o.slots;let a="string"==typeof n.component&&n.component.includes("-"),d=a?c:i.map((e=>c?.[e]?.())),p=e.isVue2?e.h(n.component,{scopedSlots:c,attrs:{...r&&{"data-locator":t.component},...o.attrs},props:l,on:o.listeners,...n.props.value},d):e.h(a?e.resolveComponent(n.component):n.component,{...r&&{"data-locator":t.component},...o.attrs,...l,...n.props.value},d);return n.extra.value.wrap?n.extra.value.wrap(p):p}}});var s={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"input",component:"inputs.number",type:"number",value:r.currentValue,onInput:s.handleInputChange},s.metaAttributes),null,16,["value","onInput"])},__file:"src/components/base/inputs/number-input.vue"},l={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:s,RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("number-input"),c=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(c,{as:"div",component:"inputs.number.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{meta:o.meta,value:o.value1,onInput:s.updateFirstValue},null,8,["meta","value","onInput"]),s.joinWord?(t.openBlock(),t.createBlock(c,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(s.joinWord),1)])),_:1})):t.createCommentVNode("v-if",!0),t.createVNode(l,{meta:o.meta,value:o.value2,onInput:s.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},__file:"src/components/base/inputs/double-number-input.vue"},c={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.text",type:"text",value:o.value,onInput:n[0]||(n[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},__file:"src/components/base/inputs/text-input.vue"},a={name:"refine-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},__file:"src/components/base/inputs/date-input.vue"},d={name:"refine-double-date-input",components:{RefineFlavor:r},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.double.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date1,onInput:n[0]||(n[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),t.createVNode(l,{as:"p",component:"inputs.date.double.joiner"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.joiner),1)])),_:1}),t.createVNode(l,t.mergeProps({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:o.date2,onInput:n[1]||(n[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},__file:"src/components/base/inputs/double-date-input.vue"},p=e=>"conjunction"===(null==e?void 0:e.type),u=Object.defineProperty,h=Object.defineProperties,m=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&b(e,n,t[n]);if(f)for(var n of f(t))v.call(t,n)&&b(e,n,t[n]);return e},y=(e,t)=>h(e,m(t)),C=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},x=(e,t,n,o)=>{var i,r;const[s]=o||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:w({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(i=null==s?void 0:s.meta)?void 0:i.clauses[0])?void 0:r.id}}),uid:C()}},O=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:C()}},k=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?y(w({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||C()}):y(w({},e),{id:void 0,uid:C()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var o in e)g.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&f)for(var o of f(e))t.indexOf(o)<0&&v.call(e,o)&&(n[o]=e[o]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{p(t)?"or"===t.word&&e.push([]):e[e.length-1].push(y(w({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:o,refinements:i}=this.findCondition(t.id),r=x(o,1,n,i);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],o=t[e+1],i=p(o)&&"or"===o.word,r=p(n)&&"or"===n.word,s=i||!o,l=r||!n,c=l&&!s,a=l&&s;n||o?a&&r?t.splice(e-1,2):a&&!n||c?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:o,refinements:i}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:C()}}()),e.push(x(n.id,1,o,i)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:o}=this,i=x(t,n);return 0===o.length?o.push(i):o.splice(o.length,0,O(),i),this.blueprintChanged(),i}insertCriterion(e){const{blueprint:t,conditions:n}=this,o=n[0],{meta:i,refinements:r}=o;return t.splice(e+1,0,O(),x(o.id,1,i,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let o;return n.forEach((e=>{e.id===t&&(o=e)})),o}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,o){const{meta:i}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(i.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},o)}switchRefinement({uid:e,id:t},n,o){const i=this.findRefinement(t,o),r=this.findCriterion(e),s=w({},r.input);delete s[n],s[o]={clause:i.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const o=this.findCriterion(e);Object.keys(t).forEach((e=>{n?o.input[n][e]=t[e]:o.input[e]=t[e]})),this.blueprintChanged()}},B=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++)if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const o=this.options[this.options.length-1]||null,i=w({previousOption:o,nextOption:null},e);o&&(o.nextOption=i),this.options.push(i)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},S={name:"renderless-selector",data:()=>({selector:e.reactive(new B),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:o,highlightOption:i,open:r,selectOption:s,selectedOptions:l,toggle:c,toggleOption:a}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:o,options:this.selector.options}}},methods:{nextTick(){return e.nextTick().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:o}=t.toggleOption(e);return o?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let t=this.$slots?.default;return e.isVue2&&(t=this.$scopedSlots?.default),t?t({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const _={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let V=1;var N={beforeCreate(){this.uid=V.toString(),V+=1}},$={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:r}};const I=t.createTextVNode(" Choose an option "),q=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);$.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.button",id:o.id,type:"button","aria-haspopup":"listbox","aria-expanded":o.isOpen,"aria-label":s.label(),ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:t.withCtx((()=>[0===o.display.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.button.placeholder"},{default:t.withCtx((()=>[I])),_:1})):(t.openBlock(),t.createBlock(l,{key:1,as:"span",component:"select.button.selected"},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.display),1)])),_:1})),t.createVNode(l,{as:"span",component:"select.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[q])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},$.__file="src/components/base/selector/selector-button.vue";var R={name:"selector-listbox",mixins:[N],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"div",component:"select.listbox.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:o.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":o.selectedOption?s.createItemId(o.selectedOption.id):"",ref:"listBox",onKeydown:[t.withKeys(t.withModifiers(s.clearBuffer,["stop","prevent"]),["delete"]),n[0]||(n[0]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),n[1]||(n[1]=t.withKeys(t.withModifiers((()=>s.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),n[3]||(n[3]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["escape"])),n[4]||(n[4]=t.withKeys(t.withModifiers((t=>e.$emit("close")),["stop","prevent"]),["tab"])),n[5]||(n[5]=e=>s.handleKeypress(e))]},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default",{createItemId:s.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},__file:"src/components/base/selector/selector-listbox.vue"},j={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:r}};const M=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);j.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:o.isHighlighted},role:"option",key:o.optionId,ref:"listItem",onMouseenter:n[0]||(n[0]=t=>e.$emit("mouseenter")),onMouseleave:n[1]||(n[1]=t=>e.$emit("mouseleave")),onClick:n[2]||(n[2]=t=>e.$emit("selected")),"aria-label":o.optionDisplay,"aria-selected":o.selected},{default:t.withCtx((()=>[t.createVNode(l,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:o.selected}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o.optionDisplay),1)])),_:1},8,["flavorOptions"]),t.createVNode(l,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:o.isHighlighted}},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: check "),t.withDirectives(t.createVNode(l,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!o.selected},{default:t.withCtx((()=>[M])),_:1},8,["aria-hidden"]),[[t.vShow,o.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},j.__file="src/components/base/selector/selector-list-item.vue";var E={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:r}};const A=t.createTextVNode(" Choose an option "),D=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),P=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);E.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"button",component:"select.multi.button",id:o.id,"aria-haspopup":"listbox","aria-label":s.label(),"aria-expanded":o.isOpen,ref:"button",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("toggle")),["prevent"])),onKeydown:[n[1]||(n[1]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["enter"])),n[2]||(n[2]=t.withKeys(t.withModifiers((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:t.withCtx((()=>[0===o.selectedOptions.length?(t.openBlock(),t.createBlock(l,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:t.withCtx((()=>[A])),_:1})):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(o.selectedOptions,(({id:n,display:o})=>(t.openBlock(),t.createBlock(l,{as:"span",component:"select.multi.button.selected",key:n},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(o)+" ",1),t.createVNode(l,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:t.withModifiers((t=>e.$emit("deselect-option",n)),["prevent"])},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[D])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),t.createVNode(l,{as:"span",component:"select.multi.button.icon.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: selector "),t.createVNode(l,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[P])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},E.__file="src/components/base/selector/multi-selector-button.vue";var F={name:"selector",mixins:[N],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:o}=n;if("function"!=typeof o)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const i=e=>{t.contains(e.target)||o()};e[t.id]=i,document.addEventListener("click",i),document.addEventListener("touchstart",i)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const o=t.find((t=>t.display.toLowerCase().includes(e)));o&&(n.highlightOption(o),this.scrollIntoView(o.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:o,toggleOption:i}=t,{isMultiSelect:r}=this;r?i(e):(n(),o(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:E,RenderlessSelector:S,SelectorListItem:j,SelectorButton:$,SelectorListbox:R,RefineFlavor:r},render:function(e,n,o,i,r,s){const l=t.resolveComponent("multi-selector-button"),c=t.resolveComponent("selector-button"),a=t.resolveComponent("selector-list-item"),d=t.resolveComponent("selector-listbox"),p=t.resolveComponent("refine-flavor"),u=t.resolveComponent("renderless-selector"),h=t.resolveDirective("click-away");return t.openBlock(),t.createBlock(u,{onSelectOption:n[0]||(n[0]=t=>e.$emit("select-option",t)),onDeselectOption:n[1]||(n[1]=t=>e.$emit("deselect-option",t))},{default:t.withCtx((({actions:n,isOpen:i,isClosed:r,selectedOptions:u,highlightedOption:m,options:f})=>[t.createVNode(p,{as:"div",component:"select.wrapper"},{default:t.withCtx((()=>[t.createCommentVNode(" Select dropdown "),t.withDirectives((t.openBlock(),t.createBlock(p,{as:"div",component:"select",class:t.normalizeClass(o.innerClass),id:`listbox-${s.selectorId}`,"aria-labelledby":s.buttonId},{default:t.withCtx((()=>[o.isMultiSelect?(t.openBlock(),t.createBlock(l,{key:0,id:s.buttonId,isOpen:i,selectedOptions:u,onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),onDeselectOption:e=>s.deselectOption(e,n),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(t.openBlock(),t.createBlock(c,{key:1,id:s.buttonId,isOpen:i,display:u[0]?u[0].display:"",onToggle:e=>s.toggle(n),onOpen:e=>s.open(n),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),t.createVNode(d,{selectedOption:u[0],isClosed:r,ref:"listBox",onHighlightNextOption:e=>s.highlightNextOption(n),onHighlightPreviousOption:e=>s.highlightPreviousOption(n),onSelectOption:e=>s.selectOption(m.id,n),onBufferChanged:e=>s.updateBuffer(e,f,n),onClose:e=>s.close(n)},{default:t.withCtx((({createItemId:e})=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f,(o=>(t.openBlock(),t.createBlock(a,{id:e(o.id),key:o.id,optionId:o.id,optionDisplay:o.display,selected:s.isSelected(o,u),isHighlighted:m&&o.id===m.id,ref_for:!0,ref:o.id,onMouseenter:e=>n.highlightOption(o),onMouseleave:e=>n.highlightOption(null),onSelected:e=>s.selectOption(o.id,n)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[h,n.close]]),t.createCommentVNode(" Custom options "),t.createVNode(p,{as:"div",component:"customOptions.wrapper"},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},__file:"src/components/base/selector/selector.vue"},T={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new k(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:o,type:i,display:r,meta:s}=this.conditionsLookup[t];return{id:o,type:i,display:r,uid:n,meta:s}}},render(){const{insertCriterion:t,addGroup:n,blueprintStore:o,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return e.isVue2&&(l=this.$scopedSlots?.default),l?l({insertCriterion:t,addGroup:n,blueprint:o,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:o.groupedBlueprint()}):null}},L={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("blueprint"),r=e.inject("builderModeActive");if(!t)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!i)throw new Error("Conditions must be rendered within a query.");let s;s=r?i.findCriterion(n.uid):i.addCriterion({id:t,depth:0});const l=(e,t)=>i.updateInput(s,e,t),c=e=>i.switchClause(s,e);e.provide("criterion",s),e.provide("criterionMeta",n.meta),e.provide("updateInput",l),e.provide("switchRefinement",((e,t)=>{i.switchRefinement(s,e,t)})),e.provide("refinementId",null),e.onUnmounted((()=>{r||i.removeCriterion(i.indexOfCriterion(s))}));let a=null;return n?.condition?.meta?.clauses&&(a=n.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:a,criterion:s,updateInput:l,switchClause:c}):null})(t.id,t,n)},H={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(t,n)=>((t,n,o)=>{const i=e.inject("criterion"),r=e.inject("updateInput"),s=e.inject("refinementId"),l=e.inject("builderModeActive"),c=e=>{r(e,s)};if(!i)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:t},s);const{clause:e,...o}=i.input;Object.keys(n).length>0&&0===Object.keys(o).length&&r({...n},s)}return e.onUnmounted((()=>{l||i.input.clause===t&&r({clause:void 0},s)})),()=>o.slots.default?o.slots.default({setValue:c,...i.input}):null})(t.clause,t,n)},K={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let t=this.$slots?.default;if(e.isVue2&&(t=this.$scopedSlots?.default),t)return t()}},z={name:"selector-option",mixins:[_],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[_],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:o}=this;o.registerOption({id:e,display:t||e,...this.$attrs}),n&&o.selectOption(e)},render(){const{isSelected:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n&&t?n():null}}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("renderless-option");return t.openBlock(),t.createBlock(l,{id:e.id,display:e.display,selected:e.selected},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["id","display","selected"])},__file:"src/components/base/selector/selector-option.vue"},G={name:"refine-date-input",components:{Selector:F,SelectorOption:z,RefineFlavor:r},mixins:[N],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("selector-option"),a=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{as:"div",component:"inputs.date.relative.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:o.amount,onInput:s.updateAmount},null,8,["value","onInput"]),t.createVNode(a,{onSelectOption:s.updateUnit},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.units,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,display:e.display,selected:e.id===o.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),t.createVNode(a,{onSelectOption:s.updateModifier},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.modifiers,(e=>(t.openBlock(),t.createBlock(c,{key:e.id,id:e.id,selected:e.id===o.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},__file:"src/components/base/inputs/relative-date-input.vue"},U={name:"refine-option-input",components:{Selector:F,SelectorOption:z},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector");return t.openBlock(),t.createBlock(c,{isMultiSelect:o.multiple,onSelectOption:s.selectOption,onDeselectOption:s.deselectOption},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.options,(({id:e,display:n})=>(t.openBlock(),t.createBlock(l,{key:e,id:e,display:n,selected:s.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},__file:"src/components/base/inputs/option-input.vue"},W={emits:["input"],components:{RefineFlavor:r},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor");return t.openBlock(),t.createBlock(l,{as:"input",component:"inputs.date",type:"date",value:o.date,onInput:s.handleInput},null,8,["value","onInput"])},__file:"src/components/base/inputs/native-date-picker.vue"},Q={RefineDateInput:a,RefineDoubleDateInput:d,RefineDoubleNumberInput:l,RefineNumberInput:s,RefineOptionInput:U,RefineRelativeDateInput:G,RefineTextInput:c,RefineNativeDatePicker:W},Y=Object.freeze({__proto__:null,default:Q,RefineDateInput:a,RefineDoubleDateInput:d,RefineDoubleNumberInput:l,RefineNumberInput:s,RefineOptionInput:U,RefineRelativeDateInput:G,RefineTextInput:c,RefineNativeDatePicker:W}),Z={install:(e,t={})=>{t={DatePicker:W,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,i.init(t)}},J={install:(e,t={})=>{Z.install(e,t)}},X={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:F},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{onSelectOption:s.selectOption},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"default")])),_:3},8,["onSelectOption"])},__file:"src/components/base/condition-selector/condition-selector.vue"},ee={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new k(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:t}=this;let n=this.$slots?.default;return e.isVue2&&(n=this.$scopedSlots?.default),n?n({blueprint:t}):null},__file:"src/components/renderless/query.vue"},te={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:H,SelectorOption:z,Selector:F,...Y},render:function(e,n,o,i,r,s){const l=t.resolveComponent("selector-option"),c=t.resolveComponent("selector"),a=t.resolveComponent("renderless-clause");return t.openBlock(),t.createBlock(a,t.normalizeProps(t.guardReactiveProps(o.input)),{default:t.withCtx((({setValue:e})=>[t.createCommentVNode(" clause selector "),t.createVNode(c,{onSelectOption:s.switchClause,innerClass:"refine-clause-selector"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.meta.clauses,(({id:n,display:i,component:r,meta:s})=>(t.openBlock(),t.createBlock(l,{key:n,id:n,display:i,selected:o.input.clause===n},{default:t.withCtx((()=>[r?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r),t.mergeProps({key:0},{...o.meta,...s,...o.input},{onInput:e}),null,16,["onInput"])):t.createCommentVNode("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},__file:"src/components/base/query-builder/clause.vue"},ne={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:te,RenderlessRefinement:K,Selector:F,SelectorOption:z},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}},render:function(e,n,o,i,r,s){const l=t.resolveComponent("clause"),c=t.resolveComponent("renderless-refinement"),a=t.resolveComponent("selector-option"),d=t.resolveComponent("selector");return t.openBlock(),t.createBlock(d,{onSelectOption:s.selectRefinement},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.refinements,(({id:e,meta:n,display:i})=>(t.openBlock(),t.createBlock(a,{key:e,id:e,display:i,selected:!!o.input[e]},{default:t.withCtx((()=>[t.createVNode(c,{id:e},{default:t.withCtx((()=>[t.createVNode(l,{meta:n,input:o.input[e],onSwitchClause:({id:t})=>s.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},__file:"src/components/base/query-builder/refinements.vue"},oe={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:te,Refinements:ne,SelectorOption:z,Selector:F,RefineFlavor:r}};const ie=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);oe.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("clause"),a=t.resolveComponent("refinements"),d=t.resolveComponent("selector-option"),p=t.resolveComponent("selector");return t.openBlock(),t.createBlock(l,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:t.withCtx((()=>[o.errors.length>0?(t.openBlock(),t.createBlock(l,{key:0,as:"ul",component:"criterion.errors"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.errors,(e=>(t.openBlock(),t.createBlock(l,{as:"li",component:"criterion.errors.error",key:e},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e),1)])),_:2},1024)))),128))])),_:1})):t.createCommentVNode("v-if",!0)])),selector:t.withCtx((()=>[t.createVNode(p,{onSelectOption:s.switchCondition},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.conditions,(({id:e,display:n,meta:i,refinements:r})=>(t.openBlock(),t.createBlock(d,{key:e,id:e,display:n,selected:o.conditionId===e},{default:t.withCtx((()=>[t.createElementVNode("div",null,[t.createVNode(c,{input:o.input,meta:i,onSwitchClause:s.switchClause},null,8,["input","meta","onSwitchClause"]),r&&r.length>0?(t.openBlock(),t.createBlock(a,{key:0,input:o.input,refinements:r},null,8,["input","refinements"])):t.createCommentVNode("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"criterion.removeCriterionButton",onClick:n[0]||(n[0]=t.withModifiers((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:t.withCtx((()=>[t.createVNode(l,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:t.withCtx((()=>[ie])),_:1})])),_:1})])),_:1})},oe.__file="src/components/base/query-builder/criterion.vue";var re={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:t=>e.isVue2?{}:{key:t},templateChildKey:t=>e.isVue2?{key:t}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(t){var o;o=t.flavor,e.provide(n,o)},components:{Criterion:oe,RefineFlavor:r,RenderlessCondition:L,RenderlessQueryBuilder:T}};const se=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),le=t.createTextVNode(" Add a new condition "),ce=t.createElementVNode("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),ae=t.createTextVNode(" And"),de=t.createTextVNode(" Add an 'Or' ");re.render=function(e,n,o,i,r,s){const l=t.resolveComponent("refine-flavor"),c=t.resolveComponent("criterion"),a=t.resolveComponent("renderless-condition"),d=t.resolveComponent("renderless-query-builder");return t.openBlock(),t.createBlock(d,{blueprint:o.blueprint,conditions:o.conditions,onChange:s.onChange},{default:t.withCtx((({groupedBlueprint:e,replaceCriterion:n,insertCriterion:i,addGroup:r,removeCriterion:d,conditionFor:p})=>[t.createCommentVNode(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(t.openBlock(),t.createBlock(l,t.mergeProps({key:0,as:"div",component:"emptyGroup"},{addGroup:r},{order:["button","default"]}),{button:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"emptyGroup.addCriterionButton",onClick:r,tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[se])),_:1}),t.createVNode(l,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:t.withCtx((()=>[le])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(t.openBlock(),t.createBlock(l,{key:1,as:"div",component:"group.wrapper"},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e,((r,u)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(l,t.mergeProps({as:"div",component:"group"},s.templateChildKey(`group-${u}`)),{default:t.withCtx((()=>[t.createCommentVNode(" This really should be named criterion, as that's what it is. "),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r,(e=>(t.openBlock(),t.createBlock(l,{as:"div",component:"condition",key:e.uid},{default:t.withCtx((()=>[t.createVNode(a,t.normalizeProps(t.guardReactiveProps(p({id:e.condition_id,...e}))),{default:t.withCtx((({switchClause:i})=>[t.createVNode(c,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>d(e.position),onSwitchCondition:t=>n(e.position,p(t)),conditionId:e.condition_id,conditions:o.conditions,errors:o.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),t.createVNode(l,{as:"div",component:"group.addCriterionButton.wrapper"},{default:t.withCtx((()=>[t.createVNode(l,{as:"button",component:"group.addCriterionButton",onClick:e=>i(r[r.length-1].position),tabindex:"0",type:"button"},{default:t.withCtx((()=>[t.createCommentVNode(" Heroicon name: plus "),t.createVNode(l,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:t.withCtx((()=>[ce])),_:1}),t.createVNode(l,{as:"span",component:"group.addCriterionButton.text"},{default:t.withCtx((()=>[ae])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),t.createCommentVNode(" Divider between groups. Blank by default, but used in Nova. "),t.createVNode(l,t.mergeProps({as:"template",component:"group.divider",index:u,total:e.length},s.templateChildKey(`separator-${u}`)),null,16,["index","total"])],64)))),256)),t.createVNode(l,{as:"button",component:"addGroupButton",onClick:r,type:"button"},{default:t.withCtx((()=>[de])),_:2},1032,["onClick"])])),_:2},1024)),t.createCommentVNode(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},re.__file="src/components/base/query-builder/query-builder.vue";const pe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",ue="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",he=`${pe} ${ue} w-60 pl-3 py-2`,me={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${pe} ${ue} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${he} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:he,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:he}},fe="bg-white relative text-left cursor-default",ge=`${fe} focus:outline-none pl-3 py-1`,ve={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${fe} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${ge} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${ge} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:ge}}};exports.ConditionSelector=X,exports.DatePickerPlugin=J,exports.Query=ee,exports.QueryBuilder=re,exports.RefinePlugin=Z,exports.Selector=F,exports.SelectorOption=z,exports.linearFlavor=ve,exports.tailwindFlavor=me; | ||
//# sourceMappingURL=refine-vue.cjs.min.js.map |
@@ -1,2 +0,2 @@ | ||
import{computed as e,provide as t,inject as n,defineComponent as i,isVue2 as o,h as r,resolveComponent as s,reactive as l,nextTick as a,onUnmounted as u}from"vue-demi";import{resolveComponent as d,openBlock as p,createBlock as c,mergeProps as h,withCtx as f,createVNode as m,createTextVNode as g,toDisplayString as b,createCommentVNode as v,withModifiers as y,withKeys as w,createElementVNode as O,renderSlot as x,withDirectives as C,vShow as S,createElementBlock as _,Fragment as $,renderList as k,resolveDirective as I,normalizeClass as q,normalizeProps as B,guardReactiveProps as R,resolveDynamicComponent as j}from"vue";const A=Symbol();const M=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,i){const l=function(t,i,o=e((()=>({})))){const r=n(A),s=e((()=>t(r)??{})),l=e((()=>{const e={},t=o.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=o.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const n=t.component.split(".");let i=e;for(const e of n)i=i?.[e];return i}),e((()=>t.as)),e((()=>({...i.attrs??{},...t.flavorOptions??{}}))));return()=>{const e=l.value,n=e.extra.value.order??t.order,a=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),u=i.slots;let d="string"==typeof e.component&&e.component.includes("-"),p=d?u:n.map((e=>u?.[e]?.())),c=o?r(e.component,{scopedSlots:u,attrs:{...i.attrs,"data-flavor":t.component},props:a,on:i.listeners,...e.props.value},p):r(d?s(e.component):e.component,{...i.attrs,"data-flavor":t.component,...a,...e.props.value},p);return e.extra.value.wrap?e.extra.value.wrap(c):c}}});var D={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:M}};D.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"input",component:"inputs.number",type:"number",value:o.currentValue,onInput:r.handleInputChange},r.metaAttributes),null,16,["value","onInput"])},D.__file="src/components/base/inputs/number-input.vue";var N={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:M}};N.render=function(e,t,n,i,o,r){const s=d("number-input"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.number.double.wrapper"},{default:f((()=>[m(s,{meta:n.meta,value:n.value1,onInput:r.updateFirstValue},null,8,["meta","value","onInput"]),r.joinWord?(p(),c(l,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:f((()=>[g(b(r.joinWord),1)])),_:1})):v("v-if",!0),m(s,{meta:n.meta,value:n.value2,onInput:r.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},N.__file="src/components/base/inputs/double-number-input.vue";var H={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:M}};H.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.text",type:"text",value:n.value,onInput:t[0]||(t[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},H.__file="src/components/base/inputs/text-input.vue";var V={name:"refine-date-input",components:{RefineFlavor:M},emits:["input"],props:{date1:{type:String,required:!1}}};V.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},V.__file="src/components/base/inputs/date-input.vue";var E={name:"refine-double-date-input",components:{RefineFlavor:M},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};E.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"inputs.date.double.wrapper"},{default:f((()=>[m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),m(s,{as:"p",component:"inputs.date.double.joiner"},{default:f((()=>[g(b(n.joiner),1)])),_:1}),m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date2,onInput:t[1]||(t[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},E.__file="src/components/base/inputs/double-date-input.vue";var P=e=>"conjunction"===(null==e?void 0:e.type),T=Object.defineProperty,F=Object.defineProperties,L=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,z=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,W=(e,t,n)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t)=>{for(var n in t||(t={}))z.call(t,n)&&W(e,n,t[n]);if(G)for(var n of G(t))K.call(t,n)&&W(e,n,t[n]);return e},U=(e,t)=>F(e,L(t)),Y=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},Z=(e,t,n,i)=>{var o,r;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:Q({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(o=null==s?void 0:s.meta)?void 0:o.clauses[0])?void 0:r.id}}),uid:Y()}},J=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:Y()}},X=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?U(Q({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||Y()}):U(Q({},e),{id:void 0,uid:Y()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)z.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&G)for(var i of G(e))t.indexOf(i)<0&&K.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)=>{P(t)?"or"===t.word&&e.push([]):e[e.length-1].push(U(Q({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:o}=this.findCondition(t.id),r=Z(i,1,n,o);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],o=P(i)&&"or"===i.word,r=P(n)&&"or"===n.word,s=o||!i,l=r||!n,a=l&&!s,u=l&&s;!n&&!i?this.blueprint=[]:u&&r?t.splice(e-1,2):u&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:o}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:Y()}}()),e.push(Z(n.id,1,i,o)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,o=Z(t,n);return 0===i.length?i.push(o):i.splice(i.length,0,J(),o),this.blueprintChanged(),o}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:o,refinements:r}=i;return t.splice(e+1,0,J(),Z(i.id,1,o,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:o}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(o.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const o=this.findRefinement(t,i),r=this.findCriterion(e),s=Q({},r.input);delete s[n],s[i]={clause:o.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},ee=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,o=Q({previousOption:i,nextOption:null},e);i&&(i.nextOption=o),this.options.push(o)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},te={name:"renderless-selector",data:()=>({selector:l(new ee),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return a().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return o&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const ne={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let ie=1;var oe={beforeCreate(){this.uid=ie.toString(),ie+=1}},re={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:M}};const se=g(" Choose an option "),le=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);re.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.button",id:n.id,type:"button","aria-haspopup":"listbox","aria-expanded":n.isOpen,"aria-label":r.label(),ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:f((()=>[0===n.display.length?(p(),c(s,{key:0,as:"span",component:"select.button.placeholder"},{default:f((()=>[se])),_:1})):(p(),c(s,{key:1,as:"span",component:"select.button.selected"},{default:f((()=>[g(b(n.display),1)])),_:1})),m(s,{as:"span",component:"select.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[le])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},re.__file="src/components/base/selector/selector-button.vue";var ae={name:"selector-listbox",mixins:[oe],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:M}};ae.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.listbox.wrapper"},{default:f((()=>[m(s,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:n.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":n.selectedOption?r.createItemId(n.selectedOption.id):"",ref:"listBox",onKeydown:[w(y(r.clearBuffer,["stop","prevent"]),["delete"]),t[0]||(t[0]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),t[1]||(t[1]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),t[2]||(t[2]=w(y((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),t[3]||(t[3]=w(y((t=>e.$emit("close")),["stop","prevent"]),["escape"])),t[4]||(t[4]=w(y((t=>e.$emit("close")),["stop","prevent"]),["tab"])),t[5]||(t[5]=e=>r.handleKeypress(e))]},{default:f((()=>[x(e.$slots,"default",{createItemId:r.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},ae.__file="src/components/base/selector/selector-listbox.vue";var ue={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:M}};const de=O("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);ue.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:n.isHighlighted},role:"option",key:n.optionId,ref:"listItem",onMouseenter:t[0]||(t[0]=t=>e.$emit("mouseenter")),onMouseleave:t[1]||(t[1]=t=>e.$emit("mouseleave")),onClick:t[2]||(t[2]=t=>e.$emit("selected")),"aria-label":n.optionDisplay,"aria-selected":n.selected},{default:f((()=>[m(s,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:n.selected}},{default:f((()=>[g(b(n.optionDisplay),1)])),_:1},8,["flavorOptions"]),m(s,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:n.isHighlighted}},{default:f((()=>[v(" Heroicon name: check "),C(m(s,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!n.selected},{default:f((()=>[de])),_:1},8,["aria-hidden"]),[[S,n.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},ue.__file="src/components/base/selector/selector-list-item.vue";var pe={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:M}};const ce=g(" Choose an option "),he=O("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),fe=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);pe.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.multi.button",id:n.id,"aria-haspopup":"listbox","aria-label":r.label(),"aria-expanded":n.isOpen,ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:[t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["enter"])),t[2]||(t[2]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:f((()=>[0===n.selectedOptions.length?(p(),c(s,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:f((()=>[ce])),_:1})):(p(!0),_($,{key:1},k(n.selectedOptions,(({id:t,display:n})=>(p(),c(s,{as:"span",component:"select.multi.button.selected",key:t},{default:f((()=>[g(b(n)+" ",1),m(s,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:y((n=>e.$emit("deselect-option",t)),["prevent"])},{default:f((()=>[m(s,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[he])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),m(s,{as:"span",component:"select.multi.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[fe])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},pe.__file="src/components/base/selector/multi-selector-button.vue";var me={name:"selector",mixins:[oe],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const o=e=>{t.contains(e.target)||i()};e[t.id]=o,document.addEventListener("click",o),document.addEventListener("touchstart",o)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:o}=t,{isMultiSelect:r}=this;r?o(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:pe,RenderlessSelector:te,SelectorListItem:ue,SelectorButton:re,SelectorListbox:ae,RefineFlavor:M}};me.render=function(e,t,n,i,o,r){const s=d("multi-selector-button"),l=d("selector-button"),a=d("selector-list-item"),u=d("selector-listbox"),h=d("refine-flavor"),g=d("renderless-selector"),b=I("click-away");return p(),c(g,{onSelectOption:t[0]||(t[0]=t=>e.$emit("select-option",t)),onDeselectOption:t[1]||(t[1]=t=>e.$emit("deselect-option",t))},{default:f((({actions:t,isOpen:i,isClosed:o,selectedOptions:d,highlightedOption:g,options:y})=>[m(h,{as:"div",component:"select.wrapper"},{default:f((()=>[v(" Select dropdown "),C((p(),c(h,{as:"div",component:"select",class:q(n.innerClass),id:`listbox-${r.selectorId}`,"aria-labelledby":r.buttonId},{default:f((()=>[n.isMultiSelect?(p(),c(s,{key:0,id:r.buttonId,isOpen:i,selectedOptions:d,onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),onDeselectOption:e=>r.deselectOption(e,t),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(p(),c(l,{key:1,id:r.buttonId,isOpen:i,display:d[0]?d[0].display:"",onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),m(u,{selectedOption:d[0],isClosed:o,ref:"listBox",onHighlightNextOption:e=>r.highlightNextOption(t),onHighlightPreviousOption:e=>r.highlightPreviousOption(t),onSelectOption:e=>r.selectOption(g.id,t),onBufferChanged:e=>r.updateBuffer(e,y,t),onClose:e=>r.close(t)},{default:f((({createItemId:e})=>[(p(!0),_($,null,k(y,(n=>(p(),c(a,{id:e(n.id),key:n.id,optionId:n.id,optionDisplay:n.display,selected:r.isSelected(n,d),isHighlighted:g&&n.id===g.id,ref_for:!0,ref:n.id,onMouseenter:e=>t.highlightOption(n),onMouseleave:e=>t.highlightOption(null),onSelected:e=>r.selectOption(n.id,t)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[b,t.close]]),v(" Custom options "),m(h,{as:"div",component:"customOptions.wrapper"},{default:f((()=>[x(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},me.__file="src/components/base/selector/selector.vue";var ge={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 X(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:o,display:r,meta:s}=this.conditionsLookup[t];return{id:i,type:o,display:r,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return o&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:n.groupedBlueprint()}):null}},be={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,o)=>{const r=n("blueprint"),s=n("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let l;l=s?r.findCriterion(i.uid):r.addCriterion({id:e,depth:0});const a=(e,t)=>r.updateInput(l,e,t),d=e=>r.switchClause(l,e);t("criterion",l),t("criterionMeta",i.meta),t("updateInput",a),t("switchRefinement",((e,t)=>{r.switchRefinement(l,e,t)})),t("refinementId",null),u((()=>{s||r.removeCriterion(r.indexOfCriterion(l))}));let p=null;return i?.condition?.meta?.clauses&&(p=i.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:p,criterion:l,updateInput:a,switchClause:d}):null})(e.id,e,i)},ve={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,i)=>{const o=n("criterion"),r=n("updateInput"),s=n("refinementId"),l=n("builderModeActive"),a=e=>{r(e,s)};if(!o)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:e},s);const{clause:n,...i}=o.input;Object.keys(t).length>0&&0===Object.keys(i).length&&r({...t},s)}return u((()=>{l||o.input.clause===e&&r({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:a,...o.input}):null})(e.clause,e,t)},ye={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(o&&(e=this.$scopedSlots?.default),e)return e()}},we={name:"selector-option",mixins:[ne],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[ne],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};we.render=function(e,t,n,i,o,r){const s=d("renderless-option");return p(),c(s,{id:e.id,display:e.display,selected:e.selected},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["id","display","selected"])},we.__file="src/components/base/selector/selector-option.vue";var Oe={name:"refine-date-input",components:{Selector:me,SelectorOption:we,RefineFlavor:M},mixins:[oe],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]})}}};Oe.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("selector-option"),a=d("selector");return p(),c(s,{as:"div",component:"inputs.date.relative.wrapper"},{default:f((()=>[m(s,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:n.amount,onInput:r.updateAmount},null,8,["value","onInput"]),m(a,{onSelectOption:r.updateUnit},{default:f((()=>[(p(!0),_($,null,k(n.units,(e=>(p(),c(l,{key:e.id,id:e.id,display:e.display,selected:e.id===n.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),m(a,{onSelectOption:r.updateModifier},{default:f((()=>[(p(!0),_($,null,k(n.modifiers,(e=>(p(),c(l,{key:e.id,id:e.id,selected:e.id===n.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},Oe.__file="src/components/base/inputs/relative-date-input.vue";var xe={name:"refine-option-input",components:{Selector:me,SelectorOption:we},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}}};xe.render=function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector");return p(),c(l,{isMultiSelect:n.multiple,onSelectOption:r.selectOption,onDeselectOption:r.deselectOption},{default:f((()=>[(p(!0),_($,null,k(n.options,(({id:e,display:t})=>(p(),c(s,{key:e,id:e,display:t,selected:r.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},xe.__file="src/components/base/inputs/option-input.vue";var Ce={emits:["input"],components:{RefineFlavor:M},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};Ce.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.date",type:"date",value:n.date,onInput:r.handleInput},null,8,["value","onInput"])},Ce.__file="src/components/base/inputs/native-date-picker.vue";var Se={RefineDateInput:V,RefineDoubleDateInput:E,RefineDoubleNumberInput:N,RefineNumberInput:D,RefineOptionInput:xe,RefineRelativeDateInput:Oe,RefineTextInput:H,RefineNativeDatePicker:Ce},_e=Object.freeze({__proto__:null,default:Se,RefineDateInput:V,RefineDoubleDateInput:E,RefineDoubleNumberInput:N,RefineNumberInput:D,RefineOptionInput:xe,RefineRelativeDateInput:Oe,RefineTextInput:H,RefineNativeDatePicker:Ce}),$e={install:(e,t={})=>{t={DatePicker:Ce,...t},e.component("refine-date-picker",t.DatePicker)}},ke={install:(e,t={})=>{$e.install(e,t)}},Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:me}};Ie.render=function(e,t,n,i,o,r){const s=d("selector");return p(),c(s,{onSelectOption:r.selectOption},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["onSelectOption"])},Ie.__file="src/components/base/condition-selector/condition-selector.vue";var qe={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 X(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null},__file:"src/components/renderless/query.vue"},Be={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:ve,SelectorOption:we,Selector:me,..._e}};Be.render=function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector"),a=d("renderless-clause");return p(),c(a,B(R(n.input)),{default:f((({setValue:e})=>[v(" clause selector "),m(l,{onSelectOption:r.switchClause,innerClass:"refine-clause-selector"},{default:f((()=>[(p(!0),_($,null,k(n.meta.clauses,(({id:t,display:i,component:o,meta:r})=>(p(),c(s,{key:t,id:t,display:i,selected:n.input.clause===t},{default:f((()=>[o?(p(),c(j(o),h({key:0},{...n.meta,...r,...n.input},{onInput:e}),null,16,["onInput"])):v("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},Be.__file="src/components/base/query-builder/clause.vue";var Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Be,RenderlessRefinement:ye,Selector:me,SelectorOption:we},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)}}};Re.render=function(e,t,n,i,o,r){const s=d("clause"),l=d("renderless-refinement"),a=d("selector-option"),u=d("selector");return p(),c(u,{onSelectOption:r.selectRefinement},{default:f((()=>[(p(!0),_($,null,k(n.refinements,(({id:e,meta:t,display:i})=>(p(),c(a,{key:e,id:e,display:i,selected:!!n.input[e]},{default:f((()=>[m(l,{id:e},{default:f((()=>[m(s,{meta:t,input:n.input[e],onSwitchClause:({id:t})=>r.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},Re.__file="src/components/base/query-builder/refinements.vue";var je={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:Be,Refinements:Re,SelectorOption:we,Selector:me,RefineFlavor:M}};const Ae=O("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);je.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("clause"),a=d("refinements"),u=d("selector-option"),h=d("selector");return p(),c(s,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:f((()=>[n.errors.length>0?(p(),c(s,{key:0,as:"ul",component:"criterion.errors"},{default:f((()=>[(p(!0),_($,null,k(n.errors,(e=>(p(),c(s,{as:"li",component:"criterion.errors.error",key:e},{default:f((()=>[g(b(e),1)])),_:2},1024)))),128))])),_:1})):v("v-if",!0)])),selector:f((()=>[m(h,{onSelectOption:r.switchCondition},{default:f((()=>[(p(!0),_($,null,k(n.conditions,(({id:e,display:t,meta:i,refinements:o})=>(p(),c(u,{key:e,id:e,display:t,selected:n.conditionId===e},{default:f((()=>[O("div",null,[m(l,{input:n.input,meta:i,onSwitchClause:r.switchClause},null,8,["input","meta","onSwitchClause"]),o&&o.length>0?(p(),c(a,{key:0,input:n.input,refinements:o},null,8,["input","refinements"])):v("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:f((()=>[m(s,{as:"button",component:"criterion.removeCriterionButton",onClick:t[0]||(t[0]=y((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:f((()=>[m(s,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[Ae])),_:1})])),_:1})])),_:1})},je.__file="src/components/base/query-builder/criterion.vue";var Me={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>o?{}:{key:e},templateChildKey:e=>o?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var n;n=e.flavor,t(A,n)},components:{Criterion:je,RefineFlavor:M,RenderlessCondition:be,RenderlessQueryBuilder:ge}};const De=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ne=g(" Add a new condition "),He=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ve=g(" And"),Ee=g(" Add an 'Or' ");Me.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("criterion"),a=d("renderless-condition"),u=d("renderless-query-builder");return p(),c(u,{blueprint:n.blueprint,conditions:n.conditions,onChange:r.onChange},{default:f((({groupedBlueprint:e,replaceCriterion:t,insertCriterion:i,addGroup:o,removeCriterion:u,conditionFor:d})=>[v(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(p(),c(s,h({key:0,as:"div",component:"emptyGroup"},{addGroup:o},{order:["button","default"]}),{button:f((()=>[m(s,{as:"button",component:"emptyGroup.addCriterionButton",onClick:o,tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[De])),_:1}),m(s,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:f((()=>[Ne])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(p(),c(s,{key:1,as:"div",component:"group.wrapper"},{default:f((()=>[(p(!0),_($,null,k(e,((o,g)=>(p(),_($,null,[m(s,h({as:"div",component:"group"},r.templateChildKey(`group-${g}`)),{default:f((()=>[v(" This really should be named criterion, as that's what it is. "),(p(!0),_($,null,k(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:f((()=>[m(a,B(R(d({id:e.condition_id,...e}))),{default:f((({switchClause:i})=>[m(l,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>u(e.position),onSwitchCondition:n=>t(e.position,d(n)),conditionId:e.condition_id,conditions:n.conditions,errors:n.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),m(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:f((()=>[m(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.length-1].position),tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[He])),_:1}),m(s,{as:"span",component:"group.addCriterionButton.text"},{default:f((()=>[Ve])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),v(" Divider between groups. Blank by default, but used in Nova. "),m(s,h({as:"template",component:"group.divider",index:g,total:e.length},r.templateChildKey(`separator-${g}`)),null,16,["index","total"])],64)))),256)),m(s,{as:"button",component:"addGroupButton",onClick:o,type:"button"},{default:f((()=>[Ee])),_:2},1032,["onClick"])])),_:2},1024)),v(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},Me.__file="src/components/base/query-builder/query-builder.vue";const Pe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Te="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Fe=`${Pe} ${Te} w-60 pl-3 py-2`,Le={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{class:`${Pe} ${Te} h-9 h-full py-5 px-2 leading-normal box-border`,relative:{class:`${Fe} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Fe,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Fe}}},Ge="bg-white relative text-left cursor-default",ze=`${Ge} focus:outline-none pl-3 py-1`,Ke={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ge} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${ze} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${ze} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:ze}}};export{Ie as ConditionSelector,ke as DatePickerPlugin,qe as Query,Me as QueryBuilder,$e as RefinePlugin,me as Selector,we as SelectorOption,Ke as linearFlavor,Le as tailwindFlavor}; | ||
import{computed as e,provide as t,inject as n,defineComponent as i,isVue2 as o,h as r,resolveComponent as s,reactive as l,nextTick as a,onUnmounted as u}from"vue-demi";import{resolveComponent as d,openBlock as p,createBlock as c,mergeProps as h,withCtx as f,createVNode as m,createTextVNode as g,toDisplayString as b,createCommentVNode as v,withModifiers as y,withKeys as w,createElementVNode as O,renderSlot as x,withDirectives as C,vShow as S,createElementBlock as _,Fragment as $,renderList as k,resolveDirective as I,normalizeClass as q,normalizeProps as B,guardReactiveProps as R,resolveDynamicComponent as j}from"vue";const A=Symbol();let M={};var D={init(e){M=e},get:(e,t=null)=>M?.[e]??t,set(e,t){M[e]=t}};const N=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,i){let l=D.get("showLocators");const a=function(t,i,o=e((()=>({})))){const r=n(A),s=e((()=>t(r)??{})),l=e((()=>{const e={},t=o.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=o.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const n=t.component.split(".");let i=e;for(const e of n)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e((()=>t.as)),e((()=>({...i.attrs??{},...t.flavorOptions??{}}))));return()=>{const e=a.value,n=e.extra.value.order??t.order,u=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),d=i.slots;let p="string"==typeof e.component&&e.component.includes("-"),c=p?d:n.map((e=>d?.[e]?.())),h=o?r(e.component,{scopedSlots:d,attrs:{...l&&{"data-locator":t.component},...i.attrs},props:u,on:i.listeners,...e.props.value},c):r(p?s(e.component):e.component,{...l&&{"data-locator":t.component},...i.attrs,...u,...e.props.value},c);return e.extra.value.wrap?e.extra.value.wrap(h):h}}});var H={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:N}};H.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"input",component:"inputs.number",type:"number",value:o.currentValue,onInput:r.handleInputChange},r.metaAttributes),null,16,["value","onInput"])},H.__file="src/components/base/inputs/number-input.vue";var V={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:H,RefineFlavor:N}};V.render=function(e,t,n,i,o,r){const s=d("number-input"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.number.double.wrapper"},{default:f((()=>[m(s,{meta:n.meta,value:n.value1,onInput:r.updateFirstValue},null,8,["meta","value","onInput"]),r.joinWord?(p(),c(l,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:f((()=>[g(b(r.joinWord),1)])),_:1})):v("v-if",!0),m(s,{meta:n.meta,value:n.value2,onInput:r.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},V.__file="src/components/base/inputs/double-number-input.vue";var P={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:N}};P.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.text",type:"text",value:n.value,onInput:t[0]||(t[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},P.__file="src/components/base/inputs/text-input.vue";var E={name:"refine-date-input",components:{RefineFlavor:N},emits:["input"],props:{date1:{type:String,required:!1}}};E.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},E.__file="src/components/base/inputs/date-input.vue";var T={name:"refine-double-date-input",components:{RefineFlavor:N},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}}};T.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"inputs.date.double.wrapper"},{default:f((()=>[m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),m(s,{as:"p",component:"inputs.date.double.joiner"},{default:f((()=>[g(b(n.joiner),1)])),_:1}),m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date2,onInput:t[1]||(t[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},T.__file="src/components/base/inputs/double-date-input.vue";var F=e=>"conjunction"===(null==e?void 0:e.type),L=Object.defineProperty,G=Object.defineProperties,z=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,U=(e,t,n)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Y=(e,t)=>{for(var n in t||(t={}))W.call(t,n)&&U(e,n,t[n]);if(K)for(var n of K(t))Q.call(t,n)&&U(e,n,t[n]);return e},Z=(e,t)=>G(e,z(t)),J=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},X=(e,t,n,i)=>{var o,r;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:Y({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(o=null==s?void 0:s.meta)?void 0:o.clauses[0])?void 0:r.id}}),uid:J()}},ee=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:J()}},te=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?Z(Y({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||J()}):Z(Y({},e),{id:void 0,uid:J()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)W.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&K)for(var i of K(e))t.indexOf(i)<0&&Q.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{F(t)?"or"===t.word&&e.push([]):e[e.length-1].push(Z(Y({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:o}=this.findCondition(t.id),r=X(i,1,n,o);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],o=F(i)&&"or"===i.word,r=F(n)&&"or"===n.word,s=o||!i,l=r||!n,a=l&&!s,u=l&&s;!n&&!i?this.blueprint=[]:u&&r?t.splice(e-1,2):u&&!n||a?t.splice(e,2):t.splice(e-1,2),this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:o}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:J()}}()),e.push(X(n.id,1,i,o)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,o=X(t,n);return 0===i.length?i.push(o):i.splice(i.length,0,ee(),o),this.blueprintChanged(),o}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:o,refinements:r}=i;return t.splice(e+1,0,ee(),X(i.id,1,o,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:o}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(o.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const o=this.findRefinement(t,i),r=this.findCriterion(e),s=Y({},r.input);delete s[n],s[i]={clause:o.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},ne=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++){if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.")}const i=this.options[this.options.length-1]||null,o=Y({previousOption:i,nextOption:null},e);i&&(i.nextOption=o),this.options.push(o)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},ie={name:"renderless-selector",data:()=>({selector:l(new ne),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return a().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return o&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const oe={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let re=1;var se={beforeCreate(){this.uid=re.toString(),re+=1}},le={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:N}};const ae=g(" Choose an option "),ue=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);le.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.button",id:n.id,type:"button","aria-haspopup":"listbox","aria-expanded":n.isOpen,"aria-label":r.label(),ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:f((()=>[0===n.display.length?(p(),c(s,{key:0,as:"span",component:"select.button.placeholder"},{default:f((()=>[ae])),_:1})):(p(),c(s,{key:1,as:"span",component:"select.button.selected"},{default:f((()=>[g(b(n.display),1)])),_:1})),m(s,{as:"span",component:"select.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[ue])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},le.__file="src/components/base/selector/selector-button.vue";var de={name:"selector-listbox",mixins:[se],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:N}};de.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.listbox.wrapper"},{default:f((()=>[m(s,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:n.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":n.selectedOption?r.createItemId(n.selectedOption.id):"",ref:"listBox",onKeydown:[w(y(r.clearBuffer,["stop","prevent"]),["delete"]),t[0]||(t[0]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),t[1]||(t[1]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),t[2]||(t[2]=w(y((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),t[3]||(t[3]=w(y((t=>e.$emit("close")),["stop","prevent"]),["escape"])),t[4]||(t[4]=w(y((t=>e.$emit("close")),["stop","prevent"]),["tab"])),t[5]||(t[5]=e=>r.handleKeypress(e))]},{default:f((()=>[x(e.$slots,"default",{createItemId:r.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},de.__file="src/components/base/selector/selector-listbox.vue";var pe={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:N}};const ce=O("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);pe.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:n.isHighlighted},role:"option",key:n.optionId,ref:"listItem",onMouseenter:t[0]||(t[0]=t=>e.$emit("mouseenter")),onMouseleave:t[1]||(t[1]=t=>e.$emit("mouseleave")),onClick:t[2]||(t[2]=t=>e.$emit("selected")),"aria-label":n.optionDisplay,"aria-selected":n.selected},{default:f((()=>[m(s,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:n.selected}},{default:f((()=>[g(b(n.optionDisplay),1)])),_:1},8,["flavorOptions"]),m(s,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:n.isHighlighted}},{default:f((()=>[v(" Heroicon name: check "),C(m(s,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!n.selected},{default:f((()=>[ce])),_:1},8,["aria-hidden"]),[[S,n.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},pe.__file="src/components/base/selector/selector-list-item.vue";var he={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:N}};const fe=g(" Choose an option "),me=O("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),ge=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);he.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.multi.button",id:n.id,"aria-haspopup":"listbox","aria-label":r.label(),"aria-expanded":n.isOpen,ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:[t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["enter"])),t[2]||(t[2]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:f((()=>[0===n.selectedOptions.length?(p(),c(s,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:f((()=>[fe])),_:1})):(p(!0),_($,{key:1},k(n.selectedOptions,(({id:t,display:n})=>(p(),c(s,{as:"span",component:"select.multi.button.selected",key:t},{default:f((()=>[g(b(n)+" ",1),m(s,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:y((n=>e.$emit("deselect-option",t)),["prevent"])},{default:f((()=>[m(s,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[me])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),m(s,{as:"span",component:"select.multi.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[ge])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},he.__file="src/components/base/selector/multi-selector-button.vue";var be={name:"selector",mixins:[se],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const o=e=>{t.contains(e.target)||i()};e[t.id]=o,document.addEventListener("click",o),document.addEventListener("touchstart",o)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:o}=t,{isMultiSelect:r}=this;r?o(e):(n(),i(e),await this.close(t))},scrollIntoView(e){if(e){this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:he,RenderlessSelector:ie,SelectorListItem:pe,SelectorButton:le,SelectorListbox:de,RefineFlavor:N}};be.render=function(e,t,n,i,o,r){const s=d("multi-selector-button"),l=d("selector-button"),a=d("selector-list-item"),u=d("selector-listbox"),h=d("refine-flavor"),g=d("renderless-selector"),b=I("click-away");return p(),c(g,{onSelectOption:t[0]||(t[0]=t=>e.$emit("select-option",t)),onDeselectOption:t[1]||(t[1]=t=>e.$emit("deselect-option",t))},{default:f((({actions:t,isOpen:i,isClosed:o,selectedOptions:d,highlightedOption:g,options:y})=>[m(h,{as:"div",component:"select.wrapper"},{default:f((()=>[v(" Select dropdown "),C((p(),c(h,{as:"div",component:"select",class:q(n.innerClass),id:`listbox-${r.selectorId}`,"aria-labelledby":r.buttonId},{default:f((()=>[n.isMultiSelect?(p(),c(s,{key:0,id:r.buttonId,isOpen:i,selectedOptions:d,onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),onDeselectOption:e=>r.deselectOption(e,t),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(p(),c(l,{key:1,id:r.buttonId,isOpen:i,display:d[0]?d[0].display:"",onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),m(u,{selectedOption:d[0],isClosed:o,ref:"listBox",onHighlightNextOption:e=>r.highlightNextOption(t),onHighlightPreviousOption:e=>r.highlightPreviousOption(t),onSelectOption:e=>r.selectOption(g.id,t),onBufferChanged:e=>r.updateBuffer(e,y,t),onClose:e=>r.close(t)},{default:f((({createItemId:e})=>[(p(!0),_($,null,k(y,(n=>(p(),c(a,{id:e(n.id),key:n.id,optionId:n.id,optionDisplay:n.display,selected:r.isSelected(n,d),isHighlighted:g&&n.id===g.id,ref_for:!0,ref:n.id,onMouseenter:e=>t.highlightOption(n),onMouseleave:e=>t.highlightOption(null),onSelected:e=>r.selectOption(n.id,t)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[b,t.close]]),v(" Custom options "),m(h,{as:"div",component:"customOptions.wrapper"},{default:f((()=>[x(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},be.__file="src/components/base/selector/selector.vue";var ve={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new te(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:o,display:r,meta:s}=this.conditionsLookup[t];return{id:i,type:o,display:r,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return o&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:n.groupedBlueprint()}):null}},ye={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,o)=>{const r=n("blueprint"),s=n("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let l;l=s?r.findCriterion(i.uid):r.addCriterion({id:e,depth:0});const a=(e,t)=>r.updateInput(l,e,t),d=e=>r.switchClause(l,e);t("criterion",l),t("criterionMeta",i.meta),t("updateInput",a),t("switchRefinement",((e,t)=>{r.switchRefinement(l,e,t)})),t("refinementId",null),u((()=>{s||r.removeCriterion(r.indexOfCriterion(l))}));let p=null;return i?.condition?.meta?.clauses&&(p=i.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:p,criterion:l,updateInput:a,switchClause:d}):null})(e.id,e,i)},we={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,i)=>{const o=n("criterion"),r=n("updateInput"),s=n("refinementId"),l=n("builderModeActive"),a=e=>{r(e,s)};if(!o)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:e},s);const{clause:n,...i}=o.input;Object.keys(t).length>0&&0===Object.keys(i).length&&r({...t},s)}return u((()=>{l||o.input.clause===e&&r({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:a,...o.input}):null})(e.clause,e,t)},Oe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(o&&(e=this.$scopedSlots?.default),e)return e()}},xe={name:"selector-option",mixins:[oe],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[oe],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t&&e?t():null}}}};xe.render=function(e,t,n,i,o,r){const s=d("renderless-option");return p(),c(s,{id:e.id,display:e.display,selected:e.selected},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["id","display","selected"])},xe.__file="src/components/base/selector/selector-option.vue";var Ce={name:"refine-date-input",components:{Selector:be,SelectorOption:xe,RefineFlavor:N},mixins:[se],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}}};Ce.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("selector-option"),a=d("selector");return p(),c(s,{as:"div",component:"inputs.date.relative.wrapper"},{default:f((()=>[m(s,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:n.amount,onInput:r.updateAmount},null,8,["value","onInput"]),m(a,{onSelectOption:r.updateUnit},{default:f((()=>[(p(!0),_($,null,k(n.units,(e=>(p(),c(l,{key:e.id,id:e.id,display:e.display,selected:e.id===n.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),m(a,{onSelectOption:r.updateModifier},{default:f((()=>[(p(!0),_($,null,k(n.modifiers,(e=>(p(),c(l,{key:e.id,id:e.id,selected:e.id===n.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},Ce.__file="src/components/base/inputs/relative-date-input.vue";var Se={name:"refine-option-input",components:{Selector:be,SelectorOption:xe},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}}};Se.render=function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector");return p(),c(l,{isMultiSelect:n.multiple,onSelectOption:r.selectOption,onDeselectOption:r.deselectOption},{default:f((()=>[(p(!0),_($,null,k(n.options,(({id:e,display:t})=>(p(),c(s,{key:e,id:e,display:t,selected:r.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},Se.__file="src/components/base/inputs/option-input.vue";var _e={emits:["input"],components:{RefineFlavor:N},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}}};_e.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.date",type:"date",value:n.date,onInput:r.handleInput},null,8,["value","onInput"])},_e.__file="src/components/base/inputs/native-date-picker.vue";var $e={RefineDateInput:E,RefineDoubleDateInput:T,RefineDoubleNumberInput:V,RefineNumberInput:H,RefineOptionInput:Se,RefineRelativeDateInput:Ce,RefineTextInput:P,RefineNativeDatePicker:_e},ke=Object.freeze({__proto__:null,default:$e,RefineDateInput:E,RefineDoubleDateInput:T,RefineDoubleNumberInput:V,RefineNumberInput:H,RefineOptionInput:Se,RefineRelativeDateInput:Ce,RefineTextInput:P,RefineNativeDatePicker:_e}),Ie={install:(e,t={})=>{t={DatePicker:_e,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,D.init(t)}},qe={install:(e,t={})=>{Ie.install(e,t)}},Be={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:be}};Be.render=function(e,t,n,i,o,r){const s=d("selector");return p(),c(s,{onSelectOption:r.selectOption},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["onSelectOption"])},Be.__file="src/components/base/condition-selector/condition-selector.vue";var Re={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new te(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null},__file:"src/components/renderless/query.vue"},je={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:we,SelectorOption:xe,Selector:be,...ke}};je.render=function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector"),a=d("renderless-clause");return p(),c(a,B(R(n.input)),{default:f((({setValue:e})=>[v(" clause selector "),m(l,{onSelectOption:r.switchClause,innerClass:"refine-clause-selector"},{default:f((()=>[(p(!0),_($,null,k(n.meta.clauses,(({id:t,display:i,component:o,meta:r})=>(p(),c(s,{key:t,id:t,display:i,selected:n.input.clause===t},{default:f((()=>[o?(p(),c(j(o),h({key:0},{...n.meta,...r,...n.input},{onInput:e}),null,16,["onInput"])):v("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},je.__file="src/components/base/query-builder/clause.vue";var Ae={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:je,RenderlessRefinement:Oe,Selector:be,SelectorOption:xe},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}}};Ae.render=function(e,t,n,i,o,r){const s=d("clause"),l=d("renderless-refinement"),a=d("selector-option"),u=d("selector");return p(),c(u,{onSelectOption:r.selectRefinement},{default:f((()=>[(p(!0),_($,null,k(n.refinements,(({id:e,meta:t,display:i})=>(p(),c(a,{key:e,id:e,display:i,selected:!!n.input[e]},{default:f((()=>[m(l,{id:e},{default:f((()=>[m(s,{meta:t,input:n.input[e],onSwitchClause:({id:t})=>r.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},Ae.__file="src/components/base/query-builder/refinements.vue";var Me={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:je,Refinements:Ae,SelectorOption:xe,Selector:be,RefineFlavor:N}};const De=O("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);Me.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("clause"),a=d("refinements"),u=d("selector-option"),h=d("selector");return p(),c(s,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:f((()=>[n.errors.length>0?(p(),c(s,{key:0,as:"ul",component:"criterion.errors"},{default:f((()=>[(p(!0),_($,null,k(n.errors,(e=>(p(),c(s,{as:"li",component:"criterion.errors.error",key:e},{default:f((()=>[g(b(e),1)])),_:2},1024)))),128))])),_:1})):v("v-if",!0)])),selector:f((()=>[m(h,{onSelectOption:r.switchCondition},{default:f((()=>[(p(!0),_($,null,k(n.conditions,(({id:e,display:t,meta:i,refinements:o})=>(p(),c(u,{key:e,id:e,display:t,selected:n.conditionId===e},{default:f((()=>[O("div",null,[m(l,{input:n.input,meta:i,onSwitchClause:r.switchClause},null,8,["input","meta","onSwitchClause"]),o&&o.length>0?(p(),c(a,{key:0,input:n.input,refinements:o},null,8,["input","refinements"])):v("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:f((()=>[m(s,{as:"button",component:"criterion.removeCriterionButton",onClick:t[0]||(t[0]=y((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:f((()=>[m(s,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[De])),_:1})])),_:1})])),_:1})},Me.__file="src/components/base/query-builder/criterion.vue";var Ne={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>o?{}:{key:e},templateChildKey:e=>o?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var n;n=e.flavor,t(A,n)},components:{Criterion:Me,RefineFlavor:N,RenderlessCondition:ye,RenderlessQueryBuilder:ve}};const He=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ve=g(" Add a new condition "),Pe=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ee=g(" And"),Te=g(" Add an 'Or' ");Ne.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("criterion"),a=d("renderless-condition"),u=d("renderless-query-builder");return p(),c(u,{blueprint:n.blueprint,conditions:n.conditions,onChange:r.onChange},{default:f((({groupedBlueprint:e,replaceCriterion:t,insertCriterion:i,addGroup:o,removeCriterion:u,conditionFor:d})=>[v(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(p(),c(s,h({key:0,as:"div",component:"emptyGroup"},{addGroup:o},{order:["button","default"]}),{button:f((()=>[m(s,{as:"button",component:"emptyGroup.addCriterionButton",onClick:o,tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[He])),_:1}),m(s,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:f((()=>[Ve])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(p(),c(s,{key:1,as:"div",component:"group.wrapper"},{default:f((()=>[(p(!0),_($,null,k(e,((o,g)=>(p(),_($,null,[m(s,h({as:"div",component:"group"},r.templateChildKey(`group-${g}`)),{default:f((()=>[v(" This really should be named criterion, as that's what it is. "),(p(!0),_($,null,k(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:f((()=>[m(a,B(R(d({id:e.condition_id,...e}))),{default:f((({switchClause:i})=>[m(l,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>u(e.position),onSwitchCondition:n=>t(e.position,d(n)),conditionId:e.condition_id,conditions:n.conditions,errors:n.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),m(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:f((()=>[m(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.length-1].position),tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[Pe])),_:1}),m(s,{as:"span",component:"group.addCriterionButton.text"},{default:f((()=>[Ee])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),v(" Divider between groups. Blank by default, but used in Nova. "),m(s,h({as:"template",component:"group.divider",index:g,total:e.length},r.templateChildKey(`separator-${g}`)),null,16,["index","total"])],64)))),256)),m(s,{as:"button",component:"addGroupButton",onClick:o,type:"button"},{default:f((()=>[Te])),_:2},1032,["onClick"])])),_:2},1024)),v(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},Ne.__file="src/components/base/query-builder/query-builder.vue";const Fe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Le="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Ge=`${Fe} ${Le} w-60 pl-3 py-2`,ze={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Fe} ${Le} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${Ge} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:Ge,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:Ge}},Ke="bg-white relative text-left cursor-default",We=`${Ke} focus:outline-none pl-3 py-1`,Qe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ke} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${We} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${We} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:We}}};export{Be as ConditionSelector,qe as DatePickerPlugin,Re as Query,Ne as QueryBuilder,Ie as RefinePlugin,be as Selector,xe as SelectorOption,Qe as linearFlavor,ze as tailwindFlavor}; | ||
//# sourceMappingURL=refine-vue.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import{computed as e,provide as t,inject as n,defineComponent as i,isVue2 as o,h as r,resolveComponent as s,reactive as l,nextTick as a,onUnmounted as u}from"vue-demi";import{resolveComponent as d,openBlock as p,createBlock as c,mergeProps as h,withCtx as f,createVNode as m,createTextVNode as g,toDisplayString as b,createCommentVNode as v,withModifiers as y,withKeys as w,createElementVNode as O,renderSlot as x,withDirectives as C,vShow as S,createElementBlock as _,Fragment as k,renderList as $,resolveDirective as I,normalizeClass as q,normalizeProps as B,guardReactiveProps as R,resolveDynamicComponent as j}from"vue";const A=Symbol(),D=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,i){const l=function(t,i,o=e((()=>({})))){const r=n(A),s=e((()=>t(r)??{})),l=e((()=>{const e={},t=o.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=o.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const n=t.component.split(".");let i=e;for(const e of n)i=i?.[e];return i}),e((()=>t.as)),e((()=>({...i.attrs??{},...t.flavorOptions??{}}))));return()=>{const e=l.value,n=e.extra.value.order??t.order,a=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),u=i.slots;let d="string"==typeof e.component&&e.component.includes("-"),p=d?u:n.map((e=>u?.[e]?.())),c=o?r(e.component,{scopedSlots:u,attrs:{...i.attrs,"data-flavor":t.component},props:a,on:i.listeners,...e.props.value},p):r(d?s(e.component):e.component,{...i.attrs,"data-flavor":t.component,...a,...e.props.value},p);return e.extra.value.wrap?e.extra.value.wrap(c):c}}});var M={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:D},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"input",component:"inputs.number",type:"number",value:o.currentValue,onInput:r.handleInputChange},r.metaAttributes),null,16,["value","onInput"])},__file:"src/components/base/inputs/number-input.vue"},N={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:D},render:function(e,t,n,i,o,r){const s=d("number-input"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.number.double.wrapper"},{default:f((()=>[m(s,{meta:n.meta,value:n.value1,onInput:r.updateFirstValue},null,8,["meta","value","onInput"]),r.joinWord?(p(),c(l,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:f((()=>[g(b(r.joinWord),1)])),_:1})):v("v-if",!0),m(s,{meta:n.meta,value:n.value2,onInput:r.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},__file:"src/components/base/inputs/double-number-input.vue"},V={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:D},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.text",type:"text",value:n.value,onInput:t[0]||(t[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},__file:"src/components/base/inputs/text-input.vue"},P={name:"refine-date-input",components:{RefineFlavor:D},emits:["input"],props:{date1:{type:String,required:!1}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},__file:"src/components/base/inputs/date-input.vue"},E={name:"refine-double-date-input",components:{RefineFlavor:D},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"inputs.date.double.wrapper"},{default:f((()=>[m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),m(s,{as:"p",component:"inputs.date.double.joiner"},{default:f((()=>[g(b(n.joiner),1)])),_:1}),m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date2,onInput:t[1]||(t[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},__file:"src/components/base/inputs/double-date-input.vue"},F=e=>"conjunction"===(null==e?void 0:e.type),H=Object.defineProperty,T=Object.defineProperties,L=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,W=(e,t,n)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t)=>{for(var n in t||(t={}))G.call(t,n)&&W(e,n,t[n]);if(z)for(var n of z(t))K.call(t,n)&&W(e,n,t[n]);return e},U=(e,t)=>T(e,L(t)),Y=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},Z=(e,t,n,i)=>{var o,r;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:Q({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(o=null==s?void 0:s.meta)?void 0:o.clauses[0])?void 0:r.id}}),uid:Y()}},J=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:Y()}},X=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?U(Q({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||Y()}):U(Q({},e),{id:void 0,uid:Y()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)G.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&z)for(var i of z(e))t.indexOf(i)<0&&K.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{F(t)?"or"===t.word&&e.push([]):e[e.length-1].push(U(Q({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:o}=this.findCondition(t.id),r=Z(i,1,n,o);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],o=F(i)&&"or"===i.word,r=F(n)&&"or"===n.word,s=o||!i,l=r||!n,a=l&&!s,u=l&&s;n||i?u&&r?t.splice(e-1,2):u&&!n||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:o}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:Y()}}()),e.push(Z(n.id,1,i,o)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,o=Z(t,n);return 0===i.length?i.push(o):i.splice(i.length,0,J(),o),this.blueprintChanged(),o}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:o,refinements:r}=i;return t.splice(e+1,0,J(),Z(i.id,1,o,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:o}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(o.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const o=this.findRefinement(t,i),r=this.findCriterion(e),s=Q({},r.input);delete s[n],s[i]={clause:o.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},ee=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++)if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const i=this.options[this.options.length-1]||null,o=Q({previousOption:i,nextOption:null},e);i&&(i.nextOption=o),this.options.push(o)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},te={name:"renderless-selector",data:()=>({selector:l(new ee),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return a().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return o&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const ne={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let ie=1;var oe={beforeCreate(){this.uid=ie.toString(),ie+=1}},re={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:D}};const se=g(" Choose an option "),le=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);re.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.button",id:n.id,type:"button","aria-haspopup":"listbox","aria-expanded":n.isOpen,"aria-label":r.label(),ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:f((()=>[0===n.display.length?(p(),c(s,{key:0,as:"span",component:"select.button.placeholder"},{default:f((()=>[se])),_:1})):(p(),c(s,{key:1,as:"span",component:"select.button.selected"},{default:f((()=>[g(b(n.display),1)])),_:1})),m(s,{as:"span",component:"select.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[le])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},re.__file="src/components/base/selector/selector-button.vue";var ae={name:"selector-listbox",mixins:[oe],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:D},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.listbox.wrapper"},{default:f((()=>[m(s,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:n.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":n.selectedOption?r.createItemId(n.selectedOption.id):"",ref:"listBox",onKeydown:[w(y(r.clearBuffer,["stop","prevent"]),["delete"]),t[0]||(t[0]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),t[1]||(t[1]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),t[2]||(t[2]=w(y((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),t[3]||(t[3]=w(y((t=>e.$emit("close")),["stop","prevent"]),["escape"])),t[4]||(t[4]=w(y((t=>e.$emit("close")),["stop","prevent"]),["tab"])),t[5]||(t[5]=e=>r.handleKeypress(e))]},{default:f((()=>[x(e.$slots,"default",{createItemId:r.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},__file:"src/components/base/selector/selector-listbox.vue"},ue={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:D}};const de=O("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);ue.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:n.isHighlighted},role:"option",key:n.optionId,ref:"listItem",onMouseenter:t[0]||(t[0]=t=>e.$emit("mouseenter")),onMouseleave:t[1]||(t[1]=t=>e.$emit("mouseleave")),onClick:t[2]||(t[2]=t=>e.$emit("selected")),"aria-label":n.optionDisplay,"aria-selected":n.selected},{default:f((()=>[m(s,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:n.selected}},{default:f((()=>[g(b(n.optionDisplay),1)])),_:1},8,["flavorOptions"]),m(s,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:n.isHighlighted}},{default:f((()=>[v(" Heroicon name: check "),C(m(s,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!n.selected},{default:f((()=>[de])),_:1},8,["aria-hidden"]),[[S,n.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},ue.__file="src/components/base/selector/selector-list-item.vue";var pe={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:D}};const ce=g(" Choose an option "),he=O("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),fe=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);pe.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.multi.button",id:n.id,"aria-haspopup":"listbox","aria-label":r.label(),"aria-expanded":n.isOpen,ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:[t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["enter"])),t[2]||(t[2]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:f((()=>[0===n.selectedOptions.length?(p(),c(s,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:f((()=>[ce])),_:1})):(p(!0),_(k,{key:1},$(n.selectedOptions,(({id:t,display:n})=>(p(),c(s,{as:"span",component:"select.multi.button.selected",key:t},{default:f((()=>[g(b(n)+" ",1),m(s,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:y((n=>e.$emit("deselect-option",t)),["prevent"])},{default:f((()=>[m(s,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[he])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),m(s,{as:"span",component:"select.multi.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[fe])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},pe.__file="src/components/base/selector/multi-selector-button.vue";var me={name:"selector",mixins:[oe],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const o=e=>{t.contains(e.target)||i()};e[t.id]=o,document.addEventListener("click",o),document.addEventListener("touchstart",o)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:o}=t,{isMultiSelect:r}=this;r?o(e):(n(),i(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:pe,RenderlessSelector:te,SelectorListItem:ue,SelectorButton:re,SelectorListbox:ae,RefineFlavor:D},render:function(e,t,n,i,o,r){const s=d("multi-selector-button"),l=d("selector-button"),a=d("selector-list-item"),u=d("selector-listbox"),h=d("refine-flavor"),g=d("renderless-selector"),b=I("click-away");return p(),c(g,{onSelectOption:t[0]||(t[0]=t=>e.$emit("select-option",t)),onDeselectOption:t[1]||(t[1]=t=>e.$emit("deselect-option",t))},{default:f((({actions:t,isOpen:i,isClosed:o,selectedOptions:d,highlightedOption:g,options:y})=>[m(h,{as:"div",component:"select.wrapper"},{default:f((()=>[v(" Select dropdown "),C((p(),c(h,{as:"div",component:"select",class:q(n.innerClass),id:`listbox-${r.selectorId}`,"aria-labelledby":r.buttonId},{default:f((()=>[n.isMultiSelect?(p(),c(s,{key:0,id:r.buttonId,isOpen:i,selectedOptions:d,onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),onDeselectOption:e=>r.deselectOption(e,t),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(p(),c(l,{key:1,id:r.buttonId,isOpen:i,display:d[0]?d[0].display:"",onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),m(u,{selectedOption:d[0],isClosed:o,ref:"listBox",onHighlightNextOption:e=>r.highlightNextOption(t),onHighlightPreviousOption:e=>r.highlightPreviousOption(t),onSelectOption:e=>r.selectOption(g.id,t),onBufferChanged:e=>r.updateBuffer(e,y,t),onClose:e=>r.close(t)},{default:f((({createItemId:e})=>[(p(!0),_(k,null,$(y,(n=>(p(),c(a,{id:e(n.id),key:n.id,optionId:n.id,optionDisplay:n.display,selected:r.isSelected(n,d),isHighlighted:g&&n.id===g.id,ref_for:!0,ref:n.id,onMouseenter:e=>t.highlightOption(n),onMouseleave:e=>t.highlightOption(null),onSelected:e=>r.selectOption(n.id,t)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[b,t.close]]),v(" Custom options "),m(h,{as:"div",component:"customOptions.wrapper"},{default:f((()=>[x(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},__file:"src/components/base/selector/selector.vue"},ge={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 X(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:o,display:r,meta:s}=this.conditionsLookup[t];return{id:i,type:o,display:r,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return o&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:n.groupedBlueprint()}):null}},be={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,o)=>{const r=n("blueprint"),s=n("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let l;l=s?r.findCriterion(i.uid):r.addCriterion({id:e,depth:0});const a=(e,t)=>r.updateInput(l,e,t),d=e=>r.switchClause(l,e);t("criterion",l),t("criterionMeta",i.meta),t("updateInput",a),t("switchRefinement",((e,t)=>{r.switchRefinement(l,e,t)})),t("refinementId",null),u((()=>{s||r.removeCriterion(r.indexOfCriterion(l))}));let p=null;return i?.condition?.meta?.clauses&&(p=i.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:p,criterion:l,updateInput:a,switchClause:d}):null})(e.id,e,i)},ve={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,i)=>{const o=n("criterion"),r=n("updateInput"),s=n("refinementId"),l=n("builderModeActive"),a=e=>{r(e,s)};if(!o)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:e},s);const{clause:n,...i}=o.input;Object.keys(t).length>0&&0===Object.keys(i).length&&r({...t},s)}return u((()=>{l||o.input.clause===e&&r({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:a,...o.input}):null})(e.clause,e,t)},ye={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(o&&(e=this.$scopedSlots?.default),e)return e()}},we={name:"selector-option",mixins:[ne],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[ne],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t&&e?t():null}}},render:function(e,t,n,i,o,r){const s=d("renderless-option");return p(),c(s,{id:e.id,display:e.display,selected:e.selected},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["id","display","selected"])},__file:"src/components/base/selector/selector-option.vue"},Oe={name:"refine-date-input",components:{Selector:me,SelectorOption:we,RefineFlavor:D},mixins:[oe],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}},render:function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("selector-option"),a=d("selector");return p(),c(s,{as:"div",component:"inputs.date.relative.wrapper"},{default:f((()=>[m(s,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:n.amount,onInput:r.updateAmount},null,8,["value","onInput"]),m(a,{onSelectOption:r.updateUnit},{default:f((()=>[(p(!0),_(k,null,$(n.units,(e=>(p(),c(l,{key:e.id,id:e.id,display:e.display,selected:e.id===n.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),m(a,{onSelectOption:r.updateModifier},{default:f((()=>[(p(!0),_(k,null,$(n.modifiers,(e=>(p(),c(l,{key:e.id,id:e.id,selected:e.id===n.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},__file:"src/components/base/inputs/relative-date-input.vue"},xe={name:"refine-option-input",components:{Selector:me,SelectorOption:we},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}},render:function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector");return p(),c(l,{isMultiSelect:n.multiple,onSelectOption:r.selectOption,onDeselectOption:r.deselectOption},{default:f((()=>[(p(!0),_(k,null,$(n.options,(({id:e,display:t})=>(p(),c(s,{key:e,id:e,display:t,selected:r.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},__file:"src/components/base/inputs/option-input.vue"},Ce={emits:["input"],components:{RefineFlavor:D},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.date",type:"date",value:n.date,onInput:r.handleInput},null,8,["value","onInput"])},__file:"src/components/base/inputs/native-date-picker.vue"},Se={RefineDateInput:P,RefineDoubleDateInput:E,RefineDoubleNumberInput:N,RefineNumberInput:M,RefineOptionInput:xe,RefineRelativeDateInput:Oe,RefineTextInput:V,RefineNativeDatePicker:Ce},_e=Object.freeze({__proto__:null,default:Se,RefineDateInput:P,RefineDoubleDateInput:E,RefineDoubleNumberInput:N,RefineNumberInput:M,RefineOptionInput:xe,RefineRelativeDateInput:Oe,RefineTextInput:V,RefineNativeDatePicker:Ce}),ke={install:(e,t={})=>{t={DatePicker:Ce,...t},e.component("refine-date-picker",t.DatePicker)}},$e={install:(e,t={})=>{ke.install(e,t)}},Ie={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:me},render:function(e,t,n,i,o,r){const s=d("selector");return p(),c(s,{onSelectOption:r.selectOption},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["onSelectOption"])},__file:"src/components/base/condition-selector/condition-selector.vue"},qe={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 X(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null},__file:"src/components/renderless/query.vue"},Be={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:ve,SelectorOption:we,Selector:me,..._e},render:function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector"),a=d("renderless-clause");return p(),c(a,B(R(n.input)),{default:f((({setValue:e})=>[v(" clause selector "),m(l,{onSelectOption:r.switchClause,innerClass:"refine-clause-selector"},{default:f((()=>[(p(!0),_(k,null,$(n.meta.clauses,(({id:t,display:i,component:o,meta:r})=>(p(),c(s,{key:t,id:t,display:i,selected:n.input.clause===t},{default:f((()=>[o?(p(),c(j(o),h({key:0},{...n.meta,...r,...n.input},{onInput:e}),null,16,["onInput"])):v("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},__file:"src/components/base/query-builder/clause.vue"},Re={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:Be,RenderlessRefinement:ye,Selector:me,SelectorOption:we},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}},render:function(e,t,n,i,o,r){const s=d("clause"),l=d("renderless-refinement"),a=d("selector-option"),u=d("selector");return p(),c(u,{onSelectOption:r.selectRefinement},{default:f((()=>[(p(!0),_(k,null,$(n.refinements,(({id:e,meta:t,display:i})=>(p(),c(a,{key:e,id:e,display:i,selected:!!n.input[e]},{default:f((()=>[m(l,{id:e},{default:f((()=>[m(s,{meta:t,input:n.input[e],onSwitchClause:({id:t})=>r.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},__file:"src/components/base/query-builder/refinements.vue"},je={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:Be,Refinements:Re,SelectorOption:we,Selector:me,RefineFlavor:D}};const Ae=O("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);je.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("clause"),a=d("refinements"),u=d("selector-option"),h=d("selector");return p(),c(s,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:f((()=>[n.errors.length>0?(p(),c(s,{key:0,as:"ul",component:"criterion.errors"},{default:f((()=>[(p(!0),_(k,null,$(n.errors,(e=>(p(),c(s,{as:"li",component:"criterion.errors.error",key:e},{default:f((()=>[g(b(e),1)])),_:2},1024)))),128))])),_:1})):v("v-if",!0)])),selector:f((()=>[m(h,{onSelectOption:r.switchCondition},{default:f((()=>[(p(!0),_(k,null,$(n.conditions,(({id:e,display:t,meta:i,refinements:o})=>(p(),c(u,{key:e,id:e,display:t,selected:n.conditionId===e},{default:f((()=>[O("div",null,[m(l,{input:n.input,meta:i,onSwitchClause:r.switchClause},null,8,["input","meta","onSwitchClause"]),o&&o.length>0?(p(),c(a,{key:0,input:n.input,refinements:o},null,8,["input","refinements"])):v("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:f((()=>[m(s,{as:"button",component:"criterion.removeCriterionButton",onClick:t[0]||(t[0]=y((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:f((()=>[m(s,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[Ae])),_:1})])),_:1})])),_:1})},je.__file="src/components/base/query-builder/criterion.vue";var De={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>o?{}:{key:e},templateChildKey:e=>o?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var n;n=e.flavor,t(A,n)},components:{Criterion:je,RefineFlavor:D,RenderlessCondition:be,RenderlessQueryBuilder:ge}};const Me=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Ne=g(" Add a new condition "),Ve=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Pe=g(" And"),Ee=g(" Add an 'Or' ");De.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("criterion"),a=d("renderless-condition"),u=d("renderless-query-builder");return p(),c(u,{blueprint:n.blueprint,conditions:n.conditions,onChange:r.onChange},{default:f((({groupedBlueprint:e,replaceCriterion:t,insertCriterion:i,addGroup:o,removeCriterion:u,conditionFor:d})=>[v(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(p(),c(s,h({key:0,as:"div",component:"emptyGroup"},{addGroup:o},{order:["button","default"]}),{button:f((()=>[m(s,{as:"button",component:"emptyGroup.addCriterionButton",onClick:o,tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[Me])),_:1}),m(s,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:f((()=>[Ne])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(p(),c(s,{key:1,as:"div",component:"group.wrapper"},{default:f((()=>[(p(!0),_(k,null,$(e,((o,g)=>(p(),_(k,null,[m(s,h({as:"div",component:"group"},r.templateChildKey(`group-${g}`)),{default:f((()=>[v(" This really should be named criterion, as that's what it is. "),(p(!0),_(k,null,$(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:f((()=>[m(a,B(R(d({id:e.condition_id,...e}))),{default:f((({switchClause:i})=>[m(l,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>u(e.position),onSwitchCondition:n=>t(e.position,d(n)),conditionId:e.condition_id,conditions:n.conditions,errors:n.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),m(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:f((()=>[m(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.length-1].position),tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[Ve])),_:1}),m(s,{as:"span",component:"group.addCriterionButton.text"},{default:f((()=>[Pe])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),v(" Divider between groups. Blank by default, but used in Nova. "),m(s,h({as:"template",component:"group.divider",index:g,total:e.length},r.templateChildKey(`separator-${g}`)),null,16,["index","total"])],64)))),256)),m(s,{as:"button",component:"addGroupButton",onClick:o,type:"button"},{default:f((()=>[Ee])),_:2},1032,["onClick"])])),_:2},1024)),v(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},De.__file="src/components/base/query-builder/query-builder.vue";const Fe="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",He="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",Te=`${Fe} ${He} w-60 pl-3 py-2`,Le={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:{class:"space-y-4"},addCriterionButton:{wrapper:{},class:"flex items-center rounded text-sm text-gray-600",icon:{class:"h-4 w-4"},text:{}}},addGroupButton:{class:"px-2 py-1 bg-blue-500 text-white rounded"},criterion:{wrapper:{order:["errors","selector","remove"],class:"flex flex-wrap gap-x-2 gap-y-4"},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:{class:"h-5 w-5"}},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:{class:"text-red-600 font-semibold"}}},select:{class:" sm:inline-block w-60",wrapper:{class:"flex items-start gap-4"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex p-1 mr-1 border border-gray-300 rounded"},deselect:{icon:{class:"w-4 h-4",wrapper:{class:"flex items-center ml-1 text-gray-500 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-400",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{class:`${Fe} ${He} h-9 h-full py-5 px-2 leading-normal box-border`,relative:{class:`${Te} mr-4`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:Te,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Te}}},ze="bg-white relative text-left cursor-default",Ge=`${ze} focus:outline-none pl-3 py-1`,Ke={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},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:`${ze} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${Ge} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${Ge} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:Ge}}};export{Ie as ConditionSelector,$e as DatePickerPlugin,qe as Query,De as QueryBuilder,ke as RefinePlugin,me as Selector,we as SelectorOption,Ke as linearFlavor,Le as tailwindFlavor}; | ||
import{computed as e,provide as t,inject as n,defineComponent as i,isVue2 as o,h as r,resolveComponent as s,reactive as l,nextTick as a,onUnmounted as u}from"vue-demi";import{resolveComponent as d,openBlock as p,createBlock as c,mergeProps as h,withCtx as f,createVNode as m,createTextVNode as g,toDisplayString as b,createCommentVNode as v,withModifiers as y,withKeys as w,createElementVNode as O,renderSlot as x,withDirectives as C,vShow as S,createElementBlock as _,Fragment as k,renderList as $,resolveDirective as I,normalizeClass as q,normalizeProps as B,guardReactiveProps as R,resolveDynamicComponent as j}from"vue";const A=Symbol();let D={};var M={init(e){D=e},get:(e,t=null)=>D?.[e]??t,set(e,t){D[e]=t}};const N=i({name:"RefineFlavor",props:{as:{type:String,default:"div"},order:{type:Array,default:()=>["default"]},component:{type:String,required:!0},flavorOptions:{type:Object,required:!1}},inheritAttrs:!1,setup(t,i){let l=M.get("showLocators");const a=function(t,i,o=e((()=>({})))){const r=n(A),s=e((()=>t(r)??{})),l=e((()=>{const e={},t=o.value??{};let n=s.value.order;return n&&(e.order="function"==typeof n?n(t):n),e.wrap=s.value.wrap,e})),a=e((()=>{const e={},t=o.value??{},n=s.value.class;n&&(e.class="function"==typeof n?n(t):n);const i=s.value.style;return i&&(e.style="function"==typeof i?i(t):i),e}));return e((()=>({component:s.value.component??i.value,props:a,extra:l})))}((e=>{const n=t.component.split(".");let i=e;for(const e of n)i=i?.[e];return"string"!=typeof i&&"function"!=typeof i||(i={class:i}),i}),e((()=>t.as)),e((()=>({...i.attrs??{},...t.flavorOptions??{}}))));return()=>{const e=a.value,n=e.extra.value.order??t.order,u=function(e,t=[]){const n=Object.assign({},e);for(const e of t)e in n&&delete n[e];return n}(t,["as","component","order"]),d=i.slots;let p="string"==typeof e.component&&e.component.includes("-"),c=p?d:n.map((e=>d?.[e]?.())),h=o?r(e.component,{scopedSlots:d,attrs:{...l&&{"data-locator":t.component},...i.attrs},props:u,on:i.listeners,...e.props.value},c):r(p?s(e.component):e.component,{...l&&{"data-locator":t.component},...i.attrs,...u,...e.props.value},c);return e.extra.value.wrap?e.extra.value.wrap(h):h}}});var V={name:"refine-number-input",data(){return{currentValue:this.value1}},emits:["input"],props:{value1:{type:[Number,String],required:!1},meta:{type:Object,required:!1,default:()=>({})}},computed:{metaAttributes(){return["min","max","step","placeholder"].reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(this.meta,t)&&""!==this.meta[t]&&(e[t]=this.meta[t]),e)),{})}},methods:{handleInputChange:function(e){const t=e.target.value,n=Number(t);isNaN(n)?this.currentValue=t:(this.currentValue=n,this.$emit("input",{value1:n}))}},components:{RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"input",component:"inputs.number",type:"number",value:o.currentValue,onInput:r.handleInputChange},r.metaAttributes),null,16,["value","onInput"])},__file:"src/components/base/inputs/number-input.vue"},P={name:"refine-double-number-input",data(){return{currentValue:this.value}},emits:["input"],computed:{joinWord(){return Object.prototype.hasOwnProperty.call(this.meta,"joiner")?this.meta.joiner:"and"}},methods:{updateFirstValue:function({value1:e}){this.$emit("input",{value1:e})},updateSecondValue:function({value1:e}){this.$emit("input",{value2:e})}},props:{value1:{type:[String,Number],required:!1},value2:{type:[String,Number],required:!1},meta:{type:Object,required:!1,default:()=>({})}},components:{NumberInput:V,RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("number-input"),l=d("refine-flavor");return p(),c(l,{as:"div",component:"inputs.number.double.wrapper"},{default:f((()=>[m(s,{meta:n.meta,value:n.value1,onInput:r.updateFirstValue},null,8,["meta","value","onInput"]),r.joinWord?(p(),c(l,{key:0,as:"span",component:"inputs.number.double.joiner"},{default:f((()=>[g(b(r.joinWord),1)])),_:1})):v("v-if",!0),m(s,{meta:n.meta,value:n.value2,onInput:r.updateSecondValue},null,8,["meta","value","onInput"])])),_:1})},__file:"src/components/base/inputs/double-number-input.vue"},E={name:"refine-text-input",props:{value:{type:String,required:!1,default:""}},emits:["input"],components:{RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.text",type:"text",value:n.value,onInput:t[0]||(t[0]=t=>e.$emit("input",{value:t.target.value}))},null,8,["value"])},__file:"src/components/base/inputs/text-input.vue"},F={name:"refine-date-input",components:{RefineFlavor:N},emits:["input"],props:{date1:{type:String,required:!1}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"])},__file:"src/components/base/inputs/date-input.vue"},H={name:"refine-double-date-input",components:{RefineFlavor:N},emits:["input"],props:{date1:{type:String,required:!1},date2:{type:String,required:!1},joiner:{type:String,required:!1,default:"and"}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"inputs.date.double.wrapper"},{default:f((()=>[m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date1,onInput:t[0]||(t[0]=t=>e.$emit("input",{date1:t.value}))}),null,16,["date"]),m(s,{as:"p",component:"inputs.date.double.joiner"},{default:f((()=>[g(b(n.joiner),1)])),_:1}),m(s,h({as:"refine-date-picker",component:"inputs.date"},e.$attrs,{date:n.date2,onInput:t[1]||(t[1]=t=>e.$emit("input",{date2:t.value}))}),null,16,["date"])])),_:1})},__file:"src/components/base/inputs/double-date-input.vue"},T=e=>"conjunction"===(null==e?void 0:e.type),L=Object.defineProperty,z=Object.defineProperties,G=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,U=(e,t,n)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Y=(e,t)=>{for(var n in t||(t={}))W.call(t,n)&&U(e,n,t[n]);if(K)for(var n of K(t))Q.call(t,n)&&U(e,n,t[n]);return e},Z=(e,t)=>z(e,G(t)),J=function(){return`${~~(1e4*Math.random()+1e4)}-${~~(Date.now()/1e3)}`},X=(e,t,n,i)=>{var o,r;const[s]=i||[];return{id:e,condition_id:e,depth:t,type:"criterion",input:Y({clause:null==n?void 0:n.clauses[0].id},s&&{[s.id]:{clause:null==(r=null==(o=null==s?void 0:s.meta)?void 0:o.clauses[0])?void 0:r.id}}),uid:J()}},ee=function(e=1){return{id:void 0,depth:e,type:"conjunction",word:"and",uid:J()}},te=class{constructor(e,t,n){e=e||[],t=t||[],this.conditions=t,this.blueprint=this.mapBlueprint(e),this.blueprintChanged=()=>{n&&n([...this.blueprint])},this.blueprintChanged()}mapBlueprint(e){return e.map((e=>{return"criterion"===(null==(t=e)?void 0:t.type)?Z(Y({},e),{id:e.condition_id,uid:(null==e?void 0:e.uid)||J()}):Z(Y({},e),{id:void 0,uid:J()});var t}))}getBlueprint(){return this.blueprint.map((e=>((e,t)=>{var n={};for(var i in e)W.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&K)for(var i of K(e))t.indexOf(i)<0&&Q.call(e,i)&&(n[i]=e[i]);return n})(e,["id","uid"])))}updateBlueprint(e){this.blueprint=this.mapBlueprint(e)}groupedBlueprint(){if(0===this.blueprint.length)return[];const e=[];return e.push([]),this.blueprint.forEach(((t,n)=>{T(t)?"or"===t.word&&e.push([]):e[e.length-1].push(Z(Y({},t),{position:n}))})),e}indexOfCriterion({uid:e}){let t=-1;for(let n=0;n<this.blueprint.length;n++)if(this.blueprint[n].uid===e){t=n;break}return t}replaceCriterion(e,t){const{meta:n,id:i,refinements:o}=this.findCondition(t.id),r=X(i,1,n,o);this.blueprint.splice(e,1,r),this.blueprintChanged()}removeCriterion(e){const{blueprint:t}=this,n=t[e-1],i=t[e+1],o=T(i)&&"or"===i.word,r=T(n)&&"or"===n.word,s=o||!i,l=r||!n,a=l&&!s,u=l&&s;n||i?u&&r?t.splice(e-1,2):u&&!n||a?t.splice(e,2):t.splice(e-1,2):this.blueprint=[],this.blueprintChanged()}findCriterion(e){const t=this.indexOfCriterion({uid:e});return this.blueprint[t]}addGroup(){const{blueprint:e,conditions:t}=this,n=t[0],{meta:i,refinements:o}=n;e.length>0&&e.push(function(e=0){return{id:void 0,depth:e,type:"conjunction",word:"or",uid:J()}}()),e.push(X(n.id,1,i,o)),this.blueprintChanged()}addCriterion(e){const{id:t,depth:n}=e,{blueprint:i}=this,o=X(t,n);return 0===i.length?i.push(o):i.splice(i.length,0,ee(),o),this.blueprintChanged(),o}insertCriterion(e){const{blueprint:t,conditions:n}=this,i=n[0],{meta:o,refinements:r}=i;return t.splice(e+1,0,ee(),X(i.id,1,o,r)),this.blueprintChanged(),t[e+1]}findRefinement(e,t){const{refinements:n}=this.findCondition(e);let i;return n.forEach((e=>{e.id===t&&(i=e)})),i}findCondition(e){let t=this.conditions[0];return this.conditions.forEach((n=>{n.id===e&&(t=n)})),t}switchClause({uid:e,id:t},n,i){const{meta:o}=this.findCondition(t),r=this.findCriterion(e);Array.isArray(o.options)?r.input={clause:n}:this.updateInput({uid:e},{clause:n},i)}switchRefinement({uid:e,id:t},n,i){const o=this.findRefinement(t,i),r=this.findCriterion(e),s=Y({},r.input);delete s[n],s[i]={clause:o.meta.clauses[0].id},r.input=s}updateInput({uid:e},t,n){const i=this.findCriterion(e);Object.keys(t).forEach((e=>{n?i.input[n][e]=t[e]:i.input[e]=t[e]})),this.blueprintChanged()}},ne=class{constructor(){this.options=[],this.selectedOptions=[]}registerOption(e){const{id:t}=e;for(var n=0;n<this.options.length;n++)if(this.options[n].id===t)throw new Error("An option with id ${optionId} has already been registered for this selector.");const i=this.options[this.options.length-1]||null,o=Y({previousOption:i,nextOption:null},e);i&&(i.nextOption=o),this.options.push(o)}isSelected(e){let t=!1;return this.selectedOptions.forEach((n=>{n.id===e&&(t=!0)})),t}findOption(e){for(var t=0;t<this.options.length;t++){const n=this.options[t];if(n.id===e)return n}return null}toggleOption(e){return this.isSelected(e)?this.deselectOption(e):this.selectOption(e)}clearSelectedOptions(){this.selectedOptions.splice(0,this.selectedOptions.length)}deselectOption(e){const t=this.findOption(e);return this.selectedOptions=this.selectedOptions.filter((t=>t.id!==e)),{deselectedOption:t,selectedOptions:this.selectedOptions}}selectOption(e){const t=this.findOption(e);return this.isSelected(e)||this.selectedOptions.push(t),{selectedOption:t,selectedOptions:this.selectedOptions}}},ie={name:"renderless-selector",data:()=>({selector:l(new ne),isClosed:!0,highlightedOption:null}),emits:["select-option","deselect-option"],provide(){return{selector:this.selector}},computed:{selectedOptions(){return this.selector.selectedOptions},firstSelectedOption(){return this.selectedOptions[0]||this.selector.options[0]},isOpen(){return!this.isClosed},actions:function(){const{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}=this;return{clearOptions:e,close:t,highlightNextOption:n,highlightPreviousOption:i,highlightOption:o,open:r,selectOption:s,selectedOptions:l,toggle:a,toggleOption:u}},state:function(){const{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i}=this;return{isClosed:e,isOpen:t,selectedOptions:n,highlightedOption:i,options:this.selector.options}}},methods:{nextTick(){return a().then((()=>({actions:this.actions,...this.state})))},close(){return this.isClosed||(this.isClosed=!0),this.nextTick()},open(){return this.isClosed=!1,this.highlightedOption=this.firstSelectedOption,this.nextTick()},toggle(){return this.isClosed?this.open():this.close(),this.nextTick()},toggleOption(e){const{selector:t,highlightOption:n}=this,{selectedOption:i}=t.toggleOption(e);return i?this.selectOption(e):this.deselectOption(e),n(t.findOption(e))},clearOptions(){this.selector.clearSelectedOptions()},deselectOption(e){this.$emit("deselect-option",this.selector.deselectOption(e))},selectOption(e){this.$emit("select-option",this.selector.selectOption(e))},highlightOption(e){return this.highlightedOption=e,this.nextTick()},highlightNextOption(){const e=this.highlightedOption?.nextOption;return e&&(this.highlightedOption=e),this.nextTick()},highlightPreviousOption(){const e=this.highlightedOption?.previousOption;return e&&(this.highlightedOption=e),this.nextTick()}},render(){let e=this.$slots?.default;return o&&(e=this.$scopedSlots?.default),e?e({actions:this.actions,...this.state}):null},__file:"src/components/renderless/selector/renderless-selector.vue"};const oe={props:{id:{type:[String,Number],required:!0},display:{type:String,required:!1},selected:{type:Boolean,required:!1,default:!1}}};let re=1;var se={beforeCreate(){this.uid=re.toString(),re+=1}},le={name:"selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},display:{type:String,required:!0}},methods:{label:function(){return this.display?`${this.display} Selected`:"Choose an option"},focus:function(){this.$refs.button.$el.focus()}},components:{RefineFlavor:N}};const ae=g(" Choose an option "),ue=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);le.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.button",id:n.id,type:"button","aria-haspopup":"listbox","aria-expanded":n.isOpen,"aria-label":r.label(),ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))},{default:f((()=>[0===n.display.length?(p(),c(s,{key:0,as:"span",component:"select.button.placeholder"},{default:f((()=>[ae])),_:1})):(p(),c(s,{key:1,as:"span",component:"select.button.selected"},{default:f((()=>[g(b(n.display),1)])),_:1})),m(s,{as:"span",component:"select.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[ue])),_:1})])),_:1})])),_:1},8,["id","aria-expanded","aria-label"])},le.__file="src/components/base/selector/selector-button.vue";var de={name:"selector-listbox",mixins:[se],data:()=>({buffer:"",clearBufferTimeout:null}),props:{isClosed:{type:Boolean,required:!1,default:!0},selectedOption:{type:Object,required:!1}},watch:{isClosed(e){e||this.$nextTick((()=>this.$refs.listBox.$el.focus()))},buffer(e){this.$emit("buffer-changed",e)}},methods:{createItemId:function(e){return`listbox-option-${this.uid}-${e}`},handleKeypress(e){new RegExp(/[a-zA-Z\d ]/).test(e.key)&&1===e.key.length&&(this.buffer+=e.key,this.preserveBuffer())},clearBuffer(){this.buffer=this.buffer.slice(0,-1),this.preserveBuffer()},preserveBuffer(){return clearTimeout(this.clearBufferTimeout),this.clearBufferTimeout=setTimeout((()=>{this.buffer=""}),1500),!0}},components:{RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"div",component:"select.listbox.wrapper"},{default:f((()=>[m(s,{as:"ul",component:"select.listbox",flavorOptions:{isClosed:n.isClosed},tabindex:"-1",role:"listbox","aria-activedescendant":n.selectedOption?r.createItemId(n.selectedOption.id):"",ref:"listBox",onKeydown:[w(y(r.clearBuffer,["stop","prevent"]),["delete"]),t[0]||(t[0]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-next-option")),["stop","prevent"]),["arrow-down"])),t[1]||(t[1]=w(y((()=>r.preserveBuffer()&&e.$emit("highlight-previous-option")),["stop","prevent"]),["arrow-up"])),t[2]||(t[2]=w(y((t=>e.$emit("select-option")),["stop","prevent"]),["enter"])),t[3]||(t[3]=w(y((t=>e.$emit("close")),["stop","prevent"]),["escape"])),t[4]||(t[4]=w(y((t=>e.$emit("close")),["stop","prevent"]),["tab"])),t[5]||(t[5]=e=>r.handleKeypress(e))]},{default:f((()=>[x(e.$slots,"default",{createItemId:r.createItemId})])),_:3},8,["flavorOptions","aria-activedescendant","onKeydown"])])),_:3})},__file:"src/components/base/selector/selector-listbox.vue"},pe={name:"selector-list-item",props:{optionId:{type:[String,Number],required:!0},optionDisplay:{type:String,required:!0},selected:{type:Boolean,required:!1,default:!1},isHighlighted:{type:Boolean,required:!1,default:!1}},emits:["selected","mouseenter","mouseleave"],components:{RefineFlavor:N}};const ce=O("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1);pe.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"li",component:"select.listbox.item",flavorOptions:{isHighlighted:n.isHighlighted},role:"option",key:n.optionId,ref:"listItem",onMouseenter:t[0]||(t[0]=t=>e.$emit("mouseenter")),onMouseleave:t[1]||(t[1]=t=>e.$emit("mouseleave")),onClick:t[2]||(t[2]=t=>e.$emit("selected")),"aria-label":n.optionDisplay,"aria-selected":n.selected},{default:f((()=>[m(s,{as:"span",component:"select.listbox.item.text",flavorOptions:{selected:n.selected}},{default:f((()=>[g(b(n.optionDisplay),1)])),_:1},8,["flavorOptions"]),m(s,{as:"span",component:"select.listbox.item.icon.wrapper",flavorOptions:{isHighlighted:n.isHighlighted}},{default:f((()=>[v(" Heroicon name: check "),C(m(s,{as:"svg",component:"select.listbox.item.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!n.selected},{default:f((()=>[ce])),_:1},8,["aria-hidden"]),[[S,n.selected]])])),_:1},8,["flavorOptions"])])),_:1},8,["flavorOptions","aria-label","aria-selected"])},pe.__file="src/components/base/selector/selector-list-item.vue";var he={name:"multi-selector-button",props:{id:{type:String,required:!0},isOpen:{type:Boolean,required:!0},selectedOptions:{type:Array,required:!0}},methods:{label:function(){const e=`${this.selectedOptions.map((({display:e})=>e)).join(", ")} Selected`;return 0===this.selectedOptions.length?"Choose an option":e},focus:function(){this.$refs.button.focus()}},components:{RefineFlavor:N}};const fe=g(" Choose an option "),me=O("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1),ge=O("path",{"fill-rule":"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1);he.render=function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"button",component:"select.multi.button",id:n.id,"aria-haspopup":"listbox","aria-label":r.label(),"aria-expanded":n.isOpen,ref:"button",onClick:t[0]||(t[0]=y((t=>e.$emit("toggle")),["prevent"])),onKeydown:[t[1]||(t[1]=w(y((t=>e.$emit("open")),["stop","prevent"]),["enter"])),t[2]||(t[2]=w(y((t=>e.$emit("open")),["stop","prevent"]),["arrow-down"]))],tabindex:"0"},{default:f((()=>[0===n.selectedOptions.length?(p(),c(s,{key:0,as:"span",component:"select.multi.button.placeholder"},{default:f((()=>[fe])),_:1})):(p(!0),_(k,{key:1},$(n.selectedOptions,(({id:t,display:n})=>(p(),c(s,{as:"span",component:"select.multi.button.selected",key:t},{default:f((()=>[g(b(n)+" ",1),m(s,{as:"span",component:"select.multi.button.deselect.icon.wrapper",onClick:y((n=>e.$emit("deselect-option",t)),["prevent"])},{default:f((()=>[m(s,{as:"svg",component:"select.multi.button.deselect.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[me])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)))),128)),m(s,{as:"span",component:"select.multi.button.icon.wrapper"},{default:f((()=>[v(" Heroicon name: selector "),m(s,{as:"svg",component:"select.multi.button.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[ge])),_:1})])),_:1})])),_:1},8,["id","aria-label","aria-expanded"])},he.__file="src/components/base/selector/multi-selector-button.vue";var be={name:"selector",mixins:[se],inject:["builderModeActive"],props:{isMultiSelect:{type:Boolean,required:!1,default:!1},innerClass:{type:String,required:!1,default:""}},emits:["select-option","deselect-option"],computed:{selectorId(){return this.uid},buttonId(){return`button-${this.selectorId}`}},mounted(){this.builderModeActive&&this.$refs.button.$el.focus()},directives:{clickAway:new function(){const e={},t=function(t,n){const{value:i}=n;if("function"!=typeof i)throw new Error("The click-away directive expects a function/method as an argument.");if(!t.id)throw new Error("The click-away directive requires the element it is bound to to have an id.");const o=e=>{t.contains(e.target)||i()};e[t.id]=o,document.addEventListener("click",o),document.addEventListener("touchstart",o)},n=function(t){document.removeEventListener("click",e[t.id]),document.removeEventListener("touchstart",e[t.id]),delete e[t.id]};return{bind:t,beforeMount:t,unbind:n,unmount:n}}},methods:{updateBuffer(e,t,n){if(!e)return;const i=t.find((t=>t.display.toLowerCase().includes(e)));i&&(n.highlightOption(i),this.scrollIntoView(i.id))},isSelected(e,t){let n=!1;return t.forEach((t=>{e.id===t.id&&(n=!0)})),n},deselectOption(e,{toggleOption:t}){t(e)},async selectOption(e,t){const{clearOptions:n,selectOption:i,toggleOption:o}=t,{isMultiSelect:r}=this;r?o(e):(n(),i(e),await this.close(t))},scrollIntoView(e){e&&this.$refs[e][0].$el.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},async close({close:e}){const{isClosed:t}=await e();t&&this.$refs.button?.$el?.focus()},async open({open:e}){const{selectedOption:t}=await e();this.scrollIntoView(t?.id)},async toggle({toggle:e}){const{isOpen:t,selectedOption:n}=await e();t&&this.scrollIntoView(n?.id)},async highlightNextOption({highlightNextOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)},async highlightPreviousOption({highlightPreviousOption:e}){const{highlightedOption:t}=await e();this.scrollIntoView(t?.id)}},components:{MultiSelectorButton:he,RenderlessSelector:ie,SelectorListItem:pe,SelectorButton:le,SelectorListbox:de,RefineFlavor:N},render:function(e,t,n,i,o,r){const s=d("multi-selector-button"),l=d("selector-button"),a=d("selector-list-item"),u=d("selector-listbox"),h=d("refine-flavor"),g=d("renderless-selector"),b=I("click-away");return p(),c(g,{onSelectOption:t[0]||(t[0]=t=>e.$emit("select-option",t)),onDeselectOption:t[1]||(t[1]=t=>e.$emit("deselect-option",t))},{default:f((({actions:t,isOpen:i,isClosed:o,selectedOptions:d,highlightedOption:g,options:y})=>[m(h,{as:"div",component:"select.wrapper"},{default:f((()=>[v(" Select dropdown "),C((p(),c(h,{as:"div",component:"select",class:q(n.innerClass),id:`listbox-${r.selectorId}`,"aria-labelledby":r.buttonId},{default:f((()=>[n.isMultiSelect?(p(),c(s,{key:0,id:r.buttonId,isOpen:i,selectedOptions:d,onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),onDeselectOption:e=>r.deselectOption(e,t),ref:"button"},null,8,["id","isOpen","selectedOptions","onToggle","onOpen","onDeselectOption"])):(p(),c(l,{key:1,id:r.buttonId,isOpen:i,display:d[0]?d[0].display:"",onToggle:e=>r.toggle(t),onOpen:e=>r.open(t),ref:"button"},null,8,["id","isOpen","display","onToggle","onOpen"])),m(u,{selectedOption:d[0],isClosed:o,ref:"listBox",onHighlightNextOption:e=>r.highlightNextOption(t),onHighlightPreviousOption:e=>r.highlightPreviousOption(t),onSelectOption:e=>r.selectOption(g.id,t),onBufferChanged:e=>r.updateBuffer(e,y,t),onClose:e=>r.close(t)},{default:f((({createItemId:e})=>[(p(!0),_(k,null,$(y,(n=>(p(),c(a,{id:e(n.id),key:n.id,optionId:n.id,optionDisplay:n.display,selected:r.isSelected(n,d),isHighlighted:g&&n.id===g.id,ref_for:!0,ref:n.id,onMouseenter:e=>t.highlightOption(n),onMouseleave:e=>t.highlightOption(null),onSelected:e=>r.selectOption(n.id,t)},null,8,["id","optionId","optionDisplay","selected","isHighlighted","onMouseenter","onMouseleave","onSelected"])))),128))])),_:2},1032,["selectedOption","isClosed","onHighlightNextOption","onHighlightPreviousOption","onSelectOption","onBufferChanged","onClose"])])),_:2},1032,["class","id","aria-labelledby"])),[[b,t.close]]),v(" Custom options "),m(h,{as:"div",component:"customOptions.wrapper"},{default:f((()=>[x(e.$slots,"default")])),_:3})])),_:2},1024)])),_:3})},__file:"src/components/base/selector/selector.vue"},ve={name:"renderless-query-builder",emits:["change"],props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!0}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!0}},data(){return{conditionsLookup:this.conditions.reduce(((e,t)=>(e[t.id]=t,e)),{}),internalBlueprint:null,blueprintStore:new te(this.blueprint,this.conditions,(e=>{this.internalBlueprint=e,this.$emit("change",e)}))}},watch:{blueprint:{deep:!0,handler(e){e!==this.internalBlueprint&&this.blueprintStore.updateBlueprint(e)}}},methods:{replaceCriterion(e,t){this.blueprintStore.replaceCriterion(e,t)},insertCriterion(e){this.blueprintStore.insertCriterion(e)},removeCriterion(e){this.blueprintStore.removeCriterion(e)},addGroup(){this.blueprintStore.addGroup()},conditionFor(e){const{id:t,uid:n}=e,{id:i,type:o,display:r,meta:s}=this.conditionsLookup[t];return{id:i,type:o,display:r,uid:n,meta:s}}},render(){const{insertCriterion:e,addGroup:t,blueprintStore:n,conditionFor:i,replaceCriterion:r,removeCriterion:s}=this;let l=this.$slots?.default;return o&&(l=this.$scopedSlots?.default),l?l({insertCriterion:e,addGroup:t,blueprint:n,conditionFor:i,removeCriterion:s,replaceCriterion:r,groupedBlueprint:n.groupedBlueprint()}):null}},ye={name:"renderless-condition",inheritAttrs:!1,props:{id:{type:String,required:!0},display:{type:String,required:!0},uid:{type:String,required:!0},meta:{type:Object,required:!0}},setup:(e,i)=>((e,i,o)=>{const r=n("blueprint"),s=n("builderModeActive");if(!e)throw new Error("useCondition requires an id.");if(!o)throw new Error("useCondition requires a Vue context.");if(!r)throw new Error("Conditions must be rendered within a query.");let l;l=s?r.findCriterion(i.uid):r.addCriterion({id:e,depth:0});const a=(e,t)=>r.updateInput(l,e,t),d=e=>r.switchClause(l,e);t("criterion",l),t("criterionMeta",i.meta),t("updateInput",a),t("switchRefinement",((e,t)=>{r.switchRefinement(l,e,t)})),t("refinementId",null),u((()=>{s||r.removeCriterion(r.indexOfCriterion(l))}));let p=null;return i?.condition?.meta?.clauses&&(p=i.condition.meta.clauses.map((e=>e.component))),()=>o.slots.default?o.slots.default({clauses:p,criterion:l,updateInput:a,switchClause:d}):null})(e.id,e,i)},we={name:"renderless-clause",inheritAttrs:!1,props:{clause:{type:String,required:!0}},setup:(e,t)=>((e,t,i)=>{const o=n("criterion"),r=n("updateInput"),s=n("refinementId"),l=n("builderModeActive"),a=e=>{r(e,s)};if(!o)throw new Error("A clause must be used within a criterion.");if(!l){r({clause:e},s);const{clause:n,...i}=o.input;Object.keys(t).length>0&&0===Object.keys(i).length&&r({...t},s)}return u((()=>{l||o.input.clause===e&&r({clause:void 0},s)})),()=>i.slots.default?i.slots.default({setValue:a,...o.input}):null})(e.clause,e,t)},Oe={name:"renderless-refinement",inject:["updateInput"],props:{id:{type:String,required:!0}},provide(){return{refinementId:this.id}},render(){let e=this.$slots?.default;if(o&&(e=this.$scopedSlots?.default),e)return e()}},xe={name:"selector-option",mixins:[oe],components:{RenderlessOption:{name:"renderless-option",inject:["selector"],mixins:[oe],computed:{isSelected:function(){const{selector:e,id:t}=this;return e.isSelected(t)}},created(){const{id:e,display:t,selected:n,selector:i}=this;i.registerOption({id:e,display:t||e,...this.$attrs}),n&&i.selectOption(e)},render(){const{isSelected:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t&&e?t():null}}},render:function(e,t,n,i,o,r){const s=d("renderless-option");return p(),c(s,{id:e.id,display:e.display,selected:e.selected},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["id","display","selected"])},__file:"src/components/base/selector/selector-option.vue"},Ce={name:"refine-date-input",components:{Selector:be,SelectorOption:xe,RefineFlavor:N},mixins:[se],emits:["input"],props:{amount:{type:[String,Number],required:!1},unit:{type:String,required:!1},modifier:{type:String,required:!1},units:{type:Array,required:!0},modifiers:{type:Array,required:!0}},created(){const{modifier:e}=this;this.$emit("input",{modifier:e})},methods:{updateModifier({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{modifier:t[0]})},updateAmount:function(e){const t=e.target.value;this.$emit("input",{amount:t})},updateUnit:function({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{unit:t[0]})}},render:function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("selector-option"),a=d("selector");return p(),c(s,{as:"div",component:"inputs.date.relative.wrapper"},{default:f((()=>[m(s,{as:"input",component:"inputs.date.relative",type:"number",name:"amount",value:n.amount,onInput:r.updateAmount},null,8,["value","onInput"]),m(a,{onSelectOption:r.updateUnit},{default:f((()=>[(p(!0),_(k,null,$(n.units,(e=>(p(),c(l,{key:e.id,id:e.id,display:e.display,selected:e.id===n.unit},null,8,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"]),m(a,{onSelectOption:r.updateModifier},{default:f((()=>[(p(!0),_(k,null,$(n.modifiers,(e=>(p(),c(l,{key:e.id,id:e.id,selected:e.id===n.modifier,display:e.display},null,8,["id","selected","display"])))),128))])),_:1},8,["onSelectOption"])])),_:1})},__file:"src/components/base/inputs/relative-date-input.vue"},Se={name:"refine-option-input",components:{Selector:be,SelectorOption:xe},emits:["input"],props:{selected:{type:Array,required:!1,default:()=>[]},options:{type:Array,required:!0},multiple:{type:Boolean,required:!1,default:!1}},methods:{selectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},deselectOption({selectedOptions:e}){const t=e.map((({id:e})=>e));this.$emit("input",{selected:t})},isSelected(e){let t=!1;return this.selected.forEach((n=>{n===e&&(t=!0)})),t}},render:function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector");return p(),c(l,{isMultiSelect:n.multiple,onSelectOption:r.selectOption,onDeselectOption:r.deselectOption},{default:f((()=>[(p(!0),_(k,null,$(n.options,(({id:e,display:t})=>(p(),c(s,{key:e,id:e,display:t,selected:r.isSelected(e)},null,8,["id","display","selected"])))),128))])),_:1},8,["isMultiSelect","onSelectOption","onDeselectOption"])},__file:"src/components/base/inputs/option-input.vue"},_e={emits:["input"],components:{RefineFlavor:N},props:{date:{type:String,required:!1}},methods:{handleInput:function(e){this.$emit("input",{value:e?.target?.value??e})}},render:function(e,t,n,i,o,r){const s=d("refine-flavor");return p(),c(s,{as:"input",component:"inputs.date",type:"date",value:n.date,onInput:r.handleInput},null,8,["value","onInput"])},__file:"src/components/base/inputs/native-date-picker.vue"},ke={RefineDateInput:F,RefineDoubleDateInput:H,RefineDoubleNumberInput:P,RefineNumberInput:V,RefineOptionInput:Se,RefineRelativeDateInput:Ce,RefineTextInput:E,RefineNativeDatePicker:_e},$e=Object.freeze({__proto__:null,default:ke,RefineDateInput:F,RefineDoubleDateInput:H,RefineDoubleNumberInput:P,RefineNumberInput:V,RefineOptionInput:Se,RefineRelativeDateInput:Ce,RefineTextInput:E,RefineNativeDatePicker:_e}),Ie={install:(e,t={})=>{t={DatePicker:_e,showLocators:!1,...t},e.component("refine-date-picker",t.DatePicker),delete t.DatePicker,M.init(t)}},qe={install:(e,t={})=>{Ie.install(e,t)}},Be={name:"condition-selector",emits:["select-condition"],methods:{selectOption(e){this.$emit("select-condition",e)}},components:{Selector:be},render:function(e,t,n,i,o,r){const s=d("selector");return p(),c(s,{onSelectOption:r.selectOption},{default:f((()=>[x(e.$slots,"default")])),_:3},8,["onSelectOption"])},__file:"src/components/base/condition-selector/condition-selector.vue"},Re={props:{blueprint:{type:Array,required:!1},conditions:{type:Array,required:!1}},provide(){const{blueprintStore:e}=this;return{blueprint:e,builderModeActive:!1}},data(){return{blueprintStore:new te(this.blueprint,this.conditions,(e=>{this.$emit("change",e)}))}},render(){const{blueprintStore:e}=this;let t=this.$slots?.default;return o&&(t=this.$scopedSlots?.default),t?t({blueprint:e}):null},__file:"src/components/renderless/query.vue"},je={name:"clause",props:{input:{type:Object,default:()=>({})},meta:{type:Object,required:!0}},emits:["switch-clause"],methods:{switchClause:function({selectedOption:e}){this.$emit("switch-clause",e)}},components:{RenderlessClause:we,SelectorOption:xe,Selector:be,...$e},render:function(e,t,n,i,o,r){const s=d("selector-option"),l=d("selector"),a=d("renderless-clause");return p(),c(a,B(R(n.input)),{default:f((({setValue:e})=>[v(" clause selector "),m(l,{onSelectOption:r.switchClause,innerClass:"refine-clause-selector"},{default:f((()=>[(p(!0),_(k,null,$(n.meta.clauses,(({id:t,display:i,component:o,meta:r})=>(p(),c(s,{key:t,id:t,display:i,selected:n.input.clause===t},{default:f((()=>[o?(p(),c(j(o),h({key:0},{...n.meta,...r,...n.input},{onInput:e}),null,16,["onInput"])):v("v-if",!0)])),_:2},1032,["id","display","selected"])))),128))])),_:2},1032,["onSelectOption"])])),_:1},16)},__file:"src/components/base/query-builder/clause.vue"},Ae={name:"refinements",inject:["updateInput","switchRefinement"],components:{Clause:je,RenderlessRefinement:Oe,Selector:be,SelectorOption:xe},props:{refinements:{required:!0,type:Array},input:{required:!1,type:Object,default:()=>({})}},methods:{selectedRefinementId(){let e;return this.refinements.forEach((({id:t})=>{this.input[t]&&(e=t)})),e},selectRefinement({selectedOption:e}){const{id:t}=e;this.switchRefinement(this.selectedRefinementId(),t)}},render:function(e,t,n,i,o,r){const s=d("clause"),l=d("renderless-refinement"),a=d("selector-option"),u=d("selector");return p(),c(u,{onSelectOption:r.selectRefinement},{default:f((()=>[(p(!0),_(k,null,$(n.refinements,(({id:e,meta:t,display:i})=>(p(),c(a,{key:e,id:e,display:i,selected:!!n.input[e]},{default:f((()=>[m(l,{id:e},{default:f((()=>[m(s,{meta:t,input:n.input[e],onSwitchClause:({id:t})=>r.updateInput({clause:t},e)},null,8,["meta","input","onSwitchClause"])])),_:2},1032,["id"])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])},__file:"src/components/base/query-builder/refinements.vue"},De={name:"criterion",props:{conditions:{required:!0,type:Array},conditionId:{type:String,required:!0},input:{type:Object,required:!0},errors:{type:Array,required:!1,default:()=>[]}},methods:{switchCondition:function({selectedOption:e}){this.conditionId!==e.id&&this.$emit("switch-condition",e)},switchClause:function(e){this.$emit("switch-clause",e)}},components:{Clause:je,Refinements:Ae,SelectorOption:xe,Selector:be,RefineFlavor:N}};const Me=O("path",{"fill-rule":"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"},null,-1);De.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("clause"),a=d("refinements"),u=d("selector-option"),h=d("selector");return p(),c(s,{order:["errors","selector","remove"],as:"div",component:"criterion.wrapper"},{errors:f((()=>[n.errors.length>0?(p(),c(s,{key:0,as:"ul",component:"criterion.errors"},{default:f((()=>[(p(!0),_(k,null,$(n.errors,(e=>(p(),c(s,{as:"li",component:"criterion.errors.error",key:e},{default:f((()=>[g(b(e),1)])),_:2},1024)))),128))])),_:1})):v("v-if",!0)])),selector:f((()=>[m(h,{onSelectOption:r.switchCondition},{default:f((()=>[(p(!0),_(k,null,$(n.conditions,(({id:e,display:t,meta:i,refinements:o})=>(p(),c(u,{key:e,id:e,display:t,selected:n.conditionId===e},{default:f((()=>[O("div",null,[m(l,{input:n.input,meta:i,onSwitchClause:r.switchClause},null,8,["input","meta","onSwitchClause"]),o&&o.length>0?(p(),c(a,{key:0,input:n.input,refinements:o},null,8,["input","refinements"])):v("v-if",!0)])])),_:2},1032,["id","display","selected"])))),128))])),_:1},8,["onSelectOption"])])),remove:f((()=>[m(s,{as:"button",component:"criterion.removeCriterionButton",onClick:t[0]||(t[0]=y((t=>e.$emit("remove-condition")),["prevent"])),type:"button"},{default:f((()=>[m(s,{as:"svg",component:"criterion.removeCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},{default:f((()=>[Me])),_:1})])),_:1})])),_:1})},De.__file="src/components/base/query-builder/criterion.vue";var Ne={name:"query-builder",model:{prop:"blueprint",event:"update:blueprint"},emits:["update:blueprint"],props:{blueprint:{required:!1,type:Array,default:()=>[]},conditions:{required:!0,type:Array},errors:{required:!1,type:Object,default:()=>({})},flavor:{required:!1,type:Object,default:()=>({})}},methods:{templateKey:e=>o?{}:{key:e},templateChildKey:e=>o?{key:e}:{},onChange(e){this.$emit("update:blueprint",e)}},created(){if(0===this.conditions.length)throw new Error("You must provide at least one condition to the query builder.")},setup(e){var n;n=e.flavor,t(A,n)},components:{Criterion:De,RefineFlavor:N,RenderlessCondition:ye,RenderlessQueryBuilder:ve}};const Ve=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Pe=g(" Add a new condition "),Ee=O("path",{"fill-rule":"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z","clip-rule":"evenodd"},null,-1),Fe=g(" And"),He=g(" Add an 'Or' ");Ne.render=function(e,t,n,i,o,r){const s=d("refine-flavor"),l=d("criterion"),a=d("renderless-condition"),u=d("renderless-query-builder");return p(),c(u,{blueprint:n.blueprint,conditions:n.conditions,onChange:r.onChange},{default:f((({groupedBlueprint:e,replaceCriterion:t,insertCriterion:i,addGroup:o,removeCriterion:u,conditionFor:d})=>[v(' When there are no conditions, we need to show something reasonable instead of just "+ OR"'),0===e.length?(p(),c(s,h({key:0,as:"div",component:"emptyGroup"},{addGroup:o},{order:["button","default"]}),{button:f((()=>[m(s,{as:"button",component:"emptyGroup.addCriterionButton",onClick:o,tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"emptyGroup.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[Ve])),_:1}),m(s,{as:"span",component:"emptyGroup.addCriterionButton.text"},{default:f((()=>[Pe])),_:1})])),_:2},1032,["onClick"])])),_:2},1040)):(p(),c(s,{key:1,as:"div",component:"group.wrapper"},{default:f((()=>[(p(!0),_(k,null,$(e,((o,g)=>(p(),_(k,null,[m(s,h({as:"div",component:"group"},r.templateChildKey(`group-${g}`)),{default:f((()=>[v(" This really should be named criterion, as that's what it is. "),(p(!0),_(k,null,$(o,(e=>(p(),c(s,{as:"div",component:"condition",key:e.uid},{default:f((()=>[m(a,B(R(d({id:e.condition_id,...e}))),{default:f((({switchClause:i})=>[m(l,{onSwitchClause:({id:e})=>i(e),onRemoveCondition:t=>u(e.position),onSwitchCondition:n=>t(e.position,d(n)),conditionId:e.condition_id,conditions:n.conditions,errors:n.errors[e.uid],input:e.input},null,8,["onSwitchClause","onRemoveCondition","onSwitchCondition","conditionId","conditions","errors","input"])])),_:2},1040)])),_:2},1024)))),128)),m(s,{as:"div",component:"group.addCriterionButton.wrapper"},{default:f((()=>[m(s,{as:"button",component:"group.addCriterionButton",onClick:e=>i(o[o.length-1].position),tabindex:"0",type:"button"},{default:f((()=>[v(" Heroicon name: plus "),m(s,{as:"svg",component:"group.addCriterionButton.icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},{default:f((()=>[Ee])),_:1}),m(s,{as:"span",component:"group.addCriterionButton.text"},{default:f((()=>[Fe])),_:1})])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1040),v(" Divider between groups. Blank by default, but used in Nova. "),m(s,h({as:"template",component:"group.divider",index:g,total:e.length},r.templateChildKey(`separator-${g}`)),null,16,["index","total"])],64)))),256)),m(s,{as:"button",component:"addGroupButton",onClick:o,type:"button"},{default:f((()=>[He])),_:2},1032,["onClick"])])),_:2},1024)),v(" wrapper div ")])),_:1},8,["blueprint","conditions","onChange"])},Ne.__file="src/components/base/query-builder/query-builder.vue";const Te="bg-white relative border border-gray-300 rounded-md shadow-sm text-left cursor-default",Le="focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",ze=`${Te} ${Le} w-60 pl-3 py-2`,Ge={emptyGroup:{class:"",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",icon:"h-4 w-4",wrapper:{},text:{}}},group:{class:"flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden",wrapper:"space-y-4",addCriterionButton:{class:"flex items-center rounded text-sm text-gray-600",wrapper:{},icon:"h-4 w-4",text:{}}},addGroupButton:"px-2 py-1 bg-blue-500 text-white rounded",criterion:{wrapper:{class:"flex flex-wrap gap-x-2 gap-y-4",order:["errors","selector","remove"]},removeCriterionButton:{class:"rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto",icon:"h-5 w-5"},errors:{class:"flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside",error:"text-red-600 font-semibold"}},select:{class:"sm:inline-block w-60",wrapper:"flex items-start gap-4",customOptions:{class:"",wrapper:"w-auto pt-4 md:flex md:pt-0"},listbox:{class:e=>e.isClosed?"hidden":"text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:"overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg",item:{class:e=>"relative py-2 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>{e.selected}},icon:{class:"w-5 h-5",wrapper:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}},button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default; focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"block truncate",icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}},multi:{button:{class:"relative w-full py-2 pl-3 pr-10 text-left bg-white border border-gray-300 rounded-md shadow-sm cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"block text-gray-300 truncate select-none",selected:"inline-flex p-1 mr-1 border border-gray-300 rounded",deselect:{icon:{class:"w-4 h-4",wrapper:"flex items-center ml-1 text-gray-500 cursor-pointer"}},icon:{class:"w-5 h-5 text-gray-400",wrapper:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}},inputs:{date:{class:`${Te} ${Le} h-9 py-5 px-2 leading-normal box-border`,relative:{class:`${ze} mr-4`,wrapper:"flex mr-4"},double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},number:{class:ze,double:{wrapper:"flex items-center gap-[1ch]",joiner:{}}},text:ze}},Ke="bg-white relative text-left cursor-default",We=`${Ke} focus:outline-none pl-3 py-1`,Qe={emptyGroup:{class:"",wrapper:{class:"space-y-4"},addCriterionButton:{class:"flex items-center rounded text-sm text-gray-400 hover:bg-gray-100",wrapper:{},icon:{class:"h-4 w-4"},text:{}}},group:{class:"flex flex-wrap items-center gap-y-2",wrapper:{class:""},addCriterionButton:{wrapper:{},class:"flex items-center p-1 text-gray-100 hover:bg-gray-100 rounded",icon:{class:"h-6 w-6 text-gray-400"},text:{class:"hidden"}}},addGroupButton:{class:"hidden"},criterion:{wrapper:{component:"linear-criterion-row",order:["errors","selector","remove"],class:"mr-4"},removeCriterionButton:{class:"px-3 hover:bg-gray-100 text-gray-400 flex items-center justify-center",icon:{class:"h-4 w-4"}},errors:{class:"hidden",error:{class:"hidden"}}},select:{class:"relative sm:inline-block",wrapper:{class:"flex items-start"},customOptions:{class:"",wrapper:{class:"w-auto pt-4 md:flex md:pt-0"}},listbox:{class:e=>e.isClosed?"hidden":"overflow-auto text-base rounded-md max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none",wrapper:{class:"absolute w-48 z-10 mt-1 bg-white rounded-md shadow-lg"},item:{class:e=>"relative py-1 border-b border-gray-100 pl-3 cursor-pointer select-none pr-9 "+(e.isHighlighted?"text-white bg-blue-600":"text-gray-900"),text:{class:e=>"block truncate "+(e.selected?"font-semibold":"font-normal")},icon:{class:"w-5 h-5",wrapper:{class:e=>"absolute inset-y-0 right-0 flex items-center pr-4 "+(e.isHighlighted?"text-white":"text-blue-600")}}}},button:{class:"relative w-full py-1 px-3 text-left bg-white cursor-default hover:bg-gray-100",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"block truncate"},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"hidden absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}},multi:{button:{class:"relative w-full py-1 pl-3 pr-10 text-left bg-white cursor-default focus:outline-none",placeholder:{class:"block text-gray-300 truncate select-none"},selected:{class:"inline-flex mr-2 "},deselect:{icon:{class:"hidden w-4 h-4",wrapper:{class:"hidden flex items-center ml-1 text-gray-300 cursor-pointer"}}},icon:{class:"w-5 h-5 text-gray-300",wrapper:{class:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"}}}}},inputs:{date:{pickerInput:{class:`${Ke} focus:outline-none block w-full pl-3 py-1 pr-0`},relative:{class:`${We} w-12`,wrapper:{class:"flex mr-4"}},double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},number:{class:`${We} w-14`,double:{wrapper:{class:"flex items-center gap-[1ch]"},joiner:{}}},text:{class:We}}};export{Be as ConditionSelector,qe as DatePickerPlugin,Re as Query,Ne as QueryBuilder,Ie as RefinePlugin,be as Selector,xe as SelectorOption,Qe as linearFlavor,Ge as tailwindFlavor}; | ||
//# sourceMappingURL=refine-vue.esm.min.js.map |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "1.0.1673184317", | ||
"version": "1.0.1673275245", | ||
"scripts": { | ||
@@ -24,0 +24,0 @@ "test": "jest ./tests", |
import { h, defineComponent, isVue2, computed } from 'vue-demi'; | ||
import { useFlavor } from '../../../hooks/useFlavor'; | ||
import Config from './../../../plugins/config'; | ||
@@ -9,4 +11,2 @@ // vue-demi does not export resolveComponent, which is required when using | ||
import { useFlavor } from '../../../hooks/useFlavor'; | ||
export const RefineFlavor = defineComponent({ | ||
@@ -33,3 +33,6 @@ name: 'RefineFlavor', | ||
inheritAttrs: false, | ||
setup(incomingProps, bindings) { | ||
let showLocators = Config.get('showLocators'); | ||
const flavor = useFlavor( | ||
@@ -42,2 +45,11 @@ (flavor) => { | ||
} | ||
// If you just want to set the class on an element, you can use a | ||
// string or function instead of an object with a "class" key. | ||
if (typeof result === 'string' || typeof result === 'function') { | ||
result = { | ||
class: result, | ||
}; | ||
} | ||
return result; | ||
@@ -54,4 +66,4 @@ }, | ||
...(incomingProps.flavorOptions ?? {}), | ||
} | ||
}) | ||
}; | ||
}), | ||
); | ||
@@ -72,26 +84,29 @@ | ||
? h( | ||
resolvedFlavor.component, | ||
{ | ||
scopedSlots: slots, | ||
attrs: { ...bindings.attrs, 'data-flavor': incomingProps.component }, | ||
props, | ||
on: bindings.listeners, | ||
...resolvedFlavor.props.value, | ||
}, | ||
orderedSlots | ||
) | ||
: h( | ||
// In Vue 3, globally registered components must be resolved before they can be used. | ||
// https://vuejs.org/guide/extras/render-function.html#components | ||
isComponent ? resolveComponent(resolvedFlavor.component) : resolvedFlavor.component, | ||
{ | ||
resolvedFlavor.component, | ||
{ | ||
scopedSlots: slots, | ||
attrs: { | ||
...(showLocators && { 'data-locator': incomingProps.component }), | ||
...bindings.attrs, | ||
'data-flavor': incomingProps.component, | ||
...props, | ||
...resolvedFlavor.props.value, | ||
}, | ||
orderedSlots | ||
); | ||
props, | ||
on: bindings.listeners, | ||
...resolvedFlavor.props.value, | ||
}, | ||
orderedSlots, | ||
) | ||
: h( | ||
// In Vue 3, globally registered components must be resolved before they can be used. | ||
// https://vuejs.org/guide/extras/render-function.html#components | ||
isComponent ? resolveComponent(resolvedFlavor.component) : resolvedFlavor.component, | ||
{ | ||
...(showLocators && { 'data-locator': incomingProps.component }), | ||
...bindings.attrs, | ||
...props, | ||
...resolvedFlavor.props.value, | ||
}, | ||
orderedSlots, | ||
); | ||
if (resolvedFlavor.extra.value.wrap) { | ||
@@ -98,0 +113,0 @@ return resolvedFlavor.extra.value.wrap(el); |
@@ -12,15 +12,8 @@ const inputBase = | ||
wrapper: { | ||
class: 'space-y-4', | ||
}, | ||
wrapper: 'space-y-4', | ||
addCriterionButton: { | ||
class: 'flex items-center rounded text-sm text-gray-600', | ||
icon: 'h-4 w-4', | ||
wrapper: {}, | ||
icon: { | ||
class: 'h-4 w-4', | ||
}, | ||
text: {}, | ||
@@ -32,15 +25,8 @@ }, | ||
class: 'flex flex-col gap-4 bg-gray-100 px-4 py-8 rounded-lg border-l-4 overflow-hidden', | ||
wrapper: { | ||
class: 'space-y-4', | ||
}, | ||
wrapper: 'space-y-4', | ||
addCriterionButton: { | ||
class: 'flex items-center rounded text-sm text-gray-600', | ||
wrapper: {}, | ||
class: 'flex items-center rounded text-sm text-gray-600', | ||
icon: { | ||
class: 'h-4 w-4', | ||
}, | ||
icon: 'h-4 w-4', | ||
text: {}, | ||
@@ -50,10 +36,8 @@ }, | ||
addGroupButton: { | ||
class: 'px-2 py-1 bg-blue-500 text-white rounded', | ||
}, | ||
addGroupButton: 'px-2 py-1 bg-blue-500 text-white rounded', | ||
criterion: { | ||
wrapper: { | ||
class: 'flex flex-wrap gap-x-2 gap-y-4', | ||
order: ['errors', 'selector', 'remove'], | ||
class: 'flex flex-wrap gap-x-2 gap-y-4', | ||
}, | ||
@@ -63,5 +47,3 @@ removeCriterionButton: { | ||
'rounded-full bg-gray-200 w-10 h-10 text-gray-600 flex items-center justify-center ml-auto', | ||
icon: { | ||
class: 'h-5 w-5', | ||
}, | ||
icon: 'h-5 w-5', | ||
}, | ||
@@ -71,5 +53,3 @@ errors: { | ||
'flex-1 basis-full bg-red-50 border-l-2 border-red-600 text-red-300 px-4 py-2 rounded list-disc list-inside', | ||
error: { | ||
class: 'text-red-600 font-semibold', | ||
}, | ||
error: 'text-red-600 font-semibold', | ||
}, | ||
@@ -79,11 +59,7 @@ }, | ||
select: { | ||
class: ' sm:inline-block w-60', | ||
wrapper: { | ||
class: 'flex items-start gap-4', | ||
}, | ||
class: 'sm:inline-block w-60', | ||
wrapper: 'flex items-start gap-4', | ||
customOptions: { | ||
class: '', | ||
wrapper: { | ||
class: 'w-auto pt-4 md:flex md:pt-0', | ||
}, | ||
wrapper: 'w-auto pt-4 md:flex md:pt-0', | ||
}, | ||
@@ -97,5 +73,3 @@ listbox: { | ||
wrapper: { | ||
class: 'overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg', | ||
}, | ||
wrapper: 'overflow-hidden absolute z-10 mt-1 bg-white rounded-md shadow-lg', | ||
@@ -110,4 +84,5 @@ item: { | ||
text: { | ||
class: (options) => | ||
`block truncate ${options.selected ? 'font-semibold' : 'font-normal'}`, | ||
class: (options) => { | ||
`block truncate ${options.selected ? 'font-semibold' : 'font-normal'}`; | ||
}, | ||
}, | ||
@@ -117,8 +92,3 @@ | ||
class: 'w-5 h-5', | ||
wrapper: { | ||
class: (options) => | ||
`absolute inset-y-0 right-0 flex items-center pr-4 ${ | ||
!options.isHighlighted ? 'text-blue-600' : 'text-white' | ||
}`, | ||
}, | ||
wrapper: (options) => `absolute inset-y-0 right-0 flex items-center pr-4 ${!options.isHighlighted ? 'text-blue-600' : 'text-white'}`, | ||
}, | ||
@@ -132,15 +102,9 @@ }, | ||
placeholder: { | ||
class: 'block text-gray-300 truncate select-none', | ||
}, | ||
placeholder: 'block text-gray-300 truncate select-none', | ||
selected: { | ||
class: 'block truncate', | ||
}, | ||
selected: 'block truncate', | ||
icon: { | ||
class: 'w-5 h-5 text-gray-400', | ||
wrapper: { | ||
class: 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none', | ||
}, | ||
wrapper: 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none', | ||
}, | ||
@@ -154,9 +118,5 @@ }, | ||
placeholder: { | ||
class: 'block text-gray-300 truncate select-none', | ||
}, | ||
placeholder: 'block text-gray-300 truncate select-none', | ||
selected: { | ||
class: 'inline-flex p-1 mr-1 border border-gray-300 rounded', | ||
}, | ||
selected: 'inline-flex p-1 mr-1 border border-gray-300 rounded', | ||
@@ -167,5 +127,3 @@ deselect: { | ||
wrapper: { | ||
class: 'flex items-center ml-1 text-gray-500 cursor-pointer', | ||
}, | ||
wrapper: 'flex items-center ml-1 text-gray-500 cursor-pointer', | ||
}, | ||
@@ -177,5 +135,3 @@ }, | ||
wrapper: { | ||
class: 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none', | ||
}, | ||
wrapper: 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none', | ||
}, | ||
@@ -188,17 +144,11 @@ }, | ||
date: { | ||
class: `${inputBase} ${inputFocus} h-9 h-full py-5 px-2 leading-normal box-border`, | ||
class: `${inputBase} ${inputFocus} h-9 py-5 px-2 leading-normal box-border`, | ||
relative: { | ||
class: `${inputClassName} mr-4`, | ||
wrapper: { | ||
class: 'flex mr-4', | ||
}, | ||
wrapper: 'flex mr-4', | ||
}, | ||
double: { | ||
wrapper: { | ||
class: 'flex items-center gap-[1ch]', | ||
}, | ||
wrapper: 'flex items-center gap-[1ch]', | ||
joiner: {}, | ||
@@ -210,8 +160,4 @@ }, | ||
class: inputClassName, | ||
double: { | ||
wrapper: { | ||
class: 'flex items-center gap-[1ch]', | ||
}, | ||
wrapper: 'flex items-center gap-[1ch]', | ||
joiner: {}, | ||
@@ -221,5 +167,3 @@ }, | ||
text: { | ||
class: inputClassName, | ||
}, | ||
text: inputClassName, | ||
}, | ||
@@ -226,0 +170,0 @@ }; |
import './directives'; | ||
import {default as RefinePlugin} from './plugins/refine'; | ||
import { default as RefinePlugin } from './plugins/refine'; | ||
/** | ||
* @deprecated Use the RefinePlugin instead. | ||
*/ | ||
import { default as DatePickerPlugin } from './plugins/date-picker'; | ||
@@ -4,0 +8,0 @@ |
import { RefineNativeDatePicker } from '../components/base/inputs'; | ||
import Config from './config'; | ||
@@ -7,7 +8,12 @@ export default { | ||
DatePicker: RefineNativeDatePicker, | ||
...options | ||
} | ||
showLocators: false, | ||
...options, | ||
}; | ||
app.component('refine-date-picker', options.DatePicker); | ||
delete options.DatePicker; | ||
Config.init(options); | ||
}, | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1652844
101
3199