1"use strict";(globalThis.webpackChunkv2||=[]).push([[5100],{68015(t,e,o){o.d(e,{l:()=>s});class s{static KEY_PREFIX="im_cache";static _localStorageAvailable=null;isLocalStorageAvailable(){if(null!==s._localStorageAvailable)return s._localStorageAvailable;try{const t="__im_cache_test__";localStorage.setItem(t,t),localStorage.removeItem(t),s._localStorageAvailable=!0}catch{s._localStorageAvailable=!1}return s._localStorageAvailable}buildStorageKey(t){return`${s.KEY_PREFIX}:${t.getGroup()}:${t.getKey()}`}get(t){if(!t.isValid()||!this.isLocalStorageAvailable())return null;try{const e=localStorage.getItem(this.buildStorageKey(t));if(!e)return null;const o=JSON.parse(e);return Date.now()>o.expiresAt?(this.delete(t),null):o.data}catch{return null}}set(t,e){if(!e.isValid()||!this.isLocalStorageAvailable())return!1;try{const o={data:t,expiresAt:Date.now()+1e3*e.getExpire()};return localStorage.setItem(this.buildStorageKey(e),JSON.stringify(o)),!0}catch{return!1}}delete(t){if(!t.isValid()||!this.isLocalStorageAvailable())return!1;try{return localStorage.removeItem(this.buildStorageKey(t)),!0}catch{return!1}}has(t){return null!==this.get(t)}flushGroup(t){if(!t||!this.isLocalStorageAvailable())return!1;try{const e=`${s.KEY_PREFIX}:${t}:`,o=[];for(let t=0;t<localStorage.length;t++){const s=localStorage.key(t);s?.startsWith(e)&&o.push(s)}return o.forEach(t=>localStorage.removeItem(t)),!0}catch{return!1}}}},96718(t,e,o){o.d(e,{s:()=>r});class s{key="";constructor(t=180,e="infomoney"){this.expire=Math.max(0,t),this.group=e}getKey(){return this.key}getExpire(){return this.expire}getGroup(){return this.group}isValid(){return this.key.length>0&&this.expire>=0&&this.group.length>0}sanitizeKey(t){return t.toLowerCase().replace(/[^a-z0-9_\-]/g,"_").replace(/_{2,}/g,"_").replace(/^_+|_+$/g,"")}}class r extends s{constructor(t,e=180,o="infomoney"){if(super(e,o),!t)throw new Error("StringCacheOptions: a chave (key) não pode ser vazia");const s=this.sanitizeKey(t);if(!s)throw new Error("StringCacheOptions: a chave (key) resultou vazia após sanitização");this.key=s}}},211876(t,e,o){function s(t){if(!t)return"";let e=5381;for(let o=0;o<t.length;o++)e=(e<<5)+e+t.charCodeAt(o)>>>0;return e.toString(36)}o.d(e,{Y:()=>s})},423696(t,e,o){o.d(e,{p:()=>l});var s=o(68015),r=o(211876),i=o(96718),a=o(915631);const n="favorite_ids",c=("undefined"!=typeof window?window.InfoMoneyPage?.cache_ttl_favorites:void 0)??604800;class l{static cache=new s.l;static buildOptions(t){return new i.s(`user_${(0,r.Y)(t)}`,c,n)}static getauthId(){return a.A.getCookie("auth-id")??null}static get(){const t=this.getauthId();if(!t)return null;const e=this.buildOptions(t),o=this.cache.get(e);return o?o.ownerHash!==(0,r.Y)(t)?(this.cache.delete(e),null):o.ids:null}static set(t){const e=this.getauthId();if(!e)return;const o=this.buildOptions(e),s={ownerHash:(0,r.Y)(e),ids:t};this.cache.set(s,o)}static addId(t){const e=this.getauthId();if(!e)return;const o=this.buildOptions(e),s=this.cache.get(o);if(!s)return;if(s.ownerHash!==(0,r.Y)(e))return void this.cache.delete(o);if(s.ids.includes(t))return;const i={ownerHash:s.ownerHash,ids:[t,...s.ids]};this.cache.set(i,o)}static removeId(t){const e=this.getauthId();if(!e)return;const o=this.buildOptions(e),s=this.cache.get(o);if(!s)return;if(s.ownerHash!==(0,r.Y)(e))return void this.cache.delete(o);const i=s.ids.filter(e=>e!==t);if(i.length===s.ids.length)return;const a={ownerHash:s.ownerHash,ids:i};this.cache.set(a,o)}static invalidate(){const t=this.getauthId();if(!t)return;const e=this.buildOptions(t);this.cache.delete(e)}static invalidateAll(){return this.cache.flushGroup(n)}}},625100(t,e,o){o.r(e);var s=o(173367),r=o(948258),i=o(9845),a=o(423696);const n="FavoritePostByIdUpdated";class c extends s.A{constructor(t={}){super(t),this.userService=new r.A,this.FavoritePostsService=new i.A,this.postId=t.postId}validateConfig(){if(!this.postId)throw new Error("[FlowGetFavoritePostById] postId é obrigatório na configuração")}async execute(){try{this.validateConfig()}catch(t){return console.error("[FlowGetFavoritePostById]",t),void this.dispatchFavoritePostByIdEvent({postId:this.postId||0,post:null,favoriteId:null,loading:!1,error:!0,isAuthenticated:!1})}const t=this.userService.checkAuthStatus();if(!t.isLoggedIn)return console.warn("[FlowGetFavoritePostById] Usuário não autenticado. Fluxo não será executado."),void this.dispatchFavoritePostByIdEvent({postId:this.postId,post:null,favoriteId:null,loading:!1,error:!1,isAuthenticated:!1});if(!t.accessToken)return console.warn("[FlowGetFavoritePostById] Access token não disponÃvel. Fluxo não será executado."),void this.dispatchFavoritePostByIdEvent({postId:this.postId,post:null,favoriteId:null,loading:!1,error:!1,isAuthenticated:!1});this.dispatchFavoritePostByIdEvent({postId:this.postId,post:null,favoriteId:null,loading:!0,error:!1,isAuthenticated:!0});try{const t=await this.findFavoriteId();this.dispatchFavoritePostByIdEvent({postId:this.postId,post:null,favoriteId:t,loading:!1,error:!1,isAuthenticated:!0})}catch(t){console.error("[FlowGetFavoritePostById] Erro ao buscar post salvo:",t),this.dispatchFavoritePostByIdEvent({postId:this.postId,post:null,favoriteId:null,loading:!1,error:!0,isAuthenticated:!0})}}async findFavoriteId(){const t=a.p.get();if(null!==t)return t.includes(this.postId)?String(this.postId):null;const e=await this.loadAllFavorites();if(!e?.length)return null;const o=e.find(t=>parseInt(t.NewsId,10)===this.postId);return o?o.NewsId:null}async loadAllFavorites(){const t=[];try{const e=await this.FavoritePostsService.getAllFavoritePosts();
1t.push(...e.Result)}catch(t){console.warn("[FlowGetFavoritePostById] Erro ao carregar favoritos:",t)}return t}dispatchFavoritePostByIdEvent(t){window.dispatchEvent(new CustomEvent(n,{detail:t}))}}const l=c;o.d(e,["FAVORITE_POST_BY_ID_EVENT",0,n,"default",0,l])},944742(t,e,o){var s=o(915631);o.d(e,["A",0,class{static getConfig(){return{url:window.InfoMoneyPage?.base_api_user_manager||"",subscriptionKey:window.InfoMoneyPage?.base_api_user_manager_ocp_apim_subscription_key||""}}static getCookie(t){return s.A.getCookie(t)||""}static getParams(t){return new URLSearchParams(Object.entries(t).filter(([t,e])=>void 0!==e).reduce((t,[e,o])=>(Array.isArray(o)?t[e]=o.join(","):t[e]=String(o),t),{})).toString()}}])},9845(t,e,o){o.d(e,{A:()=>r});var s=o(944742);class r extends s.A{static _pendingFetch=null;async getAllFavoritePosts(){return r._pendingFetch||(r._pendingFetch=this._fetchAllPages().finally(()=>{r._pendingFetch=null})),r._pendingFetch}async _fetchAllPages(){const t=r.getConfig(),e=r.getCookie("access-token"),o=[];let s=1,i=!0;try{for(;i;){const r=`${t.url}news/favorites?page=${s}`,a=await fetch(r,{method:"GET",headers:{Accept:"application/json","Ocp-Apim-Subscription-Key":t.subscriptionKey,Authorization:`Bearer ${e}`}});if(!a.ok){const t=await a.json();throw new Error(t.message||`Erro ao buscar favoritos na página ${s}`)}const n=await a.json();if(!n.Result||0===n.Result.length)break;o.push(...n.Result),i=n.PageInfo?.HasNextPage??!1,s++}return{Result:o,PageInfo:{HasNextPage:!1}}}catch(t){throw console.error("UserFavoritePostsService._fetchAllPages: Erro ao buscar favoritos:",t),t}}async savePost(t){const e=r.getConfig(),o=`${e.url}news/favorites`,s=r.getCookie("access-token");try{const r=Number(t);if(!Number.isFinite(r))throw new Error("postId inválido");const i=await fetch(o,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","Ocp-Apim-Subscription-Key":e.subscriptionKey,Authorization:`Bearer ${s}`},body:JSON.stringify({newsId:r})});if(!i.ok){const t=await i.json(),e=t.errorMessages?.[0]??t.ErrorMessages?.[0]??t.errors?.[0]??t.message??"Erro ao salvar favorito";throw Object.assign(new Error(e),{statusCode:i.status})}return await i.json()}catch(e){throw console.error(`UserFavoritePostsService.savePost: Erro ao salvar favorito ${t}:`,e),e}}async removeFavoritePost(t){const e=r.getConfig(),o=`${e.url}news/favorites/${t}`,s=r.getCookie("access-token");try{const t=await fetch(o,{method:"DELETE",headers:{Accept:"application/json","Ocp-Apim-Subscription-Key":e.subscriptionKey,Authorization:`Bearer ${s}`}});if(!t.ok){const e=await t.json();throw Object.assign(new Error(e.message||"Erro ao remover favorito"),{statusCode:t.status})}return await t.json()}catch(e){throw console.error(`UserFavoritePostsService.removeFavoritePost: Erro ao remover favorito ${t}:`,e),e}}}}}]);
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.