`:F+="
",F+=`
${D.marker}
${D.seriesName}
${O}
`}),F}},xAxis:{type:"category",data:g.value,axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{type:"dashed",color:p.value?"#253241":"#D6DAE1"}}},yAxis:[{type:"value",position:"left",name:u("Volume (%s)",pt.currencySign),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:I=>pt.formatScaledChart(I)},splitLine:{show:!0,lineStyle:{color:p.value?"#253241":"#D6DAE1",type:"dashed"}}},{type:"value",position:"right",name:u("YoY Growth (%)"),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:"{value}%"},splitLine:{show:!1},min:Math.min(...v.value.filter(I=>!isNaN(I)),0)-5,max:Math.max(...v.value.filter(I=>!isNaN(I)),0)+5}],series:y.value};try{b.setOption($,{notMerge:!0,replaceMerge:["series"]})}catch(I){i.value=`Error updating chart: ${I.message}`}},S=($,I,F,x,U=0)=>({name:$,type:I,barMaxWidth:t.barMaxWidth,areaStyle:I==="line"?null:void 0,data:F,smooth:I==="line",color:x,lineStyle:I==="line"?{width:2}:void 0,yAxisIndex:U,emphasis:{scale:2,itemStyle:{color:p.value?c.blue[800]:c.blue[400]}}});return ye([()=>t.data,s],()=>{Be(w)},{deep:!0}),Bt(()=>{window.removeEventListener("onFluentCartThemeChange",w,!1),window.removeEventListener("fluentCartCurrencyChange",w,!1),b&&(b.dispose(),b=null)}),Ee(()=>{window.addEventListener("onFluentCartThemeChange",w),window.addEventListener("fluentCartCurrencyChange",w),Be(k)}),($,I)=>(r(),h("div",xde,[n(ke,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:d(()=>[n(Ie,{title:A(u)(e.title),title_size:"small",border_bottom:""},{action:d(()=>I[0]||(I[0]=[])),_:1},8,["title"]),n(Ce,{class:"p-0"},{default:d(()=>[i.value?(r(),h("div",Sde,m(i.value),1)):B("",!0),e.isEmpty?(r(),E(Ct,{key:2,icon:"Empty/ListView","has-dark":!0,text:A(u)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),h("div",{key:1,class:"fct-chart-wrap fct-gross-volume-chart",ref_key:"chartRef",ref:a,style:{height:"400px"}},null,512))]),_:1})]),_:1},512)]))}},Ac=st(Fde,[["__scopeId","data-v-101c1068"]]),$de={class:"fct-country-volume-chart-wrap"},Ede={class:"fct-btn-group sm"},Ude=.05,Ide={__name:"CountryVolumeChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=M(null),l=M(null);let s=null;const i=M("bar");M("");const c=M(De.isDark()),p=N(()=>c.value?["#8FC0F5","#4E90E8","#2E6BC4","#1E4C90","#143562"]:["#9CC9FA","#3E9DF6","#1573D5","#0B57A3","#083C73"]),f=F=>{const x=F.replace("#",""),U=parseInt(x.substring(0,2),16),T=parseInt(x.substring(2,4),16),D=parseInt(x.substring(4,6),16);return(U*299+T*587+D*114)/1e3>150?"#0B3A66":"#ffffff"},_=N(()=>{const F=Array.isArray(t.data.by_countries)?t.data.by_countries:Object.values(t.data.by_countries);return!F.length||!F.every(x=>!!x)}),g=De.colors,y=N(()=>{const F=t.data.by_month||{};return Object.keys(F).sort().map(U=>{const T=F[U],D=Object.values(T).reduce((V,O)=>V+O,0),Q=Object.entries(T).sort((V,O)=>V[1]-O[1]).reduce((V,[O,L])=>({...V,[O]:L}),{});return{label:U,countries:Q,total:D}})}),v=N(()=>y.value.length?y.value.map(F=>{try{const[x,U]=F.label.split("-");return lt(new Date(x,U-1)).format("MMM YYYY")}catch{return F.label}}):[]),b=N(()=>{const F={};Object.values(t.data.by_month||{}).forEach(T=>{Object.entries(T).forEach(([D,Q])=>{F[D]=(F[D]||0)+Q})}),Object.entries(t.data.by_countries||{}).forEach(([T,D])=>{F[T]=D});const x=p.value,U=x[x.length-1];return Object.keys(F).sort((T,D)=>F[D]-F[T]).reduce((T,D,Q)=>(T[D]=x[Q]||U,T),{})}),k=N(()=>y.value.reduce((F,x)=>Math.max(F,x.total),0)),w=N(()=>{const F=t.data.by_month||{},x=new Set;Object.values(F).forEach(D=>{Object.keys(D).forEach(Q=>x.add(Q))});const U=p.value,T=k.value;return Array.from(x).reverse().map(D=>{const Q=b.value[D]||U[U.length-1],V=f(Q),O=y.value.map(L=>{const P=L.countries[D]||0,z=T>0&&P/T>=Ude;return{value:P/100,label:{show:P>0&&z,position:"inside",formatter:D,color:V,fontSize:10,fontWeight:"bold"}}});return{name:D,type:i.value,stack:"total",data:O,itemStyle:{color:Q},lineStyle:{color:Q}}})}),S=()=>{if(!a.value)return;s=sa(a.value);const F={backgroundColor:"transparent",tooltip:{trigger:"axis",backgroundColor:c.value?"#253241":"#ffffff",textStyle:{color:c.value?g.gray[25]:g.system.mid},borderColor:c.value?"#2C3C4E":"#c0c4ca",axisPointer:Ql(c.value,g.report.dark_cyan_blue_16,g.report.light_gray_cyan_blue,i.value),borderWidth:1,confine:!0,position:bl,formatter:x=>{const U=c.value?"#ffffff":"#565865",T=c.value?g.report.dark_cyan_blue_16:g.report.light_gray_blue,D=y.value[x[0].dataIndex].total;let Q=x[0].axisValue;return x.filter(V=>V.value>0).sort((V,O)=>O.value-V.value).forEach(V=>{const O=ja(V.value*100);Q+=`
${V.marker}
${Us(V.seriesName)}
${O}
`}),Q+=`
${u("Total")}
${ja(D)}
`,Q}},xAxis:{type:"category",data:v.value,axisLabel:{color:c.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{color:c.value?"#253241":"#D6DAE1"}}},yAxis:{type:"value",position:"left",name:u("Volume (%s)",pt.currencySign),axisLabel:{color:c.value?"#ffffff":"#696778",fontSize:12,formatter:x=>pt.formatScaled(x*100)},splitLine:{show:!0,lineStyle:{color:c.value?"#253241":"#D6DAE1",type:"dashed"}}},series:w.value};s.setOption(F)},$=()=>{c.value=De.isDark(),Be(()=>{S()})},I=()=>{s&&(s.dispose(),s=null),S()};return Ee(()=>{window.addEventListener("onFluentCartThemeChange",$),window.addEventListener("fluentCartCurrencyChange",I),Be(S)}),Bt(()=>{window.removeEventListener("onFluentCartThemeChange",$,!1),window.removeEventListener("fluentCartCurrencyChange",I,!1)}),ye(()=>c.value,()=>{s&&(s.dispose(),S())}),ye(()=>t.data,()=>{s&&S()}),(F,x)=>(r(),h("div",$de,[n(ke,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:d(()=>[n(Ie,{title:e.title,title_size:"small",border_bottom:""},{action:d(()=>[o("div",Ede,[n(Sm,{targetRef:a.value},null,8,["targetRef"])])]),_:1},8,["title"]),n(Ce,{class:"p-0"},{default:d(()=>[_.value?(r(),E(Ct,{key:1,icon:"Empty/ListView","has-dark":!0,text:A(u)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),h("div",{key:0,class:"fct-chart-wrap fct-country-volume-chart",ref_key:"chartRef",ref:a,style:{height:"400px"}},null,512))]),_:1})]),_:1},512)]))}},pc=st(Ide,[["__scopeId","data-v-b6ca7579"]]),Qde={class:"fct-card-header-title is-small"},fc={__name:"CountryNetChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=De.colors.report,l=M(De.isDark()),s=M(null),i=M("line"),c=M(t.data),p=N(()=>({textColor:l.value?"#ffffff":"#696778",borderColor:l.value?"#2C3C4E":"#c0c4ca",splitLineColor:l.value?"#253241":"#D6DAE1",bgColor:l.value?"#2d3748":"#ffffff"})),f=N(()=>Object.values(c.value).every(w=>w===0)),_=N(()=>Object.keys(c.value)),g=N(()=>[{name:u("Current"),type:i.value,data:Object.values(c.value),smooth:!0,color:l.value?a.purple_dark_mode:a.purple,lineStyle:{width:2},barMaxWidth:30}]);let y=null;const v=()=>{s.value&&!y&&(y=sa(s.value),b())},b=()=>{if(!y)return;const w={legend:{show:!1},tooltip:{trigger:"axis",backgroundColor:p.value.bgColor,borderColor:p.value.borderColor,borderWidth:1,textStyle:{color:p.value.textColor},axisPointer:Ql(l.value,a.dark_cyan_blue_16,a.light_gray_blue,i.value),confine:!0,position:bl,formatter:S=>{let $=Us(S[0].name);const I=l.value?"#ffffff":"#565865";return S.forEach(F=>{const x=ja(F.value);$+=`
${F.marker}
${F.seriesName}
${x}
`}),$}},xAxis:{type:"category",data:_.value,axisLabel:{color:p.value.textColor,fontSize:12},axisLine:{lineStyle:{type:"dashed",color:p.value.splitLineColor}}},yAxis:{type:"value",axisLabel:{color:p.value.textColor,fontSize:12,formatter:S=>pt.formatScaled(S)},splitLine:{show:!0,lineStyle:{color:p.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"]})};ye([()=>c.value,i,()=>l.value],()=>{Be(b)},{deep:!0});const k=()=>{l.value=De.isDark(),Be(()=>{b()})};return Ee(()=>{window.addEventListener("onFluentCartThemeChange",k,!1),window.addEventListener("fluentCartCurrencyChange",b),Be(v)}),Bt(()=>{window.removeEventListener("onFluentCartThemeChange",k,!1),window.removeEventListener("fluentCartCurrencyChange",b,!1)}),(w,S)=>(r(),E(ke,null,{default:d(()=>[e.title!==""?(r(),E(Ie,{key:0,border_bottom:!0},{title:d(()=>[o("h3",Qde,m(e.title),1)]),_:1})):B("",!0),n(Ce,null,{default:d(()=>[f.value?(r(),E(Ct,{key:1,icon:"Empty/ListView","has-dark":!0,text:A(u)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),h("div",{key:0,class:"fct-chart-wrap h-[350px]",ref_key:"SubscriptionCountTrendChartRef",ref:s},null,512))]),_:1})]),_:1}))}},Dde={class:"fct-overview-report-loader-wrap"},Vde={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},Tde={class:"fct-card-header-title is-small"},Mde={class:"flex gap-2 mt-1"},Lde={class:"py-6"},Rde={class:"grid grid-cols-1"},Ode={class:"fct-card-header-title is-small"},Hde={class:"py-6"},Pde={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},Nde={class:"fct-card-header-title is-small"},Kde={class:"flex gap-2 mt-1"},Gde={class:"py-6"},jde={class:"grid grid-cols-1"},zde={class:"fct-card-header-title is-small"},qde={class:"py-6"},Yde={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},Wde={class:"fct-card-header-title is-small"},Jde={class:"py-6"},Xde={__name:"OverviewLoading",setup(e){const t=[{title:u("Gross Summary"),key:"gross_summary"},{title:u("Gross Revenue Quarterly"),key:"net_summary"}],a=[{title:u("Net Revenue"),key:"net_revenue"},{title:u("Net Revenue Quarterly"),key:"net_revenue_quarterly"}],l=[{title:u("Top Country Gross Volume"),key:"top_country_gross"},{title:u("Top Country Net Volume"),key:"top_country_net"}],s=[{title:u("Top Countries Gross Revenue"),key:"top_country_revenue"},{title:u("Top Countries Net Revenue"),key:"top_country_net_revenue"}];return(i,c)=>{const p=C("el-skeleton-item"),f=C("el-skeleton");return r(),h("div",Dde,[o("div",Vde,[(r(),h(H,null,ae(t,(_,g)=>o("div",{key:g},[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Ie,{border_bottom:!0},{title:d(()=>[o("h3",Tde,m(_.title),1),o("div",Mde,[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",Lde,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",Rde,[(r(),h(H,null,ae(2,_=>o("div",{key:_},[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-2/3"})]),_:1}),n(Ie,{border_bottom:!0},{title:d(()=>[o("h2",Ode,m(A(u)("Gross Volume Breakdown")),1)]),_:1}),o("div",Hde,[n(f,{animated:"",rows:7})])]),_:1})]),_:1})])),64))]),o("div",Pde,[(r(),h(H,null,ae(a,(_,g)=>o("div",{key:g},[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Ie,{border_bottom:!0},{title:d(()=>[o("h3",Nde,m(_.title),1),o("div",Kde,[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",Gde,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",jde,[(r(),h(H,null,ae(l,(_,g)=>o("div",{key:g},[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Ie,{border_bottom:!0},{title:d(()=>[o("h2",zde,m(_.title),1)]),_:2},1024),o("div",qde,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",Yde,[(r(),h(H,null,ae(s,(_,g)=>o("div",{key:g},[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Ie,{border_bottom:!0},{title:d(()=>[o("h3",Wde,m(_.title),1)]),_:2},1024),o("div",Jde,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))])])}}},Zde={class:"overview-summary-report-inline"},eue={class:"inner-value"},tue={__name:"Summary",props:{title:{type:String},current:{type:[String,Number],required:!0},previous:{type:[String,Number],required:!0},fluctuation:{type:[String,Number],required:!0}},setup(e){return(t,a)=>(r(),h("div",Zde,[o("div",eue,[n(Ms,{amount:A(pt).formatScaled(e.current),title:A(u)(e.title)},null,8,["amount","title"])]),n(_l,{fluctuation:e.fluctuation,amount:e.previous/100,fluctuationSuffix:A(u)("YoY")},null,8,["fluctuation","amount","fluctuationSuffix"])]))}},go=st(tue,[["__scopeId","data-v-b394c9f1"]]),aue={class:"report-overview-page"},lue={class:"flex items-center justify-start gap-1 mb-2 text-xs text-system-mid dark:text-system-light"},sue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},nue={class:"fct-card-header-title is-small"},oue={class:"fct-card-header-title is-small"},iue={class:"grid grid-cols-1"},rue=["innerHTML"],due=["innerHTML"],uue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},cue={class:"fct-card-header-title is-small"},Aue={class:"fct-card-header-title is-small"},pue={class:"grid gap-4 grid-cols-1"},fue={class:"grid gap-4 grid-cols-1"},mue={class:"report-overview-col-2 grid gap-7.5 grid-cols-1 xl:grid-cols-2"},hue={__name:"Overview",setup(e){const t=M({}),a=M(!0),l=M({gross_revenue_quarterly:{},net_revenue_quarterly:{}}),s=()=>{ce.get("reports/overview").then(p=>{t.value=p.data,i()}).catch(p=>{}).finally(()=>{a.value=!1})},i=()=>{l.value.gross_revenue_quarterly=c(t.value.gross_revenue_quarterly,"current","prev_year"),l.value.net_revenue_quarterly=c(t.value.net_revenue_quarterly,"current","prev_year")},c=(p,f="current",_="prev")=>{const g=rt.sum(p,"*."+f),y=rt.sum(p,"*."+_),v=y===0?100:(g-y)/y*100;return{value:parseFloat(v.toFixed(2)),prev:y,current:g}};return N(()=>{var p,f;return((p=t.value.gross_summary)==null?void 0:p.yoy_growth)<0?"danger":((f=t.value.gross_summary)==null?void 0:f.yoy_growth)===null?"warning":"success"}),Ee(()=>{s()}),(p,f)=>(r(),h("div",aue,[o("div",lue,[n(J,{name:"InformationFill",class:"w-4 h-4 text-system-light"}),R(" "+m(A(u)("Last %s Months",A(u)(12))),1)]),a.value?(r(),E(Xde,{key:0})):(r(),h(H,{key:1},[o("div",sue,[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Ie,{border_bottom:""},{title:d(()=>[o("h3",nue,m(A(u)("Gross Summary")),1),n(go,{current:t.value.gross_summary.total,previous:t.value.gross_summary.total_prev,fluctuation:t.value.gross_summary.yoy_growth},null,8,["current","previous","fluctuation"])]),_:1}),n(vo,{data:t.value.gross_revenue,dataKey:"current","date-range":"","is-empty":!t.value.gross_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Ie,{border_bottom:""},{title:d(()=>[o("h3",oue,m(A(u)("Gross Revenue Quarterly")),1),n(go,{current:l.value.gross_revenue_quarterly.current,previous:l.value.gross_revenue_quarterly.prev,fluctuation:l.value.gross_revenue_quarterly.value},null,8,["current","previous","fluctuation"])]),_:1}),n(vo,{data:t.value.gross_revenue_quarterly,dataKey:"current","bar-max-width":80,"is-empty":!l.value.gross_revenue_quarterly.current},null,8,["data","is-empty"])]),_:1})]),_:1})]),o("div",iue,[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[o("div",{class:"mb-3",innerHTML:A(pt).generateVolumeSummary(t.value.gross_revenue,!0)},null,8,rue),n(Ac,{title:A(u)("Gross Volume Breakdown"),data:t.value.gross_revenue,dataKey:"current","is-date":"","is-empty":!t.value.gross_summary.total},null,8,["title","data","is-empty"])]),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[o("div",{class:"mb-3",innerHTML:A(pt).generateVolumeSummary(t.value.gross_revenue_quarterly)},null,8,due),n(Ac,{title:A(u)("Gross Revenue Breakdown"),data:t.value.gross_revenue_quarterly,dataKey:"current",prevKey:"prev_year",labelKey:"yy_growth","bar-max-width":80,"is-empty":!t.value.gross_summary.total},null,8,["title","data","is-empty"])]),_:1})]),_:1})]),o("div",uue,[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Ie,{border_bottom:!0},{title:d(()=>[o("h3",cue,m(A(u)("Net Revenue")),1),n(go,{title:A(u)("Net Revenue"),current:t.value.net_summary.total,previous:t.value.net_summary.total_prev,fluctuation:t.value.net_summary.yoy_growth},null,8,["title","current","previous","fluctuation"])]),_:1}),n(vo,{data:t.value.net_revenue,dataKey:"current","date-range":"","is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Ie,{border_bottom:!0},{title:d(()=>[o("h3",Aue,m(A(u)("Net Revenue Quarterly")),1),n(go,{title:A(u)("Net Revenue Quarterly"),current:l.value.net_revenue_quarterly.current,previous:l.value.net_revenue_quarterly.prev,fluctuation:l.value.net_revenue_quarterly.value},null,8,["title","current","previous","fluctuation"])]),_:1}),n(vo,{data:t.value.net_revenue_quarterly,dataKey:"current","bar-max-width":80,"is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1})]),o("div",pue,[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(pc,{data:t.value.top_country_gross,title:A(u)("Top Country Gross Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",fue,[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(pc,{data:t.value.top_country_net,title:A(u)("Top Country Net Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",mue,[n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>{var _;return[n(fc,{data:(_=t.value.top_country_gross)==null?void 0:_.by_countries,title:A(u)("Top Countries Gross Revenue")},null,8,["data","title"])]}),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ce,null,{default:d(()=>{var _;return[n(fc,{data:(_=t.value.top_country_net)==null?void 0:_.by_countries,title:A(u)("Top Countries Net Revenue")},null,8,["data","title"])]}),_:1})]),_:1})])],64))]))}},_ue={class:"setting-wrap"},vue={class:"setting-wrap-inner"},gue={key:0,class:"bg-white rounded p-6 dark:bg-dark-700"},yue={class:"grid gap-3 mb-6"},bue={class:"grid gap-3 mb-6"},wue={class:"grid gap-3 mb-6"},Cue={class:"grid gap-3"},kue={class:"payment-method-list fct-content-card-list"},Bue=["id"],xue={class:"flex items-start gap-3"},Sue={class:"grid gap-2 flex-1"},Fue={key:0,class:"fct-content-card-list-head stripe"},$ue=["src","alt"],Eue=["src","alt"],Uue={class:"block font-semibold text-system-dark dark:text-gray-50"},Iue={class:"fct-content-card-list-content"},Que={class:"fct-content-card-list-action flex items-center gap-2"},Due={key:0},Vue=Object.assign({name:"AddonSettings"},{__name:"AddonSettings",setup(e){const t=Op(),{form:a}=t.data,l=vs(),s=M([]),i=M([]),c=M(!0),p=M(!1),f=M(!0),_=M({}),g=M(!1),y=M({}),v=M(!1),b=M(""),k=M(""),w=M(""),S=N(()=>Object.keys(y.value).length>0),$=()=>{p.value=!0;let D=a.values;ce.post("settings/modules",{...D}).then(Q=>{q.success(u("Settings saved successfully")),setTimeout(()=>{window.location.reload()},300)}).catch(Q=>{if(Q&&Q.message)return q.error(Q);_.value=Q}).finally(()=>{p.value=!1,f.value=!1,c.value=!1})},I=()=>{c.value=!0,ce.get("settings/modules",{}).then(D=>{var O,L;a.setSchema(D.fields).setDefaults(D.settings).initForm(),s.value=D.settings,i.value=D.fields,f.value=!1,p.value=!1;const Q=((L=(O=D.fields)==null?void 0:O.modules_settings)==null?void 0:L.schema)||[];let V=!1;Array.isArray(Q)?V=Q.length>0:V=Object.keys(Q).length>0,g.value=V}).finally(()=>{c.value=!1})},F=()=>{v.value=!0,ce.get("settings/modules/plugin-addons",{}).then(D=>{y.value=D.addons||{},w.value&&Be(()=>ln.scrollToHashSection(w.value))}).catch(D=>{q.error(D)}).finally(()=>{v.value=!1})},x=je.get("app_config.isProActive"),U=(D,Q)=>{if(!x){window.open(D.repo_link,"_blank","noopener,noreferrer");return}b.value=Q,ce.post("settings/modules/plugin-addons/install",{plugin_slug:D.plugin_slug,source_type:D.source_type||"wordpress",source_link:D.source_link||"",asset_path:D.asset_path||""}).then(V=>{V.action==="copy"&&V.url?(Zl.copy(V.url,{successMessage:u("Download link copied to your clipboard")}),window.open(V.url,"_blank","noopener,noreferrer")):V.action==="reload"?(q.success(V.message||u("Addon installed successfully")),setTimeout(()=>{window.location.reload()},500)):q.success(V.message||u("Addon installed successfully"))}).catch(V=>{q.error(V)}).finally(()=>{b.value=""})},T=(D,Q)=>{k.value=Q,ce.post("settings/modules/plugin-addons/activate",{plugin_file:D.plugin_file}).then(V=>{q.success(V.message||u("Addon activated successfully")),setTimeout(()=>{window.location.reload()},500)}).catch(V=>{q.error(V)}).finally(()=>{k.value=""})};return Ee(()=>{const D=window.location.hash||"",Q=D.lastIndexOf("#");Q>0&&(w.value=D.substring(Q+1)),I(),F()}),l.onSave($),(D,Q)=>{const V=C("el-skeleton-item"),O=C("el-skeleton"),L=C("el-form"),P=C("el-button"),z=C("el-icon"),X=C("router-link");return r(),h("div",_ue,[n(Ua,{heading:A(u)("Addon Settings"),"show-save-button":!1},null,8,["heading"]),o("div",vue,[n(Ia),f.value?(r(),h("div",gue,[n(O,{loading:f.value,animated:""},{template:d(()=>[o("div",yue,[n(V,{variant:"p",class:"w-[20%]"}),n(V,{variant:"p"})]),o("div",bue,[n(V,{variant:"p",class:"w-[20%]"}),n(V,{variant:"p"})]),o("div",wue,[n(V,{variant:"p",class:"w-[20%]"}),n(V,{variant:"p"})]),o("div",Cue,[n(V,{variant:"p",class:"w-[20%]"}),n(V,{variant:"p"})])]),_:1},8,["loading"])])):B("",!0),f.value?B("",!0):(r(),h(H,{key:1},[A(a).isReady?(r(),E(L,{key:0},{default:d(()=>[g.value?(r(),E(ki,{key:0,form:A(a),showSubmitButton:!0,onOnSubmitButtonClick:$,submitButtonText:A(u)("Save Settings"),loading:p.value,onOnChange:Q[0]||(Q[0]=G=>{}),"validation-errors":_.value},null,8,["form","submitButtonText","loading","validation-errors"])):S.value?B("",!0):(r(),E(ke,{key:1},{default:d(()=>[n(Ie,{title:A(u)("Features & addon"),border_bottom:""},null,8,["title"]),n(Ce,null,{default:d(()=>[n(Ct,{class:"fct-addon-empty-state",icon:"Empty/Integrations",text:A(u)("No module settings found.")},null,8,["text"])]),_:1})]),_:1}))]),_:1})):B("",!0),S.value?(r(),E(ke,{key:1,class:"mt-6"},{default:d(()=>[n(Ie,{title:A(u)("Plugin Addons"),border_bottom:""},null,8,["title"]),n(Ce,{class:"py-0"},{default:d(()=>[o("div",kue,[(r(!0),h(H,null,ae(y.value,(G,ee)=>(r(),h("div",{key:ee,class:"fct-content-card-list-item",id:G.plugin_slug===w.value?w.value:null},[o("div",xue,[o("div",Sue,[G.logo?(r(),h("div",Fue,[o("img",{class:de({"dark:hidden":G.dark_logo}),src:G.logo,alt:G.title},null,10,$ue),G.dark_logo?(r(),h("img",{key:0,src:G.dark_logo,alt:G.title,class:"hidden dark:block"},null,8,Eue)):B("",!0),o("span",Uue,m(G.title),1),G.is_active?(r(),E(pa,{key:1,status:"active",text:A(u)("Active")},null,8,["text"])):B("",!0)])):B("",!0),o("div",Iue,[o("p",null,m(G.description),1)])]),o("div",Que,[G.upcoming?(r(),h("div",Due,m(A(u)("Coming Soon")),1)):(r(),h(H,{key:1},[G.is_installed?G.is_installed&&!G.is_active&&(A(x)||G.source_type!=="github")?(r(),E(P,{key:1,type:"success",size:"small",loading:k.value===ee,disabled:k.value===ee,onClick:oe=>T(G,ee)},{default:d(()=>[R(m(A(u)("Activate")),1)]),_:2},1032,["loading","disabled","onClick"])):B("",!0):(r(),E(P,{key:0,type:"primary",size:"small",loading:b.value===ee,disabled:b.value===ee,onClick:oe=>U(G,ee)},{default:d(()=>[R(m(A(x)?A(u)("Install & Activate"):A(u)("Download")),1)]),_:2},1032,["loading","disabled","onClick"])),G.is_active&&ee==="fluent-pdf"?(r(),E(X,{key:2,to:{path:"/settings/pdf-template"}},{default:d(()=>[n(z,{class:"text-gray-500 hover:text-primary cursor-pointer",size:18},{default:d(()=>[n(A(Rc))]),_:1})]),_:1})):B("",!0)],64))])])],8,Bue))),128))])]),_:1})]),_:1})):B("",!0)],64))])])}}}),Tue=st(Vue,[["__scopeId","data-v-a315b5d5"]]),Mue={class:"form-note"},Lue={class:"form-note"},Rue={class:"form-note"},Oue={class:"form-note"},Hue={class:"el-form-item__label"},Pue={class:"h-[297px] w-full relative"},Nue={class:"mt-2 mb-2"},Kue={class:"form-note"},Gue={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"},jue={class:"setting-html-wrapper"},zue={class:"setting-label"},que={class:"form-note"},Yue={class:"setting-fields-inner w-full"},Wue={__name:"MailingSettingsLoader",setup(e){return(t,a)=>{const l=C("el-skeleton-item"),s=C("el-skeleton"),i=C("el-form-item"),c=C("el-col"),p=C("el-row");return r(),E(Ce,null,{default:d(()=>[n(p,{gutter:15},{default:d(()=>[n(c,{lg:12},{default:d(()=>[n(i,{label:A(u)("From Name"),"label-position":"top"},{default:d(()=>[n(s,{animated:"",class:"h-9 gap-2"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),a[0]||(a[0]=o("br",null,null,-1)),o("div",null,[o("div",Mue,[o("p",null,m(A(u)("Name that will be used to send emails")),1)])])]),_:1,__:[0]},8,["label"])]),_:1}),n(c,{lg:12},{default:d(()=>[n(i,{label:A(u)("From Email"),"label-position":"top"},{default:d(()=>[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",null,[o("div",Lue,[o("p",null,m(A(u)(`Provide Valid Email Address email as per your domain/SMTP settings. This
email will be used to send emails like notifications`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(p,{gutter:15},{default:d(()=>[n(c,{lg:12},{default:d(()=>[n(i,{label:A(u)("Reply to name (Optional)"),"label-position":"top"},{default:d(()=>[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",Rue,[o("p",null,m(A(u)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),n(c,{lg:12},{default:d(()=>[n(i,{label:A(u)("Reply to email (Optional)"),"label-position":"top"},{default:d(()=>[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",null,[o("div",Oue,[o("p",null,m(A(u)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(p,{gutter:15},{default:d(()=>[n(c,null,{default:d(()=>[o("div",Hue,m(A(u)("Email Footer")),1),o("div",Pue,[n(s,{animated:"",rows:7})]),o("div",Nue,[o("div",Kue,[o("p",null,m(A(u)(`This email footer will be used for all emails sent from FluentCart, It's highly recommended to use your business name and address in the footer for
compliance.`)),1)])]),o("div",Gue,[n(s,{animated:"",class:"h-5"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1}),n(p,{gutter:15},{default:d(()=>[n(c,null,{default:d(()=>[n(i,null,{default:d(()=>[n(p,{gutter:15,class:"w-full"},{default:d(()=>[n(c,{lg:12},{default:d(()=>[o("div",jue,[o("span",zue,m(A(u)("Admin Email Address")),1),o("div",que,[o("p",null,m(A(u)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),n(c,{lg:12},{default:d(()=>[o("div",Yue,[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}}},Jue={class:"setting-wrap"},Xue={class:"setting-wrap-inner"},Zue={class:"form-note"},ece={class:"form-note"},tce={class:"form-note"},ace={class:"form-note"},lce={class:"el-form-item__label"},sce={class:"mt-2 mb-2"},nce={class:"form-note"},oce={class:"fct-powered-by-email-footer-checkbox"},ice={class:"setting-html-wrapper"},rce={class:"setting-label"},dce={class:"form-note"},uce={class:"setting-fields-inner w-full"},cce={class:"setting-save-action"},Ace={__name:"MailingSettings",setup(e){const t=M({from_name:"",from_email:"",reply_to_name:"",reply_to_email:"",email_footer:"",show_email_footer:"yes",admin_email:"{{wp.admin_email}}"}),a=je.get("app_config.isProActive"),l=M(!1),s=M({}),i=M({}),c=()=>{l.value=!0,ce.get("email-notification/get-settings").then(f=>{var _,g,y,v,b,k,w;t.value={from_name:(_=f.data)==null?void 0:_.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:(k=f.data)==null?void 0:k.admin_email,show_email_footer:((w=f.data)==null?void 0:w.show_email_footer)||"yes"},i.value=f.shortcodes}).catch(f=>{}).finally(()=>{l.value=!1})},p=()=>{l.value=!0,s.value={},ce.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(u("Something went wrong")),s.value=f)}).finally(()=>{l.value=!1})};return Ee(()=>{c()}),(f,_)=>{const g=C("el-input"),y=C("el-form-item"),v=C("el-col"),b=C("el-row"),k=C("el-tooltip"),w=C("el-checkbox"),S=C("el-button");return r(),h("div",Jue,[n(Ua,{heading:A(u)("Mailing Settings"),loading:l.value,onOnSave:p},null,8,["heading","loading"]),o("div",Xue,[n(Ia),n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Email Configuration"),text:A(u)("Set your from name, email, and email footer. These configurations will be used to send emails from %s.","FluentCart"),border_bottom:""},null,8,["title","text"]),l.value?(r(),E(Wue,{key:0})):(r(),E(Ce,{key:1},{default:d(()=>[n(b,{gutter:15},{default:d(()=>[n(v,{lg:12},{default:d(()=>[n(y,{label:A(u)("From Name"),"label-position":"top"},{default:d(()=>[n(g,{modelValue:t.value.from_name,"onUpdate:modelValue":_[0]||(_[0]=$=>t.value.from_name=$)},null,8,["modelValue"]),_[9]||(_[9]=o("br",null,null,-1)),o("div",null,[n(hl,{"validation-errors":s.value.from_name||{},"field-key":"from_name"},null,8,["validation-errors"]),o("div",Zue,[o("p",null,m(A(u)("Name that will be used to send emails")),1)])])]),_:1,__:[9]},8,["label"])]),_:1}),n(v,{lg:12},{default:d(()=>[n(y,{label:A(u)("From Email"),"label-position":"top"},{default:d(()=>[n(g,{modelValue:t.value.from_email,"onUpdate:modelValue":_[1]||(_[1]=$=>t.value.from_email=$)},null,8,["modelValue"]),o("div",null,[n(hl,{"validation-errors":s.value.from_email||{},"field-key":"from_email"},null,8,["validation-errors"]),o("div",ece,[o("p",null,m(A(u)(`Provide Valid Email Address email as per your domain/SMTP settings. This
email will be used to send emails like notifications`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(b,{gutter:15},{default:d(()=>[n(v,{lg:12},{default:d(()=>[n(y,{label:A(u)("Reply to name (Optional)"),"label-position":"top"},{default:d(()=>[n(g,{modelValue:t.value.reply_to_name,"onUpdate:modelValue":_[2]||(_[2]=$=>t.value.reply_to_name=$)},null,8,["modelValue"]),o("div",tce,[o("p",null,m(A(u)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),n(v,{lg:12},{default:d(()=>[n(y,{label:A(u)("Reply to email (Optional)"),"label-position":"top"},{default:d(()=>[n(g,{modelValue:t.value.reply_to_email,"onUpdate:modelValue":_[3]||(_[3]=$=>t.value.reply_to_email=$)},null,8,["modelValue"]),o("div",null,[n(hl,{"validation-errors":s.value.reply_to_email||{},"field-key":"reply_to_email"},null,8,["validation-errors"]),o("div",ace,[o("p",null,m(A(u)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(b,{gutter:15},{default:d(()=>[n(v,null,{default:d(()=>[o("div",lce,m(A(u)("Email Footer")),1),n(es,{"short-codes":i.value,modelValue:t.value.email_footer,"onUpdate:modelValue":_[4]||(_[4]=$=>t.value.email_footer=$),onUpdate:_[5]||(_[5]=$=>{t.value.email_footer=$})},null,8,["short-codes","modelValue"]),o("div",sce,[n(hl,{"validation-errors":s.value.email_footer||{},"field-key":"email_footer"},null,8,["validation-errors"]),o("div",nce,[o("p",null,m(A(u)(`This email footer will be used for all emails sent from FluentCart, It's highly recommended to use your business name and address in the footer for
compliance.`)),1)])]),o("div",oce,[n(w,{modelValue:t.value.show_email_footer,"onUpdate:modelValue":_[6]||(_[6]=$=>t.value.show_email_footer=$),"true-value":"yes","false-value":"no",disabled:!A(a)},{default:d(()=>[R(m(A(u)("Enable powered by FluentCart in the email footer"))+" ",1),A(a)?B("",!0):(r(),E(k,{key:0,"popper-class":"fct-tooltip",placement:"top"},{content:d(()=>[R(m(A(u)("This feature is available in pro version only.")),1)]),default:d(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),_:1},8,["modelValue","disabled"])])]),_:1})]),_:1}),n(b,{gutter:15},{default:d(()=>[n(v,null,{default:d(()=>[n(y,null,{default:d(()=>[n(b,{gutter:15,class:"w-full"},{default:d(()=>[n(v,{lg:12},{default:d(()=>[o("div",ice,[o("span",rce,m(A(u)("Admin Email Address")),1),o("div",dce,[o("p",null,m(A(u)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),n(v,{lg:12},{default:d(()=>[o("div",uce,[n(g,{modelValue:t.value.admin_email,"onUpdate:modelValue":_[7]||(_[7]=$=>t.value.admin_email=$)},null,8,["modelValue"])])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1}),o("div",cce,[n(S,{type:"primary",onClick:_[8]||(_[8]=$=>p()),loading:l.value},{default:d(()=>[R(m(A(u)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},pce={class:"setting-wrap"},fce={class:"setting-wrap-inner"},mce={class:"form-note"},hce={class:"form-note"},_ce={class:"form-note",style:{"padding-top":"6px"}},vce={class:"form-note"},gce={class:"setting-save-action"},mc="{{wp.admin_email}}",yce={__name:"StoreDigestSettings",setup(e){const t=M({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=M(!1),l=M({}),s=M(""),i=[{key:"daily",label:u("Daily digest"),desc:u("Yesterday's performance, sent every morning.")},{key:"weekly",label:u("Weekly digest"),desc:u("The previous 7 days, sent on your chosen day.")},{key:"monthly",label:u("Monthly digest"),desc:u("The previous calendar month, sent on the 1st.")}],c=u("Comma-separate multiple addresses. %1$s resolves to the site admin email.",mc),p=N(()=>{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:u("Monday")},{value:2,label:u("Tuesday")},{value:3,label:u("Wednesday")},{value:4,label:u("Thursday")},{value:5,label:u("Friday")},{value:6,label:u("Saturday")},{value:7,label:u("Sunday")}],_=()=>{a.value=!0,ce.get("email-notification/digest-settings").then(v=>{v.data&&(t.value=v.data)}).catch(()=>{}).finally(()=>{a.value=!1})},g=()=>{a.value=!0,l.value={},ce.post("email-notification/digest-settings",t.value).then(v=>{q.success(v.message)}).catch(v=>{v.status_code===422&&v.data?l.value=v.data:v.message?q.error(v.message):q.error(u("Something went wrong"))}).finally(()=>{a.value=!1})},y=v=>{s.value=v,ce.post("email-notification/digest-settings/send-test",{frequency:v}).then(b=>{q.success(b.message)}).catch(b=>{q.error(b.message||u("Could not send the test email."))}).finally(()=>{s.value=""})};return Ee(()=>{_()}),(v,b)=>{const k=C("el-input"),w=C("el-form-item"),S=C("el-col"),$=C("el-checkbox"),I=C("el-row"),F=C("el-switch"),x=C("el-option"),U=C("el-select"),T=C("el-button");return r(),h("div",pce,[n(Ua,{heading:A(u)("Store Digest Emails"),loading:a.value,onOnSave:g},null,8,["heading","loading"]),o("div",fce,[n(Ia),n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Recipients & General"),text:A(u)("A system email summarising your store activity. Numbers match the Reports dashboard."),border_bottom:""},null,8,["title","text"]),n(Ce,null,{default:d(()=>[n(I,{gutter:15},{default:d(()=>[n(S,{lg:12},{default:d(()=>[n(w,{label:A(u)("Recipient email addresses"),"label-position":"top"},{default:d(()=>[n(k,{modelValue:t.value.recipients,"onUpdate:modelValue":b[0]||(b[0]=D=>t.value.recipients=D),placeholder:mc},null,8,["modelValue"]),o("div",null,[n(hl,{"validation-errors":l.value.recipients||{},"field-key":"recipients"},null,8,["validation-errors"]),o("div",mce,[o("p",null,m(A(c)),1)])])]),_:1},8,["label"])]),_:1}),n(S,{lg:12},{default:d(()=>[n(w,{label:A(u)("Empty periods"),"label-position":"top"},{default:d(()=>[n($,{modelValue:t.value.send_when_empty,"onUpdate:modelValue":b[1]||(b[1]=D=>t.value.send_when_empty=D),"true-value":"yes","false-value":"no"},{default:d(()=>[R(m(A(u)("Send even when there was no activity")),1)]),_:1},8,["modelValue"]),o("div",hce,[o("p",null,m(A(u)("When off, a digest is skipped for any period with no paid orders.")),1)])]),_:1},8,["label"])]),_:1})]),_:1})]),_:1})]),_:1}),(r(),h(H,null,ae(i,D=>n(ke,{key:D.key,class:"fct-mt-4"},{default:d(()=>[n(Ie,{title:D.label,text:D.desc,border_bottom:""},null,8,["title","text"]),n(Ce,null,{default:d(()=>[n(I,{gutter:15,align:"middle"},{default:d(()=>[n(S,{lg:6},{default:d(()=>[n(w,{label:A(u)("Enable"),"label-position":"top"},{default:d(()=>[n(F,{modelValue:t.value[D.key].enabled,"onUpdate:modelValue":Q=>t.value[D.key].enabled=Q,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),n(S,{lg:6},{default:d(()=>[n(w,{label:A(u)("Send time"),"label-position":"top"},{default:d(()=>[n(U,{modelValue:t.value[D.key].send_hour,"onUpdate:modelValue":Q=>t.value[D.key].send_hour=Q,class:"w-full"},{default:d(()=>[(r(!0),h(H,null,ae(p.value,Q=>(r(),E(x,{key:Q.value,label:Q.label,value:Q.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),D.key==="weekly"?(r(),E(S,{key:0,lg:6},{default:d(()=>[n(w,{label:A(u)("Day of week"),"label-position":"top"},{default:d(()=>[n(U,{modelValue:t.value.weekly.send_dow,"onUpdate:modelValue":b[2]||(b[2]=Q=>t.value.weekly.send_dow=Q),class:"w-full"},{default:d(()=>[(r(),h(H,null,ae(f,Q=>n(x,{key:Q.value,label:Q.label,value:Q.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})):B("",!0),D.key==="monthly"?(r(),E(S,{key:1,lg:6},{default:d(()=>[n(w,{label:A(u)("Send day"),"label-position":"top"},{default:d(()=>[o("div",_ce,[o("p",null,m(A(u)("Sent on the 1st of each month.")),1)])]),_:1},8,["label"])]),_:1})):B("",!0),n(S,{lg:6},{default:d(()=>[n(w,{label:" ","label-position":"top"},{default:d(()=>[n(T,{loading:s.value===D.key,onClick:Q=>y(D.key),class:"mt-2"},{default:d(()=>[R(m(A(u)("Send test email")),1)]),_:2},1032,["loading","onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1024),o("div",vce,[o("p",null,m(A(u)("Send time is in your store timezone. Test emails use your saved recipients.")),1)])]),_:2},1024)]),_:2},1024)),64)),o("div",gce,[n(T,{type:"primary",onClick:b[3]||(b[3]=D=>g()),loading:a.value},{default:d(()=>[R(m(A(u)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},bce={};function wce(e,t){const a=C("router-view");return r(),h("div",null,[n(a)])}const Cce=st(bce,[["render",wce]]),kce={},Bce={class:"fct-setting-form-row"},xce={class:"w-[300px]"},Sce={class:"flex-grow flex-shrink flex-basis-0 self-center"},Fce={class:"fct-setting-form-row"},$ce={class:"w-[300px]"},Ece={class:"flex-grow flex-shrink flex-basis-0 self-center"},Uce={class:"fct-setting-form-row"},Ice={class:"w-[300px]"},Qce={class:"flex-grow flex-shrink flex-basis-0 self-center"};function Dce(e,t){const a=C("el-skeleton-item"),l=C("el-skeleton");return r(),h("div",null,[o("div",Bce,[o("div",xce,[n(l,{animated:"",class:"max-w-[70%]"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-[80%]"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"}),n(a,{variant:"p",class:"w-1/2 h-4"})]),_:1})]),o("div",Sce,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",Fce,[o("div",$ce,[n(l,{animated:"",class:"max-w-[60%]"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-full"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})]),o("div",Ece,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",Uce,[o("div",Ice,[n(l,{animated:"",class:"max-w-[50%]"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-full"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})]),o("div",Qce,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])])])}const Vce=st(kce,[["render",Dce]]),Tce={name:"TaxConfigurations",components:{TaxConfigurationsLoader:Vce,CardContainer:ke,CardBody:Ce,CardHeader:Ie,LabelHint:Aa,SettingsHeader:Ua,AdminNotice:Ia,Animation:_a},data(){return{settings:{enable_tax:"no",tax_inclusion:"included",tax_calculation_basis:"shipping",tax_rounding:"item",checkout_tax_breakdown_display:"itemized",tax_display_label:"Tax",price_suffix_included:"",price_suffix_excluded:"",eu_vat_settings:{require_vat_number:"no",local_reverse_charge:"yes",reverse_charge_price_mode:"fixed",vat_reverse_excluded_categories:[]}},tax_settings_changed:!1,saving:!1,loading:!1,categories:[],fetchingCategories:!1,keyboardShortcuts:null}},computed:{handlePriceMode(){return this.settings.eu_vat_settings.local_reverse_charge=="yes"}},mounted(){this.bindSaveShortcut(),this.getSettings(),this.fetchCategories()},beforeUnmount(){this.unbindSaveShortcut()},methods:{translate:u,saveSettings(){this.saving||this.loading||(this.saving=!0,this.$post("tax/configuration/settings",{settings:this.settings}).then(e=>{this.handleSuccess(e.message),this.tax_settings_changed=!0,je.mergeConfig({is_tax_enabled:this.settings.enable_tax==="yes"})}).catch(e=>{var t;this.handleError((t=e==null?void 0:e.data)==null?void 0:t.message),this.saving=!1}).finally(()=>{this.saving=!1}))},getSettings(){this.loading=!0,this.$get("tax/configuration/settings").then(e=>{if(this.settings=e.settings,this.settings.eu_vat_settings={require_vat_number:"no",local_reverse_charge:"yes",reverse_charge_price_mode:"fixed",vat_reverse_excluded_categories:[],...this.settings.eu_vat_settings||{}},["itemized","simplified"].includes(this.settings.checkout_tax_breakdown_display)||(this.settings.checkout_tax_breakdown_display="itemized"),this.settings.tax_display_label||(this.settings.tax_display_label="Tax"),!Array.isArray(this.settings.eu_vat_settings.vat_reverse_excluded_categories))this.settings.eu_vat_settings.vat_reverse_excluded_categories=[];else{let t=this.settings.eu_vat_settings.vat_reverse_excluded_categories.map(a=>a.toString());this.settings.eu_vat_settings.vat_reverse_excluded_categories=t}}).catch(e=>{var t;this.handleError((t=e==null?void 0:e.data)==null?void 0:t.message)}).finally(()=>{this.loading=!1})},fetchCategories(){this.categories.length>0||(this.fetchingCategories=!0,this.$get("products/fetch-term").then(e=>{this.categories=e.taxonomies["product-categories"].terms||[]}).catch(()=>{}).finally(()=>{this.fetchingCategories=!1}))},bindSaveShortcut(){this.keyboardShortcuts=_s(),this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.saveSettings()})},unbindSaveShortcut(){var e;(e=this.keyboardShortcuts)!=null&&e.unbind&&this.keyboardShortcuts.unbind("mod+s")}}},Mce={class:"setting-wrap"},Lce={class:"setting-wrap-inner"},Rce={class:"fct-setting-form-row"},Oce={class:"fct-setting-form-content flex gap-3.5 flex-1"},Hce={class:"fct-inline-tip"},Pce={key:1},Nce={class:"fct-setting-form-row"},Kce={class:"fct-setting-form-content"},Gce={class:"fct-inline-tip"},jce={class:"fct-setting-form-fields self-center"},zce={class:"fct-inline-tip mt-2"},qce={class:"fct-setting-form-row"},Yce={class:"fct-setting-form-content"},Wce={class:"fct-inline-tip"},Jce={class:"fct-setting-form-fields self-center"},Xce={class:"flex flex-col"},Zce={class:"price-mode-label"},eAe={class:"price-mode-text"},tAe={class:"flex flex-col"},aAe={class:"price-mode-label"},lAe={class:"price-mode-text"},sAe={class:"fct-setting-form-row"},nAe={class:"fct-setting-form-content"},oAe={class:"fct-inline-tip"},iAe={class:"fct-setting-form-fields self-center"},rAe={class:"fct-setting-form-row"},dAe={class:"fct-setting-form-content"},uAe={class:"fct-inline-tip"},cAe={class:"fct-setting-form-fields self-center"},AAe={class:"fct-setting-form-row"},pAe={class:"fct-setting-form-content"},fAe={class:"fct-inline-tip"},mAe={class:"fct-setting-form-fields self-center"},hAe={class:"fct-setting-form-row"},_Ae={class:"fct-setting-form-content"},vAe={class:"fct-inline-tip"},gAe={class:"fct-setting-form-fields self-center"},yAe={key:0,class:"fct-setting-form-row"},bAe={class:"fct-setting-form-content"},wAe={class:"fct-inline-tip"},CAe={class:"fct-setting-form-fields self-center"},kAe={class:"fct-setting-form-row"},BAe={class:"fct-setting-form-content"},xAe={class:"fct-inline-tip"},SAe={class:"fct-setting-form-fields"},FAe={class:"fct-vat-charge-setting-wrap grid gap-5 w-full"},$Ae={class:"fct-local-reverse-charge flex gap-2 justify-items-start"},EAe={class:"fct-inline-tip"},UAe={class:"fct-vat-excluded-categories"},IAe={class:"fct-inline-tip"};function QAe(e,t,a,l,s,i){const c=C("SettingsHeader"),p=C("AdminNotice"),f=C("el-switch"),_=C("LabelHint"),g=C("TaxConfigurationsLoader"),y=C("el-radio"),v=C("el-radio-group"),b=C("el-option"),k=C("el-select"),w=C("el-input"),S=C("Animation"),$=C("CardBody"),I=C("CardContainer"),F=Ta("loading");return r(),h("div",Mce,[n(c,{heading:i.translate("Tax Configuration"),loading:s.saving,"show-cmnd-icon":!0,onOnSave:i.saveSettings},null,8,["heading","loading","onOnSave"]),o("div",Lce,[n(p),n(I,null,{default:d(()=>[n($,null,{default:d(()=>[o("div",Rce,[o("div",Oce,[n(f,{modelValue:s.settings.enable_tax,"onUpdate:modelValue":t[0]||(t[0]=x=>s.settings.enable_tax=x),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Enable Tax")},null,8,["title"]),o("p",Hce,m(s.settings.enable_tax==="yes"?i.translate("This store is now collecting tax."):i.translate("This store is not collecting tax.")),1)])])]),n(S,{visible:s.settings.enable_tax==="yes",accordion:""},{default:d(()=>[s.loading?(r(),E(g,{key:0})):B("",!0),s.loading?B("",!0):(r(),h("div",Pce,[o("div",Nce,[o("div",Kce,[n(_,{title:i.translate("Prices entered with tax")},null,8,["title"]),o("p",Gce,m(i.translate("Choose whether product prices are entered including or excluding tax.")),1)]),o("div",jce,[n(v,{modelValue:s.settings.tax_inclusion,"onUpdate:modelValue":t[1]||(t[1]=x=>s.settings.tax_inclusion=x)},{default:d(()=>[n(y,{value:"included"},{default:d(()=>[R(m(i.translate("Included")),1)]),_:1}),n(y,{value:"excluded"},{default:d(()=>[R(m(i.translate("Excluded")),1)]),_:1})]),_:1},8,["modelValue"]),o("p",zce,m(i.translate("Shipping tax always follows the store-level tax mode (Included or Excluded). Product-specific tax settings do not apply to shipping.")),1)])]),o("div",qce,[o("div",Yce,[n(_,{title:i.translate("Tax-Inclusive Price Mode")},null,8,["title"]),o("p",Wce,m(i.translate("Controls how reverse charge affects tax-inclusive product prices.")),1)]),o("div",Jce,[n(v,{modelValue:s.settings.eu_vat_settings.reverse_charge_price_mode,"onUpdate:modelValue":t[2]||(t[2]=x=>s.settings.eu_vat_settings.reverse_charge_price_mode=x),class:"fct-reverse-charge-price-mode"},{default:d(()=>[n(y,{value:"fixed"},{default:d(()=>[o("div",Xce,[o("span",Zce,m(i.translate("Fixed")),1),o("span",eAe,m(i.translate("Listed price stays unchanged on reverse charge. Only the tax line is zeroed on the invoice.")),1)])]),_:1}),n(y,{value:"dynamic"},{default:d(()=>[o("div",tAe,[o("span",aAe,m(i.translate("Dynamic")),1),o("span",lAe,m(i.translate("VAT is stripped from the price on reverse charge. Customer pays the net (ex-VAT) amount.")),1)])]),_:1})]),_:1},8,["modelValue"])])]),o("div",sAe,[o("div",nAe,[n(_,{title:i.translate("Calculate Tax Based On")},null,8,["title"]),o("p",oAe,m(i.translate("Determine the location used for tax calculations.")),1)]),o("div",iAe,[n(k,{modelValue:s.settings.tax_calculation_basis,"onUpdate:modelValue":t[3]||(t[3]=x=>s.settings.tax_calculation_basis=x),clearable:""},{default:d(()=>[n(b,{value:"shipping",label:i.translate("Customer Shipping Address")},null,8,["label"]),n(b,{value:"billing",label:i.translate("Customer Billing Address")},null,8,["label"]),n(b,{value:"store",label:i.translate("Store Location")},null,8,["label"])]),_:1},8,["modelValue"])])]),o("div",rAe,[o("div",dAe,[n(_,{title:i.translate("Price Suffix (Tax Included)")},null,8,["title"]),o("p",uAe,m(i.translate("Shown on prices where tax is included. Applies when product or store pricing is tax-inclusive.")),1)]),o("div",cAe,[n(w,{modelValue:s.settings.price_suffix_included,"onUpdate:modelValue":t[4]||(t[4]=x=>s.settings.price_suffix_included=x),placeholder:i.translate("e.g. (incl. tax)")},null,8,["modelValue","placeholder"])])]),o("div",AAe,[o("div",pAe,[n(_,{title:i.translate("Price Suffix (Tax Excluded)")},null,8,["title"]),o("p",fAe,m(i.translate("Shown on prices where tax is excluded. Applies when product or store pricing is tax-exclusive.")),1)]),o("div",mAe,[n(w,{modelValue:s.settings.price_suffix_excluded,"onUpdate:modelValue":t[5]||(t[5]=x=>s.settings.price_suffix_excluded=x),placeholder:i.translate("e.g. (+ tax)")},null,8,["modelValue","placeholder"])])]),o("div",hAe,[o("div",_Ae,[n(_,{title:i.translate("Tax Display Style")},null,8,["title"]),o("p",vAe,m(i.translate("Choose how tax context appears on each checkout line item.")),1)]),o("div",gAe,[n(k,{modelValue:s.settings.checkout_tax_breakdown_display,"onUpdate:modelValue":t[6]||(t[6]=x=>s.settings.checkout_tax_breakdown_display=x)},{default:d(()=>[n(b,{value:"simplified",label:i.translate("Simplified (single line + details)")},null,8,["label"]),n(b,{value:"itemized",label:i.translate("Itemized (per-item tax + breakdown)")},null,8,["label"])]),_:1},8,["modelValue"])])]),s.settings.checkout_tax_breakdown_display==="simplified"?(r(),h("div",yAe,[o("div",bAe,[n(_,{title:i.translate("Tax Line Label")},null,8,["title"]),o("p",wAe,m(i.translate("The single-line tax label shown in Simplified mode, e.g. VAT, MwSt, GST.")),1)]),o("div",CAe,[n(w,{modelValue:s.settings.tax_display_label,"onUpdate:modelValue":t[7]||(t[7]=x=>s.settings.tax_display_label=x),placeholder:i.translate("e.g. Tax")},null,8,["modelValue","placeholder"])])])):B("",!0),o("div",kAe,[o("div",BAe,[n(_,{title:i.translate("VAT Reverse Charge Settings")},null,8,["title"]),o("p",xAe,m(i.translate("Configure reverse VAT handling for customers in the European Union.")),1)]),o("div",SAe,[o("div",FAe,[o("div",$Ae,[n(f,{modelValue:s.settings.eu_vat_settings.local_reverse_charge,"onUpdate:modelValue":t[8]||(t[8]=x=>s.settings.eu_vat_settings.local_reverse_charge=x),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Local Reverse Charge")},null,8,["title"]),o("p",EAe,m(i.translate("If enabled, apply reverse charge when applicable even when customers are in your home country.")),1)])]),n(S,{visible:i.handlePriceMode,accordion:""},{default:d(()=>[o("div",UAe,[n(_,{title:i.translate("Exclude Categories from VAT reverse")},null,8,["title"]),o("p",IAe,m(i.translate("Select product categories that should NOT get VAT reverse charge !")),1),qt((r(),E(k,{modelValue:s.settings.eu_vat_settings.vat_reverse_excluded_categories,"onUpdate:modelValue":t[9]||(t[9]=x=>s.settings.eu_vat_settings.vat_reverse_excluded_categories=x),filterable:"",multiple:"",clearable:"",placeholder:i.translate("Select Product Categories"),class:"w-full mt-4"},{default:d(()=>[(r(!0),h(H,null,ae(s.categories,x=>(r(),E(b,{key:x.value||x.term_id,label:x.label||x.name,value:x.value||x.term_id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])),[[F,s.fetchingCategories]])])]),_:1},8,["visible"])])])])]))]),_:1},8,["visible"])]),_:1})]),_:1})])])}const DAe=st(Tce,[["render",QAe]]),VAe={class:"fct-tax-rates-wrap-loader px-5"},TAe={__name:"TaxRatesLoader",setup(e){const t=M(Array.from({length:6},()=>`${Math.floor(Math.random()*21)+120}px`));return(a,l)=>{const s=C("el-skeleton-item"),i=C("el-skeleton");return r(),h("div",VAe,[(r(!0),h(H,null,ae(t.value,(c,p)=>(r(),h("div",{key:p,class:"flex items-center justify-between border-[1px] border-solid border-gray-divider dark:border-dark-400 rounded h-12 pr-4 pl-6 mb-4"},[n(i,{animated:"",style:ra({width:c}),class:"h-4"},{template:d(()=>[n(s,{variant:"p",class:"h-4"})]),_:2},1032,["style"]),n(i,{animated:"",class:"w-[100px] h-4"},{template:d(()=>[n(s,{variant:"p",class:"h-4"})]),_:1})]))),128))])}}},MAe={class:"setting-wrap"},LAe={class:"setting-wrap-inner"},RAe={class:"fct-all-tax-classes-page"},OAe={class:"flex items-center justify-end gap-4"},HAe={key:0,class:"px-6 py-4 border-b border-gray-200 dark:border-gray-700"},PAe={class:"inline-flex items-center gap-2"},NAe={class:"inline-flex items-center gap-2"},KAe=["src","alt"],GAe={key:0,class:"text-gray-400 dark:text-gray-300"},jAe={key:1,class:"text-success-500"},zAe={key:2,class:"text-system-mid dark:text-gray-300"},qAe={key:3,class:"text-gray-400 dark:text-gray-300"},YAe={key:1,class:"text-gray-400"},WAe={__name:"TaxRates",setup(e){const t=M({}),a=M([]),l=M({}),s=M({}),i=N(()=>!!je.get("is_tax_enabled")),c=M(!1),p=M({}),f={};let _=0;const g=M(""),y=M(!1),v={XI:"gb"},b=Q=>(v[Q]||Q).toLowerCase(),k=N(()=>{const Q=new Set;for(const V of a.value)for(const O of V.countries||[])Q.add(O.country_code);return Q}),w=Q=>!Q||!Object.prototype.hasOwnProperty.call(s.value,Q)?!0:s.value[Q],S=Q=>!Q||!Q.vat?!1:Q.rates&&typeof Q.rates=="object"&&Object.keys(Q.rates).length?Object.values(Q.rates).some(V=>V&&parseFloat(V.rate)>0):parseFloat(Q.rate)>0,$=N(()=>{const Q=l.value||{},V=Array.isArray(Q.country_registrations)?Q.country_registrations:[],O=Q.method||"",L=V.some(S);if(O==="oss")return!!Q.oss_country;if(O==="home"){const P=Q.home_country||"",z=V.find(X=>X.country===P);if(P&&z&&S(z))return!0}return O==="specific"?!!Q.home_country:L}),I=N(()=>{const Q=l.value||{},V=Array.isArray(Q.country_registrations)?Q.country_registrations:[],O=Q.method||"";return O==="oss"?!!Q.oss_country:O==="home"?!!Q.home_country&&V.some(L=>L.country===Q.home_country):O==="specific"?!!Q.home_country:V.some(S)}),F=N(()=>{const Q=[],V=Object.values(t.value||{});for(const P of V)if(P.group_code==="EU")Q.push({country_code:"EU",country_name:"European Union",isEU:!0,group_code:"EU",hasConfig:I.value,enabled:w("EU"),collecting:I.value&&$.value&&w("EU")});else for(const z of P.countries||[]){const X=k.value.has(z.country_code),G=w(z.country_code);Q.push({country_code:z.country_code,country_name:z.country_name,isEU:!1,group_code:P.group_code,hasConfig:X,enabled:G,collecting:X&&G})}const O=["EU","US","GB","AU","CA","NZ","IN","SG","JP"],L=new Set(O);return Q.sort((P,z)=>{if(P.hasConfig!==z.hasConfig)return P.hasConfig?-1:1;const X=L.has(P.country_code),G=L.has(z.country_code);return X&&G?O.indexOf(P.country_code)-O.indexOf(z.country_code):X?-1:G?1:P.country_name.localeCompare(z.country_name)}),Q}),x=N(()=>{const Q=g.value.trim().toLowerCase();return F.value.filter(V=>y.value&&(!i.value||!V.collecting)?!1:Q?V.country_name.toLowerCase().includes(Q)||V.country_code.toLowerCase().includes(Q):!0)}),U=N(()=>{if(!i.value)return!1;const Q=F.value.filter(O=>O.enabled).length,V=F.value.filter(O=>!O.enabled).length;return Q>0&&V>0}),T=()=>{c.value=!0,Promise.all([ce.get("tax/configuration/rates"),ce.get("tax/rates"),ce.get("tax/configuration/settings")]).then(([Q,V,O])=>{var L;t.value=Q.tax_rates,a.value=V.tax_rates,s.value=V.country_enabled_map||{},l.value=((L=O.settings)==null?void 0:L.eu_vat_settings)||{}}).catch(Q=>{}).finally(()=>{c.value=!1})},D=(Q,V)=>{const O=w(Q.country_code),L=++_;f[Q.country_code]=L,s.value={...s.value,[Q.country_code]:V},p.value={...p.value,[Q.country_code]:!0},ce.post("tax/country-status/"+Q.country_code,{enabled:V?1:0}).then(P=>{f[Q.country_code]===L&&(q.success(P.message),s.value={...s.value,[Q.country_code]:P.enabled})}).catch(P=>{var z;f[Q.country_code]===L&&(s.value={...s.value,[Q.country_code]:O},q.error(((z=P==null?void 0:P.data)==null?void 0:z.message)||u("Failed to update tax status")))}).finally(()=>{if(f[Q.country_code]===L){const P={...p.value};delete P[Q.country_code],p.value=P}})};return Ee(()=>{T()}),(Q,V)=>{const O=C("el-checkbox"),L=C("el-input"),P=C("el-table-column"),z=C("el-switch"),X=C("el-table");return r(),h("div",MAe,[n(Ua,{heading:A(u)("Tax Regions"),"show-save-button":!1},null,8,["heading"]),o("div",LAe,[n(Ia),o("div",RAe,[n(ke,{class:"overflow-hidden"},{default:d(()=>[n(Ie,{title:A(u)("Tax Regions"),text:A(u)("Manage tax rates for different regions")},{action:d(()=>[o("div",OAe,[U.value?(r(),E(O,{key:0,modelValue:y.value,"onUpdate:modelValue":V[0]||(V[0]=G=>y.value=G)},{default:d(()=>[R(m(A(u)("Collecting Tax")),1)]),_:1},8,["modelValue"])):B("",!0),n(L,{modelValue:g.value,"onUpdate:modelValue":V[1]||(V[1]=G=>g.value=G),class:"w-[200px]",placeholder:A(u)("Search regions..."),size:"small",clearable:""},{prefix:d(()=>[n(J,{name:"Search",class:"w-4 h-4"})]),_:1},8,["modelValue","placeholder"])])]),_:1},8,["title","text"]),n(Ce,{class:"px-0 pb-0"},{default:d(()=>[!c.value&&!i.value?(r(),h("div",HAe,[n(el,{type:"warning",icon:"AlertTriangle",content:A(u)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):B("",!0),c.value?(r(),E(TAe,{key:1})):(r(),E(X,{key:2,data:x.value,"max-height":"500",class:"w-full compact-table fct-tax-rates-regions-table"},{default:d(()=>[n(P,{label:A(u)("Region"),"min-width":"300"},{default:d(({row:G})=>[G.isEU?(r(),E(ka,{key:0,class:"hover:no-underline",to:{name:"eu"}},{default:d(()=>[o("div",PAe,[V[2]||(V[2]=o("img",{class:"w-[22px] block",src:"https://flagcdn.com/w40/eu.png",alt:"EU"},null,-1)),R(" "+m(G.country_name),1)])]),_:2},1024)):(r(),E(ka,{key:1,to:{name:"tax-rates-country-single",params:{country:G.country_code,group:G.group_code}},class:"fct-tax-region-link hover:no-underline"},{default:d(()=>[o("div",NAe,[o("img",{class:"w-[22px] block",src:`https://flagcdn.com/w40/${b(G.country_code)}.png`,alt:G.country_code},null,8,KAe),R(" "+m(G.country_name),1)])]),_:2},1032,["to"]))]),_:1},8,["label"]),n(P,{label:A(u)("Collecting"),width:"200"},{default:d(({row:G})=>[i.value?G.collecting?(r(),h("span",jAe,m(A(u)("Collecting tax")),1)):G.hasConfig&&!G.enabled?(r(),h("span",zAe,m(A(u)("Disabled")),1)):(r(),h("span",qAe,"—")):(r(),h("span",GAe,"—"))]),_:1},8,["label"]),n(P,{label:A(u)("Enabled"),width:"140",align:"center"},{default:d(({row:G})=>[G.hasConfig?(r(),E(z,{key:0,"model-value":i.value?G.enabled:!1,loading:!!p.value[G.country_code],disabled:!i.value,onChange:ee=>D(G,ee)},null,8,["model-value","loading","disabled","onChange"])):(r(),h("span",YAe,"—"))]),_:1},8,["label"])]),_:1},8,["data"]))]),_:1})]),_:1})])])])}}},JAe={class:"fct-base-taxes"},XAe={class:"fct-tax-class-tabs"},ZAe={class:"fct-tax-class-tabs__list"},epe={class:"fct-base-taxes__header"},tpe={class:"fct-base-taxes__header-label"},ape={class:"fct-base-taxes__state-row fct-base-taxes__state-row--federal"},lpe={class:"fct-base-taxes__region-name fct-base-taxes__region-name--federal"},spe={class:"fct-base-taxes__state-fields"},npe={class:"fct-base-taxes__region-name"},ope={class:"fct-base-taxes__state-fields"},ipe={__name:"CountryTaxRatesLoader",setup(e){const t=[1,2,3];return(a,l)=>{const s=C("el-skeleton-item"),i=C("el-skeleton");return r(),h("div",null,[o("div",JAe,[o("div",XAe,[o("div",ZAe,[(r(),h(H,null,ae(3,c=>o("div",{key:c,class:"fct-tax-class-tabs__tab"},[n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-16 h-5"})]),_:1})])),64)),n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-5 h-5"})]),_:1})])]),o("div",epe,[o("span",tpe,m(A(u)("Regions")),1)]),o("div",ape,[o("div",lpe,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-40 h-5"})]),_:1})]),o("div",spe,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),l[0]||(l[0]=o("div",{class:"fct-base-taxes__field-compound"},null,-1))])]),l[1]||(l[1]=o("div",{class:"fct-base-taxes__divider"},null,-1)),(r(),h(H,null,ae(t,c=>o("div",{key:c,class:"fct-base-taxes__state-row"},[o("div",npe,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-32 h-4"})]),_:1})]),o("div",ope,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-compound h-8"})]),_:1})])])),64))])])}}},rpe={class:"fct-tax-class-tabs"},dpe={class:"fct-tax-class-tabs__list"},upe=["onClick"],cpe=["title","onClick"],Ape=["disabled","title"],ppe=["disabled","title"],fpe=["disabled"],mpe=["disabled","title"],hpe={class:"fct-tax-class-tabs__search"},of={__name:"TaxClassTabs",props:{classes:{type:Array,default:()=>[]},activeId:{type:[Number,String],default:null},maxClasses:{type:Number,default:6},creating:{type:Boolean,default:!1},search:{type:String,default:""}},emits:["switch","delete","add","create-custom","update:search"],setup(e,{emit:t}){const a=e,l=t,s=M(!1),i=M(""),c=M(null),p=M(!1),f=N(()=>[...a.classes].sort((w,S)=>w.slug==="standard"&&S.slug!=="standard"?-1:w.slug!=="standard"&&S.slug==="standard"?1:0)),_=N(()=>["reduced","zero"].filter(w=>!a.classes.find(S=>S.slug===w))),g=()=>{i.value="",p.value=!1,s.value=!0,Be(()=>{var w;return(w=c.value)==null?void 0:w.focus()})},y=w=>{if(w==="custom"){g();return}l("add",w)},v=()=>{const w=i.value.trim();if(!w){b();return}l("create-custom",w)},b=()=>{s.value=!1,i.value="",p.value=!1},k=()=>{!a.creating&&!i.value.trim()&&b()};return ye([()=>a.classes.length,()=>a.creating],([w,S],[$,I])=>{if(s.value){if(w>$){b();return}I&&!S&&(p.value=!0)}}),ye(i,()=>{p.value=!1}),(w,S)=>{const $=C("el-input"),I=C("el-dropdown-item"),F=C("el-dropdown-menu"),x=C("el-dropdown");return r(),h("div",rpe,[o("div",dpe,[(r(!0),h(H,null,ae(f.value,U=>(r(),h("button",{key:U.id,class:de(["fct-tax-class-tabs__tab",{"fct-tax-class-tabs__tab--active":e.activeId==U.id}]),onClick:T=>l("switch",U)},[R(m(U.title)+" ",1),U.slug!=="standard"?(r(),h("span",{key:0,class:"fct-tax-class-tabs__delete",title:A(u)("Delete tax class"),onClick:Pe(T=>l("delete",U),["stop"])},[n(J,{name:"Close"})],8,cpe)):B("",!0)],10,upe))),128)),e.classes.length
i.value=U),size:"small",maxlength:"30",disabled:e.creating,placeholder:A(u)("e.g. Luxury"),onKeyup:[Ba(v,["enter"]),Ba(b,["esc"])],onBlur:k},null,8,["modelValue","disabled","placeholder"]),o("button",{class:"fct-tax-class-tabs__inline-confirm",disabled:e.creating||!i.value.trim(),title:A(u)("Create tax class"),onMousedown:S[1]||(S[1]=Pe(()=>{},["prevent"])),onClick:v},[n(J,{name:"Check"})],40,Ape),o("button",{class:"fct-tax-class-tabs__inline-cancel",disabled:e.creating,title:A(u)("Cancel"),onMousedown:S[2]||(S[2]=Pe(()=>{},["prevent"])),onClick:b},[n(J,{name:"Close"})],40,ppe)],2)):_.value.length?(r(),E(x,{key:1,trigger:"click",disabled:e.creating,onCommand:y,"popper-class":"fct-dropdown"},{dropdown:d(()=>[n(F,null,{default:d(()=>[_.value.includes("reduced")?(r(),E(I,{key:0,command:"reduced"},{default:d(()=>[R(m(A(u)("Reduced")),1)]),_:1})):B("",!0),_.value.includes("zero")?(r(),E(I,{key:1,command:"zero"},{default:d(()=>[R(m(A(u)("Zero")),1)]),_:1})):B("",!0),n(I,{command:"custom"},{default:d(()=>[R(m(A(u)("Custom Class...")),1)]),_:1})]),_:1})]),default:d(()=>[o("button",{class:"fct-tax-class-tabs__add",disabled:e.creating},[n(J,{name:"Plus"})],8,fpe)]),_:1},8,["disabled"])):(r(),h("button",{key:2,class:"fct-tax-class-tabs__add",disabled:e.creating,title:A(u)("Add custom tax class"),onClick:g},[n(J,{name:"Plus"})],8,mpe))],64)):B("",!0)]),o("div",hpe,[n($,{"model-value":e.search,placeholder:A(u)("Search country or region…"),size:"small",clearable:"","onUpdate:modelValue":S[3]||(S[3]=U=>l("update:search",U)),onClear:S[4]||(S[4]=U=>l("update:search",""))},{prefix:d(()=>[n(J,{name:"Search",class:"w-3.5 h-3.5 text-system-light dark:text-gray-400"})]),_:1},8,["model-value","placeholder"]),ba(w.$slots,"search-actions")])])}}},_pe=(e=[])=>e.find(t=>t.slug==="standard")||e[0]||null,Id=({classes:e=[],activeId:t=null})=>(t?e.find(l=>l.id===t):null)||_pe(e),vpe=({classes:e=[],previousIds:t=new Set,createdSlug:a=null})=>{if(a){const l=e.find(s=>s.slug===a);if(l)return l}return e.find(l=>!t.has(l.id))||null},zo=async({payload:e,createdSlug:t=null,currentClasses:a=[],reloadClasses:l})=>{const s=new Set((a||[]).map(p=>p.id)),i=await ce.post("tax/classes",e),c=await l();return{response:i,classes:c,createdClass:vpe({classes:c,previousIds:s,createdSlug:t})}},rf=async({classId:e,currentActiveId:t=null,reloadClasses:a})=>{const l=await ce.delete("tax/classes/"+e),s=await a();return{response:l,classes:s,nextActiveClass:Id({classes:s,activeId:t})}};function en(e){return e==null||e===""?"":String(e)}const gpe={class:"setting-wrap"},ype={class:"setting-wrap-inner"},bpe={class:"fct-single-tax-rates-country-single-page"},wpe={class:"fct-single-tax-rates-country-single"},Cpe={class:"single-page-header flex items-center justify-between"},kpe={key:0,class:"flex items-center gap-2"},Bpe={key:0,class:"notices fct-notices-wrap fct-layout-width settings"},xpe={class:"mt-3 flex justify-end"},Spe={key:1,class:"fct-base-taxes"},Fpe={class:"fct-btn-group mt-4 justify-end sm"},$pe={class:"fct-tax-rates-country-view"},Epe={key:0},Upe={key:1},Ipe={key:0},Qpe={key:1},Dpe={class:"fct-btn-group sm justify-end"},hc={__name:"TaxRatesCountrySingle",props:{country:{type:String},group:{type:String}},setup(e){const t=e,a=M(!1),l=M([]),s=M(""),i=N(()=>!!je.get("is_tax_enabled")),c=M([]),p=M(null),f=M("standard"),_=M(!1),g=M(null),y=M(6),v=M({id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0}),b=M({rate:0,name:""}),k=M([]),w=M({}),S=M(""),$=N(()=>{const Z=S.value.trim().toLowerCase();return Z?k.value.filter(we=>we.stateName&&we.stateName.toLowerCase().includes(Z)):k.value}),I=N(()=>t.group==="EU"),F=N(()=>[v.value,...$.value]),x=M([]),U=M(!1),T=M([]),D=M([]),Q=M(!1),V=M(new Set),O=M(0),L=M([]),P=M(!1),z=M(!1),X=M(!1),G=M({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:""}),ee=N(()=>{const Z=v.value.rate||0;return[{label:u("added to")+` ${Z}% `+u("federal tax"),is_compound:"0",for_order:0},{label:u("instead of")+` ${Z}% `+u("federal tax"),is_compound:"0",for_order:1},{label:u("compounded on top of")+` ${Z}% `+u("federal tax"),is_compound:"1",for_order:0}]}),oe=Z=>String(Z.is_compound)==="1"?"1_0":Z.for_order==1?"0_1":"0_0",re=(Z,we)=>{const[se,fe]=we.split("_");Z.is_compound=se,Z.for_order=parseInt(fe)},K=Z=>Z&&Z.replace(/\s*\(Standard\)\s*/gi,"").trim(),Y=M(!1),W=M({}),j=M(!1),ie=M(""),_e=M(""),me=M(""),ue=M(!1),le=M(!1),be=M(!0),Qe=M(!1),Ke=M(!1),ge=M(!1),tt=N(()=>u("Toggle tax collection for %1$s",s.value||t.country)),yt=()=>ce.get("tax/classes").then(Z=>{c.value=Z.classes||[],y.value=Z.max_classes||6,g.value=Z.next_builtin||null;const we=Id({classes:c.value,activeId:p.value});return we&&(p.value=we.id,f.value=we.slug),c.value}).catch(Z=>c.value),Je=(Z="")=>{if(!Z)return v.value.name||"Tax";const we=k.value.find(se=>se.state===Z);return we!=null&&we.name?we.name:v.value.name||"Tax"},xe=Z=>{v.value={...Z.federalRate},b.value={...Z.federalOriginal},k.value=Z.stateRows.map(we=>({...we})),w.value={...Z.stateOriginals}},Fe=()=>({federalRate:{...v.value},federalOriginal:{...b.value},stateRows:k.value.map(Z=>({...Z})),stateOriginals:{...w.value}}),Oe=()=>{p.value&&(W.value[p.value]=Fe())},Me=async Z=>{Oe(),p.value=Z.id,f.value=Z.slug,W.value[Z.id]?(xe(W.value[Z.id]),await mt()):await jt()},gt=Z=>{_.value=!0,zo({payload:{slug:Z},createdSlug:Z,currentClasses:c.value,reloadClasses:yt}).then(({response:we,createdClass:se})=>{if(q.success(we.message),se)return Me(se)}).catch(we=>{var se;q.error(((se=we==null?void 0:we.data)==null?void 0:se.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},vt=Z=>{_.value=!0,zo({payload:{title:Z},currentClasses:c.value,reloadClasses:yt}).then(({response:we,createdClass:se})=>{if(q.success(we.message),se)return Me(se)}).catch(we=>{var se;q.error(((se=we==null?void 0:we.data)==null?void 0:se.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},Lt=Z=>{const we=p.value===Z.id;ul(u("All rates for this class will be deleted. Products using it will default to Standard."),u("Delete")+" "+Z.title+"?",{confirmButtonText:u("Yes, Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{rf({classId:Z.id,currentActiveId:p.value,reloadClasses:yt}).then(({response:se,nextActiveClass:fe})=>{if(delete W.value[Z.id],q.success(se.message),fe)return we&&(p.value=null),Me(fe)}).catch(se=>{var fe;q.error(((fe=se==null?void 0:se.data)==null?void 0:fe.message)||"Failed to delete tax class")})}).catch(()=>{})},Vt=()=>ce.get("address-info/get-country-info",{country_code:t.country}).then(Z=>{l.value=Z.states||[],s.value=Z.country_name||t.country}).catch(Z=>{q.error(u("Failed to load country data. Please refresh the page."))}),Qt=()=>I.value?(_e.value="",me.value="",Promise.resolve()):(ue.value=!0,ce.get("tax/country-tax-id/"+t.country).then(Z=>{var se;const we=((se=Z==null?void 0:Z.tax_data)==null?void 0:se.tax_id)||"";_e.value=we,me.value=we}).catch(Z=>{var we;q.error(((we=Z==null?void 0:Z.data)==null?void 0:we.message)||u("Failed to load tax ID"))}).finally(()=>{ue.value=!1})),ht=({hydrateClassData:Z=!0}={})=>ce.get("tax/rates/country/rates/"+t.country).then(we=>{const se=we.tax_rates||[],fe=se.filter(Ge=>Ge.for_shipping!==null),qe=p.value?se.filter(Ge=>Number(Ge.class_id)===Number(p.value)):se;T.value=qe.filter(Ge=>!Ge.city&&!Ge.postcode).map(Ge=>({name:Ge.name,value:Ge.id,state:Ge.state||""}));const at=It(qe);return ge.value=se.length>0,Z&&(xe(at),Oe(),be.value=!!we.tax_enabled,Ke.value=!0),{allRates:se,shippingOverrides:fe,classEntry:at}}).catch(we=>(q.error(u("Failed to load tax rates. Please refresh the page.")),{allRates:[],shippingOverrides:[],classEntry:null})),Kt=()=>ce.get("tax/product-overrides/"+t.country).then(Z=>Z.overrides||[]).catch(()=>[]),bt=()=>{L.value.length>0||(P.value=!0,ce.get("products/fetch-term").then(Z=>{const we=Z.taxonomies&&Z.taxonomies["product-categories"]?Z.taxonomies["product-categories"].terms||[]:[];L.value=we.map(se=>({...se,value:en(se.value)}))}).catch(()=>{}).finally(()=>{P.value=!1}))};let St=0;const Ot=Z=>{const we=++St;return!Z||Number(Z)===Number(p.value)?(D.value=T.value.slice(),Q.value=!1,Promise.resolve()):(Q.value=!0,D.value=[],ce.get("tax/rates/country/rates/"+t.country,{class_id:Z}).then(se=>{if(we!==St)return;const fe=se.tax_rates||[];D.value=fe.filter(qe=>!qe.city&&!qe.postcode).map(qe=>({name:qe.name,value:qe.id,state:qe.state||""}))}).catch(()=>{we===St&&(D.value=[],q.error(u("Failed to load tax rates for the selected tax class")))}).finally(()=>{we===St&&(Q.value=!1)}))},Ht=(Z,we)=>{var fe,qe;const se=[];for(const at of Z){const Ge=at.state?((fe=l.value.find(Ze=>Ze.value===at.state))==null?void 0:fe.name)||at.state:s.value||t.country,We=Je(at.state||""),ft=c.value.find(Ze=>Number(Ze.id)===Number(at.class_id));se.push({id:at.id,type:"shipping",label:We,tax_label:We,category_name:"",location:Ge,city:at.city||"",postcode:at.postcode||"",rate:at.for_shipping,class_id:Number(at.class_id)||0,class_label:ft?ft.title:"",_raw:at})}for(const at of we){const Ge=at.meta_value||at,We=Ge.state||"",ft=We?((qe=l.value.find(Ae=>Ae.value===We))==null?void 0:qe.name)||We:s.value||t.country,Ze=Number(at.class_id)||0,Ut=Ze?c.value.find(Ae=>Number(Ae.id)===Ze):null;se.push({id:at.id,type:"products",label:Ge.category_name||"",tax_label:Ge.tax_label||"",category_name:Ge.category_name||"",location:ft,city:Ge.city||"",postcode:Ge.postcode||"",rate:Ge.rate,class_id:Ze,class_label:Ut?Ut.title:"",_raw:at})}x.value=se},It=Z=>{const we=Ze=>(!Ze.state||Ze.state==="")&&(!Ze.city||Ze.city==="")&&(!Ze.postcode||Ze.postcode===""),se=Z.find(we),fe=Z.filter(Ze=>Ze.state&&Ze.state!==""&&(!Ze.city||Ze.city==="")&&(!Ze.postcode||Ze.postcode===""));let qe,at;if(se){const Ze=K(se.name)||"Tax";qe={...se,name:Ze},at={rate:se.rate,name:Ze}}else qe={id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0},at={rate:0,name:"Tax"};const Ge={};for(const Ze of fe)Ge[Ze.state]=Ze;const We=[],ft={};for(const Ze of l.value){const Ut=Ge[Ze.value];if(Ut){const Ae=K(Ut.name)||"State Tax";We.push({id:Ut.id,state:Ze.value,stateName:Ze.name,rate:Ut.rate,name:Ae,is_compound:String(Ut.is_compound||"0"),for_order:Ut.for_order||0}),ft[Ze.value]={rate:Ut.rate,name:Ae,is_compound:String(Ut.is_compound||"0"),for_order:Ut.for_order||0}}else We.push({id:null,state:Ze.value,stateName:Ze.name,rate:0,name:"State Tax",is_compound:"0",for_order:0}),ft[Ze.value]={rate:0,name:"State Tax",is_compound:"0",for_order:0}}return{federalRate:qe,federalOriginal:at,stateRows:We,stateOriginals:ft}},mt=async()=>{const[{shippingOverrides:Z},we]=await Promise.all([ht({hydrateClassData:!1}),Kt()]);Ht(Z,we)},jt=async()=>{a.value=!0;try{const[{shippingOverrides:Z},we]=await Promise.all([ht(),Kt()]);Ht(Z,we)}finally{a.value=!1}},ve=async()=>{a.value=!0;try{await Promise.all([yt(),Vt(),Qt()]),await jt()}finally{a.value=!1}},Se=()=>{I.value||le.value||ue.value||(le.value=!0,ce.post("tax/country-tax-id/"+t.country,{tax_id:_e.value||""}).then(Z=>{me.value=_e.value||"",q.success(Z.message||u("Tax ID has been saved successfully"))}).catch(Z=>{var we;q.error(((we=Z==null?void 0:Z.data)==null?void 0:we.message)||u("Failed to save tax ID"))}).finally(()=>{le.value=!1}))},nt=Z=>{if(Qe.value)return;const we=be.value;be.value=Z,Qe.value=!0,ce.post("tax/country-status/"+t.country,{enabled:Z?1:0}).then(se=>{be.value=se.enabled,q.success(se.message)}).catch(se=>{var fe;be.value=we,q.error(((fe=se==null?void 0:se.data)==null?void 0:fe.message)||u("Failed to update tax status"))}).finally(()=>{Qe.value=!1})},wt=async()=>{try{await ul(u("This will overwrite your current rates with preset defaults. Continue?"),u("Reset to default tax rates"),{confirmButtonText:u("Reset"),cancelButtonText:u("Cancel"),type:"warning"})}catch{return}j.value=!0;try{const we=(await ce.get("tax/configuration/rates")).tax_rates||{};let se=[];for(const We in we){const ft=we[We];for(const Ze of ft.countries||[])if(Ze.country_code===t.country){se=Ze.rates||[];break}if(se.length)break}if(!se.length){q.error(u("No preset rates found for this country"));return}const fe=se.find(We=>(!We.state||We.state==="")&&We.type==="standard"),qe=se.filter(We=>We.state&&We.state!==""&&We.type==="standard"),at=[];fe&&fe.rate>0&&(v.value.rate=fe.rate,v.value.name=K(fe.name||"")||u("Tax"),at.push(kt()));const Ge=[];for(const We of qe){const ft=k.value.find(Ze=>Ze.state===We.state);ft&&(ft.rate=We.rate,ft.name=K(We.name)||u("State Tax"),ft.is_compound=We.compound?"1":"0",Ge.push(Jt(ft)))}await Promise.all([...at,...Ge]),Oe(),await mt(),q.success(u("Tax rates have been reset to defaults"))}catch{q.error(u("Failed to reset tax rates"))}finally{j.value=!1}},kt=()=>{const Z={country:t.country,state:"",rate:v.value.rate,name:v.value.name||"Tax",is_compound:v.value.is_compound||"0",for_order:v.value.for_order||0,group:t.group,class_id:p.value||""};return(v.value.id?ce.put("tax/country/rate/"+v.value.id,Z):ce.post("tax/country/rate",Z)).then(se=>{se.tax_rate&&(v.value.id=se.tax_rate.id),b.value={rate:v.value.rate,name:v.value.name}})},Jt=Z=>{const we={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:p.value||""};return(Z.id?ce.put("tax/country/rate/"+Z.id,we):ce.post("tax/country/rate",we)).then(fe=>{fe.tax_rate&&(Z.id=fe.tax_rate.id),w.value[Z.state]={rate:Z.rate,name:Z.name,is_compound:String(Z.is_compound),for_order:Z.for_order}})},_t=async()=>{Y.value=!0;try{const Z=[];(String(v.value.rate)!==String(b.value.rate)||v.value.name!==b.value.name)&&Z.push(kt());for(const se of k.value){const fe=w.value[se.state];(!fe||String(se.rate)!==String(fe.rate)||se.name!==fe.name||String(se.is_compound)!==String(fe.is_compound)||se.for_order!=fe.for_order)&&Z.push(Jt(se))}await Promise.all(Z),Oe(),await mt(),q.success(u("Tax rates saved"))}catch{q.error(u("Failed to save rates"))}finally{Y.value=!1}},Xt=()=>{V.value=new Set,O.value=0},Zt=()=>{const Z=Je();X.value=!1,G.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(p.value)||0,id:"",previous_id:""},ie.value=Z,D.value=T.value.slice(),U.value=!0,bt()},Gt=Z=>{if(X.value=!0,bt(),Z.type==="shipping"){const we=Z._raw.state||"",se=Je(we),fe=Number(Z._raw.class_id)||Number(p.value)||0;G.value={type:"shipping",original_type:"shipping",original_id:Z.id,category_id:"",category_name:"",state:we||"__country__",city:Z._raw.city||"",postcode:Z._raw.postcode||"",tax_label:se,tax_rate:Z.rate,override_state_tax:!0,class_id:fe,id:Z.id,previous_id:Z.id},ie.value=se,O.value=fe,Ot(fe);const qe=Z._raw.city||"",at=Z._raw.postcode||"",Ge=new Set;for(const We of x.value)We.type==="shipping"&&(We._raw.state||"")===we&&(We._raw.city||"")===qe&&(We._raw.postcode||"")===at&&Ge.add(Number(We.class_id));V.value=Ge}else{const we=Z._raw.meta_value||Z._raw,se=we.state||"",fe=Je(se),qe=Z.tax_label||fe;G.value={type:"products",original_type:"products",original_id:Z.id,category_id:en(we.category_id),category_name:Z.category_name,state:se||"__country__",tax_label:qe,tax_rate:Z.rate,override_state_tax:we.override_state_tax==="yes",city:we.city||"",postcode:we.postcode||"",class_id:Z.class_id||0,id:Z.id,previous_id:""},ie.value=fe}U.value=!0},ga=N(()=>{const Z=[{label:s.value||t.country,value:"__country__"}];for(const we of l.value)Z.push({label:we.name,value:we.value});return Z}),qa=N(()=>{if(!D.value.length)return ga.value;const Z=new Set(D.value.map(we=>we.state||""));return ga.value.filter(we=>{const se=we.value==="__country__"?"":we.value;return Z.has(se)})}),il=Z=>{const we=en(Z),se=L.value.find(fe=>fe.value===we);se&&(G.value.category_name=se.label)},Ya=Z=>{ul(u("Are you sure you want to delete this override?"),u("Confirm Delete"),{confirmButtonText:u("Yes, Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{const we=Z.type==="shipping"?"tax/rates/country/override/"+Z.id:"tax/product-overrides/"+Z.id;ce.delete(we).then(se=>{q.success(se.message),x.value=x.value.filter(fe=>!(fe.id===Z.id&&fe.type===Z.type))}).catch(se=>{var fe;q.error(((fe=se==null?void 0:se.data)==null?void 0:fe.message)||u("Failed to delete override"))})}).catch(()=>{})},fa=async()=>{var we;const Z=G.value.state==="__country__"?"":G.value.state;if(G.value.type==="products"&&!G.value.category_id){q.error(u("Please select a category"));return}if(G.value.type==="shipping"){if(!G.value.class_id){q.error(u("Please select a tax class"));return}if(Q.value){q.error(u("Please wait for the province rates to finish loading"));return}const se=D.value.find(fe=>(fe.state||"")===Z);G.value.id=se?se.value:0}z.value=!0;try{let se;if(G.value.type==="products"){const fe=G.value.state==="__country__"?"":G.value.state;se=await ce.post("tax/product-overrides",{id:X.value&&G.value.original_type==="products"?G.value.original_id:"",source_type:G.value.original_type,source_id:G.value.original_id,country:t.country,state:fe,category_id:G.value.category_id,category_name:G.value.category_name,tax_label:G.value.tax_label,rate:G.value.tax_rate,override_state_tax:G.value.override_state_tax===!0?"yes":"no",city:G.value.city||"",postcode:G.value.postcode||"",class_id:G.value.class_id||0})}else se=await ce.post("tax/rates/country/override",{id:G.value.id,country:t.country,state:Z,previous_id:X.value&&G.value.original_type==="shipping"?G.value.previous_id:"",source_type:G.value.original_type,source_id:G.value.original_id,class_id:G.value.class_id||p.value||"",override_tax_rate:G.value.tax_rate,city:G.value.city||"",postcode:G.value.postcode||""});q.success(se.message),U.value=!1,await mt()}catch(se){const fe=((we=se==null?void 0:se.data)==null?void 0:we.message)||(se==null?void 0:se.message)||"Failed to save override";q.error(fe)}finally{z.value=!1}};return ye(()=>G.value.type,Z=>{Z==="shipping"&&(G.value.class_id||(G.value.class_id=p.value||0),Ot(G.value.class_id))}),ye(()=>G.value.class_id,Z=>{G.value.type!=="shipping"||!U.value||Ot(Z).then(()=>{const we=G.value.state==="__country__"?"":G.value.state,se=D.value.map(fe=>fe.state||"");we!==""&&!se.includes(we)&&(G.value.state="__country__")})}),ye(()=>G.value.state,Z=>{if(!U.value||G.value.type!=="products"||X.value)return;const we=Je(Z==="__country__"?"":Z);(!G.value.tax_label||G.value.tax_label===ie.value)&&(G.value.tax_label=we),ie.value=we}),Ee(()=>{ve()}),(Z,we)=>{const se=C("el-breadcrumb-item"),fe=C("el-breadcrumb"),qe=C("el-switch"),at=C("el-skeleton"),Ge=C("el-input"),We=C("el-form-item"),ft=C("el-form"),Ze=C("el-button"),Ut=C("el-table-column"),Ae=C("el-option"),he=C("el-select"),Le=C("el-table"),Ve=C("el-tag"),ut=C("el-radio"),te=C("el-radio-group"),He=C("el-checkbox"),At=C("el-dialog");return r(),h("div",gpe,[o("div",ype,[o("div",bpe,[o("div",wpe,[o("div",Cpe,[n(fe,{class:"mb-0","separator-icon":A(cl)},{default:d(()=>[e.group==="EU"?(r(),E(se,{key:0,to:{name:"eu"}},{default:d(()=>[R(m(A(u)("Tax Regions")),1)]),_:1})):(r(),E(se,{key:1,to:{name:"tax_rates"}},{default:d(()=>[R(m(A(u)("Tax Regions")),1)]),_:1})),n(se,null,{default:d(()=>[R(m(s.value||e.country),1)]),_:1})]),_:1},8,["separator-icon"]),Ke.value&&ge.value?(r(),h("div",kpe,[i.value?(r(),h("span",{key:0,class:de(["text-sm",be.value?"text-success-500":"text-system-mid dark:text-gray-300"])},m(be.value?A(u)("Collecting tax"):A(u)("Disabled")),3)):B("",!0),n(qe,{"model-value":i.value?be.value:!1,loading:Qe.value,disabled:!i.value,"aria-label":tt.value,onChange:nt},null,8,["model-value","loading","disabled","aria-label"])])):B("",!0)]),!a.value&&!i.value?(r(),h("div",Bpe,[n(el,{type:"warning",icon:"AlertTriangle",content:A(u)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):B("",!0),I.value?B("",!0):(r(),E(ke,{key:1},{default:d(()=>[n(Ce,null,{default:d(()=>[ue.value?(r(),E(at,{key:0,animated:"",rows:2})):(r(),E(ft,{key:1,"label-position":"top"},{default:d(()=>[n(We,{label:A(u)("VAT/GST/Tax Number"),class:"mb-0"},{default:d(()=>[n(Ge,{modelValue:_e.value,"onUpdate:modelValue":we[0]||(we[0]=Ue=>_e.value=Ue),placeholder:A(u)("VAT/GST/Tax Number"),maxlength:"255"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})),o("div",xpe,[n(Ze,{type:"primary",size:"small",loading:le.value,disabled:ue.value||le.value||_e.value===me.value,onClick:Se},{default:d(()=>[R(m(A(u)("Save")),1)]),_:1},8,["loading","disabled"])])]),_:1})]),_:1})),n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Base taxes")},null,8,["title"]),n(Ce,null,{default:d(()=>[n(el,{type:"info"},{content:d(()=>[o("span",null,m(A(u)("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"))+" + "+m(A(u)("button to add tax classes.")),1)]),_:1}),a.value?(r(),E(ipe,{key:0})):(r(),h("div",Spe,[n(of,{classes:c.value,"active-id":p.value,"max-classes":y.value,creating:_.value,search:S.value,onSwitch:Me,onDelete:Lt,onAdd:gt,onCreateCustom:vt,"onUpdate:search":we[1]||(we[1]=Ue=>S.value=Ue)},null,8,["classes","active-id","max-classes","creating","search"]),n(Le,{data:F.value,class:"w-full fct-tax-rates-table","max-height":"450"},{default:d(()=>[n(Ut,{label:A(u)("Region")},{default:d(({row:Ue})=>[o("span",{class:de(["fct-base-taxes__region-name",Ue.state?"":"fct-base-taxes__region-name--federal"])},m(Ue.state?Ue.stateName:s.value||e.country),3)]),_:1},8,["label"]),n(Ut,{label:A(u)("Rate"),width:"130"},{default:d(({row:Ue})=>[n(Ge,{modelValue:Ue.rate,"onUpdate:modelValue":xt=>Ue.rate=xt,size:"small",type:"number",step:"0.01",min:"0"},{suffix:d(()=>we[18]||(we[18]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),n(Ut,{label:A(u)("Tax Label"),width:"200"},{default:d(({row:Ue})=>[n(Ge,{modelValue:Ue.name,"onUpdate:modelValue":xt=>Ue.name=xt,size:"small",placeholder:A(u)("Tax name")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),_:1},8,["label"]),k.value.length>0?(r(),E(Ut,{key:0,label:A(u)("Compound"),width:"310"},{default:d(({row:Ue})=>[Ue.state?(r(),E(he,{key:0,"model-value":oe(Ue),size:"small",style:{width:"100%"},onChange:xt=>re(Ue,xt)},{default:d(()=>[n(Ae,{value:"0_0",label:ee.value[0].label},null,8,["label"]),n(Ae,{value:"0_1",label:ee.value[1].label},null,8,["label"]),n(Ae,{value:"1_0",label:ee.value[2].label},null,8,["label"])]),_:2},1032,["model-value","onChange"])):B("",!0)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"]),o("div",Fpe,[f.value==="standard"?(r(),E(Ze,{key:0,loading:j.value,size:"small",onClick:wt,type:"danger",soft:""},{default:d(()=>[R(m(A(u)("Reset to default")),1)]),_:1},8,["loading"])):B("",!0),n(Ze,{type:"primary",size:"small",loading:Y.value,onClick:_t},{default:d(()=>[R(m(A(u)("Save Rates")),1)]),_:1},8,["loading"])])]))]),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Tax overrides"),text:A(u)("Override tax rates for specific product categories or shipping.")},{action:d(()=>[n(Ze,{size:"small",onClick:Zt},{default:d(()=>[R(m(A(u)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(Ce,null,{default:d(()=>[o("div",$pe,[n(Le,{data:x.value,"empty-text":A(u)("No overrides configured")},{default:d(()=>[n(Ut,{label:A(u)("Type"),width:"110"},{default:d(({row:Ue})=>[n(Ve,{type:Ue.type==="products"?"primary":"info",size:"small"},{default:d(()=>[R(m(Ue.type==="products"?A(u)("Product"):A(u)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n(Ut,{label:A(u)("Category")},{default:d(({row:Ue})=>[R(m(Ue.category_name||"—"),1)]),_:1},8,["label"]),n(Ut,{label:A(u)("Tax Label")},{default:d(({row:Ue})=>[R(m(Ue.tax_label||"—"),1)]),_:1},8,["label"]),n(Ut,{label:A(u)("Location")},{default:d(({row:Ue})=>[R(m(Ue.location),1)]),_:1},8,["label"]),n(Ut,{label:A(u)("Tax Class"),width:"130"},{default:d(({row:Ue})=>[Ue.type==="products"?(r(),h("span",Epe,m(Ue.class_label||A(u)("All")),1)):(r(),h("span",Upe,m(Ue.class_label||"—"),1))]),_:1},8,["label"]),n(Ut,{label:A(u)("City / Postcode")},{default:d(({row:Ue})=>[Ue.city||Ue.postcode?(r(),h("span",Ipe,m([Ue.city,Ue.postcode].filter(Boolean).join(" / ")),1)):(r(),h("span",Qpe,"—"))]),_:1},8,["label"]),n(Ut,{label:A(u)("Rate"),width:"100"},{default:d(({row:Ue})=>[R(m(Ue.rate)+"% ",1)]),_:1},8,["label"]),n(Ut,{label:A(u)("Actions"),width:"110",align:"right"},{default:d(({row:Ue})=>[o("div",Dpe,[n(et,{tag:"button",size:"small",onClick:xt=>Gt(Ue)},{default:d(()=>[n(J,{name:"Edit"})]),_:2},1032,["onClick"]),n(et,{tag:"button",size:"small",onClick:xt=>Ya(Ue),bg:"danger",outline:""},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"])])]),_:1})]),_:1}),n(At,{modelValue:U.value,"onUpdate:modelValue":we[17]||(we[17]=Ue=>U.value=Ue),title:(X.value?A(u)("Edit tax override for"):A(u)("Add tax override for"))+" "+(s.value||e.country),width:"520px","append-to-body":!0,onClose:Xt},{footer:d(()=>[n(Ze,{onClick:we[16]||(we[16]=Ue=>U.value=!1)},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(Ze,{type:"primary",loading:z.value,onClick:fa},{default:d(()=>[R(m(X.value?A(u)("Save changes"):A(u)("Add override")),1)]),_:1},8,["loading"])]),default:d(()=>[n(ft,{"label-position":"top",model:G.value},{default:d(()=>[n(We,{label:A(u)("Override type")},{default:d(()=>[n(te,{modelValue:G.value.type,"onUpdate:modelValue":we[2]||(we[2]=Ue=>G.value.type=Ue)},{default:d(()=>[n(ut,{value:"products"},{default:d(()=>[R(m(A(u)("Products")),1)]),_:1}),n(ut,{value:"shipping"},{default:d(()=>[R(m(A(u)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),G.value.type==="products"?(r(),h(H,{key:0},[n(We,{label:A(u)("Category")},{default:d(()=>[n(he,{modelValue:G.value.category_id,"onUpdate:modelValue":we[3]||(we[3]=Ue=>G.value.category_id=Ue),filterable:"",placeholder:A(u)("Select a category"),loading:P.value,style:{width:"100%"},onChange:il},{default:d(()=>[(r(!0),h(H,null,ae(L.value,Ue=>(r(),E(Ae,{key:Ue.value,label:Ue.label,value:Ue.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),n(We,{label:A(u)("Tax Class")},{default:d(()=>[n(he,{modelValue:G.value.class_id,"onUpdate:modelValue":we[4]||(we[4]=Ue=>G.value.class_id=Ue),style:{width:"100%"}},{default:d(()=>[n(Ae,{value:0,label:A(u)("All Tax Classes")},null,8,["label"]),(r(!0),h(H,null,ae(c.value,Ue=>(r(),E(Ae,{key:Ue.id,value:Number(Ue.id),label:Ue.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"]),n(We,{label:A(u)("Tax label")},{default:d(()=>[n(Ge,{modelValue:G.value.tax_label,"onUpdate:modelValue":we[5]||(we[5]=Ue=>G.value.tax_label=Ue),placeholder:A(u)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(We,{label:A(u)("Location")},{default:d(()=>[n(he,{modelValue:G.value.state,"onUpdate:modelValue":we[6]||(we[6]=Ue=>G.value.state=Ue),placeholder:A(u)("Select location"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(ga.value,Ue=>(r(),E(Ae,{key:Ue.value,label:Ue.label,value:Ue.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(We,{label:A(u)("City (optional)")},{default:d(()=>[n(Ge,{modelValue:G.value.city,"onUpdate:modelValue":we[7]||(we[7]=Ue=>G.value.city=Ue),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(We,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(Ge,{modelValue:G.value.postcode,"onUpdate:modelValue":we[8]||(we[8]=Ue=>G.value.postcode=Ue),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(We,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(Ge,{modelValue:G.value.tax_rate,"onUpdate:modelValue":we[9]||(we[9]=Ue=>G.value.tax_rate=Ue),type:"number",step:"0.01",min:"0",placeholder:A(u)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),k.value.length>0?(r(),E(We,{key:0},{default:d(()=>[n(He,{modelValue:G.value.override_state_tax,"onUpdate:modelValue":we[10]||(we[10]=Ue=>G.value.override_state_tax=Ue)},{default:d(()=>[R(m(A(u)("Also override state/provincial taxes")),1)]),_:1},8,["modelValue"])]),_:1})):B("",!0)],64)):(r(),h(H,{key:1},[n(We,{label:A(u)("Tax Class")},{default:d(()=>[n(he,{modelValue:G.value.class_id,"onUpdate:modelValue":we[11]||(we[11]=Ue=>G.value.class_id=Ue),style:{width:"100%"},loading:Q.value},{default:d(()=>[(r(!0),h(H,null,ae(c.value,Ue=>(r(),E(Ae,{key:Ue.id,value:Number(Ue.id),label:Ue.title,disabled:X.value&&Number(Ue.id)!==Number(O.value)&&V.value.has(Number(Ue.id))},null,8,["value","label","disabled"]))),128))]),_:1},8,["modelValue","loading"])]),_:1},8,["label"]),n(We,{label:A(u)("Location")},{default:d(()=>[n(he,{modelValue:G.value.state,"onUpdate:modelValue":we[12]||(we[12]=Ue=>G.value.state=Ue),placeholder:A(u)("Select location"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(qa.value,Ue=>(r(),E(Ae,{key:Ue.value,label:Ue.label,value:Ue.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(We,{label:A(u)("City (optional)")},{default:d(()=>[n(Ge,{modelValue:G.value.city,"onUpdate:modelValue":we[13]||(we[13]=Ue=>G.value.city=Ue),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(We,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(Ge,{modelValue:G.value.postcode,"onUpdate:modelValue":we[14]||(we[14]=Ue=>G.value.postcode=Ue),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(We,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(Ge,{modelValue:G.value.tax_rate,"onUpdate:modelValue":we[15]||(we[15]=Ue=>G.value.tax_rate=Ue),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])])])])}}};class Vpe extends Qs{getTabs(){return{all:u("All"),filed:u("Filed"),not_filed:u("Not Filed")}}getToggleableColumns(){return[{label:"ID",value:"id"},{label:"Order ID",value:"order_id"},{label:"Zip Code",value:"postcode"},{label:"Tax Rate",value:"rate"},{label:"Filed",value:"filed_at"}]}getSearchHint(){return u("Search by id, title, content or module.")}getFetchUrl(){return"taxes"}parseResponse(t){return t.taxes}getTableName(){return"taxes_table"}with(){return["admin_tax_report"]}scopes(){return["validOrder"]}}function Tpe(e){return Vpe.init(e)}const Mpe=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase()),Lpe=e=>{const t=Object.keys(e[0]),l=[t.map(Mpe).join(",")];return e.forEach(s=>{const i=t.map(c=>{let p=s[c];return typeof p=="object"&&(p=JSON.stringify(p)),typeof p=="string"&&(p=`"${p.replace(/"/g,'""')}"`),p});l.push(i.join(","))}),l.join(`
`)},Rpe=(e,t="export.csv")=>new Promise((a,l)=>{try{if(!e||!e.length)throw new Error("No data to export");const s=Lpe(e),i=new Blob([s],{type:"text/csv"}),c=document.createElement("a"),p=()=>{window.removeEventListener("focus",p),a()};window.addEventListener("focus",p),c.href=URL.createObjectURL(i),c.download=t,c.click(),URL.revokeObjectURL(c.href),setTimeout(()=>{a()},200)}catch(s){l(s)}}),Ope={class:"table-cell"},Hpe={class:"table-cell"},Ppe={class:"table-cell"},Npe={class:"table-cell"},Kpe={class:"table-cell"},Gpe={class:"table-cell"},jpe={class:"table-cell"},zpe={class:"table-cell"},qpe={class:"table-cell"},Ype={__name:"TaxesLoader",props:{nextPageCount:{type:Number,default:0},taxTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(l,s)=>s+1);return(l,s)=>{const i=C("el-table-column"),c=C("el-skeleton-item"),p=C("el-skeleton"),f=C("el-table");return r(),E(f,{data:A(a),class:"w-full compact-table full-compact"},{default:d(()=>[n(i,{type:"selection",width:45}),e.taxTable.isColumnVisible("id")?(r(),E(i,{key:0,width:100,label:A(u)("ID")},{default:d(()=>[o("div",Ope,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.taxTable.isColumnVisible("order_id")?(r(),E(i,{key:1,label:A(u)("Order ID"),width:100},{default:d(()=>[o("div",Hpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:A(u)("Tax Country"),width:120},{default:d(()=>[o("div",Ppe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"]),n(i,{label:A(u)("Tax Region"),width:120},{default:d(()=>[o("div",Npe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("postcode")?(r(),E(i,{key:2,label:A(u)("Zip Code"),width:120},{default:d(()=>[o("div",Kpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:A(u)("Tax Name"),width:120},{default:d(()=>[o("div",Gpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("rate")?(r(),E(i,{key:3,label:A(u)("Tax Rate"),width:120},{default:d(()=>[o("div",jpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:A(u)("Sale Taxes"),width:120},{default:d(()=>[o("div",zpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("filed_at")?(r(),E(i,{key:4,label:A(u)("Filed"),width:120},{default:d(()=>[o("div",qpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},Wpe={class:"table-cell"},Jpe={class:"table-cell"},Xpe={class:"table-cell"},Zpe={class:"table-cell"},efe={class:"table-cell"},tfe={class:"table-cell"},afe={class:"table-cell"},lfe={class:"table-cell"},sfe={class:"table-cell"},nfe={__name:"AllCouponsLoader",props:{nextPageCount:{type:Number,default:0},couponTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(l,s)=>s+1);return(l,s)=>{const i=C("el-skeleton-item"),c=C("el-skeleton"),p=C("el-table-column"),f=C("el-table");return r(),E(f,{data:A(a),class:"w-full compact-table responsive full-compact"},{default:d(()=>[n(p,{width:103,label:A(u)("ID")},{default:d(()=>[o("div",Wpe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("title")?(r(),E(p,{key:0,label:A(u)("Title"),width:227},{default:d(()=>[o("div",Jpe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[180px]"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(p,{label:A(u)("Code"),width:206},{default:d(()=>[o("div",Xpe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[130px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:A(u)("Amount"),width:124},{default:d(()=>[o("div",Zpe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:A(u)("Usage"),width:155},{default:d(()=>[o("div",efe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("stackable")?(r(),E(p,{key:1,label:A(u)("Stackable"),width:124},{default:d(()=>[o("div",tfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(p,{label:A(u)("Status"),width:124},{default:d(()=>[o("div",afe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:A(u)("Expiry Date"),width:124},{default:d(()=>[o("div",lfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("actions")?(r(),E(p,{key:2,label:A(u)("Actions"),width:103,align:"right"},{default:d(()=>[o("div",sfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},ofe={class:"fct-taxes-page fct-layout-width"},ife={key:1},rfe={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},dfe={class:"fct-tax-filing-wrap"},ufe={class:"fct-tax-filing-summary"},cfe={class:"summary-item"},Afe={class:"summary-label"},pfe={class:"summary-value"},ffe={class:"summary-item"},mfe={class:"summary-label"},hfe={class:"summary-value"},_fe={class:"fct-tax-filing max-h-[400px] overflow-y-auto"},vfe={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},gfe={class:"dialog-footer"},yfe={class:"fct-tax-filing-success-wrap"},bfe={class:"fct-tax-filling-success-icon"},wfe={class:"dialog-footer"},Cfe={__name:"Taxes",setup(e){const t=Object.fromEntries(rm.map(x=>[x.value,x.label])),a=x=>t[x]||x;Yt().ctx;const l=Tpe(),s=M(!1),i=M(!1),c=M(!1),p=M([]),f=N(()=>l.getTableData().map(x=>{var U,T,D,Q,V,O,L,P,z,X,G;return{id:x.id,order_id:x.order_id,country:a(((U=x.tax_rate)==null?void 0:U.country)??((T=x.meta)==null?void 0:T.tax_country)??""),state:((D=x.tax_rate)==null?void 0:D.formatted_state)??((Q=x.tax_rate)==null?void 0:Q.state)??"",postcode:((V=x.tax_rate)==null?void 0:V.postcode)??"",name:((O=x.tax_rate)==null?void 0:O.name)??((L=x.meta)==null?void 0:L.label)??"",reverse_charge:!!((P=x.meta)!=null&&P.reverse_charge_applied),rate:((z=x.tax_rate)==null?void 0:z.rate)??((X=x.meta)==null?void 0:X.rate_percent)??"",total_tax:String(parseFloat((x.total_tax/100).toFixed(2))),currency:((G=x.order)==null?void 0:G.currency)||"",total_tax:String(parseFloat((x.total_tax/100).toFixed(2))),filed_at:x.filed_at?u("Yes"):u("No")}})),_=()=>{s.value=!0,i.value=!1},g=()=>{s.value=!1,i.value=!0},y=async()=>{try{await Rpe($.value),g()}catch{}},v=()=>{i.value=!1},b=()=>{const x=$.value.map(U=>U.id);ce.post(l.getFetchUrl(),{ids:x}).then(U=>{q.success(U.message),l.fetch()}).catch(U=>{q.error(U)}).finally(()=>{v()})},k=x=>{p.value=x,c.value=x.length>0},w=x=>{$.value=x},S=M(null),$=M([]),I=N(()=>{const x=$.value.reduce((T,D)=>T+parseFloat(D.total_tax||0),0),U=[...new Set($.value.map(T=>T.order_id))];return{totalTax:pt.formatNumber(Math.round(x*100),!1),totalOrders:U.length,items:$.value}}),F=()=>{Be(()=>{$.value=[...p.value],p.value.forEach(x=>{S.value.toggleRowSelection(x,!0)})})};return(x,U)=>{const T=C("el-button"),D=C("el-tooltip"),Q=C("el-table-column"),V=C("router-link"),O=C("el-tag"),L=C("el-table"),P=C("el-dialog");return r(),h("div",ofe,[n(ol,{title:A(u)("Taxes")},{action:d(()=>[c.value?(r(),E(T,{key:1,type:"primary",onClick:_,disabled:!c.value},{default:d(()=>[R(m(A(u)("Tax Filing")),1)]),_:1},8,["disabled"])):(r(),E(D,{key:0,"popper-class":"fct-tooltip",effect:"dark",content:A(u)("Please select the taxes you want to file"),placement:"top-start"},{default:d(()=>[n(T,{type:"primary",disabled:!c.value},{default:d(()=>[R(m(A(u)("Tax Filing")),1)]),_:1},8,["disabled"])]),_:1},8,["content"]))]),_:1},8,["title"]),n(Ds,{table:A(l),"has-mobile-slot":!1},{default:d(()=>[A(l).isLoading()?(r(),E(Ype,{key:0,taxTable:A(l),"next-page-count":A(l).nextPageCount},null,8,["taxTable","next-page-count"])):(r(),h("div",ife,[n(L,{class:"w-full",data:f.value,onSelectionChange:k},{empty:d(()=>[n(Ct,{icon:"Empty/ListView","has-dark":!0,text:A(u)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:d(()=>[n(Q,{type:"selection",width:45}),A(l).isColumnVisible("id")?(r(),E(Q,{key:0,label:A(u)("ID"),width:100},{default:d(z=>[o("span",null,"#"+m(A(u)(z.row.id)),1)]),_:1},8,["label"])):B("",!0),A(l).isColumnVisible("order_id")?(r(),E(Q,{key:1,label:A(u)("Order ID"),width:100},{default:d(z=>[o("span",rfe,[n(V,{class:"link",to:{name:"view_order",params:{order_id:z.row.order_id}}},{default:d(()=>[R(" #"+m(z.row.order_id),1)]),_:2},1032,["to"]),z.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:d(()=>[R(m(A(u)("Reverse Charge")),1)]),_:1})):B("",!0)])]),_:1},8,["label"])):B("",!0),n(Q,{label:A(u)("Tax Country"),width:120},{default:d(z=>[o("span",null,m(z.row.country),1)]),_:1},8,["label"]),n(Q,{label:A(u)("Tax Region"),width:120},{default:d(z=>[o("span",null,m(z.row.state),1)]),_:1},8,["label"]),A(l).isColumnVisible("postcode")?(r(),E(Q,{key:2,label:A(u)("Zip Code"),width:120},{default:d(z=>[o("span",null,m(z.row.postcode),1)]),_:1},8,["label"])):B("",!0),n(Q,{label:A(u)("Tax Name"),width:120},{default:d(z=>[o("span",null,m(z.row.name),1)]),_:1},8,["label"]),A(l).isColumnVisible("rate")?(r(),E(Q,{key:3,label:A(u)("Tax Rate"),width:120},{default:d(z=>[o("span",null,m(z.row.rate)+"%",1)]),_:1},8,["label"])):B("",!0),n(Q,{label:A(u)("Sale Taxes"),width:120},{default:d(z=>[o("span",null,m(A(pt).formatForOrder(z.row.total_tax_cents,z.row.currency)),1)]),_:1},8,["label"]),A(l).isColumnVisible("filed_at")?(r(),E(Q,{key:4,label:A(u)("Filed"),width:120},{default:d(z=>[o("span",null,m(z.row.filed_at),1)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"]),n(P,{modelValue:s.value,"onUpdate:modelValue":U[1]||(U[1]=z=>s.value=z),title:A(u)("Tax Filing"),onOpen:F,class:"fct-tax-filling-modal"},{footer:d(()=>[o("div",gfe,[n(T,{onClick:U[0]||(U[0]=()=>{s.value=!1})},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(T,{type:"primary",onClick:y},{default:d(()=>[n(J,{name:"Download",style:{width:"16px",height:"16px"}}),R(" "+m(A(u)("Download & Continue")),1)]),_:1})])]),default:d(()=>[o("div",dfe,[o("div",ufe,[o("div",cfe,[o("span",Afe,m(A(u)("Taxable Amount")),1),o("span",pfe,m(I.value.totalTax),1)]),o("div",ffe,[o("span",mfe,m(A(u)("Total Orders")),1),o("span",hfe,m(A(u)(I.value.totalOrders)),1)])]),o("div",_fe,[n(L,{ref_key:"selectedTaxesTableRef",ref:S,data:p.value,onSelectionChange:w},{empty:d(()=>[n(Ct,{icon:"Empty/ListView",text:A(u)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:d(()=>[n(Q,{type:"selection",width:45}),n(Q,{label:A(u)("ID"),width:100},{default:d(z=>[o("span",null,m(z.row.id),1)]),_:1},8,["label"]),n(Q,{label:A(u)("Order ID"),"min-width":100},{default:d(z=>[o("span",vfe,[o("span",null,m(z.row.order_id),1),z.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:d(()=>[R(m(A(u)("Reverse Charge")),1)]),_:1})):B("",!0)])]),_:1},8,["label"]),n(Q,{width:120,label:A(u)("Tax Country")},{default:d(z=>[o("span",null,m(z.row.country),1)]),_:1},8,["label"]),n(Q,{width:120,label:A(u)("Tax Region")},{default:d(z=>[o("span",null,m(z.row.state),1)]),_:1},8,["label"]),n(Q,{label:A(u)("Zip Code"),width:120},{default:d(z=>[o("span",null,m(z.row.postcode),1)]),_:1},8,["label"]),n(Q,{width:120,label:A(u)("Tax Name")},{default:d(z=>[o("span",null,m(z.row.name),1)]),_:1},8,["label"]),n(Q,{label:A(u)("Tax Rate"),width:120},{default:d(z=>[o("span",null,m(z.row.rate)+"%",1)]),_:1},8,["label"]),n(Q,{width:150,label:A(u)("Sale Taxes")},{default:d(z=>[o("span",null,m(A(pt).formatForOrder(z.row.total_tax_cents,z.row.currency)),1)]),_:1},8,["label"])]),_:1},8,["data"])])])]),_:1},8,["modelValue","title"]),n(P,{modelValue:i.value,"onUpdate:modelValue":U[2]||(U[2]=z=>i.value=z),class:"fct-tax-filling-success-modal","close-on-click-modal":!1},{footer:d(()=>[o("div",wfe,[n(T,{onClick:v},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(T,{type:"primary",onClick:b},{default:d(()=>[R(m(A(u)("Mark as Filed")),1)]),_:1})])]),default:d(()=>[o("div",yfe,[o("div",bfe,[n(J,{name:"CheckCircleFill"})]),o("div",null,[o("h4",null,m(A(u)("Don't Forget to Save Your Tax File")),1),o("p",null,m(A(u)("You're about to mark this tax report as filed.")),1),o("p",null,[R(m(A(u)("Make sure you've downloaded and saved the CSV file for your records before proceeding."))+" ",1),o("a",{onClick:Pe(y,["prevent"]),class:"cursor-pointer"},m(A(u)("Download Again")),1)])])])]),_:1},8,["modelValue"])])}}},kfe={class:"fct-card fct-card-border fct-vat-card"},Bfe={class:"fct-card-body"},xfe={class:"fct-vat-card-header"},Sfe={class:"fct-vat-card-title"},Ffe={class:"fct-card fct-card-border fct-vat-card mt-5"},$fe={class:"fct-card-body"},Efe={class:"fct-vat-card-header"},Ufe={class:"fct-vat-card-title"},Ife={class:"fct-tax-rates-country-view"},Qfe={class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},Dfe={class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-3 border-b border-gray-200 dark:border-dark-300"},Vfe={__name:"EUVatSettingsLoader",setup(e){const t=[1,2,3];return(a,l)=>(r(),h("div",null,[o("div",kfe,[o("div",Bfe,[o("div",xfe,[o("div",Sfe,[o("h3",null,m(A(u)("Collect VAT cross-border")),1)])]),l[0]||(l[0]=o("div",{class:"fct-vat-card-body"},[o("div",{class:"fct-sk w-[200px] h-3 rounded-xs"}),o("div",{class:"fct-sk w-full h-3 rounded-xs mt-3"})],-1))])]),o("div",Ffe,[o("div",$fe,[o("div",Efe,[o("div",Ufe,[o("h3",null,m(A(u)("Tax overrides")),1)])]),o("div",Ife,[o("div",Qfe,[o("div",Dfe,[(r(),h(H,null,ae(6,s=>o("div",{key:"header-"+s,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),h(H,null,ae(t,s=>o("div",{key:"override-row-"+s,class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-4 border-b border-gray-100 last:border-b-0 dark:border-dark-400"},l[1]||(l[1]=[Un('',6)]))),64))])])])])]))}},Tfe={class:"fct-modal-body"},Mfe={class:"fct-radio-option-fields"},Lfe={class:"form-note"},Rfe={class:"fct-radio-option-fields"},Ofe={class:"fct-radio-option-fields-desc"},Hfe={class:"form-note"},Pfe={key:0,class:"fct-info-box mt-3"},Nfe={class:"text-xs text-system-mid"},Kfe={class:"fct-radio-option-fields"},Gfe={class:"fct-radio-option-fields-desc"},jfe={__name:"EUVatCrossBorderModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},currentForm:{type:Object,default:()=>({})},initialRegistrations:{type:Array,default:()=>[]}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=M({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),i=M(!1);ye(()=>a.modelValue,_=>{if(_){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 c(_){const g=a.countries.find(y=>y.value===_);return g?parseFloat(g.default_rate||0):0}function p(){return a.initialRegistrations.some(_=>_.country===s.value.home_country)}function f(){if(!s.value.method){q.error(u("Select a cross-border registration type"));return}if(s.value.method==="oss"){if(!s.value.oss_country){q.error(u("Select your country of OSS registration"));return}}else if(s.value.method==="home"&&!s.value.home_country){q.error(u("Select your country of registration"));return}i.value=!0,(s.value.method==="home"&&!p()?ce.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.home_country,vat:s.value.home_vat,rate:c(s.value.home_country)}):Promise.resolve()).then(()=>ce.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:s.value})).then(g=>{q.success(g.message),l("saved",{method:s.value.method,oss_country:s.value.oss_country,oss_vat:s.value.oss_vat,home_country:s.value.home_country,home_country_vat:s.value.home_vat}),l("update:modelValue",!1)}).catch(g=>{var y;q.error((y=g==null?void 0:g.data)==null?void 0:y.message)}).finally(()=>{i.value=!1})}return(_,g)=>{const y=C("el-radio"),v=C("el-option"),b=C("el-select"),k=C("el-form-item"),w=C("el-input"),S=C("el-radio-group"),$=C("el-form"),I=C("el-button"),F=C("el-dialog");return r(),E(F,{"model-value":e.modelValue,title:A(u)("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]=x=>l("update:modelValue",x))},{footer:d(()=>[n(I,{onClick:g[8]||(g[8]=x=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(I,{type:"primary",onClick:f,loading:i.value},{default:d(()=>[R(m(A(u)("Collect VAT")),1)]),_:1},8,["loading"])]),default:d(()=>[o("div",Tfe,[n($,{"label-position":"top"},{default:d(()=>[n(S,{modelValue:s.value.method,"onUpdate:modelValue":g[7]||(g[7]=x=>s.value.method=x),class:"fct-cross-border-radios"},{default:d(()=>[o("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="oss"}]),onClick:g[2]||(g[2]=x=>s.value.method="oss")},[n(y,{value:"oss"},{default:d(()=>[R(m(A(u)("Collect using a One Stop Shop (OSS) registration")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="oss"},{default:d(()=>[o("div",Mfe,[n(k,{label:A(u)("Country of OSS registration")},{default:d(()=>[n(b,{modelValue:s.value.oss_country,"onUpdate:modelValue":g[0]||(g[0]=x=>s.value.oss_country=x),placeholder:A(u)("Select country"),filterable:"",class:"w-full"},{default:d(()=>[(r(!0),h(H,null,ae(e.countries,x=>(r(),E(v,{key:x.value,label:x.label,value:x.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(k,{label:A(u)("VAT number")},{default:d(()=>[n(w,{modelValue:s.value.oss_vat,"onUpdate:modelValue":g[1]||(g[1]=x=>s.value.oss_vat=x),placeholder:A(u)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",Lfe,[o("p",null,m(A(u)("Shown on VAT invoice")),1)])]),_:1},8,["label"])])]),_:1},8,["visible"])],2),o("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="home"}]),onClick:g[5]||(g[5]=x=>s.value.method="home")},[n(y,{value:"home"},{default:d(()=>[R(m(A(u)("Collect using your home country registration")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="home"},{default:d(()=>[o("div",Rfe,[o("p",Ofe,m(A(u)("Applies to micro-businesses located in one EU country and making less than €10,000 in sales to other EU countries each year")),1),n(k,{label:A(u)("Country of registration")},{default:d(()=>[n(b,{modelValue:s.value.home_country,"onUpdate:modelValue":g[3]||(g[3]=x=>s.value.home_country=x),placeholder:A(u)("Select country"),filterable:"",class:"w-full"},{default:d(()=>[(r(!0),h(H,null,ae(e.countries,x=>(r(),E(v,{key:x.value,label:x.label,value:x.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(k,{label:A(u)("VAT number")},{default:d(()=>[n(w,{modelValue:s.value.home_vat,"onUpdate:modelValue":g[4]||(g[4]=x=>s.value.home_vat=x),placeholder:A(u)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",Hfe,[o("p",null,m(A(u)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),e.initialRegistrations.length?B("",!0):(r(),h("div",Pfe,[n(J,{name:"InformationFill",class:"w-4 h-4 text-blue-500 flex-shrink-0"}),o("span",Nfe,m(A(u)("You haven't added a home country registration. The information you add here will be used to create one for you.")),1)]))])]),_:1},8,["visible"])],2),o("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="specific"}]),onClick:g[6]||(g[6]=x=>s.value.method="specific")},[n(y,{value:"specific"},{default:d(()=>[R(m(A(u)("Collect using specific country registrations")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="specific"},{default:d(()=>[o("div",Kfe,[o("p",Gfe,m(A(u)("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"])}}},zfe={key:0,class:"fct-country-registrations-list mt-4"},qfe={class:"fct-home-country-header"},Yfe=["src","alt"],Wfe={class:"fct-vat-country-name"},Jfe={key:0,class:"fct-collecting-badge"},Xfe={class:"fct-home-country-body"},Zfe={class:"fct-vat-home-field"},eme={class:"fct-vat-home-field__label"},tme={class:"fct-reg-rates-section"},ame={class:"fct-reg-rates-table fct-reg-rates-table--home mt-5 px-5 pt-5"},lme={class:"fct-reg-rates-row fct-reg-rates-header"},sme={class:"fct-reg-rates-cell-label"},nme={class:"fct-reg-rates-cell-label"},ome={key:1,class:"fct-reg-class-name"},ime={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},rme={class:"fct-reg-rates-cell-input"},dme={class:"fct-reg-rates-cell-action"},ume=["title","onClick"],cme={key:0,class:"fct-reg-add-class px-5"},Ame={type:"button",class:"fct-reg-add-class-btn"},pme={class:"fct-vat-home-actions"},fme={__name:"EUVatHomeCountryRegistration",props:{countries:{type:Array,default:()=>[]},homeCountry:{type:String,default:""},homeVat:{type:String,default:""},taxClasses:{type:Array,default:()=>[]},registrations:{type:Array,default:()=>[]}},emits:["save-home","class-changed"],setup(e,{emit:t}){const a=e,l=t,s=M({country:"",vat:"",rates:{}}),i=M([]),c=N(()=>a.homeCountry&&a.countries.find(x=>x.value===a.homeCountry)||null),p=N(()=>a.homeCountry&&a.registrations.find(x=>x.country===a.homeCountry)||null),f=N(()=>{const x=p.value;return!x||!x.vat?!1:x.rates&&typeof x.rates=="object"&&Object.keys(x.rates).length?Object.values(x.rates).some(function(U){return U&&parseFloat(U.rate)>0}):parseFloat(x.rate)>0}),_=N(()=>[...a.taxClasses,...i.value]),g=N(()=>_.value.length?_.value:[{slug:"standard",title:u("Standard")}]),y=N(()=>{if(_.value.length>=6)return[];const x=_.value.map(T=>T.slug).filter(Boolean),U=[];return x.includes("reduced")||U.push({command:"reduced",label:u("Reduced")}),x.includes("zero")||U.push({command:"zero",label:u("Zero")}),U.push({command:"custom",label:u("Custom Class...")}),U});ye([()=>a.homeCountry,()=>a.homeVat,()=>a.taxClasses,()=>a.registrations],()=>{const x=p.value,U={};a.taxClasses.forEach(T=>{var O;const D=(O=x==null?void 0:x.rates)==null?void 0:O[T.slug],Q=T.slug==="standard"?(x==null?void 0:x.rate)??"":"",V=T.slug==="standard"?(x==null?void 0:x.tax_label)??"":"";D&&typeof D=="object"?U[T.slug]={rate:D.rate??"",label:D.label??""}:U[T.slug]={rate:D??Q,label:V}}),i.value.forEach(T=>{const D=v(T);U[D]=s.value.rates[D]||{rate:"",label:""}}),U.standard||(U.standard={rate:"",label:""}),s.value={country:a.homeCountry||"",vat:(x==null?void 0:x.vat)||a.homeVat||"",rates:U}},{immediate:!0});function v(x){return x.tempKey||x.slug}function b(x){if(x==="custom"){w();return}const U=x==="reduced"?u("Reduced"):u("Zero");i.value.push({slug:x,title:U,tempKey:x}),s.value.rates[x]={rate:"",label:""}}let k=0;function w(){const x="_new_"+k++;i.value.push({slug:null,title:"",tempKey:x,isNew:!0}),s.value.rates[x]={rate:"",label:""}}function S(x){return x.slug?x.title||x.slug:x.title&&x.title.trim()?x.title.trim():u("Custom")}function $(x){if(x.hasError=!1,x.created)return Promise.resolve(null);if(!x.slug&&!(x.title&&x.title.trim()))return x.hasError=!0,Promise.reject(new Error(u("Please enter a name for the custom tax class")));const U=x.slug?{slug:x.slug}:{title:x.title.trim()};return ce.post("tax/classes",U).then(T=>{const D=(T==null?void 0:T.class)||{},Q=D.slug||x.slug;if(!Q)throw new Error(u("Tax class creation returned an invalid response"));return!x.slug&&s.value.rates[x.tempKey]!==void 0&&(s.value.rates[Q]=s.value.rates[x.tempKey],delete s.value.rates[x.tempKey],x.tempKey=null),x.slug=Q,x.title=D.title||x.title,x.created=!0,D}).catch(T=>{var Q;x.hasError=!0;const D=((Q=T==null?void 0:T.data)==null?void 0:Q.message)||u("Failed to create tax class");throw new Error(u("%1$s: %2$s",D,S(x)))})}function I(x){const U=v(x);if(i.value.some(D=>v(D)===U)){i.value=i.value.filter(D=>v(D)!==U),delete s.value.rates[U];return}ul(u('This will permanently delete the "%1$s" tax class and all its rates across every country (not just EU). Products using this class will fall back to Standard. Continue?',x.title),u("Delete Tax Class"),{confirmButtonText:u("Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ce.delete("tax/classes/"+x.id).then(()=>{l("class-changed")}).catch(D=>{var Q;q.error(((Q=D==null?void 0:D.data)==null?void 0:Q.message)||u("Failed to delete tax class"))})}).catch(()=>{})}function F(){const x=i.value.map($);Promise.all(x).then(()=>{i.value=[],l("save-home",{country:s.value.country,vat:s.value.vat,rates:s.value.rates})}).catch(U=>{q.error((U==null?void 0:U.message)||u("Failed to create tax class"))})}return(x,U)=>{const T=C("el-input"),D=C("el-dropdown-item"),Q=C("el-dropdown-menu"),V=C("el-dropdown"),O=C("el-button");return c.value?(r(),h("div",zfe,[o("div",qfe,[o("img",{src:`https://flagcdn.com/w40/${e.homeCountry.toLowerCase()}.png`,alt:c.value.label,class:"fct-flag-icon"},null,8,Yfe),o("span",Wfe,m(c.value.label),1),f.value?(r(),h("span",Jfe,[U[1]||(U[1]=o("span",{class:"fct-green-dot"},null,-1)),R(" "+m(A(u)("Collecting")),1)])):B("",!0)]),o("div",Xfe,[o("div",Zfe,[o("label",eme,m(A(u)("VAT number")),1),n(T,{modelValue:s.value.vat,"onUpdate:modelValue":U[0]||(U[0]=L=>s.value.vat=L),class:"fct-vat-number-input"},null,8,["modelValue"])]),o("div",tme,[o("div",ame,[o("div",lme,[o("div",sme,m(A(u)("Tax Classes")),1),U[2]||(U[2]=o("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),U[3]||(U[3]=o("div",{class:"fct-reg-rates-cell-input"},null,-1)),U[4]||(U[4]=o("div",{class:"fct-reg-rates-cell-action"},null,-1))]),(r(!0),h(H,null,ae(g.value,L=>(r(),h("div",{key:v(L),class:"fct-reg-rates-row"},[o("div",nme,[L.isNew?(r(),E(T,{key:0,modelValue:L.title,"onUpdate:modelValue":P=>L.title=P,size:"small",placeholder:A(u)("Class name"),class:de(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":L.hasError}]),onInput:P=>L.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),h("span",ome,m(L.title),1))]),o("div",ime,[n(T,{modelValue:s.value.rates[v(L)].rate,"onUpdate:modelValue":P=>s.value.rates[v(L)].rate=P,type:"number",step:"0.01",min:"0",size:"small"},{suffix:d(()=>U[5]||(U[5]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),o("div",rme,[n(T,{modelValue:s.value.rates[v(L)].label,"onUpdate:modelValue":P=>s.value.rates[v(L)].label=P,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",dme,[L.slug!=="standard"?(r(),h("button",{key:0,type:"button",class:"fct-reg-rates-delete-btn",title:A(u)("Delete class"),onClick:P=>I(L)},[n(J,{name:"Delete"})],8,ume)):B("",!0)])]))),128))]),y.value.length?(r(),h("div",cme,[y.value.length===1&&y.value[0].command==="custom"?(r(),h("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:w},[n(J,{name:"Plus",class:"w-3 h-3"}),R(" "+m(A(u)("Add class")),1)])):(r(),E(V,{key:1,trigger:"click",onCommand:b,"popper-class":"fct-dropdown"},{dropdown:d(()=>[n(Q,null,{default:d(()=>[(r(!0),h(H,null,ae(y.value,L=>(r(),E(D,{key:L.command,command:L.command},{default:d(()=>[R(m(L.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:d(()=>[o("button",Ame,[n(J,{name:"Plus",class:"w-3 h-3"}),R(" "+m(A(u)("Add class")),1)])]),_:1}))])):B("",!0)]),o("div",pme,[n(O,{type:"primary",size:"small",onClick:F},{default:d(()=>[R(m(A(u)("Save VAT")),1)]),_:1})])])])):B("",!0)}}},mme={class:"fct-modal-body fct-country-reg-modal"},hme={class:"fct-country-reg-text"},_me={class:"form-note"},vme={class:"fct-reg-rates-table"},gme={class:"fct-reg-rates-row fct-reg-rates-header"},yme={class:"fct-reg-rates-cell-label"},bme={class:"fct-reg-rates-cell-label"},wme={key:1,class:"fct-reg-class-name"},Cme={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},kme={class:"fct-reg-rates-cell-input"},Bme={key:1,class:"fct-reg-rates-row"},xme={class:"fct-reg-rates-cell-label"},Sme={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},Fme={class:"fct-reg-rates-cell-input"},$me={key:0,class:"fct-reg-add-class"},Eme={type:"button",class:"fct-reg-add-class-btn"},Ume={__name:"EUVatRegistrationModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},taxClasses:{type:Array,default:()=>[]},initialForm:{type:Object,default:()=>({country:"",vat:"",rates:{},isEdit:!1})},registeredCountries:{type:Array,default:()=>[]}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=M({country:"",vat:"",rates:{},isEdit:!1}),i=M([]),c=M(!1),p=N(()=>[...a.taxClasses,...i.value]),f=N(()=>{if(p.value.length>=6)return[];const I=p.value.map(x=>x.slug).filter(Boolean),F=[];return I.includes("reduced")||F.push({command:"reduced",label:u("Reduced")}),I.includes("zero")||F.push({command:"zero",label:u("Zero")}),F.push({command:"custom",label:u("Custom Class...")}),F}),_=N(()=>s.value.isEdit?a.countries:a.countries.filter(I=>!a.registeredCountries.includes(I.value)));ye(()=>a.modelValue,I=>{if(I){const F=a.initialForm||{},x=F.rates?JSON.parse(JSON.stringify(F.rates)):{};a.taxClasses.forEach(U=>{x[U.slug]||(x[U.slug]={rate:"",label:""})}),x.standard||(x.standard={rate:"",label:""}),s.value={country:F.country||"",vat:F.vat||"",rates:x,isEdit:F.isEdit||!1},i.value=[]}});function g(I){return I.tempKey||I.slug}function y(I){const F=a.countries.find(x=>x.value===I);if(F&&F.default_rate){const x=s.value.rates.standard||{};s.value.rates=Object.assign({},s.value.rates,{standard:Object.assign({},x,{rate:F.default_rate})})}}function v(I){if(I==="custom"){k();return}const F=I==="reduced"?u("Reduced"):u("Zero");i.value.push({slug:I,title:F,tempKey:I}),s.value.rates[I]={rate:"",label:""}}let b=0;function k(){const I="_new_"+b++;i.value.push({slug:null,title:"",tempKey:I,isNew:!0}),s.value.rates[I]={rate:"",label:""}}function w(I){return I.slug?I.title||I.slug:I.title&&I.title.trim()?I.title.trim():u("Custom")}function S(I){if(I.hasError=!1,I.created)return Promise.resolve(null);if(!I.slug&&!(I.title&&I.title.trim()))return I.hasError=!0,Promise.reject(new Error(u("Please enter a name for the custom tax class")));const F=I.slug?{slug:I.slug}:{title:I.title.trim()};return ce.post("tax/classes",F).then(x=>{const U=(x==null?void 0:x.class)||{},T=U.slug||I.slug;if(!T)throw new Error(u("Tax class creation returned an invalid response"));return!I.slug&&s.value.rates[I.tempKey]!==void 0&&(s.value.rates[T]=s.value.rates[I.tempKey],delete s.value.rates[I.tempKey],I.tempKey=null),I.slug=T,I.title=U.title||I.title,I.created=!0,U}).catch(x=>{var T;I.hasError=!0;const U=((T=x==null?void 0:x.data)==null?void 0:T.message)||u("Failed to create tax class");throw new Error(u("%1$s: %2$s",U,w(I)))})}function $(){if(!s.value.country){q.error(u("Select a registration country"));return}const I=s.value.rates;if(!Object.values(I).some(U=>parseFloat(U.rate)>0)){q.error(u("At least one tax rate must be greater than 0%"));return}c.value=!0;const x=i.value.map(S);Promise.all(x).then(()=>ce.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.country,vat:s.value.vat,rates:s.value.rates})).then(U=>{q.success(U.message),i.value=[],l("saved"),l("update:modelValue",!1)}).catch(U=>{var T;q.error((U==null?void 0:U.message)||((T=U==null?void 0:U.data)==null?void 0:T.message)||u("Failed to save VAT registration"))}).finally(()=>{c.value=!1})}return(I,F)=>{const x=C("el-option"),U=C("el-select"),T=C("el-form-item"),D=C("el-input"),Q=C("el-dropdown-item"),V=C("el-dropdown-menu"),O=C("el-dropdown"),L=C("el-form"),P=C("el-button"),z=C("el-dialog");return r(),E(z,{"model-value":e.modelValue,title:s.value.isEdit?A(u)("Edit VAT registration"):A(u)("Collect VAT"),"close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":F[5]||(F[5]=X=>l("update:modelValue",X))},{footer:d(()=>[n(P,{onClick:F[4]||(F[4]=X=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(P,{type:"primary",onClick:$,loading:c.value},{default:d(()=>[R(m(A(u)("Collect VAT")),1)]),_:1},8,["loading"])]),default:d(()=>[o("div",mme,[o("p",hme,m(A(u)("Make sure you're registered for VAT when collecting in the EU.")),1),n(L,{"label-position":"top"},{default:d(()=>[n(T,{label:A(u)("Registration country")},{default:d(()=>[n(U,{modelValue:s.value.country,"onUpdate:modelValue":F[0]||(F[0]=X=>s.value.country=X),placeholder:A(u)("Select country"),filterable:"",class:"w-full",disabled:s.value.isEdit,onChange:y},{default:d(()=>[(r(!0),h(H,null,ae(_.value,X=>(r(),E(x,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","disabled"])]),_:1},8,["label"]),n(T,{label:A(u)("VAT number")},{default:d(()=>[n(D,{modelValue:s.value.vat,"onUpdate:modelValue":F[1]||(F[1]=X=>s.value.vat=X),placeholder:s.value.country?s.value.country+"999999999":"DE999999999"},null,8,["modelValue","placeholder"]),o("div",_me,[o("p",null,m(A(u)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),o("div",vme,[o("div",gme,[o("div",yme,m(A(u)("Tax Classes")),1),F[6]||(F[6]=o("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),F[7]||(F[7]=o("div",{class:"fct-reg-rates-cell-input"},null,-1))]),p.value.length?(r(!0),h(H,{key:0},ae(p.value,X=>(r(),h("div",{key:X.tempKey||X.slug,class:"fct-reg-rates-row"},[o("div",bme,[X.isNew?(r(),E(D,{key:0,modelValue:X.title,"onUpdate:modelValue":G=>X.title=G,size:"small",placeholder:A(u)("Class name"),class:de(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":X.hasError}]),onInput:G=>X.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),h("span",wme,m(X.title),1))]),o("div",Cme,[n(D,{modelValue:s.value.rates[g(X)].rate,"onUpdate:modelValue":G=>s.value.rates[g(X)].rate=G,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:X.slug==="standard"?"19":"0"},{suffix:d(()=>F[8]||(F[8]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",kme,[n(D,{modelValue:s.value.rates[g(X)].label,"onUpdate:modelValue":G=>s.value.rates[g(X)].label=G,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])])]))),128)):(r(),h("div",Bme,[o("div",xme,m(A(u)("Standard")),1),o("div",Sme,[n(D,{modelValue:s.value.rates.standard.rate,"onUpdate:modelValue":F[2]||(F[2]=X=>s.value.rates.standard.rate=X),modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:"19"},{suffix:d(()=>F[9]||(F[9]=[R("%",-1)])),_:1},8,["modelValue"])]),o("div",Fme,[n(D,{modelValue:s.value.rates.standard.label,"onUpdate:modelValue":F[3]||(F[3]=X=>s.value.rates.standard.label=X),size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","placeholder"])])]))]),f.value.length?(r(),h("div",$me,[f.value.length===1&&f.value[0].command==="custom"?(r(),h("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:k},[n(J,{name:"Plus"}),R(" "+m(A(u)("Add class")),1)])):(r(),E(O,{key:1,trigger:"click",onCommand:v},{dropdown:d(()=>[n(V,null,{default:d(()=>[(r(!0),h(H,null,ae(f.value,X=>(r(),E(Q,{key:X.command,command:X.command},{default:d(()=>[R(m(X.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:d(()=>[o("button",Eme,[n(J,{name:"Plus"}),R(" "+m(A(u)("Add class")),1)])]),_:1}))])):B("",!0)]),_:1})])]),_:1},8,["model-value","title"])}}},Ime={class:"fct-oss-rates-section"},Qme=["aria-expanded"],Dme={class:"inline-flex items-center gap-2"},Vme={class:"fct-oss-rates-count"},Tme={class:"fct-oss-rates-table"},Mme={key:1,class:"text-system-mid"},Lme={class:"fct-btn-group mt-4 justify-end sm"},Rme={__name:"EUVatOssRatesSection",setup(e,{expose:t}){const a=M([]),l=M([]),s=M(null),i=M("standard"),c=M(!1),p=M(!1),f=M(!1),_=M(!1),g=M(6),y=M(!1),v=M(""),b=N(()=>a.value),k=N(()=>{const T=v.value.trim().toLowerCase();return T?b.value.filter(D=>D.label&&D.label.toLowerCase().includes(T)):b.value});function w(){return c.value=!0,ce.get("tax/configuration/settings/eu-vat/oss-rates").then(T=>{a.value=T.rates||[],l.value=T.classes||[];const D=Id({classes:l.value,activeId:s.value});return D&&(s.value=D.id,i.value=D.slug),l.value}).catch(T=>{var D;q.error((D=T==null?void 0:T.data)==null?void 0:D.message)}).finally(()=>{c.value=!1})}function S(T){s.value=T.id,i.value=T.slug}function $(T){y.value=!0,zo({payload:{slug:T},createdSlug:T,currentClasses:l.value,reloadClasses:w}).then(({createdClass:D})=>{D&&S(D)}).catch(D=>{var Q;q.error((Q=D==null?void 0:D.data)==null?void 0:Q.message)}).finally(()=>{y.value=!1})}function I(T){y.value=!0,zo({payload:{title:T},currentClasses:l.value,reloadClasses:w}).then(({createdClass:D})=>{D&&S(D)}).catch(D=>{var Q;q.error((Q=D==null?void 0:D.data)==null?void 0:Q.message)}).finally(()=>{y.value=!1})}function F(T){T.slug!=="standard"&&ul(u('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?',T.title),u("Delete Tax Class"),{confirmButtonText:u("Remove"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{c.value=!0,rf({classId:T.id,currentActiveId:s.value===T.id?null:s.value,reloadClasses:w}).then(({nextActiveClass:D})=>{D&&S(D)}).catch(D=>{var Q;q.error((Q=D==null?void 0:D.data)==null?void 0:Q.message),c.value=!1})}).catch(()=>{})}function x(){p.value=!0,ce.post("tax/configuration/settings/eu-vat/oss-rates",{rates:b.value.map(T=>({country:T.country,rate:T.rate,tax_label:T.tax_label||"",class_rates:T.class_rates||{}}))}).then(T=>{q.success(T.message)}).catch(T=>{var D;q.error((D=T==null?void 0:T.data)==null?void 0:D.message)}).finally(()=>{p.value=!1})}function U(){ul(u("This will overwrite all EU destination country standard rates with preset defaults. Continue?"),u("Reset to default tax rates"),{confirmButtonText:u("Reset"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{f.value=!0,ce.post("tax/configuration/settings/eu-vat/reset-rates").then(()=>w()).then(()=>{q.success(u("EU tax rates have been reset to defaults"))}).catch(T=>{var D;q.error(((D=T==null?void 0:T.data)==null?void 0:D.message)||u("Failed to reset rates"))}).finally(()=>{f.value=!1})}).catch(()=>{})}return Ee(w),t({loadRates:w}),(T,D)=>{const Q=C("el-icon"),V=C("el-table-column"),O=C("el-input"),L=C("el-table"),P=C("el-button"),z=Ta("loading");return r(),h("div",Ime,[o("div",{class:"fct-oss-rates-toggle",role:"button",tabindex:"0","aria-expanded":_.value,onClick:D[0]||(D[0]=X=>{_.value=!_.value,_.value||(v.value="")}),onKeydown:[D[1]||(D[1]=Ba(Pe(X=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["enter"])),D[2]||(D[2]=Ba(Pe(X=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["space"]))]},[o("span",Dme,[R(m(A(u)("Destination country rates"))+" ",1),o("span",Vme," ("+m(b.value.length)+") ",1)]),n(Q,{class:de(["fct-oss-rates-arrow",{"is-expanded":_.value}])},{default:d(()=>[n(J,{name:"ChevronDown",class:"w-4 h-4"})]),_:1},8,["class"])],40,Qme),n(Wl,{name:"fct-collapse"},{default:d(()=>[qt(o("div",Tme,[n(el,{type:"info"},{content:d(()=>[o("span",null,m(A(u)("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"))+" + "+m(A(u)("button to add tax classes.")),1)]),_:1}),n(of,{classes:l.value,"active-id":s.value,"max-classes":g.value,creating:y.value,search:v.value,onSwitch:S,onDelete:F,onAdd:$,onCreateCustom:I,"onUpdate:search":D[3]||(D[3]=X=>v.value=X)},null,8,["classes","active-id","max-classes","creating","search"]),qt((r(),E(L,{data:k.value,class:"w-full fct-tax-rates-table","max-height":"450","empty-text":A(u)("No rates found")},{default:d(()=>[n(V,{label:A(u)("Country"),"min-width":"160"},{default:d(({row:X})=>[R(m(X.label),1)]),_:1},8,["label"]),n(V,{label:A(u)("Tax Label"),"min-width":"150"},{default:d(({row:X})=>[X.class_rates&&X.class_rates[i.value]?(r(),E(O,{key:0,modelValue:X.class_rates[i.value].label,"onUpdate:modelValue":G=>X.class_rates[i.value].label=G,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])):B("",!0)]),_:1},8,["label"]),n(V,{label:A(u)("Rate"),"min-width":"120"},{default:d(({row:X})=>[X.class_rates&&X.class_rates[i.value]?(r(),E(O,{key:0,modelValue:X.class_rates[i.value].rate,"onUpdate:modelValue":G=>X.class_rates[i.value].rate=G,modelModifiers:{number:!0},size:"small",type:"number",min:0,max:100,step:"0.5"},{suffix:d(()=>D[4]||(D[4]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])):(r(),h("span",Mme,"—"))]),_:1},8,["label"])]),_:1},8,["data","empty-text"])),[[z,c.value]]),o("div",Lme,[i.value==="standard"?(r(),E(P,{key:0,size:"small",loading:f.value,onClick:U,type:"danger",soft:""},{default:d(()=>[R(m(A(u)("Reset to default")),1)]),_:1},8,["loading"])):B("",!0),n(P,{type:"primary",size:"small",loading:p.value,onClick:x},{default:d(()=>[R(m(A(u)("Save Rates")),1)]),_:1},8,["loading"])])],512),[[Tl,_.value]])]),_:1})])}}},Ome={class:"fct-vat-card-header"},Hme={class:"fct-vat-card-title"},Pme={class:"fct-vat-card-body"},Nme={class:"fct-vat-reg-info"},Kme={class:"fct-vat-country-name"},Gme={key:0,size:"small",type:"success",class:"ml-3 fct-collecting-badge"},jme={key:1,class:"ml-3 text-sm text-system-mid dark:text-gray-400"},zme={key:2,class:"fct-country-registrations-list mt-4"},qme={class:"fct-reg-rows"},Yme={key:0,class:"fct-vat-registration-row"},Wme={class:"fct-vat-reg-info"},Jme=["src","alt"],Xme={class:"fct-vat-country-name"},Zme={class:"fct-vat-reg-info"},ehe=["src","alt"],the={class:"fct-vat-country-name"},ahe={key:0,class:"fct-vat-number"},lhe={key:1,class:"fct-vat-missing-badge"},she={class:"fct-vat-reg-actions"},nhe={key:1,class:"fct-vat-empty-state"},ohe={class:"text-system-mid text-sm"},ihe={key:0,class:"px-5 py-3"},rhe={key:1,class:"fct-vat-cross-border-empty"},dhe={class:"fct-vat-cross-border-empty-text"},uhe={class:"fct-vat-cross-border-empty-title"},che={class:"fct-vat-cross-border-empty-desc"},Ahe={__name:"EUVatCrossBorderCard",props:{countries:{type:Array,default:()=>[]},initialForm:{type:Object,default:()=>({})},initialRegistrations:{type:Array,default:()=>[]},storeCountry:{type:String,default:""},isTaxEnabled:{type:Boolean,default:!0}},emits:["method-changed"],setup(e,{emit:t}){const a=e,l=t,s=M({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),i=M(!1),c=M(null),p=M([]),f=M(!1),_=M({country:"",vat:"",rates:{},isEdit:!1}),g=N(()=>a.countries.length||28),y=N(()=>a.initialRegistrations.filter(I).length),v=N(()=>a.storeCountry&&a.countries.find(ee=>ee.value===a.storeCountry)||null),b=N(()=>a.storeCountry?a.initialRegistrations.some(ee=>ee.country===a.storeCountry):!1),k=N(()=>{if(s.value.method!=="home"||!s.value.home_country)return!1;const ee=a.initialRegistrations.find(oe=>oe.country===s.value.home_country);return!!ee&&I(ee)}),w=N(()=>s.value.method==="oss"||s.value.method==="home"||s.value.method==="specific");function S(ee){if(!ee||!Array.isArray(a.countries))return ee;const oe=a.countries.find(re=>re.value===ee);return oe?oe.label:ee}function $(ee){return ee?ee.rates&&typeof ee.rates=="object"&&Object.keys(ee.rates).length?Object.values(ee.rates).some(oe=>oe&&parseFloat(oe.rate)>0):parseFloat(ee.rate)>0:!1}function I(ee){return!!ee&&!!ee.vat&&$(ee)}function F(ee){return $(ee)&&!ee.vat}function x(){return ce.get("tax/classes").then(ee=>{p.value=ee.classes||[]}).catch(()=>{q.error(u("Failed to load tax classes"))})}function U(ee){const oe={};return p.value.forEach(re=>{oe[re.slug]={rate:re.slug==="standard"&&ee||"",label:""}}),oe}function T(){const ee=v.value&&!b.value?a.storeCountry:"",oe=ee&&v.value&&v.value.default_rate||"";_.value={country:ee,vat:"",rates:U(oe),isEdit:!1},f.value=!0}function D(ee){const oe=ee.rates||{},re={};p.value.forEach(K=>{const Y=oe[K.slug];if(Y&&typeof Y=="object")re[K.slug]={rate:Y.rate||"",label:Y.label||""};else{const W=K.slug==="standard"?ee.rate||"":Y||"";re[K.slug]={rate:W,label:K.slug==="standard"&&ee.tax_label||""}}}),_.value={country:ee.country,vat:ee.vat||"",rates:re,isEdit:!0},f.value=!0}function Q(){x(),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}function V(ee){ce.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:ee.country,vat:ee.vat,rates:ee.rates}).then(oe=>{q.success(oe.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:ee.vat})}).catch(oe=>{var re;q.error(((re=oe==null?void 0:oe.data)==null?void 0:re.message)||u("Failed to save VAT registration"))})}function O(ee){ul(u("Are you sure you want to remove this country registration?"),u("Confirm Remove"),{confirmButtonText:u("Yes, Remove"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ce.post("tax/configuration/settings/eu-vat",{action:"deleteCountryRegistration",country:ee}).then(oe=>{q.success(oe.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}).catch(oe=>{var re;q.error((re=oe==null?void 0:oe.data)==null?void 0:re.message)})}).catch(()=>{})}function L(){return y.value===1?u("Collecting in 1 country"):u("Collecting in %1$s countries",y.value)}const P=N(()=>g.value===1?u("Collecting in 1 region"):u("Collecting in %1$s regions",g.value));function z(ee){s.value={method:ee.method,oss_country:ee.oss_country,oss_vat:ee.oss_vat,home_country:ee.home_country,home_vat:ee.home_country_vat},ee.method==="oss"&&Be(()=>{var oe;return(oe=c.value)==null?void 0:oe.loadRates()}),l("method-changed",{method:ee.method,home_country:ee.home_country,home_vat:ee.home_country_vat})}function X(ee){ee==="edit"?i.value=!0:ee==="stop"&&G()}function G(){ul(u("Are you sure you want to stop collecting cross-border VAT? This will clear your OSS/home country registration."),u("Stop Collecting"),{confirmButtonText:u("Yes, Stop"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ce.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:{method:"specific"},reset_registration:"yes"}).then(ee=>{q.success(ee.message),s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""},l("method-changed",{method:"",home_country:"",home_vat:""})}).catch(ee=>{var oe;q.error((oe=ee==null?void 0:ee.data)==null?void 0:oe.message)})}).catch(()=>{})}return ye(()=>a.initialForm,ee=>{const oe=ee||{};s.value={method:oe.method||"",oss_country:oe.oss_country||"",oss_vat:oe.oss_vat||"",home_country:oe.home_country||"",home_vat:oe.home_vat||""}},{immediate:!0}),ye(()=>a.countries,ee=>{ee&&ee.length&&x()},{immediate:!0}),(ee,oe)=>{const re=C("el-tooltip"),K=C("el-dropdown-item"),Y=C("el-dropdown-menu"),W=C("el-dropdown"),j=C("el-button");return r(),h(H,null,[n(ke,{class:"fct-vat-card"},{default:d(()=>[n(Ce,null,{default:d(()=>[o("div",Ome,[o("div",Hme,[o("h3",null,m(A(u)("Collect VAT cross-border")),1),n(re,{content:A(u)("Choose how to collect VAT for sales to other EU countries."),placement:"top"},{default:d(()=>[n(J,{name:"InformationFill",class:"w-4 h-4 text-system-mid cursor-pointer"})]),_:1},8,["content"])]),w.value?(r(),E(W,{key:0,trigger:"click",onCommand:X,"popper-class":"fct-dropdown",placement:"bottom-end"},{dropdown:d(()=>[n(Y,null,{default:d(()=>[n(K,{command:"edit"},{default:d(()=>[R(m(A(u)("Edit registration")),1)]),_:1}),n(K,{command:"stop"},{default:d(()=>[R(m(A(u)("Stop collecting")),1)]),_:1})]),_:1})]),default:d(()=>[n(et,{border:"none",size:"small",tag:"button"},{default:d(()=>[n(J,{name:"More"})]),_:1})]),_:1})):B("",!0)]),o("div",Pme,[w.value?(r(),h(H,{key:0},[o("div",Nme,[oe[4]||(oe[4]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("span",Kme,m(s.value.method==="oss"?A(u)("EU (OSS)"):s.value.method==="home"?A(u)("EU (micro-business)"):A(u)("EU (specific countries)")),1),e.isTaxEnabled&&(s.value.method!=="specific"||y.value>0)?(r(),h("span",Gme,[oe[3]||(oe[3]=o("span",{class:"fct-green-dot"},null,-1)),s.value.method==="specific"?(r(),h(H,{key:0},[R(m(L()),1)],64)):(r(),h(H,{key:1},[R(m(P.value),1)],64))])):B("",!0),e.isTaxEnabled?B("",!0):(r(),h("span",jme,m(A(u)("Tax disabled")),1))]),s.value.method==="home"?(r(),E(el,{key:0,type:k.value?"info":"warning",icon:"Info",class:"mb-4 mt-4",content:k.value?A(u)("Collecting cross-border EU VAT at your %1$s home country rate. This is for small businesses whose total cross-border EU sales stay below €10,000/year. Once you exceed that threshold you must charge each buyer's local VAT rate instead.",S(s.value.home_country)):A(u)("Your %1$s home country VAT rate will apply to all EU cross-border sales. This is available for small businesses below €10,000/year in cross-border EU sales. Make sure %1$s is registered below with the correct rate.",S(s.value.home_country))},null,8,["type","content"])):B("",!0),s.value.method==="home"?(r(),E(fme,{key:1,countries:e.countries,"home-country":s.value.home_country,"home-vat":s.value.home_vat,"tax-classes":p.value,registrations:e.initialRegistrations,onSaveHome:V,onClassChanged:x},null,8,["countries","home-country","home-vat","tax-classes","registrations"])):B("",!0),s.value.method==="specific"?(r(),h("div",zme,[o("div",qme,[v.value&&!b.value?(r(),h("div",Yme,[o("div",Wme,[o("img",{src:`https://flagcdn.com/w40/${e.storeCountry.toLowerCase()}.png`,alt:v.value.label,class:"fct-flag-icon"},null,8,Jme),o("span",Xme,m(v.value.label),1)]),n(j,{size:"small",onClick:T},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})])):B("",!0),(r(!0),h(H,null,ae(e.initialRegistrations,ie=>(r(),h("div",{key:ie.country,class:"fct-vat-registration-row"},[o("div",Zme,[o("img",{src:`https://flagcdn.com/w40/${ie.country.toLowerCase()}.png`,alt:S(ie.country),class:"fct-flag-icon"},null,8,ehe),o("span",the,m(S(ie.country)),1),ie.vat?(r(),h("span",ahe,m(ie.vat),1)):F(ie)?(r(),h("span",lhe,m(A(u)("VAT ID missing")),1)):B("",!0)]),o("div",she,[$(ie)?(r(),E(et,{key:0,border:"none",size:"small",tag:"button",title:A(u)("Edit"),onClick:_e=>D(ie)},{default:d(()=>[n(J,{name:"Edit"})]),_:2},1032,["title","onClick"])):(r(),E(j,{key:1,size:"small",onClick:_e=>D(ie)},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:2},1032,["onClick"])),n(et,{border:"none",size:"small",tag:"button",title:A(u)("Delete"),onClick:_e=>O(ie.country)},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["title","onClick"])])]))),128)),!e.initialRegistrations.length&&!v.value?(r(),h("div",nhe,[o("p",ohe,m(A(u)("No country VAT registrations configured.")),1),n(j,{type:"primary",size:"small",onClick:T},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})])):B("",!0)]),e.initialRegistrations.length||v.value?(r(),h("div",ihe,[n(j,{type:"primary",link:"",onClick:T},{default:d(()=>[R(" + "+m(A(u)("Collect in another country")),1)]),_:1})])):B("",!0)])):B("",!0),s.value.method==="oss"?(r(),E(Rme,{key:3,ref_key:"ossRatesRef",ref:c},null,512)):B("",!0)],64)):(r(),h("div",rhe,[oe[5]||(oe[5]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("div",dhe,[o("p",uhe,m(A(u)("Not collecting cross-border VAT")),1),o("p",che,m(A(u)("Set up OSS, micro-business, or specific-country registrations to collect VAT across the EU.")),1)]),n(j,{size:"small",onClick:oe[0]||(oe[0]=ie=>i.value=!0),type:"primary"},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})]))])]),_:1})]),_:1}),n(jfe,{modelValue:i.value,"onUpdate:modelValue":oe[1]||(oe[1]=ie=>i.value=ie),countries:e.countries,"current-form":s.value,"initial-registrations":e.initialRegistrations,onSaved:z},null,8,["modelValue","countries","current-form","initial-registrations"]),n(Ume,{modelValue:f.value,"onUpdate:modelValue":oe[2]||(oe[2]=ie=>f.value=ie),countries:e.countries,"tax-classes":p.value,"initial-form":_.value,"registered-countries":e.initialRegistrations.map(ie=>ie.country),onSaved:Q},null,8,["modelValue","countries","tax-classes","initial-form","registered-countries"])],64)}}},phe={__name:"EUVatTaxOverrideModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},taxClasses:{type:Array,default:()=>[]},editRow:{type:Object,default:null}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=M({type:"products",original_type:"",original_id:"",category_id:"",category_name:"",country:"",city:"",postcode:"",tax_label:"VAT",tax_rate:0,class_id:0,id:""}),i=M([]),c=M(!1),p=M(!1);function f(){return a.taxClasses&&a.taxClasses.length>0&&Number(a.taxClasses[0].id)||0}function _(){s.value={type:"products",original_type:"",original_id:"",category_id:"",category_name:"",country:"",city:"",postcode:"",tax_label:"VAT",tax_rate:0,class_id:0,id:""}}function 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 S=w._raw.meta_value||w._raw;s.value={type:"products",original_type:"products",original_id:w.id,category_id:en(S.category_id),category_name:w.category_name,country:S.country||"",city:S.city||"",postcode:S.postcode||"",tax_label:w.tax_label,tax_rate:w.rate,class_id:Number(w.class_id)||0,id:w.id}}}ye(()=>a.modelValue,w=>{w&&(a.editRow?g(a.editRow):_(),y())}),ye(()=>s.value.type,w=>{w==="shipping"&&!s.value.class_id&&(s.value.class_id=f())}),ye(()=>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(){i.value.length>0||(c.value=!0,ce.get("products/fetch-term").then(w=>{const S=w.taxonomies&&w.taxonomies["product-categories"]?w.taxonomies["product-categories"].terms||[]:[];i.value=S.map($=>({...$,value:en($.value)}))}).catch(()=>{q.error(u("Failed to load product categories"))}).finally(()=>{c.value=!1}))}function v(w,S){return ce.get("tax/rates/country/rates/"+w,{class_id:S}).then($=>{const F=($&&$.tax_rates?$.tax_rates:[]).find(function(U){return!U.state&&!U.city&&!U.postcode});if(F)return F;const x=a.countries.find(function(U){return U.value===w});return ce.post("tax/country/rate",{country:w,state:"",rate:x&&x.default_rate||0,name:"Tax",is_compound:0,for_order:0,group:"EU",class_id:S}).then(function(U){return U&&U.tax_rate?U.tax_rate:null})})}function b(w){const S=en(w),$=i.value.find(I=>I.value===S);$&&(s.value.category_name=$.label)}function k(){if(s.value.type==="products"&&!s.value.category_id){q.error(u("Please select a category"));return}if(!s.value.country){q.error(u("Please select a location"));return}if(s.value.type==="shipping"){if(!a.taxClasses||a.taxClasses.length===0){q.error(u("Tax classes are not available. Please reload the page and try again."));return}if(!s.value.class_id){q.error(u("Please select a tax class"));return}}if(p.value=!0,s.value.type==="products")ce.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),l("saved"),l("update:modelValue",!1)}).catch(w=>{q.error(w&&w.data?w.data.message:w&&w.message?w.message:"")}).finally(()=>{p.value=!1});else{const w=s.value.class_id;v(s.value.country,w).then(S=>S?ce.post("tax/rates/country/override",{id:S.id,previous_id:s.value.original_type==="shipping"?s.value.original_id:"",source_type:s.value.original_type,source_id:s.value.original_id,class_id:w,override_tax_rate:s.value.tax_rate,city:s.value.city||"",postcode:s.value.postcode||""}).then($=>{q.success($.message),l("saved"),l("update:modelValue",!1)}).catch($=>{q.error($&&$.data?$.data.message:$&&$.message?$.message:"")}).finally(()=>{p.value=!1}):(q.error(u("No tax rate found for the selected country and tax class")),p.value=!1,null)).catch(S=>{q.error(S&&S.data?S.data.message:S&&S.message?S.message:""),p.value=!1})}}return(w,S)=>{const $=C("el-radio"),I=C("el-radio-group"),F=C("el-form-item"),x=C("el-option"),U=C("el-select"),T=C("el-input"),D=C("el-form"),Q=C("el-button"),V=C("el-dialog");return r(),E(V,{"model-value":e.modelValue,title:e.editRow?A(u)("Edit tax override"):A(u)("Add tax override"),width:"520px","close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":S[14]||(S[14]=O=>l("update:modelValue",O))},{footer:d(()=>[n(Q,{onClick:S[13]||(S[13]=O=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(Q,{type:"primary",loading:p.value,onClick:k},{default:d(()=>[R(m(e.editRow?A(u)("Save changes"):A(u)("Add override")),1)]),_:1},8,["loading"])]),default:d(()=>[n(D,{"label-position":"top",model:s.value},{default:d(()=>[n(F,{label:A(u)("Override type")},{default:d(()=>[n(I,{modelValue:s.value.type,"onUpdate:modelValue":S[0]||(S[0]=O=>s.value.type=O)},{default:d(()=>[n($,{value:"products"},{default:d(()=>[R(m(A(u)("Products")),1)]),_:1}),n($,{value:"shipping"},{default:d(()=>[R(m(A(u)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),s.value.type==="products"?(r(),h(H,{key:0},[n(F,{label:A(u)("Category")},{default:d(()=>[n(U,{modelValue:s.value.category_id,"onUpdate:modelValue":S[1]||(S[1]=O=>s.value.category_id=O),filterable:"",placeholder:A(u)("Select a category"),loading:c.value,style:{width:"100%"},onChange:b},{default:d(()=>[(r(!0),h(H,null,ae(i.value,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),e.taxClasses.length>0?(r(),E(F,{key:0,label:A(u)("Tax Class")},{default:d(()=>[n(U,{modelValue:s.value.class_id,"onUpdate:modelValue":S[2]||(S[2]=O=>s.value.class_id=O),style:{width:"100%"}},{default:d(()=>[n(x,{value:0,label:A(u)("All Tax Classes")},null,8,["label"]),(r(!0),h(H,null,ae(e.taxClasses,O=>(r(),E(x,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):B("",!0),n(F,{label:A(u)("Tax label")},{default:d(()=>[n(T,{modelValue:s.value.tax_label,"onUpdate:modelValue":S[3]||(S[3]=O=>s.value.tax_label=O),placeholder:A(u)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Location")},{default:d(()=>[n(U,{modelValue:s.value.country,"onUpdate:modelValue":S[4]||(S[4]=O=>s.value.country=O),placeholder:A(u)("Select country"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(e.countries,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("City (optional)")},{default:d(()=>[n(T,{modelValue:s.value.city,"onUpdate:modelValue":S[5]||(S[5]=O=>s.value.city=O),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(T,{modelValue:s.value.postcode,"onUpdate:modelValue":S[6]||(S[6]=O=>s.value.postcode=O),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(T,{modelValue:s.value.tax_rate,"onUpdate:modelValue":S[7]||(S[7]=O=>s.value.tax_rate=O),type:"number",step:"0.01",min:"0",placeholder:A(u)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])],64)):(r(),h(H,{key:1},[n(F,{label:A(u)("Location")},{default:d(()=>[n(U,{modelValue:s.value.country,"onUpdate:modelValue":S[8]||(S[8]=O=>s.value.country=O),placeholder:A(u)("Select country"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(e.countries,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),e.taxClasses.length>0?(r(),E(F,{key:0,label:A(u)("Tax Class")},{default:d(()=>[n(U,{modelValue:s.value.class_id,"onUpdate:modelValue":S[9]||(S[9]=O=>s.value.class_id=O),style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(e.taxClasses,O=>(r(),E(x,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):B("",!0),n(F,{label:A(u)("City (optional)")},{default:d(()=>[n(T,{modelValue:s.value.city,"onUpdate:modelValue":S[10]||(S[10]=O=>s.value.city=O),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(T,{modelValue:s.value.postcode,"onUpdate:modelValue":S[11]||(S[11]=O=>s.value.postcode=O),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(T,{modelValue:s.value.tax_rate,"onUpdate:modelValue":S[12]||(S[12]=O=>s.value.tax_rate=O),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["model-value","title"])}}},fhe={class:"fct-tax-rates-country-view"},mhe={key:0,class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},hhe={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"},_he={key:0},vhe={key:1},ghe={class:"fct-btn-group sm justify-end"},yhe={__name:"EUVatTaxOverridesCard",props:{countries:{type:Array,default:()=>[]}},setup(e){const t=e,a=M([]),l=M(!1),s=M(!1),i=M(null),c=M([]);function p(b){if(!b||!Array.isArray(t.countries))return b;const k=t.countries.find(w=>w.value===b);return k?k.label:b}function f(){ce.get("tax/classes").then(b=>{c.value=b.classes||[]}).catch(()=>{q.error(u("Failed to load tax classes"))})}function _(){l.value=!0,ce.get("tax/configuration/settings/eu-vat/product-overrides").then(b=>{const k=[],w=b.overrides||[];for(const $ of w){const I=$.meta_value||$;k.push({id:$.id,type:"products",tax_label:I.tax_label||"",category_name:I.category_name||"",location:p(I.country),city:I.city||"",postcode:I.postcode||"",rate:I.rate,class_id:Number($.class_id)||0,class_label:$.class_label||"",_raw:$})}const S=b.shipping_overrides||[];for(const $ of S)k.push({id:$.id,type:"shipping",tax_label:$.name||"",category_name:"",location:p($.country),city:$.city||"",postcode:$.postcode||"",rate:$.for_shipping,class_id:Number($.class_id)||0,class_label:$.class_label||"",_raw:$});a.value=k}).catch(()=>{a.value=[]}).finally(()=>{l.value=!1})}function g(){i.value=null,s.value=!0}function y(b){i.value=b,s.value=!0}function v(b){ul(u("Are you sure you want to delete this override?"),u("Confirm Delete"),{confirmButtonText:u("Yes, Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{const k=b.type==="shipping"?"tax/rates/country/override/"+b.id:"tax/product-overrides/"+b.id;ce.delete(k).then(w=>{q.success(w.message),a.value=a.value.filter(S=>!(S.id===b.id&&S.type===b.type))}).catch(w=>{var S;q.error((S=w==null?void 0:w.data)==null?void 0:S.message)})}).catch(()=>{})}return Ee(()=>{f(),_()}),(b,k)=>{const w=C("el-button"),S=C("el-tag"),$=C("el-table-column"),I=C("el-table");return r(),h(H,null,[n(ke,{class:"fct-vat-card"},{default:d(()=>[n(Ie,{title:A(u)("Tax overrides"),text:A(u)("Override tax rates for specific product categories or shipping.")},{action:d(()=>[n(w,{size:"small",onClick:g},{default:d(()=>[R(m(A(u)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(Ce,null,{default:d(()=>[o("div",fhe,[l.value?(r(),h("div",mhe,[o("div",hhe,[(r(),h(H,null,ae(6,F=>o("div",{key:"loading-header-"+F,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),h(H,null,ae(3,F=>o("div",{key:"loading-row-"+F,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"},k[2]||(k[2]=[o("div",{class:"fct-sk w-16 h-6 rounded-full"},null,-1),o("div",{class:"fct-sk w-28 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-24 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-24 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-12 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-4 h-4 rounded-xs justify-self-end"},null,-1)]))),64))])):(r(),E(I,{key:1,data:a.value,"empty-text":A(u)("No overrides configured")},{default:d(()=>[n($,{label:A(u)("Type"),width:"110"},{default:d(({row:F})=>[n(S,{type:F.type==="products"?"primary":"info",size:"small"},{default:d(()=>[R(m(F.type==="products"?A(u)("Product"):A(u)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n($,{label:A(u)("Category")},{default:d(({row:F})=>[R(m(F.category_name||"—"),1)]),_:1},8,["label"]),n($,{label:A(u)("Tax Class"),width:"130"},{default:d(({row:F})=>[R(m(F.class_label||A(u)("All")),1)]),_:1},8,["label"]),n($,{label:A(u)("Tax Label")},{default:d(({row:F})=>[R(m(F.tax_label||"—"),1)]),_:1},8,["label"]),n($,{label:A(u)("Location")},{default:d(({row:F})=>[R(m(F.location),1)]),_:1},8,["label"]),n($,{label:A(u)("City / Postcode")},{default:d(({row:F})=>[F.city||F.postcode?(r(),h("span",_he,m([F.city,F.postcode].filter(Boolean).join(" / ")),1)):(r(),h("span",vhe,"—"))]),_:1},8,["label"]),n($,{label:A(u)("Rate"),width:"100"},{default:d(({row:F})=>[R(m(F.rate)+"% ",1)]),_:1},8,["label"]),n($,{label:A(u)("Actions"),width:"110",align:"right"},{default:d(({row:F})=>[o("div",ghe,[n(et,{tag:"button",size:"small",onClick:x=>y(F)},{default:d(()=>[n(J,{name:"Edit"})]),_:2},1032,["onClick"]),n(et,{tag:"button",size:"small",onClick:x=>v(F),bg:"danger",outline:""},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"]))])]),_:1})]),_:1}),n(phe,{modelValue:s.value,"onUpdate:modelValue":[k[0]||(k[0]=F=>s.value=F),k[1]||(k[1]=F=>!F&&(i.value=null))],countries:e.countries,"tax-classes":c.value,"edit-row":i.value,onSaved:_},null,8,["modelValue","countries","tax-classes","edit-row"])],64)}}},bhe={class:"setting-wrap"},whe={class:"setting-wrap-inner"},Che={class:"fct-tax-collection-page"},khe={__name:"EUVatSettings",setup(e){const t=M(!0),a=je.get("eu_vat_county_options",[]),l=M(""),s=M(""),i=M([]),c=M({}),p=N(()=>!!je.get("is_tax_enabled"));function f(){return t.value=!0,ce.get("tax/configuration/settings").then(g=>{var v;const y=((v=g.settings)==null?void 0:v.eu_vat_settings)||{};l.value=g.store_country||"",i.value=y.country_registrations||[],c.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 _({method:g}){s.value=g||"",f()}return Ee(f),(g,y)=>(r(),h("div",bhe,[n(Ua,{heading:A(u)("VAT collection"),"show-save-button":!1},null,8,["heading"]),o("div",whe,[n(Ia),o("div",Che,[t.value?(r(),E(Vfe,{key:0})):(r(),h(H,{key:1},[n(Ahe,{countries:A(a),"initial-form":c.value,"initial-registrations":i.value,"store-country":l.value,"is-tax-enabled":p.value,onMethodChanged:_},null,8,["countries","initial-form","initial-registrations","store-country","is-tax-enabled"]),n(yhe,{countries:A(a),class:"mt-5"},null,8,["countries"])],64))])])]))}};class Bhe extends Qs{getTabs(){return{all:u("All"),active:u("Active"),expired:u("Inactive")}}getToggleableColumns(){return[{label:"Title",value:"title"},{label:"Stackable",value:"stackable"},{label:"Actions",value:"actions"}]}getSearchHint(){return u("Search by id, title, amount, code.")}getFetchUrl(){return"coupons"}parseResponse(t){return t.coupons}getTableName(){return"coupon_table"}getAdvanceFilterOptions(){return null}getSearchGuideOptions(){return[]}with(){return[]}}function df(e){return Bhe.init(e)}const xhe={class:"fct-table-mobile-wrap fct-coupons-table-mobile-wrap"},She={class:"fct-table-mobile-header"},Fhe={class:"fct-table-mobile-header-left"},$he={class:"fct-table-id-col"},Ehe={class:"fct-table-status-col"},Uhe=["onClick"],Ihe={class:"title"},Qhe={class:"value"},Dhe={key:0,class:"fct-table-action-col"},Vhe={class:"more-btn pr-0"},The={class:"fct-table-mobile-body"},Mhe=["onClick"],Lhe={key:0,class:"fct-table-coupon-title-col"},Rhe={class:"fct-table-coupon-code-col"},Ohe=["onClick"],Hhe={class:"fct-table-mobile-footer"},Phe=["onClick"],Nhe={class:"fct-table-date-col grid"},Khe={class:"title"},Ghe={class:"value"},jhe={key:0,class:"fct-table-stackable-col"},zhe={class:"title"},qhe={class:"value"},Yhe={class:"fct-table-amount-col"},Whe={class:"title"},Jhe={class:"value"},Xhe={__name:"CouponsTableMobile",props:{table:{type:Object,required:!0},emptyText:{type:String,default:u("No customers found.")}},setup(e){lt.extend(di);const t=e,a=s=>{if(!s||s==="0000-00-00 00:00:00")return!1;const i=lt.utc(s).local();return i.isValid()?i.isBefore(lt()):!1},l=s=>{let i=u("Are you sure you want to delete this %s coupon. This action is not recoverable",s.coupon.title);s.action==="delete"&&ul(i,u("Confirm Delete!"),{confirmButtonText:u("Yes, Delete!"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ce.delete("coupons/"+s.coupon.id).then(c=>{q.success(c.message),t.table.fetch()}).catch(c=>{q.error(c)}).finally(()=>{})}).catch(()=>{})};return(s,i)=>{const c=C("router-link"),p=C("el-tooltip"),f=C("el-dropdown-item"),_=C("el-dropdown-menu"),g=C("el-dropdown");return r(),h("div",xhe,[(r(!0),h(H,null,ae(e.table.getTableData(),(y,v)=>(r(),h("div",{key:y.id,class:"fct-table-mobile-row"},[o("div",She,[o("div",Fhe,[o("div",$he,[n(c,{to:{name:"add_or_edit_coupon",params:{coupon_id:y.id}},class:"id"},{default:d(()=>[R(" #"+m(y.id),1)]),_:2},1032,["to"])]),o("div",Ehe,[n(pa,{status:y.status},{default:d(()=>[R(m(a(y.end_date)?A(u)("Expired"):y.status),1)]),_:2},1032,["status"]),y.status==="scheduled"?(r(),E(p,{key:0,effect:"dark",placement:"top","popper-class":"fct-label-hint-popover fct-tooltip","show-after":400,"hide-after":0},{content:d(()=>[R(m(A(u)("Available On: %s",A($s)(y.start_date,!0))),1)]),default:d(()=>[n(J,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):B("",!0)]),o("div",{class:"fct-table-usage-col",onClick:b=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[o("div",Ihe,m(A(u)("Usage:")),1),o("div",Qhe,[R(m(y.use_count??0)+" ",1),i[0]||(i[0]=o("span",null,"/",-1)),R(" "+m(y.conditions.max_uses>0?y.conditions.max_uses:A(u)("Unlimited")),1)])],8,Uhe)]),e.table.isColumnVisible("actions")?(r(),h("div",Dhe,[n(g,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l,placement:"bottom-end"},{dropdown:d(()=>[n(_,null,{default:d(()=>[y.id?(r(),E(f,{key:0,class:"item-link"},{default:d(()=>[n(c,{to:{name:"add_or_edit_coupon",params:{coupon_id:y.id,action:"edit"}}},{default:d(()=>[n(J,{name:"Edit"}),R(" "+m(A(u)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),n(f,{command:{action:"delete",coupon:y},class:"item-destructive"},{default:d(()=>[n(J,{name:"Delete"}),R(" "+m(A(u)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:d(()=>[o("span",Vhe,[n(J,{name:"More"})])]),_:2},1024)])):B("",!0)]),o("div",The,[o("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")?(r(),h("div",Lhe,m(y.title),1)):B("",!0),o("div",Rhe,[o("code",{class:"copyable-content",onClick:b=>{A(Zl).copy(y.code)}},m(y.code),9,Ohe)])],8,Mhe)]),o("div",Hhe,[o("div",{class:"fct-table-mobile-footer-row items-start",onClick:b=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[o("div",Nhe,[o("div",Khe,m(A(u)("Expiry Date")),1),o("div",Ghe,[isNaN(Date.parse(y.end_date))?(r(),h(H,{key:1},[R("n/a")],64)):(r(),E(Ha,{key:0,"date-time":y.end_date,"with-time":!0},null,8,["date-time"]))])]),e.table.isColumnVisible("stackable")?(r(),h("div",jhe,[o("div",zhe,m(A(u)("Stackable")),1),o("div",qhe,m(y.stackable),1)])):B("",!0),o("div",Yhe,[o("div",Whe,m(A(u)("Amount")),1),o("div",Jhe,m(y.type!=="percentage"?A(Nt)(y.amount,!0):y.amount+"%"),1)])],8,Phe)])]))),128))])}}},Zhe={},e_e={class:"px-4 py-3"},t_e={class:"grid grid-cols-3 gap-5 mt-5"};function a_e(e,t){const a=C("el-skeleton-item"),l=C("el-skeleton");return r(),E(l,{animated:""},{template:d(()=>[o("div",e_e,[(r(),h(H,null,ae(2,s=>o("div",{key:s,class:"flex items-center justify-between mb-3"},[n(a,{varient:"p",class:"w-1/2"}),n(a,{varient:"p",class:"w-[100px]"})])),64)),o("div",t_e,[(r(),h(H,null,ae(3,s=>o("div",{key:s},[n(a,{varient:"p",class:"w-1/2"}),n(a,{varient:"p",class:"w-[100px]"})])),64))])])]),_:1})}const l_e=st(Zhe,[["render",a_e]]),s_e={class:"fct-all-coupons-page fct-layout-width"},n_e={class:"fct-all-coupons-wrap"},o_e={key:1},i_e=["onClick"],r_e={class:"capitalize"},d_e={class:"more-btn mr-2"},_c={__name:"AllCoupons",setup(e){lt.extend(di);const t=df(),a=M(!1),l=c=>{let p=u("Are you sure you want to delete this %s coupon. This action is not recoverable",c.coupon.title);c.action==="delete"&&ul(p,u("Confirm Delete!"),{confirmButtonText:u("Yes, Delete!"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ce.delete("coupons/"+c.coupon.id).then(f=>{q.success(f.message),t.fetch()}).catch(f=>{var _;f.status_code=="422"?q.validationErrors(f):q.error((_=f.data)==null?void 0:_.message)}).finally(()=>{})}).catch(()=>{})},s=()=>{ce.get("coupons/getSettings").then(c=>{a.value=!!parseInt(c.show_on_checkout)}).catch(c=>{var p;c.status_code=="422"?q.validationErrors(c):q.error((p=c.data)==null?void 0:p.message)}).finally(()=>{})},i=c=>{if(!c||c==="0000-00-00 00:00:00")return!1;const p=lt.utc(c).local();return p.isValid()?p.isBefore(lt()):!1};return Ee(()=>{s()}),(c,p)=>{const f=C("el-button"),_=C("el-table-column"),g=C("el-tooltip"),y=C("router-link"),v=C("el-dropdown-item"),b=C("el-dropdown-menu"),k=C("el-dropdown"),w=C("el-table");return r(),E(Rt,{permission:"coupons/view"},{default:d(()=>[o("div",s_e,[n(ol,{title:A(u)("Coupons")},{action:d(()=>[n(f,{tag:"router-link",type:"primary",to:{name:"add_or_edit_coupon"}},{default:d(()=>[R(m(A(u)("Add Coupon")),1)]),_:1})]),_:1},8,["title"]),o("div",n_e,[n(Ds,{table:A(t),"has-mobile-slot":!0},{mobile:d(()=>[A(t).isLoading()?(r(),E(l_e,{key:0})):B("",!0),A(t).isLoading()?B("",!0):(r(),E(Xhe,{key:1,table:A(t)},null,8,["table"]))]),default:d(()=>[A(t).isLoading()?(r(),E(nfe,{key:0,couponTable:A(t),"next-page-count":A(t).nextPageCount},null,8,["couponTable","next-page-count"])):(r(),h("div",o_e,[n(w,{data:A(t).getTableData(),class:"w-full compact-table full-compact"},{empty:d(()=>[n(Ct,{icon:"Empty/Order","has-dark":"",text:A(u)("No coupons available at the moment.")},null,8,["text"])]),default:d(()=>[n(_,{width:100,label:A(u)("ID")},{default:d(S=>[n(ka,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id}}},{default:d(()=>[R(" #"+m(A(la)(S.row.id)),1)]),_:2},1032,["to"])]),_:1},8,["label"]),A(t).isColumnVisible("title")?(r(),E(_,{key:0,label:A(u)("Title"),width:220},{default:d(S=>[n(ka,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[R(m(S.row.title),1)]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),n(_,{label:A(u)("Code"),width:200},{default:d(S=>[o("code",{class:"copyable-content",onClick:$=>{A(Zl).copy(S.row.code)}},m(S.row.code),9,i_e)]),_:1},8,["label"]),n(_,{label:A(u)("Amount"),width:120},{default:d(S=>[n(ka,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[R(m(S.row.type!=="percentage"?A(Nt)(S.row.amount,!0):S.row.amount+"%"),1)]),_:2},1032,["to"])]),_:1},8,["label"]),n(_,{label:A(u)("Usage"),width:150},{default:d(S=>[n(ka,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[o("span",null,m(A(la)(S.row.use_count??0)),1),p[0]||(p[0]=o("span",{class:"px-1"},"/",-1)),o("span",null,m(S.row.conditions.max_uses>0?S.row.conditions.max_uses:A(u)("Unlimited")),1)]),_:2,__:[0]},1032,["to"])]),_:1},8,["label"]),A(t).isColumnVisible("stackable")?(r(),E(_,{key:1,label:A(u)("Stackable"),width:120},{default:d(S=>[n(ka,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[o("span",r_e,m(S.row.stackable),1)]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),n(_,{label:A(u)("Status"),width:120},{default:d(S=>[n(ka,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[n(pa,{status:S.row.status},{default:d(()=>[R(m(i(S.row.end_date)?A(u)("Expired"):S.row.status),1)]),_:2},1032,["status"]),S.row.status==="scheduled"?(r(),E(g,{key:0,effect:"dark",placement:"top","popper-class":"fct-label-hint-popover fct-tooltip","show-after":400,"hide-after":0},{content:d(()=>[R(m(A(u)("Available On: %s",A($s)(S.row.start_date,!0))),1)]),default:d(()=>[n(J,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):B("",!0)]),_:2},1032,["to"])]),_:1},8,["label"]),n(_,{label:A(u)("Expiry Date"),width:120},{default:d(S=>[n(ka,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[o("span",null,[isNaN(Date.parse(S.row.end_date))?(r(),h(H,{key:1},[R("n/a")],64)):(r(),E(Ha,{key:0,"date-time":S.row.end_date,"with-time":!0},null,8,["date-time"]))])]),_:2},1032,["to"])]),_:1},8,["label"]),A(t).isColumnVisible("actions")?(r(),E(_,{key:2,label:A(u)("Actions"),width:100,align:"right",fixed:"right"},{default:d(S=>[n(k,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l,placement:"bottom-end"},{dropdown:d(()=>[n(b,null,{default:d(()=>[S.row.id?(r(),E(v,{key:0,class:"item-link"},{default:d(()=>[n(y,{to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[n(J,{name:"Edit"}),R(" "+m(A(u)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),n(v,{command:{action:"delete",coupon:S.row},class:"item-destructive"},{default:d(()=>[n(J,{name:"Delete"}),R(" "+m(A(u)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:d(()=>[o("span",d_e,[n(J,{name:"More"})])]),_:2},1024)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"])])])]),_:1})}}},u_e={class:"fct-add-edit-coupon-wrapper fct-layout-width"},c_e={class:"single-page-header"},A_e={class:"single-page-body"},p_e={class:"fct-add-edit-coupon"},f_e={class:"fct-add-edit-coupon-main"},m_e={class:"fct-add-edit-coupon-aside"},h_e={class:"fct-admin-sidebar"},__e={__name:"SingleCouponLoader",setup(e){return(t,a)=>{const l=C("el-skeleton-item"),s=C("el-skeleton"),i=C("el-breadcrumb-item"),c=C("el-breadcrumb");return r(),h("div",u_e,[o("div",c_e,[n(c,{"separator-icon":A(cl)},{default:d(()=>[n(i,null,{default:d(()=>[n(s,{animated:!0},{template:d(()=>[n(l,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),n(i,null,{default:d(()=>[n(s,{animated:!0},{template:d(()=>[n(l,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),n(i,null,{default:d(()=>[n(s,{animated:!0},{template:d(()=>[n(l,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"])]),o("div",A_e,[o("div",p_e,[o("div",f_e,[n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Discount Value"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1})]),o("div",m_e,[o("div",h_e,[n(ke,null,{default:d(()=>[n(Ie,{title:A(u)("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1})])])])])])}}};lt.extend(di);lt.extend(tA);const v_e={name:"AddOrEditCoupon",components:{CardContainer:ke,CardHeader:Ie,CardBody:Ce,LabelHint:Aa,ValidationError:oa,CopyToClipboard:Ea,DynamicTemplates:cn,SaveBar:rn,ProductVariationSelector:aA,SingleCouponLoader:__e,Activity:Yc},beforeRouteLeave(e,t,a){var l;(l=this.keyboardShortcuts)!=null&&l.unbind&&this.keyboardShortcuts.unbind("mod+s"),a()},props:{coupon_id:{type:[String,Number],required:!0}},data(){return{changes_made:0,creating:!1,updating:!1,keyboardShortcuts:null,coupon:{type:"fixed",status:"active",stackable:"no",show_on_checkout:"no",title:"",code:"",priority:0,amount:0,start_date:"",end_date:"",notes:"",conditions:{buy_quantity:1,get_quantity:1,excluded_categories:[],included_categories:[],excluded_products:[],included_products:[],min_purchase_amount:"",max_purchase_amount:"",min_amount_basis:"subtotal",allowed_user_ids:[],allowed_user_roles:[],apply_to_quantity:"no",apply_to_whole_cart:"yes",max_per_customer:"",max_discount_amount:"",max_uses:"",buy_products:[],get_products:[],is_recurring:"no"}},validationErrors:{},minQuantity:1,maxQuantity:100,minPurchaseAmount:0,maxPurchaseAmount:1e4,minDiscountAmount:0,minLimit:0,maxLimit:1e3,categories:[],usageError:!1,isEndDateEnabled:!1,fetchingCoupon:!1,isInitialLoading:!1,showDynamicTemplates:!1,showManageActivity:!1}},computed:{ArrowRight(){return cl},maxDiscountAmount(){return this.coupon.type==="percentage"?100:999999}},watch:{coupon:{handler(){this.handleChangesMade()},deep:!0}},mounted(){this.keyboardShortcuts=_s(),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:u,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(){ce.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,ce.get(`coupons/${this.coupon_id}`,{}).then(e=>{var l,s;const t=(l=e==null?void 0:e.coupon)==null?void 0:l.start_date,a=(s=e==null?void 0:e.coupon)==null?void 0:s.end_date;t&&t!=="0000-00-00 00:00:00"&&(e.coupon.start_date=lt.utc(t).tz(lt.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),a&&a!=="0000-00-00 00:00:00"&&(e.coupon.end_date=lt.utc(a).tz(lt.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),e=e.coupon,this.coupon=e,this.coupon.start_date=this.formatDate(this.coupon.start_date),this.coupon.end_date=this.formatDate(this.coupon.end_date),this.coupon.end_date!==null&&(this.isEndDateEnabled=!0),this.coupon.end_date=this.coupon.end_date!==null&&this.coupon.end_date!=="Invalid date"?this.coupon.end_date:null,this.coupon.conditions.excluded_products=this.parseProductIds(e.conditions.excluded_products),this.coupon.conditions.included_products=this.parseProductIds(e.conditions.included_products),this.coupon.conditions.min_amount_basis||(this.coupon.conditions.min_amount_basis="total"),this.formatAmount(),this.setDefaultStatus(),this.showDynamicTemplates=!0}).catch(e=>{var t;errors.status_code=="422"?q.validationErrors(errors):q.error((t=errors.data)==null?void 0:t.message)}).finally(()=>{this.fetchingCoupon=!1,this.isInitialLoading=!1,this.changes_made=0})},updateCoupon(){var e,t;this.updating=!0,this.validateDate(),(e=this.$refs.dynamic_templates)==null||e.beforeUpdatingData({data:{coupon:this.coupon}}),ce.put(`coupons/${this.coupon_id}`,{...this.coupon,metaValue:(t=this.$refs.dynamic_templates)==null?void 0:t.getFormStates()}).then(a=>{var l;(l=this.$refs.dynamic_templates)==null||l.afterUpdatingData({coupon:this.coupon,response:a}),q.success(a.message),this.validationErrors={},this.setDefaultStatus(),this.changes_made=0}).catch(a=>{var l;a.status_code=="422"?(q.validationErrors(a),this.validationErrors=a):q.error((l=a.data)==null?void 0:l.message)}).finally(()=>{this.updating=!1,this.changes_made=0})},addCoupon(){var e,t;this.creating=!0,this.validateDate(),(e=this.$refs.dynamic_templates)==null||e.beforeUpdatingData({data:{coupon:this.coupon}}),ce.post("coupons",{...this.coupon,metaValue:(t=this.$refs.dynamic_templates)==null?void 0:t.getFormStates()}).then(a=>{var l;(l=this.$refs.dynamic_templates)==null||l.afterUpdatingData({coupon:this.coupon,response:a}),q.success(a.message),this.$router.push({name:"coupons"}),this.validationErrors={}}).catch(a=>{var l;a.status_code=="422"?(q.validationErrors(a),this.validationErrors=a):q.error((l=a.data)==null?void 0:l.message)}).finally(()=>{this.creating=!1})}}},g_e={class:"fct-add-edit-coupon-wrapper fct-layout-width"},y_e={class:"single-page-header"},b_e={class:"single-page-body"},w_e={class:"fct-add-edit-coupon"},C_e={class:"fct-add-edit-coupon-main"},k_e={class:"flex gap-2 items-center justify-between w-full mb-2.5"},B_e={class:"form-note"},x_e=["innerHTML"],S_e={key:1},F_e=["innerHTML"],$_e=["innerHTML"],E_e=["innerHTML"],U_e={class:"fct-add-edit-coupon-aside"},I_e={class:"fct-admin-sidebar"},Q_e={class:"fct-admin-sidebar-item"},D_e={key:0,class:"flex items-center gap-1"},V_e={class:"text-sm font-medium text-system-dark dark:text-gray-300"},T_e={key:1},M_e={class:"fct-admin-sidebar-item mt-5 hidden"},L_e={class:"sidebar-title mb-3"},R_e={class:"fct-bullet-lists"},O_e={class:"fct-admin-sidebar-item mt-5 hidden"},H_e={class:"sidebar-title mb-3"},P_e={class:"fct-bullet-lists"},N_e={key:0};function K_e(e,t,a,l,s,i){const c=C("SaveBar"),p=C("SingleCouponLoader"),f=C("el-breadcrumb-item"),_=C("el-breadcrumb"),g=C("CardHeader"),y=C("el-input"),v=C("ValidationError"),b=C("el-form-item"),k=C("el-col"),w=C("LabelHint"),S=C("el-row"),$=C("CardBody"),I=C("CardContainer"),F=C("el-option"),x=C("el-select"),U=C("el-radio"),T=C("el-radio-group"),D=C("ProductVariationSelector"),Q=C("el-checkbox"),V=C("el-form"),O=C("CopyToClipboard"),L=C("el-date-picker"),P=C("DynamicTemplates"),z=C("Activity");return r(),h("div",g_e,[n(c,{isActive:s.changes_made>0?"is-active":"",loading:a.coupon_id?s.updating:s.creating,onSave:t[0]||(t[0]=X=>a.coupon_id?i.updateCoupon():i.addCoupon()),onDiscard:i.reloadPage,"show-cmnd-icon":!0,saveButtonText:a.coupon_id?i.translate("Update"):i.translate("Create")},null,8,["isActive","loading","onDiscard","saveButtonText"]),s.fetchingCoupon?(r(),E(p,{key:0})):B("",!0),s.fetchingCoupon?B("",!0):(r(),h(H,{key:1},[o("div",y_e,[n(_,{"separator-icon":i.ArrowRight},{default:d(()=>[n(f,{to:{name:"coupons"}},{default:d(()=>[R(m(i.translate("Coupons")),1)]),_:1}),n(f,null,{default:d(()=>[R(m(a.coupon_id?i.translate("Edit Coupon"):i.translate("Add Coupon")),1)]),_:1}),a.coupon_id?(r(),E(f,{key:0},{default:d(()=>[R(m(s.coupon.title),1)]),_:1})):B("",!0)]),_:1},8,["separator-icon"])]),o("div",b_e,[o("div",w_e,[o("div",C_e,[n(V,{model:s.coupon,"label-position":"top","require-asterisk-position":"right"},{default:d(()=>[n(I,null,{default:d(()=>[n(g,{title:i.translate("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:24},{default:d(()=>[n(b,{label:i.translate("Title"),required:""},{default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.title,"onUpdate:modelValue":t[1]||(t[1]=ee=>s.coupon.title=ee),placeholder:i.translate("Enter title"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("title")?"is-error":""),maxlength:"50",id:"title"},null,8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("title")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"title"},null,8,["validation-errors"])):B("",!0)]}),_:1},8,["label"])]),_:1}),n(k,{lg:12},{default:d(()=>[n(b,null,{default:d(()=>{var X,G;return[o("div",k_e,[n(w,{title:i.translate("Code"),required:""},null,8,["title"]),o("span",{class:"text-system-dark text-xs cursor-pointer hover:underline dark:text-gray-50 underline",onClick:t[2]||(t[2]=(...ee)=>i.generateRandomCouponCode&&i.generateRandomCouponCode(...ee))},m(i.translate("Generate Random Code")),1)]),n(y,{modelValue:s.coupon.code,"onUpdate:modelValue":t[3]||(t[3]=ee=>s.coupon.code=ee),placeholder:i.translate("Eg. COUPON10"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("code")?"is-error":""),maxlength:"20"},null,8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("code")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"code"},null,8,["validation-errors"])):B("",!0),o("div",B_e,[o("p",null,m(i.translate("Customers must enter this code at checkout.")),1)])]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Coupon Priority"),content:i.translate("Coupons will be calculated based on their priority. The lower the number the higher the priority is.")},null,8,["title","content"])]),default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.priority,"onUpdate:modelValue":t[4]||(t[4]=ee=>s.coupon.priority=ee),type:"number",placeholder:i.translate("Enter priority"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("priority")?"is-error":""),min:"0",max:"100",onInput:t[5]||(t[5]=ee=>{i.onChangeCouponInput("priority",ee)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","onKeypress"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("priority")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"priority"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(I,null,{default:d(()=>[n(g,{title:i.translate("Discount Details"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:8},{default:d(()=>[n(b,{label:i.translate("Type"),required:""},{default:d(()=>{var X;return[n(x,{modelValue:s.coupon.type,"onUpdate:modelValue":t[6]||(t[6]=G=>s.coupon.type=G),placeholder:i.translate("Select coupon type"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("type")?"is-error":""),"default-first-option":""},{default:d(()=>[n(F,{label:i.translate("Fixed"),value:"fixed"},null,8,["label"]),n(F,{label:i.translate("Percentage"),value:"percentage"},null,8,["label"])]),_:1},8,["modelValue","placeholder","class"])]}),_:1},8,["label"])]),_:1}),s.coupon.type==="fixed"||s.coupon.type==="percentage"?(r(),h(H,{key:0},[n(k,{lg:8},{default:d(()=>[n(b,{label:s.coupon.type==="percentage"?i.translate("Discount Percentage (%)"):i.translate("Discount Amount"),required:""},{default:d(()=>{var X;return[n(y,{modelValue:s.coupon.amount,"onUpdate:modelValue":t[7]||(t[7]=G=>s.coupon.amount=G),type:"number",placeholder:"0.00",min:s.minDiscountAmount,max:i.maxDiscountAmount,step:"0.01",onInput:t[8]||(t[8]=G=>{i.onChangeCouponInput("amount",G)}),onKeypress:t[9]||(t[9]=G=>i.preventInvalidChars(G,!0))},{prefix:d(()=>[s.coupon.type==="fixed"?(r(),h("span",{key:0,innerHTML:e.appVars.shop.currency_sign},null,8,x_e)):(r(),h("span",S_e,"%"))]),_:1},8,["modelValue","min","max"]),(X=s.validationErrors)!=null&&X.hasOwnProperty("amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"amount"},null,8,["validation-errors"])):B("",!0)]}),_:1},8,["label"])]),_:1}),s.coupon.type==="percentage"?(r(),E(k,{key:0,lg:8},{default:d(()=>[n(b,{label:i.translate("Max Discount Amount")},{default:d(()=>{var X;return[n(y,{modelValue:s.coupon.conditions.max_discount_amount,"onUpdate:modelValue":t[10]||(t[10]=G=>s.coupon.conditions.max_discount_amount=G),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("max_discount_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,F_e)]),_:1},8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_discount_amount"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1})):B("",!0)],64)):B("",!0)]),_:1})]),_:1})]),_:1}),n(I,null,{default:d(()=>[n(g,{title:i.translate("Usage Restrictions"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Min Spend Amount"),content:i.translate("Minimum spend (subtotal) allowed to use the coupon.")},null,8,["title","content"])]),default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.min_purchase_amount,"onUpdate:modelValue":t[11]||(t[11]=ee=>s.coupon.conditions.min_purchase_amount=ee),type:"number",placeholder:"0.00",class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("min_purchase_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,$_e)]),_:1},8,["modelValue","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("min_purchase_amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"min_purchase_amount"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Max Spend Amount"),content:i.translate("Set the maximum spend (subtotal) allowed when using the coupon.")},null,8,["title","content"])]),default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.max_purchase_amount,"onUpdate:modelValue":t[12]||(t[12]=ee=>s.coupon.conditions.max_purchase_amount=ee),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("max_purchase_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,E_e)]),_:1},8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("max_purchase_amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_purchase_amount"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(k,{lg:24},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Spend Amount Based On"),content:i.translate("Choose what the min/max spend limits are measured against: the cart subtotal (items only) or the order total (including shipping and fees). Applies at checkout.")},null,8,["title","content"])]),default:d(()=>[n(T,{modelValue:s.coupon.conditions.min_amount_basis,"onUpdate:modelValue":t[13]||(t[13]=X=>s.coupon.conditions.min_amount_basis=X)},{default:d(()=>[n(U,{value:"subtotal",label:i.translate("Subtotal (items only)")},null,8,["label"]),n(U,{value:"total",label:i.translate("Total (includes shipping & fees)")},null,8,["label"])]),_:1},8,["modelValue"])]),_:1})]),_:1}),n(k,{md:12},{default:d(()=>[n(b,{label:i.translate("Include Categories")},{default:d(()=>[n(x,{modelValue:s.coupon.conditions.included_categories,"onUpdate:modelValue":t[14]||(t[14]=X=>s.coupon.conditions.included_categories=X),multiple:"",placeholder:i.translate("Any Category"),filterable:"",remote:"","reserve-keyword":!1},{default:d(()=>[(r(!0),h(H,null,ae(s.categories,X=>(r(),E(F,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(k,{md:12},{default:d(()=>[n(b,{label:i.translate("Exclude Categories")},{default:d(()=>[n(x,{modelValue:s.coupon.conditions.excluded_categories,"onUpdate:modelValue":t[15]||(t[15]=X=>s.coupon.conditions.excluded_categories=X),multiple:"",placeholder:i.translate("No Categories"),filterable:"",remote:"","reserve-keyword":!1},{default:d(()=>[(r(!0),h(H,null,ae(s.categories,X=>(r(),E(F,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(b,{label:i.translate("Include Products")},{default:d(()=>[n(D,{modelValue:s.coupon.conditions.included_products,"onUpdate:modelValue":t[16]||(t[16]=X=>s.coupon.conditions.included_products=X)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(b,{label:i.translate("Excluded Products")},{default:d(()=>[n(D,{modelValue:s.coupon.conditions.excluded_products,"onUpdate:modelValue":t[17]||(t[17]=X=>s.coupon.conditions.excluded_products=X)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("By Email Address"),content:i.translate("List of email addresses that can use the coupon. Separate multiple emails with commas. You may also use regular expressions.")},null,8,["title","content"])]),default:d(()=>{var X;return[n(y,{autocomplete:"off",modelValue:s.coupon.conditions.email_restrictions,"onUpdate:modelValue":t[18]||(t[18]=G=>s.coupon.conditions.email_restrictions=G),type:"text",placeholder:i.translate("email1@domain.com, *@special.com, ... or regex pattern")},null,8,["modelValue","placeholder"]),(X=s.validationErrors)!=null&&X.hasOwnProperty("email_restrictions")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"email_restrictions"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(k,{md:24},{default:d(()=>{var X;return[n(b,null,{label:d(()=>[n(w,{title:i.translate("Recurring Coupon"),content:i.translate("Mark this coupon as recurring to apply it automatically to every future subscription order. This discount will automatically apply on every renewal. However, the coupon will not be applied if it reduces the payable amount to zero.")},null,8,["title","content"])]),default:d(()=>[n(Q,{modelValue:s.coupon.conditions.is_recurring,"onUpdate:modelValue":t[19]||(t[19]=G=>s.coupon.conditions.is_recurring=G),label:i.translate("Make this coupon recurring"),"true-value":"yes","false-value":"no"},null,8,["modelValue","label"])]),_:1}),(X=s.validationErrors)!=null&&X.hasOwnProperty("is_recurring")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"is_recurring"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1}),n(I,null,{default:d(()=>[n(g,{title:i.translate("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Total Limit"),content:i.translate("Total number of times this coupon can be redeemed across the entire store.")},null,8,["title","content"])]),default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.max_uses,"onUpdate:modelValue":t[20]||(t[20]=ee=>s.coupon.conditions.max_uses=ee),type:"number",placeholder:i.translate("Total limit"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("max_uses")?"is-error":s.usageError),min:s.minLimit,max:s.maxLimit,onInput:t[21]||(t[21]=ee=>{i.onChangeCouponInput("max_uses",ee)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("max_uses")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_uses"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Per User Limit"),content:i.translate("Maximum an user can use. 0 means unlimited")},null,8,["title","content"])]),default:d(()=>[n(y,{modelValue:s.coupon.conditions.max_per_customer,"onUpdate:modelValue":t[22]||(t[22]=X=>s.coupon.conditions.max_per_customer=X),type:"number",placeholder:i.translate("Max limit per user"),class:de(s.validationErrors.hasOwnProperty("max_per_customer")?"is-error":""),min:s.minLimit,max:s.maxLimit,onInput:t[23]||(t[23]=X=>{i.onChangeCouponInput("max_per_customer",X)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_per_customer"},null,8,["validation-errors"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(I,null,{default:d(()=>[n(g,{title:i.translate("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:24},{default:d(()=>[n(b,{label:i.translate("Status")},{default:d(()=>[n(T,{modelValue:s.coupon.status,"onUpdate:modelValue":t[24]||(t[24]=X=>s.coupon.status=X)},{default:d(()=>[n(U,{value:"active",label:i.translate("Active")},null,8,["label"]),n(U,{value:"disabled",label:i.translate("Disabled")},null,8,["label"]),n(U,{disabled:"",value:"expired",label:i.translate("Expired")},null,8,["label"])]),_:1},8,["modelValue"]),n(v,{"validation-errors":s.validationErrors,"field-key":"status"},null,8,["validation-errors"])]),_:1},8,["label"])]),_:1}),n(k,{lg:24},{default:d(()=>[n(b,{label:i.translate("Internal Notes")},{default:d(()=>{var X;return[n(y,{modelValue:s.coupon.notes,"onUpdate:modelValue":t[25]||(t[25]=G=>s.coupon.notes=G),type:"textarea",placeholder:i.translate("Enter note"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("notes")?"is-error":"")},null,8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"notes"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1}),n(k,{lg:24},{default:d(()=>{var X;return[n(b,null,{label:d(()=>[n(w,{title:i.translate("Stackable"),content:i.translate("Yes means the coupon can be applied with other coupons")},null,8,["title","content"])]),default:d(()=>[n(T,{modelValue:s.coupon.stackable,"onUpdate:modelValue":t[26]||(t[26]=G=>s.coupon.stackable=G)},{default:d(()=>[n(U,{value:"yes"},{default:d(()=>[R(m(i.translate("Yes")),1)]),_:1}),n(U,{value:"no"},{default:d(()=>[R(m(i.translate("No")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1}),(X=s.validationErrors)!=null&&X.hasOwnProperty("stackable")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"stackable"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),o("div",U_e,[o("div",I_e,[n(I,null,{default:d(()=>[n(g,{title:i.translate("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,null,{default:d(()=>[o("div",Q_e,[s.coupon.code?(r(),h("div",D_e,[o("span",V_e,m(i.translate("Coupon code"))+": "+m(s.coupon.code),1),n(O,{text:s.coupon.code,showMode:"basic_copy_btn",tooltipText:i.translate("Copy discount code")},null,8,["text","tooltipText"])])):(r(),h("div",T_e,m(i.translate("No discount code yet")),1))]),o("div",M_e,[o("h4",L_e,m(i.translate("Type & Method")),1),o("ul",R_e,[o("li",null,[o("span",null,m(i.translate("Amount off Products")),1)]),o("li",null,[o("span",null,m(i.translate("Code")),1)])])]),o("div",O_e,[o("h4",H_e,m(i.translate("Details")),1),o("ul",P_e,[o("li",null,[o("span",null,m(i.translate("For Online Store")),1)]),o("li",null,[o("span",null,m(i.translate("No Min Purchase Requirement")),1)]),o("li",null,[o("span",null,m(i.translate("All Customers")),1)])])])]),_:1})]),_:1}),n(I,null,{default:d(()=>[n(g,{title:i.translate("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(V,{"label-position":"top"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:24},{default:d(()=>[n(b,{label:i.translate("Start Date & Time")},{default:d(()=>[n(L,{modelValue:s.coupon.start_date,"onUpdate:modelValue":t[27]||(t[27]=X=>s.coupon.start_date=X),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:i.translate("Start date & time"),onChange:i.setDefaultStatus,"disabled-date":i.disabledStartDate},null,8,["modelValue","placeholder","onChange","disabled-date"])]),_:1},8,["label"])]),_:1}),n(k,{lg:24},{default:d(()=>[n(b,null,{default:d(()=>[n(Q,{modelValue:s.isEndDateEnabled,"onUpdate:modelValue":t[28]||(t[28]=X=>s.isEndDateEnabled=X),label:i.translate("Set end date & time"),onChange:t[29]||(t[29]=X=>{X||(s.coupon.end_date=null)})},null,8,["modelValue","label"])]),_:1})]),_:1}),s.isEndDateEnabled?(r(),E(k,{key:0,lg:24},{default:d(()=>[n(b,{label:i.translate("End Date & Time")},{default:d(()=>[n(L,{modelValue:s.coupon.end_date,"onUpdate:modelValue":t[30]||(t[30]=X=>s.coupon.end_date=X),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:i.translate("End date & time"),onChange:i.setDefaultStatus,"disabled-date":i.disabledEndDate},null,8,["modelValue","placeholder","onChange","disabled-date"]),s.validationErrors.hasOwnProperty("end_date")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"end_date"},null,8,["validation-errors"])):B("",!0)]),_:1},8,["label"])]),_:1})):B("",!0)]),_:1})]),_:1})]),_:1})]),_:1})]),s.showDynamicTemplates?(r(),h("div",N_e,[n(P,{filter:"fluent_cart_single_coupon_page",ref:"dynamic_templates",data:{coupon:s.coupon},widgetsQuery:{coupon_id:s.coupon.id},onChange:i.handleChangesMade},null,8,["data","widgetsQuery","onChange"])])):B("",!0),n(I,null,{default:d(()=>[n(g,{title:i.translate("Activity"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,null,{default:d(()=>[n(z,{onReload:i.fetchCoupon,activities:s.coupon.activities||[],showManageActivity:s.showManageActivity},null,8,["onReload","activities","showManageActivity"])]),_:1})]),_:1})])])])],64))])}const G_e=st(v_e,[["render",K_e]]),j_e={name:"CheckoutFields",components:{Animation:_a,CardHeader:Ie,Card:ke,CardBody:Ce,SettingsHeader:Ua,AdminNotice:Ia},data(){return{fields:{},settings:{},saving:!1,fetching:!1}},watch:{"settings.basic_info.last_name.enabled"(e){var t,a;e==="yes"&&((a=(t=this.settings.basic_info)==null?void 0:t.first_name)==null?void 0:a.enabled)==="no"&&(this.settings.basic_info.first_name.enabled="yes")},"settings.business_details":{deep:!0,handler(e){var a,l,s;if(!e||!e.b2b_only_mode)return;((a=e.company_name)==null?void 0:a.enabled)==="yes"||((l=e.vat_number)==null?void 0:l.enabled)==="yes"||((s=e.legal_registration_id)==null?void 0:s.enabled)==="yes"||(e.b2b_only_mode.enabled="no")}}},mounted(){this.getFields()},methods:{translate:u,isFirstNameDisabled(e,t){var a,l;return e==="basic_info"&&t==="first_name"&&((l=(a=this.settings.basic_info)==null?void 0:a.last_name)==null?void 0:l.enabled)==="yes"},isB2BOnlyModeDisabled(e,t){var l,s,i;if(e!=="business_details"||t!=="b2b_only_mode")return!1;const a=this.settings.business_details||{};return((l=a.company_name)==null?void 0:l.enabled)!=="yes"&&((s=a.vat_number)==null?void 0:s.enabled)!=="yes"&&((i=a.legal_registration_id)==null?void 0:i.enabled)!=="yes"},shouldDimLabel(e,t){var a,l,s,i,c,p,f;return((s=(l=(a=this.settings)==null?void 0:a[e])==null?void 0:l[t])==null?void 0:s.enabled)==="no"?!0:e==="basic_info"&&t==="full_name"?((c=(i=this.settings.basic_info)==null?void 0:i.first_name)==null?void 0:c.enabled)==="yes"||((f=(p=this.settings.basic_info)==null?void 0:p.last_name)==null?void 0:f.enabled)==="yes":!1},isVisible(e,t){var a,l,s,i;return t==="full_name"?((l=(a=this.settings.basic_info)==null?void 0:a.first_name)==null?void 0:l.enabled)!=="yes"&&((i=(s=this.settings.basic_info)==null?void 0:s.last_name)==null?void 0:i.enabled)!=="yes":!0},getFields(){this.fetching=!0,this.$get("checkout-fields/get-fields").then(e=>{this.fields=e.fields||{},this.settings=e.settings||{}}).catch(e=>{this.handleError(e)}).finally(()=>{this.fetching=!1})},saveFields(){this.saving=!0,this.$post("checkout-fields/save-fields",{settings:this.settings}).then(e=>{this.$notify.success(e.message||this.$t("Settings saved successfully!")),this.getFields()}).catch(e=>{this.handleError(e)}).finally(()=>{this.saving=!1})},formatSectionTitle(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}}},z_e={class:"setting-wrap"},q_e={class:"setting-wrap-inner"},Y_e={class:"fct-checkout-fields-wrapp"},W_e={class:"field-heading"},J_e={class:"fct-checkout-fields"},X_e={key:0,class:"fct-checkout-field"},Z_e={class:"fct-checkout-field-info"},eve={class:"fct-checkout-field-label-wrap"},tve={class:"fct-checkout-field-tags"},ave={key:0,class:"fct-checkout-field-info-desc"},lve={key:0,class:"fct-checkout-field-action"},sve={key:1,class:"fct-checkout-field-input"},nve={class:"fct-checkout-field-info"},ove={class:"fct-checkout-field-label-wrap"},ive={key:1,class:"fct-checkout-field-tags"},rve={key:0,class:"fct-checkout-field-info-desc"},dve={key:0,class:"fct-checkout-field-action"},uve={class:"form-section-save-action"};function cve(e,t,a,l,s,i){const c=C("SettingsHeader"),p=C("AdminNotice"),f=C("el-skeleton"),_=C("el-switch"),g=C("el-tag"),y=C("el-checkbox"),v=C("el-input"),b=C("CardBody"),k=C("Card"),w=C("el-button");return r(),h("div",z_e,[n(c,{heading:i.translate("Checkout Fields"),loading:s.saving,onOnSave:i.saveFields},null,8,["heading","loading","onOnSave"]),o("div",q_e,[n(p),o("div",Y_e,[n(k,null,{default:d(()=>[n(b,null,{default:d(()=>[n(f,{loading:s.fetching,animated:"",rows:5},null,8,["loading"]),s.fetching?B("",!0):(r(!0),h(H,{key:0},ae(s.fields,(S,$)=>(r(),h("div",{key:$,class:"fct-checkout-field-section"},[o("h3",W_e,m(i.formatSectionTitle($)),1),o("div",J_e,[S.label?(r(),h("div",X_e,[o("div",Z_e,[o("div",eve,[S.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[$].enabled,"onUpdate:modelValue":I=>s.settings[$].enabled=I,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])):B("",!0),o("span",{class:de(`fct-checkout-field-label ${s.settings[$].enabled==="no"?"opacity-50":""}`)},m(S.label),3),o("div",tve,[S.can_alter!=="yes"&&s.settings[$].enabled==="yes"?(r(),E(g,{key:0,size:"small"},{default:d(()=>[R(m(i.translate("System")),1)]),_:1})):B("",!0),s.settings[$].required==="yes"&&s.settings[$].enabled==="yes"?(r(),E(g,{key:1,size:"small"},{default:d(()=>[R(m(i.translate("Required")),1)]),_:1})):B("",!0)])]),S.help_text?(r(),h("div",ave,m(S.help_text),1)):B("",!0)]),S.can_alter==="yes"?(r(),h("div",lve,[n(y,{modelValue:s.settings[$].required,"onUpdate:modelValue":I=>s.settings[$].required=I,"true-label":"yes","false-label":"no",disabled:s.settings[$].enabled!=="yes"},{default:d(()=>[R(m(i.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),s.settings[$].hasOwnProperty("text")&&s.settings[$].enabled==="yes"?(r(),h("div",sve,[n(v,{type:"textarea",modelValue:s.settings[$].text,"onUpdate:modelValue":I=>s.settings[$].text=I,disabled:s.settings[$].enabled!=="yes"},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0)])):(r(!0),h(H,{key:1},ae(S,(I,F)=>(r(),h("div",{key:F,class:"fct-checkout-field"},[o("div",nve,[o("div",ove,[I.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[$][F].enabled,"onUpdate:modelValue":x=>s.settings[$][F].enabled=x,"active-value":"yes","inactive-value":"no",disabled:i.isFirstNameDisabled($,F)||i.isB2BOnlyModeDisabled($,F)},null,8,["modelValue","onUpdate:modelValue","disabled"])):B("",!0),o("span",{class:de(["fct-checkout-field-label",i.shouldDimLabel($,F)?"opacity-50":""])},m(I.label),3),i.isVisible(I,F)?(r(),h("div",ive,[I.can_alter!=="yes"&&s.settings[$][F].enabled==="yes"?(r(),E(g,{key:0,size:"small"},{default:d(()=>[R(m(i.translate("System")),1)]),_:1})):B("",!0),s.settings[$][F].required==="yes"&&s.settings[$][F].enabled==="yes"?(r(),E(g,{key:1,size:"small"},{default:d(()=>[R(m(i.translate("Required")),1)]),_:1})):B("",!0)])):B("",!0)]),I.help_text?(r(),h("div",rve,m(I.help_text),1)):B("",!0)]),I.can_alter==="yes"&&F!=="first_name"&&F!=="b2b_only_mode"?(r(),h("div",dve,[n(y,{modelValue:s.settings[$][F].required,"onUpdate:modelValue":x=>s.settings[$][F].required=x,"true-label":"yes","false-label":"no",disabled:s.settings[$][F].enabled!=="yes"},{default:d(()=>[R(m(i.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0)]))),128))])]))),128))]),_:1})]),_:1}),o("div",uve,[n(w,{type:"primary",onClick:i.saveFields,loading:s.saving},{default:d(()=>[R(m(i.translate("Save")),1)]),_:1},8,["onClick","loading"])])])])])}const Ave=st(j_e,[["render",cve]]);var So={exports:{}};/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/var pve=So.exports,vc;function fve(){return vc||(vc=1,function(e,t){((a,l)=>{e.exports=l()})(pve,function a(){var l=typeof self<"u"?self:typeof window<"u"?window:l!==void 0?l:{},s,i=!l.document&&!!l.postMessage,c=l.IS_PAPA_WORKER||!1,p={},f=0,_={};function g(Q){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(V){var O=U(V);O.chunkSize=parseInt(O.chunkSize),V.step||V.chunk||(O.chunkSize=null),this._handle=new w(O),(this._handle.streamer=this)._config=O}).call(this,Q),this.parseChunk=function(V,O){var L=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),c)l.postMessage({results:P,workerId:_.WORKER_ID,finished:L});else if(D(this._config.chunk)&&!O){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||!L||!D(this._config.complete)||P&&P.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),L||P&&P.meta.paused||this._nextChunk(),P}this._halted=!0},this._sendError=function(V){D(this._config.error)?this._config.error(V):c&&this._config.error&&l.postMessage({workerId:_.WORKER_ID,error:V,finished:!1})}}function y(Q){var V;(Q=Q||{}).chunkSize||(Q.chunkSize=_.RemoteChunkSize),g.call(this,Q),this._nextChunk=i?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(O){this._input=O,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(V=new XMLHttpRequest,this._config.withCredentials&&(V.withCredentials=this._config.withCredentials),i||(V.onload=T(this._chunkLoaded,this),V.onerror=T(this._chunkError,this)),V.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var O,L=this._config.downloadRequestHeaders;for(O in L)V.setRequestHeader(O,L[O])}var P;this._config.chunkSize&&(P=this._start+this._config.chunkSize-1,V.setRequestHeader("Range","bytes="+this._start+"-"+P));try{V.send(this._config.downloadRequestBody)}catch(z){this._chunkError(z.message)}i&&V.status===0&&this._chunkError()}},this._chunkLoaded=function(){V.readyState===4&&(V.status<200||400<=V.status?this._chunkError():(this._start+=this._config.chunkSize||V.responseText.length,this._finished=!this._config.chunkSize||this._start>=(O=>(O=O.getResponseHeader("Content-Range"))!==null?parseInt(O.substring(O.lastIndexOf("/")+1)):-1)(V),this.parseChunk(V.responseText)))},this._chunkError=function(O){O=V.statusText||O,this._sendError(new Error(O))}}function v(Q){(Q=Q||{}).chunkSize||(Q.chunkSize=_.LocalChunkSize),g.call(this,Q);var V,O,L=typeof FileReader<"u";this.stream=function(P){this._input=P,O=P.slice||P.webkitSlice||P.mozSlice,L?((V=new FileReader).onload=T(this._chunkLoaded,this),V.onerror=T(this._chunkError,this)):V=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(V.error)}}function b(Q){var V;g.call(this,Q=Q||{}),this.stream=function(O){return V=O,this._nextChunk()},this._nextChunk=function(){var O,L;if(!this._finished)return O=this._config.chunkSize,V=O?(L=V.substring(0,O),V.substring(O)):(L=V,""),this._finished=!V,this.parseChunk(L)}}function k(Q){g.call(this,Q=Q||{});var V=[],O=!0,L=!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(){L&&V.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),V.length?this.parseChunk(V.shift()):O=!0},this._streamData=T(function(P){try{V.push(typeof P=="string"?P:P.toString(this._config.encoding)),O&&(O=!1,this._checkIsFinished(),this.parseChunk(V.shift()))}catch(z){this._streamError(z)}},this),this._streamError=T(function(P){this._streamCleanUp(),this._sendError(P)},this),this._streamEnd=T(function(){this._streamCleanUp(),L=!0,this._streamData("")},this),this._streamCleanUp=T(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function w(Q){var V,O,L,P,z=Math.pow(2,53),X=-z,G=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,ee=/^((\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)))$/,oe=this,re=0,K=0,Y=!1,W=!1,j=[],ie={data:[],errors:[],meta:{}};function _e(be){return Q.skipEmptyLines==="greedy"?be.join("").trim()==="":be.length===1&&be[0].length===0}function me(){if(ie&&L&&(le("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+_.DefaultDelimiter+"'"),L=!1),Q.skipEmptyLines&&(ie.data=ie.data.filter(function(ge){return!_e(ge)})),ue()){let ge=function(tt,yt){D(Q.transformHeader)&&(tt=Q.transformHeader(tt,yt)),j.push(tt)};if(ie)if(Array.isArray(ie.data[0])){for(var be=0;ue()&&be(gt=>(Q.dynamicTypingFunction&&Q.dynamicTyping[gt]===void 0&&(Q.dynamicTyping[gt]=Q.dynamicTypingFunction(gt)),(Q.dynamicTyping[gt]||Q.dynamicTyping)===!0))(Oe)?Me==="true"||Me==="TRUE"||Me!=="false"&&Me!=="FALSE"&&((gt=>{if(G.test(gt)&&(gt=parseFloat(gt),X=j.length?"__parsed_extra":j[Je]:xe,Fe=Q.transform?Q.transform(Fe,xe):Fe);xe==="__parsed_extra"?(yt[xe]=yt[xe]||[],yt[xe].push(Fe)):yt[xe]=Fe}return Q.header&&(Je>j.length?le("FieldMismatch","TooManyFields","Too many fields: expected "+j.length+" fields but parsed "+Je,K+tt):JeQ.preview?O.abort():(ie.data=ie.data[0],P(ie,oe))))}),this.parse=function(be,Qe,Ke){var ge=Q.quoteChar||'"',ge=(Q.newline||(Q.newline=this.guessLineEndings(be,ge)),L=!1,Q.delimiter?D(Q.delimiter)&&(Q.delimiter=Q.delimiter(be),ie.meta.delimiter=Q.delimiter):((ge=((tt,yt,Je,xe,Fe)=>{var Oe,Me,gt,vt;Fe=Fe||[","," ","|",";",_.RECORD_SEP,_.UNIT_SEP];for(var Lt=0;Lt=Ke.length/2?`\r
`:"\r"}}function S(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $(Q){var V=(Q=Q||{}).delimiter,O=Q.newline,L=Q.comments,P=Q.step,z=Q.preview,X=Q.fastMode,G=null,ee=!1,oe=Q.quoteChar==null?'"':Q.quoteChar,re=oe;if(Q.escapeChar!==void 0&&(re=Q.escapeChar),(typeof V!="string"||-1<_.BAD_DELIMITERS.indexOf(V))&&(V=","),L===V)throw new Error("Comment character same as delimiter");L===!0?L="#":(typeof L!="string"||-1<_.BAD_DELIMITERS.indexOf(L))&&(L=!1),O!==`
`&&O!=="\r"&&O!==`\r
`&&(O=`
`);var K=0,Y=!1;this.parse=function(W,j,ie){if(typeof W!="string")throw new Error("Input must be a string");var _e=W.length,me=V.length,ue=O.length,le=L.length,be=D(P),Qe=[],Ke=[],ge=[],tt=K=0;if(!W)return ht();if(X||X!==!1&&W.indexOf(oe)===-1){for(var yt=W.split(O),Je=0;Je=z)return ht(!0);break}Ke.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:Qe.length,index:K}),Me++}}else if(L&&ge.length===0&&W.substring(K,K+le)===L){if(Fe===-1)return ht();K=Fe+ue,Fe=W.indexOf(O,K),xe=W.indexOf(V,K)}else if(xe!==-1&&(xe=z)return ht(!0)}return Vt();function vt(bt){Qe.push(bt),tt=K}function Lt(bt){var St=0;return St=bt!==-1&&(bt=W.substring(Me+1,bt))&&bt.trim()===""?bt.length:St}function Vt(bt){return ie||(bt===void 0&&(bt=W.substring(K)),ge.push(bt),K=_e,vt(ge),be&&Kt()),ht()}function Qt(bt){K=bt,vt(ge),ge=[],Fe=W.indexOf(O,K)}function ht(bt){if(Q.header&&!j&&Qe.length&&!ee){var St=Qe[0],Ot=Object.create(null),Ht=new Set(St);let It=!1;for(let mt=0;mtL.charCodeAt(0)!==65279?L:L.slice(1))(Q),O=new(V.download?y:b)(V)):Q.readable===!0&&D(Q.read)&&D(Q.on)?O=new k(V):(l.File&&Q instanceof File||Q instanceof Object)&&(O=new v(V)),O.stream(Q);(O=(()=>{var L;return!!_.WORKERS_SUPPORTED&&(L=(()=>{var P=l.URL||l.webkitURL||null,z=a.toString();return _.BLOB_URL||(_.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; ","(",z,")();"],{type:"text/javascript"})))})(),(L=new l.Worker(L)).onmessage=I,L.id=f++,p[L.id]=L)})()).userStep=V.step,O.userChunk=V.chunk,O.userComplete=V.complete,O.userError=V.error,V.step=D(V.step),V.chunk=D(V.chunk),V.complete=D(V.complete),V.error=D(V.error),delete V.worker,O.postMessage({input:Q,config:V,workerId:O.id})},_.unparse=function(Q,V){var O=!1,L=!0,P=",",z=`\r
`,X='"',G=X+X,ee=!1,oe=null,re=!1,K=((()=>{if(typeof V=="object"){if(typeof V.delimiter!="string"||_.BAD_DELIMITERS.filter(function(j){return V.delimiter.indexOf(j)!==-1}).length||(P=V.delimiter),typeof V.quotes!="boolean"&&typeof V.quotes!="function"&&!Array.isArray(V.quotes)||(O=V.quotes),typeof V.skipEmptyLines!="boolean"&&typeof V.skipEmptyLines!="string"||(ee=V.skipEmptyLines),typeof V.newline=="string"&&(z=V.newline),typeof V.quoteChar=="string"&&(X=V.quoteChar),typeof V.header=="boolean"&&(L=V.header),Array.isArray(V.columns)){if(V.columns.length===0)throw new Error("Option columns is empty");oe=V.columns}V.escapeChar!==void 0&&(G=V.escapeChar+X),V.escapeFormulae instanceof RegExp?re=V.escapeFormulae:typeof V.escapeFormulae=="boolean"&&V.escapeFormulae&&(re=/^[=+\-@\t\r].*$/)}})(),new RegExp(S(X),"g"));if(typeof Q=="string"&&(Q=JSON.parse(Q)),Array.isArray(Q)){if(!Q.length||Array.isArray(Q[0]))return Y(null,Q,ee);if(typeof Q[0]=="object")return Y(oe||Object.keys(Q[0]),Q,ee)}else if(typeof Q=="object")return typeof Q.data=="string"&&(Q.data=JSON.parse(Q.data)),Array.isArray(Q.data)&&(Q.fields||(Q.fields=Q.meta&&Q.meta.fields||oe),Q.fields||(Q.fields=Array.isArray(Q.data[0])?Q.fields:typeof Q.data[0]=="object"?Object.keys(Q.data[0]):[]),Array.isArray(Q.data[0])||typeof Q.data[0]=="object"||(Q.data=[Q.data])),Y(Q.fields||[],Q.data||[],ee);throw new Error("Unable to serialize unrecognized input");function Y(j,ie,_e){var me="",ue=(typeof j=="string"&&(j=JSON.parse(j)),typeof ie=="string"&&(ie=JSON.parse(ie)),Array.isArray(j)&&0{for(var be=0;beJ7(G,k.thousand),S=G=>{G&&gc.parse(G,{header:!0,complete:function(ee){p.value=ee.data,c.value=ee.meta.fields,g.value=c.value.includes("Type")&&c.value.includes("Parent"),I(),g.value&&U(),b.value=!0}})},$=()=>{_.value={},c.value=[],p.value=[],b.value=!1,g.value=!1},I=()=>{const G=[],ee=[];let oe=0;c.value.forEach(re=>{let K=null,Y=null;const W=re.toString();for(const[j,ie]of y.entries())if(W.toLocaleLowerCase().startsWith(ie)){const _e=re.toString().match(/ \d+ /g);if(Array.isArray(_e)&&_e.length===1){let me=_e[0];oe=me>oe?me:oe,K=re.toString().replace(_e[0]," %d "),Y=re.toString().replace(_e[0]," ");break}}K!=null?G.includes(K)||(G.push(K),ee.push({title:Y,value:K})):ee.push({title:re,value:re})}),_.value=ee,v=oe},F=()=>window.fluentCartRestVars.rest.url+"/files/upload",x={post_id:["ID"],post_title:["Name"],post_name:["SKU"],post_content:["description","Description"],post_excerpt:["Short description","Short Description"],post_status:["Published"],comment_status:["Allow customer reviews?"],item_price:["Regular price","Meta: _subscription_price"],compare_price:["Sale price"],images:["Images"],categories:["Categories"],sku:["SKU"],payment_type:["Payment Type"],repeat_interval:["Subscription Interval","Meta: _subscription_period"],trial_days:["Trial Days","Meta: _subscription_trial_length"],installment:["Installment"],installment_count:["Installment Count"],manage_setup_fee:["Setup Fee"],signup_fee_name:["Setup Fee Name"],signup_fee:["Setup Fee Amount","Meta: _subscription_sign_up_fee"]},U=()=>{for(const[G,ee]of Object.entries(x))if(f.value[G]){for(const oe of ee)if(c.value.includes(oe)){f.value[G].value=oe;break}}},T=G=>G?{day:"daily",week:"weekly",month:"monthly",year:"yearly"}[G.trim().toLowerCase()]||G:"",D=G=>{if(!G)return"";const ee=G.split(",").map(oe=>oe.trim().toLowerCase());return ee.includes("variation")?"variation":ee.includes("variable")?"variable":ee.includes("subscription")?"subscription":ee.includes("simple")?"simple":ee[0]||""},Q=(G=!0)=>{const ee=[],oe={},re=f.value,K={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"},Y=j=>{const ie=[];for(let _e=1;_e<=10;_e++){const me=`Attribute ${_e} name`,ue=`Attribute ${_e} value(s)`;j[me]&&j[ue]&&ie.push(j[ue])}return ie.join(" - ")},W=j=>j==="1"||j===1?"published":j==="0"||j===0?"draft":j||"published";p.value.forEach(j=>{var Ke,ge,tt,yt,Je,xe,Fe,Oe,Me,gt,vt,Lt,Vt,Qt,ht,Kt,bt,St,Ot,Ht;const ie=D(j.Type);if(ie!=="simple"&&ie!=="variable"&&ie!=="subscription")return;const _e={};_e._cid=fl(),_e.post_title=j[(Ke=re.post_title)==null?void 0:Ke.value]||"",_e.post_name=j[(ge=re.post_name)==null?void 0:ge.value]||_e.post_title,_e.ID=j[(tt=re.post_id)==null?void 0:tt.value]||"",_e.post_content=j[(yt=re.post_content)==null?void 0:yt.value]||"",_e.post_excerpt=j[(Je=re.post_excerpt)==null?void 0:Je.value]||"",_e.post_status=W(j[(xe=re.post_status)==null?void 0:xe.value]);const me={variation_type:ie==="variable"?"simple_variations":"simple",manage_stock:"0",fulfillment_type:"physical"},ue=j[(Fe=re.images)==null?void 0:Fe.value]||"",le=[];ue&&ue.split(",").map(It=>It.trim()).filter(Boolean).forEach(It=>{const mt=It.split("/").pop().split("?")[0]||"image";le.push({id:0,url:It,title:mt})}),_e.detail=me,_e.gallery=le,_e.variants=[];const be=j[(Oe=re.categories)==null?void 0:Oe.value]||"";if(be?_e.categories=be.split(",").map(It=>It.trim()).filter(Boolean):_e.categories=[],ie==="simple"||ie==="subscription"){const It=w(j[(Me=re.item_price)==null?void 0:Me.value]||""),mt=w(j[(gt=re.compare_price)==null?void 0:gt.value]||""),jt=j[(vt=re.sku)==null?void 0:vt.value]||"",ve=ie==="subscription"?"subscription":j[(Lt=re.payment_type)==null?void 0:Lt.value]||"onetime",Se=T(j[(Vt=re.repeat_interval)==null?void 0:Vt.value]||""),nt=j[(Qt=re.trial_days)==null?void 0:Qt.value]||"",wt=j[(ht=re.installment)==null?void 0:ht.value]||"",kt=j[(Kt=re.installment_count)==null?void 0:Kt.value]||"",Jt=j[(bt=re.manage_setup_fee)==null?void 0:bt.value]||"",_t=j[(St=re.signup_fee_name)==null?void 0:St.value]||"",Xt=w(j[(Ot=re.signup_fee)==null?void 0:Ot.value]||"");(It||_e.post_title)&&_e.variants.push({_cid:fl(),variation_title:_e.post_title,sku:jt,item_price:It,compare_price:mt,other_info:{...K,payment_type:ve,repeat_interval:Se,trial_days:nt,installment:wt==="yes"?"yes":"no",times:kt,manage_setup_fee:Jt==="yes"?"yes":"no",signup_fee_name:_t,signup_fee:Xt},media:[]})}const Qe=j[(Ht=re.sku)==null?void 0:Ht.value]||"";ie==="variable"&&Qe&&(oe[Qe]=_e),ee.push(_e)}),p.value.forEach(j=>{var gt,vt,Lt,Vt,Qt,ht,Kt,bt,St,Ot,Ht,It;if(D(j.Type)!=="variation")return;const ie=j.Parent;if(!ie||!oe[ie])return;const _e=Y(j),me=w(j[(gt=re.item_price)==null?void 0:gt.value]||""),ue=w(j[(vt=re.compare_price)==null?void 0:vt.value]||""),le=j[(Lt=re.images)==null?void 0:Lt.value]||"",be=[];le&&le.split(",").map(mt=>mt.trim()).filter(Boolean).forEach(mt=>{const jt=mt.split("/").pop().split("?")[0]||"image";be.push({id:0,url:mt,title:jt})});const Qe=j[(Vt=re.sku)==null?void 0:Vt.value]||"",Ke=j[(Qt=re.payment_type)==null?void 0:Qt.value]||"onetime",ge=T(j[(ht=re.repeat_interval)==null?void 0:ht.value]||""),tt=j[(Kt=re.trial_days)==null?void 0:Kt.value]||"",yt=j[(bt=re.installment)==null?void 0:bt.value]||"",Je=j[(St=re.installment_count)==null?void 0:St.value]||"",xe=j[(Ot=re.manage_setup_fee)==null?void 0:Ot.value]||"",Fe=j[(Ht=re.signup_fee_name)==null?void 0:Ht.value]||"",Oe=w(j[(It=re.signup_fee)==null?void 0:It.value]||""),Me={_cid:fl(),variation_title:_e||j.Name||"",sku:Qe,item_price:me,compare_price:ue,other_info:{...K,payment_type:Ke,repeat_interval:ge,trial_days:tt,installment:yt==="yes"?"yes":"no",times:Je,manage_setup_fee:xe==="yes"?"yes":"no",signup_fee_name:Fe,signup_fee:Oe},media:be};oe[ie].variants.push(Me)}),X("onDataPopulated",{products:ee,concat:G})},V=(G=!0)=>{if(g.value)return Q(G);const ee=[];p.value.forEach(oe=>{var Je,xe,Fe,Oe,Me,gt,vt,Lt,Vt,Qt,ht,Kt;const re={};re._cid=fl();const K=f.value;re.post_title=oe[K.post_title.value]??"",re.post_name=oe[K.post_name.value]??re.post_title,re.ID=oe[K.post_id.value]??"",re.post_content=oe[K.post_content.value]??"",re.post_excerpt=oe[K.post_excerpt.value]??"",re.post_status=oe[(Je=K.post_status)==null?void 0:Je.value]||"published",re.comment_status="close";const Y=oe[(xe=K.images)==null?void 0:xe.value]||"",W=[];Y&&Y.split(",").map(bt=>bt.trim()).filter(Boolean).forEach(bt=>{const St=bt.split("/").pop().split("?")[0]||"image";W.push({id:0,url:bt,title:St})});const j=oe[(Fe=K.categories)==null?void 0:Fe.value]||"";j?re.categories=j.split(",").map(bt=>bt.trim()).filter(Boolean):re.categories=[];const ie=oe[(Oe=K.sku)==null?void 0:Oe.value]||"",_e=oe[(Me=K.payment_type)==null?void 0:Me.value]||"onetime",me=oe[(gt=K.repeat_interval)==null?void 0:gt.value]||"",ue=oe[(vt=K.trial_days)==null?void 0:vt.value]||"",le=oe[(Lt=K.installment)==null?void 0:Lt.value]||"",be=oe[(Vt=K.installment_count)==null?void 0:Vt.value]||"",Qe=oe[(Qt=K.manage_setup_fee)==null?void 0:Qt.value]||"",Ke=oe[(ht=K.signup_fee_name)==null?void 0:ht.value]||"",ge=w(oe[(Kt=K.signup_fee)==null?void 0:Kt.value]||""),tt={variation_type:"simple",manage_stock:"0",fulfillment_type:"physical"},yt={description:"",payment_type:_e,times:be,repeat_interval:me,trial_days:ue,billing_summary:"",manage_setup_fee:Qe==="yes"?"yes":"no",signup_fee_name:Ke,signup_fee:ge,setup_fee_per_item:"no",installment:le==="yes"?"yes":"no"};re.gallery=W,re.variants=[];for(let bt=1;bt<=v;bt++){const St={};["variation_title","item_price","compare_price"].forEach(Ot=>{var It;const Ht=((It=K[Ot])==null?void 0:It.value)??"";if(Ht.length>0){const mt=Ht.replace("%d",bt.toString()),jt=oe[mt];St[Ot]=Ot==="variation_title"?jt:w(jt)}}),P(St)&&(St._cid=fl(),St.sku=ie,St.other_info={...yt},St.media=[],re.variants.push(St))}re.variants.length>0?(tt.variation_type="simple_variations",re.detail=tt,ee.push(re)):P(re)&&(re.variants.push({_cid:fl(),variation_title:"",sku:ie,item_price:0,compare_price:0,other_info:{...yt},media:[]}),re.detail=tt,ee.push(re))}),X("onDataPopulated",{products:ee,concat:G})},O=()=>{l.value=!1,s.value=[],i.value=null,$()},L=(G=!0)=>{V(G),O()},P=G=>{let ee=!1;for(const[oe,re]of Object.entries(G))if(typeof re!==null&&typeof re<"u"&&(Array.isArray(re)&&re.length>0||re.toString().length>0)){ee=!0;break}return ee};Ee(()=>{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 z=()=>{const G=[{ID:"",Type:"simple",SKU:"BASIC-TEE-001",Name:"Classic Cotton T-Shirt",Published:1,"Short description":"Comfortable everyday cotton tee",description:"Made from 100% organic cotton. Pre-shrunk and machine washable.",Categories:"Clothing, Clothing > T-Shirts",Images:"https://example.com/images/tee-front.jpg, https://example.com/images/tee-back.jpg",Parent:"","Regular price":"29.99","Sale price":"24.99","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"onetime","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"simple",SKU:"STARTER-PLAN",Name:"Starter Membership Plan",Published:1,"Short description":"Monthly access to premium content",description:"Get access to all premium tutorials and resources. Cancel anytime.",Categories:"Memberships",Images:"",Parent:"","Regular price":"9.99","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"subscription","Subscription Interval":"monthly","Trial Days":"14",Installment:"","Installment Count":"","Setup Fee":"yes","Setup Fee Name":"Activation Fee","Setup Fee Amount":"4.99"},{ID:"",Type:"simple",SKU:"PRO-YEARLY",Name:"Pro Annual Plan",Published:1,"Short description":"12-month installment plan",description:"Pay in 12 monthly installments for annual access to all pro features.",Categories:"Memberships",Images:"",Parent:"","Regular price":"19.99","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"subscription","Subscription Interval":"monthly","Trial Days":"",Installment:"yes","Installment Count":"12","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variable",SKU:"HOODIE-PREMIUM",Name:"Premium Zip Hoodie",Published:1,"Short description":"Heavyweight zip-up hoodie",description:"Premium quality hoodie with YKK zipper. Available in multiple colors.",Categories:"Clothing, Clothing > Hoodies",Images:"https://example.com/images/hoodie-main.jpg, https://example.com/images/hoodie-side.jpg, https://example.com/images/hoodie-detail.jpg",Parent:"","Regular price":"","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-BLK",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"https://example.com/images/hoodie-black.jpg",Parent:"HOODIE-PREMIUM","Regular price":"59.99","Sale price":"","Attribute 1 name":"Color","Attribute 1 value(s)":"Black","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-WHT",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"",Parent:"HOODIE-PREMIUM","Regular price":"59.99","Sale price":"","Attribute 1 name":"Color","Attribute 1 value(s)":"White","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-BLU-LE",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"",Parent:"HOODIE-PREMIUM","Regular price":"69.99","Sale price":"64.99","Attribute 1 name":"Color","Attribute 1 value(s)":"Blue","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""}],ee=gc.unparse(G),oe=new Blob([ee],{type:"text/csv;charset=utf-8;"}),re=URL.createObjectURL(oe),K=document.createElement("a");K.href=re,K.download="fluent-cart-sample-import.csv",document.body.appendChild(K),K.click(),document.body.removeChild(K),URL.revokeObjectURL(re)},X=t;return(G,ee)=>{const oe=C("el-button"),re=C("el-upload"),K=C("el-option"),Y=C("el-select"),W=C("el-dialog");return r(),h(H,null,[n(oe,{onClick:ee[0]||(ee[0]=j=>l.value=!0)},{default:d(()=>[R(m(G.$t("Import")),1)]),_:1}),n(W,{modelValue:l.value,"onUpdate:modelValue":ee[4]||(ee[4]=j=>l.value=j),"append-to-body":!0,title:G.$t("Import Products"),class:"fct-bulk-import-dialog"},{default:d(()=>[b.value?B("",!0):(r(),E(re,{key:0,class:"fct-file-uploader",ref:"uploaderRef","file-list":s.value,"onUpdate:fileList":ee[1]||(ee[1]=j=>s.value=j),drag:"",action:F(),"on-progress":()=>{},"on-success":()=>{},"on-error":()=>{},"auto-upload":!1,"on-change":j=>{$(),i.value=j,S(j==null?void 0:j.raw)},multiple:!1,limit:1,"show-file-list":!0},{default:d(()=>[n(et,{circle:"",bg:"primary",soft:""},{default:d(()=>[n(J,{name:"Upload"})]),_:1}),o("div",hve,[R(m(G.$t("Drag & Drop or"))+" ",1),o("em",null,m(G.$t("Browse/Upload")),1),R(" "+m(G.$t("Files"))+" ",1),o("span",null,m(A(u)("Any Format upto %s",A(Dt).serverMaxUploadSize())),1)])]),_:1},8,["file-list","action","on-change"])),b.value?B("",!0):(r(),E(oe,{key:1,onClick:z,link:""},{default:d(()=>[n(J,{name:"Download"}),R(" "+m(G.$t("Download a Sample CSV File")),1)]),_:1})),b.value?(r(),h(H,{key:2},[o("div",_ve,[o("h4",vve,m(G.$t("Map Columns")),1),o("table",gve,[o("thead",null,[o("tr",null,[o("th",null,m(G.$t("Products Fields")),1),o("th",null,m(G.$t("CSV Headers")),1)])]),o("tbody",null,[(r(!0),h(H,null,ae(f.value,(j,ie)=>(r(),h("tr",null,[o("td",null,m(j.title),1),o("td",yve,[n(Y,{modelValue:j.value,"onUpdate:modelValue":_e=>j.value=_e,filterable:"",clearable:""},{default:d(()=>[(r(!0),h(H,null,ae(_.value,_e=>(r(),E(K,{key:_e.value,label:_e.title,value:_e.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])])]))),256))])])]),o("div",bve,[n(oe,{onClick:ee[2]||(ee[2]=j=>L())},{default:d(()=>[R(m(G.$t("Add Products")),1)]),_:1}),n(oe,{onClick:ee[3]||(ee[3]=j=>L(!1))},{default:d(()=>[R(m(G.$t("Clear and Add Products")),1)]),_:1})])],64)):B("",!0)]),_:1},8,["modelValue","title"])],64)}}};class Cve extends Ed{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=fl(),t.detail={...this.data.dummies.productDetail},t.gallery=[],t.downloadable_files={...this.data.dummies.downloadableFile},t.variants=[this.getDummyVariation(t)],this.data.products.push(t)}clearProducts(){this.data.products=[]}isSaving(t){return this.data.savingIds.has(t)}isSaved(t){return this.data.savedIds.has(t)}isRowDisabled(t){return this.isSaving(t)||this.isSaved(t)}hasError(t){return this.data.productErrors.has(t)}getError(t){const a=this.data.productErrors.get(t);return a?a.fields&&Object.keys(a.fields).length?Object.values(a.fields).join("; "):a.message||"":""}hasProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?!!a.message:Object.keys(a.fields).some(l=>!l.startsWith("variants.")):!1}getProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?a.message||"":Object.entries(a.fields).filter(([s])=>!s.startsWith("variants.")).map(([,s])=>s).join("; ")||"":""}hasVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return!1;const s=`variants.${a}.`;return Object.keys(l.fields).some(i=>i.startsWith(s))}getVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return"";const s=`variants.${a}.`;return Object.entries(l.fields).filter(([c])=>c.startsWith(s)).map(([,c])=>c).join("; ")}hasFieldError(t,a){var s;const l=this.data.productErrors.get(t);return!!((s=l==null?void 0:l.fields)!=null&&s[a])}hasVariantFieldError(t,a,l){return this.hasFieldError(t,`variants.${a}.${l}`)}chunkArray(t,a){const l=[];for(let s=0;s!this.data.savedIds.has(c._cid));if(a.length===0){q.error(u("No products to save."));return}const l=this.chunkArray(a,10);this.data.saving=!0,this.data.productErrors=new Map,this.data.saveProgress={total:l.length,completed:0,errors:[],createdIds:[]};try{for(const f of l){const _=f.map(g=>g._cid);for(const g of _)this.data.savingIds.add(g);this.data.savingIds=new Set(this.data.savingIds);try{const g=await ce.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=((i=g==null?void 0:g.data)==null?void 0:i.message)||"A chunk failed to save";this.data.saveProgress.errors.push({message:v});for(const b of _)this.data.productErrors.set(b,{message:v,fields:{}})}this.data.productErrors=new Map(this.data.productErrors)}for(const g of _)this.data.savingIds.delete(g);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{createdIds:c,errors:p}=this.data.saveProgress;p.length===0?q.success(`${c.length} product(s) created successfully`):c.length>0?q.info(`${c.length} product(s) created, ${p.length} error(s)`):q.error(u("All products failed to save"))}finally{this.data.saving=!1}}async removeProduct(t){var l;if(t.ID&&this.data.savedIds.has(t._cid)){try{await ce.delete(`products/${t.ID}`)}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to delete product from server";q.error(i);return}this.data.savedIds.delete(t._cid),this.data.savedIds=new Set(this.data.savedIds)}const a=this.data.products.indexOf(t);a!==-1&&this.data.products.splice(a,1)}removeVariant(t,a){const l=t.variants.indexOf(a);l!==-1&&t.variants.splice(l,1)}duplicateProduct(t){const a=JSON.parse(JSON.stringify(t));a._cid=fl(),a.post_title=a.post_title?a.post_title+" (Copy)":"",a.variants&&Array.isArray(a.variants)&&a.variants.forEach(s=>{s.sku="",s._cid=fl()});const l=this.data.products.indexOf(t);this.data.products.splice(l+1,0,a)}duplicateProductWithVariants(t,a){const l=JSON.parse(JSON.stringify(t));if(l._cid=fl(),l.post_title=l.post_title?l.post_title+" (Copy)":"",l.variants&&Array.isArray(l.variants)){const i=new Set(a);l.variants=l.variants.filter((c,p)=>i.has(p)),l.variants.forEach(c=>{c.sku="",c._cid=fl()})}const s=this.data.products.indexOf(t);this.data.products.splice(s+1,0,l)}duplicateVariant(t,a){const l=JSON.parse(JSON.stringify(a));l._cid=fl(),l.variation_title=l.variation_title?l.variation_title+" (Copy)":"",l.sku="";const s=t.variants.indexOf(a);t.variants.splice(s+1,0,l)}resetPaymentTypeDefaults(t){t.other_info.payment_type==="onetime"&&(t.other_info.installment="no",t.other_info.times="",t.other_info.manage_setup_fee="no",t.other_info.signup_fee="",t.other_info.signup_fee_name="")}resetState(){this.data.products.splice(0),this.data.savedIds=new Set,this.data.savingIds=new Set,this.data.productErrors=new Map}getColumnWidthStorageKey(){return"bulk_insert_column_widths"}getColumnStorageKey(){return"bulk_insert_columns"}getToggleableColumns(){return[{label:"SKU",value:"sku"},{label:"Media",value:"media"},{label:"Categories",value:"categories"},{label:"Description",value:"description"},{label:"Short Description",value:"short_description"},{label:"Status",value:"status"},{label:"Product Type",value:"product_type"},{label:"Pricing Type",value:"pricing_type"},{label:"Payment Type",value:"payment_type"},{label:"Interval",value:"interval"},{label:"Trial Days",value:"trial_days"},{label:"Best Price",value:"best_price"},{label:"Compare-at Price",value:"compare_price"},{label:"Track Quantity",value:"track_quantity"},{label:"Stock",value:"stock"}]}flattenCategoryTree(t,a=""){var s;const l=[];for(const i of t){const c=a?`${a} > ${i.label}`:i.label;l.push({label:c,value:c}),(s=i.children)!=null&&s.length&&l.push(...this.flattenCategoryTree(i.children,c))}return l}async fetchCategories(){try{const a=(await ce.get("products/fetch-term")).taxonomies||{},l=Object.values(a).find(s=>s.name==="product-categories");l!=null&&l.terms&&(this.data.categoryOptions=this.flattenCategoryTree(l.terms))}catch{}}}const Ft=Cve.init(),kve={class:"max-w-full overflow-x-scroll"},Bve={class:"relative"},xve={key:0,class:"bulk-checkbox-cell"},Sve=["onMousedown","onTouchstart"],uf={__name:"ResizeableColumns",props:{columns:{type:Array,required:!0},stickyLast:{type:Boolean,default:!1}},emits:["scroll","resize-end"],setup(e,{emit:t}){const a=t,l=Rf(),s=Xr("table"),i=M(null);let c=null;Ee(()=>{Be(()=>{const g=s.value.querySelectorAll("th"),y=l["header-first"]?1:0;Array.from(g).forEach((v,b)=>{const k=b-y;k<0||k>=p.columns.length||(p.columns[k].width=v.offsetWidth,p.columns[k].minWidth||(p.columns[k].minWidth=v.offsetWidth))}),c=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")}),c.observe(s.value)})}),yl(()=>{c&&c.disconnect()});const p=e,f=N(()=>{const g=l["header-first"]?40:0;return p.columns.reduce((y,v)=>y+v.width,0)+g}),_=(g,y)=>{g.preventDefault();const v=g.clientX,b=p.columns[y].width,k=p.columns[y].minWidth||50;i.value=y;const w=$=>{const I=b+($.clientX-v);I>=k&&(p.columns[y].width=I)},S=()=>{i.value=null,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S),a("resize-end")};document.addEventListener("mousemove",w),document.addEventListener("mouseup",S)};return(g,y)=>(r(),h("div",kve,[o("div",{class:de(["resizable-table",{"is-resizing":i.value!==null}]),onScroll:y[0]||(y[0]=v=>a("scroll",v))},[o("div",Bve,[o("table",{id:"tb",ref_key:"table",ref:s,style:ra({tableLayout:"fixed",width:f.value+"px"})},[o("thead",null,[o("tr",null,[g.$slots["header-first"]?(r(),h("th",xve,[ba(g.$slots,"header-first")])):B("",!0),(r(!0),h(H,null,ae(e.columns,(v,b)=>(r(),h("th",{class:de({"sticky-col":b===0,"sticky-col sticky-col-right":b===e.columns.length-1&&e.stickyLast}),style:ra({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?ba(g.$slots,"header-last",{key:0},()=>[R(m(v.title),1)]):(r(),h(H,{key:1},[R(m(v.title),1)],64)),b_(k,b),onTouchstart:k=>_(k,b)},null,42,Sve)):B("",!0)],6))),128))])]),o("tbody",null,[ba(g.$slots,"default")])],4)])],34)]))}},Fve={class:"bulk-setup-fee-badge"},$ve={key:1,class:"text-gray-300 text-sm flex justify-center"},qo={__name:"BulkPriceInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=t;return(l,s)=>{var c;const i=C("el-tooltip");return e.variant?(r(),E(Za,{key:0,size:"small","error-class":e.hasError?"is-error":"","model-value":e.variant.item_price,placeholder:l.$t("Price"),disabled:e.disabled,"onUpdate:modelValue":s[0]||(s[0]=p=>{e.variant.item_price=p,a("change")})},na({_:2},[((c=e.variant.other_info)==null?void 0:c.manage_setup_fee)==="yes"&&e.variant.other_info.signup_fee?{name:"suffix",fn:d(()=>[n(i,{content:(e.variant.other_info.signup_fee_name||l.$t("Setup fee"))+": "+A(Nt)(e.variant.other_info.signup_fee,!0),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[o("span",Fve,"+ "+m(l.$t("fee")),1)]),_:1},8,["content"])]),key:"0"}:void 0]),1032,["error-class","model-value","placeholder","disabled"])):(r(),h("span",$ve,"—"))}}},Eve=["disabled"],Uve={key:0,class:"fct-bulk-sub-count"},Ive={class:"fct-bulk-sub-popover-body"},Qve={class:"fct-bulk-sub-popover-title"},Dve={class:"fct-bulk-sub-section"},Vve={class:"fct-bulk-sub-row"},Tve={class:"fct-bulk-sub-row"},Mve={class:"fct-bulk-sub-label"},Lve={class:"fct-bulk-sub-row"},Rve={class:"fct-bulk-sub-label"},Ove=["innerHTML"],Hve={class:"fct-bulk-sub-section"},Pve={class:"fct-bulk-sub-row"},Nve={class:"fct-bulk-sub-row"},Kve={class:"fct-bulk-sub-label"},Gve={class:"fct-bulk-sub-row"},jve={class:"fct-bulk-sub-label"},zve={class:"fct-bulk-sub-footer"},or=2,qve={__name:"BulkSubscriptionPopover",props:{variant:{type:Object,required:!0},disabled:{type:Boolean,default:!1}},emits:["changed"],setup(e,{emit:t}){const a=e,l=t,s=Yt().ctx,i=je.get(),c=je.get("app_config.isProActive"),p=M(!1);N(()=>{var F;return((F=i==null?void 0:i.shop)==null?void 0:F.currency_sign)||"$"});const f=N(()=>{var F;return((F=a.variant)==null?void 0:F.other_info)||{}}),_=N(()=>f.value.payment_type==="subscription"),g=N(()=>f.value.installment==="yes"),y=N(()=>Number(f.value.times)||1),v=N(()=>{var x;const F=Number((x=a.variant)==null?void 0:x.item_price)||0;return g.value?F*y.value:F}),b=N(()=>{const F=[];if(g.value&&F.push(s.$t("Installment")+": "+y.value+"x"),f.value.manage_setup_fee==="yes"){const x=f.value.signup_fee_name||s.$t("Setup fee"),U=f.value.signup_fee||0;F.push(s.$t("Setup fee")+": "+x+" ("+Nt(U,!0)+")")}return F.length>0?F.join(`
`):s.$t("Subscription settings")}),k=F=>{F==="no"?a.variant.other_info.times="":w(),l("changed")},w=()=>{const F=Number(a.variant.other_info.times);(!Number.isFinite(F)||F{F==="no"&&(a.variant.other_info.signup_fee=""),l("changed")},$=()=>{l("changed")},I=()=>{p.value=!1};return(F,x)=>{const U=C("el-checkbox"),T=C("el-tooltip"),D=C("el-input"),Q=C("el-switch"),V=C("el-button"),O=C("el-popover");return r(),E(T,{content:b.value,placement:"top",disabled:!_.value||p.value,"popper-class":"fct-tooltip","show-after":400},{default:d(()=>[n(O,{visible:p.value,"onUpdate:visible":x[6]||(x[6]=L=>p.value=L),placement:"bottom",width:320,trigger:"click",disabled:e.disabled||!_.value,"popper-class":"bulk-sub-popover"},{reference:d(()=>[o("button",{class:de(["fc-bulk-sub-icon-btn",{"is-active":_.value,"is-configured":_.value&&(g.value||f.value.manage_setup_fee==="yes")}]),disabled:e.disabled||!_.value,onClick:x[0]||(x[0]=Pe(()=>{},["prevent"]))},[x[7]||(x[7]=o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16"},[o("path",{d:"M6 4H21C21.5523 4 22 4.44772 22 5V12H20V6H6V9L1 5.5L6 2V4ZM18 20H3C2.44772 20 2 19.5523 2 19V12H4V18H18V15L23 18.5L18 22V20Z"})],-1)),g.value?(r(),h("span",Uve,m(y.value),1)):B("",!0)],10,Eve)]),default:d(()=>[o("div",Ive,[o("h4",Qve,m(F.$t("Subscription Settings")),1),o("div",Dve,[o("div",Vve,[n(U,{"true-value":"yes","false-value":"no",label:F.$t("Enable installment payment"),modelValue:e.variant.other_info.installment,"onUpdate:modelValue":x[1]||(x[1]=L=>e.variant.other_info.installment=L),disabled:!A(c)||e.disabled,onChange:k},null,8,["label","modelValue","disabled"]),A(c)?B("",!0):(r(),E(T,{key:0,"popper-class":"fct-tooltip"},{content:d(()=>[R(m(F.$t("This feature is available in pro version only.")),1)]),default:d(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),f.value.installment==="yes"?(r(),h(H,{key:0},[o("div",Tve,[o("label",Mve,m(F.$t("Installment Count")),1),n(D,{type:"number",min:or,size:"small",modelValue:e.variant.other_info.times,"onUpdate:modelValue":x[2]||(x[2]=L=>e.variant.other_info.times=L),modelModifiers:{number:!0},placeholder:F.$t("Count"),style:{width:"100px"},onInput:$,onChange:w},null,8,["modelValue","placeholder"])]),o("div",Lve,[o("span",Rve,m(F.$t("Total Price")),1),o("span",{class:"fct-bulk-sub-value",innerHTML:A(Nt)(v.value,!0)},null,8,Ove)])],64)):B("",!0)]),o("div",Hve,[o("div",Pve,[n(Q,{"active-text":F.$t("Setup fee"),modelValue:e.variant.other_info.manage_setup_fee,"onUpdate:modelValue":x[3]||(x[3]=L=>e.variant.other_info.manage_setup_fee=L),"active-value":"yes","inactive-value":"no",disabled:!A(c)||e.disabled,size:"small",onChange:S},null,8,["active-text","modelValue","disabled"]),A(c)?B("",!0):(r(),E(T,{key:0,"popper-class":"fct-tooltip"},{content:d(()=>[R(m(F.$t("This feature is available in pro version only.")),1)]),default:d(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),f.value.manage_setup_fee==="yes"?(r(),h(H,{key:0},[o("div",Nve,[o("label",Kve,m(F.$t("Label")),1),n(D,{size:"small",modelValue:e.variant.other_info.signup_fee_name,"onUpdate:modelValue":x[4]||(x[4]=L=>e.variant.other_info.signup_fee_name=L),placeholder:F.$t("e.g. Initial Setup"),onInput:$},null,8,["modelValue","placeholder"])]),o("div",Gve,[o("label",jve,m(F.$t("Amount")),1),n(Za,{size:"small","model-value":e.variant.other_info.signup_fee,placeholder:F.$t("Amount"),"onUpdate:modelValue":x[5]||(x[5]=L=>{e.variant.other_info.signup_fee=L,$()})},null,8,["model-value","placeholder"])])],64)):B("",!0)]),o("div",zve,[n(V,{size:"small",type:"primary",onClick:I},{default:d(()=>[R(m(F.$t("Done")),1)]),_:1})])])]),_:1},8,["visible","disabled"])]),_:1},8,["content","disabled"])}}},Yve={key:0,class:"flex items-center"},Wve={key:1,class:"text-gray-300 text-sm flex justify-center"},Yo={__name:"BulkPaymentTypeCell",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change","payment-type-change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i;return(i=a.variant)==null?void 0:i.other_info};return(i,c)=>{const p=C("el-option"),f=C("el-select");return e.variant&&s()?(r(),h("div",Yve,[n(f,{modelValue:e.variant.other_info.payment_type,"onUpdate:modelValue":c[0]||(c[0]=_=>e.variant.other_info.payment_type=_),size:"small",class:de({"is-field-error":e.hasError}),disabled:e.disabled,onChange:c[1]||(c[1]=_=>l("payment-type-change",e.variant))},{default:d(()=>[n(p,{label:i.$t("One Time"),value:"onetime"},null,8,["label"]),n(p,{label:i.$t("Subscription"),value:"subscription"},null,8,["label"])]),_:1},8,["modelValue","class","disabled"]),n(qve,{variant:e.variant,disabled:e.disabled,onChanged:c[2]||(c[2]=_=>l("change"))},null,8,["variant","disabled"])])):(r(),h("span",Wve,"—"))}}},Jve={key:1,class:"text-gray-300 text-sm flex justify-center"},Wo={__name:"BulkIntervalSelect",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i,c;return((c=(i=a.variant)==null?void 0:i.other_info)==null?void 0:c.payment_type)==="subscription"};return(i,c)=>{const p=C("el-option"),f=C("el-select");return e.variant&&s()?(r(),E(f,{key:0,modelValue:e.variant.other_info.repeat_interval,"onUpdate:modelValue":c[0]||(c[0]=_=>e.variant.other_info.repeat_interval=_),size:"small",class:de({"is-field-error":e.hasError}),disabled:e.disabled,onChange:c[1]||(c[1]=_=>l("change"))},{default:d(()=>[n(p,{label:i.$t("Yearly"),value:"yearly"},null,8,["label"]),n(p,{label:i.$t("Half Yearly"),value:"half_yearly"},null,8,["label"]),n(p,{label:i.$t("Quarterly"),value:"quarterly"},null,8,["label"]),n(p,{label:i.$t("Monthly"),value:"monthly"},null,8,["label"]),n(p,{label:i.$t("Weekly"),value:"weekly"},null,8,["label"]),n(p,{label:i.$t("Daily"),value:"daily"},null,8,["label"])]),_:1},8,["modelValue","class","disabled"])):(r(),h("span",Jve,"—"))}}},Xve={key:1,class:"text-gray-300 text-sm flex justify-center"},Jo={__name:"BulkTrialDaysInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i,c;return((c=(i=a.variant)==null?void 0:i.other_info)==null?void 0:c.payment_type)==="subscription"};return(i,c)=>{const p=C("el-input");return e.variant&&s()?(r(),E(p,{key:0,class:de(["fct-bulk-input",{"is-error":e.hasError}]),modelValue:e.variant.other_info.trial_days,"onUpdate:modelValue":c[0]||(c[0]=f=>e.variant.other_info.trial_days=f),placeholder:"0",disabled:e.disabled,onChange:c[1]||(c[1]=f=>l("change")),size:"small"},null,8,["class","modelValue","disabled"])):(r(),h("span",Xve,"—"))}}},Zve={key:1,class:"text-gray-300 text-sm flex justify-center"},Xo={__name:"BulkComparePriceInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=t;return(l,s)=>e.variant?(r(),E(Za,{key:0,size:"small","error-class":e.hasError?"is-error":"","model-value":e.variant.compare_price,placeholder:l.$t("Compare price"),disabled:e.disabled,"onUpdate:modelValue":s[0]||(s[0]=i=>{e.variant.compare_price=i,a("change")})},null,8,["error-class","model-value","placeholder","disabled"])):(r(),h("span",Zve,"—"))}},cf={__name:"BulkCategorySelect",props:{modelValue:{type:Array,default:()=>[]},options:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(e,{emit:t}){const a=t,l=s=>{a("update:modelValue",s),a("change",s)};return(s,i)=>{const c=C("el-option"),p=C("el-select");return r(),E(p,{"model-value":e.modelValue,multiple:"",filterable:"","allow-create":"","default-first-option":"","collapse-tags":"","collapse-tags-tooltip":!1,"max-collapse-tags":1,size:"small",placeholder:s.$t("Select or type..."),disabled:e.disabled,"onUpdate:modelValue":l},{default:d(()=>[(r(!0),h(H,null,ae(e.options,f=>(r(),E(c,{key:f.value,label:f.label,value:f.value},null,8,["label","value"]))),128))]),_:1},8,["model-value","placeholder","disabled"])}}},ege=["textContent"],tge={key:1,class:"fct-bulk-editor-placeholder"},Zo={__name:"BulkEditorCell",props:{value:{type:String,default:""},placeholder:{type:String,default:""}},emits:["click"],setup(e){return(t,a)=>(r(),h("div",{class:"fct-bulk-editor",onClick:a[0]||(a[0]=l=>t.$emit("click"))},[e.value?(r(),h("span",{key:0,class:"bulk-editor-preview",textContent:m(e.value)},null,8,ege)):(r(),h("span",tge,m(e.placeholder),1))]))}};function Af(){const e=M(new Set),t=M(null),a=M(!1),l=(y,v,b)=>{if(v.shiftKey&&t.value!==null){const w=b.indexOf(t.value),S=b.indexOf(y);if(w!==-1&&S!==-1){const $=Math.min(w,S),I=Math.max(w,S),F=new Set(e.value);for(let x=$;x<=I;x++)F.add(b[x]);e.value=F}}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)},i=y=>{e.value=new Set(y)},c=()=>{e.value=new Set,t.value=null,a.value=!1},p=()=>{a.value?a.value=!1:e.value.size>=2&&(a.value=!0)};ye(e,y=>{a.value&&y.size<2&&(a.value=!1)});const f=y=>e.value.has(y),_=N(()=>e.value.size);return{selectedKeys:e,lastClickedKey:t,isLinkMode:a,handleRowClick:l,toggleSelectAll:s,selectAll:i,deselectAll:c,toggleLinkMode:p,isSelected:f,selectedCount:_,pruneStaleKeys:y=>{const v=new Set(y);let b=!1;const k=new Set;for(const w of e.value)v.has(w)?k.add(w):b=!0;b&&(e.value=k),t.value&&!v.has(t.value)&&(t.value=null)}}}const age={mounted(e,t){e.indeterminate=!!t.value},updated(e,t){e.indeterminate=!!t.value}},pf={title:{product:{get:e=>e.post_title,set:(e,t)=>e.post_title=t},variant:{get:e=>e.variation_title,set:(e,t)=>e.variation_title=t}},sku:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.sku},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].sku=t)}},variant:{get:e=>e.sku,set:(e,t)=>e.sku=t}},status:{product:{get:e=>e.post_status,set:(e,t)=>e.post_status=t}},description:{product:{get:e=>e.post_content,set:(e,t)=>e.post_content=t}},short_desc:{product:{get:e=>e.post_excerpt,set:(e,t)=>e.post_excerpt=t}},product_type:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.fulfillment_type},set:(e,t)=>{e.detail&&(e.detail.fulfillment_type=t)}}},pricing_type:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.variation_type},set:(e,t)=>{e.detail&&(e.detail.variation_type=t)}}},payment_type:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.payment_type},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.payment_type=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.payment_type},set:(e,t)=>{e.other_info&&(e.other_info.payment_type=t)}}},interval:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.repeat_interval},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.repeat_interval=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.repeat_interval},set:(e,t)=>{e.other_info&&(e.other_info.repeat_interval=t)}}},trial_days:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.trial_days},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.trial_days=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.trial_days},set:(e,t)=>{e.other_info&&(e.other_info.trial_days=t)}}},price:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.item_price},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].item_price=t)}},variant:{get:e=>e.item_price,set:(e,t)=>e.item_price=t}},compare_price:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.compare_price},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].compare_price=t)}},variant:{get:e=>e.compare_price,set:(e,t)=>e.compare_price=t}},manage_stock:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.manage_stock},set:(e,t)=>{e.detail&&(e.detail.manage_stock=t)}}},categories:{product:{get:e=>e.categories,set:(e,t)=>e.categories=[...t]}}},lge={...pf,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}}},sge={...pf,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 ff(e,t,a,l,s,i,c){const p=c[e];if(p)for(const f of l){if(f===a)continue;const _=s(f);if(!_)continue;const g=p[_.type];g&&(g.set(_.data,t),i&&i(_.product))}}const nge={class:"fct-bulk-insert-page fct-layout-width"},oge={class:"fct-btn-group sm justify-end"},ige={class:"filter-popover-item"},rge={class:"filter-popover-title"},dge={key:0,"aria-hidden":"true"},uge=["colspan"],cge=["onClick"],Age=["onClick"],pge={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},fge={class:"flex items-center"},mge=["onClick","title"],hge={key:0,class:"bulk-collapse-count"},_ge=["title"],vge=["title"],gge={class:"bulk-status-icon is-error"},yge={key:0,class:"fct-bulk-sku-cell"},bge={key:1,class:"text-gray-300 text-sm flex justify-center"},wge={key:1,class:"fct-bulk-media-cell"},Cge={key:2,class:"fct-bulk-categories-cell"},kge={key:3,class:"fct-bulk-desc-cell"},Bge={key:4,class:"fct-bulk-short-desc-cell"},xge={key:5,class:"fct-bulk-status-cell"},Sge={key:6,class:"fct-bulk-product-type-cell"},Fge={key:7,class:"fct-bulk-product-type-cell"},$ge={key:8,class:"fct-bulk-pricing-type-cell"},Ege={key:9,class:"fct-bulk-pricing-type-cell"},Uge={key:10,class:"fct-bulk-payment-type-cell"},Ige={key:11,class:"fct-bulk-interval-cell"},Qge={key:12,class:"fct-bulk-trial-days-cell"},Dge={key:13,class:"fct-bulk-best-price-cell"},Vge={key:14,class:"fct-bulk-compare-price-cell"},Tge={key:15,class:"fct-bulk-qty-cell !pl-5"},Mge={key:16,class:"fct-bulk-stock-cell"},Lge={key:1,class:"text-gray-300 text-sm pl-5"},Rge={class:"fct-btn-group xs justify-end"},Oge=["href","title"],Hge={key:0,class:"bulk-variants-block-row"},Pge=["colspan"],Nge={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},Kge=["onClick"],Gge={class:"bulk-checkbox-cell"},jge={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},zge={class:"flex items-center gap-1 pl-4"},qge={class:"bulk-status-icon is-error"},Yge={key:0,class:"fct-bulk-sku-cell"},Wge={key:1,class:"fct-bulk-media-cell"},Jge={key:2},Xge={key:3},Zge={key:4},e1e={key:5},t1e={key:6},a1e={key:7},l1e={key:8},s1e={key:9},n1e={key:10},o1e={key:11},i1e={key:12},r1e={key:13,class:"text-center"},d1e={key:14},u1e={key:1,class:"text-gray-300 text-sm flex justify-center"},c1e={class:"fct-btn-group sm justify-end"},A1e={class:"bulk-add-variant-row"},p1e=["colspan"],f1e={class:"sticky left-0 inline-block pl-6"},m1e={key:1,"aria-hidden":"true"},h1e=["colspan"],ir=43,_1e=10,v1e=800,yc=100,g1e={__name:"BulkInsert",setup(e){const{options:t,products:a}=Ft.data,l=ve=>{var Se;return((Se=ve==null?void 0:ve.detail)==null?void 0:Se.variation_type)==="simple"},s=N(()=>Ft.data.saving),i=N(()=>Ft.data.saveProgress),c=N(()=>{const ve=Ft.data.saveProgress;return ve.total?Math.round(ve.completed/ve.total*100):0}),p=()=>{Ft.saveProducts()},f=ve=>Ft.isSaving(ve._cid),_=ve=>Ft.isSaved(ve._cid),g=ve=>Ft.isRowDisabled(ve._cid),y=ve=>Ft.hasError(ve._cid),v=ve=>Ft.getError(ve._cid),b=ve=>Ft.hasProductLevelError(ve._cid),k=(ve,Se)=>Ft.hasVariantError(ve._cid,Se),w=(ve,Se)=>Ft.getVariantError(ve._cid,Se),S=(ve,Se)=>Ft.hasFieldError(ve._cid,Se),$=(ve,Se,nt)=>Ft.hasVariantFieldError(ve._cid,Se,nt),I=async ve=>{const Se=ve.post_title||P.$t("Untitled product"),nt=Array.isArray(ve.variants)?ve.variants.length:0,wt=Ft.isSaved(ve._cid);let kt=nt>0?P.$t('This will remove "%1$s" and its %2$s variant(s).',Se,nt):P.$t('This will remove "%1$s".',Se);wt&&(kt+=" "+P.$t("This product was already saved and will be permanently deleted."));try{await Fl.confirm(kt,P.$t("Remove Product"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),type:"warning"})}catch{return}await Ft.removeProduct(ve)},F=(ve,Se)=>{const nt=Se.variation_title||P.$t("Untitled variant");Fl.confirm(P.$t('This will remove the variant "%1$s".',nt),P.$t("Remove Variant"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),confirmButtonClass:"el-button--small",cancelButtonClass:"el-button--small",type:"warning"}).then(()=>{Ft.removeVariant(ve,Se)}).catch(()=>{})},x=ve=>Ft.duplicateProduct(ve),U=(ve,Se)=>Ft.duplicateVariant(ve,Se),T=()=>{const ve=[];for(const Se of a){const nt=`p:${Se._cid}`,wt=Y.value.has(nt),kt=[];Se.variants&&Se.variants.forEach((Jt,_t)=>{Y.value.has(`v:${Se._cid}:${_t}`)&&kt.push(_t)}),!(!wt&&kt.length===0)&&(wt&&kt.length===0?ve.push({product:Se,type:"full"}):!wt&&kt.length>0?ve.push({product:Se,type:"variants-only",variantIndexes:kt}):ve.push({product:Se,type:"partial",variantIndexes:kt}))}return ve},D=()=>{const ve=T();if(!ve.length)return;const Se=ve.filter(_t=>_t.type==="full").length,nt=ve.filter(_t=>_t.type==="partial").length,kt=ve.filter(_t=>_t.type==="variants-only").reduce((_t,Xt)=>_t+Xt.variantIndexes.length,0),Jt=[];Se>0&&Jt.push(`${Se} product(s) with all variants`),nt>0&&Jt.push(`${nt} product(s) with selected variants`),kt>0&&Jt.push(`${kt} variant(s)`),Fl.confirm(P.$t("Duplicate %s?").replace("%s",Jt.join(", ")),P.$t("Bulk Duplicate"),{confirmButtonText:P.$t("Duplicate"),cancelButtonText:P.$t("Cancel"),type:"info"}).then(()=>{for(const _t of ve)if(_t.type==="full")Ft.duplicateProduct(_t.product);else if(_t.type==="variants-only")for(const Xt of _t.variantIndexes){const Zt=_t.product.variants[Xt];Zt&&Ft.duplicateVariant(_t.product,Zt)}else _t.type==="partial"&&Ft.duplicateProductWithVariants(_t.product,_t.variantIndexes);_e()}).catch(()=>{})},Q=async()=>{const ve=[],Se=[];for(const _t of a){const Xt=`p:${_t._cid}`;if(Y.value.has(Xt)){ve.push(_t);continue}const Gt=[];_t.variants&&_t.variants.forEach((ga,qa)=>{Y.value.has(`v:${_t._cid}:${qa}`)&&Gt.push(ga)}),Gt.length>0&&Se.push({product:_t,variants:Gt})}if(!ve.length&&!Se.length)return;const nt=ve.filter(_t=>Ft.isSaved(_t._cid)).length,wt=Se.reduce((_t,Xt)=>_t+Xt.variants.length,0),kt=[];ve.length>0&&kt.push(`${ve.length} product(s)`),wt>0&&kt.push(`${wt} variant(s)`);let Jt=P.$t("Remove %s?").replace("%s",kt.join(" and "));nt>0&&(Jt+=" "+P.$t("%s already saved will be permanently deleted.").replace("%s",`${nt}`));try{await Fl.confirm(Jt,P.$t("Bulk Remove"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),type:"warning"})}catch{return}for(const _t of ve)await Ft.removeProduct(_t);for(const{product:_t,variants:Xt}of Se)for(const Zt of Xt)Ft.removeVariant(_t,Zt);_e()},V=ve=>{Ft.resetPaymentTypeDefaults(ve)},O=(ve,Se)=>{const nt=Ft.data.categoryOptions;for(const wt of Se)nt.find(kt=>kt.value===wt)||nt.push({label:wt,value:wt})},L=()=>{Ft.populateDummyProduct()},P=Yt().ctx,z=ve=>{const Se=Ft.data.products;ve.concat||(Se.splice(0,Se.length),Ft.data.savedIds=new Set,Ft.data.savingIds=new Set,Ft.data.productErrors=new Map),Se.push(...ve.products)},X=M({visible:!1,field:"",product:null,value:""}),G=(ve,Se)=>{X.value={visible:!0,field:Se,product:ve,value:ve[Se]||""}},ee=ve=>{X.value.value=ve},oe=()=>{const{product:ve,field:Se,value:nt}=X.value;ve&&(ve[Se]=nt),X.value.visible=!1},re=N(()=>X.value.field==="post_content"?P.$t("Edit Description"):P.$t("Edit Short Description")),K=M(!0),{selectedKeys:Y,handleRowClick:W,toggleSelectAll:j,selectAll:ie,deselectAll:_e,isSelected:me,selectedCount:ue,isLinkMode:le,toggleLinkMode:be}=Af(),Qe=N(()=>{const ve=[];for(const Se of ht.value)if(ve.push(`p:${Se.productId}`),Se.hasVariants&&!Se.collapsed)for(let nt=0;nt{var Se;if(ve.startsWith("p:")){const nt=ve.slice(2),wt=a.find(kt=>kt._cid===nt);return wt?{type:"product",data:wt,product:wt}:null}else if(ve.startsWith("v:")){const nt=ve.split(":"),wt=nt[1],kt=parseInt(nt[2]),Jt=a.find(_t=>_t._cid===wt);if(Jt&&((Se=Jt.variants)!=null&&Se[kt]))return{type:"variant",data:Jt.variants[kt],product:Jt}}return null},ge=(ve,Se,nt)=>{!le.value||!me(nt)||ff(ve,Se,nt,Y.value,Ke,null,lge)},tt=M(!1),yt=ve=>{ve.key==="Shift"&&(tt.value=!0)},Je=ve=>{ve.key==="Shift"&&(tt.value=!1)},xe=(ve,Se)=>{if(!Se.shiftKey||Se.target.closest(".bulk-checkbox-cell"))return;Se.preventDefault();const nt=new Set(Y.value);nt.has(ve)?nt.delete(ve):nt.add(ve),Y.value=nt},Fe=M([]),Oe=N(()=>Fe.value.filter(ve=>ve.key==="title"||ve.key==="actions"?!0:Ft.isColumnVisible(ve.key))),Me=ve=>Ft.isColumnVisible(ve),gt=()=>{Ft.saveColumnWidths(Fe.value)},vt=M(new Set),Lt=ve=>{const Se=ve._cid;vt.value.has(Se)?vt.value.delete(Se):vt.value.add(Se),vt.value=new Set(vt.value)},Vt=ve=>vt.value.has(ve._cid),Qt=M(0),ht=N(()=>{let ve=0;return a.map(Se=>{var Gt;const nt=Se._cid,wt=((Gt=Se.detail)==null?void 0:Gt.variation_type)!=="simple"&&Array.isArray(Se.variants),kt=wt?Se.variants.length:0,Jt=vt.value.has(nt),_t=wt&&!Jt?(kt+1)*ir:0,Xt=ir+_t,Zt={product:Se,productId:nt,hasVariants:wt,variantCount:kt,collapsed:Jt,groupHeight:Xt,offset:ve};return ve+=Xt,Zt})}),Kt=N(()=>{const ve=ht.value;if(ve.length===0)return 0;const Se=ve[ve.length-1];return Se.offset+Se.groupHeight}),bt=N(()=>{const ve=ht.value,Se=Qt.value,nt=Se+v1e,wt=_1e*ir;return ve.filter(kt=>kt.offset+kt.groupHeight>=Se-wt&&kt.offset<=nt+wt)}),St=N(()=>bt.value.length===0?0:bt.value[0].offset),Ot=N(()=>{if(bt.value.length===0)return 0;const ve=bt.value[bt.value.length-1];return Kt.value-ve.offset-ve.groupHeight});let Ht=null,It=0;const mt=ve=>{const Se=ve.target,nt=Date.now();Ht&&clearTimeout(Ht),nt-It>=yc?(Qt.value=Se.scrollTop,It=nt):Ht=setTimeout(()=>{Qt.value=Se.scrollTop,It=Date.now(),Ht=null},yc)};let jt=null;return Ee(async()=>{jt=_s(),jt.bind("mod+a",ve=>{var nt,wt;const Se=(nt=document.activeElement)==null?void 0:nt.tagName;Se==="INPUT"||Se==="TEXTAREA"||(wt=document.activeElement)!=null&&wt.isContentEditable||(ve.preventDefault(),ie(Qe.value))}),jt.bind("escape",()=>{var Se,nt;const ve=(Se=document.activeElement)==null?void 0:Se.tagName;ve==="INPUT"||ve==="TEXTAREA"||(nt=document.activeElement)!=null&&nt.isContentEditable||(le.value?be():_e())}),Fe.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}],Ft.restoreColumnWidths(Fe.value),Ft.setupColumnVisibility(),Ft.fetchCategories(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",yt),window.addEventListener("keyup",Je)}),yl(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",yt),window.removeEventListener("keyup",Je),jt&&jt.reset()}),(ve,Se)=>{const nt=C("el-button"),wt=C("el-progress"),kt=C("el-checkbox"),Jt=C("el-checkbox-group"),_t=C("el-tooltip"),Xt=C("el-popover"),Zt=C("el-input"),Gt=C("el-icon"),ga=C("el-option"),qa=C("el-select"),il=C("el-switch"),Ya=C("el-dialog");return r(),h("div",nge,[n(ol,{title:ve.$t("Bulk Insert")},{action:d(()=>[n(wve,{onOnDataPopulated:z}),n(nt,{onClick:L},{default:d(()=>[R(m(ve.$t("Add Product")),1)]),_:1}),n(nt,{type:"primary",onClick:p,loading:s.value,disabled:s.value||A(a).length===0},{default:d(()=>[R(m(s.value?ve.$t("Saving %s/%s...").replace("%s",i.value.completed).replace("%s",i.value.total):ve.$t("Save All Products")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),s.value?(r(),E(wt,{key:0,percentage:c.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):B("",!0),n(ke,null,{default:d(()=>{var fa;return[A(a).length>0?(r(),E(Ie,{key:0,title:((fa=A(a))==null?void 0:fa.length)===1?ve.$t("Product"):ve.$t("Products"),border_bottom:""},{action:d(()=>[o("div",oge,[n(nt,{disabled:A(ue)===0,onClick:Q,size:"small",type:"danger",soft:""},{default:d(()=>[Se[8]||(Se[8]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("polyline",{points:"3 6 5 6 21 6"}),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)),R(" "+m(ve.$t("Delete")),1)]),_:1,__:[8]},8,["disabled"]),n(nt,{disabled:A(ue)===0,onClick:D,size:"small",type:"info",soft:""},{default:d(()=>[Se[9]||(Se[9]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)),R(" "+m(ve.$t("Duplicate")),1)]),_:1,__:[9]},8,["disabled"]),n(nt,{class:de({"is-active":A(le)}),disabled:A(ue)<2&&!A(le),onClick:A(be),size:"small",type:"info",soft:""},{default:d(()=>[Se[10]||(Se[10]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)),R(" "+m(A(le)?ve.$t("Unlink"):ve.$t("Link")),1)]),_:1,__:[10]},8,["class","disabled","onClick"]),n(kt,{modelValue:K.value,"onUpdate:modelValue":Se[0]||(Se[0]=Z=>K.value=Z),label:ve.$t("Pin Actions")},null,8,["modelValue","label"]),n(Xt,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:d(()=>[o("span",null,[n(_t,{effect:"light",content:ve.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(et,{tag:"button",size:"small"},{default:d(()=>[n(J,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:d(()=>[o("div",ige,[o("h3",rge,m(ve.$t("Columns")),1),n(Jt,{modelValue:A(Ft).data.visibleColumns,"onUpdate:modelValue":Se[1]||(Se[1]=Z=>A(Ft).data.visibleColumns=Z),class:"fct-checkbox-blocks",onChange:Se[2]||(Se[2]=Z=>A(Ft).handleColumnVisibilityChange())},{default:d(()=>[(r(!0),h(H,null,ae(A(Ft).getToggleableColumns(),Z=>(r(),E(kt,{key:Z.value,value:Z.value,label:ve.$t(Z.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])]),_:1},8,["title"])):B("",!0),n(Ce,{class:"p-0"},{default:d(()=>[A(a).length>0?(r(),h("div",{key:0,class:de(["relative",{"is-link-mode":A(le),"is-shift-held":tt.value}])},[n(uf,{columns:Oe.value,"sticky-last":K.value,onScroll:mt,onResizeEnd:gt},{"header-first":d(()=>[n(kt,{"model-value":A(ue)>0&&A(ue)===Qe.value.length,indeterminate:A(ue)>0&&A(ue)A(j)(Qe.value))},null,8,["model-value","indeterminate"])]),"header-last":d(()=>[R(m(ve.$t("Actions")),1)]),default:d(()=>[St.value>0?(r(),h("tr",dge,[o("td",{colspan:Oe.value.length+1,style:ra({height:St.value+"px",padding:0,border:"none"})},null,12,uge)])):B("",!0),(r(!0),h(H,null,ae(bt.value,Z=>{var we,se,fe,qe,at,Ge,We,ft,Ze,Ut,Ae,he,Le,Ve,ut;return r(),h(H,{key:Z.productId},[o("tr",{class:de(["bulk-product-row",{"is-saving":f(Z.product),"is-saved":_(Z.product),"has-product-error":y(Z.product),"is-selected":A(me)(`p:${Z.productId}`)}]),onClick:te=>xe(`p:${Z.productId}`,te)},[o("td",{class:"bulk-checkbox-cell",onClick:te=>A(W)(`p:${Z.productId}`,te,Qe.value)},[n(kt,{"model-value":A(me)(`p:${Z.productId}`),tabindex:"-1"},null,8,["model-value"])],8,Age),o("td",pge,[o("div",fge,[Z.hasVariants?(r(),h("button",{key:0,class:"bulk-collapse-btn",onClick:Pe(te=>Lt(Z.product),["prevent"]),title:Vt(Z.product)?ve.$t("Expand variants"):ve.$t("Collapse variants")},[(r(),h("svg",{class:de(["bulk-collapse-icon",{"is-collapsed":Vt(Z.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},Se[11]||(Se[11]=[o("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),Vt(Z.product)?(r(),h("span",hge,m(Z.variantCount),1)):B("",!0)],8,mge)):B("",!0),n(Zt,{class:de(["fct-bulk-input",{"is-error":S(Z.product,"post_title")}]),modelValue:Z.product.post_title,"onUpdate:modelValue":te=>Z.product.post_title=te,placeholder:ve.$t("Product title"),size:"small",disabled:g(Z.product),onInput:te=>ge("title",te,`p:${Z.productId}`)},null,8,["class","modelValue","onUpdate:modelValue","placeholder","disabled","onInput"]),f(Z.product)?(r(),h("span",{key:1,class:"bulk-status-icon is-syncing",title:ve.$t("Saving...")},[n(Gt,{class:"is-loading",size:14},{default:d(()=>[n(A(Xs))]),_:1})],8,_ge)):_(Z.product)?(r(),h("span",{key:2,class:"bulk-status-icon is-saved",title:ve.$t("Saved")},Se[12]||(Se[12]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16"},[o("path",{d:"M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-.997-6l7.07-7.071-1.414-1.414-5.656 5.657-2.829-2.829-1.414 1.414L11.003 16z"})],-1)]),8,vge)):b(Z.product)||l(Z.product)&&y(Z.product)?(r(),E(_t,{key:3,content:v(Z.product),placement:"top"},{default:d(()=>[o("span",gge,[n(Gt,{size:16},{default:d(()=>[n(A(Uo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),Me("sku")?(r(),h("td",yge,[((se=(we=Z.product)==null?void 0:we.detail)==null?void 0:se.variation_type)==="simple"&&((fe=Z.product.variants)!=null&&fe[0])?(r(),E(Zt,{key:0,class:de(["fct-bulk-input",{"is-error":S(Z.product,"variants.0.sku")}]),modelValue:Z.product.variants[0].sku,"onUpdate:modelValue":[te=>Z.product.variants[0].sku=te,te=>ge("sku",te,`p:${Z.productId}`)],placeholder:"SKU",size:"small",disabled:g(Z.product)},null,8,["class","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",bge,"—"))])):B("",!0),Me("media")?(r(),h("td",wge,[n(vl,{modelValue:Z.product.gallery,"onUpdate:modelValue":te=>Z.product.gallery=te,"show-url-tab":"",disabled:g(Z.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),Me("categories")?(r(),h("td",Cge,[n(cf,{modelValue:Z.product.categories,"onUpdate:modelValue":te=>Z.product.categories=te,options:A(Ft).data.categoryOptions,disabled:g(Z.product),onChange:te=>{O(Z.product,te),ge("categories",Z.product.categories,`p:${Z.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):B("",!0),Me("description")?(r(),h("td",kge,[n(Zo,{value:Z.product.post_content,placeholder:ve.$t("Description"),onClick:te=>G(Z.product,"post_content")},null,8,["value","placeholder","onClick"])])):B("",!0),Me("short_description")?(r(),h("td",Bge,[n(Zo,{value:Z.product.post_excerpt,placeholder:ve.$t("Short description"),onClick:te=>G(Z.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):B("",!0),Me("status")?(r(),h("td",xge,[n(qa,{modelValue:Z.product.post_status,"onUpdate:modelValue":te=>Z.product.post_status=te,size:"small",class:de({"is-field-error":S(Z.product,"post_status")}),disabled:g(Z.product),onChange:te=>ge("status",Z.product.post_status,`p:${Z.productId}`)},{default:d(()=>[(r(!0),h(H,null,ae(A(t).status,te=>(r(),E(ga,{key:te.value,label:ve.$t(te.title),value:te.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):B("",!0),Me("product_type")&&((qe=Z.product)!=null&&qe.detail)?(r(),h("td",Sge,[n(qa,{modelValue:Z.product.detail.fulfillment_type,"onUpdate:modelValue":te=>Z.product.detail.fulfillment_type=te,size:"small",class:de({"is-field-error":S(Z.product,"detail.fulfillment_type")}),disabled:g(Z.product),onChange:te=>ge("product_type",Z.product.detail.fulfillment_type,`p:${Z.productId}`)},{default:d(()=>[(r(!0),h(H,null,ae(A(t).fulfilment,te=>(r(),E(ga,{key:te.value,label:ve.$t(te.title),value:te.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Me("product_type")?(r(),h("td",Fge)):B("",!0),Me("pricing_type")&&((at=Z.product)!=null&&at.detail)?(r(),h("td",$ge,[n(qa,{modelValue:Z.product.detail.variation_type,"onUpdate:modelValue":te=>Z.product.detail.variation_type=te,size:"small",class:de({"is-field-error":S(Z.product,"detail.variation_type")}),disabled:g(Z.product),onChange:te=>{A(Ft).handleVariationChanged(Z.product,te),ge("pricing_type",te,`p:${Z.productId}`)}},{default:d(()=>[(r(!0),h(H,null,ae(A(t).variation,te=>(r(),E(ga,{key:te.value,label:ve.$t(te.title),value:te.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Me("pricing_type")?(r(),h("td",Ege)):B("",!0),Me("payment_type")?(r(),h("td",Uge,[n(Yo,{variant:l(Z.product)?(Ge=Z.product.variants)==null?void 0:Ge[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:te=>{var He;V(te),ge("payment_type",(He=te.other_info)==null?void 0:He.payment_type,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):B("",!0),Me("interval")?(r(),h("td",Ige,[n(Wo,{variant:l(Z.product)?(We=Z.product.variants)==null?void 0:We[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.other_info.repeat_interval"),onChange:te=>{var He,At,Ue;return ge("interval",(Ue=(At=(He=Z.product.variants)==null?void 0:He[0])==null?void 0:At.other_info)==null?void 0:Ue.repeat_interval,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("trial_days")?(r(),h("td",Qge,[n(Jo,{variant:l(Z.product)?(ft=Z.product.variants)==null?void 0:ft[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.other_info.trial_days"),onChange:te=>{var He,At,Ue;return ge("trial_days",(Ue=(At=(He=Z.product.variants)==null?void 0:He[0])==null?void 0:At.other_info)==null?void 0:Ue.trial_days,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("best_price")?(r(),h("td",Dge,[n(qo,{variant:l(Z.product)?(Ze=Z.product.variants)==null?void 0:Ze[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.item_price"),onChange:te=>{var He,At;return ge("price",(At=(He=Z.product.variants)==null?void 0:He[0])==null?void 0:At.item_price,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("compare_price")?(r(),h("td",Vge,[n(Xo,{variant:l(Z.product)?(Ut=Z.product.variants)==null?void 0:Ut[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.compare_price"),onChange:te=>{var He,At;return ge("compare_price",(At=(He=Z.product.variants)==null?void 0:He[0])==null?void 0:At.compare_price,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("track_quantity")?(r(),h("td",Tge,[(Ae=Z.product)!=null&&Ae.detail?(r(),E(il,{key:0,modelValue:Z.product.detail.manage_stock,"onUpdate:modelValue":te=>Z.product.detail.manage_stock=te,"active-value":"1","inactive-value":"0",disabled:g(Z.product),onChange:te=>{A(Ft).syncStockStatus(Z.product),ge("manage_stock",Z.product.detail.manage_stock,`p:${Z.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):B("",!0)])):B("",!0),Me("stock")?(r(),h("td",Mge,[((Le=(he=Z.product)==null?void 0:he.detail)==null?void 0:Le.manage_stock)==="1"&&((ut=(Ve=Z.product)==null?void 0:Ve.detail)==null?void 0:ut.variation_type)==="simple"?(r(),E(Zt,{key:0,modelValue:Z.product.detail.total_stock,"onUpdate:modelValue":[te=>Z.product.detail.total_stock=te,te=>{var He;(He=Z.product.variants)!=null&&He[0]&&(Z.product.variants[0].total_stock=te,Z.product.variants[0].available=te),A(Ft).syncStockStatus(Z.product),ge("stock",te,`p:${Z.productId}`)}],disabled:g(Z.product),size:"small",placeholder:ve.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),h("span",Lge,"—"))])):B("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":K.value}])},[o("div",Rge,[_(Z.product)&&Z.product.view_url?(r(),h("a",{key:0,href:Z.product.view_url,target:"_blank",class:"bulk-action-btn bulk-view-link",title:ve.$t("View Product")},[n(J,{name:"External"})],8,Oge)):B("",!0),n(et,{tag:"button",size:"x-small",onClick:Pe(te=>x(Z.product),["prevent"]),disabled:s.value||g(Z.product),title:ve.$t("Duplicate")},{default:d(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(et,{tag:"button",size:"x-small",hover:"danger",onClick:Pe(te=>I(Z.product),["prevent"]),disabled:s.value||g(Z.product),title:ve.$t("Delete")},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,cge),Z.hasVariants?(r(),h("tr",Hge,[o("td",{colspan:Oe.value.length+1,class:"!p-0 !border-b-0"},[n(_a,{accordion:"",visible:!Z.collapsed,duration:200},{default:d(()=>[o("table",Nge,[o("colgroup",null,[Se[13]||(Se[13]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),h(H,null,ae(Oe.value,(te,He)=>(r(),h("col",{key:He,style:ra({width:te.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),h(H,null,ae(Z.product.variants,(te,He)=>{var At,Ue;return r(),h("tr",{key:He,class:de(["bulk-variation-row",{"is-selected":A(me)(`v:${Z.productId}:${He}`)}]),onClick:xt=>xe(`v:${Z.productId}:${He}`,xt)},[o("td",Gge,[n(kt,{"model-value":A(me)(`v:${Z.productId}:${He}`),tabindex:"-1",onChange:xt=>A(W)(`v:${Z.productId}:${He}`,xt,Qe.value)},null,8,["model-value","onChange"])]),o("td",jge,[o("div",zge,[Se[14]||(Se[14]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(Zt,{size:"small",modelValue:te.variation_title,"onUpdate:modelValue":[xt=>te.variation_title=xt,xt=>ge("title",xt,`v:${Z.productId}:${He}`)],placeholder:ve.$t("Variation title"),disabled:g(Z.product),class:de({"is-error":$(Z.product,He,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),k(Z.product,He)?(r(),E(_t,{key:0,content:w(Z.product,He),placement:"top"},{default:d(()=>[o("span",qge,[n(Gt,{size:14},{default:d(()=>[n(A(Uo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),Me("sku")?(r(),h("td",Yge,[n(Zt,{size:"small",modelValue:te.sku,"onUpdate:modelValue":[xt=>te.sku=xt,xt=>ge("sku",xt,`v:${Z.productId}:${He}`)],placeholder:"SKU",disabled:g(Z.product),class:de({"is-error":$(Z.product,He,"sku")})},null,8,["modelValue","onUpdate:modelValue","disabled","class"])])):B("",!0),Me("media")?(r(),h("td",Wge,[n(vl,{modelValue:te.media,"onUpdate:modelValue":xt=>te.media=xt,"show-url-tab":"",disabled:g(Z.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),Me("categories")?(r(),h("td",Jge,Se[15]||(Se[15]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("description")?(r(),h("td",Xge,Se[16]||(Se[16]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("short_description")?(r(),h("td",Zge,Se[17]||(Se[17]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("status")?(r(),h("td",e1e,Se[18]||(Se[18]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("product_type")?(r(),h("td",t1e,Se[19]||(Se[19]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("pricing_type")?(r(),h("td",a1e,Se[20]||(Se[20]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("payment_type")?(r(),h("td",l1e,[n(Yo,{variant:te,disabled:g(Z.product),"has-error":$(Z.product,He,"other_info.payment_type"),onPaymentTypeChange:xt=>{var Wa;V(xt),ge("payment_type",(Wa=xt.other_info)==null?void 0:Wa.payment_type,`v:${Z.productId}:${He}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):B("",!0),Me("interval")?(r(),h("td",s1e,[n(Wo,{variant:te,disabled:g(Z.product),"has-error":$(Z.product,He,"other_info.repeat_interval"),onChange:xt=>{var Wa;return ge("interval",(Wa=te.other_info)==null?void 0:Wa.repeat_interval,`v:${Z.productId}:${He}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("trial_days")?(r(),h("td",n1e,[n(Jo,{variant:te,disabled:g(Z.product),"has-error":$(Z.product,He,"other_info.trial_days"),onChange:xt=>{var Wa;return ge("trial_days",(Wa=te.other_info)==null?void 0:Wa.trial_days,`v:${Z.productId}:${He}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("best_price")?(r(),h("td",o1e,[n(qo,{variant:te,disabled:g(Z.product),"has-error":$(Z.product,He,"item_price"),onChange:xt=>ge("price",te.item_price,`v:${Z.productId}:${He}`)},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("compare_price")?(r(),h("td",i1e,[n(Xo,{variant:te,disabled:g(Z.product),"has-error":$(Z.product,He,"compare_price"),onChange:xt=>ge("compare_price",te.compare_price,`v:${Z.productId}:${He}`)},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("track_quantity")?(r(),h("td",r1e,Se[21]||(Se[21]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("stock")?(r(),h("td",d1e,[((Ue=(At=Z.product)==null?void 0:At.detail)==null?void 0:Ue.manage_stock)==="1"?(r(),E(Zt,{key:0,class:"fc-bulk-input",size:"small",modelValue:te.total_stock,"onUpdate:modelValue":[xt=>te.total_stock=xt,xt=>{te.available=xt,A(Ft).syncStockStatus(Z.product),ge("stock",xt,`v:${Z.productId}:${He}`)}],disabled:g(Z.product),placeholder:ve.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),h("span",u1e,"—"))])):B("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":K.value}])},[o("div",c1e,[n(et,{tag:"button",size:"x-small",onClick:Pe(xt=>U(Z.product,te),["prevent"]),disabled:s.value||g(Z.product),title:ve.$t("Duplicate")},{default:d(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(et,{tag:"button",size:"x-small",hover:"danger",onClick:Pe(xt=>F(Z.product,te),["prevent"]),disabled:s.value||g(Z.product),title:ve.$t("Delete")},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,Kge)}),128)),o("tr",A1e,[o("td",{colspan:Oe.value.length+1},[o("div",f1e,[n(nt,{size:"small",text:"",type:"primary",onClick:Pe(te=>A(Ft).addVariationToProduct(Z.product),["prevent"])},{default:d(()=>[R(" + "+m(ve.$t("Add Variant")),1)]),_:2},1032,["onClick"])])],8,p1e)])])])]),_:2},1032,["visible"])],8,Pge)])):B("",!0)],64)}),128)),Ot.value>0?(r(),h("tr",m1e,[o("td",{colspan:Oe.value.length+1,style:ra({height:Ot.value+"px",padding:0,border:"none"})},null,12,h1e)])):B("",!0)]),_:1},8,["columns","sticky-last"])],2)):(r(),E(Ct,{key:1,icon:"Empty/ListView","has-dark":!0,text:A(u)("No products yet. Import a CSV or add products manually.")},null,8,["text"]))]),_:1})]}),_:1}),n(Ya,{modelValue:X.value.visible,"onUpdate:modelValue":Se[6]||(Se[6]=fa=>X.value.visible=fa),title:re.value,width:"700px","close-on-click-modal":!1,onClosed:Se[7]||(Se[7]=fa=>X.value.product=null)},{footer:d(()=>[n(nt,{onClick:Se[5]||(Se[5]=fa=>X.value.visible=!1)},{default:d(()=>[R(m(ve.$t("Cancel")),1)]),_:1}),n(nt,{type:"primary",onClick:oe},{default:d(()=>[R(m(ve.$t("Save")),1)]),_:1})]),default:d(()=>[X.value.visible&&X.value.field==="post_content"?(r(),E(es,{key:0,"model-value":X.value.value,height:300,onUpdate:ee},null,8,["model-value"])):B("",!0),X.value.visible&&X.value.field==="post_excerpt"?(r(),E(Zt,{key:1,modelValue:X.value.value,"onUpdate:modelValue":Se[4]||(Se[4]=fa=>X.value.value=fa),type:"textarea",rows:6,placeholder:ve.$t("Short description")},null,8,["modelValue","placeholder"])):B("",!0)]),_:1},8,["modelValue","title"])])}}};class y1e extends Ed{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:u("All"),publish:u("Published"),draft:u("Draft"),physical:u("Physical"),digital:u("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 u("Search by Id, product title or variation title")}getSearchGuideOptions(){return null}isUsingAdvanceFilter(){return this.data.filterType==="advanced"}isUsingSimpleFilter(){return this.data.filterType==="simple"}isAdvanceFilterEnabled(){return this.getAdvanceFilterOptions()!==null}getAdvanceFilterOptions(){var t,a,l;return((l=(a=(t=window.fluentCartAdminApp)==null?void 0:t.filter_options)==null?void 0:a.product_filter_options)==null?void 0:l.advance)||null}onFilterTypeChanged(t){t==="advanced"?(this.data.searching=!1,this.data.search=""):this.data.advanceFilters=[[]],this.fetchProducts({},!1)}applyAdvancedFilter(t=!1){this.fetchProducts({},!1)}addAdvanceFilterGroup(){this.data.advanceFilters.push([])}removeAdvanceFilterGroup(t){this.data.advanceFilters.length>1&&this.data.advanceFilters.splice(t,1)}clearAdvanceFilter(){this.data.advanceFilters=[[]],this.fetchProducts({},!1)}getColumnWidthStorageKey(){return"bulk_edit_column_widths"}getColumnStorageKey(){return"bulk_edit_columns"}getToggleableColumns(){return[{label:"Image",value:"image"},{label:"SKU",value:"sku"},{label:"Categories",value:"categories"},{label:"Description",value:"description"},{label:"Short Description",value:"short_description"},{label:"Status",value:"status"},{label:"Product Type",value:"product_type"},{label:"Pricing Type",value:"pricing_type"},{label:"Payment Type",value:"payment_type"},{label:"Interval",value:"interval"},{label:"Trial Days",value:"trial_days"},{label:"Best Price",value:"best_price"},{label:"Compare-at Price",value:"compare_price"},{label:"Track Quantity",value:"track_quantity"},{label:"Stock",value:"stock"}]}getSortableColumns(){return[]}markDirty(t){this._suppressDirty||(this.data.dirty.add(t),this.data.dirty=new Set(this.data.dirty),this.data.savedIds.has(t)&&(this.data.savedIds.delete(t),this.data.savedIds=new Set(this.data.savedIds)),this.data.productErrors.has(t)&&(this.data.productErrors.delete(t),this.data.productErrors=new Map(this.data.productErrors)))}get dirtyCount(){return this.data.dirty.size}getDirtyProducts(){return this.data.products.filter(t=>this.data.dirty.has(t.ID))}chunkArray(t,a){const l=[];for(let s=0;s{this._suppressDirty=!1}),this.data.pagination={page:_.page||f.page,per_page:_.per_page||f.per_page,total:_.total||0,hasMore:_.page*_.per_page<_.total}}catch(c){const p=((i=c==null?void 0:c.data)==null?void 0:i.message)||"Failed to fetch products";q.error(p)}finally{this.data.loading=!1}}isSavingProduct(t){return this.data.savingIds.has(t)}isDirty(t){return this.data.dirty.has(t)}isSaved(t){return this.data.savedIds.has(t)}isRowDisabled(t){return this.isSavingProduct(t)}isDuplicating(t){return this.data.duplicatingIds.has(t)}isDeleting(t){return this.data.deletingIds.has(t)}hasError(t){return this.data.productErrors.has(t)}getError(t){const a=this.data.productErrors.get(t);return a?a.fields&&Object.keys(a.fields).length?Object.values(a.fields).join("; "):a.message||"":""}hasProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?!!a.message:Object.keys(a.fields).some(l=>!l.startsWith("variants.")):!1}getProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?a.message||"":Object.entries(a.fields).filter(([s])=>!s.startsWith("variants.")).map(([,s])=>s).join("; ")||"":""}hasVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return!1;const s=`variants.${a}.`;return Object.keys(l.fields).some(i=>i.startsWith(s))}getVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return"";const s=`variants.${a}.`;return Object.entries(l.fields).filter(([c])=>c.startsWith(s)).map(([,c])=>c).join("; ")}hasFieldError(t,a){var s;const l=this.data.productErrors.get(t);return!!((s=l==null?void 0:l.fields)!=null&&s[a])}hasVariantFieldError(t,a,l){return this.hasFieldError(t,`variants.${a}.${l}`)}async saveProduct(t){var l,s,i,c;const a=t.ID;if(!this.data.savingIds.has(a)){this.data.savingIds.add(a),this.data.savingIds=new Set(this.data.savingIds);try{const p=await ce.post("products/bulk-update",{products:[t]});if((l=p.updated)!=null&&l.length)this.data.dirty.delete(a),this.data.dirty=new Set(this.data.dirty),this.data.savedIds.add(a),this.data.savedIds=new Set(this.data.savedIds),this.data.productErrors.delete(a),this.data.productErrors=new Map(this.data.productErrors),q.success(u("Product updated successfully"));else if((s=p.errors)!=null&&s.length){const f=p.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(p){const f=((i=p==null?void 0:p.data)==null?void 0:i.message)||"Failed to save product",_=(c=p==null?void 0:p.data)==null?void 0:c.errors;if(_!=null&&_.length){const g=_[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 l,s;const t=this.getDirtyProducts().filter(i=>!this.data.savedIds.has(i.ID));if(t.length===0){q.info(u("No changes to save"));return}const a=this.chunkArray(t,10);this.data.saving=!0,this.data.saveProgress={total:a.length,completed:0,errors:[],updatedIds:[]};try{for(const p of a){const f=p.map(_=>_.ID);for(const _ of f)this.data.savingIds.add(_);this.data.savingIds=new Set(this.data.savingIds);try{const _=await ce.post("products/bulk-update",{products:p});if(_.updated){this.data.saveProgress.updatedIds.push(..._.updated);for(const g of _.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(_.errors&&_.errors.length){this.data.saveProgress.errors.push(..._.errors);for(const g of _.errors)g.post_id&&g.fields&&this.data.productErrors.set(g.post_id,g);this.data.productErrors=new Map(this.data.productErrors)}}catch(_){const g=((l=_==null?void 0:_.data)==null?void 0:l.message)||"A chunk failed to save";this.data.saveProgress.errors.push({message:g});const y=(s=_==null?void 0:_.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 _ of f)this.data.savingIds.delete(_);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{updatedIds:i,errors:c}=this.data.saveProgress;c.length===0?q.success(`${i.length} product(s) updated successfully`):i.length>0?q.info(`${i.length} product(s) updated, ${c.length} error(s)`):q.error(u("All products failed to save"))}finally{this.data.saving=!1}}async duplicateProduct(t){var l;const a=t.ID;if(!(!a||this.data.duplicatingIds.has(a))){this.data.duplicatingIds.add(a),this.data.duplicatingIds=new Set(this.data.duplicatingIds);try{const i=(await ce.post(`products/${a}/duplicate`,{})).product_id;if(i){const p=(await ce.get("products/bulk-edit-data",{search:i,per_page:1})).products||[];if(p.length>0){const f=this.data.products.indexOf(t);this.data.products.splice(f+1,0,p[0])}}}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to duplicate product";q.error(i)}finally{this.data.duplicatingIds.delete(a),this.data.duplicatingIds=new Set(this.data.duplicatingIds)}}}async duplicateProductWithVariants(t,a){var s;const l=t.ID;if(!(!l||this.data.duplicatingIds.has(l))){this.data.duplicatingIds.add(l),this.data.duplicatingIds=new Set(this.data.duplicatingIds);try{const c=(await ce.post(`products/${l}/duplicate`,{})).product_id;if(!c)return;const f=(await ce.get("products/bulk-edit-data",{search:c,per_page:1})).products||[];if(!f.length)return;const _=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);_.variants&&y.size>0&&(_.variants=_.variants.filter(b=>y.has(b.serial_index)));const v=this.data.products.indexOf(t);this.data.products.splice(v+1,0,_),this.markDirty(_.ID)}catch(i){const c=((s=i==null?void 0:i.data)==null?void 0:s.message)||"Failed to duplicate product";q.error(c)}finally{this.data.duplicatingIds.delete(l),this.data.duplicatingIds=new Set(this.data.duplicatingIds)}}}duplicateVariant(t,a){const l=JSON.parse(JSON.stringify(a));l.variation_title=l.variation_title?l.variation_title+" (Copy)":"",l.sku="",delete l.id,delete l.post_id;const s=t.variants.indexOf(a);t.variants.splice(s+1,0,l),this.markDirty(t.ID)}async deleteProduct(t){var l;const a=t.ID;if(!(!a||this.data.deletingIds.has(a))){this.data.deletingIds.add(a),this.data.deletingIds=new Set(this.data.deletingIds);try{await ce.delete(`products/${a}`);const s=this.data.products.indexOf(t);s!==-1&&this.data.products.splice(s,1),this.data.dirty.delete(a),this.data.savedIds.delete(a)}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to delete product";q.error(i)}finally{this.data.deletingIds.delete(a),this.data.deletingIds=new Set(this.data.deletingIds)}}}removeVariant(t,a){if(t.variants.length<=1)return q.error(u("A product must have at least one variant.")),!1;const l=t.variants.indexOf(a);return l!==-1&&t.variants.splice(l,1),this.markDirty(t.ID),!0}resetPaymentTypeDefaults(t){t.other_info.payment_type==="onetime"&&(t.other_info.installment="no",t.other_info.times="",t.other_info.manage_setup_fee="no",t.other_info.signup_fee="",t.other_info.signup_fee_name="")}flattenCategoryTree(t,a=""){var s;const l=[];for(const i of t){const c=a?`${a} > ${i.label}`:i.label;l.push({label:c,value:c}),(s=i.children)!=null&&s.length&&l.push(...this.flattenCategoryTree(i.children,c))}return l}async fetchCategories(){try{const a=(await ce.get("products/fetch-term")).taxonomies||{},l=Object.values(a).find(s=>s.name==="product-categories");l!=null&&l.terms&&(this.data.categoryOptions=this.flattenCategoryTree(l.terms))}catch{}}setupSavedViews(){var a,l;const t=(a=window.fluentCartAdminApp)==null?void 0:a.table_config;this.data.savedViews=((l=t==null?void 0:t.products)==null?void 0:l.saved_views)||[]}getSavedViews(){return this.data.savedViews}getActiveSavedViewId(){return this.data.activeSavedViewId}applySavedView(t){const a=this.data.savedViews.find(l=>l.slug===t);a&&(this.data.activeSavedViewId=t,this.data.savedViewQueryParams=a.query_params)}isViewOwner(t){var a,l;return!t||!t.owner_id?!1:t.owner_id===((l=(a=window.fluentCartAdminApp)==null?void 0:a.me)==null?void 0:l.id)}renameSavedView(t,a){}updateSavedView(t){}deleteSavedView(t){}}const ot=y1e.init(),b1e={class:"fct-bulk-edit-page fct-layout-width"},w1e={class:"fct-table-wrapper"},C1e={class:"fct-card-header-top"},k1e={class:"fct-card-header-left flex-1"},B1e={class:"fct-card-header-actions"},x1e={key:0,class:"fct-advanced-filter-toggle-wrapper"},S1e={key:1,class:"fct-btn-group sm hidden md:flex"},F1e={key:0,class:"filter-search-wrap"},$1e={class:"search-bar"},E1e={class:"text-xs text-system-light pt-2 dark:text-gray-300"},U1e={class:"fct-bulk-edit-table-wrap"},I1e={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"},Q1e={class:"m-0 text-base"},D1e={key:0,class:"text-system-mid text-sm font-normal dark:text-gray-300"},V1e={class:"fct-btn-group sm justify-end"},T1e={class:"filter-popover-item"},M1e={class:"filter-popover-title"},L1e={class:"fct-bulk-edit-table"},R1e={key:0,"aria-hidden":"true"},O1e=["colspan"],H1e=["onClick"],P1e=["onClick"],N1e={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},K1e={class:"flex items-center"},G1e=["onClick","title"],j1e={key:0,class:"bulk-collapse-count"},z1e=["title"],q1e={class:"bulk-status-icon is-error"},Y1e=["disabled","onClick","title"],W1e={key:0,class:"fct-bulk-media-cell"},J1e={key:1,class:"fct-bulk-sku-cell"},X1e={key:1,class:"text-gray-300 text-sm flex justify-center"},Z1e={key:2,class:"fct-bulk-categories-cell"},eye={key:3,class:"fct-bulk-desc-cell"},tye={key:4,class:"fct-bulk-short-desc-cell"},aye={key:5,class:"fct-bulk-status-cell"},lye={key:6,class:"fct-bulk-product-type-cell"},sye={class:"bulk-readonly-label"},nye={key:7,class:"fct-bulk-pricing-type-cell"},oye={class:"bulk-readonly-label"},iye={key:8,class:"fct-bulk-payment-type-cell"},rye={key:9,class:"fct-bulk-interval-cell"},dye={key:10,class:"fct-bulk-trial-days-cell"},uye={key:11,class:"fct-bulk-best-price-cell"},cye={key:12,class:"fct-bulk-compare-price-cell"},Aye={key:13,class:"fct-bulk-qty-cell !pl-5"},pye={key:14,class:"fct-bulk-stock-cell"},fye={key:1,class:"text-gray-300 text-sm flex justify-center"},mye={class:"fct-btn-group sm justify-end"},hye={key:0,class:"bulk-variants-block-row"},_ye=["colspan"],vye={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},gye=["onClick"],yye={class:"bulk-checkbox-cell"},bye={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},wye={class:"flex items-center gap-1 pl-4"},Cye={class:"bulk-status-icon is-error"},kye={key:0},Bye={key:1},xye={key:2},Sye={key:3},Fye={key:4},$ye={key:5},Eye={key:6},Uye={key:7},Iye={key:8},Qye={key:9},Dye={key:10},Vye={key:11},Tye={key:12},Mye={key:13,class:"text-center"},Lye={key:14},Rye={key:1,class:"text-gray-300 text-sm flex justify-center"},Oye={class:"fct-btn-group sm justify-end"},Hye={key:1,"aria-hidden":"true"},Pye=["colspan"],Nye={key:1,class:"flex flex-col items-center justify-center py-16 text-center"},Kye={class:"text-system-mid text-sm"},Gye={key:2,class:"flex items-center justify-center py-8"},jye={class:"text-system-mid text-sm"},zye={key:1,class:"flex items-center justify-center py-3 border-top"},qye={class:"text-system-mid text-sm"},rr=43,Yye=10,bc=800,wc=100,Wye=200,Jye={__name:"BulkEdit",setup(e){const t=Yt().ctx,a=nl(),{options:l}=ot.data,s=se=>{var fe;return((fe=se==null?void 0:se.detail)==null?void 0:fe.variation_type)==="simple"},i=N(()=>ot.data.products),c=N(()=>ot.data.loading),p=N(()=>ot.data.saving),f=N(()=>ot.data.saveProgress),_=N(()=>ot.data.pagination),g=N(()=>ot.data.dirty),y=N(()=>g.value.size),v=N(()=>Math.max(0,_.value.total-i.value.length)),b=N(()=>Math.min(_.value.per_page,v.value)),k=N(()=>{const se=ot.data.saveProgress;return se.total?Math.round(se.completed/se.total*100):0}),w=Xr("search-input"),S=()=>{ot.openSearch(),Be(()=>{var se;(se=w.value)==null||se.focus()})},$=(se=!1)=>{ot.fetchProducts({},se)},I=()=>{ot.saveProducts()},F=se=>{ot.markDirty(se.ID)},x=(se,fe)=>{ot.resetPaymentTypeDefaults(fe),F(se)},U=(se,fe)=>{const qe=ot.data.categoryOptions;for(const at of fe)qe.find(Ge=>Ge.value===at)||qe.push({label:at,value:at});F(se)},T=se=>ot.isDirty(se.ID),D=se=>ot.isSavingProduct(se.ID),Q=se=>ot.isSaved(se.ID),V=se=>ot.isRowDisabled(se.ID),O=se=>ot.isDuplicating(se.ID),L=se=>ot.isDeleting(se.ID),P=se=>ot.hasError(se.ID),z=se=>ot.getError(se.ID),X=se=>ot.hasProductLevelError(se.ID),G=(se,fe)=>ot.hasVariantError(se.ID,fe),ee=(se,fe)=>ot.getVariantError(se.ID,fe),oe=(se,fe)=>ot.hasFieldError(se.ID,fe),re=(se,fe,qe)=>ot.hasVariantFieldError(se.ID,fe,qe),K=se=>ot.saveProduct(se),Y=se=>ot.duplicateProduct(se),W=(se,fe)=>ot.duplicateVariant(se,fe),j=M(!0),{selectedKeys:ie,handleRowClick:_e,toggleSelectAll:me,selectAll:ue,deselectAll:le,isSelected:be,selectedCount:Qe,isLinkMode:Ke,toggleLinkMode:ge}=Af(),tt=N(()=>{const se=[];for(const fe of kt.value)if(se.push(`p:${fe.productId}`),fe.hasVariants&&!fe.collapsed)for(const qe of fe.product.variants)se.push(`v:${qe.id}`);return se}),yt=se=>{var fe;if(se.startsWith("p:")){const qe=parseInt(se.slice(2)),at=kt.value.find(Ge=>Ge.productId===qe);return at?{type:"product",data:at.product,product:at.product}:null}else if(se.startsWith("v:")){const qe=parseInt(se.slice(2));for(const at of kt.value){const Ge=(fe=at.product.variants)==null?void 0:fe.find(We=>We.id===qe);if(Ge)return{type:"variant",data:Ge,product:at.product}}}return null},Je=(se,fe,qe)=>{!Ke.value||!be(qe)||ff(se,fe,qe,ie.value,yt,F,sge)},xe=M(!1),Fe=se=>{se.key==="Shift"&&(xe.value=!0)},Oe=se=>{se.key==="Shift"&&(xe.value=!1)},Me=(se,fe)=>{if(!fe.shiftKey||fe.target.closest(".bulk-checkbox-cell"))return;fe.preventDefault();const qe=new Set(ie.value);qe.has(se)?qe.delete(se):qe.add(se),ie.value=qe},gt=()=>{const se=[];for(const fe of kt.value){const qe=`p:${fe.productId}`,at=ie.value.has(qe),Ge=[];if(fe.product.variants)for(const We of fe.product.variants)ie.value.has(`v:${We.id}`)&&Ge.push(We.id);!at&&Ge.length===0||(at&&Ge.length===0?se.push({product:fe.product,type:"full"}):!at&&Ge.length>0?se.push({product:fe.product,type:"variants-only",variantIds:Ge}):se.push({product:fe.product,type:"partial",variantIds:Ge}))}return se},vt=async()=>{const se=gt();if(!se.length)return;const fe=se.filter(ft=>ft.type==="full").length,qe=se.filter(ft=>ft.type==="partial").length,Ge=se.filter(ft=>ft.type==="variants-only").reduce((ft,Ze)=>ft+Ze.variantIds.length,0),We=[];fe>0&&We.push(`${fe} product(s) with all variants`),qe>0&&We.push(`${qe} product(s) with selected variants`),Ge>0&&We.push(`${Ge} variant(s)`);try{await Fl.confirm(t.$t("Duplicate %s?").replace("%s",We.join(", ")),t.$t("Bulk Duplicate"),{confirmButtonText:t.$t("Duplicate"),cancelButtonText:t.$t("Cancel"),type:"info"})}catch{return}for(const ft of se)if(ft.type==="full")await ot.duplicateProduct(ft.product);else if(ft.type==="variants-only")for(const Ze of ft.variantIds){const Ut=ft.product.variants.find(Ae=>Ae.id===Ze);Ut&&ot.duplicateVariant(ft.product,Ut)}else ft.type==="partial"&&await ot.duplicateProductWithVariants(ft.product,ft.variantIds);le()},Lt=async()=>{const se=[],fe=[];for(const Ge of kt.value){const We=`p:${Ge.productId}`;if(ie.value.has(We)){se.push(Ge.product);continue}const Ze=[];if(Ge.product.variants)for(const Ut of Ge.product.variants)ie.value.has(`v:${Ut.id}`)&&Ze.push(Ut);Ze.length>0&&fe.push({product:Ge.product,variants:Ze})}if(!se.length&&!fe.length)return;const qe=fe.reduce((Ge,We)=>Ge+We.variants.length,0),at=[];se.length>0&&at.push(`${se.length} product(s)`),qe>0&&at.push(`${qe} variant(s)`);try{await Fl.confirm(t.$t("Permanently delete %s? This cannot be undone.").replace("%s",at.join(" and ")),t.$t("Bulk Delete"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}for(const Ge of se)await ot.deleteProduct(Ge);for(const{product:Ge,variants:We}of fe)for(const ft of We)ot.removeVariant(Ge,ft);le()},Vt=async se=>{const fe=se.ID;if(!fe||ot.isDeleting(fe))return;const qe=se.post_title||t.$t("Untitled product"),at=Array.isArray(se.variants)?se.variants.length:0,Ge=at>0?t.$t('This will permanently delete "%1$s" and its %2$s variant(s).',qe,at):t.$t('This will permanently delete "%1$s".',qe);try{await Fl.confirm(Ge,t.$t("Delete Product"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}ot.deleteProduct(se)},Qt=(se,fe)=>{if(se.variants.length<=1){ot.removeVariant(se,fe);return}const qe=fe.variation_title||t.$t("Untitled variant");Fl.confirm(t.$t('This will remove the variant "%1$s".',qe),t.$t("Remove Variant"),{confirmButtonText:t.$t("Remove"),cancelButtonText:t.$t("Cancel"),type:"warning"}).then(()=>{ot.removeVariant(se,fe)}).catch(()=>{})},ht=M({visible:!1,field:"",product:null,value:""}),Kt=(se,fe)=>{ht.value={visible:!0,field:fe,product:se,value:se[fe]||""}},bt=se=>{ht.value.value=se},St=()=>{const{product:se,field:fe,value:qe}=ht.value;se&&(se[fe]=qe,F(se)),ht.value.visible=!1},Ot=N(()=>ht.value.field==="post_content"?t.$t("Edit Description"):t.$t("Edit Short Description")),Ht=M([]),It=N(()=>Ht.value.filter(se=>se.key==="title"||se.key==="actions"?!0:ot.isColumnVisible(se.key))),mt=se=>ot.isColumnVisible(se),jt=()=>{ot.saveColumnWidths(Ht.value)},ve=M(new Set),Se=se=>{const fe=se.ID;ve.value.has(fe)?ve.value.delete(fe):ve.value.add(fe),ve.value=new Set(ve.value)},nt=se=>ve.value.has(se.ID),wt=M(0),kt=N(()=>{let se=0;return i.value.map(fe=>{var Ae;const qe=fe.ID,at=((Ae=fe.detail)==null?void 0:Ae.variation_type)!=="simple"&&Array.isArray(fe.variants)&&fe.variants.length>0,Ge=at?fe.variants.length:0,We=ve.value.has(qe),ft=at&&!We?Ge*rr:0,Ze=rr+ft,Ut={product:fe,productId:qe,hasVariants:at,variantCount:Ge,collapsed:We,groupHeight:Ze,offset:se};return se+=Ze,Ut})}),Jt=N(()=>{const se=kt.value;if(se.length===0)return 0;const fe=se[se.length-1];return fe.offset+fe.groupHeight}),_t=N(()=>{const se=kt.value,fe=wt.value,qe=fe+bc,at=Yye*rr;return se.filter(Ge=>Ge.offset+Ge.groupHeight>=fe-at&&Ge.offset<=qe+at)}),Xt=N(()=>_t.value.length===0?0:_t.value[0].offset),Zt=N(()=>{if(_t.value.length===0)return 0;const se=_t.value[_t.value.length-1];return Jt.value-se.offset-se.groupHeight});let Gt=null,ga=0;const qa=()=>{if(c.value||!_.value.hasMore||i.value.length===0)return;Jt.value-(wt.value+bc){const fe=se.target,qe=Date.now();Gt&&clearTimeout(Gt),qe-ga>=wc?(wt.value=fe.scrollTop,ga=qe,qa()):Gt=setTimeout(()=>{wt.value=fe.scrollTop,ga=Date.now(),Gt=null,qa()},wc)},Ya=se=>({physical:"Physical",digital:"Digital"})[se]||se||"—",fa=se=>({simple:"Simple",simple_variations:"Variable"})[se]||se||"—";let Z=null;const we=()=>{const se=a.query.product_ids,fe=a.query.variant_ids;se&&fe?ot.fetchProducts({},!1,se,fe):$(!1)};return Ee(async()=>{Z=_s(),Z.bind("mod+a",se=>{var qe,at;const fe=(qe=document.activeElement)==null?void 0:qe.tagName;fe==="INPUT"||fe==="TEXTAREA"||(at=document.activeElement)!=null&&at.isContentEditable||(se.preventDefault(),ue(tt.value))}),Z.bind("escape",()=>{var fe,qe;const se=(fe=document.activeElement)==null?void 0:fe.tagName;se==="INPUT"||se==="TEXTAREA"||(qe=document.activeElement)!=null&&qe.isContentEditable||(Ke.value?ge():le())}),Ht.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}],ot.restoreColumnWidths(Ht.value),ot.setupColumnVisibility(),ot.setupSavedViews(),ot.fetchCategories(),we(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",Fe),window.addEventListener("keyup",Oe)}),yl(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",Fe),window.removeEventListener("keyup",Oe),Z&&Z.reset()}),(se,fe)=>{const qe=C("el-button"),at=C("el-progress"),Ge=C("el-switch"),We=C("el-tooltip"),ft=C("el-input"),Ze=C("el-checkbox"),Ut=C("el-checkbox-group"),Ae=C("el-popover"),he=C("el-icon"),Le=C("el-option"),Ve=C("el-select"),ut=C("el-dialog");return r(),h("div",b1e,[n(ol,{title:se.$t("Bulk Edit")},{action:d(()=>[n(qe,{type:"primary",onClick:I,loading:p.value,disabled:p.value||y.value===0},{default:d(()=>[R(m(p.value?se.$t("Saving %s/%s...").replace("%s",f.value.completed).replace("%s",f.value.total):y.value>0?se.$t("Save Changes")+` (${y.value})`:se.$t("Save Changes")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),p.value?(r(),E(at,{key:0,percentage:k.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):B("",!0),o("div",w1e,[n(ke,null,{default:d(()=>[n(Ie,{border_bottom:""},{default:d(()=>[o("div",C1e,[o("div",k1e,[A(ot).getTabsCount()&&!A(ot).isUsingAdvanceFilter()?(r(),E(Nf,{key:0,class:de("hide-animation-on-mobile hidden md:inline-flex classic-tab-style"),table:A(ot)},null,8,["table"])):B("",!0)]),o("div",B1e,[A(ot).isAdvanceFilterEnabled()?(r(),h("div",x1e,[n(Ge,{class:"fct-advanced-filter-toggle",onChange:fe[0]||(fe[0]=te=>{A(ot).onFilterTypeChanged(te)}),"active-value":"advanced","inactive-value":"simple",modelValue:A(ot).data.filterType,"onUpdate:modelValue":fe[1]||(fe[1]=te=>A(ot).data.filterType=te),"active-text":se.$t("Advanced Filter"),size:"small"},null,8,["modelValue","active-text"])])):B("",!0),A(ot).isUsingAdvanceFilter()?B("",!0):(r(),h("div",S1e,[A(ot).isSearching()?B("",!0):(r(),E(We,{key:0,effect:"light",content:se.$t("Search"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(et,{tag:"button",onClick:Pe(S,["prevent"])},{default:d(()=>[n(J,{name:"Search"})]),_:1})]),_:1},8,["content"]))]))])]),n(Mc,{table:A(ot)},null,8,["table"]),A(ot).isSearching()&&!A(ot).isUsingAdvanceFilter()?(r(),h("div",F1e,[o("div",$1e,[n(ft,{ref:"search-input",onClear:fe[2]||(fe[2]=()=>{A(ot).search()}),onKeyup:fe[3]||(fe[3]=Ba(()=>{A(ot).search()},["enter"])),modelValue:A(ot).data.search,"onUpdate:modelValue":fe[4]||(fe[4]=te=>A(ot).data.search=te),type:"text",placeholder:se.$t("Search"),clearable:""},{prefix:d(()=>[n(J,{name:"Search"})]),_:1},8,["modelValue","placeholder"]),o("div",E1e,m(A(ot).getSearchHint()),1)]),n(qe,{text:"",onClick:fe[5]||(fe[5]=()=>{A(ot).closeSearch()})},{default:d(()=>[R(m(se.$t("Cancel")),1)]),_:1})])):B("",!0)]),_:1}),n(Ce,{class:"p-0"},{default:d(()=>[o("div",U1e,[i.value.length>0?(r(),h("div",I1e,[o("h5",Q1e,[R(m(i.value.length)+" "+m(i.value.length===1?se.$t("Product"):se.$t("Products"))+" ",1),_.value.total>i.value.length?(r(),h("span",D1e,m(se.$t("of"))+" "+m(_.value.total)+" "+m(se.$t("total"))+" · "+m(b.value)+" "+m(se.$t("next")),1)):B("",!0)]),o("div",V1e,[n(qe,{disabled:A(Qe)===0,onClick:vt,size:"small"},{default:d(()=>[fe[14]||(fe[14]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)),R(" "+m(se.$t("Duplicate")),1)]),_:1,__:[14]},8,["disabled"]),n(qe,{disabled:A(Qe)===0,onClick:Lt,size:"small",type:"danger",plain:""},{default:d(()=>[fe[15]||(fe[15]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("polyline",{points:"3 6 5 6 21 6"}),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)),R(" "+m(se.$t("Delete")),1)]),_:1,__:[15]},8,["disabled"]),n(qe,{class:de({"is-active":A(Ke)}),disabled:A(Qe)<2&&!A(Ke),onClick:A(ge),size:"small"},{default:d(()=>[fe[16]||(fe[16]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)),R(" "+m(A(Ke)?se.$t("Unlink"):se.$t("Link")),1)]),_:1,__:[16]},8,["class","disabled","onClick"]),n(Ze,{modelValue:j.value,"onUpdate:modelValue":fe[6]||(fe[6]=te=>j.value=te),label:se.$t("Pin Actions")},null,8,["modelValue","label"]),n(Ae,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:d(()=>[o("span",null,[n(We,{effect:"light",content:se.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(et,{tag:"button",size:"small"},{default:d(()=>[n(J,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:d(()=>[o("div",T1e,[o("h3",M1e,m(se.$t("Columns")),1),n(Ut,{modelValue:A(ot).data.visibleColumns,"onUpdate:modelValue":fe[7]||(fe[7]=te=>A(ot).data.visibleColumns=te),class:"fct-checkbox-blocks",onChange:fe[8]||(fe[8]=te=>A(ot).handleColumnVisibilityChange())},{default:d(()=>[(r(!0),h(H,null,ae(A(ot).getToggleableColumns(),te=>(r(),E(Ze,{key:te.value,value:te.value,label:se.$t(te.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])])):B("",!0),o("div",L1e,[i.value.length>0?(r(),h("div",{key:0,class:de(["relative",{"is-link-mode":A(Ke),"is-shift-held":xe.value}])},[n(uf,{columns:It.value,"sticky-last":j.value,onScroll:il,onResizeEnd:jt},{"header-first":d(()=>[qt(n(Ze,{checked:A(Qe)>0&&A(Qe)===tt.value.length,onChange:fe[9]||(fe[9]=te=>A(me)(tt.value))},null,8,["checked"]),[[A(age),A(Qe)>0&&A(Qe)[R(m(se.$t("Actions")),1)]),default:d(()=>[Xt.value>0?(r(),h("tr",R1e,[o("td",{colspan:It.value.length+1,style:ra({height:Xt.value+"px",padding:0,border:"none"})},null,12,O1e)])):B("",!0),(r(!0),h(H,null,ae(_t.value,te=>{var He,At,Ue,xt,Wa,ne,pe,$e,Te,ze,ct,Ne,$t,ea,Qa,zt,ma,xa;return r(),h(H,{key:te.productId},[o("tr",{class:de(["bulk-product-row",{"is-dirty":T(te.product),"is-saving":D(te.product),"is-saved":Q(te.product),"has-product-error":P(te.product),"is-selected":A(be)(`p:${te.productId}`)}]),onClick:Xe=>Me(`p:${te.productId}`,Xe)},[o("td",{class:"bulk-checkbox-cell",onClick:Xe=>A(_e)(`p:${te.productId}`,Xe,tt.value)},[n(Ze,{"model-value":A(be)(`p:${te.productId}`),tabindex:"-1"},null,8,["model-value"])],8,P1e),o("td",N1e,[o("div",K1e,[te.hasVariants?(r(),h("button",{key:0,class:"bulk-collapse-btn",onClick:Pe(Xe=>Se(te.product),["prevent"]),title:nt(te.product)?se.$t("Expand variants"):se.$t("Collapse variants")},[(r(),h("svg",{class:de(["bulk-collapse-icon",{"is-collapsed":nt(te.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},fe[17]||(fe[17]=[o("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),nt(te.product)?(r(),h("span",j1e,m(te.variantCount),1)):B("",!0)],8,G1e)):B("",!0),n(ft,{class:de(["fct-bulk-input",{"is-error":oe(te.product,"post_title")}]),modelValue:te.product.post_title,"onUpdate:modelValue":[Xe=>te.product.post_title=Xe,Xe=>{F(te.product),Je("title",Xe,`p:${te.productId}`)}],placeholder:se.$t("Product title"),disabled:V(te.product),size:"small"},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),D(te.product)?(r(),h("span",{key:1,class:"bulk-status-icon is-syncing",title:se.$t("Saving...")},[n(he,{class:"is-loading",size:14},{default:d(()=>[n(A(Xs))]),_:1})],8,z1e)):X(te.product)||s(te.product)&&P(te.product)?(r(),E(We,{key:2,content:z(te.product),placement:"top"},{default:d(()=>[o("span",q1e,[n(he,{size:16},{default:d(()=>[n(A(Uo))]),_:1})])]),_:2},1032,["content"])):T(te.product)?(r(),h("button",{key:3,class:"bulk-inline-save",disabled:V(te.product),onClick:Pe(Xe=>K(te.product),["prevent"]),title:se.$t("Save")},fe[18]||(fe[18]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",width:"16",height:"16"},[o("path",{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z",fill:"currentColor"})],-1)]),8,Y1e)):B("",!0)])]),mt("image")?(r(),h("td",W1e,[n(vl,{modelValue:te.product.gallery,"onUpdate:modelValue":Xe=>te.product.gallery=Xe,onChange:Xe=>F(te.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):B("",!0),mt("sku")?(r(),h("td",J1e,[((At=(He=te.product)==null?void 0:He.detail)==null?void 0:At.variation_type)==="simple"&&((Ue=te.product.variants)!=null&&Ue[0])?(r(),E(ft,{key:0,class:de(["fct-bulk-input",{"is-error":oe(te.product,"variants.0.sku")}]),modelValue:te.product.variants[0].sku,"onUpdate:modelValue":[Xe=>te.product.variants[0].sku=Xe,Xe=>{F(te.product),Je("sku",Xe,`p:${te.productId}`)}],placeholder:"SKU",size:"small",disabled:V(te.product)},null,8,["modelValue","onUpdate:modelValue","disabled","class"])):(r(),h("span",X1e,"—"))])):B("",!0),mt("categories")?(r(),h("td",Z1e,[n(cf,{modelValue:te.product.categories,"onUpdate:modelValue":Xe=>te.product.categories=Xe,options:A(ot).data.categoryOptions,disabled:V(te.product),onChange:Xe=>{U(te.product,Xe),Je("categories",te.product.categories,`p:${te.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):B("",!0),mt("description")?(r(),h("td",eye,[n(Zo,{value:te.product.post_content,placeholder:se.$t("Description"),onClick:Xe=>Kt(te.product,"post_content")},null,8,["value","placeholder","onClick"])])):B("",!0),mt("short_description")?(r(),h("td",tye,[n(Zo,{value:te.product.post_excerpt,placeholder:se.$t("Short description"),onClick:Xe=>Kt(te.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):B("",!0),mt("status")?(r(),h("td",aye,[n(Ve,{modelValue:te.product.post_status,"onUpdate:modelValue":Xe=>te.product.post_status=Xe,size:"small",class:de({"is-field-error":oe(te.product,"post_status")}),disabled:V(te.product),onChange:Xe=>{F(te.product),Je("status",te.product.post_status,`p:${te.productId}`)}},{default:d(()=>[n(Le,{label:se.$t("Published"),value:"publish"},null,8,["label"]),n(Le,{label:se.$t("Draft"),value:"draft"},null,8,["label"])]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):B("",!0),mt("product_type")?(r(),h("td",lye,[o("span",sye,m(Ya((Wa=(xt=te.product)==null?void 0:xt.detail)==null?void 0:Wa.fulfillment_type)),1)])):B("",!0),mt("pricing_type")?(r(),h("td",nye,[o("span",oye,m(fa((pe=(ne=te.product)==null?void 0:ne.detail)==null?void 0:pe.variation_type)),1)])):B("",!0),mt("payment_type")?(r(),h("td",iye,[n(Yo,{variant:s(te.product)?($e=te.product.variants)==null?void 0:$e[0]:null,disabled:V(te.product),"has-error":oe(te.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:Xe=>{var ta;x(te.product,Xe),Je("payment_type",(ta=Xe.other_info)==null?void 0:ta.payment_type,`p:${te.productId}`)},onChange:Xe=>F(te.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):B("",!0),mt("interval")?(r(),h("td",rye,[n(Wo,{variant:s(te.product)?(Te=te.product.variants)==null?void 0:Te[0]:null,disabled:V(te.product),"has-error":oe(te.product,"variants.0.other_info.repeat_interval"),onChange:Xe=>{var ta,Pa,Ye;F(te.product),Je("interval",(Ye=(Pa=(ta=te.product.variants)==null?void 0:ta[0])==null?void 0:Pa.other_info)==null?void 0:Ye.repeat_interval,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("trial_days")?(r(),h("td",dye,[n(Jo,{variant:s(te.product)?(ze=te.product.variants)==null?void 0:ze[0]:null,disabled:V(te.product),"has-error":oe(te.product,"variants.0.other_info.trial_days"),onChange:Xe=>{var ta,Pa,Ye;F(te.product),Je("trial_days",(Ye=(Pa=(ta=te.product.variants)==null?void 0:ta[0])==null?void 0:Pa.other_info)==null?void 0:Ye.trial_days,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("best_price")?(r(),h("td",uye,[n(qo,{variant:s(te.product)?(ct=te.product.variants)==null?void 0:ct[0]:null,disabled:V(te.product),"has-error":oe(te.product,"variants.0.item_price"),onChange:Xe=>{var ta,Pa;F(te.product),Je("price",(Pa=(ta=te.product.variants)==null?void 0:ta[0])==null?void 0:Pa.item_price,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("compare_price")?(r(),h("td",cye,[n(Xo,{variant:s(te.product)?(Ne=te.product.variants)==null?void 0:Ne[0]:null,disabled:V(te.product),"has-error":oe(te.product,"variants.0.compare_price"),onChange:Xe=>{var ta,Pa;F(te.product),Je("compare_price",(Pa=(ta=te.product.variants)==null?void 0:ta[0])==null?void 0:Pa.compare_price,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("track_quantity")?(r(),h("td",Aye,[($t=te.product)!=null&&$t.detail?(r(),E(Ge,{key:0,modelValue:te.product.detail.manage_stock,"onUpdate:modelValue":Xe=>te.product.detail.manage_stock=Xe,"active-value":1,"inactive-value":0,disabled:V(te.product),onChange:Xe=>{F(te.product),A(ot).syncStockStatus(te.product),Je("manage_stock",te.product.detail.manage_stock,`p:${te.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):B("",!0)])):B("",!0),mt("stock")?(r(),h("td",pye,[(Qa=(ea=te.product)==null?void 0:ea.detail)!=null&&Qa.manage_stock&&((ma=(zt=te.product)==null?void 0:zt.detail)==null?void 0:ma.variation_type)==="simple"&&((xa=te.product.variants)!=null&&xa[0])?(r(),E(ft,{key:0,class:"fct-bulk-input",placeholder:se.$t("e.g 10"),size:"small",modelValue:te.product.variants[0].available,"onUpdate:modelValue":[Xe=>te.product.variants[0].available=Xe,Xe=>{te.product.variants[0].total_stock=Xe,F(te.product),A(ot).syncStockStatus(te.product),Je("stock",Xe,`p:${te.productId}`)}],disabled:V(te.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",fye,"—"))])):B("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":j.value}])},[o("div",mye,[te.product.view_url?(r(),E(et,{key:0,tag:"a",size:"x-small",href:te.product.view_url,target:"_blank",title:se.$t("View Product")},{default:d(()=>[n(J,{name:"External"})]),_:2},1032,["href","title"])):B("",!0),n(et,{tag:"button",size:"x-small",onClick:Pe(Xe=>Y(te.product),["prevent"]),disabled:p.value||V(te.product)||O(te.product),title:se.$t("Duplicate")},{default:d(()=>[O(te.product)?(r(),E(he,{key:0,class:"is-loading",size:14},{default:d(()=>[n(A(Xs))]),_:1})):(r(),E(J,{key:1,name:"Copy"}))]),_:2},1032,["onClick","disabled","title"]),n(et,{tag:"button",size:"x-small",hover:"danger",onClick:Pe(Xe=>Vt(te.product),["prevent"]),disabled:p.value||V(te.product)||L(te.product),title:se.$t("Delete")},{default:d(()=>[L(te.product)?(r(),E(he,{key:0,class:"is-loading",size:14},{default:d(()=>[n(A(Xs))]),_:1})):(r(),E(J,{key:1,name:"Delete"}))]),_:2},1032,["onClick","disabled","title"])])],2)],10,H1e),te.hasVariants?(r(),h("tr",hye,[o("td",{colspan:It.value.length+1,class:"!p-0 !border-b-0"},[n(_a,{accordion:"",visible:!te.collapsed,duration:200},{default:d(()=>[o("table",vye,[o("colgroup",null,[fe[19]||(fe[19]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),h(H,null,ae(It.value,(Xe,ta)=>(r(),h("col",{key:ta,style:ra({width:Xe.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),h(H,null,ae(te.product.variants,(Xe,ta)=>{var Pa,Ye;return r(),h("tr",{key:Xe.id||ta,class:de(["bulk-variation-row",{"is-selected":A(be)(`v:${Xe.id}`)}]),onClick:Mt=>Me(`v:${Xe.id}`,Mt)},[o("td",yye,[n(Ze,{"model-value":A(be)(`v:${Xe.id}`),tabindex:"-1",onChange:Mt=>A(_e)(`v:${Xe.id}`,Mt,tt.value)},null,8,["model-value","onChange"])]),o("td",bye,[o("div",wye,[fe[20]||(fe[20]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(ft,{size:"small",modelValue:Xe.variation_title,"onUpdate:modelValue":[Mt=>Xe.variation_title=Mt,Mt=>{F(te.product),Je("title",Mt,`v:${Xe.id}`)}],placeholder:se.$t("Variation title"),disabled:V(te.product),class:de({"is-error":re(te.product,ta,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),G(te.product,ta)?(r(),E(We,{key:0,content:ee(te.product,ta),placement:"top"},{default:d(()=>[o("span",Cye,[n(he,{size:14},{default:d(()=>[n(A(Uo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),mt("image")?(r(),h("td",kye,[n(vl,{modelValue:Xe.media,"onUpdate:modelValue":Mt=>Xe.media=Mt,onChange:Mt=>F(te.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):B("",!0),mt("sku")?(r(),h("td",Bye,[n(ft,{class:de(["fct-bulk-input",{"is-error":re(te.product,ta,"sku")}]),size:"small",modelValue:Xe.sku,"onUpdate:modelValue":[Mt=>Xe.sku=Mt,Mt=>{F(te.product),Je("sku",Mt,`v:${Xe.id}`)}],placeholder:se.$t("SKU"),disabled:V(te.product)},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])])):B("",!0),mt("categories")?(r(),h("td",xye,fe[21]||(fe[21]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("description")?(r(),h("td",Sye,fe[22]||(fe[22]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("short_description")?(r(),h("td",Fye,fe[23]||(fe[23]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("status")?(r(),h("td",$ye,fe[24]||(fe[24]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("product_type")?(r(),h("td",Eye,fe[25]||(fe[25]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("pricing_type")?(r(),h("td",Uye,fe[26]||(fe[26]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("payment_type")?(r(),h("td",Iye,[n(Yo,{variant:Xe,disabled:V(te.product),"has-error":re(te.product,ta,"other_info.payment_type"),onPaymentTypeChange:Mt=>{var ls;x(te.product,Mt),Je("payment_type",(ls=Mt.other_info)==null?void 0:ls.payment_type,`v:${Xe.id}`)},onChange:Mt=>F(te.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):B("",!0),mt("interval")?(r(),h("td",Qye,[n(Wo,{variant:Xe,disabled:V(te.product),"has-error":re(te.product,ta,"other_info.repeat_interval"),onChange:Mt=>{var ls;F(te.product),Je("interval",(ls=Xe.other_info)==null?void 0:ls.repeat_interval,`v:${Xe.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("trial_days")?(r(),h("td",Dye,[n(Jo,{variant:Xe,disabled:V(te.product),"has-error":re(te.product,ta,"other_info.trial_days"),onChange:Mt=>{var ls;F(te.product),Je("trial_days",(ls=Xe.other_info)==null?void 0:ls.trial_days,`v:${Xe.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("best_price")?(r(),h("td",Vye,[n(qo,{variant:Xe,disabled:V(te.product),"has-error":re(te.product,ta,"item_price"),onChange:Mt=>{F(te.product),Je("price",Xe.item_price,`v:${Xe.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("compare_price")?(r(),h("td",Tye,[n(Xo,{variant:Xe,disabled:V(te.product),"has-error":re(te.product,ta,"compare_price"),onChange:Mt=>{F(te.product),Je("compare_price",Xe.compare_price,`v:${Xe.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("track_quantity")?(r(),h("td",Mye,fe[27]||(fe[27]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),mt("stock")?(r(),h("td",Lye,[(Ye=(Pa=te.product)==null?void 0:Pa.detail)!=null&&Ye.manage_stock?(r(),E(ft,{key:0,class:"fct-bulk-input",placeholder:se.$t("e.g 10"),size:"small",modelValue:Xe.available,"onUpdate:modelValue":[Mt=>Xe.available=Mt,Mt=>{Xe.total_stock=Mt,F(te.product),A(ot).syncStockStatus(te.product),Je("stock",Mt,`v:${Xe.id}`)}],disabled:V(te.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",Rye,"—"))])):B("",!0),o("td",{class:de(["text-center",{"sticky-col sticky-col-right":j.value}])},[o("div",Oye,[n(et,{tag:"button",size:"x-small",onClick:Pe(Mt=>W(te.product,Xe),["prevent"]),disabled:p.value||V(te.product),title:se.$t("Duplicate")},{default:d(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(et,{tag:"button",size:"x-small",hover:"danger",onClick:Pe(Mt=>Qt(te.product,Xe),["prevent"]),disabled:p.value||V(te.product),title:se.$t("Delete")},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,gye)}),128))])])]),_:2},1032,["visible"])],8,_ye)])):B("",!0)],64)}),128)),Zt.value>0?(r(),h("tr",Hye,[o("td",{colspan:It.value.length+1,style:ra({height:Zt.value+"px",padding:0,border:"none"})},null,12,Pye)])):B("",!0)]),_:1},8,["columns","sticky-last"])],2)):c.value?c.value?(r(),h("div",Gye,[n(he,{class:"is-loading mr-2"},{default:d(()=>fe[28]||(fe[28]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[28]}),o("span",jye,m(se.$t("Loading products...")),1)])):B("",!0):(r(),h("div",Nye,[o("p",Kye,m(se.$t("No products found.")),1)]))]),_.value.hasMore&&i.value.length>0&&c.value?(r(),h("div",zye,[n(he,{class:"is-loading mr-2"},{default:d(()=>fe[29]||(fe[29]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[29]}),o("span",qye,m(se.$t("Loading"))+" "+m(b.value)+" "+m(se.$t("more...")),1)])):B("",!0)])]),_:1})]),_:1})]),n(ut,{modelValue:ht.value.visible,"onUpdate:modelValue":fe[12]||(fe[12]=te=>ht.value.visible=te),title:Ot.value,width:"700px","close-on-click-modal":!1,onClosed:fe[13]||(fe[13]=te=>ht.value.product=null)},{footer:d(()=>[n(qe,{onClick:fe[11]||(fe[11]=te=>ht.value.visible=!1)},{default:d(()=>[R(m(se.$t("Cancel")),1)]),_:1}),n(qe,{type:"primary",onClick:St},{default:d(()=>[R(m(se.$t("Save")),1)]),_:1})]),default:d(()=>[ht.value.visible&&ht.value.field==="post_content"?(r(),E(es,{key:0,"model-value":ht.value.value,height:300,onUpdate:bt},null,8,["model-value"])):B("",!0),ht.value.visible&&ht.value.field==="post_excerpt"?(r(),E(ft,{key:1,modelValue:ht.value.value,"onUpdate:modelValue":fe[10]||(fe[10]=te=>ht.value.value=te),type:"textarea",rows:6,placeholder:se.$t("Short description")},null,8,["modelValue","placeholder"])):B("",!0)]),_:1},8,["modelValue","title"])])}}},mf=je.get("payment_routes");for(const e of mf)e.props=!0;const Xye=je.get("storage_driver_routes"),hf=(Xye||[]).filter(e=>e.name!=="s3");for(const e of hf)e.props=!0;var Zye={dashboard:{name:"dashboard",path:"/",component:gB,meta:{active_menu:"dashboard",title:u("Dashboard")}},orders:{path:"/orders",component:XF,meta:{active_menu:"orders",title:u("Orders")},children:[{name:"orders",path:"",component:q_,meta:{active_menu:"orders",title:u("Orders"),permission:"orders/view"}},{name:"view_order",path:":order_id(\\d+)/view",component:uD,props:!0,meta:{active_menu:"orders",title:u("View Order"),permission:["orders/view","orders/manage"]}},{name:"add_order",path:"add",component:PD,props:!0,meta:{active_menu:"orders",title:u("Create Order"),permission:"orders/create"}}]},products:{name:"products",path:"/products",component:MM,meta:{active_menu:"products",title:u("Products"),permission:"products/view"}},product_route:{path:"/products/:product_id(\\d+)",component:IV,name:"product_route",meta:{active_menu:"products",title:u("Products"),permission:["products/view","products/edit","integrations/manage"]},props:!0,children:[{name:"product_edit",path:"",props:!0,component:sz,meta:{active_menu:"products",title:u("Product Edit"),permission:"products/edit"}},{name:"product_integrations",path:"integrations",props:!0,component:rc,meta:{active_menu:"products",title:u("Integrations"),permission:"integrations/manage"}},{name:"product_integration_feed_editor",path:"integrations/:integration_id/:integration_name",component:Wu,meta:{active_menu:"products",title:u("Edit Integration"),permission:"integrations/manage"}},{name:"SingleIntegration",path:"integrations/:integration_id",props:!0,component:pq,meta:{active_menu:"products",title:u("Integrations"),permission:"integrations/manage"}},{name:"product_upgrade_paths",path:"upgrade-paths",props:!0,component:jz,meta:{active_menu:"products",title:u("Upgrade Paths"),permission:"integrations/manage"}},{name:"Integrations",path:"integrations",props:!0,component:rc,meta:{active_menu:"integrations",title:u("Product Integrations"),permission:"integrations/manage"}}]},product_bulk_insert:{name:"product_bulk_insert",path:"/products/bulk-insert",component:g1e,meta:{active_menu:"products",title:u("Product Bulk Insert"),permission:"products/create"}},product_bulk_edit:{name:"product_bulk_edit",path:"/products/bulk-edit",component:Jye,meta:{active_menu:"products",title:u("Product Bulk Edit"),permission:"products/edit"}},product_attributes:{name:"product_attributes",path:"/products/attributes",component:_m,meta:{active_menu:"products",title:u("Attributes"),permission:"products/view"}},product_inventory:{name:"product_inventory",path:"/products/inventory",component:qW,meta:{active_menu:"products",title:u("Inventory"),permission:"products/view"}},customers:{path:"/customers",component:rg,meta:{active_menu:"customers",permission:["customers/view","customers/manage"]},children:[{name:"customers",path:"/customers",component:Dh,meta:{active_menu:"customers",title:u("Customers"),permission:"customers/view"}},{name:"view_customer",path:":customer_id(\\d+)/view",component:WE,props:!0,meta:{active_menu:"customers",title:u("View Customer"),permission:"customers/view"}}]},reports:{name:"reports",path:"/reports",component:uee,meta:{active_menu:"reports",permission:"reports/view"},children:[{name:"reports_overview",path:"overview",component:hue,meta:{title:u("Overview"),permission:"reports/view"}},{name:"reports_sales",path:"sales",component:Oee,meta:{title:u("Sales"),permission:"reports/view"}},{name:"reports_orders",path:"orders",component:ase,meta:{title:u("Orders"),permission:"reports/view"}},{name:"reports_revenue",path:"revenue",component:Tte,meta:{title:u("Revenue"),permission:"reports/view"}},{name:"reports_refunds",path:"refunds",component:Rse,meta:{title:u("Refunds"),permission:"reports/view"}},{name:"reports_subscriptions",path:"subscriptions",component:Une,meta:{title:u("Subscriptions"),permission:"reports/view"}},{name:"subscriptions-retention",path:"subscriptions/subscriptions-retention",component:Goe,meta:{title:u("Retention"),permission:"reports/view"}},{name:"subscriptions-cohorts",path:"subscriptions/subscriptions-cohorts",component:()=>Wt(()=>import("./chunks/Cohort.js?ver=1.6.3"),[],import.meta.url),meta:{title:u("Cohorts"),permission:"reports/view"}},{name:"future_renewals",path:"subscriptions/future-renewals",component:Wne,meta:{title:u("Future Renewals"),permission:"reports/view"}},{name:"reports_products",path:"products",component:wde,meta:{title:u("Product"),permission:"reports/view"}},{name:"reports_customer",path:"customer",component:hie,meta:{title:u("Customer"),permission:"reports/view"}},{name:"reports_sources",path:"sources",component:Zie,meta:{title:u("Sources"),permission:"reports/view"}}]},settings:{path:"/settings",component:P$,meta:{active_menu:"settings",title:u("Settings"),permission:["store/settings","store/sensitive"]},children:[{name:"store_settings",path:"store-settings",component:ZD,meta:{active_menu:"settings",title:u("Settings"),permission:"store/settings"},children:[{name:"store_setup",path:"",component:ws,meta:{title:u("Store Setup")}},{name:"pages_setup",path:"pages_setup",component:ws,meta:{title:u("Pages Setup")}},{name:"single_product_setup",path:"single_product_setup",component:ws,meta:{title:u("Product Page")}},{name:"cart_and_checkout",path:"cart_and_checkout",component:ws,meta:{title:u("Cart & Checkout")}},{name:"subscriptions_setup",path:"subscriptions_setup",component:ws,meta:{title:u("Subscriptions")}},{name:"checkout_fields",path:"checkout_fields",component:Ave,meta:{}}]},...je.get("addon_settings_routes",[]).map(e=>({component:ws,...e})),{name:"email_notifications",path:"email_notifications",component:gJ,meta:{active_menu:"settings",title:u("Notifications"),permission:"store/sensitive"}},{name:"email_mailing_settings",path:"email_mailing_settings",component:Ace,meta:{active_menu:"settings",title:u("Mailing Settings"),permission:"store/sensitive"}},{name:"reminders",path:"email_mailing_settings/reminders",component:ws,meta:{active_menu:"settings",title:u("Reminders"),permission:"store/sensitive"}},{name:"email_digest_settings",path:"email_digest_settings",component:yce,meta:{active_menu:"settings",title:u("Store Digest"),permission:"store/sensitive"}},{path:"email_notifications/:name/",name:"email_notifications/edit",component:qJ,meta:{active_menu:"settings",title:u("Edit Notification"),permission:"store/sensitive"},props:!0},{path:"email_notifications/add",name:"email_notifications/add",component:hX,meta:{active_menu:"settings",title:u("Add Notification"),permission:"store/sensitive"}},{name:"licensing",path:"licensing",component:wV,meta:{active_menu:"settings",title:u("Licensing"),permission:"store/sensitive"}},{name:"payments",path:"payments",component:A$,meta:{active_menu:"settings",title:u("Payment Settings"),permission:"is_super_admin"}},{name:"gateway",component:O3,path:"payments",children:mf,props:!0,meta:{active_menu:"settings",title:u("Payment Settings"),permission:"is_super_admin"}},{name:"invoice-packing",path:"invoice-packing",component:ev,meta:{active_menu:"settings",title:u("Invoice & Packing"),permission:"is_super_admin"}},{name:"pdf-template",path:"pdf-template",component:av,meta:{active_menu:"settings",title:u("PDF Templates"),permission:"is_super_admin"},children:[{name:"pdf-template-list",path:"",component:gv,meta:{active_menu:"settings",title:u("PDF Templates"),permission:"is_super_admin"}},{name:"pdf-template-settings",path:"settings",component:sg,meta:{active_menu:"settings",title:u("PDF Template Settings"),permission:"is_super_admin"}},{name:"edit-pdf-template",path:":template/edit",component:Lv,props:!0,meta:{active_menu:"settings",title:u("Edit PDF Template"),permission:"is_super_admin"}}]},{name:"roles",path:"roles",component:I$,meta:{active_menu:"settings",title:u("Role Settings"),permission:"is_super_admin"}},{name:"addons",path:"addons",component:Tue,meta:{active_menu:"settings",title:u("Features & addon"),permission:"is_super_admin"}},{name:"coupons",path:"coupons",component:_c,meta:{active_menu:"coupons",title:u("Coupons Settings"),permission:"is_super_admin"}},{name:"storage",path:"storage",component:rX,meta:{active_menu:"settings",title:u("Storage Providers"),permission:"is_super_admin"}},{name:"s3",path:"storage/s3",component:cc,props:!0,meta:{active_menu:"settings",title:u("S3"),permission:"is_super_admin"}},{name:"payment-design",path:"payments/:method/design",component:G3,meta:{active_menu:"settings",title:u("Gateway"),permission:"is_super_admin"},props:!0},{name:"drivers",component:cc,path:"storage",children:hf,props:!0,meta:{active_menu:"settings",title:u("Storage Settings"),permission:"is_super_admin"}},{name:"tax_settings",path:"tax_settings",component:Cce,meta:{active_menu:"settings",title:u("Tax Settings"),permission:"store/settings"},children:[{name:"tax_configurations",path:"",component:DAe,meta:{}},{name:"tax_rates",path:"tax_rates",component:WAe,meta:{}},{name:"eu",path:"eu",component:khe,meta:{}},{name:"eu_country_tax_rates",path:"eu/:country/:group",component:hc,props:!0,meta:{}},{name:"tax-rates-country-single",path:"tax_rates_country_single/:country/:group",component:hc,props:!0,meta:{}}]}]},integrations:{name:"integrations",path:"/integrations",component:Q4,meta:{active_menu:"integrations",title:u("Integrations"),permission:"integrations/view"}},global_feed_editor:{name:"feed_editor",path:"/global_integrations/:integration_id/:integration_name",component:Wu,meta:{active_menu:"integrations",title:u("Global Integrations"),permission:"integrations/view"}},integration_editor:{name:"integration_editor",path:"/integrations/:integration_name",component:mS,meta:{active_menu:"integrations",title:u("Integrations"),permission:"integrations/manage"}},coupons:{name:"coupons",path:"/coupons",component:_c,meta:{active_menu:"coupons",title:u("Coupons"),permission:"coupons/view"}},logs:{name:"logs",path:"/logs",component:lZ,meta:{active_menu:"logs",title:u("Logs"),permission:"is_super_admin"}},taxes:{name:"taxes",path:"/taxes",component:Cfe,meta:{active_menu:"taxes",title:u("Taxes"),permission:"is_super_admin"}},add_or_edit_coupon_route:{name:"add_or_edit_coupon",path:"/coupons/add_or_edit_coupon/:coupon_id?",component:G_e,props:!0,meta:{active_menu:"coupons",title:u("Coupons"),permission:"coupons/manage"}},onboarding:{path:"/onboarding",component:WF,name:"onboarding",meta:{active_menu:"dashboard",title:u("Onboarding"),permission:"is_super_admin"}}};const ebe={class:"fct-theme-button-container"},tbe={class:"theme-selected-button"},abe={__name:"ThemeToggle",setup(e){const t=M(De.MODE_LIGHT),a=c=>{t.value!==c&&(t.value=c,De.apply(c))},l=[{value:"light",label:u("Light"),icon:"Sun"},{value:"dark",label:u("Dark"),icon:"Moon"},{value:"system",label:u("System"),icon:"Tools"}];Is(()=>{const c=document.getElementById("theme-button-container");if(c){const p=c.querySelector(".fct-theme-button-container");p&&p.remove()}t.value=De.getCurrentTheme(),t.value.toString().startsWith(De.MODE_SYSTEM)&&(t.value=De.MODE_SYSTEM)});const s=c=>{Be(()=>{t.value=De.getCurrentTheme()})},i=c=>{a(c)};return Ee(()=>{window.addEventListener(De.THEME_CHANGE_EVENT,s,!1)}),yl(()=>{window.removeEventListener(De.THEME_CHANGE_EVENT,s,!1)}),(c,p)=>{const f=C("el-dropdown-item"),_=C("el-dropdown-menu"),g=C("el-dropdown");return r(),h("div",ebe,[n(g,{placement:"bottom-end",trigger:"click","popper-class":"fct-dropdown",onCommand:i},{dropdown:d(()=>[n(_,null,{default:d(()=>[(r(),h(H,null,ae(l,y=>n(f,{key:y.value,command:y.value,class:de({active:t.value===y.value})},{default:d(()=>[n(J,{name:y.icon},null,8,["name"]),R(" "+m(y.label),1)]),_:2},1032,["command","class"])),64))]),_:1})]),default:d(()=>[o("div",tbe,[t.value==="light"?(r(),E(J,{key:0,name:"Sun"})):t.value==="dark"?(r(),E(J,{key:1,name:"Moon"})):t.value==="system"?(r(),E(J,{key:2,name:"Tools"})):B("",!0)])]),_:1})])}}};function as(e){return Array.isArray?Array.isArray(e):gf(e)==="[object Array]"}function lbe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function sbe(e){return e==null?"":lbe(e)}function Hl(e){return typeof e=="string"}function _f(e){return typeof e=="number"}function nbe(e){return e===!0||e===!1||obe(e)&&gf(e)=="[object Boolean]"}function vf(e){return typeof e=="object"}function obe(e){return vf(e)&&e!==null}function ml(e){return e!=null}function dr(e){return!e.trim().length}function gf(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const ibe="Incorrect 'index' type",rbe=e=>`Invalid value for key ${e}`,dbe=e=>`Pattern length exceeds max of ${e}.`,ube=e=>`Missing ${e} property in key`,cbe=e=>`Property 'weight' in key '${e}' must be a positive integer`,Cc=Object.prototype.hasOwnProperty;class Abe{constructor(t){this._keys=[],this._keyMap={};let a=0;t.forEach(l=>{let s=yf(l);this._keys.push(s),this._keyMap[s.id]=s,a+=s.weight}),this._keys.forEach(l=>{l.weight/=a})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function yf(e){let t=null,a=null,l=null,s=1,i=null;if(Hl(e)||as(e))l=e,t=kc(e),a=Kr(e);else{if(!Cc.call(e,"name"))throw new Error(ube("name"));const c=e.name;if(l=c,Cc.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(cbe(c));t=kc(c),a=Kr(c),i=e.getFn}return{path:t,id:a,weight:s,src:l,getFn:i}}function kc(e){return as(e)?e:e.split(".")}function Kr(e){return as(e)?e.join("."):e}function pbe(e,t){let a=[],l=!1;const s=(i,c,p)=>{if(ml(i))if(!c[p])a.push(i);else{let f=c[p];const _=i[f];if(!ml(_))return;if(p===c.length-1&&(Hl(_)||_f(_)||nbe(_)))a.push(sbe(_));else if(as(_)){l=!0;for(let g=0,y=_.length;ge.score===t.score?e.idx{this._keysMap[a.id]=l})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Hl(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();Hl(t)?this._addString(t,a):this._addObject(t,a)}removeAt(t){this.records.splice(t,1);for(let a=t,l=this.size();a{let c=s.getFn?s.getFn(t):this.getFn(t,s.path);if(ml(c)){if(as(c)){let p=[];const f=[{nestedArrIndex:-1,value:c}];for(;f.length;){const{nestedArrIndex:_,value:g}=f.pop();if(ml(g))if(Hl(g)&&!dr(g)){let y={v:g,i:_,n:this.norm.get(g)};p.push(y)}else as(g)&&g.forEach((y,v)=>{f.push({nestedArrIndex:v,value:y})})}l.$[i]=p}else if(Hl(c)&&!dr(c)){let p={v:c,n:this.norm.get(c)};l.$[i]=p}}}),this.records.push(l)}toJSON(){return{keys:this.keys,records:this.records}}}function bf(e,t,{getFn:a=Et.getFn,fieldNormWeight:l=Et.fieldNormWeight}={}){const s=new Qd({getFn:a,fieldNormWeight:l});return s.setKeys(e.map(yf)),s.setSources(t),s.create(),s}function ybe(e,{getFn:t=Et.getFn,fieldNormWeight:a=Et.fieldNormWeight}={}){const{keys:l,records:s}=e,i=new Qd({getFn:t,fieldNormWeight:a});return i.setKeys(l),i.setIndexRecords(s),i}function yo(e,{errors:t=0,currentLocation:a=0,expectedLocation:l=0,distance:s=Et.distance,ignoreLocation:i=Et.ignoreLocation}={}){const c=t/e.length;if(i)return c;const p=Math.abs(l-a);return s?c+p/s:p?1:c}function bbe(e=[],t=Et.minMatchCharLength){let a=[],l=-1,s=-1,i=0;for(let c=e.length;i=t&&a.push([l,s]),l=-1)}return e[i-1]&&i-l>=t&&a.push([l,i-1]),a}const ks=32;function wbe(e,t,a,{location:l=Et.location,distance:s=Et.distance,threshold:i=Et.threshold,findAllMatches:c=Et.findAllMatches,minMatchCharLength:p=Et.minMatchCharLength,includeMatches:f=Et.includeMatches,ignoreLocation:_=Et.ignoreLocation}={}){if(t.length>ks)throw new Error(dbe(ks));const g=t.length,y=e.length,v=Math.max(0,Math.min(l,y));let b=i,k=v;const w=p>1||f,S=w?Array(y):[];let $;for(;($=e.indexOf(t,k))>-1;){let D=yo(t,{currentLocation:$,expectedLocation:v,distance:s,ignoreLocation:_});if(b=Math.min(D,b),k=$+g,w){let Q=0;for(;Q=O;X-=1){let G=X-1,ee=a[e.charAt(G)];if(w&&(S[G]=+!!ee),P[X]=(P[X+1]<<1|1)&ee,D&&(P[X]|=(I[X+1]|I[X])<<1|1|I[X+1]),P[X]&U&&(F=yo(t,{errors:D,currentLocation:G,expectedLocation:v,distance:s,ignoreLocation:_}),F<=b)){if(b=F,k=G,k<=v)break;O=Math.max(1,2*v-k)}}if(yo(t,{errors:D+1,currentLocation:v,expectedLocation:v,distance:s,ignoreLocation:_})>b)break;I=P}const T={isMatch:k>=0,score:Math.max(.001,F)};if(w){const D=bbe(S,p);D.length?f&&(T.indices=D):T.isMatch=!1}return T}function Cbe(e){let t={};for(let a=0,l=e.length;ae.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e;class wf{constructor(t,{location:a=Et.location,threshold:l=Et.threshold,distance:s=Et.distance,includeMatches:i=Et.includeMatches,findAllMatches:c=Et.findAllMatches,minMatchCharLength:p=Et.minMatchCharLength,isCaseSensitive:f=Et.isCaseSensitive,ignoreDiacritics:_=Et.ignoreDiacritics,ignoreLocation:g=Et.ignoreLocation}={}){if(this.options={location:a,threshold:l,distance:s,includeMatches:i,findAllMatches:c,minMatchCharLength:p,isCaseSensitive:f,ignoreDiacritics:_,ignoreLocation:g},t=f?t:t.toLowerCase(),t=_?ei(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const y=(b,k)=>{this.chunks.push({pattern:b,alphabet:Cbe(b),startIndex:k})},v=this.pattern.length;if(v>ks){let b=0;const k=v%ks,w=v-k;for(;b{const{isMatch:I,score:F,indices:x}=wbe(t,w,S,{location:i+$,distance:c,threshold:p,findAllMatches:f,minMatchCharLength:_,includeMatches:s,ignoreLocation:g});I&&(b=!0),v+=F,I&&x&&(y=[...y,...x])});let k={isMatch:b,score:b?v/this.chunks.length:1};return b&&s&&(k.indices=y),k}}class gs{constructor(t){this.pattern=t}static isMultiMatch(t){return Bc(t,this.multiRegex)}static isSingleMatch(t){return Bc(t,this.singleRegex)}search(){}}function Bc(e,t){const a=e.match(t);return a?a[1]:null}class kbe extends gs{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 Bbe extends gs{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const l=t.indexOf(this.pattern)===-1;return{isMatch:l,score:l?0:1,indices:[0,t.length-1]}}}class xbe extends gs{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 Sbe extends gs{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 Fbe extends gs{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 $be extends gs{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 Cf extends gs{constructor(t,{location:a=Et.location,threshold:l=Et.threshold,distance:s=Et.distance,includeMatches:i=Et.includeMatches,findAllMatches:c=Et.findAllMatches,minMatchCharLength:p=Et.minMatchCharLength,isCaseSensitive:f=Et.isCaseSensitive,ignoreDiacritics:_=Et.ignoreDiacritics,ignoreLocation:g=Et.ignoreLocation}={}){super(t),this._bitapSearch=new wf(t,{location:a,threshold:l,distance:s,includeMatches:i,findAllMatches:c,minMatchCharLength:p,isCaseSensitive:f,ignoreDiacritics:_,ignoreLocation:g})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class kf extends gs{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let a=0,l;const s=[],i=this.pattern.length;for(;(l=t.indexOf(this.pattern,a))>-1;)a=l+i,s.push([l,a-1]);const c=!!s.length;return{isMatch:c,score:c?0:1,indices:s}}}const Gr=[kbe,kf,xbe,Sbe,$be,Fbe,Bbe,Cf],xc=Gr.length,Ebe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Ube="|";function Ibe(e,t={}){return e.split(Ube).map(a=>{let l=a.trim().split(Ebe).filter(i=>i&&!!i.trim()),s=[];for(let i=0,c=l.length;i!!(e[ti.AND]||e[ti.OR]),Tbe=e=>!!e[qr.PATH],Mbe=e=>!as(e)&&vf(e)&&!Yr(e),Sc=e=>({[ti.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Bf(e,t,{auto:a=!0}={}){const l=s=>{let i=Object.keys(s);const c=Tbe(s);if(!c&&i.length>1&&!Yr(s))return l(Sc(s));if(Mbe(s)){const f=c?s[qr.PATH]:i[0],_=c?s[qr.PATTERN]:s[f];if(!Hl(_))throw new Error(rbe(f));const g={keyId:Kr(f),pattern:_};return a&&(g.searcher=zr(_,t)),g}let p={children:[],operator:i[0]};return i.forEach(f=>{const _=s[f];as(_)&&_.forEach(g=>{p.children.push(l(g))})}),p};return Yr(e)||(e=Sc(e)),l(e)}function Lbe(e,{ignoreFieldNorm:t=Et.ignoreFieldNorm}){e.forEach(a=>{let l=1;a.matches.forEach(({key:s,norm:i,score:c})=>{const p=s?s.weight:null;l*=Math.pow(c===0&&p?Number.EPSILON:c,(p||1)*(t?1:i))}),a.score=l})}function Rbe(e,t){const a=e.matches;t.matches=[],ml(a)&&a.forEach(l=>{if(!ml(l.indices)||!l.indices.length)return;const{indices:s,value:i}=l;let c={indices:s,value:i};l.key&&(c.key=l.key.src),l.idx>-1&&(c.refIndex=l.idx),t.matches.push(c)})}function Obe(e,t){t.score=e.score}function Hbe(e,t,{includeMatches:a=Et.includeMatches,includeScore:l=Et.includeScore}={}){const s=[];return a&&s.push(Rbe),l&&s.push(Obe),e.map(i=>{const{idx:c}=i,p={item:t[c],refIndex:c};return s.length&&s.forEach(f=>{f(i,p)}),p})}class pn{constructor(t,a={},l){this.options={...Et,...a},this.options.useExtendedSearch,this._keyStore=new Abe(this.options.keys),this.setCollection(t,l)}setCollection(t,a){if(this._docs=t,a&&!(a instanceof Qd))throw new Error(ibe);this._myIndex=a||bf(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){ml(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const a=[];for(let l=0,s=this._docs.length;l-1&&(f=f.slice(0,a)),Hbe(f,this._docs,{includeMatches:l,includeScore:s})}_searchStringList(t){const a=zr(t,this.options),{records:l}=this._myIndex,s=[];return l.forEach(({v:i,i:c,n:p})=>{if(!ml(i))return;const{isMatch:f,score:_,indices:g}=a.searchIn(i);f&&s.push({item:i,idx:c,matches:[{score:_,value:i,norm:p,indices:g}]})}),s}_searchLogical(t){const a=Bf(t,this.options),l=(p,f,_)=>{if(!p.children){const{keyId:y,searcher:v}=p,b=this._findMatches({key:this._keyStore.get(y),value:this._myIndex.getValueForItemAtKeyId(f,y),searcher:v});return b&&b.length?[{idx:_,item:f,matches:b}]:[]}const g=[];for(let y=0,v=p.children.length;y{if(ml(p)){let _=l(a,p,f);_.length&&(i[f]||(i[f]={idx:f,item:p,matches:[]},c.push(i[f])),_.forEach(({matches:g})=>{i[f].matches.push(...g)}))}}),c}_searchObjectList(t){const a=zr(t,this.options),{keys:l,records:s}=this._myIndex,i=[];return s.forEach(({$:c,i:p})=>{if(!ml(c))return;let f=[];l.forEach((_,g)=>{f.push(...this._findMatches({key:_,value:c[g],searcher:a}))}),f.length&&i.push({idx:p,item:c,matches:f})}),i}_findMatches({key:t,value:a,searcher:l}){if(!ml(a))return[];let s=[];if(as(a))a.forEach(({v:i,i:c,n:p})=>{if(!ml(i))return;const{isMatch:f,score:_,indices:g}=l.searchIn(i);f&&s.push({score:_,key:t,value:i,idx:c,norm:p,indices:g})});else{const{v:i,n:c}=a,{isMatch:p,score:f,indices:_}=l.searchIn(i);p&&s.push({score:f,key:t,value:i,norm:c,indices:_})}return s}}pn.version="7.1.0";pn.createIndex=bf;pn.parseIndex=ybe;pn.config=Et;pn.parseQuery=Bf;Vbe(Dbe);const Pbe=(je.get("payment_routes")||[]).filter(e=>!e.upcoming).map(e=>{const t=e.meta.admin_title||e.meta.title||e.meta.label||e.name;return{title:t,subtitle:u("Manage %1$s",t),path:"/settings/payments/"+e.path}}),Nbe=[{title:u("Dashboard"),path:"/"},{title:u("Orders"),path:"/orders"},{title:u("Create Order"),path:"/orders/add"},{title:u("Customers"),path:"/customers"},{title:u("Products"),path:"/products"},{title:u("Product Inventory"),path:"/products/inventory"},{title:u("Bulk Import Products"),path:"/products/bulk-insert"},{title:u("Integrations"),path:"/integrations"},{title:u("Coupons"),path:"/coupons"},{title:u("Logs"),path:"/logs"},{title:u("Taxes"),path:"/taxes"},{title:u("Reports"),path:"/reports/overview"},{title:u("Sales Report"),path:"/reports/sales"},{title:u("Orders Report"),path:"/reports/orders"},{title:u("Revenue Report"),path:"/reports/revenue"},{title:u("Refunds Report"),path:"/reports/refunds"},{title:u("Subscriptions Report"),path:"/reports/subscriptions"},{title:u("Future Renewals Report"),path:"/reports/subscriptions/future-renewals"},{title:u("Product Report"),path:"/reports/products"},{title:u("Customer Report"),path:"/reports/customer"},{title:u("Traffic Sources Report"),path:"/reports/sources"},...Pbe],Kbe=Nbe.map(({title:e,subtitle:t,path:a})=>({title:e,...t?{subtitle:t}:{},data:{type:"action",action:({router:l})=>{l.push({path:a})},show_description:!1}})),Gbe=[{title:"Theme",title_resolver:()=>{let t=(De.isDark()?"dark":"light")==="light"?u("Dark"):u("Light");return u("Change theme to %1$s",t)},data:{type:"action",action:()=>{let t=(De.isDark()?"dark":"light")==="light"?"dark":"light";De.apply(t,{fromShortcut:!0})}}}],Fc={"/settings/store-settings":u("Store Setup"),"/settings/store-settings/pages_setup":u("Pages Setup"),"/settings/store-settings/single_product_setup":u("Single Product & Order Setup"),"/settings/store-settings/cart_and_checkout":u("Cart and Checkout"),"/settings/store-settings/subscriptions_setup":u("Subscriptions Setup"),"/settings/store-settings/checkout_fields":u("Checkout Fields"),"/settings/email_notifications":u("Email Notifications"),"/settings/email_mailing_settings":u("Mailing Settings"),"/settings/email_mailing_settings/reminders":u("Reminders"),"/settings/licensing":u("Licensing"),"/settings/payments":u("Payment Settings"),"/settings/invoice-packing":u("Invoice & Packing Slips"),"/settings/pdf-template":u("PDF Templates"),"/settings/roles":u("Role Settings"),"/settings/addons":u("Features & Addons"),"/settings/tax_settings":u("Tax Settings"),"/settings/tax_settings/tax_rates":u("Tax Rates"),"/settings/tax_settings/eu":u("EU VAT Settings"),"/settings/storage":u("Storage Providers"),"/settings/coupons":u("Coupon Settings")};let xf=[];Object.keys(Fc).forEach(e=>{const t=Fc[e];xf.push({title:t,data:{type:"action",action:({router:a})=>{a.push({path:e})},description:u("Go to %1$s",t),show_description:!1}})});const jbe=[],zbe={Menu:Kbe,Actions:Gbe,Settings:xf,Shortcuts:jbe},Wr=[];Object.entries(zbe).forEach(([e,t])=>{t.forEach((a,l)=>{Wr.push({...a,id:`${e.toString().toLowerCase()}-${l}`,group:[e]})})});const qbe=()=>({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}]}),Ybe={class:"navigable-list-container fct-global-search-result-container"},Wbe={key:0,class:"no-results fct-global-search-result-not-found"},Jbe={key:1},Xbe=["tabindex","onClick","onKeydown"],Zbe={__name:"NavigableList",props:{items:{type:Array,required:!0,default:()=>[]},noResultsText:{type:String,default:u("No results found")},onAction:{type:Function,required:!0}},setup(e,{expose:t}){const a=e,l=M(-1),s=Xr("listContainer"),i=M({}),c=(k,w)=>{w&&(i.value[k]=w)},p=k=>{const w=a.items.length;if(w===0)return;const S=w-1;k==="up"?l.value=l.value<=0?S:l.value-1:k==="down"&&(l.value=l.value>=S?0:l.value+1),f()},f=()=>{const k=s.value,w=i.value[l.value];w&&k&&(w.scrollIntoView({behavior:"smooth",block:"nearest"}),Be(()=>{w.focus()}))},_=k=>{l.value=k,g(k)},g=k=>{k>=0&&k{l.value=-1};return t({focusList:k=>{k=k??a.items.length-1,k>=0&&(l.value=k,Be(()=>{i.value[k]&&i.value[k].focus()}))},resetSelection:y,performFirstAction:()=>{a.items.length>0?(l.value=0,setTimeout(()=>{g(0)},200)):l.value=-1}}),ye(()=>a.items,k=>{y(),k.length>0&&Be(()=>{})},{immediate:!0}),ye(l,()=>{}),(k,w)=>(r(),h("div",Ybe,[e.items.length===0?(r(),h("div",Wbe,[n(J,{name:"Empty/GlobalSearch"}),R(" "+m(e.noResultsText),1)])):(r(),h("div",Jbe,[o("ul",{ref_key:"listContainer",ref:s,class:"navigable-list fct-global-search-result-list"},[(r(!0),h(H,null,ae(e.items,(S,$)=>(r(),h("li",{key:$,ref_for:!0,ref:I=>c($,I),class:de({selected:$===l.value}),tabindex:$,onClick:I=>_($),onKeydown:[w[0]||(w[0]=Ba(Pe(I=>p("up"),["prevent"]),["arrow-up"])),w[1]||(w[1]=Ba(Pe(I=>p("down"),["prevent"]),["arrow-down"])),Ba(I=>g($),["enter"])]},[ba(k.$slots,"default",{item:S,index:$,isSelected:$===l.value},void 0,!0)],42,Xbe))),128))],512)]))]))}},Jr=st(Zbe,[["__scopeId","data-v-2379fe26"]]),e0e={class:"fct-search-result-label"},t0e={class:"fct-search-result-title"},a0e={key:0,class:"fct-search-result-subtitle"},l0e={key:1,class:"fct-search-result-subtitle"},s0e={class:"action-icon"},n0e={class:"recent-search-title"},o0e={class:"fct-search-result-label"},i0e={class:"fct-search-result-title"},r0e={key:0,class:"fct-search-result-subtitle"},d0e={key:1,class:"fct-search-result-subtitle"},u0e={class:"action-icon"},ur="recent_actions",c0e={__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=sl();Yt().ctx;const l=e,s=M(0),i=M({}),c=M(),p=(S,$)=>{const F=S.item.data,x=_(F.type);if(x==="link"){let U=_(F.url);_(F.new_tab)?window.open(U,"_blank"):window.location.href=U}else x==="action"&&_(F.action);f(S),l.onActionPerformed()},f=S=>{const $=S.item.id;let I=Dt.get(ur)||[];I=I.filter(F=>F!==$),I.unshift($),I=I.slice(0,5),Dt.set(ur,I)},_=S=>typeof S=="function"?g(S):S,g=async S=>await S({query:l.query,router:a}),y=()=>{var S;(S=c.value)==null||S.resetSelection()},v=()=>{var S;(S=c.value)==null||S.focusList(0)},b=()=>{var S;(S=c.value)==null||S.performFirstAction()};ye(()=>l.searchResults,async()=>{i.value={},i.value=l.searchResults??{},s.value=Object.keys(i.value).length-1;let S=i.value;for(const $ of Object.keys(S)){const I=S[$];I.item.title_resolver&&(S[$].item.title=await _(I.item.title_resolver))}i.value={...S}});const k=M([]),w=async()=>{const S=Dt.get(ur)||[];let $=rt.whereIn(l.searchData,"id",S),I=[];for(const F of $)typeof F.title_resolver=="function"&&(F.title=await _(F.title_resolver)),I.push({item:F});k.value=I};return Ee(()=>{w()}),t({focusList:v,resetSelection:y,performFirstAction:b,fetchRecentActions:w}),(S,$)=>(r(),h(H,null,[e.query||k.value.length<1?(r(),E(Jr,{key:0,items:e.searchResults,"on-action":p,"no-results-text":A(u)("No matches found"),ref_key:"navigableList",ref:c},{default:d(({item:I,index:F,isSelected:x})=>{var U,T,D;return[o("span",e0e,[o("span",t0e,m(I.item.title),1),(U=I.item)!=null&&U.subtitle?(r(),h("span",a0e,m(I.item.subtitle),1)):((D=(T=I.item)==null?void 0:T.data)==null?void 0:D.show_description)===!0?(r(),h("span",l0e,m(I.item.data.description),1)):B("",!0)]),o("div",s0e,[n(J,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])):B("",!0),!e.query&&k.value.length>0?(r(),h(H,{key:1},[o("span",n0e,m(A(u)("Recent Actions")),1),n(Jr,{items:k.value,"on-action":p,"no-results-text":A(u)("No matches found"),ref_key:"navigableList",ref:c},{default:d(({item:I,index:F,isSelected:x})=>{var U,T,D;return[o("span",o0e,[o("span",i0e,m(I.item.title),1),(U=I.item)!=null&&U.subtitle?(r(),h("span",r0e,m(I.item.subtitle),1)):((D=(T=I.item)==null?void 0:T.data)==null?void 0:D.show_description)===!0?(r(),h("span",d0e,m(I.item.data.description),1)):B("",!0)]),o("div",u0e,[n(J,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])],64)):B("",!0)],64))}},A0e=st(c0e,[["__scopeId","data-v-ccb0ebef"]]),p0e={class:"fct-global-search-product-wrap"},f0e={class:"fct-global-search-product-left-info"},m0e={key:0,class:"type"},h0e={key:0,class:"price-and-status"},_0e={__name:"Product",props:{product:{type:Object,required:!0}},setup(e){const t=l=>l.min_price===l.max_price?Nt(l.min_price,!0):`${Nt(l.min_price,!0)} - ${Nt(l.max_price,!0)}`,a=l=>l==="publish"?u("published"):l==="future"?u("scheduled"):l;return(l,s)=>(r(),h("div",p0e,[o("div",f0e,[n(ld,{product:e.product},null,8,["product"]),e.product.detail?(r(),h("span",m0e,[R(m(A(da).headline(e.product.detail.variation_type))+" ",1),s[0]||(s[0]=o("br",null,null,-1)),R(" "+m(A(da).headline(e.product.detail.fulfillment_type)),1)])):B("",!0)]),e.product.detail?(r(),h("span",h0e,[R(m(t(e.product.detail))+" ",1),(r(),E(pa,{key:e.product.ID,status:e.product.post_status},{default:d(()=>[R(m(a(e.product.post_status)),1)]),_:1},8,["status"]))])):B("",!0)]))}},v0e={class:"fct-global-search-order-wrap"},g0e={class:"fct-global-search-order-header"},y0e={class:"fct-global-search-order-id"},b0e={class:"items"},w0e={class:"fct-global-search-order-header-meta"},C0e={class:"date"},k0e=["innerHTML"],B0e={class:"customer-name"},x0e={class:"fct-global-search-order-status-wrapper"},S0e=["src","alt"],F0e={__name:"Order",props:{order:{type:Object,required:!0}},setup(e){const t=a=>rt.get(window,"fluentCartAdminApp.payment_logos."+a);return(a,l)=>{var i;const s=C("el-tag");return r(),h("div",v0e,[o("div",g0e,[o("div",y0e,[R(" #"+m(e.order.id)+" ",1),o("span",b0e,m(A(u)("%s Items",e.order.order_items.length)),1)]),o("div",w0e,[o("span",C0e,[n(Ha,{"date-time":e.order.created_at},null,8,["date-time"])]),l[0]||(l[0]=o("span",{class:"circle"},null,-1)),o("span",{class:"total-price",innerHTML:A(Nt)(e.order.total_amount,!0,!1,e.order.currency)},null,8,k0e),l[1]||(l[1]=o("span",{class:"circle"},null,-1)),o("span",B0e,m(((i=e.order.customer)==null?void 0:i.full_name)||A(u)("No Name")),1)])]),o("div",x0e,[n(pa,{status:e.order.payment_status,"hide-icon":!0},null,8,["status"]),t(e.order.payment_method)?(r(),h("img",{key:0,src:t(e.order.payment_method),alt:A(da).headline(e.order.payment_method)},null,8,S0e)):(r(),E(s,{key:1,type:"info",round:"",size:"small",class:"capitalize"},{default:d(()=>[R(m(A(da).headline(e.order.payment_method)),1)]),_:1}))])])}}},$0e={class:"fct-global-search-customer-wrap"},E0e={class:"fct-customer-card"},U0e={class:"fct-customer-avatar"},I0e=["src"],Q0e={class:"fct-customer-details"},D0e={class:"fct-customer-name"},V0e={class:"fct-customer-id"},T0e={class:"fct-customer-email"},M0e={class:"purchase-count"},L0e={class:"date"},R0e={__name:"Customer",props:{customer:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),h("div",$0e,[o("div",E0e,[o("div",U0e,[o("img",{src:e.customer.photo,alt:"avatar"},null,8,I0e)]),o("div",Q0e,[o("div",D0e,[R(m(e.customer.full_name||t.$t("No Name"))+" ",1),o("span",V0e,"#"+m(e.customer.id),1)]),o("div",T0e,[R(m(e.customer.email)+" ",1),a[0]||(a[0]=o("span",{class:"circle"},null,-1)),a[1]||(a[1]=R()),o("span",M0e,"Purchase: "+m(e.customer.purchase_count),1)])])]),o("span",L0e,[n(Ha,{"date-time":e.customer.last_purchase_date},null,8,["date-time"])])]))}},O0e={class:"fct-global-search-coupon-wrap"},H0e={class:"amount"},P0e={__name:"Coupon",props:{coupon:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),h("div",O0e,[o("span",null,m(e.coupon.title),1),o("span",null,m(e.coupon.code),1),o("span",H0e,m(A(Nt)(e.coupon.amount,!0)),1)]))}},N0e={class:"fct-global-remote-result-container"},K0e={class:"fct-global-remote-result-label"},G0e={class:"text"},j0e={class:"navigable-content"},z0e={class:"action-icon"},q0e={__name:"RemoteResult",emits:["close-modal","onRemoteSearchStateChange"],setup(e,{expose:t,emit:a}){const l=a,s=sl(),i=M({}),c=M(""),p=M(),f=M({}),_=M([]),g=D=>{y.value=!1,_.value=S.data.tableData,l("onRemoteSearchStateChange",!1)},y=M(!1),v={orders:nA({fetch:!1}),products:Hp({fetch:!1}),customers:sA({fetch:!1}),coupons:df({fetch:!1})},b=()=>{},k=()=>{var D;(D=p.value)==null||D.focusList(0)},w=()=>{var D;(D=p.value)==null||D.performFirstAction()};Is(()=>{for(const D of Object.keys(v))v[D].onDataLoaded(g)});let S=null;const $=()=>{S=v[i.value.key],S.data.search=c.value,y.value=!0,S.fetch(),l("onRemoteSearchStateChange",!0)},I=id.debounce($,800),F=(D,Q)=>{if(_.value=[],S&&(S.data.search=""),i.value=Q,f.value={title:Q.title,key:Q.key},!D){c.value="";return}c.value=D,I()},x=()=>{s.push({name:f.value.key,query:{search:c.value}}),l("close-modal")},U={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"}},T=D=>{i.value.key in U&&(s.push({name:U[i.value.key].name,params:{[U[i.value.key].key]:D.id||D.ID,action:"edit"}}),l("close-modal"))};return t({fetchData:F,focusList:k,resetSelection:b,performFirstAction:w}),(D,Q)=>(r(),h("div",N0e,[o("div",K0e,[o("span",G0e,m(i.value.title),1),f.value.key?(r(),h("span",{key:0,class:"view-all",onClick:x},m(c.value?A(u)('Search "%1$s" in %2$s',c.value,f.value.title):A(u)("See All %s",f.value.title)),1)):B("",!0)]),n(Jr,{items:_.value,"on-action":V=>{T(V)},"no-results-text":c.value?A(u)("No matches found for %s",i.value.title):A(u)("Type something to find %s",i.value.title),ref_key:"navigableList",ref:p},{default:d(({item:V,index:O,isSelected:L})=>[o("div",j0e,[i.value.key==="products"?(r(),E(_0e,{key:0,product:V},null,8,["product"])):B("",!0),i.value.key==="orders"?(r(),E(F0e,{key:1,order:V},null,8,["order"])):B("",!0),i.value.key==="customers"?(r(),E(R0e,{key:2,customer:V},null,8,["customer"])):B("",!0),i.value.key==="coupons"?(r(),E(P0e,{key:3,coupon:V},null,8,["coupon"])):B("",!0)]),o("div",z0e,[n(J,{name:"Enter"})])]),_:1},8,["items","on-action","no-results-text"])]))}},Y0e={class:"fct-global-search-input-wrap"},W0e=["aria-label"],J0e={class:"fct-setting-search-icon"},X0e={class:"fct-global-search-input-container"},Z0e={key:0,class:"searched-item"},ewe={class:"fct-global-searching-for"},twe={class:"fct-global-searching-for-label"},awe={class:"fct-global-searching-suggestion-list"},lwe=["onClick"],swe={class:"dialog-footer is-border"},nwe={class:"fct-search-commands"},owe={class:"command-key"},iwe={class:"command-key"},rwe={class:"label"},dwe={class:"command-key"},uwe={class:"label"},cwe={class:"label"},Awe={__name:"GlobalSearch",setup(e){Yt().ctx,sl();const t=M(!1),a=M(""),l=M({}),s=M(),i=M(""),c=M([u("orders"),u("products"),u("customers"),u("coupons"),u("settings"),u("menus"),u("shortcuts...")]),p=M(0),f=M(!0),_=M(0),g=M(null),y=M(null),v=M(70),b=M(40),k=M(1700),w=()=>{Be(()=>{$()})},S=()=>{var W,j;T.value?(W=X.value)==null||W.resetSelection():(j=F.value)==null||j.resetSelection(),T.value=!1,P.value=!1,I()},$=()=>{var W;(W=s.value)==null||W.focus()},I=()=>{T.value=!1,l.value=[],t.value=!1,a.value="",D.value=null},F=M(),x=W=>{let j=W.includes(","),ie={},_e=[];(j?W.split(","):[W]).forEach(le=>{le.includes(":")?U(le,ie,_e):_e.push(le)});let ue=[];return Object.keys(ie).forEach(le=>{const be=ie[le];be.length>0?be.forEach(Qe=>{Qe.length>0?ue.push({group:"'"+le,title:Qe}):ue.push({group:"'"+le})}):ue.push({group:"'"+le})}),_e.forEach(le=>{le.length>0&&ue.push({title:le})}),ue},U=(W,j,ie)=>{if(W.length===1)return;let _e=W.split(":"),me=_e[0],ue=_e[1];me.length>0?(j.hasOwnProperty(me)||(j[me]=[]),ue.length>0&&j[me].push(ue)):ie.push(ue)},T=M(!1),D=M(null),Q=M({o:{key:"orders",title:u("Orders")},p:{key:"products",title:u("Products")},c:{key:"customers",title:u("Customers")},d:{key:"coupons",title:u("Coupons")}}),V=W=>{D.value=W,T.value=!0,l.value={},Be(()=>{var j,ie;(j=X.value)==null||j.fetchData(a.value,W),(ie=s.value)==null||ie.focus()})},O=()=>{var W;l.value=[],D.value=null,a.value="",T.value=!1,(W=s.value)==null||W.focus(),P.value=!1},L=()=>{var W;(W=X.value)==null||W.fetchData(a.value,D.value)},P=M(!1),z=W=>{P.value=W,Be(()=>{var j;(j=s.value)==null||j.focus()})},X=M(),G=_s(),ee=()=>{if(t.value){$();return}const W=["o","p","c","d"];G.bind(W,j=>{j.preventDefault();const ie=Q.value[j.key];ie&&V(ie)}),t.value=!0,Be(()=>{var j;(j=F.value)==null||j.fetchRecentActions()}),setTimeout(()=>{G.unbind(W)},800)};G.bind(["/"],W=>{!t.value&&oe()||(W.preventDefault(),ee())});const oe=()=>{const W=document.activeElement;if(!W)return!1;const j=W.tagName;return j==="INPUT"||j==="TEXTAREA"||j==="SELECT"||W.isContentEditable},re=()=>{if(g.value)return;const W=()=>{if(s.value&&s.value.length>0)return;const ie=c.value[p.value];if(f.value)_.value{y.value=null},k.value));else{if(y.value)return;_.value>0?(_.value--,i.value=ie.slice(0,_.value)):(f.value=!0,p.value=(p.value+1)%c.value.length)}},j=()=>{W();const ie=f.value?v.value:y.value?120:b.value;g.value=setTimeout(j,ie)};j()},K=M(!1);let Y;return Ee(()=>{re(),Y=new pn(Wr,qbe());const W=document.getElementById("fct_admin_menu_search");if(W){const j=W.querySelector(".fct-global-search-input-wrap");j&&j.remove()}K.value=!!W,window.fluentCart=window.fluentCart||{},window.fluentCart.openSearch=ee}),Bt(()=>{window.fluentCart&&delete window.fluentCart.openSearch}),(W,j)=>{const ie=C("el-input"),_e=C("el-dialog");return r(),h(H,null,[K.value?(r(),E(li,{key:0,to:"#fct_admin_menu_search"},[o("div",Y0e,[o("button",{onClick:ee,type:"button",class:"fct-setting-search-button","aria-label":A(u)("Search")},[o("span",J0e,[n(J,{name:"Search"})]),j[6]||(j[6]=o("span",{class:"fct-global-search-button-keys"},[o("kbd",{class:"fct-global-search-button-key"},"/")],-1))],8,W0e)])])):B("",!0),n(_e,{modelValue:t.value,"onUpdate:modelValue":j[5]||(j[5]=me=>t.value=me),onOpened:w,onClosed:S,class:"fct-global-search-container","append-to-body":!0},{header:d(()=>[o("div",X0e,[n(J,{name:"Search",class:"search-icon"}),D.value!=null?(r(),h("div",Z0e,[R(m(D.value.title)+" ",1),n(J,{name:"Cross",class:"searched-item-remove",onClick:O})])):B("",!0),n(ie,{class:"mousetrap",placeholder:A(u)("Search for %1$s",i.value),autofocus:"",ref_key:"searchRef",ref:s,id:"fct-global-search-input",disabled:P.value,onKeydown:[j[0]||(j[0]=Ba(Pe(()=>{var me,ue;if(T.value){(me=X.value)==null||me.focusList();return}(ue=F.value)==null||ue.focusList()},["prevent"]),["arrow-down"])),j[1]||(j[1]=Ba(Pe(()=>{var me,ue;if(T.value){(me=X.value)==null||me.performFirstAction();return}(ue=F.value)==null||ue.performFirstAction()},["prevent"]),["enter"])),j[2]||(j[2]=Ba(()=>{a.value.length===0&&(D.value=null,T.value=!1)},["backspace"]))],onInput:j[3]||(j[3]=()=>{if(T.value){L();return}let me=a.value.includes(","),ue=a.value.includes(":");if(!me&&!ue)l.value.value=A(Y).search(a.value);else{const le=x(a.value);l.value.value=A(Y).search({$or:le})}}),modelValue:a.value,"onUpdate:modelValue":j[4]||(j[4]=me=>a.value=me),clearable:""},null,8,["placeholder","disabled","modelValue"])])]),default:d(()=>[n(_a,{visible:!D.value&&a.value.length===0,accordion:""},{default:d(()=>[o("div",ewe,[o("div",twe,m(A(u)("Searching for")),1),o("div",awe,[(r(!0),h(H,null,ae(Q.value,me=>{var ue;return r(),h("div",{key:me.key,onClick:le=>V(me),class:de(["fct-global-searching-suggestion",((ue=D.value)==null?void 0:ue.key)===me.key?"active":""])},m(me.title),11,lwe)}),128))])])]),_:1},8,["visible"]),T.value?(r(),E(q0e,{key:0,ref_key:"remoteResultRef",ref:X,query:a.value,tag:D.value,onCloseModal:I,onOnRemoteSearchStateChange:z},null,8,["query","tag"])):(r(),E(A0e,{key:1,ref_key:"resultListRef",ref:F,query:a.value,"search-results":l.value.value,onActionPerformed:I,focusInput:$,searchData:A(Wr)},null,8,["query","search-results","searchData"])),o("div",swe,[o("ul",nwe,[o("li",null,[o("span",owe,[n(J,{name:"ArrowUp"})]),o("span",iwe,[n(J,{name:"ArrowDown"})]),o("span",rwe,m(A(u)("To navigate")),1)]),o("li",null,[o("span",dwe,[n(J,{name:"Enter"})]),o("span",uwe,m(A(u)("To select")),1)]),o("li",null,[j[7]||(j[7]=o("kbd",{class:"command-key"},"esc",-1)),o("span",cwe,m(A(u)("To close")),1)])])])]),_:1},8,["modelValue"])],64)}}},pwe={class:"fl_app fluent-cart-admin-pages"},fwe=Object.assign({name:"DashboardApplication"},{__name:"Application",setup(e){const t=M("");Ee(()=>{jQuery(".notice:not(.fluent-cart), .error:not(.fluent-cart), #ehp-admin-cb").remove(),t.value=a(),l.value=!!document.getElementById("theme-button-container");const c=document.querySelector(".fct_admin_menu_wrap"),p=()=>{window.scrollY>10?c==null||c.classList.add("scroll-header"):c==null||c.classList.remove("scroll-header")};window.addEventListener("scroll",p)});const a=()=>window.location.href,l=M(!1),s=nl();ye(()=>s.fullPath,()=>{t.value=a()});const i=N(()=>!(s.fullPath.includes("reports")||s.fullPath.includes("settings")));return(c,p)=>{const f=C("router-view");return r(),h("div",null,[n(Awe),i.value?(r(),E(Ia,{key:0})):B("",!0),o("div",pwe,[n(f)]),l.value?(r(),E(li,{key:1,to:"#theme-button-container"},[n(abe)])):B("",!0)])}}});let $c=!1;function mwe(e){return{data:function(){return{appVars:window.fluentCartAdminApp}},methods:{$get:ce.get,$post:ce.post,$put:ce.put,$del:ce.delete,$t:u,$n:Fo,formatMoney(t,a,l=!1){return!t&&l?"":(t||(t="0.00"),je.get("shop.currency_sign")+" "+t)},formatCents(t,a,l=!1){return!t&&l?"":(t?t=(t*100).toFixed(2):t="0.00",a?(t=new Intl.NumberFormat("en-US").format(t),je.get("shop.currency_sign")+" "+t):t)},formatNumber(t,a=!0,l=!1,s){return pt.formatNumber(t,a,l,s)},formatNumberForOrder(t,a,l=!0,s=!1){return pt.formatForOrder(t,a,l,s)},getAddress(t,a="billing"){let l=[t[a+"_address_1"],t[a+"_address_2"],t[a+"_city"],t[a+"_city"],t[a+"_state"],t[a+"_zip"],t[a+"_country"]];return l=l.filter(s=>!!s).join(", "),l||"no "+a+" address"},getOrderAddress(t,a="billing",l=!1){return fm(t,a,l)},changeTitle(t){jQuery("head title").text(t+" - FluentCart")},handleError(t){if(!t)return;let a="";typeof t=="string"?a=t:t&&t.message?a=t.message:a=t,typeof t=="object"&&(a=this.convertToText(t)),a||(a="Something is wrong!"),this.$notify({type:"error",title:"Error",message:a,dangerouslyUseHTMLString:!0})},convertToText(t){const a=[];if(typeof t=="object"&&t.join===void 0)for(const l in t)a.push(this.convertToText(t[l]));else if(typeof t=="object"&&t.join!==void 0)for(const l in t)a.push(this.convertToText(t[l]));else typeof t=="function"||typeof t=="string"&&a.push(t);return a.join("
")},handleSuccess:t=>{q.success(t)},handleMessage:(t,a="info",l=40,s=1e3)=>{Tc.show(t,a,l,s)},Storage:()=>Dt,buildFormRendererValue(t,a){let l={};return Object.keys(t).forEach(s=>{let i=t[s];["grid"].includes(i.type??"")?l[s]=this.buildFormRendererValue(i.schema??{},a[s]??{}):l[s]=a[s]??""}),l},registerCopyAction(){$c||($c=!0,document.addEventListener("click",t=>{t.target.matches(".copyable-content")&&Zl.copy(t.target.textContent)}))},currencySign(){return je.get("shop.currency_sign")},getPlaceholderImage(){return ms.getUrl("images/placeholder.svg")},saveLocal(t,a){Dt.set(t,a)},getLocal(t){return Dt.get(t)},hasPermission(t){return In.hasPermission(t)}}}}function hwe(e){e.beforeEach((t,a,l)=>{const s=rt.get(t,"meta.permission");return s?In.resolve({permission:s,permissionType:rt.get(t,"meta.permissionType")})?l():l({name:"unauthorized"}):(je.get("app_config.env"),l())})}function _we(e){const t={fluent_cart_products:["fluent_cart_inventory","fluent_cart_attributes"]},a=l=>{if(!l)return;const s="fluent_cart_"+l;Object.entries(t).forEach(([i,c])=>{const p=s===i;c.forEach(f=>{const _=jQuery(".toplevel_page_fluent-cart li."+f);p?_.show():_.hide()})})};e.afterEach((l,s)=>{const i=l.meta.active_menu;jQuery(".fct_menu li").removeClass("active_admin_menu"),jQuery(".fct_menu li.fct_menu_item_"+i).addClass("active_admin_menu"),jQuery(".toplevel_page_fluent-cart li").removeClass("current"),jQuery(".toplevel_page_fluent-cart li.fluent_cart_"+i).addClass("current"),a(i),l.meta.title&&jQuery("head title").text(l.meta.title+" - FluentCart")})}const vwe={mounted(e,t){const a=t.value,l=1e3,s=0,i=performance.now(),c=()=>{const p=performance.now()-i,f=Math.min(p/l,1),_=(s+f*(a-s)).toFixed(2);e.textContent=_,f<1&&requestAnimationFrame(c)};c()},updated(e,t){const a=t.value,l=2e3,s=0,i=performance.now(),c=()=>{const p=performance.now()-i,f=Math.min(p/l,1),_=(s+f*(a-s)).toFixed(2);e.textContent=_,f<1&&requestAnimationFrame(c)};c()}},gwe={__name:"Unauthorized",setup(e){return(t,a)=>(r(),h("span",null,m(A(u)("You are not allowed")),1))}},ywe=window.fluent_cart_admin.hooks.applyFilters("fluent_cart_routes",Zye);let Ec=!1;document.addEventListener("fcart_renew_rest_nonce",function(e){Ec||Fl.alert(u("Your session has expired due to inactivity. Please refresh the page to continue."),u("Session Expired"),{confirmButtonText:u("Reload"),callback:t=>{Ec=!1,window.location.reload()}})});const bwe=[Wf,Jf,Xf,Lc,Zf,ed,em,tm,ni,am,lm,Oc],zl=Of(fwe);zl.config.globalProperties.appVars=je.get();zl.provide("appVars",je.get());zl.mixin(mwe());zl.directive("loading",gm);zl.directive("animate",vwe);Fm(zl);const Dd=Hf({routes:[...Object.values(ywe),{path:"/unauthorized",name:"unauthorized",component:gwe,props:!0},{path:"/:path(.*)*",name:"NotFound",component:ri,props:!0}],history:Pf(),scrollBehavior(e,t,a){return a||{top:0,behavior:"smooth"}}});zl.use(Dd);hwe(Dd);_we(Dd);bwe.forEach(e=>{zl.component(e.name,e)});const Vd=je.get("el_strings"),Sf=je.get("datei18");Vd.el.datepicker.weeks=Sf.weekdaysShort;Vd.el.datepicker.months=Sf.monthsShort;zl.use(ym,{locale:Vd});zl.mount("#fluent_cart_plugin_app");if(je.get("has_data_migrations")){let e=0;const t=()=>{ce.post("data-backfills/run").then(a=>{a&&a.status==="running"&&++e<100&&t()}).catch(()=>{})};t()}export{Kn as E};