import{b as D,_ as S,x as C,Z as k,$ as E,a as U,r as w,d as O,G as T,e as $,o as B,f as I,w as t,c as a,i as h,t as y,j as A,bk as q,a1 as N,n as V,v as F,a0 as M,a8 as R,B as j,al as G}from"./app-DGDivIsO.js";import{a as H}from"./apiAdmin-D4J8O5cP.js";import{U as K}from"./Upload-DinpFMlS.js";import{S as L}from"./SaveOutlined-saF8VQQc.js";const Y=()=>{const e="categories",{t:l}=D(),p=["parent_id"],g={name:"",slug:"",image:void 0,image_url:void 0,parent_id:null},i=[{title:l("category.name"),dataIndex:"name"},{title:l("category.logo"),dataIndex:"image_url"},{title:l("common.action"),dataIndex:"action"}];return{hashableColumns:p,addEditUrl:e,initData:g,columns:i}},P=C({props:["formData","data","visible","url","addEditType"],components:{PlusOutlined:k,LoadingOutlined:E,SaveOutlined:L,Upload:K},setup(e,{emit:l}){const{addEditRequestAdmin:p,loading:g,rules:i}=H(),{getRecursiveCategories:b,slugify:f}=U(),{t:s}=D(),u=w([]),d=(o=null)=>{var r="categories?fields=id,xid,name,parent_id,x_parent_id&limit=10000";o!=null&&(r+=`&filters=id ne ${o}&hashable=${o}`),axiosAdmin.get(r).then(m=>{u.value=b(m,o)})},c=O(()=>e.addEditType=="add"?s("category.add"):s("category.edit")),_=()=>{var o={parent_id:null,...e.formData};const r=e.addEditType=="add"?s("category.created"):s("category.updated");p({url:e.url,data:o,successMessage:r,success:m=>{d(),l("addEditSuccess",m.xid)}})},v=()=>{i.value={},l("closed")};return T(e,(o,r)=>{o.addEditType=="add"?d():d(o.data.xid)}),{loading:g,rules:i,onClose:v,onSubmit:_,pageTitle:c,allCategories:u,slugify:f}}}),Z={class:"small-text-message"};function z(e,l,p,g,i,b){const f=q,s=N,u=V,d=F,c=M,_=$("Upload"),v=R,o=$("SaveOutlined"),r=j,m=G;return B(),I(m,{open:e.visible,closable:!1,centered:!0,title:e.pageTitle,onOk:e.onSubmit},{footer:t(()=>[a(r,{key:"submit",type:"primary",loading:e.loading,onClick:e.onSubmit},{icon:t(()=>[a(o)]),default:t(()=>[h(" "+y(e.addEditType=="add"?e.$t("common.create"):e.$t("common.update")),1)]),_:1},8,["loading","onClick"]),a(r,{key:"back",onClick:e.onClose},{default:t(()=>[h(y(e.$t("common.cancel")),1)]),_:1},8,["onClick"])]),default:t(()=>[a(v,{layout:"vertical"},{default:t(()=>[a(d,{gutter:16},{default:t(()=>[a(u,{xs:24,sm:24,md:24,lg:24},{default:t(()=>[a(s,{label:e.$t("category.parent_category"),name:"parent_id",help:e.rules.parent_id?e.rules.parent_id.message:null,validateStatus:e.rules.parent_id?"error":null},{default:t(()=>[a(f,{value:e.formData.parent_id,"onUpdate:value":l[0]||(l[0]=n=>e.formData.parent_id=n),"show-search":"",style:{width:"100%"},"dropdown-style":{maxHeight:"400px",overflow:"auto"},placeholder:e.$t("common.select_default_text",[e.$t("category.category")]),"tree-data":e.allCategories,"allow-clear":"","tree-default-expand-all":""},null,8,["value","placeholder","tree-data"]),A("small",Z,y(e.$t("messages.leave_blank_to_create_parent_category")),1)]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1}),a(d,{gutter:16},{default:t(()=>[a(u,{xs:24,sm:24,md:24,lg:24},{default:t(()=>[a(s,{label:e.$t("category.name"),name:"name",help:e.rules.name?e.rules.name.message:null,validateStatus:e.rules.name?"error":null,class:"required"},{default:t(()=>[a(c,{value:e.formData.name,"onUpdate:value":l[1]||(l[1]=n=>e.formData.name=n),placeholder:e.$t("common.placeholder_default_text",[e.$t("category.name")]),onKeyup:l[2]||(l[2]=n=>e.formData.slug=e.slugify(n.target.value))},null,8,["value","placeholder"])]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1}),a(d,{gutter:16},{default:t(()=>[a(u,{xs:24,sm:24,md:24,lg:24},{default:t(()=>[a(s,{label:e.$t("category.slug"),name:"slug",help:e.rules.slug?e.rules.slug.message:null,validateStatus:e.rules.slug?"error":null,class:"required"},{default:t(()=>[a(c,{value:e.formData.slug,"onUpdate:value":l[3]||(l[3]=n=>e.formData.slug=n),placeholder:e.$t("common.placeholder_default_text",[e.$t("category.slug")])},null,8,["value","placeholder"])]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1}),a(d,{gutter:16},{default:t(()=>[a(u,{xs:24,sm:24,md:24,lg:24},{default:t(()=>[a(s,{label:e.$t("category.logo"),name:"image",help:e.rules.image?e.rules.image.message:null,validateStatus:e.rules.image?"error":null},{default:t(()=>[a(_,{formData:e.formData,folder:"category",onOnFileUploaded:l[4]||(l[4]=n=>{e.formData.image=n.file,e.formData.image_url=n.file_url})},null,8,["formData"])]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1})]),_:1})]),_:1},8,["open","title","onOk"])}const x=S(P,[["render",z]]);export{x as A,Y as f};
