callix-dialer-widget 1.1.7 → 1.1.9

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.
@@ -53084,7 +53084,8 @@ function FloatingDialer({
53084
53084
  onLogin,
53085
53085
  onLogout,
53086
53086
  isLoadingSession,
53087
- sessionError
53087
+ sessionError,
53088
+ variant = "default"
53088
53089
  }) {
53089
53090
  const containerRef = useRef(null);
53090
53091
  const cardRef = useRef(null);
@@ -53110,6 +53111,7 @@ function FloatingDialer({
53110
53111
  });
53111
53112
  const prevAuthRef = useRef(isAuthenticated);
53112
53113
  const dialValue = useMemo(() => sanitizeDialInput(rawDialValue), [rawDialValue]);
53114
+ const isMiniMode = variant === "min";
53113
53115
  const contentScale = useMemo(() => {
53114
53116
  const widthRatio = observedSize.width / DEFAULT_DIALER_DIMENSIONS.width;
53115
53117
  const heightRatio = observedSize.height / DEFAULT_DIALER_DIMENSIONS.height;
@@ -53401,7 +53403,8 @@ function FloatingDialer({
53401
53403
  username: username ?? "",
53402
53404
  dialValue,
53403
53405
  setDialValue: updateDialValue,
53404
- onLogout
53406
+ onLogout,
53407
+ variant
53405
53408
  }
53406
53409
  ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
53407
53410
  LoginForm,
@@ -53412,6 +53415,17 @@ function FloatingDialer({
53412
53415
  error: sessionError
53413
53416
  }
53414
53417
  );
53418
+ if (isMiniMode) {
53419
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
53420
+ "div",
53421
+ {
53422
+ className: ["callix", "mode", "min", tw`w-full`].join(" "),
53423
+ "data-callix-variant": "min",
53424
+ style: { width: "100%", height: "100%" },
53425
+ children: dialerContent
53426
+ }
53427
+ );
53428
+ }
53415
53429
  const scale = Number.isFinite(contentScale) && contentScale > 0 ? contentScale : 1;
53416
53430
  const scaledWidth = DEFAULT_DIALER_DIMENSIONS.width / scale;
53417
53431
  const scaledHeight = DEFAULT_DIALER_DIMENSIONS.height / scale;
@@ -53443,7 +53457,8 @@ function FloatingDialer({
53443
53457
  "div",
53444
53458
  {
53445
53459
  ref: containerRef,
53446
- className: tw`fixed z-50 select-none`,
53460
+ className: ["callix", "mode", "full", tw`fixed z-50 select-none`].join(" "),
53461
+ "data-callix-variant": "default",
53447
53462
  style: {
53448
53463
  transform: `translate3d(${position2.x}px, ${position2.y}px, 0)`,
53449
53464
  top: 0,
@@ -53592,9 +53607,10 @@ function LoginForm({ defaultValue, onSubmit, isLoading, error: error2 }) {
53592
53607
  )
53593
53608
  ] });
53594
53609
  }
53595
- function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
53610
+ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, variant }) {
53596
53611
  var _a2, _b;
53597
53612
  const operator = clientSdkReactExports.useCallOperator();
53613
+ const isMiniMode = variant === "min";
53598
53614
  const operatorState = clientSdkReactExports.useCallOperatorState();
53599
53615
  const currentCall = clientSdkReactExports.useCallOperatorCurrentCall();
53600
53616
  const currentCallInfo = clientSdkReactExports.useCallOperatorCurrentCallInfo();
@@ -54297,6 +54313,167 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
54297
54313
  }
54298
54314
  );
54299
54315
  }
