1import{r as a,_ as C,u as D,j as e}from"./vendor-react-547455f2.js";import{b as B}from"./index-fb32e9a3.js";import{B as E}from"./Breadcrumb-0cf358b1.js";import{V as c,g as F,B as v,ad as O}from"./vendor-ui-d9311857.js";import{w as _}from"./wordpressSites-0f8e55bc.js";import{S as R}from"./SkeletonLoader-fa890f78.js";import"./vendor-router-fe73b9f8.js";import"./api-ef87b1f4.js";const A=a.lazy(()=>C(()=>import("./WordpressSitesList-d8527728.js"),["assets/WordpressSitesList-d8527728.js","assets/vendor-react-547455f2.js","assets/vendor-ui-d9311857.js"])),V=a.lazy(()=>C(()=>import("./CreateWordpressSiteModal-7c5ce8f3.js"),["assets/CreateWordpressSiteModal-7c5ce8f3.js","assets/vendor-react-547455f2.js","assets/vendor-ui-d9311857.js","assets/ModalShell-06818b59.js","assets/wordpressSites-0f8e55bc.js","assets/api-ef87b1f4.js","assets/index-fb32e9a3.js","assets/vendor-router-fe73b9f8.js","assets/index-1c962688.css","assets/ImageUpload-2d6b8322.js"])),Q=()=>{const{t}=D(),{selectedRadio:o}=B(),[g,b]=a.useState([]),[u,h]=a.useState(!0),[k,f]=a.useState(!1),[w,j]=a.useState(!1),[l,x]=a.useState(null),[p,y]=a.useState(null),N=o?[{name:o.name,to:"/dashboard"},{name:t("wordpressPage.breadcrumb"),to:"/wordpress"}]:[{name:t("wordpressPage.breadcrumb"),to:"/wordpress"}],W=s=>{var P,S;if(((P=s==null?void 0:s.response)==null?void 0:P.status)===429)return t("wordpressPage.errors.rateLimit");const r=(S=s==null?void 0:s.response)==null?void 0:S.data,d=(typeof(r==null?void 0:r.message)=="string"&&r.message||typeof(r==null?void 0:r.error)=="string"&&r.error||typeof(s==null?void 0:s.message)=="string"&&s.message||"").trim();return d?d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]")?t("wordpressPage.errors.unexpected"):d:t("wordpressPage.messages.loadError")};a.useEffect(()=>{o&&n()},[o]);const n=async()=>{if(o)try{h(!0),y(null);const s=await _.getAll(o.id);b(s.sites)}catch(s){console.error("Error loading WordPress sites:",s),c.error(t("wordpressPage.messages.loadError")),b([]),y(W(s))}finally{h(!1)}},L=async()=>{f(!0),await n(),f(!1),c.success(t("wordpressPage.messages.listUpdated"))},M=s=>
1{x(s)},I=async s=>{var i,r;if(confirm(t("wordpressPage.prompts.confirmDelete",{name:s.name})))try{await _.delete(s.id),c.success(t("wordpressPage.messages.deleteSuccess")),await n()}catch(m){console.error("Error deleting site:",m),c.error(((r=(i=m.response)==null?void 0:i.data)==null?void 0:r.message)||t("wordpressPage.messages.deleteError"))}},z=()=>{n()};return o?e.jsxs(e.Fragment,{children:[e.jsx(E,{crumbs:N}),e.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-4 rounded-[22px] border border-stroke bg-white px-5 py-4 dark:border-strokedark dark:bg-boxdark sm:px-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.14em] text-body/70 dark:text-bodydark/60",children:"Metadados"}),e.jsx("h1",{className:"truncate text-xl font-extrabold tracking-tight text-black dark:text-white",children:t("wordpressPage.title")}),e.jsx("p",{className:"mt-0.5 text-[12.5px] text-body dark:text-bodydark",children:t("wordpressPage.subtitle")})]}),e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:L,disabled:k,className:"inline-flex items-center gap-2 rounded-full border border-stroke px-4 py-2 text-sm font-semibold text-black transition hover:bg-gray disabled:opacity-50 dark:border-strokedark dark:text-white dark:hover:bg-white/8",children:[e.jsx(v,{size:14,className:k?"animate-spin":""}),t("wordpressPage.actions.refresh")]}),e.jsxs("button",{onClick:()=>j(!0),className:"inline-flex items-center gap-2 rounded-full bg-primary px-5 py-2 text-sm font-bold text-white shadow-[0_6px_16px_-6px_rgba(253,65,4,0.55)] transition hover:brightness-105",children:[e.jsx(O,{size:15}),t("wordpressPage.actions.createSite")]})]})]}),e.jsx("div",{className:"rounded-[22px] border border-stroke bg-white p-5 dark:border-strokedark dark:bg-boxdark sm:p-6",children:u?e.jsx(R,{type:"list",count:3,className:"py-4"}):p?e.jsxs("div",{className:"rounded-xl border border-ds-status-danger/30 bg-ds-status-danger/10 p-6",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.14em] text-ds-status-danger",children:"Erro"}),e.jsx("h3",{className:"mt-0.5 text-[15.5px] font-bold text-black dark:text-white",children:t("wordpressPage.errors.title")}),e.jsx("p",{className:"mt-2 text-sm text-body dark:text-bodydark",children:p}),e.jsx("div",{className:"mt-4",children:e.jsxs("button",{onClick:n,className:"inline-flex items-center gap-2 rounded-full bg-ds-status-danger px-5 py-2 text-sm font-bold text-white transition hover:brightness-105",children:[e.jsx(v,{size:14}),t("wordpressPage.errors.retry")]})})]}):e.jsx(a.Suspense,{fallback:e.jsx(R,{type:"list",count:3,className:"py-4"}),children:e.jsx(A,{sites:g,onEdit:M,onDelete:I})})}),!u&&!p&&g.length===0&&e.jsxs("section",{className:"mt-5 rounded-[22px] border border-stroke bg-white p-5 dark:border-strokedark dark:bg-boxdark sm:p-6",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.14em] text-body/70 dark:text-bodydark/60",children:"Ajuda"}),e.jsx("h3",{className:"mt-0.5 text-[15.5px] font-bold text-black dark:text-white",children:t("wordpressPage.howItWorks.title")}),e.jsx("ul",{className:"mt-4 space-y-2 text-sm text-body dark:text-bodydark",children:["step1","step2","step3","step4"].map((s,i)=>e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsxs("span",{className:"font-mono text-[11px] font-bold tabular-nums text-primary",children:[i+1,"."]}),e.jsx("span",{children:t(`wordpressPage.howItWorks.${s}`)})]},s))})]}),(w||l)&&e.jsx(a.Suspense,{fallback:null,children:e.jsx(V,{isOpen:w||!!l,onClose:()=>{j(!1),x(null)},onSuccess:()=>{x(null),z()},radioId:o.id,isEditing:!!l,initialData:l??void 0})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{crumbs:N}),e.jsxs("div",{className:"rounded-[22px] border border-stroke bg-white p-10 text-center dark:border-strokedark dark:bg-boxdark",children:[e.jsx("h2",{className:"text-xl font-extrabold tracking-tight text-black dark:text-white",children:t("wordpressPage.noRadio.title")}),e.jsx("p",{className:"mt-1 text-sm text-body dark:text-bodydark",children:t("wordpressPage.noRadio.description")}),e.jsxs("p",{className:"mt-4 inline-flex items-center justify-center gap-2 font-mono text-[10px] uppercase tracking-[0.12em] text-body/70 dark:text-bodydark/60",children:[e.jsx(F,{size:14}),t("wordpressPage.noRadio.hint")]})]})]})};export{Q as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.