@zh-keyboard/vue 1.0.0 → 1.1.0

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.
@@ -1,2 +1,2 @@
1
- (function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E.ZhKeyboardVue={},E.Vue))})(this,function(E,e){"use strict";var Tt=Object.defineProperty;var Ht=(E,e,_)=>e in E?Tt(E,e,{enumerable:!0,configurable:!0,writable:!0,value:_}):E[e]=_;var x=(E,e,_)=>Ht(E,typeof e!="symbol"?e+"":e,_);function _(n){return e.getCurrentScope()?(e.onScopeDispose(n),!0):!1}const ae=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const de=n=>n!=null,ce=Object.prototype.toString,fe=n=>ce.call(n)==="[object Object]",F=()=>{};function ue(n,o){function r(...a){return new Promise((l,i)=>{Promise.resolve(n(()=>o.apply(this,a),{fn:o,thisArg:this,args:a})).then(l).catch(i)})}return r}function me(n,o={}){let r,a,l=F;const i=u=>{clearTimeout(u),l(),l=F};let c;return u=>{const y=e.toValue(n),g=e.toValue(o.maxWait);return r&&i(r),y<=0||g!==void 0&&g<=0?(a&&(i(a),a=null),Promise.resolve(u())):new Promise((d,k)=>{l=o.rejectOnCancel?k:d,c=u,g&&!a&&(a=setTimeout(()=>{r&&i(r),a=null,d(c())},g)),r=setTimeout(()=>{a&&i(a),a=null,d(u())},y)})}}function T(n){return Array.isArray(n)?n:[n]}function pe(n){return e.getCurrentInstance()}function ke(n,o=200,r={}){return ue(me(o,r),n)}function he(n,o=!0,r){pe()?e.onMounted(n,r):o?n():e.nextTick(n)}function ge(n,o,r){return e.watch(n,o,{...r,immediate:!0})}const M=ae?window:void 0;function N(n){var o;const r=e.toValue(n);return(o=r==null?void 0:r.$el)!=null?o:r}function H(...n){const o=[],r=()=>{o.forEach(m=>m()),o.length=0},a=(m,u,y,g)=>(m.addEventListener(u,y,g),()=>m.removeEventListener(u,y,g)),l=e.computed(()=>{const m=T(e.toValue(n[0])).filter(u=>u!=null);return m.every(u=>typeof u!="string")?m:void 0}),i=ge(()=>{var m,u;return[(u=(m=l.value)==null?void 0:m.map(y=>N(y)))!=null?u:[M].filter(y=>y!=null),T(e.toValue(l.value?n[1]:n[0])),T(e.unref(l.value?n[2]:n[1])),e.toValue(l.value?n[3]:n[2])]},([m,u,y,g])=>{if(r(),!(m!=null&&m.length)||!(u!=null&&u.length)||!(y!=null&&y.length))return;const d=fe(g)?{...g}:g;o.push(...m.flatMap(k=>u.flatMap(f=>y.map(p=>a(k,f,p,d)))))},{flush:"post"}),c=()=>{i(),r()};return _(r),c}function ye(){const n=e.shallowRef(!1),o=e.getCurrentInstance();return o&&e.onMounted(()=>{n.value=!0},o),n}function X(n){const o=ye();return e.computed(()=>(o.value,!!n()))}function be(n,o,r={}){const{window:a=M,...l}=r;let i;const c=X(()=>a&&"MutationObserver"in a),m=()=>{i&&(i.disconnect(),i=void 0)},u=e.computed(()=>{const k=e.toValue(n),f=T(k).map(N).filter(de);return new Set(f)}),y=e.watch(()=>u.value,k=>{m(),c.value&&k.size&&(i=new MutationObserver(o),k.forEach(f=>i.observe(f,l)))},{immediate:!0,flush:"post"}),g=()=>i==null?void 0:i.takeRecords(),d=()=>{y(),m()};return _(d),{isSupported:c,stop:d,takeRecords:g}}function we(n,o,r={}){const{window:a=M,document:l=a==null?void 0:a.document,flush:i="sync"}=r;if(!a||!l)return F;let c;const m=g=>{c==null||c(),c=g},u=e.watchEffect(()=>{const g=N(n);if(g){const{stop:d}=be(l,k=>{k.map(p=>[...p.removedNodes]).flat().some(p=>p===g||p.contains(g))&&o(k)},{window:a,childList:!0,subtree:!0});m(d)}},{flush:i}),y=()=>{u(),m()};return _(y),y}function Ee(n={}){var o;const{window:r=M,deep:a=!0,triggerOnRemoval:l=!1}=n,i=(o=n.document)!=null?o:r==null?void 0:r.document,c=()=>{var y;let g=i==null?void 0:i.activeElement;if(a)for(;g!=null&&g.shadowRoot;)g=(y=g==null?void 0:g.shadowRoot)==null?void 0:y.activeElement;return g},m=e.shallowRef(),u=()=>{m.value=c()};if(r){const y={capture:!0,passive:!0};H(r,"blur",g=>{g.relatedTarget===null&&u()},y),H(r,"focus",u,y)}return l&&we(m,u,{document:i}),u(),m}function Ce(n,o,r={}){const{window:a=M,...l}=r;let i;const c=X(()=>a&&"ResizeObserver"in a),m=()=>{i&&(i.disconnect(),i=void 0)},u=e.computed(()=>{const d=e.toValue(n);return Array.isArray(d)?d.map(k=>N(k)):[N(d)]}),y=e.watch(u,d=>{if(m(),c.value&&a){i=new ResizeObserver(o);for(const k of d)k&&i.observe(k,l)}},{immediate:!0,flush:"post"}),g=()=>{m(),y()};return _(g),{isSupported:c,stop:g}}function Y(n,o={width:0,height:0},r={}){const{window:a=M,box:l="content-box"}=r,i=e.computed(()=>{var d,k;return(k=(d=N(n))==null?void 0:d.namespaceURI)==null?void 0:k.includes("svg")}),c=e.shallowRef(o.width),m=e.shallowRef(o.height),{stop:u}=Ce(n,([d])=>{const k=l==="border-box"?d.borderBoxSize:l==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(a&&i.value){const f=N(n);if(f){const p=f.getBoundingClientRect();c.value=p.width,m.value=p.height}}else if(k){const f=T(k);c.value=f.reduce((p,{inlineSize:z})=>p+z,0),m.value=f.reduce((p,{blockSize:z})=>p+z,0)}else c.value=d.contentRect.width,m.value=d.contentRect.height},r);he(()=>{const d=N(n);d&&(c.value="offsetWidth"in d?d.offsetWidth:o.width,m.value="offsetHeight"in d?d.offsetHeight:o.height)});const y=e.watch(()=>N(n),d=>{c.value=d?o.width:0,m.value=d?o.height:0});function g(){u(),y()}return{width:c,height:m,stop:g}}var G=class{constructor(n,o={}){x(this,"canvas");x(this,"ctx");x(this,"lastX",0);x(this,"lastY",0);x(this,"strokeData",[]);x(this,"clearTimerId",null);x(this,"isDrawing",!1);x(this,"options");x(this,"handleStart",n=>{n.preventDefault(),this.isDrawing=!0;const{offsetX:o,offsetY:r}=this.getEventCoordinates(n);this.startDrawing(o,r),this.resetClearTimer()});x(this,"handleMove",n=>{if(!this.isDrawing)return;n.preventDefault();const{offsetX:o,offsetY:r}=this.getEventCoordinates(n);this.draw(o,r),this.resetClearTimer()});x(this,"handleEnd",n=>{this.isDrawing&&(n.preventDefault(),this.isDrawing=!1,this.endStroke(),this.startClearTimer(),this.options.onDrawEnd&&this.options.onDrawEnd())});this.canvas=n,this.options={clearDelay:1e3,...o};const r=this.canvas.getContext("2d");if(!r)throw new Error("Failed to get 2D rendering context");this.ctx=r,this.setupCanvas(),this.attachEvents()}setupCanvas(){this.ctx.lineJoin="round",this.ctx.lineCap="round",this.ctx.lineWidth=3,this.ctx.strokeStyle="#000",this.clearCanvas(),this.drawGrid()}drawGrid(){const n=this.canvas.width,o=this.canvas.height;this.ctx.save(),this.ctx.strokeStyle="#ddd",this.ctx.lineWidth=1,this.ctx.setLineDash([3,3]),this.ctx.beginPath(),this.ctx.moveTo(0,o/2),this.ctx.lineTo(n,o/2),this.ctx.moveTo(n/2,0),this.ctx.lineTo(n/2,o),this.ctx.stroke(),this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.rect(0,0,n,o),this.ctx.stroke(),this.ctx.restore()}clearCanvas(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawGrid(),this.strokeData=[],this.resetClearTimer()}startDrawing(n,o){this.lastX=n,this.lastY=o,this.ctx.strokeStyle="#000",this.ctx.lineWidth=3,this.ctx.setLineDash([]),this.strokeData.push(n,o,0)}draw(n,o){this.ctx.beginPath(),this.ctx.moveTo(this.lastX,this.lastY),this.ctx.lineTo(n,o),this.ctx.stroke(),this.lastX=n,this.lastY=o,this.strokeData.push(n,o,0)}endStroke(){this.strokeData.length>=3&&(this.strokeData[this.strokeData.length-1]=1)}getStrokeData(){return this.strokeData}resetClearTimer(){this.clearTimerId&&(window.clearTimeout(this.clearTimerId),this.clearTimerId=null)}startClearTimer(){this.resetClearTimer(),this.clearTimerId=window.setTimeout(()=>{this.clearCanvas(),this.clearTimerId=null},this.options.clearDelay)}getEventCoordinates(n){if(n instanceof MouseEvent)return{offsetX:n.offsetX,offsetY:n.offsetY};{const o=n.touches[0]||n.changedTouches[0],r=n.target.getBoundingClientRect();return{offsetX:o.clientX-r.left,offsetY:o.clientY-r.top}}}attachEvents(){this.canvas.addEventListener("mousedown",this.handleStart),this.canvas.addEventListener("mousemove",this.handleMove),this.canvas.addEventListener("mouseup",this.handleEnd),this.canvas.addEventListener("mouseleave",this.handleEnd),this.canvas.addEventListener("touchstart",this.handleStart,{passive:!1}),this.canvas.addEventListener("touchmove",this.handleMove,{passive:!1}),this.canvas.addEventListener("touchend",this.handleEnd),this.canvas.addEventListener("touchcancel",this.handleEnd)}detachEvents(){this.canvas.removeEventListener("mousedown",this.handleStart),this.canvas.removeEventListener("mousemove",this.handleMove),this.canvas.removeEventListener("mouseup",this.handleEnd),this.canvas.removeEventListener("mouseleave",this.handleEnd),this.canvas.removeEventListener("touchstart",this.handleStart),this.canvas.removeEventListener("touchmove",this.handleMove),this.canvas.removeEventListener("touchend",this.handleEnd),this.canvas.removeEventListener("touchcancel",this.handleEnd)}destroy(){this.detachEvents(),this.resetClearTimer()}getCanvas(){return this.canvas}getContext(){return this.ctx}};let W={defaultMode:"en",enableHandwriting:!1,position:"static",disableWhenNoFocus:!0},v=null,q=null;function $(){return W}function ze(n){W={...W,...n}}function Be(n){v=n}function I(){return v}function Ve(n){q=n}function J(){return q}function Q(n,o,r){if(!n||!o||r==="static")return null;let a,l;if(r==="bottom")a=window.innerHeight-o.offsetHeight,l=0;else{const i=n.getBoundingClientRect(),c=o.offsetWidth;a=i.bottom+window.scrollY,l=i.left+window.scrollX+i.width/2-c/2;const m=window.innerWidth;l+c>m&&(l=m-c-10),l<10&&(l=10)}return{top:`${a}px`,left:`${l}px`}}function A(n){if(!n)return!1;if(n.tagName==="TEXTAREA")return!0;if(n.tagName==="INPUT"){const r=(n.type||"text").toLowerCase();return!["checkbox","radio","button","submit","reset","file","image","range","color","hidden","date","datetime-local","month","week","time"].includes(r)}return!1}function xe(){if(document.activeElement&&A(document.activeElement))return document.activeElement;throw new Error("输入框没有被激活")}function Pe(n,o,r){n.value=o,oe(n,r),n.dispatchEvent(new Event("input",{bubbles:!0}))}function _e(n,o,r,a=""){return n.slice(0,o)+a+n.slice(o+r)}function ee(n,o=""){const r=Number(n.getAttribute("maxlength"));let a=n.selectionStart??0;const l=n.selectionEnd??a;let i;if(o.length>0)i=l-a;else{const u=l-a;if(u>0)i=u;else if(a>0)i=1,a--;else return}if(o.length>0&&r&&n.value.length-i+o.length>r)return;const c=_e(n.value,a,i,o),m=a+o.length;Pe(n,c,m)}function te(n,o){ee(n,o)}function ne(n){ee(n)}function oe(n,o){n.selectionStart=o,n.selectionEnd=o}function re(n={}){const o=n.delay??400,r=n.interval??60;let a,l;function i(){a&&(clearTimeout(a),a=void 0),l&&(clearInterval(l),l=void 0)}function c(m){i(),m(),a=setTimeout(()=>{l=setInterval(()=>{m()},r)},o)}return{start:c,stop:i}}function Ne(n=!1){const o=e.ref(!1),r=e.ref(0);async function a(){const i=I();if(i)try{o.value=await i.initialize({onProgress:c=>{r.value=c}})}catch(c){console.error("初始化手写识别服务失败:",c),o.value=!1}else console.warn("未注册手写识别服务"),o.value=!1}async function l(){const i=I();if(i&&o.value)try{await i.close(),o.value=!1}catch(c){console.error("关闭手写识别服务失败:",c)}}return e.onMounted(()=>{n&&a()}),e.onUnmounted(()=>{l()}),{recognizerInitialized:o,recognizerProgress:r}}const O="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M21,11H6.83L10.41,7.41L9,6L3,12L9,18L10.41,16.58L6.83,13H21V11Z'%20/%3e%3c/svg%3e",U="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e";function K(){const n=re();function o(a,l){var i,c;a.preventDefault(),(c=(i=a.currentTarget)==null?void 0:i.setPointerCapture)==null||c.call(i,a.pointerId),n.start(l)}function r(){n.stop()}return e.onBeforeUnmount(()=>{n.stop()}),{startRepeat:o,stopRepeat:r}}const Se={class:"zhk-candidate-list"},Me=["onClick"],ie=e.defineComponent({__name:"CandidateList",props:{candidates:{}},emits:["select"],setup(n,{emit:o}){const r=o;function a(l){r("select",l)}return(l,i)=>(e.openBlock(),e.createElementBlock("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.candidates,(c,m)=>(e.openBlock(),e.createElementBlock("button",{key:`candidate-${m}`,class:"zhk-candidate-list__item",onClick:u=>a(m)},e.toDisplayString(c),9,Me))),128))]))}}),$e={class:"handwriting-input"},Le={class:"handwriting-buttons"},Re={class:"handwriting-canvas-container"},De={class:"progress-bar"},Te={class:"progress-text"},He=["width","height"],Ie={class:"handwriting-buttons"},Ae=e.defineComponent({__name:"HandwritingInput",props:{recognizerInitialized:{type:Boolean},recognizerProgress:{}},emits:["key","exit"],setup(n,{emit:o}){const r=n,a=o,l=e.ref(null),i=e.ref(null);let c=null;const m=e.ref(!1),{height:u}=Y(i);function y(){c&&c.clearCanvas()}function g(){l.value&&(c&&c.destroy(),c=new G(l.value,{onDrawEnd:p}))}const d=e.ref([]),{startRepeat:k,stopRepeat:f}=K();async function p(){if(!c||c.getStrokeData().length===0||m.value)return;const w=I();if(w){m.value=!0;try{const t=[...c.getStrokeData()],h=await w.recognize(t);d.value=h}catch(t){console.error("识别笔迹失败:",t)}finally{m.value=!1}}else console.warn("手写识别服务不可用")}e.onUnmounted(()=>{c&&c.destroy()}),e.watchEffect(()=>{l.value&&u.value&&r.recognizerInitialized&&e.nextTick(()=>{g()})});function z(w){const t=d.value[w];t&&(a("key",{key:t}),d.value=[],y())}return(w,t)=>(e.openBlock(),e.createElementBlock("div",$e,[e.createVNode(ie,{candidates:d.value,onSelect:z},null,8,["candidates"]),e.createElementVNode("div",{ref_key:"containerRef",ref:i,class:"handwriting-content"},[e.createElementVNode("div",Le,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[0]||(t[0]=h=>e.unref(k)(h,()=>a("key",{key:"。"}))),onPointerup:t[1]||(t[1]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[2]||(t[2]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[3]||(t[3]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[4]||(t[4]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[5]||(t[5]=h=>e.unref(k)(h,()=>a("key",{key:"?"}))),onPointerup:t[6]||(t[6]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[7]||(t[7]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[8]||(t[8]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[9]||(t[9]=e.withModifiers(()=>{},["prevent"]))}," ? ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[10]||(t[10]=h=>e.unref(k)(h,()=>a("key",{key:"!"}))),onPointerup:t[11]||(t[11]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[12]||(t[12]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[13]||(t[13]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[14]||(t[14]=e.withModifiers(()=>{},["prevent"]))}," ! ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[15]||(t[15]=h=>e.unref(k)(h,()=>a("key",{key:"、"}))),onPointerup:t[16]||(t[16]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[17]||(t[17]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[18]||(t[18]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[19]||(t[19]=e.withModifiers(()=>{},["prevent"]))}," 、 ",32)]),e.createElementVNode("div",Re,[w.recognizerInitialized?(e.openBlock(),e.createElementBlock("canvas",{key:1,ref_key:"canvasRef",ref:l,class:"handwriting-canvas",width:e.unref(u),height:e.unref(u)},null,8,He)):(e.openBlock(),e.createElementBlock("div",{key:0,class:"handwriting-loading",style:e.normalizeStyle({width:`${e.unref(u)}px`,height:`${e.unref(u)}px`})},[t[37]||(t[37]=e.createElementVNode("div",{class:"loading-text"}," 正在加载手写识别... ",-1)),e.createElementVNode("div",De,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${w.recognizerProgress*100}%`})},null,4)]),e.createElementVNode("div",Te,e.toDisplayString(Math.round(w.recognizerProgress*100))+"% ",1)],4))]),e.createElementVNode("div",Ie,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[20]||(t[20]=h=>e.unref(k)(h,()=>a("key",{key:"delete",isControl:!0}))),onPointerup:t[21]||(t[21]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[22]||(t[22]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[23]||(t[23]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[24]||(t[24]=e.withModifiers(()=>{},["prevent"]))},t[38]||(t[38]=[e.createElementVNode("img",{src:O,alt:"删除"},null,-1)]),32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onClick:t[25]||(t[25]=h=>a("exit")),onContextmenu:t[26]||(t[26]=e.withModifiers(()=>{},["prevent"]))}," 返回 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[27]||(t[27]=h=>e.unref(k)(h,()=>a("key",{key:","}))),onPointerup:t[28]||(t[28]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[29]||(t[29]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[30]||(t[30]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[31]||(t[31]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[32]||(t[32]=h=>e.unref(k)(h,()=>a("key",{key:"enter",isControl:!0}))),onPointerup:t[33]||(t[33]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[34]||(t[34]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[35]||(t[35]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[36]||(t[36]=e.withModifiers(()=>{},["prevent"]))},t[39]||(t[39]=[e.createElementVNode("img",{src:U,alt:"回车"},null,-1)]),32)])],512)]))}}),Ke="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M6,18H18V16H6M12,8.41L16.59,13L18,11.58L12,5.58L6,11.58L7.41,13L12,8.41Z'%20/%3e%3c/svg%3e",se="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e",Fe="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z'%20/%3e%3c/svg%3e",We={class:"zhk-selection"},Oe={class:"zhk-selection__list"},Ue=["onClick"],Ze=e.defineComponent({__name:"CandidateSelection",props:{candidates:{}},emits:["select","close"],setup(n,{emit:o}){const r=o;function a(c){r("select",c)}function l(){r("close")}function i(c){const m=Array.from(c).length;return m>=2&&m<=3?2:m>=4?3:1}return(c,m)=>(e.openBlock(),e.createElementBlock("div",We,[e.createElementVNode("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.candidates,(u,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["zhk-selection__text",[`zhk-selection__text--span-${i(u)}`]]),onClick:g=>a(y)},e.toDisplayString(u),11,Ue))),128))]),e.createElementVNode("div",{class:"zhk-selection__func"},[e.createElementVNode("button",{class:"zhk-selection__func-btn",onClick:l}," 返回 ")])]))}}),je={class:"zhk-candidate"},Xe={class:"zhk-candidate__container"},Ye={key:0,class:"zhk-candidate__pinyin"},Ge={class:"zhk-candidate__bottom-container"},ve=e.defineComponent({__name:"CandidateBar",props:{modelValue:{required:!0},modelModifiers:{}},emits:e.mergeModels(["key","input"],["update:modelValue"]),setup(n,{expose:o,emit:r}){const a=r,l=e.useModel(n,"modelValue");let i=null;const c=e.ref(null),m=e.computed(()=>{var d;return((d=c.value)==null?void 0:d.candidates.map(k=>k.text))??[]}),u=e.ref(!1);e.onMounted(async()=>{if(i=J(),!i)throw new Error("未找到拼音引擎实例,请确保已正确注册引擎");l.value&&(c.value=await i.processInput(l.value))}),e.onUnmounted(()=>{i==null||i.clearInput(),i=null}),e.watch(l,async d=>{const k=i;if(k){if(d===""){k.clearInput(),c.value=null;return}c.value=await k.processInput(d)}});async function y(d){if(!i)return;const k=await i.pickCandidate(d);c.value=k,k.preeditBody||(a("input",k.committed||""),l.value="",c.value=null,u.value=!1)}o({handleSelection:y});const g=e.computed(()=>{const d=c.value;return d?d.preeditHead+d.preeditBody:""});return(d,k)=>(e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("div",Xe,[g.value?(e.openBlock(),e.createElementBlock("div",Ye,e.toDisplayString(g.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ge,[m.value.length>0?(e.openBlock(),e.createBlock(ie,{key:0,candidates:m.value,onSelect:y},null,8,["candidates"])):e.createCommentVNode("",!0),m.value.length>0?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-candidate__more",onClick:k[0]||(k[0]=f=>u.value=!0)},k[2]||(k[2]=[e.createElementVNode("img",{src:Fe,alt:"更多"},null,-1)]))):e.createCommentVNode("",!0)])]),u.value?(e.openBlock(),e.createBlock(Ze,{key:0,candidates:m.value,onSelect:y,onClose:k[1]||(k[1]=f=>u.value=!1)},null,8,["candidates"])):e.createCommentVNode("",!0)]))}}),qe={class:"zhk-base"},Je={class:"zhk-base__row"},Qe=["onPointerdown"],et=["disabled"],tt={key:1,src:Ke,class:"zhk-base__key-icon",alt:"Shift"},nt=["onPointerdown"],ot={class:"zhk-base__row"},rt={class:"zhk-base__toggle-main"},it={class:"zhk-base__toggle-sub"},st=e.defineComponent({__name:"KeyboardBase",props:e.mergeModels({enableHandwriting:{type:Boolean}},{modelValue:{default:"en"},modelModifiers:{}}),emits:e.mergeModels(["key"],["update:modelValue"]),setup(n,{emit:o}){const r=n,a=o,l=e.useModel(n,"modelValue"),i=e.ref(!1),c=e.computed(()=>l.value==="zh"),m=e.computed(()=>c.value?!0:i.value);function u(P,s=!1){a("key",{key:P,isControl:s})}function y(){c.value?l.value="hand":i.value=!i.value}function g(){l.value="num"}function d(){l.value="symbol"}const k=["1","2","3","4","5","6","7","8","9","0"],f=[["q","w","e","r","t","y","u","i","o","p"],["a","s","d","f","g","h","j","k","l"],["z","x","c","v","b","n","m"]],p=e.ref(""),z=e.ref(null),{startRepeat:w,stopRepeat:t}=K();function h(){if(l.value==="zh"&&p.value){p.value=p.value.slice(0,-1);return}u("delete",!0)}function L(){var P;if(l.value==="zh"&&p.value){(P=z.value)==null||P.handleSelection(0);return}u(" ")}function Z(){if(l.value==="zh"&&p.value){u(p.value),p.value="";return}u("enter",!0)}function R(P){if(l.value==="zh"){p.value+=P;return}const s=i.value?P.toUpperCase():P;u(s)}function j(){l.value=l.value==="zh"?"en":"zh"}const C=e.computed(()=>r.enableHandwriting?"手写":"-"),V=e.computed(()=>!r.enableHandwriting);return(P,s)=>(e.openBlock(),e.createElementBlock("div",qe,[e.createElementVNode("div",Je,[l.value==="zh"?(e.openBlock(),e.createBlock(ve,{key:0,ref_key:"candidateBarRef",ref:z,modelValue:p.value,"onUpdate:modelValue":s[0]||(s[0]=b=>p.value=b),onInput:s[1]||(s[1]=b=>u(b,!1))},null,8,["modelValue"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},e.renderList(k,(b,D)=>e.createElementVNode("button",{key:`number-${D}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:B=>e.unref(w)(B,()=>R(b)),onPointerup:s[2]||(s[2]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onPointerleave:s[3]||(s[3]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onPointercancel:s[4]||(s[4]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onContextmenu:s[5]||(s[5]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(b),41,Qe)),64))]),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(f,(b,D)=>e.createElementVNode("div",{key:`row-${D}`,class:"zhk-base__row"},[D===2?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["zhk-base__key zhk-base__key--function zhk-base__key--shift",{"zhk-base__key--active":!c.value&&i.value,"zhk-base__key--disabled":c.value&&V.value}]),disabled:c.value&&V.value,onClick:y,onContextmenu:s[6]||(s[6]=e.withModifiers(()=>{},["prevent"]))},[c.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(C.value),1)],64)):(e.openBlock(),e.createElementBlock("img",tt))],42,et)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(B,Dt)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${D}-${Dt}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:S=>e.unref(w)(S,()=>R(B)),onPointerup:s[7]||(s[7]=(...S)=>e.unref(t)&&e.unref(t)(...S)),onPointerleave:s[8]||(s[8]=(...S)=>e.unref(t)&&e.unref(t)(...S)),onPointercancel:s[9]||(s[9]=(...S)=>e.unref(t)&&e.unref(t)(...S)),onContextmenu:s[10]||(s[10]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(m.value?B.toUpperCase():B),41,nt))),128)),D===2?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-base__key zhk-base__key--function zhk-base__key--delete",onPointerdown:s[11]||(s[11]=B=>e.unref(w)(B,()=>h())),onPointerup:s[12]||(s[12]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onPointerleave:s[13]||(s[13]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onPointercancel:s[14]||(s[14]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onContextmenu:s[15]||(s[15]=e.withModifiers(()=>{},["prevent"]))},s[39]||(s[39]=[e.createElementVNode("img",{src:O,class:"zhk-base__key-icon",alt:"Delete"},null,-1)]),32)):e.createCommentVNode("",!0)])),64)),e.createElementVNode("div",ot,[e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:d,onContextmenu:s[16]||(s[16]=e.withModifiers(()=>{},["prevent"]))}," 符 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:g,onContextmenu:s[17]||(s[17]=e.withModifiers(()=>{},["prevent"]))}," 123 ",32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:s[18]||(s[18]=b=>e.unref(w)(b,()=>u(","))),onPointerup:s[19]||(s[19]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointerleave:s[20]||(s[20]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointercancel:s[21]||(s[21]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onContextmenu:s[22]||(s[22]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--space",onPointerdown:s[23]||(s[23]=b=>e.unref(w)(b,()=>L())),onPointerup:s[24]||(s[24]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointerleave:s[25]||(s[25]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointercancel:s[26]||(s[26]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onContextmenu:s[27]||(s[27]=e.withModifiers(()=>{},["prevent"]))},s[40]||(s[40]=[e.createElementVNode("img",{src:se,class:"zhk-base__key-icon",alt:"Space"},null,-1)]),32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:s[28]||(s[28]=b=>e.unref(w)(b,()=>u("。"))),onPointerup:s[29]||(s[29]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointerleave:s[30]||(s[30]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointercancel:s[31]||(s[31]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onContextmenu:s[32]||(s[32]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:j,onContextmenu:s[33]||(s[33]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("span",rt,e.toDisplayString(l.value==="zh"?"中":"英"),1),e.createElementVNode("span",it,"/"+e.toDisplayString(l.value==="zh"?"英":"中"),1)],32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onPointerdown:s[34]||(s[34]=b=>e.unref(w)(b,()=>Z())),onPointerup:s[35]||(s[35]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointerleave:s[36]||(s[36]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointercancel:s[37]||(s[37]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onContextmenu:s[38]||(s[38]=e.withModifiers(()=>{},["prevent"]))},s[41]||(s[41]=[e.createElementVNode("img",{src:U,class:"zhk-base__key-icon",alt:"Enter"},null,-1)]),32)])]))}}),lt={class:"num-keyboard"},at={class:"num-keyboard__container"},dt={class:"num-keyboard__left"},ct={class:"num-keyboard__rows"},ft=["onClick","onPointerdown"],ut={key:1,src:se,class:"zhk-base__key-icon",alt:"Space"},mt={class:"num-keyboard__right"},pt=["onPointerdown"],kt=["src","alt"],ht={key:1},gt=e.defineComponent({__name:"NumericKeyboard",props:{keyboardRows:{default:()=>$().numKeys||[["1","2","3"],["4","5","6"],["7","8","9"],["back","0","space"]]}},emits:["key","exit"],setup(n,{emit:o}){const r=o,a=[{key:"delete",icon:O,text:"",alt:"Delete"},{key:".",icon:"",text:".",alt:"."},{key:"@",icon:"",text:"@",alt:"@"},{key:"enter",icon:U,text:"",alt:"Enter"}];function l(g){r("key",{key:g})}function i(g,d=!0){r("key",{key:g,isControl:d})}function c(){r("exit")}const{startRepeat:m,stopRepeat:u}=K();function y(g,d){g==="back"||(g==="space"&&(g=" "),g==="delete"||g==="enter"?m(d,()=>i(g)):m(d,()=>l(g)))}return(g,d)=>(e.openBlock(),e.createElementBlock("div",lt,[e.createElementVNode("div",at,[e.createElementVNode("div",dt,[e.createElementVNode("div",ct,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.keyboardRows,(k,f)=>(e.openBlock(),e.createElementBlock("div",{key:`row-${f}`,class:"num-keyboard__row"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,(p,z)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${f}-${z}`,class:e.normalizeClass(["num-keyboard__key",{"num-keyboard__key--back":p==="back","num-keyboard__key--space":p==="space"}]),onClick:w=>p==="back"&&c(),onPointerdown:w=>y(p,w),onPointerup:d[0]||(d[0]=(...w)=>e.unref(u)&&e.unref(u)(...w)),onPointerleave:d[1]||(d[1]=(...w)=>e.unref(u)&&e.unref(u)(...w)),onPointercancel:d[2]||(d[2]=(...w)=>e.unref(u)&&e.unref(u)(...w)),onContextmenu:d[3]||(d[3]=e.withModifiers(()=>{},["prevent"]))},[p==="back"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(" 返回 ")],64)):p==="space"?(e.openBlock(),e.createElementBlock("img",ut)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(p),1)],64))],42,ft))),128))]))),128))])]),e.createElementVNode("div",mt,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,(k,f)=>e.createElementVNode("button",{key:`func-${f}`,class:"num-keyboard__key num-keyboard__key--function",onPointerdown:p=>y(k.key,p),onPointerup:d[4]||(d[4]=(...p)=>e.unref(u)&&e.unref(u)(...p)),onPointerleave:d[5]||(d[5]=(...p)=>e.unref(u)&&e.unref(u)(...p)),onPointercancel:d[6]||(d[6]=(...p)=>e.unref(u)&&e.unref(u)(...p)),onContextmenu:d[7]||(d[7]=e.withModifiers(()=>{},["prevent"]))},[k.icon?(e.openBlock(),e.createElementBlock("img",{key:0,src:k.icon,class:"num-keyboard__key-icon",alt:k.alt},null,8,kt)):(e.openBlock(),e.createElementBlock("span",ht,e.toDisplayString(k.text),1))],40,pt)),64))])])]))}}),yt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10A2,2%200%200,1%206,8H15V6A3,3%200%200,0%2012,3A3,3%200%200,0%209,6H7A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,17A2,2%200%200,1%2010,15A2,2%200%200,1%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17Z'%20/%3e%3c/svg%3e",bt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M12,17C10.89,17%2010,16.1%2010,15C10,13.89%2010.89,13%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10C4,8.89%204.89,8%206,8H7V6A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,3A3,3%200%200,0%209,6V8H15V6A3,3%200%200,0%2012,3Z'%20/%3e%3c/svg%3e",wt={class:"symbol-keyboard"},Et={class:"symbol-keyboard__content"},Ct={class:"symbol-keyboard__functions"},zt={class:"symbol-keyboard__lang-selector"},Bt={class:"symbol-keyboard__control-group"},Vt=["src"],xt=["src"],Pt={class:"symbol-keyboard__symbols-container"},_t={class:"symbol-keyboard__symbols-grid"},Nt=["onClick","onPointerdown"],St="!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°",Mt="!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°",$t=e.defineComponent({__name:"SymbolKeyboard",emits:["key","exit"],setup(n,{emit:o}){const r=o,a=e.ref("en"),l=e.computed(()=>a.value==="zh"?Mt:St),i=e.ref(!1),{startRepeat:c,stopRepeat:m}=K();function u(f,p){i.value&&c(p,()=>y(f))}function y(f){r("key",{key:f}),i.value||r("exit")}function g(){r("exit")}function d(f){a.value=f}function k(){i.value=!i.value}return(f,p)=>(e.openBlock(),e.createElementBlock("div",wt,[e.createElementVNode("div",Et,[e.createElementVNode("div",Ct,[e.createElementVNode("div",zt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="zh"}]),onClick:p[0]||(p[0]=z=>d("zh")),onContextmenu:p[1]||(p[1]=e.withModifiers(()=>{},["prevent"]))}," 中文 ",34),e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="en"}]),onClick:p[2]||(p[2]=z=>d("en")),onContextmenu:p[3]||(p[3]=e.withModifiers(()=>{},["prevent"]))}," 英文 ",34)]),e.createElementVNode("div",Bt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock",{"symbol-keyboard__key--locked":i.value}]),onClick:k,onContextmenu:p[4]||(p[4]=e.withModifiers(()=>{},["prevent"]))},[i.value?(e.openBlock(),e.createElementBlock("img",{key:1,src:e.unref(bt),alt:"Lock closed"},null,8,xt)):(e.openBlock(),e.createElementBlock("img",{key:0,src:e.unref(yt),alt:"Lock open"},null,8,Vt))],34),e.createElementVNode("button",{class:"symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",onClick:g,onContextmenu:p[5]||(p[5]=e.withModifiers(()=>{},["prevent"]))}," 返回 ",32)])]),e.createElementVNode("div",Pt,[e.createElementVNode("div",_t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(z,w)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${w}`,class:"symbol-keyboard__key",onClick:t=>!i.value&&y(z),onPointerdown:t=>u(z,t),onPointerup:p[6]||(p[6]=(...t)=>e.unref(m)&&e.unref(m)(...t)),onPointerleave:p[7]||(p[7]=(...t)=>e.unref(m)&&e.unref(m)(...t)),onPointercancel:p[8]||(p[8]=(...t)=>e.unref(m)&&e.unref(m)(...t)),onContextmenu:p[9]||(p[9]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(z),41,Nt))),128))])])])]))}}),Lt={key:0,class:"zhk__disabled-overlay"},le=e.defineComponent({__name:"ZhKeyboard",props:{defaultMode:{default:$().defaultMode??"en"},enableHandwriting:{type:Boolean,default:$().enableHandwriting??!1},position:{default:$().position??"static"},disableWhenNoFocus:{type:Boolean,default:$().disableWhenNoFocus??!0},numKeys:{}},emits:["key"],setup(n,{emit:o}){const r=n,a=o,l=e.ref(r.defaultMode),i=e.ref(r.defaultMode),c=e.ref([]),m=e.ref(!1),u=e.ref(null),y=e.ref(null),{recognizerInitialized:g,recognizerProgress:d}=Ne(r.enableHandwriting);e.watch(l,(C,V)=>{C!==V&&(i.value=V)});const k=Ee(),f=e.computed(()=>k.value&&A(k.value)?k.value:null),p=e.computed(()=>r.position==="static"||!!(k.value&&A(k.value))),{height:z}=Y(y);e.watchEffect(()=>{if(f.value){const C=f.value.dataset.inputmode;C&&(l.value=C)}});const w=e.computed(()=>r.disableWhenNoFocus===!1?!1:!f.value);function t(){if(!z.value)return;const C=Q(f.value,y.value,r.position);u.value=C}e.watchEffect(t);const h=ke(t,100);H(window,"scroll",h,{passive:!0}),H(window,"resize",h,{passive:!0});function L(C){if(C.isControl){switch(C.key){case"delete":ne(f.value);break;case"more":m.value=!0;break}return}else Z(C.key);a("key",C)}function Z(C){te(f.value,C)}function R(){["hand","num","symbol"].includes(i.value)&&(i.value=r.defaultMode),l.value=i.value}function j(C){c.value=C}return(C,V)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",{ref_key:"keyboardRef",ref:y,class:e.normalizeClass(["zhk",{"zhk--floating":C.position==="float","zhk--bottom":C.position==="bottom","zhk--disabled":w.value}]),style:e.normalizeStyle({"--keyboard-height":`${e.unref(z)}px`,...u.value}),onMousedown:V[1]||(V[1]=e.withModifiers(()=>{},["prevent"]))},[w.value||!p.value||!e.unref(z)?(e.openBlock(),e.createElementBlock("div",Lt,V[2]||(V[2]=[e.createElementVNode("span",null,"请选择输入框以启用键盘",-1)]))):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l.value==="hand"?(e.openBlock(),e.createBlock(Ae,{key:0,"recognizer-initialized":e.unref(g),"recognizer-progress":e.unref(d),onKey:L,onExit:R,onRecognize:j},null,8,["recognizer-initialized","recognizer-progress"])):l.value==="num"?(e.openBlock(),e.createBlock(gt,{key:1,"keyboard-rows":C.numKeys,onKey:L,onExit:R},null,8,["keyboard-rows"])):l.value==="symbol"?(e.openBlock(),e.createBlock($t,{key:2,onKey:L,onExit:R})):l.value==="en"||l.value==="zh"?(e.openBlock(),e.createBlock(st,{key:3,modelValue:l.value,"onUpdate:modelValue":V[0]||(V[0]=P=>l.value=P),"enable-handwriting":C.enableHandwriting,onKey:L},null,8,["modelValue","enable-handwriting"])):e.createCommentVNode("",!0)],64))],38)),[[e.vShow,p.value]])}}),Rt={install:n=>{n.component("ZhKeyboard",le)}};E.CanvasDrawer=G,E.ZhKeyboard=le,E.calculateKeyboardPosition=Q,E.createKeyRepeater=re,E.default=Rt,E.delToInputElement=ne,E.getHandwritingRecognizer=I,E.getInputElement=xe,E.getKeyboardConfig=$,E.getPinyinEngine=J,E.isInputElement=A,E.moveCursor=oe,E.registerHandwritingRecognizer=Be,E.registerPinyinEngine=Ve,E.setKeyboardConfig=ze,E.writeToInputElement=te,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E.ZhKeyboardVue={},E.Vue))})(this,function(E,e){"use strict";var Dt=Object.defineProperty;var Ht=(E,e,_)=>e in E?Dt(E,e,{enumerable:!0,configurable:!0,writable:!0,value:_}):E[e]=_;var x=(E,e,_)=>Ht(E,typeof e!="symbol"?e+"":e,_);function _(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}const ae=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const de=t=>t!=null,ce=Object.prototype.toString,fe=t=>ce.call(t)==="[object Object]",F=()=>{};function ue(t,o){function i(...a){return new Promise((l,r)=>{Promise.resolve(t(()=>o.apply(this,a),{fn:o,thisArg:this,args:a})).then(l).catch(r)})}return i}function me(t,o={}){let i,a,l=F;const r=f=>{clearTimeout(f),l(),l=F};let c;return f=>{const y=e.toValue(t),h=e.toValue(o.maxWait);return i&&r(i),y<=0||h!==void 0&&h<=0?(a&&(r(a),a=null),Promise.resolve(f())):new Promise((d,k)=>{l=o.rejectOnCancel?k:d,c=f,h&&!a&&(a=setTimeout(()=>{i&&r(i),a=null,d(c())},h)),i=setTimeout(()=>{a&&r(a),a=null,d(f())},y)})}}function D(t){return Array.isArray(t)?t:[t]}function pe(t){return e.getCurrentInstance()}function ke(t,o=200,i={}){return ue(me(o,i),t)}function ge(t,o=!0,i){pe()?e.onMounted(t,i):o?t():e.nextTick(t)}function he(t,o,i){return e.watch(t,o,{...i,immediate:!0})}const $=ae?window:void 0;function N(t){var o;const i=e.toValue(t);return(o=i==null?void 0:i.$el)!=null?o:i}function H(...t){const o=[],i=()=>{o.forEach(m=>m()),o.length=0},a=(m,f,y,h)=>(m.addEventListener(f,y,h),()=>m.removeEventListener(f,y,h)),l=e.computed(()=>{const m=D(e.toValue(t[0])).filter(f=>f!=null);return m.every(f=>typeof f!="string")?m:void 0}),r=he(()=>{var m,f;return[(f=(m=l.value)==null?void 0:m.map(y=>N(y)))!=null?f:[$].filter(y=>y!=null),D(e.toValue(l.value?t[1]:t[0])),D(e.unref(l.value?t[2]:t[1])),e.toValue(l.value?t[3]:t[2])]},([m,f,y,h])=>{if(i(),!(m!=null&&m.length)||!(f!=null&&f.length)||!(y!=null&&y.length))return;const d=fe(h)?{...h}:h;o.push(...m.flatMap(k=>f.flatMap(u=>y.map(p=>a(k,u,p,d)))))},{flush:"post"}),c=()=>{r(),i()};return _(i),c}function ye(){const t=e.shallowRef(!1),o=e.getCurrentInstance();return o&&e.onMounted(()=>{t.value=!0},o),t}function j(t){const o=ye();return e.computed(()=>(o.value,!!t()))}function be(t,o,i={}){const{window:a=$,...l}=i;let r;const c=j(()=>a&&"MutationObserver"in a),m=()=>{r&&(r.disconnect(),r=void 0)},f=e.computed(()=>{const k=e.toValue(t),u=D(k).map(N).filter(de);return new Set(u)}),y=e.watch(()=>f.value,k=>{m(),c.value&&k.size&&(r=new MutationObserver(o),k.forEach(u=>r.observe(u,l)))},{immediate:!0,flush:"post"}),h=()=>r==null?void 0:r.takeRecords(),d=()=>{y(),m()};return _(d),{isSupported:c,stop:d,takeRecords:h}}function we(t,o,i={}){const{window:a=$,document:l=a==null?void 0:a.document,flush:r="sync"}=i;if(!a||!l)return F;let c;const m=h=>{c==null||c(),c=h},f=e.watchEffect(()=>{const h=N(t);if(h){const{stop:d}=be(l,k=>{k.map(p=>[...p.removedNodes]).flat().some(p=>p===h||p.contains(h))&&o(k)},{window:a,childList:!0,subtree:!0});m(d)}},{flush:r}),y=()=>{f(),m()};return _(y),y}function Ee(t={}){var o;const{window:i=$,deep:a=!0,triggerOnRemoval:l=!1}=t,r=(o=t.document)!=null?o:i==null?void 0:i.document,c=()=>{var y;let h=r==null?void 0:r.activeElement;if(a)for(;h!=null&&h.shadowRoot;)h=(y=h==null?void 0:h.shadowRoot)==null?void 0:y.activeElement;return h},m=e.shallowRef(),f=()=>{m.value=c()};if(i){const y={capture:!0,passive:!0};H(i,"blur",h=>{h.relatedTarget===null&&f()},y),H(i,"focus",f,y)}return l&&we(m,f,{document:r}),f(),m}function Ce(t,o,i={}){const{window:a=$,...l}=i;let r;const c=j(()=>a&&"ResizeObserver"in a),m=()=>{r&&(r.disconnect(),r=void 0)},f=e.computed(()=>{const d=e.toValue(t);return Array.isArray(d)?d.map(k=>N(k)):[N(d)]}),y=e.watch(f,d=>{if(m(),c.value&&a){r=new ResizeObserver(o);for(const k of d)k&&r.observe(k,l)}},{immediate:!0,flush:"post"}),h=()=>{m(),y()};return _(h),{isSupported:c,stop:h}}function X(t,o={width:0,height:0},i={}){const{window:a=$,box:l="content-box"}=i,r=e.computed(()=>{var d,k;return(k=(d=N(t))==null?void 0:d.namespaceURI)==null?void 0:k.includes("svg")}),c=e.shallowRef(o.width),m=e.shallowRef(o.height),{stop:f}=Ce(t,([d])=>{const k=l==="border-box"?d.borderBoxSize:l==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(a&&r.value){const u=N(t);if(u){const p=u.getBoundingClientRect();c.value=p.width,m.value=p.height}}else if(k){const u=D(k);c.value=u.reduce((p,{inlineSize:C})=>p+C,0),m.value=u.reduce((p,{blockSize:C})=>p+C,0)}else c.value=d.contentRect.width,m.value=d.contentRect.height},i);ge(()=>{const d=N(t);d&&(c.value="offsetWidth"in d?d.offsetWidth:o.width,m.value="offsetHeight"in d?d.offsetHeight:o.height)});const y=e.watch(()=>N(t),d=>{c.value=d?o.width:0,m.value=d?o.height:0});function h(){f(),y()}return{width:c,height:m,stop:h}}var Y=class{constructor(t,o={}){x(this,"canvas");x(this,"ctx");x(this,"lastX",0);x(this,"lastY",0);x(this,"strokeData",[]);x(this,"clearTimerId",null);x(this,"isDrawing",!1);x(this,"options");x(this,"handleStart",t=>{t.preventDefault(),this.isDrawing=!0;const{offsetX:o,offsetY:i}=this.getEventCoordinates(t);this.startDrawing(o,i),this.resetClearTimer()});x(this,"handleMove",t=>{if(!this.isDrawing)return;t.preventDefault();const{offsetX:o,offsetY:i}=this.getEventCoordinates(t);this.draw(o,i),this.resetClearTimer()});x(this,"handleEnd",t=>{this.isDrawing&&(t.preventDefault(),this.isDrawing=!1,this.endStroke(),this.startClearTimer(),this.options.onDrawEnd&&this.options.onDrawEnd())});this.canvas=t,this.options={clearDelay:1e3,...o};const i=this.canvas.getContext("2d");if(!i)throw new Error("Failed to get 2D rendering context");this.ctx=i,this.setupCanvas(),this.attachEvents()}setupCanvas(){this.ctx.lineJoin="round",this.ctx.lineCap="round",this.ctx.lineWidth=3,this.ctx.strokeStyle="#000",this.clearCanvas(),this.drawGrid()}drawGrid(){const t=this.canvas.width,o=this.canvas.height;this.ctx.save(),this.ctx.strokeStyle="#ddd",this.ctx.lineWidth=1,this.ctx.setLineDash([3,3]),this.ctx.beginPath(),this.ctx.moveTo(0,o/2),this.ctx.lineTo(t,o/2),this.ctx.moveTo(t/2,0),this.ctx.lineTo(t/2,o),this.ctx.stroke(),this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.rect(0,0,t,o),this.ctx.stroke(),this.ctx.restore()}clearCanvas(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawGrid(),this.strokeData=[],this.resetClearTimer()}startDrawing(t,o){this.lastX=t,this.lastY=o,this.ctx.strokeStyle="#000",this.ctx.lineWidth=3,this.ctx.setLineDash([]),this.strokeData.push(t,o,0)}draw(t,o){this.ctx.beginPath(),this.ctx.moveTo(this.lastX,this.lastY),this.ctx.lineTo(t,o),this.ctx.stroke(),this.lastX=t,this.lastY=o,this.strokeData.push(t,o,0)}endStroke(){this.strokeData.length>=3&&(this.strokeData[this.strokeData.length-1]=1)}getStrokeData(){return this.strokeData}resetClearTimer(){this.clearTimerId&&(window.clearTimeout(this.clearTimerId),this.clearTimerId=null)}startClearTimer(){this.resetClearTimer(),this.clearTimerId=window.setTimeout(()=>{this.clearCanvas(),this.clearTimerId=null},this.options.clearDelay)}getEventCoordinates(t){if(t instanceof MouseEvent)return{offsetX:t.offsetX,offsetY:t.offsetY};{const o=t.touches[0]||t.changedTouches[0],i=t.target.getBoundingClientRect();return{offsetX:o.clientX-i.left,offsetY:o.clientY-i.top}}}attachEvents(){this.canvas.addEventListener("mousedown",this.handleStart),this.canvas.addEventListener("mousemove",this.handleMove),this.canvas.addEventListener("mouseup",this.handleEnd),this.canvas.addEventListener("mouseleave",this.handleEnd),this.canvas.addEventListener("touchstart",this.handleStart,{passive:!1}),this.canvas.addEventListener("touchmove",this.handleMove,{passive:!1}),this.canvas.addEventListener("touchend",this.handleEnd),this.canvas.addEventListener("touchcancel",this.handleEnd)}detachEvents(){this.canvas.removeEventListener("mousedown",this.handleStart),this.canvas.removeEventListener("mousemove",this.handleMove),this.canvas.removeEventListener("mouseup",this.handleEnd),this.canvas.removeEventListener("mouseleave",this.handleEnd),this.canvas.removeEventListener("touchstart",this.handleStart),this.canvas.removeEventListener("touchmove",this.handleMove),this.canvas.removeEventListener("touchend",this.handleEnd),this.canvas.removeEventListener("touchcancel",this.handleEnd)}destroy(){this.detachEvents(),this.resetClearTimer()}getCanvas(){return this.canvas}getContext(){return this.ctx}};let W={defaultMode:"en",enableHandwriting:!1,position:"static",disableWhenNoFocus:!0},G=null,q=null;function S(){return W}function ze(t){W={...W,...t}}function Be(t){G=t}function I(){return G}function Ve(t){q=t}function J(){return q}function Q(t,o,i,a=0){if(!t||!o||i==="static")return null;let l,r;if(i==="bottom")l=window.innerHeight-o.offsetHeight,r=0;else{const c=t.getBoundingClientRect(),m=o.offsetWidth;l=c.bottom+window.scrollY+a,r=c.left+window.scrollX+c.width/2-m/2;const f=window.innerWidth;r+m>f&&(r=f-m-10),r<10&&(r=10)}return{top:`${l}px`,left:`${r}px`}}function A(t){if(!t)return!1;if(t.tagName==="TEXTAREA")return!0;if(t.tagName==="INPUT"){const i=(t.type||"text").toLowerCase();return!["checkbox","radio","button","submit","reset","file","image","range","color","hidden","date","datetime-local","month","week","time"].includes(i)}return!1}function xe(){if(document.activeElement&&A(document.activeElement))return document.activeElement;throw new Error("输入框没有被激活")}function Pe(t,o,i){t.value=o,oe(t,i),t.dispatchEvent(new Event("input",{bubbles:!0}))}function _e(t,o,i,a=""){return t.slice(0,o)+a+t.slice(o+i)}function ee(t,o=""){const i=Number(t.getAttribute("maxlength"));let a=t.selectionStart??0;const l=t.selectionEnd??a;let r;if(o.length>0)r=l-a;else{const f=l-a;if(f>0)r=f;else if(a>0)r=1,a--;else return}if(o.length>0&&i&&t.value.length-r+o.length>i)return;const c=_e(t.value,a,r,o),m=a+o.length;Pe(t,c,m)}function te(t,o){ee(t,o)}function ne(t){ee(t)}function oe(t,o){t.selectionStart=o,t.selectionEnd=o}function re(t={}){const o=t.delay??400,i=t.interval??60;let a,l;function r(){a&&(clearTimeout(a),a=void 0),l&&(clearInterval(l),l=void 0)}function c(m){r(),m(),a=setTimeout(()=>{l=setInterval(()=>{m()},i)},o)}return{start:c,stop:r}}function Ne(t=!1){const o=e.ref(!1),i=e.ref(0);async function a(){const r=I();if(r)try{o.value=await r.initialize({onProgress:c=>{i.value=c}})}catch(c){console.error("初始化手写识别服务失败:",c),o.value=!1}else console.warn("未注册手写识别服务"),o.value=!1}async function l(){const r=I();if(r&&o.value)try{await r.close(),o.value=!1}catch(c){console.error("关闭手写识别服务失败:",c)}}return e.onMounted(()=>{t&&a()}),e.onUnmounted(()=>{l()}),{recognizerInitialized:o,recognizerProgress:i}}const O="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M21,11H6.83L10.41,7.41L9,6L3,12L9,18L10.41,16.58L6.83,13H21V11Z'%20/%3e%3c/svg%3e",U="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e";function K(){const t=re();function o(a,l){var r,c;a.preventDefault(),(c=(r=a.currentTarget)==null?void 0:r.setPointerCapture)==null||c.call(r,a.pointerId),t.start(l)}function i(){t.stop()}return e.onBeforeUnmount(()=>{t.stop()}),{startRepeat:o,stopRepeat:i}}const Se={class:"zhk-candidate-list"},Me=["onClick"],ie=e.defineComponent({__name:"CandidateList",props:{candidates:{}},emits:["select"],setup(t,{emit:o}){const i=o;function a(l){i("select",l)}return(l,r)=>(e.openBlock(),e.createElementBlock("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.candidates,(c,m)=>(e.openBlock(),e.createElementBlock("button",{key:`candidate-${m}`,class:"zhk-candidate-list__item",onClick:f=>a(m)},e.toDisplayString(c),9,Me))),128))]))}}),$e={class:"handwriting-input"},Le={class:"handwriting-buttons"},Te={class:"handwriting-canvas-container"},Re={class:"progress-bar"},De={class:"progress-text"},He=["width","height"],Ie={class:"handwriting-buttons"},Ae=e.defineComponent({__name:"HandwritingInput",props:{recognizerInitialized:{type:Boolean},recognizerProgress:{}},emits:["key","exit"],setup(t,{emit:o}){const i=t,a=o,l=e.ref(null),r=e.ref(null);let c=null;const m=e.ref(!1),{height:f}=X(r);function y(){c&&c.clearCanvas()}function h(){l.value&&(c&&c.destroy(),c=new Y(l.value,{onDrawEnd:p}))}const d=e.ref([]),{startRepeat:k,stopRepeat:u}=K();async function p(){if(!c||c.getStrokeData().length===0||m.value)return;const w=I();if(w){m.value=!0;try{const n=[...c.getStrokeData()],g=await w.recognize(n);d.value=g}catch(n){console.error("识别笔迹失败:",n)}finally{m.value=!1}}else console.warn("手写识别服务不可用")}e.onUnmounted(()=>{c&&c.destroy()}),e.watchEffect(()=>{l.value&&f.value&&i.recognizerInitialized&&e.nextTick(()=>{h()})});function C(w){const n=d.value[w];n&&(a("key",{key:n}),d.value=[],y())}return(w,n)=>(e.openBlock(),e.createElementBlock("div",$e,[e.createVNode(ie,{candidates:d.value,onSelect:C},null,8,["candidates"]),e.createElementVNode("div",{ref_key:"containerRef",ref:r,class:"handwriting-content"},[e.createElementVNode("div",Le,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[0]||(n[0]=g=>e.unref(k)(g,()=>a("key",{key:"。"}))),onPointerup:n[1]||(n[1]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[2]||(n[2]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[3]||(n[3]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[4]||(n[4]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[5]||(n[5]=g=>e.unref(k)(g,()=>a("key",{key:"?"}))),onPointerup:n[6]||(n[6]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[7]||(n[7]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[8]||(n[8]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[9]||(n[9]=e.withModifiers(()=>{},["prevent"]))}," ? ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[10]||(n[10]=g=>e.unref(k)(g,()=>a("key",{key:"!"}))),onPointerup:n[11]||(n[11]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[12]||(n[12]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[13]||(n[13]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[14]||(n[14]=e.withModifiers(()=>{},["prevent"]))}," ! ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[15]||(n[15]=g=>e.unref(k)(g,()=>a("key",{key:"、"}))),onPointerup:n[16]||(n[16]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[17]||(n[17]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[18]||(n[18]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[19]||(n[19]=e.withModifiers(()=>{},["prevent"]))}," 、 ",32)]),e.createElementVNode("div",Te,[w.recognizerInitialized?(e.openBlock(),e.createElementBlock("canvas",{key:1,ref_key:"canvasRef",ref:l,class:"handwriting-canvas",width:e.unref(f),height:e.unref(f)},null,8,He)):(e.openBlock(),e.createElementBlock("div",{key:0,class:"handwriting-loading",style:e.normalizeStyle({width:`${e.unref(f)}px`,height:`${e.unref(f)}px`})},[n[37]||(n[37]=e.createElementVNode("div",{class:"loading-text"}," 正在加载手写识别... ",-1)),e.createElementVNode("div",Re,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${w.recognizerProgress*100}%`})},null,4)]),e.createElementVNode("div",De,e.toDisplayString(Math.round(w.recognizerProgress*100))+"% ",1)],4))]),e.createElementVNode("div",Ie,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[20]||(n[20]=g=>e.unref(k)(g,()=>a("key",{key:"delete",isControl:!0}))),onPointerup:n[21]||(n[21]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[22]||(n[22]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[23]||(n[23]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[24]||(n[24]=e.withModifiers(()=>{},["prevent"]))},n[38]||(n[38]=[e.createElementVNode("img",{src:O,alt:"删除"},null,-1)]),32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onClick:n[25]||(n[25]=g=>a("exit")),onContextmenu:n[26]||(n[26]=e.withModifiers(()=>{},["prevent"]))}," 拼音 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[27]||(n[27]=g=>e.unref(k)(g,()=>a("key",{key:","}))),onPointerup:n[28]||(n[28]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[29]||(n[29]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[30]||(n[30]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[31]||(n[31]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[32]||(n[32]=g=>e.unref(k)(g,()=>a("key",{key:"enter",isControl:!0}))),onPointerup:n[33]||(n[33]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[34]||(n[34]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[35]||(n[35]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[36]||(n[36]=e.withModifiers(()=>{},["prevent"]))},n[39]||(n[39]=[e.createElementVNode("img",{src:U,alt:"回车"},null,-1)]),32)])],512)]))}}),Ke="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M6,18H18V16H6M12,8.41L16.59,13L18,11.58L12,5.58L6,11.58L7.41,13L12,8.41Z'%20/%3e%3c/svg%3e",se="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e",Fe="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z'%20/%3e%3c/svg%3e",We={class:"zhk-selection"},Oe={class:"zhk-selection__list"},Ue=["onClick"],Ze=e.defineComponent({__name:"CandidateSelection",props:{candidates:{}},emits:["select","close"],setup(t,{emit:o}){const i=o;function a(c){i("select",c)}function l(){i("close")}function r(c){const m=Array.from(c).length;return m>=2&&m<=3?2:m>=4?3:1}return(c,m)=>(e.openBlock(),e.createElementBlock("div",We,[e.createElementVNode("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.candidates,(f,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["zhk-selection__text",[`zhk-selection__text--span-${r(f)}`]]),onClick:h=>a(y)},e.toDisplayString(f),11,Ue))),128))]),e.createElementVNode("div",{class:"zhk-selection__func"},[e.createElementVNode("button",{class:"zhk-selection__func-btn",onClick:l}," 返回 ")])]))}}),ve={class:"zhk-candidate"},je={class:"zhk-candidate__container"},Xe={key:0,class:"zhk-candidate__pinyin"},Ye={class:"zhk-candidate__bottom-container"},Ge=e.defineComponent({__name:"CandidateBar",props:{modelValue:{required:!0},modelModifiers:{}},emits:e.mergeModels(["key","input"],["update:modelValue"]),setup(t,{expose:o,emit:i}){const a=i,l=e.useModel(t,"modelValue");let r=null;const c=e.ref(null),m=e.computed(()=>{var d;return((d=c.value)==null?void 0:d.candidates.map(k=>k.text))??[]}),f=e.ref(!1);e.onMounted(async()=>{if(r=J(),!r)throw new Error("未找到拼音引擎实例,请确保已正确注册引擎");l.value&&(c.value=await r.processInput(l.value))}),e.onUnmounted(()=>{r==null||r.clearInput(),r=null}),e.watch(l,async d=>{const k=r;if(k){if(d===""){k.clearInput(),c.value=null;return}c.value=await k.processInput(d)}});async function y(d){if(!r)return;const k=await r.pickCandidate(d);c.value=k,k.preeditBody||(a("input",k.committed||""),l.value="",c.value=null,f.value=!1)}o({handleSelection:y});const h=e.computed(()=>{const d=c.value;return d?d.preeditHead+d.preeditBody:""});return(d,k)=>(e.openBlock(),e.createElementBlock("div",ve,[e.createElementVNode("div",je,[h.value?(e.openBlock(),e.createElementBlock("div",Xe,e.toDisplayString(h.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ye,[m.value.length>0?(e.openBlock(),e.createBlock(ie,{key:0,candidates:m.value,onSelect:y},null,8,["candidates"])):e.createCommentVNode("",!0),m.value.length>0?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-candidate__more",onClick:k[0]||(k[0]=u=>f.value=!0)},k[2]||(k[2]=[e.createElementVNode("img",{src:Fe,alt:"更多"},null,-1)]))):e.createCommentVNode("",!0)])]),f.value?(e.openBlock(),e.createBlock(Ze,{key:0,candidates:m.value,onSelect:y,onClose:k[1]||(k[1]=u=>f.value=!1)},null,8,["candidates"])):e.createCommentVNode("",!0)]))}}),qe={class:"zhk-base"},Je={class:"zhk-base__row"},Qe=["onPointerdown"],et=["disabled"],tt={key:1,src:Ke,class:"zhk-base__key-icon",alt:"Shift"},nt=["onPointerdown"],ot={class:"zhk-base__row"},rt={class:"zhk-base__toggle-main"},it={class:"zhk-base__toggle-sub"},st=e.defineComponent({__name:"KeyboardBase",props:e.mergeModels({enableHandwriting:{type:Boolean}},{modelValue:{default:"en"},modelModifiers:{}}),emits:e.mergeModels(["key"],["update:modelValue"]),setup(t,{emit:o}){const i=t,a=o,l=e.useModel(t,"modelValue"),r=e.computed(()=>l.value==="en_cap"),c=e.computed(()=>l.value==="zh"),m=e.computed(()=>c.value?!0:r.value);function f(P,s=!1){a("key",{key:P,isControl:s})}function y(){c.value?l.value="hand":l.value=r.value?"en":"en_cap"}function h(){l.value="num"}function d(){l.value="symbol"}const k=["1","2","3","4","5","6","7","8","9","0"],u=[["q","w","e","r","t","y","u","i","o","p"],["a","s","d","f","g","h","j","k","l"],["z","x","c","v","b","n","m"]],p=e.ref(""),C=e.ref(null),{startRepeat:w,stopRepeat:n}=K();function g(){if(l.value==="zh"&&p.value){p.value=p.value.slice(0,-1);return}f("delete",!0)}function L(){var P;if(l.value==="zh"&&p.value){(P=C.value)==null||P.handleSelection(0);return}f(" ")}function Z(){if(l.value==="zh"&&p.value){f(p.value),p.value="";return}f("enter",!0)}function T(P){if(l.value==="zh"){p.value+=P;return}const s=r.value?P.toUpperCase():P;f(s)}function v(){l.value=l.value==="zh"?"en":"zh"}const B=e.computed(()=>i.enableHandwriting?"手写":"-"),V=e.computed(()=>!i.enableHandwriting);return(P,s)=>(e.openBlock(),e.createElementBlock("div",qe,[e.createElementVNode("div",Je,[l.value==="zh"?(e.openBlock(),e.createBlock(Ge,{key:0,ref_key:"candidateBarRef",ref:C,modelValue:p.value,"onUpdate:modelValue":s[0]||(s[0]=b=>p.value=b),onInput:s[1]||(s[1]=b=>f(b,!1))},null,8,["modelValue"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},e.renderList(k,(b,R)=>e.createElementVNode("button",{key:`number-${R}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:z=>e.unref(w)(z,()=>T(b)),onPointerup:s[2]||(s[2]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onPointerleave:s[3]||(s[3]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onPointercancel:s[4]||(s[4]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onContextmenu:s[5]||(s[5]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(b),41,Qe)),64))]),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(u,(b,R)=>e.createElementVNode("div",{key:`row-${R}`,class:"zhk-base__row"},[R===2?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["zhk-base__key zhk-base__key--function zhk-base__key--shift",{"zhk-base__key--active":!c.value&&r.value,"zhk-base__key--disabled":c.value&&V.value}]),disabled:c.value&&V.value,onClick:y,onContextmenu:s[6]||(s[6]=e.withModifiers(()=>{},["prevent"]))},[c.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(B.value),1)],64)):(e.openBlock(),e.createElementBlock("img",tt))],42,et)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(z,Rt)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${R}-${Rt}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:M=>e.unref(w)(M,()=>T(z)),onPointerup:s[7]||(s[7]=(...M)=>e.unref(n)&&e.unref(n)(...M)),onPointerleave:s[8]||(s[8]=(...M)=>e.unref(n)&&e.unref(n)(...M)),onPointercancel:s[9]||(s[9]=(...M)=>e.unref(n)&&e.unref(n)(...M)),onContextmenu:s[10]||(s[10]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(m.value?z.toUpperCase():z),41,nt))),128)),R===2?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-base__key zhk-base__key--function zhk-base__key--delete",onPointerdown:s[11]||(s[11]=z=>e.unref(w)(z,()=>g())),onPointerup:s[12]||(s[12]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onPointerleave:s[13]||(s[13]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onPointercancel:s[14]||(s[14]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onContextmenu:s[15]||(s[15]=e.withModifiers(()=>{},["prevent"]))},s[39]||(s[39]=[e.createElementVNode("img",{src:O,class:"zhk-base__key-icon",alt:"Delete"},null,-1)]),32)):e.createCommentVNode("",!0)])),64)),e.createElementVNode("div",ot,[e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:d,onContextmenu:s[16]||(s[16]=e.withModifiers(()=>{},["prevent"]))}," 符 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:h,onContextmenu:s[17]||(s[17]=e.withModifiers(()=>{},["prevent"]))}," 123 ",32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:s[18]||(s[18]=b=>e.unref(w)(b,()=>f(","))),onPointerup:s[19]||(s[19]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:s[20]||(s[20]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:s[21]||(s[21]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:s[22]||(s[22]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--space",onPointerdown:s[23]||(s[23]=b=>e.unref(w)(b,()=>L())),onPointerup:s[24]||(s[24]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:s[25]||(s[25]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:s[26]||(s[26]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:s[27]||(s[27]=e.withModifiers(()=>{},["prevent"]))},s[40]||(s[40]=[e.createElementVNode("img",{src:se,class:"zhk-base__key-icon",alt:"Space"},null,-1)]),32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:s[28]||(s[28]=b=>e.unref(w)(b,()=>f("。"))),onPointerup:s[29]||(s[29]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:s[30]||(s[30]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:s[31]||(s[31]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:s[32]||(s[32]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:v,onContextmenu:s[33]||(s[33]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("span",rt,e.toDisplayString(l.value==="zh"?"中":"英"),1),e.createElementVNode("span",it,"/"+e.toDisplayString(l.value==="zh"?"英":"中"),1)],32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onPointerdown:s[34]||(s[34]=b=>e.unref(w)(b,()=>Z())),onPointerup:s[35]||(s[35]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:s[36]||(s[36]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:s[37]||(s[37]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:s[38]||(s[38]=e.withModifiers(()=>{},["prevent"]))},s[41]||(s[41]=[e.createElementVNode("img",{src:U,class:"zhk-base__key-icon",alt:"Enter"},null,-1)]),32)])]))}}),lt={class:"num-keyboard"},at={class:"num-keyboard__container"},dt={class:"num-keyboard__left"},ct={class:"num-keyboard__rows"},ft=["onClick","onPointerdown"],ut={key:1,src:se,class:"zhk-base__key-icon",alt:"Space"},mt={class:"num-keyboard__right"},pt=["onPointerdown"],kt=["src","alt"],gt={key:1},ht=e.defineComponent({__name:"NumericKeyboard",props:{keyboardRows:{default:()=>S().numKeys||[["1","2","3"],["4","5","6"],["7","8","9"],["back","0","space"]]}},emits:["key","exit"],setup(t,{emit:o}){const i=o,a=[{key:"delete",icon:O,text:"",alt:"Delete"},{key:".",icon:"",text:".",alt:"."},{key:"@",icon:"",text:"@",alt:"@"},{key:"enter",icon:U,text:"",alt:"Enter"}];function l(h){i("key",{key:h})}function r(h,d=!0){i("key",{key:h,isControl:d})}function c(){i("exit")}const{startRepeat:m,stopRepeat:f}=K();function y(h,d){h==="back"||(h==="space"&&(h=" "),h==="delete"||h==="enter"?m(d,()=>r(h)):m(d,()=>l(h)))}return(h,d)=>(e.openBlock(),e.createElementBlock("div",lt,[e.createElementVNode("div",at,[e.createElementVNode("div",dt,[e.createElementVNode("div",ct,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.keyboardRows,(k,u)=>(e.openBlock(),e.createElementBlock("div",{key:`row-${u}`,class:"num-keyboard__row"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,(p,C)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${u}-${C}`,class:e.normalizeClass(["num-keyboard__key",{"num-keyboard__key--back":p==="back","num-keyboard__key--space":p==="space"}]),onClick:w=>p==="back"&&c(),onPointerdown:w=>y(p,w),onPointerup:d[0]||(d[0]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onPointerleave:d[1]||(d[1]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onPointercancel:d[2]||(d[2]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onContextmenu:d[3]||(d[3]=e.withModifiers(()=>{},["prevent"]))},[p==="back"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(" 返回 ")],64)):p==="space"?(e.openBlock(),e.createElementBlock("img",ut)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(p),1)],64))],42,ft))),128))]))),128))])]),e.createElementVNode("div",mt,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,(k,u)=>e.createElementVNode("button",{key:`func-${u}`,class:"num-keyboard__key num-keyboard__key--function",onPointerdown:p=>y(k.key,p),onPointerup:d[4]||(d[4]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onPointerleave:d[5]||(d[5]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onPointercancel:d[6]||(d[6]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onContextmenu:d[7]||(d[7]=e.withModifiers(()=>{},["prevent"]))},[k.icon?(e.openBlock(),e.createElementBlock("img",{key:0,src:k.icon,class:"num-keyboard__key-icon",alt:k.alt},null,8,kt)):(e.openBlock(),e.createElementBlock("span",gt,e.toDisplayString(k.text),1))],40,pt)),64))])])]))}}),yt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10A2,2%200%200,1%206,8H15V6A3,3%200%200,0%2012,3A3,3%200%200,0%209,6H7A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,17A2,2%200%200,1%2010,15A2,2%200%200,1%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17Z'%20/%3e%3c/svg%3e",bt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M12,17C10.89,17%2010,16.1%2010,15C10,13.89%2010.89,13%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10C4,8.89%204.89,8%206,8H7V6A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,3A3,3%200%200,0%209,6V8H15V6A3,3%200%200,0%2012,3Z'%20/%3e%3c/svg%3e",wt={class:"symbol-keyboard"},Et={class:"symbol-keyboard__content"},Ct={class:"symbol-keyboard__functions"},zt={class:"symbol-keyboard__lang-selector"},Bt={class:"symbol-keyboard__control-group"},Vt=["src"],xt=["src"],Pt={class:"symbol-keyboard__symbols-container"},_t={class:"symbol-keyboard__symbols-grid"},Nt=["onClick","onPointerdown"],St="!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°",Mt="!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°",$t=e.defineComponent({__name:"SymbolKeyboard",emits:["key","exit"],setup(t,{emit:o}){const i=o,a=e.ref("en"),l=e.computed(()=>a.value==="zh"?Mt:St),r=e.ref(!1),{startRepeat:c,stopRepeat:m}=K();function f(u,p){r.value&&c(p,()=>y(u))}function y(u){i("key",{key:u}),r.value||i("exit")}function h(){i("exit")}function d(u){a.value=u}function k(){r.value=!r.value}return(u,p)=>(e.openBlock(),e.createElementBlock("div",wt,[e.createElementVNode("div",Et,[e.createElementVNode("div",Ct,[e.createElementVNode("div",zt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="zh"}]),onClick:p[0]||(p[0]=C=>d("zh")),onContextmenu:p[1]||(p[1]=e.withModifiers(()=>{},["prevent"]))}," 中文 ",34),e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="en"}]),onClick:p[2]||(p[2]=C=>d("en")),onContextmenu:p[3]||(p[3]=e.withModifiers(()=>{},["prevent"]))}," 英文 ",34)]),e.createElementVNode("div",Bt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock",{"symbol-keyboard__key--locked":r.value}]),onClick:k,onContextmenu:p[4]||(p[4]=e.withModifiers(()=>{},["prevent"]))},[r.value?(e.openBlock(),e.createElementBlock("img",{key:1,src:e.unref(bt),alt:"Lock closed"},null,8,xt)):(e.openBlock(),e.createElementBlock("img",{key:0,src:e.unref(yt),alt:"Lock open"},null,8,Vt))],34),e.createElementVNode("button",{class:"symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",onClick:h,onContextmenu:p[5]||(p[5]=e.withModifiers(()=>{},["prevent"]))}," 返回 ",32)])]),e.createElementVNode("div",Pt,[e.createElementVNode("div",_t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(C,w)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${w}`,class:"symbol-keyboard__key",onClick:n=>!r.value&&y(C),onPointerdown:n=>f(C,n),onPointerup:p[6]||(p[6]=(...n)=>e.unref(m)&&e.unref(m)(...n)),onPointerleave:p[7]||(p[7]=(...n)=>e.unref(m)&&e.unref(m)(...n)),onPointercancel:p[8]||(p[8]=(...n)=>e.unref(m)&&e.unref(m)(...n)),onContextmenu:p[9]||(p[9]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(C),41,Nt))),128))])])])]))}}),Lt={key:0,class:"zhk__disabled-overlay"},le=e.defineComponent({__name:"ZhKeyboard",props:{defaultMode:{type:String,default:()=>S().defaultMode??"en"},enableHandwriting:{type:Boolean,default:()=>S().enableHandwriting??!1},position:{type:String,default:()=>S().position??"static"},floatMarginTop:{type:Number,default:()=>S().floatMarginTop??0},disableWhenNoFocus:{type:Boolean,default:()=>S().disableWhenNoFocus??!0},numKeys:{type:Array||void 0}},emits:["key"],setup(t,{emit:o}){const i=t,a=o,l=e.ref(i.defaultMode),r=e.ref(i.defaultMode),c=e.ref([]),m=e.ref(!1),f=e.ref(null),y=e.ref(null),{recognizerInitialized:h,recognizerProgress:d}=Ne(i.enableHandwriting);e.watch(l,(B,V)=>{B!==V&&(r.value=V)});const k=Ee(),u=e.computed(()=>k.value&&A(k.value)?k.value:null),p=e.computed(()=>i.position==="static"||!!(k.value&&A(k.value))),{height:C}=X(y);e.watchEffect(()=>{if(u.value){const B=u.value.dataset.inputmode;B&&(l.value=B)}});const w=e.computed(()=>i.disableWhenNoFocus===!1?!1:!u.value);function n(){if(!C.value)return;const B=Q(u.value,y.value,i.position,i.floatMarginTop);f.value=B}e.watchEffect(n);const g=ke(n,100);H(window,"scroll",g,{passive:!0}),H(window,"resize",g,{passive:!0});function L(B){if(B.isControl){switch(B.key){case"delete":ne(u.value);break;case"more":m.value=!0;break}return}else Z(B.key);a("key",B)}function Z(B){te(u.value,B)}function T(){l.value==="hand"?r.value="zh":["num","symbol"].includes(r.value)&&(r.value=i.defaultMode),l.value=r.value}function v(B){c.value=B}return(B,V)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",{ref_key:"keyboardRef",ref:y,class:e.normalizeClass(["zhk",{"zhk--floating":t.position==="float","zhk--bottom":t.position==="bottom","zhk--disabled":w.value}]),style:e.normalizeStyle({"--keyboard-height":`${e.unref(C)}px`,...f.value}),onMousedown:V[1]||(V[1]=e.withModifiers(()=>{},["prevent"]))},[w.value||!p.value||!e.unref(C)?(e.openBlock(),e.createElementBlock("div",Lt,V[2]||(V[2]=[e.createElementVNode("span",null,"请选择输入框以启用键盘",-1)]))):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l.value==="hand"?(e.openBlock(),e.createBlock(Ae,{key:0,"recognizer-initialized":e.unref(h),"recognizer-progress":e.unref(d),onKey:L,onExit:T,onRecognize:v},null,8,["recognizer-initialized","recognizer-progress"])):l.value==="num"?(e.openBlock(),e.createBlock(ht,{key:1,"keyboard-rows":t.numKeys,onKey:L,onExit:T},null,8,["keyboard-rows"])):l.value==="symbol"?(e.openBlock(),e.createBlock($t,{key:2,onKey:L,onExit:T})):l.value==="en"||l.value==="en_cap"||l.value==="zh"?(e.openBlock(),e.createBlock(st,{key:3,modelValue:l.value,"onUpdate:modelValue":V[0]||(V[0]=P=>l.value=P),"enable-handwriting":t.enableHandwriting,onKey:L},null,8,["modelValue","enable-handwriting"])):e.createCommentVNode("",!0)],64))],38)),[[e.vShow,p.value]])}}),Tt={install:t=>{t.component("ZhKeyboard",le)}};E.CanvasDrawer=Y,E.ZhKeyboard=le,E.calculateKeyboardPosition=Q,E.createKeyRepeater=re,E.default=Tt,E.delToInputElement=ne,E.getHandwritingRecognizer=I,E.getInputElement=xe,E.getKeyboardConfig=S,E.getPinyinEngine=J,E.isInputElement=A,E.moveCursor=oe,E.registerHandwritingRecognizer=Be,E.registerPinyinEngine=Ve,E.setKeyboardConfig=ze,E.writeToInputElement=te,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
2
2
  //# sourceMappingURL=zh-keyboard-vue.umd.cjs.map