54316
+ const breakModal = isBreakModalOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`bg-white rounded-2xl shadow-2xl max-w-md w-full p-6 space-y-4`, children: [
54317
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between`, children: [
54318
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: tw`text-lg font-bold text-slate-800`, children: "Selecione uma Pausa" }),
54319
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
54320
+ "button",
54321
+ {
54322
+ type: "button",
54323
+ onClick: () => {
54324
+ setIsBreakModalOpen(false);
54325
+ setBreakError(null);
54326
+ },
54327
+ className: tw`text-slate-400 hover:text-slate-600 transition`,
54328
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-xl` })
54329
+ }
54330
+ )
54331
+ ] }),
54332
+ breakError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`rounded-lg bg-red-50 border border-red-200 px-3 py-2 flex items-start gap-2`, children: [
54333
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`text-red-500 shrink-0 mt-0.5` }),
54334
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm text-red-700`, children: breakError })
54335
+ ] }),
54336
+ !breaks || breaks.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`text-center py-8`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-slate-500`, children: "Nenhuma pausa disponivel" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`space-y-2 max-h-96 overflow-y-auto`, children: breaks.map((breakItem) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
54337
+ "button",
54338
+ {
54339
+ type: "button",
54340
+ onClick: () => handleGoOnBreak(breakItem.id),
54341
+ className: tw`w-full flex items-center gap-3 rounded-lg border border-slate-200 bg-white px-4 py-3 text-left transition-all hover:border-amber-300 hover:bg-amber-50 hover:shadow-md`,
54342
+ children: [
54343
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-xl text-amber-600 shrink-0` }),
54344
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex-1 min-w-0`, children: [
54345
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`font-semibold text-slate-800 truncate`, children: breakItem.name }),
54346
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: tw`text-xs text-slate-500`, children: [
54347
+ "ID: ",
54348
+ breakItem.id
54349
+ ] })
54350
+ ] })
54351
+ ]
54352
+ },
54353
+ breakItem.id
54354
+ )) }),
54355
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
54356
+ "button",
54357
+ {
54358
+ type: "button",
54359
+ onClick: () => {
54360
+ setIsBreakModalOpen(false);
54361
+ setBreakError(null);
54362
+ },
54363
+ className: tw`w-full rounded-lg border border-slate-200 bg-slate-50 px-4 py-2 text-sm font-semibold text-slate-600 transition hover:bg-slate-100`,
54364
+ children: "Cancelar"
54365
+ }
54366
+ )
54367
+ ] }) }) : null;
54368
+ if (isMiniMode) {
54369
+ const isCallActive = isInCall || isConnecting;
54370
+ const callButtonDisabled = !isCallActive && !isNumberValid;
54371
+ const miniCanUseKeypad = !availabilityError && (canUseKeypad || isIdle || isOnBreak);
54372
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
54373
+ "div",
54374
+ {
54375
+ className: ["callix", "mode", "min", tw`flex w-full max-w-full flex-col gap-3 rounded-2xl border border-slate-200 bg-white/95 p-3 shadow-sm text-slate-800`].join(" "),
54376
+ "data-callix-variant": "min",
54377
+ children: [
54378
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between gap-2`, children: [
54379
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`${statusVisual.badgeClass} flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase leading-tight`, children: [
54380
+ /* @__PURE__ */ jsxRuntimeExports.jsx(statusVisual.Icon, { className: tw`text-xs` }),
54381
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: statusLabel })
54382
+ ] }),
54383
+ isOnBreak ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
54384
+ "button",
54385
+ {
54386
+ type: "button",
54387
+ onClick: () => handleGoOffBreak(),
54388
+ className: tw`inline-flex items-center gap-1 rounded-full border border-emerald-400 bg-emerald-50 px-2.5 py-1 text-[10px] font-semibold text-emerald-700 transition hover:bg-emerald-100`,
54389
+ children: [
54390
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FiCheckCircle, { className: tw`text-xs` }),
54391
+ "Voltar"
54392
+ ]
54393
+ }
54394
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
54395
+ "button",
54396
+ {
54397
+ type: "button",
54398
+ onClick: () => setIsBreakModalOpen(true),
54399
+ className: tw`inline-flex items-center gap-1 rounded-full border border-amber-300 bg-amber-50 px-2.5 py-1 text-[10px] font-semibold text-amber-700 transition hover:bg-amber-100`,
54400
+ children: [
54401
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-xs` }),
54402
+ "Pausa"
54403
+ ]
54404
+ }
54405
+ )
54406
+ ] }),
54407
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`space-y-1 rounded-xl border border-slate-200 bg-slate-50 px-3 py-2`, children: [
54408
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-[10px] font-semibold uppercase tracking-wide text-slate-500`, children: "Numero" }),
54409
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center gap-2`, children: [
54410
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`flex-1 truncate text-lg font-semibold text-slate-800`, children: dialDisplayText || /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-slate-400 text-base font-normal`, children: "Digite um numero" }) }),
54411
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
54412
+ "button",
54413
+ {
54414
+ type: "button",
54415
+ onClick: handleBackspace,
54416
+ disabled: !miniCanUseKeypad,
54417
+ className: tw`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-slate-300 bg-white text-slate-600 transition hover:border-slate-400 hover:text-slate-800 disabled:opacity-40 disabled:cursor-not-allowed`,
54418
+ "aria-label": "Apagar ultimo digito",
54419
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiDelete, { className: tw`text-base` })
54420
+ }
54421
+ ),
54422
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
54423
+ "button",
54424
+ {
54425
+ type: "button",
54426
+ onClick: handleClear,
54427
+ disabled: !miniCanUseKeypad,
54428
+ className: tw`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-rose-300 bg-rose-50 text-rose-600 transition hover:border-rose-400 hover:bg-rose-100 disabled:opacity-40 disabled:cursor-not-allowed`,
54429
+ "aria-label": "Limpar numero",
54430
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-sm` })
54431
+ }
54432
+ )
54433
+ ] })
54434
+ ] }),
54435
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`grid grid-cols-3 gap-2`, children: keypadKeys.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
54436
+ "button",
54437
+ {
54438
+ type: "button",
54439
+ onClick: () => handleDial(item.value),
54440
+ disabled: !miniCanUseKeypad,
54441
+ className: tw`flex h-12 flex-col items-center justify-center rounded-lg border border-slate-200 bg-white text-base font-semibold text-slate-800 shadow-sm transition active:scale-95 hover:border-slate-300 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-40`,
54442
+ children: [
54443
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.value }),
54444
+ item.detail && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-[8px] font-semibold uppercase tracking-widest text-slate-400`, children: item.detail })
54445
+ ]
54446
+ },
54447
+ item.value
54448
+ )) }),
54449
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
54450
+ "button",
54451
+ {
54452
+ type: "button",
54453
+ onClick: () => {
54454
+ if (isCallActive) {
54455
+ void handleHangup();
54456
+ } else {
54457
+ void handleCall();
54458
+ }
54459
+ },
54460
+ disabled: callButtonDisabled,
54461
+ className: tw`${isCallActive ? "bg-rose-500 hover:bg-rose-600" : "bg-emerald-500 hover:bg-emerald-600"} flex h-11 w-full items-center justify-center gap-2 rounded-xl text-sm font-bold text-white shadow-md transition disabled:cursor-not-allowed disabled:opacity-60`,
54462
+ children: [
54463
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FiPhone, { className: tw`text-base` }),
54464
+ isCallActive ? "Encerrar" : "Ligar"
54465
+ ]
54466
+ }
54467
+ ),
54468
+ (callError || availabilityError || audioDeviceError) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`rounded-lg border border-rose-200 bg-rose-50 px-2.5 py-2 text-[11px] text-rose-700`, children: [
54469
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`mr-1 inline text-xs` }),
54470
+ callError || availabilityError || audioDeviceError
54471
+ ] }),
54472
+ breakModal
54473
+ ]
54474
+ }
54475
+ );
54476
+ }
54300
54477
  const showActiveSummary = isInCall || isConnecting;
54301
54478
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
54302
54479
  "div",
@@ -54638,58 +54815,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
54638
54815
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: audioDeviceError })
54639
54816
  ] })
54640
54817
  ] }),
54641
- isBreakModalOpen && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`bg-white rounded-2xl shadow-2xl max-w-md w-full p-6 space-y-4`, children: [
54642
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between`, children: [
54643
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: tw`text-lg font-bold text-slate-800`, children: "Selecione uma Pausa" }),
54644
- /* @__PURE__ */ jsxRuntimeExports.jsx(
54645
- "button",
54646
- {
54647
- type: "button",
54648
- onClick: () => {
54649
- setIsBreakModalOpen(false);
54650
- setBreakError(null);
54651
- },
54652
- className: tw`text-slate-400 hover:text-slate-600 transition`,
54653
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-xl` })
54654
- }
54655
- )
54656
- ] }),
54657
- breakError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`rounded-lg bg-red-50 border border-red-200 px-3 py-2 flex items-start gap-2`, children: [
54658
- /* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`text-red-500 shrink-0 mt-0.5` }),
54659
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm text-red-700`, children: breakError })
54660
- ] }),
54661
- !breaks || breaks.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`text-center py-8`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-slate-500`, children: "Nenhuma pausa disponível" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`space-y-2 max-h-96 overflow-y-auto`, children: breaks.map((breakItem) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
54662
- "button",
54663
- {
54664
- type: "button",
54665
- onClick: () => handleGoOnBreak(breakItem.id),
54666
- className: tw`w-full flex items-center gap-3 rounded-lg border border-slate-200 bg-white px-4 py-3 text-left transition-all hover:border-amber-300 hover:bg-amber-50 hover:shadow-md`,
54667
- children: [
54668
- /* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-xl text-amber-600 shrink-0` }),
54669
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex-1 min-w-0`, children: [
54670
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`font-semibold text-slate-800 truncate`, children: breakItem.name }),
54671
- /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: tw`text-xs text-slate-500`, children: [
54672
- "ID: ",
54673
- breakItem.id
54674
- ] })
54675
- ] })
54676
- ]
54677
- },
54678
- breakItem.id
54679
- )) }),
54680
- /* @__PURE__ */ jsxRuntimeExports.jsx(
54681
- "button",
54682
- {
54683
- type: "button",
54684
- onClick: () => {
54685
- setIsBreakModalOpen(false);
54686
- setBreakError(null);
54687
- },
54688
- className: tw`w-full rounded-lg border border-slate-200 bg-slate-50 px-4 py-2 text-sm font-semibold text-slate-600 transition hover:bg-slate-100`,
54689
- children: "Cancelar"
54690
- }
54691
- )
54692
- ] }) }),
54818
+ breakModal,
54693
54819
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
54694
54820
  "button",
54695
54821
  {
@@ -55039,8 +55165,8 @@ function ActiveCallSummary({
55039
55165
  ] })
55040
55166
  ] }) });
55041
55167
  }
55042
- function InlineDialer(props) {
55043
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { width: "100%", height: "100%" }, children: [
55168
+ function InlineDialer({ variant = "default", ...props }) {
55169
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: ["callix", "mode", variant === "min" ? "min" : "inline"].join(" "), "data-callix-variant": variant === "min" ? "min" : "inline", style: { width: "100%", height: "100%" }, children: [
55044
55170
  /* @__PURE__ */ jsxRuntimeExports.jsx(
55045
55171
  "style",
55046
55172
  {
@@ -55085,9 +55211,41 @@ function InlineDialer(props) {
55085
55211
  }
55086
55212
  }
55087
55213
  ),
55088
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "callix-inline-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingDialer, { ...props }) })
55214
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "callix-inline-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingDialer, { ...props, variant }) })
55089
55215
  ] });
55090
55216
  }
55217
+ function deriveOptionsFromElement(element) {
55218
+ const result2 = {};
55219
+ const datasetMode = element.getAttribute("data-callix-mode") || element.dataset.callixMode || element.dataset.mode;
55220
+ const datasetUsername = element.getAttribute("data-callix-username") || element.dataset.callixUsername || element.dataset.username;
55221
+ const classList = Array.from(element.classList);
55222
+ const lowerClasses = classList.map((cls) => cls.toLowerCase());
55223
+ const hasCallixClass = lowerClasses.includes("callix");
55224
+ const normalizedMode = datasetMode ? datasetMode.toLowerCase() : void 0;
55225
+ if (normalizedMode === "min" || normalizedMode === "mini") {
55226
+ result2.uiVariant = "min";
55227
+ } else if (hasCallixClass) {
55228
+ if (lowerClasses.includes("mode-min") || lowerClasses.includes("mode-mini") || lowerClasses.includes("mode") && lowerClasses.includes("min")) {
55229
+ result2.uiVariant = "min";
55230
+ }
55231
+ }
55232
+ if (!result2.presetUsername && datasetUsername) {
55233
+ result2.presetUsername = datasetUsername.trim();
55234
+ }
55235
+ if (!result2.presetUsername) {
55236
+ for (const className of classList) {
55237
+ const match2 = className.match(/(?:user|username|callix-user)[-_:]([A-Za-z0-9.@_-]+)/i);
55238
+ if (match2) {
55239
+ result2.presetUsername = match2[1];
55240
+ break;
55241
+ }
55242
+ }
55243
+ }
55244
+ if (result2.presetUsername) {
55245
+ result2.presetUsername = result2.presetUsername.trim();
55246
+ }
55247
+ return result2;
55248
+ }
55091
55249
  class CallixDialerWidget {
55092
55250
  constructor(options) {
55093
55251
  this.root = null;
@@ -55108,6 +55266,13 @@ class CallixDialerWidget {
55108
55266
  if (!this.container) {
55109
55267
  throw new Error(`Container não encontrado: ${this.options.container}`);
55110
55268
  }
55269
+ const derived = deriveOptionsFromElement(this.container);
55270
+ if (!this.options.uiVariant && derived.uiVariant) {
55271
+ this.options.uiVariant = derived.uiVariant;
55272
+ }
55273
+ if (!this.options.presetUsername && derived.presetUsername) {
55274
+ this.options.presetUsername = derived.presetUsername;
55275
+ }
55111
55276
  this.root = clientExports.createRoot(this.container);
55112
55277
  this.root.render(
55113
55278
  /* @__PURE__ */ jsxRuntimeExports.jsx(StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialerWrapper, { options: this.options }) })
@@ -55148,6 +55313,10 @@ function DialerWrapper({ options }) {
55148
55313
  const [sessionToken, setSessionToken] = useState(null);
55149
55314
  const [callixDomain, setCallixDomain] = useState(null);
55150
55315
  const [isRestoringSession, setIsRestoringSession] = useState(true);
55316
+ const presetUsername = options.presetUsername ? options.presetUsername.trim() : null;
55317
+ const uiVariant = options.uiVariant ?? "default";
55318
+ const autoLoginAttemptedRef = useRef(false);
55319
+ const lastPresetRef = useRef(presetUsername);
55151
55320
  useEffect(() => {
55152
55321
  if (typeof window === "undefined") {
55153
55322
  setIsRestoringSession(false);
@@ -55159,6 +55328,11 @@ function DialerWrapper({ options }) {
55159
55328
  setIsRestoringSession(false);
55160
55329
  return;
55161
55330
  }
55331
+ if (presetUsername && storedLastUsername !== presetUsername) {
55332
+ console.log("[Callix Dialer] Ignorando sessao salva por mismatch com preset:", storedLastUsername, "!=", presetUsername);
55333
+ setIsRestoringSession(false);
55334
+ return;
55335
+ }
55162
55336
  const STORAGE_KEYS = getStorageKeys(storedLastUsername);
55163
55337
  const storedToken = localStorage.getItem(STORAGE_KEYS.SESSION_TOKEN);
55164
55338
  const storedDomain = localStorage.getItem(STORAGE_KEYS.DOMAIN);
@@ -55186,7 +55360,12 @@ function DialerWrapper({ options }) {
55186
55360
  setIsRestoringSession(false);
55187
55361
  }
55188
55362
  }, []);
55189
- const handleLogin = async (user) => {
55363
+ useEffect(() => {
55364
+ if (presetUsername && username !== presetUsername) {
55365
+ setUsername(presetUsername);
55366
+ }
55367
+ }, [presetUsername, username]);
55368
+ const handleLogin = useCallback(async (user) => {
55190
55369
  setIsLoading(true);
55191
55370
  setError(null);
55192
55371
  try {
@@ -55231,14 +55410,32 @@ function DialerWrapper({ options }) {
55231
55410
  } finally {
55232
55411
  setIsLoading(false);
55233
55412
  }
55234
- };
55413
+ }, [options.apiUrl]);
55414
+ useEffect(() => {
55415
+ if (!presetUsername) {
55416
+ lastPresetRef.current = null;
55417
+ autoLoginAttemptedRef.current = false;
55418
+ return;
55419
+ }
55420
+ if (lastPresetRef.current !== presetUsername) {
55421
+ lastPresetRef.current = presetUsername;
55422
+ autoLoginAttemptedRef.current = false;
55423
+ }
55424
+ if (isAuthenticated || isLoading || isRestoringSession || autoLoginAttemptedRef.current) {
55425
+ return;
55426
+ }
55427
+ autoLoginAttemptedRef.current = true;
55428
+ void handleLogin(presetUsername);
55429
+ }, [presetUsername, isAuthenticated, isLoading, isRestoringSession, handleLogin]);
55235
55430
  const handleLogout = () => {
55236
55431
  const currentUsername = username;
55237
- setUsername(null);
55432
+ setUsername(presetUsername ?? null);
55238
55433
  setIsAuthenticated(false);
55239
55434
  setSessionToken(null);
55240
55435
  setCallixDomain(null);
55241
55436
  setError(null);
55437
+ autoLoginAttemptedRef.current = false;
55438
+ lastPresetRef.current = presetUsername ?? null;
55242
55439
  if (typeof window !== "undefined" && currentUsername) {
55243
55440
  try {
55244
55441
  const STORAGE_KEYS = getStorageKeys(currentUsername);
@@ -55262,7 +55459,8 @@ function DialerWrapper({ options }) {
55262
55459
  onLogin: handleLogin,
55263
55460
  onLogout: handleLogout,
55264
55461
  isLoadingSession: isLoading || isRestoringSession,
55265
- sessionError: error2
55462
+ sessionError: error2,
55463
+ variant: uiVariant
55266
55464
  }
55267
55465
  );
55268
55466
  }
@@ -55279,7 +55477,8 @@ function DialerWrapper({ options }) {
55279
55477
  onLogin: handleLogin,
55280
55478
  onLogout: handleLogout,
55281
55479
  isLoadingSession: isLoading,
55282
- sessionError: error2
55480
+ sessionError: error2,
55481
+ variant: uiVariant
55283
55482
  }
55284
55483
  )
55285
55484
  }