{"version":3,"file":"dodge.mjs","names":[],"sources":["../../../src/base-ui/Toast/dodge.ts"],"sourcesContent":["export const TOAST_WIDTH = 360;\nexport const TOAST_MIN_WIDTH = 260;\nexport const TOAST_EDGE = 16;\nexport const TOAST_ROW_HEIGHT = 88;\nexport const TOAST_DODGE_GUTTER = 12;\n\n// Spring baked as linear(): stiffness 460 / damping 53 / mass 2.3, zeta ~0.81\n// with 1.2% overshoot. The duration is the spring's settle time — change them\n// together with the curve, not independently.\nexport const TOAST_DODGE_DURATION = '608ms';\nexport const TOAST_DODGE_EASE =\n  'linear(0, 0.08, 0.249, 0.437, 0.607, 0.745, 0.847, 0.917, 0.963, 0.99, 1.004, 1.011, 1.012, 1.011, 1.009, 1.007, 1.005, 1.003, 1.002, 1)';\n\nexport const TOAST_SHIFT_X_VAR = '--toast-shift-x';\nexport const TOAST_SHIFT_Y_VAR = '--toast-shift-y';\nexport const TOAST_WIDTH_VAR = '--toast-width';\nexport const PANEL_RESERVE_VAR = '--floating-panel-reserve-block-end';\nexport const PANEL_ALIGN_INLINE_VAR = '--floating-panel-reserve-inline-end';\n\nexport interface ToastDodgeInput {\n  panelHeight: number;\n  panelOffsetX: number;\n  panelOffsetY: number;\n  panelWidth: number;\n  viewportHeight: number;\n  viewportWidth: number;\n}\n\nexport type ToastDodgeMode = 'left' | 'reserve' | 'shrink' | 'up';\n\nexport interface ToastDodgeResult {\n  alignInline: number;\n  mode: ToastDodgeMode;\n  reserve: number;\n  shiftX: number;\n  shiftY: number;\n  width: number;\n}\n\nexport const resolveToastDodge = ({\n  panelHeight,\n  panelOffsetX,\n  panelOffsetY,\n  panelWidth,\n  viewportHeight,\n  viewportWidth,\n}: ToastDodgeInput): ToastDodgeResult => {\n  const shiftX = Math.max(0, panelWidth + panelOffsetX + TOAST_DODGE_GUTTER - TOAST_EDGE);\n  const shiftY = Math.max(0, panelHeight + panelOffsetY + TOAST_DODGE_GUTTER - TOAST_EDGE);\n  const lane = viewportWidth - shiftX - TOAST_EDGE * 2;\n  const headroom = viewportHeight - shiftY - TOAST_EDGE * 2;\n\n  // The panel sits closer to the edge than the toast does, so the pair reads as\n  // misaligned until the panel is pushed out to the toast's inset. Which axis\n  // needs it follows which edge the two end up sharing.\n  const alignBlock = Math.max(0, TOAST_EDGE - panelOffsetY);\n  const alignInline = Math.max(0, TOAST_EDGE - panelOffsetX);\n\n  if (lane >= TOAST_WIDTH) {\n    return {\n      alignInline: 0,\n      mode: 'left',\n      reserve: alignBlock,\n      shiftX,\n      shiftY: 0,\n      width: TOAST_WIDTH,\n    };\n  }\n\n  if (headroom >= TOAST_ROW_HEIGHT) {\n    return { alignInline, mode: 'up', reserve: 0, shiftX: 0, shiftY, width: TOAST_WIDTH };\n  }\n\n  if (lane >= TOAST_MIN_WIDTH) {\n    return { alignInline: 0, mode: 'shrink', reserve: alignBlock, shiftX, shiftY: 0, width: lane };\n  }\n\n  // ponytail: the reserve budget is one toast row, not the live stack height —\n  // measuring the stack would feed panel resizes back into the measurement.\n  // A taller stack overflows upward here; per-stack reserve if that shows up.\n  return {\n    alignInline,\n    mode: 'reserve',\n    reserve: Math.max(0, TOAST_EDGE + TOAST_ROW_HEIGHT + TOAST_DODGE_GUTTER - panelOffsetY),\n    shiftX: 0,\n    shiftY: 0,\n    width: TOAST_WIDTH,\n  };\n};\n"],"mappings":"AASA,MAAa,uBAAuB;AACpC,MAAa,mBACX;AAEF,MAAa,oBAAoB;AACjC,MAAa,oBAAoB;AACjC,MAAa,kBAAkB;AAC/B,MAAa,oBAAoB;AACjC,MAAa,yBAAyB;AAsBtC,MAAa,qBAAqB,EAChC,aACA,cACA,cACA,YACA,gBACA,oBACuC;CACvC,MAAM,SAAS,KAAK,IAAI,GAAG,aAAa,eAAA,KAAA,EAA8C;CACtF,MAAM,SAAS,KAAK,IAAI,GAAG,cAAc,eAAA,KAAA,EAA8C;CACvF,MAAM,OAAO,gBAAgB,SAAS;CACtC,MAAM,WAAW,iBAAiB,SAAS;CAK3C,MAAM,aAAa,KAAK,IAAI,GAAA,KAAgB,YAAY;CACxD,MAAM,cAAc,KAAK,IAAI,GAAA,KAAgB,YAAY;CAEzD,IAAI,QAAA,KACF,OAAO;EACL,aAAa;EACb,MAAM;EACN,SAAS;EACT;EACA,QAAQ;EACR,OAAA;CACF;CAGF,IAAI,YAAA,IACF,OAAO;EAAE;EAAa,MAAM;EAAM,SAAS;EAAG,QAAQ;EAAG;EAAQ,OAAA;CAAmB;CAGtF,IAAI,QAAA,KACF,OAAO;EAAE,aAAa;EAAG,MAAM;EAAU,SAAS;EAAY;EAAQ,QAAQ;EAAG,OAAO;CAAK;CAM/F,OAAO;EACL;EACA,MAAM;EACN,SAAS,KAAK,IAAI,GAAG,MAAqD,YAAY;EACtF,QAAQ;EACR,QAAQ;EACR,OAAA;CACF;AACF"}