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