UNPKG

filecat

Version:
2 lines 129 kB
/*! For license information please see threads.work.filecat.js.LICENSE.txt */ (()=>{var __webpack_modules__={3054(t,e,i){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.start_ai_agent_agent=function(){(0,r.register_threads_worker_handler)(s.threads_msg_type.docs_init,async t=>{const{index_storage_type:e,db_path:i}=t.data;if(E=e,"memory"===e){if(b)return;b=new o.default.Index({tokenize:"strict"}),v=new o.default.Index({tokenize:"strict"})}if("sqlite"===e){if(S)return;S=new u(i,{nativeBinding:h}),S.exec("\n CREATE VIRTUAL TABLE IF NOT EXISTS docs USING fts5(\n file_path UNINDEXED,\n content,\n mtime UNINDEXED,\n tokenize = 'unicode61'\n );\n \n CREATE VIRTUAL TABLE IF NOT EXISTS doc_names USING fts5(\n file_path UNINDEXED,\n name,\n mtime UNINDEXED,\n tokenize = 'unicode61'\n );\n "),_=S.prepare("\n SELECT mtime FROM docs WHERE file_path = ? LIMIT 1\n "),w=S.prepare("\n SELECT mtime FROM doc_names WHERE file_path = ? LIMIT 1\n "),f=S.prepare("INSERT INTO docs (file_path, content, mtime) VALUES (?, ?, ?)"),d=S.prepare("INSERT INTO doc_names (file_path, name, mtime) VALUES (?, ?, ?)"),p=S.prepare("DELETE FROM docs WHERE file_path = ?"),m=S.prepare("DELETE FROM doc_names WHERE file_path = ?"),g=S.prepare("\n SELECT file_path\n FROM docs\n WHERE docs MATCH ?\n ORDER BY bm25(docs)\n LIMIT 50\n "),y=S.prepare("\n SELECT file_path\n FROM doc_names\n WHERE doc_names MATCH ?\n ORDER BY bm25(doc_names)\n LIMIT 50\n ")}}),(0,r.register_threads_worker_handler)(s.threads_msg_type.docs_add,async t=>{let e,i,{use_zh_segmentation:n,file_path:r,mtime:s}=t.data;if("sqlite"===E&&S){s=s??(await l.FileUtil.statSync(r)).mtime;const t=_.get(r);if(t&&t.mtime===s)return{char_num:0};e=`${r} ${(await l.FileUtil.readFileSync(r)).toString()}。`,i=e.length;let o=e,c=r;n&&(o=(0,a.cut)(e,!0).join(" "),c=(0,a.cut)(r,!0).join(" ")),p.run(r),m.run(r),f.run(r,o,s),d.run(r,c,s)}if("memory"===E){e=`${r} ${(await l.FileUtil.readFileSync(r)).toString()}。`,i=e.length;let t=e.toLowerCase(),s=r.toLowerCase();n&&(t=(0,a.cut)(e,!0).join(" ").toLowerCase(),s=(0,a.cut)(r,!0).join(" ").toLowerCase()),b?.add(r,t),v?.add(r,s)}return{char_num:i}}),(0,r.register_threads_worker_handler)(s.threads_msg_type.docs_del,async t=>{const{file_path:e}=t.data;"memory"===E&&(b?.remove(e),v?.remove(e)),"sqlite"===E&&S&&(p.run(e),m.run(e))}),(0,r.register_threads_worker_handler)(s.threads_msg_type.docs_search,async t=>{const{key:e,use_zh_segmentation:i}=t.data;let n=e;if(i){n=(0,a.cut)(e,!0).map(t=>t+"*").join(" OR ")}if("memory"===E){const t={suggest:!0,resolution:9,context:!0,limit:50};return{ids:b?.search(n,t)||[],names_ids:v?.search(n,t)||[]}}if("sqlite"===E&&S){const t=(0,a.cut)(n,!0).filter(t=>""!==t.trim()).map(t=>t+"*").join(" OR "),e=g.all(t),i=y.all(t);return{ids:e.map(t=>t.file_path),names_ids:i.map(t=>t.file_path)}}return{ids:[],names_ids:[]}}),(0,r.register_threads_worker_handler)(s.threads_msg_type.docs_close,async()=>{"memory"===E&&(b?.clear(),v?.clear(),b=null,v=null),"sqlite"===E&&S&&(S.close(),S=null)})};const r=i(324),s=i(7525),o=n(i(5474)),a=i(2880),c=i(3917),l=i(1776),h=(0,c.get_bin_dependency)("sqlite3"),u=(0,c.get_bin_dependency)("better-sqlite3");let f,d,p,m,g,y,_,w,b=null,v=null,S=null,E="memory"},3917(__unused_webpack_module,exports,__webpack_require__){"use strict";var __webpack_unused_export__;function get_bin_dependency(module,auto_throw=!1){try{return"sqlite3"===module?__webpack_require__(9642):eval("require")(module)}catch(t){if(console.log(`npm 模块没有加载失败,请手动安装 npm 依赖( -g 安装的就尝试全局安装,本地仓库安装的就在仓库内安装):${module} error ${t.message}`),auto_throw)throw t}return{}}__webpack_unused_export__={value:!0},exports.get_bin_dependency=get_bin_dependency},1776(t,e,i){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.FileUtil=void 0;const r=n(i(9896)),s=n(i(6928));e.FileUtil=class{static async statSync(t){return r.default.promises.stat(t)}static async readdirSync(t){return r.default.promises.readdir(t)}static async readFileSync(t){return r.default.promises.readFile(t)}static async open(t,e,i){return r.default.promises.open(t,e,i)}static async access(t){try{return await r.default.promises.access(t,r.default.constants.F_OK),!0}catch{return!1}}static async access_all(t){let e=0;for(const i of t)try{await r.default.promises.access(i,r.default.constants.F_OK),e++}catch{}return e===t.length}static async appendFileSync(t,e,i){return r.default.promises.appendFile(t,e,i)}static async writeFileSync(t,e,i){return r.default.promises.writeFile(t,e,i)}static async writeFileSyncWithUtf8bom(t,e){return e.startsWith("\ufeff")||(e="\ufeff"+e),r.default.promises.writeFile(t,e,{encoding:"utf8"})}static async truncateSync(t){return r.default.promises.truncate(t)}static async unlinkSync(t){return r.default.promises.unlink(t)}static async mkdirSync(t,e){return r.default.promises.mkdir(t,e)}static async renameSync(t,e){return r.default.promises.rename(t,e)}static async getUniqueFileName(t){const e=s.default.dirname(t),i=s.default.extname(t),n=s.default.basename(t,i);let r=t,o=1;for(;await this.access(r);)r=s.default.join(e,`${n}(${o})${i}`),o++;return r}static async get_exe_path_by_env_dir(t,e){if(!await this.access(t))return null;if(!(await this.statSync(t)).isDirectory())return null;const i=await this.readdirSync(t);for(const n of i)if(n.startsWith(e))return s.default.join(t,`${n}`);return null}static async ensure_dir(t){await r.default.promises.mkdir(t,{recursive:!0})}static async copy(t,e,i=[]){if((await r.default.promises.stat(t)).isFile()){if(await this.ensure_dir(s.default.dirname(e)),i.includes(s.default.basename(t)))return;return void await r.default.promises.copyFile(t,e)}await this.ensure_dir(e);const n=await r.default.promises.readdir(t,{withFileTypes:!0});for(const o of n){const n=s.default.join(t,o.name),a=s.default.join(e,o.name);i.includes(o.name)||(o.isDirectory()?await this.copy(n,a,i):o.isFile()&&await r.default.promises.copyFile(n,a))}}static async remove_dir(t){if(!await this.access(t))return;if((await r.default.promises.stat(t)).isFile())return void await r.default.promises.unlink(t);const e=await r.default.promises.readdir(t);for(const i of e){const e=s.default.join(t,i);(await r.default.promises.stat(e)).isDirectory()?await this.remove_dir(e):await r.default.promises.unlink(e)}await r.default.promises.rmdir(t)}static async find_max_numbered_version_file(t){const e=s.default.dirname(t),i=s.default.basename(t);if(!await this.access(e))return null;const n=await r.default.promises.readdir(e);let o=-1,a=null;const c=s.default.join(e,i);await this.access(c)&&(a=c,o=0);for(const t of n){if(!t.startsWith(i))continue;const n=t.slice(i.length);if(0===n.length)continue;let r=0,c=!1;for(const t of n){if(!(t>="0"&&t<="9")){c=!1;break}r=10*r+(t.charCodeAt(0)-48),c=!0}c&&(r>o&&(o=r,a=s.default.join(e,t)))}return a}static async get_next_numbered_name(t){const e=s.default.dirname(t),i=s.default.basename(t);if(!await this.access(e))return t;const n=await r.default.promises.readdir(e);let o=0;const a=s.default.join(e,i);if(!await this.access(a))return a;for(const t of n){if(!t.startsWith(i))continue;const e=t.slice(i.length);if(!e)continue;let n=0,r=!1;for(const t of e){if(!(t>="0"&&t<="9")){r=!1;break}n=10*n+(t.charCodeAt(0)-48),r=!0}r&&(n>o&&(o=n))}return s.default.join(e,`${i}${o+1}`)}}},3285(t,e,i){"use strict";e.file_search_start=function(){(0,n.register_threads_worker_handler)(r.threads_msg_type.file_search,async t=>{const{start:e,end:i,file_path:l,query_text_buffer:h,ram_id:u}=t.data;let f=0,d=Buffer.alloc(0);const p=s.openSync(l,"r");let m=0;for(;f<i&&!c[u];){const t=Buffer.alloc(2097152);let e=s.readSync(p,t,0,t.length,f);if(0===e)break;f+=e,d=Buffer.concat([d,t.subarray(0,e)]),(0,n.threads_send)({type:r.threads_msg_type.search_file_progress,data:{progress:(100*f/i).toFixed(0),ram_id:u}});const c=[];if(a(d,h,c),c.length>0){for(let t=0;t<c.length;t++)c[t]+=m;(0,n.threads_send)({type:r.threads_msg_type.search_file_index,data:{find_index:c,ram_id:u}})}m+=d.length-h.length,d=o(d,d.length-h.length,d.length)}return(0,n.threads_send)({type:r.threads_msg_type.search_file_end,data:{ram_id:u}}),s.closeSync(p),"ok"}),(0,n.register_threads_worker_handler)(r.threads_msg_type.file_search_close,async t=>{const{ram_id:e}=t.data;return c[e]=!0,"ok"}),(0,n.register_threads_worker_handler)(r.threads_msg_type.file_search_start,async t=>{const{ram_id:e}=t.data;return delete c[e],"ok"})};const n=i(324),r=i(7525),s=i(9896);function o(t,e,i){const n=i-e,r=Buffer.alloc(n);return t.copy(r,0,e,i),r}function a(t,e,i){const n=function(t){const e={},i=t.length;for(let n=0;n<i;n++)e[t[n]]=n;return e}(e),r=t.length,s=e.length,o=r-s;let a=0;for(;a<=o;){let o=s-1;for(;o>=0&&t[a+o]===e[o];)o--;if(o<0)i.push(a),a+=a+s<r?s-n[t[a+s]]||s:1;else{const e=n[t[a+o]],i=void 0!==e?o-e:o+1;a+=Math.max(i,1)}}}const c={}},1532(t,e,i){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.AsyncQueue=void 0,e.normalizeSyncRelativePath=s,e.safeResolveSyncPath=function(t,e){const i=r.default.resolve(t),n=r.default.resolve(i,e??""),s=i.endsWith(r.default.sep)?i:`${i}${r.default.sep}`;if(n!==i&&!n.startsWith(s))throw new Error(`Invalid sync path: ${e}`);return n},e.buildSyncEnvelope=function(t,e=Buffer.alloc(0)){const i=Buffer.from(JSON.stringify(t)),n=Buffer.alloc(4);return n.writeUInt32BE(i.length,0),Buffer.concat([n,i,e])},e.parseSyncEnvelope=function(t){if(t.length<4)throw new Error("Invalid sync envelope");const e=t.readUInt32BE(0),i=4+e;if(t.length<i)throw new Error("Invalid sync envelope header length");const n=JSON.parse(t.subarray(4,i).toString()),r=t.subarray(i);return{header:n,payload:r}},e.createSyncIgnoreMatcher=function(t=[]){const e=(t??[]).map(t=>s(String(t??"").trim())).filter(Boolean),i=e.filter(t=>t.includes("*")||t.includes("?")).map(t=>function(t){const e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,":::DOUBLE_STAR:::").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/:::DOUBLE_STAR:::/g,".*");return new RegExp(`^${e}$`)}(t));return(t,n=!1)=>{const r=s(t);if(!r)return!1;if(i.some(t=>t.test(r)))return!0;for(const t of e){if(!t||t.includes("*")||t.includes("?"))continue;if(r===t)return!0;if(r.startsWith(`${t}/`))return!0;if(r.split("/").includes(t))return!0;if(n&&r===`${t}/`)return!0}return!1}},e.stringToHash32=o,e.getFilePathHash=function(t,e){return o(s(r.default.relative(t,e))||e)};const r=n(i(6928));function s(t){return(t??"").replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,"")}function o(t){let e,i=305419896;const n=Buffer.from(t,"utf-8"),r=3&n.length,s=n.length-r>>2;for(let t=0;t<s;t++){const r=t<<2;e=n[r]|n[r+1]<<8|n[r+2]<<16|n[r+3]<<24,e=Math.imul(e,3432918353),e=e<<15|e>>>17,e=Math.imul(e,461845907),i^=e,i=i<<13|i>>>19,i=Math.imul(i,5)+3864292196}e=0;const o=s<<2;switch(r){case 3:e^=n[o+2]<<16;case 2:e^=n[o+1]<<8;case 1:e^=n[o],e=Math.imul(e,3432918353),e=e<<15|e>>>17,e=Math.imul(e,461845907),i^=e}return i^=n.length,i^=i>>>16,i=Math.imul(i,2246822507),i^=i>>>13,i=Math.imul(i,3266489909),i^=i>>>16,i>>>0}e.AsyncQueue=class{concurrency;processor;next_interval;queue=[];activeCount=0;constructor(t=1,e,i=100){this.concurrency=t,this.processor=e,this.next_interval=i}push(t){this.queue.push(t),this.next()}get size(){return this.queue.length}next(){if(this.activeCount>=this.concurrency||0===this.queue.length)return;const t=this.queue.shift();t&&(this.activeCount++,this.processor(t).finally(()=>{this.activeCount--,setTimeout(this.next.bind(this),this.next_interval)}).catch(t=>{console.error("[AsyncQueue Error]",t)}),this.next())}clear(){this.queue=[],this.activeCount=0}}},746(t,e,i){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.workerService=e.TcpSyncWorkerService=void 0,e.tcp_file_sync_work_start=function(){(0,l.register_threads_worker_handler)(h.threads_msg_type.file_watch_init,async t=>{const{task:i,client_num_id:n,cache_path:r}=t.data;e.workerService.open_task(i,n,r).catch(console.error)}),(0,l.register_threads_worker_handler)(h.threads_msg_type.file_watch_close,async t=>{const{task_id:i}=t.data;e.workerService.stopRuntime(i)}),(0,l.register_threads_worker_handler)(h.threads_msg_type.file_watch_apply,async t=>{const{buffer:i}=t.data;e.workerService.apply_remote_event(i).catch(console.error)}),(0,l.register_threads_worker_handler)(h.threads_msg_type.file_watch_sync_task_get,async t=>e.workerService.client_sync_task_get())};const r=n(i(6928)),s=n(i(9896)),o=n(i(1605)),a=i(1532),c=i(1776),l=i(324),h=i(7525),u=i(158);class f{runtime_map=new Map;cache_timers=new Map;client_sync_task_get(){const t=[];for(const e of this.runtime_map.keys()){const i=this.runtime_map.get(e);i.task.running_num=i.queue.size,t.push(i.task)}return t}stopRuntime(t){const e=this.runtime_map.get(t);e?.watcher&&e.watcher.close(),e?.queue&&e.queue.clear(),this.runtime_map.delete(t),this.cache_timers.has(t)&&(clearTimeout(this.cache_timers.get(t)),this.cache_timers.delete(t))}clearAll(){for(const t of this.runtime_map.keys())this.stopRuntime(t)}scheduleSuppress(t,e){const i=(0,a.normalizeSyncRelativePath)(e);i&&(t.suppress_set.add(i),setTimeout(()=>{t.suppress_set.delete(i)},5e3))}isSuppressed(t,e){const i=(0,a.normalizeSyncRelativePath)(e);return!!i&&t.suppress_set.has(i)}saveCache(t,e,i){this.cache_timers.has(t)&&clearTimeout(this.cache_timers.get(t));const n=setTimeout(async()=>{try{await c.FileUtil.writeFileSync(e,JSON.stringify(i,null,2))}catch(e){console.error(`[Sync Cache] 保存同步缓存失败 -> 任务 ID: ${t}`,e)}this.cache_timers.delete(t)},1e3);this.cache_timers.set(t,n)}async applySourceEvent(t,e,i){const n=this.runtime_map.get(t.id);if(!n)return;const c=(0,a.normalizeSyncRelativePath)(e.relative_path);if(!c)return;if(n.ignore(c,e.is_directory))return;if(this.isSuppressed(n,c))return;const l=(0,a.safeResolveSyncPath)(n.local_dir,c);switch(this.scheduleSuppress(n,c),e.event){case"addDir":await o.default.ensureDir(l);break;case"unlinkDir":case"unlink":!1!==t.delete_missing&&await o.default.remove(l);break;case"add":case"change":await o.default.ensureDir(r.default.dirname(l)),await s.default.promises.writeFile(l,i)}}async processSyncTaskItem(t,e,i){const{event:n,fullPath:o}=e,c=(0,a.normalizeSyncRelativePath)(r.default.relative(t.local_dir,o));var u;if(c&&!this.isSuppressed(t,c))try{const e="addDir"===n||"unlinkDir"===n;let r,f=Date.now(),d=Buffer.alloc(0),p=[];if("add"===n||"change"===n)try{const e=await s.default.promises.stat(o);f=e.mtimeMs,r=e.size;const i=(0,a.getFilePathHash)(t.local_dir,o);if(t.cache_file_map[i]&&t.cache_file_map[i].mtime===f)return;const n=await(u=o,s.default.promises.readFile(u));d=n,n.buffer instanceof ArrayBuffer&&p.push(n.buffer)}catch(t){return}const m=(0,a.buildSyncEnvelope)({task_id:t.task.id,event:n,relative_path:c,is_directory:e,mtime:f,size:r,source_client_num_id:i,target_client_num_id:t.remote_client_id},d);if(await(0,l.threads_send_async)(h.threads_msg_type.file_watch_send,{current_client_id:i,buffer:m},5e3,p),"add"===n||"change"===n){const e=(0,a.getFilePathHash)(t.local_dir,o);t.cache_file_map[e]={mtime:f},this.saveCache(t.task.id,t.cache_path,t.cache_file_map)}}catch(t){console.error(`[Sync Queue] 处理文件事件失败: ${o} 继续下一个`,t)}}async apply_remote_event(t){const e=Buffer.from(t),i=(0,a.parseSyncEnvelope)(e),n=this.runtime_map.get(i.header.task_id);if(!n||!n.task.open)return;const r=n.task;r.source_client_num_id!==i.header.target_client_num_id&&r.target_client_num_id!==i.header.target_client_num_id||await this.applySourceEvent(r,i.header,i.payload)}async watchLocalDir(t,e){const i=this.runtime_map.get(t.id);if(!i||i.watcher)return;await o.default.ensureDir(i.local_dir);const n=u.watch(i.local_dir,{persistent:!0,ignoreInitial:!t.full_sync,alwaysStat:!1,ignored:t=>{const e=(0,a.normalizeSyncRelativePath)(r.default.relative(i.local_dir,t));return!!e&&i.ignore(e,!1)}});i.watcher=n;const s=(t,e)=>{const n=(0,a.normalizeSyncRelativePath)(r.default.relative(i.local_dir,e));if(!n)return;const s="addDir"===t||"unlinkDir"===t;i.ignore(n,s)||this.isSuppressed(i,n)||i.queue.push({event:t,fullPath:e})};n.on("add",t=>{s("add",t)}),n.on("change",t=>{s("change",t)}),n.on("unlink",e=>{const n=(0,a.getFilePathHash)(i.local_dir,e);i.cache_file_map[n]&&(delete i.cache_file_map[n],this.saveCache(t.id,i.cache_path,i.cache_file_map)),s("unlink",e)}),n.on("addDir",t=>{s("addDir",t)}),n.on("unlinkDir",t=>{s("unlinkDir",t)}),n.on("error",t=>{console.error("sync watcher error",t)}),n.on("ready",()=>{console.log(`[Sync] 任务 ${t.id} 的初始化本地盘点遍历完成。`)})}async open_task(t,e,i){this.stopRuntime(t.id);let n={};if(await c.FileUtil.access(i))try{n=JSON.parse((await c.FileUtil.readFileSync(i)).toString())}catch(e){console.error(`[Sync Cache] 解析本地增量缓存失败,重置为空缓存: ${t.id}`,e)}else await c.FileUtil.writeFileSync(i,JSON.stringify(n));let r="",s=0;t.source_client_num_id===e?(r=t.source_dir,s=t.target_client_num_id):(r=t.target_dir,s=t.source_client_num_id);const l={},h=new a.AsyncQueue(1,async t=>{await this.processSyncTaskItem(l,t,e)}),u={task:t,ignore:(0,a.createSyncIgnoreMatcher)(t.ignore_list),suppress_set:new Set,local_dir:r,remote_client_id:s,cache_file_map:n,cache_path:i,client_num_id:e,queue:h};Object.assign(l,u),this.runtime_map.set(t.id,u),t.target_client_num_id!==e||t.two_way_sync?await this.watchLocalDir(t,e):await o.default.ensureDir(t.target_dir)}reset_tasks(t){this.clearAll()}}e.TcpSyncWorkerService=f,e.workerService=new f},7525(t,e){"use strict";var i;e.threads_msg_type=void 0,function(t){t[t.hello=1]="hello",t[t.file_search_start=2]="file_search_start",t[t.file_search=3]="file_search",t[t.file_search_close=4]="file_search_close",t[t.search_file_index=5]="search_file_index",t[t.search_file_progress=6]="search_file_progress",t[t.search_file_end=7]="search_file_end",t[t.docs_init=8]="docs_init",t[t.docs_add=9]="docs_add",t[t.docs_del=10]="docs_del",t[t.docs_close=11]="docs_close",t[t.docs_search=12]="docs_search",t[t.file_watch_init=13]="file_watch_init",t[t.file_watch_send=14]="file_watch_send",t[t.file_watch_close=15]="file_watch_close",t[t.file_watch_apply=16]="file_watch_apply",t[t.file_watch_sync_task_get=17]="file_watch_sync_task_get"}(i||(e.threads_msg_type=i={}))},324(t,e,i){"use strict";e.register_threads_worker_handler=c,e.threads_send=l,e.threads_send_async=async function(t,e,i=5e3,n){const r=o++,s={id:r,type:t,data:e};return new Promise((e,o)=>{const c=setTimeout(()=>{a.delete(r),o(new Error(`[worker] Request to main thread timeout (type: ${t}, id: ${r})`))},i);a.set(r,t=>{clearTimeout(c),e(t),a.delete(r)});try{l(s,n)}catch(t){clearTimeout(c),a.delete(r),o(t)}})};const n=i(8167),r=i(7525);console.log("[worker] 子线程启动, workerData=",n.workerData);const s=new Map;let o=1;const a=new Map;function c(t,e){s.set(t,e)}function l(t,e){try{n.parentPort?.postMessage(t,e)}catch(t){console.error("[worker] send failed:",t)}}n.parentPort?.on("message",t=>{(async function(t){try{if(t.id&&a.has(t.id)){const e=a.get(t.id);return t.error&&console.error(`[worker] received error from main: ${t.error}`),void e(t.data)}const e=s.get(t.type);if(!e)return void l({id:t.id,type:t.type,data:`unknown type ${t.type}`});const i=await e(t);t.id&&l({id:t.id,type:t.type,data:i})}catch(e){t.id&&l({id:t.id,type:t.type,data:null,error:e?.message||String(e)}),console.error("[worker] task error:",e)}})(t).catch(console.error)}),c(r.threads_msg_type.hello,async t=>new Promise((e,i)=>setTimeout(()=>{if(Math.random()<.05)return i(new Error("模拟错误"));e(`done:${t.data}`)},500))),console.log("[worker] ready and waiting for messages..."),process.on("uncaughtException",t=>{console.error("子线程全局未捕获异常:",t)}),process.on("unhandledRejection",t=>{console.error("子线程未处理的 Promise 拒绝:",t)})},5266(t,e,i){"use strict";e.NodeFsHandler=e.EVENTS=e.isIBMi=e.gH=e.j9=e.aP=e.isWindows=e.EMPTY_FN=e.STR_CLOSE=e.STR_END=e.j1=void 0;const n=i(9896),r=i(1943),s=i(6928),o=i(857);e.j1="data",e.STR_END="end",e.STR_CLOSE="close";e.EMPTY_FN=()=>{};const a=process.platform;e.isWindows="win32"===a,e.aP="darwin"===a,e.j9="linux"===a,e.gH="freebsd"===a,e.isIBMi="OS400"===(0,o.type)(),e.EVENTS={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"};const c=e.EVENTS,l={lstat:r.lstat,stat:r.stat},h="listeners",u="errHandlers",f="rawEmitters",d=[h,u,f],p=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),m=(t,e)=>{t instanceof Set?t.forEach(e):e(t)},g=(t,e,i)=>{let n=t[e];n instanceof Set||(t[e]=n=new Set([n])),n.add(i)},y=(t,e,i)=>{const n=t[e];n instanceof Set?n.delete(i):n===i&&delete t[e]},_=t=>t instanceof Set?0===t.size:!t,w=new Map;function b(t,e,i,r,o){const a=(e,n)=>{i(t),o(e,n,{watchedPath:t}),n&&t!==n&&v(s.resolve(t,n),h,s.join(t,n))};try{return(0,n.watch)(t,{persistent:e.persistent},a)}catch(t){return void r(t)}}const v=(t,e,i,n,r)=>{const s=w.get(t);s&&m(s[e],t=>{t(i,n,r)})},S=(t,i,n,s)=>{const{listener:o,errHandler:a,rawEmitter:l}=s;let p,m=w.get(i);if(!n.persistent){if(p=b(t,n,o,a,l),!p)return;return p.close.bind(p)}if(m)g(m,h,o),g(m,u,a),g(m,f,l);else{if(p=b(t,n,v.bind(null,i,h),a,v.bind(null,i,f)),!p)return;p.on(c.ERROR,async n=>{const s=v.bind(null,i,u);if(m&&(m.watcherUnusable=!0),e.isWindows&&"EPERM"===n.code)try{const e=await(0,r.open)(t,"r");await e.close(),s(n)}catch(t){}else s(n)}),m={listeners:o,errHandlers:a,rawEmitters:l,watcher:p},w.set(i,m)}return()=>{y(m,h,o),y(m,u,a),y(m,f,l),_(m.listeners)&&(m.watcher.close(),w.delete(i),d.forEach((t=>e=>{const i=t[e];i instanceof Set?i.clear():delete t[e]})(m)),m.watcher=void 0,Object.freeze(m))}},E=new Map;e.NodeFsHandler=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,i){const r=this.fsw.options,o=s.dirname(t),a=s.basename(t);this.fsw._getWatchedDir(o).add(a);const l=s.resolve(t),u={persistent:r.persistent};let d;if(i||(i=e.EMPTY_FN),r.usePolling){const e=r.interval!==r.binaryInterval;u.interval=e&&(w=a,p.has(s.extname(w).slice(1).toLowerCase()))?r.binaryInterval:r.interval,d=((t,e,i,r)=>{const{listener:s,rawEmitter:o}=r;let a=E.get(e);const l=a&&a.options;return l&&(l.persistent<i.persistent||l.interval>i.interval)&&((0,n.unwatchFile)(e),a=void 0),a?(g(a,h,s),g(a,f,o)):(a={listeners:s,rawEmitters:o,options:i,watcher:(0,n.watchFile)(e,i,(i,n)=>{m(a.rawEmitters,t=>{t(c.CHANGE,e,{curr:i,prev:n})});const r=i.mtimeMs;(i.size!==n.size||r>n.mtimeMs||0===r)&&m(a.listeners,e=>e(t,i))})},E.set(e,a)),()=>{y(a,h,s),y(a,f,o),_(a.listeners)&&(E.delete(e),(0,n.unwatchFile)(e),a.options=a.watcher=void 0,Object.freeze(a))}})(t,l,u,{listener:i,rawEmitter:this.fsw._emitRaw})}else d=S(t,l,u,{listener:i,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});var w;return d}_handleFile(t,i,n){if(this.fsw.closed)return;const o=s.dirname(t),a=s.basename(t),l=this.fsw._getWatchedDir(o);let h=i;if(l.has(a))return;const u=async(i,n)=>{if(this.fsw._throttle("watch",t,5))if(n&&0!==n.mtimeMs){if(l.has(a)){const e=n.atimeMs,i=n.mtimeMs;(!e||e<=i||i!==h.mtimeMs)&&this.fsw._emit(c.CHANGE,t,n),h=n}}else try{const n=await(0,r.stat)(t);if(this.fsw.closed)return;const s=n.atimeMs,o=n.mtimeMs;if((!s||s<=o||o!==h.mtimeMs)&&this.fsw._emit(c.CHANGE,t,n),(e.aP||e.j9||e.gH)&&h.ino!==n.ino){this.fsw._closeFile(i),h=n;const e=this._watchWithNodeFs(t,u);e&&this.fsw._addPathCloser(i,e)}else h=n}catch(t){this.fsw._remove(o,a)}},f=this._watchWithNodeFs(t,u);if((!n||!this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(c.ADD,t,0))return;this.fsw._emit(c.ADD,t,i)}return f}async _handleSymlink(t,e,i,n){if(this.fsw.closed)return;const s=t.fullPath,o=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){let e;this.fsw._incrReadyCount();try{e=await(0,r.realpath)(i)}catch(t){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;return o.has(n)?this.fsw._symlinkPaths.get(s)!==e&&(this.fsw._symlinkPaths.set(s,e),this.fsw._emit(c.CHANGE,i,t.stats)):(o.add(n),this.fsw._symlinkPaths.set(s,e),this.fsw._emit(c.ADD,i,t.stats)),this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(s))return!0;this.fsw._symlinkPaths.set(s,!0)}_handleRead(t,i,n,r,o,a,l){if(t=s.join(t,""),!(l=this.fsw._throttle("readdir",t,1e3)))return;const h=this.fsw._getWatchedDir(n.path),u=new Set;let f=this.fsw._readdirp(t,{fileFilter:t=>n.filterPath(t),directoryFilter:t=>n.filterDir(t)});return f?(f.on(e.j1,async e=>{if(this.fsw.closed)return void(f=void 0);const c=e.path;let l=s.join(t,c);u.add(c),e.stats.isSymbolicLink()&&await this._handleSymlink(e,t,l,c)||(this.fsw.closed?f=void 0:c!==r&&(r||h.has(c))||(this.fsw._incrReadyCount(),l=s.join(o,s.relative(o,l)),this._addToNodeFs(l,i,n,a+1)))}).on(c.ERROR,this._boundHandleError),new Promise((i,s)=>{if(!f)return s();f.once(e.STR_END,()=>{if(this.fsw.closed)return void(f=void 0);const e=!!l&&l.clear();i(void 0),h.getChildren().filter(e=>e!==t&&!u.has(e)).forEach(e=>{this.fsw._remove(t,e)}),f=void 0,e&&this._handleRead(t,!1,n,r,o,a,l)})})):void 0}async _handleDir(t,e,i,n,r,o,a){const l=this.fsw._getWatchedDir(s.dirname(t)),h=l.has(s.basename(t));let u,f;i&&this.fsw.options.ignoreInitial||r||h||this.fsw._emit(c.ADD_DIR,t,e),l.add(s.basename(t)),this.fsw._getWatchedDir(t);const d=this.fsw.options.depth;if((null==d||n<=d)&&!this.fsw._symlinkPaths.has(a)){if(!r&&(await this._handleRead(t,i,o,r,t,n,u),this.fsw.closed))return;f=this._watchWithNodeFs(t,(e,i)=>{i&&0===i.mtimeMs||this._handleRead(e,!1,o,r,t,n,u)})}return f}async _addToNodeFs(t,e,i,n,o){const a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;const h=this.fsw._getWatchHelpers(t);i&&(h.filterPath=t=>i.filterPath(t),h.filterDir=t=>i.filterDir(t));try{const i=await l[h.statMethod](h.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(h.watchPath,i))return a(),!1;const u=this.fsw.options.followSymlinks;let f;if(i.isDirectory()){const a=s.resolve(t),c=u?await(0,r.realpath)(t):t;if(this.fsw.closed)return;if(f=await this._handleDir(h.watchPath,i,e,n,o,h,c),this.fsw.closed)return;a!==c&&void 0!==c&&this.fsw._symlinkPaths.set(a,c)}else if(i.isSymbolicLink()){const o=u?await(0,r.realpath)(t):t;if(this.fsw.closed)return;const a=s.dirname(h.watchPath);if(this.fsw._getWatchedDir(a).add(h.watchPath),this.fsw._emit(c.ADD,h.watchPath,i),f=await this._handleDir(a,i,e,n,t,h,o),this.fsw.closed)return;void 0!==o&&this.fsw._symlinkPaths.set(s.resolve(t),o)}else f=this._handleFile(h.watchPath,i,e);return a(),f&&this.fsw._addPathCloser(t,f),!1}catch(e){if(this.fsw._handleError(e))return a(),t}}}},158(t,e,i){"use strict";e.watch=x;const n=i(9896),r=i(1943),s=i(4434),o=i(6928),a=i(9084),c=i(5266),l=/\\/g,h=/\/\//,u=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,f=/^\.[/\\]/;function d(t){return Array.isArray(t)?t:[t]}const p=t=>"object"==typeof t&&null!==t&&!(t instanceof RegExp);function m(t,e,i){const n=function(t){if("string"!=typeof t)throw new Error("string expected");let e=!1;(t=(t=o.normalize(t)).replace(/\\/g,"/")).startsWith("//")&&(e=!0);const i=/\/\//;for(;t.match(i);)t=t.replace(i,"/");return e&&(t="/"+t),t}(e);for(let e=0;e<t.length;e++){if((0,t[e])(n,i))return!0}return!1}function g(t,e){if(null==t)throw new TypeError("anymatch: specify first argument");const i=d(t).map(t=>function(t){return"function"==typeof t?t:"string"==typeof t?e=>t===e:t instanceof RegExp?e=>t.test(e):"object"==typeof t&&null!==t?e=>{if(t.path===e)return!0;if(t.recursive){const i=o.relative(t.path,e);return!!i&&!i.startsWith("..")&&!o.isAbsolute(i)}return!1}:()=>!1}(t));return null==e?(t,e)=>m(i,t,e):m(i,e)}const y=t=>{const e=d(t).flat();if(!e.every(t=>"string"==typeof t))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(w)},_=t=>{let e=t.replace(l,"/"),i=!1;for(e.startsWith("//")&&(i=!0);e.match(h);)e=e.replace(h,"/");return i&&(e="/"+e),e},w=t=>_(o.normalize(_(t))),b=(t="")=>e=>"string"==typeof e?w(o.isAbsolute(e)?e:o.join(t,e)):e,v=Object.freeze(new Set);class S{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){const{items:e}=this;e&&"."!==t&&".."!==t&&e.add(t)}async remove(t){const{items:e}=this;if(!e)return;if(e.delete(t),e.size>0)return;const i=this.path;try{await(0,r.readdir)(i)}catch(t){this._removeWatcher&&this._removeWatcher(o.dirname(i),o.basename(i))}}has(t){const{items:e}=this;if(e)return e.has(t)}getChildren(){const{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=c.EMPTY_FN,this.items=v,Object.freeze(this)}}class E{constructor(t,e,i){this.fsw=i;const n=t;this.path=t=t.replace(f,""),this.watchPath=n,this.fullWatchPath=o.resolve(n),this.dirParts=[],this.dirParts.forEach(t=>{t.length>1&&t.pop()}),this.followSymlinks=e,this.statMethod=e?"stat":"lstat"}entryPath(t){return o.join(this.watchPath,o.relative(this.watchPath,t.fullPath))}filterPath(t){const{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);const i=this.entryPath(t);return this.fsw._isntIgnored(i,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}}class k extends s.EventEmitter{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;const e=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},n={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?d(t.ignored):d([]),awaitWriteFinish:!0===e?i:"object"==typeof e&&{...i,...e}};c.isIBMi&&(n.usePolling=!0),void 0===n.atomic&&(n.atomic=!n.usePolling);const r=process.env.CHOKIDAR_USEPOLLING;if(void 0!==r){const t=r.toLowerCase();n.usePolling="false"!==t&&"0"!==t&&("true"===t||"1"===t||!!t)}const s=process.env.CHOKIDAR_INTERVAL;s&&(n.interval=Number.parseInt(s,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=c.EMPTY_FN,this._readyEmitted=!0,process.nextTick(()=>this.emit(c.EVENTS.READY)))},this._emitRaw=(...t)=>this.emit(c.EVENTS.RAW,...t),this._boundRemove=this._remove.bind(this),this.options=n,this._nodeFsHandler=new c.NodeFsHandler(this),Object.freeze(n)}_addIgnoredPath(t){if(p(t))for(const e of this._ignoredPaths)if(p(e)&&e.path===t.path&&e.recursive===t.recursive)return;this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),"string"==typeof t)for(const e of this._ignoredPaths)p(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,i){const{cwd:n}=this.options;this.closed=!1,this._closePromise=void 0;let r=y(t);return n&&(r=r.map(t=>{const e=((t,e)=>o.isAbsolute(t)?t:o.join(e,t))(t,n);return e})),r.forEach(t=>{this._removeIgnoredPath(t)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=r.length,Promise.all(r.map(async t=>{const n=await this._nodeFsHandler._addToNodeFs(t,!i,void 0,0,e);return n&&this._emitReady(),n})).then(t=>{this.closed||t.forEach(t=>{t&&this.add(o.dirname(t),o.basename(e||t))})}),this}unwatch(t){if(this.closed)return this;const e=y(t),{cwd:i}=this.options;return e.forEach(t=>{o.isAbsolute(t)||this._closers.has(t)||(i&&(t=o.join(i,t)),t=o.resolve(t)),this._closePath(t),this._addIgnoredPath(t),this._watched.has(t)&&this._addIgnoredPath({path:t,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();const t=[];return this._closers.forEach(e=>e.forEach(e=>{const i=e();i instanceof Promise&&t.push(i)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){const t={};return this._watched.forEach((e,i)=>{const n=this.options.cwd?o.relative(this.options.cwd,i):i;t[n||"."]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==c.EVENTS.ERROR&&this.emit(c.EVENTS.ALL,t,...e)}async _emit(t,e,i){if(this.closed)return;const n=this.options;c.isWindows&&(e=o.normalize(e)),n.cwd&&(e=o.relative(n.cwd,e));const s=[e];null!=i&&s.push(i);const a=n.awaitWriteFinish;let l;if(a&&(l=this._pendingWrites.get(e)))return l.lastChange=new Date,this;if(n.atomic){if(t===c.EVENTS.UNLINK)return this._pendingUnlinks.set(e,[t,...s]),setTimeout(()=>{this._pendingUnlinks.forEach((t,e)=>{this.emit(...t),this.emit(c.EVENTS.ALL,...t),this._pendingUnlinks.delete(e)})},"number"==typeof n.atomic?n.atomic:100),this;t===c.EVENTS.ADD&&this._pendingUnlinks.has(e)&&(t=c.EVENTS.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===c.EVENTS.ADD||t===c.EVENTS.CHANGE)&&this._readyEmitted){const i=(e,i)=>{e?(t=c.EVENTS.ERROR,s[0]=e,this.emitWithAll(t,s)):i&&(s.length>1?s[1]=i:s.push(i),this.emitWithAll(t,s))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,i),this}if(t===c.EVENTS.CHANGE){if(!this._throttle(c.EVENTS.CHANGE,e,50))return this}if(n.alwaysStat&&void 0===i&&(t===c.EVENTS.ADD||t===c.EVENTS.ADD_DIR||t===c.EVENTS.CHANGE)){const t=n.cwd?o.join(n.cwd,e):e;let i;try{i=await(0,r.stat)(t)}catch(t){}if(!i||this.closed)return;s.push(i)}return this.emitWithAll(t,s),this}_handleError(t){const e=t&&t.code;return t&&"ENOENT"!==e&&"ENOTDIR"!==e&&(!this.options.ignorePermissionErrors||"EPERM"!==e&&"EACCES"!==e)&&this.emit(c.EVENTS.ERROR,t),t||this.closed}_throttle(t,e,i){this._throttled.has(t)||this._throttled.set(t,new Map);const n=this._throttled.get(t);if(!n)throw new Error("invalid throttle");const r=n.get(e);if(r)return r.count++,!1;let s;const o=()=>{const t=n.get(e),i=t?t.count:0;return n.delete(e),clearTimeout(s),t&&clearTimeout(t.timeoutObject),i};s=setTimeout(o,i);const a={timeoutObject:s,clear:o,count:0};return n.set(e,a),a}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,i,r){const s=this.options.awaitWriteFinish;if("object"!=typeof s)return;const a=s.pollInterval;let c,l=t;this.options.cwd&&!o.isAbsolute(t)&&(l=o.join(this.options.cwd,t));const h=new Date,u=this._pendingWrites;u.has(t)||(u.set(t,{lastChange:h,cancelWait:()=>(u.delete(t),clearTimeout(c),i)}),c=setTimeout(function i(s){(0,n.stat)(l,(n,o)=>{if(n||!u.has(t))return void(n&&"ENOENT"!==n.code&&r(n));const l=Number(new Date);s&&o.size!==s.size&&(u.get(t).lastChange=l),l-u.get(t).lastChange>=e?(u.delete(t),r(void 0,o)):c=setTimeout(i,a,o)})},a))}_isIgnored(t,e){if(this.options.atomic&&u.test(t))return!0;if(!this._userIgnored){const{cwd:t}=this.options,e=(this.options.ignored||[]).map(b(t)),i=[...[...this._ignoredPaths].map(b(t)),...e];this._userIgnored=g(i,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new E(t,this.options.followSymlinks,this)}_getWatchedDir(t){const e=o.resolve(t);return this._watched.has(e)||this._watched.set(e,new S(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return!!this.options.ignorePermissionErrors||Boolean(256&Number(t.mode))}_remove(t,e,i){const n=o.join(t,e),r=o.resolve(n);if(i=null!=i?i:this._watched.has(n)||this._watched.has(r),!this._throttle("remove",n,100))return;i||1!==this._watched.size||this.add(t,e,!0);this._getWatchedDir(n).getChildren().forEach(t=>this._remove(n,t));const s=this._getWatchedDir(t),a=s.has(e);s.remove(e),this._symlinkPaths.has(r)&&this._symlinkPaths.delete(r);let l=n;if(this.options.cwd&&(l=o.relative(this.options.cwd,n)),this.options.awaitWriteFinish&&this._pendingWrites.has(l)){if(this._pendingWrites.get(l).cancelWait()===c.EVENTS.ADD)return}this._watched.delete(n),this._watched.delete(r);const h=i?c.EVENTS.UNLINK_DIR:c.EVENTS.UNLINK;a&&!this._isIgnored(n)&&this._emit(h,n),this._closePath(n)}_closePath(t){this._closeFile(t);const e=o.dirname(t);this._getWatchedDir(e).remove(o.basename(t))}_closeFile(t){const e=this._closers.get(t);e&&(e.forEach(t=>t()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(e)}_readdirp(t,e){if(this.closed)return;const i={type:c.EVENTS.ALL,alwaysStat:!0,lstat:!0,...e,depth:0};let n=(0,a.readdirp)(t,i);return this._streams.add(n),n.once(c.STR_CLOSE,()=>{n=void 0}),n.once(c.STR_END,()=>{n&&(this._streams.delete(n),n=void 0)}),n}}function x(t,e={}){const i=new k(e);return i.add(t),i}},5474(t,e,i){t=i.nmd(t),function e(n){"use strict";var r;function s(t,e,i){const n=typeof i,r=typeof t;if("undefined"!==n){if("undefined"!==r){if(i){if("function"===r&&n===r)return function(e){return t(i(e))};if((e=t.constructor)===i.constructor){if(e===Array)return i.concat(t);if(e===Map){var s=new Map(i);for(var o of t)s.set(o[0],o[1]);return s}if(e===Set){for(s of(o=new Set(i),t.values()))o.add(s);return o}}}return t}return i}return"undefined"===r?e:t}function o(t,e){return void 0===t?e:t}function a(){return Object.create(null)}function c(t){return"string"==typeof t}function l(t){return"object"==typeof t}function h(t,e){if(c(e))t=t[e];else for(let i=0;t&&i<e.length;i++)t=t[e[i]];return t}(n=t)._factory=e;const u=/[^\p{L}\p{N}]+/u,f=/(\d{3})/g,d=/(\D)(\d{3})/g,p=/(\d{3})(\D)/g,m=/[\u0300-\u036f]/g;function g(t={}){if(!this||this.constructor!==g)return new g(...arguments);if(arguments.length)for(t=0;t<arguments.length;t++)this.assign(arguments[t]);else this.assign(t)}function y(t){t.F=null,t.B.clear(),t.D.clear()}function _(t,e,i){i||(e||"object"!=typeof t?"object"==typeof e&&(i=e,e=0):i=t),i&&(t=i.query||t,e=i.limit||e);let n=""+(e||0);i&&(n+=(i.offset||0)+!!i.context+!!i.suggest+(!1!==i.resolve)+(i.resolution||this.resolution)+(i.boost||0)),t=(""+t).toLowerCase(),this.cache||(this.cache=new w);let r=this.cache.get(t+n);if(!r){const s=i&&i.cache;s&&(i.cache=!1),r=this.search(t,e,i),s&&(i.cache=s),this.cache.set(t+n,r)}return r}function w(t){this.limit=t&&!0!==t?t:1e3,this.cache=new Map,this.h=""}(r=g.prototype).assign=function(t){this.normalize=s(t.normalize,!0,this.normalize);let e,i=t.include,n=i||t.exclude||t.split;if(n||""===n){if("object"==typeof n&&n.constructor!==RegExp){let t="";e=!i,i||(t+="\\p{Z}"),n.letter&&(t+="\\p{L}"),n.number&&(t+="\\p{N}",e=!!i),n.symbol&&(t+="\\p{S}"),n.punctuation&&(t+="\\p{P}"),n.control&&(t+="\\p{C}"),(n=n.char)&&(t+="object"==typeof n?n.join(""):n);try{this.split=new RegExp("["+(i?"^":"")+t+"]+","u")}catch(t){this.split=/\s+/}}else this.split=n,e=!1===n||"a1a".split(n).length<2;this.numeric=s(t.numeric,e)}else{try{this.split=s(this.split,u)}catch(t){this.split=/\s+/}this.numeric=s(t.numeric,s(this.numeric,!0))}if(this.prepare=s(t.prepare,null,this.prepare),this.finalize=s(t.finalize,null,this.finalize),n=t.filter,this.filter="function"==typeof n?n:s(n&&new Set(n),null,this.filter),this.dedupe=s(t.dedupe,!0,this.dedupe),this.matcher=s((n=t.matcher)&&new Map(n),null,this.matcher),this.mapper=s((n=t.mapper)&&new Map(n),null,this.mapper),this.stemmer=s((n=t.stemmer)&&new Map(n),null,this.stemmer),this.replacer=s(t.replacer,null,this.replacer),this.minlength=s(t.minlength,1,this.minlength),this.maxlength=s(t.maxlength,1024,this.maxlength),this.rtl=s(t.rtl,!1,this.rtl),(this.cache=n=s(t.cache,!0,this.cache))&&(this.F=null,this.L="number"==typeof n?n:2e5,this.B=new Map,this.D=new Map,this.I=this.H=128),this.h="",this.J=null,this.A="",this.K=null,this.matcher)for(const t of this.matcher.keys())this.h+=(this.h?"|":"")+t;if(this.stemmer)for(const t of this.stemmer.keys())this.A+=(this.A?"|":"")+t;return this},r.addStemmer=function(t,e){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(t,e),this.A+=(this.A?"|":"")+t,this.K=null,this.cache&&y(this),this},r.addFilter=function(t){return"function"==typeof t?this.filter=t:(this.filter||(this.filter=new Set),this.filter.add(t)),this.cache&&y(this),this},r.addMapper=function(t,e){return"object"==typeof t?this.addReplacer(t,e):t.length>1?this.addMatcher(t,e):(this.mapper||(this.mapper=new Map),this.mapper.set(t,e),this.cache&&y(this),this)},r.addMatcher=function(t,e){return"object"==typeof t?this.addReplacer(t,e):t.length<2&&(this.dedupe||this.mapper)?this.addMapper(t,e):(this.matcher||(this.matcher=new Map),this.matcher.set(t,e),this.h+=(this.h?"|":"")+t,this.J=null,this.cache&&y(this),this)},r.addReplacer=function(t,e){return"string"==typeof t?this.addMatcher(t,e):(this.replacer||(this.replacer=[]),this.replacer.push(t,e),this.cache&&y(this),this)},r.encode=function(t,e){if(this.cache&&t.length<=this.H)if(this.F){if(this.B.has(t))return this.B.get(t)}else this.F=setTimeout(y,50,this);this.normalize&&(t="function"==typeof this.normalize?this.normalize(t):m?t.normalize("NFKD").replace(m,"").toLowerCase():t.toLowerCase()),this.prepare&&(t=this.prepare(t)),this.numeric&&t.length>3&&(t=t.replace(d,"$1 $2").replace(p,"$1 $2").replace(f,"$1 "));const i=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let n,r,s=[],o=a(),c=this.split||""===this.split?t.split(this.split):[t];for(let t,a,h=0;h<c.length;h++)if((t=a=c[h])&&!(t.length<this.minlength||t.length>this.maxlength)){if(e){if(o[t])continue;o[t]=1}else{if(n===t)continue;n=t}if(i)s.push(t);else if(!this.filter||("function"==typeof this.filter?this.filter(t):!this.filter.has(t))){if(this.cache&&t.length<=this.I)if(this.F){var l=this.D.get(t);if(l||""===l){l&&s.push(l);continue}}else this.F=setTimeout(y,50,this);if(this.stemmer){let e;for(this.K||(this.K=new RegExp("(?!^)("+this.A+")$"));e!==t&&t.length>2;)e=t,t=t.replace(this.K,t=>this.stemmer.get(t))}if(t&&(this.mapper||this.dedupe&&t.length>1)){l="";for(let e,i,n=0,r="";n<t.length;n++)e=t.charAt(n),e===r&&this.dedupe||((i=this.mapper&&this.mapper.get(e))||""===i?i===r&&this.dedupe||!(r=i)||(l+=i):l+=r=e);t=l}if(this.matcher&&t.length>1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),t=t.replace(this.J,t=>this.matcher.get(t))),t&&this.replacer)for(l=0;t&&l<this.replacer.length;l+=2)t=t.replace(this.replacer[l],this.replacer[l+1]);if(this.cache&&a.length<=this.I&&(this.D.set(a,t),this.D.size>this.L&&(this.D.clear(),this.I=this.I/1.1|0)),t){if(t!==a)if(e){if(o[t])continue;o[t]=1}else{if(r===t)continue;r=t}s.push(t)}}}return this.finalize&&(s=this.finalize(s)||s),this.cache&&t.length<=this.H&&(this.B.set(t,s),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),s},w.prototype.set=function(t,e){this.cache.set(this.h=t,e),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)},w.prototype.get=function(t){const e=this.cache.get(t);return e&&this.h!==t&&(this.cache.delete(t),this.cache.set(this.h=t,e)),e},w.prototype.remove=function(t){for(const e of this.cache){const i=e[0];e[1].includes(t)&&this.cache.delete(i)}},w.prototype.clear=function(){this.cache.clear(),this.h=""};const b={normalize:!1,numeric:!1,dedupe:!1},v={},S=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]),E=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),k=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],x={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,ß:2,d:3,t:3,l:4,m:5,n:5,r:6};var P={Exact:b,Default:v,Normalize:v,LatinBalance:{mapper:S},LatinAdvanced:{mapper:S,matcher:E,replacer:k},LatinExtra:{mapper:S,replacer:k.concat([/(?!^)[aeo]/g,""]),matcher:E},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(t){for(let i=0;i<t.length;i++){var e=t[i];let n=e.charAt(0),r=x[n];for(let t,i=1;i<e.length&&(t=e.charAt(i),"h"===t||"w"===t||!(t=x[t])||t===r||(n+=t,r=t,4!==n.length));i++);t[i]=n}}},CJK:{split:""},LatinExact:b,LatinDefault:v,LatinSimple:v};function D(t,e,i,n){let r=[];for(let s,o=0;o<t.index.length;o++)if(s=t.index[o],e>=s.length)e-=s.length;else{const o=(e=s[n?"splice":"slice"](e,i)).length;if(o&&(r=r.length?r.concat(e):e,i-=o,n&&(t.length-=o),!i))break;e=0}return r}function F(t){if(!this||this.constructor!==F)return new F(t);this.index=t?[t]:[],this.length=t?t.length:0;const e=this;return new Proxy([],{get:(t,i)=>"length"===i?e.length:"push"===i?function(t){e.index[e.index.length-1].push(t),e.length++}:"pop"===i?function(){if(e.length)return e.length--,e.index[e.index.length-1].pop()}:"indexOf"===i?function(t){let i=0;for(let n,r,s=0;s<e.index.length;s++){if(n=e.index[s],r=n.indexOf(t),r>=0)return i+r;i+=n.length}return-1}:"includes"===i?function(t){for(let i=0;i<e.index.length;i++)if(e.index[i].includes(t))return!0;return!1}:"slice"===i?function(t,i){return D(e,t||0,i||e.length,!1)}:"splice"===i?function(t,i){return D(e,t||0,i||e.length,!0)}:"constructor"===i?Array:"symbol"!=typeof i?(t=e.index[i/2**31|0])&&t[i]:void 0,set:(t,i,n)=>(t=i/2**31|0,(e.index[t]||(e.index[t]=[]))[i]=n,e.length++,!0)})}function N(t=8){if(!this||this.constructor!==N)return new N(t);this.index=a(),this.h=[],this.size=0,t>32?(this.B=I,this.A=BigInt(t)):(this.B=T,this.A=t)}function O(t=8){if(!this||this.constructor!==O)return new O(t);this.index=a(),this.h=[],this.size=0,t>32?(this.B=I,this.A=BigInt(t)):(this.B=T,this.A=t)}function T(t){let e=2**this.A-1;if("number"==typeof t)return t&e;let i=0,n=this.A+1;for(let r=0;r<t.length;r++)i=(i*n^t.charCodeAt(r))&e;return 32===this.A?i+2**31:i}function I(t){let e=BigInt(2)**this.A-BigInt(1);var i=typeof t;if("bigint"===i)return t&e;if("number"===i)return BigInt(t)&e;i=BigInt(0);let n=this.A+BigInt(1);for(let r=0;r<t.length;r++)i=(i*n^BigInt(t.charCodeAt(r)))&e;return i}let j,R,A,C,M;async function L(t){var e=(t=t.data).task;const i=t.id;let r=t.args;if("init"===e)R=t.options||{},(e=t.factory)?(Function("return "+e)()(n),j=new n.FlexSearch.Index(R),delete n.FlexSearch):j=new Ft(R),postMessage({id:i});else{let n;"export"===e&&(r[1]?(r[0]=R.export,r[2]=0,r[3]=1):r=null),"import"===e?r[0]&&(t=await R.import.call(j,r[0]),j.import(r[0],t)):((n=r&&j[e].apply(j,r))&&n.then&&(n=await n),n&&n.await&&(n=await n.await),"search"===e&&n.result&&(n=n.result)),postMessage("search"===e?{id:i,msg:n}:{id:i})}}function z(t){$.call(t,"add"),$.call(t,"append"),$.call(t,"search"),$.call(t,"update"),$.call(t,"remove"),$.call(t,"searchCache")}function W(){A=M=0}function $(t){this[t+"Async"]=function(){const e=arguments;var i=e[e.length-1];let n;if("function"==typeof i&&(n=i,delete e[e.length-1]),A?M||(M=Date.now()-C>=this.priority*this.priority*3):(A=setTimeout(W,0),C=Date.now()),M){const i=this;return new Promise(n=>{setTimeout(function(){n(i[t+"Async"].apply(i,e))},0)})}const r=this[t].apply(this,e);return i=r.then?r:new Promise(t=>t(r)),n&&i.then(n),i}}F.prototype.clear=function(){this.index.length=0},F.prototype.push=function(){},N.prototype.get=function(t){const e=this.index[this.B(t)];return e&&e.get(t)},N.prototype.set=function(t,e){var i=this.B(t);let n=this.index[i];n?(i=n.size,n.set(t,e),(i-=n.size)&&this.size++):(this.index[i]=n=new Map([[t,e]]),this.h.push(n),this.size++)},O.prototype.add=function(t){var e=this.B(t);let i=this.index[e];i?(e=i.size,i.add(t),(e-=i.size)&&this.size++):(this.index[e]=i=new Set([t]),this.h.push(i),this.size++)},(r=N.prototype).has=O.prototype.has=function(t){const e=this.index[this.B(t)];return e&&e.has(t)},r.delete=O.prototype.delete=function(t){const e=this.index[this.B(t)];e&&e.delete(t)&&this.size--},r.clear=O.prototype.clear=function(){this.index=a(),this.h=[],this.size=0},r.values=O.prototype.values=function*(){for(let t=0;t<this.h.length;t++)for(let e of this.h[t].values())yield e},r.keys=O.prototype.keys=function*(){for(let t=0;t<this.h.length;t++)for(let e of this.h[t].keys())yield e},r.entries=O.prototype.entries=function*(){for(let t=0;t<this.h.length;t++)