import{u as w,b4 as i,e as v,a as h,V as x,ai as b,be as D,n as $,L as k,bf as F}from"./BxiWQxwE.js";import{C as N}from"./Ci7sx34z.js";function P(a){return a==="/"?a:a.endsWith("/")?a.slice(0,-1):a}function R(){const a=x(),f=w(),n=i("SwCloudCategory",()=>null),d=i("SwCloudCategoryId",()=>null),r=i("SwCloudCustomData",()=>({})),g=async t=>{const s=["isSnakeware","category","ms"],e=await k().getPage(t);if(!e)return{status:404,message:"Not found"};n.value=e.category,d.value=e.category.id;const o=Object.keys(e).filter(u=>!s.includes(u)),l={};for(const u of o){const c=e;l[u]=c[u]}return r.value=l,{status:200,message:"succes",data:e.category}},C=async(t=null)=>{var m;const s=h(),{excludedUrls:e}=a.public.swCloud;let o=t??P(f.path);if(b(o,e)){n.value=null;return}s.$i18n&&(o=o.replace(`/${(m=s.$i18n.locale)==null?void 0:m.value}`,""));const{status:u,redirectUrl:c,data:p}=await g(o);if(u===301&&c){const S=D(c);await $(S,{})}return p},y=v(()=>{const t=F(n.value);return N.create(t??{})});return{categoryState:n,categoryIdState:d,category:y,fetchCategory:g,loadCategory:C,getCustomData:t=>Object.keys(r.value).includes(t)?r.value[t]:{},getSectionByName:t=>y.value.sections.find(s=>s.name===t)}}export{R as u};
