1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BMwF3ZB-.js","assets/index-WMTlnV3K.css"])))=>i.map(i=>d[i]); 2import{z as m,B as C,S as B,C as F,E as x,G as H,H as I,I as j,J as y,q as R,K as S,_ as k}from"./index-BMwF3ZB-.js";import{b as D,r as z}from"./capacitorPlugins-BcZPu0V4.js";import{storeInstance as $}from"./vuex-C2quRAe4.js";import{e as L}from"./extractAuthCode-9u5KQ5g3.js";import"./contractingCompanyModules-BoGWi5rD.js";import"./salesStatus-DlrXlO1H.js";const O="sso:deeplink-refresh-once";function _(t){return t?{open:(...o)=>t.open(...o),close:(...o)=>t.close(...o),addListener:(...o)=>t.addListener(...o)}:null}async function q(){try{const t=await k(()=>import("./index-BMwF3ZB-.js").then(o=>o.d_),__vite__mapDeps([0,1]));return _(t?.Browser||null)}catch{}try{return _(window?.Capacitor?.Plugins?.Browser||null)}catch{}try{if(typeof require=="function"){const t=require("@capacitor/browser");return _(t?.Browser||null)}}catch{}return null}function T(t){try{if(typeof window<"u"&&window.localStorage&&typeof window.localStorage.getItem=="function")return window.localStorage.getItem(t)}catch{}try{return R.getItem(t)}catch{return null}}function g(t){try{typeof window<"u"&&window.localStorage&&typeof window.localStorage.removeItem=="function"&&window.localStorage.removeItem(t)}catch{}try{R.remove(t)}catch{}}function v(t){if(t==null)return null;if(typeof t!="string")return t;const o=t.indexOf("|");return o>=0&&o<t.length-1?t.substring(o+1):t}function K(){try{if(typeof window>"u"||!window.sessionStorage)return!1;const t=Number(window.sessionStorage.getItem(O)||"0");return!t||Number.isNaN(t)||Date.now()-t>15e3}catch{return!1}}function M(){try{if(typeof window>"u"||!window.sessionStorage)return;window.sessionStorage.setItem(O,String(Date.now()))}catch{}}function J(){try{if(typeof window>"u"||!window.sessionStorage)return;window.sessionStorage.removeItem(O)}catch{}}function b(){if(!K())return!1;M();try{if(typeof window<"u"&&window.location)return window.location.reload(),!0}catch{}return!1}const Z=D(async({app:t,router:o,store:U})=>{const c=U||$,d=m.is.capacitor?await z():null,n=m.is.capacitor?await q():null;if(!m.is.capacitor||!d){t.config.globalProperties.$capacitorSso={Browser:null,App:null,getCapacitorSsoRedirectUri:C,openSsoBrowser:async()=>{throw new Error("Capacitor SSO Browser indisponÃvel (não-capacitor).")}};return}async function E(i){try{const u=x()||C(),l=await H(i,{redirectUriOverride:u});if(!l?.access_token){I("Não foi possÃvel concluir o login (token não retornado). Tente novamente.","negative",7e3);try{n&&n.close().catch(()=>{})}catch{}return}if(j(l),!c||typeof c.commit!="function"){if(b())return;throw new Error("Store indisponivel para concluir login SSO")}J(),c.commit("person/setHasPersonLogged",!0);let f=null;try{const r=v(T(y))||v(R.getItem(y));let e=null;if(r&&typeof r=="string")try{e=JSON.parse(r)}catch{e=null}else r&&typeof r=="object"&&(e=r);if(e&&typeof e=="object"&&Array.isArray(e.appointments)){const a=c?.state?.cart||null,s=a&&a.cart||null,A=(s&&Array.isArray(s.appointments)?s.appointments:null)||(a&&Array.isArray(a.appointments)?a.appointments:null)||[],P=s&&s.values||a&&a.values||null,h=[...e.appointments];if(Array.isArray(A)&&e.appointments.length>0&&(A.length===0||A.length<e.appointments.length))try{await c.dispatch("cart/addAppointmentsOfCache",h).catch(()=>{try{c.commit("cart/addAppointmentsOfCache",h)}catch{try{s?s.appointments=h:a&&(a.appointments=h)}catch{}}})}catch{}if(e.values&&typeof e.values=="object"&&P&&typeof P=="object"&&a)try{s&&s.values?c.state.cart.cart.values={...c.state.cart.cart.values,...e.values}:a.values&&(c.state.cart.values={...c.state.cart.values,...e.values})}catch{}g(y)}const p=v(T(S))||v(R.getItem(S));p&&typeof p=="string"&&p.length>0&&(f=p,g(S))}catch{try{g(y),g(S)}catch{}}try{await c.dispatch("person/getPerson",!0).catch(()=>{})}catch{}try{n&&n.close().catch(()=>{})}catch{}if(f){try{await o.replace(f).catch(()=>{})}catch{}try{String(o.currentRoute.value?.path||"")!==String(f)&&await o.push(f).catch(()=>{})}catch{}}}catch(u){const l=u?.message||String(u);if(typeof l=="string"&&l.includes("Cannot read properties of undefined (reading 'commit')")&&b())return;I("Erro ao concluir o login no SSO. Tente novamente. 02","negative",7e3);try{n&&n.close().catch(()=>{})}catch{}}}try{const i=typeof d.getLaunchUrl=="function"?await d.getLaunchUrl().catch(()=>null):null;if(i&&i.url){const u=String(i.url),l=L(u);l&&setTimeout(()=>E(l),50)}}catch{}let w=null;try{const i=[B,"eumais",F].map(r=>
2String(r||"").toLowerCase()).filter(Boolean),u=new RegExp(`^(${i.map(r=>r.replace(/[.]/g,"\\.")).join("|")}):`,"i"),l=r=>{const e=String(r||"");if(u.test(e))return!0;try{const a=(new URL(e).protocol||"").toLowerCase();return i.some(s=>a===`${s}:`)}catch{return/^[a-z][a-z0-9+\-.]*:/i.test(e)&&u.test(e)}},f=r=>{const e=String(r?.url||"");if(!l(e))return;const p=L(e);p&&setTimeout(()=>E(p),20)};d.addListener("appUrlOpen",f).then(r=>{w=r&&typeof r.remove=="function"?()=>r.remove().catch(()=>{}):null}).catch(()=>{w=null})}catch{}async function N(i){if(!n)throw new Error("Plugin @capacitor/browser não está disponÃvel.");if(typeof n.addListener=="function")try{n.addListener("browserFinished",()=>{}).catch(()=>{})}catch{}m.is.ios?await n.open({url:i,presentationStyle:"popover"}):await n.open({url:i})}return t.config.globalProperties.$capacitorSso={Browser:n,App:d,openSsoBrowser:N,getCapacitorSsoRedirectUri:C},()=>{try{w&&w()}catch{}try{n&&n.close().catch(()=>{})}catch{}}});export{Z as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.