(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{8312:function(e,s,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return a(1805)}])},1805:function(e,s,a){"use strict";a.r(s),a.d(s,{default:function(){return v}});var t=a(5893),r=a(7294),l=a(6072),i=a(3454),n=e=>{let{onSubmit:s,loading:a}=e,[l,n]=(0,r.useState)("c54a15cb-0f09-4508-9c61-662b4f3cc466"),o=i.env.NEXT_PUBLIC_API_KEY||"",d=i.env.NEXT_PUBLIC_CSRF_TOKEN||"";return(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),s(l,o,d)},className:"space-y-6",children:[(0,t.jsx)("div",{className:"grid grid-cols-1 gap-6",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"accountId",className:"block text-sm font-medium text-gray-700 mb-2",children:"Account ID"}),(0,t.jsx)("input",{type:"text",id:"accountId",name:"accountId",value:l,onChange:e=>{n(e.target.value)},className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500",placeholder:"Ingresa el ID de la cuenta",required:!0})]})}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)("button",{type:"submit",disabled:a,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed",children:a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,t.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Consultando..."]}):"Consultar API"})})]})};let o=e=>{let{value:s,keyName:a}=e;if(null==s)return(0,t.jsx)("span",{className:"text-gray-400 italic",children:"No especificado"});if("boolean"==typeof s)return a.toLowerCase().includes("toggle")||a.toLowerCase().includes("switch")?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${s?"bg-cyan-600":"bg-gray-300"}`,children:(0,t.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${s?"translate-x-6":"translate-x-1"}`})}),(0,t.jsx)("span",{className:`text-sm font-medium ${s?"text-cyan-800":"text-gray-600"}`,children:s?"Activado":"Desactivado"})]}):(0,t.jsx)("span",{className:`px-2 py-1 rounded text-sm font-medium ${s?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:s?"S\xed":"No"});if("number"==typeof s)return(0,t.jsx)("span",{className:"px-2 py-1 bg-blue-50 text-blue-800 rounded text-sm font-mono",children:s.toLocaleString()});if("object"==typeof s){if("metadata"===a.toLowerCase()&&s.palette)return(0,t.jsx)(o,{value:s.palette,keyName:"palette"});if(Array.isArray(s))return 0===s.length?(0,t.jsx)("span",{className:"text-gray-400 italic",children:"Lista vac\xeda"}):a.toLowerCase().includes("palette")||s.every(e=>"string"==typeof e?/^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{3}$/.test(e):"object"==typeof e&&null!==e&&e.value&&"string"==typeof e.value&&/^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{3}$/.test(e.value))?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-600",children:[(0,t.jsx)("span",{children:"\uD83C\uDFA8"}),(0,t.jsx)("span",{children:"Paleta de Colores"}),(0,t.jsxs)("span",{className:"text-xs bg-purple-100 text-purple-700 px-2 py-1 rounded",children:[s.length," colores"]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:s.map((e,s)=>{let a="string"==typeof e?e:e.value,r="object"==typeof e&&null!==e?e.label:null,l=!a||""===a;return(0,t.jsxs)("div",{className:"group relative",children:[(0,t.jsx)("div",{className:`w-full h-20 rounded-lg shadow-md border-2 hover:scale-105 transition-transform cursor-pointer ${l?"border-gray-300 bg-gray-100":"border-white"}`,style:{backgroundColor:l?"transparent":a},title:l?"Color vac\xedo":`${r||"Color"}: ${a}`,children:l&&(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-gray-400 text-xs",children:"Vac\xedo"})}),(0,t.jsxs)("div",{className:"mt-2 text-center",children:[r&&(0,t.jsx)("div",{className:"text-xs font-medium text-gray-700 truncate",children:r}),(0,t.jsx)("div",{className:"text-xs font-mono text-gray-500",children:l?"Sin color":a})]})]},s)})})]}):(0,t.jsx)("div",{className:"space-y-1",children:s.map((e,s)=>(0,t.jsx)("div",{className:"text-sm bg-gray-50 p-2 rounded border-l-2 border-gray-300",children:(0,t.jsx)(o,{value:e,keyName:`${a}_${s}`})},s))});if(a.toLowerCase().includes("palette")||Object.values(s).every(e=>"string"==typeof e&&/^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{3}$/.test(e))){let e=Object.entries(s).filter(e=>{let[,s]=e;return"string"==typeof s});return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-600",children:[(0,t.jsx)("span",{children:"\uD83C\uDFA8"}),(0,t.jsx)("span",{children:"Paleta de Colores"}),(0,t.jsxs)("span",{className:"text-xs bg-purple-100 text-purple-700 px-2 py-1 rounded",children:[e.length," colores"]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:e.map((e,s)=>{let[a,r]=e;return(0,t.jsxs)("div",{className:"group relative",children:[(0,t.jsx)("div",{className:"w-full h-16 rounded-lg shadow-md border-2 border-white hover:scale-105 transition-transform cursor-pointer",style:{backgroundColor:r},title:`${a}: ${r}`}),(0,t.jsxs)("div",{className:"mt-2 text-center",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-gray-700 truncate",children:a}),(0,t.jsx)("div",{className:"text-xs font-mono text-gray-500",children:r})]})]},s)})})]})}if(s.type&&(void 0!==s.label||s.id||s.placeholder)){let e=s.type.toLowerCase(),a=void 0!==s.fallback?s.fallback:s.value,r=s.label||s.placeholder||s.id||"Campo sin nombre",l="",i="border-gray-200";switch(e){case"text":case"string":l="\uD83D\uDCDD",i="border-blue-200";break;case"email":l="\uD83D\uDCE7",i="border-purple-200";break;case"number":case"integer":l="\uD83D\uDD22",i="border-green-200";break;case"boolean":case"checkbox":l="☑️",i="border-yellow-200";break;case"toggle":case"switch":l="\uD83D\uDD18",i="border-cyan-200";break;case"date":case"datetime":l="\uD83D\uDCC5",i="border-amber-200";break;case"url":l="\uD83D\uDD17",i="border-indigo-200";break;case"select":case"dropdown":l="\uD83D\uDCCB",i="border-teal-200";break;case"textarea":l="\uD83D\uDCC4",i="border-slate-200";break;case"file":case"upload":l="\uD83D\uDCCE",i="border-orange-200";break;case"icon-text":l="\uD83D\uDDBC️",i="border-pink-200";break;default:l="❓",i="border-gray-200"}return(0,t.jsxs)("div",{className:`border-l-4 ${i} pl-4 py-2 bg-white rounded-r`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-600 mb-1",children:[(0,t.jsx)("span",{children:l}),(0,t.jsx)("span",{children:r}),(0,t.jsx)("span",{className:"text-xs bg-gray-100 px-2 py-1 rounded",children:e}),s.optional&&(0,t.jsx)("span",{className:"text-xs bg-blue-100 text-blue-700 px-2 py-1 rounded",children:"Opcional"})]}),"icon-text"===e?(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[s.icon&&(0,t.jsx)("img",{src:s.icon,alt:s.placeholder||r,className:"w-6 h-6 rounded",onError:e=>{e.currentTarget.style.display="none"}}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)(o,{value:a||s.placeholder||"Sin valor",keyName:r}),s.placeholder&&a!==s.placeholder&&(0,t.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:["Placeholder: ",s.placeholder]})]})]}):(0,t.jsx)(o,{value:a,keyName:"toggle"===e||"switch"===e?`${r}_toggle`:r}),s.id&&(0,t.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:["ID: ",s.id]}),s.depends_on&&s.depends_on.length>0&&(0,t.jsxs)("div",{className:"text-xs text-amber-600 mt-1",children:["Depende de: ",s.depends_on.join(", ")]})]})}return(0,t.jsx)("pre",{className:"text-sm bg-gray-50 p-2 rounded overflow-auto max-h-32 border",children:JSON.stringify(s,null,2)})}let r=String(s);if(/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/.test(r))return(0,t.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline break-all",children:r});if(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return(0,t.jsx)("a",{href:`mailto:${r}`,className:"text-purple-600 hover:text-purple-800 underline",children:r});if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/.test(r)){let e=new Date(r);if(!isNaN(e.getTime()))return(0,t.jsx)("span",{className:"px-2 py-1 bg-amber-50 text-amber-800 rounded text-sm",children:e.toLocaleString("es-ES",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})}if(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(r)||a.toLowerCase().includes("id")&&r.length>10)return(0,t.jsx)("span",{className:"px-2 py-1 bg-gray-100 text-gray-700 rounded text-xs font-mono break-all",children:r});if(a.toLowerCase().includes("status")&&/^[1-5]\d{2}$/.test(r)){let e=parseInt(r),s="bg-gray-100 text-gray-800";return e>=200&&e<300?s="bg-green-100 text-green-800":e>=300&&e<400?s="bg-yellow-100 text-yellow-800":e>=400&&(s="bg-red-100 text-red-800"),(0,t.jsx)("span",{className:`px-2 py-1 rounded text-sm font-medium ${s}`,children:r})}return r.length>100?(0,t.jsxs)("div",{className:"text-sm",children:[(0,t.jsxs)("div",{className:"mb-2",children:[r.substring(0,100),"..."]}),(0,t.jsxs)("details",{className:"cursor-pointer",children:[(0,t.jsx)("summary",{className:"text-blue-600 hover:text-blue-800 text-xs",children:"Ver completo"}),(0,t.jsx)("div",{className:"mt-2 p-2 bg-gray-50 rounded border",children:r})]})]}):(0,t.jsx)("span",{className:"text-gray-800",children:r})};var d=e=>{let{formValues:s}=e,a=(e,s)=>{if(s&&"object"==typeof s&&s.type){let a=s.type.toLowerCase(),r=void 0!==s.value?s.value:s.default_value,l=s.label||e.replace(/_/g," "),i="";switch(a){case"text":case"string":i="\uD83D\uDCDD";break;case"email":i="\uD83D\uDCE7";break;case"number":case"integer":i="\uD83D\uDD22";break;case"boolean":case"checkbox":i="☑️";break;case"toggle":case"switch":i="\uD83D\uDD18";break;case"date":case"datetime":i="\uD83D\uDCC5";break;case"url":i="\uD83D\uDD17";break;case"select":case"dropdown":i="\uD83D\uDCCB";break;case"textarea":i="\uD83D\uDCC4";break;case"file":case"upload":i="\uD83D\uDCCE";break;case"icon-text":i="\uD83D\uDDBC️";break;default:i="❓"}return(0,t.jsx)("div",{className:"bg-gray-50 rounded-lg p-4 hover:bg-gray-100 transition-colors duration-200",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-white rounded-full flex items-center justify-center shadow-sm",children:(0,t.jsx)("span",{className:"text-sm",children:i})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,t.jsx)("h4",{className:"text-sm font-semibold text-gray-800 truncate",children:l}),(0,t.jsx)("span",{className:"text-xs bg-white px-2 py-0.5 rounded-full text-gray-600 border",children:a}),s.required&&(0,t.jsx)("span",{className:"text-xs text-red-500 font-medium",children:"*"})]}),(0,t.jsx)("div",{className:"text-gray-900 mb-1",children:(0,t.jsx)(o,{value:r,keyName:"toggle"===a||"switch"===a?`${l}_toggle`:e})}),s.description&&(0,t.jsx)("p",{className:"text-xs text-gray-500 leading-relaxed",children:s.description})]})]})},e)}return s&&"object"==typeof s&&s.label&&void 0!==s.value?(0,t.jsx)("div",{className:"bg-gray-50 rounded-lg p-4 hover:bg-gray-100 transition-colors duration-200",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-white rounded-full flex items-center justify-center shadow-sm",children:(0,t.jsx)("span",{className:"text-sm",children:"\uD83D\uDCCB"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h4",{className:"text-sm font-semibold text-gray-800 mb-1",children:s.label}),(0,t.jsx)("div",{className:"text-gray-900",children:(0,t.jsx)(o,{value:s.value,keyName:e})})]})]})},e):Array.isArray(s)?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 bg-blue-100 rounded-full flex items-center justify-center",children:(0,t.jsx)("span",{className:"text-xs",children:"\uD83D\uDCCB"})}),(0,t.jsx)("h4",{className:"text-sm font-semibold text-gray-700",children:e.replace(/_/g," ")})]}),s.map((s,a)=>s&&"object"==typeof s&&s.label&&void 0!==s.value?(0,t.jsx)("div",{className:"bg-gray-50 rounded-lg p-3 hover:bg-gray-100 transition-colors duration-200",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"flex-shrink-0 w-6 h-6 bg-white rounded-full flex items-center justify-center shadow-sm",children:(0,t.jsx)("span",{className:"text-xs",children:"\uD83D\uDCC4"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h5",{className:"text-sm font-medium text-gray-800 mb-1",children:s.label}),(0,t.jsx)("div",{className:"text-gray-900",children:(0,t.jsx)(o,{value:s.value,keyName:`${e}_${a}`})})]})]})},a):(0,t.jsx)("div",{className:"bg-gray-50 rounded-lg p-3 hover:bg-gray-100 transition-colors duration-200",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"flex-shrink-0 w-6 h-6 bg-white rounded-full flex items-center justify-center shadow-sm",children:(0,t.jsx)("span",{className:"text-xs",children:"\uD83D\uDCDD"})}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)("div",{className:"text-gray-900",children:(0,t.jsx)(o,{value:s,keyName:`${e}_${a}`})})})]})},a))]},e):(0,t.jsx)("div",{className:"bg-gray-50 rounded-lg p-4 hover:bg-gray-100 transition-colors duration-200",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-white rounded-full flex items-center justify-center shadow-sm",children:(0,t.jsx)("span",{className:"text-sm",children:"\uD83D\uDCDD"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h4",{className:"text-sm font-semibold text-gray-800 mb-1",children:e.replace(/_/g," ")}),(0,t.jsx)("div",{className:"text-gray-900",children:(0,t.jsx)(o,{value:s,keyName:e})})]})]})},e)};return s&&s.sections&&Array.isArray(s.sections)&&s.sections.length>0?(0,t.jsx)("div",{className:"space-y-6",children:s.sections.map((e,s)=>(0,t.jsxs)("div",{className:"bg-white rounded-xl shadow-lg border border-indigo-200 overflow-hidden",children:[e.name&&(0,t.jsx)("div",{className:"bg-gradient-to-r from-indigo-500 to-indigo-600 p-4",children:(0,t.jsxs)("h5",{className:"text-lg font-bold text-white flex items-center",children:[(0,t.jsx)("svg",{className:"w-5 h-5 text-white mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.name]})}),e.forms&&Array.isArray(e.forms)&&e.forms.length>0&&(0,t.jsx)("div",{className:"p-6",children:(0,t.jsx)("div",{className:"space-y-4",children:e.forms.map((e,s)=>(0,t.jsxs)("div",{className:"bg-gradient-to-r from-blue-50 to-blue-100 rounded-lg p-4 border border-blue-200",children:[e.id&&(0,t.jsxs)("h6",{className:"text-md font-bold text-blue-800 mb-3 flex items-center",children:[(0,t.jsx)("svg",{className:"w-4 h-4 text-blue-600 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.id]}),(0,t.jsx)("div",{className:"space-y-3",children:Object.entries(e).filter(e=>{let[s]=e;return"id"!==s}).map(e=>{let[s,t]=e;return a(s,t)})})]},s))})})]},s))}):Array.isArray(s)&&s.length>0?(0,t.jsx)("div",{className:"space-y-6",children:s.map((e,s)=>(0,t.jsxs)("div",{className:"bg-white rounded-xl shadow-lg border border-blue-200 overflow-hidden",children:[(0,t.jsx)("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 p-4",children:(0,t.jsxs)("h5",{className:"text-lg font-bold text-white flex items-center",children:[(0,t.jsx)("svg",{className:"w-5 h-5 text-white mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.id||`Formulario ${s+1}`]})}),(0,t.jsx)("div",{className:"p-6",children:(0,t.jsx)("div",{className:"space-y-4",children:Object.entries(e).filter(e=>{let[s]=e;return"id"!==s}).map(e=>{let[s,t]=e;return a(s,t)})})})]},s))}):null},c=e=>{let{title:s,data:a,gradientFrom:r,gradientTo:l,borderColor:i,dotColor:n,isBrief:c=!1}=e;if(!a||0===Object.keys(a).length)return null;let m=c?Object.entries(a).filter(e=>{let[s]=e;return"form_values"!==s&&"sections"!==s}):Object.entries(a),x=m.length>0,u=c&&a.form_values;return(0,t.jsx)("div",{className:"mb-6 break-inside-avoid",children:(0,t.jsxs)("div",{className:`bg-gradient-to-r ${r} ${l} rounded-lg p-6 border ${i}`,children:[(0,t.jsxs)("h3",{className:"text-xl font-bold text-gray-800 mb-4 flex items-center",children:[(0,t.jsx)("span",{className:`w-2 h-2 ${n} rounded-full mr-3`}),s]}),c?(0,t.jsxs)("div",{className:"space-y-4",children:[u&&(0,t.jsxs)("div",{className:"bg-white rounded-lg p-4 shadow-sm",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-gray-600 mb-3 capitalize",children:"Formularios y Secciones"}),(0,t.jsx)(d,{formValues:a.form_values})]}),x&&(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:m.map(e=>{let[s,a]=e;return(0,t.jsxs)("div",{className:"bg-white rounded-lg p-4 shadow-sm",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-gray-600 mb-1 capitalize",children:s.replace(/_/g," ")}),(0,t.jsx)("div",{children:(0,t.jsx)(o,{value:a,keyName:s})})]},s)})})]}):(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Object.entries(a).map(e=>{let[s,a]=e;return(0,t.jsxs)("div",{className:"bg-white rounded-lg p-4 shadow-sm",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-gray-600 mb-1 capitalize",children:s.replace(/_/g," ")}),(0,t.jsx)("div",{children:(0,t.jsx)(o,{value:a,keyName:s})})]},s)})})]})})},m=e=>{let{data:s}=e;return(0,t.jsx)("div",{className:"mt-8",children:(0,t.jsxs)("details",{className:"cursor-pointer",children:[(0,t.jsx)("summary",{className:"text-lg font-semibold text-gray-700 mb-4 hover:text-gray-900",children:"\uD83D\uDCCB Ver JSON Completo"}),(0,t.jsx)("div",{className:"bg-gray-100 p-4 rounded-lg overflow-auto max-h-96 mt-4",children:(0,t.jsx)("pre",{className:"text-sm text-gray-800",children:JSON.stringify(s,null,2)})})]})})},x=e=>{let s,{data:a,title:r}=e;if(!a)return(0,t.jsx)("div",{className:"p-6 text-center text-gray-500",children:"No hay datos para mostrar"});if(a.data&&(a.data.profile||a.data.brief)){let{uuid:e,business_cid:t,active:r,has_kd_product:l,has_active_subscription:i,preferred_currency:n,preferred_frequency:o,created_at:d,updated_at:c,deactivated_at:m,hubspot_client_id:x,...u}=a.data;s={accountIdentifiers:{uuid:e,business_cid:t,hubspot_client_id:x},accountStatus:{active:r,has_kd_product:l,has_active_subscription:i},accountSettings:{preferred_currency:n,preferred_frequency:o},accountTimestamps:{created_at:d,updated_at:c,deactivated_at:m},profile:a.data.profile||{},brief:a.data.brief||{},integrations:{},rawAdditionalFields:u}}else{let{accountIdentifiers:e={},accountStatus:t={},accountSettings:r={},accountTimestamps:l={},integrations:i={},profile:n={},brief:o={},...d}=a;s={accountIdentifiers:e,accountStatus:t,accountSettings:r,accountTimestamps:l,integrations:i,profile:n,brief:o,rawAdditionalFields:d}}let{accountIdentifiers:l,accountStatus:i,accountSettings:n,accountTimestamps:o,integrations:d,profile:x,brief:u,rawAdditionalFields:h}=s,g=Object.fromEntries(Object.entries(h).filter(e=>{let[s]=e;return!["api_key","csrf_token"].includes(s)}));return(0,t.jsxs)("div",{className:"max-w-7xl mx-auto p-6",children:[x&&Object.keys(x).length>0&&(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(c,{title:"Principal",data:x,gradientFrom:"from-indigo-50",gradientTo:"to-blue-50",borderColor:"border-indigo-200",dotColor:"bg-indigo-500"})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8",children:[(0,t.jsx)(c,{title:"Identificadores de Cuenta",data:l,gradientFrom:"from-blue-50",gradientTo:"to-indigo-50",borderColor:"border-blue-200",dotColor:"bg-blue-500"}),(0,t.jsx)(c,{title:"Estado de la Cuenta",data:i,gradientFrom:"from-green-50",gradientTo:"to-emerald-50",borderColor:"border-green-200",dotColor:"bg-green-500"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8",children:[(0,t.jsx)(c,{title:"Configuraci\xf3n de Cuenta",data:n,gradientFrom:"from-purple-50",gradientTo:"to-pink-50",borderColor:"border-purple-200",dotColor:"bg-purple-500"}),(0,t.jsx)(c,{title:"Marcas de Tiempo",data:o,gradientFrom:"from-amber-50",gradientTo:"to-orange-50",borderColor:"border-amber-200",dotColor:"bg-amber-500"})]}),(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(c,{title:"Integraciones",data:d,gradientFrom:"from-teal-50",gradientTo:"to-cyan-50",borderColor:"border-teal-200",dotColor:"bg-teal-500"})}),u&&Object.keys(u).filter(e=>"form_values"!==e).length>0&&(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(c,{title:"Brief del Proyecto",data:Object.fromEntries(Object.entries(u).filter(e=>{let[s]=e;return"form_values"!==s})),gradientFrom:"from-purple-50",gradientTo:"to-pink-50",borderColor:"border-purple-200",dotColor:"bg-purple-500"})}),u?.form_values&&(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(c,{title:"Formularios del Proyecto",data:(()=>{let e={};return u.form_values.sections&&Array.isArray(u.form_values.sections)?u.form_values.sections.forEach((s,a)=>{s.forms&&Array.isArray(s.forms)&&s.forms.forEach((s,t)=>{let r=s.fields||{},l=s.id||`Formulario_${a+1}_${t+1}`;Object.entries(r).forEach(s=>{let[a,t]=s;e[`${l}_${a}`]=t})})}):Object.entries(u.form_values).forEach(s=>{let[a,t]=s;"sections"!==a&&(e[a]=t)}),e})(),gradientFrom:"from-cyan-50",gradientTo:"to-blue-50",borderColor:"border-cyan-200",dotColor:"bg-cyan-500"})}),u?.metadata&&Object.keys(u.metadata).length>0&&(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(c,{title:"Metadatos del Brief",data:u.metadata,gradientFrom:"from-emerald-50",gradientTo:"to-teal-50",borderColor:"border-emerald-200",dotColor:"bg-emerald-500"})}),u?.keywords&&Array.isArray(u.keywords)&&u.keywords.length>0&&(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(c,{title:"Keywords del Brief",data:{keywords:u.keywords.join(", ")},gradientFrom:"from-violet-50",gradientTo:"to-purple-50",borderColor:"border-violet-200",dotColor:"bg-violet-500"})}),(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(c,{title:"Informaci\xf3n Adicional",data:g,gradientFrom:"from-rose-50",gradientTo:"to-pink-50",borderColor:"border-rose-200",dotColor:"bg-rose-500"})}),(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(m,{data:a})})]})};let u=e=>{let{conversations:s}=e,[a,l]=(0,r.useState)(!1),i=s.filter(e=>e.messages&&e.messages.length>0);return(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>l(!a),children:[(0,t.jsxs)("h2",{className:"text-xl font-semibold text-gray-900",children:["\uD83D\uDCAC Conversaciones con Feedback (",i.length,")"]}),(0,t.jsx)("button",{className:"text-gray-500 hover:text-gray-700 transition-colors",children:a?(0,t.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})}):(0,t.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),a&&(0,t.jsx)("div",{className:"mt-4 space-y-4",children:i.map((e,s)=>(0,t.jsxs)("div",{className:"border border-gray-200 rounded-lg p-4",children:[(0,t.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,t.jsx)("h3",{className:"font-medium text-gray-900",children:e.task_friendly_id}),(0,t.jsx)("span",{className:`px-2 py-1 text-xs rounded-full ${e.task_state.includes("PENDING")?"bg-yellow-100 text-yellow-800":e.task_state.includes("CREATED")?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`,children:e.task_state.replace("TASK_","").replace("_"," ")})]}),(0,t.jsx)("div",{className:"space-y-2",children:e.messages.map((e,s)=>(0,t.jsxs)("div",{className:"bg-gray-50 p-3 rounded",children:[(0,t.jsx)("div",{className:"text-sm text-gray-600 mb-1",children:new Date(e.created_at).toLocaleDateString("es-ES",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),(0,t.jsx)("div",{className:"text-gray-800",children:e.message}),e.feedback_attached?.attachments?.map((e,s)=>t.jsx("div",{className:"mt-1 text-sm text-gray-600 italic",children:e.content},s))]},e.uuid))})]},e.uuid))})]})};var h=e=>{let{conversations:s,analysisResult:a,loading:r,error:l,accountData:i}=e;return r?(0,t.jsx)("div",{className:"bg-white rounded-lg shadow-md p-6",children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-8",children:[(0,t.jsx)("img",{src:"https://media.giphy.com/media/3oKIPnAiaMCws8nOsE/giphy.gif",alt:"Gato analizando",className:"w-40 h-40 mb-4 rounded-lg"}),(0,t.jsxs)("span",{className:"text-gray-600 text-center",children:["\uD83D\uDC31 El gato est\xe1 analizando tus conversaciones...",(0,t.jsx)("br",{}),(0,t.jsx)("span",{className:"text-sm text-gray-500",children:"\xa1Esto puede tomar unos segundos!"})]})]})}):l?(0,t.jsx)("div",{className:"bg-white rounded-lg shadow-md p-6",children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-8",children:[(0,t.jsx)("img",{src:"https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif",alt:"Gato confundido",className:"w-40 h-40 mb-4 rounded-lg"}),(0,t.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"\uD83E\uDD37‍♂️ \xa1Ups! No hay feedback que analizar"}),(0,t.jsxs)("p",{className:"text-gray-600 text-center",children:["Por el momento no hay ning\xfan feedback disponible para analizar.",(0,t.jsx)("br",{}),(0,t.jsx)("span",{className:"text-sm text-gray-500",children:"\xa1Vuelve m\xe1s tarde cuando haya nuevas conversaciones!"})]})]})}):a?(0,t.jsxs)("div",{className:"space-y-6 overflow-y-auto",children:[(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"\uD83D\uDCCA Estad\xedsticas de Conversaciones"}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{className:"bg-blue-50 p-4 rounded-lg",children:[(0,t.jsx)("div",{className:"text-2xl font-bold text-blue-600",children:a.total_conversations}),(0,t.jsx)("div",{className:"text-sm text-blue-800",children:"Total de conversaciones"})]}),(0,t.jsxs)("div",{className:"bg-green-50 p-4 rounded-lg",children:[(0,t.jsx)("div",{className:"text-2xl font-bold text-green-600",children:a.conversations_with_messages}),(0,t.jsx)("div",{className:"text-sm text-green-800",children:"Con mensajes"})]}),(0,t.jsxs)("div",{className:"bg-purple-50 p-4 rounded-lg",children:[(0,t.jsxs)("div",{className:"text-2xl font-bold text-purple-600",children:[Math.round(a.conversations_with_messages/a.total_conversations*100),"%"]}),(0,t.jsx)("div",{className:"text-sm text-purple-800",children:"Tasa de feedback"})]})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"\uD83C\uDFAD An\xe1lisis de Sentimientos"}),(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,t.jsxs)("div",{className:`px-4 py-2 rounded-full ${(e=>{switch(e){case"positive":return"text-green-600 bg-green-100";case"negative":return"text-red-600 bg-red-100";default:return"text-yellow-600 bg-yellow-100"}})(a.analysis.sentiment_analysis.overall_sentiment)}`,children:[(0,t.jsx)("span",{className:"text-lg mr-2",children:(e=>{switch(e){case"positive":return"\uD83D\uDE0A";case"negative":return"\uD83D\uDE1E";default:return"\uD83D\uDE10"}})(a.analysis.sentiment_analysis.overall_sentiment)}),(0,t.jsx)("span",{className:"font-medium capitalize",children:a.analysis.sentiment_analysis.overall_sentiment})]}),(0,t.jsxs)("div",{className:"text-sm text-gray-600",children:["Confianza:"," ",Math.round(100*a.analysis.sentiment_analysis.confidence),"%"]})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"\uD83D\uDCA1 Insights Clave"}),(0,t.jsx)("ul",{className:"space-y-2",children:a.analysis.insights.map((e,s)=>(0,t.jsxs)("li",{className:"flex items-start",children:[(0,t.jsx)("span",{className:"text-blue-500 mr-2",children:"•"}),(0,t.jsx)("span",{className:"text-gray-700",children:e})]},s))})]}),(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"\uD83C\uDFAF Recomendaciones para el Equipo de Producci\xf3n"}),(0,t.jsx)("ul",{className:"space-y-2",children:a.analysis.recommendations.map((e,s)=>(0,t.jsxs)("li",{className:"flex items-start",children:[(0,t.jsx)("span",{className:"text-green-500 mr-2",children:"✓"}),(0,t.jsx)("span",{className:"text-gray-700",children:e})]},s))})]}),a.analysis.client_specific_corrections&&a.analysis.client_specific_corrections.length>0&&(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"\uD83D\uDD27 Cambios Puntuales y Correcciones del Cliente"}),(0,t.jsx)("div",{className:"space-y-4",children:a.analysis.client_specific_corrections.map((e,s)=>(0,t.jsx)("div",{className:"border-l-4 border-orange-400 bg-orange-50 p-4 rounded-r-lg",children:(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("span",{className:"text-orange-500 text-lg",children:"⚠️"})}),(0,t.jsxs)("div",{className:"ml-3 w-full",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-orange-800 mb-2",children:e.error_type}),(0,t.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-medium text-gray-700",children:"Feedback del cliente:"}),(0,t.jsxs)("p",{className:"text-gray-600 italic mt-1",children:['"',e.client_feedback,'"']})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-medium text-gray-700",children:"Correcci\xf3n requerida:"}),(0,t.jsx)("p",{className:"text-gray-600 mt-1",children:e.correction_required})]}),(0,t.jsxs)("div",{className:"bg-yellow-50 p-2 rounded border-l-2 border-yellow-400",children:[(0,t.jsx)("span",{className:"font-medium text-yellow-800",children:"Nota de prevenci\xf3n:"}),(0,t.jsx)("p",{className:"text-yellow-700 mt-1",children:e.prevention_note})]})]})]})]})},s))})]}),a.analysis.common_themes.length>0&&(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"\uD83C\uDFF7️ Temas Comunes"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:a.analysis.common_themes.map((e,s)=>(0,t.jsx)("span",{className:"px-3 py-1 bg-gray-100 text-gray-700 rounded-full text-sm",children:e},s))})]}),a.analysis.priority_areas.length>0&&(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"\uD83D\uDEA8 \xc1reas Prioritarias"}),(0,t.jsx)("ul",{className:"space-y-2",children:a.analysis.priority_areas.map((e,s)=>(0,t.jsxs)("li",{className:"flex items-start",children:[(0,t.jsx)("span",{className:"text-red-500 mr-2",children:"⚠️"}),(0,t.jsx)("span",{className:"text-gray-700 font-medium",children:e})]},s))})]}),(0,t.jsx)(u,{conversations:s}),(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"\uD83D\uDCC4 Datos Completos (JSON)"}),(0,t.jsx)("div",{className:"bg-gray-50 rounded-lg p-4 max-h-96 overflow-y-auto",children:(0,t.jsx)("pre",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:JSON.stringify(a,null,2)})})]})]}):null},g=a(8885),p=e=>{let{conversations:s,analysisResult:a,accountData:l}=e,[i,n]=(0,r.useState)([{id:"1",content:"\xa1Hola! Soy tu asistente de an\xe1lisis de producci\xf3n. Puedo ayudarte a entender mejor los datos de la cuenta y las conversaciones de feedback. \xbfEn qu\xe9 puedo ayudarte?",isUser:!1,timestamp:new Date}]),[o,d]=(0,r.useState)(""),[c,m]=(0,r.useState)(!1),x=(0,r.useRef)(null),u=()=>{x.current?.scrollIntoView({behavior:"smooth"})};(0,r.useEffect)(()=>{u()},[i]);let h=async()=>{if(!o.trim()||c)return;let e={id:Date.now().toString(),content:o,isUser:!0,timestamp:new Date};n(s=>[...s,e]),d(""),m(!0);try{let e=s.filter(e=>!!e.messages&&0!==e.messages.length&&e.messages.some(e=>e.message&&e.message.trim().length>0)).map(e=>({id:e.uuid,taskId:e.task_friendly_id,state:e.task_state,messages:e.messages?.map(e=>({content:e.message,createdAt:e.created_at,attachments:e.feedback_attached?.attachments}))||[]})),t=a?{totalConversations:a.total_conversations,conversationsWithMessages:a.conversations_with_messages,sentiment:a.analysis.sentiment_analysis,insights:a.analysis.insights,recommendations:a.analysis.recommendations,commonThemes:a.analysis.common_themes,priorityAreas:a.analysis.priority_areas,clientCorrections:a.analysis.client_specific_corrections}:null,r=await fetch("/api/production-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:o,accountData:l,conversations:e,analysisResult:t})});if(!r.ok)throw Error("Error al procesar la consulta");let i=await r.json(),d={id:(Date.now()+1).toString(),content:i.response,isUser:!1,timestamp:new Date,followUpQuestions:i.follow_up_questions||[]};n(e=>[...e,d])}catch(s){let e={id:(Date.now()+1).toString(),content:"Lo siento, hubo un error al procesar tu consulta. Por favor, intenta de nuevo.",isUser:!1,timestamp:new Date};n(s=>[...s,e])}finally{m(!1)}},p=e=>e.toLocaleTimeString("es-ES",{hour:"2-digit",minute:"2-digit"});return(0,t.jsxs)("div",{className:"flex flex-col h-full bg-white rounded-lg shadow-md",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center",children:(0,t.jsx)("span",{className:"text-blue-600 text-lg",children:"\uD83E\uDD16"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-semibold text-gray-900",children:"Asistente de Producci\xf3n"}),(0,t.jsx)("p",{className:"text-sm text-gray-500",children:"An\xe1lisis de feedback y datos"})]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),(0,t.jsx)("span",{className:"text-xs text-gray-500",children:"En l\xednea"})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[i.map(e=>(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:`flex ${e.isUser?"justify-end":"justify-start"}`,children:(0,t.jsxs)("div",{className:`max-w-xs lg:max-w-md px-4 py-2 rounded-lg ${e.isUser?"bg-blue-600 text-white":"bg-gray-100 text-gray-900"}`,children:[e.isUser?(0,t.jsx)("p",{className:"text-sm whitespace-pre-wrap",children:e.content}):(0,t.jsx)("div",{className:"text-sm prose prose-sm max-w-none",children:(0,t.jsx)(g.UG,{components:{p:e=>{let{children:s}=e;return(0,t.jsx)("p",{className:"mb-2 last:mb-0",children:s})},ul:e=>{let{children:s}=e;return(0,t.jsx)("ul",{className:"list-disc list-inside mb-2",children:s})},ol:e=>{let{children:s}=e;return(0,t.jsx)("ol",{className:"list-decimal list-inside mb-2",children:s})},li:e=>{let{children:s}=e;return(0,t.jsx)("li",{className:"mb-1",children:s})},strong:e=>{let{children:s}=e;return(0,t.jsx)("strong",{className:"font-semibold",children:s})},em:e=>{let{children:s}=e;return(0,t.jsx)("em",{className:"italic",children:s})},code:e=>{let{children:s}=e;return(0,t.jsx)("code",{className:"bg-gray-200 px-1 py-0.5 rounded text-xs font-mono",children:s})},pre:e=>{let{children:s}=e;return(0,t.jsx)("pre",{className:"bg-gray-200 p-2 rounded text-xs font-mono overflow-x-auto mb-2",children:s})},h1:e=>{let{children:s}=e;return(0,t.jsx)("h1",{className:"text-lg font-bold mb-2",children:s})},h2:e=>{let{children:s}=e;return(0,t.jsx)("h2",{className:"text-base font-bold mb-2",children:s})},h3:e=>{let{children:s}=e;return(0,t.jsx)("h3",{className:"text-sm font-bold mb-1",children:s})},blockquote:e=>{let{children:s}=e;return(0,t.jsx)("blockquote",{className:"border-l-4 border-gray-300 pl-3 italic mb-2",children:s})}},children:e.content})}),(0,t.jsx)("p",{className:`text-xs mt-1 ${e.isUser?"text-blue-100":"text-gray-500"}`,children:p(e.timestamp)})]})}),!e.isUser&&e.followUpQuestions&&e.followUpQuestions.length>0&&(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsxs)("div",{className:"max-w-xs lg:max-w-md space-y-2",children:[(0,t.jsx)("p",{className:"text-xs text-gray-500 font-medium",children:"\uD83D\uDCA1 Preguntas de seguimiento:"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:e.followUpQuestions.map((e,s)=>(0,t.jsx)("button",{onClick:()=>d(e),className:"px-3 py-1 text-xs bg-blue-50 text-blue-700 border border-blue-200 rounded-full hover:bg-blue-100 transition-colors text-left",disabled:c,children:e},s))})]})})]},e.id)),c&&(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsx)("div",{className:"bg-gray-100 rounded-lg px-4 py-2",children:(0,t.jsxs)("div",{className:"flex space-x-1",children:[(0,t.jsx)("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce"}),(0,t.jsx)("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,t.jsx)("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})}),(0,t.jsx)("div",{ref:x})]}),(0,t.jsx)("div",{className:"p-4 border-t border-gray-200",children:(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("textarea",{value:o,onChange:e=>d(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),h())},placeholder:"Pregunta sobre el an\xe1lisis, datos de cuenta, o feedback...",className:"flex-1 resize-none border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",rows:2,disabled:c}),(0,t.jsx)("button",{onClick:h,disabled:!o.trim()||c,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:(0,t.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]})})]})};let b=e=>{let{post:s}=e,[a,l]=(0,r.useState)(0),[i,n]=(0,r.useState)(!1),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)(!1),[x,u]=(0,r.useState)(!1),[h,g]=(0,r.useState)(s.approval_status||"pending_approval"),p=s.caption.length>100?s.caption.substring(0,100)+"...":s.caption,b=e=>{"approve"===e?g("approved"):g("changes_requested")},j=s.images.length>1;return(0,t.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("img",{src:s.avatar_url,alt:s.username,className:"w-8 h-8 rounded-full object-cover"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-semibold text-sm text-gray-900",children:s.username}),s.location&&(0,t.jsx)("p",{className:"text-xs text-gray-500",children:s.location})]})]}),(0,t.jsx)("button",{className:"p-2",children:(0,t.jsx)("svg",{className:"w-5 h-5 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})})})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("img",{src:s.images[a],alt:`Post by ${s.username}`,className:"w-full aspect-square object-cover"}),j&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{onClick:()=>{l(e=>(e-1+s.images.length)%s.images.length)},className:"absolute left-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white rounded-full p-2 hover:bg-opacity-70",children:(0,t.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),(0,t.jsx)("button",{onClick:()=>{l(e=>(e+1)%s.images.length)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white rounded-full p-2 hover:bg-opacity-70",children:(0,t.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),(0,t.jsx)("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 flex space-x-1",children:s.images.map((e,s)=>(0,t.jsx)("div",{className:`w-2 h-2 rounded-full ${s===a?"bg-white":"bg-white bg-opacity-50"}`},s))})]})]}),(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,t.jsx)("button",{onClick:()=>m(!c),className:"p-1",children:(0,t.jsx)("svg",{className:`w-6 h-6 ${c?"text-red-500 fill-current":"text-gray-700"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"})})}),(0,t.jsx)("button",{className:"p-1",children:(0,t.jsx)("svg",{className:"w-6 h-6 text-gray-700",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),(0,t.jsx)("button",{className:"p-1",children:(0,t.jsx)("svg",{className:"w-6 h-6 text-gray-700",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),(0,t.jsx)("button",{onClick:()=>u(!x),className:"p-1","aria-label":x?"Quitar de guardados":"Guardar post",children:(0,t.jsx)("svg",{className:`w-6 h-6 ${x?"text-gray-900 fill-current":"text-gray-700"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})})})]}),(0,t.jsx)("div",{className:"mb-2",children:(0,t.jsxs)("p",{className:"font-semibold text-sm text-gray-900",children:[s.likes.toLocaleString()," Me gusta"]})}),(0,t.jsx)("div",{className:"mb-2",children:(0,t.jsxs)("p",{className:"text-sm text-gray-900",children:[(0,t.jsx)("span",{className:"font-semibold",children:s.username})," ",o?s.caption:p,s.caption.length>100&&(0,t.jsx)("button",{onClick:()=>d(!o),className:"text-gray-500 ml-1",children:o?"menos":"m\xe1s"})]})}),(0,t.jsx)("div",{className:"mb-3",children:s.hashtags.map((e,s)=>(0,t.jsxs)("span",{className:"text-blue-600 text-sm mr-1",children:["#",e]},s))}),(0,t.jsx)("div",{className:"mb-2",children:(0,t.jsxs)("button",{onClick:()=>n(!i),className:"text-gray-500 text-sm",children:["Ver los ",s.comments.length," comentarios"]})}),i&&(0,t.jsx)("div",{className:"space-y-1 mb-3",children:s.comments.map((e,s)=>(0,t.jsxs)("p",{className:"text-sm text-gray-900",children:[(0,t.jsx)("span",{className:"font-semibold",children:e.user})," ",e.text]},s))}),(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsx)("p",{className:"text-xs text-gray-500 uppercase",children:(e=>{let s=new Date,a=new Date(e),t=Math.floor((s.getTime()-a.getTime())/36e5);if(t<1)return"HACE MENOS DE 1 HORA";if(1===t)return"HACE 1 HORA";if(t<24)return`HACE ${t} HORAS`;let r=Math.floor(t/24);return 1===r?"HACE 1 D\xcdA":`HACE ${r} D\xcdAS`})(s.created_at)})}),(0,t.jsx)("div",{className:"border-t pt-3",children:(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:()=>b("approve"),className:"flex-1 bg-green-600 hover:bg-green-700 text-white text-sm font-medium py-2 px-4 rounded-md transition-colors",children:"Aprobar"}),(0,t.jsx)("button",{onClick:()=>b("request_changes"),className:"flex-1 bg-orange-600 hover:bg-orange-700 text-white text-sm font-medium py-2 px-4 rounded-md transition-colors",children:"Solicitar cambios"})]})})]})]})};var j=()=>{let[e,s]=(0,r.useState)([{id:"1",name:"Navidad La Abuela",objective:"Aumentar ventas navide\xf1as",postsCount:12,startDate:"2024-12-01T09:00",status:"backlog_pending_approval",createdAt:"2024-11-15T10:30:00Z"},{id:"2",name:"Promoci\xf3n Pan Artesanal",objective:"Destacar productos artesanales",postsCount:8,startDate:"2024-11-20T08:00",status:"active",createdAt:"2024-11-10T14:20:00Z"}]),[a,l]=(0,r.useState)(null),[i,n]=(0,r.useState)("campaigns"),[o,d]=(0,r.useState)({name:"",objective:"",postsCount:"",startDate:""}),[c]=(0,r.useState)([{post_id:"1",username:"laabuela_bakery",avatar_url:"https://images.unsplash.com/photo-1494790108755-2616c9c0e8d3?w=150&h=150&fit=crop&crop=face",images:["https://images.unsplash.com/photo-1509440159596-0249088772ff?w=1080&h=1350&fit=crop"],caption:"Pan artesanal de masa madre reci\xe9n horneado. Cada hogaza lleva 24 horas de fermentaci\xf3n natural para conseguir esa textura perfecta y ese sabor inconfundible que nos caracteriza.",hashtags:["panader\xeda","artesanal","Madrid","masamadre"],likes:1024,comments:[{user:"maria_chef",text:"\xa1Se ve delicioso! \xbfHacen env\xedos?"},{user:"carlos_foodie",text:"El mejor pan de Madrid sin duda"}],created_at:"2024-11-20T14:30:00Z",location:"Madrid, Espa\xf1a"},{post_id:"2",username:"laabuela_bakery",avatar_url:"https://images.unsplash.com/photo-1494790108755-2616c9c0e8d3?w=150&h=150&fit=crop&crop=face",images:["https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1080&h=1350&fit=crop","https://images.unsplash.com/photo-1549931319-a545dcf3bc73?w=1080&h=1350&fit=crop"],caption:"Croissants reci\xe9n salidos del horno. La mantequilla francesa y la t\xe9cnica tradicional hacen la diferencia.",hashtags:["croissants","franc\xe9s","mantequilla","tradici\xf3n"],likes:856,comments:[{user:"ana_paris",text:"Como los de Par\xeds!"},{user:"luis_baker",text:"\xbfCu\xe1l es el secreto del hojaldre?"},{user:"sofia_sweet",text:"Necesito la receta \uD83D\uDE0D"}],created_at:"2024-11-19T09:15:00Z",location:"Madrid, Espa\xf1a"},{post_id:"3",username:"laabuela_bakery",avatar_url:"https://images.unsplash.com/photo-1494790108755-2616c9c0e8d3?w=150&h=150&fit=crop&crop=face",images:["https://images.unsplash.com/photo-1571115764595-644a1f56a55c?w=1080&h=1350&fit=crop"],caption:"Empanadas caseras con rellenos tradicionales. Masa crujiente y jugosos rellenos preparados cada ma\xf1ana.",hashtags:["empanadas","caseras","tradicional","rellenos"],likes:743,comments:[{user:"pedro_arg",text:"Como las de mi abuela argentina"}],created_at:"2024-11-18T16:45:00Z"},{post_id:"4",username:"laabuela_bakery",avatar_url:"https://images.unsplash.com/photo-1494790108755-2616c9c0e8d3?w=150&h=150&fit=crop&crop=face",images:["https://images.unsplash.com/photo-1578985545062-69928b1d9587?w=1080&h=1350&fit=crop"],caption:"Dulces navide\xf1os ya disponibles. Polvorones, mantecados y turrones artesanales para endulzar estas fiestas.",hashtags:["navidad","dulces","polvorones","artesanal"],likes:1205,comments:[{user:"carmen_xmas",text:"\xa1Ya huele a Navidad!"},{user:"miguel_sweet",text:"Los mejores turrones de la ciudad"}],created_at:"2024-11-17T11:20:00Z",location:"Madrid, Espa\xf1a"},{post_id:"5",username:"laabuela_bakery",avatar_url:"https://images.unsplash.com/photo-1494790108755-2616c9c0e8d3?w=150&h=150&fit=crop&crop=face",images:["https://images.unsplash.com/photo-1555507036-ab794f4ade2a?w=1080&h=1350&fit=crop"],caption:"Proceso de amasado tradicional. Nuestras manos expertas trabajan la masa con la t\xe9cnica de siempre.",hashtags:["proceso","amasado","tradicional","artesano"],likes:892,comments:[{user:"chef_antonio",text:"El arte del buen pan"}],created_at:"2024-11-16T13:10:00Z"},{post_id:"6",username:"laabuela_bakery",avatar_url:"https://images.unsplash.com/photo-1494790108755-2616c9c0e8d3?w=150&h=150&fit=crop&crop=face",images:["https://images.unsplash.com/photo-1506459225024-1428097a7e18?w=1080&h=1350&fit=crop"],caption:"Tartas personalizadas para ocasiones especiales. Cada tarta es \xfanica y est\xe1 hecha con amor.",hashtags:["tartas","personalizadas","especiales","amor"],likes:967,comments:[{user:"lucia_party",text:"\xbfHacen tartas de cumplea\xf1os?"},{user:"raul_events",text:"Perfectas para eventos"}],created_at:"2024-11-15T15:30:00Z",location:"Madrid, Espa\xf1a"}]),m=(e,s)=>{},x=e=>new Date(e).toLocaleDateString("es-ES");return(0,t.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,t.jsx)("div",{className:"sticky top-0 z-10 bg-white border-b border-gray-200 px-4 py-3",children:(0,t.jsx)("div",{className:"flex justify-between items-center max-w-4xl mx-auto",children:(0,t.jsx)("h1",{className:"text-xl font-bold text-gray-900",children:"Posts"})})}),(0,t.jsx)("div",{className:"bg-white border-b border-gray-200",children:(0,t.jsx)("div",{className:"max-w-4xl mx-auto px-4",children:(0,t.jsx)("nav",{className:"flex space-x-8",children:[{key:"campaigns",label:"Campa\xf1as"},{key:"feed",label:"Feed"}].map(e=>{let{key:s,label:a}=e;return(0,t.jsx)("button",{onClick:()=>n(s),className:`py-4 px-1 border-b-2 font-medium text-sm transition-colors ${i===s?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:a},s)})})})}),(0,t.jsxs)("div",{className:"max-w-4xl mx-auto px-4 py-6",children:["campaigns"===i&&(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Crear Nueva Campa\xf1a"}),(0,t.jsxs)("form",{onSubmit:a=>{a.preventDefault(),o.name&&o.objective&&o.postsCount&&o.startDate&&(s([...e,{id:Date.now().toString(),name:o.name,objective:o.objective,postsCount:parseInt(o.postsCount),startDate:o.startDate,status:"backlog_pending_approval",createdAt:new Date().toISOString()}]),d({name:"",objective:"",postsCount:"",startDate:""}))},className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Nombre de campa\xf1a"}),(0,t.jsx)("input",{type:"text",value:o.name,onChange:e=>d({...o,name:e.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500",required:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Objetivo"}),(0,t.jsx)("input",{type:"text",value:o.objective,onChange:e=>d({...o,objective:e.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500",required:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"N\xba de posts"}),(0,t.jsx)("input",{type:"number",value:o.postsCount,onChange:e=>d({...o,postsCount:e.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500",min:"1",required:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Fecha de inicio"}),(0,t.jsx)("input",{type:"datetime-local",value:o.startDate,onChange:e=>d({...o,startDate:e.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500",required:!0})]}),(0,t.jsx)("div",{className:"md:col-span-2",children:(0,t.jsx)("button",{type:"submit",className:"bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-md transition-colors",children:"Crear campa\xf1a"})})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden",children:[(0,t.jsx)("div",{className:"px-6 py-4 border-b border-gray-200",children:(0,t.jsx)("h2",{className:"text-lg font-semibold text-gray-900",children:"Campa\xf1as"})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,t.jsx)("thead",{className:"bg-gray-50",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"ID"}),(0,t.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Nombre"}),(0,t.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado"}),(0,t.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Fecha creaci\xf3n"}),(0,t.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),(0,t.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:e.map(e=>(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:e.id}),(0,t.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:e.name}),(0,t.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,t.jsx)("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${"active"===e.status?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:e.status})}),(0,t.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:x(e.createdAt)}),(0,t.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:(0,t.jsx)("button",{onClick:()=>{l(e.id),n("backlog")},className:"text-blue-600 hover:text-blue-900",children:"Ver backlog"})})]},e.id))})]})})]})]}),"backlog"===i&&a&&(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("h2",{className:"text-2xl font-bold text-gray-900",children:["Backlog - ",e.find(e=>e.id===a)?.name]}),(0,t.jsx)("button",{onClick:()=>n("campaigns"),className:"text-blue-600 hover:text-blue-900",children:"← Volver a campa\xf1as"})]}),(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden",children:[(0,t.jsx)("div",{className:"px-6 py-4 border-b border-gray-200",children:(0,t.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Tareas del Backlog"})}),(0,t.jsx)("div",{className:"divide-y divide-gray-200",children:({1:[{task_id:"task_001",status:"pending_approval",publish_at:"2024-12-01T09:00:00Z",creative_angle:"Tradici\xf3n navide\xf1a familiar"},{task_id:"task_002",status:"draft",publish_at:"2024-12-03T11:00:00Z",creative_angle:"Ingredientes naturales"},{task_id:"task_003",status:"approved",publish_at:"2024-12-05T16:00:00Z",creative_angle:"Proceso artesanal"}],2:[{task_id:"task_004",status:"approved",publish_at:"2024-11-20T08:00:00Z",creative_angle:"Masa madre tradicional"},{task_id:"task_005",status:"pending_approval",publish_at:"2024-11-22T10:00:00Z",creative_angle:"Horneado diario"}]})[a]?.map(e=>t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{children:[t.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:["Task ID: ",e.task_id]}),t.jsxs("p",{className:"text-sm text-gray-500",children:["\xc1ngulo creativo: ",e.creative_angle]})]}),t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${"approved"===e.status?"bg-green-100 text-green-800":"pending_approval"===e.status?"bg-yellow-100 text-yellow-800":"bg-gray-100 text-gray-800"}`,children:e.status})]}),t.jsxs("p",{className:"text-sm text-gray-600 mb-4",children:["Publicar: ",new Date(e.publish_at).toLocaleString("es-ES")]}),t.jsxs("div",{className:"flex space-x-3",children:[t.jsx("button",{onClick:()=>m(e.task_id,"approve"),className:"bg-green-600 hover:bg-green-700 text-white text-sm font-medium py-2 px-4 rounded-md transition-colors",children:"Aprobar plan"}),t.jsx("button",{onClick:()=>m(e.task_id,"request_changes"),className:"bg-orange-600 hover:bg-orange-700 text-white text-sm font-medium py-2 px-4 rounded-md transition-colors",children:"Solicitar cambios"})]})]},e.task_id))||(0,t.jsx)("div",{className:"p-6 text-center text-gray-500",children:"No hay tareas en el backlog para esta campa\xf1a."})})]})]}),"feed"===i&&(0,t.jsx)("div",{className:"mx-auto max-w-md",children:(0,t.jsx)("div",{className:"space-y-6",children:c.map(e=>(0,t.jsx)(b,{post:e},e.post_id))})})]})]})};class f{static async getFeedbackConversations(e){try{let s=await fetch(`/api/feedback-conversations?accountId=${e}`);if(!s.ok)throw Error(`Error ${s.status}: ${s.statusText}`);let a=await s.json();if(!a.success)throw Error(a.error||"Error desconocido");return a.data}catch(e){if(e instanceof TypeError&&e.message.includes("fetch"))throw Error("Error de conexi\xf3n: No se pudo conectar con la API de Orbidi. Esto puede deberse a problemas de CORS o conectividad.");throw e}}static async testApiConnection(e){try{return await this.getFeedbackConversations(e),!0}catch(e){return!1}}static getConversationsWithMessages(e){return e.filter(e=>e.messages&&e.messages.length>0)}static getConversationStats(e){let s=this.getConversationsWithMessages(e),a=s.reduce((e,s)=>e+s.messages.length,0),t=e.reduce((e,s)=>(e[s.task_state]=(e[s.task_state]||0)+1,e),{}),r=e.reduce((e,s)=>{let a=s.task_friendly_id.split(" - ")[0]||"Unknown";return e[a]=(e[a]||0)+1,e},{});return{total_conversations:e.length,conversations_with_messages:s.length,total_messages:a,task_states:t,task_types:r,average_messages_per_conversation:s.length>0?(a/s.length).toFixed(2):"0"}}}class y{static async analyzeFeedbackConversations(e){try{let s=await fetch("/api/analyze-feedback",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8","Accept-Charset":"utf-8"},body:JSON.stringify({conversations:e})});if(!s.ok){let e=await s.json();throw Error(e.error||"Error en la API de an\xe1lisis")}return await s.json()}catch(e){throw Error("Error al analizar con OpenAI: "+e.message)}}static async testConnection(){try{return(await fetch("/api/analyze-feedback",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8","Accept-Charset":"utf-8"},body:JSON.stringify({conversations:[]})})).ok}catch(e){return!1}}}function v(){let{user:e,isLoaded:s}=(0,l.aF)(),[a,i]=(0,r.useState)(null),[o,d]=(0,r.useState)([]),[c,m]=(0,r.useState)(null),[u,g]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[N,w]=(0,r.useState)(null),[k,D]=(0,r.useState)(null),[C,_]=(0,r.useState)("account"),A=async(e,s,a)=>{await Promise.all([E(e),S(e)])},E=async e=>{g(!0),w(null);try{let s=await fetch(`/api/account-data?accountId=${e}`);if(!s.ok)throw Error(`Error ${s.status}: ${s.statusText}`);let a=await s.json();if(!a.success)throw Error(a.error||"Error desconocido");i(a.data)}catch(e){e instanceof Error?e.message.includes("CORS")||e.message.includes("ERR_FAILED")?w("Error de CORS: La API no permite peticiones desde el navegador. Considera usar un proxy CORS o configurar el servidor para permitir peticiones cross-origin."):w(e.message):w("Error desconocido")}finally{g(!1)}},S=async e=>{g(!0),v(!1),w(null),D(null),d([]),m(null);try{let s=await f.getFeedbackConversations(e);d(s),g(!1),v(!0);let a=await y.analyzeFeedbackConversations(s),t={total_conversations:s.length,conversations_with_messages:s.filter(e=>e.messages?.length>0).length,analysis:a,processed_at:new Date().toISOString()};m(t)}catch(e){e instanceof Error?e.message.includes("OpenAI")?D(`Error de OpenAI: ${e.message}. Verifica que tu API key est\xe9 configurada correctamente.`):D(e.message):D("Error desconocido en el an\xe1lisis")}finally{g(!1),v(!1)}};return s?(0,t.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,t.jsx)("header",{className:"bg-white shadow-sm border-b",children:(0,t.jsx)("div",{className:"max-w-full mx-auto px-6 sm:px-8 lg:px-12",children:(0,t.jsxs)("div",{className:"flex justify-between items-center py-4",children:[(0,t.jsx)("div",{className:"flex items-center",children:(0,t.jsx)("h1",{className:"text-xl font-semibold text-gray-900",children:"Orbidi Feedback Analysis Tool"})}),(0,t.jsx)("div",{className:"flex items-center space-x-4",children:e&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[e.imageUrl&&(0,t.jsx)("img",{className:"h-8 w-8 rounded-full",src:e.imageUrl,alt:e.fullName||"Usuario"}),(0,t.jsxs)("div",{className:"text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-gray-900",children:e.fullName}),(0,t.jsx)("p",{className:"text-gray-500",children:e.primaryEmailAddress?.emailAddress})]})]}),(0,t.jsx)(l.AM,{children:(0,t.jsx)("button",{className:"inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-colors",children:"Cerrar Sesi\xf3n"})})]})})]})})}),e?(0,t.jsx)("div",{className:"py-8",children:(0,t.jsxs)("div",{className:"max-w-full mx-auto px-6 sm:px-8 lg:px-12",children:[(0,t.jsxs)("div",{className:"text-center mb-8",children:[(0,t.jsx)("h2",{className:"text-2xl font-bold text-gray-900",children:"An\xe1lisis de Feedback con IA"}),(0,t.jsx)("p",{className:"mt-2 text-gray-600",children:"Herramienta para analizar conversaciones de feedback con IA"})]}),(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md mb-8 p-6",children:[(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Consulta de Datos Completos"}),(0,t.jsx)("p",{className:"text-gray-600 text-sm",children:"Ingresa el Account ID para obtener tanto los datos de cuenta como el an\xe1lisis de feedback con IA simult\xe1neamente."})]}),(0,t.jsx)(n,{onSubmit:A,loading:u||b})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 xl:grid-cols-4 gap-8",children:[(0,t.jsxs)("div",{className:"xl:col-span-3",children:[(0,t.jsx)("div",{className:"bg-white rounded-lg shadow-md mb-8",children:(0,t.jsx)("div",{className:"border-b border-gray-200",children:(0,t.jsxs)("nav",{className:"-mb-px flex",children:[(0,t.jsx)("button",{onClick:()=>_("account"),className:`py-4 px-6 text-sm font-medium border-b-2 ${"account"===C?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:"\uD83D\uDC64 Datos de Cuenta"}),(0,t.jsx)("button",{onClick:()=>_("feedback"),className:`py-4 px-6 text-sm font-medium border-b-2 ${"feedback"===C?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:"\uD83E\uDD16 An\xe1lisis de Feedback con IA"}),e?.primaryEmailAddress?.emailAddress==="angel.kurten@orbidi.com"&&(0,t.jsx)("button",{onClick:()=>_("posts"),className:`py-4 px-6 text-sm font-medium border-b-2 ${"posts"===C?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:"\uD83D\uDCF1 Posts"})]})})}),N&&"account"===C&&(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 mb-8",children:(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,t.jsxs)("div",{className:"ml-3",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-red-800",children:"Error en datos de cuenta"}),(0,t.jsx)("div",{className:"mt-2 text-sm text-red-700",children:(0,t.jsx)("p",{children:N})})]})]})}),"posts"===C?e?.primaryEmailAddress?.emailAddress==="angel.kurten@orbidi.com"?(0,t.jsx)(j,{}):(0,t.jsx)("div",{className:"bg-white rounded-lg shadow-md p-6",children:(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)("div",{className:"text-red-400 mb-4",children:(0,t.jsx)("svg",{className:"mx-auto h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),(0,t.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Acceso Denegado"}),(0,t.jsx)("p",{className:"text-gray-500",children:"No tienes permisos para acceder a esta secci\xf3n."})]})}):"feedback"===C?(0,t.jsx)(h,{conversations:o,analysisResult:c,loading:b,error:k,accountData:a}):(0,t.jsx)("div",{className:"bg-white rounded-lg shadow-md p-6",children:a?(0,t.jsx)(x,{data:a,title:"Datos de Cuenta"}):(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)("div",{className:"text-gray-400 mb-4",children:(0,t.jsx)("svg",{className:"mx-auto h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),(0,t.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Datos de Cuenta"}),(0,t.jsx)("p",{className:"text-gray-500",children:u?"Cargando datos de cuenta...":"Ingresa un Account ID para ver los datos de cuenta"})]})})]}),(0,t.jsx)("div",{className:"xl:col-span-1",children:(0,t.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6 h-[calc(100vh-20rem)] sticky top-8 min-w-[350px]",children:[(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsx)("h3",{className:"text-lg font-medium text-gray-900 flex items-center",children:"\uD83D\uDCAC Chat de Producci\xf3n"})}),a?(0,t.jsx)(p,{conversations:o,analysisResult:c,accountData:a}):(0,t.jsxs)("div",{className:"text-center py-8",children:[(0,t.jsx)("div",{className:"text-gray-400 mb-4",children:(0,t.jsx)("svg",{className:"mx-auto h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-3.582 8-8 8a8.959 8.959 0 01-4.906-1.456L3 21l2.544-5.094A8.959 8.959 0 013 12c0-4.418 3.582-8 8-8s8 3.582 8 8z"})})}),(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Chat Deshabilitado"}),(0,t.jsx)("p",{className:"text-gray-500 text-sm",children:"El chat se habilitar\xe1 cuando los datos de cuenta est\xe9n disponibles"})]})]})})]})]})}):(0,t.jsx)("div",{className:"py-16",children:(0,t.jsxs)("div",{className:"max-w-md mx-auto text-center",children:[(0,t.jsx)("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Acceso Requerido"}),(0,t.jsx)("p",{className:"text-gray-600 mb-8",children:"Inicia sesi\xf3n para acceder a las herramientas de an\xe1lisis de contexto."}),(0,t.jsx)("a",{href:"/sign-in",className:"inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors",children:"Iniciar Sesi\xf3n"})]})})]}):(0,t.jsx)("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),(0,t.jsx)("p",{className:"text-gray-600",children:"Cargando..."})]})})}}},function(e){e.O(0,[885,888,774,179],function(){return e(e.s=8312)}),_N_E=e.O()}]);