"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("@dialpad/dialtone-icons/vue3"),t=require("vue"),d=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),s={"{win}":e.DtIconLayoutGrid,"{arrow-right}":e.DtIconArrowRight,"{arrow-left}":e.DtIconArrowLeft,"{arrow-up}":e.DtIconArrowUp,"{arrow-down}":e.DtIconArrowDown,"{cmd}":e.DtIconCommand,"{opt}":e.DtIconOption},l={"{cmd}":"Command","{opt}":"Option","{win}":"Windows","{arrow-right}":"Right Arrow","{arrow-left}":"Left Arrow","{arrow-up}":"Up Arrow","{arrow-down}":"Down Arrow","{plus}":"plus"},u={ctrl:"Control",alt:"Alt",esc:"Escape",del:"Delete",ins:"Insert",pgup:"Page Up",pgdn:"Page Down",num:"Number",caps:"Caps Lock"},p={compatConfig:{MODE:3},name:"DtKeyboardShortcut",components:{DtIconLayoutGrid:e.DtIconLayoutGrid,DtIconArrowRight:e.DtIconArrowRight,DtIconArrowLeft:e.DtIconArrowLeft,DtIconArrowUp:e.DtIconArrowUp,DtIconArrowDown:e.DtIconArrowDown,DtIconCommand:e.DtIconCommand,DtIconOption:e.DtIconOption,DtIconPlus:e.DtIconPlus},props:{inverted:{type:Boolean,default:!1},shortcut:{type:String,required:!0},screenReaderText:{type:String,default:null}},data(){return{separator:/\+/gi}},computed:{icons(){return{...s,"{plus}":e.DtIconPlus}},shortcutWithSeparator(){return this.shortcut.replace(this.separator,"{plus}")},formattedShortcut(){return Object.keys(s).reduce((o,r)=>o.replace(new RegExp("{"+r+"}","gi"),s[r]),this.shortcutWithSeparator)},formattedShortcutSplit(){const o=Object.keys(this.icons).join("|"),r=new RegExp(`(${o})`,"gi");return this.formattedShortcut.split(r).filter(Boolean)},generatedScreenReaderText(){return this.formattedShortcutSplit.map(o=>{const r=o.trim();if(l[r])return l[r];const n=r.toLowerCase();return u[n]?u[n]:r}).filter(o=>o).join(" ")}}},m={class:"d-keyboard-shortcut--sr-only"},w=["innerHTML"];function h(o,r,n,I,_,a){return t.openBlock(),t.createElementBlock("kbd",{class:t.normalizeClass(["d-keyboard-shortcut",{"d-keyboard-shortcut--inverted":n.inverted}])},[t.createElementVNode("span",m,t.toDisplayString(n.screenReaderText||a.generatedScreenReaderText),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.formattedShortcutSplit,(c,i)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[a.icons[c]?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(a.icons[c]),{key:`icon-${i}-${c}`,size:"100","aria-hidden":"true",class:t.normalizeClass(["d-keyboard-shortcut__icon",{"d-keyboard-shortcut__icon--inverted":n.inverted}])},null,8,["class"])):c.trim()?(t.openBlock(),t.createElementBlock("span",{key:`text-${i}-${c}`,"aria-hidden":"true",class:t.normalizeClass(["d-keyboard-shortcut__item",{"d-keyboard-shortcut__item--inverted":n.inverted}]),innerHTML:c},null,10,w)):t.createCommentVNode("",!0)],64))),256))],2)}const D=d._(p,[["render",h]]);exports.default=D;
//# sourceMappingURL=keyboard-shortcut.cjs.map
