/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{keyName as t,base as e}from"../../w3c-keyname/index.js";import{Plugin as r}from"../../prosemirror-state/dist/index.js";const i="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),n="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function o(t){let e,r,n,o,l=t.split(/-(?!$)/),a=l[l.length-1];"Space"==a&&(a=" ");for(let f=0;f<l.length-1;f++){let t=l[f];if(/^(cmd|meta|m)$/i.test(t))o=!0;else if(/^a(lt)?$/i.test(t))e=!0;else if(/^(c|ctrl|control)$/i.test(t))r=!0;else if(/^s(hift)?$/i.test(t))n=!0;else{if(!/^mod$/i.test(t))throw new Error("Unrecognized modifier name: "+t);i?o=!0:r=!0}}return e&&(a="Alt-"+a),r&&(a="Ctrl-"+a),o&&(a="Meta-"+a),n&&(a="Shift-"+a),a}function l(t,e,r=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),r&&e.shiftKey&&(t="Shift-"+t),t}function a(t){return new r({props:{handleKeyDown:f(t)}})}function f(r){let i=function(t){let e=/* @__PURE__ */Object.create(null);for(let r in t)e[o(r)]=t[r];return e}(r);return function(r,o){let a,f=t(o),s=i[l(f,o)];if(s&&s(r.state,r.dispatch,r))return!0;if(1==f.length&&" "!=f){if(o.shiftKey){let t=i[l(f,o,!1)];if(t&&t(r.state,r.dispatch,r))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(n&&o.ctrlKey&&o.altKey)&&(a=e[o.keyCode])&&a!=f){let t=i[l(a,o)];if(t&&t(r.state,r.dispatch,r))return!0}}return!1}}export{f as keydownHandler,a as keymap};