callix-dialer-widget 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,8 +28,15 @@
28
28
  [&>div]:!transform-none
29
29
  [&>div]:!w-full
30
30
  [&>div]:!max-w-none
31
- [&>div]:scale-75
31
+ [&>div]:scale-60
32
32
  [&>div]:origin-top
33
33
  [&>div]:!overflow-visible
34
+ [&>div]:!rounded-xl
35
+ [&_button]:!py-1
36
+ [&_button]:!px-2
37
+ [&_button]:!text-xs
38
+ [&_input]:!py-1
39
+ [&_input]:!px-2
40
+ [&_input]:!text-xs
34
41
  `,children:m.jsx(zv,{...t})})})}class rg{constructor(t){this.root=null,this.container=null,this.options=t}init(){try{if("string"==typeof this.options.container?this.container=document.querySelector(this.options.container):this.container=this.options.container,!this.container)throw new Error(`Container não encontrado: ${this.options.container}`);this.root=y.createRoot(this.container),this.root.render(m.jsx(t.StrictMode,{children:m.jsx(og,{options:this.options})})),this.options.onReady&&this.options.onReady()}catch(e){this.options.onError?this.options.onError(e):console.error("[Callix Dialer] Erro ao inicializar:",e)}}destroy(){this.root&&(this.root.unmount(),this.root=null)}}const ig=288e5;function og({options:e}){const[n,r]=t.useState(null),[i,o]=t.useState(!1),[a,d]=t.useState(!1),[s,u]=t.useState(null),[l,c]=t.useState(null),[f,h]=t.useState(null),[p,$]=t.useState(!0);t.useEffect(()=>{if("undefined"!=typeof window)try{const t=localStorage.getItem(STORAGE_KEYS.USERNAME),e=localStorage.getItem(STORAGE_KEYS.SESSION_TOKEN),n=localStorage.getItem(STORAGE_KEYS.DOMAIN),i=localStorage.getItem(STORAGE_KEYS.TIMESTAMP);if(t&&e&&n&&i){const a=parseInt(i,10);Date.now()-a<ig?(console.log("[Callix Dialer] Restaurando sessão salva:",t),r(t),c(e),h(n),o(!0)):(console.log("[Callix Dialer] Sessão expirada, limpando..."),localStorage.removeItem(STORAGE_KEYS.USERNAME),localStorage.removeItem(STORAGE_KEYS.SESSION_TOKEN),localStorage.removeItem(STORAGE_KEYS.DOMAIN),localStorage.removeItem(STORAGE_KEYS.TIMESTAMP))}}catch(t){console.error("[Callix Dialer] Erro ao restaurar sessão:",t)}finally{$(!1)}else $(!1)},[]);const v=async t=>{d(!0),u(null);try{const i=e.apiUrl||"/api/user-sdk-session",a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t}),credentials:"same-origin"});if(!a.ok){const t=await a.json().catch(()=>({error:"Erro desconhecido"}));throw new Error(t.error||`Falha na autenticação: ${a.status}`)}const d=await a.json();if(c(d.userSessionToken),h(d.domain||"villelabrasil.callix.com.br"),r(t),o(!0),u(null),"undefined"!=typeof window)try{localStorage.setItem(STORAGE_KEYS.USERNAME,t),localStorage.setItem(STORAGE_KEYS.SESSION_TOKEN,d.userSessionToken),localStorage.setItem(STORAGE_KEYS.DOMAIN,d.domain||"villelabrasil.callix.com.br"),localStorage.setItem(STORAGE_KEYS.TIMESTAMP,Date.now().toString()),console.log("[Callix Dialer] Sessão salva no localStorage")}catch(n){console.warn("[Callix Dialer] Não foi possível salvar sessão:",n)}console.log("[Callix Dialer] Autenticado com sucesso:",t)}catch(n){console.error("[Callix Dialer] Erro ao autenticar:",n),u(n instanceof Error?n.message:"Erro ao autenticar"),o(!1),c(null)}finally{d(!1)}},g=()=>{if(r(null),o(!1),c(null),h(null),u(null),"undefined"!=typeof window)try{localStorage.removeItem(STORAGE_KEYS.USERNAME),localStorage.removeItem(STORAGE_KEYS.SESSION_TOKEN),localStorage.removeItem(STORAGE_KEYS.DOMAIN),localStorage.removeItem(STORAGE_KEYS.TIMESTAMP),console.log("[Callix Dialer] Sessão removida do localStorage")}catch(t){console.warn("[Callix Dialer] Não foi possível limpar sessão:",t)}},y="inline"===e.mode?ng:zv;return i&&l&&f?m.jsx(_f.CallixClientProvider,{domain:f,userSessionToken:l,children:m.jsx(y,{isAuthenticated:i,username:n,onLogin:v,onLogout:g,isLoadingSession:a,sessionError:s})}):m.jsx(y,{isAuthenticated:!1,username:n,onLogin:v,onLogout:g,isLoadingSession:a||p,sessionError:s})}const ag={CallixDialerWidget:rg,init:function(t){const e=new rg(t);return e.init(),e}};return"undefined"!=typeof window&&(window.CallixDialer=ag),ag});
35
42
  //# sourceMappingURL=callix-dialer.umd.js.map