!function(){function e(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e=function(){return t};var r,t={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{l({},"")}catch(r){l=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var o=r&&r.prototype instanceof w?r:w,a=Object.create(o.prototype),c=new C(n||[]);return i(a,"_invoke",{value:L(e,t,c)}),a}function h(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var p="suspendedStart",d="suspendedYield",v="executing",y="completed",g={};function w(){}function m(){}function x(){}var b={};l(b,c,(function(){return this}));var E=Object.getPrototypeOf,k=E&&E(E(N([])));k&&k!==n&&o.call(k,c)&&(b=k);var S=x.prototype=w.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(r){l(e,r,(function(e){return this._invoke(r,e)}))}))}function P(e,r){function t(n,i,a,c){var u=h(e[n],e,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&o.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,a,c)}),(function(e){t("throw",e,a,c)})):r.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return t("throw",e,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(e,o){function i(){return new r((function(r,n){t(e,o,r,n)}))}return n=n?n.then(i,i):i()}})}function L(e,t,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=j(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=h(e,t,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function j(e,t){var n=t.method,o=e.iterator[n];if(o===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=r,j(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,g;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=r),t.delegate=null,g):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g)}function D(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function O(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function N(e){if(e||""===e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),O(t),g}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;O(t)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:N(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=r),g}},t}function r(e,r,t,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void t(e)}c.done?r(u):Promise.resolve(u).then(n,o)}function t(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function c(e){r(a,o,i,c,u,"next",e)}function u(e){r(a,o,i,c,u,"throw",e)}c(void 0)}))}}function n(e,r){for(var t=0;t0&&n(Math.round(t/r*100))}});case 7:return c=e.sent,u=cep_node.require("buffer").Buffer,h.writeFileSync(a,u.from(c.data)),e.abrupt("return",a);case 11:case"end":return e.stop()}}),r,this)}))),function(e,r){return m.apply(this,arguments)})},{key:"unzip",value:(w=t(e().mark((function t(n,o){var i,a,u,s,l,d;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f()){e.next=2;break}throw new Error("解压功能需要在 CEP 环境中运行");case 2:if(c.log("📦 [解压] 开始解压..."),c.log(" - ZIP 文件:",n),c.log(" - 版本:",o),i=p.join(this.cacheDir,o),c.log(" - 目标目录:",i),h.existsSync(i)){c.log(" ⚠️ 目标目录已存在,删除旧文件...");try{h.rmSync(i,{recursive:!0,force:!0}),c.log(" ✓ 旧文件已删除")}catch(r){c.error(" ❌ 删除失败:",r.message)}}return h.mkdirSync(i,{recursive:!0}),c.log(" ✓ 目标目录已创建"),c.log(" ⏳ 正在解压 ZIP 文件(使用 PowerShell)..."),c.log(" ⚠️ 此过程可能需要 5-15 秒,请耐心等待..."),a=Date.now(),u=cep_node.require("child_process"),s=n.replace(/'/g,"''"),l=i.replace(/'/g,"''"),d=`powershell -NoProfile -ExecutionPolicy Bypass -Command "Write-Host 'Starting extraction...'; Expand-Archive -Path '${s}' -DestinationPath '${l}' -Force; Write-Host 'Extraction completed'"`,c.log(" 📝 执行命令:",d.substring(0,100)+"..."),e.abrupt("return",new Promise((function(e,r){var t=setTimeout((function(){c.error(" ❌ 解压超时(60秒)"),r(new Error("解压超时,请检查文件大小或手动删除缓存目录重试"))}),6e4);u.exec(d,{maxBuffer:10485760},(function(n,o,u){clearTimeout(t);var s=((Date.now()-a)/1e3).toFixed(2);if(c.log(` ⏱️ PowerShell 执行耗时: ${s}秒`),o&&c.log(" 📤 PowerShell 输出:",o),n)return c.error(" ❌ PowerShell 错误:",u||n.message),void r(new Error(`解压失败: ${u||n.message}`));var l=p.join(i,"index.html");if(!h.existsSync(l))return c.error(" ❌ 验证失败: 未找到 index.html"),c.log(" 📁 目录内容:",h.readdirSync(i)),void r(new Error("解压后未找到 index.html,文件可能损坏"));c.log(" ✅ 解压完成并验证通过!"),e(i)}))})));case 19:case"end":return e.stop()}}),t,this)}))),function(e,r){return w.apply(this,arguments)})},{key:"checkVersionCache",value:(g=t(e().mark((function r(t){var n,o,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f()){e.next=2;break}return e.abrupt("return",!1);case 2:return n=p.join(this.cacheDir,t),o=p.join(n,"index.html"),i=h.existsSync(o),c.log(`[Updater] 检查版本缓存: ${t} -> ${i?"存在":"不存在"}`),e.abrupt("return",i);case 7:case"end":return e.stop()}}),r,this)}))),function(e){return g.apply(this,arguments)})},{key:"launch",value:(y=t(e().mark((function r(t){var n,o,a,s,d,v,y,g,w;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f()){e.next=2;break}throw new Error("启动功能需要在 CEP 环境中运行");case 2:if(c.separator(),c.log("🚀 [启动 Core] 开始启动 Core 应用"),c.log(" - 版本:",t),c.log(" - 缓存目录:",this.cacheDir),n=p.join(this.cacheDir,t),o=p.join(n,"index.html"),c.log(" - 版本目录:",n),c.log(" - 入口文件:",o),c.log(" - 文件存在:",h.existsSync(o)),h.existsSync(o)){e.next=14;break}throw c.error("❌ [启动 Core] 入口文件不存在!"),new Error(`入口文件未找到: ${o}`);case 14:return a=localStorage.getItem("token"),s=localStorage.getItem("username"),e.next=18,u((function(){return i.import("./index-legacy-fd2a7686.js").then((function(e){return e.d}))}),void 0,i.meta.url);case 18:d=e.sent,v=d.getDeviceId,y=v(),c.log("🔐 [启动 Core] 读取登录信息:"),c.log(" - token:",a?"存在":"不存在"),c.log(" - username:",s),c.log(" - device_id:",y),g=l.getCoreUrl(t),a&&s?(w=new URLSearchParams({token:a,username:s,device_id:y,auto_login:"true"}),g+="#/home?"+w.toString(),c.log("✅ [启动 Core] 将通过 URL 参数传递登录信息(含 device_id)")):(c.warn("⚠️ [启动 Core] 没有登录信息,Core 需要重新登录"),g+="#/login"),c.log(" - 目标 URL:",g),c.log("✅ [启动 Core] 准备跳转到后端服务器..."),c.separator(),window.location.href=g;case 31:case"end":return e.stop()}}),r,this)}))),function(e){return y.apply(this,arguments)})}],d&&n(r.prototype,d),v&&n(r,v),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,d,v,y,g,w,m,x,b}();r("Updater",d)}}}))}();