`:$+="
",$+=`
${D.marker}
${D.seriesName}
${O}
`}),$}},xAxis:{type:"category",data:y.value,axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{type:"dashed",color:p.value?"#253241":"#D6DAE1"}}},yAxis:[{type:"value",position:"left",name:d("Volume (%s)",vt.currencySign),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:Q=>vt.formatScaledChart(Q)},splitLine:{show:!0,lineStyle:{color:p.value?"#253241":"#D6DAE1",type:"dashed"}}},{type:"value",position:"right",name:d("YoY Growth (%)"),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:"{value}%"},splitLine:{show:!1},min:Math.min(...v.value.filter(Q=>!isNaN(Q)),0)-5,max:Math.max(...v.value.filter(Q=>!isNaN(Q)),0)+5}],series:g.value};try{C.setOption(F,{notMerge:!0,replaceMerge:["series"]})}catch(Q){i.value=`Error updating chart: ${Q.message}`}},S=(F,Q,$,x,I=0)=>({name:F,type:Q,barMaxWidth:t.barMaxWidth,areaStyle:Q==="line"?null:void 0,data:$,smooth:Q==="line",color:x,lineStyle:Q==="line"?{width:2}:void 0,yAxisIndex:I,emphasis:{scale:2,itemStyle:{color:p.value?A.blue[800]:A.blue[400]}}});return ke([()=>t.data,s],()=>{Fe(b)},{deep:!0}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",b,!1),window.removeEventListener("fluentCartCurrencyChange",b,!1),C&&(C.dispose(),C=null)}),De(()=>{window.addEventListener("onFluentCartThemeChange",b),window.addEventListener("fluentCartCurrencyChange",b),Fe(w)}),(F,Q)=>(r(),m("div",$ue,[n($e,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:u(()=>[n(Qe,{title:c(d)(e.title),title_size:"small",border_bottom:""},{action:u(()=>Q[0]||(Q[0]=[])),_:1},8,["title"]),n(xe,{class:"p-0"},{default:u(()=>[i.value?(r(),m("div",Fue,f(i.value),1)):B("",!0),e.isEmpty?(r(),E(wt,{key:2,icon:"Empty/ListView","has-dark":!0,text:c(d)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),m("div",{key:1,class:"fct-chart-wrap fct-gross-volume-chart",ref_key:"chartRef",ref:a,style:{height:"400px"}},null,512))]),_:1})]),_:1},512)]))}},xc=nt(Eue,[["__scopeId","data-v-a0726f58"]]),Uue={class:"fct-country-volume-chart-wrap"},Iue={class:"fct-btn-group sm"},Vue=.05,Due={__name:"CountryVolumeChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=T(null),l=T(null);let s=null;const i=T("bar");T("");const A=T(Re.isDark()),p=K(()=>A.value?["#8FC0F5","#4E90E8","#2E6BC4","#1E4C90","#143562"]:["#9CC9FA","#3E9DF6","#1573D5","#0B57A3","#083C73"]),h=$=>{const x=$.replace("#",""),I=parseInt(x.substring(0,2),16),V=parseInt(x.substring(2,4),16),D=parseInt(x.substring(4,6),16);return(I*299+V*587+D*114)/1e3>150?"#0B3A66":"#ffffff"},_=K(()=>{const $=Array.isArray(t.data.by_countries)?t.data.by_countries:Object.values(t.data.by_countries);return!$.length||!$.every(x=>!!x)}),y=Re.colors,g=K(()=>{const $=t.data.by_month||{};return Object.keys($).sort().map(I=>{const V=$[I],D=Object.values(V).reduce((L,O)=>L+O,0),U=Object.entries(V).sort((L,O)=>L[1]-O[1]).reduce((L,[O,M])=>({...L,[O]:M}),{});return{label:I,countries:U,total:D}})}),v=K(()=>g.value.length?g.value.map($=>{try{const[x,I]=$.label.split("-");return st(new Date(x,I-1)).locale(es()).format(Rl("month_year"))}catch{return $.label}}):[]),C=K(()=>{const $={};Object.values(t.data.by_month||{}).forEach(V=>{Object.entries(V).forEach(([D,U])=>{$[D]=($[D]||0)+U})}),Object.entries(t.data.by_countries||{}).forEach(([V,D])=>{$[V]=D});const x=p.value,I=x[x.length-1];return Object.keys($).sort((V,D)=>$[D]-$[V]).reduce((V,D,U)=>(V[D]=x[U]||I,V),{})}),w=K(()=>g.value.reduce(($,x)=>Math.max($,x.total),0)),b=K(()=>{const $=t.data.by_month||{},x=new Set;Object.values($).forEach(D=>{Object.keys(D).forEach(U=>x.add(U))});const I=p.value,V=w.value;return Array.from(x).reverse().map(D=>{const U=C.value[D]||I[I.length-1],L=h(U),O=g.value.map(M=>{const H=M.countries[D]||0,j=V>0&&H/V>=Vue;return{value:H/100,label:{show:H>0&&j,position:"inside",formatter:D,color:L,fontSize:10,fontWeight:"bold"}}});return{name:D,type:i.value,stack:"total",data:O,itemStyle:{color:U},lineStyle:{color:U}}})}),S=()=>{if(!a.value)return;s=ua(a.value);const $={backgroundColor:"transparent",tooltip:{trigger:"axis",backgroundColor:A.value?"#253241":"#ffffff",textStyle:{color:A.value?y.gray[25]:y.system.mid},borderColor:A.value?"#2C3C4E":"#c0c4ca",axisPointer:Ql(A.value,y.report.dark_cyan_blue_16,y.report.light_gray_cyan_blue,i.value),borderWidth:1,confine:!0,position:Cl,formatter:x=>{const I=A.value?"#ffffff":"#565865",V=A.value?y.report.dark_cyan_blue_16:y.report.light_gray_blue,D=g.value[x[0].dataIndex].total;let U=x[0].axisValue;return x.filter(L=>L.value>0).sort((L,O)=>O.value-L.value).forEach(L=>{const O=qa(L.value*100);U+=`
${L.marker}
${Rs(L.seriesName)}
${O}
`}),U+=`
${d("Total")}
${qa(D)}
`,U}},xAxis:{type:"category",data:v.value,axisLabel:{color:A.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{color:A.value?"#253241":"#D6DAE1"}}},yAxis:{type:"value",position:"left",name:d("Volume (%s)",vt.currencySign),axisLabel:{color:A.value?"#ffffff":"#696778",fontSize:12,formatter:x=>vt.formatScaled(x*100)},splitLine:{show:!0,lineStyle:{color:A.value?"#253241":"#D6DAE1",type:"dashed"}}},series:b.value};s.setOption($)},F=()=>{A.value=Re.isDark(),Fe(()=>{S()})},Q=()=>{s&&(s.dispose(),s=null),S()};return De(()=>{window.addEventListener("onFluentCartThemeChange",F),window.addEventListener("fluentCartCurrencyChange",Q),Fe(S)}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",F,!1),window.removeEventListener("fluentCartCurrencyChange",Q,!1)}),ke(()=>A.value,()=>{s&&(s.dispose(),S())}),ke(()=>t.data,()=>{s&&S()}),($,x)=>(r(),m("div",Uue,[n($e,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:u(()=>[n(Qe,{title:e.title,title_size:"small",border_bottom:""},{action:u(()=>[o("div",Iue,[n(eh,{targetRef:a.value},null,8,["targetRef"])])]),_:1},8,["title"]),n(xe,{class:"p-0"},{default:u(()=>[_.value?(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:c(d)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),m("div",{key:0,class:"fct-chart-wrap fct-country-volume-chart",ref_key:"chartRef",ref:a,style:{height:"400px"}},null,512))]),_:1})]),_:1},512)]))}},Sc=nt(Due,[["__scopeId","data-v-c6534652"]]),Que={class:"fct-card-header-title is-small"},$c={__name:"CountryNetChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=Re.colors.report,l=T(Re.isDark()),s=T(null),i=T("line"),A=T(t.data),p=K(()=>({textColor:l.value?"#ffffff":"#696778",borderColor:l.value?"#2C3C4E":"#c0c4ca",splitLineColor:l.value?"#253241":"#D6DAE1",bgColor:l.value?"#2d3748":"#ffffff"})),h=K(()=>Object.values(A.value).every(b=>b===0)),_=K(()=>Object.keys(A.value)),y=K(()=>[{name:d("Current"),type:i.value,data:Object.values(A.value),smooth:!0,color:l.value?a.purple_dark_mode:a.purple,lineStyle:{width:2},barMaxWidth:30}]);let g=null;const v=()=>{s.value&&!g&&(g=ua(s.value),C())},C=()=>{if(!g)return;const b={legend:{show:!1},tooltip:{trigger:"axis",backgroundColor:p.value.bgColor,borderColor:p.value.borderColor,borderWidth:1,textStyle:{color:p.value.textColor},axisPointer:Ql(l.value,a.dark_cyan_blue_16,a.light_gray_blue,i.value),confine:!0,position:Cl,formatter:S=>{let F=Rs(S[0].name);const Q=l.value?"#ffffff":"#565865";return S.forEach($=>{const x=qa($.value);F+=`
${$.marker}
${$.seriesName}
${x}
`}),F}},xAxis:{type:"category",data:_.value,axisLabel:{color:p.value.textColor,fontSize:12},axisLine:{lineStyle:{type:"dashed",color:p.value.splitLineColor}}},yAxis:{type:"value",axisLabel:{color:p.value.textColor,fontSize:12,formatter:S=>vt.formatScaled(S)},splitLine:{show:!0,lineStyle:{color:p.value.splitLineColor,type:"dashed"}}},series:y.value,grid:{left:"10px",right:"10px",top:"20px",bottom:"60px",containLabel:!0}};g.setOption(b,{notMerge:!0,replaceMerge:["series"]})};ke([()=>A.value,i,()=>l.value],()=>{Fe(C)},{deep:!0});const w=()=>{l.value=Re.isDark(),Fe(()=>{C()})};return De(()=>{window.addEventListener("onFluentCartThemeChange",w,!1),window.addEventListener("fluentCartCurrencyChange",C),Fe(v)}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",w,!1),window.removeEventListener("fluentCartCurrencyChange",C,!1)}),(b,S)=>(r(),E($e,null,{default:u(()=>[e.title!==""?(r(),E(Qe,{key:0,border_bottom:!0},{title:u(()=>[o("h3",Que,f(e.title),1)]),_:1})):B("",!0),n(xe,null,{default:u(()=>[h.value?(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:c(d)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),m("div",{key:0,class:"fct-chart-wrap h-[350px]",ref_key:"SubscriptionCountTrendChartRef",ref:s},null,512))]),_:1})]),_:1}))}},Tue={class:"fct-overview-report-loader-wrap"},Mue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},Lue={class:"fct-card-header-title is-small"},Rue={class:"flex gap-2 mt-1"},Oue={class:"py-6"},Pue={class:"grid grid-cols-1"},Hue={class:"fct-card-header-title is-small"},Nue={class:"py-6"},Kue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},Gue={class:"fct-card-header-title is-small"},zue={class:"flex gap-2 mt-1"},jue={class:"py-6"},que={class:"grid grid-cols-1"},Yue={class:"fct-card-header-title is-small"},Wue={class:"py-6"},Xue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},Jue={class:"fct-card-header-title is-small"},Zue={class:"py-6"},ece={__name:"OverviewLoading",setup(e){const t=[{title:d("Gross Summary"),key:"gross_summary"},{title:d("Gross Revenue Quarterly"),key:"net_summary"}],a=[{title:d("Net Revenue"),key:"net_revenue"},{title:d("Net Revenue Quarterly"),key:"net_revenue_quarterly"}],l=[{title:d("Top Country Gross Volume"),key:"top_country_gross"},{title:d("Top Country Net Volume"),key:"top_country_net"}],s=[{title:d("Top Countries Gross Revenue"),key:"top_country_revenue"},{title:d("Top Countries Net Revenue"),key:"top_country_net_revenue"}];return(i,A)=>{const p=k("el-skeleton-item"),h=k("el-skeleton");return r(),m("div",Tue,[o("div",Mue,[(r(),m(P,null,ae(t,(_,y)=>o("div",{key:y},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",Lue,f(_.title),1),o("div",Rue,[n(h,{animated:""},{template:u(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",Oue,[n(h,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",Pue,[(r(),m(P,null,ae(2,_=>o("div",{key:_},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(h,{animated:""},{template:u(()=>[n(p,{variant:"p",class:"w-2/3"})]),_:1}),n(Qe,{border_bottom:!0},{title:u(()=>[o("h2",Hue,f(c(d)("Gross Volume Breakdown")),1)]),_:1}),o("div",Nue,[n(h,{animated:"",rows:7})])]),_:1})]),_:1})])),64))]),o("div",Kue,[(r(),m(P,null,ae(a,(_,y)=>o("div",{key:y},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",Gue,f(_.title),1),o("div",zue,[n(h,{animated:""},{template:u(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",jue,[n(h,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",que,[(r(),m(P,null,ae(l,(_,y)=>o("div",{key:y},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h2",Yue,f(_.title),1)]),_:2},1024),o("div",Wue,[n(h,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",Xue,[(r(),m(P,null,ae(s,(_,y)=>o("div",{key:y},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",Jue,f(_.title),1)]),_:2},1024),o("div",Zue,[n(h,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))])])}}},tce={class:"overview-summary-report-inline"},ace={class:"inner-value"},lce={__name:"Summary",props:{title:{type:String},current:{type:[String,Number],required:!0},previous:{type:[String,Number],required:!0},fluctuation:{type:[String,Number],required:!0}},setup(e){return(t,a)=>(r(),m("div",tce,[o("div",ace,[n(Ns,{amount:c(vt).formatScaled(e.current),title:c(d)(e.title)},null,8,["amount","title"])]),n(gl,{fluctuation:e.fluctuation,amount:e.previous/100,fluctuationSuffix:c(d)("YoY")},null,8,["fluctuation","amount","fluctuationSuffix"])]))}},ko=nt(lce,[["__scopeId","data-v-b394c9f1"]]),sce={class:"report-overview-page"},nce={class:"flex items-center justify-start gap-1 mb-2 text-xs text-system-mid dark:text-system-light"},oce={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},ice={class:"fct-card-header-title is-small"},rce={class:"fct-card-header-title is-small"},dce={class:"grid grid-cols-1"},uce=["innerHTML"],cce=["innerHTML"],Ace={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},pce={class:"fct-card-header-title is-small"},fce={class:"fct-card-header-title is-small"},mce={class:"grid gap-4 grid-cols-1"},hce={class:"grid gap-4 grid-cols-1"},_ce={class:"report-overview-col-2 grid gap-7.5 grid-cols-1 xl:grid-cols-2"},vce={__name:"Overview",setup(e){const t=T({}),a=T(!0),l=T({gross_revenue_quarterly:{},net_revenue_quarterly:{}}),s=()=>{Ae.get("reports/overview").then(p=>{t.value=p.data,i()}).catch(p=>{}).finally(()=>{a.value=!1})},i=()=>{l.value.gross_revenue_quarterly=A(t.value.gross_revenue_quarterly,"current","prev_year"),l.value.net_revenue_quarterly=A(t.value.net_revenue_quarterly,"current","prev_year")},A=(p,h="current",_="prev")=>{const y=dt.sum(p,"*."+h),g=dt.sum(p,"*."+_),v=g===0?100:(y-g)/g*100;return{value:parseFloat(v.toFixed(2)),prev:g,current:y}};return K(()=>{var p,h;return((p=t.value.gross_summary)==null?void 0:p.yoy_growth)<0?"danger":((h=t.value.gross_summary)==null?void 0:h.yoy_growth)===null?"warning":"success"}),De(()=>{s()}),(p,h)=>(r(),m("div",sce,[o("div",nce,[n(X,{name:"InformationFill",class:"w-4 h-4 text-system-light"}),R(" "+f(c(d)("Last %s Months",c(d)(12))),1)]),a.value?(r(),E(ece,{key:0})):(r(),m(P,{key:1},[o("div",oce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:""},{title:u(()=>[o("h3",ice,f(c(d)("Gross Summary")),1),n(ko,{current:t.value.gross_summary.total,previous:t.value.gross_summary.total_prev,fluctuation:t.value.gross_summary.yoy_growth},null,8,["current","previous","fluctuation"])]),_:1}),n(Co,{data:t.value.gross_revenue,dataKey:"current","date-range":"","is-empty":!t.value.gross_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:""},{title:u(()=>[o("h3",rce,f(c(d)("Gross Revenue Quarterly")),1),n(ko,{current:l.value.gross_revenue_quarterly.current,previous:l.value.gross_revenue_quarterly.prev,fluctuation:l.value.gross_revenue_quarterly.value},null,8,["current","previous","fluctuation"])]),_:1}),n(Co,{data:t.value.gross_revenue_quarterly,dataKey:"current","bar-max-width":80,"is-empty":!l.value.gross_revenue_quarterly.current},null,8,["data","is-empty"])]),_:1})]),_:1})]),o("div",dce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[o("div",{class:"mb-3",innerHTML:c(vt).generateVolumeSummary(t.value.gross_revenue,!0)},null,8,uce),n(xc,{title:c(d)("Gross Volume Breakdown"),data:t.value.gross_revenue,dataKey:"current","is-date":"","is-empty":!t.value.gross_summary.total},null,8,["title","data","is-empty"])]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[o("div",{class:"mb-3",innerHTML:c(vt).generateVolumeSummary(t.value.gross_revenue_quarterly)},null,8,cce),n(xc,{title:c(d)("Gross Revenue Breakdown"),data:t.value.gross_revenue_quarterly,dataKey:"current",prevKey:"prev_year",labelKey:"yy_growth","bar-max-width":80,"is-empty":!t.value.gross_summary.total},null,8,["title","data","is-empty"])]),_:1})]),_:1})]),o("div",Ace,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",pce,f(c(d)("Net Revenue")),1),n(ko,{title:c(d)("Net Revenue"),current:t.value.net_summary.total,previous:t.value.net_summary.total_prev,fluctuation:t.value.net_summary.yoy_growth},null,8,["title","current","previous","fluctuation"])]),_:1}),n(Co,{data:t.value.net_revenue,dataKey:"current","date-range":"","is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",fce,f(c(d)("Net Revenue Quarterly")),1),n(ko,{title:c(d)("Net Revenue Quarterly"),current:l.value.net_revenue_quarterly.current,previous:l.value.net_revenue_quarterly.prev,fluctuation:l.value.net_revenue_quarterly.value},null,8,["title","current","previous","fluctuation"])]),_:1}),n(Co,{data:t.value.net_revenue_quarterly,dataKey:"current","bar-max-width":80,"is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1})]),o("div",mce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Sc,{data:t.value.top_country_gross,title:c(d)("Top Country Gross Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",hce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Sc,{data:t.value.top_country_net,title:c(d)("Top Country Net Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",_ce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>{var _;return[n($c,{data:(_=t.value.top_country_gross)==null?void 0:_.by_countries,title:c(d)("Top Countries Gross Revenue")},null,8,["data","title"])]}),_:1})]),_:1}),n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>{var _;return[n($c,{data:(_=t.value.top_country_net)==null?void 0:_.by_countries,title:c(d)("Top Countries Net Revenue")},null,8,["data","title"])]}),_:1})]),_:1})])],64))]))}},gce={class:"setting-wrap"},yce={class:"setting-wrap-inner"},bce={key:0,class:"bg-white rounded p-6 dark:bg-dark-700"},wce={class:"grid gap-3 mb-6"},Cce={class:"grid gap-3 mb-6"},kce={class:"grid gap-3 mb-6"},Bce={class:"grid gap-3"},xce={class:"payment-method-list fct-content-card-list"},Sce=["id"],$ce={class:"flex items-start gap-3"},Fce={class:"grid gap-2 flex-1"},Ece={key:0,class:"fct-content-card-list-head stripe"},Uce=["src","alt"],Ice=["src","alt"],Vce={class:"block font-semibold text-system-dark dark:text-gray-50"},Dce={class:"fct-content-card-list-content"},Qce={class:"fct-content-card-list-action flex items-center gap-2"},Tce={key:0},Mce=Object.assign({name:"AddonSettings"},{__name:"AddonSettings",setup(e){const t=sf(),{form:a}=t.data,l=ks(),s=T([]),i=T([]),A=T(!0),p=T(!1),h=T(!0),_=T({}),y=T(!1),g=T({}),v=T(!1),C=T(""),w=T(""),b=T(""),S=K(()=>Object.keys(g.value).length>0),F=()=>{p.value=!0;let D=a.values;Ae.post("settings/modules",{...D}).then(U=>{q.success(d("Settings saved successfully")),setTimeout(()=>{window.location.reload()},300)}).catch(U=>{if(U&&U.message)return q.error(U);_.value=U}).finally(()=>{p.value=!1,h.value=!1,A.value=!1})},Q=()=>{A.value=!0,Ae.get("settings/modules",{}).then(D=>{var O,M;a.setSchema(D.fields).setDefaults(D.settings).initForm(),s.value=D.settings,i.value=D.fields,h.value=!1,p.value=!1;const U=((M=(O=D.fields)==null?void 0:O.modules_settings)==null?void 0:M.schema)||[];let L=!1;Array.isArray(U)?L=U.length>0:L=Object.keys(U).length>0,y.value=L}).finally(()=>{A.value=!1})},$=()=>{v.value=!0,Ae.get("settings/modules/plugin-addons",{}).then(D=>{g.value=D.addons||{},b.value&&Fe(()=>Ms.scrollToHashSection(b.value))}).catch(D=>{q.error(D)}).finally(()=>{v.value=!1})},x=je.get("app_config.isProActive"),I=(D,U)=>{if(!x){window.open(D.repo_link,"_blank","noopener,noreferrer");return}C.value=U,Ae.post("settings/modules/plugin-addons/install",{plugin_slug:D.plugin_slug,source_type:D.source_type||"wordpress",source_link:D.source_link||"",asset_path:D.asset_path||""}).then(L=>{L.action==="copy"&&L.url?(ls.copy(L.url,{successMessage:d("Download link copied to your clipboard")}),window.open(L.url,"_blank","noopener,noreferrer")):L.action==="reload"?(q.success(L.message||d("Addon installed successfully")),setTimeout(()=>{window.location.reload()},500)):q.success(L.message||d("Addon installed successfully"))}).catch(L=>{q.error(L)}).finally(()=>{C.value=""})},V=(D,U)=>{w.value=U,Ae.post("settings/modules/plugin-addons/activate",{plugin_file:D.plugin_file}).then(L=>{q.success(L.message||d("Addon activated successfully")),setTimeout(()=>{window.location.reload()},500)}).catch(L=>{q.error(L)}).finally(()=>{w.value=""})};return De(()=>{const D=window.location.hash||"",U=D.lastIndexOf("#");U>0&&(b.value=D.substring(U+1)),Q(),$()}),l.onSave(F),(D,U)=>{const L=k("el-skeleton-item"),O=k("el-skeleton"),M=k("el-form"),H=k("el-button"),j=k("el-icon"),W=k("router-link");return r(),m("div",gce,[n($a,{heading:c(d)("Addon Settings"),"show-save-button":!1},null,8,["heading"]),o("div",yce,[n(Fa),h.value?(r(),m("div",bce,[n(O,{loading:h.value,animated:""},{template:u(()=>[o("div",wce,[n(L,{variant:"p",class:"w-[20%]"}),n(L,{variant:"p"})]),o("div",Cce,[n(L,{variant:"p",class:"w-[20%]"}),n(L,{variant:"p"})]),o("div",kce,[n(L,{variant:"p",class:"w-[20%]"}),n(L,{variant:"p"})]),o("div",Bce,[n(L,{variant:"p",class:"w-[20%]"}),n(L,{variant:"p"})])]),_:1},8,["loading"])])):B("",!0),h.value?B("",!0):(r(),m(P,{key:1},[c(a).isReady?(r(),E(M,{key:0},{default:u(()=>[y.value?(r(),E(Fi,{key:0,form:c(a),showSubmitButton:!0,onOnSubmitButtonClick:F,submitButtonText:c(d)("Save Settings"),loading:p.value,onOnChange:U[0]||(U[0]=G=>{}),"validation-errors":_.value},null,8,["form","submitButtonText","loading","validation-errors"])):S.value?B("",!0):(r(),E($e,{key:1},{default:u(()=>[n(Qe,{title:c(d)("Features & addon"),border_bottom:""},null,8,["title"]),n(xe,null,{default:u(()=>[n(wt,{class:"fct-addon-empty-state",icon:"Empty/Integrations",text:c(d)("No module settings found.")},null,8,["text"])]),_:1})]),_:1}))]),_:1})):B("",!0),S.value?(r(),E($e,{key:1,class:"mt-6"},{default:u(()=>[n(Qe,{title:c(d)("Plugin Addons"),border_bottom:""},null,8,["title"]),n(xe,{class:"py-0"},{default:u(()=>[o("div",xce,[(r(!0),m(P,null,ae(g.value,(G,Y)=>(r(),m("div",{key:Y,class:"fct-content-card-list-item",id:G.plugin_slug===b.value?b.value:null},[o("div",$ce,[o("div",Fce,[G.logo?(r(),m("div",Ece,[o("img",{class:ue({"dark:hidden":G.dark_logo}),src:G.logo,alt:G.title},null,10,Uce),G.dark_logo?(r(),m("img",{key:0,src:G.dark_logo,alt:G.title,class:"hidden dark:block"},null,8,Ice)):B("",!0),o("span",Vce,f(G.title),1),G.is_active?(r(),E(la,{key:1,status:"active",text:c(d)("Active")},null,8,["text"])):B("",!0)])):B("",!0),o("div",Dce,[o("p",null,f(G.description),1)])]),o("div",Qce,[G.upcoming?(r(),m("div",Tce,f(c(d)("Coming Soon")),1)):(r(),m(P,{key:1},[G.is_installed?G.is_installed&&!G.is_active&&(c(x)||G.source_type!=="github")?(r(),E(H,{key:1,type:"success",size:"small",loading:w.value===Y,disabled:w.value===Y,onClick:J=>V(G,Y)},{default:u(()=>[R(f(c(d)("Activate")),1)]),_:2},1032,["loading","disabled","onClick"])):B("",!0):(r(),E(H,{key:0,type:"primary",size:"small",loading:C.value===Y,disabled:C.value===Y,onClick:J=>I(G,Y)},{default:u(()=>[R(f(c(x)?c(d)("Install & Activate"):c(d)("Download")),1)]),_:2},1032,["loading","disabled","onClick"])),G.is_active&&Y==="fluent-pdf"?(r(),E(W,{key:2,to:{path:"/settings/pdf-template"}},{default:u(()=>[n(j,{class:"text-gray-500 hover:text-primary cursor-pointer",size:18},{default:u(()=>[n(c(tA))]),_:1})]),_:1})):B("",!0)],64))])])],8,Sce))),128))])]),_:1})]),_:1})):B("",!0)],64))])])}}}),Lce=nt(Mce,[["__scopeId","data-v-a315b5d5"]]),Rce={class:"form-note"},Oce={class:"form-note"},Pce={class:"form-note"},Hce={class:"form-note"},Nce={class:"el-form-item__label"},Kce={class:"h-[297px] w-full relative"},Gce={class:"mt-2 mb-2"},zce={class:"form-note"},jce={class:"fct-powered-by-email-footer-checkbox mb-4 pb-4 border-[1px] border-l-0 border-t-0 border-r-0 border-solid border-gray-outline dark:border-dark-400"},qce={class:"setting-html-wrapper"},Yce={class:"setting-label"},Wce={class:"form-note"},Xce={class:"setting-fields-inner w-full"},Jce={__name:"MailingSettingsLoader",setup(e){return(t,a)=>{const l=k("el-skeleton-item"),s=k("el-skeleton"),i=k("el-form-item"),A=k("el-col"),p=k("el-row");return r(),E(xe,null,{default:u(()=>[n(p,{gutter:15},{default:u(()=>[n(A,{lg:12},{default:u(()=>[n(i,{label:c(d)("From Name"),"label-position":"top"},{default:u(()=>[n(s,{animated:"",class:"h-9 gap-2"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),a[0]||(a[0]=o("br",null,null,-1)),o("div",null,[o("div",Rce,[o("p",null,f(c(d)("Name that will be used to send emails")),1)])])]),_:1,__:[0]},8,["label"])]),_:1}),n(A,{lg:12},{default:u(()=>[n(i,{label:c(d)("From Email"),"label-position":"top"},{default:u(()=>[n(s,{animated:"",class:"h-9"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",null,[o("div",Oce,[o("p",null,f(c(d)(`Provide Valid Email Address email as per your domain/SMTP settings. This
email will be used to send emails like notifications`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(p,{gutter:15},{default:u(()=>[n(A,{lg:12},{default:u(()=>[n(i,{label:c(d)("Reply to name (Optional)"),"label-position":"top"},{default:u(()=>[n(s,{animated:"",class:"h-9"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",Pce,[o("p",null,f(c(d)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),n(A,{lg:12},{default:u(()=>[n(i,{label:c(d)("Reply to email (Optional)"),"label-position":"top"},{default:u(()=>[n(s,{animated:"",class:"h-9"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",null,[o("div",Hce,[o("p",null,f(c(d)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(p,{gutter:15},{default:u(()=>[n(A,null,{default:u(()=>[o("div",Nce,f(c(d)("Email Footer")),1),o("div",Kce,[n(s,{animated:"",rows:7})]),o("div",Gce,[o("div",zce,[o("p",null,f(c(d)(`This email footer will be used for all emails sent from FluentCart, It's highly recommended to use your business name and address in the footer for
compliance.`)),1)])]),o("div",jce,[n(s,{animated:"",class:"h-5"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1}),n(p,{gutter:15},{default:u(()=>[n(A,null,{default:u(()=>[n(i,null,{default:u(()=>[n(p,{gutter:15,class:"w-full"},{default:u(()=>[n(A,{lg:12},{default:u(()=>[o("div",qce,[o("span",Yce,f(c(d)("Admin Email Address")),1),o("div",Wce,[o("p",null,f(c(d)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),n(A,{lg:12},{default:u(()=>[o("div",Xce,[n(s,{animated:"",class:"h-9"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}}},Zce={class:"setting-wrap"},eAe={class:"setting-wrap-inner"},tAe={class:"form-note"},aAe={class:"form-note"},lAe={class:"form-note"},sAe={class:"form-note"},nAe={class:"el-form-item__label"},oAe={class:"mt-2 mb-2"},iAe={class:"form-note"},rAe={class:"fct-powered-by-email-footer-checkbox"},dAe={class:"setting-html-wrapper"},uAe={class:"setting-label"},cAe={class:"form-note"},AAe={class:"setting-fields-inner w-full"},pAe={class:"setting-save-action"},fAe={__name:"MailingSettings",setup(e){const t=T({from_name:"",from_email:"",reply_to_name:"",reply_to_email:"",email_footer:"",show_email_footer:"yes",admin_email:"{{wp.admin_email}}"}),a=je.get("app_config.isProActive"),l=T(!1),s=T({}),i=T({}),A=()=>{l.value=!0,Ae.get("email-notification/get-settings").then(h=>{var _,y,g,v,C,w,b;t.value={from_name:(_=h.data)==null?void 0:_.from_name,from_email:(y=h.data)==null?void 0:y.from_email,reply_to_name:(g=h.data)==null?void 0:g.reply_to_name,reply_to_email:(v=h.data)==null?void 0:v.reply_to_email,email_footer:(C=h.data)==null?void 0:C.email_footer,admin_email:(w=h.data)==null?void 0:w.admin_email,show_email_footer:((b=h.data)==null?void 0:b.show_email_footer)||"yes"},i.value=h.shortcodes}).catch(h=>{}).finally(()=>{l.value=!1})},p=()=>{l.value=!0,s.value={},Ae.post("email-notification/save-settings",t.value).then(h=>{q.success(h.message)}).catch(h=>{h.status_code===422&&h.data?s.value=h.data:h.message?q.error(h.message):(q.error(d("Something went wrong")),s.value=h)}).finally(()=>{l.value=!1})};return De(()=>{A()}),(h,_)=>{const y=k("el-input"),g=k("el-form-item"),v=k("el-col"),C=k("el-row"),w=k("el-tooltip"),b=k("el-checkbox"),S=k("el-button");return r(),m("div",Zce,[n($a,{heading:c(d)("Mailing Settings"),loading:l.value,onOnSave:p},null,8,["heading","loading"]),o("div",eAe,[n(Fa),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Email Configuration"),text:c(d)("Set your from name, email, and email footer. These configurations will be used to send emails from %s.","FluentCart"),border_bottom:""},null,8,["title","text"]),l.value?(r(),E(Jce,{key:0})):(r(),E(xe,{key:1},{default:u(()=>[n(C,{gutter:15},{default:u(()=>[n(v,{lg:12},{default:u(()=>[n(g,{label:c(d)("From Name"),"label-position":"top"},{default:u(()=>[n(y,{modelValue:t.value.from_name,"onUpdate:modelValue":_[0]||(_[0]=F=>t.value.from_name=F)},null,8,["modelValue"]),_[9]||(_[9]=o("br",null,null,-1)),o("div",null,[n(vl,{"validation-errors":s.value.from_name||{},"field-key":"from_name"},null,8,["validation-errors"]),o("div",tAe,[o("p",null,f(c(d)("Name that will be used to send emails")),1)])])]),_:1,__:[9]},8,["label"])]),_:1}),n(v,{lg:12},{default:u(()=>[n(g,{label:c(d)("From Email"),"label-position":"top"},{default:u(()=>[n(y,{modelValue:t.value.from_email,"onUpdate:modelValue":_[1]||(_[1]=F=>t.value.from_email=F)},null,8,["modelValue"]),o("div",null,[n(vl,{"validation-errors":s.value.from_email||{},"field-key":"from_email"},null,8,["validation-errors"]),o("div",aAe,[o("p",null,f(c(d)(`Provide Valid Email Address email as per your domain/SMTP settings. This
email will be used to send emails like notifications`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(C,{gutter:15},{default:u(()=>[n(v,{lg:12},{default:u(()=>[n(g,{label:c(d)("Reply to name (Optional)"),"label-position":"top"},{default:u(()=>[n(y,{modelValue:t.value.reply_to_name,"onUpdate:modelValue":_[2]||(_[2]=F=>t.value.reply_to_name=F)},null,8,["modelValue"]),o("div",lAe,[o("p",null,f(c(d)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),n(v,{lg:12},{default:u(()=>[n(g,{label:c(d)("Reply to email (Optional)"),"label-position":"top"},{default:u(()=>[n(y,{modelValue:t.value.reply_to_email,"onUpdate:modelValue":_[3]||(_[3]=F=>t.value.reply_to_email=F)},null,8,["modelValue"]),o("div",null,[n(vl,{"validation-errors":s.value.reply_to_email||{},"field-key":"reply_to_email"},null,8,["validation-errors"]),o("div",sAe,[o("p",null,f(c(d)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(C,{gutter:15},{default:u(()=>[n(v,null,{default:u(()=>[o("div",nAe,f(c(d)("Email Footer")),1),n(ss,{"short-codes":i.value,modelValue:t.value.email_footer,"onUpdate:modelValue":_[4]||(_[4]=F=>t.value.email_footer=F),onUpdate:_[5]||(_[5]=F=>{t.value.email_footer=F})},null,8,["short-codes","modelValue"]),o("div",oAe,[n(vl,{"validation-errors":s.value.email_footer||{},"field-key":"email_footer"},null,8,["validation-errors"]),o("div",iAe,[o("p",null,f(c(d)(`This email footer will be used for all emails sent from FluentCart, It's highly recommended to use your business name and address in the footer for
compliance.`)),1)])]),o("div",rAe,[n(b,{modelValue:t.value.show_email_footer,"onUpdate:modelValue":_[6]||(_[6]=F=>t.value.show_email_footer=F),"true-value":"yes","false-value":"no",disabled:!c(a)},{default:u(()=>[R(f(c(d)("Enable powered by FluentCart in the email footer"))+" ",1),c(a)?B("",!0):(r(),E(w,{key:0,"popper-class":"fct-tooltip",placement:"top"},{content:u(()=>[R(f(c(d)("This feature is available in pro version only.")),1)]),default:u(()=>[n(X,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),_:1},8,["modelValue","disabled"])])]),_:1})]),_:1}),n(C,{gutter:15},{default:u(()=>[n(v,null,{default:u(()=>[n(g,null,{default:u(()=>[n(C,{gutter:15,class:"w-full"},{default:u(()=>[n(v,{lg:12},{default:u(()=>[o("div",dAe,[o("span",uAe,f(c(d)("Admin Email Address")),1),o("div",cAe,[o("p",null,f(c(d)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),n(v,{lg:12},{default:u(()=>[o("div",AAe,[n(y,{modelValue:t.value.admin_email,"onUpdate:modelValue":_[7]||(_[7]=F=>t.value.admin_email=F)},null,8,["modelValue"])])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1}),o("div",pAe,[n(S,{type:"primary",onClick:_[8]||(_[8]=F=>p()),loading:l.value},{default:u(()=>[R(f(c(d)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},mAe={class:"setting-wrap"},hAe={class:"setting-wrap-inner"},_Ae={class:"form-note"},vAe={class:"form-note"},gAe={class:"form-note",style:{"padding-top":"6px"}},yAe={class:"form-note"},bAe={class:"setting-save-action"},Fc="{{wp.admin_email}}",wAe={__name:"StoreDigestSettings",setup(e){const t=T({recipients:"{{wp.admin_email}}",send_when_empty:"no",daily:{enabled:"no",send_hour:8},weekly:{enabled:"no",send_hour:8,send_dow:1},monthly:{enabled:"no",send_hour:8}}),a=T(!1),l=T({}),s=T(""),i=[{key:"daily",label:d("Daily digest"),desc:d("Yesterday's performance, sent every morning.")},{key:"weekly",label:d("Weekly digest"),desc:d("The previous 7 days, sent on your chosen day.")},{key:"monthly",label:d("Monthly digest"),desc:d("The previous calendar month, sent on the 1st.")}],A=d("Comma-separate multiple addresses. %1$s resolves to the site admin email.",Fc),p=K(()=>{const v=[];for(let C=0;C<24;C++)v.push({value:C,label:String(C).padStart(2,"0")+":00"});return v}),h=[{value:1,label:d("Monday")},{value:2,label:d("Tuesday")},{value:3,label:d("Wednesday")},{value:4,label:d("Thursday")},{value:5,label:d("Friday")},{value:6,label:d("Saturday")},{value:7,label:d("Sunday")}],_=()=>{a.value=!0,Ae.get("email-notification/digest-settings").then(v=>{v.data&&(t.value=v.data)}).catch(()=>{}).finally(()=>{a.value=!1})},y=()=>{a.value=!0,l.value={},Ae.post("email-notification/digest-settings",t.value).then(v=>{q.success(v.message)}).catch(v=>{v.status_code===422&&v.data?l.value=v.data:v.message?q.error(v.message):q.error(d("Something went wrong"))}).finally(()=>{a.value=!1})},g=v=>{s.value=v,Ae.post("email-notification/digest-settings/send-test",{frequency:v}).then(C=>{q.success(C.message)}).catch(C=>{q.error(C.message||d("Could not send the test email."))}).finally(()=>{s.value=""})};return De(()=>{_()}),(v,C)=>{const w=k("el-input"),b=k("el-form-item"),S=k("el-col"),F=k("el-checkbox"),Q=k("el-row"),$=k("el-switch"),x=k("el-option"),I=k("el-select"),V=k("el-button");return r(),m("div",mAe,[n($a,{heading:c(d)("Store Digest Emails"),loading:a.value,onOnSave:y},null,8,["heading","loading"]),o("div",hAe,[n(Fa),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Recipients & General"),text:c(d)("A system email summarising your store activity. Numbers match the Reports dashboard."),border_bottom:""},null,8,["title","text"]),n(xe,null,{default:u(()=>[n(Q,{gutter:15},{default:u(()=>[n(S,{lg:12},{default:u(()=>[n(b,{label:c(d)("Recipient email addresses"),"label-position":"top"},{default:u(()=>[n(w,{modelValue:t.value.recipients,"onUpdate:modelValue":C[0]||(C[0]=D=>t.value.recipients=D),placeholder:Fc},null,8,["modelValue"]),o("div",null,[n(vl,{"validation-errors":l.value.recipients||{},"field-key":"recipients"},null,8,["validation-errors"]),o("div",_Ae,[o("p",null,f(c(A)),1)])])]),_:1},8,["label"])]),_:1}),n(S,{lg:12},{default:u(()=>[n(b,{label:c(d)("Empty periods"),"label-position":"top"},{default:u(()=>[n(F,{modelValue:t.value.send_when_empty,"onUpdate:modelValue":C[1]||(C[1]=D=>t.value.send_when_empty=D),"true-value":"yes","false-value":"no"},{default:u(()=>[R(f(c(d)("Send even when there was no activity")),1)]),_:1},8,["modelValue"]),o("div",vAe,[o("p",null,f(c(d)("When off, a digest is skipped for any period with no paid orders.")),1)])]),_:1},8,["label"])]),_:1})]),_:1})]),_:1})]),_:1}),(r(),m(P,null,ae(i,D=>n($e,{key:D.key,class:"fct-mt-4"},{default:u(()=>[n(Qe,{title:D.label,text:D.desc,border_bottom:""},null,8,["title","text"]),n(xe,null,{default:u(()=>[n(Q,{gutter:15,align:"middle"},{default:u(()=>[n(S,{lg:6},{default:u(()=>[n(b,{label:c(d)("Enable"),"label-position":"top"},{default:u(()=>[n($,{modelValue:t.value[D.key].enabled,"onUpdate:modelValue":U=>t.value[D.key].enabled=U,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),n(S,{lg:6},{default:u(()=>[n(b,{label:c(d)("Send time"),"label-position":"top"},{default:u(()=>[n(I,{modelValue:t.value[D.key].send_hour,"onUpdate:modelValue":U=>t.value[D.key].send_hour=U,class:"w-full"},{default:u(()=>[(r(!0),m(P,null,ae(p.value,U=>(r(),E(x,{key:U.value,label:U.label,value:U.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),D.key==="weekly"?(r(),E(S,{key:0,lg:6},{default:u(()=>[n(b,{label:c(d)("Day of week"),"label-position":"top"},{default:u(()=>[n(I,{modelValue:t.value.weekly.send_dow,"onUpdate:modelValue":C[2]||(C[2]=U=>t.value.weekly.send_dow=U),class:"w-full"},{default:u(()=>[(r(),m(P,null,ae(h,U=>n(x,{key:U.value,label:U.label,value:U.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})):B("",!0),D.key==="monthly"?(r(),E(S,{key:1,lg:6},{default:u(()=>[n(b,{label:c(d)("Send day"),"label-position":"top"},{default:u(()=>[o("div",gAe,[o("p",null,f(c(d)("Sent on the 1st of each month.")),1)])]),_:1},8,["label"])]),_:1})):B("",!0),n(S,{lg:6},{default:u(()=>[n(b,{label:" ","label-position":"top"},{default:u(()=>[n(V,{loading:s.value===D.key,onClick:U=>g(D.key),class:"mt-2"},{default:u(()=>[R(f(c(d)("Send test email")),1)]),_:2},1032,["loading","onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1024),o("div",yAe,[o("p",null,f(c(d)("Send time is in your store timezone. Test emails use your saved recipients.")),1)])]),_:2},1024)]),_:2},1024)),64)),o("div",bAe,[n(V,{type:"primary",onClick:C[3]||(C[3]=D=>y()),loading:a.value},{default:u(()=>[R(f(c(d)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},CAe={};function kAe(e,t){const a=k("router-view");return r(),m("div",null,[n(a)])}const BAe=nt(CAe,[["render",kAe]]),xAe={},SAe={class:"fct-setting-form-row"},$Ae={class:"w-[300px]"},FAe={class:"flex-grow flex-shrink flex-basis-0 self-center"},EAe={class:"fct-setting-form-row"},UAe={class:"w-[300px]"},IAe={class:"flex-grow flex-shrink flex-basis-0 self-center"},VAe={class:"fct-setting-form-row"},DAe={class:"w-[300px]"},QAe={class:"flex-grow flex-shrink flex-basis-0 self-center"};function TAe(e,t){const a=k("el-skeleton-item"),l=k("el-skeleton");return r(),m("div",null,[o("div",SAe,[o("div",$Ae,[n(l,{animated:"",class:"max-w-[70%]"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-[80%]"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"}),n(a,{variant:"p",class:"w-1/2 h-4"})]),_:1})]),o("div",FAe,[n(l,{animated:""},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",EAe,[o("div",UAe,[n(l,{animated:"",class:"max-w-[60%]"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-full"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})]),o("div",IAe,[n(l,{animated:""},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",VAe,[o("div",DAe,[n(l,{animated:"",class:"max-w-[50%]"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-full"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})]),o("div",QAe,[n(l,{animated:""},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])])])}const MAe=nt(xAe,[["render",TAe]]),LAe={name:"TaxConfigurations",components:{TaxConfigurationsLoader:MAe,CardContainer:$e,CardBody:xe,CardHeader:Qe,LabelHint:Rt,SettingsHeader:$a,AdminNotice:Fa,Animation:_a},data(){return{settings:{enable_tax:"no",tax_inclusion:"included",tax_calculation_basis:"shipping",tax_rounding:"item",checkout_tax_breakdown_display:"itemized",tax_display_label:"Tax",price_suffix_included:"",price_suffix_excluded:"",eu_vat_settings:{require_vat_number:"no",local_reverse_charge:"yes",reverse_charge_price_mode:"fixed",vat_reverse_excluded_categories:[]}},tax_settings_changed:!1,saving:!1,loading:!1,categories:[],fetchingCategories:!1,keyboardShortcuts:null}},computed:{handlePriceMode(){return this.settings.eu_vat_settings.local_reverse_charge=="yes"}},mounted(){this.bindSaveShortcut(),this.getSettings(),this.fetchCategories()},beforeUnmount(){this.unbindSaveShortcut()},methods:{translate:d,saveSettings(){this.saving||this.loading||(this.saving=!0,this.$post("tax/configuration/settings",{settings:this.settings}).then(e=>{this.handleSuccess(e.message),this.tax_settings_changed=!0,je.mergeConfig({is_tax_enabled:this.settings.enable_tax==="yes"})}).catch(e=>{var t;this.handleError((t=e==null?void 0:e.data)==null?void 0:t.message),this.saving=!1}).finally(()=>{this.saving=!1}))},getSettings(){this.loading=!0,this.$get("tax/configuration/settings").then(e=>{if(this.settings=e.settings,this.settings.eu_vat_settings={require_vat_number:"no",local_reverse_charge:"yes",reverse_charge_price_mode:"fixed",vat_reverse_excluded_categories:[],...this.settings.eu_vat_settings||{}},["itemized","simplified"].includes(this.settings.checkout_tax_breakdown_display)||(this.settings.checkout_tax_breakdown_display="itemized"),this.settings.tax_display_label||(this.settings.tax_display_label="Tax"),!Array.isArray(this.settings.eu_vat_settings.vat_reverse_excluded_categories))this.settings.eu_vat_settings.vat_reverse_excluded_categories=[];else{let t=this.settings.eu_vat_settings.vat_reverse_excluded_categories.map(a=>a.toString());this.settings.eu_vat_settings.vat_reverse_excluded_categories=t}}).catch(e=>{var t;this.handleError((t=e==null?void 0:e.data)==null?void 0:t.message)}).finally(()=>{this.loading=!1})},fetchCategories(){this.categories.length>0||(this.fetchingCategories=!0,this.$get("products/fetch-term").then(e=>{this.categories=e.taxonomies["product-categories"].terms||[]}).catch(()=>{}).finally(()=>{this.fetchingCategories=!1}))},bindSaveShortcut(){this.keyboardShortcuts=is(),this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.saveSettings()})},unbindSaveShortcut(){var e;(e=this.keyboardShortcuts)!=null&&e.unbind&&this.keyboardShortcuts.unbind("mod+s")}}},RAe={class:"setting-wrap"},OAe={class:"setting-wrap-inner"},PAe={class:"fct-setting-form-row"},HAe={class:"fct-setting-form-content flex gap-3.5 flex-1"},NAe={class:"fct-inline-tip"},KAe={key:1},GAe={class:"fct-setting-form-row"},zAe={class:"fct-setting-form-content"},jAe={class:"fct-inline-tip"},qAe={class:"fct-setting-form-fields self-center"},YAe={class:"fct-inline-tip mt-2"},WAe={class:"fct-setting-form-row"},XAe={class:"fct-setting-form-content"},JAe={class:"fct-inline-tip"},ZAe={class:"fct-setting-form-fields self-center"},epe={class:"flex flex-col"},tpe={class:"price-mode-label"},ape={class:"price-mode-text"},lpe={class:"flex flex-col"},spe={class:"price-mode-label"},npe={class:"price-mode-text"},ope={class:"fct-setting-form-row"},ipe={class:"fct-setting-form-content"},rpe={class:"fct-inline-tip"},dpe={class:"fct-setting-form-fields self-center"},upe={class:"fct-setting-form-row"},cpe={class:"fct-setting-form-content"},Ape={class:"fct-inline-tip"},ppe={class:"fct-setting-form-fields self-center"},fpe={class:"fct-setting-form-row"},mpe={class:"fct-setting-form-content"},hpe={class:"fct-inline-tip"},_pe={class:"fct-setting-form-fields self-center"},vpe={class:"fct-setting-form-row"},gpe={class:"fct-setting-form-content"},ype={class:"fct-inline-tip"},bpe={class:"fct-setting-form-fields self-center"},wpe={key:0,class:"fct-setting-form-row"},Cpe={class:"fct-setting-form-content"},kpe={class:"fct-inline-tip"},Bpe={class:"fct-setting-form-fields self-center"},xpe={class:"fct-setting-form-row"},Spe={class:"fct-setting-form-content"},$pe={class:"fct-inline-tip"},Fpe={class:"fct-setting-form-fields"},Epe={class:"fct-vat-charge-setting-wrap grid gap-5 w-full"},Upe={class:"fct-local-reverse-charge flex gap-2 justify-items-start"},Ipe={class:"fct-inline-tip"},Vpe={class:"fct-vat-excluded-categories"},Dpe={class:"fct-inline-tip"};function Qpe(e,t,a,l,s,i){const A=k("SettingsHeader"),p=k("AdminNotice"),h=k("el-switch"),_=k("LabelHint"),y=k("TaxConfigurationsLoader"),g=k("el-radio"),v=k("el-radio-group"),C=k("el-option"),w=k("el-select"),b=k("el-input"),S=k("Animation"),F=k("CardBody"),Q=k("CardContainer"),$=Ta("loading");return r(),m("div",RAe,[n(A,{heading:i.translate("Tax Configuration"),loading:s.saving,"show-cmnd-icon":!0,onOnSave:i.saveSettings},null,8,["heading","loading","onOnSave"]),o("div",OAe,[n(p),n(Q,null,{default:u(()=>[n(F,null,{default:u(()=>[o("div",PAe,[o("div",HAe,[n(h,{modelValue:s.settings.enable_tax,"onUpdate:modelValue":t[0]||(t[0]=x=>s.settings.enable_tax=x),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Enable Tax")},null,8,["title"]),o("p",NAe,f(s.settings.enable_tax==="yes"?i.translate("This store is now collecting tax."):i.translate("This store is not collecting tax.")),1)])])]),n(S,{visible:s.settings.enable_tax==="yes",accordion:""},{default:u(()=>[s.loading?(r(),E(y,{key:0})):B("",!0),s.loading?B("",!0):(r(),m("div",KAe,[o("div",GAe,[o("div",zAe,[n(_,{title:i.translate("Prices entered with tax")},null,8,["title"]),o("p",jAe,f(i.translate("Choose whether product prices are entered including or excluding tax.")),1)]),o("div",qAe,[n(v,{modelValue:s.settings.tax_inclusion,"onUpdate:modelValue":t[1]||(t[1]=x=>s.settings.tax_inclusion=x)},{default:u(()=>[n(g,{value:"included"},{default:u(()=>[R(f(i.translate("Included")),1)]),_:1}),n(g,{value:"excluded"},{default:u(()=>[R(f(i.translate("Excluded")),1)]),_:1})]),_:1},8,["modelValue"]),o("p",YAe,f(i.translate("Shipping tax always follows the store-level tax mode (Included or Excluded). Product-specific tax settings do not apply to shipping.")),1)])]),o("div",WAe,[o("div",XAe,[n(_,{title:i.translate("Tax-Inclusive Price Mode")},null,8,["title"]),o("p",JAe,f(i.translate("Controls how reverse charge affects tax-inclusive product prices.")),1)]),o("div",ZAe,[n(v,{modelValue:s.settings.eu_vat_settings.reverse_charge_price_mode,"onUpdate:modelValue":t[2]||(t[2]=x=>s.settings.eu_vat_settings.reverse_charge_price_mode=x),class:"fct-reverse-charge-price-mode"},{default:u(()=>[n(g,{value:"fixed"},{default:u(()=>[o("div",epe,[o("span",tpe,f(i.translate("Fixed")),1),o("span",ape,f(i.translate("Listed price stays unchanged on reverse charge. Only the tax line is zeroed on the invoice.")),1)])]),_:1}),n(g,{value:"dynamic"},{default:u(()=>[o("div",lpe,[o("span",spe,f(i.translate("Dynamic")),1),o("span",npe,f(i.translate("VAT is stripped from the price on reverse charge. Customer pays the net (ex-VAT) amount.")),1)])]),_:1})]),_:1},8,["modelValue"])])]),o("div",ope,[o("div",ipe,[n(_,{title:i.translate("Calculate Tax Based On")},null,8,["title"]),o("p",rpe,f(i.translate("Determine the location used for tax calculations.")),1)]),o("div",dpe,[n(w,{modelValue:s.settings.tax_calculation_basis,"onUpdate:modelValue":t[3]||(t[3]=x=>s.settings.tax_calculation_basis=x),clearable:""},{default:u(()=>[n(C,{value:"shipping",label:i.translate("Customer Shipping Address")},null,8,["label"]),n(C,{value:"billing",label:i.translate("Customer Billing Address")},null,8,["label"]),n(C,{value:"store",label:i.translate("Store Location")},null,8,["label"])]),_:1},8,["modelValue"])])]),o("div",upe,[o("div",cpe,[n(_,{title:i.translate("Price Suffix (Tax Included)")},null,8,["title"]),o("p",Ape,f(i.translate("Shown on prices where tax is included. Applies when product or store pricing is tax-inclusive.")),1)]),o("div",ppe,[n(b,{modelValue:s.settings.price_suffix_included,"onUpdate:modelValue":t[4]||(t[4]=x=>s.settings.price_suffix_included=x),placeholder:i.translate("e.g. (incl. tax)")},null,8,["modelValue","placeholder"])])]),o("div",fpe,[o("div",mpe,[n(_,{title:i.translate("Price Suffix (Tax Excluded)")},null,8,["title"]),o("p",hpe,f(i.translate("Shown on prices where tax is excluded. Applies when product or store pricing is tax-exclusive.")),1)]),o("div",_pe,[n(b,{modelValue:s.settings.price_suffix_excluded,"onUpdate:modelValue":t[5]||(t[5]=x=>s.settings.price_suffix_excluded=x),placeholder:i.translate("e.g. (+ tax)")},null,8,["modelValue","placeholder"])])]),o("div",vpe,[o("div",gpe,[n(_,{title:i.translate("Tax Display Style")},null,8,["title"]),o("p",ype,f(i.translate("Choose how tax context appears on each checkout line item.")),1)]),o("div",bpe,[n(w,{modelValue:s.settings.checkout_tax_breakdown_display,"onUpdate:modelValue":t[6]||(t[6]=x=>s.settings.checkout_tax_breakdown_display=x)},{default:u(()=>[n(C,{value:"simplified",label:i.translate("Simplified (single line + details)")},null,8,["label"]),n(C,{value:"itemized",label:i.translate("Itemized (per-item tax + breakdown)")},null,8,["label"])]),_:1},8,["modelValue"])])]),s.settings.checkout_tax_breakdown_display==="simplified"?(r(),m("div",wpe,[o("div",Cpe,[n(_,{title:i.translate("Tax Line Label")},null,8,["title"]),o("p",kpe,f(i.translate("The single-line tax label shown in Simplified mode, e.g. VAT, MwSt, GST.")),1)]),o("div",Bpe,[n(b,{modelValue:s.settings.tax_display_label,"onUpdate:modelValue":t[7]||(t[7]=x=>s.settings.tax_display_label=x),placeholder:i.translate("e.g. Tax")},null,8,["modelValue","placeholder"])])])):B("",!0),o("div",xpe,[o("div",Spe,[n(_,{title:i.translate("VAT Reverse Charge Settings")},null,8,["title"]),o("p",$pe,f(i.translate("Configure reverse VAT handling for customers in the European Union.")),1)]),o("div",Fpe,[o("div",Epe,[o("div",Upe,[n(h,{modelValue:s.settings.eu_vat_settings.local_reverse_charge,"onUpdate:modelValue":t[8]||(t[8]=x=>s.settings.eu_vat_settings.local_reverse_charge=x),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Local Reverse Charge")},null,8,["title"]),o("p",Ipe,f(i.translate("If enabled, apply reverse charge when applicable even when customers are in your home country.")),1)])]),n(S,{visible:i.handlePriceMode,accordion:""},{default:u(()=>[o("div",Vpe,[n(_,{title:i.translate("Exclude Categories from VAT reverse")},null,8,["title"]),o("p",Dpe,f(i.translate("Select product categories that should NOT get VAT reverse charge !")),1),Wt((r(),E(w,{modelValue:s.settings.eu_vat_settings.vat_reverse_excluded_categories,"onUpdate:modelValue":t[9]||(t[9]=x=>s.settings.eu_vat_settings.vat_reverse_excluded_categories=x),filterable:"",multiple:"",clearable:"",placeholder:i.translate("Select Product Categories"),class:"w-full mt-4"},{default:u(()=>[(r(!0),m(P,null,ae(s.categories,x=>(r(),E(C,{key:x.value||x.term_id,label:x.label||x.name,value:x.value||x.term_id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])),[[$,s.fetchingCategories]])])]),_:1},8,["visible"])])])])]))]),_:1},8,["visible"])]),_:1})]),_:1})])])}const Tpe=nt(LAe,[["render",Qpe]]),Mpe={class:"fct-tax-rates-wrap-loader px-5"},Lpe={__name:"TaxRatesLoader",setup(e){const t=T(Array.from({length:6},()=>`${Math.floor(Math.random()*21)+120}px`));return(a,l)=>{const s=k("el-skeleton-item"),i=k("el-skeleton");return r(),m("div",Mpe,[(r(!0),m(P,null,ae(t.value,(A,p)=>(r(),m("div",{key:p,class:"flex items-center justify-between border-[1px] border-solid border-gray-divider dark:border-dark-400 rounded h-12 pr-4 pl-6 mb-4"},[n(i,{animated:"",style:fa({width:A}),class:"h-4"},{template:u(()=>[n(s,{variant:"p",class:"h-4"})]),_:2},1032,["style"]),n(i,{animated:"",class:"w-[100px] h-4"},{template:u(()=>[n(s,{variant:"p",class:"h-4"})]),_:1})]))),128))])}}},Rpe={class:"setting-wrap"},Ope={class:"setting-wrap-inner"},Ppe={class:"fct-all-tax-classes-page"},Hpe={class:"flex items-center justify-end gap-4"},Npe={key:0,class:"px-6 py-4 border-b border-gray-200 dark:border-gray-700"},Kpe={class:"inline-flex items-center gap-2"},Gpe={class:"inline-flex items-center gap-2"},zpe=["src","alt"],jpe={key:0,class:"text-gray-400 dark:text-gray-300"},qpe={key:1,class:"text-success-500"},Ype={key:2,class:"text-system-mid dark:text-gray-300"},Wpe={key:3,class:"text-gray-400 dark:text-gray-300"},Xpe={key:1,class:"text-gray-400"},Jpe={__name:"TaxRates",setup(e){const t=T({}),a=T([]),l=T({}),s=T({}),i=K(()=>!!je.get("is_tax_enabled")),A=T(!1),p=T({}),h={};let _=0;const y=T(""),g=T(!1),v={XI:"gb"},C=U=>(v[U]||U).toLowerCase(),w=K(()=>{const U=new Set;for(const L of a.value)for(const O of L.countries||[])U.add(O.country_code);return U}),b=U=>!U||!Object.prototype.hasOwnProperty.call(s.value,U)?!0:s.value[U],S=U=>!U||!U.vat?!1:U.rates&&typeof U.rates=="object"&&Object.keys(U.rates).length?Object.values(U.rates).some(L=>L&&parseFloat(L.rate)>0):parseFloat(U.rate)>0,F=K(()=>{const U=l.value||{},L=Array.isArray(U.country_registrations)?U.country_registrations:[],O=U.method||"",M=L.some(S);if(O==="oss")return!!U.oss_country;if(O==="home"){const H=U.home_country||"",j=L.find(W=>W.country===H);if(H&&j&&S(j))return!0}return O==="specific"?!!U.home_country:M}),Q=K(()=>{const U=l.value||{},L=Array.isArray(U.country_registrations)?U.country_registrations:[],O=U.method||"";return O==="oss"?!!U.oss_country:O==="home"?!!U.home_country&&L.some(M=>M.country===U.home_country):O==="specific"?!!U.home_country:L.some(S)}),$=K(()=>{const U=[],L=Object.values(t.value||{});for(const H of L)if(H.group_code==="EU")U.push({country_code:"EU",country_name:"European Union",isEU:!0,group_code:"EU",hasConfig:Q.value,enabled:b("EU"),collecting:Q.value&&F.value&&b("EU")});else for(const j of H.countries||[]){const W=w.value.has(j.country_code),G=b(j.country_code);U.push({country_code:j.country_code,country_name:j.country_name,isEU:!1,group_code:H.group_code,hasConfig:W,enabled:G,collecting:W&&G})}const O=["EU","US","GB","AU","CA","NZ","IN","SG","JP"],M=new Set(O);return U.sort((H,j)=>{if(H.hasConfig!==j.hasConfig)return H.hasConfig?-1:1;const W=M.has(H.country_code),G=M.has(j.country_code);return W&&G?O.indexOf(H.country_code)-O.indexOf(j.country_code):W?-1:G?1:H.country_name.localeCompare(j.country_name)}),U}),x=K(()=>{const U=y.value.trim().toLowerCase();return $.value.filter(L=>g.value&&(!i.value||!L.collecting)?!1:U?L.country_name.toLowerCase().includes(U)||L.country_code.toLowerCase().includes(U):!0)}),I=K(()=>{if(!i.value)return!1;const U=$.value.filter(O=>O.enabled).length,L=$.value.filter(O=>!O.enabled).length;return U>0&&L>0}),V=()=>{A.value=!0,Promise.all([Ae.get("tax/configuration/rates"),Ae.get("tax/rates"),Ae.get("tax/configuration/settings")]).then(([U,L,O])=>{var M;t.value=U.tax_rates,a.value=L.tax_rates,s.value=L.country_enabled_map||{},l.value=((M=O.settings)==null?void 0:M.eu_vat_settings)||{}}).catch(U=>{}).finally(()=>{A.value=!1})},D=(U,L)=>{const O=b(U.country_code),M=++_;h[U.country_code]=M,s.value={...s.value,[U.country_code]:L},p.value={...p.value,[U.country_code]:!0},Ae.post("tax/country-status/"+U.country_code,{enabled:L?1:0}).then(H=>{h[U.country_code]===M&&(q.success(H.message),s.value={...s.value,[U.country_code]:H.enabled})}).catch(H=>{var j;h[U.country_code]===M&&(s.value={...s.value,[U.country_code]:O},q.error(((j=H==null?void 0:H.data)==null?void 0:j.message)||d("Failed to update tax status")))}).finally(()=>{if(h[U.country_code]===M){const H={...p.value};delete H[U.country_code],p.value=H}})};return De(()=>{V()}),(U,L)=>{const O=k("el-checkbox"),M=k("el-input"),H=k("el-table-column"),j=k("el-switch"),W=k("el-table");return r(),m("div",Rpe,[n($a,{heading:c(d)("Tax Regions"),"show-save-button":!1},null,8,["heading"]),o("div",Ope,[n(Fa),o("div",Ppe,[n($e,{class:"overflow-hidden"},{default:u(()=>[n(Qe,{title:c(d)("Tax Regions"),text:c(d)("Manage tax rates for different regions")},{action:u(()=>[o("div",Hpe,[I.value?(r(),E(O,{key:0,modelValue:g.value,"onUpdate:modelValue":L[0]||(L[0]=G=>g.value=G)},{default:u(()=>[R(f(c(d)("Collecting Tax")),1)]),_:1},8,["modelValue"])):B("",!0),n(M,{modelValue:y.value,"onUpdate:modelValue":L[1]||(L[1]=G=>y.value=G),class:"w-[200px]",placeholder:c(d)("Search regions..."),size:"small",clearable:""},{prefix:u(()=>[n(X,{name:"Search",class:"w-4 h-4"})]),_:1},8,["modelValue","placeholder"])])]),_:1},8,["title","text"]),n(xe,{class:"px-0 pb-0"},{default:u(()=>[!A.value&&!i.value?(r(),m("div",Npe,[n(sl,{type:"warning",icon:"AlertTriangle",content:c(d)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):B("",!0),A.value?(r(),E(Lpe,{key:1})):(r(),E(W,{key:2,data:x.value,"max-height":"500",class:"w-full compact-table fct-tax-rates-regions-table"},{default:u(()=>[n(H,{label:c(d)("Region"),"min-width":"300"},{default:u(({row:G})=>[G.isEU?(r(),E(ra,{key:0,class:"hover:no-underline",to:{name:"eu"}},{default:u(()=>[o("div",Kpe,[L[2]||(L[2]=o("img",{class:"w-[22px] block",src:"https://flagcdn.com/w40/eu.png",alt:"EU"},null,-1)),R(" "+f(G.country_name),1)])]),_:2},1024)):(r(),E(ra,{key:1,to:{name:"tax-rates-country-single",params:{country:G.country_code,group:G.group_code}},class:"fct-tax-region-link hover:no-underline"},{default:u(()=>[o("div",Gpe,[o("img",{class:"w-[22px] block",src:`https://flagcdn.com/w40/${C(G.country_code)}.png`,alt:G.country_code},null,8,zpe),R(" "+f(G.country_name),1)])]),_:2},1032,["to"]))]),_:1},8,["label"]),n(H,{label:c(d)("Collecting"),width:"200"},{default:u(({row:G})=>[i.value?G.collecting?(r(),m("span",qpe,f(c(d)("Collecting tax")),1)):G.hasConfig&&!G.enabled?(r(),m("span",Ype,f(c(d)("Disabled")),1)):(r(),m("span",Wpe,"—")):(r(),m("span",jpe,"—"))]),_:1},8,["label"]),n(H,{label:c(d)("Enabled"),width:"140",align:"center"},{default:u(({row:G})=>[G.hasConfig?(r(),E(j,{key:0,"model-value":i.value?G.enabled:!1,loading:!!p.value[G.country_code],disabled:!i.value,onChange:Y=>D(G,Y)},null,8,["model-value","loading","disabled","onChange"])):(r(),m("span",Xpe,"—"))]),_:1},8,["label"])]),_:1},8,["data"]))]),_:1})]),_:1})])])])}}},Zpe={class:"fct-base-taxes"},efe={class:"fct-tax-class-tabs"},tfe={class:"fct-tax-class-tabs__list"},afe={class:"fct-base-taxes__header"},lfe={class:"fct-base-taxes__header-label"},sfe={class:"fct-base-taxes__state-row fct-base-taxes__state-row--federal"},nfe={class:"fct-base-taxes__region-name fct-base-taxes__region-name--federal"},ofe={class:"fct-base-taxes__state-fields"},ife={class:"fct-base-taxes__region-name"},rfe={class:"fct-base-taxes__state-fields"},dfe={__name:"CountryTaxRatesLoader",setup(e){const t=[1,2,3];return(a,l)=>{const s=k("el-skeleton-item"),i=k("el-skeleton");return r(),m("div",null,[o("div",Zpe,[o("div",efe,[o("div",tfe,[(r(),m(P,null,ae(3,A=>o("div",{key:A,class:"fct-tax-class-tabs__tab"},[n(i,{animated:""},{template:u(()=>[n(s,{variant:"text",class:"w-16 h-5"})]),_:1})])),64)),n(i,{animated:""},{template:u(()=>[n(s,{variant:"text",class:"w-5 h-5"})]),_:1})])]),o("div",afe,[o("span",lfe,f(c(d)("Regions")),1)]),o("div",sfe,[o("div",nfe,[n(i,{animated:""},{template:u(()=>[n(s,{variant:"text",class:"w-40 h-5"})]),_:1})]),o("div",ofe,[n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),l[0]||(l[0]=o("div",{class:"fct-base-taxes__field-compound"},null,-1))])]),l[1]||(l[1]=o("div",{class:"fct-base-taxes__divider"},null,-1)),(r(),m(P,null,ae(t,A=>o("div",{key:A,class:"fct-base-taxes__state-row"},[o("div",ife,[n(i,{animated:""},{template:u(()=>[n(s,{variant:"text",class:"w-32 h-4"})]),_:1})]),o("div",rfe,[n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-compound h-8"})]),_:1})])])),64))])])}}},ufe={class:"fct-tax-class-tabs"},cfe={class:"fct-tax-class-tabs__list"},Afe=["onClick"],pfe=["title","onClick"],ffe=["disabled","title"],mfe=["disabled","title"],hfe=["disabled"],_fe=["disabled","title"],vfe={class:"fct-tax-class-tabs__search"},xf={__name:"TaxClassTabs",props:{classes:{type:Array,default:()=>[]},activeId:{type:[Number,String],default:null},maxClasses:{type:Number,default:6},creating:{type:Boolean,default:!1},search:{type:String,default:""}},emits:["switch","delete","add","create-custom","update:search"],setup(e,{emit:t}){const a=e,l=t,s=T(!1),i=T(""),A=T(null),p=T(!1),h=K(()=>[...a.classes].sort((b,S)=>b.slug==="standard"&&S.slug!=="standard"?-1:b.slug!=="standard"&&S.slug==="standard"?1:0)),_=K(()=>["reduced","zero"].filter(b=>!a.classes.find(S=>S.slug===b))),y=()=>{i.value="",p.value=!1,s.value=!0,Fe(()=>{var b;return(b=A.value)==null?void 0:b.focus()})},g=b=>{if(b==="custom"){y();return}l("add",b)},v=()=>{const b=i.value.trim();if(!b){C();return}l("create-custom",b)},C=()=>{s.value=!1,i.value="",p.value=!1},w=()=>{!a.creating&&!i.value.trim()&&C()};return ke([()=>a.classes.length,()=>a.creating],([b,S],[F,Q])=>{if(s.value){if(b>F){C();return}Q&&!S&&(p.value=!0)}}),ke(i,()=>{p.value=!1}),(b,S)=>{const F=k("el-input"),Q=k("el-dropdown-item"),$=k("el-dropdown-menu"),x=k("el-dropdown");return r(),m("div",ufe,[o("div",cfe,[(r(!0),m(P,null,ae(h.value,I=>(r(),m("button",{key:I.id,class:ue(["fct-tax-class-tabs__tab",{"fct-tax-class-tabs__tab--active":e.activeId==I.id}]),onClick:V=>l("switch",I)},[R(f(I.title)+" ",1),I.slug!=="standard"?(r(),m("span",{key:0,class:"fct-tax-class-tabs__delete",title:c(d)("Delete tax class"),onClick:Ge(V=>l("delete",I),["stop"])},[n(X,{name:"Close"})],8,pfe)):B("",!0)],10,Afe))),128)),e.classes.length
i.value=I),size:"small",maxlength:"30",disabled:e.creating,placeholder:c(d)("e.g. Luxury"),onKeyup:[da(v,["enter"]),da(C,["esc"])],onBlur:w},null,8,["modelValue","disabled","placeholder"]),o("button",{class:"fct-tax-class-tabs__inline-confirm",disabled:e.creating||!i.value.trim(),title:c(d)("Create tax class"),onMousedown:S[1]||(S[1]=Ge(()=>{},["prevent"])),onClick:v},[n(X,{name:"Check"})],40,ffe),o("button",{class:"fct-tax-class-tabs__inline-cancel",disabled:e.creating,title:c(d)("Cancel"),onMousedown:S[2]||(S[2]=Ge(()=>{},["prevent"])),onClick:C},[n(X,{name:"Close"})],40,mfe)],2)):_.value.length?(r(),E(x,{key:1,trigger:"click",disabled:e.creating,onCommand:g,"popper-class":"fct-dropdown"},{dropdown:u(()=>[n($,null,{default:u(()=>[_.value.includes("reduced")?(r(),E(Q,{key:0,command:"reduced"},{default:u(()=>[R(f(c(d)("Reduced")),1)]),_:1})):B("",!0),_.value.includes("zero")?(r(),E(Q,{key:1,command:"zero"},{default:u(()=>[R(f(c(d)("Zero")),1)]),_:1})):B("",!0),n(Q,{command:"custom"},{default:u(()=>[R(f(c(d)("Custom Class...")),1)]),_:1})]),_:1})]),default:u(()=>[o("button",{class:"fct-tax-class-tabs__add",disabled:e.creating},[n(X,{name:"Plus"})],8,hfe)]),_:1},8,["disabled"])):(r(),m("button",{key:2,class:"fct-tax-class-tabs__add",disabled:e.creating,title:c(d)("Add custom tax class"),onClick:y},[n(X,{name:"Plus"})],8,_fe))],64)):B("",!0)]),o("div",vfe,[n(F,{"model-value":e.search,placeholder:c(d)("Search country or region…"),size:"small",clearable:"","onUpdate:modelValue":S[3]||(S[3]=I=>l("update:search",I)),onClear:S[4]||(S[4]=I=>l("update:search",""))},{prefix:u(()=>[n(X,{name:"Search",class:"w-3.5 h-3.5 text-system-light dark:text-gray-400"})]),_:1},8,["model-value","placeholder"]),wa(b.$slots,"search-actions")])])}}},gfe=(e=[])=>e.find(t=>t.slug==="standard")||e[0]||null,Rd=({classes:e=[],activeId:t=null})=>(t?e.find(l=>l.id===t):null)||gfe(e),yfe=({classes:e=[],previousIds:t=new Set,createdSlug:a=null})=>{if(a){const l=e.find(s=>s.slug===a);if(l)return l}return e.find(l=>!t.has(l.id))||null},Zo=async({payload:e,createdSlug:t=null,currentClasses:a=[],reloadClasses:l})=>{const s=new Set((a||[]).map(p=>p.id)),i=await Ae.post("tax/classes",e),A=await l();return{response:i,classes:A,createdClass:yfe({classes:A,previousIds:s,createdSlug:t})}},Sf=async({classId:e,currentActiveId:t=null,reloadClasses:a})=>{const l=await Ae.delete("tax/classes/"+e),s=await a();return{response:l,classes:s,nextActiveClass:Rd({classes:s,activeId:t})}};function on(e){return e==null||e===""?"":String(e)}const bfe={class:"setting-wrap"},wfe={class:"setting-wrap-inner"},Cfe={class:"fct-single-tax-rates-country-single-page"},kfe={class:"fct-single-tax-rates-country-single"},Bfe={class:"single-page-header flex items-center justify-between"},xfe={key:0,class:"flex items-center gap-2"},Sfe={key:0,class:"notices fct-notices-wrap fct-layout-width settings"},$fe={class:"mt-3 flex justify-end"},Ffe={key:1,class:"fct-base-taxes"},Efe={class:"fct-btn-group mt-4 justify-end sm"},Ufe={class:"fct-tax-rates-country-view"},Ife={key:0},Vfe={key:1},Dfe={key:0},Qfe={key:1},Tfe={class:"fct-btn-group sm justify-end"},Ec={__name:"TaxRatesCountrySingle",props:{country:{type:String},group:{type:String}},setup(e){const t=e,a=T(!1),l=T([]),s=T(""),i=K(()=>!!je.get("is_tax_enabled")),A=T([]),p=T(null),h=T("standard"),_=T(!1),y=T(null),g=T(6),v=T({id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0}),C=T({rate:0,name:""}),w=T([]),b=T({}),S=T(""),F=K(()=>{const te=S.value.trim().toLowerCase();return te?w.value.filter(Se=>Se.stateName&&Se.stateName.toLowerCase().includes(te)):w.value}),Q=K(()=>t.group==="EU"),$=K(()=>[v.value,...F.value]),x=T([]),I=T(!1),V=T([]),D=T([]),U=T(!1),L=T(new Set),O=T(0),M=T([]),H=T(!1),j=T(!1),W=T(!1),G=T({type:"products",original_type:"",original_id:"",category_id:"",category_name:"",state:"__country__",city:"",postcode:"",tax_label:"",tax_rate:0,override_state_tax:!0,class_id:0,id:"",previous_id:""}),Y=K(()=>{const te=v.value.rate||0;return[{label:d("added to")+` ${te}% `+d("federal tax"),is_compound:"0",for_order:0},{label:d("instead of")+` ${te}% `+d("federal tax"),is_compound:"0",for_order:1},{label:d("compounded on top of")+` ${te}% `+d("federal tax"),is_compound:"1",for_order:0}]}),J=te=>String(te.is_compound)==="1"?"1_0":te.for_order==1?"0_1":"0_0",de=(te,Se)=>{const[ne,_e]=Se.split("_");te.is_compound=ne,te.for_order=parseInt(_e)},z=te=>te&&te.replace(/\s*\(Standard\)\s*/gi,"").trim(),ce=T(!1),oe=T({}),Z=T(!1),N=T(""),le=T(""),ee=T(""),pe=T(!1),re=T(!1),Ue=T(!0),we=T(!1),Be=T(!1),ge=T(!1),Ce=K(()=>d("Toggle tax collection for %1$s",s.value||t.country)),Oe=()=>Ae.get("tax/classes").then(te=>{A.value=te.classes||[],g.value=te.max_classes||6,y.value=te.next_builtin||null;const Se=Rd({classes:A.value,activeId:p.value});return Se&&(p.value=Se.id,h.value=Se.slug),A.value}).catch(te=>A.value),Ee=(te="")=>{if(!te)return v.value.name||"Tax";const Se=w.value.find(ne=>ne.state===te);return Se!=null&&Se.name?Se.name:v.value.name||"Tax"},fe=te=>{v.value={...te.federalRate},C.value={...te.federalOriginal},w.value=te.stateRows.map(Se=>({...Se})),b.value={...te.stateOriginals}},ye=()=>({federalRate:{...v.value},federalOriginal:{...C.value},stateRows:w.value.map(te=>({...te})),stateOriginals:{...b.value}}),Ve=()=>{p.value&&(oe.value[p.value]=ye())},Le=async te=>{Ve(),p.value=te.id,h.value=te.slug,oe.value[te.id]?(fe(oe.value[te.id]),await yt()):await Xt()},At=te=>{_.value=!0,Zo({payload:{slug:te},createdSlug:te,currentClasses:A.value,reloadClasses:Oe}).then(({response:Se,createdClass:ne})=>{if(q.success(Se.message),ne)return Le(ne)}).catch(Se=>{var ne;q.error(((ne=Se==null?void 0:Se.data)==null?void 0:ne.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},mt=te=>{_.value=!0,Zo({payload:{title:te},currentClasses:A.value,reloadClasses:Oe}).then(({response:Se,createdClass:ne})=>{if(q.success(Se.message),ne)return Le(ne)}).catch(Se=>{var ne;q.error(((ne=Se==null?void 0:Se.data)==null?void 0:ne.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},Mt=te=>{const Se=p.value===te.id;Pa(d("All rates for this class will be deleted. Products using it will default to Standard."),d("Delete")+" "+te.title+"?",{confirmButtonText:d("Yes, Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Sf({classId:te.id,currentActiveId:p.value,reloadClasses:Oe}).then(({response:ne,nextActiveClass:_e})=>{if(delete oe.value[te.id],q.success(ne.message),_e)return Se&&(p.value=null),Le(_e)}).catch(ne=>{var _e;q.error(((_e=ne==null?void 0:ne.data)==null?void 0:_e.message)||"Failed to delete tax class")})}).catch(()=>{})},Dt=()=>Ae.get("address-info/get-country-info",{country_code:t.country}).then(te=>{l.value=te.states||[],s.value=te.country_name||t.country}).catch(te=>{q.error(d("Failed to load country data. Please refresh the page."))}),Xe=()=>Q.value?(le.value="",ee.value="",Promise.resolve()):(pe.value=!0,Ae.get("tax/country-tax-id/"+t.country).then(te=>{var ne;const Se=((ne=te==null?void 0:te.tax_data)==null?void 0:ne.tax_id)||"";le.value=Se,ee.value=Se}).catch(te=>{var Se;q.error(((Se=te==null?void 0:te.data)==null?void 0:Se.message)||d("Failed to load tax ID"))}).finally(()=>{pe.value=!1})),pt=({hydrateClassData:te=!0}={})=>Ae.get("tax/rates/country/rates/"+t.country).then(Se=>{const ne=Se.tax_rates||[],_e=ne.filter(qe=>qe.for_shipping!==null),We=p.value?ne.filter(qe=>Number(qe.class_id)===Number(p.value)):ne;V.value=We.filter(qe=>!qe.city&&!qe.postcode).map(qe=>({name:qe.name,value:qe.id,state:qe.state||""}));const ot=Qt(We);return ge.value=ne.length>0,te&&(fe(ot),Ve(),Ue.value=!!Se.tax_enabled,Be.value=!0),{allRates:ne,shippingOverrides:_e,classEntry:ot}}).catch(Se=>(q.error(d("Failed to load tax rates. Please refresh the page.")),{allRates:[],shippingOverrides:[],classEntry:null})),jt=()=>Ae.get("tax/product-overrides/"+t.country).then(te=>te.overrides||[]).catch(()=>[]),Ct=()=>{M.value.length>0||(H.value=!0,Ae.get("products/fetch-term").then(te=>{const Se=te.taxonomies&&te.taxonomies["product-categories"]?te.taxonomies["product-categories"].terms||[]:[];M.value=Se.map(ne=>({...ne,value:on(ne.value)}))}).catch(()=>{}).finally(()=>{H.value=!1}))};let $t=0;const Ht=te=>{const Se=++$t;return!te||Number(te)===Number(p.value)?(D.value=V.value.slice(),U.value=!1,Promise.resolve()):(U.value=!0,D.value=[],Ae.get("tax/rates/country/rates/"+t.country,{class_id:te}).then(ne=>{if(Se!==$t)return;const _e=ne.tax_rates||[];D.value=_e.filter(We=>!We.city&&!We.postcode).map(We=>({name:We.name,value:We.id,state:We.state||""}))}).catch(()=>{Se===$t&&(D.value=[],q.error(d("Failed to load tax rates for the selected tax class")))}).finally(()=>{Se===$t&&(U.value=!1)}))},Nt=(te,Se)=>{var _e,We;const ne=[];for(const ot of te){const qe=ot.state?((_e=l.value.find(tt=>tt.value===ot.state))==null?void 0:_e.name)||ot.state:s.value||t.country,Ze=Ee(ot.state||""),gt=A.value.find(tt=>Number(tt.id)===Number(ot.class_id));ne.push({id:ot.id,type:"shipping",label:Ze,tax_label:Ze,category_name:"",location:qe,city:ot.city||"",postcode:ot.postcode||"",rate:ot.for_shipping,class_id:Number(ot.class_id)||0,class_label:gt?gt.title:"",_raw:ot})}for(const ot of Se){const qe=ot.meta_value||ot,Ze=qe.state||"",gt=Ze?((We=l.value.find(me=>me.value===Ze))==null?void 0:We.name)||Ze:s.value||t.country,tt=Number(ot.class_id)||0,Vt=tt?A.value.find(me=>Number(me.id)===tt):null;ne.push({id:ot.id,type:"products",label:qe.category_name||"",tax_label:qe.tax_label||"",category_name:qe.category_name||"",location:gt,city:qe.city||"",postcode:qe.postcode||"",rate:qe.rate,class_id:tt,class_label:Vt?Vt.title:"",_raw:ot})}x.value=ne},Qt=te=>{const Se=tt=>(!tt.state||tt.state==="")&&(!tt.city||tt.city==="")&&(!tt.postcode||tt.postcode===""),ne=te.find(Se),_e=te.filter(tt=>tt.state&&tt.state!==""&&(!tt.city||tt.city==="")&&(!tt.postcode||tt.postcode===""));let We,ot;if(ne){const tt=z(ne.name)||"Tax";We={...ne,name:tt},ot={rate:ne.rate,name:tt}}else We={id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0},ot={rate:0,name:"Tax"};const qe={};for(const tt of _e)qe[tt.state]=tt;const Ze=[],gt={};for(const tt of l.value){const Vt=qe[tt.value];if(Vt){const me=z(Vt.name)||"State Tax";Ze.push({id:Vt.id,state:tt.value,stateName:tt.name,rate:Vt.rate,name:me,is_compound:String(Vt.is_compound||"0"),for_order:Vt.for_order||0}),gt[tt.value]={rate:Vt.rate,name:me,is_compound:String(Vt.is_compound||"0"),for_order:Vt.for_order||0}}else Ze.push({id:null,state:tt.value,stateName:tt.name,rate:0,name:"State Tax",is_compound:"0",for_order:0}),gt[tt.value]={rate:0,name:"State Tax",is_compound:"0",for_order:0}}return{federalRate:We,federalOriginal:ot,stateRows:Ze,stateOriginals:gt}},yt=async()=>{const[{shippingOverrides:te},Se]=await Promise.all([pt({hydrateClassData:!1}),jt()]);Nt(te,Se)},Xt=async()=>{a.value=!0;try{const[{shippingOverrides:te},Se]=await Promise.all([pt(),jt()]);Nt(te,Se)}finally{a.value=!1}},be=async()=>{a.value=!0;try{await Promise.all([Oe(),Dt(),Xe()]),await Xt()}finally{a.value=!1}},Ie=()=>{Q.value||re.value||pe.value||(re.value=!0,Ae.post("tax/country-tax-id/"+t.country,{tax_id:le.value||""}).then(te=>{ee.value=le.value||"",q.success(te.message||d("Tax ID has been saved successfully"))}).catch(te=>{var Se;q.error(((Se=te==null?void 0:te.data)==null?void 0:Se.message)||d("Failed to save tax ID"))}).finally(()=>{re.value=!1}))},it=te=>{if(we.value)return;const Se=Ue.value;Ue.value=te,we.value=!0,Ae.post("tax/country-status/"+t.country,{enabled:te?1:0}).then(ne=>{Ue.value=ne.enabled,q.success(ne.message)}).catch(ne=>{var _e;Ue.value=Se,q.error(((_e=ne==null?void 0:ne.data)==null?void 0:_e.message)||d("Failed to update tax status"))}).finally(()=>{we.value=!1})},kt=async()=>{try{await Pa(d("This will overwrite your current rates with preset defaults. Continue?"),d("Reset to default tax rates"),{confirmButtonText:d("Reset"),cancelButtonText:d("Cancel"),type:"warning"})}catch{return}Z.value=!0;try{const Se=(await Ae.get("tax/configuration/rates")).tax_rates||{};let ne=[];for(const Ze in Se){const gt=Se[Ze];for(const tt of gt.countries||[])if(tt.country_code===t.country){ne=tt.rates||[];break}if(ne.length)break}if(!ne.length){q.error(d("No preset rates found for this country"));return}const _e=ne.find(Ze=>(!Ze.state||Ze.state==="")&&Ze.type==="standard"),We=ne.filter(Ze=>Ze.state&&Ze.state!==""&&Ze.type==="standard"),ot=[];_e&&_e.rate>0&&(v.value.rate=_e.rate,v.value.name=z(_e.name||"")||d("Tax"),ot.push(Bt()));const qe=[];for(const Ze of We){const gt=w.value.find(tt=>tt.state===Ze.state);gt&&(gt.rate=Ze.rate,gt.name=z(Ze.name)||d("State Tax"),gt.is_compound=Ze.compound?"1":"0",qe.push(ta(gt)))}await Promise.all([...ot,...qe]),Ve(),await yt(),q.success(d("Tax rates have been reset to defaults"))}catch{q.error(d("Failed to reset tax rates"))}finally{Z.value=!1}},Bt=()=>{const te={country:t.country,state:"",rate:v.value.rate,name:v.value.name||"Tax",is_compound:v.value.is_compound||"0",for_order:v.value.for_order||0,group:t.group,class_id:p.value||""};return(v.value.id?Ae.put("tax/country/rate/"+v.value.id,te):Ae.post("tax/country/rate",te)).then(ne=>{ne.tax_rate&&(v.value.id=ne.tax_rate.id),C.value={rate:v.value.rate,name:v.value.name}})},ta=te=>{const Se={country:t.country,state:te.state,rate:te.rate,name:te.name,is_compound:te.is_compound,for_order:te.for_order,group:t.group,class_id:p.value||""};return(te.id?Ae.put("tax/country/rate/"+te.id,Se):Ae.post("tax/country/rate",Se)).then(_e=>{_e.tax_rate&&(te.id=_e.tax_rate.id),b.value[te.state]={rate:te.rate,name:te.name,is_compound:String(te.is_compound),for_order:te.for_order}})},bt=async()=>{ce.value=!0;try{const te=[];(String(v.value.rate)!==String(C.value.rate)||v.value.name!==C.value.name)&&te.push(Bt());for(const ne of w.value){const _e=b.value[ne.state];(!_e||String(ne.rate)!==String(_e.rate)||ne.name!==_e.name||String(ne.is_compound)!==String(_e.is_compound)||ne.for_order!=_e.for_order)&&te.push(ta(ne))}await Promise.all(te),Ve(),await yt(),q.success(d("Tax rates saved"))}catch{q.error(d("Failed to save rates"))}finally{ce.value=!1}},sa=()=>{L.value=new Set,O.value=0},na=()=>{const te=Ee();W.value=!1,G.value={type:"products",original_type:"",original_id:"",category_id:"",category_name:"",state:"__country__",city:"",postcode:"",tax_label:te,tax_rate:0,override_state_tax:!0,class_id:Number(p.value)||0,id:"",previous_id:""},N.value=te,D.value=V.value.slice(),I.value=!0,Ct()},qt=te=>{if(W.value=!0,Ct(),te.type==="shipping"){const Se=te._raw.state||"",ne=Ee(Se),_e=Number(te._raw.class_id)||Number(p.value)||0;G.value={type:"shipping",original_type:"shipping",original_id:te.id,category_id:"",category_name:"",state:Se||"__country__",city:te._raw.city||"",postcode:te._raw.postcode||"",tax_label:ne,tax_rate:te.rate,override_state_tax:!0,class_id:_e,id:te.id,previous_id:te.id},N.value=ne,O.value=_e,Ht(_e);const We=te._raw.city||"",ot=te._raw.postcode||"",qe=new Set;for(const Ze of x.value)Ze.type==="shipping"&&(Ze._raw.state||"")===Se&&(Ze._raw.city||"")===We&&(Ze._raw.postcode||"")===ot&&qe.add(Number(Ze.class_id));L.value=qe}else{const Se=te._raw.meta_value||te._raw,ne=Se.state||"",_e=Ee(ne),We=te.tax_label||_e;G.value={type:"products",original_type:"products",original_id:te.id,category_id:on(Se.category_id),category_name:te.category_name,state:ne||"__country__",tax_label:We,tax_rate:te.rate,override_state_tax:Se.override_state_tax==="yes",city:Se.city||"",postcode:Se.postcode||"",class_id:te.class_id||0,id:te.id,previous_id:""},N.value=_e}I.value=!0},ka=K(()=>{const te=[{label:s.value||t.country,value:"__country__"}];for(const Se of l.value)te.push({label:Se.name,value:Se.value});return te}),Ja=K(()=>{if(!D.value.length)return ka.value;const te=new Set(D.value.map(Se=>Se.state||""));return ka.value.filter(Se=>{const ne=Se.value==="__country__"?"":Se.value;return te.has(ne)})}),ul=te=>{const Se=on(te),ne=M.value.find(_e=>_e.value===Se);ne&&(G.value.category_name=ne.label)},Za=te=>{Pa(d("Are you sure you want to delete this override?"),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{const Se=te.type==="shipping"?"tax/rates/country/override/"+te.id:"tax/product-overrides/"+te.id;Ae.delete(Se).then(ne=>{q.success(ne.message),x.value=x.value.filter(_e=>!(_e.id===te.id&&_e.type===te.type))}).catch(ne=>{var _e;q.error(((_e=ne==null?void 0:ne.data)==null?void 0:_e.message)||d("Failed to delete override"))})}).catch(()=>{})},va=async()=>{var Se;const te=G.value.state==="__country__"?"":G.value.state;if(G.value.type==="products"&&!G.value.category_id){q.error(d("Please select a category"));return}if(G.value.type==="shipping"){if(!G.value.class_id){q.error(d("Please select a tax class"));return}if(U.value){q.error(d("Please wait for the province rates to finish loading"));return}const ne=D.value.find(_e=>(_e.state||"")===te);G.value.id=ne?ne.value:0}j.value=!0;try{let ne;if(G.value.type==="products"){const _e=G.value.state==="__country__"?"":G.value.state;ne=await Ae.post("tax/product-overrides",{id:W.value&&G.value.original_type==="products"?G.value.original_id:"",source_type:G.value.original_type,source_id:G.value.original_id,country:t.country,state:_e,category_id:G.value.category_id,category_name:G.value.category_name,tax_label:G.value.tax_label,rate:G.value.tax_rate,override_state_tax:G.value.override_state_tax===!0?"yes":"no",city:G.value.city||"",postcode:G.value.postcode||"",class_id:G.value.class_id||0})}else ne=await Ae.post("tax/rates/country/override",{id:G.value.id,country:t.country,state:te,previous_id:W.value&&G.value.original_type==="shipping"?G.value.previous_id:"",source_type:G.value.original_type,source_id:G.value.original_id,class_id:G.value.class_id||p.value||"",override_tax_rate:G.value.tax_rate,city:G.value.city||"",postcode:G.value.postcode||""});q.success(ne.message),I.value=!1,await yt()}catch(ne){const _e=((Se=ne==null?void 0:ne.data)==null?void 0:Se.message)||(ne==null?void 0:ne.message)||"Failed to save override";q.error(_e)}finally{j.value=!1}};return ke(()=>G.value.type,te=>{te==="shipping"&&(G.value.class_id||(G.value.class_id=p.value||0),Ht(G.value.class_id))}),ke(()=>G.value.class_id,te=>{G.value.type!=="shipping"||!I.value||Ht(te).then(()=>{const Se=G.value.state==="__country__"?"":G.value.state,ne=D.value.map(_e=>_e.state||"");Se!==""&&!ne.includes(Se)&&(G.value.state="__country__")})}),ke(()=>G.value.state,te=>{if(!I.value||G.value.type!=="products"||W.value)return;const Se=Ee(te==="__country__"?"":te);(!G.value.tax_label||G.value.tax_label===N.value)&&(G.value.tax_label=Se),N.value=Se}),De(()=>{be()}),(te,Se)=>{const ne=k("el-breadcrumb-item"),_e=k("el-breadcrumb"),We=k("el-switch"),ot=k("el-skeleton"),qe=k("el-input"),Ze=k("el-form-item"),gt=k("el-form"),tt=k("el-button"),Vt=k("el-table-column"),me=k("el-option"),ve=k("el-select"),Ne=k("el-table"),Pe=k("el-tag"),ft=k("el-radio"),se=k("el-radio-group"),ze=k("el-checkbox"),_t=k("el-dialog");return r(),m("div",bfe,[o("div",wfe,[o("div",Cfe,[o("div",kfe,[o("div",Bfe,[n(_e,{class:"mb-0","separator-icon":c(dl)},{default:u(()=>[e.group==="EU"?(r(),E(ne,{key:0,to:{name:"eu"}},{default:u(()=>[R(f(c(d)("Tax Regions")),1)]),_:1})):(r(),E(ne,{key:1,to:{name:"tax_rates"}},{default:u(()=>[R(f(c(d)("Tax Regions")),1)]),_:1})),n(ne,null,{default:u(()=>[R(f(s.value||e.country),1)]),_:1})]),_:1},8,["separator-icon"]),Be.value&&ge.value?(r(),m("div",xfe,[i.value?(r(),m("span",{key:0,class:ue(["text-sm",Ue.value?"text-success-500":"text-system-mid dark:text-gray-300"])},f(Ue.value?c(d)("Collecting tax"):c(d)("Disabled")),3)):B("",!0),n(We,{"model-value":i.value?Ue.value:!1,loading:we.value,disabled:!i.value,"aria-label":Ce.value,onChange:it},null,8,["model-value","loading","disabled","aria-label"])])):B("",!0)]),!a.value&&!i.value?(r(),m("div",Sfe,[n(sl,{type:"warning",icon:"AlertTriangle",content:c(d)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):B("",!0),Q.value?B("",!0):(r(),E($e,{key:1},{default:u(()=>[n(xe,null,{default:u(()=>[pe.value?(r(),E(ot,{key:0,animated:"",rows:2})):(r(),E(gt,{key:1,"label-position":"top"},{default:u(()=>[n(Ze,{label:c(d)("VAT/GST/Tax Number"),class:"mb-0"},{default:u(()=>[n(qe,{modelValue:le.value,"onUpdate:modelValue":Se[0]||(Se[0]=Me=>le.value=Me),placeholder:c(d)("VAT/GST/Tax Number"),maxlength:"255"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})),o("div",$fe,[n(tt,{type:"primary",size:"small",loading:re.value,disabled:pe.value||re.value||le.value===ee.value,onClick:Ie},{default:u(()=>[R(f(c(d)("Save")),1)]),_:1},8,["loading","disabled"])])]),_:1})]),_:1})),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Base taxes")},null,8,["title"]),n(xe,null,{default:u(()=>[n(sl,{type:"info"},{content:u(()=>[o("span",null,f(c(d)("Rates are pre-filled for convenience and may not reflect current laws — verify with a tax advisor before going live. If you sell products taxed at different rates (e.g. food, books, digital goods), use the"))+" + "+f(c(d)("button to add tax classes.")),1)]),_:1}),a.value?(r(),E(dfe,{key:0})):(r(),m("div",Ffe,[n(xf,{classes:A.value,"active-id":p.value,"max-classes":g.value,creating:_.value,search:S.value,onSwitch:Le,onDelete:Mt,onAdd:At,onCreateCustom:mt,"onUpdate:search":Se[1]||(Se[1]=Me=>S.value=Me)},null,8,["classes","active-id","max-classes","creating","search"]),n(Ne,{data:$.value,class:"w-full fct-tax-rates-table","max-height":"450"},{default:u(()=>[n(Vt,{label:c(d)("Region")},{default:u(({row:Me})=>[o("span",{class:ue(["fct-base-taxes__region-name",Me.state?"":"fct-base-taxes__region-name--federal"])},f(Me.state?Me.stateName:s.value||e.country),3)]),_:1},8,["label"]),n(Vt,{label:c(d)("Rate"),width:"130"},{default:u(({row:Me})=>[n(qe,{modelValue:Me.rate,"onUpdate:modelValue":St=>Me.rate=St,size:"small",type:"number",step:"0.01",min:"0"},{suffix:u(()=>Se[18]||(Se[18]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),n(Vt,{label:c(d)("Tax Label"),width:"200"},{default:u(({row:Me})=>[n(qe,{modelValue:Me.name,"onUpdate:modelValue":St=>Me.name=St,size:"small",placeholder:c(d)("Tax name")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),_:1},8,["label"]),w.value.length>0?(r(),E(Vt,{key:0,label:c(d)("Compound"),width:"310"},{default:u(({row:Me})=>[Me.state?(r(),E(ve,{key:0,"model-value":J(Me),size:"small",style:{width:"100%"},onChange:St=>de(Me,St)},{default:u(()=>[n(me,{value:"0_0",label:Y.value[0].label},null,8,["label"]),n(me,{value:"0_1",label:Y.value[1].label},null,8,["label"]),n(me,{value:"1_0",label:Y.value[2].label},null,8,["label"])]),_:2},1032,["model-value","onChange"])):B("",!0)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"]),o("div",Efe,[h.value==="standard"?(r(),E(tt,{key:0,loading:Z.value,size:"small",onClick:kt,type:"danger",soft:""},{default:u(()=>[R(f(c(d)("Reset to default")),1)]),_:1},8,["loading"])):B("",!0),n(tt,{type:"primary",size:"small",loading:ce.value,onClick:bt},{default:u(()=>[R(f(c(d)("Save Rates")),1)]),_:1},8,["loading"])])]))]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Tax overrides"),text:c(d)("Override tax rates for specific product categories or shipping.")},{action:u(()=>[n(tt,{size:"small",onClick:na},{default:u(()=>[R(f(c(d)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(xe,null,{default:u(()=>[o("div",Ufe,[n(Ne,{data:x.value,"empty-text":c(d)("No overrides configured")},{default:u(()=>[n(Vt,{label:c(d)("Type"),width:"110"},{default:u(({row:Me})=>[n(Pe,{type:Me.type==="products"?"primary":"info",size:"small"},{default:u(()=>[R(f(Me.type==="products"?c(d)("Product"):c(d)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n(Vt,{label:c(d)("Category")},{default:u(({row:Me})=>[R(f(Me.category_name||"—"),1)]),_:1},8,["label"]),n(Vt,{label:c(d)("Tax Label")},{default:u(({row:Me})=>[R(f(Me.tax_label||"—"),1)]),_:1},8,["label"]),n(Vt,{label:c(d)("Location")},{default:u(({row:Me})=>[R(f(Me.location),1)]),_:1},8,["label"]),n(Vt,{label:c(d)("Tax Class"),width:"130"},{default:u(({row:Me})=>[Me.type==="products"?(r(),m("span",Ife,f(Me.class_label||c(d)("All")),1)):(r(),m("span",Vfe,f(Me.class_label||"—"),1))]),_:1},8,["label"]),n(Vt,{label:c(d)("City / Postcode")},{default:u(({row:Me})=>[Me.city||Me.postcode?(r(),m("span",Dfe,f([Me.city,Me.postcode].filter(Boolean).join(" / ")),1)):(r(),m("span",Qfe,"—"))]),_:1},8,["label"]),n(Vt,{label:c(d)("Rate"),width:"100"},{default:u(({row:Me})=>[R(f(Me.rate)+"% ",1)]),_:1},8,["label"]),n(Vt,{label:c(d)("Actions"),width:"110",align:"right"},{default:u(({row:Me})=>[o("div",Tfe,[n(lt,{tag:"button",size:"small",onClick:St=>qt(Me)},{default:u(()=>[n(X,{name:"Edit"})]),_:2},1032,["onClick"]),n(lt,{tag:"button",size:"small",onClick:St=>Za(Me),bg:"danger",outline:""},{default:u(()=>[n(X,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"])])]),_:1})]),_:1}),n(_t,{modelValue:I.value,"onUpdate:modelValue":Se[17]||(Se[17]=Me=>I.value=Me),title:(W.value?c(d)("Edit tax override for"):c(d)("Add tax override for"))+" "+(s.value||e.country),width:"520px","append-to-body":!0,onClose:sa},{footer:u(()=>[n(tt,{onClick:Se[16]||(Se[16]=Me=>I.value=!1)},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(tt,{type:"primary",loading:j.value,onClick:va},{default:u(()=>[R(f(W.value?c(d)("Save changes"):c(d)("Add override")),1)]),_:1},8,["loading"])]),default:u(()=>[n(gt,{"label-position":"top",model:G.value},{default:u(()=>[n(Ze,{label:c(d)("Override type")},{default:u(()=>[n(se,{modelValue:G.value.type,"onUpdate:modelValue":Se[2]||(Se[2]=Me=>G.value.type=Me)},{default:u(()=>[n(ft,{value:"products"},{default:u(()=>[R(f(c(d)("Products")),1)]),_:1}),n(ft,{value:"shipping"},{default:u(()=>[R(f(c(d)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),G.value.type==="products"?(r(),m(P,{key:0},[n(Ze,{label:c(d)("Category")},{default:u(()=>[n(ve,{modelValue:G.value.category_id,"onUpdate:modelValue":Se[3]||(Se[3]=Me=>G.value.category_id=Me),filterable:"",placeholder:c(d)("Select a category"),loading:H.value,style:{width:"100%"},onChange:ul},{default:u(()=>[(r(!0),m(P,null,ae(M.value,Me=>(r(),E(me,{key:Me.value,label:Me.label,value:Me.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Tax Class")},{default:u(()=>[n(ve,{modelValue:G.value.class_id,"onUpdate:modelValue":Se[4]||(Se[4]=Me=>G.value.class_id=Me),style:{width:"100%"}},{default:u(()=>[n(me,{value:0,label:c(d)("All Tax Classes")},null,8,["label"]),(r(!0),m(P,null,ae(A.value,Me=>(r(),E(me,{key:Me.id,value:Number(Me.id),label:Me.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Tax label")},{default:u(()=>[n(qe,{modelValue:G.value.tax_label,"onUpdate:modelValue":Se[5]||(Se[5]=Me=>G.value.tax_label=Me),placeholder:c(d)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Location")},{default:u(()=>[n(ve,{modelValue:G.value.state,"onUpdate:modelValue":Se[6]||(Se[6]=Me=>G.value.state=Me),placeholder:c(d)("Select location"),filterable:"",style:{width:"100%"}},{default:u(()=>[(r(!0),m(P,null,ae(ka.value,Me=>(r(),E(me,{key:Me.value,label:Me.label,value:Me.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("City (optional)")},{default:u(()=>[n(qe,{modelValue:G.value.city,"onUpdate:modelValue":Se[7]||(Se[7]=Me=>G.value.city=Me),placeholder:c(d)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Postcode (optional)")},{default:u(()=>[n(qe,{modelValue:G.value.postcode,"onUpdate:modelValue":Se[8]||(Se[8]=Me=>G.value.postcode=Me),placeholder:c(d)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Tax rate (%)")},{default:u(()=>[n(qe,{modelValue:G.value.tax_rate,"onUpdate:modelValue":Se[9]||(Se[9]=Me=>G.value.tax_rate=Me),type:"number",step:"0.01",min:"0",placeholder:c(d)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),w.value.length>0?(r(),E(Ze,{key:0},{default:u(()=>[n(ze,{modelValue:G.value.override_state_tax,"onUpdate:modelValue":Se[10]||(Se[10]=Me=>G.value.override_state_tax=Me)},{default:u(()=>[R(f(c(d)("Also override state/provincial taxes")),1)]),_:1},8,["modelValue"])]),_:1})):B("",!0)],64)):(r(),m(P,{key:1},[n(Ze,{label:c(d)("Tax Class")},{default:u(()=>[n(ve,{modelValue:G.value.class_id,"onUpdate:modelValue":Se[11]||(Se[11]=Me=>G.value.class_id=Me),style:{width:"100%"},loading:U.value},{default:u(()=>[(r(!0),m(P,null,ae(A.value,Me=>(r(),E(me,{key:Me.id,value:Number(Me.id),label:Me.title,disabled:W.value&&Number(Me.id)!==Number(O.value)&&L.value.has(Number(Me.id))},null,8,["value","label","disabled"]))),128))]),_:1},8,["modelValue","loading"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Location")},{default:u(()=>[n(ve,{modelValue:G.value.state,"onUpdate:modelValue":Se[12]||(Se[12]=Me=>G.value.state=Me),placeholder:c(d)("Select location"),filterable:"",style:{width:"100%"}},{default:u(()=>[(r(!0),m(P,null,ae(Ja.value,Me=>(r(),E(me,{key:Me.value,label:Me.label,value:Me.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("City (optional)")},{default:u(()=>[n(qe,{modelValue:G.value.city,"onUpdate:modelValue":Se[13]||(Se[13]=Me=>G.value.city=Me),placeholder:c(d)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Postcode (optional)")},{default:u(()=>[n(qe,{modelValue:G.value.postcode,"onUpdate:modelValue":Se[14]||(Se[14]=Me=>G.value.postcode=Me),placeholder:c(d)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Tax rate (%)")},{default:u(()=>[n(qe,{modelValue:G.value.tax_rate,"onUpdate:modelValue":Se[15]||(Se[15]=Me=>G.value.tax_rate=Me),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])])])])}}};class Mfe extends ws{getTabs(){return{all:d("All"),filed:d("Filed"),not_filed:d("Not Filed")}}getToggleableColumns(){return[{label:"ID",value:"id"},{label:"Order ID",value:"order_id"},{label:"Zip Code",value:"postcode"},{label:"Tax Rate",value:"rate"},{label:"Filed",value:"filed_at"}]}getSearchHint(){return d("Search by id, title, content or module.")}getFetchUrl(){return"taxes"}parseResponse(t){return t.taxes}getTableName(){return"taxes_table"}with(){return["admin_tax_report"]}scopes(){return["validOrder"]}}function Lfe(e){return Mfe.init(e)}const Rfe=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase()),Ofe=e=>{const t=Object.keys(e[0]),l=[t.map(Rfe).join(",")];return e.forEach(s=>{const i=t.map(A=>{let p=s[A];return typeof p=="object"&&(p=JSON.stringify(p)),typeof p=="string"&&(p=`"${p.replace(/"/g,'""')}"`),p});l.push(i.join(","))}),l.join(`
`)},Pfe=(e,t="export.csv")=>new Promise((a,l)=>{try{if(!e||!e.length)throw new Error("No data to export");const s=Ofe(e),i=new Blob([s],{type:"text/csv"}),A=document.createElement("a"),p=()=>{window.removeEventListener("focus",p),a()};window.addEventListener("focus",p),A.href=URL.createObjectURL(i),A.download=t,A.click(),URL.revokeObjectURL(A.href),setTimeout(()=>{a()},200)}catch(s){l(s)}}),Hfe={class:"table-cell"},Nfe={class:"table-cell"},Kfe={class:"table-cell"},Gfe={class:"table-cell"},zfe={class:"table-cell"},jfe={class:"table-cell"},qfe={class:"table-cell"},Yfe={class:"table-cell"},Wfe={class:"table-cell"},Xfe={__name:"TaxesLoader",props:{nextPageCount:{type:Number,default:0},taxTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(l,s)=>s+1);return(l,s)=>{const i=k("el-table-column"),A=k("el-skeleton-item"),p=k("el-skeleton"),h=k("el-table");return r(),E(h,{data:c(a),class:"w-full compact-table full-compact"},{default:u(()=>[n(i,{type:"selection",width:45}),e.taxTable.isColumnVisible("id")?(r(),E(i,{key:0,width:100,label:c(d)("ID")},{default:u(()=>[o("div",Hfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.taxTable.isColumnVisible("order_id")?(r(),E(i,{key:1,label:c(d)("Order ID"),width:100},{default:u(()=>[o("div",Nfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:c(d)("Tax Country"),width:120},{default:u(()=>[o("div",Kfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"]),n(i,{label:c(d)("Tax Region"),width:120},{default:u(()=>[o("div",Gfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("postcode")?(r(),E(i,{key:2,label:c(d)("Zip Code"),width:120},{default:u(()=>[o("div",zfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:c(d)("Tax Name"),width:120},{default:u(()=>[o("div",jfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("rate")?(r(),E(i,{key:3,label:c(d)("Tax Rate"),width:120},{default:u(()=>[o("div",qfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:c(d)("Sale Taxes"),width:120},{default:u(()=>[o("div",Yfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("filed_at")?(r(),E(i,{key:4,label:c(d)("Filed"),width:120},{default:u(()=>[o("div",Wfe,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},Jfe={class:"table-cell"},Zfe={class:"table-cell"},eme={class:"table-cell"},tme={class:"table-cell"},ame={class:"table-cell"},lme={class:"table-cell"},sme={class:"table-cell"},nme={class:"table-cell"},ome={class:"table-cell"},ime={__name:"AllCouponsLoader",props:{nextPageCount:{type:Number,default:0},couponTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(l,s)=>s+1);return(l,s)=>{const i=k("el-skeleton-item"),A=k("el-skeleton"),p=k("el-table-column"),h=k("el-table");return r(),E(h,{data:c(a),class:"w-full compact-table responsive full-compact"},{default:u(()=>[n(p,{width:103,label:c(d)("ID")},{default:u(()=>[o("div",Jfe,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("title")?(r(),E(p,{key:0,label:c(d)("Title"),width:227},{default:u(()=>[o("div",Zfe,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[180px]"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(p,{label:c(d)("Code"),width:206},{default:u(()=>[o("div",eme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[130px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:c(d)("Amount"),width:124},{default:u(()=>[o("div",tme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:c(d)("Usage"),width:155},{default:u(()=>[o("div",ame,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("stackable")?(r(),E(p,{key:1,label:c(d)("Stackable"),width:124},{default:u(()=>[o("div",lme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(p,{label:c(d)("Status"),width:124},{default:u(()=>[o("div",sme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:c(d)("Expiry Date"),width:124},{default:u(()=>[o("div",nme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("actions")?(r(),E(p,{key:2,label:c(d)("Actions"),width:103,align:"right"},{default:u(()=>[o("div",ome,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},rme={class:"fct-taxes-page fct-layout-width"},dme={key:1},ume={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},cme={class:"fct-tax-filing-wrap"},Ame={class:"fct-tax-filing-summary"},pme={class:"summary-item"},fme={class:"summary-label"},mme={class:"summary-value"},hme={class:"summary-item"},_me={class:"summary-label"},vme={class:"summary-value"},gme={class:"fct-tax-filing max-h-[400px] overflow-y-auto"},yme={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},bme={class:"dialog-footer"},wme={class:"fct-tax-filing-success-wrap"},Cme={class:"fct-tax-filling-success-icon"},kme={class:"dialog-footer"},Bme={__name:"Taxes",setup(e){const t=Object.fromEntries(Cm.map(x=>[x.value,x.label])),a=x=>t[x]||x;Zt().ctx;const l=Lfe(),s=T(!1),i=T(!1),A=T(!1),p=T([]),h=K(()=>l.getTableData().map(x=>{var I,V,D,U,L,O,M,H,j,W,G;return{id:x.id,order_id:x.order_id,country:a(((I=x.tax_rate)==null?void 0:I.country)??((V=x.meta)==null?void 0:V.tax_country)??""),state:((D=x.tax_rate)==null?void 0:D.formatted_state)??((U=x.tax_rate)==null?void 0:U.state)??"",postcode:((L=x.tax_rate)==null?void 0:L.postcode)??"",name:((O=x.tax_rate)==null?void 0:O.name)??((M=x.meta)==null?void 0:M.label)??"",reverse_charge:!!((H=x.meta)!=null&&H.reverse_charge_applied),rate:((j=x.tax_rate)==null?void 0:j.rate)??((W=x.meta)==null?void 0:W.rate_percent)??"",total_tax:String(parseFloat((x.total_tax/100).toFixed(2))),currency:((G=x.order)==null?void 0:G.currency)||"",total_tax:String(parseFloat((x.total_tax/100).toFixed(2))),filed_at:x.filed_at?d("Yes"):d("No")}})),_=()=>{s.value=!0,i.value=!1},y=()=>{s.value=!1,i.value=!0},g=async()=>{try{await Pfe(F.value),y()}catch{}},v=()=>{i.value=!1},C=()=>{const x=F.value.map(I=>I.id);Ae.post(l.getFetchUrl(),{ids:x}).then(I=>{q.success(I.message),l.fetch()}).catch(I=>{q.error(I)}).finally(()=>{v()})},w=x=>{p.value=x,A.value=x.length>0},b=x=>{F.value=x},S=T(null),F=T([]),Q=K(()=>{const x=F.value.reduce((V,D)=>V+parseFloat(D.total_tax||0),0),I=[...new Set(F.value.map(V=>V.order_id))];return{totalTax:vt.formatNumber(Math.round(x*100),!1),totalOrders:I.length,items:F.value}}),$=()=>{Fe(()=>{F.value=[...p.value],p.value.forEach(x=>{S.value.toggleRowSelection(x,!0)})})};return(x,I)=>{const V=k("el-button"),D=k("el-tooltip"),U=k("el-table-column"),L=k("router-link"),O=k("el-tag"),M=k("el-table"),H=k("el-dialog");return r(),m("div",rme,[n(nl,{title:c(d)("Taxes")},{action:u(()=>[A.value?(r(),E(V,{key:1,type:"primary",onClick:_,disabled:!A.value},{default:u(()=>[R(f(c(d)("Tax Filing")),1)]),_:1},8,["disabled"])):(r(),E(D,{key:0,"popper-class":"fct-tooltip",effect:"dark",content:c(d)("Please select the taxes you want to file"),placement:"top-start"},{default:u(()=>[n(V,{type:"primary",disabled:!A.value},{default:u(()=>[R(f(c(d)("Tax Filing")),1)]),_:1},8,["disabled"])]),_:1},8,["content"]))]),_:1},8,["title"]),n(Cs,{table:c(l),"has-mobile-slot":!1},{default:u(()=>[c(l).isLoading()?(r(),E(Xfe,{key:0,taxTable:c(l),"next-page-count":c(l).nextPageCount},null,8,["taxTable","next-page-count"])):(r(),m("div",dme,[n(M,{class:"w-full",data:h.value,onSelectionChange:w},{empty:u(()=>[n(wt,{icon:"Empty/ListView","has-dark":!0,text:c(d)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:u(()=>[n(U,{type:"selection",width:45}),c(l).isColumnVisible("id")?(r(),E(U,{key:0,label:c(d)("ID"),width:100},{default:u(j=>[o("span",null,"#"+f(c(d)(j.row.id)),1)]),_:1},8,["label"])):B("",!0),c(l).isColumnVisible("order_id")?(r(),E(U,{key:1,label:c(d)("Order ID"),width:100},{default:u(j=>[o("span",ume,[n(L,{class:"link",to:{name:"view_order",params:{order_id:j.row.order_id}}},{default:u(()=>[R(" #"+f(j.row.order_id),1)]),_:2},1032,["to"]),j.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:u(()=>[R(f(c(d)("Reverse Charge")),1)]),_:1})):B("",!0)])]),_:1},8,["label"])):B("",!0),n(U,{label:c(d)("Tax Country"),width:120},{default:u(j=>[o("span",null,f(j.row.country),1)]),_:1},8,["label"]),n(U,{label:c(d)("Tax Region"),width:120},{default:u(j=>[o("span",null,f(j.row.state),1)]),_:1},8,["label"]),c(l).isColumnVisible("postcode")?(r(),E(U,{key:2,label:c(d)("Zip Code"),width:120},{default:u(j=>[o("span",null,f(j.row.postcode),1)]),_:1},8,["label"])):B("",!0),n(U,{label:c(d)("Tax Name"),width:120},{default:u(j=>[o("span",null,f(j.row.name),1)]),_:1},8,["label"]),c(l).isColumnVisible("rate")?(r(),E(U,{key:3,label:c(d)("Tax Rate"),width:120},{default:u(j=>[o("span",null,f(j.row.rate)+"%",1)]),_:1},8,["label"])):B("",!0),n(U,{label:c(d)("Sale Taxes"),width:120},{default:u(j=>[o("span",null,f(c(vt).formatForOrder(j.row.total_tax_cents,j.row.currency)),1)]),_:1},8,["label"]),c(l).isColumnVisible("filed_at")?(r(),E(U,{key:4,label:c(d)("Filed"),width:120},{default:u(j=>[o("span",null,f(j.row.filed_at),1)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"]),n(H,{modelValue:s.value,"onUpdate:modelValue":I[1]||(I[1]=j=>s.value=j),title:c(d)("Tax Filing"),onOpen:$,class:"fct-tax-filling-modal"},{footer:u(()=>[o("div",bme,[n(V,{onClick:I[0]||(I[0]=()=>{s.value=!1})},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(V,{type:"primary",onClick:g},{default:u(()=>[n(X,{name:"Download",style:{width:"16px",height:"16px"}}),R(" "+f(c(d)("Download & Continue")),1)]),_:1})])]),default:u(()=>[o("div",cme,[o("div",Ame,[o("div",pme,[o("span",fme,f(c(d)("Taxable Amount")),1),o("span",mme,f(Q.value.totalTax),1)]),o("div",hme,[o("span",_me,f(c(d)("Total Orders")),1),o("span",vme,f(c(d)(Q.value.totalOrders)),1)])]),o("div",gme,[n(M,{ref_key:"selectedTaxesTableRef",ref:S,data:p.value,onSelectionChange:b},{empty:u(()=>[n(wt,{icon:"Empty/ListView",text:c(d)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:u(()=>[n(U,{type:"selection",width:45}),n(U,{label:c(d)("ID"),width:100},{default:u(j=>[o("span",null,f(j.row.id),1)]),_:1},8,["label"]),n(U,{label:c(d)("Order ID"),"min-width":100},{default:u(j=>[o("span",yme,[o("span",null,f(j.row.order_id),1),j.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:u(()=>[R(f(c(d)("Reverse Charge")),1)]),_:1})):B("",!0)])]),_:1},8,["label"]),n(U,{width:120,label:c(d)("Tax Country")},{default:u(j=>[o("span",null,f(j.row.country),1)]),_:1},8,["label"]),n(U,{width:120,label:c(d)("Tax Region")},{default:u(j=>[o("span",null,f(j.row.state),1)]),_:1},8,["label"]),n(U,{label:c(d)("Zip Code"),width:120},{default:u(j=>[o("span",null,f(j.row.postcode),1)]),_:1},8,["label"]),n(U,{width:120,label:c(d)("Tax Name")},{default:u(j=>[o("span",null,f(j.row.name),1)]),_:1},8,["label"]),n(U,{label:c(d)("Tax Rate"),width:120},{default:u(j=>[o("span",null,f(j.row.rate)+"%",1)]),_:1},8,["label"]),n(U,{width:150,label:c(d)("Sale Taxes")},{default:u(j=>[o("span",null,f(c(vt).formatForOrder(j.row.total_tax_cents,j.row.currency)),1)]),_:1},8,["label"])]),_:1},8,["data"])])])]),_:1},8,["modelValue","title"]),n(H,{modelValue:i.value,"onUpdate:modelValue":I[2]||(I[2]=j=>i.value=j),class:"fct-tax-filling-success-modal","close-on-click-modal":!1},{footer:u(()=>[o("div",kme,[n(V,{onClick:v},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(V,{type:"primary",onClick:C},{default:u(()=>[R(f(c(d)("Mark as Filed")),1)]),_:1})])]),default:u(()=>[o("div",wme,[o("div",Cme,[n(X,{name:"CheckCircleFill"})]),o("div",null,[o("h4",null,f(c(d)("Don't Forget to Save Your Tax File")),1),o("p",null,f(c(d)("You're about to mark this tax report as filed.")),1),o("p",null,[R(f(c(d)("Make sure you've downloaded and saved the CSV file for your records before proceeding."))+" ",1),o("a",{onClick:Ge(g,["prevent"]),class:"cursor-pointer"},f(c(d)("Download Again")),1)])])])]),_:1},8,["modelValue"])])}}},xme={class:"fct-card fct-card-border fct-vat-card"},Sme={class:"fct-card-body"},$me={class:"fct-vat-card-header"},Fme={class:"fct-vat-card-title"},Eme={class:"fct-card fct-card-border fct-vat-card mt-5"},Ume={class:"fct-card-body"},Ime={class:"fct-vat-card-header"},Vme={class:"fct-vat-card-title"},Dme={class:"fct-tax-rates-country-view"},Qme={class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},Tme={class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-3 border-b border-gray-200 dark:border-dark-300"},Mme={__name:"EUVatSettingsLoader",setup(e){const t=[1,2,3];return(a,l)=>(r(),m("div",null,[o("div",xme,[o("div",Sme,[o("div",$me,[o("div",Fme,[o("h3",null,f(c(d)("Collect VAT cross-border")),1)])]),l[0]||(l[0]=o("div",{class:"fct-vat-card-body"},[o("div",{class:"fct-sk w-[200px] h-3 rounded-xs"}),o("div",{class:"fct-sk w-full h-3 rounded-xs mt-3"})],-1))])]),o("div",Eme,[o("div",Ume,[o("div",Ime,[o("div",Vme,[o("h3",null,f(c(d)("Tax overrides")),1)])]),o("div",Dme,[o("div",Qme,[o("div",Tme,[(r(),m(P,null,ae(6,s=>o("div",{key:"header-"+s,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),m(P,null,ae(t,s=>o("div",{key:"override-row-"+s,class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-4 border-b border-gray-100 last:border-b-0 dark:border-dark-400"},l[1]||(l[1]=[Mn('',6)]))),64))])])])])]))}},Lme={class:"fct-modal-body"},Rme={class:"fct-radio-option-fields"},Ome={class:"form-note"},Pme={class:"fct-radio-option-fields"},Hme={class:"fct-radio-option-fields-desc"},Nme={class:"form-note"},Kme={key:0,class:"fct-info-box mt-3"},Gme={class:"text-xs text-system-mid"},zme={class:"fct-radio-option-fields"},jme={class:"fct-radio-option-fields-desc"},qme={__name:"EUVatCrossBorderModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},currentForm:{type:Object,default:()=>({})},initialRegistrations:{type:Array,default:()=>[]}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=T({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),i=T(!1);ke(()=>a.modelValue,_=>{if(_){const y=a.initialRegistrations.length?a.initialRegistrations[0]:null,g=y?y.country:"",v=y&&y.vat||"",C=a.currentForm||{};s.value={method:C.method||"oss",oss_country:C.oss_country||g,oss_vat:C.oss_vat||v,home_country:C.home_country||g,home_vat:C.home_vat||v}}else s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}});function A(_){const y=a.countries.find(g=>g.value===_);return y?parseFloat(y.default_rate||0):0}function p(){return a.initialRegistrations.some(_=>_.country===s.value.home_country)}function h(){if(!s.value.method){q.error(d("Select a cross-border registration type"));return}if(s.value.method==="oss"){if(!s.value.oss_country){q.error(d("Select your country of OSS registration"));return}}else if(s.value.method==="home"&&!s.value.home_country){q.error(d("Select your country of registration"));return}i.value=!0,(s.value.method==="home"&&!p()?Ae.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.home_country,vat:s.value.home_vat,rate:A(s.value.home_country)}):Promise.resolve()).then(()=>Ae.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:s.value})).then(y=>{q.success(y.message),l("saved",{method:s.value.method,oss_country:s.value.oss_country,oss_vat:s.value.oss_vat,home_country:s.value.home_country,home_country_vat:s.value.home_vat}),l("update:modelValue",!1)}).catch(y=>{var g;q.error((g=y==null?void 0:y.data)==null?void 0:g.message)}).finally(()=>{i.value=!1})}return(_,y)=>{const g=k("el-radio"),v=k("el-option"),C=k("el-select"),w=k("el-form-item"),b=k("el-input"),S=k("el-radio-group"),F=k("el-form"),Q=k("el-button"),$=k("el-dialog");return r(),E($,{"model-value":e.modelValue,title:c(d)("Collect across the EU"),width:"760px","close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":y[9]||(y[9]=x=>l("update:modelValue",x))},{footer:u(()=>[n(Q,{onClick:y[8]||(y[8]=x=>l("update:modelValue",!1))},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(Q,{type:"primary",onClick:h,loading:i.value},{default:u(()=>[R(f(c(d)("Collect VAT")),1)]),_:1},8,["loading"])]),default:u(()=>[o("div",Lme,[n(F,{"label-position":"top"},{default:u(()=>[n(S,{modelValue:s.value.method,"onUpdate:modelValue":y[7]||(y[7]=x=>s.value.method=x),class:"fct-cross-border-radios"},{default:u(()=>[o("div",{class:ue(["fct-radio-option",{"is-active":s.value.method==="oss"}]),onClick:y[2]||(y[2]=x=>s.value.method="oss")},[n(g,{value:"oss"},{default:u(()=>[R(f(c(d)("Collect using a One Stop Shop (OSS) registration")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="oss"},{default:u(()=>[o("div",Rme,[n(w,{label:c(d)("Country of OSS registration")},{default:u(()=>[n(C,{modelValue:s.value.oss_country,"onUpdate:modelValue":y[0]||(y[0]=x=>s.value.oss_country=x),placeholder:c(d)("Select country"),filterable:"",class:"w-full"},{default:u(()=>[(r(!0),m(P,null,ae(e.countries,x=>(r(),E(v,{key:x.value,label:x.label,value:x.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(w,{label:c(d)("VAT number")},{default:u(()=>[n(b,{modelValue:s.value.oss_vat,"onUpdate:modelValue":y[1]||(y[1]=x=>s.value.oss_vat=x),placeholder:c(d)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",Ome,[o("p",null,f(c(d)("Shown on VAT invoice")),1)])]),_:1},8,["label"])])]),_:1},8,["visible"])],2),o("div",{class:ue(["fct-radio-option",{"is-active":s.value.method==="home"}]),onClick:y[5]||(y[5]=x=>s.value.method="home")},[n(g,{value:"home"},{default:u(()=>[R(f(c(d)("Collect using your home country registration")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="home"},{default:u(()=>[o("div",Pme,[o("p",Hme,f(c(d)("Applies to micro-businesses located in one EU country and making less than €10,000 in sales to other EU countries each year")),1),n(w,{label:c(d)("Country of registration")},{default:u(()=>[n(C,{modelValue:s.value.home_country,"onUpdate:modelValue":y[3]||(y[3]=x=>s.value.home_country=x),placeholder:c(d)("Select country"),filterable:"",class:"w-full"},{default:u(()=>[(r(!0),m(P,null,ae(e.countries,x=>(r(),E(v,{key:x.value,label:x.label,value:x.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(w,{label:c(d)("VAT number")},{default:u(()=>[n(b,{modelValue:s.value.home_vat,"onUpdate:modelValue":y[4]||(y[4]=x=>s.value.home_vat=x),placeholder:c(d)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",Nme,[o("p",null,f(c(d)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),e.initialRegistrations.length?B("",!0):(r(),m("div",Kme,[n(X,{name:"InformationFill",class:"w-4 h-4 text-blue-500 flex-shrink-0"}),o("span",Gme,f(c(d)("You haven't added a home country registration. The information you add here will be used to create one for you.")),1)]))])]),_:1},8,["visible"])],2),o("div",{class:ue(["fct-radio-option",{"is-active":s.value.method==="specific"}]),onClick:y[6]||(y[6]=x=>s.value.method="specific")},[n(g,{value:"specific"},{default:u(()=>[R(f(c(d)("Collect using specific country registrations")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="specific"},{default:u(()=>[o("div",zme,[o("p",jme,f(c(d)("Register in each EU country where you are required to collect VAT. Manage your registrations in the country list below.")),1)])]),_:1},8,["visible"])],2)]),_:1},8,["modelValue"])]),_:1})])]),_:1},8,["model-value","title"])}}},Yme={key:0,class:"fct-country-registrations-list mt-4"},Wme={class:"fct-home-country-header"},Xme=["src","alt"],Jme={class:"fct-vat-country-name"},Zme={key:0,class:"fct-collecting-badge"},ehe={class:"fct-home-country-body"},the={class:"fct-vat-home-field"},ahe={class:"fct-vat-home-field__label"},lhe={class:"fct-reg-rates-section"},she={class:"fct-reg-rates-table fct-reg-rates-table--home mt-5 px-5 pt-5"},nhe={class:"fct-reg-rates-row fct-reg-rates-header"},ohe={class:"fct-reg-rates-cell-label"},ihe={class:"fct-reg-rates-cell-label"},rhe={key:1,class:"fct-reg-class-name"},dhe={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},uhe={class:"fct-reg-rates-cell-input"},che={class:"fct-reg-rates-cell-action"},Ahe=["title","onClick"],phe={key:0,class:"fct-reg-add-class px-5"},fhe={type:"button",class:"fct-reg-add-class-btn"},mhe={class:"fct-vat-home-actions"},hhe={__name:"EUVatHomeCountryRegistration",props:{countries:{type:Array,default:()=>[]},homeCountry:{type:String,default:""},homeVat:{type:String,default:""},taxClasses:{type:Array,default:()=>[]},registrations:{type:Array,default:()=>[]}},emits:["save-home","class-changed"],setup(e,{emit:t}){const a=e,l=t,s=T({country:"",vat:"",rates:{}}),i=T([]),A=K(()=>a.homeCountry&&a.countries.find(x=>x.value===a.homeCountry)||null),p=K(()=>a.homeCountry&&a.registrations.find(x=>x.country===a.homeCountry)||null),h=K(()=>{const x=p.value;return!x||!x.vat?!1:x.rates&&typeof x.rates=="object"&&Object.keys(x.rates).length?Object.values(x.rates).some(function(I){return I&&parseFloat(I.rate)>0}):parseFloat(x.rate)>0}),_=K(()=>[...a.taxClasses,...i.value]),y=K(()=>_.value.length?_.value:[{slug:"standard",title:d("Standard")}]),g=K(()=>{if(_.value.length>=6)return[];const x=_.value.map(V=>V.slug).filter(Boolean),I=[];return x.includes("reduced")||I.push({command:"reduced",label:d("Reduced")}),x.includes("zero")||I.push({command:"zero",label:d("Zero")}),I.push({command:"custom",label:d("Custom Class...")}),I});ke([()=>a.homeCountry,()=>a.homeVat,()=>a.taxClasses,()=>a.registrations],()=>{const x=p.value,I={};a.taxClasses.forEach(V=>{var O;const D=(O=x==null?void 0:x.rates)==null?void 0:O[V.slug],U=V.slug==="standard"?(x==null?void 0:x.rate)??"":"",L=V.slug==="standard"?(x==null?void 0:x.tax_label)??"":"";D&&typeof D=="object"?I[V.slug]={rate:D.rate??"",label:D.label??""}:I[V.slug]={rate:D??U,label:L}}),i.value.forEach(V=>{const D=v(V);I[D]=s.value.rates[D]||{rate:"",label:""}}),I.standard||(I.standard={rate:"",label:""}),s.value={country:a.homeCountry||"",vat:(x==null?void 0:x.vat)||a.homeVat||"",rates:I}},{immediate:!0});function v(x){return x.tempKey||x.slug}function C(x){if(x==="custom"){b();return}const I=x==="reduced"?d("Reduced"):d("Zero");i.value.push({slug:x,title:I,tempKey:x}),s.value.rates[x]={rate:"",label:""}}let w=0;function b(){const x="_new_"+w++;i.value.push({slug:null,title:"",tempKey:x,isNew:!0}),s.value.rates[x]={rate:"",label:""}}function S(x){return x.slug?x.title||x.slug:x.title&&x.title.trim()?x.title.trim():d("Custom")}function F(x){if(x.hasError=!1,x.created)return Promise.resolve(null);if(!x.slug&&!(x.title&&x.title.trim()))return x.hasError=!0,Promise.reject(new Error(d("Please enter a name for the custom tax class")));const I=x.slug?{slug:x.slug}:{title:x.title.trim()};return Ae.post("tax/classes",I).then(V=>{const D=(V==null?void 0:V.class)||{},U=D.slug||x.slug;if(!U)throw new Error(d("Tax class creation returned an invalid response"));return!x.slug&&s.value.rates[x.tempKey]!==void 0&&(s.value.rates[U]=s.value.rates[x.tempKey],delete s.value.rates[x.tempKey],x.tempKey=null),x.slug=U,x.title=D.title||x.title,x.created=!0,D}).catch(V=>{var U;x.hasError=!0;const D=((U=V==null?void 0:V.data)==null?void 0:U.message)||d("Failed to create tax class");throw new Error(d("%1$s: %2$s",D,S(x)))})}function Q(x){const I=v(x);if(i.value.some(D=>v(D)===I)){i.value=i.value.filter(D=>v(D)!==I),delete s.value.rates[I];return}Pa(d('This will permanently delete the "%1$s" tax class and all its rates across every country (not just EU). Products using this class will fall back to Standard. Continue?',x.title),d("Delete Tax Class"),{confirmButtonText:d("Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Ae.delete("tax/classes/"+x.id).then(()=>{l("class-changed")}).catch(D=>{var U;q.error(((U=D==null?void 0:D.data)==null?void 0:U.message)||d("Failed to delete tax class"))})}).catch(()=>{})}function $(){const x=i.value.map(F);Promise.all(x).then(()=>{i.value=[],l("save-home",{country:s.value.country,vat:s.value.vat,rates:s.value.rates})}).catch(I=>{q.error((I==null?void 0:I.message)||d("Failed to create tax class"))})}return(x,I)=>{const V=k("el-input"),D=k("el-dropdown-item"),U=k("el-dropdown-menu"),L=k("el-dropdown"),O=k("el-button");return A.value?(r(),m("div",Yme,[o("div",Wme,[o("img",{src:`https://flagcdn.com/w40/${e.homeCountry.toLowerCase()}.png`,alt:A.value.label,class:"fct-flag-icon"},null,8,Xme),o("span",Jme,f(A.value.label),1),h.value?(r(),m("span",Zme,[I[1]||(I[1]=o("span",{class:"fct-green-dot"},null,-1)),R(" "+f(c(d)("Collecting")),1)])):B("",!0)]),o("div",ehe,[o("div",the,[o("label",ahe,f(c(d)("VAT number")),1),n(V,{modelValue:s.value.vat,"onUpdate:modelValue":I[0]||(I[0]=M=>s.value.vat=M),class:"fct-vat-number-input"},null,8,["modelValue"])]),o("div",lhe,[o("div",she,[o("div",nhe,[o("div",ohe,f(c(d)("Tax Classes")),1),I[2]||(I[2]=o("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),I[3]||(I[3]=o("div",{class:"fct-reg-rates-cell-input"},null,-1)),I[4]||(I[4]=o("div",{class:"fct-reg-rates-cell-action"},null,-1))]),(r(!0),m(P,null,ae(y.value,M=>(r(),m("div",{key:v(M),class:"fct-reg-rates-row"},[o("div",ihe,[M.isNew?(r(),E(V,{key:0,modelValue:M.title,"onUpdate:modelValue":H=>M.title=H,size:"small",placeholder:c(d)("Class name"),class:ue(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":M.hasError}]),onInput:H=>M.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),m("span",rhe,f(M.title),1))]),o("div",dhe,[n(V,{modelValue:s.value.rates[v(M)].rate,"onUpdate:modelValue":H=>s.value.rates[v(M)].rate=H,type:"number",step:"0.01",min:"0",size:"small"},{suffix:u(()=>I[5]||(I[5]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),o("div",uhe,[n(V,{modelValue:s.value.rates[v(M)].label,"onUpdate:modelValue":H=>s.value.rates[v(M)].label=H,size:"small",placeholder:c(d)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",che,[M.slug!=="standard"?(r(),m("button",{key:0,type:"button",class:"fct-reg-rates-delete-btn",title:c(d)("Delete class"),onClick:H=>Q(M)},[n(X,{name:"Delete"})],8,Ahe)):B("",!0)])]))),128))]),g.value.length?(r(),m("div",phe,[g.value.length===1&&g.value[0].command==="custom"?(r(),m("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:b},[n(X,{name:"Plus",class:"w-3 h-3"}),R(" "+f(c(d)("Add class")),1)])):(r(),E(L,{key:1,trigger:"click",onCommand:C,"popper-class":"fct-dropdown"},{dropdown:u(()=>[n(U,null,{default:u(()=>[(r(!0),m(P,null,ae(g.value,M=>(r(),E(D,{key:M.command,command:M.command},{default:u(()=>[R(f(M.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:u(()=>[o("button",fhe,[n(X,{name:"Plus",class:"w-3 h-3"}),R(" "+f(c(d)("Add class")),1)])]),_:1}))])):B("",!0)]),o("div",mhe,[n(O,{type:"primary",size:"small",onClick:$},{default:u(()=>[R(f(c(d)("Save VAT")),1)]),_:1})])])])):B("",!0)}}},_he={class:"fct-modal-body fct-country-reg-modal"},vhe={class:"fct-country-reg-text"},ghe={class:"form-note"},yhe={class:"fct-reg-rates-table"},bhe={class:"fct-reg-rates-row fct-reg-rates-header"},whe={class:"fct-reg-rates-cell-label"},Che={class:"fct-reg-rates-cell-label"},khe={key:1,class:"fct-reg-class-name"},Bhe={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},xhe={class:"fct-reg-rates-cell-input"},She={key:1,class:"fct-reg-rates-row"},$he={class:"fct-reg-rates-cell-label"},Fhe={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},Ehe={class:"fct-reg-rates-cell-input"},Uhe={key:0,class:"fct-reg-add-class"},Ihe={type:"button",class:"fct-reg-add-class-btn"},Vhe={__name:"EUVatRegistrationModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},taxClasses:{type:Array,default:()=>[]},initialForm:{type:Object,default:()=>({country:"",vat:"",rates:{},isEdit:!1})},registeredCountries:{type:Array,default:()=>[]}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=T({country:"",vat:"",rates:{},isEdit:!1}),i=T([]),A=T(!1),p=K(()=>[...a.taxClasses,...i.value]),h=K(()=>{if(p.value.length>=6)return[];const Q=p.value.map(x=>x.slug).filter(Boolean),$=[];return Q.includes("reduced")||$.push({command:"reduced",label:d("Reduced")}),Q.includes("zero")||$.push({command:"zero",label:d("Zero")}),$.push({command:"custom",label:d("Custom Class...")}),$}),_=K(()=>s.value.isEdit?a.countries:a.countries.filter(Q=>!a.registeredCountries.includes(Q.value)));ke(()=>a.modelValue,Q=>{if(Q){const $=a.initialForm||{},x=$.rates?JSON.parse(JSON.stringify($.rates)):{};a.taxClasses.forEach(I=>{x[I.slug]||(x[I.slug]={rate:"",label:""})}),x.standard||(x.standard={rate:"",label:""}),s.value={country:$.country||"",vat:$.vat||"",rates:x,isEdit:$.isEdit||!1},i.value=[]}});function y(Q){return Q.tempKey||Q.slug}function g(Q){const $=a.countries.find(x=>x.value===Q);if($&&$.default_rate){const x=s.value.rates.standard||{};s.value.rates=Object.assign({},s.value.rates,{standard:Object.assign({},x,{rate:$.default_rate})})}}function v(Q){if(Q==="custom"){w();return}const $=Q==="reduced"?d("Reduced"):d("Zero");i.value.push({slug:Q,title:$,tempKey:Q}),s.value.rates[Q]={rate:"",label:""}}let C=0;function w(){const Q="_new_"+C++;i.value.push({slug:null,title:"",tempKey:Q,isNew:!0}),s.value.rates[Q]={rate:"",label:""}}function b(Q){return Q.slug?Q.title||Q.slug:Q.title&&Q.title.trim()?Q.title.trim():d("Custom")}function S(Q){if(Q.hasError=!1,Q.created)return Promise.resolve(null);if(!Q.slug&&!(Q.title&&Q.title.trim()))return Q.hasError=!0,Promise.reject(new Error(d("Please enter a name for the custom tax class")));const $=Q.slug?{slug:Q.slug}:{title:Q.title.trim()};return Ae.post("tax/classes",$).then(x=>{const I=(x==null?void 0:x.class)||{},V=I.slug||Q.slug;if(!V)throw new Error(d("Tax class creation returned an invalid response"));return!Q.slug&&s.value.rates[Q.tempKey]!==void 0&&(s.value.rates[V]=s.value.rates[Q.tempKey],delete s.value.rates[Q.tempKey],Q.tempKey=null),Q.slug=V,Q.title=I.title||Q.title,Q.created=!0,I}).catch(x=>{var V;Q.hasError=!0;const I=((V=x==null?void 0:x.data)==null?void 0:V.message)||d("Failed to create tax class");throw new Error(d("%1$s: %2$s",I,b(Q)))})}function F(){if(!s.value.country){q.error(d("Select a registration country"));return}const Q=s.value.rates;if(!Object.values(Q).some(I=>parseFloat(I.rate)>0)){q.error(d("At least one tax rate must be greater than 0%"));return}A.value=!0;const x=i.value.map(S);Promise.all(x).then(()=>Ae.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.country,vat:s.value.vat,rates:s.value.rates})).then(I=>{q.success(I.message),i.value=[],l("saved"),l("update:modelValue",!1)}).catch(I=>{var V;q.error((I==null?void 0:I.message)||((V=I==null?void 0:I.data)==null?void 0:V.message)||d("Failed to save VAT registration"))}).finally(()=>{A.value=!1})}return(Q,$)=>{const x=k("el-option"),I=k("el-select"),V=k("el-form-item"),D=k("el-input"),U=k("el-dropdown-item"),L=k("el-dropdown-menu"),O=k("el-dropdown"),M=k("el-form"),H=k("el-button"),j=k("el-dialog");return r(),E(j,{"model-value":e.modelValue,title:s.value.isEdit?c(d)("Edit VAT registration"):c(d)("Collect VAT"),"close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":$[5]||($[5]=W=>l("update:modelValue",W))},{footer:u(()=>[n(H,{onClick:$[4]||($[4]=W=>l("update:modelValue",!1))},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(H,{type:"primary",onClick:F,loading:A.value},{default:u(()=>[R(f(c(d)("Collect VAT")),1)]),_:1},8,["loading"])]),default:u(()=>[o("div",_he,[o("p",vhe,f(c(d)("Make sure you're registered for VAT when collecting in the EU.")),1),n(M,{"label-position":"top"},{default:u(()=>[n(V,{label:c(d)("Registration country")},{default:u(()=>[n(I,{modelValue:s.value.country,"onUpdate:modelValue":$[0]||($[0]=W=>s.value.country=W),placeholder:c(d)("Select country"),filterable:"",class:"w-full",disabled:s.value.isEdit,onChange:g},{default:u(()=>[(r(!0),m(P,null,ae(_.value,W=>(r(),E(x,{key:W.value,label:W.label,value:W.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","disabled"])]),_:1},8,["label"]),n(V,{label:c(d)("VAT number")},{default:u(()=>[n(D,{modelValue:s.value.vat,"onUpdate:modelValue":$[1]||($[1]=W=>s.value.vat=W),placeholder:s.value.country?s.value.country+"999999999":"DE999999999"},null,8,["modelValue","placeholder"]),o("div",ghe,[o("p",null,f(c(d)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),o("div",yhe,[o("div",bhe,[o("div",whe,f(c(d)("Tax Classes")),1),$[6]||($[6]=o("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),$[7]||($[7]=o("div",{class:"fct-reg-rates-cell-input"},null,-1))]),p.value.length?(r(!0),m(P,{key:0},ae(p.value,W=>(r(),m("div",{key:W.tempKey||W.slug,class:"fct-reg-rates-row"},[o("div",Che,[W.isNew?(r(),E(D,{key:0,modelValue:W.title,"onUpdate:modelValue":G=>W.title=G,size:"small",placeholder:c(d)("Class name"),class:ue(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":W.hasError}]),onInput:G=>W.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),m("span",khe,f(W.title),1))]),o("div",Bhe,[n(D,{modelValue:s.value.rates[y(W)].rate,"onUpdate:modelValue":G=>s.value.rates[y(W)].rate=G,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:W.slug==="standard"?"19":"0"},{suffix:u(()=>$[8]||($[8]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",xhe,[n(D,{modelValue:s.value.rates[y(W)].label,"onUpdate:modelValue":G=>s.value.rates[y(W)].label=G,size:"small",placeholder:c(d)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])])]))),128)):(r(),m("div",She,[o("div",$he,f(c(d)("Standard")),1),o("div",Fhe,[n(D,{modelValue:s.value.rates.standard.rate,"onUpdate:modelValue":$[2]||($[2]=W=>s.value.rates.standard.rate=W),modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:"19"},{suffix:u(()=>$[9]||($[9]=[R("%",-1)])),_:1},8,["modelValue"])]),o("div",Ehe,[n(D,{modelValue:s.value.rates.standard.label,"onUpdate:modelValue":$[3]||($[3]=W=>s.value.rates.standard.label=W),size:"small",placeholder:c(d)("e.g. VAT, MwSt")},null,8,["modelValue","placeholder"])])]))]),h.value.length?(r(),m("div",Uhe,[h.value.length===1&&h.value[0].command==="custom"?(r(),m("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:w},[n(X,{name:"Plus"}),R(" "+f(c(d)("Add class")),1)])):(r(),E(O,{key:1,trigger:"click",onCommand:v},{dropdown:u(()=>[n(L,null,{default:u(()=>[(r(!0),m(P,null,ae(h.value,W=>(r(),E(U,{key:W.command,command:W.command},{default:u(()=>[R(f(W.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:u(()=>[o("button",Ihe,[n(X,{name:"Plus"}),R(" "+f(c(d)("Add class")),1)])]),_:1}))])):B("",!0)]),_:1})])]),_:1},8,["model-value","title"])}}},Dhe={class:"fct-oss-rates-section"},Qhe=["aria-expanded"],The={class:"inline-flex items-center gap-2"},Mhe={class:"fct-oss-rates-count"},Lhe={class:"fct-oss-rates-table"},Rhe={key:1,class:"text-system-mid"},Ohe={class:"fct-btn-group mt-4 justify-end sm"},Phe={__name:"EUVatOssRatesSection",setup(e,{expose:t}){const a=T([]),l=T([]),s=T(null),i=T("standard"),A=T(!1),p=T(!1),h=T(!1),_=T(!1),y=T(6),g=T(!1),v=T(""),C=K(()=>a.value),w=K(()=>{const V=v.value.trim().toLowerCase();return V?C.value.filter(D=>D.label&&D.label.toLowerCase().includes(V)):C.value});function b(){return A.value=!0,Ae.get("tax/configuration/settings/eu-vat/oss-rates").then(V=>{a.value=V.rates||[],l.value=V.classes||[];const D=Rd({classes:l.value,activeId:s.value});return D&&(s.value=D.id,i.value=D.slug),l.value}).catch(V=>{var D;q.error((D=V==null?void 0:V.data)==null?void 0:D.message)}).finally(()=>{A.value=!1})}function S(V){s.value=V.id,i.value=V.slug}function F(V){g.value=!0,Zo({payload:{slug:V},createdSlug:V,currentClasses:l.value,reloadClasses:b}).then(({createdClass:D})=>{D&&S(D)}).catch(D=>{var U;q.error((U=D==null?void 0:D.data)==null?void 0:U.message)}).finally(()=>{g.value=!1})}function Q(V){g.value=!0,Zo({payload:{title:V},currentClasses:l.value,reloadClasses:b}).then(({createdClass:D})=>{D&&S(D)}).catch(D=>{var U;q.error((U=D==null?void 0:D.data)==null?void 0:U.message)}).finally(()=>{g.value=!1})}function $(V){V.slug!=="standard"&&Pa(d('This will permanently delete the "%1$s" tax class and all its rates across every country (not just EU). Products using this class will fall back to Standard. Continue?',V.title),d("Delete Tax Class"),{confirmButtonText:d("Remove"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{A.value=!0,Sf({classId:V.id,currentActiveId:s.value===V.id?null:s.value,reloadClasses:b}).then(({nextActiveClass:D})=>{D&&S(D)}).catch(D=>{var U;q.error((U=D==null?void 0:D.data)==null?void 0:U.message),A.value=!1})}).catch(()=>{})}function x(){p.value=!0,Ae.post("tax/configuration/settings/eu-vat/oss-rates",{rates:C.value.map(V=>({country:V.country,rate:V.rate,tax_label:V.tax_label||"",class_rates:V.class_rates||{}}))}).then(V=>{q.success(V.message)}).catch(V=>{var D;q.error((D=V==null?void 0:V.data)==null?void 0:D.message)}).finally(()=>{p.value=!1})}function I(){Pa(d("This will overwrite all EU destination country standard rates with preset defaults. Continue?"),d("Reset to default tax rates"),{confirmButtonText:d("Reset"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{h.value=!0,Ae.post("tax/configuration/settings/eu-vat/reset-rates").then(()=>b()).then(()=>{q.success(d("EU tax rates have been reset to defaults"))}).catch(V=>{var D;q.error(((D=V==null?void 0:V.data)==null?void 0:D.message)||d("Failed to reset rates"))}).finally(()=>{h.value=!1})}).catch(()=>{})}return De(b),t({loadRates:b}),(V,D)=>{const U=k("el-icon"),L=k("el-table-column"),O=k("el-input"),M=k("el-table"),H=k("el-button"),j=Ta("loading");return r(),m("div",Dhe,[o("div",{class:"fct-oss-rates-toggle",role:"button",tabindex:"0","aria-expanded":_.value,onClick:D[0]||(D[0]=W=>{_.value=!_.value,_.value||(v.value="")}),onKeydown:[D[1]||(D[1]=da(Ge(W=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["enter"])),D[2]||(D[2]=da(Ge(W=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["space"]))]},[o("span",The,[R(f(c(d)("Destination country rates"))+" ",1),o("span",Mhe," ("+f(C.value.length)+") ",1)]),n(U,{class:ue(["fct-oss-rates-arrow",{"is-expanded":_.value}])},{default:u(()=>[n(X,{name:"ChevronDown",class:"w-4 h-4"})]),_:1},8,["class"])],40,Qhe),n(Kl,{name:"fct-collapse"},{default:u(()=>[Wt(o("div",Lhe,[n(sl,{type:"info"},{content:u(()=>[o("span",null,f(c(d)("Rates are pre-filled for convenience and may not reflect current laws — verify with a tax advisor before going live. If you sell products taxed at different rates (e.g. food, books, digital goods), use the"))+" + "+f(c(d)("button to add tax classes.")),1)]),_:1}),n(xf,{classes:l.value,"active-id":s.value,"max-classes":y.value,creating:g.value,search:v.value,onSwitch:S,onDelete:$,onAdd:F,onCreateCustom:Q,"onUpdate:search":D[3]||(D[3]=W=>v.value=W)},null,8,["classes","active-id","max-classes","creating","search"]),Wt((r(),E(M,{data:w.value,class:"w-full fct-tax-rates-table","max-height":"450","empty-text":c(d)("No rates found")},{default:u(()=>[n(L,{label:c(d)("Country"),"min-width":"160"},{default:u(({row:W})=>[R(f(W.label),1)]),_:1},8,["label"]),n(L,{label:c(d)("Tax Label"),"min-width":"150"},{default:u(({row:W})=>[W.class_rates&&W.class_rates[i.value]?(r(),E(O,{key:0,modelValue:W.class_rates[i.value].label,"onUpdate:modelValue":G=>W.class_rates[i.value].label=G,size:"small",placeholder:c(d)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])):B("",!0)]),_:1},8,["label"]),n(L,{label:c(d)("Rate"),"min-width":"120"},{default:u(({row:W})=>[W.class_rates&&W.class_rates[i.value]?(r(),E(O,{key:0,modelValue:W.class_rates[i.value].rate,"onUpdate:modelValue":G=>W.class_rates[i.value].rate=G,modelModifiers:{number:!0},size:"small",type:"number",min:0,max:100,step:"0.5"},{suffix:u(()=>D[4]||(D[4]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])):(r(),m("span",Rhe,"—"))]),_:1},8,["label"])]),_:1},8,["data","empty-text"])),[[j,A.value]]),o("div",Ohe,[i.value==="standard"?(r(),E(H,{key:0,size:"small",loading:h.value,onClick:I,type:"danger",soft:""},{default:u(()=>[R(f(c(d)("Reset to default")),1)]),_:1},8,["loading"])):B("",!0),n(H,{type:"primary",size:"small",loading:p.value,onClick:x},{default:u(()=>[R(f(c(d)("Save Rates")),1)]),_:1},8,["loading"])])],512),[[Sl,_.value]])]),_:1})])}}},Hhe={class:"fct-vat-card-header"},Nhe={class:"fct-vat-card-title"},Khe={class:"fct-vat-card-body"},Ghe={class:"fct-vat-reg-info"},zhe={class:"fct-vat-country-name"},jhe={key:0,size:"small",type:"success",class:"ml-3 fct-collecting-badge"},qhe={key:1,class:"ml-3 text-sm text-system-mid dark:text-gray-400"},Yhe={key:2,class:"fct-country-registrations-list mt-4"},Whe={class:"fct-reg-rows"},Xhe={key:0,class:"fct-vat-registration-row"},Jhe={class:"fct-vat-reg-info"},Zhe=["src","alt"],e_e={class:"fct-vat-country-name"},t_e={class:"fct-vat-reg-info"},a_e=["src","alt"],l_e={class:"fct-vat-country-name"},s_e={key:0,class:"fct-vat-number"},n_e={key:1,class:"fct-vat-missing-badge"},o_e={class:"fct-vat-reg-actions"},i_e={key:1,class:"fct-vat-empty-state"},r_e={class:"text-system-mid text-sm"},d_e={key:0,class:"px-5 py-3"},u_e={key:1,class:"fct-vat-cross-border-empty"},c_e={class:"fct-vat-cross-border-empty-text"},A_e={class:"fct-vat-cross-border-empty-title"},p_e={class:"fct-vat-cross-border-empty-desc"},f_e={__name:"EUVatCrossBorderCard",props:{countries:{type:Array,default:()=>[]},initialForm:{type:Object,default:()=>({})},initialRegistrations:{type:Array,default:()=>[]},storeCountry:{type:String,default:""},isTaxEnabled:{type:Boolean,default:!0}},emits:["method-changed"],setup(e,{emit:t}){const a=e,l=t,s=T({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),i=T(!1),A=T(null),p=T([]),h=T(!1),_=T({country:"",vat:"",rates:{},isEdit:!1}),y=K(()=>a.countries.length||28),g=K(()=>a.initialRegistrations.filter(Q).length),v=K(()=>a.storeCountry&&a.countries.find(Y=>Y.value===a.storeCountry)||null),C=K(()=>a.storeCountry?a.initialRegistrations.some(Y=>Y.country===a.storeCountry):!1),w=K(()=>{if(s.value.method!=="home"||!s.value.home_country)return!1;const Y=a.initialRegistrations.find(J=>J.country===s.value.home_country);return!!Y&&Q(Y)}),b=K(()=>s.value.method==="oss"||s.value.method==="home"||s.value.method==="specific");function S(Y){if(!Y||!Array.isArray(a.countries))return Y;const J=a.countries.find(de=>de.value===Y);return J?J.label:Y}function F(Y){return Y?Y.rates&&typeof Y.rates=="object"&&Object.keys(Y.rates).length?Object.values(Y.rates).some(J=>J&&parseFloat(J.rate)>0):parseFloat(Y.rate)>0:!1}function Q(Y){return!!Y&&!!Y.vat&&F(Y)}function $(Y){return F(Y)&&!Y.vat}function x(){return Ae.get("tax/classes").then(Y=>{p.value=Y.classes||[]}).catch(()=>{q.error(d("Failed to load tax classes"))})}function I(Y){const J={};return p.value.forEach(de=>{J[de.slug]={rate:de.slug==="standard"&&Y||"",label:""}}),J}function V(){const Y=v.value&&!C.value?a.storeCountry:"",J=Y&&v.value&&v.value.default_rate||"";_.value={country:Y,vat:"",rates:I(J),isEdit:!1},h.value=!0}function D(Y){const J=Y.rates||{},de={};p.value.forEach(z=>{const ce=J[z.slug];if(ce&&typeof ce=="object")de[z.slug]={rate:ce.rate||"",label:ce.label||""};else{const oe=z.slug==="standard"?Y.rate||"":ce||"";de[z.slug]={rate:oe,label:z.slug==="standard"&&Y.tax_label||""}}}),_.value={country:Y.country,vat:Y.vat||"",rates:de,isEdit:!0},h.value=!0}function U(){x(),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}function L(Y){Ae.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:Y.country,vat:Y.vat,rates:Y.rates}).then(J=>{q.success(J.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:Y.vat})}).catch(J=>{var de;q.error(((de=J==null?void 0:J.data)==null?void 0:de.message)||d("Failed to save VAT registration"))})}function O(Y){Pa(d("Are you sure you want to remove this country registration?"),d("Confirm Remove"),{confirmButtonText:d("Yes, Remove"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Ae.post("tax/configuration/settings/eu-vat",{action:"deleteCountryRegistration",country:Y}).then(J=>{q.success(J.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}).catch(J=>{var de;q.error((de=J==null?void 0:J.data)==null?void 0:de.message)})}).catch(()=>{})}function M(){return g.value===1?d("Collecting in 1 country"):d("Collecting in %1$s countries",g.value)}const H=K(()=>y.value===1?d("Collecting in 1 region"):d("Collecting in %1$s regions",y.value));function j(Y){s.value={method:Y.method,oss_country:Y.oss_country,oss_vat:Y.oss_vat,home_country:Y.home_country,home_vat:Y.home_country_vat},Y.method==="oss"&&Fe(()=>{var J;return(J=A.value)==null?void 0:J.loadRates()}),l("method-changed",{method:Y.method,home_country:Y.home_country,home_vat:Y.home_country_vat})}function W(Y){Y==="edit"?i.value=!0:Y==="stop"&&G()}function G(){Pa(d("Are you sure you want to stop collecting cross-border VAT? This will clear your OSS/home country registration."),d("Stop Collecting"),{confirmButtonText:d("Yes, Stop"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Ae.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:{method:"specific"},reset_registration:"yes"}).then(Y=>{q.success(Y.message),s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""},l("method-changed",{method:"",home_country:"",home_vat:""})}).catch(Y=>{var J;q.error((J=Y==null?void 0:Y.data)==null?void 0:J.message)})}).catch(()=>{})}return ke(()=>a.initialForm,Y=>{const J=Y||{};s.value={method:J.method||"",oss_country:J.oss_country||"",oss_vat:J.oss_vat||"",home_country:J.home_country||"",home_vat:J.home_vat||""}},{immediate:!0}),ke(()=>a.countries,Y=>{Y&&Y.length&&x()},{immediate:!0}),(Y,J)=>{const de=k("el-tooltip"),z=k("el-dropdown-item"),ce=k("el-dropdown-menu"),oe=k("el-dropdown"),Z=k("el-button");return r(),m(P,null,[n($e,{class:"fct-vat-card"},{default:u(()=>[n(xe,null,{default:u(()=>[o("div",Hhe,[o("div",Nhe,[o("h3",null,f(c(d)("Collect VAT cross-border")),1),n(de,{content:c(d)("Choose how to collect VAT for sales to other EU countries."),placement:"top"},{default:u(()=>[n(X,{name:"InformationFill",class:"w-4 h-4 text-system-mid cursor-pointer"})]),_:1},8,["content"])]),b.value?(r(),E(oe,{key:0,trigger:"click",onCommand:W,"popper-class":"fct-dropdown",placement:"bottom-end"},{dropdown:u(()=>[n(ce,null,{default:u(()=>[n(z,{command:"edit"},{default:u(()=>[R(f(c(d)("Edit registration")),1)]),_:1}),n(z,{command:"stop"},{default:u(()=>[R(f(c(d)("Stop collecting")),1)]),_:1})]),_:1})]),default:u(()=>[n(lt,{border:"none",size:"small",tag:"button"},{default:u(()=>[n(X,{name:"More"})]),_:1})]),_:1})):B("",!0)]),o("div",Khe,[b.value?(r(),m(P,{key:0},[o("div",Ghe,[J[4]||(J[4]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("span",zhe,f(s.value.method==="oss"?c(d)("EU (OSS)"):s.value.method==="home"?c(d)("EU (micro-business)"):c(d)("EU (specific countries)")),1),e.isTaxEnabled&&(s.value.method!=="specific"||g.value>0)?(r(),m("span",jhe,[J[3]||(J[3]=o("span",{class:"fct-green-dot"},null,-1)),s.value.method==="specific"?(r(),m(P,{key:0},[R(f(M()),1)],64)):(r(),m(P,{key:1},[R(f(H.value),1)],64))])):B("",!0),e.isTaxEnabled?B("",!0):(r(),m("span",qhe,f(c(d)("Tax disabled")),1))]),s.value.method==="home"?(r(),E(sl,{key:0,type:w.value?"info":"warning",icon:"Info",class:"mb-4 mt-4",content:w.value?c(d)("Collecting cross-border EU VAT at your %1$s home country rate. This is for small businesses whose total cross-border EU sales stay below €10,000/year. Once you exceed that threshold you must charge each buyer's local VAT rate instead.",S(s.value.home_country)):c(d)("Your %1$s home country VAT rate will apply to all EU cross-border sales. This is available for small businesses below €10,000/year in cross-border EU sales. Make sure %1$s is registered below with the correct rate.",S(s.value.home_country))},null,8,["type","content"])):B("",!0),s.value.method==="home"?(r(),E(hhe,{key:1,countries:e.countries,"home-country":s.value.home_country,"home-vat":s.value.home_vat,"tax-classes":p.value,registrations:e.initialRegistrations,onSaveHome:L,onClassChanged:x},null,8,["countries","home-country","home-vat","tax-classes","registrations"])):B("",!0),s.value.method==="specific"?(r(),m("div",Yhe,[o("div",Whe,[v.value&&!C.value?(r(),m("div",Xhe,[o("div",Jhe,[o("img",{src:`https://flagcdn.com/w40/${e.storeCountry.toLowerCase()}.png`,alt:v.value.label,class:"fct-flag-icon"},null,8,Zhe),o("span",e_e,f(v.value.label),1)]),n(Z,{size:"small",onClick:V},{default:u(()=>[R(f(c(d)("Configure")),1)]),_:1})])):B("",!0),(r(!0),m(P,null,ae(e.initialRegistrations,N=>(r(),m("div",{key:N.country,class:"fct-vat-registration-row"},[o("div",t_e,[o("img",{src:`https://flagcdn.com/w40/${N.country.toLowerCase()}.png`,alt:S(N.country),class:"fct-flag-icon"},null,8,a_e),o("span",l_e,f(S(N.country)),1),N.vat?(r(),m("span",s_e,f(N.vat),1)):$(N)?(r(),m("span",n_e,f(c(d)("VAT ID missing")),1)):B("",!0)]),o("div",o_e,[F(N)?(r(),E(lt,{key:0,border:"none",size:"small",tag:"button",title:c(d)("Edit"),onClick:le=>D(N)},{default:u(()=>[n(X,{name:"Edit"})]),_:2},1032,["title","onClick"])):(r(),E(Z,{key:1,size:"small",onClick:le=>D(N)},{default:u(()=>[R(f(c(d)("Configure")),1)]),_:2},1032,["onClick"])),n(lt,{border:"none",size:"small",tag:"button",title:c(d)("Delete"),onClick:le=>O(N.country)},{default:u(()=>[n(X,{name:"Delete"})]),_:2},1032,["title","onClick"])])]))),128)),!e.initialRegistrations.length&&!v.value?(r(),m("div",i_e,[o("p",r_e,f(c(d)("No country VAT registrations configured.")),1),n(Z,{type:"primary",size:"small",onClick:V},{default:u(()=>[R(f(c(d)("Configure")),1)]),_:1})])):B("",!0)]),e.initialRegistrations.length||v.value?(r(),m("div",d_e,[n(Z,{type:"primary",link:"",onClick:V},{default:u(()=>[R(" + "+f(c(d)("Collect in another country")),1)]),_:1})])):B("",!0)])):B("",!0),s.value.method==="oss"?(r(),E(Phe,{key:3,ref_key:"ossRatesRef",ref:A},null,512)):B("",!0)],64)):(r(),m("div",u_e,[J[5]||(J[5]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("div",c_e,[o("p",A_e,f(c(d)("Not collecting cross-border VAT")),1),o("p",p_e,f(c(d)("Set up OSS, micro-business, or specific-country registrations to collect VAT across the EU.")),1)]),n(Z,{size:"small",onClick:J[0]||(J[0]=N=>i.value=!0),type:"primary"},{default:u(()=>[R(f(c(d)("Configure")),1)]),_:1})]))])]),_:1})]),_:1}),n(qme,{modelValue:i.value,"onUpdate:modelValue":J[1]||(J[1]=N=>i.value=N),countries:e.countries,"current-form":s.value,"initial-registrations":e.initialRegistrations,onSaved:j},null,8,["modelValue","countries","current-form","initial-registrations"]),n(Vhe,{modelValue:h.value,"onUpdate:modelValue":J[2]||(J[2]=N=>h.value=N),countries:e.countries,"tax-classes":p.value,"initial-form":_.value,"registered-countries":e.initialRegistrations.map(N=>N.country),onSaved:U},null,8,["modelValue","countries","tax-classes","initial-form","registered-countries"])],64)}}},m_e={__name:"EUVatTaxOverrideModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},taxClasses:{type:Array,default:()=>[]},editRow:{type:Object,default:null}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=T({type:"products",original_type:"",original_id:"",category_id:"",category_name:"",country:"",city:"",postcode:"",tax_label:"VAT",tax_rate:0,class_id:0,id:""}),i=T([]),A=T(!1),p=T(!1);function h(){return a.taxClasses&&a.taxClasses.length>0&&Number(a.taxClasses[0].id)||0}function _(){s.value={type:"products",original_type:"",original_id:"",category_id:"",category_name:"",country:"",city:"",postcode:"",tax_label:"VAT",tax_rate:0,class_id:0,id:""}}function y(b){if(b.type==="shipping")s.value={type:"shipping",original_type:"shipping",original_id:b.id,category_id:"",category_name:"",country:b._raw.country||"",city:b._raw.city||"",postcode:b._raw.postcode||"",tax_label:b.tax_label,tax_rate:b.rate,class_id:Number(b._raw.class_id)||h(),id:b.id};else{const S=b._raw.meta_value||b._raw;s.value={type:"products",original_type:"products",original_id:b.id,category_id:on(S.category_id),category_name:b.category_name,country:S.country||"",city:S.city||"",postcode:S.postcode||"",tax_label:b.tax_label,tax_rate:b.rate,class_id:Number(b.class_id)||0,id:b.id}}}ke(()=>a.modelValue,b=>{b&&(a.editRow?y(a.editRow):_(),g())}),ke(()=>s.value.type,b=>{b==="shipping"&&!s.value.class_id&&(s.value.class_id=h())}),ke(()=>a.taxClasses,b=>{s.value.type==="shipping"&&!s.value.class_id&&b&&b.length>0&&(s.value.class_id=Number(b[0].id)||0)});function g(){i.value.length>0||(A.value=!0,Ae.get("products/fetch-term").then(b=>{const S=b.taxonomies&&b.taxonomies["product-categories"]?b.taxonomies["product-categories"].terms||[]:[];i.value=S.map(F=>({...F,value:on(F.value)}))}).catch(()=>{q.error(d("Failed to load product categories"))}).finally(()=>{A.value=!1}))}function v(b,S){return Ae.get("tax/rates/country/rates/"+b,{class_id:S}).then(F=>{const $=(F&&F.tax_rates?F.tax_rates:[]).find(function(I){return!I.state&&!I.city&&!I.postcode});if($)return $;const x=a.countries.find(function(I){return I.value===b});return Ae.post("tax/country/rate",{country:b,state:"",rate:x&&x.default_rate||0,name:"Tax",is_compound:0,for_order:0,group:"EU",class_id:S}).then(function(I){return I&&I.tax_rate?I.tax_rate:null})})}function C(b){const S=on(b),F=i.value.find(Q=>Q.value===S);F&&(s.value.category_name=F.label)}function w(){if(s.value.type==="products"&&!s.value.category_id){q.error(d("Please select a category"));return}if(!s.value.country){q.error(d("Please select a location"));return}if(s.value.type==="shipping"){if(!a.taxClasses||a.taxClasses.length===0){q.error(d("Tax classes are not available. Please reload the page and try again."));return}if(!s.value.class_id){q.error(d("Please select a tax class"));return}}if(p.value=!0,s.value.type==="products")Ae.post("tax/product-overrides",{id:s.value.original_type==="products"?s.value.original_id:"",source_type:s.value.original_type,source_id:s.value.original_id,country:s.value.country,state:"",city:s.value.city||"",postcode:s.value.postcode||"",category_id:s.value.category_id,category_name:s.value.category_name,tax_label:s.value.tax_label,rate:s.value.tax_rate,override_state_tax:"no",class_id:s.value.class_id||0}).then(b=>{q.success(b.message),l("saved"),l("update:modelValue",!1)}).catch(b=>{q.error(b&&b.data?b.data.message:b&&b.message?b.message:"")}).finally(()=>{p.value=!1});else{const b=s.value.class_id;v(s.value.country,b).then(S=>S?Ae.post("tax/rates/country/override",{id:S.id,previous_id:s.value.original_type==="shipping"?s.value.original_id:"",source_type:s.value.original_type,source_id:s.value.original_id,class_id:b,override_tax_rate:s.value.tax_rate,city:s.value.city||"",postcode:s.value.postcode||""}).then(F=>{q.success(F.message),l("saved"),l("update:modelValue",!1)}).catch(F=>{q.error(F&&F.data?F.data.message:F&&F.message?F.message:"")}).finally(()=>{p.value=!1}):(q.error(d("No tax rate found for the selected country and tax class")),p.value=!1,null)).catch(S=>{q.error(S&&S.data?S.data.message:S&&S.message?S.message:""),p.value=!1})}}return(b,S)=>{const F=k("el-radio"),Q=k("el-radio-group"),$=k("el-form-item"),x=k("el-option"),I=k("el-select"),V=k("el-input"),D=k("el-form"),U=k("el-button"),L=k("el-dialog");return r(),E(L,{"model-value":e.modelValue,title:e.editRow?c(d)("Edit tax override"):c(d)("Add tax override"),width:"520px","close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":S[14]||(S[14]=O=>l("update:modelValue",O))},{footer:u(()=>[n(U,{onClick:S[13]||(S[13]=O=>l("update:modelValue",!1))},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(U,{type:"primary",loading:p.value,onClick:w},{default:u(()=>[R(f(e.editRow?c(d)("Save changes"):c(d)("Add override")),1)]),_:1},8,["loading"])]),default:u(()=>[n(D,{"label-position":"top",model:s.value},{default:u(()=>[n($,{label:c(d)("Override type")},{default:u(()=>[n(Q,{modelValue:s.value.type,"onUpdate:modelValue":S[0]||(S[0]=O=>s.value.type=O)},{default:u(()=>[n(F,{value:"products"},{default:u(()=>[R(f(c(d)("Products")),1)]),_:1}),n(F,{value:"shipping"},{default:u(()=>[R(f(c(d)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),s.value.type==="products"?(r(),m(P,{key:0},[n($,{label:c(d)("Category")},{default:u(()=>[n(I,{modelValue:s.value.category_id,"onUpdate:modelValue":S[1]||(S[1]=O=>s.value.category_id=O),filterable:"",placeholder:c(d)("Select a category"),loading:A.value,style:{width:"100%"},onChange:C},{default:u(()=>[(r(!0),m(P,null,ae(i.value,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),e.taxClasses.length>0?(r(),E($,{key:0,label:c(d)("Tax Class")},{default:u(()=>[n(I,{modelValue:s.value.class_id,"onUpdate:modelValue":S[2]||(S[2]=O=>s.value.class_id=O),style:{width:"100%"}},{default:u(()=>[n(x,{value:0,label:c(d)("All Tax Classes")},null,8,["label"]),(r(!0),m(P,null,ae(e.taxClasses,O=>(r(),E(x,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):B("",!0),n($,{label:c(d)("Tax label")},{default:u(()=>[n(V,{modelValue:s.value.tax_label,"onUpdate:modelValue":S[3]||(S[3]=O=>s.value.tax_label=O),placeholder:c(d)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Location")},{default:u(()=>[n(I,{modelValue:s.value.country,"onUpdate:modelValue":S[4]||(S[4]=O=>s.value.country=O),placeholder:c(d)("Select country"),filterable:"",style:{width:"100%"}},{default:u(()=>[(r(!0),m(P,null,ae(e.countries,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("City (optional)")},{default:u(()=>[n(V,{modelValue:s.value.city,"onUpdate:modelValue":S[5]||(S[5]=O=>s.value.city=O),placeholder:c(d)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Postcode (optional)")},{default:u(()=>[n(V,{modelValue:s.value.postcode,"onUpdate:modelValue":S[6]||(S[6]=O=>s.value.postcode=O),placeholder:c(d)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Tax rate (%)")},{default:u(()=>[n(V,{modelValue:s.value.tax_rate,"onUpdate:modelValue":S[7]||(S[7]=O=>s.value.tax_rate=O),type:"number",step:"0.01",min:"0",placeholder:c(d)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])],64)):(r(),m(P,{key:1},[n($,{label:c(d)("Location")},{default:u(()=>[n(I,{modelValue:s.value.country,"onUpdate:modelValue":S[8]||(S[8]=O=>s.value.country=O),placeholder:c(d)("Select country"),filterable:"",style:{width:"100%"}},{default:u(()=>[(r(!0),m(P,null,ae(e.countries,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),e.taxClasses.length>0?(r(),E($,{key:0,label:c(d)("Tax Class")},{default:u(()=>[n(I,{modelValue:s.value.class_id,"onUpdate:modelValue":S[9]||(S[9]=O=>s.value.class_id=O),style:{width:"100%"}},{default:u(()=>[(r(!0),m(P,null,ae(e.taxClasses,O=>(r(),E(x,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):B("",!0),n($,{label:c(d)("City (optional)")},{default:u(()=>[n(V,{modelValue:s.value.city,"onUpdate:modelValue":S[10]||(S[10]=O=>s.value.city=O),placeholder:c(d)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Postcode (optional)")},{default:u(()=>[n(V,{modelValue:s.value.postcode,"onUpdate:modelValue":S[11]||(S[11]=O=>s.value.postcode=O),placeholder:c(d)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Tax rate (%)")},{default:u(()=>[n(V,{modelValue:s.value.tax_rate,"onUpdate:modelValue":S[12]||(S[12]=O=>s.value.tax_rate=O),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["model-value","title"])}}},h_e={class:"fct-tax-rates-country-view"},__e={key:0,class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},v_e={class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_110px] gap-4 px-4 py-3 border-b border-gray-200 dark:border-dark-300"},g_e={key:0},y_e={key:1},b_e={class:"fct-btn-group sm justify-end"},w_e={__name:"EUVatTaxOverridesCard",props:{countries:{type:Array,default:()=>[]}},setup(e){const t=e,a=T([]),l=T(!1),s=T(!1),i=T(null),A=T([]);function p(C){if(!C||!Array.isArray(t.countries))return C;const w=t.countries.find(b=>b.value===C);return w?w.label:C}function h(){Ae.get("tax/classes").then(C=>{A.value=C.classes||[]}).catch(()=>{q.error(d("Failed to load tax classes"))})}function _(){l.value=!0,Ae.get("tax/configuration/settings/eu-vat/product-overrides").then(C=>{const w=[],b=C.overrides||[];for(const F of b){const Q=F.meta_value||F;w.push({id:F.id,type:"products",tax_label:Q.tax_label||"",category_name:Q.category_name||"",location:p(Q.country),city:Q.city||"",postcode:Q.postcode||"",rate:Q.rate,class_id:Number(F.class_id)||0,class_label:F.class_label||"",_raw:F})}const S=C.shipping_overrides||[];for(const F of S)w.push({id:F.id,type:"shipping",tax_label:F.name||"",category_name:"",location:p(F.country),city:F.city||"",postcode:F.postcode||"",rate:F.for_shipping,class_id:Number(F.class_id)||0,class_label:F.class_label||"",_raw:F});a.value=w}).catch(()=>{a.value=[]}).finally(()=>{l.value=!1})}function y(){i.value=null,s.value=!0}function g(C){i.value=C,s.value=!0}function v(C){Pa(d("Are you sure you want to delete this override?"),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{const w=C.type==="shipping"?"tax/rates/country/override/"+C.id:"tax/product-overrides/"+C.id;Ae.delete(w).then(b=>{q.success(b.message),a.value=a.value.filter(S=>!(S.id===C.id&&S.type===C.type))}).catch(b=>{var S;q.error((S=b==null?void 0:b.data)==null?void 0:S.message)})}).catch(()=>{})}return De(()=>{h(),_()}),(C,w)=>{const b=k("el-button"),S=k("el-tag"),F=k("el-table-column"),Q=k("el-table");return r(),m(P,null,[n($e,{class:"fct-vat-card"},{default:u(()=>[n(Qe,{title:c(d)("Tax overrides"),text:c(d)("Override tax rates for specific product categories or shipping.")},{action:u(()=>[n(b,{size:"small",onClick:y},{default:u(()=>[R(f(c(d)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(xe,null,{default:u(()=>[o("div",h_e,[l.value?(r(),m("div",__e,[o("div",v_e,[(r(),m(P,null,ae(6,$=>o("div",{key:"loading-header-"+$,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),m(P,null,ae(3,$=>o("div",{key:"loading-row-"+$,class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_110px] gap-4 px-4 py-4 border-b border-gray-100 last:border-b-0 dark:border-dark-400"},w[2]||(w[2]=[o("div",{class:"fct-sk w-16 h-6 rounded-full"},null,-1),o("div",{class:"fct-sk w-28 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-24 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-24 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-12 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-4 h-4 rounded-xs justify-self-end"},null,-1)]))),64))])):(r(),E(Q,{key:1,data:a.value,"empty-text":c(d)("No overrides configured")},{default:u(()=>[n(F,{label:c(d)("Type"),width:"110"},{default:u(({row:$})=>[n(S,{type:$.type==="products"?"primary":"info",size:"small"},{default:u(()=>[R(f($.type==="products"?c(d)("Product"):c(d)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n(F,{label:c(d)("Category")},{default:u(({row:$})=>[R(f($.category_name||"—"),1)]),_:1},8,["label"]),n(F,{label:c(d)("Tax Class"),width:"130"},{default:u(({row:$})=>[R(f($.class_label||c(d)("All")),1)]),_:1},8,["label"]),n(F,{label:c(d)("Tax Label")},{default:u(({row:$})=>[R(f($.tax_label||"—"),1)]),_:1},8,["label"]),n(F,{label:c(d)("Location")},{default:u(({row:$})=>[R(f($.location),1)]),_:1},8,["label"]),n(F,{label:c(d)("City / Postcode")},{default:u(({row:$})=>[$.city||$.postcode?(r(),m("span",g_e,f([$.city,$.postcode].filter(Boolean).join(" / ")),1)):(r(),m("span",y_e,"—"))]),_:1},8,["label"]),n(F,{label:c(d)("Rate"),width:"100"},{default:u(({row:$})=>[R(f($.rate)+"% ",1)]),_:1},8,["label"]),n(F,{label:c(d)("Actions"),width:"110",align:"right"},{default:u(({row:$})=>[o("div",b_e,[n(lt,{tag:"button",size:"small",onClick:x=>g($)},{default:u(()=>[n(X,{name:"Edit"})]),_:2},1032,["onClick"]),n(lt,{tag:"button",size:"small",onClick:x=>v($),bg:"danger",outline:""},{default:u(()=>[n(X,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"]))])]),_:1})]),_:1}),n(m_e,{modelValue:s.value,"onUpdate:modelValue":[w[0]||(w[0]=$=>s.value=$),w[1]||(w[1]=$=>!$&&(i.value=null))],countries:e.countries,"tax-classes":A.value,"edit-row":i.value,onSaved:_},null,8,["modelValue","countries","tax-classes","edit-row"])],64)}}},C_e={class:"setting-wrap"},k_e={class:"setting-wrap-inner"},B_e={class:"fct-tax-collection-page"},x_e={__name:"EUVatSettings",setup(e){const t=T(!0),a=je.get("eu_vat_county_options",[]),l=T(""),s=T(""),i=T([]),A=T({}),p=K(()=>!!je.get("is_tax_enabled"));function h(){return t.value=!0,Ae.get("tax/configuration/settings").then(y=>{var v;const g=((v=y.settings)==null?void 0:v.eu_vat_settings)||{};l.value=y.store_country||"",i.value=g.country_registrations||[],A.value=g,s.value=g.method||""}).catch(y=>{var g;q.error((g=y==null?void 0:y.data)==null?void 0:g.message)}).finally(()=>{t.value=!1})}function _({method:y}){s.value=y||"",h()}return De(h),(y,g)=>(r(),m("div",C_e,[n($a,{heading:c(d)("VAT collection"),"show-save-button":!1},null,8,["heading"]),o("div",k_e,[n(Fa),o("div",B_e,[t.value?(r(),E(Mme,{key:0})):(r(),m(P,{key:1},[n(f_e,{countries:c(a),"initial-form":A.value,"initial-registrations":i.value,"store-country":l.value,"is-tax-enabled":p.value,onMethodChanged:_},null,8,["countries","initial-form","initial-registrations","store-country","is-tax-enabled"]),n(w_e,{countries:c(a),class:"mt-5"},null,8,["countries"])],64))])])]))}};class S_e extends ws{getTabs(){return{all:d("All"),active:d("Active"),expired:d("Inactive")}}getToggleableColumns(){return[{label:"Title",value:"title"},{label:"Stackable",value:"stackable"},{label:"Actions",value:"actions"}]}getSearchHint(){return d("Search by id, title, amount, code.")}getFetchUrl(){return"coupons"}parseResponse(t){return t.coupons}getTableName(){return"coupon_table"}getAdvanceFilterOptions(){return null}getSearchGuideOptions(){return[]}with(){return[]}}function $f(e){return S_e.init(e)}const $_e={class:"fct-table-mobile-wrap fct-coupons-table-mobile-wrap"},F_e={class:"fct-table-mobile-header"},E_e={class:"fct-table-mobile-header-left"},U_e={class:"fct-table-id-col"},I_e={class:"fct-table-status-col"},V_e=["onClick"],D_e={class:"title"},Q_e={class:"value"},T_e={key:0,class:"fct-table-action-col"},M_e={class:"more-btn pr-0"},L_e={class:"fct-table-mobile-body"},R_e=["onClick"],O_e={key:0,class:"fct-table-coupon-title-col"},P_e={class:"fct-table-coupon-code-col"},H_e=["onClick"],N_e={class:"fct-table-mobile-footer"},K_e=["onClick"],G_e={class:"fct-table-date-col grid"},z_e={class:"title"},j_e={class:"value"},q_e={key:0,class:"fct-table-stackable-col"},Y_e={class:"title"},W_e={class:"value"},X_e={class:"fct-table-amount-col"},J_e={class:"title"},Z_e={class:"value"},eve={__name:"CouponsTableMobile",props:{table:{type:Object,required:!0},emptyText:{type:String,default:d("No customers found.")}},setup(e){st.extend(fi);const t=e,a=s=>{if(!s||s==="0000-00-00 00:00:00")return!1;const i=st.utc(s).local();return i.isValid()?i.isBefore(st()):!1},l=s=>{let i=d("Are you sure you want to delete this %s coupon. This action is not recoverable",s.coupon.title);s.action==="delete"&&Pa(i,d("Confirm Delete!"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Ae.delete("coupons/"+s.coupon.id).then(A=>{q.success(A.message),t.table.fetch()}).catch(A=>{q.error(A)}).finally(()=>{})}).catch(()=>{})};return(s,i)=>{const A=k("router-link"),p=k("el-tooltip"),h=k("el-dropdown-item"),_=k("el-dropdown-menu"),y=k("el-dropdown");return r(),m("div",$_e,[(r(!0),m(P,null,ae(e.table.getTableData(),(g,v)=>(r(),m("div",{key:g.id,class:"fct-table-mobile-row"},[o("div",F_e,[o("div",E_e,[o("div",U_e,[n(A,{to:{name:"add_or_edit_coupon",params:{coupon_id:g.id}},class:"id"},{default:u(()=>[R(" #"+f(g.id),1)]),_:2},1032,["to"])]),o("div",I_e,[n(la,{status:g.status},{default:u(()=>[R(f(a(g.end_date)?c(d)("Expired"):g.status),1)]),_:2},1032,["status"]),g.status==="scheduled"?(r(),E(p,{key:0,effect:"dark",placement:"top","popper-class":"fct-label-hint-popover fct-tooltip","show-after":400,"hide-after":0},{content:u(()=>[R(f(c(d)("Available On: %s",c(Ts)(g.start_date,!0))),1)]),default:u(()=>[n(X,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):B("",!0)]),o("div",{class:"fct-table-usage-col",onClick:C=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:g.id}})},[o("div",D_e,f(c(d)("Usage:")),1),o("div",Q_e,[R(f(g.use_count??0)+" ",1),i[0]||(i[0]=o("span",null,"/",-1)),R(" "+f(g.conditions.max_uses>0?g.conditions.max_uses:c(d)("Unlimited")),1)])],8,V_e)]),e.table.isColumnVisible("actions")?(r(),m("div",T_e,[n(y,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l,placement:"bottom-end"},{dropdown:u(()=>[n(_,null,{default:u(()=>[g.id?(r(),E(h,{key:0,class:"item-link"},{default:u(()=>[n(A,{to:{name:"add_or_edit_coupon",params:{coupon_id:g.id,action:"edit"}}},{default:u(()=>[n(X,{name:"Edit"}),R(" "+f(c(d)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),n(h,{command:{action:"delete",coupon:g},class:"item-destructive"},{default:u(()=>[n(X,{name:"Delete"}),R(" "+f(c(d)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:u(()=>[o("span",M_e,[n(X,{name:"More"})])]),_:2},1024)])):B("",!0)]),o("div",L_e,[o("div",{class:"fct-table-coupon-code-wrapper-col",onClick:C=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:g.id}})},[e.table.isColumnVisible("title")?(r(),m("div",O_e,f(g.title),1)):B("",!0),o("div",P_e,[o("code",{class:"copyable-content",onClick:C=>{c(ls).copy(g.code)}},f(g.code),9,H_e)])],8,R_e)]),o("div",N_e,[o("div",{class:"fct-table-mobile-footer-row items-start",onClick:C=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:g.id}})},[o("div",G_e,[o("div",z_e,f(c(d)("Expiry Date")),1),o("div",j_e,[isNaN(Date.parse(g.end_date))?(r(),m(P,{key:1},[R("n/a")],64)):(r(),E(Sa,{key:0,"date-time":g.end_date,"with-time":!0},null,8,["date-time"]))])]),e.table.isColumnVisible("stackable")?(r(),m("div",q_e,[o("div",Y_e,f(c(d)("Stackable")),1),o("div",W_e,f(g.stackable),1)])):B("",!0),o("div",X_e,[o("div",J_e,f(c(d)("Amount")),1),o("div",Z_e,f(g.type!=="percentage"?c(zt)(g.amount,!0):g.amount+"%"),1)])],8,K_e)])]))),128))])}}},tve={},ave={class:"px-4 py-3"},lve={class:"grid grid-cols-3 gap-5 mt-5"};function sve(e,t){const a=k("el-skeleton-item"),l=k("el-skeleton");return r(),E(l,{animated:""},{template:u(()=>[o("div",ave,[(r(),m(P,null,ae(2,s=>o("div",{key:s,class:"flex items-center justify-between mb-3"},[n(a,{varient:"p",class:"w-1/2"}),n(a,{varient:"p",class:"w-[100px]"})])),64)),o("div",lve,[(r(),m(P,null,ae(3,s=>o("div",{key:s},[n(a,{varient:"p",class:"w-1/2"}),n(a,{varient:"p",class:"w-[100px]"})])),64))])])]),_:1})}const nve=nt(tve,[["render",sve]]),ove={class:"fct-all-coupons-page fct-layout-width"},ive={class:"fct-all-coupons-wrap"},rve={key:1},dve=["onClick"],uve={class:"capitalize"},cve={class:"more-btn mr-2"},Uc={__name:"AllCoupons",setup(e){st.extend(fi);const t=$f(),a=T(!1),l=A=>{let p=d("Are you sure you want to delete this %s coupon. This action is not recoverable",A.coupon.title);A.action==="delete"&&Pa(p,d("Confirm Delete!"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Ae.delete("coupons/"+A.coupon.id).then(h=>{q.success(h.message),t.fetch()}).catch(h=>{var _;h.status_code=="422"?q.validationErrors(h):q.error((_=h.data)==null?void 0:_.message)}).finally(()=>{})}).catch(()=>{})},s=()=>{Ae.get("coupons/getSettings").then(A=>{a.value=!!parseInt(A.show_on_checkout)}).catch(A=>{var p;A.status_code=="422"?q.validationErrors(A):q.error((p=A.data)==null?void 0:p.message)}).finally(()=>{})},i=A=>{if(!A||A==="0000-00-00 00:00:00")return!1;const p=st.utc(A).local();return p.isValid()?p.isBefore(st()):!1};return De(()=>{s()}),(A,p)=>{const h=k("el-button"),_=k("el-table-column"),y=k("el-tooltip"),g=k("router-link"),v=k("el-dropdown-item"),C=k("el-dropdown-menu"),w=k("el-dropdown"),b=k("el-table");return r(),E(Ot,{permission:"coupons/view"},{default:u(()=>[o("div",ove,[n(nl,{title:c(d)("Coupons")},{action:u(()=>[n(h,{tag:"router-link",type:"primary",to:{name:"add_or_edit_coupon"}},{default:u(()=>[R(f(c(d)("Add Coupon")),1)]),_:1})]),_:1},8,["title"]),o("div",ive,[n(Cs,{table:c(t),"has-mobile-slot":!0},{mobile:u(()=>[c(t).isLoading()?(r(),E(nve,{key:0})):B("",!0),c(t).isLoading()?B("",!0):(r(),E(eve,{key:1,table:c(t)},null,8,["table"]))]),default:u(()=>[c(t).isLoading()?(r(),E(ime,{key:0,couponTable:c(t),"next-page-count":c(t).nextPageCount},null,8,["couponTable","next-page-count"])):(r(),m("div",rve,[n(b,{data:c(t).getTableData(),class:"w-full compact-table full-compact"},{empty:u(()=>[n(wt,{icon:"Empty/Order","has-dark":"",text:c(d)("No coupons available at the moment.")},null,8,["text"])]),default:u(()=>[n(_,{width:100,label:c(d)("ID")},{default:u(S=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id}}},{default:u(()=>[R(" #"+f(c(ea)(S.row.id)),1)]),_:2},1032,["to"])]),_:1},8,["label"]),c(t).isColumnVisible("title")?(r(),E(_,{key:0,label:c(d)("Title"),width:220},{default:u(S=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:u(()=>[R(f(S.row.title),1)]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),n(_,{label:c(d)("Code"),width:200},{default:u(S=>[o("code",{class:"copyable-content",onClick:F=>{c(ls).copy(S.row.code)}},f(S.row.code),9,dve)]),_:1},8,["label"]),n(_,{label:c(d)("Amount"),width:120},{default:u(S=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:u(()=>[R(f(S.row.type!=="percentage"?c(zt)(S.row.amount,!0):S.row.amount+"%"),1)]),_:2},1032,["to"])]),_:1},8,["label"]),n(_,{label:c(d)("Usage"),width:150},{default:u(S=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:u(()=>[o("span",null,f(c(ea)(S.row.use_count??0)),1),p[0]||(p[0]=o("span",{class:"px-1"},"/",-1)),o("span",null,f(S.row.conditions.max_uses>0?S.row.conditions.max_uses:c(d)("Unlimited")),1)]),_:2,__:[0]},1032,["to"])]),_:1},8,["label"]),c(t).isColumnVisible("stackable")?(r(),E(_,{key:1,label:c(d)("Stackable"),width:120},{default:u(S=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:u(()=>[o("span",uve,f(S.row.stackable),1)]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),n(_,{label:c(d)("Status"),width:120},{default:u(S=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:u(()=>[n(la,{status:S.row.status},{default:u(()=>[R(f(i(S.row.end_date)?c(d)("Expired"):S.row.status),1)]),_:2},1032,["status"]),S.row.status==="scheduled"?(r(),E(y,{key:0,effect:"dark",placement:"top","popper-class":"fct-label-hint-popover fct-tooltip","show-after":400,"hide-after":0},{content:u(()=>[R(f(c(d)("Available On: %s",c(Ts)(S.row.start_date,!0))),1)]),default:u(()=>[n(X,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):B("",!0)]),_:2},1032,["to"])]),_:1},8,["label"]),n(_,{label:c(d)("Expiry Date"),width:120},{default:u(S=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:u(()=>[o("span",null,[isNaN(Date.parse(S.row.end_date))?(r(),m(P,{key:1},[R("n/a")],64)):(r(),E(Sa,{key:0,"date-time":S.row.end_date,"with-time":!0},null,8,["date-time"]))])]),_:2},1032,["to"])]),_:1},8,["label"]),c(t).isColumnVisible("actions")?(r(),E(_,{key:2,label:c(d)("Actions"),width:100,align:"right",fixed:"right"},{default:u(S=>[n(w,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l,placement:"bottom-end"},{dropdown:u(()=>[n(C,null,{default:u(()=>[S.row.id?(r(),E(v,{key:0,class:"item-link"},{default:u(()=>[n(g,{to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:u(()=>[n(X,{name:"Edit"}),R(" "+f(c(d)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),n(v,{command:{action:"delete",coupon:S.row},class:"item-destructive"},{default:u(()=>[n(X,{name:"Delete"}),R(" "+f(c(d)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:u(()=>[o("span",cve,[n(X,{name:"More"})])]),_:2},1024)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"])])])]),_:1})}}},Ave={class:"fct-add-edit-coupon-wrapper fct-layout-width"},pve={class:"single-page-header"},fve={class:"single-page-body"},mve={class:"fct-add-edit-coupon"},hve={class:"fct-add-edit-coupon-main"},_ve={class:"fct-add-edit-coupon-aside"},vve={class:"fct-admin-sidebar"},gve={__name:"SingleCouponLoader",setup(e){return(t,a)=>{const l=k("el-skeleton-item"),s=k("el-skeleton"),i=k("el-breadcrumb-item"),A=k("el-breadcrumb");return r(),m("div",Ave,[o("div",pve,[n(A,{"separator-icon":c(dl)},{default:u(()=>[n(i,null,{default:u(()=>[n(s,{animated:!0},{template:u(()=>[n(l,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),n(i,null,{default:u(()=>[n(s,{animated:!0},{template:u(()=>[n(l,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),n(i,null,{default:u(()=>[n(s,{animated:!0},{template:u(()=>[n(l,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"])]),o("div",fve,[o("div",mve,[o("div",hve,[n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Discount Value"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1})]),o("div",_ve,[o("div",vve,[n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1})])])])])])}}};st.extend(fi);st.extend(_A);const yve={name:"AddOrEditCoupon",components:{CardContainer:$e,CardHeader:Qe,CardBody:xe,LabelHint:Rt,ValidationError:Gt,CopyToClipboard:Va,DynamicTemplates:hn,SaveBar:pn,ProductVariationSelector:vA,SingleCouponLoader:gve,Activity:cA},beforeRouteLeave(e,t,a){var l;(l=this.keyboardShortcuts)!=null&&l.unbind&&this.keyboardShortcuts.unbind("mod+s"),a()},props:{coupon_id:{type:[String,Number],required:!0}},data(){return{changes_made:0,creating:!1,updating:!1,keyboardShortcuts:null,coupon:{type:"fixed",status:"active",stackable:"no",show_on_checkout:"no",title:"",code:"",priority:0,amount:0,start_date:"",end_date:"",notes:"",conditions:{buy_quantity:1,get_quantity:1,excluded_categories:[],included_categories:[],excluded_products:[],included_products:[],min_purchase_amount:"",max_purchase_amount:"",min_amount_basis:"subtotal",allowed_user_ids:[],allowed_user_roles:[],apply_to_quantity:"no",apply_to_whole_cart:"yes",max_per_customer:"",max_discount_amount:"",max_uses:"",buy_products:[],get_products:[],is_recurring:"no"}},validationErrors:{},minQuantity:1,maxQuantity:100,minPurchaseAmount:0,maxPurchaseAmount:1e4,minDiscountAmount:0,minLimit:0,maxLimit:1e3,categories:[],usageError:!1,isEndDateEnabled:!1,fetchingCoupon:!1,isInitialLoading:!1,showDynamicTemplates:!1,showManageActivity:!1}},computed:{ArrowRight(){return dl},maxDiscountAmount(){return this.coupon.type==="percentage"?100:999999}},watch:{coupon:{handler(){this.handleChangesMade()},deep:!0}},mounted(){this.keyboardShortcuts=is(),this.fetchTerms(),this.coupon_id?(this.fetchCoupon(),this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.updateCoupon()}),window.onbeforeunload=()=>{if(this.changes_made>1)return!0}):this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.addCoupon()})},methods:{translate:d,generateRandomCouponCode(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let t="";for(let a=0;a<8;a++)t+=e.charAt(Math.floor(Math.random()*e.length));this.coupon.code=t},onChangeCouponInput(e,t){if(t=parseInt(t),isNaN(t)||t===""){this.coupon[e]="";return}if(e==="priority"&&(t<0||t>100)){this.coupon[e]=0;return}if((e==="buy_quantity"||e==="get_quantity")&&(tthis.maxQuantity)){this.coupon[e]=this.minQuantity;return}if((e==="min_purchase_amount"||e==="max_discount_amount")&&(tthis.maxPurchaseAmount)){this.coupon.conditions[e]=this.minPurchaseAmount;return}if(e==="amount"){if(this.coupon.type==="fixed"&&(tthis.maxDiscountAmount)){this.coupon[e]=this.minDiscountAmount;return}if(this.coupon.type==="percentage"&&(tthis.maxDiscountAmount)){this.coupon[e]=this.minDiscountAmount;return}}if((e==="max_uses"||e==="max_per_customer")&&(tthis.maxLimit)){this.coupon[e]=this.minLimit;return}},preventInvalidChars(e,t=!1){let a=["-",".","+"];t&&(a=["-","+"]),a.includes(e.key)&&e.preventDefault()},handleChangesMade(){this.changes_made++},setDefaultStatus(){const e=new Date,t=this.coupon.start_date?new Date(this.coupon.start_date):null,a=this.coupon.end_date?new Date(this.coupon.end_date):null;this.coupon.status!=="disabled"&&(a===null&&(this.isEndDateEnabled=!1),!t&&!a?this.coupon.status="active":t&&ea?this.coupon.status="expired":this.coupon.status="active")},disabledStartDate(e){const t=new Date;return t.setHours(0,0,0,0),e&&e.getTime()parseInt(t,10)):[]},reloadPage(){return window.location.reload()},validateAndFormatDate(e){let t=this.formatDate(e);return t!==null&&t!=="Invalid date"?t:null},validateDate(){this.coupon.start_date=this.validateAndFormatDate(this.coupon.start_date),this.coupon.end_date=this.validateAndFormatDate(this.coupon.end_date)},fetchTerms(){Ae.get("products/fetch-term").then(e=>{this.categories=e.taxonomies["product-categories"].terms}).catch(e=>{var t;e.status_code=="422"?q.validationErrors(e):q.error((t=e.data)==null?void 0:t.message)}).finally(()=>{})},fetchCoupon(){this.fetchingCoupon=!0,this.isInitialLoading=!0,Ae.get(`coupons/${this.coupon_id}`,{}).then(e=>{var l,s;const t=(l=e==null?void 0:e.coupon)==null?void 0:l.start_date,a=(s=e==null?void 0:e.coupon)==null?void 0:s.end_date;t&&t!=="0000-00-00 00:00:00"&&(e.coupon.start_date=st.utc(t).tz(st.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),a&&a!=="0000-00-00 00:00:00"&&(e.coupon.end_date=st.utc(a).tz(st.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),e=e.coupon,this.coupon=e,this.coupon.start_date=this.formatDate(this.coupon.start_date),this.coupon.end_date=this.formatDate(this.coupon.end_date),this.coupon.end_date!==null&&(this.isEndDateEnabled=!0),this.coupon.end_date=this.coupon.end_date!==null&&this.coupon.end_date!=="Invalid date"?this.coupon.end_date:null,this.coupon.conditions.excluded_products=this.parseProductIds(e.conditions.excluded_products),this.coupon.conditions.included_products=this.parseProductIds(e.conditions.included_products),this.coupon.conditions.min_amount_basis||(this.coupon.conditions.min_amount_basis="total"),this.formatAmount(),this.setDefaultStatus(),this.showDynamicTemplates=!0}).catch(e=>{var t;errors.status_code=="422"?q.validationErrors(errors):q.error((t=errors.data)==null?void 0:t.message)}).finally(()=>{this.fetchingCoupon=!1,this.isInitialLoading=!1,this.changes_made=0})},updateCoupon(){var e,t;this.updating=!0,this.validateDate(),(e=this.$refs.dynamic_templates)==null||e.beforeUpdatingData({data:{coupon:this.coupon}}),Ae.put(`coupons/${this.coupon_id}`,{...this.coupon,metaValue:(t=this.$refs.dynamic_templates)==null?void 0:t.getFormStates()}).then(a=>{var l;(l=this.$refs.dynamic_templates)==null||l.afterUpdatingData({coupon:this.coupon,response:a}),q.success(a.message),this.validationErrors={},this.setDefaultStatus(),this.changes_made=0}).catch(a=>{var l;a.status_code=="422"?(q.validationErrors(a),this.validationErrors=a):q.error((l=a.data)==null?void 0:l.message)}).finally(()=>{this.updating=!1,this.changes_made=0})},addCoupon(){var e,t;this.creating=!0,this.validateDate(),(e=this.$refs.dynamic_templates)==null||e.beforeUpdatingData({data:{coupon:this.coupon}}),Ae.post("coupons",{...this.coupon,metaValue:(t=this.$refs.dynamic_templates)==null?void 0:t.getFormStates()}).then(a=>{var l;(l=this.$refs.dynamic_templates)==null||l.afterUpdatingData({coupon:this.coupon,response:a}),q.success(a.message),this.$router.push({name:"coupons"}),this.validationErrors={}}).catch(a=>{var l;a.status_code=="422"?(q.validationErrors(a),this.validationErrors=a):q.error((l=a.data)==null?void 0:l.message)}).finally(()=>{this.creating=!1})}}},bve={class:"fct-add-edit-coupon-wrapper fct-layout-width"},wve={class:"single-page-header"},Cve={class:"single-page-body"},kve={class:"fct-add-edit-coupon"},Bve={class:"fct-add-edit-coupon-main"},xve={class:"flex gap-2 items-center justify-between w-full mb-2.5"},Sve={class:"form-note"},$ve=["innerHTML"],Fve={key:1},Eve=["innerHTML"],Uve=["innerHTML"],Ive=["innerHTML"],Vve={class:"fct-add-edit-coupon-aside"},Dve={class:"fct-admin-sidebar"},Qve={class:"fct-admin-sidebar-item"},Tve={key:0,class:"flex items-center gap-1"},Mve={class:"text-sm font-medium text-system-dark dark:text-gray-300"},Lve={key:1},Rve={class:"fct-admin-sidebar-item mt-5 hidden"},Ove={class:"sidebar-title mb-3"},Pve={class:"fct-bullet-lists"},Hve={class:"fct-admin-sidebar-item mt-5 hidden"},Nve={class:"sidebar-title mb-3"},Kve={class:"fct-bullet-lists"},Gve={key:0};function zve(e,t,a,l,s,i){const A=k("SaveBar"),p=k("SingleCouponLoader"),h=k("el-breadcrumb-item"),_=k("el-breadcrumb"),y=k("CardHeader"),g=k("el-input"),v=k("ValidationError"),C=k("el-form-item"),w=k("el-col"),b=k("LabelHint"),S=k("el-row"),F=k("CardBody"),Q=k("CardContainer"),$=k("el-option"),x=k("el-select"),I=k("el-radio"),V=k("el-radio-group"),D=k("ProductVariationSelector"),U=k("el-checkbox"),L=k("el-form"),O=k("CopyToClipboard"),M=k("el-date-picker"),H=k("DynamicTemplates"),j=k("Activity");return r(),m("div",bve,[n(A,{isActive:s.changes_made>0?"is-active":"",loading:a.coupon_id?s.updating:s.creating,onSave:t[0]||(t[0]=W=>a.coupon_id?i.updateCoupon():i.addCoupon()),onDiscard:i.reloadPage,"show-cmnd-icon":!0,saveButtonText:a.coupon_id?i.translate("Update"):i.translate("Create")},null,8,["isActive","loading","onDiscard","saveButtonText"]),s.fetchingCoupon?(r(),E(p,{key:0})):B("",!0),s.fetchingCoupon?B("",!0):(r(),m(P,{key:1},[o("div",wve,[n(_,{"separator-icon":i.ArrowRight},{default:u(()=>[n(h,{to:{name:"coupons"}},{default:u(()=>[R(f(i.translate("Coupons")),1)]),_:1}),n(h,null,{default:u(()=>[R(f(a.coupon_id?i.translate("Edit Coupon"):i.translate("Add Coupon")),1)]),_:1}),a.coupon_id?(r(),E(h,{key:0},{default:u(()=>[R(f(s.coupon.title),1)]),_:1})):B("",!0)]),_:1},8,["separator-icon"])]),o("div",Cve,[o("div",kve,[o("div",Bve,[n(L,{model:s.coupon,"label-position":"top","require-asterisk-position":"right"},{default:u(()=>[n(Q,null,{default:u(()=>[n(y,{title:i.translate("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(S,{gutter:20},{default:u(()=>[n(w,{lg:24},{default:u(()=>[n(C,{label:i.translate("Title"),required:""},{default:u(()=>{var W,G;return[n(g,{modelValue:s.coupon.title,"onUpdate:modelValue":t[1]||(t[1]=Y=>s.coupon.title=Y),placeholder:i.translate("Enter title"),class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("title")?"is-error":""),maxlength:"50",id:"title"},null,8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("title")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"title"},null,8,["validation-errors"])):B("",!0)]}),_:1},8,["label"])]),_:1}),n(w,{lg:12},{default:u(()=>[n(C,null,{default:u(()=>{var W,G;return[o("div",xve,[n(b,{title:i.translate("Code"),required:""},null,8,["title"]),o("span",{class:"text-system-dark text-xs cursor-pointer hover:underline dark:text-gray-50 underline",onClick:t[2]||(t[2]=(...Y)=>i.generateRandomCouponCode&&i.generateRandomCouponCode(...Y))},f(i.translate("Generate Random Code")),1)]),n(g,{modelValue:s.coupon.code,"onUpdate:modelValue":t[3]||(t[3]=Y=>s.coupon.code=Y),placeholder:i.translate("Eg. COUPON10"),class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("code")?"is-error":""),maxlength:"20"},null,8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("code")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"code"},null,8,["validation-errors"])):B("",!0),o("div",Sve,[o("p",null,f(i.translate("Customers must enter this code at checkout.")),1)])]}),_:1})]),_:1}),n(w,{lg:12},{default:u(()=>[n(C,null,{label:u(()=>[n(b,{title:i.translate("Coupon Priority"),content:i.translate("Coupons will be calculated based on their priority. The lower the number the higher the priority is.")},null,8,["title","content"])]),default:u(()=>{var W,G;return[n(g,{modelValue:s.coupon.priority,"onUpdate:modelValue":t[4]||(t[4]=Y=>s.coupon.priority=Y),type:"number",placeholder:i.translate("Enter priority"),class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("priority")?"is-error":""),min:"0",max:"100",onInput:t[5]||(t[5]=Y=>{i.onChangeCouponInput("priority",Y)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","onKeypress"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("priority")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"priority"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(y,{title:i.translate("Discount Details"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(S,{gutter:20},{default:u(()=>[n(w,{lg:8},{default:u(()=>[n(C,{label:i.translate("Type"),required:""},{default:u(()=>{var W;return[n(x,{modelValue:s.coupon.type,"onUpdate:modelValue":t[6]||(t[6]=G=>s.coupon.type=G),placeholder:i.translate("Select coupon type"),class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("type")?"is-error":""),"default-first-option":""},{default:u(()=>[n($,{label:i.translate("Fixed"),value:"fixed"},null,8,["label"]),n($,{label:i.translate("Percentage"),value:"percentage"},null,8,["label"])]),_:1},8,["modelValue","placeholder","class"])]}),_:1},8,["label"])]),_:1}),s.coupon.type==="fixed"||s.coupon.type==="percentage"?(r(),m(P,{key:0},[n(w,{lg:8},{default:u(()=>[n(C,{label:s.coupon.type==="percentage"?i.translate("Discount Percentage (%)"):i.translate("Discount Amount"),required:""},{default:u(()=>{var W;return[n(g,{modelValue:s.coupon.amount,"onUpdate:modelValue":t[7]||(t[7]=G=>s.coupon.amount=G),type:"number",placeholder:"0.00",min:s.minDiscountAmount,max:i.maxDiscountAmount,step:"0.01",onInput:t[8]||(t[8]=G=>{i.onChangeCouponInput("amount",G)}),onKeypress:t[9]||(t[9]=G=>i.preventInvalidChars(G,!0))},{prefix:u(()=>[s.coupon.type==="fixed"?(r(),m("span",{key:0,innerHTML:e.appVars.shop.currency_sign},null,8,$ve)):(r(),m("span",Fve,"%"))]),_:1},8,["modelValue","min","max"]),(W=s.validationErrors)!=null&&W.hasOwnProperty("amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"amount"},null,8,["validation-errors"])):B("",!0)]}),_:1},8,["label"])]),_:1}),s.coupon.type==="percentage"?(r(),E(w,{key:0,lg:8},{default:u(()=>[n(C,{label:i.translate("Max Discount Amount")},{default:u(()=>{var W;return[n(g,{modelValue:s.coupon.conditions.max_discount_amount,"onUpdate:modelValue":t[10]||(t[10]=G=>s.coupon.conditions.max_discount_amount=G),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("max_discount_amount")?"is-error":"")},{prefix:u(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Eve)]),_:1},8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_discount_amount"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1})):B("",!0)],64)):B("",!0)]),_:1})]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(y,{title:i.translate("Usage Restrictions"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(S,{gutter:20},{default:u(()=>[n(w,{lg:12},{default:u(()=>[n(C,null,{label:u(()=>[n(b,{title:i.translate("Min Spend Amount"),content:i.translate("Minimum spend (subtotal) allowed to use the coupon.")},null,8,["title","content"])]),default:u(()=>{var W,G;return[n(g,{modelValue:s.coupon.conditions.min_purchase_amount,"onUpdate:modelValue":t[11]||(t[11]=Y=>s.coupon.conditions.min_purchase_amount=Y),type:"number",placeholder:"0.00",class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("min_purchase_amount")?"is-error":"")},{prefix:u(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Uve)]),_:1},8,["modelValue","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("min_purchase_amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"min_purchase_amount"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(w,{lg:12},{default:u(()=>[n(C,null,{label:u(()=>[n(b,{title:i.translate("Max Spend Amount"),content:i.translate("Set the maximum spend (subtotal) allowed when using the coupon.")},null,8,["title","content"])]),default:u(()=>{var W,G;return[n(g,{modelValue:s.coupon.conditions.max_purchase_amount,"onUpdate:modelValue":t[12]||(t[12]=Y=>s.coupon.conditions.max_purchase_amount=Y),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("max_purchase_amount")?"is-error":"")},{prefix:u(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Ive)]),_:1},8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("max_purchase_amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_purchase_amount"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(w,{lg:24},{default:u(()=>[n(C,null,{label:u(()=>[n(b,{title:i.translate("Spend Amount Based On"),content:i.translate("Choose what the min/max spend limits are measured against: the cart subtotal (items only) or the order total (including shipping and fees). Applies at checkout.")},null,8,["title","content"])]),default:u(()=>[n(V,{modelValue:s.coupon.conditions.min_amount_basis,"onUpdate:modelValue":t[13]||(t[13]=W=>s.coupon.conditions.min_amount_basis=W)},{default:u(()=>[n(I,{value:"subtotal",label:i.translate("Subtotal (items only)")},null,8,["label"]),n(I,{value:"total",label:i.translate("Total (includes shipping & fees)")},null,8,["label"])]),_:1},8,["modelValue"])]),_:1})]),_:1}),n(w,{md:12},{default:u(()=>[n(C,{label:i.translate("Include Categories")},{default:u(()=>[n(x,{modelValue:s.coupon.conditions.included_categories,"onUpdate:modelValue":t[14]||(t[14]=W=>s.coupon.conditions.included_categories=W),multiple:"",placeholder:i.translate("Any Category"),filterable:"",remote:"","reserve-keyword":!1},{default:u(()=>[(r(!0),m(P,null,ae(s.categories,W=>(r(),E($,{key:W.value,label:W.label,value:W.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(w,{md:12},{default:u(()=>[n(C,{label:i.translate("Exclude Categories")},{default:u(()=>[n(x,{modelValue:s.coupon.conditions.excluded_categories,"onUpdate:modelValue":t[15]||(t[15]=W=>s.coupon.conditions.excluded_categories=W),multiple:"",placeholder:i.translate("No Categories"),filterable:"",remote:"","reserve-keyword":!1},{default:u(()=>[(r(!0),m(P,null,ae(s.categories,W=>(r(),E($,{key:W.value,label:W.label,value:W.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(w,{md:24},{default:u(()=>[n(C,{label:i.translate("Include Products")},{default:u(()=>[n(D,{modelValue:s.coupon.conditions.included_products,"onUpdate:modelValue":t[16]||(t[16]=W=>s.coupon.conditions.included_products=W)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(w,{md:24},{default:u(()=>[n(C,{label:i.translate("Excluded Products")},{default:u(()=>[n(D,{modelValue:s.coupon.conditions.excluded_products,"onUpdate:modelValue":t[17]||(t[17]=W=>s.coupon.conditions.excluded_products=W)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(w,{md:24},{default:u(()=>[n(C,null,{label:u(()=>[n(b,{title:i.translate("By Email Address"),content:i.translate("List of email addresses that can use the coupon. Separate multiple emails with commas. You may also use regular expressions.")},null,8,["title","content"])]),default:u(()=>{var W;return[n(g,{autocomplete:"off",modelValue:s.coupon.conditions.email_restrictions,"onUpdate:modelValue":t[18]||(t[18]=G=>s.coupon.conditions.email_restrictions=G),type:"text",placeholder:i.translate("email1@domain.com, *@special.com, ... or regex pattern")},null,8,["modelValue","placeholder"]),(W=s.validationErrors)!=null&&W.hasOwnProperty("email_restrictions")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"email_restrictions"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(w,{md:24},{default:u(()=>{var W;return[n(C,null,{label:u(()=>[n(b,{title:i.translate("Recurring Coupon"),content:i.translate("Mark this coupon as recurring to apply it automatically to every future subscription order. This discount will automatically apply on every renewal. However, the coupon will not be applied if it reduces the payable amount to zero.")},null,8,["title","content"])]),default:u(()=>[n(U,{modelValue:s.coupon.conditions.is_recurring,"onUpdate:modelValue":t[19]||(t[19]=G=>s.coupon.conditions.is_recurring=G),label:i.translate("Make this coupon recurring"),"true-value":"yes","false-value":"no"},null,8,["modelValue","label"])]),_:1}),(W=s.validationErrors)!=null&&W.hasOwnProperty("is_recurring")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"is_recurring"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(y,{title:i.translate("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(S,{gutter:20},{default:u(()=>[n(w,{lg:12},{default:u(()=>[n(C,null,{label:u(()=>[n(b,{title:i.translate("Total Limit"),content:i.translate("Total number of times this coupon can be redeemed across the entire store.")},null,8,["title","content"])]),default:u(()=>{var W,G;return[n(g,{modelValue:s.coupon.conditions.max_uses,"onUpdate:modelValue":t[20]||(t[20]=Y=>s.coupon.conditions.max_uses=Y),type:"number",placeholder:i.translate("Total limit"),class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("max_uses")?"is-error":s.usageError),min:s.minLimit,max:s.maxLimit,onInput:t[21]||(t[21]=Y=>{i.onChangeCouponInput("max_uses",Y)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("max_uses")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_uses"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(w,{lg:12},{default:u(()=>[n(C,null,{label:u(()=>[n(b,{title:i.translate("Per Logged in User Limit"),content:i.translate("Maximum an logged in user can use. 0 means unlimited. Only logged in user can use this coupon.")},null,8,["title","content"])]),default:u(()=>[n(g,{modelValue:s.coupon.conditions.max_per_customer,"onUpdate:modelValue":t[22]||(t[22]=W=>s.coupon.conditions.max_per_customer=W),type:"number",placeholder:i.translate("Max limit per logged in user"),class:ue(s.validationErrors.hasOwnProperty("max_per_customer")?"is-error":""),min:s.minLimit,max:s.maxLimit,onInput:t[23]||(t[23]=W=>{i.onChangeCouponInput("max_per_customer",W)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_per_customer"},null,8,["validation-errors"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(y,{title:i.translate("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(S,{gutter:20},{default:u(()=>[n(w,{lg:24},{default:u(()=>[n(C,{label:i.translate("Status")},{default:u(()=>[n(V,{modelValue:s.coupon.status,"onUpdate:modelValue":t[24]||(t[24]=W=>s.coupon.status=W)},{default:u(()=>[n(I,{value:"active",label:i.translate("Active")},null,8,["label"]),n(I,{value:"disabled",label:i.translate("Disabled")},null,8,["label"]),n(I,{disabled:"",value:"expired",label:i.translate("Expired")},null,8,["label"])]),_:1},8,["modelValue"]),n(v,{"validation-errors":s.validationErrors,"field-key":"status"},null,8,["validation-errors"])]),_:1},8,["label"])]),_:1}),n(w,{lg:24},{default:u(()=>[n(C,{label:i.translate("Internal Notes")},{default:u(()=>{var W;return[n(g,{modelValue:s.coupon.notes,"onUpdate:modelValue":t[25]||(t[25]=G=>s.coupon.notes=G),type:"textarea",placeholder:i.translate("Enter note"),class:ue((W=s.validationErrors)!=null&&W.hasOwnProperty("notes")?"is-error":"")},null,8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"notes"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1}),n(w,{lg:24},{default:u(()=>{var W;return[n(C,null,{label:u(()=>[n(b,{title:i.translate("Stackable"),content:i.translate("Yes means the coupon can be applied with other coupons")},null,8,["title","content"])]),default:u(()=>[n(V,{modelValue:s.coupon.stackable,"onUpdate:modelValue":t[26]||(t[26]=G=>s.coupon.stackable=G)},{default:u(()=>[n(I,{value:"yes"},{default:u(()=>[R(f(i.translate("Yes")),1)]),_:1}),n(I,{value:"no"},{default:u(()=>[R(f(i.translate("No")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1}),(W=s.validationErrors)!=null&&W.hasOwnProperty("stackable")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"stackable"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),o("div",Vve,[o("div",Dve,[n(Q,null,{default:u(()=>[n(y,{title:i.translate("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,null,{default:u(()=>[o("div",Qve,[s.coupon.code?(r(),m("div",Tve,[o("span",Mve,f(i.translate("Coupon code"))+": "+f(s.coupon.code),1),n(O,{text:s.coupon.code,showMode:"basic_copy_btn",tooltipText:i.translate("Copy discount code")},null,8,["text","tooltipText"])])):(r(),m("div",Lve,f(i.translate("No discount code yet")),1))]),o("div",Rve,[o("h4",Ove,f(i.translate("Type & Method")),1),o("ul",Pve,[o("li",null,[o("span",null,f(i.translate("Amount off Products")),1)]),o("li",null,[o("span",null,f(i.translate("Code")),1)])])]),o("div",Hve,[o("h4",Nve,f(i.translate("Details")),1),o("ul",Kve,[o("li",null,[o("span",null,f(i.translate("For Online Store")),1)]),o("li",null,[o("span",null,f(i.translate("No Min Purchase Requirement")),1)]),o("li",null,[o("span",null,f(i.translate("All Customers")),1)])])])]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(y,{title:i.translate("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(L,{"label-position":"top"},{default:u(()=>[n(S,{gutter:20},{default:u(()=>[n(w,{lg:24},{default:u(()=>[n(C,{label:i.translate("Start Date & Time")},{default:u(()=>[n(M,{modelValue:s.coupon.start_date,"onUpdate:modelValue":t[27]||(t[27]=W=>s.coupon.start_date=W),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:i.translate("Start date & time"),onChange:i.setDefaultStatus,"disabled-date":i.disabledStartDate},null,8,["modelValue","placeholder","onChange","disabled-date"])]),_:1},8,["label"])]),_:1}),n(w,{lg:24},{default:u(()=>[n(C,null,{default:u(()=>[n(U,{modelValue:s.isEndDateEnabled,"onUpdate:modelValue":t[28]||(t[28]=W=>s.isEndDateEnabled=W),label:i.translate("Set end date & time"),onChange:t[29]||(t[29]=W=>{W||(s.coupon.end_date=null)})},null,8,["modelValue","label"])]),_:1})]),_:1}),s.isEndDateEnabled?(r(),E(w,{key:0,lg:24},{default:u(()=>[n(C,{label:i.translate("End Date & Time")},{default:u(()=>[n(M,{modelValue:s.coupon.end_date,"onUpdate:modelValue":t[30]||(t[30]=W=>s.coupon.end_date=W),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:i.translate("End date & time"),onChange:i.setDefaultStatus,"disabled-date":i.disabledEndDate},null,8,["modelValue","placeholder","onChange","disabled-date"]),s.validationErrors.hasOwnProperty("end_date")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"end_date"},null,8,["validation-errors"])):B("",!0)]),_:1},8,["label"])]),_:1})):B("",!0)]),_:1})]),_:1})]),_:1})]),_:1})]),s.showDynamicTemplates?(r(),m("div",Gve,[n(H,{filter:"fluent_cart_single_coupon_page",ref:"dynamic_templates",data:{coupon:s.coupon},widgetsQuery:{coupon_id:s.coupon.id},onChange:i.handleChangesMade},null,8,["data","widgetsQuery","onChange"])])):B("",!0),n(Q,null,{default:u(()=>[n(y,{title:i.translate("Activity"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,null,{default:u(()=>[n(j,{onReload:i.fetchCoupon,activities:s.coupon.activities||[],showManageActivity:s.showManageActivity},null,8,["onReload","activities","showManageActivity"])]),_:1})]),_:1})])])])],64))])}const jve=nt(yve,[["render",zve]]),qve={class:"fct-reviews-route-wrap"},Yve=Object.assign({name:"ReviewsRoute"},{__name:"ReviewsRoute",setup(e){const t=Na();return(a,l)=>{const s=k("router-view");return r(),m("div",qve,[(r(),E(s,{key:c(t).query.post_id||"default"}))])}}});class Wve extends ws{constructor(t={}){super(t),this.data.postId=t.postId||null}buildQueryParams(){const t=super.buildQueryParams();return this.data.postId&&(t.post_id=this.data.postId),t}getPostId(){return this.data.postId}shouldDisableFilters(){return!!this.data.postId}isUsingSimpleFilter(){return super.isUsingSimpleFilter()&&!this.shouldDisableFilters()}isAdvanceFilterEnabled(){return super.isAdvanceFilterEnabled()&&!this.shouldDisableFilters()}setupInitialData(){super.setupInitialData(),this.shouldDisableFilters()&&(this.data.filterType="simple",this.data.searching=!1,this.data.search="",this.data.advanceFilters=[[]],this.data.activeSavedViewId&&(this.data.activeSavedViewId=null,this.data.savedViewQueryParams=null,this.data.selectedView=this.getDefaultView(),Tt.set(this.getTabStorageName(),this.getDefaultView()),Ms.pushToVueUrl(null,{active_view:this.getDefaultView()})))}getSavedViews(){return this.shouldDisableFilters()?[]:super.getSavedViews()}applySavedView(t){this.shouldDisableFilters()||super.applySavedView(t)}getTabs(){return{all:d("All"),approved:d("Approved"),pending:d("Pending"),spam:d("Spam"),trash:d("Trash")}}getToggleableColumns(){return[{label:d("Reviewer"),value:"reviewer"},{label:d("Rating"),value:"rating"},{label:d("Content"),value:"content"},{label:d("Status"),value:"status"},{label:d("Date"),value:"date"},{label:d("Actions"),value:"actions"}]}getSortableColumns(){return[{label:d("ID"),value:"id"},{label:d("Rating"),value:"rating"},{label:d("Reviewer"),value:"reviewer_name"},{label:d("Created At"),value:"created_at"}]}getSearchHint(){return d("Search by title, content, reviewer name, email or product name.")}getFetchUrl(){return"reviews"}parseResponse(t){return t.reviews}getTableName(){return"review_table"}with(){return["product","customer"]}}function Xve(e){return Wve.init(e)}const Jve={class:"table-cell"},Zve={class:"table-cell"},ege={class:"table-cell"},tge={class:"table-cell"},age={class:"table-cell"},lge={class:"table-cell"},sge={class:"table-cell"},nge={__name:"ReviewsLoader",props:{nextPageCount:{type:Number,default:0},reviewTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(l,s)=>s+1);return(l,s)=>{const i=k("el-skeleton-item"),A=k("el-skeleton"),p=k("el-table-column"),h=k("el-table");return r(),E(h,{data:c(a),class:"w-full compact-table"},{default:u(()=>[n(p,{label:c(d)("ID"),width:"300"},{default:u(()=>[o("div",Jve,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"]),e.reviewTable.isColumnVisible("reviewer")?(r(),E(p,{key:0,label:c(d)("Reviewer"),width:220},{default:u(()=>[o("div",Zve,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("rating")?(r(),E(p,{key:1,label:c(d)("Rating"),width:120},{default:u(()=>[o("div",ege,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("content")?(r(),E(p,{key:2,label:c(d)("Review"),"min-width":200},{default:u(()=>[o("div",tge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("status")?(r(),E(p,{key:3,label:c(d)("Status"),width:120},{default:u(()=>[o("div",age,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("date")?(r(),E(p,{key:4,label:c(d)("Date"),width:140},{default:u(()=>[o("div",lge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("actions")?(r(),E(p,{key:5,label:c(d)("Actions"),width:90},{default:u(()=>[o("div",sge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},oge={class:"fct-table-mobile-wrap fct-reviews-table-mobile-wrap"},ige={class:"fct-table-mobile-header"},rge={class:"fct-table-date-col"},dge=["title"],uge={class:"fct-table-mobile-body"},cge={key:0,class:"mb-1 text-sm font-medium"},Age={key:1,class:"mb-1 text-xs text-gray-500"},pge={key:2,class:"mb-1"},fge={key:3,class:"text-sm text-gray-600 truncate"},mge={key:0,class:"font-medium"},hge={class:"fct-table-mobile-footer"},_ge={class:"fct-table-mobile-footer-row"},vge={key:0,class:"fct-table-status-col"},gge={class:"title"},yge={class:"value text-sm"},bge={key:1,class:"fct-table-status-col"},wge={class:"title"},Cge={key:2,class:"fct-table-actions-col"},kge={class:"title"},Bge={__name:"ReviewsTableMobile",props:{table:{type:Object}},setup(e){return(t,a)=>{const l=k("router-link");return r(),m("div",oge,[(r(!0),m(P,null,ae(e.table.getTableData(),s=>(r(),m("div",{key:s.id,class:"fct-table-mobile-row"},[o("div",ige,[o("div",rge,[o("div",{title:c(d)("Review ID: %s",s.id),class:"invoice-no"}," #"+f(s.id),9,dge),e.table.isColumnVisible("date")?(r(),m(P,{key:0},[a[0]||(a[0]=o("span",{class:"bullet"},"•",-1)),n(Sa,{class:"date","date-time":s.created_at,"with-time":!0},null,8,["date-time"])],64)):B("",!0)])]),o("div",uge,[s.product?(r(),m("div",cge,f(s.product.post_title),1)):B("",!0),s.item_label?(r(),m("div",Age,f(s.item_label),1)):B("",!0),e.table.isColumnVisible("rating")?(r(),m("div",pge,[n(Vi,{rating:s.rating,size:"small"},null,8,["rating"])])):B("",!0),e.table.isColumnVisible("content")?(r(),m("div",fge,[s.title?(r(),m("span",mge,f(s.title)+" — ",1)):B("",!0),R(" "+f(s.content),1)])):B("",!0)]),o("div",hge,[o("div",_ge,[e.table.isColumnVisible("reviewer")?(r(),m("div",vge,[o("div",gge,f(c(d)("Reviewer")),1),o("div",yge,f(s.reviewer_name),1)])):B("",!0),e.table.isColumnVisible("status")?(r(),m("div",bge,[o("div",wge,f(c(d)("Status")),1),(r(),E(la,{status:s.status,size:"small",key:s.id},null,8,["status"]))])):B("",!0),e.table.isColumnVisible("actions")?(r(),m("div",Cge,[o("div",kge,f(c(d)("Actions")),1),n(l,{class:"value text-primary text-sm",to:{name:"view_review",params:{review_id:s.id}},"aria-label":c(d)("View review #%1$s",s.id)},{default:u(()=>[R(f(c(d)("View")),1)]),_:2},1032,["to","aria-label"])])):B("",!0)])])]))),128))])}}},xge={},Sge={class:"fct-table-mobile-wrap"};function $ge(e,t){const a=k("el-skeleton");return r(),m("div",Sge,[(r(),m(P,null,ae(5,l=>o("div",{key:l,class:"fct-table-mobile-row"},[n(a,{animated:"",rows:3})])),64))])}const Fge=nt(xge,[["render",$ge]]),Ege=["aria-label"],Uge=["aria-checked","aria-label","tabindex","disabled","onClick","onMouseenter","onFocus"],Ige={__name:"StarRatingInput",props:{modelValue:{type:Number,default:0},size:{type:String,default:"medium",validator:e=>["small","medium","large"].includes(e)},label:{type:String,default:()=>d("Rating")},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e,{emit:t}){const a=e,l=t,s=T(0),i=T([]),A=w=>{a.disabled||l("update:modelValue",w)},p=w=>{const b=w===a.modelValue;A(b?0:w),b&&(s.value=0)},h=w=>{if(a.disabled)return;const b=Math.min(5,Math.max(1,(a.modelValue||0)+w));A(b),s.value=b,Fe(()=>{var S;return(S=i.value[b-1])==null?void 0:S.focus()})},_=w=>d("Rate %1$s out of 5 stars",w),y={1:d("Poor"),2:d("Average"),3:d("Good"),4:d("Very Good"),5:d("Excellent")},g={1:"danger",2:"warning",3:"info",4:"success",5:"success"},v=w=>y[w]||"",C=w=>g[w]||"none";return(w,b)=>(r(),m("div",{class:ue(["fct-star-rating-input",`fct-star-rating-input-${e.size}`])},[o("div",{class:"fct-star-rating-input__stars",role:"radiogroup","aria-label":e.label},[(r(),m(P,null,ae(5,S=>o("button",{key:S,ref_for:!0,ref:F=>i.value[S-1]=F,type:"button",role:"radio",class:ue(["fct-star-rating-input__star",{"is-filled":S<=(s.value||e.modelValue),"is-selected":S<=e.modelValue}]),"aria-checked":e.modelValue===S,"aria-label":_(S),tabindex:e.modelValue===S||!e.modelValue&&S===1?0:-1,disabled:e.disabled,onClick:F=>p(S),onMouseenter:F=>s.value=S,onMouseleave:b[0]||(b[0]=F=>s.value=0),onFocus:F=>s.value=S,onBlur:b[1]||(b[1]=F=>s.value=0),onKeydown:[b[2]||(b[2]=da(Ge(F=>h(-1),["prevent"]),["left"])),b[3]||(b[3]=da(Ge(F=>h(1),["prevent"]),["right"])),b[4]||(b[4]=da(Ge(F=>h(1),["prevent"]),["up"])),b[5]||(b[5]=da(Ge(F=>h(-1),["prevent"]),["down"]))]},b[6]||(b[6]=[o("svg",{class:"fct-star-rating-input__svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",focusable:"false"},[o("path",{d:"M12 2.25l2.955 6.377 6.98.638-5.268 4.62 1.558 6.865L12 17.155 5.775 20.75l1.558-6.865-5.268-4.62 6.98-.638L12 2.25z"})],-1)]),42,Uge)),64))],8,Ege),s.value||e.modelValue?(r(),m("span",{key:0,class:ue(["fct-star-rating-input__badge",`is-${C(s.value||e.modelValue)}`]),"aria-hidden":"true"},f(v(s.value||e.modelValue)),3)):B("",!0)],2))}},Vge=["onKeydown"],Dge={key:0,class:"fct-add-review-field"},Qge={class:"fct-add-review-label",for:"fct_add_review_product"},Tge={key:1,class:"fct-add-review-field"},Mge={class:"fct-add-review-label",for:"fct_add_review_variation"},Lge={key:2,class:"fct-add-review-field"},Rge={class:"fct-add-review-label"},Oge={key:0,class:"fct-add-review-required"},Pge={class:"fct-add-review-field"},Hge={class:"fct-add-review-label",for:"fct_add_review_title"},Nge={class:"fct-add-review-field"},Kge={class:"fct-add-review-label",for:"fct_add_review_content"},Gge={class:"fct-add-review-row"},zge={class:"fct-add-review-field"},jge={class:"fct-add-review-label",for:"fct_add_review_name"},qge={class:"fct-add-review-field"},Yge={class:"fct-add-review-label",for:"fct_add_review_email"},Wge={class:"fct-add-review-field"},Xge={class:"fct-add-review-label",for:"fct_add_review_status"},Jge={key:0,class:"fct-add-review-field fct-add-review-field-inline"},Zge={class:"fct-add-review-switch"},e1e={class:"fct-add-review-label"},t1e={key:3,class:"fct-add-review-field"},a1e={class:"fct-add-review-label"},l1e={key:0,class:"fct-add-review-media"},s1e=["src","alt"],n1e=["aria-label","onClick"],o1e={key:0,class:"fct-add-review-media-item is-add"},i1e=["aria-label"],r1e={class:"fct-add-review-hint"},d1e=["accept"],u1e={key:1,class:"fct-add-review-locked"},c1e={class:"fct-add-review-hint"},A1e=["href"],p1e={__name:"AddReviewModal",props:{modelValue:{type:Boolean,default:!1},productId:{type:Number,default:null}},emits:["update:modelValue","created","update:saving"],setup(e,{emit:t}){const a=e,l=t,s=K({get:()=>a.modelValue,set:Ee=>l("update:modelValue",Ee)}),i=je.get("modules_settings.reviews")||{},A=i.enable_star_rating==="yes",p=A&&i.star_rating_required==="yes",h=i.show_verified_badge===void 0||i.show_verified_badge==="yes",_=i.enable_photo_reviews==="yes",y=()=>({post_id:a.productId||null,item_id:null,rating:0,title:"",content:"",reviewer_name:"",reviewer_email:"",status:"approved",is_verified:!1,media:[]}),g=T(y()),v=T(!1),C=T(null),w=T({}),b=Ee=>Object.prototype.hasOwnProperty.call(w.value,Ee),S=Ee=>{Object.prototype.hasOwnProperty.call(w.value,Ee)&&delete w.value[Ee]},F=()=>{const Ee=C.value;if(!Ee)return;const fe=Ee.querySelector("#fct_add_review_product"),Ve=(fe?fe.matches("input")?fe:fe.querySelector("input"):null)||Ee.querySelector('.fct-star-rating-input__star[tabindex="0"]')||Ee.querySelector("#fct_add_review_title");Ve&&Ve.focus()};ke(v,Ee=>l("update:saving",Ee));const Q=Ee=>String(Ee.id),$=(Ee,fe)=>`${Ee.id}:${fe.id}`,x=T([]),I=T(!1),V=T(null),D=je.get("review_media")||null,U=!!(D&&D.enabled&&_),L=Number(D==null?void 0:D.max_photos)||0,O=Number(D==null?void 0:D.max_size_mb)||0,M=String((D==null?void 0:D.accept)||"").split(",").map(Ee=>Ee.trim()).filter(Boolean),H=Mo("review_attachments","reviews"),j=!!je.get("app_config.isProActive"),W=j?d("Update FluentCart Pro to attach photos to a review"):d("Reviews with photos are available in FluentCart Pro"),G=()=>{S("post_id"),S("item_id")},Y=Ee=>{const[fe,ye]=String(Ee).split(":");g.value.post_id=Number(fe),g.value.item_id=ye?Number(ye):null},J=T([]);let de=null,z=0,ce=null;const oe=()=>{ce&&(ce.abort(),ce=null)},Z=(Ee,fe)=>{const ye=typeof AbortController<"u"?new AbortController:null;return ce=ye,Ae.get("advance_filter/get-filter-options",{remote_data_key:"review_products",limit:20,...Ee},null,ye?{signal:ye.signal}:{}).then(Ve=>{var Le;return fe!==z?null:(((Le=Ve.options)==null?void 0:Le.data)||[]).map(At=>({id:Number(At.id),title:At.title,variations:(At.variations||[]).map(mt=>({id:Number(mt.id),title:mt.title}))}))})},N=Ee=>{clearTimeout(de);const fe=++z;if(oe(),!Ee){x.value=[],I.value=!1;return}I.value=!0,de=setTimeout(()=>{Z({search:Ee},fe).then(ye=>{ye!==null&&(x.value=ye)}).catch(ye=>{var Ve;fe===z&&(x.value=[],q.error(((Ve=ye==null?void 0:ye.data)==null?void 0:Ve.message)||d("Could not load products. Please try again.")))}).finally(()=>{fe===z&&(ce=null,I.value=!1)})},400)},le=Ee=>{const fe=++z;oe(),Z({include_ids:[Ee],limit:1},fe).then(ye=>{if(ye===null)return;const Ve=ye.find(Le=>Le.id===Number(Ee));J.value=Ve?Ve.variations:[]}).catch(ye=>{var Ve;fe===z&&(J.value=[],q.error(((Ve=ye==null?void 0:ye.data)==null?void 0:Ve.message)||d("Could not load this product's variations.")))})};ke(()=>a.productId,Ee=>{g.value.post_id=Ee||null,g.value.item_id=null,V.value=null,J.value=[],Ee&&le(Ee)},{immediate:!0}),Ya(()=>{clearTimeout(de),oe(),g.value.media.forEach(Be)});const ee=T(null);let pe=0;const re=K(()=>g.value.media.length>=L?d("Photo limit reached (%1$s)",L):d("Up to %1$s photos, %2$s MB each",L,O)),Ue=()=>{var Ee;return(Ee=ee.value)==null?void 0:Ee.click()},we=Ee=>{const fe=Array.from(Ee.target.files||[]);if(Ee.target.value="",!fe.length)return;const ye=L-g.value.media.length;ye<=0||(fe.length>ye&&q.info(d("%1$s photo(s) were skipped — the limit is %2$s per review",fe.length-ye,L)),fe.slice(0,ye).forEach(Ve=>{if(O&&Ve.size>O*1024*1024){q.error(d("%1$s is too large",Ve.name));return}if(M.length&&Ve.type&&!M.includes(Ve.type)){q.error(d("%1$s is not an allowed file type",Ve.name));return}g.value.media.push({key:`${Ve.name}-${Ve.size}-${Ve.lastModified}-${pe++}`,name:Ve.name,url:URL.createObjectURL(Ve),file:Ve})}))},Be=Ee=>{Ee!=null&&Ee.url&&URL.revokeObjectURL(Ee.url)},ge=Ee=>{const fe=g.value.media.find(ye=>ye.key===Ee);Be(fe),g.value.media=g.value.media.filter(ye=>ye.key!==Ee)},Ce=()=>{g.value.media.forEach(Be),g.value=y(),x.value=[],V.value=null,w.value={}},Oe=()=>{if(v.value)return;w.value={},v.value=!0;const Ee=new FormData;Ee.append("post_id",g.value.post_id),g.value.item_id&&Ee.append("item_id",g.value.item_id),Ee.append("rating",g.value.rating),Ee.append("title",g.value.title),Ee.append("content",g.value.content),Ee.append("reviewer_name",g.value.reviewer_name),Ee.append("reviewer_email",g.value.reviewer_email),Ee.append("status",g.value.status),Ee.append("is_verified",g.value.is_verified?1:0),g.value.media.forEach(fe=>Ee.append("files[]",fe.file,fe.name)),Ae.upload("reviews",Ee).then(fe=>{var ye;(ye=fe.media_rejected)!=null&&ye.length?q.error(fe.message,d("Photos not saved"),8e3):q.success(fe.message),l("created",fe.review),s.value=!1}).catch(fe=>{const ye=fe&&typeof fe=="object"&&!fe.message&&Object.values(fe).some(Ve=>Ve&&typeof Ve=="object");w.value=ye?fe:{general:{server:(fe==null?void 0:fe.message)||d("Could not add the review. Please try again.")}}}).finally(()=>{v.value=!1})};return(Ee,fe)=>{const ye=k("el-option"),Ve=k("el-option-group"),Le=k("el-select"),At=k("el-input"),mt=k("el-switch"),Mt=k("el-button"),Dt=k("el-dialog");return r(),E(Dt,{modelValue:s.value,"onUpdate:modelValue":fe[16]||(fe[16]=Xe=>s.value=Xe),class:"fct-add-review-modal",title:c(d)("Add Review"),width:"560px","align-center":"","append-to-body":"","destroy-on-close":"","close-on-click-modal":!v.value,"close-on-press-escape":!v.value,onOpened:F,onClosed:Ce},{footer:u(()=>[n(Mt,{disabled:v.value,onClick:fe[15]||(fe[15]=Xe=>s.value=!1)},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1},8,["disabled"]),n(Mt,{type:"primary",loading:v.value,disabled:v.value,onClick:Oe},{default:u(()=>[R(f(c(d)("Add Review")),1)]),_:1},8,["loading","disabled"])]),default:u(()=>[o("div",{ref_key:"formRef",ref:C,class:"fct-add-review-form",onKeydown:[da(Ge(Oe,["ctrl","prevent"]),["enter"]),da(Ge(Oe,["meta","prevent"]),["enter"])]},[n(Gt,{"validation-errors":w.value,"field-key":"general"},null,8,["validation-errors"]),e.productId?J.value.length?(r(),m("div",Tge,[o("label",Mge,f(c(d)("Variation")),1),n(Le,{id:"fct_add_review_variation",modelValue:g.value.item_id,"onUpdate:modelValue":fe[1]||(fe[1]=Xe=>g.value.item_id=Xe),class:ue(["w-full",b("item_id")?"is-error":""]),"aria-invalid":b("item_id")?"true":void 0,clearable:"",filterable:"",placeholder:c(d)("Whole product (no specific variation)"),onFocus:fe[2]||(fe[2]=Xe=>S("item_id"))},{default:u(()=>[(r(!0),m(P,null,ae(J.value,Xe=>(r(),E(ye,{key:Xe.id,label:Xe.title,value:Xe.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","class","aria-invalid","placeholder"]),n(Gt,{"validation-errors":w.value,"field-key":"item_id"},null,8,["validation-errors"])])):B("",!0):(r(),m("div",Dge,[o("label",Qge,[R(f(c(d)("Select Product"))+" ",1),fe[17]||(fe[17]=o("span",{class:"fct-add-review-required"},"*",-1))]),n(Le,{id:"fct_add_review_product",modelValue:V.value,"onUpdate:modelValue":fe[0]||(fe[0]=Xe=>V.value=Xe),class:ue(["w-full",b("post_id")||b("item_id")?"is-error":""]),"aria-invalid":b("post_id")||b("item_id")?"true":void 0,filterable:"",remote:"","reserve-keyword":!1,"remote-method":N,loading:I.value,placeholder:c(d)("Search a product"),"popper-class":"fct-add-review-product-options",onFocus:G,onChange:Y},{default:u(()=>[(r(!0),m(P,null,ae(x.value,Xe=>(r(),m(P,{key:Xe.id},[Xe.variations.length?(r(),E(Ve,{key:0,label:Xe.title},{default:u(()=>[(r(!0),m(P,null,ae(Xe.variations,pt=>(r(),E(ye,{key:pt.id,label:pt.title,value:$(Xe,pt)},null,8,["label","value"]))),128))]),_:2},1032,["label"])):(r(),E(ye,{key:1,label:Xe.title,value:Q(Xe)},null,8,["label","value"]))],64))),128))]),_:1},8,["modelValue","class","aria-invalid","loading","placeholder"]),n(Gt,{"validation-errors":w.value,"field-key":"post_id"},null,8,["validation-errors"]),n(Gt,{"validation-errors":w.value,"field-key":"item_id"},null,8,["validation-errors"])])),A?(r(),m("div",Lge,[o("span",Rge,[R(f(c(d)("How would you rate this product?"))+" ",1),c(p)?(r(),m("span",Oge,"*")):B("",!0)]),n(Ige,{modelValue:g.value.rating,"onUpdate:modelValue":[fe[3]||(fe[3]=Xe=>g.value.rating=Xe),fe[4]||(fe[4]=Xe=>S("rating"))],class:ue(b("rating")?"is-error":""),label:c(d)("Review rating")},null,8,["modelValue","class","label"]),n(Gt,{"validation-errors":w.value,"field-key":"rating"},null,8,["validation-errors"])])):B("",!0),o("div",Pge,[o("label",Hge,f(c(d)("Review title")),1),n(At,{id:"fct_add_review_title",modelValue:g.value.title,"onUpdate:modelValue":fe[5]||(fe[5]=Xe=>g.value.title=Xe),maxlength:"192",class:ue(b("title")?"is-error":""),placeholder:c(d)("Summarize your experience"),"aria-invalid":b("title")?"true":void 0,onFocus:fe[6]||(fe[6]=Xe=>S("title"))},null,8,["modelValue","class","placeholder","aria-invalid"]),n(Gt,{"validation-errors":w.value,"field-key":"title"},null,8,["validation-errors"])]),o("div",Nge,[o("label",Kge,[R(f(c(d)("Your review"))+" ",1),fe[18]||(fe[18]=o("span",{class:"fct-add-review-required"},"*",-1))]),n(At,{id:"fct_add_review_content",modelValue:g.value.content,"onUpdate:modelValue":fe[7]||(fe[7]=Xe=>g.value.content=Xe),type:"textarea",rows:4,maxlength:"5000","show-word-limit":"",class:ue(b("content")?"is-error":""),placeholder:c(d)("What did you like or dislike? How did you use this product?"),"aria-invalid":b("content")?"true":void 0,onFocus:fe[8]||(fe[8]=Xe=>S("content"))},null,8,["modelValue","class","placeholder","aria-invalid"]),n(Gt,{"validation-errors":w.value,"field-key":"content"},null,8,["validation-errors"])]),o("div",Gge,[o("div",zge,[o("label",jge,[R(f(c(d)("Reviewer name"))+" ",1),fe[19]||(fe[19]=o("span",{class:"fct-add-review-required"},"*",-1))]),n(At,{id:"fct_add_review_name",modelValue:g.value.reviewer_name,"onUpdate:modelValue":fe[9]||(fe[9]=Xe=>g.value.reviewer_name=Xe),maxlength:"100",class:ue(b("reviewer_name")?"is-error":""),placeholder:c(d)("Name shown on the review"),"aria-invalid":b("reviewer_name")?"true":void 0,onFocus:fe[10]||(fe[10]=Xe=>S("reviewer_name"))},null,8,["modelValue","class","placeholder","aria-invalid"]),n(Gt,{"validation-errors":w.value,"field-key":"reviewer_name"},null,8,["validation-errors"])]),o("div",qge,[o("label",Yge,f(c(d)("Reviewer email")),1),n(At,{id:"fct_add_review_email",modelValue:g.value.reviewer_email,"onUpdate:modelValue":fe[11]||(fe[11]=Xe=>g.value.reviewer_email=Xe),type:"email",maxlength:"192",class:ue(b("reviewer_email")?"is-error":""),placeholder:c(d)("name@example.com (optional)"),"aria-invalid":b("reviewer_email")?"true":void 0,onFocus:fe[12]||(fe[12]=Xe=>S("reviewer_email"))},null,8,["modelValue","class","placeholder","aria-invalid"]),n(Gt,{"validation-errors":w.value,"field-key":"reviewer_email"},null,8,["validation-errors"])])]),o("div",{class:ue(["fct-add-review-row",{"fct-add-review-row-single":!c(h)}])},[o("div",Wge,[o("label",Xge,f(c(d)("Status")),1),n(Le,{id:"fct_add_review_status",modelValue:g.value.status,"onUpdate:modelValue":fe[13]||(fe[13]=Xe=>g.value.status=Xe),class:"w-full"},{default:u(()=>[n(ye,{label:c(d)("Approved"),value:"approved"},null,8,["label"]),n(ye,{label:c(d)("Pending"),value:"pending"},null,8,["label"])]),_:1},8,["modelValue"])]),c(h)?(r(),m("div",Jge,[o("div",Zge,[n(mt,{modelValue:g.value.is_verified,"onUpdate:modelValue":fe[14]||(fe[14]=Xe=>g.value.is_verified=Xe),"aria-label":c(d)("Mark as verified purchase")},null,8,["modelValue","aria-label"]),o("span",e1e,f(c(d)("Verified purchase")),1)])])):B("",!0)],2),_?(r(),m("div",t1e,[o("span",a1e,f(c(d)("Attachments")),1),U?(r(),m(P,{key:0},[g.value.media.length?(r(),m("ul",l1e,[(r(!0),m(P,null,ae(g.value.media,Xe=>(r(),m("li",{key:Xe.key,class:"fct-add-review-media-item"},[o("img",{src:Xe.url,alt:Xe.name||""},null,8,s1e),o("button",{type:"button",class:"fct-add-review-media-remove","aria-label":c(d)("Remove attachment"),onClick:pt=>ge(Xe.key)},"×",8,n1e)]))),128)),g.value.media.length[n(X,{name:"Crown"}),R(" "+f(c(d)("Add attachment")),1)]),_:1}),o("span",c1e,[R(f(c(W))+" ",1),!c(j)&&c(H)?(r(),m("a",{key:0,class:"fct-add-review-upgrade",href:c(H),target:"_blank",rel:"noopener noreferrer"},f(c(d)("Upgrade to Pro")),9,A1e)):B("",!0)])]))])):B("",!0)],40,Vge)]),_:1},8,["modelValue","title","close-on-click-modal","close-on-press-escape"])}}},f1e={class:"fct-all-reviews-page fct-layout-width"},m1e={key:0,class:"fct-product-filter-banner"},h1e={class:"fct-all-reviews-wrap"},_1e={key:0,class:"bulk-actions-bar"},v1e={class:"bulk-left flex items-center gap-2"},g1e={class:"bulk-right"},y1e={key:0,class:"px-4 pb-3"},b1e={class:"mb-1 text-xs text-gray-500"},w1e={class:"font-medium"},C1e={class:"text-sm text-system-dark dark:text-gray-300 truncate max-w-[220px]"},k1e={key:0,class:"text-xs text-gray-500 dark:text-gray-400 truncate max-w-[220px]"},B1e={key:1,class:"text-sm text-gray-400"},x1e={class:"font-medium"},S1e={class:"text-xs text-gray-500"},$1e={class:"max-w-[250px]"},F1e={key:0,class:"font-medium truncate"},E1e={class:"text-xs text-gray-500 truncate"},U1e=["aria-label"],Ic=20,I1e={__name:"AllReviews",setup(e){const t=Na(),a=Wa(),l=t.query.post_id?parseInt(t.query.post_id):null,s=Xve({postId:l}),i=T(null),A=T([]),p=T(""),h=T(!1),_=T(""),y=T(!1),g=T(!1),v=T(null),C=T(null);let w=[];ke(C,M=>{if(!M||!w.length)return;const H=new Set(w);w=[],Fe(()=>{s.getTableData().forEach(j=>{H.has(j.id)&&M.toggleRowSelection(j,!0)})})});const b=T(!1),S=T(!1),F=()=>{let M;M=ke(()=>s.getTableData(),H=>{H.length>0&&H[0].product&&H[0].post_id===s.getPostId()?(i.value=H[0].product.post_title,M==null||M()):H.length===0&&(i.value=d("Product #%1$s",s.getPostId()),M==null||M())})};l>0&&F();const Q=()=>{a.replace({query:{...t.query,post_id:void 0}})},$=M=>{A.value=M},x=M=>{if(M.action==="delete")Pa(d("Are you sure you want to permanently delete this review? This action cannot be undone."),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Ae.delete("reviews/"+M.review.id).then(H=>{q.success(H.message),s.fetch()}).catch(H=>{var j;q.error((j=H.data)==null?void 0:j.message)})}).catch(()=>{});else if(["approve","pending","spam","trash"].includes(M.action)){const H={approve:"approved",pending:"pending",spam:"spam",trash:"trash"};Ae.put("reviews/"+M.review.id,{status:H[M.action]}).then(j=>{q.success(j.message),s.fetch()}).catch(j=>{var W;q.error((W=j.data)==null?void 0:W.message)})}},I=()=>{if(!p.value){q.error(d("Please select a bulk action"));return}V(p.value)},V=M=>{const H=A.value.map(j=>j.id);if(M==="reply"){_.value="",h.value=!0;return}M==="delete"?Pa(d("Are you sure you want to permanently delete %s reviews?",H.length),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{O(M,H)}).catch(()=>{}):O(M,H)},D=async(M,H)=>{const j=[];for(let G=0;G{const G=W?d("Replied to %s review(s).",M):d("%s review(s) updated.",M),Y=W&&H>0?" "+d("%s skipped: already replied.",H):"";if(!j.length){q.success(G+Y);return}q.error(G+Y+" "+d("%s review(s) were not processed and are still selected. Try again.",j.length))},L=async()=>{if(!_.value.trim()){q.error(d("Please write a reply message before sending."));return}const M=A.value.map(j=>j.id);if(!M.length){q.error(d("No reviews selected"));return}y.value=!0;const H=await D(M,j=>Ae.post("reviews/bulk-reply",{content:_.value,review_ids:j}));U(H,!0),y.value=!1,H.failedIds.length||(h.value=!1,p.value=""),w=H.failedIds,s.fetch()},O=async(M,H)=>{if(g.value)return;g.value=!0;const j=await D(H,W=>Ae.post("reviews/bulk-action",{action_type:M,review_ids:W}));U(j),g.value=!1,j.failedIds.length||(p.value=""),w=j.failedIds,s.fetch()};return(M,H)=>{const j=k("el-button"),W=k("el-option"),G=k("el-select"),Y=k("el-progress"),J=k("el-table-column"),de=k("router-link"),z=k("el-dropdown-item"),ce=k("el-dropdown-menu"),oe=k("el-dropdown"),Z=k("el-table"),N=k("el-input"),le=k("el-dialog");return r(),E(Ot,{permission:"reviews/manage"},{default:u(()=>[o("div",f1e,[n(nl,{title:c(d)("Reviews")},{action:u(()=>[n(j,{type:"primary",loading:S.value,disabled:S.value,onClick:H[0]||(H[0]=ee=>b.value=!0)},{default:u(()=>[R(f(c(d)("Add Review")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),i.value?(r(),m("div",m1e,[o("span",null,[R(f(c(d)("Showing reviews for:"))+" ",1),o("strong",null,f(i.value),1)]),n(j,{size:"small",text:"",disabled:c(s).isLoading(),onClick:Q},{default:u(()=>[R(f(c(d)("Clear filter")),1)]),_:1},8,["disabled"])])):B("",!0),o("div",h1e,[n(Cs,{table:c(s),classicTabStyle:!0,"has-mobile-slot":!0},{mobile:u(()=>[c(s).isLoading()?(r(),E(Fge,{key:0})):B("",!0),c(s).isLoading()?B("",!0):(r(),E(Bge,{key:1,table:c(s)},null,8,["table"]))]),default:u(()=>[n(Kl,{name:"slide-fade"},{default:u(()=>[A.value.length>0?(r(),m("div",_1e,[o("div",v1e,[n(G,{size:"small",class:"bulk-select min-w-[180px]",placeholder:c(d)("Select Bulk Action"),disabled:c(s).isLoading()||g.value,modelValue:p.value,"onUpdate:modelValue":H[1]||(H[1]=ee=>p.value=ee)},{default:u(()=>[n(W,{label:c(d)("Approve"),value:"approve"},null,8,["label"]),n(W,{label:c(d)("Pending"),value:"pending"},null,8,["label"]),n(W,{label:c(d)("Mark as Spam"),value:"spam"},null,8,["label"]),n(W,{label:c(d)("Move to Trash"),value:"trash"},null,8,["label"]),n(W,{label:c(d)("Delete Permanently"),value:"delete"},null,8,["label"]),n(W,{label:c(d)("Reply"),value:"reply"},null,8,["label"])]),_:1},8,["placeholder","disabled","modelValue"]),n(j,{size:"small",type:p.value==="delete"?"danger":"primary",disabled:!p.value||g.value||c(s).isLoading(),loading:g.value,onClick:I},{default:u(()=>[R(f(v.value?c(d)("Processing %1$s of %2$s",v.value.current,v.value.total):c(d)("Confirm")),1)]),_:1},8,["type","disabled","loading"])]),o("div",g1e,f(A.value.length)+" "+f(c(d)("item(s) selected")),1)])):B("",!0)]),_:1}),v.value?(r(),m("div",y1e,[o("div",b1e,f(c(d)("Processing batch %1$s of %2$s",v.value.current,v.value.total)),1),n(Y,{percentage:Math.round(v.value.current/v.value.total*100),"show-text":!1,"stroke-width":6},null,8,["percentage"])])):B("",!0),c(s).isLoading()?(r(),E(nge,{key:1,reviewTable:c(s),"next-page-count":c(s).nextPageCount},null,8,["reviewTable","next-page-count"])):(r(),E(Z,{key:2,ref_key:"reviewTableEl",ref:C,data:c(s).getTableData(),class:"w-full compact-table",onSelectionChange:$},{empty:u(()=>[n(wt,{icon:"Empty/ListView","has-dark":"",text:c(d)("No reviews found.")},null,8,["text"])]),default:u(()=>[n(J,{type:"selection",width:45}),n(J,{label:c(d)("ID"),width:"300"},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[o("div",null,[o("div",w1e,"#"+f(c(ea)(ee.row.id)),1),ee.row.product?(r(),m(P,{key:0},[o("div",C1e,f(ee.row.product.post_title),1),ee.row.item_label?(r(),m("div",k1e,f(ee.row.item_label),1)):B("",!0)],64)):(r(),m("span",B1e,"-"))])]),_:2},1032,["to"])]),_:1},8,["label"]),c(s).isColumnVisible("reviewer")?(r(),E(J,{key:0,label:c(d)("Reviewer"),width:220},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[o("div",null,[o("div",x1e,f(ee.row.reviewer_name),1),o("div",S1e,f(ee.row.reviewer_email),1)])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("rating")?(r(),E(J,{key:1,label:c(d)("Rating"),width:120},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[n(Vi,{rating:ee.row.rating,size:"small"},null,8,["rating"])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("content")?(r(),E(J,{key:2,label:c(d)("Review"),"min-width":200},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[o("div",$1e,[ee.row.title?(r(),m("div",F1e,f(ee.row.title),1)):B("",!0),o("div",E1e,f(ee.row.content),1)])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("status")?(r(),E(J,{key:3,label:c(d)("Status"),width:120},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[n(la,{status:ee.row.status,size:"small"},null,8,["status"])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("date")?(r(),E(J,{key:4,label:c(d)("Date"),width:140},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[n(Sa,{"date-time":ee.row.created_at},null,8,["date-time"])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("actions")?(r(),E(J,{key:5,label:c(d)("Actions"),width:90,align:"right"},{default:u(ee=>[n(oe,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:x,placement:"bottom-end"},{dropdown:u(()=>[n(ce,null,{default:u(()=>[ee.row.id?(r(),E(z,{key:0,class:"item-link"},{default:u(()=>[n(de,{to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[n(X,{name:"Eye"}),R(" "+f(c(d)("View")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),ee.row.status!=="approved"?(r(),E(z,{key:1,command:{action:"approve",review:ee.row}},{default:u(()=>[R(f(c(d)("Approve")),1)]),_:2},1032,["command"])):B("",!0),ee.row.status!=="pending"?(r(),E(z,{key:2,command:{action:"pending",review:ee.row}},{default:u(()=>[R(f(c(d)("Pending")),1)]),_:2},1032,["command"])):B("",!0),ee.row.status!=="spam"?(r(),E(z,{key:3,command:{action:"spam",review:ee.row}},{default:u(()=>[R(f(c(d)("Spam")),1)]),_:2},1032,["command"])):B("",!0),ee.row.status!=="trash"?(r(),E(z,{key:4,command:{action:"trash",review:ee.row}},{default:u(()=>[R(f(c(d)("Trash")),1)]),_:2},1032,["command"])):B("",!0),n(z,{command:{action:"delete",review:ee.row},class:"item-destructive"},{default:u(()=>[n(X,{name:"Delete"}),R(" "+f(c(d)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:u(()=>[o("span",{class:"more-btn mr-2","aria-label":c(d)("Review actions")},[n(X,{name:"More"})],8,U1e)]),_:2},1024)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"]))]),_:1},8,["table"])]),n(p1e,{modelValue:b.value,"onUpdate:modelValue":H[2]||(H[2]=ee=>b.value=ee),saving:S.value,"onUpdate:saving":H[3]||(H[3]=ee=>S.value=ee),"product-id":c(s).getPostId()||null,onCreated:H[4]||(H[4]=ee=>c(s).fetch())},null,8,["modelValue","saving","product-id"]),n(le,{modelValue:h.value,"onUpdate:modelValue":H[7]||(H[7]=ee=>h.value=ee),title:c(d)("Reply to %s reviews",A.value.length),width:"500px","aria-label":c(d)("Bulk reply to reviews")},{footer:u(()=>[n(j,{disabled:y.value,onClick:H[6]||(H[6]=ee=>h.value=!1)},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1},8,["disabled"]),n(j,{type:"primary",loading:y.value,disabled:y.value,onClick:L},{default:u(()=>[R(f(v.value?c(d)("Processing %1$s of %2$s",v.value.current,v.value.total):c(d)("Send Reply")),1)]),_:1},8,["loading","disabled"])]),default:u(()=>[n(N,{modelValue:_.value,"onUpdate:modelValue":H[5]||(H[5]=ee=>_.value=ee),type:"textarea",rows:4,placeholder:c(d)("Write your reply...")},null,8,["modelValue","placeholder"])]),_:1},8,["modelValue","title","aria-label"])])]),_:1})}}},V1e={class:"fct-single-review-page fct-layout-width"},D1e={key:0,class:"p-6"},Q1e={class:"single-page-header flex items-start justify-between"},T1e={class:"single-page-header-title-wrap"},M1e={key:1},L1e={class:"single-page-header-status-wrap"},R1e={class:"fct-btn-group sm"},O1e={class:"single-page-body"},P1e={class:"fct-single-review-layout"},H1e={class:"fct-single-review-main"},N1e={class:"fct-review-rating-inline"},K1e={class:"fct-review-rating-num"},G1e={class:"fct-review-thread-container"},z1e={class:"fct-thread-item"},j1e={class:"fct-thread-content"},q1e={class:"fct-thread-name-row"},Y1e={class:"fct-thread-name"},W1e={class:"fct-thread-meta"},X1e={key:0,class:"fct-thread-title"},J1e={class:"fct-thread-text"},Z1e={key:1,class:"fct-thread-media"},eye=["aria-label","onClick"],tye=["src","alt"],aye={key:1,class:"fct-thread-media-video"},lye={key:0,class:"fct-thread-reply-group"},sye={class:"fct-thread-content"},nye={class:"fct-thread-name-row"},oye={class:"fct-thread-name"},iye={class:"fct-thread-meta"},rye=["disabled","aria-label","aria-expanded"],dye={class:"fct-thread-text"},uye={key:0,class:"fct-thread-form"},cye={class:"fct-thread-form-box"},Aye={class:"fct-thread-form-actions"},pye={key:0,class:"fct-review-media-preview"},fye=["src","alt"],mye=["src"],hye={key:2,class:"fct-review-media-preview-nav"},_ye={class:"text-sm text-gray-500"},vye={class:"fct-single-review-aside"},gye={class:"fct-admin-sidebar"},yye={class:"fct-review-context"},bye={key:0,class:"fct-review-context-row"},wye={class:"fct-review-context-thumb","aria-hidden":"true"},Cye=["src"],kye={class:"fct-review-context-label"},Bye={key:0,class:"block text-xs text-gray-500 dark:text-gray-400"},xye=["href","aria-label","title"],Sye={class:"fct-review-context-row"},$ye={class:"fct-review-context-label"},Fye={class:"fct-review-verified-row"},Eye={class:"fct-review-verified-label"},Uye={class:"fct-review-verified-hint"},Iye={class:"fct-review-actions-label"},Vye={class:"fct-review-action-buttons"},Dye=["disabled","aria-label","title","onClick"],Qye={class:"fct-review-action-label"},Tye={class:"fct-vote-rows"},Mye={class:"fct-vote-row fct-vote-row--helpful"},Lye={class:"fct-vote-row-count"},Rye={class:"sr-only"},Oye={class:"fct-vote-row fct-vote-row--not-helpful"},Pye={class:"fct-vote-row-count"},Hye={class:"sr-only"},Nye={key:2,class:"p-6 text-center text-gray-500"},Kye={__name:"SingleReview",setup(e){const t=Na(),a=Wa(),l=T(null),s=T(!0),i=()=>{var Y;return dt.get((Y=l.value)==null?void 0:Y.product,"detail.featured_media.url")??pl.productPlaceholder()},A=K(()=>[{status:"approved",label:d("Approve"),aria:d("Approve")},{status:"spam",label:d("Spam"),aria:d("Mark as Spam")},{status:"trash",label:d("Trash"),aria:d("Move to Trash")},{status:"pending",label:d("Pending"),aria:d("Mark as Pending")}].filter(J=>{var de;return J.status!==((de=l.value)==null?void 0:de.status)}).slice(0,3)),p=T(""),h=T(!1),_=T(null),y=[{status:"pending",label:d("Pending"),icon:"Clock"},{status:"approved",label:d("Approved"),icon:"Check"},{status:"spam",label:d("Spam"),icon:"AlertIcon"},{status:"trash",label:d("Trash"),icon:"TrashIcon"}],g=Y=>{const J=y.find(de=>de.status===Y);return J?J.label:Y},v=T(null),C=(Y,J)=>{_.value===null&&(_.value=Y.id,Ae.put("reviews/"+Y.id,{status:J}).then(de=>{Y.status=J,q.success(de.message)}).catch(de=>{var z;return q.error((z=de.data)==null?void 0:z.message)}).finally(()=>{_.value=null}))},w=T(null),b=()=>{Fe(()=>{w.value&&(w.value.scrollTop=w.value.scrollHeight)})},S=T(!1),F=T(!1),Q=T(null),$=T([]),x=T(!1),I=K(()=>{var Y;return x.value||!(((Y=l.value)==null?void 0:Y.replies)||[]).length}),V=T(!1),D=T(0),U=Y=>{D.value=Y,V.value=!0},L=Y=>{!V.value||!$.value.length||(Y.key==="ArrowLeft"&&D.value>0?D.value--:Y.key==="ArrowRight"&&D.value<$.value.length-1&&D.value++)};ke(V,Y=>{Y?document.addEventListener("keydown",L):document.removeEventListener("keydown",L)});const O=()=>{s.value=!0,Ae.get("reviews/"+t.params.review_id).then(Y=>{l.value=Y.review,Q.value=Y.vote_counts||null,$.value=Y.review_media||[],x.value=!!Y.allow_multiple_replies,b()}).catch(Y=>{var J;q.error(((J=Y.data)==null?void 0:J.message)||d("Review not found"))}).finally(()=>{s.value=!1})},M=Y=>{S.value||(S.value=!0,Ae.put("reviews/"+l.value.id,{status:Y}).then(J=>{q.success(J.message),l.value.status=Y}).catch(J=>{var de;q.error((de=J.data)==null?void 0:de.message)}).finally(()=>{S.value=!1}))},H=Y=>{F.value||(F.value=!0,Ae.put("reviews/"+l.value.id,{is_verified:Y?1:0}).then(J=>{q.success(J.message),l.value.is_verified=Y?1:0}).catch(J=>{var de;q.error((de=J.data)==null?void 0:de.message)}).finally(()=>{F.value=!1}))},j=()=>{Pa(d("Are you sure you want to permanently delete this review? This action cannot be undone."),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Ae.delete("reviews/"+l.value.id).then(Y=>{q.success(Y.message),a.push({name:"reviews"})}).catch(Y=>{var J;q.error((J=Y.data)==null?void 0:J.message)})}).catch(()=>{})},W=Y=>{Pa(d("Are you sure you want to delete this reply?"),d("Delete Reply"),{confirmButtonText:d("Yes, Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Ae.delete("reviews/"+l.value.id+"/replies/"+Y).then(J=>{q.success(J.message),Array.isArray(l.value.replies)&&(l.value.replies=l.value.replies.filter(de=>de.id!==Y))}).catch(J=>{var de;q.error((de=J.data)==null?void 0:de.message)})}).catch(()=>{})},G=()=>{if(!p.value.trim()){q.error(d("Please write a reply message before sending."));return}h.value=!0,Ae.post("reviews/"+l.value.id+"/reply",{content:p.value}).then(Y=>{q.success(Y.message),p.value="",Y.reply?(Array.isArray(l.value.replies)||(l.value.replies=[]),l.value.replies.push(Y.reply),b()):O()}).catch(Y=>{var J;q.error((J=Y.data)==null?void 0:J.message)}).finally(()=>{h.value=!1})};return De(()=>{O()}),Ya(()=>{document.removeEventListener("keydown",L)}),(Y,J)=>{const de=k("el-skeleton"),z=k("el-breadcrumb-item"),ce=k("el-tooltip"),oe=k("router-link"),Z=k("el-breadcrumb"),N=k("el-icon"),le=k("el-button"),ee=k("el-dropdown-item"),pe=k("el-dropdown-menu"),re=k("el-dropdown"),Ue=k("el-tag"),we=k("el-input"),Be=k("el-dialog"),ge=k("el-switch");return r(),E(Ot,{permission:"reviews/manage"},{default:u(()=>[o("div",V1e,[s.value?(r(),m("div",D1e,[n(de,{rows:8,animated:""})])):l.value?(r(),m(P,{key:1},[o("div",Q1e,[o("div",null,[o("div",T1e,[n(Z,{"separator-icon":c(dl)},{default:u(()=>[n(z,{to:{name:"reviews"}},{default:u(()=>[R(f(c(d)("Reviews")),1)]),_:1}),l.value.product?(r(),E(z,{key:0,to:{name:"reviews",query:{post_id:l.value.post_id}}},{default:u(()=>[R(f(l.value.product.post_title),1)]),_:1},8,["to"])):B("",!0),n(z,null,{default:u(()=>[l.value.reviewer_email?(r(),E(ce,{key:0,content:l.value.reviewer_email,placement:"bottom"},{default:u(()=>[o("span",null,f(l.value.reviewer_name),1)]),_:1},8,["content"])):(r(),m("span",M1e,f(l.value.reviewer_name),1)),l.value.customer?(r(),E(oe,{key:2,class:"fct-goto-customer-pill",to:{name:"view_customer",params:{customer_id:l.value.customer.id}}},{default:u(()=>[R(f(c(d)("Go to Customer")),1),J[8]||(J[8]=o("span",{"aria-hidden":"true"},"→",-1))]),_:1,__:[8]},8,["to"])):B("",!0)]),_:1})]),_:1},8,["separator-icon"]),o("div",L1e,[n(la,{status:l.value.status},null,8,["status"])])])]),o("div",R1e,[n(re,{trigger:"click"},{dropdown:u(()=>[n(pe,null,{default:u(()=>[l.value.status!=="approved"?(r(),E(ee,{key:0,disabled:S.value,onClick:J[0]||(J[0]=Ce=>M("approved"))},{default:u(()=>[R(f(c(d)("Approve")),1)]),_:1},8,["disabled"])):B("",!0),l.value.status!=="spam"?(r(),E(ee,{key:1,disabled:S.value,onClick:J[1]||(J[1]=Ce=>M("spam"))},{default:u(()=>[R(f(c(d)("Mark as Spam")),1)]),_:1},8,["disabled"])):B("",!0),l.value.status!=="pending"?(r(),E(ee,{key:2,disabled:S.value,onClick:J[2]||(J[2]=Ce=>M("pending"))},{default:u(()=>[R(f(c(d)("Mark as Pending")),1)]),_:1},8,["disabled"])):B("",!0),l.value.status!=="trash"?(r(),E(ee,{key:3,disabled:S.value,onClick:J[3]||(J[3]=Ce=>M("trash"))},{default:u(()=>[R(f(c(d)("Move to Trash")),1)]),_:1},8,["disabled"])):B("",!0),n(ee,{onClick:j,class:"fct-dropdown-item--danger"},{default:u(()=>[R(f(c(d)("Delete Permanently")),1)]),_:1})]),_:1})]),default:u(()=>[n(le,{size:"small"},{default:u(()=>[R(f(c(d)("More Actions"))+" ",1),n(N,{class:"el-icon--right"},{default:u(()=>[n(c(Qs))]),_:1})]),_:1})]),_:1})])]),o("div",O1e,[o("div",P1e,[o("div",H1e,[n(c($e),null,{default:u(()=>[n(c(Qe),{title:c(d)("Review Information"),border_bottom:"",title_size:"small"},{action:u(()=>[o("span",N1e,[n(Vi,{rating:l.value.rating,size:"small"},null,8,["rating"]),o("span",K1e,f(l.value.rating?Number(l.value.rating).toFixed(1):"—"),1)])]),_:1},8,["title"]),o("div",G1e,[o("div",{class:"fct-review-thread",ref_key:"chatScrollRef",ref:w},[o("div",z1e,[n(Is,{name:l.value.reviewer_name,url:l.value.photo},null,8,["name","url"]),o("div",j1e,[o("div",q1e,[o("span",Y1e,f(l.value.reviewer_name),1),n(Ue,{size:"small",effect:"light",class:"fct-customer-review-badge"},{default:u(()=>[R(f(c(d)("Customer review")),1)]),_:1}),l.value.user_id?B("",!0):(r(),E(Ue,{key:0,size:"small",type:"warning",effect:"light"},{default:u(()=>[R(f(c(d)("Guest")),1)]),_:1})),l.value.is_verified?(r(),E(Ue,{key:1,size:"small",type:"success",effect:"light"},{default:u(()=>[R(f(c(d)("Verified Purchase")),1)]),_:1})):B("",!0)]),o("div",W1e,[n(Sa,{"date-time":l.value.created_at,"with-time":!0},null,8,["date-time"])]),l.value.title?(r(),m("div",X1e,f(l.value.title),1)):B("",!0),o("div",J1e,f(l.value.content||c(d)("No review content.")),1),$.value&&$.value.length?(r(),m("div",Z1e,[(r(!0),m(P,null,ae($.value,(Ce,Oe)=>(r(),m("button",{key:Ce.id,type:"button",class:"fct-thread-media-thumb","aria-label":`${c(d)("Preview")} ${Ce.name||c(d)("media")}`,onClick:Ee=>U(Oe)},[Ce.type==="image"?(r(),m("img",{key:0,src:Ce.url,alt:Ce.name,loading:"lazy"},null,8,tye)):(r(),m("div",aye,J[9]||(J[9]=[o("span",{class:"fct-thread-media-play"},"▶",-1)])))],8,eye))),128))])):B("",!0)])]),l.value.replies&&l.value.replies.length?(r(),m("div",lye,[(r(!0),m(P,null,ae(l.value.replies,Ce=>(r(),m("div",{key:Ce.id,class:"fct-thread-reply-card"},[n(Is,{name:Ce.reviewer_name||c(d)("Customer"),url:Ce.photo},null,8,["name","url"]),o("div",sye,[o("div",nye,[o("span",oye,f(Ce.reviewer_name||c(d)("Customer")),1),Number(Ce.is_admin_reply)===1?(r(),E(Ue,{key:0,size:"small",effect:"light",class:"fct-admin-reply-badge"},{default:u(()=>[R(f(c(d)("Admin")),1)]),_:1})):B("",!0)]),o("div",iye,[n(Sa,{"date-time":Ce.created_at,"with-time":!0},null,8,["date-time"]),J[10]||(J[10]=o("span",{class:"fct-thread-meta-dot","aria-hidden":"true"},"·",-1)),n(re,{trigger:"click",disabled:_.value!==null,onCommand:Oe=>C(Ce,Oe),onVisibleChange:Oe=>v.value=Oe?Ce.id:null},{dropdown:u(()=>[n(pe,{class:"fct-thread-status-menu"},{default:u(()=>[(r(),m(P,null,ae(y,Oe=>n(ee,{key:Oe.status,command:Oe.status,disabled:Oe.status===Ce.status,class:ue(["fct-thread-status-option",`fct-thread-status-option--${Oe.status}`,{"is-current":Oe.status===Ce.status}])},{default:u(()=>[n(X,{name:Oe.status===Ce.status?"Check":Oe.icon,class:"fct-thread-status-option-icon"},null,8,["name"]),o("span",null,f(Oe.label),1)]),_:2},1032,["command","disabled","class"])),64))]),_:2},1024)]),default:u(()=>[o("button",{type:"button",class:ue(["fct-thread-status-trigger",{"is-open":v.value===Ce.id,"is-busy":_.value===Ce.id}]),disabled:_.value!==null,"aria-label":c(d)("Reply status"),"aria-expanded":v.value===Ce.id?"true":"false","aria-haspopup":"menu"},[n(la,{type:Ce.status,class:"fct-thread-status-pill"},{default:u(()=>[o("span",null,f(g(Ce.status)),1),n(N,{class:"fct-thread-status-caret","aria-hidden":"true"},{default:u(()=>[n(c(Qs))]),_:1})]),_:2},1032,["type"])],10,rye)]),_:2},1032,["disabled","onCommand","onVisibleChange"]),n(le,{type:"danger",text:"",size:"small",class:"fct-thread-delete-btn","aria-label":c(d)("Delete reply"),onClick:Oe=>W(Ce.id)},{default:u(()=>[n(X,{name:"TrashIcon"})]),_:2},1032,["aria-label","onClick"])]),o("div",dye,f(Ce.content),1)])]))),128))])):B("",!0)],512),I.value?(r(),m("div",uye,[o("div",cye,[n(we,{modelValue:p.value,"onUpdate:modelValue":J[4]||(J[4]=Ce=>p.value=Ce),type:"textarea",rows:3,placeholder:c(d)("Type a message"),"aria-label":c(d)("Reply to review"),resize:"none"},null,8,["modelValue","placeholder","aria-label"]),o("div",Aye,[n(le,{class:"fct-thread-reply-btn",size:"small",onClick:G,loading:h.value,disabled:h.value||!p.value.trim()},{default:u(()=>[R(f(c(d)("Reply")),1)]),_:1},8,["loading","disabled"])])])])):B("",!0)])]),_:1}),n(Be,{modelValue:V.value,"onUpdate:modelValue":J[7]||(J[7]=Ce=>V.value=Ce),title:c(d)("Review Media"),width:"720px","destroy-on-close":"","aria-label":c(d)("Review media preview")},{default:u(()=>[$.value&&$.value[D.value]?(r(),m("div",pye,[$.value[D.value].type==="image"?(r(),m("img",{key:0,src:$.value[D.value].url,alt:$.value[D.value].name,class:"fct-review-media-preview-img"},null,8,fye)):(r(),m("video",{key:1,src:$.value[D.value].url,controls:"",class:"fct-review-media-preview-video"},null,8,mye)),$.value.length>1?(r(),m("div",hye,[n(le,{size:"small",disabled:D.value===0,onClick:J[5]||(J[5]=Ce=>D.value--)},{default:u(()=>[R(" ← "+f(c(d)("Previous")),1)]),_:1},8,["disabled"]),o("span",_ye,f(D.value+1)+" / "+f($.value.length),1),n(le,{size:"small",disabled:D.value===$.value.length-1,onClick:J[6]||(J[6]=Ce=>D.value++)},{default:u(()=>[R(f(c(d)("Next"))+" → ",1)]),_:1},8,["disabled"])])):B("",!0)])):B("",!0)]),_:1},8,["modelValue","title","aria-label"])]),o("div",vye,[o("div",gye,[n(c($e),null,{default:u(()=>[n(c(Qe),{title:c(d)("About the Reviews"),border_bottom:"",title_size:"small"},null,8,["title"]),n(c(xe),null,{default:u(()=>[o("div",yye,[l.value.product?(r(),m("div",bye,[o("span",wye,[o("img",{src:i(),alt:""},null,8,Cye)]),o("span",kye,[R(f(l.value.product.post_title)+" ",1),l.value.item_label?(r(),m("span",Bye,f(l.value.item_label),1)):B("",!0)]),l.value.product.view_url?(r(),m("a",{key:0,class:"fct-review-context-link",href:l.value.product.view_url,target:"_blank",rel:"noopener noreferrer","aria-label":c(d)("View product"),title:c(d)("View product")},[n(X,{name:"Redirect"})],8,xye)):B("",!0)])):B("",!0),o("div",Sye,[n(Is,{class:"fct-review-context-avatar",name:l.value.reviewer_name,url:l.value.photo},null,8,["name","url"]),o("span",$ye,f(l.value.customer?l.value.reviewer_name:c(d)("Guest customer")),1),l.value.customer?(r(),E(oe,{key:0,class:"fct-review-context-link",to:{name:"view_customer",params:{customer_id:l.value.customer.id}},target:"_blank","aria-label":c(d)("View profile"),title:c(d)("View profile")},{default:u(()=>[n(X,{name:"Redirect"})]),_:1},8,["to","aria-label","title"])):(r(),E(Ue,{key:1,type:"info",round:"",class:"flex-shrink-0"},{default:u(()=>[R(f(c(d)("No account")),1)]),_:1}))])]),o("div",Fye,[o("div",null,[o("div",Eye,f(c(d)("Verified purchase")),1),o("div",Uye,f(c(d)("Show the verified badge on this review")),1)]),n(ge,{"model-value":!!l.value.is_verified,loading:F.value,disabled:F.value,"aria-label":c(d)("Mark as verified purchase"),"onUpdate:modelValue":H},null,8,["model-value","loading","disabled","aria-label"])]),o("div",Iye,f(c(d)("Actions")),1),o("div",Vye,[(r(!0),m(P,null,ae(A.value,Ce=>(r(),m("button",{key:Ce.status,type:"button",class:ue(["fct-review-action",`fct-review-action--${Ce.status}`]),disabled:S.value,"aria-label":Ce.aria,title:Ce.aria,onClick:Oe=>M(Ce.status)},[Ce.status==="approved"?(r(),E(X,{key:0,class:"fct-review-action-icon",name:"Check"})):Ce.status==="spam"?(r(),E(X,{key:1,class:"fct-review-action-icon",name:"FlagIcon"})):Ce.status==="trash"?(r(),E(X,{key:2,class:"fct-review-action-icon",name:"TrashIcon"})):(r(),E(X,{key:3,class:"fct-review-action-icon",name:"Clock"})),o("span",Qye,f(Ce.label),1)],10,Dye))),128))])]),_:1})]),_:1}),Q.value?(r(),E(c($e),{key:0},{default:u(()=>[n(c(Qe),{title:c(d)("Helpful Votes"),text:c(d)("How shoppers reacted to this review"),title_size:"small"},null,8,["title","text"]),n(c(xe),null,{default:u(()=>[o("div",Tye,[o("div",Mye,[n(X,{name:"ThumbUp"}),o("span",Lye,f(Q.value.helpful),1),o("span",Rye,f(c(d)("Helpful votes")),1)]),o("div",Oye,[n(X,{name:"ThumbDown"}),o("span",Pye,f(Q.value.not_helpful),1),o("span",Hye,f(c(d)("Not helpful votes")),1)])])]),_:1})]),_:1})):B("",!0)])])])])],64)):(r(),m("div",Nye,f(c(d)("Review not found")),1))])]),_:1})}}},Gye={class:"setting-wrap fct-review-settings"},zye={class:"setting-wrap-inner"},jye={class:"fct-setting-form-row"},qye={class:"fct-setting-form-content flex gap-3.5 flex-1"},Yye={class:"fct-inline-tip"},Wye={key:0,class:"fct-setting-form-row"},Xye={class:"grid gap-3 mb-6"},Jye={class:"grid gap-3"},Zye={key:1},ebe={class:"fct-setting-form-row"},tbe={class:"fct-setting-form-content"},abe={class:"fct-inline-tip"},lbe={class:"fct-setting-form-fields self-center"},sbe={class:"flex flex-col"},nbe={class:"fct-review-radio-label"},obe={class:"fct-review-radio-text"},ibe={class:"fct-setting-form-row"},rbe={class:"fct-setting-form-content"},dbe={class:"fct-inline-tip"},ube={class:"fct-setting-form-fields self-center flex justify-end"},cbe={class:"fct-setting-form-row"},Abe={class:"fct-setting-form-content"},pbe={class:"fct-inline-tip"},fbe={class:"fct-setting-form-fields self-center flex justify-end"},mbe={key:0,class:"fct-setting-form-row is-child"},hbe={class:"fct-setting-form-content"},_be={class:"fct-inline-tip"},vbe={class:"fct-setting-form-fields self-center flex justify-end"},gbe={class:"fct-setting-form-row"},ybe={class:"fct-setting-form-content"},bbe={class:"fct-inline-tip"},wbe={class:"fct-setting-form-fields self-center flex justify-end"},Cbe={class:"fct-setting-form-row"},kbe={class:"fct-setting-form-content"},Bbe={class:"fct-inline-tip"},xbe={class:"fct-setting-form-fields self-center flex justify-end"},Sbe={class:"fct-setting-form-row"},$be={class:"fct-setting-form-content"},Fbe={class:"fct-inline-tip"},Ebe={key:0,class:"fct-inline-tip"},Ube={class:"fct-setting-form-fields self-center flex justify-end"},Ibe={class:"fct-setting-form-row is-child"},Vbe={class:"fct-setting-form-content"},Dbe={class:"fct-setting-form-fields self-center flex justify-end"},Qbe={class:"fct-setting-form-row is-child"},Tbe={class:"fct-setting-form-content"},Mbe={class:"fct-setting-form-fields self-center flex justify-end"},Lbe={class:"fct-setting-form-row is-child"},Rbe={class:"fct-setting-form-content"},Obe={class:"fct-inline-tip"},Pbe={class:"fct-setting-form-fields self-center flex justify-end"},Hbe={class:"fct-setting-form-row is-child"},Nbe={class:"fct-setting-form-content"},Kbe={class:"fct-setting-form-fields self-center"},Gbe={class:"fct-setting-form-row"},zbe={class:"fct-setting-form-content"},jbe={class:"fct-inline-tip"},qbe={key:0,class:"fct-inline-tip"},Ybe={class:"fct-setting-form-fields self-center flex justify-end"},Wbe=Object.assign({name:"ReviewSettings"},{__name:"ReviewSettings",setup(e){const t=$e,a=xe,l=je.get("app_config.isProActive"),s=T(!0),i=T(!1);let A=!1;const p=is(),h=[{value:"verified_buyers",label:d("Verified buyers only"),desc:d("Only customers who purchased the product.")},{value:"logged_in",label:d("Logged-in users"),desc:d("Any logged-in user can leave a review.")},{value:"anyone",label:d("Anyone"),desc:d("Guests can leave reviews too.")}],_=Us({active:"yes",review_permission_mode:"verified_buyers",auto_approve_reviews:"no",show_verified_badge:"yes",enable_star_rating:"yes",star_rating_required:"yes",reviews_per_page:10,enable_photo_reviews:"no",auto_approve_photo_reviews:"no",max_photos_per_review:5,max_photo_size_mb:1,allowed_photo_types:["jpeg","png","gif","webp"],enable_helpful_votes:"yes"});let y={};const g=()=>{s.value=!0,A=!1,Ae.get("settings/modules",{}).then(C=>{y=C.settings||{};const w=y.reviews||{};Object.keys(_).forEach(b=>{w[b]!==void 0&&(_[b]=w[b])}),A=!0}).catch(C=>{var w;q.error(((w=C==null?void 0:C.data)==null?void 0:w.message)||(C==null?void 0:C.message)||d("Could not load review settings."))}).finally(()=>{s.value=!1})},v=()=>{s.value||!A||(i.value=!0,Ae.post("settings/modules",{...y,reviews:{..._}}).then(()=>{q.success(d("Settings saved successfully"))}).catch(C=>{var w;q.error(((w=C==null?void 0:C.data)==null?void 0:w.message)||(C==null?void 0:C.message)||d("Failed to save settings"))}).finally(()=>{i.value=!1}))};return De(()=>{g(),p.bind(["mod+s"],C=>{C.preventDefault(),v()})}),Ya(()=>{p.unbind(["mod+s"])}),(C,w)=>{const b=k("el-switch"),S=k("el-skeleton-item"),F=k("el-skeleton"),Q=k("el-radio"),$=k("el-radio-group"),x=k("el-input-number"),I=k("el-button"),V=k("el-checkbox"),D=k("el-checkbox-group");return r(),m("div",Gye,[n($a,{heading:c(d)("Product Reviews"),loading:i.value,"show-cmnd-icon":!0,onOnSave:v},null,8,["heading","loading"]),o("div",zye,[n(Fa),n(c(t),null,{default:u(()=>[n(c(a),null,{default:u(()=>[o("div",jye,[o("div",qye,[n(b,{modelValue:_.active,"onUpdate:modelValue":w[0]||(w[0]=U=>_.active=U),"active-value":"yes","inactive-value":"no",disabled:s.value},null,8,["modelValue","disabled"]),o("div",null,[n(Rt,{title:c(d)("Enable Product Reviews")},null,8,["title"]),o("p",Yye,f(_.active==="yes"?c(d)("Customers can leave ratings and reviews on products."):c(d)("Customers cannot leave reviews right now.")),1)])])]),n(_a,{visible:_.active==="yes",accordion:""},{default:u(()=>[s.value?(r(),m("div",Wye,[n(F,{animated:"",class:"w-full"},{template:u(()=>[o("div",Xye,[n(S,{variant:"p",class:"w-[20%]"}),n(S,{variant:"p"})]),o("div",Jye,[n(S,{variant:"p",class:"w-[20%]"}),n(S,{variant:"p"})])]),_:1})])):B("",!0),s.value?B("",!0):(r(),m("div",Zye,[o("div",ebe,[o("div",tbe,[n(Rt,{title:c(d)("Who can leave reviews?")},null,8,["title"]),o("p",abe,f(c(d)("Who is offered the review form on a product.")),1)]),o("div",lbe,[n($,{modelValue:_.review_permission_mode,"onUpdate:modelValue":w[1]||(w[1]=U=>_.review_permission_mode=U),class:"fct-review-stacked-radios"},{default:u(()=>[(r(),m(P,null,ae(h,U=>n(Q,{key:U.value,value:U.value},{default:u(()=>[o("div",sbe,[o("span",nbe,f(U.label),1),o("span",obe,f(U.desc),1)])]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"])])]),o("div",ibe,[o("div",rbe,[n(Rt,{title:c(d)("Show 'Verified Owner' Badge")},null,8,["title"]),o("p",dbe,f(c(d)("Display a verified badge on reviews from customers who purchased the product.")),1)]),o("div",ube,[n(b,{modelValue:_.show_verified_badge,"onUpdate:modelValue":w[2]||(w[2]=U=>_.show_verified_badge=U),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])]),o("div",cbe,[o("div",Abe,[n(Rt,{title:c(d)("Enable Star Ratings")},null,8,["title"]),o("p",pbe,f(c(d)("Allow customers to rate products with stars.")),1)]),o("div",fbe,[n(b,{modelValue:_.enable_star_rating,"onUpdate:modelValue":w[3]||(w[3]=U=>_.enable_star_rating=U),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])]),_.enable_star_rating==="yes"?(r(),m("div",mbe,[o("div",hbe,[n(Rt,{title:c(d)("Star Ratings Required")},null,8,["title"]),o("p",_be,f(c(d)("When off, customers can submit text-only reviews without a star rating.")),1)]),o("div",vbe,[n(b,{modelValue:_.star_rating_required,"onUpdate:modelValue":w[4]||(w[4]=U=>_.star_rating_required=U),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])])):B("",!0),o("div",gbe,[o("div",ybe,[n(Rt,{title:c(d)("Auto-approve Reviews")},null,8,["title"]),o("p",bbe,f(c(d)("Publish new reviews immediately, without moderation.")),1)]),o("div",wbe,[n(b,{modelValue:_.auto_approve_reviews,"onUpdate:modelValue":w[5]||(w[5]=U=>_.auto_approve_reviews=U),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])]),o("div",Cbe,[o("div",kbe,[n(Rt,{title:c(d)("Reviews Per Page")},null,8,["title"]),o("p",Bbe,f(c(d)("How many reviews a product page lists before paging.")),1)]),o("div",xbe,[n(x,{modelValue:_.reviews_per_page,"onUpdate:modelValue":w[6]||(w[6]=U=>_.reviews_per_page=U),min:1,max:50},null,8,["modelValue"])])]),o("div",Sbe,[o("div",$be,[n(Rt,{title:c(d)("Photo Reviews")},null,8,["title"]),o("p",Fbe,f(c(d)("Let customers attach photos to their reviews.")),1),c(l)?B("",!0):(r(),m("p",Ebe,[R(f(c(d)("This feature is only available in FluentCart Pro."))+" ",1),n(I,{size:"small",tag:"a",link:"",href:c(Mo)("feature_lock_review_settings"),target:"_blank",rel:"noopener noreferrer"},{default:u(()=>[R(f(c(d)("Upgrade to Pro")),1)]),_:1},8,["href"])]))]),o("div",Ube,[n(b,{modelValue:_.enable_photo_reviews,"onUpdate:modelValue":w[7]||(w[7]=U=>_.enable_photo_reviews=U),"active-value":"yes","inactive-value":"no",disabled:!c(l)},null,8,["modelValue","disabled"])])]),c(l)&&_.enable_photo_reviews==="yes"?(r(),m(P,{key:1},[o("div",Ibe,[o("div",Vbe,[n(Rt,{title:c(d)("Max Photos Per Review")},null,8,["title"])]),o("div",Dbe,[n(x,{modelValue:_.max_photos_per_review,"onUpdate:modelValue":w[8]||(w[8]=U=>_.max_photos_per_review=U),min:1,max:10},null,8,["modelValue"])])]),o("div",Qbe,[o("div",Tbe,[n(Rt,{title:c(d)("Max File Size (MB)")},null,8,["title"])]),o("div",Mbe,[n(x,{modelValue:_.max_photo_size_mb,"onUpdate:modelValue":w[9]||(w[9]=U=>_.max_photo_size_mb=U),min:.1,max:10,step:.1,precision:1,"controls-position":"right"},null,8,["modelValue"])])]),o("div",Lbe,[o("div",Rbe,[n(Rt,{title:c(d)("Auto-approve Photo Reviews")},null,8,["title"]),o("p",Obe,f(c(d)("Publish reviews with photos immediately. When off, photo reviews always wait for moderation.")),1)]),o("div",Pbe,[n(b,{modelValue:_.auto_approve_photo_reviews,"onUpdate:modelValue":w[10]||(w[10]=U=>_.auto_approve_photo_reviews=U),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])]),o("div",Hbe,[o("div",Nbe,[n(Rt,{title:c(d)("Allowed File Types")},null,8,["title"])]),o("div",Kbe,[n(D,{modelValue:_.allowed_photo_types,"onUpdate:modelValue":w[11]||(w[11]=U=>_.allowed_photo_types=U)},{default:u(()=>[n(V,{label:"jpeg"},{default:u(()=>w[13]||(w[13]=[R("JPEG",-1)])),_:1,__:[13]}),n(V,{label:"png"},{default:u(()=>w[14]||(w[14]=[R("PNG",-1)])),_:1,__:[14]}),n(V,{label:"gif"},{default:u(()=>w[15]||(w[15]=[R("GIF",-1)])),_:1,__:[15]}),n(V,{label:"webp"},{default:u(()=>w[16]||(w[16]=[R("WebP",-1)])),_:1,__:[16]})]),_:1},8,["modelValue"])])])],64)):B("",!0),o("div",Gbe,[o("div",zbe,[n(Rt,{title:c(d)("Helpful Votes")},null,8,["title"]),o("p",jbe,f(c(d)("Let visitors mark reviews as helpful.")),1),c(l)?B("",!0):(r(),m("p",qbe,[R(f(c(d)("This feature is only available in FluentCart Pro."))+" ",1),n(I,{size:"small",tag:"a",link:"",href:c(Mo)("feature_lock_review_settings"),target:"_blank",rel:"noopener noreferrer"},{default:u(()=>[R(f(c(d)("Upgrade to Pro")),1)]),_:1},8,["href"])]))]),o("div",Ybe,[n(b,{modelValue:_.enable_helpful_votes,"onUpdate:modelValue":w[12]||(w[12]=U=>_.enable_helpful_votes=U),"active-value":"yes","inactive-value":"no",disabled:!c(l)},null,8,["modelValue","disabled"])])])]))]),_:1},8,["visible"])]),_:1})]),_:1})])])}}}),Xbe={name:"CheckoutFields",components:{Animation:_a,CardHeader:Qe,Card:$e,CardBody:xe,SettingsHeader:$a,AdminNotice:Fa},data(){return{fields:{},settings:{},saving:!1,fetching:!1}},watch:{"settings.basic_info.last_name.enabled"(e){var t,a;e==="yes"&&((a=(t=this.settings.basic_info)==null?void 0:t.first_name)==null?void 0:a.enabled)==="no"&&(this.settings.basic_info.first_name.enabled="yes")},"settings.business_details":{deep:!0,handler(e){var a,l,s;if(!e||!e.b2b_only_mode)return;((a=e.company_name)==null?void 0:a.enabled)==="yes"||((l=e.vat_number)==null?void 0:l.enabled)==="yes"||((s=e.legal_registration_id)==null?void 0:s.enabled)==="yes"||(e.b2b_only_mode.enabled="no")}}},mounted(){this.getFields()},methods:{translate:d,isFirstNameDisabled(e,t){var a,l;return e==="basic_info"&&t==="first_name"&&((l=(a=this.settings.basic_info)==null?void 0:a.last_name)==null?void 0:l.enabled)==="yes"},isB2BOnlyModeDisabled(e,t){var l,s,i;if(e!=="business_details"||t!=="b2b_only_mode")return!1;const a=this.settings.business_details||{};return((l=a.company_name)==null?void 0:l.enabled)!=="yes"&&((s=a.vat_number)==null?void 0:s.enabled)!=="yes"&&((i=a.legal_registration_id)==null?void 0:i.enabled)!=="yes"},shouldDimLabel(e,t){var a,l,s,i,A,p,h;return((s=(l=(a=this.settings)==null?void 0:a[e])==null?void 0:l[t])==null?void 0:s.enabled)==="no"?!0:e==="basic_info"&&t==="full_name"?((A=(i=this.settings.basic_info)==null?void 0:i.first_name)==null?void 0:A.enabled)==="yes"||((h=(p=this.settings.basic_info)==null?void 0:p.last_name)==null?void 0:h.enabled)==="yes":!1},isVisible(e,t){var a,l,s,i;return t==="full_name"?((l=(a=this.settings.basic_info)==null?void 0:a.first_name)==null?void 0:l.enabled)!=="yes"&&((i=(s=this.settings.basic_info)==null?void 0:s.last_name)==null?void 0:i.enabled)!=="yes":!0},getFields(){this.fetching=!0,this.$get("checkout-fields/get-fields").then(e=>{this.fields=e.fields||{},this.settings=e.settings||{}}).catch(e=>{this.handleError(e)}).finally(()=>{this.fetching=!1})},saveFields(){this.saving=!0,this.$post("checkout-fields/save-fields",{settings:this.settings}).then(e=>{this.$notify.success(e.message||this.$t("Settings saved successfully!")),this.getFields()}).catch(e=>{this.handleError(e)}).finally(()=>{this.saving=!1})},formatSectionTitle(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}}},Jbe={class:"setting-wrap"},Zbe={class:"setting-wrap-inner"},e0e={class:"fct-checkout-fields-wrapp"},t0e={class:"field-heading"},a0e={class:"fct-checkout-fields"},l0e={key:0,class:"fct-checkout-field"},s0e={class:"fct-checkout-field-info"},n0e={class:"fct-checkout-field-label-wrap"},o0e={class:"fct-checkout-field-tags"},i0e={key:0,class:"fct-checkout-field-info-desc"},r0e={key:0,class:"fct-checkout-field-action"},d0e={key:1,class:"fct-checkout-field-input"},u0e={class:"fct-checkout-field-info"},c0e={class:"fct-checkout-field-label-wrap"},A0e={key:1,class:"fct-checkout-field-tags"},p0e={key:0,class:"fct-checkout-field-info-desc"},f0e={key:0,class:"fct-checkout-field-action"},m0e={class:"form-section-save-action"};function h0e(e,t,a,l,s,i){const A=k("SettingsHeader"),p=k("AdminNotice"),h=k("el-skeleton"),_=k("el-switch"),y=k("el-tag"),g=k("el-checkbox"),v=k("el-input"),C=k("CardBody"),w=k("Card"),b=k("el-button");return r(),m("div",Jbe,[n(A,{heading:i.translate("Checkout Fields"),loading:s.saving,onOnSave:i.saveFields},null,8,["heading","loading","onOnSave"]),o("div",Zbe,[n(p),o("div",e0e,[n(w,null,{default:u(()=>[n(C,null,{default:u(()=>[n(h,{loading:s.fetching,animated:"",rows:5},null,8,["loading"]),s.fetching?B("",!0):(r(!0),m(P,{key:0},ae(s.fields,(S,F)=>(r(),m("div",{key:F,class:"fct-checkout-field-section"},[o("h3",t0e,f(i.formatSectionTitle(F)),1),o("div",a0e,[S.label?(r(),m("div",l0e,[o("div",s0e,[o("div",n0e,[S.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[F].enabled,"onUpdate:modelValue":Q=>s.settings[F].enabled=Q,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])):B("",!0),o("span",{class:ue(`fct-checkout-field-label ${s.settings[F].enabled==="no"?"opacity-50":""}`)},f(S.label),3),o("div",o0e,[S.can_alter!=="yes"&&s.settings[F].enabled==="yes"?(r(),E(y,{key:0,size:"small"},{default:u(()=>[R(f(i.translate("System")),1)]),_:1})):B("",!0),s.settings[F].required==="yes"&&s.settings[F].enabled==="yes"?(r(),E(y,{key:1,size:"small"},{default:u(()=>[R(f(i.translate("Required")),1)]),_:1})):B("",!0)])]),S.help_text?(r(),m("div",i0e,f(S.help_text),1)):B("",!0)]),S.can_alter==="yes"?(r(),m("div",r0e,[n(g,{modelValue:s.settings[F].required,"onUpdate:modelValue":Q=>s.settings[F].required=Q,"true-label":"yes","false-label":"no",disabled:s.settings[F].enabled!=="yes"},{default:u(()=>[R(f(i.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),s.settings[F].hasOwnProperty("text")&&s.settings[F].enabled==="yes"?(r(),m("div",d0e,[n(v,{type:"textarea",modelValue:s.settings[F].text,"onUpdate:modelValue":Q=>s.settings[F].text=Q,disabled:s.settings[F].enabled!=="yes"},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0)])):(r(!0),m(P,{key:1},ae(S,(Q,$)=>(r(),m("div",{key:$,class:"fct-checkout-field"},[o("div",u0e,[o("div",c0e,[Q.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[F][$].enabled,"onUpdate:modelValue":x=>s.settings[F][$].enabled=x,"active-value":"yes","inactive-value":"no",disabled:i.isFirstNameDisabled(F,$)||i.isB2BOnlyModeDisabled(F,$)},null,8,["modelValue","onUpdate:modelValue","disabled"])):B("",!0),o("span",{class:ue(["fct-checkout-field-label",i.shouldDimLabel(F,$)?"opacity-50":""])},f(Q.label),3),i.isVisible(Q,$)?(r(),m("div",A0e,[Q.can_alter!=="yes"&&s.settings[F][$].enabled==="yes"?(r(),E(y,{key:0,size:"small"},{default:u(()=>[R(f(i.translate("System")),1)]),_:1})):B("",!0),s.settings[F][$].required==="yes"&&s.settings[F][$].enabled==="yes"?(r(),E(y,{key:1,size:"small"},{default:u(()=>[R(f(i.translate("Required")),1)]),_:1})):B("",!0)])):B("",!0)]),Q.help_text?(r(),m("div",p0e,f(Q.help_text),1)):B("",!0)]),Q.can_alter==="yes"&&$!=="first_name"&&$!=="b2b_only_mode"?(r(),m("div",f0e,[n(g,{modelValue:s.settings[F][$].required,"onUpdate:modelValue":x=>s.settings[F][$].required=x,"true-label":"yes","false-label":"no",disabled:s.settings[F][$].enabled!=="yes"},{default:u(()=>[R(f(i.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0)]))),128))])]))),128))]),_:1})]),_:1}),o("div",m0e,[n(b,{type:"primary",onClick:i.saveFields,loading:s.saving},{default:u(()=>[R(f(i.translate("Save")),1)]),_:1},8,["onClick","loading"])])])])])}const _0e=nt(Xbe,[["render",h0e]]);var Io={exports:{}};/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/var v0e=Io.exports,Vc;function g0e(){return Vc||(Vc=1,function(e,t){((a,l)=>{e.exports=l()})(v0e,function a(){var l=typeof self<"u"?self:typeof window<"u"?window:l!==void 0?l:{},s,i=!l.document&&!!l.postMessage,A=l.IS_PAPA_WORKER||!1,p={},h=0,_={};function y(U){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(L){var O=I(L);O.chunkSize=parseInt(O.chunkSize),L.step||L.chunk||(O.chunkSize=null),this._handle=new b(O),(this._handle.streamer=this)._config=O}).call(this,U),this.parseChunk=function(L,O){var M=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),A)l.postMessage({results:H,workerId:_.WORKER_ID,finished:M});else if(D(this._config.chunk)&&!O){if(this._config.chunk(H,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=H=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(H.data),this._completeResults.errors=this._completeResults.errors.concat(H.errors),this._completeResults.meta=H.meta),this._completed||!M||!D(this._config.complete)||H&&H.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),M||H&&H.meta.paused||this._nextChunk(),H}this._halted=!0},this._sendError=function(L){D(this._config.error)?this._config.error(L):A&&this._config.error&&l.postMessage({workerId:_.WORKER_ID,error:L,finished:!1})}}function g(U){var L;(U=U||{}).chunkSize||(U.chunkSize=_.RemoteChunkSize),y.call(this,U),this._nextChunk=i?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(O){this._input=O,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(L=new XMLHttpRequest,this._config.withCredentials&&(L.withCredentials=this._config.withCredentials),i||(L.onload=V(this._chunkLoaded,this),L.onerror=V(this._chunkError,this)),L.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var O,M=this._config.downloadRequestHeaders;for(O in M)L.setRequestHeader(O,M[O])}var H;this._config.chunkSize&&(H=this._start+this._config.chunkSize-1,L.setRequestHeader("Range","bytes="+this._start+"-"+H));try{L.send(this._config.downloadRequestBody)}catch(j){this._chunkError(j.message)}i&&L.status===0&&this._chunkError()}},this._chunkLoaded=function(){L.readyState===4&&(L.status<200||400<=L.status?this._chunkError():(this._start+=this._config.chunkSize||L.responseText.length,this._finished=!this._config.chunkSize||this._start>=(O=>(O=O.getResponseHeader("Content-Range"))!==null?parseInt(O.substring(O.lastIndexOf("/")+1)):-1)(L),this.parseChunk(L.responseText)))},this._chunkError=function(O){O=L.statusText||O,this._sendError(new Error(O))}}function v(U){(U=U||{}).chunkSize||(U.chunkSize=_.LocalChunkSize),y.call(this,U);var L,O,M=typeof FileReader<"u";this.stream=function(H){this._input=H,O=H.slice||H.webkitSlice||H.mozSlice,M?((L=new FileReader).onload=V(this._chunkLoaded,this),L.onerror=V(this._chunkError,this)):L=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(H.target.result)},this._chunkError=function(){this._sendError(L.error)}}function C(U){var L;y.call(this,U=U||{}),this.stream=function(O){return L=O,this._nextChunk()},this._nextChunk=function(){var O,M;if(!this._finished)return O=this._config.chunkSize,L=O?(M=L.substring(0,O),L.substring(O)):(M=L,""),this._finished=!L,this.parseChunk(M)}}function w(U){y.call(this,U=U||{});var L=[],O=!0,M=!1;this.pause=function(){y.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){y.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(H){this._input=H,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){M&&L.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),L.length?this.parseChunk(L.shift()):O=!0},this._streamData=V(function(H){try{L.push(typeof H=="string"?H:H.toString(this._config.encoding)),O&&(O=!1,this._checkIsFinished(),this.parseChunk(L.shift()))}catch(j){this._streamError(j)}},this),this._streamError=V(function(H){this._streamCleanUp(),this._sendError(H)},this),this._streamEnd=V(function(){this._streamCleanUp(),M=!0,this._streamData("")},this),this._streamCleanUp=V(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function b(U){var L,O,M,H,j=Math.pow(2,53),W=-j,G=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,Y=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,J=this,de=0,z=0,ce=!1,oe=!1,Z=[],N={data:[],errors:[],meta:{}};function le(Ue){return U.skipEmptyLines==="greedy"?Ue.join("").trim()==="":Ue.length===1&&Ue[0].length===0}function ee(){if(N&&M&&(re("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+_.DefaultDelimiter+"'"),M=!1),U.skipEmptyLines&&(N.data=N.data.filter(function(ge){return!le(ge)})),pe()){let ge=function(Ce,Oe){D(U.transformHeader)&&(Ce=U.transformHeader(Ce,Oe)),Z.push(Ce)};if(N)if(Array.isArray(N.data[0])){for(var Ue=0;pe()&&Ue(At=>(U.dynamicTypingFunction&&U.dynamicTyping[At]===void 0&&(U.dynamicTyping[At]=U.dynamicTypingFunction(At)),(U.dynamicTyping[At]||U.dynamicTyping)===!0))(Ve)?Le==="true"||Le==="TRUE"||Le!=="false"&&Le!=="FALSE"&&((At=>{if(G.test(At)&&(At=parseFloat(At),W=Z.length?"__parsed_extra":Z[Ee]:fe,ye=U.transform?U.transform(ye,fe):ye);fe==="__parsed_extra"?(Oe[fe]=Oe[fe]||[],Oe[fe].push(ye)):Oe[fe]=ye}return U.header&&(Ee>Z.length?re("FieldMismatch","TooManyFields","Too many fields: expected "+Z.length+" fields but parsed "+Ee,z+Ce):EeU.preview?O.abort():(N.data=N.data[0],H(N,J))))}),this.parse=function(Ue,we,Be){var ge=U.quoteChar||'"',ge=(U.newline||(U.newline=this.guessLineEndings(Ue,ge)),M=!1,U.delimiter?D(U.delimiter)&&(U.delimiter=U.delimiter(Ue),N.meta.delimiter=U.delimiter):((ge=((Ce,Oe,Ee,fe,ye)=>{var Ve,Le,At,mt;ye=ye||[","," ","|",";",_.RECORD_SEP,_.UNIT_SEP];for(var Mt=0;Mt=Be.length/2?`\r
`:"\r"}}function S(U){return U.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F(U){var L=(U=U||{}).delimiter,O=U.newline,M=U.comments,H=U.step,j=U.preview,W=U.fastMode,G=null,Y=!1,J=U.quoteChar==null?'"':U.quoteChar,de=J;if(U.escapeChar!==void 0&&(de=U.escapeChar),(typeof L!="string"||-1<_.BAD_DELIMITERS.indexOf(L))&&(L=","),M===L)throw new Error("Comment character same as delimiter");M===!0?M="#":(typeof M!="string"||-1<_.BAD_DELIMITERS.indexOf(M))&&(M=!1),O!==`
`&&O!=="\r"&&O!==`\r
`&&(O=`
`);var z=0,ce=!1;this.parse=function(oe,Z,N){if(typeof oe!="string")throw new Error("Input must be a string");var le=oe.length,ee=L.length,pe=O.length,re=M.length,Ue=D(H),we=[],Be=[],ge=[],Ce=z=0;if(!oe)return pt();if(W||W!==!1&&oe.indexOf(J)===-1){for(var Oe=oe.split(O),Ee=0;Ee=j)return pt(!0);break}Be.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:we.length,index:z}),Le++}}else if(M&&ge.length===0&&oe.substring(z,z+re)===M){if(ye===-1)return pt();z=ye+pe,ye=oe.indexOf(O,z),fe=oe.indexOf(L,z)}else if(fe!==-1&&(fe=j)return pt(!0)}return Dt();function mt(Ct){we.push(Ct),Ce=z}function Mt(Ct){var $t=0;return $t=Ct!==-1&&(Ct=oe.substring(Le+1,Ct))&&Ct.trim()===""?Ct.length:$t}function Dt(Ct){return N||(Ct===void 0&&(Ct=oe.substring(z)),ge.push(Ct),z=le,mt(ge),Ue&&jt()),pt()}function Xe(Ct){z=Ct,mt(ge),ge=[],ye=oe.indexOf(O,z)}function pt(Ct){if(U.header&&!Z&&we.length&&!Y){var $t=we[0],Ht=Object.create(null),Nt=new Set($t);let Qt=!1;for(let yt=0;yt<$t.length;yt++){let Xt=$t[yt];if(Ht[Xt=D(U.transformHeader)?U.transformHeader(Xt,yt):Xt]){let be,Ie=Ht[Xt];for(;be=Xt+"_"+Ie,Ie++,Nt.has(be););Nt.add(be),$t[yt]=be,Ht[Xt]++,Qt=!0,(G=G===null?{}:G)[be]=Xt}else Ht[Xt]=1,$t[yt]=Xt;Nt.add(Xt)}Qt&&console.warn("Duplicate headers found and renamed."),Y=!0}return{data:we,errors:Be,meta:{delimiter:L,linebreak:O,aborted:ce,truncated:!!Ct,cursor:Ce+(Z||0),renamedHeaders:G}}}function jt(){H(pt()),we=[],Be=[]}},this.abort=function(){ce=!0},this.getCharIndex=function(){return z}}function Q(U){var L=U.data,O=p[L.workerId],M=!1;if(L.error)O.userError(L.error,L.file);else if(L.results&&L.results.data){var H={abort:function(){M=!0,$(L.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:x,resume:x};if(D(O.userStep)){for(var j=0;jM.charCodeAt(0)!==65279?M:M.slice(1))(U),O=new(L.download?g:C)(L)):U.readable===!0&&D(U.read)&&D(U.on)?O=new w(L):(l.File&&U instanceof File||U instanceof Object)&&(O=new v(L)),O.stream(U);(O=(()=>{var M;return!!_.WORKERS_SUPPORTED&&(M=(()=>{var H=l.URL||l.webkitURL||null,j=a.toString();return _.BLOB_URL||(_.BLOB_URL=H.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",j,")();"],{type:"text/javascript"})))})(),(M=new l.Worker(M)).onmessage=Q,M.id=h++,p[M.id]=M)})()).userStep=L.step,O.userChunk=L.chunk,O.userComplete=L.complete,O.userError=L.error,L.step=D(L.step),L.chunk=D(L.chunk),L.complete=D(L.complete),L.error=D(L.error),delete L.worker,O.postMessage({input:U,config:L,workerId:O.id})},_.unparse=function(U,L){var O=!1,M=!0,H=",",j=`\r
`,W='"',G=W+W,Y=!1,J=null,de=!1,z=((()=>{if(typeof L=="object"){if(typeof L.delimiter!="string"||_.BAD_DELIMITERS.filter(function(Z){return L.delimiter.indexOf(Z)!==-1}).length||(H=L.delimiter),typeof L.quotes!="boolean"&&typeof L.quotes!="function"&&!Array.isArray(L.quotes)||(O=L.quotes),typeof L.skipEmptyLines!="boolean"&&typeof L.skipEmptyLines!="string"||(Y=L.skipEmptyLines),typeof L.newline=="string"&&(j=L.newline),typeof L.quoteChar=="string"&&(W=L.quoteChar),typeof L.header=="boolean"&&(M=L.header),Array.isArray(L.columns)){if(L.columns.length===0)throw new Error("Option columns is empty");J=L.columns}L.escapeChar!==void 0&&(G=L.escapeChar+W),L.escapeFormulae instanceof RegExp?de=L.escapeFormulae:typeof L.escapeFormulae=="boolean"&&L.escapeFormulae&&(de=/^[=+\-@\t\r].*$/)}})(),new RegExp(S(W),"g"));if(typeof U=="string"&&(U=JSON.parse(U)),Array.isArray(U)){if(!U.length||Array.isArray(U[0]))return ce(null,U,Y);if(typeof U[0]=="object")return ce(J||Object.keys(U[0]),U,Y)}else if(typeof U=="object")return typeof U.data=="string"&&(U.data=JSON.parse(U.data)),Array.isArray(U.data)&&(U.fields||(U.fields=U.meta&&U.meta.fields||J),U.fields||(U.fields=Array.isArray(U.data[0])?U.fields:typeof U.data[0]=="object"?Object.keys(U.data[0]):[]),Array.isArray(U.data[0])||typeof U.data[0]=="object"||(U.data=[U.data])),ce(U.fields||[],U.data||[],Y);throw new Error("Unable to serialize unrecognized input");function ce(Z,N,le){var ee="",pe=(typeof Z=="string"&&(Z=JSON.parse(Z)),typeof N=="string"&&(N=JSON.parse(N)),Array.isArray(Z)&&0{for(var Ue=0;UeYL(G,w.thousand),S=G=>{G&&Dc.parse(G,{header:!0,complete:function(Y){p.value=Y.data,A.value=Y.meta.fields,y.value=A.value.includes("Type")&&A.value.includes("Parent"),Q(),y.value&&I(),C.value=!0}})},F=()=>{_.value={},A.value=[],p.value=[],C.value=!1,y.value=!1},Q=()=>{const G=[],Y=[];let J=0;A.value.forEach(de=>{let z=null,ce=null;const oe=de.toString();for(const[Z,N]of g.entries())if(oe.toLocaleLowerCase().startsWith(N)){const le=de.toString().match(/ \d+ /g);if(Array.isArray(le)&&le.length===1){let ee=le[0];J=ee>J?ee:J,z=de.toString().replace(le[0]," %d "),ce=de.toString().replace(le[0]," ");break}}z!=null?G.includes(z)||(G.push(z),Y.push({title:ce,value:z})):Y.push({title:de,value:de})}),_.value=Y,v=J},$=()=>window.fluentCartRestVars.rest.url+"/files/upload",x={post_id:["ID"],post_title:["Name"],post_name:["SKU"],post_content:["description","Description"],post_excerpt:["Short description","Short Description"],post_status:["Published"],comment_status:["Allow customer reviews?"],item_price:["Regular price","Meta: _subscription_price"],compare_price:["Sale price"],images:["Images"],categories:["Categories"],sku:["SKU"],payment_type:["Payment Type"],repeat_interval:["Subscription Interval","Meta: _subscription_period"],trial_days:["Trial Days","Meta: _subscription_trial_length"],installment:["Installment"],installment_count:["Installment Count"],manage_setup_fee:["Setup Fee"],signup_fee_name:["Setup Fee Name"],signup_fee:["Setup Fee Amount","Meta: _subscription_sign_up_fee"]},I=()=>{for(const[G,Y]of Object.entries(x))if(h.value[G]){for(const J of Y)if(A.value.includes(J)){h.value[G].value=J;break}}},V=G=>G?{day:"daily",week:"weekly",month:"monthly",year:"yearly"}[G.trim().toLowerCase()]||G:"",D=G=>{if(!G)return"";const Y=G.split(",").map(J=>J.trim().toLowerCase());return Y.includes("variation")?"variation":Y.includes("variable")?"variable":Y.includes("subscription")?"subscription":Y.includes("simple")?"simple":Y[0]||""},U=(G=!0)=>{const Y=[],J={},de=h.value,z={description:"",payment_type:"onetime",times:"",repeat_interval:"",trial_days:"",billing_summary:"",manage_setup_fee:"no",signup_fee_name:"",signup_fee:"",setup_fee_per_item:"no"},ce=Z=>{const N=[];for(let le=1;le<=10;le++){const ee=`Attribute ${le} name`,pe=`Attribute ${le} value(s)`;Z[ee]&&Z[pe]&&N.push(Z[pe])}return N.join(" - ")},oe=Z=>Z==="1"||Z===1?"published":Z==="0"||Z===0?"draft":Z||"published";p.value.forEach(Z=>{var Be,ge,Ce,Oe,Ee,fe,ye,Ve,Le,At,mt,Mt,Dt,Xe,pt,jt,Ct,$t,Ht,Nt;const N=D(Z.Type);if(N!=="simple"&&N!=="variable"&&N!=="subscription")return;const le={};le._cid=hl(),le.post_title=Z[(Be=de.post_title)==null?void 0:Be.value]||"",le.post_name=Z[(ge=de.post_name)==null?void 0:ge.value]||le.post_title,le.ID=Z[(Ce=de.post_id)==null?void 0:Ce.value]||"",le.post_content=Z[(Oe=de.post_content)==null?void 0:Oe.value]||"",le.post_excerpt=Z[(Ee=de.post_excerpt)==null?void 0:Ee.value]||"",le.post_status=oe(Z[(fe=de.post_status)==null?void 0:fe.value]);const ee={variation_type:N==="variable"?"simple_variations":"simple",manage_stock:"0",fulfillment_type:"physical"},pe=Z[(ye=de.images)==null?void 0:ye.value]||"",re=[];pe&&pe.split(",").map(Qt=>Qt.trim()).filter(Boolean).forEach(Qt=>{const yt=Qt.split("/").pop().split("?")[0]||"image";re.push({id:0,url:Qt,title:yt})}),le.detail=ee,le.gallery=re,le.variants=[];const Ue=Z[(Ve=de.categories)==null?void 0:Ve.value]||"";if(Ue?le.categories=Ue.split(",").map(Qt=>Qt.trim()).filter(Boolean):le.categories=[],N==="simple"||N==="subscription"){const Qt=b(Z[(Le=de.item_price)==null?void 0:Le.value]||""),yt=b(Z[(At=de.compare_price)==null?void 0:At.value]||""),Xt=Z[(mt=de.sku)==null?void 0:mt.value]||"",be=N==="subscription"?"subscription":Z[(Mt=de.payment_type)==null?void 0:Mt.value]||"onetime",Ie=V(Z[(Dt=de.repeat_interval)==null?void 0:Dt.value]||""),it=Z[(Xe=de.trial_days)==null?void 0:Xe.value]||"",kt=Z[(pt=de.installment)==null?void 0:pt.value]||"",Bt=Z[(jt=de.installment_count)==null?void 0:jt.value]||"",ta=Z[(Ct=de.manage_setup_fee)==null?void 0:Ct.value]||"",bt=Z[($t=de.signup_fee_name)==null?void 0:$t.value]||"",sa=b(Z[(Ht=de.signup_fee)==null?void 0:Ht.value]||"");(Qt||le.post_title)&&le.variants.push({_cid:hl(),variation_title:le.post_title,sku:Xt,item_price:Qt,compare_price:yt,other_info:{...z,payment_type:be,repeat_interval:Ie,trial_days:it,installment:kt==="yes"?"yes":"no",times:Bt,manage_setup_fee:ta==="yes"?"yes":"no",signup_fee_name:bt,signup_fee:sa},media:[]})}const we=Z[(Nt=de.sku)==null?void 0:Nt.value]||"";N==="variable"&&we&&(J[we]=le),Y.push(le)}),p.value.forEach(Z=>{var At,mt,Mt,Dt,Xe,pt,jt,Ct,$t,Ht,Nt,Qt;if(D(Z.Type)!=="variation")return;const N=Z.Parent;if(!N||!J[N])return;const le=ce(Z),ee=b(Z[(At=de.item_price)==null?void 0:At.value]||""),pe=b(Z[(mt=de.compare_price)==null?void 0:mt.value]||""),re=Z[(Mt=de.images)==null?void 0:Mt.value]||"",Ue=[];re&&re.split(",").map(yt=>yt.trim()).filter(Boolean).forEach(yt=>{const Xt=yt.split("/").pop().split("?")[0]||"image";Ue.push({id:0,url:yt,title:Xt})});const we=Z[(Dt=de.sku)==null?void 0:Dt.value]||"",Be=Z[(Xe=de.payment_type)==null?void 0:Xe.value]||"onetime",ge=V(Z[(pt=de.repeat_interval)==null?void 0:pt.value]||""),Ce=Z[(jt=de.trial_days)==null?void 0:jt.value]||"",Oe=Z[(Ct=de.installment)==null?void 0:Ct.value]||"",Ee=Z[($t=de.installment_count)==null?void 0:$t.value]||"",fe=Z[(Ht=de.manage_setup_fee)==null?void 0:Ht.value]||"",ye=Z[(Nt=de.signup_fee_name)==null?void 0:Nt.value]||"",Ve=b(Z[(Qt=de.signup_fee)==null?void 0:Qt.value]||""),Le={_cid:hl(),variation_title:le||Z.Name||"",sku:we,item_price:ee,compare_price:pe,other_info:{...z,payment_type:Be,repeat_interval:ge,trial_days:Ce,installment:Oe==="yes"?"yes":"no",times:Ee,manage_setup_fee:fe==="yes"?"yes":"no",signup_fee_name:ye,signup_fee:Ve},media:Ue};J[N].variants.push(Le)}),W("onDataPopulated",{products:Y,concat:G})},L=(G=!0)=>{if(y.value)return U(G);const Y=[];p.value.forEach(J=>{var Ee,fe,ye,Ve,Le,At,mt,Mt,Dt,Xe,pt,jt;const de={};de._cid=hl();const z=h.value;de.post_title=J[z.post_title.value]??"",de.post_name=J[z.post_name.value]??de.post_title,de.ID=J[z.post_id.value]??"",de.post_content=J[z.post_content.value]??"",de.post_excerpt=J[z.post_excerpt.value]??"",de.post_status=J[(Ee=z.post_status)==null?void 0:Ee.value]||"published",de.comment_status="close";const ce=J[(fe=z.images)==null?void 0:fe.value]||"",oe=[];ce&&ce.split(",").map(Ct=>Ct.trim()).filter(Boolean).forEach(Ct=>{const $t=Ct.split("/").pop().split("?")[0]||"image";oe.push({id:0,url:Ct,title:$t})});const Z=J[(ye=z.categories)==null?void 0:ye.value]||"";Z?de.categories=Z.split(",").map(Ct=>Ct.trim()).filter(Boolean):de.categories=[];const N=J[(Ve=z.sku)==null?void 0:Ve.value]||"",le=J[(Le=z.payment_type)==null?void 0:Le.value]||"onetime",ee=J[(At=z.repeat_interval)==null?void 0:At.value]||"",pe=J[(mt=z.trial_days)==null?void 0:mt.value]||"",re=J[(Mt=z.installment)==null?void 0:Mt.value]||"",Ue=J[(Dt=z.installment_count)==null?void 0:Dt.value]||"",we=J[(Xe=z.manage_setup_fee)==null?void 0:Xe.value]||"",Be=J[(pt=z.signup_fee_name)==null?void 0:pt.value]||"",ge=b(J[(jt=z.signup_fee)==null?void 0:jt.value]||""),Ce={variation_type:"simple",manage_stock:"0",fulfillment_type:"physical"},Oe={description:"",payment_type:le,times:Ue,repeat_interval:ee,trial_days:pe,billing_summary:"",manage_setup_fee:we==="yes"?"yes":"no",signup_fee_name:Be,signup_fee:ge,setup_fee_per_item:"no",installment:re==="yes"?"yes":"no"};de.gallery=oe,de.variants=[];for(let Ct=1;Ct<=v;Ct++){const $t={};["variation_title","item_price","compare_price"].forEach(Ht=>{var Qt;const Nt=((Qt=z[Ht])==null?void 0:Qt.value)??"";if(Nt.length>0){const yt=Nt.replace("%d",Ct.toString()),Xt=J[yt];$t[Ht]=Ht==="variation_title"?Xt:b(Xt)}}),H($t)&&($t._cid=hl(),$t.sku=N,$t.other_info={...Oe},$t.media=[],de.variants.push($t))}de.variants.length>0?(Ce.variation_type="simple_variations",de.detail=Ce,Y.push(de)):H(de)&&(de.variants.push({_cid:hl(),variation_title:"",sku:N,item_price:0,compare_price:0,other_info:{...Oe},media:[]}),de.detail=Ce,Y.push(de))}),W("onDataPopulated",{products:Y,concat:G})},O=()=>{l.value=!1,s.value=[],i.value=null,F()},M=(G=!0)=>{L(G),O()},H=G=>{let Y=!1;for(const[J,de]of Object.entries(G))if(typeof de!==null&&typeof de<"u"&&(Array.isArray(de)&&de.length>0||de.toString().length>0)){Y=!0;break}return Y};De(()=>{h.value={post_id:{title:a.$t("Post ID"),value:""},post_title:{title:a.$t("Post Title"),value:""},post_name:{title:a.$t("Post Name"),value:""},post_content:{title:a.$t("Post Content"),value:""},post_excerpt:{title:a.$t("Post Excerpt"),value:""},post_status:{title:a.$t("Post Status"),value:""},post_date:{title:a.$t("Post Date"),value:""},comment_status:{title:a.$t("Comment Status"),value:""},images:{title:a.$t("Images"),value:""},variation_title:{title:a.$t("Variation Title"),value:""},item_price:{title:a.$t("Variation Price"),value:""},compare_price:{title:a.$t("Variation Compare Price"),value:""},sku:{title:a.$t("SKU"),value:""},categories:{title:a.$t("Categories"),value:""},payment_type:{title:a.$t("Payment Type"),value:""},repeat_interval:{title:a.$t("Subscription Interval"),value:""},trial_days:{title:a.$t("Trial Days"),value:""},installment:{title:a.$t("Installment"),value:""},installment_count:{title:a.$t("Installment Count"),value:""},manage_setup_fee:{title:a.$t("Setup Fee"),value:""},signup_fee_name:{title:a.$t("Setup Fee Name"),value:""},signup_fee:{title:a.$t("Setup Fee Amount"),value:""}}});const j=()=>{const G=[{ID:"",Type:"simple",SKU:"BASIC-TEE-001",Name:"Classic Cotton T-Shirt",Published:1,"Short description":"Comfortable everyday cotton tee",description:"Made from 100% organic cotton. Pre-shrunk and machine washable.",Categories:"Clothing, Clothing > T-Shirts",Images:"https://example.com/images/tee-front.jpg, https://example.com/images/tee-back.jpg",Parent:"","Regular price":"29.99","Sale price":"24.99","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"onetime","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"simple",SKU:"STARTER-PLAN",Name:"Starter Membership Plan",Published:1,"Short description":"Monthly access to premium content",description:"Get access to all premium tutorials and resources. Cancel anytime.",Categories:"Memberships",Images:"",Parent:"","Regular price":"9.99","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"subscription","Subscription Interval":"monthly","Trial Days":"14",Installment:"","Installment Count":"","Setup Fee":"yes","Setup Fee Name":"Activation Fee","Setup Fee Amount":"4.99"},{ID:"",Type:"simple",SKU:"PRO-YEARLY",Name:"Pro Annual Plan",Published:1,"Short description":"12-month installment plan",description:"Pay in 12 monthly installments for annual access to all pro features.",Categories:"Memberships",Images:"",Parent:"","Regular price":"19.99","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"subscription","Subscription Interval":"monthly","Trial Days":"",Installment:"yes","Installment Count":"12","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variable",SKU:"HOODIE-PREMIUM",Name:"Premium Zip Hoodie",Published:1,"Short description":"Heavyweight zip-up hoodie",description:"Premium quality hoodie with YKK zipper. Available in multiple colors.",Categories:"Clothing, Clothing > Hoodies",Images:"https://example.com/images/hoodie-main.jpg, https://example.com/images/hoodie-side.jpg, https://example.com/images/hoodie-detail.jpg",Parent:"","Regular price":"","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-BLK",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"https://example.com/images/hoodie-black.jpg",Parent:"HOODIE-PREMIUM","Regular price":"59.99","Sale price":"","Attribute 1 name":"Color","Attribute 1 value(s)":"Black","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-WHT",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"",Parent:"HOODIE-PREMIUM","Regular price":"59.99","Sale price":"","Attribute 1 name":"Color","Attribute 1 value(s)":"White","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-BLU-LE",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"",Parent:"HOODIE-PREMIUM","Regular price":"69.99","Sale price":"64.99","Attribute 1 name":"Color","Attribute 1 value(s)":"Blue","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""}],Y=Dc.unparse(G),J=new Blob([Y],{type:"text/csv;charset=utf-8;"}),de=URL.createObjectURL(J),z=document.createElement("a");z.href=de,z.download="fluent-cart-sample-import.csv",document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(de)},W=t;return(G,Y)=>{const J=k("el-button"),de=k("el-upload"),z=k("el-option"),ce=k("el-select"),oe=k("el-dialog");return r(),m(P,null,[n(J,{onClick:Y[0]||(Y[0]=Z=>l.value=!0)},{default:u(()=>[R(f(G.$t("Import")),1)]),_:1}),n(oe,{modelValue:l.value,"onUpdate:modelValue":Y[4]||(Y[4]=Z=>l.value=Z),"append-to-body":!0,title:G.$t("Import Products"),class:"fct-bulk-import-dialog"},{default:u(()=>[C.value?B("",!0):(r(),E(de,{key:0,class:"fct-file-uploader",ref:"uploaderRef","file-list":s.value,"onUpdate:fileList":Y[1]||(Y[1]=Z=>s.value=Z),drag:"",action:$(),"on-progress":()=>{},"on-success":()=>{},"on-error":()=>{},"auto-upload":!1,"on-change":Z=>{F(),i.value=Z,S(Z==null?void 0:Z.raw)},multiple:!1,limit:1,"show-file-list":!0},{default:u(()=>[n(lt,{circle:"",bg:"primary",soft:""},{default:u(()=>[n(X,{name:"Upload"})]),_:1}),o("div",b0e,[R(f(G.$t("Drag & Drop or"))+" ",1),o("em",null,f(G.$t("Browse/Upload")),1),R(" "+f(G.$t("Files"))+" ",1),o("span",null,f(c(d)("Any Format upto %s",c(Tt).serverMaxUploadSize())),1)])]),_:1},8,["file-list","action","on-change"])),C.value?B("",!0):(r(),E(J,{key:1,onClick:j,link:""},{default:u(()=>[n(X,{name:"Download"}),R(" "+f(G.$t("Download a Sample CSV File")),1)]),_:1})),C.value?(r(),m(P,{key:2},[o("div",w0e,[o("h4",C0e,f(G.$t("Map Columns")),1),o("table",k0e,[o("thead",null,[o("tr",null,[o("th",null,f(G.$t("Products Fields")),1),o("th",null,f(G.$t("CSV Headers")),1)])]),o("tbody",null,[(r(!0),m(P,null,ae(h.value,(Z,N)=>(r(),m("tr",null,[o("td",null,f(Z.title),1),o("td",B0e,[n(ce,{modelValue:Z.value,"onUpdate:modelValue":le=>Z.value=le,filterable:"",clearable:""},{default:u(()=>[(r(!0),m(P,null,ae(_.value,le=>(r(),E(z,{key:le.value,label:le.title,value:le.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])])]))),256))])])]),o("div",x0e,[n(J,{onClick:Y[2]||(Y[2]=Z=>M())},{default:u(()=>[R(f(G.$t("Add Products")),1)]),_:1}),n(J,{onClick:Y[3]||(Y[3]=Z=>M(!1))},{default:u(()=>[R(f(G.$t("Clear and Add Products")),1)]),_:1})])],64)):B("",!0)]),_:1},8,["modelValue","title"])],64)}}};class $0e extends Md{beforeInit(){this.data.products=[],this.data.saving=!1,this.data.saveProgress={total:0,completed:0,errors:[],createdIds:[]},this.data.savingIds=new Set,this.data.savedIds=new Set,this.data.productErrors=new Map,this.data.categoryOptions=[],this.data.dummies.product={ID:"",post_title:"",post_name:"",post_content:"",post_excerpt:"",post_status:"published",post_date:new Date,comment_status:"close",categories:[],variants:!1}}populateDummyProduct(){const t={...this.data.dummies.product};t._cid=hl(),t.detail={...this.data.dummies.productDetail},t.gallery=[],t.downloadable_files={...this.data.dummies.downloadableFile},t.variants=[this.getDummyVariation(t)],this.data.products.push(t)}clearProducts(){this.data.products=[]}isSaving(t){return this.data.savingIds.has(t)}isSaved(t){return this.data.savedIds.has(t)}isRowDisabled(t){return this.isSaving(t)||this.isSaved(t)}hasError(t){return this.data.productErrors.has(t)}getError(t){const a=this.data.productErrors.get(t);return a?a.fields&&Object.keys(a.fields).length?Object.values(a.fields).join("; "):a.message||"":""}hasProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?!!a.message:Object.keys(a.fields).some(l=>!l.startsWith("variants.")):!1}getProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?a.message||"":Object.entries(a.fields).filter(([s])=>!s.startsWith("variants.")).map(([,s])=>s).join("; ")||"":""}hasVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return!1;const s=`variants.${a}.`;return Object.keys(l.fields).some(i=>i.startsWith(s))}getVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return"";const s=`variants.${a}.`;return Object.entries(l.fields).filter(([A])=>A.startsWith(s)).map(([,A])=>A).join("; ")}hasFieldError(t,a){var s;const l=this.data.productErrors.get(t);return!!((s=l==null?void 0:l.fields)!=null&&s[a])}hasVariantFieldError(t,a,l){return this.hasFieldError(t,`variants.${a}.${l}`)}chunkArray(t,a){const l=[];for(let s=0;s!this.data.savedIds.has(A._cid));if(a.length===0){q.error(d("No products to save."));return}const l=this.chunkArray(a,10);this.data.saving=!0,this.data.productErrors=new Map,this.data.saveProgress={total:l.length,completed:0,errors:[],createdIds:[]};try{for(const h of l){const _=h.map(y=>y._cid);for(const y of _)this.data.savingIds.add(y);this.data.savingIds=new Set(this.data.savingIds);try{const y=await Ae.post("products/bulk-insert",{products:h});if(y.created&&y.created.length){this.data.saveProgress.createdIds.push(...y.created);for(const g of y.created){this.data.savedIds.add(g._cid);const v=t.find(C=>C._cid===g._cid);v&&(v.ID=g.id,v.view_url=g.view_url||"")}this.data.savedIds=new Set(this.data.savedIds)}if(y.errors&&y.errors.length){this.data.saveProgress.errors.push(...y.errors);for(const g of y.errors)g._cid&&this.data.productErrors.set(g._cid,{message:g.message,fields:g.fields||{}});this.data.productErrors=new Map(this.data.productErrors)}}catch(y){const g=(s=y==null?void 0:y.data)==null?void 0:s.errors;if(Array.isArray(g)&&g.length){this.data.saveProgress.errors.push(...g);for(const v of g)v._cid&&this.data.productErrors.set(v._cid,{message:v.message,fields:v.fields||{}})}else{const v=((i=y==null?void 0:y.data)==null?void 0:i.message)||"A chunk failed to save";this.data.saveProgress.errors.push({message:v});for(const C of _)this.data.productErrors.set(C,{message:v,fields:{}})}this.data.productErrors=new Map(this.data.productErrors)}for(const y of _)this.data.savingIds.delete(y);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{createdIds:A,errors:p}=this.data.saveProgress;p.length===0?q.success(`${A.length} product(s) created successfully`):A.length>0?q.info(`${A.length} product(s) created, ${p.length} error(s)`):q.error(d("All products failed to save"))}finally{this.data.saving=!1}}async removeProduct(t){var l;if(t.ID&&this.data.savedIds.has(t._cid)){try{await Ae.delete(`products/${t.ID}`)}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to delete product from server";q.error(i);return}this.data.savedIds.delete(t._cid),this.data.savedIds=new Set(this.data.savedIds)}const a=this.data.products.indexOf(t);a!==-1&&this.data.products.splice(a,1)}removeVariant(t,a){const l=t.variants.indexOf(a);l!==-1&&t.variants.splice(l,1)}duplicateProduct(t){const a=JSON.parse(JSON.stringify(t));a._cid=hl(),a.post_title=a.post_title?a.post_title+" (Copy)":"",a.variants&&Array.isArray(a.variants)&&a.variants.forEach(s=>{s.sku="",s._cid=hl()});const l=this.data.products.indexOf(t);this.data.products.splice(l+1,0,a)}duplicateProductWithVariants(t,a){const l=JSON.parse(JSON.stringify(t));if(l._cid=hl(),l.post_title=l.post_title?l.post_title+" (Copy)":"",l.variants&&Array.isArray(l.variants)){const i=new Set(a);l.variants=l.variants.filter((A,p)=>i.has(p)),l.variants.forEach(A=>{A.sku="",A._cid=hl()})}const s=this.data.products.indexOf(t);this.data.products.splice(s+1,0,l)}duplicateVariant(t,a){const l=JSON.parse(JSON.stringify(a));l._cid=hl(),l.variation_title=l.variation_title?l.variation_title+" (Copy)":"",l.sku="";const s=t.variants.indexOf(a);t.variants.splice(s+1,0,l)}resetPaymentTypeDefaults(t){t.other_info.payment_type==="onetime"&&(t.other_info.installment="no",t.other_info.times="",t.other_info.manage_setup_fee="no",t.other_info.signup_fee="",t.other_info.signup_fee_name="")}resetState(){this.data.products.splice(0),this.data.savedIds=new Set,this.data.savingIds=new Set,this.data.productErrors=new Map}getColumnWidthStorageKey(){return"bulk_insert_column_widths"}getColumnStorageKey(){return"bulk_insert_columns"}getToggleableColumns(){return[{label:"SKU",value:"sku"},{label:"Media",value:"media"},{label:"Categories",value:"categories"},{label:"Description",value:"description"},{label:"Short Description",value:"short_description"},{label:"Status",value:"status"},{label:"Product Type",value:"product_type"},{label:"Pricing Type",value:"pricing_type"},{label:"Payment Type",value:"payment_type"},{label:"Interval",value:"interval"},{label:"Trial Days",value:"trial_days"},{label:"Best Price",value:"best_price"},{label:"Compare-at Price",value:"compare_price"},{label:"Track Quantity",value:"track_quantity"},{label:"Stock",value:"stock"}]}flattenCategoryTree(t,a=""){var s;const l=[];for(const i of t){const A=a?`${a} > ${i.label}`:i.label;l.push({label:A,value:A}),(s=i.children)!=null&&s.length&&l.push(...this.flattenCategoryTree(i.children,A))}return l}async fetchCategories(){try{const a=(await Ae.get("products/fetch-term")).taxonomies||{},l=Object.values(a).find(s=>s.name==="product-categories");l!=null&&l.terms&&(this.data.categoryOptions=this.flattenCategoryTree(l.terms))}catch{}}}const Ft=$0e.init(),F0e={class:"max-w-full overflow-x-scroll"},E0e={class:"relative"},U0e={key:0,class:"bulk-checkbox-cell"},I0e=["onMousedown","onTouchstart"],Ff={__name:"ResizeableColumns",props:{columns:{type:Array,required:!0},stickyLast:{type:Boolean,default:!1}},emits:["scroll","resize-end"],setup(e,{emit:t}){const a=t,l=am(),s=sd("table"),i=T(null);let A=null;De(()=>{Fe(()=>{const y=s.value.querySelectorAll("th"),g=l["header-first"]?1:0;Array.from(y).forEach((v,C)=>{const w=C-g;w<0||w>=p.columns.length||(p.columns[w].width=v.offsetWidth,p.columns[w].minWidth||(p.columns[w].minWidth=v.offsetWidth))}),A=new ResizeObserver(()=>{s.value.style.setProperty("--resizer-height",s.value.offsetHeight+"px");const v=s.value.querySelector("th");v&&s.value.style.setProperty("--header-height",v.offsetHeight+"px")}),A.observe(s.value)})}),Ya(()=>{A&&A.disconnect()});const p=e,h=K(()=>{const y=l["header-first"]?40:0;return p.columns.reduce((g,v)=>g+v.width,0)+y}),_=(y,g)=>{y.preventDefault();const v=y.clientX,C=p.columns[g].width,w=p.columns[g].minWidth||50;i.value=g;const b=F=>{const Q=C+(F.clientX-v);Q>=w&&(p.columns[g].width=Q)},S=()=>{i.value=null,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",S),a("resize-end")};document.addEventListener("mousemove",b),document.addEventListener("mouseup",S)};return(y,g)=>(r(),m("div",F0e,[o("div",{class:ue(["resizable-table",{"is-resizing":i.value!==null}]),onScroll:g[0]||(g[0]=v=>a("scroll",v))},[o("div",E0e,[o("table",{id:"tb",ref_key:"table",ref:s,style:fa({tableLayout:"fixed",width:h.value+"px"})},[o("thead",null,[o("tr",null,[y.$slots["header-first"]?(r(),m("th",U0e,[wa(y.$slots,"header-first")])):B("",!0),(r(!0),m(P,null,ae(e.columns,(v,C)=>(r(),m("th",{class:ue({"sticky-col":C===0,"sticky-col sticky-col-right":C===e.columns.length-1&&e.stickyLast}),style:fa({width:v.width+"px",zIndex:C===0||C===e.columns.length-1&&e.stickyLast?70:e.columns.length-C+50,left:C===0&&y.$slots["header-first"]?"40px":C===0?"0px":void 0}),key:v.key||C},[C===e.columns.length-1?wa(y.$slots,"header-last",{key:0},()=>[R(f(v.title),1)]):(r(),m(P,{key:1},[R(f(v.title),1)],64)),C_(w,C),onTouchstart:w=>_(w,C)},null,42,I0e)):B("",!0)],6))),128))])]),o("tbody",null,[wa(y.$slots,"default")])],4)])],34)]))}},V0e={class:"bulk-setup-fee-badge"},D0e={key:1,class:"text-gray-300 text-sm flex justify-center"},ei={__name:"BulkPriceInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=t;return(l,s)=>{var A;const i=k("el-tooltip");return e.variant?(r(),E(ll,{key:0,size:"small","error-class":e.hasError?"is-error":"","model-value":e.variant.item_price,placeholder:l.$t("Price"),disabled:e.disabled,"onUpdate:modelValue":s[0]||(s[0]=p=>{e.variant.item_price=p,a("change")})},ca({_:2},[((A=e.variant.other_info)==null?void 0:A.manage_setup_fee)==="yes"&&e.variant.other_info.signup_fee?{name:"suffix",fn:u(()=>[n(i,{content:(e.variant.other_info.signup_fee_name||l.$t("Setup fee"))+": "+c(zt)(e.variant.other_info.signup_fee,!0),placement:"top","popper-class":"fct-tooltip"},{default:u(()=>[o("span",V0e,"+ "+f(l.$t("fee")),1)]),_:1},8,["content"])]),key:"0"}:void 0]),1032,["error-class","model-value","placeholder","disabled"])):(r(),m("span",D0e,"—"))}}},Q0e=["disabled"],T0e={key:0,class:"fct-bulk-sub-count"},M0e={class:"fct-bulk-sub-popover-body"},L0e={class:"fct-bulk-sub-popover-title"},R0e={class:"fct-bulk-sub-section"},O0e={class:"fct-bulk-sub-row"},P0e={class:"fct-bulk-sub-row"},H0e={class:"fct-bulk-sub-label"},N0e={class:"fct-bulk-sub-row"},K0e={class:"fct-bulk-sub-label"},G0e=["innerHTML"],z0e={class:"fct-bulk-sub-section"},j0e={class:"fct-bulk-sub-row"},q0e={class:"fct-bulk-sub-row"},Y0e={class:"fct-bulk-sub-label"},W0e={class:"fct-bulk-sub-row"},X0e={class:"fct-bulk-sub-label"},J0e={class:"fct-bulk-sub-footer"},Ar=2,Z0e={__name:"BulkSubscriptionPopover",props:{variant:{type:Object,required:!0},disabled:{type:Boolean,default:!1}},emits:["changed"],setup(e,{emit:t}){const a=e,l=t,s=Zt().ctx,i=je.get(),A=je.get("app_config.isProActive"),p=T(!1);K(()=>{var $;return(($=i==null?void 0:i.shop)==null?void 0:$.currency_sign)||"$"});const h=K(()=>{var $;return(($=a.variant)==null?void 0:$.other_info)||{}}),_=K(()=>h.value.payment_type==="subscription"),y=K(()=>h.value.installment==="yes"),g=K(()=>Number(h.value.times)||1),v=K(()=>{var x;const $=Number((x=a.variant)==null?void 0:x.item_price)||0;return y.value?$*g.value:$}),C=K(()=>{const $=[];if(y.value&&$.push(s.$t("Installment")+": "+g.value+"x"),h.value.manage_setup_fee==="yes"){const x=h.value.signup_fee_name||s.$t("Setup fee"),I=h.value.signup_fee||0;$.push(s.$t("Setup fee")+": "+x+" ("+zt(I,!0)+")")}return $.length>0?$.join(`
`):s.$t("Subscription settings")}),w=$=>{$==="no"?a.variant.other_info.times="":b(),l("changed")},b=()=>{const $=Number(a.variant.other_info.times);(!Number.isFinite($)||${$==="no"&&(a.variant.other_info.signup_fee=""),l("changed")},F=()=>{l("changed")},Q=()=>{p.value=!1};return($,x)=>{const I=k("el-checkbox"),V=k("el-tooltip"),D=k("el-input"),U=k("el-switch"),L=k("el-button"),O=k("el-popover");return r(),E(V,{content:C.value,placement:"top",disabled:!_.value||p.value,"popper-class":"fct-tooltip","show-after":400},{default:u(()=>[n(O,{visible:p.value,"onUpdate:visible":x[6]||(x[6]=M=>p.value=M),placement:"bottom",width:320,trigger:"click",disabled:e.disabled||!_.value,"popper-class":"bulk-sub-popover"},{reference:u(()=>[o("button",{class:ue(["fc-bulk-sub-icon-btn",{"is-active":_.value,"is-configured":_.value&&(y.value||h.value.manage_setup_fee==="yes")}]),disabled:e.disabled||!_.value,onClick:x[0]||(x[0]=Ge(()=>{},["prevent"]))},[x[7]||(x[7]=o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16"},[o("path",{d:"M6 4H21C21.5523 4 22 4.44772 22 5V12H20V6H6V9L1 5.5L6 2V4ZM18 20H3C2.44772 20 2 19.5523 2 19V12H4V18H18V15L23 18.5L18 22V20Z"})],-1)),y.value?(r(),m("span",T0e,f(g.value),1)):B("",!0)],10,Q0e)]),default:u(()=>[o("div",M0e,[o("h4",L0e,f($.$t("Subscription Settings")),1),o("div",R0e,[o("div",O0e,[n(I,{"true-value":"yes","false-value":"no",label:$.$t("Enable installment payment"),modelValue:e.variant.other_info.installment,"onUpdate:modelValue":x[1]||(x[1]=M=>e.variant.other_info.installment=M),disabled:!c(A)||e.disabled,onChange:w},null,8,["label","modelValue","disabled"]),c(A)?B("",!0):(r(),E(V,{key:0,"popper-class":"fct-tooltip"},{content:u(()=>[R(f($.$t("This feature is available in pro version only.")),1)]),default:u(()=>[n(X,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),h.value.installment==="yes"?(r(),m(P,{key:0},[o("div",P0e,[o("label",H0e,f($.$t("Installment Count")),1),n(D,{type:"number",min:Ar,size:"small",modelValue:e.variant.other_info.times,"onUpdate:modelValue":x[2]||(x[2]=M=>e.variant.other_info.times=M),modelModifiers:{number:!0},placeholder:$.$t("Count"),style:{width:"100px"},onInput:F,onChange:b},null,8,["modelValue","placeholder"])]),o("div",N0e,[o("span",K0e,f($.$t("Total Price")),1),o("span",{class:"fct-bulk-sub-value",innerHTML:c(zt)(v.value,!0)},null,8,G0e)])],64)):B("",!0)]),o("div",z0e,[o("div",j0e,[n(U,{"active-text":$.$t("Setup fee"),modelValue:e.variant.other_info.manage_setup_fee,"onUpdate:modelValue":x[3]||(x[3]=M=>e.variant.other_info.manage_setup_fee=M),"active-value":"yes","inactive-value":"no",disabled:!c(A)||e.disabled,size:"small",onChange:S},null,8,["active-text","modelValue","disabled"]),c(A)?B("",!0):(r(),E(V,{key:0,"popper-class":"fct-tooltip"},{content:u(()=>[R(f($.$t("This feature is available in pro version only.")),1)]),default:u(()=>[n(X,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),h.value.manage_setup_fee==="yes"?(r(),m(P,{key:0},[o("div",q0e,[o("label",Y0e,f($.$t("Label")),1),n(D,{size:"small",modelValue:e.variant.other_info.signup_fee_name,"onUpdate:modelValue":x[4]||(x[4]=M=>e.variant.other_info.signup_fee_name=M),placeholder:$.$t("e.g. Initial Setup"),onInput:F},null,8,["modelValue","placeholder"])]),o("div",W0e,[o("label",X0e,f($.$t("Amount")),1),n(ll,{size:"small","model-value":e.variant.other_info.signup_fee,placeholder:$.$t("Amount"),"onUpdate:modelValue":x[5]||(x[5]=M=>{e.variant.other_info.signup_fee=M,F()})},null,8,["model-value","placeholder"])])],64)):B("",!0)]),o("div",J0e,[n(L,{size:"small",type:"primary",onClick:Q},{default:u(()=>[R(f($.$t("Done")),1)]),_:1})])])]),_:1},8,["visible","disabled"])]),_:1},8,["content","disabled"])}}},ewe={key:0,class:"flex items-center"},twe={key:1,class:"text-gray-300 text-sm flex justify-center"},ti={__name:"BulkPaymentTypeCell",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change","payment-type-change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i;return(i=a.variant)==null?void 0:i.other_info};return(i,A)=>{const p=k("el-option"),h=k("el-select");return e.variant&&s()?(r(),m("div",ewe,[n(h,{modelValue:e.variant.other_info.payment_type,"onUpdate:modelValue":A[0]||(A[0]=_=>e.variant.other_info.payment_type=_),size:"small",class:ue({"is-field-error":e.hasError}),disabled:e.disabled,onChange:A[1]||(A[1]=_=>l("payment-type-change",e.variant))},{default:u(()=>[n(p,{label:i.$t("One Time"),value:"onetime"},null,8,["label"]),n(p,{label:i.$t("Subscription"),value:"subscription"},null,8,["label"])]),_:1},8,["modelValue","class","disabled"]),n(Z0e,{variant:e.variant,disabled:e.disabled,onChanged:A[2]||(A[2]=_=>l("change"))},null,8,["variant","disabled"])])):(r(),m("span",twe,"—"))}}},awe={key:1,class:"text-gray-300 text-sm flex justify-center"},ai={__name:"BulkIntervalSelect",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i,A;return((A=(i=a.variant)==null?void 0:i.other_info)==null?void 0:A.payment_type)==="subscription"};return(i,A)=>{const p=k("el-option"),h=k("el-select");return e.variant&&s()?(r(),E(h,{key:0,modelValue:e.variant.other_info.repeat_interval,"onUpdate:modelValue":A[0]||(A[0]=_=>e.variant.other_info.repeat_interval=_),size:"small",class:ue({"is-field-error":e.hasError}),disabled:e.disabled,onChange:A[1]||(A[1]=_=>l("change"))},{default:u(()=>[n(p,{label:i.$t("Yearly"),value:"yearly"},null,8,["label"]),n(p,{label:i.$t("Half Yearly"),value:"half_yearly"},null,8,["label"]),n(p,{label:i.$t("Quarterly"),value:"quarterly"},null,8,["label"]),n(p,{label:i.$t("Monthly"),value:"monthly"},null,8,["label"]),n(p,{label:i.$t("Weekly"),value:"weekly"},null,8,["label"]),n(p,{label:i.$t("Daily"),value:"daily"},null,8,["label"])]),_:1},8,["modelValue","class","disabled"])):(r(),m("span",awe,"—"))}}},lwe={key:1,class:"text-gray-300 text-sm flex justify-center"},li={__name:"BulkTrialDaysInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i,A;return((A=(i=a.variant)==null?void 0:i.other_info)==null?void 0:A.payment_type)==="subscription"};return(i,A)=>{const p=k("el-input");return e.variant&&s()?(r(),E(p,{key:0,class:ue(["fct-bulk-input",{"is-error":e.hasError}]),modelValue:e.variant.other_info.trial_days,"onUpdate:modelValue":A[0]||(A[0]=h=>e.variant.other_info.trial_days=h),placeholder:"0",disabled:e.disabled,onChange:A[1]||(A[1]=h=>l("change")),size:"small"},null,8,["class","modelValue","disabled"])):(r(),m("span",lwe,"—"))}}},swe={key:1,class:"text-gray-300 text-sm flex justify-center"},si={__name:"BulkComparePriceInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=t;return(l,s)=>e.variant?(r(),E(ll,{key:0,size:"small","error-class":e.hasError?"is-error":"","model-value":e.variant.compare_price,placeholder:l.$t("Compare price"),disabled:e.disabled,"onUpdate:modelValue":s[0]||(s[0]=i=>{e.variant.compare_price=i,a("change")})},null,8,["error-class","model-value","placeholder","disabled"])):(r(),m("span",swe,"—"))}},Ef={__name:"BulkCategorySelect",props:{modelValue:{type:Array,default:()=>[]},options:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(e,{emit:t}){const a=t,l=s=>{a("update:modelValue",s),a("change",s)};return(s,i)=>{const A=k("el-option"),p=k("el-select");return r(),E(p,{"model-value":e.modelValue,multiple:"",filterable:"","allow-create":"","default-first-option":"","collapse-tags":"","collapse-tags-tooltip":!1,"max-collapse-tags":1,size:"small",placeholder:s.$t("Select or type..."),disabled:e.disabled,"onUpdate:modelValue":l},{default:u(()=>[(r(!0),m(P,null,ae(e.options,h=>(r(),E(A,{key:h.value,label:h.label,value:h.value},null,8,["label","value"]))),128))]),_:1},8,["model-value","placeholder","disabled"])}}},nwe=["textContent"],owe={key:1,class:"fct-bulk-editor-placeholder"},ni={__name:"BulkEditorCell",props:{value:{type:String,default:""},placeholder:{type:String,default:""}},emits:["click"],setup(e){return(t,a)=>(r(),m("div",{class:"fct-bulk-editor",onClick:a[0]||(a[0]=l=>t.$emit("click"))},[e.value?(r(),m("span",{key:0,class:"bulk-editor-preview",textContent:f(e.value)},null,8,nwe)):(r(),m("span",owe,f(e.placeholder),1))]))}};function Uf(){const e=T(new Set),t=T(null),a=T(!1),l=(g,v,C)=>{if(v.shiftKey&&t.value!==null){const b=C.indexOf(t.value),S=C.indexOf(g);if(b!==-1&&S!==-1){const F=Math.min(b,S),Q=Math.max(b,S),$=new Set(e.value);for(let x=F;x<=Q;x++)$.add(C[x]);e.value=$}}else{const b=new Set(e.value);b.has(g)?b.delete(g):b.add(g),e.value=b,t.value=g}},s=g=>{e.value.size===g.length&&g.length>0?e.value=new Set:e.value=new Set(g)},i=g=>{e.value=new Set(g)},A=()=>{e.value=new Set,t.value=null,a.value=!1},p=()=>{a.value?a.value=!1:e.value.size>=2&&(a.value=!0)};ke(e,g=>{a.value&&g.size<2&&(a.value=!1)});const h=g=>e.value.has(g),_=K(()=>e.value.size);return{selectedKeys:e,lastClickedKey:t,isLinkMode:a,handleRowClick:l,toggleSelectAll:s,selectAll:i,deselectAll:A,toggleLinkMode:p,isSelected:h,selectedCount:_,pruneStaleKeys:g=>{const v=new Set(g);let C=!1;const w=new Set;for(const b of e.value)v.has(b)?w.add(b):C=!0;C&&(e.value=w),t.value&&!v.has(t.value)&&(t.value=null)}}}const iwe={mounted(e,t){e.indeterminate=!!t.value},updated(e,t){e.indeterminate=!!t.value}},If={title:{product:{get:e=>e.post_title,set:(e,t)=>e.post_title=t},variant:{get:e=>e.variation_title,set:(e,t)=>e.variation_title=t}},sku:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.sku},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].sku=t)}},variant:{get:e=>e.sku,set:(e,t)=>e.sku=t}},status:{product:{get:e=>e.post_status,set:(e,t)=>e.post_status=t}},description:{product:{get:e=>e.post_content,set:(e,t)=>e.post_content=t}},short_desc:{product:{get:e=>e.post_excerpt,set:(e,t)=>e.post_excerpt=t}},product_type:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.fulfillment_type},set:(e,t)=>{e.detail&&(e.detail.fulfillment_type=t)}}},pricing_type:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.variation_type},set:(e,t)=>{e.detail&&(e.detail.variation_type=t)}}},payment_type:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.payment_type},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.payment_type=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.payment_type},set:(e,t)=>{e.other_info&&(e.other_info.payment_type=t)}}},interval:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.repeat_interval},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.repeat_interval=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.repeat_interval},set:(e,t)=>{e.other_info&&(e.other_info.repeat_interval=t)}}},trial_days:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.trial_days},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.trial_days=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.trial_days},set:(e,t)=>{e.other_info&&(e.other_info.trial_days=t)}}},price:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.item_price},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].item_price=t)}},variant:{get:e=>e.item_price,set:(e,t)=>e.item_price=t}},compare_price:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.compare_price},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].compare_price=t)}},variant:{get:e=>e.compare_price,set:(e,t)=>e.compare_price=t}},manage_stock:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.manage_stock},set:(e,t)=>{e.detail&&(e.detail.manage_stock=t)}}},categories:{product:{get:e=>e.categories,set:(e,t)=>e.categories=[...t]}}},rwe={...If,stock:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.total_stock},set:(e,t)=>{e.detail&&(e.detail.total_stock=t)}},variant:{get:e=>e.total_stock,set:(e,t)=>e.total_stock=t}}},dwe={...If,stock:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.available},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].available=t)}},variant:{get:e=>e.available,set:(e,t)=>e.available=t}}};function Vf(e,t,a,l,s,i,A){const p=A[e];if(p)for(const h of l){if(h===a)continue;const _=s(h);if(!_)continue;const y=p[_.type];y&&(y.set(_.data,t),i&&i(_.product))}}const uwe={class:"fct-bulk-insert-page fct-layout-width"},cwe={class:"fct-btn-group sm justify-end"},Awe={class:"filter-popover-item"},pwe={class:"filter-popover-title"},fwe={key:0,"aria-hidden":"true"},mwe=["colspan"],hwe=["onClick"],_we=["onClick"],vwe={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},gwe={class:"flex items-center"},ywe=["onClick","title"],bwe={key:0,class:"bulk-collapse-count"},wwe=["title"],Cwe=["title"],kwe={class:"bulk-status-icon is-error"},Bwe={key:0,class:"fct-bulk-sku-cell"},xwe={key:1,class:"text-gray-300 text-sm flex justify-center"},Swe={key:1,class:"fct-bulk-media-cell"},$we={key:2,class:"fct-bulk-categories-cell"},Fwe={key:3,class:"fct-bulk-desc-cell"},Ewe={key:4,class:"fct-bulk-short-desc-cell"},Uwe={key:5,class:"fct-bulk-status-cell"},Iwe={key:6,class:"fct-bulk-product-type-cell"},Vwe={key:7,class:"fct-bulk-product-type-cell"},Dwe={key:8,class:"fct-bulk-pricing-type-cell"},Qwe={key:9,class:"fct-bulk-pricing-type-cell"},Twe={key:10,class:"fct-bulk-payment-type-cell"},Mwe={key:11,class:"fct-bulk-interval-cell"},Lwe={key:12,class:"fct-bulk-trial-days-cell"},Rwe={key:13,class:"fct-bulk-best-price-cell"},Owe={key:14,class:"fct-bulk-compare-price-cell"},Pwe={key:15,class:"fct-bulk-qty-cell !pl-5"},Hwe={key:16,class:"fct-bulk-stock-cell"},Nwe={key:1,class:"text-gray-300 text-sm pl-5"},Kwe={class:"fct-btn-group xs justify-end"},Gwe=["href","title"],zwe={key:0,class:"bulk-variants-block-row"},jwe=["colspan"],qwe={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},Ywe=["onClick"],Wwe={class:"bulk-checkbox-cell"},Xwe={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},Jwe={class:"flex items-center gap-1 pl-4"},Zwe={class:"bulk-status-icon is-error"},eCe={key:0,class:"fct-bulk-sku-cell"},tCe={key:1,class:"fct-bulk-media-cell"},aCe={key:2},lCe={key:3},sCe={key:4},nCe={key:5},oCe={key:6},iCe={key:7},rCe={key:8},dCe={key:9},uCe={key:10},cCe={key:11},ACe={key:12},pCe={key:13,class:"text-center"},fCe={key:14},mCe={key:1,class:"text-gray-300 text-sm flex justify-center"},hCe={class:"fct-btn-group sm justify-end"},_Ce={class:"bulk-add-variant-row"},vCe=["colspan"],gCe={class:"sticky left-0 inline-block pl-6"},yCe={key:1,"aria-hidden":"true"},bCe=["colspan"],pr=43,wCe=10,CCe=800,Qc=100,kCe={__name:"BulkInsert",setup(e){const{options:t,products:a}=Ft.data,l=be=>{var Ie;return((Ie=be==null?void 0:be.detail)==null?void 0:Ie.variation_type)==="simple"},s=K(()=>Ft.data.saving),i=K(()=>Ft.data.saveProgress),A=K(()=>{const be=Ft.data.saveProgress;return be.total?Math.round(be.completed/be.total*100):0}),p=()=>{Ft.saveProducts()},h=be=>Ft.isSaving(be._cid),_=be=>Ft.isSaved(be._cid),y=be=>Ft.isRowDisabled(be._cid),g=be=>Ft.hasError(be._cid),v=be=>Ft.getError(be._cid),C=be=>Ft.hasProductLevelError(be._cid),w=(be,Ie)=>Ft.hasVariantError(be._cid,Ie),b=(be,Ie)=>Ft.getVariantError(be._cid,Ie),S=(be,Ie)=>Ft.hasFieldError(be._cid,Ie),F=(be,Ie,it)=>Ft.hasVariantFieldError(be._cid,Ie,it),Q=async be=>{const Ie=be.post_title||H.$t("Untitled product"),it=Array.isArray(be.variants)?be.variants.length:0,kt=Ft.isSaved(be._cid);let Bt=it>0?H.$t('This will remove "%1$s" and its %2$s variant(s).',Ie,it):H.$t('This will remove "%1$s".',Ie);kt&&(Bt+=" "+H.$t("This product was already saved and will be permanently deleted."));try{await El.confirm(Bt,H.$t("Remove Product"),{confirmButtonText:H.$t("Remove"),cancelButtonText:H.$t("Cancel"),type:"warning"})}catch{return}await Ft.removeProduct(be)},$=(be,Ie)=>{const it=Ie.variation_title||H.$t("Untitled variant");El.confirm(H.$t('This will remove the variant "%1$s".',it),H.$t("Remove Variant"),{confirmButtonText:H.$t("Remove"),cancelButtonText:H.$t("Cancel"),confirmButtonClass:"el-button--small",cancelButtonClass:"el-button--small",type:"warning"}).then(()=>{Ft.removeVariant(be,Ie)}).catch(()=>{})},x=be=>Ft.duplicateProduct(be),I=(be,Ie)=>Ft.duplicateVariant(be,Ie),V=()=>{const be=[];for(const Ie of a){const it=`p:${Ie._cid}`,kt=ce.value.has(it),Bt=[];Ie.variants&&Ie.variants.forEach((ta,bt)=>{ce.value.has(`v:${Ie._cid}:${bt}`)&&Bt.push(bt)}),!(!kt&&Bt.length===0)&&(kt&&Bt.length===0?be.push({product:Ie,type:"full"}):!kt&&Bt.length>0?be.push({product:Ie,type:"variants-only",variantIndexes:Bt}):be.push({product:Ie,type:"partial",variantIndexes:Bt}))}return be},D=()=>{const be=V();if(!be.length)return;const Ie=be.filter(bt=>bt.type==="full").length,it=be.filter(bt=>bt.type==="partial").length,Bt=be.filter(bt=>bt.type==="variants-only").reduce((bt,sa)=>bt+sa.variantIndexes.length,0),ta=[];Ie>0&&ta.push(`${Ie} product(s) with all variants`),it>0&&ta.push(`${it} product(s) with selected variants`),Bt>0&&ta.push(`${Bt} variant(s)`),El.confirm(H.$t("Duplicate %s?").replace("%s",ta.join(", ")),H.$t("Bulk Duplicate"),{confirmButtonText:H.$t("Duplicate"),cancelButtonText:H.$t("Cancel"),type:"info"}).then(()=>{for(const bt of be)if(bt.type==="full")Ft.duplicateProduct(bt.product);else if(bt.type==="variants-only")for(const sa of bt.variantIndexes){const na=bt.product.variants[sa];na&&Ft.duplicateVariant(bt.product,na)}else bt.type==="partial"&&Ft.duplicateProductWithVariants(bt.product,bt.variantIndexes);le()}).catch(()=>{})},U=async()=>{const be=[],Ie=[];for(const bt of a){const sa=`p:${bt._cid}`;if(ce.value.has(sa)){be.push(bt);continue}const qt=[];bt.variants&&bt.variants.forEach((ka,Ja)=>{ce.value.has(`v:${bt._cid}:${Ja}`)&&qt.push(ka)}),qt.length>0&&Ie.push({product:bt,variants:qt})}if(!be.length&&!Ie.length)return;const it=be.filter(bt=>Ft.isSaved(bt._cid)).length,kt=Ie.reduce((bt,sa)=>bt+sa.variants.length,0),Bt=[];be.length>0&&Bt.push(`${be.length} product(s)`),kt>0&&Bt.push(`${kt} variant(s)`);let ta=H.$t("Remove %s?").replace("%s",Bt.join(" and "));it>0&&(ta+=" "+H.$t("%s already saved will be permanently deleted.").replace("%s",`${it}`));try{await El.confirm(ta,H.$t("Bulk Remove"),{confirmButtonText:H.$t("Remove"),cancelButtonText:H.$t("Cancel"),type:"warning"})}catch{return}for(const bt of be)await Ft.removeProduct(bt);for(const{product:bt,variants:sa}of Ie)for(const na of sa)Ft.removeVariant(bt,na);le()},L=be=>{Ft.resetPaymentTypeDefaults(be)},O=(be,Ie)=>{const it=Ft.data.categoryOptions;for(const kt of Ie)it.find(Bt=>Bt.value===kt)||it.push({label:kt,value:kt})},M=()=>{Ft.populateDummyProduct()},H=Zt().ctx,j=be=>{const Ie=Ft.data.products;be.concat||(Ie.splice(0,Ie.length),Ft.data.savedIds=new Set,Ft.data.savingIds=new Set,Ft.data.productErrors=new Map),Ie.push(...be.products)},W=T({visible:!1,field:"",product:null,value:""}),G=(be,Ie)=>{W.value={visible:!0,field:Ie,product:be,value:be[Ie]||""}},Y=be=>{W.value.value=be},J=()=>{const{product:be,field:Ie,value:it}=W.value;be&&(be[Ie]=it),W.value.visible=!1},de=K(()=>W.value.field==="post_content"?H.$t("Edit Description"):H.$t("Edit Short Description")),z=T(!0),{selectedKeys:ce,handleRowClick:oe,toggleSelectAll:Z,selectAll:N,deselectAll:le,isSelected:ee,selectedCount:pe,isLinkMode:re,toggleLinkMode:Ue}=Uf(),we=K(()=>{const be=[];for(const Ie of pt.value)if(be.push(`p:${Ie.productId}`),Ie.hasVariants&&!Ie.collapsed)for(let it=0;it{var Ie;if(be.startsWith("p:")){const it=be.slice(2),kt=a.find(Bt=>Bt._cid===it);return kt?{type:"product",data:kt,product:kt}:null}else if(be.startsWith("v:")){const it=be.split(":"),kt=it[1],Bt=parseInt(it[2]),ta=a.find(bt=>bt._cid===kt);if(ta&&((Ie=ta.variants)!=null&&Ie[Bt]))return{type:"variant",data:ta.variants[Bt],product:ta}}return null},ge=(be,Ie,it)=>{!re.value||!ee(it)||Vf(be,Ie,it,ce.value,Be,null,rwe)},Ce=T(!1),Oe=be=>{be.key==="Shift"&&(Ce.value=!0)},Ee=be=>{be.key==="Shift"&&(Ce.value=!1)},fe=(be,Ie)=>{if(!Ie.shiftKey||Ie.target.closest(".bulk-checkbox-cell"))return;Ie.preventDefault();const it=new Set(ce.value);it.has(be)?it.delete(be):it.add(be),ce.value=it},ye=T([]),Ve=K(()=>ye.value.filter(be=>be.key==="title"||be.key==="actions"?!0:Ft.isColumnVisible(be.key))),Le=be=>Ft.isColumnVisible(be),At=()=>{Ft.saveColumnWidths(ye.value)},mt=T(new Set),Mt=be=>{const Ie=be._cid;mt.value.has(Ie)?mt.value.delete(Ie):mt.value.add(Ie),mt.value=new Set(mt.value)},Dt=be=>mt.value.has(be._cid),Xe=T(0),pt=K(()=>{let be=0;return a.map(Ie=>{var qt;const it=Ie._cid,kt=((qt=Ie.detail)==null?void 0:qt.variation_type)!=="simple"&&Array.isArray(Ie.variants),Bt=kt?Ie.variants.length:0,ta=mt.value.has(it),bt=kt&&!ta?(Bt+1)*pr:0,sa=pr+bt,na={product:Ie,productId:it,hasVariants:kt,variantCount:Bt,collapsed:ta,groupHeight:sa,offset:be};return be+=sa,na})}),jt=K(()=>{const be=pt.value;if(be.length===0)return 0;const Ie=be[be.length-1];return Ie.offset+Ie.groupHeight}),Ct=K(()=>{const be=pt.value,Ie=Xe.value,it=Ie+CCe,kt=wCe*pr;return be.filter(Bt=>Bt.offset+Bt.groupHeight>=Ie-kt&&Bt.offset<=it+kt)}),$t=K(()=>Ct.value.length===0?0:Ct.value[0].offset),Ht=K(()=>{if(Ct.value.length===0)return 0;const be=Ct.value[Ct.value.length-1];return jt.value-be.offset-be.groupHeight});let Nt=null,Qt=0;const yt=be=>{const Ie=be.target,it=Date.now();Nt&&clearTimeout(Nt),it-Qt>=Qc?(Xe.value=Ie.scrollTop,Qt=it):Nt=setTimeout(()=>{Xe.value=Ie.scrollTop,Qt=Date.now(),Nt=null},Qc)};let Xt=null;return De(async()=>{Xt=is(),Xt.bind("mod+a",be=>{var it,kt;const Ie=(it=document.activeElement)==null?void 0:it.tagName;Ie==="INPUT"||Ie==="TEXTAREA"||(kt=document.activeElement)!=null&&kt.isContentEditable||(be.preventDefault(),N(we.value))}),Xt.bind("escape",()=>{var Ie,it;const be=(Ie=document.activeElement)==null?void 0:Ie.tagName;be==="INPUT"||be==="TEXTAREA"||(it=document.activeElement)!=null&&it.isContentEditable||(re.value?Ue():le())}),ye.value=[{key:"title",title:H.$t("Title"),width:150,minWidth:100},{key:"sku",title:H.$t("SKU"),width:120,minWidth:80},{key:"media",title:H.$t("Media"),width:100,minWidth:50},{key:"categories",title:H.$t("Categories"),width:200,minWidth:150},{key:"description",title:H.$t("Description"),width:200,minWidth:150},{key:"short_description",title:H.$t("Short Description"),width:150,minWidth:100},{key:"status",title:H.$t("Status"),width:100,minWidth:50},{key:"product_type",title:H.$t("Product Type"),width:200,minWidth:150},{key:"pricing_type",title:H.$t("Pricing Type"),width:200,minWidth:150},{key:"payment_type",title:H.$t("Payment Type"),width:120,minWidth:100},{key:"interval",title:H.$t("Interval"),width:120,minWidth:80},{key:"trial_days",title:H.$t("Trial Days"),width:100,minWidth:70},{key:"best_price",title:H.$t("Best Price"),width:100,minWidth:100},{key:"compare_price",title:H.$t("Compare-at Price"),width:200,minWidth:150},{key:"track_quantity",title:H.$t("Track Quantity"),width:100,minWidth:100},{key:"stock",title:H.$t("Stock"),width:150,minWidth:150},{key:"actions",title:"",width:110,minWidth:110}],Ft.restoreColumnWidths(ye.value),Ft.setupColumnVisibility(),Ft.fetchCategories(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",Oe),window.addEventListener("keyup",Ee)}),Ya(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",Oe),window.removeEventListener("keyup",Ee),Xt&&Xt.reset()}),(be,Ie)=>{const it=k("el-button"),kt=k("el-progress"),Bt=k("el-checkbox"),ta=k("el-checkbox-group"),bt=k("el-tooltip"),sa=k("el-popover"),na=k("el-input"),qt=k("el-icon"),ka=k("el-option"),Ja=k("el-select"),ul=k("el-switch"),Za=k("el-dialog");return r(),m("div",uwe,[n(nl,{title:be.$t("Bulk Insert")},{action:u(()=>[n(S0e,{onOnDataPopulated:j}),n(it,{onClick:M},{default:u(()=>[R(f(be.$t("Add Product")),1)]),_:1}),n(it,{type:"primary",onClick:p,loading:s.value,disabled:s.value||c(a).length===0},{default:u(()=>[R(f(s.value?be.$t("Saving %s/%s...").replace("%s",i.value.completed).replace("%s",i.value.total):be.$t("Save All Products")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),s.value?(r(),E(kt,{key:0,percentage:A.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):B("",!0),n($e,null,{default:u(()=>{var va;return[c(a).length>0?(r(),E(Qe,{key:0,title:((va=c(a))==null?void 0:va.length)===1?be.$t("Product"):be.$t("Products"),border_bottom:""},{action:u(()=>[o("div",cwe,[n(it,{disabled:c(pe)===0,onClick:U,size:"small",type:"danger",soft:""},{default:u(()=>[Ie[8]||(Ie[8]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("polyline",{points:"3 6 5 6 21 6"}),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)),R(" "+f(be.$t("Delete")),1)]),_:1,__:[8]},8,["disabled"]),n(it,{disabled:c(pe)===0,onClick:D,size:"small",type:"info",soft:""},{default:u(()=>[Ie[9]||(Ie[9]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)),R(" "+f(be.$t("Duplicate")),1)]),_:1,__:[9]},8,["disabled"]),n(it,{class:ue({"is-active":c(re)}),disabled:c(pe)<2&&!c(re),onClick:c(Ue),size:"small",type:"info",soft:""},{default:u(()=>[Ie[10]||(Ie[10]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)),R(" "+f(c(re)?be.$t("Unlink"):be.$t("Link")),1)]),_:1,__:[10]},8,["class","disabled","onClick"]),n(Bt,{modelValue:z.value,"onUpdate:modelValue":Ie[0]||(Ie[0]=te=>z.value=te),label:be.$t("Pin Actions")},null,8,["modelValue","label"]),n(sa,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:u(()=>[o("span",null,[n(bt,{effect:"light",content:be.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:u(()=>[n(lt,{tag:"button",size:"small"},{default:u(()=>[n(X,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:u(()=>[o("div",Awe,[o("h3",pwe,f(be.$t("Columns")),1),n(ta,{modelValue:c(Ft).data.visibleColumns,"onUpdate:modelValue":Ie[1]||(Ie[1]=te=>c(Ft).data.visibleColumns=te),class:"fct-checkbox-blocks",onChange:Ie[2]||(Ie[2]=te=>c(Ft).handleColumnVisibilityChange())},{default:u(()=>[(r(!0),m(P,null,ae(c(Ft).getToggleableColumns(),te=>(r(),E(Bt,{key:te.value,value:te.value,label:be.$t(te.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])]),_:1},8,["title"])):B("",!0),n(xe,{class:"p-0"},{default:u(()=>[c(a).length>0?(r(),m("div",{key:0,class:ue(["relative",{"is-link-mode":c(re),"is-shift-held":Ce.value}])},[n(Ff,{columns:Ve.value,"sticky-last":z.value,onScroll:yt,onResizeEnd:At},{"header-first":u(()=>[n(Bt,{"model-value":c(pe)>0&&c(pe)===we.value.length,indeterminate:c(pe)>0&&c(pe)c(Z)(we.value))},null,8,["model-value","indeterminate"])]),"header-last":u(()=>[R(f(be.$t("Actions")),1)]),default:u(()=>[$t.value>0?(r(),m("tr",fwe,[o("td",{colspan:Ve.value.length+1,style:fa({height:$t.value+"px",padding:0,border:"none"})},null,12,mwe)])):B("",!0),(r(!0),m(P,null,ae(Ct.value,te=>{var Se,ne,_e,We,ot,qe,Ze,gt,tt,Vt,me,ve,Ne,Pe,ft;return r(),m(P,{key:te.productId},[o("tr",{class:ue(["bulk-product-row",{"is-saving":h(te.product),"is-saved":_(te.product),"has-product-error":g(te.product),"is-selected":c(ee)(`p:${te.productId}`)}]),onClick:se=>fe(`p:${te.productId}`,se)},[o("td",{class:"bulk-checkbox-cell",onClick:se=>c(oe)(`p:${te.productId}`,se,we.value)},[n(Bt,{"model-value":c(ee)(`p:${te.productId}`),tabindex:"-1"},null,8,["model-value"])],8,_we),o("td",vwe,[o("div",gwe,[te.hasVariants?(r(),m("button",{key:0,class:"bulk-collapse-btn",onClick:Ge(se=>Mt(te.product),["prevent"]),title:Dt(te.product)?be.$t("Expand variants"):be.$t("Collapse variants")},[(r(),m("svg",{class:ue(["bulk-collapse-icon",{"is-collapsed":Dt(te.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},Ie[11]||(Ie[11]=[o("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),Dt(te.product)?(r(),m("span",bwe,f(te.variantCount),1)):B("",!0)],8,ywe)):B("",!0),n(na,{class:ue(["fct-bulk-input",{"is-error":S(te.product,"post_title")}]),modelValue:te.product.post_title,"onUpdate:modelValue":se=>te.product.post_title=se,placeholder:be.$t("Product title"),size:"small",disabled:y(te.product),onInput:se=>ge("title",se,`p:${te.productId}`)},null,8,["class","modelValue","onUpdate:modelValue","placeholder","disabled","onInput"]),h(te.product)?(r(),m("span",{key:1,class:"bulk-status-icon is-syncing",title:be.$t("Saving...")},[n(qt,{class:"is-loading",size:14},{default:u(()=>[n(c(ln))]),_:1})],8,wwe)):_(te.product)?(r(),m("span",{key:2,class:"bulk-status-icon is-saved",title:be.$t("Saved")},Ie[12]||(Ie[12]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16"},[o("path",{d:"M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-.997-6l7.07-7.071-1.414-1.414-5.656 5.657-2.829-2.829-1.414 1.414L11.003 16z"})],-1)]),8,Cwe)):C(te.product)||l(te.product)&&g(te.product)?(r(),E(bt,{key:3,content:v(te.product),placement:"top"},{default:u(()=>[o("span",kwe,[n(qt,{size:16},{default:u(()=>[n(c(To))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),Le("sku")?(r(),m("td",Bwe,[((ne=(Se=te.product)==null?void 0:Se.detail)==null?void 0:ne.variation_type)==="simple"&&((_e=te.product.variants)!=null&&_e[0])?(r(),E(na,{key:0,class:ue(["fct-bulk-input",{"is-error":S(te.product,"variants.0.sku")}]),modelValue:te.product.variants[0].sku,"onUpdate:modelValue":[se=>te.product.variants[0].sku=se,se=>ge("sku",se,`p:${te.productId}`)],placeholder:"SKU",size:"small",disabled:y(te.product)},null,8,["class","modelValue","onUpdate:modelValue","disabled"])):(r(),m("span",xwe,"—"))])):B("",!0),Le("media")?(r(),m("td",Swe,[n(bl,{modelValue:te.product.gallery,"onUpdate:modelValue":se=>te.product.gallery=se,"show-url-tab":"",disabled:y(te.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),Le("categories")?(r(),m("td",$we,[n(Ef,{modelValue:te.product.categories,"onUpdate:modelValue":se=>te.product.categories=se,options:c(Ft).data.categoryOptions,disabled:y(te.product),onChange:se=>{O(te.product,se),ge("categories",te.product.categories,`p:${te.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):B("",!0),Le("description")?(r(),m("td",Fwe,[n(ni,{value:te.product.post_content,placeholder:be.$t("Description"),onClick:se=>G(te.product,"post_content")},null,8,["value","placeholder","onClick"])])):B("",!0),Le("short_description")?(r(),m("td",Ewe,[n(ni,{value:te.product.post_excerpt,placeholder:be.$t("Short description"),onClick:se=>G(te.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):B("",!0),Le("status")?(r(),m("td",Uwe,[n(Ja,{modelValue:te.product.post_status,"onUpdate:modelValue":se=>te.product.post_status=se,size:"small",class:ue({"is-field-error":S(te.product,"post_status")}),disabled:y(te.product),onChange:se=>ge("status",te.product.post_status,`p:${te.productId}`)},{default:u(()=>[(r(!0),m(P,null,ae(c(t).status,se=>(r(),E(ka,{key:se.value,label:be.$t(se.title),value:se.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):B("",!0),Le("product_type")&&((We=te.product)!=null&&We.detail)?(r(),m("td",Iwe,[n(Ja,{modelValue:te.product.detail.fulfillment_type,"onUpdate:modelValue":se=>te.product.detail.fulfillment_type=se,size:"small",class:ue({"is-field-error":S(te.product,"detail.fulfillment_type")}),disabled:y(te.product),onChange:se=>ge("product_type",te.product.detail.fulfillment_type,`p:${te.productId}`)},{default:u(()=>[(r(!0),m(P,null,ae(c(t).fulfilment,se=>(r(),E(ka,{key:se.value,label:be.$t(se.title),value:se.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Le("product_type")?(r(),m("td",Vwe)):B("",!0),Le("pricing_type")&&((ot=te.product)!=null&&ot.detail)?(r(),m("td",Dwe,[n(Ja,{modelValue:te.product.detail.variation_type,"onUpdate:modelValue":se=>te.product.detail.variation_type=se,size:"small",class:ue({"is-field-error":S(te.product,"detail.variation_type")}),disabled:y(te.product),onChange:se=>{c(Ft).handleVariationChanged(te.product,se),ge("pricing_type",se,`p:${te.productId}`)}},{default:u(()=>[(r(!0),m(P,null,ae(c(t).variation,se=>(r(),E(ka,{key:se.value,label:be.$t(se.title),value:se.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Le("pricing_type")?(r(),m("td",Qwe)):B("",!0),Le("payment_type")?(r(),m("td",Twe,[n(ti,{variant:l(te.product)?(qe=te.product.variants)==null?void 0:qe[0]:null,disabled:y(te.product),"has-error":S(te.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:se=>{var ze;L(se),ge("payment_type",(ze=se.other_info)==null?void 0:ze.payment_type,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):B("",!0),Le("interval")?(r(),m("td",Mwe,[n(ai,{variant:l(te.product)?(Ze=te.product.variants)==null?void 0:Ze[0]:null,disabled:y(te.product),"has-error":S(te.product,"variants.0.other_info.repeat_interval"),onChange:se=>{var ze,_t,Me;return ge("interval",(Me=(_t=(ze=te.product.variants)==null?void 0:ze[0])==null?void 0:_t.other_info)==null?void 0:Me.repeat_interval,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("trial_days")?(r(),m("td",Lwe,[n(li,{variant:l(te.product)?(gt=te.product.variants)==null?void 0:gt[0]:null,disabled:y(te.product),"has-error":S(te.product,"variants.0.other_info.trial_days"),onChange:se=>{var ze,_t,Me;return ge("trial_days",(Me=(_t=(ze=te.product.variants)==null?void 0:ze[0])==null?void 0:_t.other_info)==null?void 0:Me.trial_days,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("best_price")?(r(),m("td",Rwe,[n(ei,{variant:l(te.product)?(tt=te.product.variants)==null?void 0:tt[0]:null,disabled:y(te.product),"has-error":S(te.product,"variants.0.item_price"),onChange:se=>{var ze,_t;return ge("price",(_t=(ze=te.product.variants)==null?void 0:ze[0])==null?void 0:_t.item_price,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("compare_price")?(r(),m("td",Owe,[n(si,{variant:l(te.product)?(Vt=te.product.variants)==null?void 0:Vt[0]:null,disabled:y(te.product),"has-error":S(te.product,"variants.0.compare_price"),onChange:se=>{var ze,_t;return ge("compare_price",(_t=(ze=te.product.variants)==null?void 0:ze[0])==null?void 0:_t.compare_price,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("track_quantity")?(r(),m("td",Pwe,[(me=te.product)!=null&&me.detail?(r(),E(ul,{key:0,modelValue:te.product.detail.manage_stock,"onUpdate:modelValue":se=>te.product.detail.manage_stock=se,"active-value":"1","inactive-value":"0",disabled:y(te.product),onChange:se=>{c(Ft).syncStockStatus(te.product),ge("manage_stock",te.product.detail.manage_stock,`p:${te.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):B("",!0)])):B("",!0),Le("stock")?(r(),m("td",Hwe,[((Ne=(ve=te.product)==null?void 0:ve.detail)==null?void 0:Ne.manage_stock)==="1"&&((ft=(Pe=te.product)==null?void 0:Pe.detail)==null?void 0:ft.variation_type)==="simple"?(r(),E(na,{key:0,modelValue:te.product.detail.total_stock,"onUpdate:modelValue":[se=>te.product.detail.total_stock=se,se=>{var ze;(ze=te.product.variants)!=null&&ze[0]&&(te.product.variants[0].total_stock=se,te.product.variants[0].available=se),c(Ft).syncStockStatus(te.product),ge("stock",se,`p:${te.productId}`)}],disabled:y(te.product),size:"small",placeholder:be.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),m("span",Nwe,"—"))])):B("",!0),o("td",{class:ue(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":z.value}])},[o("div",Kwe,[_(te.product)&&te.product.view_url?(r(),m("a",{key:0,href:te.product.view_url,target:"_blank",class:"bulk-action-btn bulk-view-link",title:be.$t("View Product")},[n(X,{name:"External"})],8,Gwe)):B("",!0),n(lt,{tag:"button",size:"x-small",onClick:Ge(se=>x(te.product),["prevent"]),disabled:s.value||y(te.product),title:be.$t("Duplicate")},{default:u(()=>[n(X,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(lt,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(se=>Q(te.product),["prevent"]),disabled:s.value||y(te.product),title:be.$t("Delete")},{default:u(()=>[n(X,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,hwe),te.hasVariants?(r(),m("tr",zwe,[o("td",{colspan:Ve.value.length+1,class:"!p-0 !border-b-0"},[n(_a,{accordion:"",visible:!te.collapsed,duration:200},{default:u(()=>[o("table",qwe,[o("colgroup",null,[Ie[13]||(Ie[13]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),m(P,null,ae(Ve.value,(se,ze)=>(r(),m("col",{key:ze,style:fa({width:se.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),m(P,null,ae(te.product.variants,(se,ze)=>{var _t,Me;return r(),m("tr",{key:ze,class:ue(["bulk-variation-row",{"is-selected":c(ee)(`v:${te.productId}:${ze}`)}]),onClick:St=>fe(`v:${te.productId}:${ze}`,St)},[o("td",Wwe,[n(Bt,{"model-value":c(ee)(`v:${te.productId}:${ze}`),tabindex:"-1",onChange:St=>c(oe)(`v:${te.productId}:${ze}`,St,we.value)},null,8,["model-value","onChange"])]),o("td",Xwe,[o("div",Jwe,[Ie[14]||(Ie[14]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(na,{size:"small",modelValue:se.variation_title,"onUpdate:modelValue":[St=>se.variation_title=St,St=>ge("title",St,`v:${te.productId}:${ze}`)],placeholder:be.$t("Variation title"),disabled:y(te.product),class:ue({"is-error":F(te.product,ze,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),w(te.product,ze)?(r(),E(bt,{key:0,content:b(te.product,ze),placement:"top"},{default:u(()=>[o("span",Zwe,[n(qt,{size:14},{default:u(()=>[n(c(To))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),Le("sku")?(r(),m("td",eCe,[n(na,{size:"small",modelValue:se.sku,"onUpdate:modelValue":[St=>se.sku=St,St=>ge("sku",St,`v:${te.productId}:${ze}`)],placeholder:"SKU",disabled:y(te.product),class:ue({"is-error":F(te.product,ze,"sku")})},null,8,["modelValue","onUpdate:modelValue","disabled","class"])])):B("",!0),Le("media")?(r(),m("td",tCe,[n(bl,{modelValue:se.media,"onUpdate:modelValue":St=>se.media=St,"show-url-tab":"",disabled:y(te.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),Le("categories")?(r(),m("td",aCe,Ie[15]||(Ie[15]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("description")?(r(),m("td",lCe,Ie[16]||(Ie[16]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("short_description")?(r(),m("td",sCe,Ie[17]||(Ie[17]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("status")?(r(),m("td",nCe,Ie[18]||(Ie[18]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("product_type")?(r(),m("td",oCe,Ie[19]||(Ie[19]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("pricing_type")?(r(),m("td",iCe,Ie[20]||(Ie[20]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("payment_type")?(r(),m("td",rCe,[n(ti,{variant:se,disabled:y(te.product),"has-error":F(te.product,ze,"other_info.payment_type"),onPaymentTypeChange:St=>{var el;L(St),ge("payment_type",(el=St.other_info)==null?void 0:el.payment_type,`v:${te.productId}:${ze}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):B("",!0),Le("interval")?(r(),m("td",dCe,[n(ai,{variant:se,disabled:y(te.product),"has-error":F(te.product,ze,"other_info.repeat_interval"),onChange:St=>{var el;return ge("interval",(el=se.other_info)==null?void 0:el.repeat_interval,`v:${te.productId}:${ze}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("trial_days")?(r(),m("td",uCe,[n(li,{variant:se,disabled:y(te.product),"has-error":F(te.product,ze,"other_info.trial_days"),onChange:St=>{var el;return ge("trial_days",(el=se.other_info)==null?void 0:el.trial_days,`v:${te.productId}:${ze}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("best_price")?(r(),m("td",cCe,[n(ei,{variant:se,disabled:y(te.product),"has-error":F(te.product,ze,"item_price"),onChange:St=>ge("price",se.item_price,`v:${te.productId}:${ze}`)},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("compare_price")?(r(),m("td",ACe,[n(si,{variant:se,disabled:y(te.product),"has-error":F(te.product,ze,"compare_price"),onChange:St=>ge("compare_price",se.compare_price,`v:${te.productId}:${ze}`)},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("track_quantity")?(r(),m("td",pCe,Ie[21]||(Ie[21]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("stock")?(r(),m("td",fCe,[((Me=(_t=te.product)==null?void 0:_t.detail)==null?void 0:Me.manage_stock)==="1"?(r(),E(na,{key:0,class:"fc-bulk-input",size:"small",modelValue:se.total_stock,"onUpdate:modelValue":[St=>se.total_stock=St,St=>{se.available=St,c(Ft).syncStockStatus(te.product),ge("stock",St,`v:${te.productId}:${ze}`)}],disabled:y(te.product),placeholder:be.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),m("span",mCe,"—"))])):B("",!0),o("td",{class:ue(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":z.value}])},[o("div",hCe,[n(lt,{tag:"button",size:"x-small",onClick:Ge(St=>I(te.product,se),["prevent"]),disabled:s.value||y(te.product),title:be.$t("Duplicate")},{default:u(()=>[n(X,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(lt,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(St=>$(te.product,se),["prevent"]),disabled:s.value||y(te.product),title:be.$t("Delete")},{default:u(()=>[n(X,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,Ywe)}),128)),o("tr",_Ce,[o("td",{colspan:Ve.value.length+1},[o("div",gCe,[n(it,{size:"small",text:"",type:"primary",onClick:Ge(se=>c(Ft).addVariationToProduct(te.product),["prevent"])},{default:u(()=>[R(" + "+f(be.$t("Add Variant")),1)]),_:2},1032,["onClick"])])],8,vCe)])])])]),_:2},1032,["visible"])],8,jwe)])):B("",!0)],64)}),128)),Ht.value>0?(r(),m("tr",yCe,[o("td",{colspan:Ve.value.length+1,style:fa({height:Ht.value+"px",padding:0,border:"none"})},null,12,bCe)])):B("",!0)]),_:1},8,["columns","sticky-last"])],2)):(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:c(d)("No products yet. Import a CSV or add products manually.")},null,8,["text"]))]),_:1})]}),_:1}),n(Za,{modelValue:W.value.visible,"onUpdate:modelValue":Ie[6]||(Ie[6]=va=>W.value.visible=va),title:de.value,width:"700px","close-on-click-modal":!1,onClosed:Ie[7]||(Ie[7]=va=>W.value.product=null)},{footer:u(()=>[n(it,{onClick:Ie[5]||(Ie[5]=va=>W.value.visible=!1)},{default:u(()=>[R(f(be.$t("Cancel")),1)]),_:1}),n(it,{type:"primary",onClick:J},{default:u(()=>[R(f(be.$t("Save")),1)]),_:1})]),default:u(()=>[W.value.visible&&W.value.field==="post_content"?(r(),E(ss,{key:0,"model-value":W.value.value,height:300,onUpdate:Y},null,8,["model-value"])):B("",!0),W.value.visible&&W.value.field==="post_excerpt"?(r(),E(na,{key:1,modelValue:W.value.value,"onUpdate:modelValue":Ie[4]||(Ie[4]=va=>W.value.value=va),type:"textarea",rows:6,placeholder:be.$t("Short description")},null,8,["modelValue","placeholder"])):B("",!0)]),_:1},8,["modelValue","title"])])}}};class BCe extends Md{beforeInit(){this.data.products=[],this.data.dirty=new Set,this.data.loading=!1,this.data.saving=!1,this.data.pagination={page:1,per_page:5,total:0,hasMore:!1},this.data.saveProgress={total:0,completed:0,errors:[],updatedIds:[]},this.data.savingIds=new Set,this.data.savedIds=new Set,this.data.productErrors=new Map,this.data.advanceFilters=[[]],this.data.filterType="simple",this.data.selectedView="all",this.data.searching=!1,this.data.search="",this.data.duplicatingIds=new Set,this.data.deletingIds=new Set,this.data.categoryOptions=[],this.data.constrainedProductIds="",this.data.constrainedVariantIds="",this.data.savedViews=[],this.data.activeSavedViewId=null,this.data.savedViewQueryParams=null}getTabs(){return{all:d("All"),publish:d("Published"),draft:d("Draft"),physical:d("Physical"),digital:d("Digital")}}getTabsCount(){return Object.values(this.getTabs()).length}getSelectedTab(){return this.data.selectedView}handleTabChanged(t){t!==this.data.selectedView&&(this.data.selectedView=t,this.fetchProducts({},!1))}isSearching(){return this.data.searching!==!1}openSearch(){this.data.searching=!0}closeSearch(){this.data.searching=!1,this.data.search="",this.fetchProducts({},!1)}search(){this.fetchProducts({},!1)}useFullWidthSearch(){return!1}getSearchHint(){return d("Search by Id, product title or variation title")}getSearchGuideOptions(){return null}isUsingAdvanceFilter(){return this.data.filterType==="advanced"}isUsingSimpleFilter(){return this.data.filterType==="simple"}isAdvanceFilterEnabled(){return this.getAdvanceFilterOptions()!==null}getAdvanceFilterOptions(){var t,a,l;return((l=(a=(t=window.fluentCartAdminApp)==null?void 0:t.filter_options)==null?void 0:a.product_filter_options)==null?void 0:l.advance)||null}onFilterTypeChanged(t){t==="advanced"?(this.data.searching=!1,this.data.search=""):this.data.advanceFilters=[[]],this.fetchProducts({},!1)}applyAdvancedFilter(t=!1){this.fetchProducts({},!1)}addAdvanceFilterGroup(){this.data.advanceFilters.push([])}removeAdvanceFilterGroup(t){this.data.advanceFilters.length>1&&this.data.advanceFilters.splice(t,1)}clearAdvanceFilter(){this.data.advanceFilters=[[]],this.fetchProducts({},!1)}getColumnWidthStorageKey(){return"bulk_edit_column_widths"}getColumnStorageKey(){return"bulk_edit_columns"}getToggleableColumns(){return[{label:"Image",value:"image"},{label:"SKU",value:"sku"},{label:"Categories",value:"categories"},{label:"Description",value:"description"},{label:"Short Description",value:"short_description"},{label:"Status",value:"status"},{label:"Product Type",value:"product_type"},{label:"Pricing Type",value:"pricing_type"},{label:"Payment Type",value:"payment_type"},{label:"Interval",value:"interval"},{label:"Trial Days",value:"trial_days"},{label:"Best Price",value:"best_price"},{label:"Compare-at Price",value:"compare_price"},{label:"Track Quantity",value:"track_quantity"},{label:"Stock",value:"stock"}]}getSortableColumns(){return[]}markDirty(t){this._suppressDirty||(this.data.dirty.add(t),this.data.dirty=new Set(this.data.dirty),this.data.savedIds.has(t)&&(this.data.savedIds.delete(t),this.data.savedIds=new Set(this.data.savedIds)),this.data.productErrors.has(t)&&(this.data.productErrors.delete(t),this.data.productErrors=new Map(this.data.productErrors)))}get dirtyCount(){return this.data.dirty.size}getDirtyProducts(){return this.data.products.filter(t=>this.data.dirty.has(t.ID))}chunkArray(t,a){const l=[];for(let s=0;s{this._suppressDirty=!1}),this.data.pagination={page:_.page||h.page,per_page:_.per_page||h.per_page,total:_.total||0,hasMore:_.page*_.per_page<_.total}}catch(A){const p=((i=A==null?void 0:A.data)==null?void 0:i.message)||"Failed to fetch products";q.error(p)}finally{this.data.loading=!1}}isSavingProduct(t){return this.data.savingIds.has(t)}isDirty(t){return this.data.dirty.has(t)}isSaved(t){return this.data.savedIds.has(t)}isRowDisabled(t){return this.isSavingProduct(t)}isDuplicating(t){return this.data.duplicatingIds.has(t)}isDeleting(t){return this.data.deletingIds.has(t)}hasError(t){return this.data.productErrors.has(t)}getError(t){const a=this.data.productErrors.get(t);return a?a.fields&&Object.keys(a.fields).length?Object.values(a.fields).join("; "):a.message||"":""}hasProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?!!a.message:Object.keys(a.fields).some(l=>!l.startsWith("variants.")):!1}getProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?a.message||"":Object.entries(a.fields).filter(([s])=>!s.startsWith("variants.")).map(([,s])=>s).join("; ")||"":""}hasVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return!1;const s=`variants.${a}.`;return Object.keys(l.fields).some(i=>i.startsWith(s))}getVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return"";const s=`variants.${a}.`;return Object.entries(l.fields).filter(([A])=>A.startsWith(s)).map(([,A])=>A).join("; ")}hasFieldError(t,a){var s;const l=this.data.productErrors.get(t);return!!((s=l==null?void 0:l.fields)!=null&&s[a])}hasVariantFieldError(t,a,l){return this.hasFieldError(t,`variants.${a}.${l}`)}async saveProduct(t){var l,s,i,A;const a=t.ID;if(!this.data.savingIds.has(a)){this.data.savingIds.add(a),this.data.savingIds=new Set(this.data.savingIds);try{const p=await Ae.post("products/bulk-update",{products:[t]});if((l=p.updated)!=null&&l.length)this.data.dirty.delete(a),this.data.dirty=new Set(this.data.dirty),this.data.savedIds.add(a),this.data.savedIds=new Set(this.data.savedIds),this.data.productErrors.delete(a),this.data.productErrors=new Map(this.data.productErrors),q.success(d("Product updated successfully"));else if((s=p.errors)!=null&&s.length){const h=p.errors[0];h!=null&&h.fields&&(this.data.productErrors.set(a,h),this.data.productErrors=new Map(this.data.productErrors)),q.error((h==null?void 0:h.message)||"Failed to save product")}}catch(p){const h=((i=p==null?void 0:p.data)==null?void 0:i.message)||"Failed to save product",_=(A=p==null?void 0:p.data)==null?void 0:A.errors;if(_!=null&&_.length){const y=_[0];y!=null&&y.fields&&(this.data.productErrors.set(a,y),this.data.productErrors=new Map(this.data.productErrors))}q.error(h)}finally{this.data.savingIds.delete(a),this.data.savingIds=new Set(this.data.savingIds)}}}async saveProducts(){var l,s;const t=this.getDirtyProducts().filter(i=>!this.data.savedIds.has(i.ID));if(t.length===0){q.info(d("No changes to save"));return}const a=this.chunkArray(t,10);this.data.saving=!0,this.data.saveProgress={total:a.length,completed:0,errors:[],updatedIds:[]};try{for(const p of a){const h=p.map(_=>_.ID);for(const _ of h)this.data.savingIds.add(_);this.data.savingIds=new Set(this.data.savingIds);try{const _=await Ae.post("products/bulk-update",{products:p});if(_.updated){this.data.saveProgress.updatedIds.push(..._.updated);for(const y of _.updated)this.data.savedIds.add(y),this.data.dirty.delete(y),this.data.productErrors.delete(y);this.data.savedIds=new Set(this.data.savedIds),this.data.dirty=new Set(this.data.dirty),this.data.productErrors=new Map(this.data.productErrors)}if(_.errors&&_.errors.length){this.data.saveProgress.errors.push(..._.errors);for(const y of _.errors)y.post_id&&y.fields&&this.data.productErrors.set(y.post_id,y);this.data.productErrors=new Map(this.data.productErrors)}}catch(_){const y=((l=_==null?void 0:_.data)==null?void 0:l.message)||"A chunk failed to save";this.data.saveProgress.errors.push({message:y});const g=(s=_==null?void 0:_.data)==null?void 0:s.errors;if(g!=null&&g.length){for(const v of g)v.post_id&&v.fields&&this.data.productErrors.set(v.post_id,v);this.data.productErrors=new Map(this.data.productErrors)}}for(const _ of h)this.data.savingIds.delete(_);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{updatedIds:i,errors:A}=this.data.saveProgress;A.length===0?q.success(`${i.length} product(s) updated successfully`):i.length>0?q.info(`${i.length} product(s) updated, ${A.length} error(s)`):q.error(d("All products failed to save"))}finally{this.data.saving=!1}}async duplicateProduct(t){var l;const a=t.ID;if(!(!a||this.data.duplicatingIds.has(a))){this.data.duplicatingIds.add(a),this.data.duplicatingIds=new Set(this.data.duplicatingIds);try{const i=(await Ae.post(`products/${a}/duplicate`,{})).product_id;if(i){const p=(await Ae.get("products/bulk-edit-data",{search:i,per_page:1})).products||[];if(p.length>0){const h=this.data.products.indexOf(t);this.data.products.splice(h+1,0,p[0])}}}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to duplicate product";q.error(i)}finally{this.data.duplicatingIds.delete(a),this.data.duplicatingIds=new Set(this.data.duplicatingIds)}}}async duplicateProductWithVariants(t,a){var s;const l=t.ID;if(!(!l||this.data.duplicatingIds.has(l))){this.data.duplicatingIds.add(l),this.data.duplicatingIds=new Set(this.data.duplicatingIds);try{const A=(await Ae.post(`products/${l}/duplicate`,{})).product_id;if(!A)return;const h=(await Ae.get("products/bulk-edit-data",{search:A,per_page:1})).products||[];if(!h.length)return;const _=h[0],y=t.variants||[],g=new Set;for(const C of y)a.includes(C.id)&&C.serial_index!=null&&g.add(C.serial_index);_.variants&&g.size>0&&(_.variants=_.variants.filter(C=>g.has(C.serial_index)));const v=this.data.products.indexOf(t);this.data.products.splice(v+1,0,_),this.markDirty(_.ID)}catch(i){const A=((s=i==null?void 0:i.data)==null?void 0:s.message)||"Failed to duplicate product";q.error(A)}finally{this.data.duplicatingIds.delete(l),this.data.duplicatingIds=new Set(this.data.duplicatingIds)}}}duplicateVariant(t,a){const l=JSON.parse(JSON.stringify(a));l.variation_title=l.variation_title?l.variation_title+" (Copy)":"",l.sku="",delete l.id,delete l.post_id;const s=t.variants.indexOf(a);t.variants.splice(s+1,0,l),this.markDirty(t.ID)}async deleteProduct(t){var l;const a=t.ID;if(!(!a||this.data.deletingIds.has(a))){this.data.deletingIds.add(a),this.data.deletingIds=new Set(this.data.deletingIds);try{await Ae.delete(`products/${a}`);const s=this.data.products.indexOf(t);s!==-1&&this.data.products.splice(s,1),this.data.dirty.delete(a),this.data.savedIds.delete(a)}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to delete product";q.error(i)}finally{this.data.deletingIds.delete(a),this.data.deletingIds=new Set(this.data.deletingIds)}}}removeVariant(t,a){if(t.variants.length<=1)return q.error(d("A product must have at least one variant.")),!1;const l=t.variants.indexOf(a);return l!==-1&&t.variants.splice(l,1),this.markDirty(t.ID),!0}resetPaymentTypeDefaults(t){t.other_info.payment_type==="onetime"&&(t.other_info.installment="no",t.other_info.times="",t.other_info.manage_setup_fee="no",t.other_info.signup_fee="",t.other_info.signup_fee_name="")}flattenCategoryTree(t,a=""){var s;const l=[];for(const i of t){const A=a?`${a} > ${i.label}`:i.label;l.push({label:A,value:A}),(s=i.children)!=null&&s.length&&l.push(...this.flattenCategoryTree(i.children,A))}return l}async fetchCategories(){try{const a=(await Ae.get("products/fetch-term")).taxonomies||{},l=Object.values(a).find(s=>s.name==="product-categories");l!=null&&l.terms&&(this.data.categoryOptions=this.flattenCategoryTree(l.terms))}catch{}}setupSavedViews(){var a,l;const t=(a=window.fluentCartAdminApp)==null?void 0:a.table_config;this.data.savedViews=((l=t==null?void 0:t.products)==null?void 0:l.saved_views)||[]}getSavedViews(){return this.data.savedViews}getActiveSavedViewId(){return this.data.activeSavedViewId}applySavedView(t){const a=this.data.savedViews.find(l=>l.slug===t);a&&(this.data.activeSavedViewId=t,this.data.savedViewQueryParams=a.query_params)}isViewOwner(t){var a,l;return!t||!t.owner_id?!1:t.owner_id===((l=(a=window.fluentCartAdminApp)==null?void 0:a.me)==null?void 0:l.id)}renameSavedView(t,a){}updateSavedView(t){}deleteSavedView(t){}}const rt=BCe.init(),xCe={class:"fct-bulk-edit-page fct-layout-width"},SCe={class:"fct-table-wrapper"},$Ce={class:"fct-card-header-top"},FCe={class:"fct-card-header-left flex-1"},ECe={class:"fct-card-header-actions"},UCe={key:0,class:"fct-advanced-filter-toggle-wrapper"},ICe={key:1,class:"fct-btn-group sm hidden md:flex"},VCe={key:0,class:"filter-search-wrap"},DCe={class:"search-bar"},QCe={class:"text-xs text-system-light pt-2 dark:text-gray-300"},TCe={class:"fct-bulk-edit-table-wrap"},MCe={key:0,class:"px-5 py-3 flex items-center justify-between border border-solid border-x-0 border-gray-divider border-t-0 dark:border-dark-400"},LCe={class:"m-0 text-base"},RCe={key:0,class:"text-system-mid text-sm font-normal dark:text-gray-300"},OCe={class:"fct-btn-group sm justify-end"},PCe={class:"filter-popover-item"},HCe={class:"filter-popover-title"},NCe={class:"fct-bulk-edit-table"},KCe={key:0,"aria-hidden":"true"},GCe=["colspan"],zCe=["onClick"],jCe=["onClick"],qCe={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},YCe={class:"flex items-center"},WCe=["onClick","title"],XCe={key:0,class:"bulk-collapse-count"},JCe=["title"],ZCe={class:"bulk-status-icon is-error"},e2e=["disabled","onClick","title"],t2e={key:0,class:"fct-bulk-media-cell"},a2e={key:1,class:"fct-bulk-sku-cell"},l2e={key:1,class:"text-gray-300 text-sm flex justify-center"},s2e={key:2,class:"fct-bulk-categories-cell"},n2e={key:3,class:"fct-bulk-desc-cell"},o2e={key:4,class:"fct-bulk-short-desc-cell"},i2e={key:5,class:"fct-bulk-status-cell"},r2e={key:6,class:"fct-bulk-product-type-cell"},d2e={class:"bulk-readonly-label"},u2e={key:7,class:"fct-bulk-pricing-type-cell"},c2e={class:"bulk-readonly-label"},A2e={key:8,class:"fct-bulk-payment-type-cell"},p2e={key:9,class:"fct-bulk-interval-cell"},f2e={key:10,class:"fct-bulk-trial-days-cell"},m2e={key:11,class:"fct-bulk-best-price-cell"},h2e={key:12,class:"fct-bulk-compare-price-cell"},_2e={key:13,class:"fct-bulk-qty-cell !pl-5"},v2e={key:14,class:"fct-bulk-stock-cell"},g2e={key:1,class:"text-gray-300 text-sm flex justify-center"},y2e={class:"fct-btn-group sm justify-end"},b2e={key:0,class:"bulk-variants-block-row"},w2e=["colspan"],C2e={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},k2e=["onClick"],B2e={class:"bulk-checkbox-cell"},x2e={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},S2e={class:"flex items-center gap-1 pl-4"},$2e={class:"bulk-status-icon is-error"},F2e={key:0},E2e={key:1},U2e={key:2},I2e={key:3},V2e={key:4},D2e={key:5},Q2e={key:6},T2e={key:7},M2e={key:8},L2e={key:9},R2e={key:10},O2e={key:11},P2e={key:12},H2e={key:13,class:"text-center"},N2e={key:14},K2e={key:1,class:"text-gray-300 text-sm flex justify-center"},G2e={class:"fct-btn-group sm justify-end"},z2e={key:1,"aria-hidden":"true"},j2e=["colspan"],q2e={key:1,class:"flex flex-col items-center justify-center py-16 text-center"},Y2e={class:"text-system-mid text-sm"},W2e={key:2,class:"flex items-center justify-center py-8"},X2e={class:"text-system-mid text-sm"},J2e={key:1,class:"flex items-center justify-center py-3 border-top"},Z2e={class:"text-system-mid text-sm"},fr=43,eke=10,Tc=800,Mc=100,tke=200,ake={__name:"BulkEdit",setup(e){const t=Zt().ctx,a=Na(),{options:l}=rt.data,s=ne=>{var _e;return((_e=ne==null?void 0:ne.detail)==null?void 0:_e.variation_type)==="simple"},i=K(()=>rt.data.products),A=K(()=>rt.data.loading),p=K(()=>rt.data.saving),h=K(()=>rt.data.saveProgress),_=K(()=>rt.data.pagination),y=K(()=>rt.data.dirty),g=K(()=>y.value.size),v=K(()=>Math.max(0,_.value.total-i.value.length)),C=K(()=>Math.min(_.value.per_page,v.value)),w=K(()=>{const ne=rt.data.saveProgress;return ne.total?Math.round(ne.completed/ne.total*100):0}),b=sd("search-input"),S=()=>{rt.openSearch(),Fe(()=>{var ne;(ne=b.value)==null||ne.focus()})},F=(ne=!1)=>{rt.fetchProducts({},ne)},Q=()=>{rt.saveProducts()},$=ne=>{rt.markDirty(ne.ID)},x=(ne,_e)=>{rt.resetPaymentTypeDefaults(_e),$(ne)},I=(ne,_e)=>{const We=rt.data.categoryOptions;for(const ot of _e)We.find(qe=>qe.value===ot)||We.push({label:ot,value:ot});$(ne)},V=ne=>rt.isDirty(ne.ID),D=ne=>rt.isSavingProduct(ne.ID),U=ne=>rt.isSaved(ne.ID),L=ne=>rt.isRowDisabled(ne.ID),O=ne=>rt.isDuplicating(ne.ID),M=ne=>rt.isDeleting(ne.ID),H=ne=>rt.hasError(ne.ID),j=ne=>rt.getError(ne.ID),W=ne=>rt.hasProductLevelError(ne.ID),G=(ne,_e)=>rt.hasVariantError(ne.ID,_e),Y=(ne,_e)=>rt.getVariantError(ne.ID,_e),J=(ne,_e)=>rt.hasFieldError(ne.ID,_e),de=(ne,_e,We)=>rt.hasVariantFieldError(ne.ID,_e,We),z=ne=>rt.saveProduct(ne),ce=ne=>rt.duplicateProduct(ne),oe=(ne,_e)=>rt.duplicateVariant(ne,_e),Z=T(!0),{selectedKeys:N,handleRowClick:le,toggleSelectAll:ee,selectAll:pe,deselectAll:re,isSelected:Ue,selectedCount:we,isLinkMode:Be,toggleLinkMode:ge}=Uf(),Ce=K(()=>{const ne=[];for(const _e of Bt.value)if(ne.push(`p:${_e.productId}`),_e.hasVariants&&!_e.collapsed)for(const We of _e.product.variants)ne.push(`v:${We.id}`);return ne}),Oe=ne=>{var _e;if(ne.startsWith("p:")){const We=parseInt(ne.slice(2)),ot=Bt.value.find(qe=>qe.productId===We);return ot?{type:"product",data:ot.product,product:ot.product}:null}else if(ne.startsWith("v:")){const We=parseInt(ne.slice(2));for(const ot of Bt.value){const qe=(_e=ot.product.variants)==null?void 0:_e.find(Ze=>Ze.id===We);if(qe)return{type:"variant",data:qe,product:ot.product}}}return null},Ee=(ne,_e,We)=>{!Be.value||!Ue(We)||Vf(ne,_e,We,N.value,Oe,$,dwe)},fe=T(!1),ye=ne=>{ne.key==="Shift"&&(fe.value=!0)},Ve=ne=>{ne.key==="Shift"&&(fe.value=!1)},Le=(ne,_e)=>{if(!_e.shiftKey||_e.target.closest(".bulk-checkbox-cell"))return;_e.preventDefault();const We=new Set(N.value);We.has(ne)?We.delete(ne):We.add(ne),N.value=We},At=()=>{const ne=[];for(const _e of Bt.value){const We=`p:${_e.productId}`,ot=N.value.has(We),qe=[];if(_e.product.variants)for(const Ze of _e.product.variants)N.value.has(`v:${Ze.id}`)&&qe.push(Ze.id);!ot&&qe.length===0||(ot&&qe.length===0?ne.push({product:_e.product,type:"full"}):!ot&&qe.length>0?ne.push({product:_e.product,type:"variants-only",variantIds:qe}):ne.push({product:_e.product,type:"partial",variantIds:qe}))}return ne},mt=async()=>{const ne=At();if(!ne.length)return;const _e=ne.filter(gt=>gt.type==="full").length,We=ne.filter(gt=>gt.type==="partial").length,qe=ne.filter(gt=>gt.type==="variants-only").reduce((gt,tt)=>gt+tt.variantIds.length,0),Ze=[];_e>0&&Ze.push(`${_e} product(s) with all variants`),We>0&&Ze.push(`${We} product(s) with selected variants`),qe>0&&Ze.push(`${qe} variant(s)`);try{await El.confirm(t.$t("Duplicate %s?").replace("%s",Ze.join(", ")),t.$t("Bulk Duplicate"),{confirmButtonText:t.$t("Duplicate"),cancelButtonText:t.$t("Cancel"),type:"info"})}catch{return}for(const gt of ne)if(gt.type==="full")await rt.duplicateProduct(gt.product);else if(gt.type==="variants-only")for(const tt of gt.variantIds){const Vt=gt.product.variants.find(me=>me.id===tt);Vt&&rt.duplicateVariant(gt.product,Vt)}else gt.type==="partial"&&await rt.duplicateProductWithVariants(gt.product,gt.variantIds);re()},Mt=async()=>{const ne=[],_e=[];for(const qe of Bt.value){const Ze=`p:${qe.productId}`;if(N.value.has(Ze)){ne.push(qe.product);continue}const tt=[];if(qe.product.variants)for(const Vt of qe.product.variants)N.value.has(`v:${Vt.id}`)&&tt.push(Vt);tt.length>0&&_e.push({product:qe.product,variants:tt})}if(!ne.length&&!_e.length)return;const We=_e.reduce((qe,Ze)=>qe+Ze.variants.length,0),ot=[];ne.length>0&&ot.push(`${ne.length} product(s)`),We>0&&ot.push(`${We} variant(s)`);try{await El.confirm(t.$t("Permanently delete %s? This cannot be undone.").replace("%s",ot.join(" and ")),t.$t("Bulk Delete"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}for(const qe of ne)await rt.deleteProduct(qe);for(const{product:qe,variants:Ze}of _e)for(const gt of Ze)rt.removeVariant(qe,gt);re()},Dt=async ne=>{const _e=ne.ID;if(!_e||rt.isDeleting(_e))return;const We=ne.post_title||t.$t("Untitled product"),ot=Array.isArray(ne.variants)?ne.variants.length:0,qe=ot>0?t.$t('This will permanently delete "%1$s" and its %2$s variant(s).',We,ot):t.$t('This will permanently delete "%1$s".',We);try{await El.confirm(qe,t.$t("Delete Product"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}rt.deleteProduct(ne)},Xe=(ne,_e)=>{if(ne.variants.length<=1){rt.removeVariant(ne,_e);return}const We=_e.variation_title||t.$t("Untitled variant");El.confirm(t.$t('This will remove the variant "%1$s".',We),t.$t("Remove Variant"),{confirmButtonText:t.$t("Remove"),cancelButtonText:t.$t("Cancel"),type:"warning"}).then(()=>{rt.removeVariant(ne,_e)}).catch(()=>{})},pt=T({visible:!1,field:"",product:null,value:""}),jt=(ne,_e)=>{pt.value={visible:!0,field:_e,product:ne,value:ne[_e]||""}},Ct=ne=>{pt.value.value=ne},$t=()=>{const{product:ne,field:_e,value:We}=pt.value;ne&&(ne[_e]=We,$(ne)),pt.value.visible=!1},Ht=K(()=>pt.value.field==="post_content"?t.$t("Edit Description"):t.$t("Edit Short Description")),Nt=T([]),Qt=K(()=>Nt.value.filter(ne=>ne.key==="title"||ne.key==="actions"?!0:rt.isColumnVisible(ne.key))),yt=ne=>rt.isColumnVisible(ne),Xt=()=>{rt.saveColumnWidths(Nt.value)},be=T(new Set),Ie=ne=>{const _e=ne.ID;be.value.has(_e)?be.value.delete(_e):be.value.add(_e),be.value=new Set(be.value)},it=ne=>be.value.has(ne.ID),kt=T(0),Bt=K(()=>{let ne=0;return i.value.map(_e=>{var me;const We=_e.ID,ot=((me=_e.detail)==null?void 0:me.variation_type)!=="simple"&&Array.isArray(_e.variants)&&_e.variants.length>0,qe=ot?_e.variants.length:0,Ze=be.value.has(We),gt=ot&&!Ze?qe*fr:0,tt=fr+gt,Vt={product:_e,productId:We,hasVariants:ot,variantCount:qe,collapsed:Ze,groupHeight:tt,offset:ne};return ne+=tt,Vt})}),ta=K(()=>{const ne=Bt.value;if(ne.length===0)return 0;const _e=ne[ne.length-1];return _e.offset+_e.groupHeight}),bt=K(()=>{const ne=Bt.value,_e=kt.value,We=_e+Tc,ot=eke*fr;return ne.filter(qe=>qe.offset+qe.groupHeight>=_e-ot&&qe.offset<=We+ot)}),sa=K(()=>bt.value.length===0?0:bt.value[0].offset),na=K(()=>{if(bt.value.length===0)return 0;const ne=bt.value[bt.value.length-1];return ta.value-ne.offset-ne.groupHeight});let qt=null,ka=0;const Ja=()=>{if(A.value||!_.value.hasMore||i.value.length===0)return;ta.value-(kt.value+Tc){const _e=ne.target,We=Date.now();qt&&clearTimeout(qt),We-ka>=Mc?(kt.value=_e.scrollTop,ka=We,Ja()):qt=setTimeout(()=>{kt.value=_e.scrollTop,ka=Date.now(),qt=null,Ja()},Mc)},Za=ne=>({physical:"Physical",digital:"Digital"})[ne]||ne||"—",va=ne=>({simple:"Simple",simple_variations:"Variable"})[ne]||ne||"—";let te=null;const Se=()=>{const ne=a.query.product_ids,_e=a.query.variant_ids;ne&&_e?rt.fetchProducts({},!1,ne,_e):F(!1)};return De(async()=>{te=is(),te.bind("mod+a",ne=>{var We,ot;const _e=(We=document.activeElement)==null?void 0:We.tagName;_e==="INPUT"||_e==="TEXTAREA"||(ot=document.activeElement)!=null&&ot.isContentEditable||(ne.preventDefault(),pe(Ce.value))}),te.bind("escape",()=>{var _e,We;const ne=(_e=document.activeElement)==null?void 0:_e.tagName;ne==="INPUT"||ne==="TEXTAREA"||(We=document.activeElement)!=null&&We.isContentEditable||(Be.value?ge():re())}),Nt.value=[{key:"title",title:t.$t("Title"),width:150,minWidth:100},{key:"image",title:t.$t("Image"),width:60,minWidth:50},{key:"sku",title:t.$t("SKU"),width:120,minWidth:80},{key:"categories",title:t.$t("Categories"),width:200,minWidth:150},{key:"description",title:t.$t("Description"),width:200,minWidth:150},{key:"short_description",title:t.$t("Short Description"),width:150,minWidth:100},{key:"status",title:t.$t("Status"),width:100,minWidth:50},{key:"product_type",title:t.$t("Product Type"),width:120,minWidth:80},{key:"pricing_type",title:t.$t("Pricing Type"),width:120,minWidth:80},{key:"payment_type",title:t.$t("Payment Type"),width:120,minWidth:100},{key:"interval",title:t.$t("Interval"),width:120,minWidth:80},{key:"trial_days",title:t.$t("Trial Days"),width:100,minWidth:70},{key:"best_price",title:t.$t("Best Price"),width:100,minWidth:100},{key:"compare_price",title:t.$t("Compare-at Price"),width:150,minWidth:100},{key:"track_quantity",title:t.$t("Track Quantity"),width:100,minWidth:100},{key:"stock",title:t.$t("Stock"),width:120,minWidth:80},{key:"actions",title:"",width:110,minWidth:110}],rt.restoreColumnWidths(Nt.value),rt.setupColumnVisibility(),rt.setupSavedViews(),rt.fetchCategories(),Se(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",ye),window.addEventListener("keyup",Ve)}),Ya(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",ye),window.removeEventListener("keyup",Ve),te&&te.reset()}),(ne,_e)=>{const We=k("el-button"),ot=k("el-progress"),qe=k("el-switch"),Ze=k("el-tooltip"),gt=k("el-input"),tt=k("el-checkbox"),Vt=k("el-checkbox-group"),me=k("el-popover"),ve=k("el-icon"),Ne=k("el-option"),Pe=k("el-select"),ft=k("el-dialog");return r(),m("div",xCe,[n(nl,{title:ne.$t("Bulk Edit")},{action:u(()=>[n(We,{type:"primary",onClick:Q,loading:p.value,disabled:p.value||g.value===0},{default:u(()=>[R(f(p.value?ne.$t("Saving %s/%s...").replace("%s",h.value.completed).replace("%s",h.value.total):g.value>0?ne.$t("Save Changes")+` (${g.value})`:ne.$t("Save Changes")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),p.value?(r(),E(ot,{key:0,percentage:w.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):B("",!0),o("div",SCe,[n($e,null,{default:u(()=>[n(Qe,{border_bottom:""},{default:u(()=>[o("div",$Ce,[o("div",FCe,[c(rt).getTabsCount()&&!c(rt).isUsingAdvanceFilter()?(r(),E(om,{key:0,class:ue("hide-animation-on-mobile hidden md:inline-flex classic-tab-style"),table:c(rt)},null,8,["table"])):B("",!0)]),o("div",ECe,[c(rt).isAdvanceFilterEnabled()?(r(),m("div",UCe,[n(qe,{class:"fct-advanced-filter-toggle",onChange:_e[0]||(_e[0]=se=>{c(rt).onFilterTypeChanged(se)}),"active-value":"advanced","inactive-value":"simple",modelValue:c(rt).data.filterType,"onUpdate:modelValue":_e[1]||(_e[1]=se=>c(rt).data.filterType=se),"active-text":ne.$t("Advanced Filter"),size:"small"},null,8,["modelValue","active-text"])])):B("",!0),c(rt).isUsingAdvanceFilter()?B("",!0):(r(),m("div",ICe,[c(rt).isSearching()?B("",!0):(r(),E(Ze,{key:0,effect:"light",content:ne.$t("Search"),placement:"top","popper-class":"fct-tooltip"},{default:u(()=>[n(lt,{tag:"button",onClick:Ge(S,["prevent"])},{default:u(()=>[n(X,{name:"Search"})]),_:1})]),_:1},8,["content"]))]))])]),n(Zc,{table:c(rt)},null,8,["table"]),c(rt).isSearching()&&!c(rt).isUsingAdvanceFilter()?(r(),m("div",VCe,[o("div",DCe,[n(gt,{ref:"search-input",onClear:_e[2]||(_e[2]=()=>{c(rt).search()}),onKeyup:_e[3]||(_e[3]=da(()=>{c(rt).search()},["enter"])),modelValue:c(rt).data.search,"onUpdate:modelValue":_e[4]||(_e[4]=se=>c(rt).data.search=se),type:"text",placeholder:ne.$t("Search"),clearable:""},{prefix:u(()=>[n(X,{name:"Search"})]),_:1},8,["modelValue","placeholder"]),o("div",QCe,f(c(rt).getSearchHint()),1)]),n(We,{text:"",onClick:_e[5]||(_e[5]=()=>{c(rt).closeSearch()})},{default:u(()=>[R(f(ne.$t("Cancel")),1)]),_:1})])):B("",!0)]),_:1}),n(xe,{class:"p-0"},{default:u(()=>[o("div",TCe,[i.value.length>0?(r(),m("div",MCe,[o("h5",LCe,[R(f(i.value.length)+" "+f(i.value.length===1?ne.$t("Product"):ne.$t("Products"))+" ",1),_.value.total>i.value.length?(r(),m("span",RCe,f(ne.$t("of"))+" "+f(_.value.total)+" "+f(ne.$t("total"))+" · "+f(C.value)+" "+f(ne.$t("next")),1)):B("",!0)]),o("div",OCe,[n(We,{disabled:c(we)===0,onClick:mt,size:"small"},{default:u(()=>[_e[14]||(_e[14]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)),R(" "+f(ne.$t("Duplicate")),1)]),_:1,__:[14]},8,["disabled"]),n(We,{disabled:c(we)===0,onClick:Mt,size:"small",type:"danger",plain:""},{default:u(()=>[_e[15]||(_e[15]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("polyline",{points:"3 6 5 6 21 6"}),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)),R(" "+f(ne.$t("Delete")),1)]),_:1,__:[15]},8,["disabled"]),n(We,{class:ue({"is-active":c(Be)}),disabled:c(we)<2&&!c(Be),onClick:c(ge),size:"small"},{default:u(()=>[_e[16]||(_e[16]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)),R(" "+f(c(Be)?ne.$t("Unlink"):ne.$t("Link")),1)]),_:1,__:[16]},8,["class","disabled","onClick"]),n(tt,{modelValue:Z.value,"onUpdate:modelValue":_e[6]||(_e[6]=se=>Z.value=se),label:ne.$t("Pin Actions")},null,8,["modelValue","label"]),n(me,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:u(()=>[o("span",null,[n(Ze,{effect:"light",content:ne.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:u(()=>[n(lt,{tag:"button",size:"small"},{default:u(()=>[n(X,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:u(()=>[o("div",PCe,[o("h3",HCe,f(ne.$t("Columns")),1),n(Vt,{modelValue:c(rt).data.visibleColumns,"onUpdate:modelValue":_e[7]||(_e[7]=se=>c(rt).data.visibleColumns=se),class:"fct-checkbox-blocks",onChange:_e[8]||(_e[8]=se=>c(rt).handleColumnVisibilityChange())},{default:u(()=>[(r(!0),m(P,null,ae(c(rt).getToggleableColumns(),se=>(r(),E(tt,{key:se.value,value:se.value,label:ne.$t(se.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])])):B("",!0),o("div",NCe,[i.value.length>0?(r(),m("div",{key:0,class:ue(["relative",{"is-link-mode":c(Be),"is-shift-held":fe.value}])},[n(Ff,{columns:Qt.value,"sticky-last":Z.value,onScroll:ul,onResizeEnd:Xt},{"header-first":u(()=>[Wt(n(tt,{checked:c(we)>0&&c(we)===Ce.value.length,onChange:_e[9]||(_e[9]=se=>c(ee)(Ce.value))},null,8,["checked"]),[[c(iwe),c(we)>0&&c(we)[R(f(ne.$t("Actions")),1)]),default:u(()=>[sa.value>0?(r(),m("tr",KCe,[o("td",{colspan:Qt.value.length+1,style:fa({height:sa.value+"px",padding:0,border:"none"})},null,12,GCe)])):B("",!0),(r(!0),m(P,null,ae(bt.value,se=>{var ze,_t,Me,St,el,ie,he,Te,He,Ye,ht,at,It,Yt,Ma,Et,aa,ga;return r(),m(P,{key:se.productId},[o("tr",{class:ue(["bulk-product-row",{"is-dirty":V(se.product),"is-saving":D(se.product),"is-saved":U(se.product),"has-product-error":H(se.product),"is-selected":c(Ue)(`p:${se.productId}`)}]),onClick:et=>Le(`p:${se.productId}`,et)},[o("td",{class:"bulk-checkbox-cell",onClick:et=>c(le)(`p:${se.productId}`,et,Ce.value)},[n(tt,{"model-value":c(Ue)(`p:${se.productId}`),tabindex:"-1"},null,8,["model-value"])],8,jCe),o("td",qCe,[o("div",YCe,[se.hasVariants?(r(),m("button",{key:0,class:"bulk-collapse-btn",onClick:Ge(et=>Ie(se.product),["prevent"]),title:it(se.product)?ne.$t("Expand variants"):ne.$t("Collapse variants")},[(r(),m("svg",{class:ue(["bulk-collapse-icon",{"is-collapsed":it(se.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},_e[17]||(_e[17]=[o("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),it(se.product)?(r(),m("span",XCe,f(se.variantCount),1)):B("",!0)],8,WCe)):B("",!0),n(gt,{class:ue(["fct-bulk-input",{"is-error":J(se.product,"post_title")}]),modelValue:se.product.post_title,"onUpdate:modelValue":[et=>se.product.post_title=et,et=>{$(se.product),Ee("title",et,`p:${se.productId}`)}],placeholder:ne.$t("Product title"),disabled:L(se.product),size:"small"},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),D(se.product)?(r(),m("span",{key:1,class:"bulk-status-icon is-syncing",title:ne.$t("Saving...")},[n(ve,{class:"is-loading",size:14},{default:u(()=>[n(c(ln))]),_:1})],8,JCe)):W(se.product)||s(se.product)&&H(se.product)?(r(),E(Ze,{key:2,content:j(se.product),placement:"top"},{default:u(()=>[o("span",ZCe,[n(ve,{size:16},{default:u(()=>[n(c(To))]),_:1})])]),_:2},1032,["content"])):V(se.product)?(r(),m("button",{key:3,class:"bulk-inline-save",disabled:L(se.product),onClick:Ge(et=>z(se.product),["prevent"]),title:ne.$t("Save")},_e[18]||(_e[18]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",width:"16",height:"16"},[o("path",{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z",fill:"currentColor"})],-1)]),8,e2e)):B("",!0)])]),yt("image")?(r(),m("td",t2e,[n(bl,{modelValue:se.product.gallery,"onUpdate:modelValue":et=>se.product.gallery=et,onChange:et=>$(se.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):B("",!0),yt("sku")?(r(),m("td",a2e,[((_t=(ze=se.product)==null?void 0:ze.detail)==null?void 0:_t.variation_type)==="simple"&&((Me=se.product.variants)!=null&&Me[0])?(r(),E(gt,{key:0,class:ue(["fct-bulk-input",{"is-error":J(se.product,"variants.0.sku")}]),modelValue:se.product.variants[0].sku,"onUpdate:modelValue":[et=>se.product.variants[0].sku=et,et=>{$(se.product),Ee("sku",et,`p:${se.productId}`)}],placeholder:"SKU",size:"small",disabled:L(se.product)},null,8,["modelValue","onUpdate:modelValue","disabled","class"])):(r(),m("span",l2e,"—"))])):B("",!0),yt("categories")?(r(),m("td",s2e,[n(Ef,{modelValue:se.product.categories,"onUpdate:modelValue":et=>se.product.categories=et,options:c(rt).data.categoryOptions,disabled:L(se.product),onChange:et=>{I(se.product,et),Ee("categories",se.product.categories,`p:${se.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):B("",!0),yt("description")?(r(),m("td",n2e,[n(ni,{value:se.product.post_content,placeholder:ne.$t("Description"),onClick:et=>jt(se.product,"post_content")},null,8,["value","placeholder","onClick"])])):B("",!0),yt("short_description")?(r(),m("td",o2e,[n(ni,{value:se.product.post_excerpt,placeholder:ne.$t("Short description"),onClick:et=>jt(se.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):B("",!0),yt("status")?(r(),m("td",i2e,[n(Pe,{modelValue:se.product.post_status,"onUpdate:modelValue":et=>se.product.post_status=et,size:"small",class:ue({"is-field-error":J(se.product,"post_status")}),disabled:L(se.product),onChange:et=>{$(se.product),Ee("status",se.product.post_status,`p:${se.productId}`)}},{default:u(()=>[n(Ne,{label:ne.$t("Published"),value:"publish"},null,8,["label"]),n(Ne,{label:ne.$t("Draft"),value:"draft"},null,8,["label"])]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):B("",!0),yt("product_type")?(r(),m("td",r2e,[o("span",d2e,f(Za((el=(St=se.product)==null?void 0:St.detail)==null?void 0:el.fulfillment_type)),1)])):B("",!0),yt("pricing_type")?(r(),m("td",u2e,[o("span",c2e,f(va((he=(ie=se.product)==null?void 0:ie.detail)==null?void 0:he.variation_type)),1)])):B("",!0),yt("payment_type")?(r(),m("td",A2e,[n(ti,{variant:s(se.product)?(Te=se.product.variants)==null?void 0:Te[0]:null,disabled:L(se.product),"has-error":J(se.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:et=>{var oa;x(se.product,et),Ee("payment_type",(oa=et.other_info)==null?void 0:oa.payment_type,`p:${se.productId}`)},onChange:et=>$(se.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):B("",!0),yt("interval")?(r(),m("td",p2e,[n(ai,{variant:s(se.product)?(He=se.product.variants)==null?void 0:He[0]:null,disabled:L(se.product),"has-error":J(se.product,"variants.0.other_info.repeat_interval"),onChange:et=>{var oa,Ka,Je;$(se.product),Ee("interval",(Je=(Ka=(oa=se.product.variants)==null?void 0:oa[0])==null?void 0:Ka.other_info)==null?void 0:Je.repeat_interval,`p:${se.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("trial_days")?(r(),m("td",f2e,[n(li,{variant:s(se.product)?(Ye=se.product.variants)==null?void 0:Ye[0]:null,disabled:L(se.product),"has-error":J(se.product,"variants.0.other_info.trial_days"),onChange:et=>{var oa,Ka,Je;$(se.product),Ee("trial_days",(Je=(Ka=(oa=se.product.variants)==null?void 0:oa[0])==null?void 0:Ka.other_info)==null?void 0:Je.trial_days,`p:${se.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("best_price")?(r(),m("td",m2e,[n(ei,{variant:s(se.product)?(ht=se.product.variants)==null?void 0:ht[0]:null,disabled:L(se.product),"has-error":J(se.product,"variants.0.item_price"),onChange:et=>{var oa,Ka;$(se.product),Ee("price",(Ka=(oa=se.product.variants)==null?void 0:oa[0])==null?void 0:Ka.item_price,`p:${se.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("compare_price")?(r(),m("td",h2e,[n(si,{variant:s(se.product)?(at=se.product.variants)==null?void 0:at[0]:null,disabled:L(se.product),"has-error":J(se.product,"variants.0.compare_price"),onChange:et=>{var oa,Ka;$(se.product),Ee("compare_price",(Ka=(oa=se.product.variants)==null?void 0:oa[0])==null?void 0:Ka.compare_price,`p:${se.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("track_quantity")?(r(),m("td",_2e,[(It=se.product)!=null&&It.detail?(r(),E(qe,{key:0,modelValue:se.product.detail.manage_stock,"onUpdate:modelValue":et=>se.product.detail.manage_stock=et,"active-value":1,"inactive-value":0,disabled:L(se.product),onChange:et=>{$(se.product),c(rt).syncStockStatus(se.product),Ee("manage_stock",se.product.detail.manage_stock,`p:${se.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):B("",!0)])):B("",!0),yt("stock")?(r(),m("td",v2e,[(Ma=(Yt=se.product)==null?void 0:Yt.detail)!=null&&Ma.manage_stock&&((aa=(Et=se.product)==null?void 0:Et.detail)==null?void 0:aa.variation_type)==="simple"&&((ga=se.product.variants)!=null&&ga[0])?(r(),E(gt,{key:0,class:"fct-bulk-input",placeholder:ne.$t("e.g 10"),size:"small",modelValue:se.product.variants[0].available,"onUpdate:modelValue":[et=>se.product.variants[0].available=et,et=>{se.product.variants[0].total_stock=et,$(se.product),c(rt).syncStockStatus(se.product),Ee("stock",et,`p:${se.productId}`)}],disabled:L(se.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),m("span",g2e,"—"))])):B("",!0),o("td",{class:ue(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":Z.value}])},[o("div",y2e,[se.product.view_url?(r(),E(lt,{key:0,tag:"a",size:"x-small",href:se.product.view_url,target:"_blank",title:ne.$t("View Product")},{default:u(()=>[n(X,{name:"External"})]),_:2},1032,["href","title"])):B("",!0),n(lt,{tag:"button",size:"x-small",onClick:Ge(et=>ce(se.product),["prevent"]),disabled:p.value||L(se.product)||O(se.product),title:ne.$t("Duplicate")},{default:u(()=>[O(se.product)?(r(),E(ve,{key:0,class:"is-loading",size:14},{default:u(()=>[n(c(ln))]),_:1})):(r(),E(X,{key:1,name:"Copy"}))]),_:2},1032,["onClick","disabled","title"]),n(lt,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(et=>Dt(se.product),["prevent"]),disabled:p.value||L(se.product)||M(se.product),title:ne.$t("Delete")},{default:u(()=>[M(se.product)?(r(),E(ve,{key:0,class:"is-loading",size:14},{default:u(()=>[n(c(ln))]),_:1})):(r(),E(X,{key:1,name:"Delete"}))]),_:2},1032,["onClick","disabled","title"])])],2)],10,zCe),se.hasVariants?(r(),m("tr",b2e,[o("td",{colspan:Qt.value.length+1,class:"!p-0 !border-b-0"},[n(_a,{accordion:"",visible:!se.collapsed,duration:200},{default:u(()=>[o("table",C2e,[o("colgroup",null,[_e[19]||(_e[19]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),m(P,null,ae(Qt.value,(et,oa)=>(r(),m("col",{key:oa,style:fa({width:et.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),m(P,null,ae(se.product.variants,(et,oa)=>{var Ka,Je;return r(),m("tr",{key:et.id||oa,class:ue(["bulk-variation-row",{"is-selected":c(Ue)(`v:${et.id}`)}]),onClick:Pt=>Le(`v:${et.id}`,Pt)},[o("td",B2e,[n(tt,{"model-value":c(Ue)(`v:${et.id}`),tabindex:"-1",onChange:Pt=>c(le)(`v:${et.id}`,Pt,Ce.value)},null,8,["model-value","onChange"])]),o("td",x2e,[o("div",S2e,[_e[20]||(_e[20]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(gt,{size:"small",modelValue:et.variation_title,"onUpdate:modelValue":[Pt=>et.variation_title=Pt,Pt=>{$(se.product),Ee("title",Pt,`v:${et.id}`)}],placeholder:ne.$t("Variation title"),disabled:L(se.product),class:ue({"is-error":de(se.product,oa,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),G(se.product,oa)?(r(),E(Ze,{key:0,content:Y(se.product,oa),placement:"top"},{default:u(()=>[o("span",$2e,[n(ve,{size:14},{default:u(()=>[n(c(To))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),yt("image")?(r(),m("td",F2e,[n(bl,{modelValue:et.media,"onUpdate:modelValue":Pt=>et.media=Pt,onChange:Pt=>$(se.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):B("",!0),yt("sku")?(r(),m("td",E2e,[n(gt,{class:ue(["fct-bulk-input",{"is-error":de(se.product,oa,"sku")}]),size:"small",modelValue:et.sku,"onUpdate:modelValue":[Pt=>et.sku=Pt,Pt=>{$(se.product),Ee("sku",Pt,`v:${et.id}`)}],placeholder:ne.$t("SKU"),disabled:L(se.product)},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])])):B("",!0),yt("categories")?(r(),m("td",U2e,_e[21]||(_e[21]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("description")?(r(),m("td",I2e,_e[22]||(_e[22]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("short_description")?(r(),m("td",V2e,_e[23]||(_e[23]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("status")?(r(),m("td",D2e,_e[24]||(_e[24]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("product_type")?(r(),m("td",Q2e,_e[25]||(_e[25]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("pricing_type")?(r(),m("td",T2e,_e[26]||(_e[26]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("payment_type")?(r(),m("td",M2e,[n(ti,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"other_info.payment_type"),onPaymentTypeChange:Pt=>{var rs;x(se.product,Pt),Ee("payment_type",(rs=Pt.other_info)==null?void 0:rs.payment_type,`v:${et.id}`)},onChange:Pt=>$(se.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):B("",!0),yt("interval")?(r(),m("td",L2e,[n(ai,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"other_info.repeat_interval"),onChange:Pt=>{var rs;$(se.product),Ee("interval",(rs=et.other_info)==null?void 0:rs.repeat_interval,`v:${et.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("trial_days")?(r(),m("td",R2e,[n(li,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"other_info.trial_days"),onChange:Pt=>{var rs;$(se.product),Ee("trial_days",(rs=et.other_info)==null?void 0:rs.trial_days,`v:${et.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("best_price")?(r(),m("td",O2e,[n(ei,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"item_price"),onChange:Pt=>{$(se.product),Ee("price",et.item_price,`v:${et.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("compare_price")?(r(),m("td",P2e,[n(si,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"compare_price"),onChange:Pt=>{$(se.product),Ee("compare_price",et.compare_price,`v:${et.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("track_quantity")?(r(),m("td",H2e,_e[27]||(_e[27]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),yt("stock")?(r(),m("td",N2e,[(Je=(Ka=se.product)==null?void 0:Ka.detail)!=null&&Je.manage_stock?(r(),E(gt,{key:0,class:"fct-bulk-input",placeholder:ne.$t("e.g 10"),size:"small",modelValue:et.available,"onUpdate:modelValue":[Pt=>et.available=Pt,Pt=>{et.total_stock=Pt,$(se.product),c(rt).syncStockStatus(se.product),Ee("stock",Pt,`v:${et.id}`)}],disabled:L(se.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),m("span",K2e,"—"))])):B("",!0),o("td",{class:ue(["text-center",{"sticky-col sticky-col-right":Z.value}])},[o("div",G2e,[n(lt,{tag:"button",size:"x-small",onClick:Ge(Pt=>oe(se.product,et),["prevent"]),disabled:p.value||L(se.product),title:ne.$t("Duplicate")},{default:u(()=>[n(X,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(lt,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(Pt=>Xe(se.product,et),["prevent"]),disabled:p.value||L(se.product),title:ne.$t("Delete")},{default:u(()=>[n(X,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,k2e)}),128))])])]),_:2},1032,["visible"])],8,w2e)])):B("",!0)],64)}),128)),na.value>0?(r(),m("tr",z2e,[o("td",{colspan:Qt.value.length+1,style:fa({height:na.value+"px",padding:0,border:"none"})},null,12,j2e)])):B("",!0)]),_:1},8,["columns","sticky-last"])],2)):A.value?A.value?(r(),m("div",W2e,[n(ve,{class:"is-loading mr-2"},{default:u(()=>_e[28]||(_e[28]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[28]}),o("span",X2e,f(ne.$t("Loading products...")),1)])):B("",!0):(r(),m("div",q2e,[o("p",Y2e,f(ne.$t("No products found.")),1)]))]),_.value.hasMore&&i.value.length>0&&A.value?(r(),m("div",J2e,[n(ve,{class:"is-loading mr-2"},{default:u(()=>_e[29]||(_e[29]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[29]}),o("span",Z2e,f(ne.$t("Loading"))+" "+f(C.value)+" "+f(ne.$t("more...")),1)])):B("",!0)])]),_:1})]),_:1})]),n(ft,{modelValue:pt.value.visible,"onUpdate:modelValue":_e[12]||(_e[12]=se=>pt.value.visible=se),title:Ht.value,width:"700px","close-on-click-modal":!1,onClosed:_e[13]||(_e[13]=se=>pt.value.product=null)},{footer:u(()=>[n(We,{onClick:_e[11]||(_e[11]=se=>pt.value.visible=!1)},{default:u(()=>[R(f(ne.$t("Cancel")),1)]),_:1}),n(We,{type:"primary",onClick:$t},{default:u(()=>[R(f(ne.$t("Save")),1)]),_:1})]),default:u(()=>[pt.value.visible&&pt.value.field==="post_content"?(r(),E(ss,{key:0,"model-value":pt.value.value,height:300,onUpdate:Ct},null,8,["model-value"])):B("",!0),pt.value.visible&&pt.value.field==="post_excerpt"?(r(),E(gt,{key:1,modelValue:pt.value.value,"onUpdate:modelValue":_e[10]||(_e[10]=se=>pt.value.value=se),type:"textarea",rows:6,placeholder:ne.$t("Short description")},null,8,["modelValue","placeholder"])):B("",!0)]),_:1},8,["modelValue","title"])])}}},Df=je.get("payment_routes");for(const e of Df)e.props=!0;const lke=je.get("storage_driver_routes"),Qf=(lke||[]).filter(e=>e.name!=="s3");for(const e of Qf)e.props=!0;var ske={dashboard:{name:"dashboard",path:"/",component:WB,meta:{active_menu:"dashboard",title:d("Dashboard")}},orders:{path:"/orders",component:$F,meta:{active_menu:"orders",title:d("Orders")},children:[{name:"orders",path:"",component:gv,meta:{active_menu:"orders",title:d("Orders"),permission:"orders/view"}},{name:"view_order",path:":order_id(\\d+)/view",component:HD,props:!0,meta:{active_menu:"orders",title:d("View Order"),permission:["orders/view","orders/manage"]}},{name:"add_order",path:"add",component:yQ,props:!0,meta:{active_menu:"orders",title:d("Create Order"),permission:"orders/create"}}]},products:{name:"products",path:"/products",component:g7,meta:{active_menu:"products",title:d("Products"),permission:"products/view"}},product_route:{path:"/products/:product_id(\\d+)",component:uT,name:"product_route",meta:{active_menu:"products",title:d("Products"),permission:["products/view","products/edit","integrations/manage"]},props:!0,children:[{name:"product_edit",path:"",props:!0,component:oq,meta:{active_menu:"products",title:d("Product Edit"),permission:"products/edit"}},{name:"product_integrations",path:"integrations",props:!0,component:wc,meta:{active_menu:"products",title:d("Integrations"),permission:"integrations/manage"}},{name:"product_integration_feed_editor",path:"integrations/:integration_id/:integration_name",component:rc,meta:{active_menu:"products",title:d("Edit Integration"),permission:"integrations/manage"}},{name:"SingleIntegration",path:"integrations/:integration_id",props:!0,component:mY,meta:{active_menu:"products",title:d("Integrations"),permission:"integrations/manage"}},{name:"product_upgrade_paths",path:"upgrade-paths",props:!0,component:qq,meta:{active_menu:"products",title:d("Upgrade Paths"),permission:"integrations/manage"}},{name:"Integrations",path:"integrations",props:!0,component:wc,meta:{active_menu:"integrations",title:d("Product Integrations"),permission:"integrations/manage"}}]},product_bulk_insert:{name:"product_bulk_insert",path:"/products/bulk-insert",component:kCe,meta:{active_menu:"products",title:d("Product Bulk Insert"),permission:"products/create"}},product_bulk_edit:{name:"product_bulk_edit",path:"/products/bulk-edit",component:ake,meta:{active_menu:"products",title:d("Product Bulk Edit"),permission:"products/edit"}},product_attributes:{name:"product_attributes",path:"/products/attributes",component:Im,meta:{active_menu:"products",title:d("Attributes"),permission:"products/view"}},product_inventory:{name:"product_inventory",path:"/products/inventory",component:WX,meta:{active_menu:"products",title:d("Inventory"),permission:"products/view"}},customers:{path:"/customers",component:Vg,meta:{active_menu:"customers",permission:["customers/view","customers/manage"]},children:[{name:"customers",path:"/customers",component:n_,meta:{active_menu:"customers",title:d("Customers"),permission:"customers/view"}},{name:"view_customer",path:":customer_id(\\d+)/view",component:BU,props:!0,meta:{active_menu:"customers",title:d("View Customer"),permission:"customers/view"}}]},reports:{name:"reports",path:"/reports",component:Ate,meta:{active_menu:"reports",permission:"reports/view"},children:[{name:"reports_overview",path:"overview",component:vce,meta:{title:d("Overview"),permission:"reports/view"}},{name:"reports_sales",path:"sales",component:Hte,meta:{title:d("Sales"),permission:"reports/view"}},{name:"reports_orders",path:"orders",component:sne,meta:{title:d("Orders"),permission:"reports/view"}},{name:"reports_revenue",path:"revenue",component:Lae,meta:{title:d("Revenue"),permission:"reports/view"}},{name:"reports_refunds",path:"refunds",component:Pne,meta:{title:d("Refunds"),permission:"reports/view"}},{name:"reports_subscriptions",path:"subscriptions",component:Voe,meta:{title:d("Subscriptions"),permission:"reports/view"}},{name:"subscriptions-retention",path:"subscriptions/subscriptions-retention",component:jie,meta:{title:d("Retention"),permission:"reports/view"}},{name:"subscriptions-cohorts",path:"subscriptions/subscriptions-cohorts",component:()=>Jt(()=>import("./chunks/Cohort.js?ver=1.7.0"),[],import.meta.url),meta:{title:d("Cohorts"),permission:"reports/view"}},{name:"future_renewals",path:"subscriptions/future-renewals",component:Joe,meta:{title:d("Future Renewals"),permission:"reports/view"}},{name:"reports_products",path:"products",component:kue,meta:{title:d("Product"),permission:"reports/view"}},{name:"reports_customer",path:"customer",component:vre,meta:{title:d("Customer"),permission:"reports/view"}},{name:"reports_sources",path:"sources",component:tde,meta:{title:d("Sources"),permission:"reports/view"}}]},settings:{path:"/settings",component:vE,meta:{active_menu:"settings",title:d("Settings"),permission:["store/settings","store/sensitive"]},children:[{name:"store_settings",path:"store-settings",component:UQ,meta:{active_menu:"settings",title:d("Settings"),permission:"store/settings"},children:[{name:"store_setup",path:"",component:Zl,meta:{title:d("Store Setup")}},{name:"pages_setup",path:"pages_setup",component:Zl,meta:{title:d("Pages Setup")}},{name:"single_product_setup",path:"single_product_setup",component:Zl,meta:{title:d("Product Page")}},{name:"cart_and_checkout",path:"cart_and_checkout",component:Zl,meta:{title:d("Cart & Checkout")}},{name:"subscriptions_setup",path:"subscriptions_setup",component:Zl,meta:{title:d("Subscriptions")}},{name:"checkout_fields",path:"checkout_fields",component:_0e,meta:{}},{name:"appearance",path:"appearance",component:Zl,meta:{title:d("Appearance")}}]},{name:"compliance",path:"compliance",component:Zl,meta:{active_menu:"settings",title:d("Compliance"),permission:"store/settings"}},...je.get("addon_settings_routes",[]).map(e=>({component:Zl,...e})),{name:"product_reviews",path:"product-reviews",component:Wbe,meta:{active_menu:"settings",title:d("Product Reviews"),permission:"reviews/manage"}},{name:"email_notifications",path:"email_notifications",component:bJ,meta:{active_menu:"settings",title:d("Notifications"),permission:"store/sensitive"}},{name:"email_mailing_settings",path:"email_mailing_settings",component:fAe,meta:{active_menu:"settings",title:d("Mailing Settings"),permission:"store/sensitive"}},{name:"reminders",path:"email_mailing_settings/reminders",component:Zl,meta:{active_menu:"settings",title:d("Reminders"),permission:"store/sensitive"}},{name:"email_digest_settings",path:"email_digest_settings",component:wAe,meta:{active_menu:"settings",title:d("Store Digest"),permission:"store/sensitive"}},{path:"email_notifications/:name/",name:"email_notifications/edit",component:WJ,meta:{active_menu:"settings",title:d("Edit Notification"),permission:"store/sensitive"},props:!0},{path:"email_notifications/add",name:"email_notifications/add",component:vZ,meta:{active_menu:"settings",title:d("Add Notification"),permission:"store/sensitive"}},{name:"licensing",path:"licensing",component:eT,meta:{active_menu:"settings",title:d("Licensing"),permission:"store/sensitive"}},{name:"payments",path:"payments",component:HF,meta:{active_menu:"settings",title:d("Payment Settings"),permission:"is_super_admin"}},{name:"gateway",component:hS,path:"payments",children:Df,props:!0,meta:{active_menu:"settings",title:d("Payment Settings"),permission:"is_super_admin"}},{name:"invoice-packing",path:"invoice-packing",component:Bv,meta:{active_menu:"settings",title:d("Invoice & Packing"),permission:"is_super_admin"}},{name:"pdf-template",path:"pdf-template",component:Sv,meta:{active_menu:"settings",title:d("PDF Templates"),permission:"is_super_admin"},children:[{name:"pdf-template-list",path:"",component:Kv,meta:{active_menu:"settings",title:d("PDF Templates"),permission:"is_super_admin"}},{name:"pdf-template-settings",path:"settings",component:Fg,meta:{active_menu:"settings",title:d("PDF Template Settings"),permission:"is_super_admin"}},{name:"edit-pdf-template",path:":template/edit",component:dg,props:!0,meta:{active_menu:"settings",title:d("Edit PDF Template"),permission:"is_super_admin"}}]},{name:"roles",path:"roles",component:rE,meta:{active_menu:"settings",title:d("Role Settings"),permission:"is_super_admin"}},{name:"addons",path:"addons",component:Lce,meta:{active_menu:"settings",title:d("Features & addon"),permission:"is_super_admin"}},{name:"coupons",path:"coupons",component:Uc,meta:{active_menu:"coupons",title:d("Coupons Settings"),permission:"is_super_admin"}},{name:"storage",path:"storage",component:uZ,meta:{active_menu:"settings",title:d("Storage Providers"),permission:"is_super_admin"}},{name:"s3",path:"storage/s3",component:Bc,props:!0,meta:{active_menu:"settings",title:d("S3"),permission:"is_super_admin"}},{name:"payment-design",path:"payments/:method/design",component:bS,meta:{active_menu:"settings",title:d("Gateway"),permission:"is_super_admin"},props:!0},{name:"drivers",component:Bc,path:"storage",children:Qf,props:!0,meta:{active_menu:"settings",title:d("Storage Settings"),permission:"is_super_admin"}},{name:"tax_settings",path:"tax_settings",component:BAe,meta:{active_menu:"settings",title:d("Tax Settings"),permission:"store/settings"},children:[{name:"tax_configurations",path:"",component:Tpe,meta:{}},{name:"tax_rates",path:"tax_rates",component:Jpe,meta:{}},{name:"eu",path:"eu",component:x_e,meta:{}},{name:"eu_country_tax_rates",path:"eu/:country/:group",component:Ec,props:!0,meta:{}},{name:"tax-rates-country-single",path:"tax_rates_country_single/:country/:group",component:Ec,props:!0,meta:{}}]}]},integrations:{name:"integrations",path:"/integrations",component:dx,meta:{active_menu:"integrations",title:d("Integrations"),permission:"integrations/view"}},global_feed_editor:{name:"feed_editor",path:"/global_integrations/:integration_id/:integration_name",component:rc,meta:{active_menu:"integrations",title:d("Global Integrations"),permission:"integrations/view"}},integration_editor:{name:"integration_editor",path:"/integrations/:integration_name",component:GS,meta:{active_menu:"integrations",title:d("Integrations"),permission:"integrations/manage"}},coupons:{name:"coupons",path:"/coupons",component:Uc,meta:{active_menu:"coupons",title:d("Coupons"),permission:"coupons/view"}},reviews:{path:"/reviews",component:Yve,meta:{active_menu:"products",title:d("Reviews"),permission:"reviews/manage"},beforeEnter:(e,t,a)=>{const l=je.get("modules_settings.reviews");if(!l||l.active!=="yes"){a({name:"dashboard"});return}a()},children:[{name:"reviews",path:"",component:I1e,meta:{active_menu:"products",title:d("Reviews"),permission:"reviews/manage"}},{name:"view_review",path:":review_id(\\d+)/view",component:Kye,props:!0,meta:{active_menu:"products",title:d("View Review"),permission:"reviews/manage"}}]},logs:{name:"logs",path:"/logs",component:nee,meta:{active_menu:"logs",title:d("Logs"),permission:"is_super_admin"}},taxes:{name:"taxes",path:"/taxes",component:Bme,meta:{active_menu:"taxes",title:d("Taxes"),permission:"is_super_admin"}},add_or_edit_coupon_route:{name:"add_or_edit_coupon",path:"/coupons/add_or_edit_coupon/:coupon_id?",component:jve,props:!0,meta:{active_menu:"coupons",title:d("Coupons"),permission:"coupons/manage"}},onboarding:{path:"/onboarding",component:xF,name:"onboarding",meta:{active_menu:"dashboard",title:d("Onboarding"),permission:"is_super_admin"}}};const nke={class:"fct-theme-button-container"},oke={class:"theme-selected-button"},ike={__name:"ThemeToggle",setup(e){const t=T(Re.MODE_LIGHT),a=A=>{t.value!==A&&(t.value=A,Re.apply(A))},l=[{value:"light",label:d("Light"),icon:"Sun"},{value:"dark",label:d("Dark"),icon:"Moon"},{value:"system",label:d("System"),icon:"Tools"}];Os(()=>{const A=document.getElementById("theme-button-container");if(A){const p=A.querySelector(".fct-theme-button-container");p&&p.remove()}t.value=Re.getCurrentTheme(),t.value.toString().startsWith(Re.MODE_SYSTEM)&&(t.value=Re.MODE_SYSTEM)});const s=A=>{Fe(()=>{t.value=Re.getCurrentTheme()})},i=A=>{a(A)};return De(()=>{window.addEventListener(Re.THEME_CHANGE_EVENT,s,!1)}),Ya(()=>{window.removeEventListener(Re.THEME_CHANGE_EVENT,s,!1)}),(A,p)=>{const h=k("el-dropdown-item"),_=k("el-dropdown-menu"),y=k("el-dropdown");return r(),m("div",nke,[n(y,{placement:"bottom-end",trigger:"click","popper-class":"fct-dropdown",onCommand:i},{dropdown:u(()=>[n(_,null,{default:u(()=>[(r(),m(P,null,ae(l,g=>n(h,{key:g.value,command:g.value,class:ue({active:t.value===g.value})},{default:u(()=>[n(X,{name:g.icon},null,8,["name"]),R(" "+f(g.label),1)]),_:2},1032,["command","class"])),64))]),_:1})]),default:u(()=>[o("div",oke,[t.value==="light"?(r(),E(X,{key:0,name:"Sun"})):t.value==="dark"?(r(),E(X,{key:1,name:"Moon"})):t.value==="system"?(r(),E(X,{key:2,name:"Tools"})):B("",!0)])]),_:1})])}}};function os(e){return Array.isArray?Array.isArray(e):Lf(e)==="[object Array]"}function rke(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function dke(e){return e==null?"":rke(e)}function Nl(e){return typeof e=="string"}function Tf(e){return typeof e=="number"}function uke(e){return e===!0||e===!1||cke(e)&&Lf(e)=="[object Boolean]"}function Mf(e){return typeof e=="object"}function cke(e){return Mf(e)&&e!==null}function _l(e){return e!=null}function mr(e){return!e.trim().length}function Lf(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Ake="Incorrect 'index' type",pke=e=>`Invalid value for key ${e}`,fke=e=>`Pattern length exceeds max of ${e}.`,mke=e=>`Missing ${e} property in key`,hke=e=>`Property 'weight' in key '${e}' must be a positive integer`,Lc=Object.prototype.hasOwnProperty;class _ke{constructor(t){this._keys=[],this._keyMap={};let a=0;t.forEach(l=>{let s=Rf(l);this._keys.push(s),this._keyMap[s.id]=s,a+=s.weight}),this._keys.forEach(l=>{l.weight/=a})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Rf(e){let t=null,a=null,l=null,s=1,i=null;if(Nl(e)||os(e))l=e,t=Rc(e),a=Wr(e);else{if(!Lc.call(e,"name"))throw new Error(mke("name"));const A=e.name;if(l=A,Lc.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(hke(A));t=Rc(A),a=Wr(A),i=e.getFn}return{path:t,id:a,weight:s,src:l,getFn:i}}function Rc(e){return os(e)?e:e.split(".")}function Wr(e){return os(e)?e.join("."):e}function vke(e,t){let a=[],l=!1;const s=(i,A,p)=>{if(_l(i))if(!A[p])a.push(i);else{let h=A[p];const _=i[h];if(!_l(_))return;if(p===A.length-1&&(Nl(_)||Tf(_)||uke(_)))a.push(dke(_));else if(os(_)){l=!0;for(let y=0,g=_.length;ye.score===t.score?e.idx{this._keysMap[a.id]=l})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Nl(this.docs[0])?this.docs.forEach((t,a)=>{this._addString(t,a)}):this.docs.forEach((t,a)=>{this._addObject(t,a)}),this.norm.clear())}add(t){const a=this.size();Nl(t)?this._addString(t,a):this._addObject(t,a)}removeAt(t){this.records.splice(t,1);for(let a=t,l=this.size();a{let A=s.getFn?s.getFn(t):this.getFn(t,s.path);if(_l(A)){if(os(A)){let p=[];const h=[{nestedArrIndex:-1,value:A}];for(;h.length;){const{nestedArrIndex:_,value:y}=h.pop();if(_l(y))if(Nl(y)&&!mr(y)){let g={v:y,i:_,n:this.norm.get(y)};p.push(g)}else os(y)&&y.forEach((g,v)=>{h.push({nestedArrIndex:v,value:g})})}l.$[i]=p}else if(Nl(A)&&!mr(A)){let p={v:A,n:this.norm.get(A)};l.$[i]=p}}}),this.records.push(l)}toJSON(){return{keys:this.keys,records:this.records}}}function Of(e,t,{getFn:a=Ut.getFn,fieldNormWeight:l=Ut.fieldNormWeight}={}){const s=new Od({getFn:a,fieldNormWeight:l});return s.setKeys(e.map(Rf)),s.setSources(t),s.create(),s}function Bke(e,{getFn:t=Ut.getFn,fieldNormWeight:a=Ut.fieldNormWeight}={}){const{keys:l,records:s}=e,i=new Od({getFn:t,fieldNormWeight:a});return i.setKeys(l),i.setIndexRecords(s),i}function Bo(e,{errors:t=0,currentLocation:a=0,expectedLocation:l=0,distance:s=Ut.distance,ignoreLocation:i=Ut.ignoreLocation}={}){const A=t/e.length;if(i)return A;const p=Math.abs(l-a);return s?A+p/s:p?1:A}function xke(e=[],t=Ut.minMatchCharLength){let a=[],l=-1,s=-1,i=0;for(let A=e.length;i=t&&a.push([l,s]),l=-1)}return e[i-1]&&i-l>=t&&a.push([l,i-1]),a}const Fs=32;function Ske(e,t,a,{location:l=Ut.location,distance:s=Ut.distance,threshold:i=Ut.threshold,findAllMatches:A=Ut.findAllMatches,minMatchCharLength:p=Ut.minMatchCharLength,includeMatches:h=Ut.includeMatches,ignoreLocation:_=Ut.ignoreLocation}={}){if(t.length>Fs)throw new Error(fke(Fs));const y=t.length,g=e.length,v=Math.max(0,Math.min(l,g));let C=i,w=v;const b=p>1||h,S=b?Array(g):[];let F;for(;(F=e.indexOf(t,w))>-1;){let D=Bo(t,{currentLocation:F,expectedLocation:v,distance:s,ignoreLocation:_});if(C=Math.min(D,C),w=F+y,b){let U=0;for(;U=O;W-=1){let G=W-1,Y=a[e.charAt(G)];if(b&&(S[G]=+!!Y),H[W]=(H[W+1]<<1|1)&Y,D&&(H[W]|=(Q[W+1]|Q[W])<<1|1|Q[W+1]),H[W]&I&&($=Bo(t,{errors:D,currentLocation:G,expectedLocation:v,distance:s,ignoreLocation:_}),$<=C)){if(C=$,w=G,w<=v)break;O=Math.max(1,2*v-w)}}if(Bo(t,{errors:D+1,currentLocation:v,expectedLocation:v,distance:s,ignoreLocation:_})>C)break;Q=H}const V={isMatch:w>=0,score:Math.max(.001,$)};if(b){const D=xke(S,p);D.length?h&&(V.indices=D):V.isMatch=!1}return V}function $ke(e){let t={};for(let a=0,l=e.length;ae.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e;class Pf{constructor(t,{location:a=Ut.location,threshold:l=Ut.threshold,distance:s=Ut.distance,includeMatches:i=Ut.includeMatches,findAllMatches:A=Ut.findAllMatches,minMatchCharLength:p=Ut.minMatchCharLength,isCaseSensitive:h=Ut.isCaseSensitive,ignoreDiacritics:_=Ut.ignoreDiacritics,ignoreLocation:y=Ut.ignoreLocation}={}){if(this.options={location:a,threshold:l,distance:s,includeMatches:i,findAllMatches:A,minMatchCharLength:p,isCaseSensitive:h,ignoreDiacritics:_,ignoreLocation:y},t=h?t:t.toLowerCase(),t=_?oi(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const g=(C,w)=>{this.chunks.push({pattern:C,alphabet:$ke(C),startIndex:w})},v=this.pattern.length;if(v>Fs){let C=0;const w=v%Fs,b=v-w;for(;C{const{isMatch:Q,score:$,indices:x}=Ske(t,b,S,{location:i+F,distance:A,threshold:p,findAllMatches:h,minMatchCharLength:_,includeMatches:s,ignoreLocation:y});Q&&(C=!0),v+=$,Q&&x&&(g=[...g,...x])});let w={isMatch:C,score:C?v/this.chunks.length:1};return C&&s&&(w.indices=g),w}}class Bs{constructor(t){this.pattern=t}static isMultiMatch(t){return Oc(t,this.multiRegex)}static isSingleMatch(t){return Oc(t,this.singleRegex)}search(){}}function Oc(e,t){const a=e.match(t);return a?a[1]:null}class Fke extends Bs{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const a=t===this.pattern;return{isMatch:a,score:a?0:1,indices:[0,this.pattern.length-1]}}}class Eke extends Bs{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const l=t.indexOf(this.pattern)===-1;return{isMatch:l,score:l?0:1,indices:[0,t.length-1]}}}class Uke extends Bs{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const a=t.startsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,this.pattern.length-1]}}}class Ike extends Bs{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const a=!t.startsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,t.length-1]}}}class Vke extends Bs{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const a=t.endsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Dke extends Bs{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const a=!t.endsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,t.length-1]}}}class Hf extends Bs{constructor(t,{location:a=Ut.location,threshold:l=Ut.threshold,distance:s=Ut.distance,includeMatches:i=Ut.includeMatches,findAllMatches:A=Ut.findAllMatches,minMatchCharLength:p=Ut.minMatchCharLength,isCaseSensitive:h=Ut.isCaseSensitive,ignoreDiacritics:_=Ut.ignoreDiacritics,ignoreLocation:y=Ut.ignoreLocation}={}){super(t),this._bitapSearch=new Pf(t,{location:a,threshold:l,distance:s,includeMatches:i,findAllMatches:A,minMatchCharLength:p,isCaseSensitive:h,ignoreDiacritics:_,ignoreLocation:y})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Nf extends Bs{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let a=0,l;const s=[],i=this.pattern.length;for(;(l=t.indexOf(this.pattern,a))>-1;)a=l+i,s.push([l,a-1]);const A=!!s.length;return{isMatch:A,score:A?0:1,indices:s}}}const Xr=[Fke,Nf,Uke,Ike,Dke,Vke,Eke,Hf],Pc=Xr.length,Qke=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Tke="|";function Mke(e,t={}){return e.split(Tke).map(a=>{let l=a.trim().split(Qke).filter(i=>i&&!!i.trim()),s=[];for(let i=0,A=l.length;i!!(e[ii.AND]||e[ii.OR]),Pke=e=>!!e[ed.PATH],Hke=e=>!os(e)&&Mf(e)&&!td(e),Hc=e=>({[ii.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Kf(e,t,{auto:a=!0}={}){const l=s=>{let i=Object.keys(s);const A=Pke(s);if(!A&&i.length>1&&!td(s))return l(Hc(s));if(Hke(s)){const h=A?s[ed.PATH]:i[0],_=A?s[ed.PATTERN]:s[h];if(!Nl(_))throw new Error(pke(h));const y={keyId:Wr(h),pattern:_};return a&&(y.searcher=Zr(_,t)),y}let p={children:[],operator:i[0]};return i.forEach(h=>{const _=s[h];os(_)&&_.forEach(y=>{p.children.push(l(y))})}),p};return td(e)||(e=Hc(e)),l(e)}function Nke(e,{ignoreFieldNorm:t=Ut.ignoreFieldNorm}){e.forEach(a=>{let l=1;a.matches.forEach(({key:s,norm:i,score:A})=>{const p=s?s.weight:null;l*=Math.pow(A===0&&p?Number.EPSILON:A,(p||1)*(t?1:i))}),a.score=l})}function Kke(e,t){const a=e.matches;t.matches=[],_l(a)&&a.forEach(l=>{if(!_l(l.indices)||!l.indices.length)return;const{indices:s,value:i}=l;let A={indices:s,value:i};l.key&&(A.key=l.key.src),l.idx>-1&&(A.refIndex=l.idx),t.matches.push(A)})}function Gke(e,t){t.score=e.score}function zke(e,t,{includeMatches:a=Ut.includeMatches,includeScore:l=Ut.includeScore}={}){const s=[];return a&&s.push(Kke),l&&s.push(Gke),e.map(i=>{const{idx:A}=i,p={item:t[A],refIndex:A};return s.length&&s.forEach(h=>{h(i,p)}),p})}class vn{constructor(t,a={},l){this.options={...Ut,...a},this.options.useExtendedSearch,this._keyStore=new _ke(this.options.keys),this.setCollection(t,l)}setCollection(t,a){if(this._docs=t,a&&!(a instanceof Od))throw new Error(Ake);this._myIndex=a||Of(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){_l(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const a=[];for(let l=0,s=this._docs.length;l-1&&(h=h.slice(0,a)),zke(h,this._docs,{includeMatches:l,includeScore:s})}_searchStringList(t){const a=Zr(t,this.options),{records:l}=this._myIndex,s=[];return l.forEach(({v:i,i:A,n:p})=>{if(!_l(i))return;const{isMatch:h,score:_,indices:y}=a.searchIn(i);h&&s.push({item:i,idx:A,matches:[{score:_,value:i,norm:p,indices:y}]})}),s}_searchLogical(t){const a=Kf(t,this.options),l=(p,h,_)=>{if(!p.children){const{keyId:g,searcher:v}=p,C=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(h,g),searcher:v});return C&&C.length?[{idx:_,item:h,matches:C}]:[]}const y=[];for(let g=0,v=p.children.length;g{if(_l(p)){let _=l(a,p,h);_.length&&(i[h]||(i[h]={idx:h,item:p,matches:[]},A.push(i[h])),_.forEach(({matches:y})=>{i[h].matches.push(...y)}))}}),A}_searchObjectList(t){const a=Zr(t,this.options),{keys:l,records:s}=this._myIndex,i=[];return s.forEach(({$:A,i:p})=>{if(!_l(A))return;let h=[];l.forEach((_,y)=>{h.push(...this._findMatches({key:_,value:A[y],searcher:a}))}),h.length&&i.push({idx:p,item:A,matches:h})}),i}_findMatches({key:t,value:a,searcher:l}){if(!_l(a))return[];let s=[];if(os(a))a.forEach(({v:i,i:A,n:p})=>{if(!_l(i))return;const{isMatch:h,score:_,indices:y}=l.searchIn(i);h&&s.push({score:_,key:t,value:i,idx:A,norm:p,indices:y})});else{const{v:i,n:A}=a,{isMatch:p,score:h,indices:_}=l.searchIn(i);p&&s.push({score:h,key:t,value:i,norm:A,indices:_})}return s}}vn.version="7.1.0";vn.createIndex=Of;vn.parseIndex=Bke;vn.config=Ut;vn.parseQuery=Kf;Oke(Rke);const jke=(je.get("payment_routes")||[]).filter(e=>!e.upcoming).map(e=>{const t=e.meta.admin_title||e.meta.title||e.meta.label||e.name;return{title:t,subtitle:d("Manage %1$s",t),path:"/settings/payments/"+e.path}}),qke=[{title:d("Dashboard"),path:"/"},{title:d("Orders"),path:"/orders"},{title:d("Create Order"),path:"/orders/add"},{title:d("Customers"),path:"/customers"},{title:d("Products"),path:"/products"},{title:d("Product Inventory"),path:"/products/inventory"},{title:d("Bulk Import Products"),path:"/products/bulk-insert"},{title:d("Integrations"),path:"/integrations"},{title:d("Coupons"),path:"/coupons"},{title:d("Logs"),path:"/logs"},{title:d("Taxes"),path:"/taxes"},{title:d("Reports"),path:"/reports/overview"},{title:d("Sales Report"),path:"/reports/sales"},{title:d("Orders Report"),path:"/reports/orders"},{title:d("Revenue Report"),path:"/reports/revenue"},{title:d("Refunds Report"),path:"/reports/refunds"},{title:d("Subscriptions Report"),path:"/reports/subscriptions"},{title:d("Future Renewals Report"),path:"/reports/subscriptions/future-renewals"},{title:d("Product Report"),path:"/reports/products"},{title:d("Customer Report"),path:"/reports/customer"},{title:d("Traffic Sources Report"),path:"/reports/sources"},...jke],Yke=qke.map(({title:e,subtitle:t,path:a})=>({title:e,...t?{subtitle:t}:{},data:{type:"action",action:({router:l})=>{l.push({path:a})},show_description:!1}})),Wke=[{title:"Theme",title_resolver:()=>{let t=(Re.isDark()?"dark":"light")==="light"?d("Dark"):d("Light");return d("Change theme to %1$s",t)},data:{type:"action",action:()=>{let t=(Re.isDark()?"dark":"light")==="light"?"dark":"light";Re.apply(t,{fromShortcut:!0})}}}],Nc={"/settings/store-settings":d("Store Setup"),"/settings/store-settings/pages_setup":d("Pages Setup"),"/settings/store-settings/single_product_setup":d("Single Product & Order Setup"),"/settings/store-settings/cart_and_checkout":d("Cart and Checkout"),"/settings/compliance":d("Compliance"),"/settings/store-settings/subscriptions_setup":d("Subscriptions Setup"),"/settings/store-settings/checkout_fields":d("Checkout Fields"),"/settings/store-settings/appearance":d("Appearance"),"/settings/email_notifications":d("Email Notifications"),"/settings/email_mailing_settings":d("Mailing Settings"),"/settings/email_mailing_settings/reminders":d("Reminders"),"/settings/licensing":d("Licensing"),"/settings/payments":d("Payment Settings"),"/settings/invoice-packing":d("Invoice & Packing Slips"),"/settings/pdf-template":d("PDF Templates"),"/settings/roles":d("Role Settings"),"/settings/addons":d("Features & Addons"),"/settings/tax_settings":d("Tax Settings"),"/settings/tax_settings/tax_rates":d("Tax Rates"),"/settings/tax_settings/eu":d("EU VAT Settings"),"/settings/storage":d("Storage Providers"),"/settings/coupons":d("Coupon Settings")};let Gf=[];Object.keys(Nc).forEach(e=>{const t=Nc[e];Gf.push({title:t,data:{type:"action",action:({router:a})=>{a.push({path:e})},description:d("Go to %1$s",t),show_description:!1}})});const Xke=[],Jke={Menu:Yke,Actions:Wke,Settings:Gf,Shortcuts:Xke},ad=[];Object.entries(Jke).forEach(([e,t])=>{t.forEach((a,l)=>{ad.push({...a,id:`${e.toString().toLowerCase()}-${l}`,group:[e]})})});const Zke=()=>({shouldSort:!0,threshold:.6,keys:[{name:"title",getFn:e=>e.title},{name:"data.description",getFn:e=>e.data.description},{name:"group",weight:2,getFn:e=>e.group}]}),eBe={class:"navigable-list-container fct-global-search-result-container"},tBe={key:0,class:"no-results fct-global-search-result-not-found"},aBe={key:1},lBe=["tabindex","onClick","onKeydown"],sBe={__name:"NavigableList",props:{items:{type:Array,required:!0,default:()=>[]},noResultsText:{type:String,default:d("No results found")},onAction:{type:Function,required:!0}},setup(e,{expose:t}){const a=e,l=T(-1),s=sd("listContainer"),i=T({}),A=(w,b)=>{b&&(i.value[w]=b)},p=w=>{const b=a.items.length;if(b===0)return;const S=b-1;w==="up"?l.value=l.value<=0?S:l.value-1:w==="down"&&(l.value=l.value>=S?0:l.value+1),h()},h=()=>{const w=s.value,b=i.value[l.value];b&&w&&(b.scrollIntoView({behavior:"smooth",block:"nearest"}),Fe(()=>{b.focus()}))},_=w=>{l.value=w,y(w)},y=w=>{w>=0&&w{l.value=-1};return t({focusList:w=>{w=w??a.items.length-1,w>=0&&(l.value=w,Fe(()=>{i.value[w]&&i.value[w].focus()}))},resetSelection:g,performFirstAction:()=>{a.items.length>0?(l.value=0,setTimeout(()=>{y(0)},200)):l.value=-1}}),ke(()=>a.items,w=>{g(),w.length>0&&Fe(()=>{})},{immediate:!0}),ke(l,()=>{}),(w,b)=>(r(),m("div",eBe,[e.items.length===0?(r(),m("div",tBe,[n(X,{name:"Empty/GlobalSearch"}),R(" "+f(e.noResultsText),1)])):(r(),m("div",aBe,[o("ul",{ref_key:"listContainer",ref:s,class:"navigable-list fct-global-search-result-list"},[(r(!0),m(P,null,ae(e.items,(S,F)=>(r(),m("li",{key:F,ref_for:!0,ref:Q=>A(F,Q),class:ue({selected:F===l.value}),tabindex:F,onClick:Q=>_(F),onKeydown:[b[0]||(b[0]=da(Ge(Q=>p("up"),["prevent"]),["arrow-up"])),b[1]||(b[1]=da(Ge(Q=>p("down"),["prevent"]),["arrow-down"])),da(Q=>y(F),["enter"])]},[wa(w.$slots,"default",{item:S,index:F,isSelected:F===l.value},void 0,!0)],42,lBe))),128))],512)]))]))}},ld=nt(sBe,[["__scopeId","data-v-2379fe26"]]),nBe={class:"fct-search-result-label"},oBe={class:"fct-search-result-title"},iBe={key:0,class:"fct-search-result-subtitle"},rBe={key:1,class:"fct-search-result-subtitle"},dBe={class:"action-icon"},uBe={class:"recent-search-title"},cBe={class:"fct-search-result-label"},ABe={class:"fct-search-result-title"},pBe={key:0,class:"fct-search-result-subtitle"},fBe={key:1,class:"fct-search-result-subtitle"},mBe={class:"action-icon"},hr="recent_actions",hBe={__name:"ResultList",props:{query:{type:String,required:!0},searchResults:{type:Array,required:!0,default:()=>[]},onActionPerformed:{type:Function,required:!0},focusInput:{type:Function,required:!0},searchData:{type:Array,required:!0,default:()=>[]}},setup(e,{expose:t}){const a=Wa();Zt().ctx;const l=e,s=T(0),i=T({}),A=T(),p=(S,F)=>{const $=S.item.data,x=_($.type);if(x==="link"){let I=_($.url);_($.new_tab)?window.open(I,"_blank"):window.location.href=I}else x==="action"&&_($.action);h(S),l.onActionPerformed()},h=S=>{const F=S.item.id;let Q=Tt.get(hr)||[];Q=Q.filter($=>$!==F),Q.unshift(F),Q=Q.slice(0,5),Tt.set(hr,Q)},_=S=>typeof S=="function"?y(S):S,y=async S=>await S({query:l.query,router:a}),g=()=>{var S;(S=A.value)==null||S.resetSelection()},v=()=>{var S;(S=A.value)==null||S.focusList(0)},C=()=>{var S;(S=A.value)==null||S.performFirstAction()};ke(()=>l.searchResults,async()=>{i.value={},i.value=l.searchResults??{},s.value=Object.keys(i.value).length-1;let S=i.value;for(const F of Object.keys(S)){const Q=S[F];Q.item.title_resolver&&(S[F].item.title=await _(Q.item.title_resolver))}i.value={...S}});const w=T([]),b=async()=>{const S=Tt.get(hr)||[];let F=dt.whereIn(l.searchData,"id",S),Q=[];for(const $ of F)typeof $.title_resolver=="function"&&($.title=await _($.title_resolver)),Q.push({item:$});w.value=Q};return De(()=>{b()}),t({focusList:v,resetSelection:g,performFirstAction:C,fetchRecentActions:b}),(S,F)=>(r(),m(P,null,[e.query||w.value.length<1?(r(),E(ld,{key:0,items:e.searchResults,"on-action":p,"no-results-text":c(d)("No matches found"),ref_key:"navigableList",ref:A},{default:u(({item:Q,index:$,isSelected:x})=>{var I,V,D;return[o("span",nBe,[o("span",oBe,f(Q.item.title),1),(I=Q.item)!=null&&I.subtitle?(r(),m("span",iBe,f(Q.item.subtitle),1)):((D=(V=Q.item)==null?void 0:V.data)==null?void 0:D.show_description)===!0?(r(),m("span",rBe,f(Q.item.data.description),1)):B("",!0)]),o("div",dBe,[n(X,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])):B("",!0),!e.query&&w.value.length>0?(r(),m(P,{key:1},[o("span",uBe,f(c(d)("Recent Actions")),1),n(ld,{items:w.value,"on-action":p,"no-results-text":c(d)("No matches found"),ref_key:"navigableList",ref:A},{default:u(({item:Q,index:$,isSelected:x})=>{var I,V,D;return[o("span",cBe,[o("span",ABe,f(Q.item.title),1),(I=Q.item)!=null&&I.subtitle?(r(),m("span",pBe,f(Q.item.subtitle),1)):((D=(V=Q.item)==null?void 0:V.data)==null?void 0:D.show_description)===!0?(r(),m("span",fBe,f(Q.item.data.description),1)):B("",!0)]),o("div",mBe,[n(X,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])],64)):B("",!0)],64))}},_Be=nt(hBe,[["__scopeId","data-v-ccb0ebef"]]),vBe={class:"fct-global-search-product-wrap"},gBe={class:"fct-global-search-product-left-info"},yBe={key:0,class:"type"},bBe={key:0,class:"price-and-status"},wBe={__name:"Product",props:{product:{type:Object,required:!0}},setup(e){const t=l=>l.min_price===l.max_price?zt(l.min_price,!0):`${zt(l.min_price,!0)} - ${zt(l.max_price,!0)}`,a=l=>l==="publish"?d("published"):l==="future"?d("scheduled"):l;return(l,s)=>(r(),m("div",vBe,[o("div",gBe,[n(ud,{product:e.product},null,8,["product"]),e.product.detail?(r(),m("span",yBe,[R(f(c(Aa).headline(e.product.detail.variation_type))+" ",1),s[0]||(s[0]=o("br",null,null,-1)),R(" "+f(c(Aa).headline(e.product.detail.fulfillment_type)),1)])):B("",!0)]),e.product.detail?(r(),m("span",bBe,[R(f(t(e.product.detail))+" ",1),(r(),E(la,{key:e.product.ID,status:e.product.post_status},{default:u(()=>[R(f(a(e.product.post_status)),1)]),_:1},8,["status"]))])):B("",!0)]))}},CBe={class:"fct-global-search-order-wrap"},kBe={class:"fct-global-search-order-header"},BBe={class:"fct-global-search-order-id"},xBe={class:"items"},SBe={class:"fct-global-search-order-header-meta"},$Be={class:"date"},FBe=["innerHTML"],EBe={class:"customer-name"},UBe={class:"fct-global-search-order-status-wrapper"},IBe=["src","alt"],VBe={__name:"Order",props:{order:{type:Object,required:!0}},setup(e){const t=a=>dt.get(window,"fluentCartAdminApp.payment_logos."+a);return(a,l)=>{var i;const s=k("el-tag");return r(),m("div",CBe,[o("div",kBe,[o("div",BBe,[R(" #"+f(e.order.id)+" ",1),o("span",xBe,f(c(d)("%s Items",e.order.order_items.length)),1)]),o("div",SBe,[o("span",$Be,[n(Sa,{"date-time":e.order.created_at},null,8,["date-time"])]),l[0]||(l[0]=o("span",{class:"circle"},null,-1)),o("span",{class:"total-price",innerHTML:c(zt)(e.order.total_amount,!0,!1,e.order.currency)},null,8,FBe),l[1]||(l[1]=o("span",{class:"circle"},null,-1)),o("span",EBe,f(((i=e.order.customer)==null?void 0:i.full_name)||c(d)("No Name")),1)])]),o("div",UBe,[n(la,{status:e.order.payment_status,"hide-icon":!0},null,8,["status"]),t(e.order.payment_method)?(r(),m("img",{key:0,src:t(e.order.payment_method),alt:c(Aa).headline(e.order.payment_method)},null,8,IBe)):(r(),E(s,{key:1,type:"info",round:"",size:"small",class:"capitalize"},{default:u(()=>[R(f(c(Aa).headline(e.order.payment_method)),1)]),_:1}))])])}}},DBe={class:"fct-global-search-customer-wrap"},QBe={class:"fct-customer-card"},TBe={class:"fct-customer-avatar"},MBe={class:"fct-customer-details"},LBe={class:"fct-customer-name"},RBe={class:"fct-customer-id"},OBe={class:"fct-customer-email"},PBe={class:"purchase-count"},HBe={class:"date"},NBe={__name:"Customer",props:{customer:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),m("div",DBe,[o("div",QBe,[o("div",TBe,[n(Is,{url:e.customer.photo,name:e.customer.full_name},null,8,["url","name"])]),o("div",MBe,[o("div",LBe,[R(f(e.customer.full_name||t.$t("No Name"))+" ",1),o("span",RBe,"#"+f(e.customer.id),1)]),o("div",OBe,[R(f(e.customer.email)+" ",1),a[0]||(a[0]=o("span",{class:"circle"},null,-1)),a[1]||(a[1]=R()),o("span",PBe,"Purchase: "+f(e.customer.purchase_count),1)])])]),o("span",HBe,[n(Sa,{"date-time":e.customer.last_purchase_date},null,8,["date-time"])])]))}},KBe={class:"fct-global-search-coupon-wrap"},GBe={class:"amount"},zBe={__name:"Coupon",props:{coupon:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),m("div",KBe,[o("span",null,f(e.coupon.title),1),o("span",null,f(e.coupon.code),1),o("span",GBe,f(c(zt)(e.coupon.amount,!0)),1)]))}},jBe={class:"fct-global-remote-result-container"},qBe={class:"fct-global-remote-result-label"},YBe={class:"text"},WBe={class:"navigable-content"},XBe={class:"action-icon"},JBe={__name:"RemoteResult",emits:["close-modal","onRemoteSearchStateChange"],setup(e,{expose:t,emit:a}){const l=a,s=Wa(),i=T({}),A=T(""),p=T(),h=T({}),_=T([]),y=D=>{g.value=!1,_.value=S.data.tableData,l("onRemoteSearchStateChange",!1)},g=T(!1),v={orders:bA({fetch:!1}),products:nf({fetch:!1}),customers:yA({fetch:!1}),coupons:$f({fetch:!1})},C=()=>{},w=()=>{var D;(D=p.value)==null||D.focusList(0)},b=()=>{var D;(D=p.value)==null||D.performFirstAction()};Os(()=>{for(const D of Object.keys(v))v[D].onDataLoaded(y)});let S=null;const F=()=>{S=v[i.value.key],S.data.search=A.value,g.value=!0,S.fetch(),l("onRemoteSearchStateChange",!0)},Q=fd.debounce(F,800),$=(D,U)=>{if(_.value=[],S&&(S.data.search=""),i.value=U,h.value={title:U.title,key:U.key},!D){A.value="";return}A.value=D,Q()},x=()=>{s.push({name:h.value.key,query:{search:A.value}}),l("close-modal")},I={orders:{name:"view_order",key:"order_id"},products:{name:"product_edit",key:"product_id"},customers:{name:"view_customer",key:"customer_id"},coupons:{name:"edit_coupon",key:"coupon_id"}},V=D=>{i.value.key in I&&(s.push({name:I[i.value.key].name,params:{[I[i.value.key].key]:D.id||D.ID,action:"edit"}}),l("close-modal"))};return t({fetchData:$,focusList:w,resetSelection:C,performFirstAction:b}),(D,U)=>(r(),m("div",jBe,[o("div",qBe,[o("span",YBe,f(i.value.title),1),h.value.key?(r(),m("span",{key:0,class:"view-all",onClick:x},f(A.value?c(d)('Search "%1$s" in %2$s',A.value,h.value.title):c(d)("See All %s",h.value.title)),1)):B("",!0)]),n(ld,{items:_.value,"on-action":L=>{V(L)},"no-results-text":A.value?c(d)("No matches found for %s",i.value.title):c(d)("Type something to find %s",i.value.title),ref_key:"navigableList",ref:p},{default:u(({item:L,index:O,isSelected:M})=>[o("div",WBe,[i.value.key==="products"?(r(),E(wBe,{key:0,product:L},null,8,["product"])):B("",!0),i.value.key==="orders"?(r(),E(VBe,{key:1,order:L},null,8,["order"])):B("",!0),i.value.key==="customers"?(r(),E(NBe,{key:2,customer:L},null,8,["customer"])):B("",!0),i.value.key==="coupons"?(r(),E(zBe,{key:3,coupon:L},null,8,["coupon"])):B("",!0)]),o("div",XBe,[n(X,{name:"Enter"})])]),_:1},8,["items","on-action","no-results-text"])]))}},ZBe={class:"fct-global-search-input-wrap"},e8e=["aria-label"],t8e={class:"fct-setting-search-icon"},a8e={class:"fct-global-search-input-container"},l8e={key:0,class:"searched-item"},s8e={class:"fct-global-searching-for"},n8e={class:"fct-global-searching-for-label"},o8e={class:"fct-global-searching-suggestion-list"},i8e=["onClick"],r8e={class:"dialog-footer is-border"},d8e={class:"fct-search-commands"},u8e={class:"command-key"},c8e={class:"command-key"},A8e={class:"label"},p8e={class:"command-key"},f8e={class:"label"},m8e={class:"label"},h8e={__name:"GlobalSearch",setup(e){Zt().ctx,Wa();const t=T(!1),a=T(""),l=T({}),s=T(),i=T(""),A=T([d("orders"),d("products"),d("customers"),d("coupons"),d("settings"),d("menus"),d("shortcuts...")]),p=T(0),h=T(!0),_=T(0),y=T(null),g=T(null),v=T(70),C=T(40),w=T(1700),b=()=>{Fe(()=>{F()})},S=()=>{var oe,Z;V.value?(oe=W.value)==null||oe.resetSelection():(Z=$.value)==null||Z.resetSelection(),V.value=!1,H.value=!1,Q()},F=()=>{var oe;(oe=s.value)==null||oe.focus()},Q=()=>{V.value=!1,l.value=[],t.value=!1,a.value="",D.value=null},$=T(),x=oe=>{let Z=oe.includes(","),N={},le=[];(Z?oe.split(","):[oe]).forEach(re=>{re.includes(":")?I(re,N,le):le.push(re)});let pe=[];return Object.keys(N).forEach(re=>{const Ue=N[re];Ue.length>0?Ue.forEach(we=>{we.length>0?pe.push({group:"'"+re,title:we}):pe.push({group:"'"+re})}):pe.push({group:"'"+re})}),le.forEach(re=>{re.length>0&&pe.push({title:re})}),pe},I=(oe,Z,N)=>{if(oe.length===1)return;let le=oe.split(":"),ee=le[0],pe=le[1];ee.length>0?(Z.hasOwnProperty(ee)||(Z[ee]=[]),pe.length>0&&Z[ee].push(pe)):N.push(pe)},V=T(!1),D=T(null),U=T({o:{key:"orders",title:d("Orders")},p:{key:"products",title:d("Products")},c:{key:"customers",title:d("Customers")},d:{key:"coupons",title:d("Coupons")}}),L=oe=>{D.value=oe,V.value=!0,l.value={},Fe(()=>{var Z,N;(Z=W.value)==null||Z.fetchData(a.value,oe),(N=s.value)==null||N.focus()})},O=()=>{var oe;l.value=[],D.value=null,a.value="",V.value=!1,(oe=s.value)==null||oe.focus(),H.value=!1},M=()=>{var oe;(oe=W.value)==null||oe.fetchData(a.value,D.value)},H=T(!1),j=oe=>{H.value=oe,Fe(()=>{var Z;(Z=s.value)==null||Z.focus()})},W=T(),G=is(),Y=()=>{if(t.value){F();return}const oe=["o","p","c","d"];G.bind(oe,Z=>{Z.preventDefault();const N=U.value[Z.key];N&&L(N)}),t.value=!0,Fe(()=>{var Z;(Z=$.value)==null||Z.fetchRecentActions()}),setTimeout(()=>{G.unbind(oe)},800)};G.bind(["/"],oe=>{!t.value&&J()||(oe.preventDefault(),Y())});const J=()=>{const oe=document.activeElement;if(!oe)return!1;const Z=oe.tagName;return Z==="INPUT"||Z==="TEXTAREA"||Z==="SELECT"||oe.isContentEditable},de=()=>{if(y.value)return;const oe=()=>{if(s.value&&s.value.length>0)return;const N=A.value[p.value];if(h.value)_.value{g.value=null},w.value));else{if(g.value)return;_.value>0?(_.value--,i.value=N.slice(0,_.value)):(h.value=!0,p.value=(p.value+1)%A.value.length)}},Z=()=>{oe();const N=h.value?v.value:g.value?120:C.value;y.value=setTimeout(Z,N)};Z()},z=T(!1);let ce;return De(()=>{de(),ce=new vn(ad,Zke());const oe=document.getElementById("fct_admin_menu_search");if(oe){const Z=oe.querySelector(".fct-global-search-input-wrap");Z&&Z.remove()}z.value=!!oe,window.fluentCart=window.fluentCart||{},window.fluentCart.openSearch=Y}),xt(()=>{window.fluentCart&&delete window.fluentCart.openSearch}),(oe,Z)=>{const N=k("el-input"),le=k("el-dialog");return r(),m(P,null,[z.value?(r(),E(di,{key:0,to:"#fct_admin_menu_search"},[o("div",ZBe,[o("button",{onClick:Y,type:"button",class:"fct-setting-search-button","aria-label":c(d)("Search")},[o("span",t8e,[n(X,{name:"Search"})]),Z[6]||(Z[6]=o("span",{class:"fct-global-search-button-keys"},[o("kbd",{class:"fct-global-search-button-key"},"/")],-1))],8,e8e)])])):B("",!0),n(le,{modelValue:t.value,"onUpdate:modelValue":Z[5]||(Z[5]=ee=>t.value=ee),onOpened:b,onClosed:S,class:"fct-global-search-container","append-to-body":!0},{header:u(()=>[o("div",a8e,[n(X,{name:"Search",class:"search-icon"}),D.value!=null?(r(),m("div",l8e,[R(f(D.value.title)+" ",1),n(X,{name:"Cross",class:"searched-item-remove",onClick:O})])):B("",!0),n(N,{class:"mousetrap",placeholder:c(d)("Search for %1$s",i.value),autofocus:"",ref_key:"searchRef",ref:s,id:"fct-global-search-input",disabled:H.value,onKeydown:[Z[0]||(Z[0]=da(Ge(()=>{var ee,pe;if(V.value){(ee=W.value)==null||ee.focusList();return}(pe=$.value)==null||pe.focusList()},["prevent"]),["arrow-down"])),Z[1]||(Z[1]=da(Ge(()=>{var ee,pe;if(V.value){(ee=W.value)==null||ee.performFirstAction();return}(pe=$.value)==null||pe.performFirstAction()},["prevent"]),["enter"])),Z[2]||(Z[2]=da(()=>{a.value.length===0&&(D.value=null,V.value=!1)},["backspace"]))],onInput:Z[3]||(Z[3]=()=>{if(V.value){M();return}let ee=a.value.includes(","),pe=a.value.includes(":");if(!ee&&!pe)l.value.value=c(ce).search(a.value);else{const re=x(a.value);l.value.value=c(ce).search({$or:re})}}),modelValue:a.value,"onUpdate:modelValue":Z[4]||(Z[4]=ee=>a.value=ee),clearable:""},null,8,["placeholder","disabled","modelValue"])])]),default:u(()=>[n(_a,{visible:!D.value&&a.value.length===0,accordion:""},{default:u(()=>[o("div",s8e,[o("div",n8e,f(c(d)("Searching for")),1),o("div",o8e,[(r(!0),m(P,null,ae(U.value,ee=>{var pe;return r(),m("div",{key:ee.key,onClick:re=>L(ee),class:ue(["fct-global-searching-suggestion",((pe=D.value)==null?void 0:pe.key)===ee.key?"active":""])},f(ee.title),11,i8e)}),128))])])]),_:1},8,["visible"]),V.value?(r(),E(JBe,{key:0,ref_key:"remoteResultRef",ref:W,query:a.value,tag:D.value,onCloseModal:Q,onOnRemoteSearchStateChange:j},null,8,["query","tag"])):(r(),E(_Be,{key:1,ref_key:"resultListRef",ref:$,query:a.value,"search-results":l.value.value,onActionPerformed:Q,focusInput:F,searchData:c(ad)},null,8,["query","search-results","searchData"])),o("div",r8e,[o("ul",d8e,[o("li",null,[o("span",u8e,[n(X,{name:"ArrowUp"})]),o("span",c8e,[n(X,{name:"ArrowDown"})]),o("span",A8e,f(c(d)("To navigate")),1)]),o("li",null,[o("span",p8e,[n(X,{name:"Enter"})]),o("span",f8e,f(c(d)("To select")),1)]),o("li",null,[Z[7]||(Z[7]=o("kbd",{class:"command-key"},"esc",-1)),o("span",m8e,f(c(d)("To close")),1)])])])]),_:1},8,["modelValue"])],64)}}},_8e={class:"fl_app fluent-cart-admin-pages"},v8e=Object.assign({name:"DashboardApplication"},{__name:"Application",setup(e){const t=T("");De(()=>{jQuery(".notice:not(.fluent-cart), .error:not(.fluent-cart), #ehp-admin-cb").remove(),t.value=a(),l.value=!!document.getElementById("theme-button-container");const A=document.querySelector(".fct_admin_menu_wrap"),p=()=>{window.scrollY>10?A==null||A.classList.add("scroll-header"):A==null||A.classList.remove("scroll-header")};window.addEventListener("scroll",p)});const a=()=>window.location.href,l=T(!1),s=Na();ke(()=>s.fullPath,()=>{t.value=a()});const i=K(()=>!(s.fullPath.includes("reports")||s.fullPath.includes("settings")));return(A,p)=>{const h=k("router-view");return r(),m("div",null,[n(h8e),i.value?(r(),E(Fa,{key:0})):B("",!0),o("div",_8e,[n(h)]),l.value?(r(),E(di,{key:1,to:"#theme-button-container"},[n(ike)])):B("",!0)])}}});let Kc=!1;function g8e(e){return{data:function(){return{appVars:window.fluentCartAdminApp}},methods:{$get:Ae.get,$post:Ae.post,$put:Ae.put,$del:Ae.delete,$t:d,$n:Vo,formatMoney(t,a,l=!1){return!t&&l?"":(t||(t="0.00"),je.get("shop.currency_sign")+" "+t)},formatCents(t,a,l=!1){return!t&&l?"":(t?t=(t*100).toFixed(2):t="0.00",a?(t=new Intl.NumberFormat("en-US").format(t),je.get("shop.currency_sign")+" "+t):t)},formatNumber(t,a=!0,l=!1,s){return vt.formatNumber(t,a,l,s)},formatNumberForOrder(t,a,l=!0,s=!1){return vt.formatForOrder(t,a,l,s)},getAddress(t,a="billing"){let l=[t[a+"_address_1"],t[a+"_address_2"],t[a+"_city"],t[a+"_city"],t[a+"_state"],t[a+"_zip"],t[a+"_country"]];return l=l.filter(s=>!!s).join(", "),l||"no "+a+" address"},getOrderAddress(t,a="billing",l=!1){return Fm(t,a,l)},changeTitle(t){jQuery("head title").text(t+" - FluentCart")},handleError(t){if(!t)return;let a="";typeof t=="string"?a=t:t&&t.message?a=t.message:a=t,typeof t=="object"&&(a=this.convertToText(t)),a||(a="Something is wrong!"),this.$notify({type:"error",title:"Error",message:a,dangerouslyUseHTMLString:!0})},convertToText(t){const a=[];if(typeof t=="object"&&t.join===void 0)for(const l in t)a.push(this.convertToText(t[l]));else if(typeof t=="object"&&t.join!==void 0)for(const l in t)a.push(this.convertToText(t[l]));else typeof t=="function"||typeof t=="string"&&a.push(t);return a.join("
")},handleSuccess:t=>{q.success(t)},handleMessage:(t,a="info",l=40,s=1e3)=>{Jc.show(t,a,l,s)},Storage:()=>Tt,buildFormRendererValue(t,a){let l={};return Object.keys(t).forEach(s=>{let i=t[s];["grid"].includes(i.type??"")?l[s]=this.buildFormRendererValue(i.schema??{},a[s]??{}):l[s]=a[s]??""}),l},registerCopyAction(){Kc||(Kc=!0,document.addEventListener("click",t=>{t.target.matches(".copyable-content")&&ls.copy(t.target.textContent)}))},currencySign(){return je.get("shop.currency_sign")},getPlaceholderImage(){return pl.productPlaceholder()},saveLocal(t,a){Tt.set(t,a)},getLocal(t){return Tt.get(t)},hasPermission(t){return sn.hasPermission(t)}}}}function y8e(e){e.beforeEach((t,a,l)=>{const s=dt.get(t,"meta.permission");return s?sn.resolve({permission:s,permissionType:dt.get(t,"meta.permissionType")})?l():l({name:"unauthorized"}):(je.get("app_config.env"),l())})}function b8e(e){const t={fluent_cart_products:["fluent_cart_inventory","fluent_cart_attributes","fluent_cart_reviews"]},a=l=>{if(!l)return;const s="fluent_cart_"+l;Object.entries(t).forEach(([i,A])=>{const p=s===i;A.forEach(h=>{const _=jQuery(".toplevel_page_fluent-cart li."+h);p?_.show():_.hide()})})};e.afterEach((l,s)=>{const i=l.meta.active_menu;jQuery(".fct_menu li").removeClass("active_admin_menu"),jQuery(".fct_menu li.fct_menu_item_"+i).addClass("active_admin_menu"),jQuery(".toplevel_page_fluent-cart li").removeClass("current"),jQuery(".toplevel_page_fluent-cart li.fluent_cart_"+i).addClass("current"),a(i),l.meta.title&&jQuery("head title").text(l.meta.title+" - FluentCart")})}const w8e={mounted(e,t){const a=t.value,l=1e3,s=0,i=performance.now(),A=()=>{const p=performance.now()-i,h=Math.min(p/l,1),_=(s+h*(a-s)).toFixed(2);e.textContent=_,h<1&&requestAnimationFrame(A)};A()},updated(e,t){const a=t.value,l=2e3,s=0,i=performance.now(),A=()=>{const p=performance.now()-i,h=Math.min(p/l,1),_=(s+h*(a-s)).toFixed(2);e.textContent=_,h<1&&requestAnimationFrame(A)};A()}},C8e={__name:"Unauthorized",setup(e){return(t,a)=>(r(),m("span",null,f(c(d)("You are not allowed")),1))}},k8e=window.fluent_cart_admin.hooks.applyFilters("fluent_cart_routes",ske);let Gc=!1;document.addEventListener("fcart_renew_rest_nonce",function(e){Gc||El.alert(d("Your session has expired due to inactivity. Please refresh the page to continue."),d("Session Expired"),{confirmButtonText:d("Reload"),callback:t=>{Gc=!1,window.location.reload()}})});const B8e=[Am,pm,fm,eA,mm,od,hm,_m,id,vm,gm,aA],Wl=lm(v8e);Wl.config.globalProperties.appVars=je.get();Wl.provide("appVars",je.get());Wl.mixin(g8e());Wl.directive("loading",Dm);Wl.directive("animate",w8e);th(Wl);const Pd=sm({routes:[...Object.values(k8e),{path:"/unauthorized",name:"unauthorized",component:C8e,props:!0},{path:"/:path(.*)*",name:"NotFound",component:pi,props:!0}],history:nm(),scrollBehavior(e,t,a){return a||{top:0,behavior:"smooth"}}});Wl.use(Pd);y8e(Pd);b8e(Pd);B8e.forEach(e=>{Wl.component(e.name,e)});const Hd=je.get("el_strings"),zf=je.get("datei18");Hd.el.datepicker.weeks=zf.weekdaysShort;Hd.el.datepicker.months=zf.monthsShort;Wl.use(Qm,{locale:Hd});Wl.mount("#fluent_cart_plugin_app");if(je.get("has_data_migrations")){let e=0;const t=()=>{Ae.post("data-backfills/run").then(a=>{a&&a.status==="running"&&++e<100&&t()}).catch(()=>{})};t()}export{qn as E,Sd as _};