`}),$}},xAxis:{type:"category",data:g.value,axisLabel:{color:A.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{type:"dashed",color:A.value?"#253241":"#D6DAE1"}}},yAxis:[{type:"value",position:"left",name:c("Volume (%s)",Te.currencySign),axisLabel:{color:A.value?"#ffffff":"#696778",fontSize:12,formatter:M=>Te.formatScaledChart(M)},splitLine:{show:!0,lineStyle:{color:A.value?"#253241":"#D6DAE1",type:"dashed"}}},{type:"value",position:"right",name:"YoY Growth (%)",axisLabel:{color:A.value?"#ffffff":"#696778",fontSize:12,formatter:"{value}%"},splitLine:{show:!1},min:Math.min(...v.value.filter(M=>!isNaN(M)),0)-5,max:Math.max(...v.value.filter(M=>!isNaN(M)),0)+5}],series:y.value};try{B.setOption(S,{notMerge:!0,replaceMerge:["series"]})}catch(M){o.value=`Error updating chart: ${M.message}`}},k=(S,M,$,F,L=0)=>({name:S,type:M,barMaxWidth:t.barMaxWidth,areaStyle:M==="line"?null:void 0,data:$,smooth:M==="line",color:F,lineStyle:M==="line"?{width:2}:void 0,yAxisIndex:L,emphasis:{scale:2,itemStyle:{color:A.value?u.blue[800]:u.blue[400]}}});return ge([()=>t.data,s],()=>{ye(w)},{deep:!0}),At(()=>{window.removeEventListener("onFluentCartThemeChange",w,!1),window.removeEventListener("fluentCartCurrencyChange",w,!1),B&&(B.dispose(),B=null)}),Be(()=>{window.addEventListener("onFluentCartThemeChange",w),window.addEventListener("fluentCartCurrencyChange",w),ye(b)}),(S,M)=>(d(),_("div",$le,[l(he,{id:"chartContainer",ref_key:"cardRef",ref:n},{default:i(()=>[l(Ce,{title:p(c)(e.title),title_size:"small",border_bottom:""},{action:i(()=>M[0]||(M[0]=[])),_:1},8,["title"]),l(me,{class:"p-0"},{default:i(()=>[o.value?(d(),_("div",Dle,h(o.value),1)):x("",!0),e.isEmpty?(d(),E(at,{key:2,icon:"Empty/ListView","has-dark":!0,text:p(c)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(d(),_("div",{key:1,class:"fct-chart-wrap fct-gross-volume-chart",ref_key:"chartRef",ref:a,style:{height:"400px"}},null,512))]),_:1})]),_:1},512)]))}},FA=He(Qle,[["__scopeId","data-v-f7c41726"]]),Ile={class:"fct-country-volume-chart-wrap"},Tle={class:"fct-btn-group sm"},Vle={__name:"CountryVolumeChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=V(null),n=V(null);let s=null;const o=V("bar");V("");const u=V(ke.isDark()),A=j(()=>[u.value?"#032647":"#3e9df6",u.value?"#04315b":"#1589f4",u.value?"#053c70":"#0a73d5",u.value?"#064784":"#0968c1",u.value?"#075298":"#085dad"]),f=j(()=>{const k=Array.isArray(t.data.by_countries)?t.data.by_countries:Object.values(t.data.by_countries);return!k.length||!k.every(S=>!!S)}),m=ke.colors,g=j(()=>{const k=t.data.by_month||{};return Object.keys(k).sort().map(M=>{const $=k[M],F=Object.values($).reduce((Q,T)=>Q+T,0),L=Object.entries($).sort((Q,T)=>Q[1]-T[1]).reduce((Q,[T,D])=>({...Q,[T]:D}),{});return{label:M,countries:L,total:F}})}),y=j(()=>g.value.length?g.value.map(k=>{try{const[S,M]=k.label.split("-");return Re(new Date(S,M-1)).format("MMM YYYY")}catch{return k.label}}):[]),v=j(()=>{const k=t.data.by_month||{},S=Object.keys(k).sort(),M=new Set;return Object.values(k).forEach($=>{Object.keys($).forEach(F=>M.add(F))}),Array.from(M).reverse().map($=>{let F;const L=g.value.map((Q,T)=>{const D=k[S[T]],I=Object.entries(D).sort((K,G)=>G[1]-K[1]).map(([K])=>K).indexOf($),O=Q.countries[$]||0,P=I<5?I:4;return!F&&P>=0&&(F=A.value[P]||A.value[4]),{value:O/100,label:{show:O>0,position:"inside",formatter:$,color:(u.value,"#fff"),fontSize:10,fontWeight:"bold"}}});return{name:$,type:o.value,stack:"total",data:L,itemStyle:{color:F},lineStyle:{color:F}}})}),B=()=>{if(!a.value)return;s=Mt(a.value);const k={backgroundColor:"transparent",tooltip:{trigger:"axis",backgroundColor:u.value?"#253241":"#ffffff",textStyle:{color:u.value?m.gray[25]:m.system.mid},borderColor:u.value?"#2C3C4E":"#c0c4ca",axisPointer:{type:"line",lineStyle:{type:"solid",width:2,color:u.value?m.report.dark_cyan_blue_16:m.report.light_gray_cyan_blue}},borderWidth:1,formatter:S=>{let M=S[0].axisValue;const $=u.value?"#ffffff":"#565865",F=g.value[S[0].dataIndex].total;S=S.sort((Q,T)=>T.value-Q.value).filter(Q=>Q.value>0),S.push({marker:'
',seriesName:c("Total"),value:F/100});const L=u.value?m.report.dark_cyan_blue_16:m.report.light_gray_blue;return S.forEach(function(Q,T){const D=T===S.length-1;if(!D&&Q.value===0)return;const U=Te.scaled(Q.value);D?M+=`
`:M+="
",M+=`
${Q.marker}
${Q.seriesName}
${U}
`}),M}},xAxis:{type:"category",data:y.value,axisLabel:{color:u.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{color:u.value?"#253241":"#D6DAE1"}}},yAxis:{type:"value",position:"left",name:c("Volume (%s)",Te.currencySign),axisLabel:{color:u.value?"#ffffff":"#696778",fontSize:12,formatter:S=>Te.formatScaled(S*100)},splitLine:{show:!0,lineStyle:{color:u.value?"#253241":"#D6DAE1",type:"dashed"}}},series:v.value};s.setOption(k)},b=()=>{u.value=ke.isDark(),ye(()=>{B()})},w=()=>{s&&(s.dispose(),s=null),B()};return Be(()=>{window.addEventListener("onFluentCartThemeChange",b),window.addEventListener("fluentCartCurrencyChange",w),ye(B)}),At(()=>{window.removeEventListener("onFluentCartThemeChange",b,!1),window.removeEventListener("fluentCartCurrencyChange",w,!1)}),ge(()=>u.value,()=>{s&&(s.dispose(),B())}),ge(()=>t.data,()=>{s&&B()}),(k,S)=>(d(),_("div",Ile,[l(he,{id:"chartContainer",ref_key:"cardRef",ref:n},{default:i(()=>[l(Ce,{title:e.title,title_size:"small",border_bottom:""},{action:i(()=>[r("div",Tle,[l(Lh,{targetRef:a.value},null,8,["targetRef"])])]),_:1},8,["title"]),l(me,{class:"p-0"},{default:i(()=>[f.value?(d(),E(at,{key:1,icon:"Empty/ListView","has-dark":!0,text:p(c)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(d(),_("div",{key:0,class:"fct-chart-wrap fct-country-volume-chart",ref_key:"chartRef",ref:a,style:{height:"400px"}},null,512))]),_:1})]),_:1},512)]))}},EA=He(Vle,[["__scopeId","data-v-89fa1969"]]),Mle={class:"fct-card-header-title is-small"},UA={__name:"CountryNetChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=ke.colors.report,n=V(ke.isDark()),s=V(null),o=V("line"),u=V(t.data),A=j(()=>({textColor:n.value?"#ffffff":"#696778",borderColor:n.value?"#2C3C4E":"#c0c4ca",splitLineColor:n.value?"#253241":"#D6DAE1",bgColor:n.value?"#2d3748":"#ffffff"})),f=j(()=>Object.values(u.value).every(w=>w===0)),m=j(()=>Object.keys(u.value)),g=j(()=>[{name:c("Current"),type:o.value,data:Object.values(u.value),smooth:!0,color:n.value?a.purple_dark_mode:a.purple,lineStyle:{width:2},barMaxWidth:30}]);let y=null;const v=()=>{s.value&&!y&&(y=Mt(s.value),B())},B=()=>{if(!y)return;const w={legend:{show:!1},tooltip:{trigger:"axis",backgroundColor:A.value.bgColor,borderColor:A.value.borderColor,borderWidth:1,textStyle:{color:A.value.textColor},axisPointer:{type:"line",lineStyle:{type:"solid",width:2,color:n.value?a.dark_cyan_blue_16:a.light_gray_blue}},formatter:k=>{let S=k[0].name;const M=n.value?"#ffffff":"#565865";return k.forEach($=>{const F=Te.formatScaled($.value);S+=`
${$.marker}
${$.seriesName}
${F}
`}),S}},xAxis:{type:"category",data:m.value,axisLabel:{color:A.value.textColor,fontSize:12},axisLine:{lineStyle:{type:"dashed",color:A.value.splitLineColor}}},yAxis:{type:"value",axisLabel:{color:A.value.textColor,fontSize:12,formatter:k=>Te.formatScaled(k)},splitLine:{show:!0,lineStyle:{color:A.value.splitLineColor,type:"dashed"}}},series:g.value,grid:{left:"10px",right:"10px",top:"20px",bottom:"60px",containLabel:!0}};y.setOption(w,{notMerge:!0,replaceMerge:["series"]})};ge([()=>u.value,o,()=>n.value],()=>{ye(B)},{deep:!0});const b=()=>{n.value=ke.isDark(),ye(()=>{B()})};return Be(()=>{window.addEventListener("onFluentCartThemeChange",b,!1),window.addEventListener("fluentCartCurrencyChange",B),ye(v)}),At(()=>{window.removeEventListener("onFluentCartThemeChange",b,!1),window.removeEventListener("fluentCartCurrencyChange",B,!1)}),(w,k)=>(d(),E(he,null,{default:i(()=>[e.title!==""?(d(),E(Ce,{key:0,border_bottom:!0},{title:i(()=>[r("h3",Mle,h(e.title),1)]),_:1})):x("",!0),l(me,null,{default:i(()=>[f.value?(d(),E(at,{key:1,icon:"Empty/ListView","has-dark":!0,text:p(c)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(d(),_("div",{key:0,class:"fct-chart-wrap h-[350px]",ref_key:"SubscriptionCountTrendChartRef",ref:s},null,512))]),_:1})]),_:1}))}},Lle={class:"fct-overview-report-loader-wrap"},Rle={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},Ole={class:"fct-card-header-title is-small"},Hle={class:"flex gap-2 mt-1"},Ple={class:"py-6"},Nle={class:"grid grid-cols-1"},Kle={class:"fct-card-header-title is-small"},Gle={class:"py-6"},jle={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},zle={class:"fct-card-header-title is-small"},Yle={class:"flex gap-2 mt-1"},qle={class:"py-6"},Wle={class:"grid grid-cols-1"},Xle={class:"fct-card-header-title is-small"},Jle={class:"py-6"},Zle={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},eoe={class:"fct-card-header-title is-small"},toe={class:"py-6"},aoe={__name:"OverviewLoading",setup(e){const t=[{title:c("Gross Summary"),key:"gross_summary"},{title:c("Gross Revenue Quarterly"),key:"net_summary"}],a=[{title:c("Net Revenue"),key:"net_revenue"},{title:c("Net Revenue Quarterly"),key:"net_revenue_quarterly"}],n=[{title:c("Top Country Gross Volume"),key:"top_country_gross"},{title:c("Top Country Net Volume"),key:"top_country_net"}],s=[{title:c("Top Countries Gross Revenue"),key:"top_country_revenue"},{title:c("Top Countries Net Revenue"),key:"top_country_net_revenue"}];return(o,u)=>{const A=C("el-skeleton-item"),f=C("el-skeleton");return d(),_("div",Lle,[r("div",Rle,[(d(),_(H,null,ee(t,(m,g)=>r("div",{key:g},[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(Ce,{border_bottom:!0},{title:i(()=>[r("h3",Ole,h(m.title),1),r("div",Hle,[l(f,{animated:""},{template:i(()=>[l(A,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),r("div",Ple,[l(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),r("div",Nle,[(d(),_(H,null,ee(2,m=>r("div",{key:m},[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(f,{animated:""},{template:i(()=>[l(A,{variant:"p",class:"w-2/3"})]),_:1}),l(Ce,{border_bottom:!0},{title:i(()=>[r("h2",Kle,h(p(c)("Gross Volume Breakdown")),1)]),_:1}),r("div",Gle,[l(f,{animated:"",rows:7})])]),_:1})]),_:1})])),64))]),r("div",jle,[(d(),_(H,null,ee(a,(m,g)=>r("div",{key:g},[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(Ce,{border_bottom:!0},{title:i(()=>[r("h3",zle,h(m.title),1),r("div",Yle,[l(f,{animated:""},{template:i(()=>[l(A,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),r("div",qle,[l(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),r("div",Wle,[(d(),_(H,null,ee(n,(m,g)=>r("div",{key:g},[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(Ce,{border_bottom:!0},{title:i(()=>[r("h2",Xle,h(m.title),1)]),_:2},1024),r("div",Jle,[l(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),r("div",Zle,[(d(),_(H,null,ee(s,(m,g)=>r("div",{key:g},[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(Ce,{border_bottom:!0},{title:i(()=>[r("h3",eoe,h(m.title),1)]),_:2},1024),r("div",toe,[l(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))])])}}},noe={class:"overview-summary-report-inline"},soe={class:"inner-value"},loe={__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)=>(d(),_("div",noe,[r("div",soe,[l(qs,{amount:p(Te).formatScaled(e.current),title:p(c)(e.title)},null,8,["amount","title"])]),l(An,{fluctuation:e.fluctuation,amount:e.previous/100,fluctuationSuffix:p(c)("YoY")},null,8,["fluctuation","amount","fluctuationSuffix"])]))}},Yo=He(loe,[["__scopeId","data-v-b394c9f1"]]),ooe={class:"report-overview-page"},roe={class:"flex items-center justify-start gap-1 mb-2 text-xs text-system-mid dark:text-system-light"},ioe={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},doe={class:"fct-card-header-title is-small"},uoe={class:"fct-card-header-title is-small"},coe={class:"grid grid-cols-1"},Aoe=["innerHTML"],poe=["innerHTML"],foe={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},moe={class:"fct-card-header-title is-small"},hoe={class:"fct-card-header-title is-small"},_oe={class:"grid gap-4 grid-cols-1"},goe={class:"grid gap-4 grid-cols-1"},voe={class:"report-overview-col-2 grid gap-7.5 grid-cols-1 xl:grid-cols-2"},yoe={__name:"Overview",setup(e){const t=V({}),a=V(!0),n=V({gross_revenue_quarterly:{},net_revenue_quarterly:{}}),s=()=>{re.get("reports/overview").then(A=>{t.value=A.data,o()}).catch(A=>{}).finally(()=>{a.value=!1})},o=()=>{n.value.gross_revenue_quarterly=u(t.value.gross_revenue_quarterly,"current","prev_year"),n.value.net_revenue_quarterly=u(t.value.net_revenue_quarterly,"current","prev_year")},u=(A,f="current",m="prev")=>{const g=Ke.sum(A,"*."+f),y=Ke.sum(A,"*."+m),v=y===0?100:(g-y)/y*100;return{value:parseFloat(v.toFixed(2)),prev:y,current:g}};return j(()=>{var A,f;return((A=t.value.gross_summary)==null?void 0:A.yoy_growth)<0?"danger":((f=t.value.gross_summary)==null?void 0:f.yoy_growth)===null?"warning":"success"}),Be(()=>{s()}),(A,f)=>(d(),_("div",ooe,[r("div",roe,[l(W,{name:"InformationFill",class:"w-4 h-4 text-system-light"}),R(" "+h(p(c)("Last %s Months",p(c)(12))),1)]),a.value?(d(),E(aoe,{key:0})):(d(),_(H,{key:1},[r("div",ioe,[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(Ce,{border_bottom:""},{title:i(()=>[r("h3",doe,h(p(c)("Gross Summary")),1),l(Yo,{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}),l(zo,{data:t.value.gross_revenue,dataKey:"current","date-range":"","is-empty":!t.value.gross_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(Ce,{border_bottom:""},{title:i(()=>[r("h3",uoe,h(p(c)("Gross Revenue Quarterly")),1),l(Yo,{current:n.value.gross_revenue_quarterly.current,previous:n.value.gross_revenue_quarterly.prev,fluctuation:n.value.gross_revenue_quarterly.value},null,8,["current","previous","fluctuation"])]),_:1}),l(zo,{data:t.value.gross_revenue_quarterly,dataKey:"current","bar-max-width":80,"is-empty":!n.value.gross_revenue_quarterly.current},null,8,["data","is-empty"])]),_:1})]),_:1})]),r("div",coe,[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[r("div",{class:"mb-3",innerHTML:p(Te).generateVolumeSummary(t.value.gross_revenue,!0)},null,8,Aoe),l(FA,{title:"Gross Volume Breakdown",data:t.value.gross_revenue,dataKey:"current","is-date":"","is-empty":!t.value.gross_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[r("div",{class:"mb-3",innerHTML:p(Te).generateVolumeSummary(t.value.gross_revenue_quarterly)},null,8,poe),l(FA,{title:p(c)("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})]),r("div",foe,[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(Ce,{border_bottom:!0},{title:i(()=>[r("h3",moe,h(p(c)("Net Revenue")),1),l(Yo,{title:"Net Revenue",current:t.value.net_summary.total,previous:t.value.net_summary.total_prev,fluctuation:t.value.net_summary.yoy_growth},null,8,["current","previous","fluctuation"])]),_:1}),l(zo,{data:t.value.net_revenue,dataKey:"current","date-range":"","is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(Ce,{border_bottom:!0},{title:i(()=>[r("h3",hoe,h(p(c)("Net Revenue Quarterly")),1),l(Yo,{title:"Net Revenue Quarterly",current:n.value.net_revenue_quarterly.current,previous:n.value.net_revenue_quarterly.prev,fluctuation:n.value.net_revenue_quarterly.value},null,8,["current","previous","fluctuation"])]),_:1}),l(zo,{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})]),r("div",_oe,[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(EA,{data:t.value.top_country_gross,title:p(c)("Top Country Gross Volume")},null,8,["data","title"])]),_:1})]),_:1})]),r("div",goe,[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>[l(EA,{data:t.value.top_country_net,title:p(c)("Top Country Net Volume")},null,8,["data","title"])]),_:1})]),_:1})]),r("div",voe,[l(he,null,{default:i(()=>[l(me,null,{default:i(()=>{var m;return[l(UA,{data:(m=t.value.top_country_gross)==null?void 0:m.by_countries,title:p(c)("Top Countries Gross Revenue")},null,8,["data","title"])]}),_:1})]),_:1}),l(he,null,{default:i(()=>[l(me,null,{default:i(()=>{var m;return[l(UA,{data:(m=t.value.top_country_net)==null?void 0:m.by_countries,title:p(c)("Top Countries Net Revenue")},null,8,["data","title"])]}),_:1})]),_:1})])],64))]))}},boe={class:"setting-wrap"},woe={class:"setting-wrap-inner"},Coe={key:0,class:"bg-white rounded p-6 dark:bg-dark-700"},Boe={class:"grid gap-3 mb-6"},koe={class:"grid gap-3 mb-6"},xoe={class:"grid gap-3 mb-6"},Soe={class:"grid gap-3"},Foe={class:"payment-method-list fct-content-card-list"},Eoe={class:"flex items-start gap-3"},Uoe={class:"grid gap-2 flex-1"},$oe={key:0,class:"fct-content-card-list-head stripe"},Doe=["src","alt"],Qoe=["src","alt"],Ioe={class:"block font-semibold text-system-dark dark:text-system-light"},Toe={class:"fct-content-card-list-content"},Voe={class:"fct-content-card-list-action flex items-center gap-2"},Moe={key:0},Loe=Object.assign({name:"AddonSettings"},{__name:"AddonSettings",setup(e){const t=dm(),{form:a}=t.data,n=xs(),s=V([]),o=V([]),u=V(!0),A=V(!1),f=V(!0),m=V({}),g=V(!1),y=V({}),v=V(!1),B=V(""),b=V(""),w=j(()=>Object.keys(y.value).length>0),k=()=>{A.value=!0;let Q=a.values;re.post("settings/modules",{...Q}).then(T=>{q.success(c("Settings saved successfully")),setTimeout(()=>{window.location.reload()},300)}).catch(T=>{if(T&&T.message)return q.error(T);m.value=T}).finally(()=>{A.value=!1,f.value=!1,u.value=!1})},S=()=>{u.value=!0,re.get("settings/modules",{}).then(Q=>{var U,I;a.setSchema(Q.fields).setDefaults(Q.settings).initForm(),s.value=Q.settings,o.value=Q.fields,f.value=!1,A.value=!1;const T=((I=(U=Q.fields)==null?void 0:U.modules_settings)==null?void 0:I.schema)||[];let D=!1;Array.isArray(T)?D=T.length>0:D=Object.keys(T).length>0,g.value=D}).finally(()=>{u.value=!1})},M=()=>{v.value=!0,re.get("settings/modules/plugin-addons",{}).then(Q=>{y.value=Q.addons||{}}).catch(Q=>{q.error(Q)}).finally(()=>{v.value=!1})},$=Ie.get("app_config.isProActive"),F=(Q,T)=>{if(!$){window.open(Q.repo_link,"_blank","noopener,noreferrer");return}B.value=T,re.post("settings/modules/plugin-addons/install",{plugin_slug:Q.plugin_slug,source_type:Q.source_type||"wordpress",source_link:Q.source_link||"",asset_path:Q.asset_path||""}).then(D=>{D.action==="copy"&&D.url?(Os.copy(D.url,{successMessage:c("Download link copied to your clipboard")}),window.open(D.url,"_blank","noopener,noreferrer")):D.action==="reload"?(q.success(D.message||c("Addon installed successfully")),setTimeout(()=>{window.location.reload()},500)):q.success(D.message||c("Addon installed successfully"))}).catch(D=>{q.error(D)}).finally(()=>{B.value=""})},L=(Q,T)=>{b.value=T,re.post("settings/modules/plugin-addons/activate",{plugin_file:Q.plugin_file}).then(D=>{q.success(D.message||c("Addon activated successfully")),setTimeout(()=>{window.location.reload()},500)}).catch(D=>{q.error(D)}).finally(()=>{b.value=""})};return Be(()=>{S(),M()}),n.onSave(k),(Q,T)=>{const D=C("el-skeleton-item"),U=C("el-skeleton"),I=C("el-form"),O=C("el-button"),P=C("el-icon"),K=C("router-link");return d(),_("div",boe,[l(ha,{heading:p(c)("Addon Settings"),"show-save-button":!1},null,8,["heading"]),r("div",woe,[l(_a),f.value?(d(),_("div",Coe,[l(U,{loading:f.value,animated:""},{template:i(()=>[r("div",Boe,[l(D,{variant:"p",class:"w-[20%]"}),l(D,{variant:"p"})]),r("div",koe,[l(D,{variant:"p",class:"w-[20%]"}),l(D,{variant:"p"})]),r("div",xoe,[l(D,{variant:"p",class:"w-[20%]"}),l(D,{variant:"p"})]),r("div",Soe,[l(D,{variant:"p",class:"w-[20%]"}),l(D,{variant:"p"})])]),_:1},8,["loading"])])):x("",!0),f.value?x("",!0):(d(),_(H,{key:1},[p(a).isReady?(d(),E(I,{key:0},{default:i(()=>[g.value?(d(),E(oi,{key:0,form:p(a),showSubmitButton:!0,onOnSubmitButtonClick:k,submitButtonText:p(c)("Save Settings"),loading:A.value,onOnChange:T[0]||(T[0]=G=>{}),"validation-errors":m.value},null,8,["form","submitButtonText","loading","validation-errors"])):w.value?x("",!0):(d(),E(he,{key:1},{default:i(()=>[l(Ce,{title:p(c)("Features & addon"),border_bottom:""},null,8,["title"]),l(me,null,{default:i(()=>[l(at,{class:"fct-addon-empty-state",icon:"Empty/Integrations",text:p(c)("No module settings found.")},null,8,["text"])]),_:1})]),_:1}))]),_:1})):x("",!0),w.value?(d(),E(he,{key:1,class:"mt-6"},{default:i(()=>[l(Ce,{title:p(c)("Plugin Addons"),border_bottom:""},null,8,["title"]),l(me,null,{default:i(()=>[r("div",Foe,[(d(!0),_(H,null,ee(y.value,(G,ne)=>(d(),_("div",{key:ne,class:"fct-content-card-list-item"},[r("div",Eoe,[r("div",Uoe,[G.logo?(d(),_("div",$oe,[r("img",{class:de({"dark:hidden":G.dark_logo}),src:G.logo,alt:G.title},null,10,Doe),G.dark_logo?(d(),_("img",{key:0,src:G.dark_logo,alt:G.title,class:"hidden dark:block"},null,8,Qoe)):x("",!0),r("span",Ioe,h(G.title),1),G.is_active?(d(),E(qt,{key:1,status:"active",text:p(c)("Active")},null,8,["text"])):x("",!0)])):x("",!0),r("div",Toe,[r("p",null,h(G.description),1)])]),r("div",Voe,[G.upcoming?(d(),_("div",Moe,h(p(c)("Coming Soon")),1)):(d(),_(H,{key:1},[G.is_installed?G.is_installed&&!G.is_active&&(p($)||G.source_type!=="github")?(d(),E(O,{key:1,type:"success",size:"small",loading:b.value===ne,disabled:b.value===ne,onClick:Y=>L(G,ne)},{default:i(()=>[R(h(p(c)("Activate")),1)]),_:2},1032,["loading","disabled","onClick"])):x("",!0):(d(),E(O,{key:0,type:"primary",size:"small",loading:B.value===ne,disabled:B.value===ne,onClick:Y=>F(G,ne)},{default:i(()=>[R(h(p($)?p(c)("Install & Activate"):p(c)("Download")),1)]),_:2},1032,["loading","disabled","onClick"])),G.is_active&&ne==="fluent-pdf"?(d(),E(K,{key:2,to:{path:"/settings/pdf-template"}},{default:i(()=>[l(P,{class:"text-gray-500 hover:text-primary cursor-pointer",size:18},{default:i(()=>[l(p(ap))]),_:1})]),_:1})):x("",!0)],64))])])]))),128))])]),_:1})]),_:1})):x("",!0)],64))])])}}}),Roe=He(Loe,[["__scopeId","data-v-68277391"]]),Ooe={class:"form-note"},Hoe={class:"form-note"},Poe={class:"form-note"},Noe={class:"form-note"},Koe={class:"el-form-item__label"},Goe={class:"h-[297px] w-full relative"},joe={class:"mt-2 mb-2"},zoe={class:"form-note"},Yoe={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"},qoe={class:"setting-html-wrapper"},Woe={class:"setting-label"},Xoe={class:"form-note"},Joe={class:"setting-fields-inner w-full"},Zoe={__name:"MailingSettingsLoader",setup(e){return(t,a)=>{const n=C("el-skeleton-item"),s=C("el-skeleton"),o=C("el-form-item"),u=C("el-col"),A=C("el-row");return d(),E(me,null,{default:i(()=>[l(A,{gutter:15},{default:i(()=>[l(u,{lg:12},{default:i(()=>[l(o,{label:p(c)("From Name"),"label-position":"top"},{default:i(()=>[l(s,{animated:"",class:"h-9 gap-2"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"})]),_:1}),a[0]||(a[0]=r("br",null,null,-1)),r("div",null,[r("div",Ooe,[r("p",null,h(p(c)("Name that will be used to send emails")),1)])])]),_:1,__:[0]},8,["label"])]),_:1}),l(u,{lg:12},{default:i(()=>[l(o,{label:p(c)("From Email"),"label-position":"top"},{default:i(()=>[l(s,{animated:"",class:"h-9"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"})]),_:1}),r("div",null,[r("div",Hoe,[r("p",null,h(p(c)(`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}),l(A,{gutter:15},{default:i(()=>[l(u,{lg:12},{default:i(()=>[l(o,{label:p(c)("Reply to name (Optional)"),"label-position":"top"},{default:i(()=>[l(s,{animated:"",class:"h-9"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"})]),_:1}),r("div",Poe,[r("p",null,h(p(c)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),l(u,{lg:12},{default:i(()=>[l(o,{label:p(c)("Reply to email (Optional)"),"label-position":"top"},{default:i(()=>[l(s,{animated:"",class:"h-9"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"})]),_:1}),r("div",null,[r("div",Noe,[r("p",null,h(p(c)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),l(A,{gutter:15},{default:i(()=>[l(u,null,{default:i(()=>[r("div",Koe,h(p(c)("Email Footer")),1),r("div",Goe,[l(s,{animated:"",rows:7})]),r("div",joe,[r("div",zoe,[r("p",null,h(p(c)(`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)])]),r("div",Yoe,[l(s,{animated:"",class:"h-5"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1}),l(A,{gutter:15},{default:i(()=>[l(u,null,{default:i(()=>[l(o,null,{default:i(()=>[l(A,{gutter:15,class:"w-full"},{default:i(()=>[l(u,{lg:12},{default:i(()=>[r("div",qoe,[r("span",Woe,h(p(c)("Admin Email Address")),1),r("div",Xoe,[r("p",null,h(p(c)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),l(u,{lg:12},{default:i(()=>[r("div",Joe,[l(s,{animated:"",class:"h-9"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}}},ere={class:"setting-wrap"},tre={class:"setting-wrap-inner"},are={class:"form-note"},nre={class:"form-note"},sre={class:"form-note"},lre={class:"form-note"},ore={class:"el-form-item__label"},rre={class:"mt-2 mb-2"},ire={class:"form-note"},dre={class:"fct-powered-by-email-footer-checkbox"},ure={class:"setting-html-wrapper"},cre={class:"setting-label"},Are={class:"form-note"},pre={class:"setting-fields-inner w-full"},fre={class:"setting-save-action"},mre={__name:"MailingSettings",setup(e){const t=V({from_name:"",from_email:"",reply_to_name:"",reply_to_email:"",email_footer:"",show_email_footer:"yes",admin_email:"{{wp.admin_email}}"}),a=Ie.get("app_config.isProActive"),n=V(!1),s=V({}),o=V({}),u=()=>{n.value=!0,re.get("email-notification/get-settings").then(f=>{var m,g,y,v,B,b,w;t.value={from_name:(m=f.data)==null?void 0:m.from_name,from_email:(g=f.data)==null?void 0:g.from_email,reply_to_name:(y=f.data)==null?void 0:y.reply_to_name,reply_to_email:(v=f.data)==null?void 0:v.reply_to_email,email_footer:(B=f.data)==null?void 0:B.email_footer,admin_email:(b=f.data)==null?void 0:b.admin_email,show_email_footer:((w=f.data)==null?void 0:w.show_email_footer)||"yes"},o.value=f.shortcodes}).catch(f=>{}).finally(()=>{n.value=!1})},A=()=>{n.value=!0,s.value={},re.post("email-notification/save-settings",t.value).then(f=>{q.success(f.message)}).catch(f=>{f.status_code===422&&f.data?s.value=f.data:f.message?q.error(f.message):(q.error(c("Something went wrong")),s.value=f)}).finally(()=>{n.value=!1})};return Be(()=>{u()}),(f,m)=>{const g=C("el-input"),y=C("el-form-item"),v=C("el-col"),B=C("el-row"),b=C("el-tooltip"),w=C("el-checkbox"),k=C("el-button");return d(),_("div",ere,[l(ha,{heading:p(c)("Mailing Settings"),loading:n.value,onOnSave:A},null,8,["heading","loading"]),r("div",tre,[l(_a),l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Email Configuration"),text:p(c)("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"]),n.value?(d(),E(Zoe,{key:0})):(d(),E(me,{key:1},{default:i(()=>[l(B,{gutter:15},{default:i(()=>[l(v,{lg:12},{default:i(()=>[l(y,{label:p(c)("From Name"),"label-position":"top"},{default:i(()=>[l(g,{modelValue:t.value.from_name,"onUpdate:modelValue":m[0]||(m[0]=S=>t.value.from_name=S)},null,8,["modelValue"]),m[9]||(m[9]=r("br",null,null,-1)),r("div",null,[l(un,{"validation-errors":s.value.from_name||{},"field-key":"from_name"},null,8,["validation-errors"]),r("div",are,[r("p",null,h(p(c)("Name that will be used to send emails")),1)])])]),_:1,__:[9]},8,["label"])]),_:1}),l(v,{lg:12},{default:i(()=>[l(y,{label:p(c)("From Email"),"label-position":"top"},{default:i(()=>[l(g,{modelValue:t.value.from_email,"onUpdate:modelValue":m[1]||(m[1]=S=>t.value.from_email=S)},null,8,["modelValue"]),r("div",null,[l(un,{"validation-errors":s.value.from_email||{},"field-key":"from_email"},null,8,["validation-errors"]),r("div",nre,[r("p",null,h(p(c)(`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}),l(B,{gutter:15},{default:i(()=>[l(v,{lg:12},{default:i(()=>[l(y,{label:p(c)("Reply to name (Optional)"),"label-position":"top"},{default:i(()=>[l(g,{modelValue:t.value.reply_to_name,"onUpdate:modelValue":m[2]||(m[2]=S=>t.value.reply_to_name=S)},null,8,["modelValue"]),r("div",sre,[r("p",null,h(p(c)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),l(v,{lg:12},{default:i(()=>[l(y,{label:p(c)("Reply to email (Optional)"),"label-position":"top"},{default:i(()=>[l(g,{modelValue:t.value.reply_to_email,"onUpdate:modelValue":m[3]||(m[3]=S=>t.value.reply_to_email=S)},null,8,["modelValue"]),r("div",null,[l(un,{"validation-errors":s.value.reply_to_email||{},"field-key":"reply_to_email"},null,8,["validation-errors"]),r("div",lre,[r("p",null,h(p(c)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),l(B,{gutter:15},{default:i(()=>[l(v,null,{default:i(()=>[r("div",ore,h(p(c)("Email Footer")),1),l(ts,{"short-codes":o.value,modelValue:t.value.email_footer,"onUpdate:modelValue":m[4]||(m[4]=S=>t.value.email_footer=S),onUpdate:m[5]||(m[5]=S=>{t.value.email_footer=S})},null,8,["short-codes","modelValue"]),r("div",rre,[l(un,{"validation-errors":s.value.email_footer||{},"field-key":"email_footer"},null,8,["validation-errors"]),r("div",ire,[r("p",null,h(p(c)(`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)])]),r("div",dre,[l(w,{modelValue:t.value.show_email_footer,"onUpdate:modelValue":m[6]||(m[6]=S=>t.value.show_email_footer=S),"true-value":"yes","false-value":"no",disabled:!p(a)},{default:i(()=>[R(h(p(c)("Enable powered by FluentCart in the email footer"))+" ",1),p(a)?x("",!0):(d(),E(b,{key:0,"popper-class":"fct-tooltip",placement:"top"},{content:i(()=>[R(h(p(c)("This feature is available in pro version only.")),1)]),default:i(()=>[l(W,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),_:1},8,["modelValue","disabled"])])]),_:1})]),_:1}),l(B,{gutter:15},{default:i(()=>[l(v,null,{default:i(()=>[l(y,null,{default:i(()=>[l(B,{gutter:15,class:"w-full"},{default:i(()=>[l(v,{lg:12},{default:i(()=>[r("div",ure,[r("span",cre,h(p(c)("Admin Email Address")),1),r("div",Are,[r("p",null,h(p(c)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),l(v,{lg:12},{default:i(()=>[r("div",pre,[l(g,{modelValue:t.value.admin_email,"onUpdate:modelValue":m[7]||(m[7]=S=>t.value.admin_email=S)},null,8,["modelValue"])])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1}),r("div",fre,[l(k,{type:"primary",onClick:m[8]||(m[8]=S=>A()),loading:n.value},{default:i(()=>[R(h(p(c)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},hre={class:"setting-wrap"},_re={class:"setting-wrap-inner"},gre={class:"form-note"},vre={class:"form-note"},yre={class:"form-note",style:{"padding-top":"6px"}},bre={class:"form-note"},wre={class:"setting-save-action"},$A="{{wp.admin_email}}",Cre={__name:"StoreDigestSettings",setup(e){const t=V({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=V(!1),n=V({}),s=V(""),o=[{key:"daily",label:c("Daily digest"),desc:c("Yesterday's performance, sent every morning.")},{key:"weekly",label:c("Weekly digest"),desc:c("The previous 7 days, sent on your chosen day.")},{key:"monthly",label:c("Monthly digest"),desc:c("The previous calendar month, sent on the 1st.")}],u=c("Comma-separate multiple addresses. %1$s resolves to the site admin email.",$A),A=j(()=>{const v=[];for(let B=0;B<24;B++)v.push({value:B,label:String(B).padStart(2,"0")+":00"});return v}),f=[{value:1,label:c("Monday")},{value:2,label:c("Tuesday")},{value:3,label:c("Wednesday")},{value:4,label:c("Thursday")},{value:5,label:c("Friday")},{value:6,label:c("Saturday")},{value:7,label:c("Sunday")}],m=()=>{a.value=!0,re.get("email-notification/digest-settings").then(v=>{v.data&&(t.value=v.data)}).catch(()=>{}).finally(()=>{a.value=!1})},g=()=>{a.value=!0,n.value={},re.post("email-notification/digest-settings",t.value).then(v=>{q.success(v.message)}).catch(v=>{v.status_code===422&&v.data?n.value=v.data:v.message?q.error(v.message):q.error(c("Something went wrong"))}).finally(()=>{a.value=!1})},y=v=>{s.value=v,re.post("email-notification/digest-settings/send-test",{frequency:v}).then(B=>{q.success(B.message)}).catch(B=>{q.error(B.message||c("Could not send the test email."))}).finally(()=>{s.value=""})};return Be(()=>{m()}),(v,B)=>{const b=C("el-input"),w=C("el-form-item"),k=C("el-col"),S=C("el-checkbox"),M=C("el-row"),$=C("el-switch"),F=C("el-option"),L=C("el-select"),Q=C("el-button");return d(),_("div",hre,[l(ha,{heading:p(c)("Store Digest Emails"),loading:a.value,onOnSave:g},null,8,["heading","loading"]),r("div",_re,[l(_a),l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Recipients & General"),text:p(c)("A system email summarising your store activity. Numbers match the Reports dashboard."),border_bottom:""},null,8,["title","text"]),l(me,null,{default:i(()=>[l(M,{gutter:15},{default:i(()=>[l(k,{lg:12},{default:i(()=>[l(w,{label:p(c)("Recipient email addresses"),"label-position":"top"},{default:i(()=>[l(b,{modelValue:t.value.recipients,"onUpdate:modelValue":B[0]||(B[0]=T=>t.value.recipients=T),placeholder:$A},null,8,["modelValue"]),r("div",null,[l(un,{"validation-errors":n.value.recipients||{},"field-key":"recipients"},null,8,["validation-errors"]),r("div",gre,[r("p",null,h(p(u)),1)])])]),_:1},8,["label"])]),_:1}),l(k,{lg:12},{default:i(()=>[l(w,{label:p(c)("Empty periods"),"label-position":"top"},{default:i(()=>[l(S,{modelValue:t.value.send_when_empty,"onUpdate:modelValue":B[1]||(B[1]=T=>t.value.send_when_empty=T),"true-value":"yes","false-value":"no"},{default:i(()=>[R(h(p(c)("Send even when there was no activity")),1)]),_:1},8,["modelValue"]),r("div",vre,[r("p",null,h(p(c)("When off, a digest is skipped for any period with no paid orders.")),1)])]),_:1},8,["label"])]),_:1})]),_:1})]),_:1})]),_:1}),(d(),_(H,null,ee(o,T=>l(he,{key:T.key,class:"fct-mt-4"},{default:i(()=>[l(Ce,{title:T.label,text:T.desc,border_bottom:""},null,8,["title","text"]),l(me,null,{default:i(()=>[l(M,{gutter:15,align:"middle"},{default:i(()=>[l(k,{lg:6},{default:i(()=>[l(w,{label:p(c)("Enable"),"label-position":"top"},{default:i(()=>[l($,{modelValue:t.value[T.key].enabled,"onUpdate:modelValue":D=>t.value[T.key].enabled=D,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),l(k,{lg:6},{default:i(()=>[l(w,{label:p(c)("Send time"),"label-position":"top"},{default:i(()=>[l(L,{modelValue:t.value[T.key].send_hour,"onUpdate:modelValue":D=>t.value[T.key].send_hour=D,class:"w-full"},{default:i(()=>[(d(!0),_(H,null,ee(A.value,D=>(d(),E(F,{key:D.value,label:D.label,value:D.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),T.key==="weekly"?(d(),E(k,{key:0,lg:6},{default:i(()=>[l(w,{label:p(c)("Day of week"),"label-position":"top"},{default:i(()=>[l(L,{modelValue:t.value.weekly.send_dow,"onUpdate:modelValue":B[2]||(B[2]=D=>t.value.weekly.send_dow=D),class:"w-full"},{default:i(()=>[(d(),_(H,null,ee(f,D=>l(F,{key:D.value,label:D.label,value:D.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})):x("",!0),T.key==="monthly"?(d(),E(k,{key:1,lg:6},{default:i(()=>[l(w,{label:p(c)("Send day"),"label-position":"top"},{default:i(()=>[r("div",yre,[r("p",null,h(p(c)("Sent on the 1st of each month.")),1)])]),_:1},8,["label"])]),_:1})):x("",!0),l(k,{lg:6},{default:i(()=>[l(w,{label:" ","label-position":"top"},{default:i(()=>[l(Q,{loading:s.value===T.key,onClick:D=>y(T.key)},{default:i(()=>[R(h(p(c)("Send test email")),1)]),_:2},1032,["loading","onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1024),r("div",bre,[r("p",null,h(p(c)("Send time is in your store timezone. Test emails use your saved recipients.")),1)])]),_:2},1024)]),_:2},1024)),64)),r("div",wre,[l(Q,{type:"primary",onClick:B[3]||(B[3]=T=>g()),loading:a.value},{default:i(()=>[R(h(p(c)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},Bre={};function kre(e,t){const a=C("router-view");return d(),_("div",null,[l(a)])}const xre=He(Bre,[["render",kre]]),Sre={},Fre={class:"fct-setting-form-row"},Ere={class:"w-[300px]"},Ure={class:"flex-grow flex-shrink flex-basis-0 self-center"},$re={class:"fct-setting-form-row"},Dre={class:"w-[300px]"},Qre={class:"flex-grow flex-shrink flex-basis-0 self-center"},Ire={class:"fct-setting-form-row"},Tre={class:"w-[300px]"},Vre={class:"flex-grow flex-shrink flex-basis-0 self-center"};function Mre(e,t){const a=C("el-skeleton-item"),n=C("el-skeleton");return d(),_("div",null,[r("div",Fre,[r("div",Ere,[l(n,{animated:"",class:"max-w-[70%]"},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"})]),_:1}),l(n,{animated:"",class:"max-w-[80%]"},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"}),l(a,{variant:"p",class:"w-1/2 h-4"})]),_:1})]),r("div",Ure,[l(n,{animated:""},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),r("div",$re,[r("div",Dre,[l(n,{animated:"",class:"max-w-[60%]"},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"})]),_:1}),l(n,{animated:"",class:"max-w-full"},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"})]),_:1})]),r("div",Qre,[l(n,{animated:""},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),r("div",Ire,[r("div",Tre,[l(n,{animated:"",class:"max-w-[50%]"},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"})]),_:1}),l(n,{animated:"",class:"max-w-full"},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"})]),_:1})]),r("div",Vre,[l(n,{animated:""},{template:i(()=>[l(a,{variant:"p",class:"w-full h-4"})]),_:1})])])])}const Lre=He(Sre,[["render",Mre]]),Rre={name:"TaxConfigurations",components:{TaxConfigurationsLoader:Lre,CardContainer:he,CardBody:me,CardHeader:Ce,LabelHint:sa,SettingsHeader:ha,AdminNotice:_a,Animation:ra},data(){return{settings:{enable_tax:"no",tax_inclusion:"included",tax_calculation_basis:"shipping",tax_rounding:"item",checkout_tax_breakdown_display:"both",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:c,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,Ie.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||{}},this.settings.checkout_tax_breakdown_display||(this.settings.checkout_tax_breakdown_display="both"),!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=ks(),this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.saveSettings()})},unbindSaveShortcut(){var e;(e=this.keyboardShortcuts)!=null&&e.unbind&&this.keyboardShortcuts.unbind("mod+s")}}},Ore={class:"setting-wrap"},Hre={class:"setting-wrap-inner"},Pre={class:"fct-setting-form-row"},Nre={class:"fct-setting-form-content flex gap-3.5 flex-1"},Kre={class:"fct-inline-tip"},Gre={key:1},jre={class:"fct-setting-form-row"},zre={class:"fct-setting-form-content"},Yre={class:"fct-inline-tip"},qre={class:"fct-setting-form-fields self-center"},Wre={class:"fct-inline-tip mt-2"},Xre={class:"fct-setting-form-row"},Jre={class:"fct-setting-form-content"},Zre={class:"fct-inline-tip"},eie={class:"fct-setting-form-fields self-center"},tie={class:"flex flex-col"},aie={class:"price-mode-label"},nie={class:"price-mode-text"},sie={class:"flex flex-col"},lie={class:"price-mode-label"},oie={class:"price-mode-text"},rie={class:"fct-setting-form-row"},iie={class:"fct-setting-form-content"},die={class:"fct-inline-tip"},uie={class:"fct-setting-form-fields self-center"},cie={class:"fct-setting-form-row"},Aie={class:"fct-setting-form-content"},pie={class:"fct-inline-tip"},fie={class:"fct-setting-form-fields self-center"},mie={class:"fct-setting-form-row"},hie={class:"fct-setting-form-content"},_ie={class:"fct-inline-tip"},gie={class:"fct-setting-form-fields self-center"},vie={class:"fct-setting-form-row"},yie={class:"fct-setting-form-content"},bie={class:"fct-inline-tip"},wie={class:"fct-setting-form-fields self-center"},Cie={class:"fct-setting-form-row"},Bie={class:"fct-setting-form-content"},kie={class:"fct-inline-tip"},xie={class:"fct-setting-form-fields"},Sie={class:"fct-vat-charge-setting-wrap grid gap-5 w-full"},Fie={class:"fct-local-reverse-charge flex gap-2 justify-items-start"},Eie={class:"fct-inline-tip"},Uie={class:"fct-vat-excluded-categories"},$ie={class:"fct-inline-tip"};function Die(e,t,a,n,s,o){const u=C("SettingsHeader"),A=C("AdminNotice"),f=C("el-switch"),m=C("LabelHint"),g=C("TaxConfigurationsLoader"),y=C("el-radio"),v=C("el-radio-group"),B=C("el-option"),b=C("el-select"),w=C("el-input"),k=C("Animation"),S=C("CardBody"),M=C("CardContainer"),$=Ca("loading");return d(),_("div",Ore,[l(u,{heading:o.translate("Tax Configuration"),loading:s.saving,"show-cmnd-icon":!0,onOnSave:o.saveSettings},null,8,["heading","loading","onOnSave"]),r("div",Hre,[l(A),l(M,null,{default:i(()=>[l(S,null,{default:i(()=>[r("div",Pre,[r("div",Nre,[l(f,{modelValue:s.settings.enable_tax,"onUpdate:modelValue":t[0]||(t[0]=F=>s.settings.enable_tax=F),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),r("div",null,[l(m,{title:o.translate("Enable Tax")},null,8,["title"]),r("p",Kre,h(s.settings.enable_tax==="yes"?o.translate("This store is now collecting tax."):o.translate("This store is not collecting tax.")),1)])])]),l(k,{visible:s.settings.enable_tax==="yes",accordion:""},{default:i(()=>[s.loading?(d(),E(g,{key:0})):x("",!0),s.loading?x("",!0):(d(),_("div",Gre,[r("div",jre,[r("div",zre,[l(m,{title:o.translate("Prices entered with tax")},null,8,["title"]),r("p",Yre,h(o.translate("Choose whether product prices are entered including or excluding tax.")),1)]),r("div",qre,[l(v,{modelValue:s.settings.tax_inclusion,"onUpdate:modelValue":t[1]||(t[1]=F=>s.settings.tax_inclusion=F)},{default:i(()=>[l(y,{value:"included"},{default:i(()=>[R(h(o.translate("Included")),1)]),_:1}),l(y,{value:"excluded"},{default:i(()=>[R(h(o.translate("Excluded")),1)]),_:1})]),_:1},8,["modelValue"]),r("p",Wre,h(o.translate("Shipping tax always follows the store-level tax mode (Included or Excluded). Product-specific tax settings do not apply to shipping.")),1)])]),r("div",Xre,[r("div",Jre,[l(m,{title:o.translate("Tax-Inclusive Price Mode")},null,8,["title"]),r("p",Zre,h(o.translate("Controls how reverse charge affects tax-inclusive product prices.")),1)]),r("div",eie,[l(v,{modelValue:s.settings.eu_vat_settings.reverse_charge_price_mode,"onUpdate:modelValue":t[2]||(t[2]=F=>s.settings.eu_vat_settings.reverse_charge_price_mode=F),class:"fct-reverse-charge-price-mode"},{default:i(()=>[l(y,{value:"fixed"},{default:i(()=>[r("div",tie,[r("span",aie,h(o.translate("Fixed")),1),r("span",nie,h(o.translate("Listed price stays unchanged on reverse charge. Only the tax line is zeroed on the invoice.")),1)])]),_:1}),l(y,{value:"dynamic"},{default:i(()=>[r("div",sie,[r("span",lie,h(o.translate("Dynamic")),1),r("span",oie,h(o.translate("VAT is stripped from the price on reverse charge. Customer pays the net (ex-VAT) amount.")),1)])]),_:1})]),_:1},8,["modelValue"])])]),r("div",rie,[r("div",iie,[l(m,{title:o.translate("Calculate Tax Based On")},null,8,["title"]),r("p",die,h(o.translate("Determine the location used for tax calculations.")),1)]),r("div",uie,[l(b,{modelValue:s.settings.tax_calculation_basis,"onUpdate:modelValue":t[3]||(t[3]=F=>s.settings.tax_calculation_basis=F),clearable:""},{default:i(()=>[l(B,{value:"shipping",label:o.translate("Customer Shipping Address")},null,8,["label"]),l(B,{value:"billing",label:o.translate("Customer Billing Address")},null,8,["label"]),l(B,{value:"store",label:o.translate("Store Location")},null,8,["label"])]),_:1},8,["modelValue"])])]),r("div",cie,[r("div",Aie,[l(m,{title:o.translate("Price Suffix (Tax Included)")},null,8,["title"]),r("p",pie,h(o.translate("Shown on prices where tax is included. Applies when product or store pricing is tax-inclusive.")),1)]),r("div",fie,[l(w,{modelValue:s.settings.price_suffix_included,"onUpdate:modelValue":t[4]||(t[4]=F=>s.settings.price_suffix_included=F),placeholder:o.translate("e.g. (incl. tax)")},null,8,["modelValue","placeholder"])])]),r("div",mie,[r("div",hie,[l(m,{title:o.translate("Price Suffix (Tax Excluded)")},null,8,["title"]),r("p",_ie,h(o.translate("Shown on prices where tax is excluded. Applies when product or store pricing is tax-exclusive.")),1)]),r("div",gie,[l(w,{modelValue:s.settings.price_suffix_excluded,"onUpdate:modelValue":t[5]||(t[5]=F=>s.settings.price_suffix_excluded=F),placeholder:o.translate("e.g. (+ tax)")},null,8,["modelValue","placeholder"])])]),r("div",vie,[r("div",yie,[l(m,{title:o.translate("Checkout Tax Breakdown Display")},null,8,["title"]),r("p",bie,h(o.translate("Choose how tax context appears on each checkout line item.")),1)]),r("div",wie,[l(b,{modelValue:s.settings.checkout_tax_breakdown_display,"onUpdate:modelValue":t[6]||(t[6]=F=>s.settings.checkout_tax_breakdown_display=F)},{default:i(()=>[l(B,{value:"both",label:o.translate("Item label and tooltip")},null,8,["label"]),l(B,{value:"label",label:o.translate("Item label only")},null,8,["label"]),l(B,{value:"tooltip",label:o.translate("Tooltip only")},null,8,["label"])]),_:1},8,["modelValue"])])]),r("div",Cie,[r("div",Bie,[l(m,{title:o.translate("VAT Reverse Charge Settings")},null,8,["title"]),r("p",kie,h(o.translate("Configure reverse VAT handling for customers in the European Union.")),1)]),r("div",xie,[r("div",Sie,[r("div",Fie,[l(f,{modelValue:s.settings.eu_vat_settings.local_reverse_charge,"onUpdate:modelValue":t[7]||(t[7]=F=>s.settings.eu_vat_settings.local_reverse_charge=F),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),r("div",null,[l(m,{title:o.translate("Local Reverse Charge")},null,8,["title"]),r("p",Eie,h(o.translate("If enabled, apply reverse charge when applicable even when customers are in your home country.")),1)])]),l(k,{visible:o.handlePriceMode,accordion:""},{default:i(()=>[r("div",Uie,[l(m,{title:o.translate("Exclude Categories from VAT reverse")},null,8,["title"]),r("p",$ie,h(o.translate("Select product categories that should NOT get VAT reverse charge !")),1),Dt((d(),E(b,{modelValue:s.settings.eu_vat_settings.vat_reverse_excluded_categories,"onUpdate:modelValue":t[8]||(t[8]=F=>s.settings.eu_vat_settings.vat_reverse_excluded_categories=F),filterable:"",multiple:"",clearable:"",placeholder:o.translate("Select Product Categories"),class:"w-full mt-4"},{default:i(()=>[(d(!0),_(H,null,ee(s.categories,F=>(d(),E(B,{key:F.value||F.term_id,label:F.label||F.name,value:F.value||F.term_id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])),[[$,s.fetchingCategories]])])]),_:1},8,["visible"])])])])]))]),_:1},8,["visible"])]),_:1})]),_:1})])])}const Qie=He(Rre,[["render",Die]]),Iie={class:"fct-tax-rates-wrap-loader px-5"},Tie={__name:"TaxRatesLoader",setup(e){const t=V(Array.from({length:6},()=>`${Math.floor(Math.random()*21)+120}px`));return(a,n)=>{const s=C("el-skeleton-item"),o=C("el-skeleton");return d(),_("div",Iie,[(d(!0),_(H,null,ee(t.value,(u,A)=>(d(),_("div",{key:A,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"},[l(o,{animated:"",style:ia({width:u}),class:"h-4"},{template:i(()=>[l(s,{variant:"p",class:"h-4"})]),_:2},1032,["style"]),l(o,{animated:"",class:"w-[100px] h-4"},{template:i(()=>[l(s,{variant:"p",class:"h-4"})]),_:1})]))),128))])}}},Vie={class:"setting-wrap"},Mie={class:"setting-wrap-inner"},Lie={class:"fct-all-tax-classes-page"},Rie={class:"flex items-center justify-end gap-4"},Oie={key:0,class:"px-6 py-4 border-b border-gray-200 dark:border-gray-700"},Hie={class:"inline-flex items-center gap-2"},Pie={class:"inline-flex items-center gap-2"},Nie=["src","alt"],Kie={key:0,class:"text-gray-400 dark:text-gray-300"},Gie={key:1,class:"text-success-500"},jie={key:2,class:"text-system-mid dark:text-gray-300"},zie={key:3,class:"text-gray-400 dark:text-gray-300"},Yie={key:1,class:"text-gray-400"},qie={__name:"TaxRates",setup(e){const t=V({}),a=V([]),n=V({}),s=V({}),o=j(()=>!!Ie.get("is_tax_enabled")),u=V(!1),A=V({}),f={};let m=0;const g=V(""),y=V(!1),v={XI:"gb"},B=D=>(v[D]||D).toLowerCase(),b=j(()=>{const D=new Set;for(const U of a.value)for(const I of U.countries||[])D.add(I.country_code);return D}),w=D=>!D||!Object.prototype.hasOwnProperty.call(s.value,D)?!0:s.value[D],k=D=>!D||!D.vat?!1:D.rates&&typeof D.rates=="object"&&Object.keys(D.rates).length?Object.values(D.rates).some(U=>U&&parseFloat(U.rate)>0):parseFloat(D.rate)>0,S=j(()=>{const D=n.value||{},U=Array.isArray(D.country_registrations)?D.country_registrations:[],I=D.method||"",O=U.some(k);if(I==="oss")return!!D.oss_country;if(I==="home"){const P=D.home_country||"",K=U.find(G=>G.country===P);if(P&&K&&k(K))return!0}return I==="specific"?!!D.home_country:O}),M=j(()=>{const D=n.value||{},U=Array.isArray(D.country_registrations)?D.country_registrations:[],I=D.method||"";return I==="oss"?!!D.oss_country:I==="home"?!!D.home_country&&U.some(O=>O.country===D.home_country):I==="specific"?!!D.home_country:U.some(k)}),$=j(()=>{const D=[],U=Object.values(t.value||{});for(const P of U)if(P.group_code==="EU")D.push({country_code:"EU",country_name:"European Union",isEU:!0,group_code:"EU",hasConfig:M.value,enabled:w("EU"),collecting:M.value&&S.value&&w("EU")});else for(const K of P.countries||[]){const G=b.value.has(K.country_code),ne=w(K.country_code);D.push({country_code:K.country_code,country_name:K.country_name,isEU:!1,group_code:P.group_code,hasConfig:G,enabled:ne,collecting:G&&ne})}const I=["EU","US","GB","AU","CA","NZ","IN","SG","JP"],O=new Set(I);return D.sort((P,K)=>{if(P.hasConfig!==K.hasConfig)return P.hasConfig?-1:1;const G=O.has(P.country_code),ne=O.has(K.country_code);return G&&ne?I.indexOf(P.country_code)-I.indexOf(K.country_code):G?-1:ne?1:P.country_name.localeCompare(K.country_name)}),D}),F=j(()=>{const D=g.value.trim().toLowerCase();return $.value.filter(U=>y.value&&(!o.value||!U.collecting)?!1:D?U.country_name.toLowerCase().includes(D)||U.country_code.toLowerCase().includes(D):!0)}),L=j(()=>{if(!o.value)return!1;const D=$.value.filter(I=>I.enabled).length,U=$.value.filter(I=>!I.enabled).length;return D>0&&U>0}),Q=()=>{u.value=!0,Promise.all([re.get("tax/configuration/rates"),re.get("tax/rates"),re.get("tax/configuration/settings")]).then(([D,U,I])=>{var O;t.value=D.tax_rates,a.value=U.tax_rates,s.value=U.country_enabled_map||{},n.value=((O=I.settings)==null?void 0:O.eu_vat_settings)||{}}).catch(D=>{}).finally(()=>{u.value=!1})},T=(D,U)=>{const I=w(D.country_code),O=++m;f[D.country_code]=O,s.value={...s.value,[D.country_code]:U},A.value={...A.value,[D.country_code]:!0},re.post("tax/country-status/"+D.country_code,{enabled:U?1:0}).then(P=>{f[D.country_code]===O&&(q.success(P.message),s.value={...s.value,[D.country_code]:P.enabled})}).catch(P=>{var K;f[D.country_code]===O&&(s.value={...s.value,[D.country_code]:I},q.error(((K=P==null?void 0:P.data)==null?void 0:K.message)||c("Failed to update tax status")))}).finally(()=>{if(f[D.country_code]===O){const P={...A.value};delete P[D.country_code],A.value=P}})};return Be(()=>{Q()}),(D,U)=>{const I=C("el-checkbox"),O=C("el-input"),P=C("el-table-column"),K=C("el-switch"),G=C("el-table");return d(),_("div",Vie,[l(ha,{heading:p(c)("Tax Regions"),"show-save-button":!1},null,8,["heading"]),r("div",Mie,[l(_a),r("div",Lie,[l(he,{class:"overflow-hidden"},{default:i(()=>[l(Ce,{title:p(c)("Tax Regions"),text:p(c)("Manage tax rates for different regions")},{action:i(()=>[r("div",Rie,[L.value?(d(),E(I,{key:0,modelValue:y.value,"onUpdate:modelValue":U[0]||(U[0]=ne=>y.value=ne)},{default:i(()=>[R(h(p(c)("Collecting Tax")),1)]),_:1},8,["modelValue"])):x("",!0),l(O,{modelValue:g.value,"onUpdate:modelValue":U[1]||(U[1]=ne=>g.value=ne),class:"w-[200px]",placeholder:p(c)("Search regions..."),size:"small",clearable:""},{prefix:i(()=>[l(W,{name:"Search",class:"w-4 h-4"})]),_:1},8,["modelValue","placeholder"])])]),_:1},8,["title","text"]),l(me,{class:"px-0 pb-0"},{default:i(()=>[!u.value&&!o.value?(d(),_("div",Oie,[l(Na,{type:"warning",icon:"AlertTriangle",content:p(c)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):x("",!0),u.value?(d(),E(Tie,{key:1})):(d(),E(G,{key:2,data:F.value,"max-height":"500",class:"w-full compact-table fct-tax-rates-regions-table"},{default:i(()=>[l(P,{label:p(c)("Region"),"min-width":"300"},{default:i(({row:ne})=>[ne.isEU?(d(),E(na,{key:0,class:"hover:no-underline",to:{name:"eu"}},{default:i(()=>[r("div",Hie,[U[2]||(U[2]=r("img",{class:"w-[22px] block",src:"https://flagcdn.com/w40/eu.png",alt:"EU"},null,-1)),R(" "+h(ne.country_name),1)])]),_:2},1024)):(d(),E(na,{key:1,to:{name:"tax-rates-country-single",params:{country:ne.country_code,group:ne.group_code}},class:"fct-tax-region-link hover:no-underline"},{default:i(()=>[r("div",Pie,[r("img",{class:"w-[22px] block",src:`https://flagcdn.com/w40/${B(ne.country_code)}.png`,alt:ne.country_code},null,8,Nie),R(" "+h(ne.country_name),1)])]),_:2},1032,["to"]))]),_:1},8,["label"]),l(P,{label:p(c)("Collecting"),width:"200"},{default:i(({row:ne})=>[o.value?ne.collecting?(d(),_("span",Gie,h(p(c)("Collecting tax")),1)):ne.hasConfig&&!ne.enabled?(d(),_("span",jie,h(p(c)("Disabled")),1)):(d(),_("span",zie,"—")):(d(),_("span",Kie,"—"))]),_:1},8,["label"]),l(P,{label:p(c)("Enabled"),width:"140",align:"center"},{default:i(({row:ne})=>[ne.hasConfig?(d(),E(K,{key:0,"model-value":o.value?ne.enabled:!1,loading:!!A.value[ne.country_code],disabled:!o.value,onChange:Y=>T(ne,Y)},null,8,["model-value","loading","disabled","onChange"])):(d(),_("span",Yie,"—"))]),_:1},8,["label"])]),_:1},8,["data"]))]),_:1})]),_:1})])])])}}},Wie={class:"fct-base-taxes"},Xie={class:"fct-tax-class-tabs"},Jie={class:"fct-tax-class-tabs__list"},Zie={class:"fct-base-taxes__header"},ede={class:"fct-base-taxes__header-label"},tde={class:"fct-base-taxes__state-row fct-base-taxes__state-row--federal"},ade={class:"fct-base-taxes__region-name fct-base-taxes__region-name--federal"},nde={class:"fct-base-taxes__state-fields"},sde={class:"fct-base-taxes__region-name"},lde={class:"fct-base-taxes__state-fields"},ode={__name:"CountryTaxRatesLoader",setup(e){const t=[1,2,3];return(a,n)=>{const s=C("el-skeleton-item"),o=C("el-skeleton");return d(),_("div",null,[r("div",Wie,[r("div",Xie,[r("div",Jie,[(d(),_(H,null,ee(3,u=>r("div",{key:u,class:"fct-tax-class-tabs__tab"},[l(o,{animated:""},{template:i(()=>[l(s,{variant:"text",class:"w-16 h-5"})]),_:1})])),64)),l(o,{animated:""},{template:i(()=>[l(s,{variant:"text",class:"w-5 h-5"})]),_:1})])]),r("div",Zie,[r("span",ede,h(p(c)("Regions")),1)]),r("div",tde,[r("div",ade,[l(o,{animated:""},{template:i(()=>[l(s,{variant:"text",class:"w-40 h-5"})]),_:1})]),r("div",nde,[l(o,{animated:""},{template:i(()=>[l(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),l(o,{animated:""},{template:i(()=>[l(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),n[0]||(n[0]=r("div",{class:"fct-base-taxes__field-compound"},null,-1))])]),n[1]||(n[1]=r("div",{class:"fct-base-taxes__divider"},null,-1)),(d(),_(H,null,ee(t,u=>r("div",{key:u,class:"fct-base-taxes__state-row"},[r("div",sde,[l(o,{animated:""},{template:i(()=>[l(s,{variant:"text",class:"w-32 h-4"})]),_:1})]),r("div",lde,[l(o,{animated:""},{template:i(()=>[l(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),l(o,{animated:""},{template:i(()=>[l(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),l(o,{animated:""},{template:i(()=>[l(s,{variant:"rect",class:"fct-base-taxes__field-compound h-8"})]),_:1})])])),64))])])}}},rde={class:"fct-tax-class-tabs"},ide={class:"fct-tax-class-tabs__list"},dde=["onClick"],ude=["title","onClick"],cde=["disabled"],Ade={class:"fct-tax-class-tabs__search"},ym={__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","update:search"],setup(e,{emit:t}){const a=e,n=t,s=j(()=>[...a.classes].sort((o,u)=>o.slug==="standard"&&u.slug!=="standard"?-1:o.slug!=="standard"&&u.slug==="standard"?1:0));return(o,u)=>{const A=C("el-dropdown-item"),f=C("el-dropdown-menu"),m=C("el-dropdown"),g=C("el-input");return d(),_("div",rde,[r("div",ide,[(d(!0),_(H,null,ee(s.value,y=>(d(),_("button",{key:y.id,class:de(["fct-tax-class-tabs__tab",{"fct-tax-class-tabs__tab--active":e.activeId==y.id}]),onClick:v=>n("switch",y)},[R(h(y.title)+" ",1),y.slug!=="standard"?(d(),_("span",{key:0,class:"fct-tax-class-tabs__delete",title:p(c)("Delete tax class"),onClick:Xe(v=>n("delete",y),["stop"])},[l(W,{name:"Close"})],8,ude)):x("",!0)],10,dde))),128)),e.classes.length
n("add",y)),"popper-class":"fct-dropdown"},{dropdown:i(()=>[l(f,null,{default:i(()=>[e.classes.find(y=>y.slug==="reduced")?x("",!0):(d(),E(A,{key:0,command:"reduced"},{default:i(()=>[R(h(p(c)("Reduced")),1)]),_:1})),e.classes.find(y=>y.slug==="zero")?x("",!0):(d(),E(A,{key:1,command:"zero"},{default:i(()=>[R(h(p(c)("Zero")),1)]),_:1})),l(A,{command:"custom"},{default:i(()=>[R(h(p(c)("Custom Class...")),1)]),_:1})]),_:1})]),default:i(()=>[r("button",{class:"fct-tax-class-tabs__add",disabled:e.creating},[l(W,{name:"Plus"})],8,cde)]),_:1},8,["disabled"])):x("",!0)]),r("div",Ade,[l(g,{"model-value":e.search,placeholder:p(c)("Search country or region…"),size:"small",clearable:"","onUpdate:modelValue":u[1]||(u[1]=y=>n("update:search",y)),onClear:u[2]||(u[2]=y=>n("update:search",""))},{prefix:i(()=>[l(W,{name:"Search",class:"w-3.5 h-3.5 text-system-light dark:text-gray-400"})]),_:1},8,["model-value","placeholder"]),oa(o.$slots,"search-actions")])])}}},pde=(e=[])=>e.find(t=>t.slug==="standard")||e[0]||null,Du=({classes:e=[],activeId:t=null})=>(t?e.find(n=>n.id===t):null)||pde(e),fde=({classes:e=[],previousIds:t=new Set,createdSlug:a=null})=>{if(a){const n=e.find(s=>s.slug===a);if(n)return n}return e.find(n=>!t.has(n.id))||null},Ur=async({payload:e,createdSlug:t=null,currentClasses:a=[],reloadClasses:n})=>{const s=new Set((a||[]).map(A=>A.id)),o=await re.post("tax/classes",e),u=await n();return{response:o,classes:u,createdClass:fde({classes:u,previousIds:s,createdSlug:t})}},bm=async({classId:e,currentActiveId:t=null,reloadClasses:a})=>{const n=await re.delete("tax/classes/"+e),s=await a();return{response:n,classes:s,nextActiveClass:Du({classes:s,activeId:t})}};function yl(e){return e==null||e===""?"":String(e)}const mde={class:"setting-wrap"},hde={class:"setting-wrap-inner"},_de={class:"fct-single-tax-rates-country-single-page"},gde={class:"fct-single-tax-rates-country-single"},vde={class:"single-page-header flex items-center justify-between"},yde={key:0,class:"flex items-center gap-2"},bde={key:0,class:"notices fct-notices-wrap fct-layout-width settings"},wde={class:"mt-3 flex justify-end"},Cde={key:1,class:"fct-base-taxes"},Bde={class:"fct-btn-group mt-4 justify-end sm"},kde={class:"fct-tax-rates-country-view"},xde={key:0},Sde={key:1},Fde={key:0},Ede={key:1},Ude={class:"fct-btn-group sm justify-end"},DA={__name:"TaxRatesCountrySingle",props:{country:{type:String},group:{type:String}},setup(e){const t=e,a=V(!1),n=V([]),s=V(""),o=j(()=>!!Ie.get("is_tax_enabled")),u=V([]),A=V(null),f=V("standard"),m=V(!1),g=V(null),y=V(6),v=V(!1),B=V(""),b=V({id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0}),w=V({rate:0,name:""}),k=V([]),S=V({}),M=V(""),$=j(()=>{const z=M.value.trim().toLowerCase();return z?k.value.filter(J=>J.stateName&&J.stateName.toLowerCase().includes(z)):k.value}),F=j(()=>t.group==="EU"),L=j(()=>[b.value,...$.value]),Q=V([]),T=V(!1),D=V([]),U=V([]),I=V(!1),O=V(new Set),P=V(0),K=V([]),G=V(!1),ne=V(!1),Y=V(!1),N=V({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:""}),oe=j(()=>{const z=b.value.rate||0;return[{label:c("added to")+` ${z}% `+c("federal tax"),is_compound:"0",for_order:0},{label:c("instead of")+` ${z}% `+c("federal tax"),is_compound:"0",for_order:1},{label:c("compounded on top of")+` ${z}% `+c("federal tax"),is_compound:"1",for_order:0}]}),Z=z=>String(z.is_compound)==="1"?"1_0":z.for_order==1?"0_1":"0_0",le=(z,J)=>{const[fe,Ue]=J.split("_");z.is_compound=fe,z.for_order=parseInt(Ue)},te=z=>z&&z.replace(/\s*\(Standard\)\s*/gi,"").trim(),X=V(!1),ie=V({}),be=V(!1),se=V(""),ce=V(""),pe=V(""),De=V(!1),$e=V(!1),Je=V(!0),we=V(!1),Ye=V(!1),ft=V(!1),Ge=j(()=>c("Toggle tax collection for %1$s",s.value||t.country)),_e=()=>re.get("tax/classes").then(z=>{u.value=z.classes||[],y.value=z.max_classes||6,g.value=z.next_builtin||null;const J=Du({classes:u.value,activeId:A.value});return J&&(A.value=J.id,f.value=J.slug),u.value}).catch(z=>u.value),xe=(z="")=>{if(!z)return b.value.name||"Tax";const J=k.value.find(fe=>fe.state===z);return J!=null&&J.name?J.name:b.value.name||"Tax"},Me=z=>{b.value={...z.federalRate},w.value={...z.federalOriginal},k.value=z.stateRows.map(J=>({...J})),S.value={...z.stateOriginals}},Fe=()=>({federalRate:{...b.value},federalOriginal:{...w.value},stateRows:k.value.map(z=>({...z})),stateOriginals:{...S.value}}),nt=()=>{A.value&&(ie.value[A.value]=Fe())},st=async z=>{nt(),A.value=z.id,f.value=z.slug,ie.value[z.id]?(Me(ie.value[z.id]),await ue()):await ve()},Ot=z=>{if(z==="custom"){B.value="",v.value=!0;return}m.value=!0,Ur({payload:{slug:z},createdSlug:z,currentClasses:u.value,reloadClasses:_e}).then(({response:J,createdClass:fe})=>{if(q.success(J.message),fe)return st(fe)}).catch(J=>{var fe;q.error(((fe=J==null?void 0:J.data)==null?void 0:fe.message)||"Failed to create tax class")}).finally(()=>{m.value=!1})},Ct=()=>{if(!B.value.trim()){q.error(c("Please enter a class name"));return}m.value=!0,Ur({payload:{title:B.value.trim()},currentClasses:u.value,reloadClasses:_e}).then(({response:z,createdClass:J})=>{if(q.success(z.message),v.value=!1,J)return st(J)}).catch(z=>{var J;q.error(((J=z==null?void 0:z.data)==null?void 0:J.message)||"Failed to create tax class")}).finally(()=>{m.value=!1})},yt=z=>{const J=A.value===z.id;en(c("All rates for this class will be deleted. Products using it will default to Standard."),c("Delete")+" "+z.title+"?",{confirmButtonText:c("Yes, Delete"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{bm({classId:z.id,currentActiveId:A.value,reloadClasses:_e}).then(({response:fe,nextActiveClass:Ue})=>{if(delete ie.value[z.id],q.success(fe.message),Ue)return J&&(A.value=null),st(Ue)}).catch(fe=>{var Ue;q.error(((Ue=fe==null?void 0:fe.data)==null?void 0:Ue.message)||"Failed to delete tax class")})}).catch(()=>{})},Ze=()=>re.get("address-info/get-country-info",{country_code:t.country}).then(z=>{n.value=z.states||[],s.value=z.country_name||t.country}).catch(z=>{q.error(c("Failed to load country data. Please refresh the page."))}),Bt=()=>F.value?(ce.value="",pe.value="",Promise.resolve()):(De.value=!0,re.get("tax/country-tax-id/"+t.country).then(z=>{var fe;const J=((fe=z==null?void 0:z.tax_data)==null?void 0:fe.tax_id)||"";ce.value=J,pe.value=J}).catch(z=>{var J;q.error(((J=z==null?void 0:z.data)==null?void 0:J.message)||c("Failed to load tax ID"))}).finally(()=>{De.value=!1})),ht=({hydrateClassData:z=!0}={})=>re.get("tax/rates/country/rates/"+t.country).then(J=>{const fe=J.tax_rates||[],Ue=fe.filter(Le=>Le.for_shipping!==null),je=A.value?fe.filter(Le=>Number(Le.class_id)===Number(A.value)):fe;D.value=je.filter(Le=>!Le.city&&!Le.postcode).map(Le=>({name:Le.name,value:Le.id,state:Le.state||""}));const et=da(je);return ft.value=fe.length>0,z&&(Me(et),nt(),Je.value=!!J.tax_enabled,Ye.value=!0),{allRates:fe,shippingOverrides:Ue,classEntry:et}}).catch(J=>(q.error(c("Failed to load tax rates. Please refresh the page.")),{allRates:[],shippingOverrides:[],classEntry:null})),Ft=()=>re.get("tax/product-overrides/"+t.country).then(z=>z.overrides||[]).catch(()=>[]),kt=()=>{K.value.length>0||(G.value=!0,re.get("products/fetch-term").then(z=>{const J=z.taxonomies&&z.taxonomies["product-categories"]?z.taxonomies["product-categories"].terms||[]:[];K.value=J.map(fe=>({...fe,value:yl(fe.value)}))}).catch(()=>{}).finally(()=>{G.value=!1}))};let xt=0;const Ht=z=>{const J=++xt;return!z||Number(z)===Number(A.value)?(U.value=D.value.slice(),I.value=!1,Promise.resolve()):(I.value=!0,U.value=[],re.get("tax/rates/country/rates/"+t.country,{class_id:z}).then(fe=>{if(J!==xt)return;const Ue=fe.tax_rates||[];U.value=Ue.filter(je=>!je.city&&!je.postcode).map(je=>({name:je.name,value:je.id,state:je.state||""}))}).catch(()=>{J===xt&&(U.value=[],q.error(c("Failed to load tax rates for the selected tax class")))}).finally(()=>{J===xt&&(I.value=!1)}))},pt=(z,J)=>{var Ue,je;const fe=[];for(const et of z){const Le=et.state?((Ue=n.value.find(tt=>tt.value===et.state))==null?void 0:Ue.name)||et.state:s.value||t.country,qe=xe(et.state||""),Et=u.value.find(tt=>Number(tt.id)===Number(et.class_id));fe.push({id:et.id,type:"shipping",label:qe,tax_label:qe,category_name:"",location:Le,city:et.city||"",postcode:et.postcode||"",rate:et.for_shipping,class_id:Number(et.class_id)||0,class_label:Et?Et.title:"",_raw:et})}for(const et of J){const Le=et.meta_value||et,qe=Le.state||"",Et=qe?((je=n.value.find(ua=>ua.value===qe))==null?void 0:je.name)||qe:s.value||t.country,tt=Number(et.class_id)||0,bt=tt?u.value.find(ua=>Number(ua.id)===tt):null;fe.push({id:et.id,type:"products",label:Le.category_name||"",tax_label:Le.tax_label||"",category_name:Le.category_name||"",location:Et,city:Le.city||"",postcode:Le.postcode||"",rate:Le.rate,class_id:tt,class_label:bt?bt.title:"",_raw:et})}Q.value=fe},da=z=>{const J=tt=>(!tt.state||tt.state==="")&&(!tt.city||tt.city==="")&&(!tt.postcode||tt.postcode===""),fe=z.find(J),Ue=z.filter(tt=>tt.state&&tt.state!==""&&(!tt.city||tt.city==="")&&(!tt.postcode||tt.postcode===""));let je,et;if(fe){const tt=te(fe.name)||"Tax";je={...fe,name:tt},et={rate:fe.rate,name:tt}}else je={id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0},et={rate:0,name:"Tax"};const Le={};for(const tt of Ue)Le[tt.state]=tt;const qe=[],Et={};for(const tt of n.value){const bt=Le[tt.value];if(bt){const ua=te(bt.name)||"State Tax";qe.push({id:bt.id,state:tt.value,stateName:tt.name,rate:bt.rate,name:ua,is_compound:String(bt.is_compound||"0"),for_order:bt.for_order||0}),Et[tt.value]={rate:bt.rate,name:ua,is_compound:String(bt.is_compound||"0"),for_order:bt.for_order||0}}else qe.push({id:null,state:tt.value,stateName:tt.name,rate:0,name:"State Tax",is_compound:"0",for_order:0}),Et[tt.value]={rate:0,name:"State Tax",is_compound:"0",for_order:0}}return{federalRate:je,federalOriginal:et,stateRows:qe,stateOriginals:Et}},ue=async()=>{const[{shippingOverrides:z},J]=await Promise.all([ht({hydrateClassData:!1}),Ft()]);pt(z,J)},ve=async()=>{a.value=!0;try{const[{shippingOverrides:z},J]=await Promise.all([ht(),Ft()]);pt(z,J)}finally{a.value=!1}},We=async()=>{a.value=!0;try{await Promise.all([_e(),Ze(),Bt()]),await ve()}finally{a.value=!1}},_t=()=>{F.value||$e.value||De.value||($e.value=!0,re.post("tax/country-tax-id/"+t.country,{tax_id:ce.value||""}).then(z=>{pe.value=ce.value||"",q.success(z.message||c("Tax ID has been saved successfully"))}).catch(z=>{var J;q.error(((J=z==null?void 0:z.data)==null?void 0:J.message)||c("Failed to save tax ID"))}).finally(()=>{$e.value=!1}))},rt=z=>{if(we.value)return;const J=Je.value;Je.value=z,we.value=!0,re.post("tax/country-status/"+t.country,{enabled:z?1:0}).then(fe=>{Je.value=fe.enabled,q.success(fe.message)}).catch(fe=>{var Ue;Je.value=J,q.error(((Ue=fe==null?void 0:fe.data)==null?void 0:Ue.message)||c("Failed to update tax status"))}).finally(()=>{we.value=!1})},Wt=async()=>{try{await en(c("This will overwrite your current rates with preset defaults. Continue?"),c("Reset to default tax rates"),{confirmButtonText:c("Reset"),cancelButtonText:c("Cancel"),type:"warning"})}catch{return}be.value=!0;try{const J=(await re.get("tax/configuration/rates")).tax_rates||{};let fe=[];for(const qe in J){const Et=J[qe];for(const tt of Et.countries||[])if(tt.country_code===t.country){fe=tt.rates||[];break}if(fe.length)break}if(!fe.length){q.error(c("No preset rates found for this country"));return}const Ue=fe.find(qe=>(!qe.state||qe.state==="")&&qe.type==="standard"),je=fe.filter(qe=>qe.state&&qe.state!==""&&qe.type==="standard"),et=[];Ue&&Ue.rate>0&&(b.value.rate=Ue.rate,b.value.name=te(Ue.name||"")||c("Tax"),et.push(lt()));const Le=[];for(const qe of je){const Et=k.value.find(tt=>tt.state===qe.state);Et&&(Et.rate=qe.rate,Et.name=te(qe.name)||c("State Tax"),Et.is_compound=qe.compound?"1":"0",Le.push(ga(Et)))}await Promise.all([...et,...Le]),nt(),await ue(),q.success(c("Tax rates have been reset to defaults"))}catch{q.error(c("Failed to reset tax rates"))}finally{be.value=!1}},lt=()=>{const z={country:t.country,state:"",rate:b.value.rate,name:b.value.name||"Tax",is_compound:b.value.is_compound||"0",for_order:b.value.for_order||0,group:t.group,class_id:A.value||""};return(b.value.id?re.put("tax/country/rate/"+b.value.id,z):re.post("tax/country/rate",z)).then(fe=>{fe.tax_rate&&(b.value.id=fe.tax_rate.id),w.value={rate:b.value.rate,name:b.value.name}})},ga=z=>{const J={country:t.country,state:z.state,rate:z.rate,name:z.name,is_compound:z.is_compound,for_order:z.for_order,group:t.group,class_id:A.value||""};return(z.id?re.put("tax/country/rate/"+z.id,J):re.post("tax/country/rate",J)).then(Ue=>{Ue.tax_rate&&(z.id=Ue.tax_rate.id),S.value[z.state]={rate:z.rate,name:z.name,is_compound:String(z.is_compound),for_order:z.for_order}})},va=async()=>{X.value=!0;try{const z=[];(String(b.value.rate)!==String(w.value.rate)||b.value.name!==w.value.name)&&z.push(lt());for(const fe of k.value){const Ue=S.value[fe.state];(!Ue||String(fe.rate)!==String(Ue.rate)||fe.name!==Ue.name||String(fe.is_compound)!==String(Ue.is_compound)||fe.for_order!=Ue.for_order)&&z.push(ga(fe))}await Promise.all(z),nt(),await ue(),q.success(c("Tax rates saved"))}catch{q.error(c("Failed to save rates"))}finally{X.value=!1}},Da=()=>{O.value=new Set,P.value=0},Sn=()=>{const z=xe();Y.value=!1,N.value={type:"products",original_type:"",original_id:"",category_id:"",category_name:"",state:"__country__",city:"",postcode:"",tax_label:z,tax_rate:0,override_state_tax:!0,class_id:Number(A.value)||0,id:"",previous_id:""},se.value=z,U.value=D.value.slice(),T.value=!0,kt()},Tn=z=>{if(Y.value=!0,kt(),z.type==="shipping"){const J=z._raw.state||"",fe=xe(J),Ue=Number(z._raw.class_id)||Number(A.value)||0;N.value={type:"shipping",original_type:"shipping",original_id:z.id,category_id:"",category_name:"",state:J||"__country__",city:z._raw.city||"",postcode:z._raw.postcode||"",tax_label:fe,tax_rate:z.rate,override_state_tax:!0,class_id:Ue,id:z.id,previous_id:z.id},se.value=fe,P.value=Ue,Ht(Ue);const je=z._raw.city||"",et=z._raw.postcode||"",Le=new Set;for(const qe of Q.value)qe.type==="shipping"&&(qe._raw.state||"")===J&&(qe._raw.city||"")===je&&(qe._raw.postcode||"")===et&&Le.add(Number(qe.class_id));O.value=Le}else{const J=z._raw.meta_value||z._raw,fe=J.state||"",Ue=xe(fe),je=z.tax_label||Ue;N.value={type:"products",original_type:"products",original_id:z.id,category_id:yl(J.category_id),category_name:z.category_name,state:fe||"__country__",tax_label:je,tax_rate:z.rate,override_state_tax:J.override_state_tax==="yes",city:J.city||"",postcode:J.postcode||"",class_id:z.class_id||0,id:z.id,previous_id:""},se.value=Ue}T.value=!0},Fs=j(()=>{const z=[{label:s.value||t.country,value:"__country__"}];for(const J of n.value)z.push({label:J.name,value:J.value});return z}),El=j(()=>{if(!U.value.length)return Fs.value;const z=new Set(U.value.map(J=>J.state||""));return Fs.value.filter(J=>{const fe=J.value==="__country__"?"":J.value;return z.has(fe)})}),mn=z=>{const J=yl(z),fe=K.value.find(Ue=>Ue.value===J);fe&&(N.value.category_name=fe.label)},Ae=z=>{en(c("Are you sure you want to delete this override?"),c("Confirm Delete"),{confirmButtonText:c("Yes, Delete"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{const J=z.type==="shipping"?"tax/rates/country/override/"+z.id:"tax/product-overrides/"+z.id;re.delete(J).then(fe=>{q.success(fe.message),Q.value=Q.value.filter(Ue=>!(Ue.id===z.id&&Ue.type===z.type))}).catch(fe=>{var Ue;q.error(((Ue=fe==null?void 0:fe.data)==null?void 0:Ue.message)||c("Failed to delete override"))})}).catch(()=>{})},Ws=async()=>{var J;const z=N.value.state==="__country__"?"":N.value.state;if(N.value.type==="products"&&!N.value.category_id){q.error(c("Please select a category"));return}if(N.value.type==="shipping"){if(!N.value.class_id){q.error(c("Please select a tax class"));return}if(I.value){q.error(c("Please wait for the province rates to finish loading"));return}const fe=U.value.find(Ue=>(Ue.state||"")===z);N.value.id=fe?fe.value:0}ne.value=!0;try{let fe;if(N.value.type==="products"){const Ue=N.value.state==="__country__"?"":N.value.state;fe=await re.post("tax/product-overrides",{id:Y.value&&N.value.original_type==="products"?N.value.original_id:"",source_type:N.value.original_type,source_id:N.value.original_id,country:t.country,state:Ue,category_id:N.value.category_id,category_name:N.value.category_name,tax_label:N.value.tax_label,rate:N.value.tax_rate,override_state_tax:N.value.override_state_tax===!0?"yes":"no",city:N.value.city||"",postcode:N.value.postcode||"",class_id:N.value.class_id||0})}else fe=await re.post("tax/rates/country/override",{id:N.value.id,country:t.country,state:z,previous_id:Y.value&&N.value.original_type==="shipping"?N.value.previous_id:"",source_type:N.value.original_type,source_id:N.value.original_id,class_id:N.value.class_id||A.value||"",override_tax_rate:N.value.tax_rate,city:N.value.city||"",postcode:N.value.postcode||""});q.success(fe.message),T.value=!1,await ue()}catch(fe){const Ue=((J=fe==null?void 0:fe.data)==null?void 0:J.message)||(fe==null?void 0:fe.message)||"Failed to save override";q.error(Ue)}finally{ne.value=!1}};return ge(()=>N.value.type,z=>{z==="shipping"&&(N.value.class_id||(N.value.class_id=A.value||0),Ht(N.value.class_id))}),ge(()=>N.value.class_id,z=>{N.value.type!=="shipping"||!T.value||Ht(z).then(()=>{const J=N.value.state==="__country__"?"":N.value.state,fe=U.value.map(Ue=>Ue.state||"");J!==""&&!fe.includes(J)&&(N.value.state="__country__")})}),ge(()=>N.value.state,z=>{if(!T.value||N.value.type!=="products"||Y.value)return;const J=xe(z==="__country__"?"":z);(!N.value.tax_label||N.value.tax_label===se.value)&&(N.value.tax_label=J),se.value=J}),Be(()=>{We()}),(z,J)=>{const fe=C("el-breadcrumb-item"),Ue=C("el-breadcrumb"),je=C("el-switch"),et=C("el-skeleton"),Le=C("el-input"),qe=C("el-form-item"),Et=C("el-form"),tt=C("el-button"),bt=C("el-table-column"),ua=C("el-option"),Fn=C("el-select"),Es=C("el-table"),ae=C("el-tag"),it=C("el-radio"),Ba=C("el-radio-group"),nn=C("el-checkbox"),Ut=C("el-dialog");return d(),_("div",mde,[r("div",hde,[r("div",_de,[r("div",gde,[r("div",vde,[l(Ue,{class:"mb-0","separator-icon":p(tn)},{default:i(()=>[e.group==="EU"?(d(),E(fe,{key:0,to:{name:"eu"}},{default:i(()=>[R(h(p(c)("Tax Regions")),1)]),_:1})):(d(),E(fe,{key:1,to:{name:"tax_rates"}},{default:i(()=>[R(h(p(c)("Tax Regions")),1)]),_:1})),l(fe,null,{default:i(()=>[R(h(s.value||e.country),1)]),_:1})]),_:1},8,["separator-icon"]),Ye.value&&ft.value?(d(),_("div",yde,[o.value?(d(),_("span",{key:0,class:de(["text-sm",Je.value?"text-success-500":"text-system-mid dark:text-gray-300"])},h(Je.value?p(c)("Collecting tax"):p(c)("Disabled")),3)):x("",!0),l(je,{"model-value":o.value?Je.value:!1,loading:we.value,disabled:!o.value,"aria-label":Ge.value,onChange:rt},null,8,["model-value","loading","disabled","aria-label"])])):x("",!0)]),!a.value&&!o.value?(d(),_("div",bde,[l(Na,{type:"warning",icon:"AlertTriangle",content:p(c)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):x("",!0),F.value?x("",!0):(d(),E(he,{key:1},{default:i(()=>[l(me,null,{default:i(()=>[De.value?(d(),E(et,{key:0,animated:"",rows:2})):(d(),E(Et,{key:1,"label-position":"top"},{default:i(()=>[l(qe,{label:p(c)("VAT/GST/Tax Number"),class:"mb-0"},{default:i(()=>[l(Le,{modelValue:ce.value,"onUpdate:modelValue":J[0]||(J[0]=Se=>ce.value=Se),placeholder:p(c)("VAT/GST/Tax Number"),maxlength:"255"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})),r("div",wde,[l(tt,{type:"primary",size:"small",loading:$e.value,disabled:De.value||$e.value||ce.value===pe.value,onClick:_t},{default:i(()=>[R(h(p(c)("Save")),1)]),_:1},8,["loading","disabled"])])]),_:1})]),_:1})),l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Base taxes")},null,8,["title"]),l(me,null,{default:i(()=>[l(Na,{type:"info"},{content:i(()=>[r("span",null,h(p(c)("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"))+" + "+h(p(c)("button to add tax classes.")),1)]),_:1}),a.value?(d(),E(ode,{key:0})):(d(),_("div",Cde,[l(ym,{classes:u.value,"active-id":A.value,"max-classes":y.value,creating:m.value,search:M.value,onSwitch:st,onDelete:yt,onAdd:Ot,"onUpdate:search":J[1]||(J[1]=Se=>M.value=Se)},null,8,["classes","active-id","max-classes","creating","search"]),l(Es,{data:L.value,class:"w-full fct-tax-rates-table","max-height":"450"},{default:i(()=>[l(bt,{label:p(c)("Region")},{default:i(({row:Se})=>[r("span",{class:de(["fct-base-taxes__region-name",Se.state?"":"fct-base-taxes__region-name--federal"])},h(Se.state?Se.stateName:s.value||e.country),3)]),_:1},8,["label"]),l(bt,{label:p(c)("Rate"),width:"130"},{default:i(({row:Se})=>[l(Le,{modelValue:Se.rate,"onUpdate:modelValue":Vn=>Se.rate=Vn,size:"small",type:"number",step:"0.01",min:"0"},{suffix:i(()=>J[21]||(J[21]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),l(bt,{label:p(c)("Tax Label"),width:"200"},{default:i(({row:Se})=>[l(Le,{modelValue:Se.name,"onUpdate:modelValue":Vn=>Se.name=Vn,size:"small",placeholder:p(c)("Tax name")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),_:1},8,["label"]),k.value.length>0?(d(),E(bt,{key:0,label:p(c)("Compound"),width:"310"},{default:i(({row:Se})=>[Se.state?(d(),E(Fn,{key:0,"model-value":Z(Se),size:"small",style:{width:"100%"},onChange:Vn=>le(Se,Vn)},{default:i(()=>[l(ua,{value:"0_0",label:oe.value[0].label},null,8,["label"]),l(ua,{value:"0_1",label:oe.value[1].label},null,8,["label"]),l(ua,{value:"1_0",label:oe.value[2].label},null,8,["label"])]),_:2},1032,["model-value","onChange"])):x("",!0)]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"]),r("div",Bde,[f.value==="standard"?(d(),E(tt,{key:0,loading:be.value,size:"small",onClick:Wt,type:"danger",soft:""},{default:i(()=>[R(h(p(c)("Reset to default")),1)]),_:1},8,["loading"])):x("",!0),l(tt,{type:"primary",size:"small",loading:X.value,onClick:va},{default:i(()=>[R(h(p(c)("Save Rates")),1)]),_:1},8,["loading"])])]))]),_:1})]),_:1}),l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Tax overrides"),text:p(c)("Override tax rates for specific product categories or shipping.")},{action:i(()=>[l(tt,{size:"small",onClick:Sn},{default:i(()=>[R(h(p(c)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),l(me,null,{default:i(()=>[r("div",kde,[l(Es,{data:Q.value,"empty-text":p(c)("No overrides configured")},{default:i(()=>[l(bt,{label:p(c)("Type"),width:"110"},{default:i(({row:Se})=>[l(ae,{type:Se.type==="products"?"primary":"info",size:"small"},{default:i(()=>[R(h(Se.type==="products"?p(c)("Product"):p(c)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),l(bt,{label:p(c)("Category")},{default:i(({row:Se})=>[R(h(Se.category_name||"—"),1)]),_:1},8,["label"]),l(bt,{label:p(c)("Tax Label")},{default:i(({row:Se})=>[R(h(Se.tax_label||"—"),1)]),_:1},8,["label"]),l(bt,{label:p(c)("Location")},{default:i(({row:Se})=>[R(h(Se.location),1)]),_:1},8,["label"]),l(bt,{label:p(c)("Tax Class"),width:"130"},{default:i(({row:Se})=>[Se.type==="products"?(d(),_("span",xde,h(Se.class_label||p(c)("All")),1)):(d(),_("span",Sde,h(Se.class_label||"—"),1))]),_:1},8,["label"]),l(bt,{label:p(c)("City / Postcode")},{default:i(({row:Se})=>[Se.city||Se.postcode?(d(),_("span",Fde,h([Se.city,Se.postcode].filter(Boolean).join(" / ")),1)):(d(),_("span",Ede,"—"))]),_:1},8,["label"]),l(bt,{label:p(c)("Rate"),width:"100"},{default:i(({row:Se})=>[R(h(Se.rate)+"% ",1)]),_:1},8,["label"]),l(bt,{label:p(c)("Actions"),width:"110",align:"right"},{default:i(({row:Se})=>[r("div",Ude,[l(Oe,{tag:"button",size:"small",onClick:Vn=>Tn(Se)},{default:i(()=>[l(W,{name:"Edit"})]),_:2},1032,["onClick"]),l(Oe,{tag:"button",size:"small",onClick:Vn=>Ae(Se),bg:"danger",outline:""},{default:i(()=>[l(W,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"])])]),_:1})]),_:1}),l(Ut,{modelValue:T.value,"onUpdate:modelValue":J[17]||(J[17]=Se=>T.value=Se),title:(Y.value?p(c)("Edit tax override for"):p(c)("Add tax override for"))+" "+(s.value||e.country),width:"520px","append-to-body":!0,onClose:Da},{footer:i(()=>[l(tt,{onClick:J[16]||(J[16]=Se=>T.value=!1)},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(tt,{type:"primary",loading:ne.value,onClick:Ws},{default:i(()=>[R(h(Y.value?p(c)("Save changes"):p(c)("Add override")),1)]),_:1},8,["loading"])]),default:i(()=>[l(Et,{"label-position":"top",model:N.value},{default:i(()=>[l(qe,{label:p(c)("Override type")},{default:i(()=>[l(Ba,{modelValue:N.value.type,"onUpdate:modelValue":J[2]||(J[2]=Se=>N.value.type=Se)},{default:i(()=>[l(it,{value:"products"},{default:i(()=>[R(h(p(c)("Products")),1)]),_:1}),l(it,{value:"shipping"},{default:i(()=>[R(h(p(c)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),N.value.type==="products"?(d(),_(H,{key:0},[l(qe,{label:p(c)("Category")},{default:i(()=>[l(Fn,{modelValue:N.value.category_id,"onUpdate:modelValue":J[3]||(J[3]=Se=>N.value.category_id=Se),filterable:"",placeholder:p(c)("Select a category"),loading:G.value,style:{width:"100%"},onChange:mn},{default:i(()=>[(d(!0),_(H,null,ee(K.value,Se=>(d(),E(ua,{key:Se.value,label:Se.label,value:Se.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),l(qe,{label:p(c)("Tax Class")},{default:i(()=>[l(Fn,{modelValue:N.value.class_id,"onUpdate:modelValue":J[4]||(J[4]=Se=>N.value.class_id=Se),style:{width:"100%"}},{default:i(()=>[l(ua,{value:0,label:p(c)("All Tax Classes")},null,8,["label"]),(d(!0),_(H,null,ee(u.value,Se=>(d(),E(ua,{key:Se.id,value:Number(Se.id),label:Se.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"]),l(qe,{label:p(c)("Tax label")},{default:i(()=>[l(Le,{modelValue:N.value.tax_label,"onUpdate:modelValue":J[5]||(J[5]=Se=>N.value.tax_label=Se),placeholder:p(c)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(qe,{label:p(c)("Location")},{default:i(()=>[l(Fn,{modelValue:N.value.state,"onUpdate:modelValue":J[6]||(J[6]=Se=>N.value.state=Se),placeholder:p(c)("Select location"),filterable:"",style:{width:"100%"}},{default:i(()=>[(d(!0),_(H,null,ee(Fs.value,Se=>(d(),E(ua,{key:Se.value,label:Se.label,value:Se.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),l(qe,{label:p(c)("City (optional)")},{default:i(()=>[l(Le,{modelValue:N.value.city,"onUpdate:modelValue":J[7]||(J[7]=Se=>N.value.city=Se),placeholder:p(c)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(qe,{label:p(c)("Postcode (optional)")},{default:i(()=>[l(Le,{modelValue:N.value.postcode,"onUpdate:modelValue":J[8]||(J[8]=Se=>N.value.postcode=Se),placeholder:p(c)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(qe,{label:p(c)("Tax rate (%)")},{default:i(()=>[l(Le,{modelValue:N.value.tax_rate,"onUpdate:modelValue":J[9]||(J[9]=Se=>N.value.tax_rate=Se),type:"number",step:"0.01",min:"0",placeholder:p(c)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),k.value.length>0?(d(),E(qe,{key:0},{default:i(()=>[l(nn,{modelValue:N.value.override_state_tax,"onUpdate:modelValue":J[10]||(J[10]=Se=>N.value.override_state_tax=Se)},{default:i(()=>[R(h(p(c)("Also override state/provincial taxes")),1)]),_:1},8,["modelValue"])]),_:1})):x("",!0)],64)):(d(),_(H,{key:1},[l(qe,{label:p(c)("Tax Class")},{default:i(()=>[l(Fn,{modelValue:N.value.class_id,"onUpdate:modelValue":J[11]||(J[11]=Se=>N.value.class_id=Se),style:{width:"100%"},loading:I.value},{default:i(()=>[(d(!0),_(H,null,ee(u.value,Se=>(d(),E(ua,{key:Se.id,value:Number(Se.id),label:Se.title,disabled:Y.value&&Number(Se.id)!==Number(P.value)&&O.value.has(Number(Se.id))},null,8,["value","label","disabled"]))),128))]),_:1},8,["modelValue","loading"])]),_:1},8,["label"]),l(qe,{label:p(c)("Location")},{default:i(()=>[l(Fn,{modelValue:N.value.state,"onUpdate:modelValue":J[12]||(J[12]=Se=>N.value.state=Se),placeholder:p(c)("Select location"),filterable:"",style:{width:"100%"}},{default:i(()=>[(d(!0),_(H,null,ee(El.value,Se=>(d(),E(ua,{key:Se.value,label:Se.label,value:Se.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),l(qe,{label:p(c)("City (optional)")},{default:i(()=>[l(Le,{modelValue:N.value.city,"onUpdate:modelValue":J[13]||(J[13]=Se=>N.value.city=Se),placeholder:p(c)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(qe,{label:p(c)("Postcode (optional)")},{default:i(()=>[l(Le,{modelValue:N.value.postcode,"onUpdate:modelValue":J[14]||(J[14]=Se=>N.value.postcode=Se),placeholder:p(c)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(qe,{label:p(c)("Tax rate (%)")},{default:i(()=>[l(Le,{modelValue:N.value.tax_rate,"onUpdate:modelValue":J[15]||(J[15]=Se=>N.value.tax_rate=Se),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["modelValue","title"])]),l(Ut,{modelValue:v.value,"onUpdate:modelValue":J[20]||(J[20]=Se=>v.value=Se),title:p(c)("Create Custom Tax Class"),"append-to-body":!0},{footer:i(()=>[l(tt,{onClick:J[19]||(J[19]=Se=>v.value=!1)},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(tt,{type:"primary",loading:m.value,onClick:Ct},{default:i(()=>[R(h(p(c)("Create")),1)]),_:1},8,["loading"])]),default:i(()=>[l(Et,{onSubmit:Xe(Ct,["prevent"]),"label-position":"top"},{default:i(()=>[l(qe,{label:p(c)("Class Name")},{default:i(()=>[l(Le,{modelValue:B.value,"onUpdate:modelValue":J[18]||(J[18]=Se=>B.value=Se),placeholder:p(c)("e.g. Super Reduced, Luxury"),maxlength:"30"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"])])])])}}};class $de extends Gs{getTabs(){return{all:c("All"),filed:c("Filed"),not_filed:c("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"}]}getSortableColumns(){return[{label:c("ID"),value:"id"},{label:c("Tax Country"),value:"country"}]}getSearchHint(){return c("Search by id, title, content or module.")}getFetchUrl(){return"taxes"}parseResponse(t){return t.taxes}getTableName(){return"taxes_table"}with(){return["tax_rate","order:id,currency"]}scopes(){return["validOrder"]}}function Dde(e){return $de.init(e)}const Qde=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase()),Ide=e=>{const t=Object.keys(e[0]),n=[t.map(Qde).join(",")];return e.forEach(s=>{const o=t.map(u=>{let A=s[u];return typeof A=="object"&&(A=JSON.stringify(A)),typeof A=="string"&&(A=`"${A.replace(/"/g,'""')}"`),A});n.push(o.join(","))}),n.join(`
`)},Tde=(e,t="export.csv")=>new Promise((a,n)=>{try{if(!e||!e.length)throw new Error("No data to export");const s=Ide(e),o=new Blob([s],{type:"text/csv"}),u=document.createElement("a"),A=()=>{window.removeEventListener("focus",A),a()};window.addEventListener("focus",A),u.href=URL.createObjectURL(o),u.download=t,u.click(),URL.revokeObjectURL(u.href),setTimeout(()=>{a()},200)}catch(s){n(s)}}),Vde={class:"table-cell"},Mde={class:"table-cell"},Lde={class:"table-cell"},Rde={class:"table-cell"},Ode={class:"table-cell"},Hde={class:"table-cell"},Pde={class:"table-cell"},Nde={class:"table-cell"},Kde={class:"table-cell"},Gde={__name:"TaxesLoader",props:{nextPageCount:{type:Number,default:0},taxTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(n,s)=>s+1);return(n,s)=>{const o=C("el-table-column"),u=C("el-skeleton-item"),A=C("el-skeleton"),f=C("el-table");return d(),E(f,{data:p(a),class:"w-full compact-table full-compact"},{default:i(()=>[l(o,{type:"selection",width:45}),e.taxTable.isColumnVisible("id")?(d(),E(o,{key:0,width:100,label:p(c)("ID")},{default:i(()=>[r("div",Vde,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0),e.taxTable.isColumnVisible("order_id")?(d(),E(o,{key:1,label:p(c)("Order ID"),width:100},{default:i(()=>[r("div",Mde,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0),l(o,{label:p(c)("Tax Country"),width:120},{default:i(()=>[r("div",Lde,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"]),l(o,{label:p(c)("Tax Region"),width:120},{default:i(()=>[r("div",Rde,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("postcode")?(d(),E(o,{key:2,label:p(c)("Zip Code"),width:120},{default:i(()=>[r("div",Ode,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0),l(o,{label:p(c)("Tax Name"),width:120},{default:i(()=>[r("div",Hde,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("rate")?(d(),E(o,{key:3,label:p(c)("Tax Rate"),width:120},{default:i(()=>[r("div",Pde,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0),l(o,{label:p(c)("Sale Taxes"),width:120},{default:i(()=>[r("div",Nde,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("filed_at")?(d(),E(o,{key:4,label:p(c)("Filed"),width:120},{default:i(()=>[r("div",Kde,[l(A,{animated:""},{template:i(()=>[l(u,{varient:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"])}}},jde={class:"table-cell"},zde={class:"table-cell"},Yde={class:"table-cell"},qde={class:"table-cell"},Wde={class:"table-cell"},Xde={class:"table-cell"},Jde={class:"table-cell"},Zde={class:"table-cell"},eue={class:"table-cell"},tue={__name:"AllCouponsLoader",props:{nextPageCount:{type:Number,default:0},couponTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(n,s)=>s+1);return(n,s)=>{const o=C("el-skeleton-item"),u=C("el-skeleton"),A=C("el-table-column"),f=C("el-table");return d(),E(f,{data:p(a),class:"w-full compact-table responsive full-compact"},{default:i(()=>[l(A,{width:100,label:p(c)("ID")},{default:i(()=>[r("div",jde,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("title")?(d(),E(A,{key:0,label:p(c)("Title"),width:250},{default:i(()=>[r("div",zde,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[180px]"})]),_:1})])]),_:1},8,["label"])):x("",!0),l(A,{label:p(c)("Code"),width:200},{default:i(()=>[r("div",Yde,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[130px]"})]),_:1})])]),_:1},8,["label"]),l(A,{label:p(c)("Amount"),width:120},{default:i(()=>[r("div",qde,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),l(A,{label:p(c)("Usage"),width:150},{default:i(()=>[r("div",Wde,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("stackable")?(d(),E(A,{key:1,label:p(c)("Stackable"),width:120},{default:i(()=>[r("div",Xde,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"])):x("",!0),l(A,{label:p(c)("Status"),width:120},{default:i(()=>[r("div",Jde,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),l(A,{label:p(c)("Expiry Date"),width:120},{default:i(()=>[r("div",Zde,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("actions")?(d(),E(A,{key:2,label:p(c)("Actions"),width:100,align:"right"},{default:i(()=>[r("div",eue,[l(u,{animated:""},{template:i(()=>[l(o,{varient:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"])}}},aue={class:"fct-taxes-page fct-layout-width"},nue={key:1},sue={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},lue=["innerHTML"],oue={class:"fct-tax-filing-wrap"},rue={class:"fct-tax-filing-summary"},iue={class:"summary-item"},due={class:"summary-label"},uue={class:"summary-value"},cue={class:"summary-item"},Aue={class:"summary-label"},pue={class:"summary-value"},fue={class:"fct-tax-filing max-h-[400px] overflow-y-auto"},mue={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},hue=["innerHTML"],_ue={class:"dialog-footer"},gue={class:"fct-tax-filing-success-wrap"},vue={class:"fct-tax-filling-success-icon"},yue={class:"dialog-footer"},bue={__name:"Taxes",setup(e){const t=Object.fromEntries(Ah.map(F=>[F.value,F.label])),a=F=>t[F]||F;Qt().ctx;const n=Dde(),s=V(!1),o=V(!1),u=V(!1),A=V([]),f=j(()=>n.getTableData().map(F=>{var L,Q,T,D,U,I,O,P,K,G,ne;return{id:F.id,order_id:F.order_id,country:a(((L=F.tax_rate)==null?void 0:L.country)??((Q=F.meta)==null?void 0:Q.tax_country)??""),state:((T=F.tax_rate)==null?void 0:T.formatted_state)??((D=F.tax_rate)==null?void 0:D.state)??"",postcode:((U=F.tax_rate)==null?void 0:U.postcode)??"",name:((I=F.tax_rate)==null?void 0:I.name)??((O=F.meta)==null?void 0:O.label)??"",reverse_charge:!!((P=F.meta)!=null&&P.reverse_charge_applied),rate:((K=F.tax_rate)==null?void 0:K.rate)??((G=F.meta)==null?void 0:G.rate_percent)??"",total_tax:String(parseFloat((F.total_tax/100).toFixed(2))),currency:((ne=F.order)==null?void 0:ne.currency)||"",total_tax:String(parseFloat((F.total_tax/100).toFixed(2))),filed_at:F.filed_at?"Yes":"No"}})),m=()=>{s.value=!0,o.value=!1},g=()=>{s.value=!1,o.value=!0},y=async()=>{try{await Tde(S.value),g()}catch{}},v=()=>{o.value=!1},B=()=>{const F=S.value.map(L=>L.id);re.post(n.getFetchUrl(),{ids:F}).then(L=>{q.success(L.message),n.fetch()}).catch(L=>{q.error(L)}).finally(()=>{v()})},b=F=>{A.value=F,u.value=F.length>0},w=F=>{S.value=F},k=V(null),S=V([]),M=j(()=>{const F=S.value.reduce((Q,T)=>Q+parseFloat(T.total_tax||0),0),L=[...new Set(S.value.map(Q=>Q.order_id))];return{totalTax:Te.formatNumber(Math.round(F*100),!1),totalOrders:L.length,items:S.value}}),$=()=>{ye(()=>{S.value=[...A.value],A.value.forEach(F=>{k.value.toggleRowSelection(F,!0)})})};return(F,L)=>{const Q=C("el-button"),T=C("el-tooltip"),D=C("el-table-column"),U=C("router-link"),I=C("el-tag"),O=C("el-table"),P=C("el-dialog");return d(),_("div",aue,[l(za,{title:p(c)("Taxes")},{action:i(()=>[u.value?(d(),E(Q,{key:1,type:"primary",onClick:m,disabled:!u.value},{default:i(()=>[R(h(p(c)("Tax Filing")),1)]),_:1},8,["disabled"])):(d(),E(T,{key:0,"popper-class":"fct-tooltip",effect:"dark",content:p(c)("Please select the taxes you want to file"),placement:"top-start"},{default:i(()=>[l(Q,{type:"primary",disabled:!u.value},{default:i(()=>[R(h(p(c)("Tax Filing")),1)]),_:1},8,["disabled"])]),_:1},8,["content"]))]),_:1},8,["title"]),l(js,{table:p(n),"has-mobile-slot":!1},{default:i(()=>[p(n).isLoading()?(d(),E(Gde,{key:0,taxTable:p(n),"next-page-count":p(n).nextPageCount},null,8,["taxTable","next-page-count"])):(d(),_("div",nue,[l(O,{class:"w-full",data:f.value,onSelectionChange:b},{empty:i(()=>[l(at,{icon:"Empty/ListView","has-dark":!0,text:p(c)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:i(()=>[l(D,{type:"selection",width:45}),p(n).isColumnVisible("id")?(d(),E(D,{key:0,label:p(c)("ID"),width:100},{default:i(K=>[r("span",null,"#"+h(p(c)(K.row.id)),1)]),_:1},8,["label"])):x("",!0),p(n).isColumnVisible("order_id")?(d(),E(D,{key:1,label:p(c)("Order ID"),"min-width":100},{default:i(K=>[r("span",sue,[l(U,{class:"link",to:{name:"view_order",params:{order_id:K.row.order_id}}},{default:i(()=>[R(" #"+h(K.row.order_id),1)]),_:2},1032,["to"]),K.row.reverse_charge?(d(),E(I,{key:0,type:"warning",size:"small","disable-transitions":""},{default:i(()=>[R(h(p(c)("Reverse Charge")),1)]),_:1})):x("",!0)])]),_:1},8,["label"])):x("",!0),l(D,{label:p(c)("Tax Country"),width:120},{default:i(K=>[r("span",null,h(K.row.country),1)]),_:1},8,["label"]),l(D,{label:p(c)("Tax Region"),width:120},{default:i(K=>[r("span",null,h(K.row.state),1)]),_:1},8,["label"]),p(n).isColumnVisible("postcode")?(d(),E(D,{key:2,label:p(c)("Zip Code"),width:120},{default:i(K=>[r("span",null,h(K.row.postcode),1)]),_:1},8,["label"])):x("",!0),l(D,{label:p(c)("Tax Name"),width:120},{default:i(K=>[r("span",null,h(K.row.name),1)]),_:1},8,["label"]),p(n).isColumnVisible("rate")?(d(),E(D,{key:3,label:p(c)("Tax Rate"),width:120},{default:i(K=>[r("span",null,h(K.row.rate)+"%",1)]),_:1},8,["label"])):x("",!0),l(D,{label:p(c)("Sale Taxes"),width:120},{default:i(K=>[r("span",{innerHTML:p(Te).formatForOrder(K.row.total_tax_cents,K.row.currency)},null,8,lue)]),_:1},8,["label"]),p(n).isColumnVisible("filed_at")?(d(),E(D,{key:4,label:p(c)("Filed"),width:120},{default:i(K=>[r("span",null,h(K.row.filed_at),1)]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"]),l(P,{modelValue:s.value,"onUpdate:modelValue":L[1]||(L[1]=K=>s.value=K),title:p(c)("Tax Filing"),onOpen:$,class:"fct-tax-filling-modal"},{footer:i(()=>[r("div",_ue,[l(Q,{onClick:L[0]||(L[0]=()=>{s.value=!1})},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(Q,{type:"primary",onClick:y},{default:i(()=>[l(W,{name:"Download",style:{width:"16px",height:"16px"}}),R(" "+h(p(c)("Download & Continue")),1)]),_:1})])]),default:i(()=>[r("div",oue,[r("div",rue,[r("div",iue,[r("span",due,h(p(c)("Taxable Amount")),1),r("span",uue,h(M.value.totalTax),1)]),r("div",cue,[r("span",Aue,h(p(c)("Total Orders")),1),r("span",pue,h(p(c)(M.value.totalOrders)),1)])]),r("div",fue,[l(O,{ref_key:"selectedTaxesTableRef",ref:k,data:A.value,onSelectionChange:w},{empty:i(()=>[l(at,{icon:"Empty/ListView",text:p(c)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:i(()=>[l(D,{type:"selection",width:45}),l(D,{label:p(c)("ID"),width:100},{default:i(K=>[r("span",null,h(K.row.id),1)]),_:1},8,["label"]),l(D,{label:p(c)("Order ID"),"min-width":100},{default:i(K=>[r("span",mue,[r("span",null,h(K.row.order_id),1),K.row.reverse_charge?(d(),E(I,{key:0,type:"warning",size:"small","disable-transitions":""},{default:i(()=>[R(h(p(c)("Reverse Charge")),1)]),_:1})):x("",!0)])]),_:1},8,["label"]),l(D,{width:120,label:p(c)("Tax Country")},{default:i(K=>[r("span",null,h(K.row.country),1)]),_:1},8,["label"]),l(D,{width:120,label:p(c)("Tax Region")},{default:i(K=>[r("span",null,h(K.row.state),1)]),_:1},8,["label"]),l(D,{label:p(c)("Zip Code"),width:120},{default:i(K=>[r("span",null,h(K.row.postcode),1)]),_:1},8,["label"]),l(D,{width:120,label:p(c)("Tax Name")},{default:i(K=>[r("span",null,h(K.row.name),1)]),_:1},8,["label"]),l(D,{label:p(c)("Tax Rate"),width:120},{default:i(K=>[r("span",null,h(K.row.rate)+"%",1)]),_:1},8,["label"]),l(D,{width:150,label:p(c)("Sale Taxes")},{default:i(K=>[r("span",{innerHTML:p(Te).formatForOrder(K.row.total_tax_cents,K.row.currency)},null,8,hue)]),_:1},8,["label"])]),_:1},8,["data"])])])]),_:1},8,["modelValue","title"]),l(P,{modelValue:o.value,"onUpdate:modelValue":L[2]||(L[2]=K=>o.value=K),class:"fct-tax-filling-success-modal","close-on-click-modal":!1},{footer:i(()=>[r("div",yue,[l(Q,{onClick:v},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(Q,{type:"primary",onClick:B},{default:i(()=>[R(h(p(c)("Mark as Filed")),1)]),_:1})])]),default:i(()=>[r("div",gue,[r("div",vue,[l(W,{name:"CheckCircleFill"})]),r("div",null,[r("h4",null,h(p(c)("Don't Forget to Save Your Tax File")),1),r("p",null,h(p(c)("You're about to mark this tax report as filed.")),1),r("p",null,[R(h(p(c)("Make sure you've downloaded and saved the CSV file for your records before proceeding."))+" ",1),r("a",{onClick:Xe(y,["prevent"]),class:"cursor-pointer"},h(p(c)("Download Again")),1)])])])]),_:1},8,["modelValue"])])}}},wue={class:"fct-card fct-card-border fct-vat-card"},Cue={class:"fct-card-body"},Bue={class:"fct-vat-card-header"},kue={class:"fct-vat-card-title"},xue={class:"fct-card fct-card-border fct-vat-card mt-5"},Sue={class:"fct-card-body"},Fue={class:"fct-vat-card-header"},Eue={class:"fct-vat-card-title"},Uue={class:"fct-tax-rates-country-view"},$ue={class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},Due={class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-3 border-b border-gray-200 dark:border-dark-300"},Que={__name:"EUVatSettingsLoader",setup(e){const t=[1,2,3];return(a,n)=>(d(),_("div",null,[r("div",wue,[r("div",Cue,[r("div",Bue,[r("div",kue,[r("h3",null,h(p(c)("Collect VAT cross-border")),1)])]),n[0]||(n[0]=r("div",{class:"fct-vat-card-body"},[r("div",{class:"fct-sk w-[200px] h-3 rounded-xs"}),r("div",{class:"fct-sk w-full h-3 rounded-xs mt-3"})],-1))])]),r("div",xue,[r("div",Sue,[r("div",Fue,[r("div",Eue,[r("h3",null,h(p(c)("Tax overrides")),1)])]),r("div",Uue,[r("div",$ue,[r("div",Due,[(d(),_(H,null,ee(6,s=>r("div",{key:"header-"+s,class:"fct-sk h-3 rounded-xs"})),64))]),(d(),_(H,null,ee(t,s=>r("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"},n[1]||(n[1]=[ao('',6)]))),64))])])])])]))}},Iue={class:"fct-modal-body"},Tue={class:"fct-radio-option-fields"},Vue={class:"form-note"},Mue={class:"fct-radio-option-fields"},Lue={class:"fct-radio-option-fields-desc"},Rue={class:"form-note"},Oue={key:0,class:"fct-info-box mt-3"},Hue={class:"text-xs text-system-mid"},Pue={class:"fct-radio-option-fields"},Nue={class:"fct-radio-option-fields-desc"},Kue={__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,n=t,s=V({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),o=V(!1);ge(()=>a.modelValue,m=>{if(m){const g=a.initialRegistrations.length?a.initialRegistrations[0]:null,y=g?g.country:"",v=g&&g.vat||"",B=a.currentForm||{};s.value={method:B.method||"oss",oss_country:B.oss_country||y,oss_vat:B.oss_vat||v,home_country:B.home_country||y,home_vat:B.home_vat||v}}else s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}});function u(m){const g=a.countries.find(y=>y.value===m);return g?parseFloat(g.default_rate||0):0}function A(){return a.initialRegistrations.some(m=>m.country===s.value.home_country)}function f(){if(!s.value.method){q.error(c("Select a cross-border registration type"));return}if(s.value.method==="oss"){if(!s.value.oss_country){q.error(c("Select your country of OSS registration"));return}}else if(s.value.method==="home"&&!s.value.home_country){q.error(c("Select your country of registration"));return}o.value=!0,(s.value.method==="home"&&!A()?re.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.home_country,vat:s.value.home_vat,rate:u(s.value.home_country)}):Promise.resolve()).then(()=>re.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:s.value})).then(g=>{q.success(g.message),n("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}),n("update:modelValue",!1)}).catch(g=>{var y;q.error((y=g==null?void 0:g.data)==null?void 0:y.message)}).finally(()=>{o.value=!1})}return(m,g)=>{const y=C("el-radio"),v=C("el-option"),B=C("el-select"),b=C("el-form-item"),w=C("el-input"),k=C("el-radio-group"),S=C("el-form"),M=C("el-button"),$=C("el-dialog");return d(),E($,{"model-value":e.modelValue,title:p(c)("Collect across the EU"),width:"760px","close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":g[9]||(g[9]=F=>n("update:modelValue",F))},{footer:i(()=>[l(M,{onClick:g[8]||(g[8]=F=>n("update:modelValue",!1))},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(M,{type:"primary",onClick:f,loading:o.value},{default:i(()=>[R(h(p(c)("Collect VAT")),1)]),_:1},8,["loading"])]),default:i(()=>[r("div",Iue,[l(S,{"label-position":"top"},{default:i(()=>[l(k,{modelValue:s.value.method,"onUpdate:modelValue":g[7]||(g[7]=F=>s.value.method=F),class:"fct-cross-border-radios"},{default:i(()=>[r("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="oss"}]),onClick:g[2]||(g[2]=F=>s.value.method="oss")},[l(y,{value:"oss"},{default:i(()=>[R(h(p(c)("Collect using a One Stop Shop (OSS) registration")),1)]),_:1}),l(ra,{accordion:"",visible:s.value.method==="oss"},{default:i(()=>[r("div",Tue,[l(b,{label:p(c)("Country of OSS registration")},{default:i(()=>[l(B,{modelValue:s.value.oss_country,"onUpdate:modelValue":g[0]||(g[0]=F=>s.value.oss_country=F),placeholder:p(c)("Select country"),filterable:"",class:"w-full"},{default:i(()=>[(d(!0),_(H,null,ee(e.countries,F=>(d(),E(v,{key:F.value,label:F.label,value:F.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),l(b,{label:p(c)("VAT number")},{default:i(()=>[l(w,{modelValue:s.value.oss_vat,"onUpdate:modelValue":g[1]||(g[1]=F=>s.value.oss_vat=F),placeholder:p(c)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),r("div",Vue,[r("p",null,h(p(c)("Shown on VAT invoice")),1)])]),_:1},8,["label"])])]),_:1},8,["visible"])],2),r("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="home"}]),onClick:g[5]||(g[5]=F=>s.value.method="home")},[l(y,{value:"home"},{default:i(()=>[R(h(p(c)("Collect using your home country registration")),1)]),_:1}),l(ra,{accordion:"",visible:s.value.method==="home"},{default:i(()=>[r("div",Mue,[r("p",Lue,h(p(c)("Applies to micro-businesses located in one EU country and making less than €10,000 in sales to other EU countries each year")),1),l(b,{label:p(c)("Country of registration")},{default:i(()=>[l(B,{modelValue:s.value.home_country,"onUpdate:modelValue":g[3]||(g[3]=F=>s.value.home_country=F),placeholder:p(c)("Select country"),filterable:"",class:"w-full"},{default:i(()=>[(d(!0),_(H,null,ee(e.countries,F=>(d(),E(v,{key:F.value,label:F.label,value:F.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),l(b,{label:p(c)("VAT number")},{default:i(()=>[l(w,{modelValue:s.value.home_vat,"onUpdate:modelValue":g[4]||(g[4]=F=>s.value.home_vat=F),placeholder:p(c)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),r("div",Rue,[r("p",null,h(p(c)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),e.initialRegistrations.length?x("",!0):(d(),_("div",Oue,[l(W,{name:"InformationFill",class:"w-4 h-4 text-blue-500 flex-shrink-0"}),r("span",Hue,h(p(c)("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),r("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="specific"}]),onClick:g[6]||(g[6]=F=>s.value.method="specific")},[l(y,{value:"specific"},{default:i(()=>[R(h(p(c)("Collect using specific country registrations")),1)]),_:1}),l(ra,{accordion:"",visible:s.value.method==="specific"},{default:i(()=>[r("div",Pue,[r("p",Nue,h(p(c)("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"])}}},Gue={key:0,class:"fct-country-registrations-list mt-4"},jue={class:"fct-home-country-header"},zue=["src","alt"],Yue={class:"fct-vat-country-name"},que={key:0,class:"fct-collecting-badge"},Wue={class:"fct-home-country-body"},Xue={class:"fct-vat-home-field"},Jue={class:"fct-vat-home-field__label"},Zue={class:"fct-reg-rates-section"},ece={class:"fct-reg-rates-table fct-reg-rates-table--home mt-5 px-5 pt-5"},tce={class:"fct-reg-rates-row fct-reg-rates-header"},ace={class:"fct-reg-rates-cell-label"},nce={class:"fct-reg-rates-cell-label"},sce={key:1,class:"fct-reg-class-name"},lce={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},oce={class:"fct-reg-rates-cell-input"},rce={class:"fct-reg-rates-cell-action"},ice=["title","onClick"],dce={key:0,class:"fct-reg-add-class px-5"},uce={type:"button",class:"fct-reg-add-class-btn"},cce={class:"fct-vat-home-actions"},Ace={__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,n=t,s=V({country:"",vat:"",rates:{}}),o=V([]),u=V(!1),A=V(""),f=j(()=>a.homeCountry&&a.countries.find(Q=>Q.value===a.homeCountry)||null),m=j(()=>a.homeCountry&&a.registrations.find(Q=>Q.country===a.homeCountry)||null),g=j(()=>{const Q=m.value;return!Q||!Q.vat?!1:Q.rates&&typeof Q.rates=="object"&&Object.keys(Q.rates).length?Object.values(Q.rates).some(function(T){return T&&parseFloat(T.rate)>0}):parseFloat(Q.rate)>0}),y=j(()=>[...a.taxClasses,...o.value]),v=j(()=>y.value.length?y.value:[{slug:"standard",title:c("Standard")}]),B=j(()=>{if(y.value.length>=6)return[];const Q=y.value.map(D=>D.slug).filter(Boolean),T=[];return Q.includes("reduced")||T.push({command:"reduced",label:c("Reduced")}),Q.includes("zero")||T.push({command:"zero",label:c("Zero")}),T.push({command:"custom",label:c("Custom Class...")}),T});ge([()=>a.homeCountry,()=>a.homeVat,()=>a.taxClasses,()=>a.registrations],()=>{const Q=m.value,T={};a.taxClasses.forEach(D=>{var P;const U=(P=Q==null?void 0:Q.rates)==null?void 0:P[D.slug],I=D.slug==="standard"?(Q==null?void 0:Q.rate)??"":"",O=D.slug==="standard"?(Q==null?void 0:Q.tax_label)??"":"";U&&typeof U=="object"?T[D.slug]={rate:U.rate??"",label:U.label??""}:T[D.slug]={rate:U??I,label:O}}),o.value.forEach(D=>{const U=b(D);T[U]=s.value.rates[U]||{rate:"",label:""}}),T.standard||(T.standard={rate:"",label:""}),s.value={country:a.homeCountry||"",vat:(Q==null?void 0:Q.vat)||a.homeVat||"",rates:T}},{immediate:!0});function b(Q){return Q.tempKey||Q.slug}function w(Q){if(Q==="custom"){A.value="",u.value=!0;return}const T=Q==="reduced"?c("Reduced"):c("Zero");o.value.push({slug:Q,title:T,tempKey:Q}),s.value.rates[Q]={rate:"",label:""}}function k(){if(!A.value.trim())return;const Q=A.value.trim(),T="_new_"+o.value.length;o.value.push({slug:null,title:Q,tempKey:T,isNew:!1}),s.value.rates[T]={rate:"",label:""},u.value=!1,A.value=""}function S(){const Q="_new_"+o.value.length;o.value.push({slug:null,title:"",tempKey:Q,isNew:!0}),s.value.rates[Q]={rate:"",label:""}}function M(Q){return Q.slug?Q.title||Q.slug:Q.title&&Q.title.trim()?Q.title.trim():c("Custom")}function $(Q){const T=Q.slug?{slug:Q.slug}:{title:M(Q)};return re.post("tax/classes",T).then(D=>{const U=(D==null?void 0:D.class)||{},I=U.slug||Q.slug;if(!I)throw new Error(c("Tax class creation returned an invalid response"));return!Q.slug&&s.value.rates[Q.tempKey]!==void 0&&(s.value.rates[I]=s.value.rates[Q.tempKey],delete s.value.rates[Q.tempKey]),Q.slug=I,Q.title=U.title||Q.title,U}).catch(D=>{var I;const U=((I=D==null?void 0:D.data)==null?void 0:I.message)||c("Failed to create tax class");throw new Error(c("%1$s: %2$s",U,M(Q)))})}function F(Q){const T=b(Q);if(o.value.some(U=>b(U)===T)){o.value=o.value.filter(U=>b(U)!==T),delete s.value.rates[T];return}en(c('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?',Q.title),c("Delete Tax Class"),{confirmButtonText:c("Delete"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{re.delete("tax/classes/"+Q.id).then(()=>{n("class-changed")}).catch(U=>{var I;q.error(((I=U==null?void 0:U.data)==null?void 0:I.message)||c("Failed to delete tax class"))})}).catch(()=>{})}function L(){const Q=o.value.map($);Promise.all(Q).then(()=>{o.value=[],n("save-home",{country:s.value.country,vat:s.value.vat,rates:s.value.rates})}).catch(T=>{q.error((T==null?void 0:T.message)||c("Failed to create tax class"))})}return(Q,T)=>{const D=C("el-input"),U=C("el-dropdown-item"),I=C("el-dropdown-menu"),O=C("el-dropdown"),P=C("el-button"),K=C("el-form-item"),G=C("el-form"),ne=C("el-dialog");return f.value?(d(),_("div",Gue,[r("div",jue,[r("img",{src:`https://flagcdn.com/w40/${e.homeCountry.toLowerCase()}.png`,alt:f.value.label,class:"fct-flag-icon"},null,8,zue),r("span",Yue,h(f.value.label),1),g.value?(d(),_("span",que,[T[4]||(T[4]=r("span",{class:"fct-green-dot"},null,-1)),R(" "+h(p(c)("Collecting")),1)])):x("",!0)]),r("div",Wue,[r("div",Xue,[r("label",Jue,h(p(c)("VAT number")),1),l(D,{modelValue:s.value.vat,"onUpdate:modelValue":T[0]||(T[0]=Y=>s.value.vat=Y),class:"fct-vat-number-input"},null,8,["modelValue"])]),r("div",Zue,[r("div",ece,[r("div",tce,[r("div",ace,h(p(c)("Tax Classes")),1),T[5]||(T[5]=r("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),T[6]||(T[6]=r("div",{class:"fct-reg-rates-cell-input"},null,-1)),T[7]||(T[7]=r("div",{class:"fct-reg-rates-cell-action"},null,-1))]),(d(!0),_(H,null,ee(v.value,Y=>(d(),_("div",{key:b(Y),class:"fct-reg-rates-row"},[r("div",nce,[Y.isNew?(d(),E(D,{key:0,modelValue:Y.title,"onUpdate:modelValue":N=>Y.title=N,size:"small",placeholder:p(c)("Class name"),class:"fct-reg-class-name-input"},null,8,["modelValue","onUpdate:modelValue","placeholder"])):(d(),_("span",sce,h(Y.title),1))]),r("div",lce,[l(D,{modelValue:s.value.rates[b(Y)].rate,"onUpdate:modelValue":N=>s.value.rates[b(Y)].rate=N,type:"number",step:"0.01",min:"0",size:"small"},{suffix:i(()=>T[8]||(T[8]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),r("div",oce,[l(D,{modelValue:s.value.rates[b(Y)].label,"onUpdate:modelValue":N=>s.value.rates[b(Y)].label=N,size:"small",placeholder:p(c)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),r("div",rce,[Y.slug!=="standard"?(d(),_("button",{key:0,type:"button",class:"fct-reg-rates-delete-btn",title:p(c)("Delete class"),onClick:N=>F(Y)},[l(W,{name:"Delete"})],8,ice)):x("",!0)])]))),128))]),B.value.length?(d(),_("div",dce,[B.value.length===1&&B.value[0].command==="custom"?(d(),_("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:S},[l(W,{name:"Plus",class:"w-3 h-3"}),R(" "+h(p(c)("Add class")),1)])):(d(),E(O,{key:1,trigger:"click",onCommand:w,"popper-class":"fct-dropdown"},{dropdown:i(()=>[l(I,null,{default:i(()=>[(d(!0),_(H,null,ee(B.value,Y=>(d(),E(U,{key:Y.command,command:Y.command},{default:i(()=>[R(h(Y.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:i(()=>[r("button",uce,[l(W,{name:"Plus",class:"w-3 h-3"}),R(" "+h(p(c)("Add class")),1)])]),_:1}))])):x("",!0)]),r("div",cce,[l(P,{type:"primary",size:"small",onClick:L},{default:i(()=>[R(h(p(c)("Save VAT")),1)]),_:1})])]),l(ne,{modelValue:u.value,"onUpdate:modelValue":T[3]||(T[3]=Y=>u.value=Y),title:p(c)("Create Tax Class"),width:"400px","append-to-body":!0},{footer:i(()=>[l(P,{onClick:T[2]||(T[2]=Y=>u.value=!1)},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(P,{type:"primary",onClick:k},{default:i(()=>[R(h(p(c)("Create")),1)]),_:1})]),default:i(()=>[l(G,{onSubmit:Xe(k,["prevent"])},{default:i(()=>[l(K,{label:p(c)("Class Name")},{default:i(()=>[l(D,{modelValue:A.value,"onUpdate:modelValue":T[1]||(T[1]=Y=>A.value=Y),placeholder:p(c)("e.g. Super Reduced, Luxury"),maxlength:"30"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"])])):x("",!0)}}},pce={class:"fct-modal-body fct-country-reg-modal"},fce={class:"fct-country-reg-text"},mce={class:"form-note"},hce={class:"fct-reg-rates-table"},_ce={class:"fct-reg-rates-row fct-reg-rates-header"},gce={class:"fct-reg-rates-cell-label"},vce={class:"fct-reg-rates-cell-label"},yce={key:1,class:"fct-reg-class-name"},bce={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},wce={class:"fct-reg-rates-cell-input"},Cce={key:1,class:"fct-reg-rates-row"},Bce={class:"fct-reg-rates-cell-label"},kce={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},xce={class:"fct-reg-rates-cell-input"},Sce={key:0,class:"fct-reg-add-class"},Fce={type:"button",class:"fct-reg-add-class-btn"},Ece={__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,n=t,s=V({country:"",vat:"",rates:{},isEdit:!1}),o=V([]),u=V(!1),A=V(!1),f=V(""),m=j(()=>[...a.taxClasses,...o.value]),g=j(()=>{if(m.value.length>=6)return[];const F=m.value.map(Q=>Q.slug).filter(Boolean),L=[];return F.includes("reduced")||L.push({command:"reduced",label:c("Reduced")}),F.includes("zero")||L.push({command:"zero",label:c("Zero")}),L.push({command:"custom",label:c("Custom Class...")}),L}),y=j(()=>s.value.isEdit?a.countries:a.countries.filter(F=>!a.registeredCountries.includes(F.value)));ge(()=>a.modelValue,F=>{if(F){const L=a.initialForm||{},Q=L.rates?JSON.parse(JSON.stringify(L.rates)):{};a.taxClasses.forEach(T=>{Q[T.slug]||(Q[T.slug]={rate:"",label:""})}),Q.standard||(Q.standard={rate:"",label:""}),s.value={country:L.country||"",vat:L.vat||"",rates:Q,isEdit:L.isEdit||!1},o.value=[]}});function v(F){return F.tempKey||F.slug}function B(F){const L=a.countries.find(Q=>Q.value===F);if(L&&L.default_rate){const Q=s.value.rates.standard||{};s.value.rates=Object.assign({},s.value.rates,{standard:Object.assign({},Q,{rate:L.default_rate})})}}function b(F){if(F==="custom"){f.value="",A.value=!0;return}const L=F==="reduced"?c("Reduced"):c("Zero");o.value.push({slug:F,title:L,tempKey:F}),s.value.rates[F]={rate:"",label:""}}function w(){if(!f.value.trim())return;const F=f.value.trim(),L="_new_"+o.value.length;o.value.push({slug:null,title:F,tempKey:L,isNew:!1}),s.value.rates[L]={rate:"",label:""},A.value=!1,f.value=""}function k(){const F="_new_"+o.value.length;o.value.push({slug:null,title:"",tempKey:F,isNew:!0}),s.value.rates[F]={rate:"",label:""}}function S(F){return F.slug?F.title||F.slug:F.title&&F.title.trim()?F.title.trim():c("Custom")}function M(F){const L=F.slug?{slug:F.slug}:{title:S(F)};return re.post("tax/classes",L).then(Q=>{const T=(Q==null?void 0:Q.class)||{},D=T.slug||F.slug;if(!D)throw new Error(c("Tax class creation returned an invalid response"));return!F.slug&&s.value.rates[F.tempKey]!==void 0&&(s.value.rates[D]=s.value.rates[F.tempKey],delete s.value.rates[F.tempKey]),F.slug=D,F.title=T.title||F.title,T}).catch(Q=>{var D;const T=((D=Q==null?void 0:Q.data)==null?void 0:D.message)||c("Failed to create tax class");throw new Error(`${T}: ${S(F)}`)})}function $(){if(!s.value.country){q.error(c("Select a registration country"));return}const F=s.value.rates;if(!Object.values(F).some(T=>parseFloat(T.rate)>0)){q.error(c("At least one tax rate must be greater than 0%"));return}u.value=!0;const Q=o.value.map(M);Promise.all(Q).then(()=>re.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.country,vat:s.value.vat,rates:s.value.rates})).then(T=>{q.success(T.message),o.value=[],n("saved"),n("update:modelValue",!1)}).catch(T=>{var D;q.error((T==null?void 0:T.message)||((D=T==null?void 0:T.data)==null?void 0:D.message)||c("Failed to save VAT registration"))}).finally(()=>{u.value=!1})}return(F,L)=>{const Q=C("el-option"),T=C("el-select"),D=C("el-form-item"),U=C("el-input"),I=C("el-dropdown-item"),O=C("el-dropdown-menu"),P=C("el-dropdown"),K=C("el-form"),G=C("el-button"),ne=C("el-dialog");return d(),_(H,null,[l(ne,{"model-value":e.modelValue,title:s.value.isEdit?p(c)("Edit VAT registration"):p(c)("Collect VAT"),"close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":L[5]||(L[5]=Y=>n("update:modelValue",Y))},{footer:i(()=>[l(G,{onClick:L[4]||(L[4]=Y=>n("update:modelValue",!1))},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(G,{type:"primary",onClick:$,loading:u.value},{default:i(()=>[R(h(p(c)("Collect VAT")),1)]),_:1},8,["loading"])]),default:i(()=>[r("div",pce,[r("p",fce,h(p(c)("Make sure you're registered for VAT when collecting in the EU.")),1),l(K,{"label-position":"top"},{default:i(()=>[l(D,{label:p(c)("Registration country")},{default:i(()=>[l(T,{modelValue:s.value.country,"onUpdate:modelValue":L[0]||(L[0]=Y=>s.value.country=Y),placeholder:p(c)("Select country"),filterable:"",class:"w-full",disabled:s.value.isEdit,onChange:B},{default:i(()=>[(d(!0),_(H,null,ee(y.value,Y=>(d(),E(Q,{key:Y.value,label:Y.label,value:Y.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","disabled"])]),_:1},8,["label"]),l(D,{label:p(c)("VAT number")},{default:i(()=>[l(U,{modelValue:s.value.vat,"onUpdate:modelValue":L[1]||(L[1]=Y=>s.value.vat=Y),placeholder:s.value.country?s.value.country+"999999999":"DE999999999"},null,8,["modelValue","placeholder"]),r("div",mce,[r("p",null,h(p(c)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),r("div",hce,[r("div",_ce,[r("div",gce,h(p(c)("Tax Classes")),1),L[9]||(L[9]=r("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),L[10]||(L[10]=r("div",{class:"fct-reg-rates-cell-input"},null,-1))]),m.value.length?(d(!0),_(H,{key:0},ee(m.value,Y=>(d(),_("div",{key:Y.tempKey||Y.slug,class:"fct-reg-rates-row"},[r("div",vce,[Y.isNew?(d(),E(U,{key:0,modelValue:Y.title,"onUpdate:modelValue":N=>Y.title=N,size:"small",placeholder:p(c)("Class name"),class:"fct-reg-class-name-input"},null,8,["modelValue","onUpdate:modelValue","placeholder"])):(d(),_("span",yce,h(Y.title),1))]),r("div",bce,[l(U,{modelValue:s.value.rates[v(Y)].rate,"onUpdate:modelValue":N=>s.value.rates[v(Y)].rate=N,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:Y.slug==="standard"?"19":"0"},{suffix:i(()=>L[11]||(L[11]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue","placeholder"])]),r("div",wce,[l(U,{modelValue:s.value.rates[v(Y)].label,"onUpdate:modelValue":N=>s.value.rates[v(Y)].label=N,size:"small",placeholder:p(c)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])])]))),128)):(d(),_("div",Cce,[r("div",Bce,h(p(c)("Standard")),1),r("div",kce,[l(U,{modelValue:s.value.rates.standard.rate,"onUpdate:modelValue":L[2]||(L[2]=Y=>s.value.rates.standard.rate=Y),modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:"19"},{suffix:i(()=>L[12]||(L[12]=[R("%",-1)])),_:1},8,["modelValue"])]),r("div",xce,[l(U,{modelValue:s.value.rates.standard.label,"onUpdate:modelValue":L[3]||(L[3]=Y=>s.value.rates.standard.label=Y),size:"small",placeholder:p(c)("e.g. VAT, MwSt")},null,8,["modelValue","placeholder"])])]))]),g.value.length?(d(),_("div",Sce,[g.value.length===1&&g.value[0].command==="custom"?(d(),_("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:k},[l(W,{name:"Plus"}),R(" "+h(p(c)("Add class")),1)])):(d(),E(P,{key:1,trigger:"click",onCommand:b},{dropdown:i(()=>[l(O,null,{default:i(()=>[(d(!0),_(H,null,ee(g.value,Y=>(d(),E(I,{key:Y.command,command:Y.command},{default:i(()=>[R(h(Y.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:i(()=>[r("button",Fce,[l(W,{name:"Plus"}),R(" "+h(p(c)("Add class")),1)])]),_:1}))])):x("",!0)]),_:1})])]),_:1},8,["model-value","title"]),l(ne,{modelValue:A.value,"onUpdate:modelValue":L[8]||(L[8]=Y=>A.value=Y),title:p(c)("Create Tax Class"),width:"400px","append-to-body":!0},{footer:i(()=>[l(G,{onClick:L[7]||(L[7]=Y=>A.value=!1)},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(G,{type:"primary",onClick:w},{default:i(()=>[R(h(p(c)("Create")),1)]),_:1})]),default:i(()=>[l(K,{onSubmit:Xe(w,["prevent"])},{default:i(()=>[l(D,{label:p(c)("Class Name")},{default:i(()=>[l(U,{modelValue:f.value,"onUpdate:modelValue":L[6]||(L[6]=Y=>f.value=Y),placeholder:p(c)("e.g. Super Reduced, Luxury"),maxlength:"30"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"])],64)}}},Uce={class:"fct-oss-rates-section"},$ce=["aria-expanded"],Dce={class:"inline-flex items-center gap-2"},Qce={class:"fct-oss-rates-count"},Ice={class:"fct-oss-rates-table"},Tce={key:1,class:"text-system-mid"},Vce={class:"fct-btn-group mt-4 justify-end sm"},Mce={__name:"EUVatOssRatesSection",setup(e,{expose:t}){const a=V([]),n=V([]),s=V(null),o=V("standard"),u=V(!1),A=V(!1),f=V(!1),m=V(!1),g=V(6),y=V(!1),v=V(!1),B=V(""),b=V(""),w=j(()=>a.value),k=j(()=>{const D=b.value.trim().toLowerCase();return D?w.value.filter(U=>U.label&&U.label.toLowerCase().includes(D)):w.value});function S(){return u.value=!0,re.get("tax/configuration/settings/eu-vat/oss-rates").then(D=>{a.value=D.rates||[],n.value=D.classes||[];const U=Du({classes:n.value,activeId:s.value});return U&&(s.value=U.id,o.value=U.slug),n.value}).catch(D=>{var U;q.error((U=D==null?void 0:D.data)==null?void 0:U.message)}).finally(()=>{u.value=!1})}function M(D){s.value=D.id,o.value=D.slug}function $(D){if(D==="custom"){B.value="",v.value=!0;return}y.value=!0,Ur({payload:{slug:D},createdSlug:D,currentClasses:n.value,reloadClasses:S}).then(({createdClass:U})=>{U&&M(U)}).catch(U=>{var I;q.error((I=U==null?void 0:U.data)==null?void 0:I.message)}).finally(()=>{y.value=!1})}function F(){if(!B.value.trim()){q.error(c("Please enter a class name"));return}y.value=!0,Ur({payload:{title:B.value.trim()},currentClasses:n.value,reloadClasses:S}).then(({createdClass:D})=>{v.value=!1,D&&M(D)}).catch(D=>{var U;q.error((U=D==null?void 0:D.data)==null?void 0:U.message)}).finally(()=>{y.value=!1})}function L(D){D.slug!=="standard"&&en(c('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?',D.title),c("Delete Tax Class"),{confirmButtonText:c("Remove"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{u.value=!0,bm({classId:D.id,currentActiveId:s.value===D.id?null:s.value,reloadClasses:S}).then(({nextActiveClass:U})=>{U&&M(U)}).catch(U=>{var I;q.error((I=U==null?void 0:U.data)==null?void 0:I.message),u.value=!1})}).catch(()=>{})}function Q(){A.value=!0,re.post("tax/configuration/settings/eu-vat/oss-rates",{rates:w.value.map(D=>({country:D.country,rate:D.rate,tax_label:D.tax_label||"",class_rates:D.class_rates||{}}))}).then(D=>{q.success(D.message)}).catch(D=>{var U;q.error((U=D==null?void 0:D.data)==null?void 0:U.message)}).finally(()=>{A.value=!1})}function T(){en(c("This will overwrite all EU destination country standard rates with preset defaults. Continue?"),c("Reset to default tax rates"),{confirmButtonText:c("Reset"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{f.value=!0,re.post("tax/configuration/settings/eu-vat/reset-rates").then(()=>S()).then(()=>{q.success(c("EU tax rates have been reset to defaults"))}).catch(D=>{var U;q.error(((U=D==null?void 0:D.data)==null?void 0:U.message)||c("Failed to reset rates"))}).finally(()=>{f.value=!1})}).catch(()=>{})}return Be(S),t({loadRates:S}),(D,U)=>{const I=C("el-icon"),O=C("el-table-column"),P=C("el-input"),K=C("el-table"),G=C("el-button"),ne=C("el-form-item"),Y=C("el-form"),N=C("el-dialog"),oe=Ca("loading");return d(),_(H,null,[r("div",Uce,[r("div",{class:"fct-oss-rates-toggle",role:"button",tabindex:"0","aria-expanded":m.value,onClick:U[0]||(U[0]=Z=>{m.value=!m.value,m.value||(b.value="")}),onKeydown:[U[1]||(U[1]=Pa(Xe(Z=>{m.value=!m.value,m.value||(b.value="")},["prevent"]),["enter"])),U[2]||(U[2]=Pa(Xe(Z=>{m.value=!m.value,m.value||(b.value="")},["prevent"]),["space"]))]},[r("span",Dce,[R(h(p(c)("Destination country rates"))+" ",1),r("span",Qce," ("+h(w.value.length)+") ",1)]),l(I,{class:de(["fct-oss-rates-arrow",{"is-expanded":m.value}])},{default:i(()=>[l(W,{name:"ChevronDown",class:"w-4 h-4"})]),_:1},8,["class"])],40,$ce),l(vs,{name:"fct-collapse"},{default:i(()=>[Dt(r("div",Ice,[l(Na,{type:"info"},{content:i(()=>[r("span",null,h(p(c)("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"))+" + "+h(p(c)("button to add tax classes.")),1)]),_:1}),l(ym,{classes:n.value,"active-id":s.value,"max-classes":g.value,creating:y.value,search:b.value,onSwitch:M,onDelete:L,onAdd:$,"onUpdate:search":U[3]||(U[3]=Z=>b.value=Z)},null,8,["classes","active-id","max-classes","creating","search"]),Dt((d(),E(K,{data:k.value,class:"w-full fct-tax-rates-table","max-height":"450","empty-text":p(c)("No rates found")},{default:i(()=>[l(O,{label:p(c)("Country"),"min-width":"160"},{default:i(({row:Z})=>[R(h(Z.label),1)]),_:1},8,["label"]),l(O,{label:p(c)("Tax Label"),"min-width":"150"},{default:i(({row:Z})=>[Z.class_rates&&Z.class_rates[o.value]?(d(),E(P,{key:0,modelValue:Z.class_rates[o.value].label,"onUpdate:modelValue":le=>Z.class_rates[o.value].label=le,size:"small",placeholder:p(c)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])):x("",!0)]),_:1},8,["label"]),l(O,{label:p(c)("Rate"),"min-width":"120"},{default:i(({row:Z})=>[Z.class_rates&&Z.class_rates[o.value]?(d(),E(P,{key:0,modelValue:Z.class_rates[o.value].rate,"onUpdate:modelValue":le=>Z.class_rates[o.value].rate=le,modelModifiers:{number:!0},size:"small",type:"number",min:0,max:100,step:"0.5"},{suffix:i(()=>U[7]||(U[7]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])):(d(),_("span",Tce,"—"))]),_:1},8,["label"])]),_:1},8,["data","empty-text"])),[[oe,u.value]]),r("div",Vce,[o.value==="standard"?(d(),E(G,{key:0,size:"small",loading:f.value,onClick:T,type:"danger",soft:""},{default:i(()=>[R(h(p(c)("Reset to default")),1)]),_:1},8,["loading"])):x("",!0),l(G,{type:"primary",size:"small",loading:A.value,onClick:Q},{default:i(()=>[R(h(p(c)("Save Rates")),1)]),_:1},8,["loading"])])],512),[[Rn,m.value]])]),_:1})]),l(N,{modelValue:v.value,"onUpdate:modelValue":U[6]||(U[6]=Z=>v.value=Z),title:p(c)("Create Custom Tax Class"),"append-to-body":!0},{footer:i(()=>[l(G,{onClick:U[5]||(U[5]=Z=>v.value=!1)},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(G,{type:"primary",loading:y.value,onClick:F},{default:i(()=>[R(h(p(c)("Create")),1)]),_:1},8,["loading"])]),default:i(()=>[l(Y,{onSubmit:Xe(F,["prevent"]),"label-position":"top"},{default:i(()=>[l(ne,{label:p(c)("Class Name")},{default:i(()=>[l(P,{modelValue:B.value,"onUpdate:modelValue":U[4]||(U[4]=Z=>B.value=Z),placeholder:p(c)("e.g. Super Reduced, Luxury"),maxlength:"30"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"])],64)}}},Lce={class:"fct-vat-card-header"},Rce={class:"fct-vat-card-title"},Oce={class:"fct-vat-card-body"},Hce={class:"fct-vat-reg-info"},Pce={class:"fct-vat-country-name"},Nce={key:0,size:"small",type:"success",class:"ml-3 fct-collecting-badge"},Kce={key:1,class:"ml-3 text-sm text-system-mid dark:text-gray-400"},Gce={key:2,class:"fct-country-registrations-list mt-4"},jce={class:"fct-reg-rows"},zce={key:0,class:"fct-vat-registration-row"},Yce={class:"fct-vat-reg-info"},qce=["src","alt"],Wce={class:"fct-vat-country-name"},Xce={class:"fct-vat-reg-info"},Jce=["src","alt"],Zce={class:"fct-vat-country-name"},eAe={key:0,class:"fct-vat-number"},tAe={key:1,class:"fct-vat-missing-badge"},aAe={class:"fct-vat-reg-actions"},nAe={key:1,class:"fct-vat-empty-state"},sAe={class:"text-system-mid text-sm"},lAe={key:0,class:"px-5 py-3"},oAe={key:1,class:"fct-vat-cross-border-empty"},rAe={class:"fct-vat-cross-border-empty-text"},iAe={class:"fct-vat-cross-border-empty-title"},dAe={class:"fct-vat-cross-border-empty-desc"},uAe={__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,n=t,s=V({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),o=V(!1),u=V(null),A=V([]),f=V(!1),m=V({country:"",vat:"",rates:{},isEdit:!1}),g=j(()=>a.countries.length||28),y=j(()=>a.initialRegistrations.filter(M).length),v=j(()=>a.storeCountry&&a.countries.find(Y=>Y.value===a.storeCountry)||null),B=j(()=>a.storeCountry?a.initialRegistrations.some(Y=>Y.country===a.storeCountry):!1),b=j(()=>{if(s.value.method!=="home"||!s.value.home_country)return!1;const Y=a.initialRegistrations.find(N=>N.country===s.value.home_country);return!!Y&&M(Y)}),w=j(()=>s.value.method==="oss"||s.value.method==="home"||s.value.method==="specific");function k(Y){if(!Y||!Array.isArray(a.countries))return Y;const N=a.countries.find(oe=>oe.value===Y);return N?N.label:Y}function S(Y){return Y?Y.rates&&typeof Y.rates=="object"&&Object.keys(Y.rates).length?Object.values(Y.rates).some(N=>N&&parseFloat(N.rate)>0):parseFloat(Y.rate)>0:!1}function M(Y){return!!Y&&!!Y.vat&&S(Y)}function $(Y){return S(Y)&&!Y.vat}function F(){return re.get("tax/classes").then(Y=>{A.value=Y.classes||[]}).catch(()=>{q.error(c("Failed to load tax classes"))})}function L(Y){const N={};return A.value.forEach(oe=>{N[oe.slug]={rate:oe.slug==="standard"&&Y||"",label:""}}),N}function Q(){const Y=v.value&&!B.value?a.storeCountry:"",N=Y&&v.value&&v.value.default_rate||"";m.value={country:Y,vat:"",rates:L(N),isEdit:!1},f.value=!0}function T(Y){const N=Y.rates||{},oe={};A.value.forEach(Z=>{const le=N[Z.slug];if(le&&typeof le=="object")oe[Z.slug]={rate:le.rate||"",label:le.label||""};else{const te=Z.slug==="standard"?Y.rate||"":le||"";oe[Z.slug]={rate:te,label:Z.slug==="standard"&&Y.tax_label||""}}}),m.value={country:Y.country,vat:Y.vat||"",rates:oe,isEdit:!0},f.value=!0}function D(){F(),n("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}function U(Y){re.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:Y.country,vat:Y.vat,rates:Y.rates}).then(N=>{q.success(N.message),n("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:Y.vat})}).catch(N=>{var oe;q.error(((oe=N==null?void 0:N.data)==null?void 0:oe.message)||c("Failed to save VAT registration"))})}function I(Y){en(c("Are you sure you want to remove this country registration?"),c("Confirm Remove"),{confirmButtonText:c("Yes, Remove"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{re.post("tax/configuration/settings/eu-vat",{action:"deleteCountryRegistration",country:Y}).then(N=>{q.success(N.message),n("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}).catch(N=>{var oe;q.error((oe=N==null?void 0:N.data)==null?void 0:oe.message)})}).catch(()=>{})}function O(){return y.value===1?c("Collecting in 1 country"):c("Collecting in %1$s countries",y.value)}const P=j(()=>g.value===1?c("Collecting in 1 region"):c("Collecting in %1$s regions",g.value));function K(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"&&ye(()=>{var N;return(N=u.value)==null?void 0:N.loadRates()}),n("method-changed",{method:Y.method,home_country:Y.home_country,home_vat:Y.home_country_vat})}function G(Y){Y==="edit"?o.value=!0:Y==="stop"&&ne()}function ne(){en(c("Are you sure you want to stop collecting cross-border VAT? This will clear your OSS/home country registration."),c("Stop Collecting"),{confirmButtonText:c("Yes, Stop"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{re.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:""},n("method-changed",{method:"",home_country:"",home_vat:""})}).catch(Y=>{var N;q.error((N=Y==null?void 0:Y.data)==null?void 0:N.message)})}).catch(()=>{})}return ge(()=>a.initialForm,Y=>{const N=Y||{};s.value={method:N.method||"",oss_country:N.oss_country||"",oss_vat:N.oss_vat||"",home_country:N.home_country||"",home_vat:N.home_vat||""}},{immediate:!0}),ge(()=>a.countries,Y=>{Y&&Y.length&&F()},{immediate:!0}),(Y,N)=>{const oe=C("el-tooltip"),Z=C("el-dropdown-item"),le=C("el-dropdown-menu"),te=C("el-dropdown"),X=C("el-button");return d(),_(H,null,[l(he,{class:"fct-vat-card"},{default:i(()=>[l(me,null,{default:i(()=>[r("div",Lce,[r("div",Rce,[r("h3",null,h(p(c)("Collect VAT cross-border")),1),l(oe,{content:p(c)("Choose how to collect VAT for sales to other EU countries."),placement:"top"},{default:i(()=>[l(W,{name:"InformationFill",class:"w-4 h-4 text-system-mid cursor-pointer"})]),_:1},8,["content"])]),w.value?(d(),E(te,{key:0,trigger:"click",onCommand:G,"popper-class":"fct-dropdown",placement:"bottom-end"},{dropdown:i(()=>[l(le,null,{default:i(()=>[l(Z,{command:"edit"},{default:i(()=>[R(h(p(c)("Edit registration")),1)]),_:1}),l(Z,{command:"stop"},{default:i(()=>[R(h(p(c)("Stop collecting")),1)]),_:1})]),_:1})]),default:i(()=>[l(Oe,{border:"none",size:"small",tag:"button"},{default:i(()=>[l(W,{name:"More"})]),_:1})]),_:1})):x("",!0)]),r("div",Oce,[w.value?(d(),_(H,{key:0},[r("div",Hce,[N[4]||(N[4]=r("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),r("span",Pce,h(s.value.method==="oss"?p(c)("EU (OSS)"):s.value.method==="home"?p(c)("EU (micro-business)"):p(c)("EU (specific countries)")),1),e.isTaxEnabled&&(s.value.method!=="specific"||y.value>0)?(d(),_("span",Nce,[N[3]||(N[3]=r("span",{class:"fct-green-dot"},null,-1)),s.value.method==="specific"?(d(),_(H,{key:0},[R(h(O()),1)],64)):(d(),_(H,{key:1},[R(h(P.value),1)],64))])):x("",!0),e.isTaxEnabled?x("",!0):(d(),_("span",Kce,h(p(c)("Tax disabled")),1))]),s.value.method==="home"?(d(),E(Na,{key:0,type:b.value?"info":"warning",icon:"Info",class:"mb-4 mt-4",content:b.value?p(c)("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.",k(s.value.home_country)):p(c)("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.",k(s.value.home_country))},null,8,["type","content"])):x("",!0),s.value.method==="home"?(d(),E(Ace,{key:1,countries:e.countries,"home-country":s.value.home_country,"home-vat":s.value.home_vat,"tax-classes":A.value,registrations:e.initialRegistrations,onSaveHome:U,onClassChanged:F},null,8,["countries","home-country","home-vat","tax-classes","registrations"])):x("",!0),s.value.method==="specific"?(d(),_("div",Gce,[r("div",jce,[v.value&&!B.value?(d(),_("div",zce,[r("div",Yce,[r("img",{src:`https://flagcdn.com/w40/${e.storeCountry.toLowerCase()}.png`,alt:v.value.label,class:"fct-flag-icon"},null,8,qce),r("span",Wce,h(v.value.label),1)]),l(X,{size:"small",onClick:Q},{default:i(()=>[R(h(p(c)("Configure")),1)]),_:1})])):x("",!0),(d(!0),_(H,null,ee(e.initialRegistrations,ie=>(d(),_("div",{key:ie.country,class:"fct-vat-registration-row"},[r("div",Xce,[r("img",{src:`https://flagcdn.com/w40/${ie.country.toLowerCase()}.png`,alt:k(ie.country),class:"fct-flag-icon"},null,8,Jce),r("span",Zce,h(k(ie.country)),1),ie.vat?(d(),_("span",eAe,h(ie.vat),1)):$(ie)?(d(),_("span",tAe,h(p(c)("VAT ID missing")),1)):x("",!0)]),r("div",aAe,[S(ie)?(d(),E(Oe,{key:0,border:"none",size:"small",tag:"button",title:p(c)("Edit"),onClick:be=>T(ie)},{default:i(()=>[l(W,{name:"Edit"})]),_:2},1032,["title","onClick"])):(d(),E(X,{key:1,size:"small",onClick:be=>T(ie)},{default:i(()=>[R(h(p(c)("Configure")),1)]),_:2},1032,["onClick"])),l(Oe,{border:"none",size:"small",tag:"button",title:p(c)("Delete"),onClick:be=>I(ie.country)},{default:i(()=>[l(W,{name:"Delete"})]),_:2},1032,["title","onClick"])])]))),128)),!e.initialRegistrations.length&&!v.value?(d(),_("div",nAe,[r("p",sAe,h(p(c)("No country VAT registrations configured.")),1),l(X,{type:"primary",size:"small",onClick:Q},{default:i(()=>[R(h(p(c)("Configure")),1)]),_:1})])):x("",!0)]),e.initialRegistrations.length||v.value?(d(),_("div",lAe,[l(X,{type:"primary",link:"",onClick:Q},{default:i(()=>[R(" + "+h(p(c)("Collect in another country")),1)]),_:1})])):x("",!0)])):x("",!0),s.value.method==="oss"?(d(),E(Mce,{key:3,ref_key:"ossRatesRef",ref:u},null,512)):x("",!0)],64)):(d(),_("div",oAe,[N[5]||(N[5]=r("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),r("div",rAe,[r("p",iAe,h(p(c)("Not collecting cross-border VAT")),1),r("p",dAe,h(p(c)("Set up OSS, micro-business, or specific-country registrations to collect VAT across the EU.")),1)]),l(X,{size:"small",onClick:N[0]||(N[0]=ie=>o.value=!0),type:"primary"},{default:i(()=>[R(h(p(c)("Configure")),1)]),_:1})]))])]),_:1})]),_:1}),l(Kue,{modelValue:o.value,"onUpdate:modelValue":N[1]||(N[1]=ie=>o.value=ie),countries:e.countries,"current-form":s.value,"initial-registrations":e.initialRegistrations,onSaved:K},null,8,["modelValue","countries","current-form","initial-registrations"]),l(Ece,{modelValue:f.value,"onUpdate:modelValue":N[2]||(N[2]=ie=>f.value=ie),countries:e.countries,"tax-classes":A.value,"initial-form":m.value,"registered-countries":e.initialRegistrations.map(ie=>ie.country),onSaved:D},null,8,["modelValue","countries","tax-classes","initial-form","registered-countries"])],64)}}},cAe={__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,n=t,s=V({type:"products",original_type:"",original_id:"",category_id:"",category_name:"",country:"",city:"",postcode:"",tax_label:"VAT",tax_rate:0,class_id:0,id:""}),o=V([]),u=V(!1),A=V(!1);function f(){return a.taxClasses&&a.taxClasses.length>0&&Number(a.taxClasses[0].id)||0}function m(){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 g(w){if(w.type==="shipping")s.value={type:"shipping",original_type:"shipping",original_id:w.id,category_id:"",category_name:"",country:w._raw.country||"",city:w._raw.city||"",postcode:w._raw.postcode||"",tax_label:w.tax_label,tax_rate:w.rate,class_id:Number(w._raw.class_id)||f(),id:w.id};else{const k=w._raw.meta_value||w._raw;s.value={type:"products",original_type:"products",original_id:w.id,category_id:yl(k.category_id),category_name:w.category_name,country:k.country||"",city:k.city||"",postcode:k.postcode||"",tax_label:w.tax_label,tax_rate:w.rate,class_id:Number(w.class_id)||0,id:w.id}}}ge(()=>a.modelValue,w=>{w&&(a.editRow?g(a.editRow):m(),y())}),ge(()=>s.value.type,w=>{w==="shipping"&&!s.value.class_id&&(s.value.class_id=f())}),ge(()=>a.taxClasses,w=>{s.value.type==="shipping"&&!s.value.class_id&&w&&w.length>0&&(s.value.class_id=Number(w[0].id)||0)});function y(){o.value.length>0||(u.value=!0,re.get("products/fetch-term").then(w=>{const k=w.taxonomies&&w.taxonomies["product-categories"]?w.taxonomies["product-categories"].terms||[]:[];o.value=k.map(S=>({...S,value:yl(S.value)}))}).catch(()=>{q.error(c("Failed to load product categories"))}).finally(()=>{u.value=!1}))}function v(w,k){return re.get("tax/rates/country/rates/"+w,{class_id:k}).then(S=>{const $=(S&&S.tax_rates?S.tax_rates:[]).find(function(L){return!L.state&&!L.city&&!L.postcode});if($)return $;const F=a.countries.find(function(L){return L.value===w});return re.post("tax/country/rate",{country:w,state:"",rate:F&&F.default_rate||0,name:"Tax",is_compound:0,for_order:0,group:"EU",class_id:k}).then(function(L){return L&&L.tax_rate?L.tax_rate:null})})}function B(w){const k=yl(w),S=o.value.find(M=>M.value===k);S&&(s.value.category_name=S.label)}function b(){if(s.value.type==="products"&&!s.value.category_id){q.error(c("Please select a category"));return}if(!s.value.country){q.error(c("Please select a location"));return}if(s.value.type==="shipping"){if(!a.taxClasses||a.taxClasses.length===0){q.error(c("Tax classes are not available. Please reload the page and try again."));return}if(!s.value.class_id){q.error(c("Please select a tax class"));return}}if(A.value=!0,s.value.type==="products")re.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(w=>{q.success(w.message),n("saved"),n("update:modelValue",!1)}).catch(w=>{q.error(w&&w.data?w.data.message:w&&w.message?w.message:"")}).finally(()=>{A.value=!1});else{const w=s.value.class_id;v(s.value.country,w).then(k=>k?re.post("tax/rates/country/override",{id:k.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:w,override_tax_rate:s.value.tax_rate,city:s.value.city||"",postcode:s.value.postcode||""}).then(S=>{q.success(S.message),n("saved"),n("update:modelValue",!1)}).catch(S=>{q.error(S&&S.data?S.data.message:S&&S.message?S.message:"")}).finally(()=>{A.value=!1}):(q.error(c("No tax rate found for the selected country and tax class")),A.value=!1,null)).catch(k=>{q.error(k&&k.data?k.data.message:k&&k.message?k.message:""),A.value=!1})}}return(w,k)=>{const S=C("el-radio"),M=C("el-radio-group"),$=C("el-form-item"),F=C("el-option"),L=C("el-select"),Q=C("el-input"),T=C("el-form"),D=C("el-button"),U=C("el-dialog");return d(),E(U,{"model-value":e.modelValue,title:e.editRow?p(c)("Edit tax override"):p(c)("Add tax override"),width:"520px","close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":k[14]||(k[14]=I=>n("update:modelValue",I))},{footer:i(()=>[l(D,{onClick:k[13]||(k[13]=I=>n("update:modelValue",!1))},{default:i(()=>[R(h(p(c)("Cancel")),1)]),_:1}),l(D,{type:"primary",loading:A.value,onClick:b},{default:i(()=>[R(h(e.editRow?p(c)("Save changes"):p(c)("Add override")),1)]),_:1},8,["loading"])]),default:i(()=>[l(T,{"label-position":"top",model:s.value},{default:i(()=>[l($,{label:p(c)("Override type")},{default:i(()=>[l(M,{modelValue:s.value.type,"onUpdate:modelValue":k[0]||(k[0]=I=>s.value.type=I)},{default:i(()=>[l(S,{value:"products"},{default:i(()=>[R(h(p(c)("Products")),1)]),_:1}),l(S,{value:"shipping"},{default:i(()=>[R(h(p(c)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),s.value.type==="products"?(d(),_(H,{key:0},[l($,{label:p(c)("Category")},{default:i(()=>[l(L,{modelValue:s.value.category_id,"onUpdate:modelValue":k[1]||(k[1]=I=>s.value.category_id=I),filterable:"",placeholder:p(c)("Select a category"),loading:u.value,style:{width:"100%"},onChange:B},{default:i(()=>[(d(!0),_(H,null,ee(o.value,I=>(d(),E(F,{key:I.value,label:I.label,value:I.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),e.taxClasses.length>0?(d(),E($,{key:0,label:p(c)("Tax Class")},{default:i(()=>[l(L,{modelValue:s.value.class_id,"onUpdate:modelValue":k[2]||(k[2]=I=>s.value.class_id=I),style:{width:"100%"}},{default:i(()=>[l(F,{value:0,label:p(c)("All Tax Classes")},null,8,["label"]),(d(!0),_(H,null,ee(e.taxClasses,I=>(d(),E(F,{key:I.id,value:Number(I.id),label:I.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):x("",!0),l($,{label:p(c)("Tax label")},{default:i(()=>[l(Q,{modelValue:s.value.tax_label,"onUpdate:modelValue":k[3]||(k[3]=I=>s.value.tax_label=I),placeholder:p(c)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l($,{label:p(c)("Location")},{default:i(()=>[l(L,{modelValue:s.value.country,"onUpdate:modelValue":k[4]||(k[4]=I=>s.value.country=I),placeholder:p(c)("Select country"),filterable:"",style:{width:"100%"}},{default:i(()=>[(d(!0),_(H,null,ee(e.countries,I=>(d(),E(F,{key:I.value,label:I.label,value:I.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),l($,{label:p(c)("City (optional)")},{default:i(()=>[l(Q,{modelValue:s.value.city,"onUpdate:modelValue":k[5]||(k[5]=I=>s.value.city=I),placeholder:p(c)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l($,{label:p(c)("Postcode (optional)")},{default:i(()=>[l(Q,{modelValue:s.value.postcode,"onUpdate:modelValue":k[6]||(k[6]=I=>s.value.postcode=I),placeholder:p(c)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l($,{label:p(c)("Tax rate (%)")},{default:i(()=>[l(Q,{modelValue:s.value.tax_rate,"onUpdate:modelValue":k[7]||(k[7]=I=>s.value.tax_rate=I),type:"number",step:"0.01",min:"0",placeholder:p(c)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])],64)):(d(),_(H,{key:1},[l($,{label:p(c)("Location")},{default:i(()=>[l(L,{modelValue:s.value.country,"onUpdate:modelValue":k[8]||(k[8]=I=>s.value.country=I),placeholder:p(c)("Select country"),filterable:"",style:{width:"100%"}},{default:i(()=>[(d(!0),_(H,null,ee(e.countries,I=>(d(),E(F,{key:I.value,label:I.label,value:I.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),e.taxClasses.length>0?(d(),E($,{key:0,label:p(c)("Tax Class")},{default:i(()=>[l(L,{modelValue:s.value.class_id,"onUpdate:modelValue":k[9]||(k[9]=I=>s.value.class_id=I),style:{width:"100%"}},{default:i(()=>[(d(!0),_(H,null,ee(e.taxClasses,I=>(d(),E(F,{key:I.id,value:Number(I.id),label:I.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):x("",!0),l($,{label:p(c)("City (optional)")},{default:i(()=>[l(Q,{modelValue:s.value.city,"onUpdate:modelValue":k[10]||(k[10]=I=>s.value.city=I),placeholder:p(c)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l($,{label:p(c)("Postcode (optional)")},{default:i(()=>[l(Q,{modelValue:s.value.postcode,"onUpdate:modelValue":k[11]||(k[11]=I=>s.value.postcode=I),placeholder:p(c)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l($,{label:p(c)("Tax rate (%)")},{default:i(()=>[l(Q,{modelValue:s.value.tax_rate,"onUpdate:modelValue":k[12]||(k[12]=I=>s.value.tax_rate=I),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["model-value","title"])}}},AAe={class:"fct-tax-rates-country-view"},pAe={key:0,class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},fAe={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"},mAe={key:0},hAe={key:1},_Ae={class:"fct-btn-group sm justify-end"},gAe={__name:"EUVatTaxOverridesCard",props:{countries:{type:Array,default:()=>[]}},setup(e){const t=e,a=V([]),n=V(!1),s=V(!1),o=V(null),u=V([]);function A(B){if(!B||!Array.isArray(t.countries))return B;const b=t.countries.find(w=>w.value===B);return b?b.label:B}function f(){re.get("tax/classes").then(B=>{u.value=B.classes||[]}).catch(()=>{q.error(c("Failed to load tax classes"))})}function m(){n.value=!0,re.get("tax/configuration/settings/eu-vat/product-overrides").then(B=>{const b=[],w=B.overrides||[];for(const S of w){const M=S.meta_value||S;b.push({id:S.id,type:"products",tax_label:M.tax_label||"",category_name:M.category_name||"",location:A(M.country),city:M.city||"",postcode:M.postcode||"",rate:M.rate,class_id:Number(S.class_id)||0,class_label:S.class_label||"",_raw:S})}const k=B.shipping_overrides||[];for(const S of k)b.push({id:S.id,type:"shipping",tax_label:S.name||"",category_name:"",location:A(S.country),city:S.city||"",postcode:S.postcode||"",rate:S.for_shipping,class_id:Number(S.class_id)||0,class_label:S.class_label||"",_raw:S});a.value=b}).catch(()=>{a.value=[]}).finally(()=>{n.value=!1})}function g(){o.value=null,s.value=!0}function y(B){o.value=B,s.value=!0}function v(B){en(c("Are you sure you want to delete this override?"),c("Confirm Delete"),{confirmButtonText:c("Yes, Delete"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{const b=B.type==="shipping"?"tax/rates/country/override/"+B.id:"tax/product-overrides/"+B.id;re.delete(b).then(w=>{q.success(w.message),a.value=a.value.filter(k=>!(k.id===B.id&&k.type===B.type))}).catch(w=>{var k;q.error((k=w==null?void 0:w.data)==null?void 0:k.message)})}).catch(()=>{})}return Be(()=>{f(),m()}),(B,b)=>{const w=C("el-button"),k=C("el-tag"),S=C("el-table-column"),M=C("el-table");return d(),_(H,null,[l(he,{class:"fct-vat-card"},{default:i(()=>[l(Ce,{title:p(c)("Tax overrides"),text:p(c)("Override tax rates for specific product categories or shipping.")},{action:i(()=>[l(w,{size:"small",onClick:g},{default:i(()=>[R(h(p(c)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),l(me,null,{default:i(()=>[r("div",AAe,[n.value?(d(),_("div",pAe,[r("div",fAe,[(d(),_(H,null,ee(6,$=>r("div",{key:"loading-header-"+$,class:"fct-sk h-3 rounded-xs"})),64))]),(d(),_(H,null,ee(3,$=>r("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"},b[2]||(b[2]=[r("div",{class:"fct-sk w-16 h-6 rounded-full"},null,-1),r("div",{class:"fct-sk w-28 h-3.5 rounded-xs"},null,-1),r("div",{class:"fct-sk w-24 h-3.5 rounded-xs"},null,-1),r("div",{class:"fct-sk w-24 h-3.5 rounded-xs"},null,-1),r("div",{class:"fct-sk w-12 h-3.5 rounded-xs"},null,-1),r("div",{class:"fct-sk w-4 h-4 rounded-xs justify-self-end"},null,-1)]))),64))])):(d(),E(M,{key:1,data:a.value,"empty-text":p(c)("No overrides configured")},{default:i(()=>[l(S,{label:p(c)("Type"),width:"110"},{default:i(({row:$})=>[l(k,{type:$.type==="products"?"primary":"info",size:"small"},{default:i(()=>[R(h($.type==="products"?p(c)("Product"):p(c)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),l(S,{label:p(c)("Category")},{default:i(({row:$})=>[R(h($.category_name||"—"),1)]),_:1},8,["label"]),l(S,{label:p(c)("Tax Class"),width:"130"},{default:i(({row:$})=>[R(h($.class_label||p(c)("All")),1)]),_:1},8,["label"]),l(S,{label:p(c)("Tax Label")},{default:i(({row:$})=>[R(h($.tax_label||"—"),1)]),_:1},8,["label"]),l(S,{label:p(c)("Location")},{default:i(({row:$})=>[R(h($.location),1)]),_:1},8,["label"]),l(S,{label:p(c)("City / Postcode")},{default:i(({row:$})=>[$.city||$.postcode?(d(),_("span",mAe,h([$.city,$.postcode].filter(Boolean).join(" / ")),1)):(d(),_("span",hAe,"—"))]),_:1},8,["label"]),l(S,{label:p(c)("Rate"),width:"100"},{default:i(({row:$})=>[R(h($.rate)+"% ",1)]),_:1},8,["label"]),l(S,{label:p(c)("Actions"),width:"110",align:"right"},{default:i(({row:$})=>[r("div",_Ae,[l(Oe,{tag:"button",size:"small",onClick:F=>y($)},{default:i(()=>[l(W,{name:"Edit"})]),_:2},1032,["onClick"]),l(Oe,{tag:"button",size:"small",onClick:F=>v($),bg:"danger",outline:""},{default:i(()=>[l(W,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"]))])]),_:1})]),_:1}),l(cAe,{modelValue:s.value,"onUpdate:modelValue":[b[0]||(b[0]=$=>s.value=$),b[1]||(b[1]=$=>!$&&(o.value=null))],countries:e.countries,"tax-classes":u.value,"edit-row":o.value,onSaved:m},null,8,["modelValue","countries","tax-classes","edit-row"])],64)}}},vAe={class:"setting-wrap"},yAe={class:"setting-wrap-inner"},bAe={class:"fct-tax-collection-page"},wAe={__name:"EUVatSettings",setup(e){const t=V(!0),a=Ie.get("eu_vat_county_options",[]),n=V(""),s=V(""),o=V([]),u=V({}),A=j(()=>!!Ie.get("is_tax_enabled"));function f(){return t.value=!0,re.get("tax/configuration/settings").then(g=>{var v;const y=((v=g.settings)==null?void 0:v.eu_vat_settings)||{};n.value=g.store_country||"",o.value=y.country_registrations||[],u.value=y,s.value=y.method||""}).catch(g=>{var y;q.error((y=g==null?void 0:g.data)==null?void 0:y.message)}).finally(()=>{t.value=!1})}function m({method:g}){s.value=g||"",f()}return Be(f),(g,y)=>(d(),_("div",vAe,[l(ha,{heading:p(c)("VAT collection"),"show-save-button":!1},null,8,["heading"]),r("div",yAe,[l(_a),r("div",bAe,[t.value?(d(),E(Que,{key:0})):(d(),_(H,{key:1},[l(uAe,{countries:p(a),"initial-form":u.value,"initial-registrations":o.value,"store-country":n.value,"is-tax-enabled":A.value,onMethodChanged:m},null,8,["countries","initial-form","initial-registrations","store-country","is-tax-enabled"]),l(gAe,{countries:p(a),class:"mt-5"},null,8,["countries"])],64))])])]))}};class CAe extends Gs{getTabs(){return{all:c("All"),active:c("Active"),expired:c("Inactive")}}getToggleableColumns(){return[{label:"Title",value:"title"},{label:"Stackable",value:"stackable"},{label:"Actions",value:"actions"}]}getSortableColumns(){return[{label:c("ID"),value:"id"},{label:c("Title"),value:"title"},{label:c("Code"),value:"code"},{label:c("Amount"),value:"amount"},{label:c("Max Uses"),value:"max_uses"},{label:c("Stackable"),value:"stackable"},{label:c("Status"),value:"status"},{label:c("Expiry Date"),value:"expiry_date"}]}getSearchHint(){return c("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["appliedCouponsCount"]}}function wm(e){return CAe.init(e)}const BAe={class:"fct-table-mobile-wrap fct-coupons-table-mobile-wrap"},kAe={class:"fct-table-mobile-header"},xAe={class:"fct-table-mobile-header-left"},SAe={class:"fct-table-id-col"},FAe={class:"fct-table-status-col"},EAe=["onClick"],UAe={class:"title"},$Ae={class:"value"},DAe={key:0,class:"fct-table-action-col"},QAe={class:"more-btn pr-0"},IAe={class:"fct-table-mobile-body"},TAe=["onClick"],VAe={key:0,class:"fct-table-coupon-title-col"},MAe={class:"fct-table-coupon-code-col"},LAe=["onClick"],RAe={class:"fct-table-mobile-footer"},OAe=["onClick"],HAe={class:"fct-table-date-col grid"},PAe={class:"title"},NAe={class:"value"},KAe={key:0,class:"fct-table-stackable-col"},GAe={class:"title"},jAe={class:"value"},zAe={class:"fct-table-amount-col"},YAe={class:"title"},qAe={class:"value"},WAe={__name:"CouponsTableMobile",props:{table:{type:Object,required:!0},emptyText:{type:String,default:c("No customers found.")}},setup(e){Re.extend(Gr);const t=e,a=s=>{if(!s||s==="0000-00-00 00:00:00")return!1;const o=Re.utc(s).local();return o.isValid()?o.isBefore(Re()):!1},n=s=>{let o=c("Are you sure you want to delete this %s coupon. This action is not recoverable",s.coupon.title);s.action==="delete"&&en(o,c("Confirm Delete!"),{confirmButtonText:c("Yes, Delete!"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{re.delete("coupons/"+s.coupon.id).then(u=>{q.success(u.message),t.table.fetch()}).catch(u=>{q.error(u)}).finally(()=>{})}).catch(()=>{})};return(s,o)=>{const u=C("router-link"),A=C("el-tooltip"),f=C("el-dropdown-item"),m=C("el-dropdown-menu"),g=C("el-dropdown");return d(),_("div",BAe,[(d(!0),_(H,null,ee(e.table.getTableData(),(y,v)=>(d(),_("div",{key:y.id,class:"fct-table-mobile-row"},[r("div",kAe,[r("div",xAe,[r("div",SAe,[l(u,{to:{name:"add_or_edit_coupon",params:{coupon_id:y.id}},class:"id"},{default:i(()=>[R(" #"+h(y.id),1)]),_:2},1032,["to"])]),r("div",FAe,[l(qt,{status:y.status},{default:i(()=>[R(h(a(y.end_date)?p(c)("Expired"):y.status),1)]),_:2},1032,["status"]),y.status==="scheduled"?(d(),E(A,{key:0,effect:"dark",placement:"top","popper-class":"fct-label-hint-popover fct-tooltip","show-after":400,"hide-after":0},{content:i(()=>[R(h(p(c)("Available On: %s",p(Hs)(y.start_date,!0))),1)]),default:i(()=>[l(W,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):x("",!0)]),r("div",{class:"fct-table-usage-col",onClick:B=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[r("div",UAe,h(p(c)("Usage:")),1),r("div",$Ae,[R(h(y.use_count??0)+" ",1),o[0]||(o[0]=r("span",null,"/",-1)),R(" "+h(y.conditions.max_uses>0?y.conditions.max_uses:p(c)("Unlimited")),1)])],8,EAe)]),e.table.isColumnVisible("actions")?(d(),_("div",DAe,[l(g,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:n,placement:"bottom-end"},{dropdown:i(()=>[l(m,null,{default:i(()=>[y.id?(d(),E(f,{key:0,class:"item-link"},{default:i(()=>[l(u,{to:{name:"add_or_edit_coupon",params:{coupon_id:y.id,action:"edit"}}},{default:i(()=>[l(W,{name:"Edit"}),R(" "+h(p(c)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):x("",!0),l(f,{command:{action:"delete",coupon:y},class:"item-destructive"},{default:i(()=>[l(W,{name:"Delete"}),R(" "+h(p(c)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:i(()=>[r("span",QAe,[l(W,{name:"More"})])]),_:2},1024)])):x("",!0)]),r("div",IAe,[r("div",{class:"fct-table-coupon-code-wrapper-col",onClick:B=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[e.table.isColumnVisible("title")?(d(),_("div",VAe,h(y.title),1)):x("",!0),r("div",MAe,[r("code",{class:"copyable-content",onClick:B=>{p(Os).copy(y.code)}},h(y.code),9,LAe)])],8,TAe)]),r("div",RAe,[r("div",{class:"fct-table-mobile-footer-row items-start",onClick:B=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[r("div",HAe,[r("div",PAe,h(p(c)("Expiry Date")),1),r("div",NAe,[isNaN(Date.parse(y.end_date))?(d(),_(H,{key:1},[R("n/a")],64)):(d(),E($a,{key:0,"date-time":y.end_date,"with-time":!0},null,8,["date-time"]))])]),e.table.isColumnVisible("stackable")?(d(),_("div",KAe,[r("div",GAe,h(p(c)("Stackable")),1),r("div",jAe,h(y.stackable),1)])):x("",!0),r("div",zAe,[r("div",YAe,h(p(c)("Amount")),1),r("div",qAe,h(y.type!=="percentage"?p(Jt)(y.amount,!0):y.amount+"%"),1)])],8,OAe)])]))),128))])}}},XAe={},JAe={class:"px-4 py-3"},ZAe={class:"grid grid-cols-3 gap-5 mt-5"};function epe(e,t){const a=C("el-skeleton-item"),n=C("el-skeleton");return d(),E(n,{animated:""},{template:i(()=>[r("div",JAe,[(d(),_(H,null,ee(2,s=>r("div",{key:s,class:"flex items-center justify-between mb-3"},[l(a,{varient:"p",class:"w-1/2"}),l(a,{varient:"p",class:"w-[100px]"})])),64)),r("div",ZAe,[(d(),_(H,null,ee(3,s=>r("div",{key:s},[l(a,{varient:"p",class:"w-1/2"}),l(a,{varient:"p",class:"w-[100px]"})])),64))])])]),_:1})}const tpe=He(XAe,[["render",epe]]),ape={class:"fct-all-coupons-page fct-layout-width"},npe={class:"fct-all-coupons-wrap"},spe={key:1},lpe=["onClick"],ope={class:"capitalize"},rpe={class:"more-btn mr-2"},QA={__name:"AllCoupons",setup(e){Re.extend(Gr);const t=wm(),a=V(!1),n=u=>{let A=c("Are you sure you want to delete this %s coupon. This action is not recoverable",u.coupon.title);u.action==="delete"&&en(A,c("Confirm Delete!"),{confirmButtonText:c("Yes, Delete!"),cancelButtonText:c("Cancel"),type:"warning"}).then(()=>{re.delete("coupons/"+u.coupon.id).then(f=>{q.success(f.message),t.fetch()}).catch(f=>{var m;f.status_code=="422"?q.validationErrors(f):q.error((m=f.data)==null?void 0:m.message)}).finally(()=>{})}).catch(()=>{})},s=()=>{re.get("coupons/getSettings").then(u=>{a.value=!!parseInt(u.show_on_checkout)}).catch(u=>{var A;u.status_code=="422"?q.validationErrors(u):q.error((A=u.data)==null?void 0:A.message)}).finally(()=>{})},o=u=>{if(!u||u==="0000-00-00 00:00:00")return!1;const A=Re.utc(u).local();return A.isValid()?A.isBefore(Re()):!1};return Be(()=>{s()}),(u,A)=>{const f=C("el-button"),m=C("el-table-column"),g=C("el-tooltip"),y=C("router-link"),v=C("el-dropdown-item"),B=C("el-dropdown-menu"),b=C("el-dropdown"),w=C("el-table");return d(),E(St,{permission:"coupons/view"},{default:i(()=>[r("div",ape,[l(za,{title:p(c)("Coupons")},{action:i(()=>[l(f,{tag:"router-link",type:"primary",to:{name:"add_or_edit_coupon"}},{default:i(()=>[R(h(p(c)("Add Coupon")),1)]),_:1})]),_:1},8,["title"]),r("div",npe,[l(js,{table:p(t),"has-mobile-slot":!0},{mobile:i(()=>[p(t).isLoading()?(d(),E(tpe,{key:0})):x("",!0),p(t).isLoading()?x("",!0):(d(),E(WAe,{key:1,table:p(t)},null,8,["table"]))]),default:i(()=>[p(t).isLoading()?(d(),E(tue,{key:0,couponTable:p(t),"next-page-count":p(t).nextPageCount},null,8,["couponTable","next-page-count"])):(d(),_("div",spe,[l(w,{data:p(t).getTableData(),class:"w-full compact-table full-compact"},{empty:i(()=>[l(at,{icon:"Empty/Order","has-dark":"",text:p(c)("No coupons available at the moment.")},null,8,["text"])]),default:i(()=>[l(m,{width:100,label:p(c)("ID")},{default:i(k=>[l(na,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:k.row.id}}},{default:i(()=>[R(" #"+h(p(Kt)(k.row.id)),1)]),_:2},1032,["to"])]),_:1},8,["label"]),p(t).isColumnVisible("title")?(d(),E(m,{key:0,label:p(c)("Title"),width:220},{default:i(k=>[l(na,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:k.row.id,action:"edit"}}},{default:i(()=>[R(h(k.row.title),1)]),_:2},1032,["to"])]),_:1},8,["label"])):x("",!0),l(m,{label:p(c)("Code"),width:200},{default:i(k=>[r("code",{class:"copyable-content",onClick:S=>{p(Os).copy(k.row.code)}},h(k.row.code),9,lpe)]),_:1},8,["label"]),l(m,{label:p(c)("Amount"),width:120},{default:i(k=>[l(na,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:k.row.id,action:"edit"}}},{default:i(()=>[R(h(k.row.type!=="percentage"?p(Jt)(k.row.amount,!0):k.row.amount+"%"),1)]),_:2},1032,["to"])]),_:1},8,["label"]),l(m,{label:p(c)("Usage"),width:150},{default:i(k=>[l(na,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:k.row.id,action:"edit"}}},{default:i(()=>[r("span",null,h(p(Kt)(k.row.use_count??0)),1),A[0]||(A[0]=r("span",{class:"px-1"},"/",-1)),r("span",null,h(k.row.conditions.max_uses>0?k.row.conditions.max_uses:p(c)("Unlimited")),1)]),_:2,__:[0]},1032,["to"])]),_:1},8,["label"]),p(t).isColumnVisible("stackable")?(d(),E(m,{key:1,label:p(c)("Stackable"),width:120},{default:i(k=>[l(na,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:k.row.id,action:"edit"}}},{default:i(()=>[r("span",ope,h(k.row.stackable),1)]),_:2},1032,["to"])]),_:1},8,["label"])):x("",!0),l(m,{label:p(c)("Status"),width:120},{default:i(k=>[l(na,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:k.row.id,action:"edit"}}},{default:i(()=>[l(qt,{status:k.row.status},{default:i(()=>[R(h(o(k.row.end_date)?p(c)("Expired"):k.row.status),1)]),_:2},1032,["status"]),k.row.status==="scheduled"?(d(),E(g,{key:0,effect:"dark",placement:"top","popper-class":"fct-label-hint-popover fct-tooltip","show-after":400,"hide-after":0},{content:i(()=>[R(h(p(c)("Available On: %s",p(Hs)(k.row.start_date,!0))),1)]),default:i(()=>[l(W,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):x("",!0)]),_:2},1032,["to"])]),_:1},8,["label"]),l(m,{label:p(c)("Expiry Date"),width:120},{default:i(k=>[l(na,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:k.row.id,action:"edit"}}},{default:i(()=>[r("span",null,[isNaN(Date.parse(k.row.end_date))?(d(),_(H,{key:1},[R("n/a")],64)):(d(),E($a,{key:0,"date-time":k.row.end_date,"with-time":!0},null,8,["date-time"]))])]),_:2},1032,["to"])]),_:1},8,["label"]),p(t).isColumnVisible("actions")?(d(),E(m,{key:2,label:p(c)("Actions"),width:100,align:"right",fixed:"right"},{default:i(k=>[l(b,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:n,placement:"bottom-end"},{dropdown:i(()=>[l(B,null,{default:i(()=>[k.row.id?(d(),E(v,{key:0,class:"item-link"},{default:i(()=>[l(y,{to:{name:"add_or_edit_coupon",params:{coupon_id:k.row.id,action:"edit"}}},{default:i(()=>[l(W,{name:"Edit"}),R(" "+h(p(c)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):x("",!0),l(v,{command:{action:"delete",coupon:k.row},class:"item-destructive"},{default:i(()=>[l(W,{name:"Delete"}),R(" "+h(p(c)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:i(()=>[r("span",rpe,[l(W,{name:"More"})])]),_:2},1024)]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"])])])]),_:1})}}},ipe={class:"fct-add-edit-coupon-wrapper fct-layout-width"},dpe={class:"single-page-header"},upe={class:"single-page-body"},cpe={class:"fct-add-edit-coupon"},Ape={class:"fct-add-edit-coupon-main"},ppe={class:"fct-add-edit-coupon-aside"},fpe={class:"fct-admin-sidebar"},mpe={__name:"SingleCouponLoader",setup(e){return(t,a)=>{const n=C("el-skeleton-item"),s=C("el-skeleton"),o=C("el-breadcrumb-item"),u=C("el-breadcrumb");return d(),_("div",ipe,[r("div",dpe,[l(u,{"separator-icon":p(tn)},{default:i(()=>[l(o,null,{default:i(()=>[l(s,{animated:!0},{template:i(()=>[l(n,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),l(o,null,{default:i(()=>[l(s,{animated:!0},{template:i(()=>[l(n,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),l(o,null,{default:i(()=>[l(s,{animated:!0},{template:i(()=>[l(n,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"])]),r("div",upe,[r("div",cpe,[r("div",Ape,[l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),l(me,null,{default:i(()=>[l(s,{animated:!0,class:"flex flex-col gap-3"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"}),l(n,{variant:"p",class:"max-w-[400px] h-4"}),l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Discount Value"),border_bottom:"",title_size:"small"},null,8,["title"]),l(me,null,{default:i(()=>[l(s,{animated:!0,class:"flex flex-col gap-3"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"}),l(n,{variant:"p",class:"max-w-[400px] h-4"}),l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),l(me,null,{default:i(()=>[l(s,{animated:!0,class:"flex flex-col gap-3"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"}),l(n,{variant:"p",class:"max-w-[400px] h-4"}),l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),l(me,null,{default:i(()=>[l(s,{animated:!0,class:"flex flex-col gap-3"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),l(me,null,{default:i(()=>[l(s,{animated:!0,class:"flex flex-col gap-3"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"}),l(n,{variant:"p",class:"max-w-[400px] h-4"}),l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"}),l(n,{variant:"p",class:"max-w-[400px] h-4"}),l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1})]),r("div",ppe,[r("div",fpe,[l(he,null,{default:i(()=>[l(Ce,{title:p(c)("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),l(me,null,{default:i(()=>[l(s,{animated:!0,class:"flex flex-col gap-3"},{template:i(()=>[l(n,{variant:"p",class:"w-full h-4"}),l(n,{variant:"p",class:"w-2/3 h-4"}),l(n,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1})])])])])])}}};Re.extend(Gr);Re.extend(cp);const hpe={name:"AddOrEditCoupon",components:{CardContainer:he,CardHeader:Ce,CardBody:me,LabelHint:sa,ValidationError:Pt,CopyToClipboard:Za,DynamicTemplates:Sl,SaveBar:Bl,ProductVariationSelector:Ap,SingleCouponLoader:mpe,Activity:op},beforeRouteLeave(e,t,a){var n;(n=this.keyboardShortcuts)!=null&&n.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:"",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 tn},maxDiscountAmount(){return this.coupon.type==="percentage"?100:999999}},watch:{coupon:{handler(){this.handleChangesMade()},deep:!0}},mounted(){this.keyboardShortcuts=ks(),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:c,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(){re.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,re.get(`coupons/${this.coupon_id}`,{}).then(e=>{var n,s;const t=(n=e==null?void 0:e.coupon)==null?void 0:n.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=Re.utc(t).tz(Re.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),a&&a!=="0000-00-00 00:00:00"&&(e.coupon.end_date=Re.utc(a).tz(Re.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.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}}),re.put(`coupons/${this.coupon_id}`,{...this.coupon,metaValue:(t=this.$refs.dynamic_templates)==null?void 0:t.getFormStates()}).then(a=>{var n;(n=this.$refs.dynamic_templates)==null||n.afterUpdatingData({coupon:this.coupon,response:a}),q.success(a.message),this.validationErrors={},this.setDefaultStatus(),this.changes_made=0}).catch(a=>{var n;a.status_code=="422"?(q.validationErrors(a),this.validationErrors=a):q.error((n=a.data)==null?void 0:n.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}}),re.post("coupons",{...this.coupon,metaValue:(t=this.$refs.dynamic_templates)==null?void 0:t.getFormStates()}).then(a=>{var n;(n=this.$refs.dynamic_templates)==null||n.afterUpdatingData({coupon:this.coupon,response:a}),q.success(a.message),this.$router.push({name:"coupons"}),this.validationErrors={}}).catch(a=>{var n;a.status_code=="422"?(q.validationErrors(a),this.validationErrors=a):q.error((n=a.data)==null?void 0:n.message)}).finally(()=>{this.creating=!1})}}},_pe={class:"fct-add-edit-coupon-wrapper fct-layout-width"},gpe={class:"single-page-header"},vpe={class:"single-page-body"},ype={class:"fct-add-edit-coupon"},bpe={class:"fct-add-edit-coupon-main"},wpe={class:"flex gap-2 items-center justify-between w-full mb-2.5"},Cpe={class:"form-note"},Bpe=["innerHTML"],kpe={key:1},xpe=["innerHTML"],Spe=["innerHTML"],Fpe=["innerHTML"],Epe={class:"fct-add-edit-coupon-aside"},Upe={class:"fct-admin-sidebar"},$pe={class:"fct-admin-sidebar-item"},Dpe={key:0,class:"flex items-center gap-1"},Qpe={class:"text-sm font-medium text-system-dark dark:text-gray-300"},Ipe={key:1},Tpe={class:"fct-admin-sidebar-item mt-5 hidden"},Vpe={class:"sidebar-title mb-3"},Mpe={class:"fct-bullet-lists"},Lpe={class:"fct-admin-sidebar-item mt-5 hidden"},Rpe={class:"sidebar-title mb-3"},Ope={class:"fct-bullet-lists"},Hpe={key:0};function Ppe(e,t,a,n,s,o){const u=C("SaveBar"),A=C("SingleCouponLoader"),f=C("el-breadcrumb-item"),m=C("el-breadcrumb"),g=C("CardHeader"),y=C("el-input"),v=C("ValidationError"),B=C("el-form-item"),b=C("el-col"),w=C("LabelHint"),k=C("el-row"),S=C("CardBody"),M=C("CardContainer"),$=C("el-option"),F=C("el-select"),L=C("ProductVariationSelector"),Q=C("el-checkbox"),T=C("el-radio"),D=C("el-radio-group"),U=C("el-form"),I=C("CopyToClipboard"),O=C("el-date-picker"),P=C("DynamicTemplates"),K=C("Activity");return d(),_("div",_pe,[l(u,{isActive:s.changes_made>0?"is-active":"",loading:a.coupon_id?s.updating:s.creating,onSave:t[0]||(t[0]=G=>a.coupon_id?o.updateCoupon():o.addCoupon()),onDiscard:o.reloadPage,"show-cmnd-icon":!0,saveButtonText:a.coupon_id?o.translate("Update"):o.translate("Create")},null,8,["isActive","loading","onDiscard","saveButtonText"]),s.fetchingCoupon?(d(),E(A,{key:0})):x("",!0),s.fetchingCoupon?x("",!0):(d(),_(H,{key:1},[r("div",gpe,[l(m,{"separator-icon":o.ArrowRight},{default:i(()=>[l(f,{to:{name:"coupons"}},{default:i(()=>[R(h(o.translate("Coupons")),1)]),_:1}),l(f,null,{default:i(()=>[R(h(a.coupon_id?o.translate("Edit Coupon"):o.translate("Add Coupon")),1)]),_:1}),a.coupon_id?(d(),E(f,{key:0},{default:i(()=>[R(h(s.coupon.title),1)]),_:1})):x("",!0)]),_:1},8,["separator-icon"])]),r("div",vpe,[r("div",ype,[r("div",bpe,[l(U,{model:s.coupon,"label-position":"top","require-asterisk-position":"right"},{default:i(()=>[l(M,null,{default:i(()=>[l(g,{title:o.translate("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),l(S,{class:"pb-1.5"},{default:i(()=>[l(k,{gutter:20},{default:i(()=>[l(b,{lg:24},{default:i(()=>[l(B,{label:o.translate("Title"),required:""},{default:i(()=>{var G,ne;return[l(y,{modelValue:s.coupon.title,"onUpdate:modelValue":t[1]||(t[1]=Y=>s.coupon.title=Y),placeholder:o.translate("Enter title"),class:de((G=s.validationErrors)!=null&&G.hasOwnProperty("title")?"is-error":""),maxlength:"50",id:"title"},null,8,["modelValue","placeholder","class"]),(ne=s.validationErrors)!=null&&ne.hasOwnProperty("title")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"title"},null,8,["validation-errors"])):x("",!0)]}),_:1},8,["label"])]),_:1}),l(b,{lg:12},{default:i(()=>[l(B,null,{default:i(()=>{var G,ne;return[r("div",wpe,[l(w,{title:o.translate("Code"),required:""},null,8,["title"]),r("span",{class:"text-system-dark text-xs cursor-pointer hover:underline dark:text-gray-50 underline",onClick:t[2]||(t[2]=(...Y)=>o.generateRandomCouponCode&&o.generateRandomCouponCode(...Y))},h(o.translate("Generate Random Code")),1)]),l(y,{modelValue:s.coupon.code,"onUpdate:modelValue":t[3]||(t[3]=Y=>s.coupon.code=Y),placeholder:o.translate("Eg. COUPON10"),class:de((G=s.validationErrors)!=null&&G.hasOwnProperty("code")?"is-error":""),maxlength:"20"},null,8,["modelValue","placeholder","class"]),(ne=s.validationErrors)!=null&&ne.hasOwnProperty("code")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"code"},null,8,["validation-errors"])):x("",!0),r("div",Cpe,[r("p",null,h(o.translate("Customers must enter this code at checkout.")),1)])]}),_:1})]),_:1}),l(b,{lg:12},{default:i(()=>[l(B,null,{label:i(()=>[l(w,{title:o.translate("Coupon Priority"),content:o.translate("Coupons will be calculated based on their priority. The lower the number the higher the priority is.")},null,8,["title","content"])]),default:i(()=>{var G,ne;return[l(y,{modelValue:s.coupon.priority,"onUpdate:modelValue":t[4]||(t[4]=Y=>s.coupon.priority=Y),type:"number",placeholder:o.translate("Enter priority"),class:de((G=s.validationErrors)!=null&&G.hasOwnProperty("priority")?"is-error":""),min:"0",max:"100",onInput:t[5]||(t[5]=Y=>{o.onChangeCouponInput("priority",Y)}),onKeypress:o.preventInvalidChars},null,8,["modelValue","placeholder","class","onKeypress"]),(ne=s.validationErrors)!=null&&ne.hasOwnProperty("priority")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"priority"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),l(M,null,{default:i(()=>[l(g,{title:o.translate("Discount Details"),border_bottom:"",title_size:"small"},null,8,["title"]),l(S,{class:"pb-1.5"},{default:i(()=>[l(k,{gutter:20},{default:i(()=>[l(b,{lg:8},{default:i(()=>[l(B,{label:o.translate("Type"),required:""},{default:i(()=>{var G;return[l(F,{modelValue:s.coupon.type,"onUpdate:modelValue":t[6]||(t[6]=ne=>s.coupon.type=ne),placeholder:o.translate("Select coupon type"),class:de((G=s.validationErrors)!=null&&G.hasOwnProperty("type")?"is-error":""),"default-first-option":""},{default:i(()=>[l($,{label:o.translate("Fixed"),value:"fixed"},null,8,["label"]),l($,{label:o.translate("Percentage"),value:"percentage"},null,8,["label"])]),_:1},8,["modelValue","placeholder","class"])]}),_:1},8,["label"])]),_:1}),s.coupon.type==="fixed"||s.coupon.type==="percentage"?(d(),_(H,{key:0},[l(b,{lg:8},{default:i(()=>[l(B,{label:s.coupon.type==="percentage"?o.translate("Discount Percentage (%)"):o.translate("Discount Amount"),required:""},{default:i(()=>{var G;return[l(y,{modelValue:s.coupon.amount,"onUpdate:modelValue":t[7]||(t[7]=ne=>s.coupon.amount=ne),type:"number",placeholder:"0.00",min:s.minDiscountAmount,max:o.maxDiscountAmount,step:"0.01",onInput:t[8]||(t[8]=ne=>{o.onChangeCouponInput("amount",ne)}),onKeypress:t[9]||(t[9]=ne=>o.preventInvalidChars(ne,!0))},{prefix:i(()=>[s.coupon.type==="fixed"?(d(),_("span",{key:0,innerHTML:e.appVars.shop.currency_sign},null,8,Bpe)):(d(),_("span",kpe,"%"))]),_:1},8,["modelValue","min","max"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("amount")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"amount"},null,8,["validation-errors"])):x("",!0)]}),_:1},8,["label"])]),_:1}),s.coupon.type==="percentage"?(d(),E(b,{key:0,lg:8},{default:i(()=>[l(B,{label:o.translate("Max Discount Amount")},{default:i(()=>{var G;return[l(y,{modelValue:s.coupon.conditions.max_discount_amount,"onUpdate:modelValue":t[10]||(t[10]=ne=>s.coupon.conditions.max_discount_amount=ne),type:"number",placeholder:o.translate("leave empty or 0 for no max limit"),class:de((G=s.validationErrors)!=null&&G.hasOwnProperty("max_discount_amount")?"is-error":"")},{prefix:i(()=>[r("span",{innerHTML:e.appVars.shop.currency_sign},null,8,xpe)]),_:1},8,["modelValue","placeholder","class"]),l(v,{"validation-errors":s.validationErrors,"field-key":"max_discount_amount"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1})):x("",!0)],64)):x("",!0)]),_:1})]),_:1})]),_:1}),l(M,null,{default:i(()=>[l(g,{title:o.translate("Usage Restrictions"),border_bottom:"",title_size:"small"},null,8,["title"]),l(S,{class:"pb-1.5"},{default:i(()=>[l(k,{gutter:20},{default:i(()=>[l(b,{lg:12},{default:i(()=>[l(B,null,{label:i(()=>[l(w,{title:o.translate("Min Spend Amount"),content:o.translate("Minimum spend (subtotal) allowed to use the coupon.")},null,8,["title","content"])]),default:i(()=>{var G,ne;return[l(y,{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:de((G=s.validationErrors)!=null&&G.hasOwnProperty("min_purchase_amount")?"is-error":"")},{prefix:i(()=>[r("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Spe)]),_:1},8,["modelValue","class"]),(ne=s.validationErrors)!=null&&ne.hasOwnProperty("min_purchase_amount")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"min_purchase_amount"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1}),l(b,{lg:12},{default:i(()=>[l(B,null,{label:i(()=>[l(w,{title:o.translate("Max Spend Amount"),content:o.translate("Set the maximum spend (subtotal) allowed when using the coupon.")},null,8,["title","content"])]),default:i(()=>{var G,ne;return[l(y,{modelValue:s.coupon.conditions.max_purchase_amount,"onUpdate:modelValue":t[12]||(t[12]=Y=>s.coupon.conditions.max_purchase_amount=Y),type:"number",placeholder:o.translate("leave empty or 0 for no max limit"),class:de((G=s.validationErrors)!=null&&G.hasOwnProperty("max_purchase_amount")?"is-error":"")},{prefix:i(()=>[r("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Fpe)]),_:1},8,["modelValue","placeholder","class"]),(ne=s.validationErrors)!=null&&ne.hasOwnProperty("max_purchase_amount")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_purchase_amount"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1}),l(b,{md:12},{default:i(()=>[l(B,{label:o.translate("Include Categories")},{default:i(()=>[l(F,{modelValue:s.coupon.conditions.included_categories,"onUpdate:modelValue":t[13]||(t[13]=G=>s.coupon.conditions.included_categories=G),multiple:"",placeholder:o.translate("Any Category"),filterable:"",remote:"","reserve-keyword":!1},{default:i(()=>[(d(!0),_(H,null,ee(s.categories,G=>(d(),E($,{key:G.value,label:G.label,value:G.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),l(b,{md:12},{default:i(()=>[l(B,{label:o.translate("Exclude Categories")},{default:i(()=>[l(F,{modelValue:s.coupon.conditions.excluded_categories,"onUpdate:modelValue":t[14]||(t[14]=G=>s.coupon.conditions.excluded_categories=G),multiple:"",placeholder:o.translate("No Categories"),filterable:"",remote:"","reserve-keyword":!1},{default:i(()=>[(d(!0),_(H,null,ee(s.categories,G=>(d(),E($,{key:G.value,label:G.label,value:G.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),l(b,{md:24},{default:i(()=>[l(B,{label:o.translate("Include Products")},{default:i(()=>[l(L,{modelValue:s.coupon.conditions.included_products,"onUpdate:modelValue":t[15]||(t[15]=G=>s.coupon.conditions.included_products=G)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),l(b,{md:24},{default:i(()=>[l(B,{label:o.translate("Excluded Products")},{default:i(()=>[l(L,{modelValue:s.coupon.conditions.excluded_products,"onUpdate:modelValue":t[16]||(t[16]=G=>s.coupon.conditions.excluded_products=G)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),l(b,{md:24},{default:i(()=>[l(B,null,{label:i(()=>[l(w,{title:o.translate("By Email Address"),content:o.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:i(()=>{var G;return[l(y,{autocomplete:"off",modelValue:s.coupon.conditions.email_restrictions,"onUpdate:modelValue":t[17]||(t[17]=ne=>s.coupon.conditions.email_restrictions=ne),type:"text",placeholder:o.translate("email1@domain.com, *@special.com, ... or regex pattern")},null,8,["modelValue","placeholder"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("email_restrictions")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"email_restrictions"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1}),l(b,{md:24},{default:i(()=>{var G;return[l(B,null,{label:i(()=>[l(w,{title:o.translate("Recurring Coupon"),content:o.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:i(()=>[l(Q,{modelValue:s.coupon.conditions.is_recurring,"onUpdate:modelValue":t[18]||(t[18]=ne=>s.coupon.conditions.is_recurring=ne),label:o.translate("Make this coupon recurring"),"true-value":"yes","false-value":"no"},null,8,["modelValue","label"])]),_:1}),(G=s.validationErrors)!=null&&G.hasOwnProperty("is_recurring")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"is_recurring"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1})]),_:1})]),_:1}),l(M,null,{default:i(()=>[l(g,{title:o.translate("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),l(S,{class:"pb-1.5"},{default:i(()=>[l(k,{gutter:20},{default:i(()=>[l(b,{lg:12},{default:i(()=>[l(B,null,{label:i(()=>[l(w,{title:o.translate("Total Limit"),content:o.translate("Total number of times this coupon can be redeemed across the entire store.")},null,8,["title","content"])]),default:i(()=>{var G,ne;return[l(y,{modelValue:s.coupon.conditions.max_uses,"onUpdate:modelValue":t[19]||(t[19]=Y=>s.coupon.conditions.max_uses=Y),type:"number",placeholder:o.translate("Total limit"),class:de((G=s.validationErrors)!=null&&G.hasOwnProperty("max_uses")?"is-error":s.usageError),min:s.minLimit,max:s.maxLimit,onInput:t[20]||(t[20]=Y=>{o.onChangeCouponInput("max_uses",Y)}),onKeypress:o.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),(ne=s.validationErrors)!=null&&ne.hasOwnProperty("max_uses")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_uses"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1}),l(b,{lg:12},{default:i(()=>[l(B,null,{label:i(()=>[l(w,{title:o.translate("Per User Limit"),content:o.translate("Maximum an user can use. 0 means unlimited")},null,8,["title","content"])]),default:i(()=>[l(y,{modelValue:s.coupon.conditions.max_per_customer,"onUpdate:modelValue":t[21]||(t[21]=G=>s.coupon.conditions.max_per_customer=G),type:"number",placeholder:o.translate("Max limit per user"),class:de(s.validationErrors.hasOwnProperty("max_per_customer")?"is-error":""),min:s.minLimit,max:s.maxLimit,onInput:t[22]||(t[22]=G=>{o.onChangeCouponInput("max_per_customer",G)}),onKeypress:o.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),l(v,{"validation-errors":s.validationErrors,"field-key":"max_per_customer"},null,8,["validation-errors"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),l(M,null,{default:i(()=>[l(g,{title:o.translate("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),l(S,{class:"pb-1.5"},{default:i(()=>[l(k,{gutter:20},{default:i(()=>[l(b,{lg:24},{default:i(()=>[l(B,{label:o.translate("Status")},{default:i(()=>[l(D,{modelValue:s.coupon.status,"onUpdate:modelValue":t[23]||(t[23]=G=>s.coupon.status=G)},{default:i(()=>[l(T,{value:"active",label:o.translate("Active")},null,8,["label"]),l(T,{value:"disabled",label:o.translate("Disabled")},null,8,["label"]),l(T,{disabled:"",value:"expired",label:o.translate("Expired")},null,8,["label"])]),_:1},8,["modelValue"]),l(v,{"validation-errors":s.validationErrors,"field-key":"status"},null,8,["validation-errors"])]),_:1},8,["label"])]),_:1}),l(b,{lg:24},{default:i(()=>[l(B,{label:o.translate("Internal Notes")},{default:i(()=>{var G;return[l(y,{modelValue:s.coupon.notes,"onUpdate:modelValue":t[24]||(t[24]=ne=>s.coupon.notes=ne),type:"textarea",placeholder:o.translate("Enter note"),class:de((G=s.validationErrors)!=null&&G.hasOwnProperty("notes")?"is-error":"")},null,8,["modelValue","placeholder","class"]),l(v,{"validation-errors":s.validationErrors,"field-key":"notes"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1}),l(b,{lg:24},{default:i(()=>{var G;return[l(B,null,{label:i(()=>[l(w,{title:o.translate("Stackable"),content:o.translate("Yes means the coupon can be applied with other coupons")},null,8,["title","content"])]),default:i(()=>[l(D,{modelValue:s.coupon.stackable,"onUpdate:modelValue":t[25]||(t[25]=ne=>s.coupon.stackable=ne)},{default:i(()=>[l(T,{value:"yes"},{default:i(()=>[R(h(o.translate("Yes")),1)]),_:1}),l(T,{value:"no"},{default:i(()=>[R(h(o.translate("No")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1}),(G=s.validationErrors)!=null&&G.hasOwnProperty("stackable")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"stackable"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),r("div",Epe,[r("div",Upe,[l(M,null,{default:i(()=>[l(g,{title:o.translate("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),l(S,null,{default:i(()=>[r("div",$pe,[s.coupon.code?(d(),_("div",Dpe,[r("span",Qpe,h(o.translate("Coupon code"))+": "+h(s.coupon.code),1),l(I,{text:s.coupon.code,showMode:"basic_copy_btn",tooltipText:o.translate("Copy discount code")},null,8,["text","tooltipText"])])):(d(),_("div",Ipe,h(o.translate("No discount code yet")),1))]),r("div",Tpe,[r("h4",Vpe,h(o.translate("Type & Method")),1),r("ul",Mpe,[r("li",null,[r("span",null,h(o.translate("Amount off Products")),1)]),r("li",null,[r("span",null,h(o.translate("Code")),1)])])]),r("div",Lpe,[r("h4",Rpe,h(o.translate("Details")),1),r("ul",Ope,[r("li",null,[r("span",null,h(o.translate("For Online Store")),1)]),r("li",null,[r("span",null,h(o.translate("No Min Purchase Requirement")),1)]),r("li",null,[r("span",null,h(o.translate("All Customers")),1)])])])]),_:1})]),_:1}),l(M,null,{default:i(()=>[l(g,{title:o.translate("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),l(S,{class:"pb-1.5"},{default:i(()=>[l(U,{"label-position":"top"},{default:i(()=>[l(k,{gutter:20},{default:i(()=>[l(b,{lg:24},{default:i(()=>[l(B,{label:o.translate("Start Date & Time")},{default:i(()=>[l(O,{modelValue:s.coupon.start_date,"onUpdate:modelValue":t[26]||(t[26]=G=>s.coupon.start_date=G),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:o.translate("Start date & time"),onChange:o.setDefaultStatus,"disabled-date":o.disabledStartDate},null,8,["modelValue","placeholder","onChange","disabled-date"])]),_:1},8,["label"])]),_:1}),l(b,{lg:24},{default:i(()=>[l(B,null,{default:i(()=>[l(Q,{modelValue:s.isEndDateEnabled,"onUpdate:modelValue":t[27]||(t[27]=G=>s.isEndDateEnabled=G),label:o.translate("Set end date & time"),onChange:t[28]||(t[28]=G=>{G||(s.coupon.end_date=null)})},null,8,["modelValue","label"])]),_:1})]),_:1}),s.isEndDateEnabled?(d(),E(b,{key:0,lg:24},{default:i(()=>[l(B,{label:o.translate("End Date & Time")},{default:i(()=>[l(O,{modelValue:s.coupon.end_date,"onUpdate:modelValue":t[29]||(t[29]=G=>s.coupon.end_date=G),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:o.translate("End date & time"),onChange:o.setDefaultStatus,"disabled-date":o.disabledEndDate},null,8,["modelValue","placeholder","onChange","disabled-date"]),s.validationErrors.hasOwnProperty("end_date")?(d(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"end_date"},null,8,["validation-errors"])):x("",!0)]),_:1},8,["label"])]),_:1})):x("",!0)]),_:1})]),_:1})]),_:1})]),_:1})]),s.showDynamicTemplates?(d(),_("div",Hpe,[l(P,{filter:"fluent_cart_single_coupon_page",ref:"dynamic_templates",data:{coupon:s.coupon},widgetsQuery:{coupon_id:s.coupon.id},onChange:o.handleChangesMade},null,8,["data","widgetsQuery","onChange"])])):x("",!0),l(M,null,{default:i(()=>[l(g,{title:o.translate("Activity"),border_bottom:"",title_size:"small"},null,8,["title"]),l(S,null,{default:i(()=>[l(K,{onReload:o.fetchCoupon,activities:s.coupon.activities||[],showManageActivity:s.showManageActivity},null,8,["onReload","activities","showManageActivity"])]),_:1})]),_:1})])])])],64))])}const Npe=He(hpe,[["render",Ppe]]),Kpe={name:"CheckoutFields",components:{Animation:ra,CardHeader:Ce,Card:he,CardBody:me,SettingsHeader:ha,AdminNotice:_a},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")}},mounted(){this.getFields()},methods:{translate:c,isFirstNameDisabled(e,t){var a,n;return e==="basic_info"&&t==="first_name"&&((n=(a=this.settings.basic_info)==null?void 0:a.last_name)==null?void 0:n.enabled)==="yes"},shouldDimLabel(e,t){var a,n,s,o,u,A,f;return((s=(n=(a=this.settings)==null?void 0:a[e])==null?void 0:n[t])==null?void 0:s.enabled)==="no"?!0:e==="basic_info"&&t==="full_name"?((u=(o=this.settings.basic_info)==null?void 0:o.first_name)==null?void 0:u.enabled)==="yes"||((f=(A=this.settings.basic_info)==null?void 0:A.last_name)==null?void 0:f.enabled)==="yes":!1},isVisible(e,t){var a,n,s,o;return t==="full_name"?((n=(a=this.settings.basic_info)==null?void 0:a.first_name)==null?void 0:n.enabled)!=="yes"&&((o=(s=this.settings.basic_info)==null?void 0:s.last_name)==null?void 0:o.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())}}},Gpe={class:"setting-wrap"},jpe={class:"setting-wrap-inner"},zpe={class:"fct-checkout-fields-wrapp"},Ype={class:"field-heading"},qpe={class:"fct-checkout-fields"},Wpe={key:0,class:"fct-checkout-field"},Xpe={class:"fct-checkout-field-info"},Jpe={class:"fct-checkout-field-label-wrap"},Zpe={class:"fct-checkout-field-tags"},efe={key:0,class:"fct-checkout-field-info-desc"},tfe={key:0,class:"fct-checkout-field-action"},afe={key:1,class:"fct-checkout-field-input"},nfe={class:"fct-checkout-field-info"},sfe={class:"fct-checkout-field-label-wrap"},lfe={key:1,class:"fct-checkout-field-tags"},ofe={key:0,class:"fct-checkout-field-info-desc"},rfe={key:0,class:"fct-checkout-field-action"},ife={class:"form-section-save-action"};function dfe(e,t,a,n,s,o){const u=C("SettingsHeader"),A=C("AdminNotice"),f=C("el-skeleton"),m=C("el-switch"),g=C("el-tag"),y=C("el-checkbox"),v=C("el-input"),B=C("CardBody"),b=C("Card"),w=C("el-button");return d(),_("div",Gpe,[l(u,{heading:o.translate("Checkout Fields"),loading:s.saving,onOnSave:o.saveFields},null,8,["heading","loading","onOnSave"]),r("div",jpe,[l(A),r("div",zpe,[l(b,null,{default:i(()=>[l(B,null,{default:i(()=>[l(f,{loading:s.fetching,animated:"",rows:5},null,8,["loading"]),s.fetching?x("",!0):(d(!0),_(H,{key:0},ee(s.fields,(k,S)=>(d(),_("div",{key:S,class:"fct-checkout-field-section"},[r("h3",Ype,h(o.formatSectionTitle(S)),1),r("div",qpe,[k.label?(d(),_("div",Wpe,[r("div",Xpe,[r("div",Jpe,[k.can_alter==="yes"?(d(),E(m,{key:0,modelValue:s.settings[S].enabled,"onUpdate:modelValue":M=>s.settings[S].enabled=M,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])):x("",!0),r("span",{class:de(`fct-checkout-field-label ${s.settings[S].enabled==="no"?"opacity-50":""}`)},h(k.label),3),r("div",Zpe,[k.can_alter!=="yes"&&s.settings[S].enabled==="yes"?(d(),E(g,{key:0,size:"small"},{default:i(()=>[R(h(o.translate("System")),1)]),_:1})):x("",!0),s.settings[S].required==="yes"&&s.settings[S].enabled==="yes"?(d(),E(g,{key:1,size:"small"},{default:i(()=>[R(h(o.translate("Required")),1)]),_:1})):x("",!0)])]),k.help_text?(d(),_("div",efe,h(k.help_text),1)):x("",!0)]),k.can_alter==="yes"?(d(),_("div",tfe,[l(y,{modelValue:s.settings[S].required,"onUpdate:modelValue":M=>s.settings[S].required=M,"true-label":"yes","false-label":"no",disabled:s.settings[S].enabled!=="yes"},{default:i(()=>[R(h(o.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):x("",!0),s.settings[S].hasOwnProperty("text")&&s.settings[S].enabled==="yes"?(d(),_("div",afe,[l(v,{type:"textarea",modelValue:s.settings[S].text,"onUpdate:modelValue":M=>s.settings[S].text=M,disabled:s.settings[S].enabled!=="yes"},null,8,["modelValue","onUpdate:modelValue","disabled"])])):x("",!0)])):(d(!0),_(H,{key:1},ee(k,(M,$)=>(d(),_("div",{key:$,class:"fct-checkout-field"},[r("div",nfe,[r("div",sfe,[M.can_alter==="yes"?(d(),E(m,{key:0,modelValue:s.settings[S][$].enabled,"onUpdate:modelValue":F=>s.settings[S][$].enabled=F,"active-value":"yes","inactive-value":"no",disabled:o.isFirstNameDisabled(S,$)},null,8,["modelValue","onUpdate:modelValue","disabled"])):x("",!0),r("span",{class:de(["fct-checkout-field-label",o.shouldDimLabel(S,$)?"opacity-50":""])},h(M.label),3),o.isVisible(M,$)?(d(),_("div",lfe,[M.can_alter!=="yes"&&s.settings[S][$].enabled==="yes"?(d(),E(g,{key:0,size:"small"},{default:i(()=>[R(h(o.translate("System")),1)]),_:1})):x("",!0),s.settings[S][$].required==="yes"&&s.settings[S][$].enabled==="yes"?(d(),E(g,{key:1,size:"small"},{default:i(()=>[R(h(o.translate("Required")),1)]),_:1})):x("",!0)])):x("",!0)]),M.help_text?(d(),_("div",ofe,h(M.help_text),1)):x("",!0)]),M.can_alter==="yes"&&$!=="first_name"?(d(),_("div",rfe,[l(y,{modelValue:s.settings[S][$].required,"onUpdate:modelValue":F=>s.settings[S][$].required=F,"true-label":"yes","false-label":"no",disabled:s.settings[S][$].enabled!=="yes"},{default:i(()=>[R(h(o.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):x("",!0)]))),128))])]))),128))]),_:1})]),_:1}),r("div",ife,[l(w,{type:"primary",onClick:o.saveFields,loading:s.saving},{default:i(()=>[R(h(o.translate("Save")),1)]),_:1},8,["onClick","loading"])])])])])}const ufe=He(Kpe,[["render",dfe]]);var or={exports:{}};/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/var cfe=or.exports,IA;function Afe(){return IA||(IA=1,function(e,t){((a,n)=>{e.exports=n()})(cfe,function a(){var n=typeof self<"u"?self:typeof window<"u"?window:n!==void 0?n:{},s,o=!n.document&&!!n.postMessage,u=n.IS_PAPA_WORKER||!1,A={},f=0,m={};function g(D){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(U){var I=L(U);I.chunkSize=parseInt(I.chunkSize),U.step||U.chunk||(I.chunkSize=null),this._handle=new w(I),(this._handle.streamer=this)._config=I}).call(this,D),this.parseChunk=function(U,I){var O=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),u)n.postMessage({results:P,workerId:m.WORKER_ID,finished:O});else if(T(this._config.chunk)&&!I){if(this._config.chunk(P,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=P=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(P.data),this._completeResults.errors=this._completeResults.errors.concat(P.errors),this._completeResults.meta=P.meta),this._completed||!O||!T(this._config.complete)||P&&P.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),O||P&&P.meta.paused||this._nextChunk(),P}this._halted=!0},this._sendError=function(U){T(this._config.error)?this._config.error(U):u&&this._config.error&&n.postMessage({workerId:m.WORKER_ID,error:U,finished:!1})}}function y(D){var U;(D=D||{}).chunkSize||(D.chunkSize=m.RemoteChunkSize),g.call(this,D),this._nextChunk=o?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(I){this._input=I,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(U=new XMLHttpRequest,this._config.withCredentials&&(U.withCredentials=this._config.withCredentials),o||(U.onload=Q(this._chunkLoaded,this),U.onerror=Q(this._chunkError,this)),U.open(this._config.downloadRequestBody?"POST":"GET",this._input,!o),this._config.downloadRequestHeaders){var I,O=this._config.downloadRequestHeaders;for(I in O)U.setRequestHeader(I,O[I])}var P;this._config.chunkSize&&(P=this._start+this._config.chunkSize-1,U.setRequestHeader("Range","bytes="+this._start+"-"+P));try{U.send(this._config.downloadRequestBody)}catch(K){this._chunkError(K.message)}o&&U.status===0&&this._chunkError()}},this._chunkLoaded=function(){U.readyState===4&&(U.status<200||400<=U.status?this._chunkError():(this._start+=this._config.chunkSize||U.responseText.length,this._finished=!this._config.chunkSize||this._start>=(I=>(I=I.getResponseHeader("Content-Range"))!==null?parseInt(I.substring(I.lastIndexOf("/")+1)):-1)(U),this.parseChunk(U.responseText)))},this._chunkError=function(I){I=U.statusText||I,this._sendError(new Error(I))}}function v(D){(D=D||{}).chunkSize||(D.chunkSize=m.LocalChunkSize),g.call(this,D);var U,I,O=typeof FileReader<"u";this.stream=function(P){this._input=P,I=P.slice||P.webkitSlice||P.mozSlice,O?((U=new FileReader).onload=Q(this._chunkLoaded,this),U.onerror=Q(this._chunkError,this)):U=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(P.target.result)},this._chunkError=function(){this._sendError(U.error)}}function B(D){var U;g.call(this,D=D||{}),this.stream=function(I){return U=I,this._nextChunk()},this._nextChunk=function(){var I,O;if(!this._finished)return I=this._config.chunkSize,U=I?(O=U.substring(0,I),U.substring(I)):(O=U,""),this._finished=!U,this.parseChunk(O)}}function b(D){g.call(this,D=D||{});var U=[],I=!0,O=!1;this.pause=function(){g.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){g.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(P){this._input=P,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){O&&U.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),U.length?this.parseChunk(U.shift()):I=!0},this._streamData=Q(function(P){try{U.push(typeof P=="string"?P:P.toString(this._config.encoding)),I&&(I=!1,this._checkIsFinished(),this.parseChunk(U.shift()))}catch(K){this._streamError(K)}},this),this._streamError=Q(function(P){this._streamCleanUp(),this._sendError(P)},this),this._streamEnd=Q(function(){this._streamCleanUp(),O=!0,this._streamData("")},this),this._streamCleanUp=Q(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function w(D){var U,I,O,P,K=Math.pow(2,53),G=-K,ne=/^\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)))$/,N=this,oe=0,Z=0,le=!1,te=!1,X=[],ie={data:[],errors:[],meta:{}};function be(De){return D.skipEmptyLines==="greedy"?De.join("").trim()==="":De.length===1&&De[0].length===0}function se(){if(ie&&O&&(pe("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+m.DefaultDelimiter+"'"),O=!1),D.skipEmptyLines&&(ie.data=ie.data.filter(function(we){return!be(we)})),ce()){let we=function(Ye,ft){T(D.transformHeader)&&(Ye=D.transformHeader(Ye,ft)),X.push(Ye)};if(ie)if(Array.isArray(ie.data[0])){for(var De=0;ce()&&De(nt=>(D.dynamicTypingFunction&&D.dynamicTyping[nt]===void 0&&(D.dynamicTyping[nt]=D.dynamicTypingFunction(nt)),(D.dynamicTyping[nt]||D.dynamicTyping)===!0))(Me)?Fe==="true"||Fe==="TRUE"||Fe!=="false"&&Fe!=="FALSE"&&((nt=>{if(ne.test(nt)&&(nt=parseFloat(nt),G=X.length?"__parsed_extra":X[Ge]:_e,xe=D.transform?D.transform(xe,_e):xe);_e==="__parsed_extra"?(ft[_e]=ft[_e]||[],ft[_e].push(xe)):ft[_e]=xe}return D.header&&(Ge>X.length?pe("FieldMismatch","TooManyFields","Too many fields: expected "+X.length+" fields but parsed "+Ge,Z+Ye):GeD.preview?I.abort():(ie.data=ie.data[0],P(ie,N))))}),this.parse=function(De,$e,Je){var we=D.quoteChar||'"',we=(D.newline||(D.newline=this.guessLineEndings(De,we)),O=!1,D.delimiter?T(D.delimiter)&&(D.delimiter=D.delimiter(De),ie.meta.delimiter=D.delimiter):((we=((Ye,ft,Ge,_e,xe)=>{var Me,Fe,nt,st;xe=xe||[","," ","|",";",m.RECORD_SEP,m.UNIT_SEP];for(var Ot=0;Ot=Je.length/2?`\r
`:"\r"}}function k(D){return D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S(D){var U=(D=D||{}).delimiter,I=D.newline,O=D.comments,P=D.step,K=D.preview,G=D.fastMode,ne=null,Y=!1,N=D.quoteChar==null?'"':D.quoteChar,oe=N;if(D.escapeChar!==void 0&&(oe=D.escapeChar),(typeof U!="string"||-1=K)return Ze(!0);break}Je.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:$e.length,index:Z}),Fe++}}else if(O&&we.length===0&&te.substring(Z,Z+pe)===O){if(xe===-1)return Ze();Z=xe+ce,xe=te.indexOf(I,Z),_e=te.indexOf(U,Z)}else if(_e!==-1&&(_e=K)return Ze(!0)}return Ct();function st(ht){$e.push(ht),Ye=Z}function Ot(ht){var Ft=0;return Ft=ht!==-1&&(ht=te.substring(Fe+1,ht))&&ht.trim()===""?ht.length:Ft}function Ct(ht){return ie||(ht===void 0&&(ht=te.substring(Z)),we.push(ht),Z=be,st(we),De&&Bt()),Ze()}function yt(ht){Z=ht,st(we),we=[],xe=te.indexOf(I,Z)}function Ze(ht){if(D.header&&!X&&$e.length&&!Y){var Ft=$e[0],kt=Object.create(null),xt=new Set(Ft);let Ht=!1;for(let pt=0;ptO.charCodeAt(0)!==65279?O:O.slice(1))(D),I=new(U.download?y:B)(U)):D.readable===!0&&T(D.read)&&T(D.on)?I=new b(U):(n.File&&D instanceof File||D instanceof Object)&&(I=new v(U)),I.stream(D);(I=(()=>{var O;return!!m.WORKERS_SUPPORTED&&(O=(()=>{var P=n.URL||n.webkitURL||null,K=a.toString();return m.BLOB_URL||(m.BLOB_URL=P.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; ","(",K,")();"],{type:"text/javascript"})))})(),(O=new n.Worker(O)).onmessage=M,O.id=f++,A[O.id]=O)})()).userStep=U.step,I.userChunk=U.chunk,I.userComplete=U.complete,I.userError=U.error,U.step=T(U.step),U.chunk=T(U.chunk),U.complete=T(U.complete),U.error=T(U.error),delete U.worker,I.postMessage({input:D,config:U,workerId:I.id})},m.unparse=function(D,U){var I=!1,O=!0,P=",",K=`\r
`,G='"',ne=G+G,Y=!1,N=null,oe=!1,Z=((()=>{if(typeof U=="object"){if(typeof U.delimiter!="string"||m.BAD_DELIMITERS.filter(function(X){return U.delimiter.indexOf(X)!==-1}).length||(P=U.delimiter),typeof U.quotes!="boolean"&&typeof U.quotes!="function"&&!Array.isArray(U.quotes)||(I=U.quotes),typeof U.skipEmptyLines!="boolean"&&typeof U.skipEmptyLines!="string"||(Y=U.skipEmptyLines),typeof U.newline=="string"&&(K=U.newline),typeof U.quoteChar=="string"&&(G=U.quoteChar),typeof U.header=="boolean"&&(O=U.header),Array.isArray(U.columns)){if(U.columns.length===0)throw new Error("Option columns is empty");N=U.columns}U.escapeChar!==void 0&&(ne=U.escapeChar+G),U.escapeFormulae instanceof RegExp?oe=U.escapeFormulae:typeof U.escapeFormulae=="boolean"&&U.escapeFormulae&&(oe=/^[=+\-@\t\r].*$/)}})(),new RegExp(k(G),"g"));if(typeof D=="string"&&(D=JSON.parse(D)),Array.isArray(D)){if(!D.length||Array.isArray(D[0]))return le(null,D,Y);if(typeof D[0]=="object")return le(N||Object.keys(D[0]),D,Y)}else if(typeof D=="object")return typeof D.data=="string"&&(D.data=JSON.parse(D.data)),Array.isArray(D.data)&&(D.fields||(D.fields=D.meta&&D.meta.fields||N),D.fields||(D.fields=Array.isArray(D.data[0])?D.fields:typeof D.data[0]=="object"?Object.keys(D.data[0]):[]),Array.isArray(D.data[0])||typeof D.data[0]=="object"||(D.data=[D.data])),le(D.fields||[],D.data||[],Y);throw new Error("Unable to serialize unrecognized input");function le(X,ie,be){var se="",ce=(typeof X=="string"&&(X=JSON.parse(X)),typeof ie=="string"&&(ie=JSON.parse(ie)),Array.isArray(X)&&0{for(var De=0;De{K&&TA.parse(K,{header:!0,complete:function(G){A.value=G.data,u.value=G.meta.fields,g.value=u.value.includes("Type")&&u.value.includes("Parent"),k(),g.value&&$(),B.value=!0}})},w=()=>{m.value={},u.value=[],A.value=[],B.value=!1,g.value=!1},k=()=>{const K=[],G=[];let ne=0;u.value.forEach(Y=>{let N=null,oe=null;const Z=Y.toString();for(const[le,te]of y.entries())if(Z.toLocaleLowerCase().startsWith(te)){const X=Y.toString().match(/ \d+ /g);if(Array.isArray(X)&&X.length===1){let ie=X[0];ne=ie>ne?ie:ne,N=Y.toString().replace(X[0]," %d "),oe=Y.toString().replace(X[0]," ");break}}N!=null?K.includes(N)||(K.push(N),G.push({title:oe,value:N})):G.push({title:Y,value:Y})}),m.value=G,v=ne},S=()=>window.fluentCartRestVars.rest.url+"/files/upload",M={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"]},$=()=>{for(const[K,G]of Object.entries(M))if(f.value[K]){for(const ne of G)if(u.value.includes(ne)){f.value[K].value=ne;break}}},F=K=>K?{day:"daily",week:"weekly",month:"monthly",year:"yearly"}[K.trim().toLowerCase()]||K:"",L=K=>{if(!K)return"";const G=K.split(",").map(ne=>ne.trim().toLowerCase());return G.includes("variation")?"variation":G.includes("variable")?"variable":G.includes("subscription")?"subscription":G.includes("simple")?"simple":G[0]||""},Q=(K=!0)=>{const G=[],ne={},Y=f.value,N={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"},oe=le=>{const te=[];for(let X=1;X<=10;X++){const ie=`Attribute ${X} name`,be=`Attribute ${X} value(s)`;le[ie]&&le[be]&&te.push(le[be])}return te.join(" - ")},Z=le=>le==="1"||le===1?"published":le==="0"||le===0?"draft":le||"published";A.value.forEach(le=>{var De,$e,Je,we,Ye,ft,Ge,_e,xe,Me,Fe,nt,st,Ot,Ct,yt,Ze,Bt,ht,Ft;const te=L(le.Type);if(te!=="simple"&&te!=="variable"&&te!=="subscription")return;const X={};X._cid=rn(),X.post_title=le[(De=Y.post_title)==null?void 0:De.value]||"",X.post_name=le[($e=Y.post_name)==null?void 0:$e.value]||X.post_title,X.ID=le[(Je=Y.post_id)==null?void 0:Je.value]||"",X.post_content=le[(we=Y.post_content)==null?void 0:we.value]||"",X.post_excerpt=le[(Ye=Y.post_excerpt)==null?void 0:Ye.value]||"",X.post_status=Z(le[(ft=Y.post_status)==null?void 0:ft.value]);const ie={variation_type:te==="variable"?"simple_variations":"simple",manage_stock:"0",fulfillment_type:"physical"},be=le[(Ge=Y.images)==null?void 0:Ge.value]||"",se=[];be&&be.split(",").map(kt=>kt.trim()).filter(Boolean).forEach(kt=>{const xt=kt.split("/").pop().split("?")[0]||"image";se.push({id:0,url:kt,title:xt})}),X.detail=ie,X.gallery=se,X.variants=[];const ce=le[(_e=Y.categories)==null?void 0:_e.value]||"";if(ce?X.categories=ce.split(",").map(kt=>kt.trim()).filter(Boolean):X.categories=[],te==="simple"||te==="subscription"){const kt=le[(xe=Y.item_price)==null?void 0:xe.value]||"",xt=le[(Me=Y.compare_price)==null?void 0:Me.value]||"",Ht=le[(Fe=Y.sku)==null?void 0:Fe.value]||"",pt=te==="subscription"?"subscription":le[(nt=Y.payment_type)==null?void 0:nt.value]||"onetime",da=F(le[(st=Y.repeat_interval)==null?void 0:st.value]||""),ue=le[(Ot=Y.trial_days)==null?void 0:Ot.value]||"",ve=le[(Ct=Y.installment)==null?void 0:Ct.value]||"",We=le[(yt=Y.installment_count)==null?void 0:yt.value]||"",_t=le[(Ze=Y.manage_setup_fee)==null?void 0:Ze.value]||"",rt=le[(Bt=Y.signup_fee_name)==null?void 0:Bt.value]||"",Wt=le[(ht=Y.signup_fee)==null?void 0:ht.value]||"";(kt||X.post_title)&&X.variants.push({_cid:rn(),variation_title:X.post_title,sku:Ht,item_price:kt,compare_price:xt,other_info:{...N,payment_type:pt,repeat_interval:da,trial_days:ue,installment:ve==="yes"?"yes":"no",times:We,manage_setup_fee:_t==="yes"?"yes":"no",signup_fee_name:rt,signup_fee:Wt},media:[]})}const pe=le[(Ft=Y.sku)==null?void 0:Ft.value]||"";te==="variable"&&pe&&(ne[pe]=X),G.push(X)}),A.value.forEach(le=>{var Me,Fe,nt,st,Ot,Ct,yt,Ze,Bt,ht,Ft,kt;if(L(le.Type)!=="variation")return;const te=le.Parent;if(!te||!ne[te])return;const X=oe(le),ie=le[(Me=Y.item_price)==null?void 0:Me.value]||"",be=le[(Fe=Y.compare_price)==null?void 0:Fe.value]||"",se=le[(nt=Y.images)==null?void 0:nt.value]||"",ce=[];se&&se.split(",").map(xt=>xt.trim()).filter(Boolean).forEach(xt=>{const Ht=xt.split("/").pop().split("?")[0]||"image";ce.push({id:0,url:xt,title:Ht})});const pe=le[(st=Y.sku)==null?void 0:st.value]||"",De=le[(Ot=Y.payment_type)==null?void 0:Ot.value]||"onetime",$e=F(le[(Ct=Y.repeat_interval)==null?void 0:Ct.value]||""),Je=le[(yt=Y.trial_days)==null?void 0:yt.value]||"",we=le[(Ze=Y.installment)==null?void 0:Ze.value]||"",Ye=le[(Bt=Y.installment_count)==null?void 0:Bt.value]||"",ft=le[(ht=Y.manage_setup_fee)==null?void 0:ht.value]||"",Ge=le[(Ft=Y.signup_fee_name)==null?void 0:Ft.value]||"",_e=le[(kt=Y.signup_fee)==null?void 0:kt.value]||"",xe={_cid:rn(),variation_title:X||le.Name||"",sku:pe,item_price:ie,compare_price:be,other_info:{...N,payment_type:De,repeat_interval:$e,trial_days:Je,installment:we==="yes"?"yes":"no",times:Ye,manage_setup_fee:ft==="yes"?"yes":"no",signup_fee_name:Ge,signup_fee:_e},media:ce};ne[te].variants.push(xe)}),P("onDataPopulated",{products:G,concat:K})},T=(K=!0)=>{if(g.value)return Q(K);const G=[];A.value.forEach(ne=>{var Ye,ft,Ge,_e,xe,Me,Fe,nt,st,Ot,Ct,yt;const Y={};Y._cid=rn();const N=f.value;Y.post_title=ne[N.post_title.value]??"",Y.post_name=ne[N.post_name.value]??Y.post_title,Y.ID=ne[N.post_id.value]??"",Y.post_content=ne[N.post_content.value]??"",Y.post_excerpt=ne[N.post_excerpt.value]??"",Y.post_status=ne[(Ye=N.post_status)==null?void 0:Ye.value]||"published",Y.comment_status="close";const oe=ne[(ft=N.images)==null?void 0:ft.value]||"",Z=[];oe&&oe.split(",").map(Ze=>Ze.trim()).filter(Boolean).forEach(Ze=>{const Bt=Ze.split("/").pop().split("?")[0]||"image";Z.push({id:0,url:Ze,title:Bt})});const le=ne[(Ge=N.categories)==null?void 0:Ge.value]||"";le?Y.categories=le.split(",").map(Ze=>Ze.trim()).filter(Boolean):Y.categories=[];const te=ne[(_e=N.sku)==null?void 0:_e.value]||"",X=ne[(xe=N.payment_type)==null?void 0:xe.value]||"onetime",ie=ne[(Me=N.repeat_interval)==null?void 0:Me.value]||"",be=ne[(Fe=N.trial_days)==null?void 0:Fe.value]||"",se=ne[(nt=N.installment)==null?void 0:nt.value]||"",ce=ne[(st=N.installment_count)==null?void 0:st.value]||"",pe=ne[(Ot=N.manage_setup_fee)==null?void 0:Ot.value]||"",De=ne[(Ct=N.signup_fee_name)==null?void 0:Ct.value]||"",$e=ne[(yt=N.signup_fee)==null?void 0:yt.value]||"",Je={variation_type:"simple",manage_stock:"0",fulfillment_type:"physical"},we={description:"",payment_type:X,times:ce,repeat_interval:ie,trial_days:be,billing_summary:"",manage_setup_fee:pe==="yes"?"yes":"no",signup_fee_name:De,signup_fee:$e,setup_fee_per_item:"no",installment:se==="yes"?"yes":"no"};Y.gallery=Z,Y.variants=[];for(let Ze=1;Ze<=v;Ze++){const Bt={};["variation_title","item_price","compare_price"].forEach(ht=>{var kt;const Ft=((kt=N[ht])==null?void 0:kt.value)??"";if(Ft.length>0){const xt=Ft.replace("%d",Ze.toString());Bt[ht]=ne[xt]}}),I(Bt)&&(Bt._cid=rn(),Bt.sku=te,Bt.other_info={...we},Bt.media=[],Y.variants.push(Bt))}Y.variants.length>0?(Je.variation_type="simple_variations",Y.detail=Je,G.push(Y)):I(Y)&&(Y.variants.push({_cid:rn(),variation_title:"",sku:te,item_price:0,compare_price:0,other_info:{...we},media:[]}),Y.detail=Je,G.push(Y))}),P("onDataPopulated",{products:G,concat:K})},D=()=>{n.value=!1,s.value=[],o.value=null,w()},U=(K=!0)=>{T(K),D()},I=K=>{let G=!1;for(const[ne,Y]of Object.entries(K))if(typeof Y!==null&&typeof Y<"u"&&(Array.isArray(Y)&&Y.length>0||Y.toString().length>0)){G=!0;break}return G};Be(()=>{f.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 O=()=>{const K=[{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":""}],G=TA.unparse(K),ne=new Blob([G],{type:"text/csv;charset=utf-8;"}),Y=URL.createObjectURL(ne),N=document.createElement("a");N.href=Y,N.download="fluent-cart-sample-import.csv",document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(Y)},P=t;return(K,G)=>{const ne=C("el-button"),Y=C("el-upload"),N=C("el-option"),oe=C("el-select"),Z=C("el-dialog");return d(),_(H,null,[l(ne,{onClick:G[0]||(G[0]=le=>n.value=!0)},{default:i(()=>[R(h(K.$t("Import")),1)]),_:1}),l(Z,{modelValue:n.value,"onUpdate:modelValue":G[4]||(G[4]=le=>n.value=le),"append-to-body":!0,title:K.$t("Import Products"),class:"fct-bulk-import-dialog"},{default:i(()=>[B.value?x("",!0):(d(),E(Y,{key:0,class:"fct-file-uploader",ref:"uploaderRef","file-list":s.value,"onUpdate:fileList":G[1]||(G[1]=le=>s.value=le),drag:"",action:S(),"on-progress":()=>{},"on-success":()=>{},"on-error":()=>{},"auto-upload":!1,"on-change":le=>{w(),o.value=le,b(le==null?void 0:le.raw)},multiple:!1,limit:1,"show-file-list":!0},{default:i(()=>[l(Oe,{circle:"",bg:"primary",soft:""},{default:i(()=>[l(W,{name:"Upload"})]),_:1}),r("div",ffe,[R(h(K.$t("Drag & Drop or"))+" ",1),r("em",null,h(K.$t("Browse/Upload")),1),R(" "+h(K.$t("Files"))+" ",1),r("span",null,h(p(c)("Any Format upto %s",p(vt).serverMaxUploadSize())),1)])]),_:1},8,["file-list","action","on-change"])),B.value?x("",!0):(d(),E(ne,{key:1,onClick:O,link:""},{default:i(()=>[l(W,{name:"Download"}),R(" "+h(K.$t("Download a Sample CSV File")),1)]),_:1})),B.value?(d(),_(H,{key:2},[r("div",mfe,[r("h4",hfe,h(K.$t("Map Columns")),1),r("table",_fe,[r("thead",null,[r("tr",null,[r("th",null,h(K.$t("Products Fields")),1),r("th",null,h(K.$t("CSV Headers")),1)])]),r("tbody",null,[(d(!0),_(H,null,ee(f.value,(le,te)=>(d(),_("tr",null,[r("td",null,h(le.title),1),r("td",gfe,[l(oe,{modelValue:le.value,"onUpdate:modelValue":X=>le.value=X,filterable:"",clearable:""},{default:i(()=>[(d(!0),_(H,null,ee(m.value,X=>(d(),E(N,{key:X.value,label:X.title,value:X.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])])]))),256))])])]),r("div",vfe,[l(ne,{onClick:G[2]||(G[2]=le=>U())},{default:i(()=>[R(h(K.$t("Add Products")),1)]),_:1}),l(ne,{onClick:G[3]||(G[3]=le=>U(!1))},{default:i(()=>[R(h(K.$t("Clear and Add Products")),1)]),_:1})])],64)):x("",!0)]),_:1},8,["modelValue","title"])],64)}}};class bfe extends Uu{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=rn(),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(n=>!n.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 n=this.data.productErrors.get(t);if(!(n!=null&&n.fields))return!1;const s=`variants.${a}.`;return Object.keys(n.fields).some(o=>o.startsWith(s))}getVariantError(t,a){const n=this.data.productErrors.get(t);if(!(n!=null&&n.fields))return"";const s=`variants.${a}.`;return Object.entries(n.fields).filter(([u])=>u.startsWith(s)).map(([,u])=>u).join("; ")}hasFieldError(t,a){var s;const n=this.data.productErrors.get(t);return!!((s=n==null?void 0:n.fields)!=null&&s[a])}hasVariantFieldError(t,a,n){return this.hasFieldError(t,`variants.${a}.${n}`)}chunkArray(t,a){const n=[];for(let s=0;s!this.data.savedIds.has(u._cid));if(a.length===0){q.error("No products to save.");return}const n=this.chunkArray(a,10);this.data.saving=!0,this.data.productErrors=new Map,this.data.saveProgress={total:n.length,completed:0,errors:[],createdIds:[]};try{for(const f of n){const m=f.map(g=>g._cid);for(const g of m)this.data.savingIds.add(g);this.data.savingIds=new Set(this.data.savingIds);try{const g=await re.post("products/bulk-insert",{products:f});if(g.created&&g.created.length){this.data.saveProgress.createdIds.push(...g.created);for(const y of g.created){this.data.savedIds.add(y._cid);const v=t.find(B=>B._cid===y._cid);v&&(v.ID=y.id,v.view_url=y.view_url||"")}this.data.savedIds=new Set(this.data.savedIds)}if(g.errors&&g.errors.length){this.data.saveProgress.errors.push(...g.errors);for(const y of g.errors)y._cid&&this.data.productErrors.set(y._cid,{message:y.message,fields:y.fields||{}});this.data.productErrors=new Map(this.data.productErrors)}}catch(g){const y=(s=g==null?void 0:g.data)==null?void 0:s.errors;if(Array.isArray(y)&&y.length){this.data.saveProgress.errors.push(...y);for(const v of y)v._cid&&this.data.productErrors.set(v._cid,{message:v.message,fields:v.fields||{}})}else{const v=((o=g==null?void 0:g.data)==null?void 0:o.message)||"A chunk failed to save";this.data.saveProgress.errors.push({message:v});for(const B of m)this.data.productErrors.set(B,{message:v,fields:{}})}this.data.productErrors=new Map(this.data.productErrors)}for(const g of m)this.data.savingIds.delete(g);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{createdIds:u,errors:A}=this.data.saveProgress;A.length===0?q.success(`${u.length} product(s) created successfully`):u.length>0?q.info(`${u.length} product(s) created, ${A.length} error(s)`):q.error("All products failed to save")}finally{this.data.saving=!1}}async removeProduct(t){var n;if(t.ID&&this.data.savedIds.has(t._cid)){try{await re.delete(`products/${t.ID}`)}catch(s){const o=((n=s==null?void 0:s.data)==null?void 0:n.message)||"Failed to delete product from server";q.error(o);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 n=t.variants.indexOf(a);n!==-1&&t.variants.splice(n,1)}duplicateProduct(t){const a=JSON.parse(JSON.stringify(t));a._cid=rn(),a.post_title=a.post_title?a.post_title+" (Copy)":"",a.variants&&Array.isArray(a.variants)&&a.variants.forEach(s=>{s.sku="",s._cid=rn()});const n=this.data.products.indexOf(t);this.data.products.splice(n+1,0,a)}duplicateProductWithVariants(t,a){const n=JSON.parse(JSON.stringify(t));if(n._cid=rn(),n.post_title=n.post_title?n.post_title+" (Copy)":"",n.variants&&Array.isArray(n.variants)){const o=new Set(a);n.variants=n.variants.filter((u,A)=>o.has(A)),n.variants.forEach(u=>{u.sku="",u._cid=rn()})}const s=this.data.products.indexOf(t);this.data.products.splice(s+1,0,n)}duplicateVariant(t,a){const n=JSON.parse(JSON.stringify(a));n._cid=rn(),n.variation_title=n.variation_title?n.variation_title+" (Copy)":"",n.sku="";const s=t.variants.indexOf(a);t.variants.splice(s+1,0,n)}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 n=[];for(const o of t){const u=a?`${a} > ${o.label}`:o.label;n.push({label:u,value:u}),(s=o.children)!=null&&s.length&&n.push(...this.flattenCategoryTree(o.children,u))}return n}async fetchCategories(){try{const a=(await re.get("products/fetch-term")).taxonomies||{},n=Object.values(a).find(s=>s.name==="product-categories");n!=null&&n.terms&&(this.data.categoryOptions=this.flattenCategoryTree(n.terms))}catch{}}}const ot=bfe.init(),wfe={class:"max-w-full overflow-x-scroll"},Cfe={class:"relative"},Bfe={key:0,class:"bulk-checkbox-cell"},kfe=["onMousedown","onTouchstart"],Cm={__name:"ResizeableColumns",props:{columns:{type:Array,required:!0},stickyLast:{type:Boolean,default:!1}},emits:["scroll","resize-end"],setup(e,{emit:t}){const a=t,n=Xm(),s=zd("table"),o=V(null);let u=null;Be(()=>{ye(()=>{const g=s.value.querySelectorAll("th"),y=n["header-first"]?1:0;Array.from(g).forEach((v,B)=>{const b=B-y;b<0||b>=A.columns.length||(A.columns[b].width=v.offsetWidth,A.columns[b].minWidth||(A.columns[b].minWidth=v.offsetWidth))}),u=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")}),u.observe(s.value)})}),xn(()=>{u&&u.disconnect()});const A=e,f=j(()=>{const g=n["header-first"]?40:0;return A.columns.reduce((y,v)=>y+v.width,0)+g}),m=(g,y)=>{g.preventDefault();const v=g.clientX,B=A.columns[y].width,b=A.columns[y].minWidth||50;o.value=y;const w=S=>{const M=B+(S.clientX-v);M>=b&&(A.columns[y].width=M)},k=()=>{o.value=null,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k),a("resize-end")};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k)};return(g,y)=>(d(),_("div",wfe,[r("div",{class:de(["resizable-table",{"is-resizing":o.value!==null}]),onScroll:y[0]||(y[0]=v=>a("scroll",v))},[r("div",Cfe,[r("table",{id:"tb",ref_key:"table",ref:s,style:ia({tableLayout:"fixed",width:f.value+"px"})},[r("thead",null,[r("tr",null,[g.$slots["header-first"]?(d(),_("th",Bfe,[oa(g.$slots,"header-first")])):x("",!0),(d(!0),_(H,null,ee(e.columns,(v,B)=>(d(),_("th",{class:de({"sticky-col":B===0,"sticky-col sticky-col-right":B===e.columns.length-1&&e.stickyLast}),style:ia({width:v.width+"px",zIndex:B===0||B===e.columns.length-1&&e.stickyLast?70:e.columns.length-B+50,left:B===0&&g.$slots["header-first"]?"40px":B===0?"0px":void 0}),key:v.key||B},[B===e.columns.length-1?oa(g.$slots,"header-last",{key:0},()=>[R(h(v.title),1)]):(d(),_(H,{key:1},[R(h(v.title),1)],64)),Bm(b,B),onTouchstart:b=>m(b,B)},null,42,kfe)):x("",!0)],6))),128))])]),r("tbody",null,[oa(g.$slots,"default")])],4)])],34)]))}},xfe={class:"bulk-setup-fee-badge"},Sfe={key:1,class:"text-gray-300 text-sm flex justify-center"},$r={__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(n,s)=>{var A;const o=C("el-tooltip"),u=C("el-input");return e.variant?(d(),E(u,{key:0,size:"small",class:de({"is-error":e.hasError}),modelValue:e.variant.item_price,"onUpdate:modelValue":s[0]||(s[0]=f=>e.variant.item_price=f),placeholder:n.$t("Price"),type:"number",disabled:e.disabled,onInput:s[1]||(s[1]=f=>a("change"))},Rt({_:2},[((A=e.variant.other_info)==null?void 0:A.manage_setup_fee)==="yes"&&e.variant.other_info.signup_fee?{name:"suffix",fn:i(()=>[l(o,{content:(e.variant.other_info.signup_fee_name||n.$t("Setup fee"))+": "+n.currencySign()+e.variant.other_info.signup_fee,placement:"top","popper-class":"fct-tooltip"},{default:i(()=>[r("span",xfe,"+ "+h(n.$t("fee")),1)]),_:1},8,["content"])]),key:"0"}:void 0]),1032,["class","modelValue","placeholder","disabled"])):(d(),_("span",Sfe,"—"))}}},Ffe=["disabled"],Efe={key:0,class:"fct-bulk-sub-count"},Ufe={class:"fct-bulk-sub-popover-body"},$fe={class:"fct-bulk-sub-popover-title"},Dfe={class:"fct-bulk-sub-section"},Qfe={class:"fct-bulk-sub-row"},Ife={class:"fct-bulk-sub-row"},Tfe={class:"fct-bulk-sub-label"},Vfe={class:"fct-bulk-sub-row"},Mfe={class:"fct-bulk-sub-label"},Lfe=["innerHTML"],Rfe={class:"fct-bulk-sub-section"},Ofe={class:"fct-bulk-sub-row"},Hfe={class:"fct-bulk-sub-row"},Pfe={class:"fct-bulk-sub-label"},Nfe={class:"fct-bulk-sub-row"},Kfe={class:"fct-bulk-sub-label"},Gfe=["innerHTML"],jfe={class:"fct-bulk-sub-footer"},zfe={__name:"BulkSubscriptionPopover",props:{variant:{type:Object,required:!0},disabled:{type:Boolean,default:!1}},emits:["changed"],setup(e,{emit:t}){const a=e,n=t,s=Qt().ctx,o=Ie.get(),u=Ie.get("app_config.isProActive"),A=V(!1),f=j(()=>{var $;return(($=o==null?void 0:o.shop)==null?void 0:$.currency_sign)||"$"}),m=j(()=>{var $;return(($=a.variant)==null?void 0:$.other_info)||{}}),g=j(()=>m.value.payment_type==="subscription"),y=j(()=>m.value.installment==="yes"),v=j(()=>Number(m.value.times)||1),B=j(()=>{var F;const $=Number((F=a.variant)==null?void 0:F.item_price)||0;return y.value?$*v.value:$}),b=j(()=>{const $=[];if(y.value&&$.push(s.$t("Installment")+": "+v.value+"x"),m.value.manage_setup_fee==="yes"){const F=m.value.signup_fee_name||s.$t("Setup fee"),L=m.value.signup_fee||0;$.push(s.$t("Setup fee")+": "+F+" ("+f.value+L+")")}return $.length>0?$.join(`
`):s.$t("Subscription settings")}),w=$=>{$==="no"?a.variant.other_info.times="":a.variant.other_info.times||(a.variant.other_info.times=1),n("changed")},k=$=>{$==="no"&&(a.variant.other_info.signup_fee=""),n("changed")},S=()=>{n("changed")},M=()=>{A.value=!1};return($,F)=>{const L=C("el-checkbox"),Q=C("el-tooltip"),T=C("el-input"),D=C("el-switch"),U=C("el-button"),I=C("el-popover");return d(),E(Q,{content:b.value,placement:"top",disabled:!g.value||A.value,"popper-class":"fct-tooltip","show-after":400},{default:i(()=>[l(I,{visible:A.value,"onUpdate:visible":F[6]||(F[6]=O=>A.value=O),placement:"bottom",width:320,trigger:"click",disabled:e.disabled||!g.value,"popper-class":"bulk-sub-popover"},{reference:i(()=>[r("button",{class:de(["fc-bulk-sub-icon-btn",{"is-active":g.value,"is-configured":g.value&&(y.value||m.value.manage_setup_fee==="yes")}]),disabled:e.disabled||!g.value,onClick:F[0]||(F[0]=Xe(()=>{},["prevent"]))},[F[7]||(F[7]=r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16"},[r("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?(d(),_("span",Efe,h(v.value),1)):x("",!0)],10,Ffe)]),default:i(()=>[r("div",Ufe,[r("h4",$fe,h($.$t("Subscription Settings")),1),r("div",Dfe,[r("div",Qfe,[l(L,{"true-value":"yes","false-value":"no",label:$.$t("Enable installment payment"),modelValue:e.variant.other_info.installment,"onUpdate:modelValue":F[1]||(F[1]=O=>e.variant.other_info.installment=O),disabled:!p(u)||e.disabled,onChange:w},null,8,["label","modelValue","disabled"]),p(u)?x("",!0):(d(),E(Q,{key:0,"popper-class":"fct-tooltip"},{content:i(()=>[R(h($.$t("This feature is available in pro version only.")),1)]),default:i(()=>[l(W,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),m.value.installment==="yes"?(d(),_(H,{key:0},[r("div",Ife,[r("label",Tfe,h($.$t("Installment Count")),1),l(T,{type:"number",min:1,size:"small",modelValue:e.variant.other_info.times,"onUpdate:modelValue":F[2]||(F[2]=O=>e.variant.other_info.times=O),modelModifiers:{number:!0},placeholder:$.$t("Count"),style:{width:"100px"},onInput:S},null,8,["modelValue","placeholder"])]),r("div",Vfe,[r("span",Mfe,h($.$t("Total Price")),1),r("span",{class:"fct-bulk-sub-value",innerHTML:f.value+B.value},null,8,Lfe)])],64)):x("",!0)]),r("div",Rfe,[r("div",Ofe,[l(D,{"active-text":$.$t("Setup fee"),modelValue:e.variant.other_info.manage_setup_fee,"onUpdate:modelValue":F[3]||(F[3]=O=>e.variant.other_info.manage_setup_fee=O),"active-value":"yes","inactive-value":"no",disabled:!p(u)||e.disabled,size:"small",onChange:k},null,8,["active-text","modelValue","disabled"]),p(u)?x("",!0):(d(),E(Q,{key:0,"popper-class":"fct-tooltip"},{content:i(()=>[R(h($.$t("This feature is available in pro version only.")),1)]),default:i(()=>[l(W,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),m.value.manage_setup_fee==="yes"?(d(),_(H,{key:0},[r("div",Hfe,[r("label",Pfe,h($.$t("Label")),1),l(T,{size:"small",modelValue:e.variant.other_info.signup_fee_name,"onUpdate:modelValue":F[4]||(F[4]=O=>e.variant.other_info.signup_fee_name=O),placeholder:$.$t("e.g. Initial Setup"),onInput:S},null,8,["modelValue","placeholder"])]),r("div",Nfe,[r("label",Kfe,h($.$t("Amount")),1),l(T,{size:"small",type:"number",min:0,modelValue:e.variant.other_info.signup_fee,"onUpdate:modelValue":F[5]||(F[5]=O=>e.variant.other_info.signup_fee=O),modelModifiers:{number:!0},placeholder:$.$t("Amount"),onInput:S},{prefix:i(()=>[r("span",{innerHTML:f.value},null,8,Gfe)]),_:1},8,["modelValue","placeholder"])])],64)):x("",!0)]),r("div",jfe,[l(U,{size:"small",type:"primary",onClick:M},{default:i(()=>[R(h($.$t("Done")),1)]),_:1})])])]),_:1},8,["visible","disabled"])]),_:1},8,["content","disabled"])}}},Yfe={key:0,class:"flex items-center"},qfe={key:1,class:"text-gray-300 text-sm flex justify-center"},Dr={__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,n=t,s=()=>{var o;return(o=a.variant)==null?void 0:o.other_info};return(o,u)=>{const A=C("el-option"),f=C("el-select");return e.variant&&s()?(d(),_("div",Yfe,[l(f,{modelValue:e.variant.other_info.payment_type,"onUpdate:modelValue":u[0]||(u[0]=m=>e.variant.other_info.payment_type=m),size:"small",class:de({"is-field-error":e.hasError}),disabled:e.disabled,onChange:u[1]||(u[1]=m=>n("payment-type-change",e.variant))},{default:i(()=>[l(A,{label:o.$t("One Time"),value:"onetime"},null,8,["label"]),l(A,{label:o.$t("Subscription"),value:"subscription"},null,8,["label"])]),_:1},8,["modelValue","class","disabled"]),l(zfe,{variant:e.variant,disabled:e.disabled,onChanged:u[2]||(u[2]=m=>n("change"))},null,8,["variant","disabled"])])):(d(),_("span",qfe,"—"))}}},Wfe={key:1,class:"text-gray-300 text-sm flex justify-center"},Qr={__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,n=t,s=()=>{var o,u;return((u=(o=a.variant)==null?void 0:o.other_info)==null?void 0:u.payment_type)==="subscription"};return(o,u)=>{const A=C("el-option"),f=C("el-select");return e.variant&&s()?(d(),E(f,{key:0,modelValue:e.variant.other_info.repeat_interval,"onUpdate:modelValue":u[0]||(u[0]=m=>e.variant.other_info.repeat_interval=m),size:"small",class:de({"is-field-error":e.hasError}),disabled:e.disabled,onChange:u[1]||(u[1]=m=>n("change"))},{default:i(()=>[l(A,{label:o.$t("Yearly"),value:"yearly"},null,8,["label"]),l(A,{label:o.$t("Half Yearly"),value:"half_yearly"},null,8,["label"]),l(A,{label:o.$t("Quarterly"),value:"quarterly"},null,8,["label"]),l(A,{label:o.$t("Monthly"),value:"monthly"},null,8,["label"]),l(A,{label:o.$t("Weekly"),value:"weekly"},null,8,["label"]),l(A,{label:o.$t("Daily"),value:"daily"},null,8,["label"])]),_:1},8,["modelValue","class","disabled"])):(d(),_("span",Wfe,"—"))}}},Xfe={key:1,class:"text-gray-300 text-sm flex justify-center"},Ir={__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,n=t,s=()=>{var o,u;return((u=(o=a.variant)==null?void 0:o.other_info)==null?void 0:u.payment_type)==="subscription"};return(o,u)=>{const A=C("el-input");return e.variant&&s()?(d(),E(A,{key:0,class:de(["fct-bulk-input",{"is-error":e.hasError}]),modelValue:e.variant.other_info.trial_days,"onUpdate:modelValue":u[0]||(u[0]=f=>e.variant.other_info.trial_days=f),placeholder:"0",disabled:e.disabled,onChange:u[1]||(u[1]=f=>n("change")),size:"small"},null,8,["class","modelValue","disabled"])):(d(),_("span",Xfe,"—"))}}},Jfe={key:1,class:"text-gray-300 text-sm flex justify-center"},Tr={__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(n,s)=>{const o=C("el-input");return e.variant?(d(),E(o,{key:0,size:"small",class:de({"is-error":e.hasError}),modelValue:e.variant.compare_price,"onUpdate:modelValue":s[0]||(s[0]=u=>e.variant.compare_price=u),placeholder:n.$t("Compare price"),disabled:e.disabled,onInput:s[1]||(s[1]=u=>a("change"))},null,8,["class","modelValue","placeholder","disabled"])):(d(),_("span",Jfe,"—"))}}},Bm={__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,n=s=>{a("update:modelValue",s),a("change",s)};return(s,o)=>{const u=C("el-option"),A=C("el-select");return d(),E(A,{"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":n},{default:i(()=>[(d(!0),_(H,null,ee(e.options,f=>(d(),E(u,{key:f.value,label:f.label,value:f.value},null,8,["label","value"]))),128))]),_:1},8,["model-value","placeholder","disabled"])}}},Zfe=["textContent"],eme={key:1,class:"fct-bulk-editor-placeholder"},Vr={__name:"BulkEditorCell",props:{value:{type:String,default:""},placeholder:{type:String,default:""}},emits:["click"],setup(e){return(t,a)=>(d(),_("div",{class:"fct-bulk-editor",onClick:a[0]||(a[0]=n=>t.$emit("click"))},[e.value?(d(),_("span",{key:0,class:"bulk-editor-preview",textContent:h(e.value)},null,8,Zfe)):(d(),_("span",eme,h(e.placeholder),1))]))}};function km(){const e=V(new Set),t=V(null),a=V(!1),n=(y,v,B)=>{if(v.shiftKey&&t.value!==null){const w=B.indexOf(t.value),k=B.indexOf(y);if(w!==-1&&k!==-1){const S=Math.min(w,k),M=Math.max(w,k),$=new Set(e.value);for(let F=S;F<=M;F++)$.add(B[F]);e.value=$}}else{const w=new Set(e.value);w.has(y)?w.delete(y):w.add(y),e.value=w,t.value=y}},s=y=>{e.value.size===y.length&&y.length>0?e.value=new Set:e.value=new Set(y)},o=y=>{e.value=new Set(y)},u=()=>{e.value=new Set,t.value=null,a.value=!1},A=()=>{a.value?a.value=!1:e.value.size>=2&&(a.value=!0)};ge(e,y=>{a.value&&y.size<2&&(a.value=!1)});const f=y=>e.value.has(y),m=j(()=>e.value.size);return{selectedKeys:e,lastClickedKey:t,isLinkMode:a,handleRowClick:n,toggleSelectAll:s,selectAll:o,deselectAll:u,toggleLinkMode:A,isSelected:f,selectedCount:m,pruneStaleKeys:y=>{const v=new Set(y);let B=!1;const b=new Set;for(const w of e.value)v.has(w)?b.add(w):B=!0;B&&(e.value=b),t.value&&!v.has(t.value)&&(t.value=null)}}}const tme={mounted(e,t){e.indeterminate=!!t.value},updated(e,t){e.indeterminate=!!t.value}},xm={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,n;return(n=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:n.payment_type},set:(e,t)=>{var a,n;(n=(a=e.variants)==null?void 0:a[0])!=null&&n.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,n;return(n=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:n.repeat_interval},set:(e,t)=>{var a,n;(n=(a=e.variants)==null?void 0:a[0])!=null&&n.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,n;return(n=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:n.trial_days},set:(e,t)=>{var a,n;(n=(a=e.variants)==null?void 0:a[0])!=null&&n.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]}}},ame={...xm,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}}},nme={...xm,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 Sm(e,t,a,n,s,o,u){const A=u[e];if(A)for(const f of n){if(f===a)continue;const m=s(f);if(!m)continue;const g=A[m.type];g&&(g.set(m.data,t),o&&o(m.product))}}const sme={class:"fct-bulk-insert-page fct-layout-width"},lme={class:"fct-btn-group sm justify-end"},ome={class:"filter-popover-item"},rme={class:"filter-popover-title"},ime={key:0,"aria-hidden":"true"},dme=["colspan"],ume=["onClick"],cme=["onClick"],Ame={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},pme={class:"flex items-center"},fme=["onClick","title"],mme={key:0,class:"bulk-collapse-count"},hme=["title"],_me=["title"],gme={class:"bulk-status-icon is-error"},vme={key:0,class:"fct-bulk-sku-cell"},yme={key:1,class:"text-gray-300 text-sm flex justify-center"},bme={key:1,class:"fct-bulk-media-cell"},wme={key:2,class:"fct-bulk-categories-cell"},Cme={key:3,class:"fct-bulk-desc-cell"},Bme={key:4,class:"fct-bulk-short-desc-cell"},kme={key:5,class:"fct-bulk-status-cell"},xme={key:6,class:"fct-bulk-product-type-cell"},Sme={key:7,class:"fct-bulk-product-type-cell"},Fme={key:8,class:"fct-bulk-pricing-type-cell"},Eme={key:9,class:"fct-bulk-pricing-type-cell"},Ume={key:10,class:"fct-bulk-payment-type-cell"},$me={key:11,class:"fct-bulk-interval-cell"},Dme={key:12,class:"fct-bulk-trial-days-cell"},Qme={key:13,class:"fct-bulk-best-price-cell"},Ime={key:14,class:"fct-bulk-compare-price-cell"},Tme={key:15,class:"fct-bulk-qty-cell !pl-5"},Vme={key:16,class:"fct-bulk-stock-cell"},Mme={key:1,class:"text-gray-300 text-sm pl-5"},Lme={class:"fct-btn-group xs justify-end"},Rme=["href","title"],Ome={key:0,class:"bulk-variants-block-row"},Hme=["colspan"],Pme={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},Nme=["onClick"],Kme={class:"bulk-checkbox-cell"},Gme={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},jme={class:"flex items-center gap-1 pl-4"},zme={class:"bulk-status-icon is-error"},Yme={key:0,class:"fct-bulk-sku-cell"},qme={key:1,class:"fct-bulk-media-cell"},Wme={key:2},Xme={key:3},Jme={key:4},Zme={key:5},ehe={key:6},the={key:7},ahe={key:8},nhe={key:9},she={key:10},lhe={key:11},ohe={key:12},rhe={key:13,class:"text-center"},ihe={key:14},dhe={key:1,class:"text-gray-300 text-sm flex justify-center"},uhe={class:"fct-btn-group sm justify-end"},che={class:"bulk-add-variant-row"},Ahe=["colspan"],phe={class:"sticky left-0 inline-block pl-6"},fhe={key:1,"aria-hidden":"true"},mhe=["colspan"],qi=43,hhe=10,_he=800,VA=100,ghe={__name:"BulkInsert",setup(e){const{options:t,products:a}=ot.data,n=ue=>{var ve;return((ve=ue==null?void 0:ue.detail)==null?void 0:ve.variation_type)==="simple"},s=j(()=>ot.data.saving),o=j(()=>ot.data.saveProgress),u=j(()=>{const ue=ot.data.saveProgress;return ue.total?Math.round(ue.completed/ue.total*100):0}),A=()=>{ot.saveProducts()},f=ue=>ot.isSaving(ue._cid),m=ue=>ot.isSaved(ue._cid),g=ue=>ot.isRowDisabled(ue._cid),y=ue=>ot.hasError(ue._cid),v=ue=>ot.getError(ue._cid),B=ue=>ot.hasProductLevelError(ue._cid),b=(ue,ve)=>ot.hasVariantError(ue._cid,ve),w=(ue,ve)=>ot.getVariantError(ue._cid,ve),k=(ue,ve)=>ot.hasFieldError(ue._cid,ve),S=(ue,ve,We)=>ot.hasVariantFieldError(ue._cid,ve,We),M=async ue=>{const ve=ue.post_title||P.$t("Untitled product"),We=Array.isArray(ue.variants)?ue.variants.length:0,_t=ot.isSaved(ue._cid);let rt=We>0?P.$t('This will remove "%s" and its %s variant(s).').replace("%s",ve).replace("%s",We):P.$t('This will remove "%s".').replace("%s",ve);_t&&(rt+=" "+P.$t("This product was already saved and will be permanently deleted."));try{await Ea.confirm(rt,P.$t("Remove Product"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),type:"warning"})}catch{return}await ot.removeProduct(ue)},$=(ue,ve)=>{const We=ve.variation_title||P.$t("Untitled variant");Ea.confirm(P.$t('This will remove the variant "%s".').replace("%s",We),P.$t("Remove Variant"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),confirmButtonClass:"el-button--small",cancelButtonClass:"el-button--small",type:"warning"}).then(()=>{ot.removeVariant(ue,ve)}).catch(()=>{})},F=ue=>ot.duplicateProduct(ue),L=(ue,ve)=>ot.duplicateVariant(ue,ve),Q=()=>{const ue=[];for(const ve of a){const We=`p:${ve._cid}`,_t=le.value.has(We),rt=[];ve.variants&&ve.variants.forEach((Wt,lt)=>{le.value.has(`v:${ve._cid}:${lt}`)&&rt.push(lt)}),!(!_t&&rt.length===0)&&(_t&&rt.length===0?ue.push({product:ve,type:"full"}):!_t&&rt.length>0?ue.push({product:ve,type:"variants-only",variantIndexes:rt}):ue.push({product:ve,type:"partial",variantIndexes:rt}))}return ue},T=()=>{const ue=Q();if(!ue.length)return;const ve=ue.filter(lt=>lt.type==="full").length,We=ue.filter(lt=>lt.type==="partial").length,rt=ue.filter(lt=>lt.type==="variants-only").reduce((lt,ga)=>lt+ga.variantIndexes.length,0),Wt=[];ve>0&&Wt.push(`${ve} product(s) with all variants`),We>0&&Wt.push(`${We} product(s) with selected variants`),rt>0&&Wt.push(`${rt} variant(s)`),Ea.confirm(P.$t("Duplicate %s?").replace("%s",Wt.join(", ")),P.$t("Bulk Duplicate"),{confirmButtonText:P.$t("Duplicate"),cancelButtonText:P.$t("Cancel"),type:"info"}).then(()=>{for(const lt of ue)if(lt.type==="full")ot.duplicateProduct(lt.product);else if(lt.type==="variants-only")for(const ga of lt.variantIndexes){const va=lt.product.variants[ga];va&&ot.duplicateVariant(lt.product,va)}else lt.type==="partial"&&ot.duplicateProductWithVariants(lt.product,lt.variantIndexes);be()}).catch(()=>{})},D=async()=>{const ue=[],ve=[];for(const lt of a){const ga=`p:${lt._cid}`;if(le.value.has(ga)){ue.push(lt);continue}const Da=[];lt.variants&<.variants.forEach((Sn,Tn)=>{le.value.has(`v:${lt._cid}:${Tn}`)&&Da.push(Sn)}),Da.length>0&&ve.push({product:lt,variants:Da})}if(!ue.length&&!ve.length)return;const We=ue.filter(lt=>ot.isSaved(lt._cid)).length,_t=ve.reduce((lt,ga)=>lt+ga.variants.length,0),rt=[];ue.length>0&&rt.push(`${ue.length} product(s)`),_t>0&&rt.push(`${_t} variant(s)`);let Wt=P.$t("Remove %s?").replace("%s",rt.join(" and "));We>0&&(Wt+=" "+P.$t("%s already saved will be permanently deleted.").replace("%s",`${We}`));try{await Ea.confirm(Wt,P.$t("Bulk Remove"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),type:"warning"})}catch{return}for(const lt of ue)await ot.removeProduct(lt);for(const{product:lt,variants:ga}of ve)for(const va of ga)ot.removeVariant(lt,va);be()},U=ue=>{ot.resetPaymentTypeDefaults(ue)},I=(ue,ve)=>{const We=ot.data.categoryOptions;for(const _t of ve)We.find(rt=>rt.value===_t)||We.push({label:_t,value:_t})},O=()=>{ot.populateDummyProduct()},P=Qt().ctx,K=ue=>{const ve=ot.data.products;ue.concat||(ve.splice(0,ve.length),ot.data.savedIds=new Set,ot.data.savingIds=new Set,ot.data.productErrors=new Map),ve.push(...ue.products)},G=V({visible:!1,field:"",product:null,value:""}),ne=(ue,ve)=>{G.value={visible:!0,field:ve,product:ue,value:ue[ve]||""}},Y=ue=>{G.value.value=ue},N=()=>{const{product:ue,field:ve,value:We}=G.value;ue&&(ue[ve]=We),G.value.visible=!1},oe=j(()=>G.value.field==="post_content"?P.$t("Edit Description"):P.$t("Edit Short Description")),Z=V(!0),{selectedKeys:le,handleRowClick:te,toggleSelectAll:X,selectAll:ie,deselectAll:be,isSelected:se,selectedCount:ce,isLinkMode:pe,toggleLinkMode:De}=km(),$e=j(()=>{const ue=[];for(const ve of Ze.value)if(ue.push(`p:${ve.productId}`),ve.hasVariants&&!ve.collapsed)for(let We=0;We{var ve;if(ue.startsWith("p:")){const We=ue.slice(2),_t=a.find(rt=>rt._cid===We);return _t?{type:"product",data:_t,product:_t}:null}else if(ue.startsWith("v:")){const We=ue.split(":"),_t=We[1],rt=parseInt(We[2]),Wt=a.find(lt=>lt._cid===_t);if(Wt&&((ve=Wt.variants)!=null&&ve[rt]))return{type:"variant",data:Wt.variants[rt],product:Wt}}return null},we=(ue,ve,We)=>{!pe.value||!se(We)||Sm(ue,ve,We,le.value,Je,null,ame)},Ye=V(!1),ft=ue=>{ue.key==="Shift"&&(Ye.value=!0)},Ge=ue=>{ue.key==="Shift"&&(Ye.value=!1)},_e=(ue,ve)=>{if(!ve.shiftKey||ve.target.closest(".bulk-checkbox-cell"))return;ve.preventDefault();const We=new Set(le.value);We.has(ue)?We.delete(ue):We.add(ue),le.value=We},xe=V([]),Me=j(()=>xe.value.filter(ue=>ue.key==="title"||ue.key==="actions"?!0:ot.isColumnVisible(ue.key))),Fe=ue=>ot.isColumnVisible(ue),nt=()=>{ot.saveColumnWidths(xe.value)},st=V(new Set),Ot=ue=>{const ve=ue._cid;st.value.has(ve)?st.value.delete(ve):st.value.add(ve),st.value=new Set(st.value)},Ct=ue=>st.value.has(ue._cid),yt=V(0),Ze=j(()=>{let ue=0;return a.map(ve=>{var Da;const We=ve._cid,_t=((Da=ve.detail)==null?void 0:Da.variation_type)!=="simple"&&Array.isArray(ve.variants),rt=_t?ve.variants.length:0,Wt=st.value.has(We),lt=_t&&!Wt?(rt+1)*qi:0,ga=qi+lt,va={product:ve,productId:We,hasVariants:_t,variantCount:rt,collapsed:Wt,groupHeight:ga,offset:ue};return ue+=ga,va})}),Bt=j(()=>{const ue=Ze.value;if(ue.length===0)return 0;const ve=ue[ue.length-1];return ve.offset+ve.groupHeight}),ht=j(()=>{const ue=Ze.value,ve=yt.value,We=ve+_he,_t=hhe*qi;return ue.filter(rt=>rt.offset+rt.groupHeight>=ve-_t&&rt.offset<=We+_t)}),Ft=j(()=>ht.value.length===0?0:ht.value[0].offset),kt=j(()=>{if(ht.value.length===0)return 0;const ue=ht.value[ht.value.length-1];return Bt.value-ue.offset-ue.groupHeight});let xt=null,Ht=0;const pt=ue=>{const ve=ue.target,We=Date.now();xt&&clearTimeout(xt),We-Ht>=VA?(yt.value=ve.scrollTop,Ht=We):xt=setTimeout(()=>{yt.value=ve.scrollTop,Ht=Date.now(),xt=null},VA)};let da=null;return Be(async()=>{da=ks(),da.bind("mod+a",ue=>{var We,_t;const ve=(We=document.activeElement)==null?void 0:We.tagName;ve==="INPUT"||ve==="TEXTAREA"||(_t=document.activeElement)!=null&&_t.isContentEditable||(ue.preventDefault(),ie($e.value))}),da.bind("escape",()=>{var ve,We;const ue=(ve=document.activeElement)==null?void 0:ve.tagName;ue==="INPUT"||ue==="TEXTAREA"||(We=document.activeElement)!=null&&We.isContentEditable||(pe.value?De():be())}),xe.value=[{key:"title",title:P.$t("Title"),width:150,minWidth:100},{key:"sku",title:P.$t("SKU"),width:120,minWidth:80},{key:"media",title:P.$t("Media"),width:100,minWidth:50},{key:"categories",title:P.$t("Categories"),width:200,minWidth:150},{key:"description",title:P.$t("Description"),width:200,minWidth:150},{key:"short_description",title:P.$t("Short Description"),width:150,minWidth:100},{key:"status",title:P.$t("Status"),width:100,minWidth:50},{key:"product_type",title:P.$t("Product Type"),width:200,minWidth:150},{key:"pricing_type",title:P.$t("Pricing Type"),width:200,minWidth:150},{key:"payment_type",title:P.$t("Payment Type"),width:120,minWidth:100},{key:"interval",title:P.$t("Interval"),width:120,minWidth:80},{key:"trial_days",title:P.$t("Trial Days"),width:100,minWidth:70},{key:"best_price",title:P.$t("Best Price"),width:100,minWidth:100},{key:"compare_price",title:P.$t("Compare-at Price"),width:200,minWidth:150},{key:"track_quantity",title:P.$t("Track Quantity"),width:100,minWidth:100},{key:"stock",title:P.$t("Stock"),width:150,minWidth:150},{key:"actions",title:"",width:110,minWidth:110}],ot.restoreColumnWidths(xe.value),ot.setupColumnVisibility(),ot.fetchCategories(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",ft),window.addEventListener("keyup",Ge)}),xn(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",ft),window.removeEventListener("keyup",Ge),da&&da.reset()}),(ue,ve)=>{const We=C("el-button"),_t=C("el-progress"),rt=C("el-checkbox"),Wt=C("el-checkbox-group"),lt=C("el-tooltip"),ga=C("el-popover"),va=C("el-input"),Da=C("el-icon"),Sn=C("el-option"),Tn=C("el-select"),Fs=C("el-switch"),El=C("el-dialog");return d(),_("div",sme,[l(za,{title:ue.$t("Bulk Insert")},{action:i(()=>[l(yfe,{onOnDataPopulated:K}),l(We,{onClick:O},{default:i(()=>[R(h(ue.$t("Add Product")),1)]),_:1}),l(We,{type:"primary",onClick:A,loading:s.value,disabled:s.value||p(a).length===0},{default:i(()=>[R(h(s.value?ue.$t("Saving %s/%s...").replace("%s",o.value.completed).replace("%s",o.value.total):ue.$t("Save All Products")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),s.value?(d(),E(_t,{key:0,percentage:u.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):x("",!0),l(he,null,{default:i(()=>{var mn;return[p(a).length>0?(d(),E(Ce,{key:0,title:((mn=p(a))==null?void 0:mn.length)===1?ue.$t("Product"):ue.$t("Products"),border_bottom:""},{action:i(()=>[r("div",lme,[l(We,{disabled:p(ce)===0,onClick:D,size:"small",type:"danger",soft:""},{default:i(()=>[ve[8]||(ve[8]=r("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[r("polyline",{points:"3 6 5 6 21 6"}),r("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(" "+h(ue.$t("Delete")),1)]),_:1,__:[8]},8,["disabled"]),l(We,{disabled:p(ce)===0,onClick:T,size:"small",type:"info",soft:""},{default:i(()=>[ve[9]||(ve[9]=r("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[r("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)),R(" "+h(ue.$t("Duplicate")),1)]),_:1,__:[9]},8,["disabled"]),l(We,{class:de({"is-active":p(pe)}),disabled:p(ce)<2&&!p(pe),onClick:p(De),size:"small",type:"info",soft:""},{default:i(()=>[ve[10]||(ve[10]=r("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[r("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r("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(" "+h(p(pe)?ue.$t("Unlink"):ue.$t("Link")),1)]),_:1,__:[10]},8,["class","disabled","onClick"]),l(rt,{modelValue:Z.value,"onUpdate:modelValue":ve[0]||(ve[0]=Ae=>Z.value=Ae),label:ue.$t("Pin Actions")},null,8,["modelValue","label"]),l(ga,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:i(()=>[r("span",null,[l(lt,{effect:"light",content:ue.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:i(()=>[l(Oe,{tag:"button",size:"small"},{default:i(()=>[l(W,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:i(()=>[r("div",ome,[r("h3",rme,h(ue.$t("Columns")),1),l(Wt,{modelValue:p(ot).data.visibleColumns,"onUpdate:modelValue":ve[1]||(ve[1]=Ae=>p(ot).data.visibleColumns=Ae),class:"fct-checkbox-blocks",onChange:ve[2]||(ve[2]=Ae=>p(ot).handleColumnVisibilityChange())},{default:i(()=>[(d(!0),_(H,null,ee(p(ot).getToggleableColumns(),Ae=>(d(),E(rt,{key:Ae.value,value:Ae.value,label:ue.$t(Ae.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])]),_:1},8,["title"])):x("",!0),l(me,{class:"p-0"},{default:i(()=>[p(a).length>0?(d(),_("div",{key:0,class:de(["relative",{"is-link-mode":p(pe),"is-shift-held":Ye.value}])},[l(Cm,{columns:Me.value,"sticky-last":Z.value,onScroll:pt,onResizeEnd:nt},{"header-first":i(()=>[l(rt,{"model-value":p(ce)>0&&p(ce)===$e.value.length,indeterminate:p(ce)>0&&p(ce)<$e.value.length,onChange:ve[3]||(ve[3]=Ae=>p(X)($e.value))},null,8,["model-value","indeterminate"])]),"header-last":i(()=>[R(h(ue.$t("Actions")),1)]),default:i(()=>[Ft.value>0?(d(),_("tr",ime,[r("td",{colspan:Me.value.length+1,style:ia({height:Ft.value+"px",padding:0,border:"none"})},null,12,dme)])):x("",!0),(d(!0),_(H,null,ee(ht.value,Ae=>{var Ws,z,J,fe,Ue,je,et,Le,qe,Et,tt,bt,ua,Fn,Es;return d(),_(H,{key:Ae.productId},[r("tr",{class:de(["bulk-product-row",{"is-saving":f(Ae.product),"is-saved":m(Ae.product),"has-product-error":y(Ae.product),"is-selected":p(se)(`p:${Ae.productId}`)}]),onClick:ae=>_e(`p:${Ae.productId}`,ae)},[r("td",{class:"bulk-checkbox-cell",onClick:ae=>p(te)(`p:${Ae.productId}`,ae,$e.value)},[l(rt,{"model-value":p(se)(`p:${Ae.productId}`),tabindex:"-1"},null,8,["model-value"])],8,cme),r("td",Ame,[r("div",pme,[Ae.hasVariants?(d(),_("button",{key:0,class:"bulk-collapse-btn",onClick:Xe(ae=>Ot(Ae.product),["prevent"]),title:Ct(Ae.product)?ue.$t("Expand variants"):ue.$t("Collapse variants")},[(d(),_("svg",{class:de(["bulk-collapse-icon",{"is-collapsed":Ct(Ae.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},ve[11]||(ve[11]=[r("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),Ct(Ae.product)?(d(),_("span",mme,h(Ae.variantCount),1)):x("",!0)],8,fme)):x("",!0),l(va,{class:de(["fct-bulk-input",{"is-error":k(Ae.product,"post_title")}]),modelValue:Ae.product.post_title,"onUpdate:modelValue":ae=>Ae.product.post_title=ae,placeholder:ue.$t("Product title"),size:"small",disabled:g(Ae.product),onInput:ae=>we("title",ae,`p:${Ae.productId}`)},null,8,["class","modelValue","onUpdate:modelValue","placeholder","disabled","onInput"]),f(Ae.product)?(d(),_("span",{key:1,class:"bulk-status-icon is-syncing",title:ue.$t("Saving...")},[l(Da,{class:"is-loading",size:14},{default:i(()=>[l(p(_l))]),_:1})],8,hme)):m(Ae.product)?(d(),_("span",{key:2,class:"bulk-status-icon is-saved",title:ue.$t("Saved")},ve[12]||(ve[12]=[r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16"},[r("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,_me)):B(Ae.product)||n(Ae.product)&&y(Ae.product)?(d(),E(lt,{key:3,content:v(Ae.product),placement:"top"},{default:i(()=>[r("span",gme,[l(Da,{size:16},{default:i(()=>[l(p(ur))]),_:1})])]),_:2},1032,["content"])):x("",!0)])]),Fe("sku")?(d(),_("td",vme,[((z=(Ws=Ae.product)==null?void 0:Ws.detail)==null?void 0:z.variation_type)==="simple"&&((J=Ae.product.variants)!=null&&J[0])?(d(),E(va,{key:0,class:de(["fct-bulk-input",{"is-error":k(Ae.product,"variants.0.sku")}]),modelValue:Ae.product.variants[0].sku,"onUpdate:modelValue":[ae=>Ae.product.variants[0].sku=ae,ae=>we("sku",ae,`p:${Ae.productId}`)],placeholder:"SKU",size:"small",disabled:g(Ae.product)},null,8,["class","modelValue","onUpdate:modelValue","disabled"])):(d(),_("span",yme,"—"))])):x("",!0),Fe("media")?(d(),_("td",bme,[l(Bs,{modelValue:Ae.product.gallery,"onUpdate:modelValue":ae=>Ae.product.gallery=ae,"show-url-tab":"",disabled:g(Ae.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):x("",!0),Fe("categories")?(d(),_("td",wme,[l(Bm,{modelValue:Ae.product.categories,"onUpdate:modelValue":ae=>Ae.product.categories=ae,options:p(ot).data.categoryOptions,disabled:g(Ae.product),onChange:ae=>{I(Ae.product,ae),we("categories",Ae.product.categories,`p:${Ae.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):x("",!0),Fe("description")?(d(),_("td",Cme,[l(Vr,{value:Ae.product.post_content,placeholder:ue.$t("Description"),onClick:ae=>ne(Ae.product,"post_content")},null,8,["value","placeholder","onClick"])])):x("",!0),Fe("short_description")?(d(),_("td",Bme,[l(Vr,{value:Ae.product.post_excerpt,placeholder:ue.$t("Short description"),onClick:ae=>ne(Ae.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):x("",!0),Fe("status")?(d(),_("td",kme,[l(Tn,{modelValue:Ae.product.post_status,"onUpdate:modelValue":ae=>Ae.product.post_status=ae,size:"small",class:de({"is-field-error":k(Ae.product,"post_status")}),disabled:g(Ae.product),onChange:ae=>we("status",Ae.product.post_status,`p:${Ae.productId}`)},{default:i(()=>[(d(!0),_(H,null,ee(p(t).status,ae=>(d(),E(Sn,{key:ae.value,label:ue.$t(ae.title),value:ae.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):x("",!0),Fe("product_type")&&((fe=Ae.product)!=null&&fe.detail)?(d(),_("td",xme,[l(Tn,{modelValue:Ae.product.detail.fulfillment_type,"onUpdate:modelValue":ae=>Ae.product.detail.fulfillment_type=ae,size:"small",class:de({"is-field-error":k(Ae.product,"detail.fulfillment_type")}),disabled:g(Ae.product),onChange:ae=>we("product_type",Ae.product.detail.fulfillment_type,`p:${Ae.productId}`)},{default:i(()=>[(d(!0),_(H,null,ee(p(t).fulfilment,ae=>(d(),E(Sn,{key:ae.value,label:ue.$t(ae.title),value:ae.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Fe("product_type")?(d(),_("td",Sme)):x("",!0),Fe("pricing_type")&&((Ue=Ae.product)!=null&&Ue.detail)?(d(),_("td",Fme,[l(Tn,{modelValue:Ae.product.detail.variation_type,"onUpdate:modelValue":ae=>Ae.product.detail.variation_type=ae,size:"small",class:de({"is-field-error":k(Ae.product,"detail.variation_type")}),disabled:g(Ae.product),onChange:ae=>{p(ot).handleVariationChanged(Ae.product,ae),we("pricing_type",ae,`p:${Ae.productId}`)}},{default:i(()=>[(d(!0),_(H,null,ee(p(t).variation,ae=>(d(),E(Sn,{key:ae.value,label:ue.$t(ae.title),value:ae.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Fe("pricing_type")?(d(),_("td",Eme)):x("",!0),Fe("payment_type")?(d(),_("td",Ume,[l(Dr,{variant:n(Ae.product)?(je=Ae.product.variants)==null?void 0:je[0]:null,disabled:g(Ae.product),"has-error":k(Ae.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:ae=>{var it;U(ae),we("payment_type",(it=ae.other_info)==null?void 0:it.payment_type,`p:${Ae.productId}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):x("",!0),Fe("interval")?(d(),_("td",$me,[l(Qr,{variant:n(Ae.product)?(et=Ae.product.variants)==null?void 0:et[0]:null,disabled:g(Ae.product),"has-error":k(Ae.product,"variants.0.other_info.repeat_interval"),onChange:ae=>{var it,Ba,nn;return we("interval",(nn=(Ba=(it=Ae.product.variants)==null?void 0:it[0])==null?void 0:Ba.other_info)==null?void 0:nn.repeat_interval,`p:${Ae.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Fe("trial_days")?(d(),_("td",Dme,[l(Ir,{variant:n(Ae.product)?(Le=Ae.product.variants)==null?void 0:Le[0]:null,disabled:g(Ae.product),"has-error":k(Ae.product,"variants.0.other_info.trial_days"),onChange:ae=>{var it,Ba,nn;return we("trial_days",(nn=(Ba=(it=Ae.product.variants)==null?void 0:it[0])==null?void 0:Ba.other_info)==null?void 0:nn.trial_days,`p:${Ae.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Fe("best_price")?(d(),_("td",Qme,[l($r,{variant:n(Ae.product)?(qe=Ae.product.variants)==null?void 0:qe[0]:null,disabled:g(Ae.product),"has-error":k(Ae.product,"variants.0.item_price"),onChange:ae=>{var it,Ba;return we("price",(Ba=(it=Ae.product.variants)==null?void 0:it[0])==null?void 0:Ba.item_price,`p:${Ae.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Fe("compare_price")?(d(),_("td",Ime,[l(Tr,{variant:n(Ae.product)?(Et=Ae.product.variants)==null?void 0:Et[0]:null,disabled:g(Ae.product),"has-error":k(Ae.product,"variants.0.compare_price"),onChange:ae=>{var it,Ba;return we("compare_price",(Ba=(it=Ae.product.variants)==null?void 0:it[0])==null?void 0:Ba.compare_price,`p:${Ae.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Fe("track_quantity")?(d(),_("td",Tme,[(tt=Ae.product)!=null&&tt.detail?(d(),E(Fs,{key:0,modelValue:Ae.product.detail.manage_stock,"onUpdate:modelValue":ae=>Ae.product.detail.manage_stock=ae,"active-value":"1","inactive-value":"0",disabled:g(Ae.product),onChange:ae=>{p(ot).syncStockStatus(Ae.product),we("manage_stock",Ae.product.detail.manage_stock,`p:${Ae.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):x("",!0)])):x("",!0),Fe("stock")?(d(),_("td",Vme,[((ua=(bt=Ae.product)==null?void 0:bt.detail)==null?void 0:ua.manage_stock)==="1"&&((Es=(Fn=Ae.product)==null?void 0:Fn.detail)==null?void 0:Es.variation_type)==="simple"?(d(),E(va,{key:0,modelValue:Ae.product.detail.total_stock,"onUpdate:modelValue":[ae=>Ae.product.detail.total_stock=ae,ae=>{var it;(it=Ae.product.variants)!=null&&it[0]&&(Ae.product.variants[0].total_stock=ae,Ae.product.variants[0].available=ae),p(ot).syncStockStatus(Ae.product),we("stock",ae,`p:${Ae.productId}`)}],disabled:g(Ae.product),size:"small",placeholder:ue.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(d(),_("span",Mme,"—"))])):x("",!0),r("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":Z.value}])},[r("div",Lme,[m(Ae.product)&&Ae.product.view_url?(d(),_("a",{key:0,href:Ae.product.view_url,target:"_blank",class:"bulk-action-btn bulk-view-link",title:ue.$t("View Product")},[l(W,{name:"External"})],8,Rme)):x("",!0),l(Oe,{tag:"button",size:"x-small",onClick:Xe(ae=>F(Ae.product),["prevent"]),disabled:s.value||g(Ae.product),title:ue.$t("Duplicate")},{default:i(()=>[l(W,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),l(Oe,{tag:"button",size:"x-small",hover:"danger",onClick:Xe(ae=>M(Ae.product),["prevent"]),disabled:s.value||g(Ae.product),title:ue.$t("Delete")},{default:i(()=>[l(W,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,ume),Ae.hasVariants?(d(),_("tr",Ome,[r("td",{colspan:Me.value.length+1,class:"!p-0 !border-b-0"},[l(ra,{accordion:"",visible:!Ae.collapsed,duration:200},{default:i(()=>[r("table",Pme,[r("colgroup",null,[ve[13]||(ve[13]=r("col",{style:{width:"40px"}},null,-1)),(d(!0),_(H,null,ee(Me.value,(ae,it)=>(d(),_("col",{key:it,style:ia({width:ae.width+"px"})},null,4))),128))]),r("tbody",null,[(d(!0),_(H,null,ee(Ae.product.variants,(ae,it)=>{var Ba,nn;return d(),_("tr",{key:it,class:de(["bulk-variation-row",{"is-selected":p(se)(`v:${Ae.productId}:${it}`)}]),onClick:Ut=>_e(`v:${Ae.productId}:${it}`,Ut)},[r("td",Kme,[l(rt,{"model-value":p(se)(`v:${Ae.productId}:${it}`),tabindex:"-1",onChange:Ut=>p(te)(`v:${Ae.productId}:${it}`,Ut,$e.value)},null,8,["model-value","onChange"])]),r("td",Gme,[r("div",jme,[ve[14]||(ve[14]=r("span",{class:"text-gray-300 text-xs"},"└",-1)),l(va,{size:"small",modelValue:ae.variation_title,"onUpdate:modelValue":[Ut=>ae.variation_title=Ut,Ut=>we("title",Ut,`v:${Ae.productId}:${it}`)],placeholder:ue.$t("Variation title"),disabled:g(Ae.product),class:de({"is-error":S(Ae.product,it,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),b(Ae.product,it)?(d(),E(lt,{key:0,content:w(Ae.product,it),placement:"top"},{default:i(()=>[r("span",zme,[l(Da,{size:14},{default:i(()=>[l(p(ur))]),_:1})])]),_:2},1032,["content"])):x("",!0)])]),Fe("sku")?(d(),_("td",Yme,[l(va,{size:"small",modelValue:ae.sku,"onUpdate:modelValue":[Ut=>ae.sku=Ut,Ut=>we("sku",Ut,`v:${Ae.productId}:${it}`)],placeholder:"SKU",disabled:g(Ae.product),class:de({"is-error":S(Ae.product,it,"sku")})},null,8,["modelValue","onUpdate:modelValue","disabled","class"])])):x("",!0),Fe("media")?(d(),_("td",qme,[l(Bs,{modelValue:ae.media,"onUpdate:modelValue":Ut=>ae.media=Ut,"show-url-tab":"",disabled:g(Ae.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):x("",!0),Fe("categories")?(d(),_("td",Wme,ve[15]||(ve[15]=[r("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Fe("description")?(d(),_("td",Xme,ve[16]||(ve[16]=[r("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Fe("short_description")?(d(),_("td",Jme,ve[17]||(ve[17]=[r("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Fe("status")?(d(),_("td",Zme,ve[18]||(ve[18]=[r("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Fe("product_type")?(d(),_("td",ehe,ve[19]||(ve[19]=[r("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Fe("pricing_type")?(d(),_("td",the,ve[20]||(ve[20]=[r("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Fe("payment_type")?(d(),_("td",ahe,[l(Dr,{variant:ae,disabled:g(Ae.product),"has-error":S(Ae.product,it,"other_info.payment_type"),onPaymentTypeChange:Ut=>{var Se;U(Ut),we("payment_type",(Se=Ut.other_info)==null?void 0:Se.payment_type,`v:${Ae.productId}:${it}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):x("",!0),Fe("interval")?(d(),_("td",nhe,[l(Qr,{variant:ae,disabled:g(Ae.product),"has-error":S(Ae.product,it,"other_info.repeat_interval"),onChange:Ut=>{var Se;return we("interval",(Se=ae.other_info)==null?void 0:Se.repeat_interval,`v:${Ae.productId}:${it}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Fe("trial_days")?(d(),_("td",she,[l(Ir,{variant:ae,disabled:g(Ae.product),"has-error":S(Ae.product,it,"other_info.trial_days"),onChange:Ut=>{var Se;return we("trial_days",(Se=ae.other_info)==null?void 0:Se.trial_days,`v:${Ae.productId}:${it}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Fe("best_price")?(d(),_("td",lhe,[l($r,{variant:ae,disabled:g(Ae.product),"has-error":S(Ae.product,it,"item_price"),onChange:Ut=>we("price",ae.item_price,`v:${Ae.productId}:${it}`)},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Fe("compare_price")?(d(),_("td",ohe,[l(Tr,{variant:ae,disabled:g(Ae.product),"has-error":S(Ae.product,it,"compare_price"),onChange:Ut=>we("compare_price",ae.compare_price,`v:${Ae.productId}:${it}`)},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Fe("track_quantity")?(d(),_("td",rhe,ve[21]||(ve[21]=[r("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Fe("stock")?(d(),_("td",ihe,[((nn=(Ba=Ae.product)==null?void 0:Ba.detail)==null?void 0:nn.manage_stock)==="1"?(d(),E(va,{key:0,class:"fc-bulk-input",size:"small",modelValue:ae.total_stock,"onUpdate:modelValue":[Ut=>ae.total_stock=Ut,Ut=>{ae.available=Ut,p(ot).syncStockStatus(Ae.product),we("stock",Ut,`v:${Ae.productId}:${it}`)}],disabled:g(Ae.product),placeholder:ue.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(d(),_("span",dhe,"—"))])):x("",!0),r("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":Z.value}])},[r("div",uhe,[l(Oe,{tag:"button",size:"x-small",onClick:Xe(Ut=>L(Ae.product,ae),["prevent"]),disabled:s.value||g(Ae.product),title:ue.$t("Duplicate")},{default:i(()=>[l(W,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),l(Oe,{tag:"button",size:"x-small",hover:"danger",onClick:Xe(Ut=>$(Ae.product,ae),["prevent"]),disabled:s.value||g(Ae.product),title:ue.$t("Delete")},{default:i(()=>[l(W,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,Nme)}),128)),r("tr",che,[r("td",{colspan:Me.value.length+1},[r("div",phe,[l(We,{size:"small",text:"",type:"primary",onClick:Xe(ae=>p(ot).addVariationToProduct(Ae.product),["prevent"])},{default:i(()=>[R(" + "+h(ue.$t("Add Variant")),1)]),_:2},1032,["onClick"])])],8,Ahe)])])])]),_:2},1032,["visible"])],8,Hme)])):x("",!0)],64)}),128)),kt.value>0?(d(),_("tr",fhe,[r("td",{colspan:Me.value.length+1,style:ia({height:kt.value+"px",padding:0,border:"none"})},null,12,mhe)])):x("",!0)]),_:1},8,["columns","sticky-last"])],2)):(d(),E(at,{key:1,icon:"Empty/ListView","has-dark":!0,text:p(c)("No products yet. Import a CSV or add products manually.")},null,8,["text"]))]),_:1})]}),_:1}),l(El,{modelValue:G.value.visible,"onUpdate:modelValue":ve[6]||(ve[6]=mn=>G.value.visible=mn),title:oe.value,width:"700px","close-on-click-modal":!1,onClosed:ve[7]||(ve[7]=mn=>G.value.product=null)},{footer:i(()=>[l(We,{onClick:ve[5]||(ve[5]=mn=>G.value.visible=!1)},{default:i(()=>[R(h(ue.$t("Cancel")),1)]),_:1}),l(We,{type:"primary",onClick:N},{default:i(()=>[R(h(ue.$t("Save")),1)]),_:1})]),default:i(()=>[G.value.visible&&G.value.field==="post_content"?(d(),E(ts,{key:0,"model-value":G.value.value,height:300,onUpdate:Y},null,8,["model-value"])):x("",!0),G.value.visible&&G.value.field==="post_excerpt"?(d(),E(va,{key:1,modelValue:G.value.value,"onUpdate:modelValue":ve[4]||(ve[4]=mn=>G.value.value=mn),type:"textarea",rows:6,placeholder:ue.$t("Short description")},null,8,["modelValue","placeholder"])):x("",!0)]),_:1},8,["modelValue","title"])])}}};class vhe extends Uu{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:c("All"),publish:c("Published"),draft:c("Draft"),physical:c("Physical"),digital:c("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 c("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,n;return((n=(a=(t=window.fluentCartAdminApp)==null?void 0:t.filter_options)==null?void 0:a.product_filter_options)==null?void 0:n.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 n=[];for(let s=0;s{this._suppressDirty=!1}),this.data.pagination={page:m.page||f.page,per_page:m.per_page||f.per_page,total:m.total||0,hasMore:m.page*m.per_page!n.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 n=this.data.productErrors.get(t);if(!(n!=null&&n.fields))return!1;const s=`variants.${a}.`;return Object.keys(n.fields).some(o=>o.startsWith(s))}getVariantError(t,a){const n=this.data.productErrors.get(t);if(!(n!=null&&n.fields))return"";const s=`variants.${a}.`;return Object.entries(n.fields).filter(([u])=>u.startsWith(s)).map(([,u])=>u).join("; ")}hasFieldError(t,a){var s;const n=this.data.productErrors.get(t);return!!((s=n==null?void 0:n.fields)!=null&&s[a])}hasVariantFieldError(t,a,n){return this.hasFieldError(t,`variants.${a}.${n}`)}async saveProduct(t){var n,s,o,u;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 A=await re.post("products/bulk-update",{products:[t]});if((n=A.updated)!=null&&n.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("Product updated successfully");else if((s=A.errors)!=null&&s.length){const f=A.errors[0];f!=null&&f.fields&&(this.data.productErrors.set(a,f),this.data.productErrors=new Map(this.data.productErrors)),q.error((f==null?void 0:f.message)||"Failed to save product")}}catch(A){const f=((o=A==null?void 0:A.data)==null?void 0:o.message)||"Failed to save product",m=(u=A==null?void 0:A.data)==null?void 0:u.errors;if(m!=null&&m.length){const g=m[0];g!=null&&g.fields&&(this.data.productErrors.set(a,g),this.data.productErrors=new Map(this.data.productErrors))}q.error(f)}finally{this.data.savingIds.delete(a),this.data.savingIds=new Set(this.data.savingIds)}}}async saveProducts(){var n,s;const t=this.getDirtyProducts().filter(o=>!this.data.savedIds.has(o.ID));if(t.length===0){q.info("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 A of a){const f=A.map(m=>m.ID);for(const m of f)this.data.savingIds.add(m);this.data.savingIds=new Set(this.data.savingIds);try{const m=await re.post("products/bulk-update",{products:A});if(m.updated){this.data.saveProgress.updatedIds.push(...m.updated);for(const g of m.updated)this.data.savedIds.add(g),this.data.dirty.delete(g),this.data.productErrors.delete(g);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(m.errors&&m.errors.length){this.data.saveProgress.errors.push(...m.errors);for(const g of m.errors)g.post_id&&g.fields&&this.data.productErrors.set(g.post_id,g);this.data.productErrors=new Map(this.data.productErrors)}}catch(m){const g=((n=m==null?void 0:m.data)==null?void 0:n.message)||"A chunk failed to save";this.data.saveProgress.errors.push({message:g});const y=(s=m==null?void 0:m.data)==null?void 0:s.errors;if(y!=null&&y.length){for(const v of y)v.post_id&&v.fields&&this.data.productErrors.set(v.post_id,v);this.data.productErrors=new Map(this.data.productErrors)}}for(const m of f)this.data.savingIds.delete(m);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{updatedIds:o,errors:u}=this.data.saveProgress;u.length===0?q.success(`${o.length} product(s) updated successfully`):o.length>0?q.info(`${o.length} product(s) updated, ${u.length} error(s)`):q.error("All products failed to save")}finally{this.data.saving=!1}}async duplicateProduct(t){var n;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 o=(await re.post(`products/${a}/duplicate`,{})).product_id;if(o){const A=(await re.get("products/bulk-edit-data",{search:o,per_page:1})).products||[];if(A.length>0){const f=this.data.products.indexOf(t);this.data.products.splice(f+1,0,A[0])}}}catch(s){const o=((n=s==null?void 0:s.data)==null?void 0:n.message)||"Failed to duplicate product";q.error(o)}finally{this.data.duplicatingIds.delete(a),this.data.duplicatingIds=new Set(this.data.duplicatingIds)}}}async duplicateProductWithVariants(t,a){var s;const n=t.ID;if(!(!n||this.data.duplicatingIds.has(n))){this.data.duplicatingIds.add(n),this.data.duplicatingIds=new Set(this.data.duplicatingIds);try{const u=(await re.post(`products/${n}/duplicate`,{})).product_id;if(!u)return;const f=(await re.get("products/bulk-edit-data",{search:u,per_page:1})).products||[];if(!f.length)return;const m=f[0],g=t.variants||[],y=new Set;for(const B of g)a.includes(B.id)&&B.serial_index!=null&&y.add(B.serial_index);m.variants&&y.size>0&&(m.variants=m.variants.filter(B=>y.has(B.serial_index)));const v=this.data.products.indexOf(t);this.data.products.splice(v+1,0,m),this.markDirty(m.ID)}catch(o){const u=((s=o==null?void 0:o.data)==null?void 0:s.message)||"Failed to duplicate product";q.error(u)}finally{this.data.duplicatingIds.delete(n),this.data.duplicatingIds=new Set(this.data.duplicatingIds)}}}duplicateVariant(t,a){const n=JSON.parse(JSON.stringify(a));n.variation_title=n.variation_title?n.variation_title+" (Copy)":"",n.sku="",delete n.id,delete n.post_id;const s=t.variants.indexOf(a);t.variants.splice(s+1,0,n),this.markDirty(t.ID)}async deleteProduct(t){var n;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 re.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 o=((n=s==null?void 0:s.data)==null?void 0:n.message)||"Failed to delete product";q.error(o)}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(c("A product must have at least one variant.")),!1;const n=t.variants.indexOf(a);return n!==-1&&t.variants.splice(n,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 n=[];for(const o of t){const u=a?`${a} > ${o.label}`:o.label;n.push({label:u,value:u}),(s=o.children)!=null&&s.length&&n.push(...this.flattenCategoryTree(o.children,u))}return n}async fetchCategories(){try{const a=(await re.get("products/fetch-term")).taxonomies||{},n=Object.values(a).find(s=>s.name==="product-categories");n!=null&&n.terms&&(this.data.categoryOptions=this.flattenCategoryTree(n.terms))}catch{}}setupSavedViews(){var a,n;const t=(a=window.fluentCartAdminApp)==null?void 0:a.table_config;this.data.savedViews=((n=t==null?void 0:t.products)==null?void 0:n.saved_views)||[]}getSavedViews(){return this.data.savedViews}getActiveSavedViewId(){return this.data.activeSavedViewId}applySavedView(t){const a=this.data.savedViews.find(n=>n.slug===t);a&&(this.data.activeSavedViewId=t,this.data.savedViewQueryParams=a.query_params)}isViewOwner(t){var a,n;return!t||!t.owner_id?!1:t.owner_id===((n=(a=window.fluentCartAdminApp)==null?void 0:a.me)==null?void 0:n.id)}renameSavedView(t,a){}updateSavedView(t){}deleteSavedView(t){}}const Pe=vhe.init(),yhe={class:"fct-bulk-edit-page fct-layout-width"},bhe={class:"fct-table-wrapper"},whe={class:"fct-card-header-top"},Che={class:"fct-card-header-left flex-1"},Bhe={class:"fct-card-header-actions"},khe={key:0,class:"fct-advanced-filter-toggle-wrapper"},xhe={key:1,class:"fct-btn-group sm hidden md:flex"},She={key:0,class:"filter-search-wrap"},Fhe={class:"search-bar"},Ehe={class:"text-xs text-system-light pt-2 dark:text-gray-300"},Uhe={class:"fct-bulk-edit-table-wrap"},$he={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"},Dhe={class:"m-0 text-base"},Qhe={key:0,class:"text-system-mid text-sm font-normal dark:text-gray-300"},Ihe={class:"fct-btn-group sm justify-end"},The={class:"filter-popover-item"},Vhe={class:"filter-popover-title"},Mhe={class:"fct-bulk-edit-table"},Lhe={key:0,"aria-hidden":"true"},Rhe=["colspan"],Ohe=["onClick"],Hhe=["onClick"],Phe={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},Nhe={class:"flex items-center"},Khe=["onClick","title"],Ghe={key:0,class:"bulk-collapse-count"},jhe=["title"],zhe={class:"bulk-status-icon is-error"},Yhe=["disabled","onClick","title"],qhe={key:0,class:"fct-bulk-media-cell"},Whe={key:1,class:"fct-bulk-sku-cell"},Xhe={key:1,class:"text-gray-300 text-sm flex justify-center"},Jhe={key:2,class:"fct-bulk-categories-cell"},Zhe={key:3,class:"fct-bulk-desc-cell"},e_e={key:4,class:"fct-bulk-short-desc-cell"},t_e={key:5,class:"fct-bulk-status-cell"},a_e={key:6,class:"fct-bulk-product-type-cell"},n_e={class:"bulk-readonly-label"},s_e={key:7,class:"fct-bulk-pricing-type-cell"},l_e={class:"bulk-readonly-label"},o_e={key:8,class:"fct-bulk-payment-type-cell"},r_e={key:9,class:"fct-bulk-interval-cell"},i_e={key:10,class:"fct-bulk-trial-days-cell"},d_e={key:11,class:"fct-bulk-best-price-cell"},u_e={key:12,class:"fct-bulk-compare-price-cell"},c_e={key:13,class:"fct-bulk-qty-cell !pl-5"},A_e={key:14,class:"fct-bulk-stock-cell"},p_e={key:1,class:"text-gray-300 text-sm flex justify-center"},f_e={class:"fct-btn-group sm justify-end"},m_e={key:0,class:"bulk-variants-block-row"},h_e=["colspan"],__e={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},g_e=["onClick"],v_e={class:"bulk-checkbox-cell"},y_e={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},b_e={class:"flex items-center gap-1 pl-4"},w_e={class:"bulk-status-icon is-error"},C_e={key:0},B_e={key:1},k_e={key:2},x_e={key:3},S_e={key:4},F_e={key:5},E_e={key:6},U_e={key:7},$_e={key:8},D_e={key:9},Q_e={key:10},I_e={key:11},T_e={key:12},V_e={key:13,class:"text-center"},M_e={key:14},L_e={key:1,class:"text-gray-300 text-sm flex justify-center"},R_e={class:"fct-btn-group sm justify-end"},O_e={key:1,"aria-hidden":"true"},H_e=["colspan"],P_e={key:1,class:"flex flex-col items-center justify-center py-16 text-center"},N_e={class:"text-system-mid text-sm"},K_e={key:2,class:"flex items-center justify-center py-8"},G_e={class:"text-system-mid text-sm"},j_e={key:1,class:"flex items-center justify-center py-3 border-top"},z_e={class:"text-system-mid text-sm"},Wi=43,Y_e=10,MA=800,LA=100,q_e=200,W_e={__name:"BulkEdit",setup(e){const t=Qt().ctx,a=fn(),{options:n}=Pe.data,s=z=>{var J;return((J=z==null?void 0:z.detail)==null?void 0:J.variation_type)==="simple"},o=j(()=>Pe.data.products),u=j(()=>Pe.data.loading),A=j(()=>Pe.data.saving),f=j(()=>Pe.data.saveProgress),m=j(()=>Pe.data.pagination),g=j(()=>Pe.data.dirty),y=j(()=>g.value.size),v=j(()=>Math.max(0,m.value.total-o.value.length)),B=j(()=>Math.min(m.value.per_page,v.value)),b=j(()=>{const z=Pe.data.saveProgress;return z.total?Math.round(z.completed/z.total*100):0}),w=zd("search-input"),k=()=>{Pe.openSearch(),ye(()=>{var z;(z=w.value)==null||z.focus()})},S=(z=!1)=>{Pe.fetchProducts({},z)},M=()=>{Pe.saveProducts()},$=z=>{Pe.markDirty(z.ID)},F=(z,J)=>{Pe.resetPaymentTypeDefaults(J),$(z)},L=(z,J)=>{const fe=Pe.data.categoryOptions;for(const Ue of J)fe.find(je=>je.value===Ue)||fe.push({label:Ue,value:Ue});$(z)},Q=z=>Pe.isDirty(z.ID),T=z=>Pe.isSavingProduct(z.ID),D=z=>Pe.isSaved(z.ID),U=z=>Pe.isRowDisabled(z.ID),I=z=>Pe.isDuplicating(z.ID),O=z=>Pe.isDeleting(z.ID),P=z=>Pe.hasError(z.ID),K=z=>Pe.getError(z.ID),G=z=>Pe.hasProductLevelError(z.ID),ne=(z,J)=>Pe.hasVariantError(z.ID,J),Y=(z,J)=>Pe.getVariantError(z.ID,J),N=(z,J)=>Pe.hasFieldError(z.ID,J),oe=(z,J,fe)=>Pe.hasVariantFieldError(z.ID,J,fe),Z=z=>Pe.saveProduct(z),le=z=>Pe.duplicateProduct(z),te=(z,J)=>Pe.duplicateVariant(z,J),X=V(!0),{selectedKeys:ie,handleRowClick:be,toggleSelectAll:se,selectAll:ce,deselectAll:pe,isSelected:De,selectedCount:$e,isLinkMode:Je,toggleLinkMode:we}=km(),Ye=j(()=>{const z=[];for(const J of rt.value)if(z.push(`p:${J.productId}`),J.hasVariants&&!J.collapsed)for(const fe of J.product.variants)z.push(`v:${fe.id}`);return z}),ft=z=>{var J;if(z.startsWith("p:")){const fe=parseInt(z.slice(2)),Ue=rt.value.find(je=>je.productId===fe);return Ue?{type:"product",data:Ue.product,product:Ue.product}:null}else if(z.startsWith("v:")){const fe=parseInt(z.slice(2));for(const Ue of rt.value){const je=(J=Ue.product.variants)==null?void 0:J.find(et=>et.id===fe);if(je)return{type:"variant",data:je,product:Ue.product}}}return null},Ge=(z,J,fe)=>{!Je.value||!De(fe)||Sm(z,J,fe,ie.value,ft,$,nme)},_e=V(!1),xe=z=>{z.key==="Shift"&&(_e.value=!0)},Me=z=>{z.key==="Shift"&&(_e.value=!1)},Fe=(z,J)=>{if(!J.shiftKey||J.target.closest(".bulk-checkbox-cell"))return;J.preventDefault();const fe=new Set(ie.value);fe.has(z)?fe.delete(z):fe.add(z),ie.value=fe},nt=()=>{const z=[];for(const J of rt.value){const fe=`p:${J.productId}`,Ue=ie.value.has(fe),je=[];if(J.product.variants)for(const et of J.product.variants)ie.value.has(`v:${et.id}`)&&je.push(et.id);!Ue&&je.length===0||(Ue&&je.length===0?z.push({product:J.product,type:"full"}):!Ue&&je.length>0?z.push({product:J.product,type:"variants-only",variantIds:je}):z.push({product:J.product,type:"partial",variantIds:je}))}return z},st=async()=>{const z=nt();if(!z.length)return;const J=z.filter(Le=>Le.type==="full").length,fe=z.filter(Le=>Le.type==="partial").length,je=z.filter(Le=>Le.type==="variants-only").reduce((Le,qe)=>Le+qe.variantIds.length,0),et=[];J>0&&et.push(`${J} product(s) with all variants`),fe>0&&et.push(`${fe} product(s) with selected variants`),je>0&&et.push(`${je} variant(s)`);try{await Ea.confirm(t.$t("Duplicate %s?").replace("%s",et.join(", ")),t.$t("Bulk Duplicate"),{confirmButtonText:t.$t("Duplicate"),cancelButtonText:t.$t("Cancel"),type:"info"})}catch{return}for(const Le of z)if(Le.type==="full")await Pe.duplicateProduct(Le.product);else if(Le.type==="variants-only")for(const qe of Le.variantIds){const Et=Le.product.variants.find(tt=>tt.id===qe);Et&&Pe.duplicateVariant(Le.product,Et)}else Le.type==="partial"&&await Pe.duplicateProductWithVariants(Le.product,Le.variantIds);pe()},Ot=async()=>{const z=[],J=[];for(const je of rt.value){const et=`p:${je.productId}`;if(ie.value.has(et)){z.push(je.product);continue}const qe=[];if(je.product.variants)for(const Et of je.product.variants)ie.value.has(`v:${Et.id}`)&&qe.push(Et);qe.length>0&&J.push({product:je.product,variants:qe})}if(!z.length&&!J.length)return;const fe=J.reduce((je,et)=>je+et.variants.length,0),Ue=[];z.length>0&&Ue.push(`${z.length} product(s)`),fe>0&&Ue.push(`${fe} variant(s)`);try{await Ea.confirm(t.$t("Permanently delete %s? This cannot be undone.").replace("%s",Ue.join(" and ")),t.$t("Bulk Delete"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}for(const je of z)await Pe.deleteProduct(je);for(const{product:je,variants:et}of J)for(const Le of et)Pe.removeVariant(je,Le);pe()},Ct=async z=>{const J=z.ID;if(!J||Pe.isDeleting(J))return;const fe=z.post_title||t.$t("Untitled product"),Ue=Array.isArray(z.variants)?z.variants.length:0,je=Ue>0?t.$t('This will permanently delete "%s" and its %s variant(s).').replace("%s",fe).replace("%s",Ue):t.$t('This will permanently delete "%s".').replace("%s",fe);try{await Ea.confirm(je,t.$t("Delete Product"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}Pe.deleteProduct(z)},yt=(z,J)=>{if(z.variants.length<=1){Pe.removeVariant(z,J);return}const fe=J.variation_title||t.$t("Untitled variant");Ea.confirm(t.$t('This will remove the variant "%s".').replace("%s",fe),t.$t("Remove Variant"),{confirmButtonText:t.$t("Remove"),cancelButtonText:t.$t("Cancel"),type:"warning"}).then(()=>{Pe.removeVariant(z,J)}).catch(()=>{})},Ze=V({visible:!1,field:"",product:null,value:""}),Bt=(z,J)=>{Ze.value={visible:!0,field:J,product:z,value:z[J]||""}},ht=z=>{Ze.value.value=z},Ft=()=>{const{product:z,field:J,value:fe}=Ze.value;z&&(z[J]=fe,$(z)),Ze.value.visible=!1},kt=j(()=>Ze.value.field==="post_content"?t.$t("Edit Description"):t.$t("Edit Short Description")),xt=V([]),Ht=j(()=>xt.value.filter(z=>z.key==="title"||z.key==="actions"?!0:Pe.isColumnVisible(z.key))),pt=z=>Pe.isColumnVisible(z),da=()=>{Pe.saveColumnWidths(xt.value)},ue=V(new Set),ve=z=>{const J=z.ID;ue.value.has(J)?ue.value.delete(J):ue.value.add(J),ue.value=new Set(ue.value)},We=z=>ue.value.has(z.ID),_t=V(0),rt=j(()=>{let z=0;return o.value.map(J=>{var tt;const fe=J.ID,Ue=((tt=J.detail)==null?void 0:tt.variation_type)!=="simple"&&Array.isArray(J.variants)&&J.variants.length>0,je=Ue?J.variants.length:0,et=ue.value.has(fe),Le=Ue&&!et?je*Wi:0,qe=Wi+Le,Et={product:J,productId:fe,hasVariants:Ue,variantCount:je,collapsed:et,groupHeight:qe,offset:z};return z+=qe,Et})}),Wt=j(()=>{const z=rt.value;if(z.length===0)return 0;const J=z[z.length-1];return J.offset+J.groupHeight}),lt=j(()=>{const z=rt.value,J=_t.value,fe=J+MA,Ue=Y_e*Wi;return z.filter(je=>je.offset+je.groupHeight>=J-Ue&&je.offset<=fe+Ue)}),ga=j(()=>lt.value.length===0?0:lt.value[0].offset),va=j(()=>{if(lt.value.length===0)return 0;const z=lt.value[lt.value.length-1];return Wt.value-z.offset-z.groupHeight});let Da=null,Sn=0;const Tn=()=>{if(u.value||!m.value.hasMore||o.value.length===0)return;Wt.value-(_t.value+MA){const J=z.target,fe=Date.now();Da&&clearTimeout(Da),fe-Sn>=LA?(_t.value=J.scrollTop,Sn=fe,Tn()):Da=setTimeout(()=>{_t.value=J.scrollTop,Sn=Date.now(),Da=null,Tn()},LA)},El=z=>({physical:"Physical",digital:"Digital"})[z]||z||"—",mn=z=>({simple:"Simple",simple_variations:"Variable"})[z]||z||"—";let Ae=null;const Ws=()=>{const z=a.query.product_ids,J=a.query.variant_ids;z&&J?Pe.fetchProducts({},!1,z,J):S(!1)};return Be(async()=>{Ae=ks(),Ae.bind("mod+a",z=>{var fe,Ue;const J=(fe=document.activeElement)==null?void 0:fe.tagName;J==="INPUT"||J==="TEXTAREA"||(Ue=document.activeElement)!=null&&Ue.isContentEditable||(z.preventDefault(),ce(Ye.value))}),Ae.bind("escape",()=>{var J,fe;const z=(J=document.activeElement)==null?void 0:J.tagName;z==="INPUT"||z==="TEXTAREA"||(fe=document.activeElement)!=null&&fe.isContentEditable||(Je.value?we():pe())}),xt.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}],Pe.restoreColumnWidths(xt.value),Pe.setupColumnVisibility(),Pe.setupSavedViews(),Pe.fetchCategories(),Ws(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",xe),window.addEventListener("keyup",Me)}),xn(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",xe),window.removeEventListener("keyup",Me),Ae&&Ae.reset()}),(z,J)=>{const fe=C("el-button"),Ue=C("el-progress"),je=C("el-switch"),et=C("el-tooltip"),Le=C("el-input"),qe=C("el-checkbox"),Et=C("el-checkbox-group"),tt=C("el-popover"),bt=C("el-icon"),ua=C("el-option"),Fn=C("el-select"),Es=C("el-dialog");return d(),_("div",yhe,[l(za,{title:z.$t("Bulk Edit")},{action:i(()=>[l(fe,{type:"primary",onClick:M,loading:A.value,disabled:A.value||y.value===0},{default:i(()=>[R(h(A.value?z.$t("Saving %s/%s...").replace("%s",f.value.completed).replace("%s",f.value.total):y.value>0?z.$t("Save Changes")+` (${y.value})`:z.$t("Save Changes")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),A.value?(d(),E(Ue,{key:0,percentage:b.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):x("",!0),r("div",bhe,[l(he,null,{default:i(()=>[l(Ce,{border_bottom:""},{default:i(()=>[r("div",whe,[r("div",Che,[p(Pe).getTabsCount()&&!p(Pe).isUsingAdvanceFilter()?(d(),E(th,{key:0,class:de("hide-animation-on-mobile hidden md:inline-flex classic-tab-style"),table:p(Pe)},null,8,["table"])):x("",!0)]),r("div",Bhe,[p(Pe).isAdvanceFilterEnabled()?(d(),_("div",khe,[l(je,{class:"fct-advanced-filter-toggle",onChange:J[0]||(J[0]=ae=>{p(Pe).onFilterTypeChanged(ae)}),"active-value":"advanced","inactive-value":"simple",modelValue:p(Pe).data.filterType,"onUpdate:modelValue":J[1]||(J[1]=ae=>p(Pe).data.filterType=ae),"active-text":z.$t("Advanced Filter"),size:"small"},null,8,["modelValue","active-text"])])):x("",!0),p(Pe).isUsingAdvanceFilter()?x("",!0):(d(),_("div",xhe,[p(Pe).isSearching()?x("",!0):(d(),E(et,{key:0,effect:"light",content:z.$t("Search"),placement:"top","popper-class":"fct-tooltip"},{default:i(()=>[l(Oe,{tag:"button",onClick:Xe(k,["prevent"])},{default:i(()=>[l(W,{name:"Search"})]),_:1})]),_:1},8,["content"]))]))])]),l(ah,{table:p(Pe)},null,8,["table"]),p(Pe).isSearching()&&!p(Pe).isUsingAdvanceFilter()?(d(),_("div",She,[r("div",Fhe,[l(Le,{ref:"search-input",onClear:J[2]||(J[2]=()=>{p(Pe).search()}),onKeyup:J[3]||(J[3]=Pa(()=>{p(Pe).search()},["enter"])),modelValue:p(Pe).data.search,"onUpdate:modelValue":J[4]||(J[4]=ae=>p(Pe).data.search=ae),type:"text",placeholder:z.$t("Search"),clearable:""},{prefix:i(()=>[l(W,{name:"Search"})]),_:1},8,["modelValue","placeholder"]),r("div",Ehe,h(p(Pe).getSearchHint()),1)]),l(fe,{text:"",onClick:J[5]||(J[5]=()=>{p(Pe).closeSearch()})},{default:i(()=>[R(h(z.$t("Cancel")),1)]),_:1})])):x("",!0)]),_:1}),l(me,{class:"p-0"},{default:i(()=>[r("div",Uhe,[o.value.length>0?(d(),_("div",$he,[r("h5",Dhe,[R(h(o.value.length)+" "+h(o.value.length===1?z.$t("Product"):z.$t("Products"))+" ",1),m.value.total>o.value.length?(d(),_("span",Qhe,h(z.$t("of"))+" "+h(m.value.total)+" "+h(z.$t("total"))+" · "+h(B.value)+" "+h(z.$t("next")),1)):x("",!0)]),r("div",Ihe,[l(fe,{disabled:p($e)===0,onClick:st,size:"small"},{default:i(()=>[J[14]||(J[14]=r("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[r("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)),R(" "+h(z.$t("Duplicate")),1)]),_:1,__:[14]},8,["disabled"]),l(fe,{disabled:p($e)===0,onClick:Ot,size:"small",type:"danger",plain:""},{default:i(()=>[J[15]||(J[15]=r("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[r("polyline",{points:"3 6 5 6 21 6"}),r("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(" "+h(z.$t("Delete")),1)]),_:1,__:[15]},8,["disabled"]),l(fe,{class:de({"is-active":p(Je)}),disabled:p($e)<2&&!p(Je),onClick:p(we),size:"small"},{default:i(()=>[J[16]||(J[16]=r("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[r("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r("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(" "+h(p(Je)?z.$t("Unlink"):z.$t("Link")),1)]),_:1,__:[16]},8,["class","disabled","onClick"]),l(qe,{modelValue:X.value,"onUpdate:modelValue":J[6]||(J[6]=ae=>X.value=ae),label:z.$t("Pin Actions")},null,8,["modelValue","label"]),l(tt,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:i(()=>[r("span",null,[l(et,{effect:"light",content:z.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:i(()=>[l(Oe,{tag:"button",size:"small"},{default:i(()=>[l(W,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:i(()=>[r("div",The,[r("h3",Vhe,h(z.$t("Columns")),1),l(Et,{modelValue:p(Pe).data.visibleColumns,"onUpdate:modelValue":J[7]||(J[7]=ae=>p(Pe).data.visibleColumns=ae),class:"fct-checkbox-blocks",onChange:J[8]||(J[8]=ae=>p(Pe).handleColumnVisibilityChange())},{default:i(()=>[(d(!0),_(H,null,ee(p(Pe).getToggleableColumns(),ae=>(d(),E(qe,{key:ae.value,value:ae.value,label:z.$t(ae.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])])):x("",!0),r("div",Mhe,[o.value.length>0?(d(),_("div",{key:0,class:de(["relative",{"is-link-mode":p(Je),"is-shift-held":_e.value}])},[l(Cm,{columns:Ht.value,"sticky-last":X.value,onScroll:Fs,onResizeEnd:da},{"header-first":i(()=>[Dt(l(qe,{checked:p($e)>0&&p($e)===Ye.value.length,onChange:J[9]||(J[9]=ae=>p(se)(Ye.value))},null,8,["checked"]),[[p(tme),p($e)>0&&p($e)[R(h(z.$t("Actions")),1)]),default:i(()=>[ga.value>0?(d(),_("tr",Lhe,[r("td",{colspan:Ht.value.length+1,style:ia({height:ga.value+"px",padding:0,border:"none"})},null,12,Rhe)])):x("",!0),(d(!0),_(H,null,ee(lt.value,ae=>{var it,Ba,nn,Ut,Se,Vn,Vu,Mu,Lu,Ru,Ou,Hu,Pu,Nu,Ku,Gu,ju,zu;return d(),_(H,{key:ae.productId},[r("tr",{class:de(["bulk-product-row",{"is-dirty":Q(ae.product),"is-saving":T(ae.product),"is-saved":D(ae.product),"has-product-error":P(ae.product),"is-selected":p(De)(`p:${ae.productId}`)}]),onClick:Ve=>Fe(`p:${ae.productId}`,Ve)},[r("td",{class:"bulk-checkbox-cell",onClick:Ve=>p(be)(`p:${ae.productId}`,Ve,Ye.value)},[l(qe,{"model-value":p(De)(`p:${ae.productId}`),tabindex:"-1"},null,8,["model-value"])],8,Hhe),r("td",Phe,[r("div",Nhe,[ae.hasVariants?(d(),_("button",{key:0,class:"bulk-collapse-btn",onClick:Xe(Ve=>ve(ae.product),["prevent"]),title:We(ae.product)?z.$t("Expand variants"):z.$t("Collapse variants")},[(d(),_("svg",{class:de(["bulk-collapse-icon",{"is-collapsed":We(ae.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},J[17]||(J[17]=[r("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),We(ae.product)?(d(),_("span",Ghe,h(ae.variantCount),1)):x("",!0)],8,Khe)):x("",!0),l(Le,{class:de(["fct-bulk-input",{"is-error":N(ae.product,"post_title")}]),modelValue:ae.product.post_title,"onUpdate:modelValue":[Ve=>ae.product.post_title=Ve,Ve=>{$(ae.product),Ge("title",Ve,`p:${ae.productId}`)}],placeholder:z.$t("Product title"),disabled:U(ae.product),size:"small"},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),T(ae.product)?(d(),_("span",{key:1,class:"bulk-status-icon is-syncing",title:z.$t("Saving...")},[l(bt,{class:"is-loading",size:14},{default:i(()=>[l(p(_l))]),_:1})],8,jhe)):G(ae.product)||s(ae.product)&&P(ae.product)?(d(),E(et,{key:2,content:K(ae.product),placement:"top"},{default:i(()=>[r("span",zhe,[l(bt,{size:16},{default:i(()=>[l(p(ur))]),_:1})])]),_:2},1032,["content"])):Q(ae.product)?(d(),_("button",{key:3,class:"bulk-inline-save",disabled:U(ae.product),onClick:Xe(Ve=>Z(ae.product),["prevent"]),title:z.$t("Save")},J[18]||(J[18]=[r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",width:"16",height:"16"},[r("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,Yhe)):x("",!0)])]),pt("image")?(d(),_("td",qhe,[l(Bs,{modelValue:ae.product.gallery,"onUpdate:modelValue":Ve=>ae.product.gallery=Ve,onChange:Ve=>$(ae.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):x("",!0),pt("sku")?(d(),_("td",Whe,[((Ba=(it=ae.product)==null?void 0:it.detail)==null?void 0:Ba.variation_type)==="simple"&&((nn=ae.product.variants)!=null&&nn[0])?(d(),E(Le,{key:0,class:de(["fct-bulk-input",{"is-error":N(ae.product,"variants.0.sku")}]),modelValue:ae.product.variants[0].sku,"onUpdate:modelValue":[Ve=>ae.product.variants[0].sku=Ve,Ve=>{$(ae.product),Ge("sku",Ve,`p:${ae.productId}`)}],placeholder:"SKU",size:"small",disabled:U(ae.product)},null,8,["modelValue","onUpdate:modelValue","disabled","class"])):(d(),_("span",Xhe,"—"))])):x("",!0),pt("categories")?(d(),_("td",Jhe,[l(Bm,{modelValue:ae.product.categories,"onUpdate:modelValue":Ve=>ae.product.categories=Ve,options:p(Pe).data.categoryOptions,disabled:U(ae.product),onChange:Ve=>{L(ae.product,Ve),Ge("categories",ae.product.categories,`p:${ae.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):x("",!0),pt("description")?(d(),_("td",Zhe,[l(Vr,{value:ae.product.post_content,placeholder:z.$t("Description"),onClick:Ve=>Bt(ae.product,"post_content")},null,8,["value","placeholder","onClick"])])):x("",!0),pt("short_description")?(d(),_("td",e_e,[l(Vr,{value:ae.product.post_excerpt,placeholder:z.$t("Short description"),onClick:Ve=>Bt(ae.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):x("",!0),pt("status")?(d(),_("td",t_e,[l(Fn,{modelValue:ae.product.post_status,"onUpdate:modelValue":Ve=>ae.product.post_status=Ve,size:"small",class:de({"is-field-error":N(ae.product,"post_status")}),disabled:U(ae.product),onChange:Ve=>{$(ae.product),Ge("status",ae.product.post_status,`p:${ae.productId}`)}},{default:i(()=>[l(ua,{label:z.$t("Published"),value:"publish"},null,8,["label"]),l(ua,{label:z.$t("Draft"),value:"draft"},null,8,["label"])]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):x("",!0),pt("product_type")?(d(),_("td",a_e,[r("span",n_e,h(El((Se=(Ut=ae.product)==null?void 0:Ut.detail)==null?void 0:Se.fulfillment_type)),1)])):x("",!0),pt("pricing_type")?(d(),_("td",s_e,[r("span",l_e,h(mn((Vu=(Vn=ae.product)==null?void 0:Vn.detail)==null?void 0:Vu.variation_type)),1)])):x("",!0),pt("payment_type")?(d(),_("td",o_e,[l(Dr,{variant:s(ae.product)?(Mu=ae.product.variants)==null?void 0:Mu[0]:null,disabled:U(ae.product),"has-error":N(ae.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:Ve=>{var zt;F(ae.product,Ve),Ge("payment_type",(zt=Ve.other_info)==null?void 0:zt.payment_type,`p:${ae.productId}`)},onChange:Ve=>$(ae.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):x("",!0),pt("interval")?(d(),_("td",r_e,[l(Qr,{variant:s(ae.product)?(Lu=ae.product.variants)==null?void 0:Lu[0]:null,disabled:U(ae.product),"has-error":N(ae.product,"variants.0.other_info.repeat_interval"),onChange:Ve=>{var zt,qa,os;$(ae.product),Ge("interval",(os=(qa=(zt=ae.product.variants)==null?void 0:zt[0])==null?void 0:qa.other_info)==null?void 0:os.repeat_interval,`p:${ae.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),pt("trial_days")?(d(),_("td",i_e,[l(Ir,{variant:s(ae.product)?(Ru=ae.product.variants)==null?void 0:Ru[0]:null,disabled:U(ae.product),"has-error":N(ae.product,"variants.0.other_info.trial_days"),onChange:Ve=>{var zt,qa,os;$(ae.product),Ge("trial_days",(os=(qa=(zt=ae.product.variants)==null?void 0:zt[0])==null?void 0:qa.other_info)==null?void 0:os.trial_days,`p:${ae.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),pt("best_price")?(d(),_("td",d_e,[l($r,{variant:s(ae.product)?(Ou=ae.product.variants)==null?void 0:Ou[0]:null,disabled:U(ae.product),"has-error":N(ae.product,"variants.0.item_price"),onChange:Ve=>{var zt,qa;$(ae.product),Ge("price",(qa=(zt=ae.product.variants)==null?void 0:zt[0])==null?void 0:qa.item_price,`p:${ae.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),pt("compare_price")?(d(),_("td",u_e,[l(Tr,{variant:s(ae.product)?(Hu=ae.product.variants)==null?void 0:Hu[0]:null,disabled:U(ae.product),"has-error":N(ae.product,"variants.0.compare_price"),onChange:Ve=>{var zt,qa;$(ae.product),Ge("compare_price",(qa=(zt=ae.product.variants)==null?void 0:zt[0])==null?void 0:qa.compare_price,`p:${ae.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),pt("track_quantity")?(d(),_("td",c_e,[(Pu=ae.product)!=null&&Pu.detail?(d(),E(je,{key:0,modelValue:ae.product.detail.manage_stock,"onUpdate:modelValue":Ve=>ae.product.detail.manage_stock=Ve,"active-value":1,"inactive-value":0,disabled:U(ae.product),onChange:Ve=>{$(ae.product),p(Pe).syncStockStatus(ae.product),Ge("manage_stock",ae.product.detail.manage_stock,`p:${ae.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):x("",!0)])):x("",!0),pt("stock")?(d(),_("td",A_e,[(Ku=(Nu=ae.product)==null?void 0:Nu.detail)!=null&&Ku.manage_stock&&((ju=(Gu=ae.product)==null?void 0:Gu.detail)==null?void 0:ju.variation_type)==="simple"&&((zu=ae.product.variants)!=null&&zu[0])?(d(),E(Le,{key:0,class:"fct-bulk-input",placeholder:z.$t("e.g 10"),size:"small",modelValue:ae.product.variants[0].available,"onUpdate:modelValue":[Ve=>ae.product.variants[0].available=Ve,Ve=>{ae.product.variants[0].total_stock=Ve,$(ae.product),p(Pe).syncStockStatus(ae.product),Ge("stock",Ve,`p:${ae.productId}`)}],disabled:U(ae.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(d(),_("span",p_e,"—"))])):x("",!0),r("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":X.value}])},[r("div",f_e,[ae.product.view_url?(d(),E(Oe,{key:0,tag:"a",size:"x-small",href:ae.product.view_url,target:"_blank",title:z.$t("View Product")},{default:i(()=>[l(W,{name:"External"})]),_:2},1032,["href","title"])):x("",!0),l(Oe,{tag:"button",size:"x-small",onClick:Xe(Ve=>le(ae.product),["prevent"]),disabled:A.value||U(ae.product)||I(ae.product),title:z.$t("Duplicate")},{default:i(()=>[I(ae.product)?(d(),E(bt,{key:0,class:"is-loading",size:14},{default:i(()=>[l(p(_l))]),_:1})):(d(),E(W,{key:1,name:"Copy"}))]),_:2},1032,["onClick","disabled","title"]),l(Oe,{tag:"button",size:"x-small",hover:"danger",onClick:Xe(Ve=>Ct(ae.product),["prevent"]),disabled:A.value||U(ae.product)||O(ae.product),title:z.$t("Delete")},{default:i(()=>[O(ae.product)?(d(),E(bt,{key:0,class:"is-loading",size:14},{default:i(()=>[l(p(_l))]),_:1})):(d(),E(W,{key:1,name:"Delete"}))]),_:2},1032,["onClick","disabled","title"])])],2)],10,Ohe),ae.hasVariants?(d(),_("tr",m_e,[r("td",{colspan:Ht.value.length+1,class:"!p-0 !border-b-0"},[l(ra,{accordion:"",visible:!ae.collapsed,duration:200},{default:i(()=>[r("table",__e,[r("colgroup",null,[J[19]||(J[19]=r("col",{style:{width:"40px"}},null,-1)),(d(!0),_(H,null,ee(Ht.value,(Ve,zt)=>(d(),_("col",{key:zt,style:ia({width:Ve.width+"px"})},null,4))),128))]),r("tbody",null,[(d(!0),_(H,null,ee(ae.product.variants,(Ve,zt)=>{var qa,os;return d(),_("tr",{key:Ve.id||zt,class:de(["bulk-variation-row",{"is-selected":p(De)(`v:${Ve.id}`)}]),onClick:Lt=>Fe(`v:${Ve.id}`,Lt)},[r("td",v_e,[l(qe,{"model-value":p(De)(`v:${Ve.id}`),tabindex:"-1",onChange:Lt=>p(be)(`v:${Ve.id}`,Lt,Ye.value)},null,8,["model-value","onChange"])]),r("td",y_e,[r("div",b_e,[J[20]||(J[20]=r("span",{class:"text-gray-300 text-xs"},"└",-1)),l(Le,{size:"small",modelValue:Ve.variation_title,"onUpdate:modelValue":[Lt=>Ve.variation_title=Lt,Lt=>{$(ae.product),Ge("title",Lt,`v:${Ve.id}`)}],placeholder:z.$t("Variation title"),disabled:U(ae.product),class:de({"is-error":oe(ae.product,zt,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),ne(ae.product,zt)?(d(),E(et,{key:0,content:Y(ae.product,zt),placement:"top"},{default:i(()=>[r("span",w_e,[l(bt,{size:14},{default:i(()=>[l(p(ur))]),_:1})])]),_:2},1032,["content"])):x("",!0)])]),pt("image")?(d(),_("td",C_e,[l(Bs,{modelValue:Ve.media,"onUpdate:modelValue":Lt=>Ve.media=Lt,onChange:Lt=>$(ae.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):x("",!0),pt("sku")?(d(),_("td",B_e,[l(Le,{class:de(["fct-bulk-input",{"is-error":oe(ae.product,zt,"sku")}]),size:"small",modelValue:Ve.sku,"onUpdate:modelValue":[Lt=>Ve.sku=Lt,Lt=>{$(ae.product),Ge("sku",Lt,`v:${Ve.id}`)}],placeholder:z.$t("SKU"),disabled:U(ae.product)},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])])):x("",!0),pt("categories")?(d(),_("td",k_e,J[21]||(J[21]=[r("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),pt("description")?(d(),_("td",x_e,J[22]||(J[22]=[r("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),pt("short_description")?(d(),_("td",S_e,J[23]||(J[23]=[r("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),pt("status")?(d(),_("td",F_e,J[24]||(J[24]=[r("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),pt("product_type")?(d(),_("td",E_e,J[25]||(J[25]=[r("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),pt("pricing_type")?(d(),_("td",U_e,J[26]||(J[26]=[r("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),pt("payment_type")?(d(),_("td",$_e,[l(Dr,{variant:Ve,disabled:U(ae.product),"has-error":oe(ae.product,zt,"other_info.payment_type"),onPaymentTypeChange:Lt=>{var rs;F(ae.product,Lt),Ge("payment_type",(rs=Lt.other_info)==null?void 0:rs.payment_type,`v:${Ve.id}`)},onChange:Lt=>$(ae.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):x("",!0),pt("interval")?(d(),_("td",D_e,[l(Qr,{variant:Ve,disabled:U(ae.product),"has-error":oe(ae.product,zt,"other_info.repeat_interval"),onChange:Lt=>{var rs;$(ae.product),Ge("interval",(rs=Ve.other_info)==null?void 0:rs.repeat_interval,`v:${Ve.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),pt("trial_days")?(d(),_("td",Q_e,[l(Ir,{variant:Ve,disabled:U(ae.product),"has-error":oe(ae.product,zt,"other_info.trial_days"),onChange:Lt=>{var rs;$(ae.product),Ge("trial_days",(rs=Ve.other_info)==null?void 0:rs.trial_days,`v:${Ve.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),pt("best_price")?(d(),_("td",I_e,[l($r,{variant:Ve,disabled:U(ae.product),"has-error":oe(ae.product,zt,"item_price"),onChange:Lt=>{$(ae.product),Ge("price",Ve.item_price,`v:${Ve.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),pt("compare_price")?(d(),_("td",T_e,[l(Tr,{variant:Ve,disabled:U(ae.product),"has-error":oe(ae.product,zt,"compare_price"),onChange:Lt=>{$(ae.product),Ge("compare_price",Ve.compare_price,`v:${Ve.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),pt("track_quantity")?(d(),_("td",V_e,J[27]||(J[27]=[r("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),pt("stock")?(d(),_("td",M_e,[(os=(qa=ae.product)==null?void 0:qa.detail)!=null&&os.manage_stock?(d(),E(Le,{key:0,class:"fct-bulk-input",placeholder:z.$t("e.g 10"),size:"small",modelValue:Ve.available,"onUpdate:modelValue":[Lt=>Ve.available=Lt,Lt=>{Ve.total_stock=Lt,$(ae.product),p(Pe).syncStockStatus(ae.product),Ge("stock",Lt,`v:${Ve.id}`)}],disabled:U(ae.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(d(),_("span",L_e,"—"))])):x("",!0),r("td",{class:de(["text-center",{"sticky-col sticky-col-right":X.value}])},[r("div",R_e,[l(Oe,{tag:"button",size:"x-small",onClick:Xe(Lt=>te(ae.product,Ve),["prevent"]),disabled:A.value||U(ae.product),title:z.$t("Duplicate")},{default:i(()=>[l(W,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),l(Oe,{tag:"button",size:"x-small",hover:"danger",onClick:Xe(Lt=>yt(ae.product,Ve),["prevent"]),disabled:A.value||U(ae.product),title:z.$t("Delete")},{default:i(()=>[l(W,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,g_e)}),128))])])]),_:2},1032,["visible"])],8,h_e)])):x("",!0)],64)}),128)),va.value>0?(d(),_("tr",O_e,[r("td",{colspan:Ht.value.length+1,style:ia({height:va.value+"px",padding:0,border:"none"})},null,12,H_e)])):x("",!0)]),_:1},8,["columns","sticky-last"])],2)):u.value?u.value?(d(),_("div",K_e,[l(bt,{class:"is-loading mr-2"},{default:i(()=>J[28]||(J[28]=[r("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[28]}),r("span",G_e,h(z.$t("Loading products...")),1)])):x("",!0):(d(),_("div",P_e,[r("p",N_e,h(z.$t("No products found.")),1)]))]),m.value.hasMore&&o.value.length>0&&u.value?(d(),_("div",j_e,[l(bt,{class:"is-loading mr-2"},{default:i(()=>J[29]||(J[29]=[r("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[29]}),r("span",z_e,h(z.$t("Loading"))+" "+h(B.value)+" "+h(z.$t("more...")),1)])):x("",!0)])]),_:1})]),_:1})]),l(Es,{modelValue:Ze.value.visible,"onUpdate:modelValue":J[12]||(J[12]=ae=>Ze.value.visible=ae),title:kt.value,width:"700px","close-on-click-modal":!1,onClosed:J[13]||(J[13]=ae=>Ze.value.product=null)},{footer:i(()=>[l(fe,{onClick:J[11]||(J[11]=ae=>Ze.value.visible=!1)},{default:i(()=>[R(h(z.$t("Cancel")),1)]),_:1}),l(fe,{type:"primary",onClick:Ft},{default:i(()=>[R(h(z.$t("Save")),1)]),_:1})]),default:i(()=>[Ze.value.visible&&Ze.value.field==="post_content"?(d(),E(ts,{key:0,"model-value":Ze.value.value,height:300,onUpdate:ht},null,8,["model-value"])):x("",!0),Ze.value.visible&&Ze.value.field==="post_excerpt"?(d(),E(Le,{key:1,modelValue:Ze.value.value,"onUpdate:modelValue":J[10]||(J[10]=ae=>Ze.value.value=ae),type:"textarea",rows:6,placeholder:z.$t("Short description")},null,8,["modelValue","placeholder"])):x("",!0)]),_:1},8,["modelValue","title"])])}}},Fm=Ie.get("payment_routes");for(const e of Fm)e.props=!0;const X_e=Ie.get("storage_driver_routes"),Em=(X_e||[]).filter(e=>e.name!=="s3");for(const e of Em)e.props=!0;var J_e={dashboard:{name:"dashboard",path:"/",component:I8,meta:{active_menu:"dashboard",title:"Dashboard"}},orders:{path:"/orders",component:IE,meta:{active_menu:"orders",title:"Orders"},children:[{name:"orders",path:"",component:sv,meta:{active_menu:"orders",title:"Orders",permission:"orders/view"}},{name:"view_order",path:":order_id(\\d+)/view",component:lT,props:!0,meta:{active_menu:"orders",title:"View Order",permission:["orders/view","orders/manage"]}},{name:"add_order",path:"add",component:VT,props:!0,meta:{active_menu:"orders",title:"Create Order",permission:"orders/create"}}]},products:{name:"products",path:"/products",component:$7,meta:{active_menu:"products",title:"Products",permission:"products/view"}},product_route:{path:"/products/:product_id(\\d+)",component:xV,name:"product_route",meta:{active_menu:"products",title:"Products",permission:["products/view","products/edit","integrations/manage"]},props:!0,children:[{name:"product_edit",path:"",props:!0,component:SN,meta:{active_menu:"products",title:"Product Edit",permission:"products/edit"}},{name:"product_integrations",path:"integrations",props:!0,component:kA,meta:{active_menu:"products",title:"Integrations",permission:"integrations/manage"}},{name:"product_integration_feed_editor",path:"integrations/:integration_id/:integration_name",component:rA,meta:{active_menu:"products",title:"Edit Integration",permission:"integrations/manage"}},{name:"SingleIntegration",path:"integrations/:integration_id",props:!0,component:VK,meta:{active_menu:"products",title:"Integrations",permission:"integrations/manage"}},{name:"product_upgrade_paths",path:"upgrade-paths",props:!0,component:mK,meta:{active_menu:"products",title:"Upgrade Paths",permission:"integrations/manage"}},{name:"Integrations",path:"integrations",props:!0,component:kA,meta:{active_menu:"integrations",title:"Product Integrations",permission:"integrations/manage"}}]},product_bulk_insert:{name:"product_bulk_insert",path:"/products/bulk-insert",component:ghe,meta:{active_menu:"products",title:"Product Bulk Insert",permission:"products/create"}},product_bulk_edit:{name:"product_bulk_edit",path:"/products/bulk-edit",component:W_e,meta:{active_menu:"products",title:"Product Bulk Edit",permission:"products/edit"}},product_inventory:{name:"product_inventory",path:"/products/inventory",component:fz,meta:{active_menu:"products",title:"Inventory",permission:"products/view"}},customers:{path:"/customers",component:x1,meta:{active_menu:"customers",permission:["customers/view","customers/manage"]},children:[{name:"customers",path:"/customers",component:K_,meta:{active_menu:"customers",title:"Customers",permission:"customers/view"}},{name:"view_customer",path:":customer_id(\\d+)/view",component:f5,props:!0,meta:{active_menu:"customers",title:"View Customer",permission:"customers/view"}}]},reports:{name:"reports",path:"/reports",component:kW,meta:{active_menu:"reports",permission:"reports/view"},children:[{name:"reports_overview",path:"overview",component:yoe,meta:{title:"Overview",permission:"reports/view"}},{name:"reports_sales",path:"sales",component:tX,meta:{title:"Sales",permission:"reports/view"}},{name:"reports_orders",path:"orders",component:_ee,meta:{title:"Orders",permission:"reports/view"}},{name:"reports_revenue",path:"revenue",component:XX,meta:{title:"Revenue",permission:"reports/view"}},{name:"reports_refunds",path:"refunds",component:ete,meta:{title:"Refunds",permission:"reports/view"}},{name:"reports_subscriptions",path:"subscriptions",component:jte,meta:{title:"Subscriptions",permission:"reports/view"}},{name:"subscriptions-retention",path:"subscriptions/subscriptions-retention",component:one,meta:{title:"Retention",permission:"reports/view"}},{name:"subscriptions-cohorts",path:"subscriptions/subscriptions-cohorts",component:()=>It(()=>import("./chunks/Cohort.js?ver=1.4.1"),[],import.meta.url),meta:{title:"Cohorts",permission:"reports/view"}},{name:"future_renewals",path:"subscriptions/future-renewals",component:cae,meta:{title:"Future Renewals",permission:"reports/view"}},{name:"reports_products",path:"products",component:Sle,meta:{title:"Product",permission:"reports/view"}},{name:"reports_customer",path:"customer",component:$ne,meta:{title:"Customer",permission:"reports/view"}},{name:"reports_sources",path:"sources",component:sse,meta:{title:"Sources",permission:"reports/view"}}]},settings:{path:"/settings",component:o$,meta:{active_menu:"settings",title:"Settings",permission:["store/settings","store/sensitive"]},children:[{name:"store_settings",path:"store-settings",component:zT,meta:{active_menu:"settings",title:"Settings",permission:"store/settings"},children:[{name:"store_setup",path:"",component:ol,meta:{title:"Store Setup"}},{name:"pages_setup",path:"pages_setup",component:ol,meta:{title:"Pages Setup"}},{name:"single_product_setup",path:"single_product_setup",component:ol,meta:{title:"Product Page"}},{name:"cart_and_checkout",path:"cart_and_checkout",component:ol,meta:{title:"Cart & Checkout"}},{name:"subscriptions_setup",path:"subscriptions",component:ol,meta:{title:"Subscriptions"}},{name:"checkout_fields",path:"checkout_fields",component:ufe,meta:{}}]},{name:"email_notifications",path:"email_notifications",component:Mz,meta:{active_menu:"settings",title:"Notifications",permission:"store/sensitive"}},{name:"email_mailing_settings",path:"email_mailing_settings",component:mre,meta:{active_menu:"settings",title:"Mailing Settings",permission:"store/sensitive"}},{name:"reminders",path:"email_mailing_settings/reminders",component:ol,meta:{active_menu:"settings",title:"Reminders",permission:"store/sensitive"}},{name:"email_digest_settings",path:"email_digest_settings",component:Cre,meta:{active_menu:"settings",title:"Store Digest",permission:"store/sensitive"}},{path:"email_notifications/:name/",name:"email_notifications/edit",component:uY,meta:{active_menu:"settings",title:"Edit Notification",permission:"store/sensitive"},props:!0},{path:"email_notifications/add",name:"email_notifications/add",component:QY,meta:{active_menu:"settings",title:"Add Notification",permission:"store/sensitive"}},{name:"licensing",path:"licensing",component:hV,meta:{active_menu:"settings",title:"Licensing",permission:"store/sensitive"}},{name:"payments",path:"payments",component:$U,meta:{active_menu:"settings",title:"Payment Settings",permission:"is_super_admin"}},{name:"gateway",component:QS,path:"payments",children:Fm,props:!0,meta:{active_menu:"settings",title:"Payment Settings",permission:"is_super_admin"}},{name:"invoice-packing",path:"invoice-packing",component:uv,meta:{active_menu:"settings",title:"Invoice & Packing",permission:"is_super_admin"}},{name:"pdf-template",path:"pdf-template",component:yv,meta:{active_menu:"settings",title:"PDF Templates",permission:"is_super_admin"},children:[{name:"pdf-template-list",path:"",component:Mv,meta:{active_menu:"settings",title:"PDF Templates",permission:"is_super_admin"}},{name:"pdf-template-settings",path:"settings",component:w1,meta:{active_menu:"settings",title:"PDF Template Settings",permission:"is_super_admin"}},{name:"edit-pdf-template",path:":template/edit",component:a1,props:!0,meta:{active_menu:"settings",title:"Edit PDF Template",permission:"is_super_admin"}}]},{name:"roles",path:"roles",component:JU,meta:{active_menu:"settings",title:"Role Settings",permission:"is_super_admin"}},{name:"addons",path:"addons",component:Roe,meta:{active_menu:"settings",title:"Features & addon",permission:"is_super_admin"}},{name:"coupons",path:"coupons",component:QA,meta:{active_menu:"coupons",title:"Coupons Settings",permission:"is_super_admin"}},{name:"storage",path:"storage",component:kY,meta:{active_menu:"settings",title:"Storage Providers",permission:"is_super_admin"}},{name:"s3",path:"storage/s3",component:SA,props:!0,meta:{active_menu:"settings",title:"S3",permission:"is_super_admin"}},{name:"payment-design",path:"payments/:method/design",component:LS,meta:{active_menu:"settings",title:"Gateway",permission:"is_super_admin"},props:!0},{name:"drivers",component:SA,path:"storage",children:Em,props:!0,meta:{active_menu:"settings",title:"Storage Settings",permission:"is_super_admin"}},{name:"tax_settings",path:"tax_settings",component:xre,meta:{active_menu:"settings",title:"Tax Settings",permission:"store/settings"},children:[{name:"tax_configurations",path:"",component:Qie,meta:{}},{name:"tax_rates",path:"tax_rates",component:qie,meta:{}},{name:"eu",path:"eu",component:wAe,meta:{}},{name:"eu_country_tax_rates",path:"eu/:country/:group",component:DA,props:!0,meta:{}},{name:"tax-rates-country-single",path:"tax_rates_country_single/:country/:group",component:DA,props:!0,meta:{}}]}]},integrations:{name:"integrations",path:"/integrations",component:Yx,meta:{active_menu:"integrations",title:"Integrations",permission:"integrations/view"}},global_feed_editor:{name:"feed_editor",path:"/global_integrations/:integration_id/:integration_name",component:rA,meta:{active_menu:"integrations",title:"Global Integrations",permission:"integrations/view"}},integration_editor:{name:"integration_editor",path:"/integrations/:integration_name",component:iF,meta:{active_menu:"integrations",title:"Integrations",permission:"integrations/manage"}},coupons:{name:"coupons",path:"/coupons",component:QA,meta:{active_menu:"coupons",title:"Coupons",permission:"coupons/view"}},logs:{name:"logs",path:"/logs",component:yq,meta:{active_menu:"logs",title:"Logs",permission:"is_super_admin"}},taxes:{name:"taxes",path:"/taxes",component:bue,meta:{active_menu:"taxes",title:"taxes",permission:"is_super_admin"}},add_or_edit_coupon_route:{name:"add_or_edit_coupon",path:"/coupons/add_or_edit_coupon/:coupon_id?",component:Npe,props:!0,meta:{active_menu:"coupons",title:"Coupons",permission:"coupons/manage"}},onboarding:{path:"/onboarding",component:DE,name:"onboarding",meta:{active_menu:"dashboard",title:"Onboarding",permission:"is_super_admin"}}};const Z_e={class:"fct-theme-button-container"},ege={class:"theme-selected-button"},tge={__name:"ThemeToggle",setup(e){const t=V(ke.MODE_LIGHT),a=u=>{t.value!==u&&(t.value=u,ke.apply(u))},n=[{value:"light",label:c("Light"),icon:"Sun"},{value:"dark",label:c("Dark"),icon:"Moon"},{value:"system",label:c("System"),icon:"Tools"}];Ks(()=>{const u=document.getElementById("theme-button-container");if(u){const A=u.querySelector(".fct-theme-button-container");A&&A.remove()}t.value=ke.getCurrentTheme(),t.value.toString().startsWith(ke.MODE_SYSTEM)&&(t.value=ke.MODE_SYSTEM)});const s=u=>{ye(()=>{t.value=ke.getCurrentTheme()})},o=u=>{a(u)};return Be(()=>{window.addEventListener(ke.THEME_CHANGE_EVENT,s,!1)}),xn(()=>{window.removeEventListener(ke.THEME_CHANGE_EVENT,s,!1)}),(u,A)=>{const f=C("el-dropdown-item"),m=C("el-dropdown-menu"),g=C("el-dropdown");return d(),_("div",Z_e,[l(g,{placement:"bottom-end",trigger:"click","popper-class":"fct-dropdown",onCommand:o},{dropdown:i(()=>[l(m,null,{default:i(()=>[(d(),_(H,null,ee(n,y=>l(f,{key:y.value,command:y.value,class:de({active:t.value===y.value})},{default:i(()=>[l(W,{name:y.icon},null,8,["name"]),R(" "+h(y.label),1)]),_:2},1032,["command","class"])),64))]),_:1})]),default:i(()=>[r("div",ege,[t.value==="light"?(d(),E(W,{key:0,name:"Sun"})):t.value==="dark"?(d(),E(W,{key:1,name:"Moon"})):t.value==="system"?(d(),E(W,{key:2,name:"Tools"})):x("",!0)])]),_:1})])}}};function ss(e){return Array.isArray?Array.isArray(e):Dm(e)==="[object Array]"}function age(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function nge(e){return e==null?"":age(e)}function On(e){return typeof e=="string"}function Um(e){return typeof e=="number"}function sge(e){return e===!0||e===!1||lge(e)&&Dm(e)=="[object Boolean]"}function $m(e){return typeof e=="object"}function lge(e){return $m(e)&&e!==null}function dn(e){return e!=null}function Xi(e){return!e.trim().length}function Dm(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const oge="Incorrect 'index' type",rge=e=>`Invalid value for key ${e}`,ige=e=>`Pattern length exceeds max of ${e}.`,dge=e=>`Missing ${e} property in key`,uge=e=>`Property 'weight' in key '${e}' must be a positive integer`,RA=Object.prototype.hasOwnProperty;class cge{constructor(t){this._keys=[],this._keyMap={};let a=0;t.forEach(n=>{let s=Qm(n);this._keys.push(s),this._keyMap[s.id]=s,a+=s.weight}),this._keys.forEach(n=>{n.weight/=a})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Qm(e){let t=null,a=null,n=null,s=1,o=null;if(On(e)||ss(e))n=e,t=OA(e),a=Md(e);else{if(!RA.call(e,"name"))throw new Error(dge("name"));const u=e.name;if(n=u,RA.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(uge(u));t=OA(u),a=Md(u),o=e.getFn}return{path:t,id:a,weight:s,src:n,getFn:o}}function OA(e){return ss(e)?e:e.split(".")}function Md(e){return ss(e)?e.join("."):e}function Age(e,t){let a=[],n=!1;const s=(o,u,A)=>{if(dn(o))if(!u[A])a.push(o);else{let f=u[A];const m=o[f];if(!dn(m))return;if(A===u.length-1&&(On(m)||Um(m)||sge(m)))a.push(nge(m));else if(ss(m)){n=!0;for(let g=0,y=m.length;ge.score===t.score?e.idx{this._keysMap[a.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,On(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();On(t)?this._addString(t,a):this._addObject(t,a)}removeAt(t){this.records.splice(t,1);for(let a=t,n=this.size();a{let u=s.getFn?s.getFn(t):this.getFn(t,s.path);if(dn(u)){if(ss(u)){let A=[];const f=[{nestedArrIndex:-1,value:u}];for(;f.length;){const{nestedArrIndex:m,value:g}=f.pop();if(dn(g))if(On(g)&&!Xi(g)){let y={v:g,i:m,n:this.norm.get(g)};A.push(y)}else ss(g)&&g.forEach((y,v)=>{f.push({nestedArrIndex:v,value:y})})}n.$[o]=A}else if(On(u)&&!Xi(u)){let A={v:u,n:this.norm.get(u)};n.$[o]=A}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Im(e,t,{getFn:a=ct.getFn,fieldNormWeight:n=ct.fieldNormWeight}={}){const s=new Qu({getFn:a,fieldNormWeight:n});return s.setKeys(e.map(Qm)),s.setSources(t),s.create(),s}function vge(e,{getFn:t=ct.getFn,fieldNormWeight:a=ct.fieldNormWeight}={}){const{keys:n,records:s}=e,o=new Qu({getFn:t,fieldNormWeight:a});return o.setKeys(n),o.setIndexRecords(s),o}function qo(e,{errors:t=0,currentLocation:a=0,expectedLocation:n=0,distance:s=ct.distance,ignoreLocation:o=ct.ignoreLocation}={}){const u=t/e.length;if(o)return u;const A=Math.abs(n-a);return s?u+A/s:A?1:u}function yge(e=[],t=ct.minMatchCharLength){let a=[],n=-1,s=-1,o=0;for(let u=e.length;o=t&&a.push([n,s]),n=-1)}return e[o-1]&&o-n>=t&&a.push([n,o-1]),a}const Vs=32;function bge(e,t,a,{location:n=ct.location,distance:s=ct.distance,threshold:o=ct.threshold,findAllMatches:u=ct.findAllMatches,minMatchCharLength:A=ct.minMatchCharLength,includeMatches:f=ct.includeMatches,ignoreLocation:m=ct.ignoreLocation}={}){if(t.length>Vs)throw new Error(ige(Vs));const g=t.length,y=e.length,v=Math.max(0,Math.min(n,y));let B=o,b=v;const w=A>1||f,k=w?Array(y):[];let S;for(;(S=e.indexOf(t,b))>-1;){let T=qo(t,{currentLocation:S,expectedLocation:v,distance:s,ignoreLocation:m});if(B=Math.min(T,B),b=S+g,w){let D=0;for(;D=I;G-=1){let ne=G-1,Y=a[e.charAt(ne)];if(w&&(k[ne]=+!!Y),P[G]=(P[G+1]<<1|1)&Y,T&&(P[G]|=(M[G+1]|M[G])<<1|1|M[G+1]),P[G]&L&&($=qo(t,{errors:T,currentLocation:ne,expectedLocation:v,distance:s,ignoreLocation:m}),$<=B)){if(B=$,b=ne,b<=v)break;I=Math.max(1,2*v-b)}}if(qo(t,{errors:T+1,currentLocation:v,expectedLocation:v,distance:s,ignoreLocation:m})>B)break;M=P}const Q={isMatch:b>=0,score:Math.max(.001,$)};if(w){const T=yge(k,A);T.length?f&&(Q.indices=T):Q.isMatch=!1}return Q}function wge(e){let t={};for(let a=0,n=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 Tm{constructor(t,{location:a=ct.location,threshold:n=ct.threshold,distance:s=ct.distance,includeMatches:o=ct.includeMatches,findAllMatches:u=ct.findAllMatches,minMatchCharLength:A=ct.minMatchCharLength,isCaseSensitive:f=ct.isCaseSensitive,ignoreDiacritics:m=ct.ignoreDiacritics,ignoreLocation:g=ct.ignoreLocation}={}){if(this.options={location:a,threshold:n,distance:s,includeMatches:o,findAllMatches:u,minMatchCharLength:A,isCaseSensitive:f,ignoreDiacritics:m,ignoreLocation:g},t=f?t:t.toLowerCase(),t=m?Mr(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const y=(B,b)=>{this.chunks.push({pattern:B,alphabet:wge(B),startIndex:b})},v=this.pattern.length;if(v>Vs){let B=0;const b=v%Vs,w=v-b;for(;B{const{isMatch:M,score:$,indices:F}=bge(t,w,k,{location:o+S,distance:u,threshold:A,findAllMatches:f,minMatchCharLength:m,includeMatches:s,ignoreLocation:g});M&&(B=!0),v+=$,M&&F&&(y=[...y,...F])});let b={isMatch:B,score:B?v/this.chunks.length:1};return B&&s&&(b.indices=y),b}}class Ss{constructor(t){this.pattern=t}static isMultiMatch(t){return HA(t,this.multiRegex)}static isSingleMatch(t){return HA(t,this.singleRegex)}search(){}}function HA(e,t){const a=e.match(t);return a?a[1]:null}class Cge extends Ss{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 Bge extends Ss{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const n=t.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class kge extends Ss{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 xge extends Ss{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 Sge extends Ss{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 Fge extends Ss{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 Vm extends Ss{constructor(t,{location:a=ct.location,threshold:n=ct.threshold,distance:s=ct.distance,includeMatches:o=ct.includeMatches,findAllMatches:u=ct.findAllMatches,minMatchCharLength:A=ct.minMatchCharLength,isCaseSensitive:f=ct.isCaseSensitive,ignoreDiacritics:m=ct.ignoreDiacritics,ignoreLocation:g=ct.ignoreLocation}={}){super(t),this._bitapSearch=new Tm(t,{location:a,threshold:n,distance:s,includeMatches:o,findAllMatches:u,minMatchCharLength:A,isCaseSensitive:f,ignoreDiacritics:m,ignoreLocation:g})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Mm extends Ss{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let a=0,n;const s=[],o=this.pattern.length;for(;(n=t.indexOf(this.pattern,a))>-1;)a=n+o,s.push([n,a-1]);const u=!!s.length;return{isMatch:u,score:u?0:1,indices:s}}}const Ld=[Cge,Mm,kge,xge,Fge,Sge,Bge,Vm],PA=Ld.length,Ege=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Uge="|";function $ge(e,t={}){return e.split(Uge).map(a=>{let n=a.trim().split(Ege).filter(o=>o&&!!o.trim()),s=[];for(let o=0,u=n.length;o!!(e[Lr.AND]||e[Lr.OR]),Tge=e=>!!e[Hd.PATH],Vge=e=>!ss(e)&&$m(e)&&!Pd(e),NA=e=>({[Lr.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Lm(e,t,{auto:a=!0}={}){const n=s=>{let o=Object.keys(s);const u=Tge(s);if(!u&&o.length>1&&!Pd(s))return n(NA(s));if(Vge(s)){const f=u?s[Hd.PATH]:o[0],m=u?s[Hd.PATTERN]:s[f];if(!On(m))throw new Error(rge(f));const g={keyId:Md(f),pattern:m};return a&&(g.searcher=Od(m,t)),g}let A={children:[],operator:o[0]};return o.forEach(f=>{const m=s[f];ss(m)&&m.forEach(g=>{A.children.push(n(g))})}),A};return Pd(e)||(e=NA(e)),n(e)}function Mge(e,{ignoreFieldNorm:t=ct.ignoreFieldNorm}){e.forEach(a=>{let n=1;a.matches.forEach(({key:s,norm:o,score:u})=>{const A=s?s.weight:null;n*=Math.pow(u===0&&A?Number.EPSILON:u,(A||1)*(t?1:o))}),a.score=n})}function Lge(e,t){const a=e.matches;t.matches=[],dn(a)&&a.forEach(n=>{if(!dn(n.indices)||!n.indices.length)return;const{indices:s,value:o}=n;let u={indices:s,value:o};n.key&&(u.key=n.key.src),n.idx>-1&&(u.refIndex=n.idx),t.matches.push(u)})}function Rge(e,t){t.score=e.score}function Oge(e,t,{includeMatches:a=ct.includeMatches,includeScore:n=ct.includeScore}={}){const s=[];return a&&s.push(Lge),n&&s.push(Rge),e.map(o=>{const{idx:u}=o,A={item:t[u],refIndex:u};return s.length&&s.forEach(f=>{f(o,A)}),A})}class Fl{constructor(t,a={},n){this.options={...ct,...a},this.options.useExtendedSearch,this._keyStore=new cge(this.options.keys),this.setCollection(t,n)}setCollection(t,a){if(this._docs=t,a&&!(a instanceof Qu))throw new Error(oge);this._myIndex=a||Im(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){dn(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const a=[];for(let n=0,s=this._docs.length;n-1&&(f=f.slice(0,a)),Oge(f,this._docs,{includeMatches:n,includeScore:s})}_searchStringList(t){const a=Od(t,this.options),{records:n}=this._myIndex,s=[];return n.forEach(({v:o,i:u,n:A})=>{if(!dn(o))return;const{isMatch:f,score:m,indices:g}=a.searchIn(o);f&&s.push({item:o,idx:u,matches:[{score:m,value:o,norm:A,indices:g}]})}),s}_searchLogical(t){const a=Lm(t,this.options),n=(A,f,m)=>{if(!A.children){const{keyId:y,searcher:v}=A,B=this._findMatches({key:this._keyStore.get(y),value:this._myIndex.getValueForItemAtKeyId(f,y),searcher:v});return B&&B.length?[{idx:m,item:f,matches:B}]:[]}const g=[];for(let y=0,v=A.children.length;y{if(dn(A)){let m=n(a,A,f);m.length&&(o[f]||(o[f]={idx:f,item:A,matches:[]},u.push(o[f])),m.forEach(({matches:g})=>{o[f].matches.push(...g)}))}}),u}_searchObjectList(t){const a=Od(t,this.options),{keys:n,records:s}=this._myIndex,o=[];return s.forEach(({$:u,i:A})=>{if(!dn(u))return;let f=[];n.forEach((m,g)=>{f.push(...this._findMatches({key:m,value:u[g],searcher:a}))}),f.length&&o.push({idx:A,item:u,matches:f})}),o}_findMatches({key:t,value:a,searcher:n}){if(!dn(a))return[];let s=[];if(ss(a))a.forEach(({v:o,i:u,n:A})=>{if(!dn(o))return;const{isMatch:f,score:m,indices:g}=n.searchIn(o);f&&s.push({score:m,key:t,value:o,idx:u,norm:A,indices:g})});else{const{v:o,n:u}=a,{isMatch:A,score:f,indices:m}=n.searchIn(o);A&&s.push({score:f,key:t,value:o,norm:u,indices:m})}return s}}Fl.version="7.1.0";Fl.createIndex=Im;Fl.parseIndex=vge;Fl.config=ct;Fl.parseQuery=Lm;Ige(Qge);const Hge=(Ie.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:c("Manage %1$s",t),path:"/settings/payments/"+e.path}}),Pge=[{title:c("Dashboard"),path:"/"},{title:c("Orders"),path:"/orders"},{title:c("Create Order"),path:"/orders/add"},{title:c("Customers"),path:"/customers"},{title:c("Products"),path:"/products"},{title:c("Product Inventory"),path:"/products/inventory"},{title:c("Bulk Import Products"),path:"/products/bulk-insert"},{title:c("Integrations"),path:"/integrations"},{title:c("Coupons"),path:"/coupons"},{title:c("Logs"),path:"/logs"},{title:c("Taxes"),path:"/taxes"},{title:c("Reports"),path:"/reports/overview"},{title:c("Sales Report"),path:"/reports/sales"},{title:c("Orders Report"),path:"/reports/orders"},{title:c("Revenue Report"),path:"/reports/revenue"},{title:c("Refunds Report"),path:"/reports/refunds"},{title:c("Subscriptions Report"),path:"/reports/subscriptions"},{title:c("Future Renewals Report"),path:"/reports/subscriptions/future-renewals"},{title:c("Product Report"),path:"/reports/products"},{title:c("Customer Report"),path:"/reports/customer"},{title:c("Traffic Sources Report"),path:"/reports/sources"},...Hge],Nge=Pge.map(({title:e,subtitle:t,path:a})=>({title:e,...t?{subtitle:t}:{},data:{type:"action",action:({router:n})=>{n.push({path:a})},show_description:!1}})),Kge=[{title:"Theme",title_resolver:()=>{let t=(ke.isDark()?"dark":"light")==="light"?c("Dark"):c("Light");return c("Change theme to %1$s",t)},data:{type:"action",action:()=>{let t=(ke.isDark()?"dark":"light")==="light"?"dark":"light";ke.apply(t,{fromShortcut:!0})}}}],KA={"/settings/store-settings":c("Store Setup"),"/settings/store-settings/pages_setup":c("Pages Setup"),"/settings/store-settings/single_product_setup":c("Single Product & Order Setup"),"/settings/store-settings/cart_and_checkout":c("Cart and Checkout"),"/settings/store-settings/subscriptions":c("Subscriptions Setup"),"/settings/store-settings/checkout_fields":c("Checkout Fields"),"/settings/email_notifications":c("Email Notifications"),"/settings/email_mailing_settings":c("Mailing Settings"),"/settings/email_mailing_settings/reminders":c("Reminders"),"/settings/licensing":c("Licensing"),"/settings/payments":c("Payment Settings"),"/settings/invoice-packing":c("Invoice & Packing Slips"),"/settings/pdf-template":c("PDF Templates"),"/settings/roles":c("Role Settings"),"/settings/addons":c("Features & Addons"),"/settings/tax_settings":c("Tax Settings"),"/settings/tax_settings/tax_rates":c("Tax Rates"),"/settings/tax_settings/eu":c("EU VAT Settings"),"/settings/storage":c("Storage Providers"),"/settings/coupons":c("Coupon Settings")};let Rm=[];Object.keys(KA).forEach(e=>{const t=KA[e];Rm.push({title:t,data:{type:"action",action:({router:a})=>{a.push({path:e})},description:c("Go to %1$s",t),show_description:!1}})});const Gge=[],jge={Menu:Nge,Actions:Kge,Settings:Rm,Shortcuts:Gge},Nd=[];Object.entries(jge).forEach(([e,t])=>{t.forEach((a,n)=>{Nd.push({...a,id:`${e.toString().toLowerCase()}-${n}`,group:[e]})})});const zge=()=>({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}]}),Yge={class:"navigable-list-container fct-global-search-result-container"},qge={key:0,class:"no-results fct-global-search-result-not-found"},Wge={key:1},Xge=["tabindex","onClick","onKeydown"],Jge={__name:"NavigableList",props:{items:{type:Array,required:!0,default:()=>[]},noResultsText:{type:String,default:c("No results found")},onAction:{type:Function,required:!0}},setup(e,{expose:t}){const a=e,n=V(-1),s=zd("listContainer"),o=V({}),u=(b,w)=>{w&&(o.value[b]=w)},A=b=>{const w=a.items.length;if(w===0)return;const k=w-1;b==="up"?n.value=n.value<=0?k:n.value-1:b==="down"&&(n.value=n.value>=k?0:n.value+1),f()},f=()=>{const b=s.value,w=o.value[n.value];w&&b&&(w.scrollIntoView({behavior:"smooth",block:"nearest"}),ye(()=>{w.focus()}))},m=b=>{n.value=b,g(b)},g=b=>{b>=0&&b{n.value=-1};return t({focusList:b=>{b=b??a.items.length-1,b>=0&&(n.value=b,ye(()=>{o.value[b]&&o.value[b].focus()}))},resetSelection:y,performFirstAction:()=>{a.items.length>0?(n.value=0,setTimeout(()=>{g(0)},200)):n.value=-1}}),ge(()=>a.items,b=>{y(),b.length>0&&ye(()=>{})},{immediate:!0}),ge(n,()=>{}),(b,w)=>(d(),_("div",Yge,[e.items.length===0?(d(),_("div",qge,[l(W,{name:"Empty/GlobalSearch"}),R(" "+h(e.noResultsText),1)])):(d(),_("div",Wge,[r("ul",{ref_key:"listContainer",ref:s,class:"navigable-list fct-global-search-result-list"},[(d(!0),_(H,null,ee(e.items,(k,S)=>(d(),_("li",{key:S,ref_for:!0,ref:M=>u(S,M),class:de({selected:S===n.value}),tabindex:S,onClick:M=>m(S),onKeydown:[w[0]||(w[0]=Pa(Xe(M=>A("up"),["prevent"]),["arrow-up"])),w[1]||(w[1]=Pa(Xe(M=>A("down"),["prevent"]),["arrow-down"])),Pa(M=>g(S),["enter"])]},[oa(b.$slots,"default",{item:k,index:S,isSelected:S===n.value},void 0,!0)],42,Xge))),128))],512)]))]))}},Kd=He(Jge,[["__scopeId","data-v-2379fe26"]]),Zge={class:"fct-search-result-label"},eve={class:"fct-search-result-title"},tve={key:0,class:"fct-search-result-subtitle"},ave={key:1,class:"fct-search-result-subtitle"},nve={class:"action-icon"},sve={class:"recent-search-title"},lve={class:"fct-search-result-label"},ove={class:"fct-search-result-title"},rve={key:0,class:"fct-search-result-subtitle"},ive={key:1,class:"fct-search-result-subtitle"},dve={class:"action-icon"},Ji="recent_actions",uve={__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=ja();Qt().ctx;const n=e,s=V(0),o=V({}),u=V(),A=(k,S)=>{const $=k.item.data,F=m($.type);if(F==="link"){let L=m($.url);m($.new_tab)?window.open(L,"_blank"):window.location.href=L}else F==="action"&&m($.action);f(k),n.onActionPerformed()},f=k=>{const S=k.item.id;let M=vt.get(Ji)||[];M=M.filter($=>$!==S),M.unshift(S),M=M.slice(0,5),vt.set(Ji,M)},m=k=>typeof k=="function"?g(k):k,g=async k=>await k({query:n.query,router:a}),y=()=>{var k;(k=u.value)==null||k.resetSelection()},v=()=>{var k;(k=u.value)==null||k.focusList(0)},B=()=>{var k;(k=u.value)==null||k.performFirstAction()};ge(()=>n.searchResults,async()=>{o.value={},o.value=n.searchResults??{},s.value=Object.keys(o.value).length-1;let k=o.value;for(const S of Object.keys(k)){const M=k[S];M.item.title_resolver&&(k[S].item.title=await m(M.item.title_resolver))}o.value={...k}});const b=V([]),w=async()=>{const k=vt.get(Ji)||[];let S=Ke.whereIn(n.searchData,"id",k),M=[];for(const $ of S)typeof $.title_resolver=="function"&&($.title=await m($.title_resolver)),M.push({item:$});b.value=M};return Be(()=>{w()}),t({focusList:v,resetSelection:y,performFirstAction:B,fetchRecentActions:w}),(k,S)=>(d(),_(H,null,[e.query||b.value.length<1?(d(),E(Kd,{key:0,items:e.searchResults,"on-action":A,"no-results-text":p(c)("No matches found"),ref_key:"navigableList",ref:u},{default:i(({item:M,index:$,isSelected:F})=>{var L,Q,T;return[r("span",Zge,[r("span",eve,h(M.item.title),1),(L=M.item)!=null&&L.subtitle?(d(),_("span",tve,h(M.item.subtitle),1)):((T=(Q=M.item)==null?void 0:Q.data)==null?void 0:T.show_description)===!0?(d(),_("span",ave,h(M.item.data.description),1)):x("",!0)]),r("div",nve,[l(W,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])):x("",!0),!e.query&&b.value.length>0?(d(),_(H,{key:1},[r("span",sve,h(p(c)("Recent Actions")),1),l(Kd,{items:b.value,"on-action":A,"no-results-text":p(c)("No matches found"),ref_key:"navigableList",ref:u},{default:i(({item:M,index:$,isSelected:F})=>{var L,Q,T;return[r("span",lve,[r("span",ove,h(M.item.title),1),(L=M.item)!=null&&L.subtitle?(d(),_("span",rve,h(M.item.subtitle),1)):((T=(Q=M.item)==null?void 0:Q.data)==null?void 0:T.show_description)===!0?(d(),_("span",ive,h(M.item.data.description),1)):x("",!0)]),r("div",dve,[l(W,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])],64)):x("",!0)],64))}},cve=He(uve,[["__scopeId","data-v-ccb0ebef"]]),Ave={class:"fct-global-search-product-wrap"},pve={class:"fct-global-search-product-left-info"},fve={key:0,class:"type"},mve={key:0,class:"price-and-status"},hve={__name:"Product",props:{product:{type:Object,required:!0}},setup(e){const t=n=>n.min_price===n.max_price?Jt(n.min_price,!0):`${Jt(n.min_price,!0)} - ${Jt(n.max_price,!0)}`,a=n=>n==="publish"?c("published"):n==="future"?c("scheduled"):n;return(n,s)=>(d(),_("div",Ave,[r("div",pve,[l(Xd,{product:e.product},null,8,["product"]),e.product.detail?(d(),_("span",fve,[R(h(p(Gt).headline(e.product.detail.variation_type))+" ",1),s[0]||(s[0]=r("br",null,null,-1)),R(" "+h(p(Gt).headline(e.product.detail.fulfillment_type)),1)])):x("",!0)]),e.product.detail?(d(),_("span",mve,[R(h(t(e.product.detail))+" ",1),(d(),E(qt,{key:e.product.ID,status:e.product.post_status},{default:i(()=>[R(h(a(e.product.post_status)),1)]),_:1},8,["status"]))])):x("",!0)]))}},_ve={class:"fct-global-search-order-wrap"},gve={class:"fct-global-search-order-header"},vve={class:"fct-global-search-order-id"},yve={class:"items"},bve={class:"fct-global-search-order-header-meta"},wve={class:"date"},Cve=["innerHTML"],Bve={class:"customer-name"},kve={class:"fct-global-search-order-status-wrapper"},xve=["src","alt"],Sve={__name:"Order",props:{order:{type:Object,required:!0}},setup(e){const t=a=>Ke.get(window,"fluentCartAdminApp.payment_logos."+a);return(a,n)=>{var o;const s=C("el-tag");return d(),_("div",_ve,[r("div",gve,[r("div",vve,[R(" #"+h(e.order.id)+" ",1),r("span",yve,h(p(c)("%s Items",e.order.order_items.length)),1)]),r("div",bve,[r("span",wve,[l($a,{"date-time":e.order.created_at},null,8,["date-time"])]),n[0]||(n[0]=r("span",{class:"circle"},null,-1)),r("span",{class:"total-price",innerHTML:p(Jt)(e.order.total_amount,!0,!1,e.order.currency)},null,8,Cve),n[1]||(n[1]=r("span",{class:"circle"},null,-1)),r("span",Bve,h(((o=e.order.customer)==null?void 0:o.full_name)||p(c)("No Name")),1)])]),r("div",kve,[l(qt,{status:e.order.payment_status,"hide-icon":!0},null,8,["status"]),t(e.order.payment_method)?(d(),_("img",{key:0,src:t(e.order.payment_method),alt:p(Gt).headline(e.order.payment_method)},null,8,xve)):(d(),E(s,{key:1,type:"info",round:"",size:"small",class:"capitalize"},{default:i(()=>[R(h(p(Gt).headline(e.order.payment_method)),1)]),_:1}))])])}}},Fve={class:"fct-global-search-customer-wrap"},Eve={class:"fct-customer-card"},Uve={class:"fct-customer-avatar"},$ve=["src"],Dve={class:"fct-customer-details"},Qve={class:"fct-customer-name"},Ive={class:"fct-customer-id"},Tve={class:"fct-customer-email"},Vve={class:"purchase-count"},Mve={class:"date"},Lve={__name:"Customer",props:{customer:{type:Object,required:!0}},setup(e){return(t,a)=>(d(),_("div",Fve,[r("div",Eve,[r("div",Uve,[r("img",{src:e.customer.photo,alt:"avatar"},null,8,$ve)]),r("div",Dve,[r("div",Qve,[R(h(e.customer.full_name||t.$t("No Name"))+" ",1),r("span",Ive,"#"+h(e.customer.id),1)]),r("div",Tve,[R(h(e.customer.email)+" ",1),a[0]||(a[0]=r("span",{class:"circle"},null,-1)),a[1]||(a[1]=R()),r("span",Vve,"Purchase: "+h(e.customer.purchase_count),1)])])]),r("span",Mve,[l($a,{"date-time":e.customer.last_purchase_date},null,8,["date-time"])])]))}},Rve={class:"fct-global-search-coupon-wrap"},Ove={class:"amount"},Hve={__name:"Coupon",props:{coupon:{type:Object,required:!0}},setup(e){return(t,a)=>(d(),_("div",Rve,[r("span",null,h(e.coupon.title),1),r("span",null,h(e.coupon.code),1),r("span",Ove,h(p(Jt)(e.coupon.amount,!0)),1)]))}},Pve={class:"fct-global-remote-result-container"},Nve={class:"fct-global-remote-result-label"},Kve={class:"text"},Gve={class:"navigable-content"},jve={class:"action-icon"},zve={__name:"RemoteResult",emits:["close-modal","onRemoteSearchStateChange"],setup(e,{expose:t,emit:a}){const n=a,s=ja(),o=V({}),u=V(""),A=V(),f=V({}),m=V([]),g=T=>{y.value=!1,m.value=k.data.tableData,n("onRemoteSearchStateChange",!1)},y=V(!1),v={orders:mp({fetch:!1}),products:um({fetch:!1}),customers:fp({fetch:!1}),coupons:wm({fetch:!1})},B=()=>{},b=()=>{var T;(T=A.value)==null||T.focusList(0)},w=()=>{var T;(T=A.value)==null||T.performFirstAction()};Ks(()=>{for(const T of Object.keys(v))v[T].onDataLoaded(g)});let k=null;const S=()=>{k=v[o.value.key],k.data.search=u.value,y.value=!0,k.fetch(),n("onRemoteSearchStateChange",!0)},M=nu.debounce(S,800),$=(T,D)=>{if(m.value=[],k&&(k.data.search=""),o.value=D,f.value={title:D.title,key:D.key},!T){u.value="";return}u.value=T,M()},F=()=>{s.push({name:f.value.key,query:{search:u.value}}),n("close-modal")},L={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"}},Q=T=>{o.value.key in L&&(s.push({name:L[o.value.key].name,params:{[L[o.value.key].key]:T.id||T.ID,action:"edit"}}),n("close-modal"))};return t({fetchData:$,focusList:b,resetSelection:B,performFirstAction:w}),(T,D)=>(d(),_("div",Pve,[r("div",Nve,[r("span",Kve,h(o.value.title),1),f.value.key?(d(),_("span",{key:0,class:"view-all",onClick:F},h(u.value?p(c)('Search "%1$s" in %2$s',u.value,f.value.title):p(c)("See All %s",f.value.title)),1)):x("",!0)]),l(Kd,{items:m.value,"on-action":U=>{Q(U)},"no-results-text":u.value?p(c)("No matches found for %s",o.value.title):p(c)("Type something to find %s",o.value.title),ref_key:"navigableList",ref:A},{default:i(({item:U,index:I,isSelected:O})=>[r("div",Gve,[o.value.key==="products"?(d(),E(hve,{key:0,product:U},null,8,["product"])):x("",!0),o.value.key==="orders"?(d(),E(Sve,{key:1,order:U},null,8,["order"])):x("",!0),o.value.key==="customers"?(d(),E(Lve,{key:2,customer:U},null,8,["customer"])):x("",!0),o.value.key==="coupons"?(d(),E(Hve,{key:3,coupon:U},null,8,["coupon"])):x("",!0)]),r("div",jve,[l(W,{name:"Enter"})])]),_:1},8,["items","on-action","no-results-text"])]))}},Yve={class:"fct-global-search-input-wrap"},qve={class:"fct-setting-search-icon"},Wve={class:"fct-global-search-input-container"},Xve={key:0,class:"searched-item"},Jve={class:"fct-global-searching-for"},Zve={class:"fct-global-searching-for-label"},e1e={class:"fct-global-searching-suggestion-list"},t1e=["onClick"],a1e={class:"dialog-footer is-border"},n1e={class:"fct-search-commands"},s1e={class:"command-key"},l1e={class:"command-key"},o1e={class:"label"},r1e={class:"command-key"},i1e={class:"label"},d1e={class:"label"},u1e={__name:"GlobalSearch",setup(e){Qt().ctx,ja();const t=V(!1),a=V(""),n=V({}),s=V(),o=V(""),u=V([c("orders"),c("products"),c("customers"),c("coupons"),c("settings"),c("menus"),c("shortcuts...")]),A=V(0),f=V(!0),m=V(0),g=V(null),y=V(null),v=V(70),B=V(40),b=V(1700),w=()=>{ye(()=>{S()})},k=()=>{var te,X;Q.value?(te=G.value)==null||te.resetSelection():(X=$.value)==null||X.resetSelection(),Q.value=!1,P.value=!1,M()},S=()=>{var te;(te=s.value)==null||te.focus()},M=()=>{Q.value=!1,n.value=[],t.value=!1,a.value="",T.value=null},$=V(),F=te=>{let X=te.includes(","),ie={},be=[];(X?te.split(","):[te]).forEach(pe=>{pe.includes(":")?L(pe,ie,be):be.push(pe)});let ce=[];return Object.keys(ie).forEach(pe=>{const De=ie[pe];De.length>0?De.forEach($e=>{$e.length>0?ce.push({group:"'"+pe,title:$e}):ce.push({group:"'"+pe})}):ce.push({group:"'"+pe})}),be.forEach(pe=>{pe.length>0&&ce.push({title:pe})}),ce},L=(te,X,ie)=>{if(te.length===1)return;let be=te.split(":"),se=be[0],ce=be[1];se.length>0?(X.hasOwnProperty(se)||(X[se]=[]),ce.length>0&&X[se].push(ce)):ie.push(ce)},Q=V(!1),T=V(null),D=V({o:{key:"orders",title:c("Orders")},p:{key:"products",title:c("Products")},c:{key:"customers",title:c("Customers")},d:{key:"coupons",title:c("Coupons")}}),U=te=>{T.value=te,Q.value=!0,n.value={},ye(()=>{var X,ie;(X=G.value)==null||X.fetchData(a.value,te),(ie=s.value)==null||ie.focus()})},I=()=>{var te;n.value=[],T.value=null,a.value="",Q.value=!1,(te=s.value)==null||te.focus(),P.value=!1},O=()=>{var te;(te=G.value)==null||te.fetchData(a.value,T.value)},P=V(!1),K=te=>{P.value=te,ye(()=>{var X;(X=s.value)==null||X.focus()})},G=V(),ne=ks(),Y=()=>{if(t.value){S();return}const te=["o","p","c","d"];ne.bind(te,X=>{X.preventDefault();const ie=D.value[X.key];ie&&U(ie)}),t.value=!0,ye(()=>{var X;(X=$.value)==null||X.fetchRecentActions()}),setTimeout(()=>{ne.unbind(te)},800)};ne.bind(["/"],te=>{!t.value&&N()||(te.preventDefault(),Y())});const N=()=>{const te=document.activeElement;if(!te)return!1;const X=te.tagName;return X==="INPUT"||X==="TEXTAREA"||X==="SELECT"||te.isContentEditable},oe=()=>{if(g.value)return;const te=()=>{if(s.value&&s.value.length>0)return;const ie=u.value[A.value];if(f.value)m.value{y.value=null},b.value));else{if(y.value)return;m.value>0?(m.value--,o.value=ie.slice(0,m.value)):(f.value=!0,A.value=(A.value+1)%u.value.length)}},X=()=>{te();const ie=f.value?v.value:y.value?120:B.value;g.value=setTimeout(X,ie)};X()},Z=V(!1);let le;return Be(()=>{oe(),le=new Fl(Nd,zge());const te=document.getElementById("fct_admin_menu_search");if(te){const X=te.querySelector(".fct-global-search-input-wrap");X&&X.remove()}Z.value=!!te,window.fluentCart=window.fluentCart||{},window.fluentCart.openSearch=Y}),At(()=>{window.fluentCart&&delete window.fluentCart.openSearch}),(te,X)=>{const ie=C("el-input"),be=C("el-dialog");return d(),_(H,null,[Z.value?(d(),E(Rr,{key:0,to:"#fct_admin_menu_search"},[r("div",Yve,[r("button",{onClick:Y,type:"button",class:"fct-setting-search-button","aria-label":"Search"},[r("span",qve,[l(W,{name:"Search"})]),X[6]||(X[6]=r("span",{class:"fct-global-search-button-keys"},[r("kbd",{class:"fct-global-search-button-key"},"/")],-1))])])])):x("",!0),l(be,{modelValue:t.value,"onUpdate:modelValue":X[5]||(X[5]=se=>t.value=se),onOpened:w,onClosed:k,class:"fct-global-search-container","append-to-body":!0},{header:i(()=>[r("div",Wve,[l(W,{name:"Search",class:"search-icon"}),T.value!=null?(d(),_("div",Xve,[R(h(T.value.title)+" ",1),l(W,{name:"Cross",class:"searched-item-remove",onClick:I})])):x("",!0),l(ie,{class:"mousetrap",placeholder:p(c)("Search for %1$s",o.value),autofocus:"",ref_key:"searchRef",ref:s,id:"fct-global-search-input",disabled:P.value,onKeydown:[X[0]||(X[0]=Pa(Xe(()=>{var se,ce;if(Q.value){(se=G.value)==null||se.focusList();return}(ce=$.value)==null||ce.focusList()},["prevent"]),["arrow-down"])),X[1]||(X[1]=Pa(Xe(()=>{var se,ce;if(Q.value){(se=G.value)==null||se.performFirstAction();return}(ce=$.value)==null||ce.performFirstAction()},["prevent"]),["enter"])),X[2]||(X[2]=Pa(()=>{a.value.length===0&&(T.value=null,Q.value=!1)},["backspace"]))],onInput:X[3]||(X[3]=()=>{if(Q.value){O();return}let se=a.value.includes(","),ce=a.value.includes(":");if(!se&&!ce)n.value.value=p(le).search(a.value);else{const pe=F(a.value);n.value.value=p(le).search({$or:pe})}}),modelValue:a.value,"onUpdate:modelValue":X[4]||(X[4]=se=>a.value=se),clearable:""},null,8,["placeholder","disabled","modelValue"])])]),default:i(()=>[l(ra,{visible:!T.value&&a.value.length===0,accordion:""},{default:i(()=>[r("div",Jve,[r("div",Zve,h(p(c)("Searching for")),1),r("div",e1e,[(d(!0),_(H,null,ee(D.value,se=>{var ce;return d(),_("div",{key:se.key,onClick:pe=>U(se),class:de(["fct-global-searching-suggestion",((ce=T.value)==null?void 0:ce.key)===se.key?"active":""])},h(se.title),11,t1e)}),128))])])]),_:1},8,["visible"]),Q.value?(d(),E(zve,{key:0,ref_key:"remoteResultRef",ref:G,query:a.value,tag:T.value,onCloseModal:M,onOnRemoteSearchStateChange:K},null,8,["query","tag"])):(d(),E(cve,{key:1,ref_key:"resultListRef",ref:$,query:a.value,"search-results":n.value.value,onActionPerformed:M,focusInput:S,searchData:p(Nd)},null,8,["query","search-results","searchData"])),r("div",a1e,[r("ul",n1e,[r("li",null,[r("span",s1e,[l(W,{name:"ArrowUp"})]),r("span",l1e,[l(W,{name:"ArrowDown"})]),r("span",o1e,h(p(c)("To navigate")),1)]),r("li",null,[r("span",r1e,[l(W,{name:"Enter"})]),r("span",i1e,h(p(c)("To select")),1)]),r("li",null,[X[7]||(X[7]=r("kbd",{class:"command-key"},"esc",-1)),r("span",d1e,h(p(c)("To close")),1)])])])]),_:1},8,["modelValue"])],64)}}},c1e={class:"fl_app fluent-cart-admin-pages"},A1e=Object.assign({name:"DashboardApplication"},{__name:"Application",setup(e){const t=V("");Be(()=>{jQuery(".notice:not(.fluent-cart), .error:not(.fluent-cart), #ehp-admin-cb").remove(),t.value=a(),n.value=!!document.getElementById("theme-button-container");const u=document.querySelector(".fct_admin_menu_wrap"),A=()=>{window.scrollY>10?u==null||u.classList.add("scroll-header"):u==null||u.classList.remove("scroll-header")};window.addEventListener("scroll",A)});const a=()=>window.location.href,n=V(!1),s=fn();ge(()=>s.fullPath,()=>{t.value=a()});const o=j(()=>!(s.fullPath.includes("reports")||s.fullPath.includes("settings")));return(u,A)=>{const f=C("router-view");return d(),_("div",null,[l(u1e),o.value?(d(),E(_a,{key:0})):x("",!0),r("div",c1e,[l(f)]),n.value?(d(),E(Rr,{key:1,to:"#theme-button-container"},[l(tge)])):x("",!0)])}}});let GA=!1;function p1e(e){return{data:function(){return{appVars:window.fluentCartAdminApp}},methods:{$get:re.get,$post:re.post,$put:re.put,$del:re.delete,$t:c,$n:ir,formatMoney(t,a,n=!1){return!t&&n?"":(t||(t="0.00"),Ie.get("shop.currency_sign")+" "+t)},formatCents(t,a,n=!1){return!t&&n?"":(t?t=(t*100).toFixed(2):t="0.00",a?(t=new Intl.NumberFormat("en-US").format(t),Ie.get("shop.currency_sign")+" "+t):t)},formatNumber(t,a=!0,n=!1,s){return Te.formatNumber(t,a,n,s)},formatNumberForOrder(t,a,n=!0,s=!1){return Te.formatForOrder(t,a,n,s)},getAddress(t,a="billing"){let n=[t[a+"_address_1"],t[a+"_address_2"],t[a+"_city"],t[a+"_city"],t[a+"_state"],t[a+"_zip"],t[a+"_country"]];return n=n.filter(s=>!!s).join(", "),n||"no "+a+" address"},getOrderAddress(t,a="billing",n=!1){return Th(t,a,n)},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 n in t)a.push(this.convertToText(t[n]));else if(typeof t=="object"&&t.join!==void 0)for(const n in t)a.push(this.convertToText(t[n]));else typeof t=="function"||typeof t=="string"&&a.push(t);return a.join("
")},handleSuccess:t=>{q.success(t)},handleMessage:(t,a="info",n=40,s=1e3)=>{nh.show(t,a,n,s)},Storage:()=>vt,buildFormRendererValue(t,a){let n={};return Object.keys(t).forEach(s=>{let o=t[s];["grid"].includes(o.type??"")?n[s]=this.buildFormRendererValue(o.schema??{},a[s]??{}):n[s]=a[s]??""}),n},registerCopyAction(){GA||(GA=!0,document.addEventListener("click",t=>{t.target.matches(".copyable-content")&&Os.copy(t.target.textContent)}))},currencySign(){return Ie.get("shop.currency_sign")},getPlaceholderImage(){return Ps.getUrl("images/placeholder.svg")},saveLocal(t,a){vt.set(t,a)},getLocal(t){return vt.get(t)},hasPermission(t){return no.hasPermission(t)}}}}function f1e(e){e.beforeEach((t,a,n)=>{const s=Ke.get(t,"meta.permission");return s?no.resolve({permission:s,permissionType:Ke.get(t,"meta.permissionType")})?n():n({name:"unauthorized"}):(Ie.get("app_config.env"),n())})}function m1e(e){const t={fluent_cart_products:["fluent_cart_inventory"]},a=n=>{if(!n)return;const s="fluent_cart_"+n;Object.entries(t).forEach(([o,u])=>{const A=s===o;u.forEach(f=>{const m=jQuery(".toplevel_page_fluent-cart li."+f);A?m.show():m.hide()})})};e.afterEach((n,s)=>{const o=n.meta.active_menu;jQuery(".fct_menu li").removeClass("active_admin_menu"),jQuery(".fct_menu li.fct_menu_item_"+o).addClass("active_admin_menu"),jQuery(".toplevel_page_fluent-cart li").removeClass("current"),jQuery(".toplevel_page_fluent-cart li.fluent_cart_"+o).addClass("current"),a(o),n.meta.title&&jQuery("head title").text(n.meta.title+" - FluentCart")})}const h1e={mounted(e,t){const a=t.value,n=1e3,s=0,o=performance.now(),u=()=>{const A=performance.now()-o,f=Math.min(A/n,1),m=(s+f*(a-s)).toFixed(2);e.textContent=m,f<1&&requestAnimationFrame(u)};u()},updated(e,t){const a=t.value,n=2e3,s=0,o=performance.now(),u=()=>{const A=performance.now()-o,f=Math.min(A/n,1),m=(s+f*(a-s)).toFixed(2);e.textContent=m,f<1&&requestAnimationFrame(u)};u()}},_1e={__name:"Unauthorized",setup(e){return(t,a)=>(d(),_("span",null,h(p(c)("You are not allowed")),1))}},g1e=window.fluent_cart_admin.hooks.applyFilters("fluent_cart_routes",J_e);let jA=!1;document.addEventListener("fcart_renew_rest_nonce",function(e){jA||Ea.alert(c("Your session has expired due to inactivity. Please refresh the page to continue."),c("Session Expired"),{confirmButtonText:c("Reload"),callback:t=>{jA=!1,window.location.reload()}})});const v1e=[yh,bh,wh,Is,Ch,Jd,Bh,kh,Nr,xh,Sh,np],qn=Jm(A1e);qn.config.globalProperties.appVars=Ie.get();qn.provide("appVars",Ie.get());qn.mixin(p1e());qn.directive("loading",Vh);qn.directive("animate",h1e);Rh(qn);const Iu=Zm({routes:[...Object.values(g1e),{path:"/unauthorized",name:"unauthorized",component:_1e,props:!0},{path:"/:path(.*)*",name:"NotFound",component:Kr,props:!0}],history:eh(),scrollBehavior(e,t,a){return a||{top:0,behavior:"smooth"}}});qn.use(Iu);f1e(Iu);m1e(Iu);v1e.forEach(e=>{qn.component(e.name,e)});const Tu=Ie.get("el_strings"),Om=Ie.get("datei18");Tu.el.datepicker.weeks=Om.weekdaysShort;Tu.el.datepicker.months=Om.monthsShort;qn.use(Mh,{locale:Tu});qn.mount("#fluent_cart_plugin_app");export{go as E};