1import{aZ as R,be as C,bF as j,bI as k,bf as f,b0 as O}from"./YSys8W1B.js";import{s as N}from"./HxhR0s2V.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"23ecd1d65cfd2b04a3ca202b459367cdf91f97eb"};var s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="ca099794-017e-4d8f-ad07-4a82f7a57ca7",e._sentryDebugIdIdentifier="sentry-dbid-ca099794-017e-4d8f-ad07-4a82f7a57ca7")}catch{}})();const T={report:120,insights:180,comments:120,filter:120,default:150},u=C(new Map),v=C(0);let m=null;const P=()=>{const e=R(()=>u.value.size>0),s=R(()=>Array.from(u.value.values()).some(o=>o.status==="failed")),t=R(()=>{if(u.value.size===0)return"";const o=Array.from(u.value.values())[0],g=u.value.size;return g===1?o.message:`${o.message} (+${g-1} ${g===2?"outro":"outros"})`}),a=R(()=>{if(u.value.size===0)return 0;const o=Array.from(u.value.values())[0],g=v.value,h=o.estimatedDuration,d=Math.min(g/h*100,95);return Math.round(d)}),i=(o,g,h)=>{console.log(`ð [PROCESSING-BAR] Iniciando job: ${o} - ${h}`);const d=T[g]||T.default;u.value.set(o,{type:g,message:h,startTime:Date.now(),status:"processing",estimatedDuration:d}),m||(v.value=0,m=N(()=>{if(u.value.size>0){const I=Array.from(u.value.values())[0];v.value=Math.floor((Date.now()-I.startTime)/1e3)}},1e3))},r=o=>{console.log(`â
[PROCESSING-BAR] Finalizando job: ${o}`),u.value.delete(o),u.value.size===0&&m&&(clearInterval(m),m=null,v.value=0)};return{isProcessing:e,hasFailedJob:s,currentMessage:t,elapsedTime:v,progressPercentage:a,startProcessing:i,stopProcessing:r,markAsFailed:(o,g)=>{console.log(`â [PROCESSING-BAR] Job falhou: ${o} - ${g}`);const h=u.value.get(o);h&&(u.value.set(o,{...h,status:"failed",message:g}),setTimeout(()=>{r(o)},5e3))},clearAll:()=>{console.log("ð§¹ [PROCESSING-BAR] Limpando todos os jobs"),u.value.clear(),m&&(clearInterval(m),m=null),v.value=0},isJobProcessing:o=>u.value.has(o)}};function G(e,s){const{urgentSpeed:t=3e3,mediumSpeed:a=8e3,slowSpeed:i=15e3,finalSpeed:r=3e4}=s;return e<45e3?t:e<18e4?a:e<36e4?i:r}async function _(e,s={}){const{maxAttempts:t=90,onProgress:a}=s,i=Date.now();let r=0;for(;r<t;){const n=Date.now()-i,c=G(n,s);r++,a&&a(Math.floor(n/1e3),c,r),console.log(`â³ Smart Polling: tentativa ${r}/${t} (${Math.floor(n/1e3)}s, próximo em ${c/1e3}s)`);try{const o=await e(r,n);if(o)return console.log(`â
Smart Polling: Sucesso após ${r} tentativas (${Math.floor(n/1e3)}s)`),o}catch(o){console.error(`â Smart Polling: Erro na tentativa ${r}:`,o)}r<t&&await new Promise(o=>setTimeout(o,c))}const l=Math.floor((Date.now()-i)/1e3);return console.log(`â±ï¸ Smart Polling: Timeout após ${r} tentativas (${l}s)`),null}const J=["owner","admin"],U=()=>{const e=j(),s=R(()=>{const a=e.value;return a?!!a.isSuper||J.includes(String(a.role||"")):!1}),t=R(()=>s.value);return{isAdmin:s,podeGerarRelatorioGeral:t}};function L(e){return e.reduce((s,t)=>(t.value&&(s[t.key]||=[]).push(t.value),s),{})}function $(...e){const s={};e.forEach(a=>{Object.entries(a).forEach(([i,r])=>{const l=Array.isArray(r)?r:[r],n=s[i]||=[];l.forEach(c=>{c&&!n.includes(c)&&n.push(c)})})});const t={};return Object.entries(s).forEach(([a,i])=>{i.length!==0&&(t[a]=i.length===1?i[0]:i)}),t}const q=k("winnieExpert",{state:()=>({campaignId:null,reportData:null,aiAnalysis:{},loading:!1,generating:!1,generatingAI:!1,generatingAIMap:{},error:null,activeFilters:{},serverSelectedFilters:{},availableReports:[],reportsLoaded:!1,selectedReportId:null,selectedReportOwnerId:null,regeneratingReportIds:[],winnieFilters:null,excludeDimensions:[],isPreparingNewReport:!1}),getters:{hasReportData:e=>!!e.reportData,hasAIAnalysis:e=>Object.keys(e.aiAnalysis).length>0,hasAIAnalysisForFilter:e=>s=>!!e.aiAnalysis[s],isLoading:e=>e.loading,isGenerating:e=>e.generating,isGeneratingAI:e=>e.generatingAI,isInsightGenerating:e=>s=>!!e.generatingAIMap[s],hasError:e=>!!e.error,hasWinnieFilters:e=>!!e.winnieFilters},actions:{setCampaignId(e){this.campaignId!==e&&(this.availableReports=[],this.reportsLoaded=!1),this.campaignId=e,this.clearError()},setFilters(e){this.activeFilters=e,this.selectedReportOwnerId=null,console.log("ð Filtros ativos definidos:",this.activeFilters)},async clearFilters(){this.activeFilters=await this.fetchSelectedFilters(),this.selectedReportOwnerId=null,console.log("ð Filtros limpos, recorte fixo mantido:",this.activeFilters)},async fetchSelectedFilters(e={}){if(!this.campaignId)return console.warn("â ï¸ Campaign ID não definido para buscar filtros selecionados"),{};try{const{data:s,success:t}=await f(`/api/${this.campaignId}/filters/selected`,{query:e}),a=t.value&&Array.isArray(s.value)?s.value:[],i=$(...a.filter(r=>r.isSelected!==!1).map(r=>
1({[r.key]:r.values.map(l=>l.value)})));return this.serverSelectedFilters=i,console.log("ð [SELECTED-FILTERS] Recorte fixo do servidor:",i),i}catch(s){return console.error("â [SELECTED-FILTERS] Erro ao buscar filtros selecionados:",s),this.serverSelectedFilters={},{}}},async fetchWinnieFilters(){if(!this.campaignId){console.warn("â ï¸ Campaign ID não definido para buscar filtros Winnie");return}try{console.log(`ð¯ [WINNIE-FILTERS] Buscando filtros para campanha ${this.campaignId}...`);const{data:e,success:s}=await f(`/api/${this.campaignId}/filters/winnie`);s.value&&e.value?(this.winnieFilters=e.value,this.excludeDimensions=Object.values(e.value).filter(t=>t.status==="exclude").map(t=>t.key),console.log("â
[WINNIE-FILTERS] Filtros carregados:",Object.keys(this.winnieFilters).length),console.log("ð« [EXCLUDE-DIMENSIONS] Dimensões a excluir:",this.excludeDimensions)):(console.warn("â ï¸ [WINNIE-FILTERS] Nenhum filtro encontrado"),this.winnieFilters=null,this.excludeDimensions=[])}catch(e){console.error("â [WINNIE-FILTERS] Erro ao buscar filtros:",e),this.winnieFilters=null,this.excludeDimensions=[]}},async fetchAvailableReports(){if(this.campaignId)try{const e=this.availableReports.length,{data:s,success:t}=await f(`/api/campaign-report/${this.campaignId}/list`);t.value&&s.value?.success?(this.availableReports=s.value.data||[],this.isPreparingNewReport&&this.availableReports.length>e&&(console.log("â
Novo relatório detectado na lista, removendo placeholder"),this.isPreparingNewReport=!1)):this.availableReports=[]}catch(e){console.error("â Erro ao buscar relatórios disponÃveis:",e),this.availableReports=[]}finally{this.reportsLoaded=!0}},async selectReport(e){const s=this.availableReports.find(a=>a._id===e);if(!s){console.warn("â ï¸ Relatório não encontrado:",e);return}console.log("ð Relatório selecionado:",s.label),this.selectedReportId=e,this.selectedReportOwnerId=s.created_by?.user_id||null,this.activeFilters=s.applied_filters||{},await this.fetchReport(),await this.fetchAllAIInsights();const t=this.reportData?.insights?.favorability?.insights?.general?.json_result?.group_analysis;if(t&&t.length>0){const a=t.slice(0,5);let i=!1;for(let r=0;r<a.length;r++){const l=a[r].variable;if(!this.hasAIAnalysisForFilter(l)){i=!0;break}}i&&(console.log("ð [STORE] Relatório selecionado não tem insights completos, gerando automaticamente..."),await this.generateAllInsights())}},comDono(e,s){const t=s===void 0?this.selectedReportOwnerId:s;if(!t)return e;const a=e.includes("?")?"&":"?";return`${e}${a}owner=${encodeURIComponent(t)}`},async syncFiltersFromCampaignStore(e){const s=$(L(e)),t=await this.fetchSelectedFilters(),a=$({...t,...s});console.log("ð Sincronizando filtros do CampaignStore:",{selecionados:s,fixos:t,filters:a}),this.setFilters(a)},async checkAndResumeProcessingJobs(){if(!this.campaignId){console.log("â ï¸ checkAndResumeProcessingJobs: Sem campaignId");return}console.log("ð [RESUME] Verificando jobs em processamento ao montar componente...");try{const e=this.reportData?.insights?.favorability?.insights?.general?.json_result?.group_analysis;if(!e?.length)return;const s=e.slice(0,5);for(const t of s){const a=t.variable;!(this.hasAIAnalysisForFilter(a)||await this.fetchAIInsights(a))&&!(a in this.aiAnalysis)&&await this.checkIfProcessing("general",a)&&(console.log(`â³ [RESUME] Insight para filtro ${a} está processando, retomando polling...`),this.resumePollingForInsight(a))}}catch(e){console.error("â [RESUME] Erro ao verificar jobs em processamento:",e)}},async checkIfProcessing(e,s){if(!this.campaignId)return!1;try{if(e==="general"){let t=`/api/campaign-report/${this.campaignId}/ai-insights`;s&&(t+=`?filterName=${encodeURIComponent(s)}`);const{data:a}=await f(t);return a.value?.data?.status==="processing"}return!1}catch(t){return console.error(`â Erro ao verificar status de ${e}:`,t),!1}},async resumePollingForInsight(e){this.generatingAI=!0,this.generatingAIMap[e]=!0,console.log(`ð [RESUME] Retomando polling para insight do filtro: ${e}...`);try{await _((t,a)=>(console.log(`â³ [RESUME] Smart Polling insights AI (${e}): tentativa ${t} (${Math.floor(a/1e3)}s)`),this.fetchAIInsights(e).then(i=>i?!0:null)),{maxAttempts:90,onProgress:(t,a,i)=>{console.log(`ð [RESUME] Progresso: ${t}s decorridos, próximo check em ${a/1e3}s`)}})?console.log(`â
[RESUME] Insight do filtro ${e} completado após retomar polling`):(console.log("â ï¸ [RESUME] Polling atingiu timeout máximo"),this.error="Análise está demorando mais que o esperado. Tente recarregar a página.")}catch(s){console.error("â [RESUME] Erro ao retomar polling:",s)}finally{this.generatingAI=!1,this.generatingAIMap[e]=!1}
1},setError(e){this.error=e,this.loading=!1,this.generating=!1,this.generatingAI=!1,this.generatingAIMap={},this.isPreparingNewReport=!1},clearError(){this.error=null},clearData(){this.reportData=null,this.aiAnalysis={},this.error=null,this.loading=!1,this.generating=!1,this.generatingAI=!1,this.generatingAIMap={}},async fetchReport(){if(!this.campaignId){this.setError("ID da campanha não fornecido");return}this.loading=!0,this.clearError();try{let e=`/api/campaign-report/${this.campaignId}`;if(Object.keys(this.activeFilters).length>0){const a=JSON.stringify(this.activeFilters);e+=`?filters=${encodeURIComponent(a)}`}e=this.comDono(e),console.log(`ð¡ fetchReport: Fazendo requisição para ${e}`);const{data:s,success:t}=await f(e);return console.log("ð¡ fetchReport: Response recebido:",{success:t.value,dataExists:!!s.value,dataSuccess:s.value?.success,dataData:!!s.value?.data}),t.value&&s.value?.success?(this.reportData=s.value.data,this.reportData?.insights?.favorability?.insights?.general?.json_result||console.log("â ï¸ Relatório existe mas não contém dados de favorabilidade"),console.log("â
Relatório carregado com sucesso - ID:",s.value.data?.id||"N/A"),!0):(this.reportData=null,console.log("ð Relatório não existe ainda - Response:",s.value),!1)}catch(e){return console.error("â Erro ao carregar relatório:",{message:e.message,status:e.status,statusCode:e.statusCode,data:e.data,campaignId:this.campaignId}),e.status!==404&&this.setError(e.message||"Erro ao carregar relatório"),this.reportData=null,!1}finally{this.loading=!1}},async fetchReportData(e,s){if(!this.campaignId)return null;try{let t=`/api/campaign-report/${this.campaignId}`;Object.keys(e).length>0&&(t+=`?filters=${encodeURIComponent(JSON.stringify(e))}`);const{data:a,success:i}=await f(this.comDono(t,s));return i.value&&a.value?.success?a.value.data:null}catch(t){return console.error("â fetchReportData: erro ao buscar dados do relatório:",t),null}},async generateReport(){if(!this.campaignId)return this.setError("ID da campanha não fornecido"),!1;const{podeGerarRelatorioGeral:e}=U();if(Object.keys(this.activeFilters).length===0&&!e.value)return console.log("ð« [STORE] Relatório geral é restrito a administradores â geração não disparada"),this.isPreparingNewReport=!1,this.generating=!1,!1;const{startProcessing:t,stopProcessing:a,markAsFailed:i}=P(),r=`report-${this.campaignId}`;let l=!1;try{this.generating=!0,this.isPreparingNewReport=!0,console.log("ð¯ [STORE] isPreparingNewReport = true (iniciando geração)"),t(r,"report","Gerando relatório da campanha");try{const{csrf:o}=O(),g={filters:this.activeFilters,analysis_types:["favorability"],exclude_dimensions:this.excludeDimensions};console.log("ð¤ [GENERATE] Solicitando geração:",JSON.stringify(g,null,2)),console.log("ð« [EXCLUDE-DIMENSIONS] Excluindo dimensões:",this.excludeDimensions);const h=await $fetch(`/api/campaign-report/${this.campaignId}/generate-report`,{method:"POST",headers:{"Content-Type":"application/json",...o?{"csrf-token":o}:{}},body:g,timeout:3e4});if(h?.success===!1)return this.setError(h.error||"Não foi possÃvel iniciar a geração do relatório"),i(r,"Falha ao iniciar a geração do relatório"),l=!0,!1;if(h?.status==="exists")return console.log("â»ï¸ [GENERATE] Relatório geral já existe, reaproveitando"),this.isPreparingNewReport=!1,await this.fetchAvailableReports(),await this.fetchReport(),!0}catch(o){console.warn("â ï¸ [GENERATE] Sem resposta ao solicitar a geração, seguindo para polling:",o)}await new Promise(o=>setTimeout(o,2e3)),await this.fetchAvailableReports();const n=90,c=1e4;for(let o=0;o<n;o++)try{o>0&&await this.fetchAvailableReports();let g=`/api/report/${this.campaignId}`;if(Object.keys(this.activeFilters).length>0){const d=JSON.stringify(this.activeFilters);g+=`?filters=${encodeURIComponent(d)}`}const h=await $fetch(g);if(h?.status==="completed")return await this.fetchReport(),await this.fetchAvailableReports(),!0;if(h?.status==="failed")throw new Error("Falha na geração do relatório");await new Promise(d=>setTimeout(d,c))}catch{if(o===n-1)throw new Error("Timeout aguardando relatório ficar pronto");await new Promise(h=>setTimeout(h,c))}throw new Error("Timeout aguardando relatório")}catch(n){return this.error=n.message||"Erro desconhecido na geração do relatório",i(r,"Erro ao gerar relatório"),l=!0,!1}finally{this.generating=!1,l&&(this.isPreparingNewReport=!1),l||a(r)}},async generateAIInsights(e,s,t=!1,a){const i=Date.now(),{startProcessing:r,stopProcessing:l,markAsFailed:n}=P(),c=`ai-insights-${this.campaignId}-${e}`;let o=!1;const g=a?.appliedFilters??this.activeFilters,h=a?.reportData??this.reportData,d=a?.ownerId===void 0?this.selectedReportOwnerId:a.ownerId;try{if(this.generatingAI=!0,this.generatingAIMap[e]=!0,r(c,"insights",`Gerando insights: ${e}`),console.log(`ð§ [STORE] generateAIInsights: Iniciando para campanha ${this.campaignId}, filtro ${e}`),console.log(`ð [STORE] Hora de inÃcio: ${new Date().toISOString()}`),!h||!h.insights?.favorability?.insights?.general?.json_result)return console.log("â ï¸ [STORE] Relatório sem dados suficientes para gerar insights"),this.error="Não há dados suficientes no relatório para gerar insights de IA",!1;const I=h.insights?.favorability?.insights?.general?.json_result?.key_metrics||[];if(I.length===0)return console.log("â ï¸ [STORE] Nenhuma métrica encontrada no relatório"),this.error="Não há métricas suficientes no relatório para gerar insights de IA",!1;console.log(`â
[STORE] Validação passou - ${I.length} métricas encontradas`);const{csrf:E}=O();try{const y=Date.now();console.log(`ð¤ [STORE] Enviando requisição POST para filtro ${e}...`),console.log(`ð [STORE] forceRegenerate: ${t}`);const D={filters:g,filterName:e,filterIndex:s,forceRegenerate:t,...d?{owner:d}:{}};console.log("ð¦ [STORE] Body da requisição:",D);const{data:p,success:A,error:w}=await f(`/api/campaign-report/${this.campaignId}/generate-ai-insights`,{method:"POST",headers:{"Content-Type":"application/json",...E?{"csrf-token":E}:{}},body:JSON.stringify(D)}),M=Date.now()-y;if(console.log(`ð¥ [STORE] Resposta recebida em ${M}ms:`,{success:A.value,dataExists:!!p.value,dataSuccess:p.value?.success,errorExists:!!w.value}),!A.value&&w.value)throw new Error(w.value?.message||"Erro ao gerar insights de IA");if(A.value&&p.value?.success){if(p.value.status==="processing")return console.log(`â
[STORE] Job criado para filtro ${e}, iniciando polling...`),await _((S,b)=>(console.log(`â³ Smart Polling insights AI (${e}): tentativa ${S} (${Math.floor(b/1e3)}s)`),this.fetchAIInsights(e,g,d).then(F=>F?!0:null)),{maxAttempts:90,onProgress:(S,b,F)=>{console.log(`ð Progresso: ${S}s decorridos, próximo check em ${b/1e3}s`)}})?(console.log(`â
Insights IA encontrados para filtro ${e} com smart polling`),!0):(this.error="Análise está demorando mais que o esperado. Tente recarregar a página.",!1);if(p.value.status==="no_data")return console.log(`â¹ï¸ [STORE] Filtro ${e} sem dados suficientes para insights; nada a gerar`),!0;this.aiAnalysis[e]=p.value.data;const x=Date.now()-i;return console.log(`â
[STORE] Insights IA gerados para filtro ${e} em ${x}ms`),!0}else return console.error(`â [STORE] Falha na geração dos insights IA para filtro ${e}:`,p.value),this.error=p.value?.error||"Erro desconhecido na geração dos insights IA",!1}catch(y){throw console.error("â [STORE] Erro inesperado:",y),y}}catch(I){const E=Date.now()-i;return console.error(`â [STORE] Erro final após ${E}ms:`,{message:I.message,filterName:e,campaignId:this.campaignId}),this.error=I.message||"Erro desconhecido na geração dos insights IA",n(c,"Erro ao gerar insights de IA"),o=!0,!1}finally{this.generatingAI=!1,this.generatingAIMap[e]=!1,o||l(c)}},async fetchAIInsights(e,s,t){if(!this.campaignId)return this.setError("ID da campanha não fornecido"),!1;const a=s??this.activeFilters;try{let i=`/api/campaign-report/${this.campaignId}/ai-insights?filterName=${encodeURIComponent(e)}`;if(i=this.comDono(i,t),Object.keys(a).length>0){const n=JSON.stringify(a);i+=`&filters=${encodeURIComponent(n)}`}console.log(`ð¡ fetchAIInsights(${e}): Fazendo requisição para ${i}`);const{data:r,success:l}=await f(i);if(console.log(`ð¡ fetchAIInsights(${e}): Response recebido:`,{success:l.value,dataExists:!!r.value,dataSuccess:r.value?.success,dataData:!!r.value?.data,status:r.value?.data?.status}),l.value&&r.value?.success){const n=r.value.status||r.value.data?.status;if(n==="completed"&&r.value?.data)return this.aiAnalysis[e]=r.value.data,console.log(`â
Insights IA carregados para filtro ${e} (completed)`),!0;if(n==="processing")return console.log(`â³ Insights IA ainda processando para filtro ${e}...`),!1;if(n==="failed"){const c=r.value.data?.error?.message||r.value.message||"Erro ao gerar insights",o=r.value.data?.error?.code||"UNKNOWN_ERROR";return console.error(`â Insights IA falharam para filtro ${e}:`,{errorMsg:c,errorCode:o}),this.error=`Falha ao gerar insights para "${e}": ${c}`,!0}else if(n==="not_generated")return console.log(`ð¤ Insights IA não foram gerados ainda para filtro ${e}`),!0}return console.log(`ð¤ Insights IA não existem para filtro ${e}`),!1}catch(i){return console.error(`â Erro ao carregar insights IA para filtro ${e}:`,i.message),!1}},async fetchAllAIInsights(){if(!this.campaignId)return!1;const e=this.reportData?.insights?.favorability?.insights?.general?.json_result?.group_analysis;if(!e?.length)return!1;const s=e.slice(0,5),a=(await Promise.all(s.map(i=>this.fetchAIInsights(i.variable)))).every(Boolean);
1return console.log(`ð¡ fetchAllAIInsights: ${Object.keys(this.aiAnalysis).length}/${s.length} filtros carregados`),a},async generateAllInsights(e=!1,s){const t=s?.appliedFilters??this.activeFilters,a=s?.reportData??this.reportData;if(!this.campaignId||!a)return console.warn("â ï¸ Sem campaignId ou reportData para gerar insights"),!1;const i=a?.insights?.favorability?.insights?.general?.json_result?.group_analysis;if(!i?.length)return console.warn("â ï¸ Sem group_analysis para gerar insights"),!1;const r=i.slice(0,5);console.log(`ð Gerando insights para ${r.length} filtros (forceRegenerate: ${e})...`);try{const l=r.map((n,c)=>{const o=n.variable;return console.log(`ð [${c+1}/${r.length}] Disparando insight para filtro: ${o} (forceRegenerate: ${e})`),this.generateAIInsights(o,c,e,{appliedFilters:t,reportData:a,ownerId:s?.ownerId})});return await Promise.allSettled(l),console.log("â
Todos os insights foram disparados para geração em paralelo"),!0}catch(l){return console.error("â Erro ao gerar insights:",l),!1}},async ensureReportReady(){if(!this.campaignId)return this.setError("ID da campanha não fornecido"),!1;this.generating=!0,this.clearError();try{return console.log("ð ensureReportReady: Verificando relatório existente..."),await this.fetchReport()&&this.reportData?.status==="completed"?(console.log("â
Relatório encontrado:",this.reportData),!0):(console.log("ð Gerando novo relatório para campanha:",this.campaignId),await this.generateReport())}catch(e){const s=e.message||"Erro desconhecido";return this.setError(s),console.error("â Erro no fluxo do relatório:",s),!1}finally{this.generating=!1}},async ensureDataComplete(){if(console.log("ð¯ [STORE] ensureDataComplete: INÃCIO DA FUNÃÃO"),!this.campaignId)return console.log("â ensureDataComplete: Sem campaignId"),this.setError("ID da campanha não fornecido"),!1;try{if(console.log("ð [STORE] ensureDataComplete: Verificando dados da campanha...",this.campaignId),this.loading=!0,this.clearError(),!await this.fetchReport()){if(!await this.generateReport())return!1;await new Promise(t=>setTimeout(t,1e3)),await this.fetchReport()}if(!this.reportData?.insights?.favorability?.insights?.general?.json_result)return console.log("â ï¸ ensureDataComplete: Relatório existe mas não tem dados suficientes"),this.reportData?.status==="completed"?this.setError("A campanha foi processada mas não possui respostas válidas. Verifique se há dados na pesquisa."):this.setError("O relatório não contém dados suficientes para gerar insights"),!1;if(await this.generateAllInsights(),await this.fetchAvailableReports(),this.availableReports.length>0){const s=Object.keys(this.activeFilters).length>0;let t;s?t=this.availableReports.find(a=>JSON.stringify(a.applied_filters)===JSON.stringify(this.activeFilters)):t=this.availableReports.find(a=>a.is_general===!0),t?(this.selectedReportId=t._id,console.log("â
Relatório auto-selecionado:",t.label)):s||(t=this.availableReports.find(a=>!a.applied_filters||Object.keys(a.applied_filters).length===0),t&&(this.selectedReportId=t._id,console.log("â
Relatório sem filtros auto-selecionado:",t.label)))}return!0}catch(e){return console.error("Erro em ensureDataComplete:",e),this.isPreparingNewReport=!1,!1}finally{this.loading=!1}}}}),V=Object.freeze(Object.defineProperty({__proto__:null,useWinnieExpertStore:q},Symbol.toStringTag,{value:"Module"}));export{U as a,q as u,V as w};
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.