1import ue from"./CKwYHLbt.js";import{f as P,m as Y}from"./Cf5Hy4I4.js";import{L as de,a8 as me,r as y,I as ce,E as w,j as q,ae as p,e as r,aH as U,ah as m,h as f,af as g,_ as s,ao as O,aI as A,aJ as C,aL as $,n as h,F as L,aM as D,c as R,ai as d,m as H,bS as fe}from"./BJ-8wcDK.js";import{V as pe}from"./DZaX1b8o.js";import{V as I}from"./0jTFyppv.js";import{V as W}from"./DyDlyf1g.js";import{V as G}from"./DN4g89QP.js";import{V as Q}from"./Wh5r7RGp.js";import{V as S}from"./C7imXgCt.js";import{V as X}from"./CW7bOFa4.js";import"./DUkNh-op.js";import"./CXjaOfKi.js";import"./BcFeW9cW.js";import"./BeFZw9hk.js";import"./B8Uu0eO6.js";import"./CrjaqgVf.js";import"./CBq6R2yk.js";import"./JhwT4Zhu.js";import"./Y3kqfIzb.js";import"./MXlMVQoQ.js";import"./bBKQzEfD.js";import"./CtezZ2lm.js";import"./DNzft_J4.js";import"./Bj_l7BPo.js";import"./DFhZP2ye.js";import"./Bc_1Qc5C.js";import"./kLJXBPFC.js";import"./D1PVXjzM.js";import"./DUpw3eHF.js";import"./Cp9D3-bo.js";import"./n0debvxu.js";const ve={class:"filters-menu"},ye={class:"max-w-[120px] overflow-hidden text-ellipsis whitespace-nowrap"},ge={class:"d-flex justify-space-between align-center mb-4"},_e={class:"text-h6 font-weight-semibold"},ke={class:"d-flex flex-column gap-4"},xe={key:0},he={key:1,class:"mb-4"},be={class:"text-body-2 font-weight-medium mb-3"},Ve={class:"d-flex gap-2"},we={class:"d-flex flex-column align-center gap-1"},Ce={key:3},Ne={class:"d-flex flex-column gap-2"},Oe={class:"text-body-2 font-weight-medium"},Re={key:0,class:"d-flex align-center gap-2"},Se={key:1,class:"d-flex align-center gap-2"},Fe={class:"d-flex justify-end gap-2 mt-4 pt-4 border-t"},Ue="__BLANK__",Ae="__NULL__",$e=de({__name:"FiltersMenu",props:{modelValue:{},filters:{default:()=>[]},kpiFilters:{default:()=>[]},orderFilter:{default:"all"},showOrderFilter:{type:Boolean,default:!0},showNoCache:{type:Boolean,default:!1}},emits:["update:modelValue","update:orderFilter"],setup(Z,{emit:ee}){const t=Z;function le(l,a){return l===Ue?a("widgets.dateRange.filters.valueBlank"):l===Ae?a("widgets.dateRange.filters.valueNull"):l}const B=ee,{t:i,locale:M}=me({useScope:"global"}),_=y(!1),v=y(t.orderFilter),k=y(t.modelValue.no_cache??!1),ae=[{value:"all",label:i("insightpro.orders.filter.all")},{value:"good",label:i("insightpro.orders.filter.good")},{value:"bad",label:i("insightpro.orders.filter.bad")}],c=y({}),b=y({}),x=y({}),N=y(new Set),n=y({}),V=l=>({orders_count:{min:0,max:1e3,step:1},days_since_last_order:{min:0,max:365,step:1},total_income:{min:0,max:1e5,step:100},total_amount:{min:0,max:1e5,step:100},total_product_amount:{min:0,max:1e5,step:100},total_product_net_amount:{min:0,max:1e5,step:100},aov:{min:0,max:1e4,step:10},total_qty:{min:0,max:1e4,step:1},total_profit:{min:-5e4,max:5e4,step:100},total_profit_margin:{min:-100,max:100,step:1},variant_stock:{min:0,max:1e5,step:1},variant_price:{min:0,max:1e5,step:10},variant_cost_of_good:{min:0,max:1e5,step:10},total_organic_clicks:{min:0,max:1e5,step:10},total_ads_clicks:{min:0,max:1e5,step:10}})[l]||{min:0,max:1e3,step:1},K=async l=>{if(l.loadOptions&&!(N.value.has(l.key)||x.value[l.key])){x.value[l.key]=!0;try{const a=await l.loadOptions();Array.isArray(a)?(b.value[l.key]=a,a.length>0&&N.value.add(l.key)):b.value[l.key]=[]}catch{b.value[l.key]=[]}finally{x.value[l.key]=!1}}},te=()=>{for(const l of t.filters)l.loadOptions&&!N.value.has(l.key)&&K(l)};ce(()=>{te()}),w(()=>t.filters,l=>{for(const a of l)a.loadOptions&&!N.value.has(a.key)&&!x.value[a.key]&&K(a)},{immediate:!1}),w(()=>_.value,async l=>{if(l){for(const a of t.filters)if(a.loadOptions&&b.value[a.key]?.length===0&&!x.value[a.key]){const e=await a.loadOptions();Array.isArray(e)&&e.length>0&&(b.value[a.key]=e,N.value.add(a.key))}}});const j=()=>{for(const l of t.filters)l.type==="boolean"?c.value[l.key]=null:c.value[l.key]=l.multiple?[]:null;for(const l of t.kpiFilters)n.value[l.key]={min:null,max:null};v.value="all",k.value=!1},z=R(()=>{let l=0;for(const a of t.filters){const e=t.modelValue.filters?.[a.key];a.type==="boolean"?(e===!0||e===!1)&&l++:a.multiple?Array.isArray(e)&&e.length>0&&l++:e!=null&&e!==""&&l++}for(const a of t.kpiFilters){let e,o;a.key==="registration_date"?(e=t.modelValue.filters?.registration_date_after,o=t.modelValue.filters?.registration_date_before):(e=t.modelValue.filters?.[`${a.key}_min`],o=t.modelValue.filters?.[`${a.key}_max`]),(e||o)&&l++}return t.showOrderFilter&&t.orderFilter!=="all"&&l++,t.modelValue.no_cac
1he===!0&&l++,l}),T=R(()=>z.value>0),E=R(()=>t.filters.length===1),oe=R(()=>t.kpiFilters.length===1),se=R(()=>E.value&&t.kpiFilters.length===0),F=y(!1),ie=()=>{if(F.value)return;const l={...t.modelValue,no_cache:k.value};if(t.filters.length>0||t.kpiFilters.length>0){const e={};for(const o of t.filters){const u=c.value[o.key];o.type==="boolean"?u===!0||u===!1?e[o.key]=u:e[o.key]=null:o.multiple?e[o.key]=Array.isArray(u)&&u.length>0?u:null:e[o.key]=u||null}for(const o of t.kpiFilters){const u=n.value[o.key];u?.min!==null&&u?.min!==void 0&&u.min!==""&&(o.key==="registration_date"?e[`${o.key}_after`]=P(u.min):e[`${o.key}_min`]=u.min),u?.max!==null&&u?.max!==void 0&&u.max!==""&&(o.key==="registration_date"?e[`${o.key}_before`]=P(u.max):e[`${o.key}_max`]=u.max)}l.filters=e}const a=t.modelValue;JSON.stringify(a.filters||{})===JSON.stringify(l.filters||{})&&a.no_cache===l.no_cache||(F.value=!0,B("update:modelValue",l),q(()=>{F.value=!1}))},ne=l=>{v.value=l},re=()=>{ie(),v.value!==t.orderFilter&&B("update:orderFilter",v.value),_.value=!1},J=l=>c.value[l];return w(()=>t.modelValue.no_cache,l=>{l!==void 0&&k.value!==l&&(k.value=l)}),w(()=>t.orderFilter,l=>{v.value!==l&&(v.value=l)}),w(()=>_.value,l=>{l&&q(()=>{if(t.modelValue.filters){c.value={...t.modelValue.filters};for(const a of t.kpiFilters)if(a.key==="registration_date")n.value[a.key]={min:t.modelValue.filters?.registration_date_after||null,max:t.modelValue.filters?.registration_date_before||null};else{const e=`${a.key}_min`,o=`${a.key}_max`;n.value[a.key]={min:t.modelValue.filters[e]||null,max:t.modelValue.filters[o]||null}}}else{for(const a of t.filters)a.type==="boolean"?c.value[a.key]=null:c.value[a.key]=a.multiple?[]:null;for(const a of t.kpiFilters)n.value[a.key]={min:null,max:null}}v.value=t.orderFilter,k.value=t.modelValue.no_cache??!1})}),w(()=>t.modelValue.filters,l=>{if(!(F.value||_.value)){if(l){c.value={...l};for(const a of t.kpiFilters)if(a.key==="registration_date")n.value[a.key]={min:t.modelValue.filters?.registration_date_after||null,max:t.modelValue.filters?.registration_date_before||null};else{const e=`${a.key}_min`,o=`${a.key}_max`;n.value[a.key]={min:t.modelValue.filters[e]||null,max:t.modelValue.filters[o]||null}}}else if(t.filters.length>0||t.kpiFilters.length>0){for(const a of t.filters)(!l||!l[a.key])&&(a.type==="boolean"?c.value[a.key]=null:c.value[a.key]=a.multiple?[]:null);for(const a of t.kpiFilters)l||(n.value[a.key]={min:null,max:null})}}},{deep:!0}),(l,a)=>(d(),p("div",ve,[r(U,{variant:"tonal",color:"primary",class:"min-w-[160px] justify-start normal-case font-medium rounded-lg shadow-none hover:shadow-lg hover:shadow-primary/20"},{prepend:m(()=>[r($,{icon:"tabler-filter",size:"20",class:"mr-2"})]),default:m(()=>[f("span",ye,g(s(i)("widgets.dateRange.filters.title")),1),T.value?(d(),O(pe,{key:0,size:"x-small",color:"primary",class:"ml-2"},{default:m(()=>[A(g(z.value),1)]),_:1})):C("",!0),r($,{icon:"tabler-chevron-down",size:"16",class:h(["ml-2 transition-transform duration-200",{"rotate-180":_.value}])},null,8,["class"]),r(I,{modelValue:_.value,"onUpdate:modelValue":a[1]||(a[1]=e=>_.value=e),"close-on-content-click":!1,location:"bottom end",offset:"16px",activator:"parent","min-width":1200,"max-width":1200},{default:m(()=>[r(W,{class:h(["filters-menu-card",{"filters-menu-card--single":se.value}])},{default:m(()=>[r(G,{class:"pa-4"},{default:m(()=>[f("div",ge,[f("h6",_e,g(s(i)("widgets.dateRange.filters.title")),1),T.value?(d(),O(U,{key:0,variant:"text",size:"small","prepend-icon":"tabler-x",onClick:j},{default:m(()=>[A(g(s(i)("widgets.dateRange.filters.clearAll")),1)]),_:1})):C("",!0)]),f("div",ke,[t.showNoCache?(d(),p("div",xe,[r(ue,{title:s(i)("widgets.dateRange.noCache"),description:s(i)("widgets.dateRange.noCacheDescription"),icon:"tabler-database","is-selected":k.value,compact:!0,"show-description":!0,"onUpdate:isSelected":a[0]||(a[0]=e=>k.value=e)},null,8,["title","description","is-selected"])])):C("",!0),t.showOrderFilter?(d(),p("div",he,[f("div",be,g(s(i)("insightpro.orders.filter.title")),1),f("div",Ve,[(d(),p(L,null,D(ae,e=>r(W,{key:e.value,class:h(["order-filter-card","flex-grow-1","cursor-pointer","transition-all",{"order-filter-card--active":v.value===e.value}]),variant:"outlined",onClick:o=>ne(e.value)},{default:m(()=>[r(G,{class:"pa-3 text-center"},{default:m(()=>[f("div",we,[r($,{icon:e.value==="all"?"tabler-list":e.value==="good"?"tabler-check":"tabler-x",size:24,color:v.value===e.value?"primary":"medium-emphasis"},null,8,["icon","color"]),f("span",{class:h(["text-body-2","font-weight-medium",v.value===e.value?"text-primary":"text-medium-emphasis"])},g(e.label),3)])]),_:2},1024)]),_:2},1032,["class","onClick"])),64))])])):C("",!0),t.filters&&t.filters.length>
10?(d(),p("div",{key:2,class:h(["filters-grid",{"filters-grid--single":E.value}])},[(d(!0),p(L,null,D(t.filters,e=>(d(),p("div",{key:e.key,class:h(["filter-item",{"filter-item--full-width":e.fullWidth}])},[e.type==="boolean"?(d(),O(Q,{key:0,"model-value":c.value[e.key],items:[{value:null,title:s(i)("widgets.dateRange.filters.all")||s(i)("common.all")||"All"},{value:!0,title:s(i)("widgets.dateRange.filters.yes")||s(i)("common.yes")||"Yes"},{value:!1,title:s(i)("widgets.dateRange.filters.no")||s(i)("common.no")||"No"}],label:s(i)(`widgets.dateRange.filters.${e.key}`)||e.label,variant:"outlined",density:"comfortable",clearable:"","onUpdate:modelValue":o=>c.value[e.key]=o},null,8,["model-value","items","label","onUpdate:modelValue"])):e.type==="text"?(d(),O(S,{key:1,"model-value":J(e.key),label:s(i)(`widgets.dateRange.filters.${e.key}`)||e.label,variant:"outlined",density:"comfortable",clearable:"","onUpdate:modelValue":o=>c.value[e.key]=o},null,8,["model-value","label","onUpdate:modelValue"])):(d(),O(Q,{key:2,"model-value":J(e.key),items:(b.value[e.key]||[]).map(o=>({value:o,title:le(o,s(i))})),label:s(i)(`widgets.dateRange.filters.${e.key}`)||e.label,multiple:e.multiple,loading:x.value[e.key],placeholder:x.value[e.key]?s(i)("widgets.dateRange.filters.loading"):s(i)("widgets.dateRange.filters.selectPlaceholder",{filter:s(i)(`widgets.dateRange.filters.${e.key}`)||e.label}),variant:"outlined",density:"comfortable",clearable:"","onUpdate:modelValue":o=>c.value[e.key]=o},null,8,["model-value","items","label","multiple","loading","placeholder","onUpdate:modelValue"]))],2))),128))],2)):C("",!0),t.kpiFilters&&t.kpiFilters.length>0?(d(),p("div",Ce,[f("div",{class:h(["kpi-filters-grid",{"kpi-filters-grid--single":oe.value}])},[(d(!0),p(L,null,D(t.kpiFilters,e=>(d(),p("div",{key:e.key,class:"kpi-filter-item"},[f("div",Ne,[f("div",Oe,g(s(i)(`widgets.dateRange.kpiFilters.${e.key}`)||e.label),1),e.key!=="registration_date"?(d(),p("div",Re,[r(S,{"model-value":n.value[e.key]?.min?e.percentage?(Number(n.value[e.key].min)*100).toString():n.value[e.key].min:"",label:s(i)("widgets.dateRange.kpiFilters.min")||"Min",prefix:e.currency?"â¬":"",suffix:e.percentage?"%":"",type:"number",variant:"outlined",density:"comfortable",min:V(e.key).min,max:V(e.key).max,step:V(e.key).step,clearable:"","hide-details":"",class:"flex-grow-1","onUpdate:modelValue":o=>n.value[e.key]={...n.value[e.key],min:e.percentage?(Number(o)/100).toString()||null:o||null}},null,8,["model-value","label","prefix","suffix","min","max","step","onUpdate:modelValue"]),a[2]||(a[2]=f("span",{class:"text-body-2 text-medium-emphasis"},"-",-1)),r(S,{"model-value":n.value[e.key]?.max?e.percentage?(Number(n.value[e.key].max)*100).toString():n.value[e.key].max:"",label:s(i)("widgets.dateRange.kpiFilters.max")||"Max",prefix:e.currency?"â¬":"",suffix:e.percentage?"%":"",type:"number",variant:"outlined",density:"comfortable",min:V(e.key).min,max:V(e.key).max,step:V(e.key).step,clearable:"","hide-details":"",class:"flex-grow-1","onUpdate:modelValue":o=>n.value[e.key]={...n.value[e.key],max:e.percentage?(Number(o)/100).toString()||null:o||null}},null,8,["model-value","label","prefix","suffix","min","max","step","onUpdate:modelValue"])])):(d(),p("div",Se,[r(I,{"close-on-content-click":!1},{activator:m(({props:o})=>[r(S,H({ref_for:!0},o,{"model-value":n.value[e.key]?.min?s(Y)(n.value[e.key].min):"",readonly:"",label:s(i)("widgets.dateRange.startDate")}),null,16,["model-value","label"])]),default:m(()=>[r(X,{"model-value":n.value[e.key].min,locale:s(M),max:new Date().toISOString().split("T")[0],color:"primary","show-adjacent-months":"","onUpdate:modelValue":o=>n.value[e.key].min=o},null,8,["model-value","locale","max","onUpdate:modelValue"])]),_:2},1024),r(I,{"close-on-content-click":!1},{activator:m(({props:o})=>[r(S,H({ref_for:!0},o,{"model-value":n.value[e.key]?.max?s(Y)(n.value[e.key].max):"",readonly:"",label:s(i)("widgets.dateRange.endDate")}),null,16,["model-value","label"])]),default:m(()=>[r(X,{"model-value":n.value[e.key].max,locale:s(M),max:new Date().toISOString().split("T")[0],color:"primary","show-adjacent-months":"","onUpdate:modelValue":o=>n.value[e.key].max=o},null,8,["model-value","locale","max","onUpdate:modelValue"])]),_:2},1024)]))])]))),128))],2)])):C("",!0)]),f("div",Fe,[r(U,{variant:"outlined",color:"secondary","prepe
1nd-icon":"tabler-refresh",onClick:j},{default:m(()=>[A(g(s(i)("common.reset")),1)]),_:1}),r(U,{color:"primary","prepend-icon":"tabler-check",onClick:re},{default:m(()=>[A(g(s(i)("common.apply")),1)]),_:1})])]),_:1})]),_:1},8,["class"])]),_:1},8,["modelValue"])]),_:1})]))}}),ml=Object.assign(fe($e,[["__scopeId","data-v-4df98618"]]),{__name:"FiltersMenu"});export{ml as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.