"use strict";var r=require("fs");function t(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n=r.length?{done:!0}:{done:!1,value:r[e++]}},e:function(r){throw r},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){n=n.call(r)},n:function(){var r=n.next();return u=r.done,r},e:function(r){l=!0,i=r},f:function(){try{u||null==n.return||n.return()}finally{if(l)throw i}}}}function o(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var e,o,i,a,u=[],l=!0,c=!1;try{if(i=(n=n.call(r)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(e=i.call(n)).done)&&(u.push(e.value),u.length!==t);l=!0);}catch(r){c=!0,o=r}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(r,t)||a(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(r){var t=function(r,t){if("object"!=typeof r||!r)return r;var n=r[Symbol.toPrimitive];if(void 0!==n){var e=n.call(r,t||"default");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(r)}(r,"string");return"symbol"==typeof t?t:t+""}function a(r,n){if(r){if("string"==typeof r)return t(r,n);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?t(r,n):void 0}}var u=function(){return r=function r(){!function(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.map=new Map},t=[{key:"addWord",value:function(r,t){var n,o=this.map,i=e(r);try{for(i.s();!(n=i.n()).done;){var a=n.value.codePointAt(0),u=o.get(a);if(null==u){var l=new Map;o.set(a,l),o=l}else o=u}}catch(r){i.e(r)}finally{i.f()}o.trie_val=t}},{key:"loadDict",value:function(r){if("string"==typeof r){var t,n=e(r=r.split("|"));try{for(n.s();!(t=n.n()).done;){var i=o(t.value.split(" "),2),a=i[0],u=i[1];this.addWord(a,u)}}catch(r){n.e(r)}finally{n.f()}}else{var l,c=e(r);try{for(c.s();!(l=c.n()).done;){var f=o(l.value,2),v=f[0],s=f[1];this.addWord(v,s)}}catch(r){c.e(r)}finally{c.f()}}}},{key:"loadDictGroup",value:function(r){var t=this;r.forEach((function(r){t.loadDict(r)}))}},{key:"convert",value:function(r){for(var t,n=this.map,e=r.length,o=[],i=0;i65535?2:1;var v=a.get(f);if(void 0===v)break;var s=(a=v).trie_val;void 0!==s&&(u=c,l=s)}u>0?(null!==t&&(o.push(r.slice(t,i)),t=null),o.push(l),i=u):(null===t&&(t=i),i+=r.codePointAt(i)>65535?2:1)}return null!==t&&o.push(r.slice(t,e)),o.join("")}}],t&&n(r.prototype,t),i&&n(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,t,i}();function l(){for(var r=arguments.length,t=new Array(r),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.inputPath,e=void 0===n?"src/locales/zh-CN.ts":n,o=t.outputPath,i=void 0===o?"src/locales/zh-TW.ts":o,a=t.from,u=void 0===a?"cn":a,l=t.to,c=void 0===l?"hk":l;return{name:"vite-plugin-chinese-converter",buildStart:function(){r.watch(e,(function(t){"change"===t&&r.readFile(e,"utf-8",(function(t,n){if(t)console.error(t);else{var e=p({from:u,to:c})(n);r.writeFile(i,e,(function(r){r?console.error(r):console.log("".concat(i," 文件已生成"))}))}}))}))}}};