import{d as N,i as t,s as u,m as k,v as l,n as i,A as c,q as $,M as x,z as m,u as P,x as z,y as V,N as D}from"../../../../common/index.CPcBO1Os.js";import{B as I}from"../../../../common/index.B1jVoQr7.js";import{_ as M}from"../../../../common/_plugin-vue_export-helper.DlAUqK2U.js";import"../../../../common/index.TkDYtvUB.js";import"../../../../common/index.B91jMiUk.js";import"../../../../common/_getTag.5j88QV3u.js";import"../../../../common/useState.DXwtWea_.js";import"../../../../common/devWarning.DpJYEIzv.js";import"../../../../common/compact-item.BK6dH04p.js";import"../../../../common/Compact.B3btkLRg.js";const S={class:"saai-usage-bar-wrap"},T=["aria-valuenow","aria-label"],j={class:"saai-usage-label"},q=["href"],A=N({__name:"UsageIndicator",setup(E){const{__:o,sprintf:n}=window.wp.i18n,s=t(()=>u().usageData),p=t(()=>u().usageBarUpgradeUrl),y=t(()=>u().isConnected),r=t(()=>{var e,a;return(a=(e=s.value)==null?void 0:e.percentage)!=null?a:0}),U=t(()=>{var e,a;return(a=(e=s.value)==null?void 0:e.used)!=null?a:0}),v=t(()=>{var e,a;return(a=(e=s.value)==null?void 0:e.limit)!=null?a:0}),d=t(()=>{var e,a;return(a=(e=s.value)==null?void 0:e.resource)!=null?a:""}),g=t(()=>{var e,a;return(a=(e=s.value)==null?void 0:e.nextPlanName)!=null?a:""}),B=t(()=>y.value&&d.value&&v.value>0),f=t(()=>{const e=r.value;return e>=90?"#ff4d4f":e>=75?"#fa8c16":e>=50?"#faad14":"#52c41a"}),_=t(()=>{const e=r.value,a=n(o("%1$s/%2$s %3$s used","storeagent-ai-for-woocommerce"),U.value,v.value,d.value);return e>=100?g.value?o("Plan paused — upgrade to continue","storeagent-ai-for-woocommerce"):o("Plan paused — contact support to continue","storeagent-ai-for-woocommerce"):e>=90?n(o("%s — almost out!","storeagent-ai-for-woocommerce"),a):e>=75?n(o("%s — running low","storeagent-ai-for-woocommerce"),a):a}),w=t(()=>r.value>=50&&g.value),b=t(()=>r.value>=75?"".concat(o("Upgrade now","storeagent-ai-for-woocommerce")," →"):"".concat(o("Upgrade for more","storeagent-ai-for-woocommerce")," →")),h=t(()=>r.value>=90),C=t(()=>r.value>=100);return(e,a)=>B.value?(i(),k("div",{key:0,class:D(["saai-usage-indicator",{"is-pulsing":C.value}])},[c("div",S,[c("div",{class:"saai-usage-bar",role:"progressbar","aria-valuenow":r.value,"aria-valuemin":"0","aria-valuemax":"100","aria-label":_.value,style:x({width:"".concat(Math.min(r.value,100),"%"),backgroundColor:f.value})},null,12,T)]),c("span",j,m(_.value),1),w.value&&!h.value?(i(),k("a",{key:0,href:p.value,target:"_blank",class:"saai-usage-upgrade-link",style:x({color:f.value})},m(b.value),13,q)):l("",!0),w.value&&h.value?(i(),$(P(I),{key:1,type:"primary",size:"small",danger:"",href:p.value,target:"_blank",class:"saai-usage-upgrade-btn"},{default:z(()=>[V(m(b.value),1)]),_:1},8,["href"])):l("",!0)],2)):l("",!0)}}),X=M(A,[["__scopeId","data-v-0222c73f"]]);export{X as default};
