{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/Hotkey/utils.ts"],"sourcesContent":["import { KeyMapEnum } from './const';\n\n// https://superuser.com/questions/1238058/key-combination-order\nexport const NORMATIVE_MODIFIER = [\n  // win: Ctrl ,mac: Control\n  KeyMapEnum.Ctrl,\n  KeyMapEnum.Control,\n  KeyMapEnum.CommandOrControl,\n\n  //  win: Win ,mac: Command\n  KeyMapEnum.Meta,\n\n  // Mod should have same priority as Ctrl since it represents Ctrl on Windows\n  KeyMapEnum.Mod,\n\n  // win: Alt ,mac: Option\n  KeyMapEnum.Alt,\n\n  // win: Shift ,mac: Shift\n  KeyMapEnum.Shift,\n];\n\nconst orderMap = Object.fromEntries(NORMATIVE_MODIFIER.map((key, index) => [key, index]));\n\nexport const splitKeysByPlus = (keys: string): string[] => {\n  return keys\n    .replaceAll('++', `+${KeyMapEnum.Equal}`)\n    .split('+')\n    .sort((x, y) => {\n      const idxX = orderMap[x.toLowerCase()] ?? orderMap.length;\n      const idxY = orderMap[y.toLowerCase()] ?? orderMap.length;\n\n      return idxX - idxY;\n    });\n};\n\nexport const startCase = (str: string): string => {\n  return str\n    .replaceAll(/([A-Z])/g, ' $1')\n    .replace(/^./, (s) => s.toUpperCase())\n    .trim();\n};\n\nexport const checkIsAppleDevice = (isApple?: boolean) => {\n  if (isApple !== undefined) {\n    return isApple;\n  }\n\n  if (typeof window === 'undefined' || typeof navigator === 'undefined') {\n    return false; // 处理 SSR 环境\n  }\n\n  const userAgent = navigator.userAgent.toLowerCase();\n  return /mac|iphone|ipod|ipad|ios/i.test(userAgent);\n};\n\nexport const combineKeys = (keys: string[]): string => keys.join('+');\n"],"mappings":";;AAGA,MAAa,qBAAqB;CAEhC,WAAW;CACX,WAAW;CACX,WAAW;CAGX,WAAW;CAGX,WAAW;CAGX,WAAW;CAGX,WAAW;CACZ;AAED,MAAM,WAAW,OAAO,YAAY,mBAAmB,KAAK,KAAK,UAAU,CAAC,KAAK,MAAM,CAAC,CAAC;AAEzF,MAAa,mBAAmB,SAA2B;AACzD,QAAO,KACJ,WAAW,MAAM,IAAI,WAAW,QAAQ,CACxC,MAAM,IAAI,CACV,MAAM,GAAG,MAAM;AAId,UAHa,SAAS,EAAE,aAAa,KAAK,SAAS,WACtC,SAAS,EAAE,aAAa,KAAK,SAAS;GAGnD;;AAGN,MAAa,aAAa,QAAwB;AAChD,QAAO,IACJ,WAAW,YAAY,MAAM,CAC7B,QAAQ,OAAO,MAAM,EAAE,aAAa,CAAC,CACrC,MAAM;;AAGX,MAAa,sBAAsB,YAAsB;AACvD,KAAI,YAAY,KAAA,EACd,QAAO;AAGT,KAAI,OAAO,WAAW,eAAe,OAAO,cAAc,YACxD,QAAO;CAGT,MAAM,YAAY,UAAU,UAAU,aAAa;AACnD,QAAO,4BAA4B,KAAK,UAAU;;AAGpD,MAAa,eAAe,SAA2B,KAAK,KAAK,IAAI"}