import{s as i}from"./main-few-lands-burn.js";const r=async e=>i("wordpress-core/get-posts",{postType:e}),l=()=>i("wordpress-core/get-post-types"),c=()=>i("wordpress-core/get-user-roles"),u=()=>i("wordpress-core/get-users"),g=()=>i("wordpress-core/get-generated-password"),d=()=>i("wordpress-core/get-post-tags"),f=()=>i("wordpress-core/get-taxonomies"),m=()=>i("wordpress-core/get-post-category"),p=e=>i("wordpress-core/get-term-by-taxonomy",e),C=async e=>{e.setComponent("post-type",t=>{t.loading=!0});const{data:n,status:o}=await l();if(o==="error"){e.setComponent("post-type",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=JSON.stringify(n))}),console.error("Failed to fetch post types");return}e.setComponent("post-type",t=>{e.util.isSelectComponent(t)&&(t.options=n,t.loading=!1,t.status=void 0)})},w=async e=>{e.setComponent("post-id",s=>{s.loading=!0});const n=e.getComponent("post-type")?.value,{data:o,status:t}=await r(n);if(t==="error"){e.setComponent("post-id",s=>{e.util.isSelectComponent(s)&&(s.status=t,s.loading=!1,s.invalidMessage=JSON.stringify(o))}),console.error("Failed to fetch posts");return}e.setComponent("post-id",s=>{e.util.isSelectComponent(s)&&(s.options=o,s.loading=!1,s.status=void 0)})},S=async e=>{e.setComponent("user-role",t=>{t.loading=!0});const{data:n,status:o}=await c();if(o==="error"){e.setComponent("user-role",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=JSON.stringify(n))}),console.error("Failed to fetch user roles");return}e.setComponent("user-role",t=>{e.util.isSelectComponent(t)&&(t.options=n,t.loading=!1)})},h=async e=>{e.setComponent("generate-password",s=>{s.loading=!0});const{data:n,status:o}=await g();if(o==="error"){e.setComponent("generate-password",s=>{e.util.isMixInputComponent(s)&&(s.loading=!1,s.invalidMessage=JSON.stringify(n))}),console.error("Failed to generate password");return}const t=[{type:"string",value:n}];e.setComponent("password",s=>{e.util.isMixInputComponent(s)&&(s.value=t)}),e.setComponent("generate-password",s=>{s.loading=!1}),e.setDb(s=>{s.password=t})},x=async e=>{e.setComponent("user",t=>{t.loading=!0});const{data:n,status:o}=await u();if(o==="error"){e.setComponent("user",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=JSON.stringify(n))}),console.error("Failed to fetch users");return}e.setComponent("user",t=>{e.util.isSelectComponent(t)&&(t.options=n,t.loading=!1)})},T=async e=>{e.setComponent("tags",t=>{t.loading=!0});const{data:n,status:o}=await d();if(o==="error"){e.setComponent("tags",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=JSON.stringify(n))}),console.error("Failed to fetch Post tags");return}e.setComponent("tags",t=>{e.util.isSelectComponent(t)&&(t.options=n,t.loading=!1)})},M=async e=>{e.setComponent("taxonomy",t=>{t.loading=!0});const{data:n,status:o}=await f();if(o==="error"){e.setComponent("taxonomy",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=JSON.stringify(n))}),console.error("Failed to fetch Taxonomy");return}e.setComponent("taxonomy",t=>{e.util.isSelectComponent(t)&&(t.options=n,t.loading=!1)})},P=async({$:e,e:n})=>{const o=n||e.db?.taxonomy;if(!o)return;e.setComponent("terms",a=>{a.loading=!0});const{data:t,status:s}=await p({taxonomy:o});if(s==="error"){e.setComponent("terms",a=>{e.util.isSelectComponent(a)&&(a.status=s,a.loading=!1,a.invalidMessage=JSON.stringify(t))}),console.error("Failed to fetch terms");return}e.setComponent("terms",a=>{e.util.isSelectComponent(a)&&(a.options=t,a.loading=!1)})},F=async e=>{e.setComponent("post-category",t=>{t.loading=!0});const{data:n,status:o}=await m();if(o==="error"){e.setComponent("post-category",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=JSON.stringify(n))}),console.error("Failed to fetch post category");return}e.setComponent("post-category",t=>{e.util.isSelectComponent(t)&&(t.options=n,t.loading=!1)})};export{F as a,T as b,P as c,M as d,C as e,S as f,x as g,h,w as i};
