Files
ST-Amily2-Chat-Optimisation/ui/hanlinyuan-bindings.js
2025-08-05 07:14:39 +08:00

1 line
47 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const _0x34a9aa=_0x2a3e;(function(_0x2f1c95,_0x1baf57){const _0x5eb2ee=_0x2a3e,_0xe7c316=_0x2f1c95();while(!![]){try{const _0x5f506e=-parseInt(_0x5eb2ee(0xd9))/0x1+-parseInt(_0x5eb2ee(0x17c))/0x2+-parseInt(_0x5eb2ee(0x127))/0x3*(-parseInt(_0x5eb2ee(0x1a7))/0x4)+parseInt(_0x5eb2ee(0x1df))/0x5*(parseInt(_0x5eb2ee(0x1b8))/0x6)+parseInt(_0x5eb2ee(0x163))/0x7+parseInt(_0x5eb2ee(0x1b1))/0x8+parseInt(_0x5eb2ee(0x18d))/0x9;if(_0x5f506e===_0x1baf57)break;else _0xe7c316['push'](_0xe7c316['shift']());}catch(_0x375de8){_0xe7c316['push'](_0xe7c316['shift']());}}}(_0x22ab,0x844a7));import{getContext}from'/scripts/extensions.js';import*as _0x1750b8 from'../core/rag-processor.js';import*as _0x41ee77 from'../core/historiographer.js';import*as _0x3e1193 from'../core/utils/context-utils.js';import*as _0x58a2b6 from'../core/ingestion-manager.js';import{showContentModal,showHtmlModal}from'./page-window.js';function _0x22ab(){const _0x5cf9be=['from','<i\x20class=\x22fa-solid\x20','<option\x20value=\x22\x22>请选择一个书库...</option>','清空宝库失败。','hly-overlap-size','\x20块继续录入。','开始获取Rerank模型列表...','children','》中条目\x20(Key:\x20','ingestTextToHanlinyuan','未能获取到任何Rerank模型。','scripts/extensions/third-party/ST-Amily2-Chat-Optimisation/HanLin.md','signal','\x22\x20placeholder=\x22开始字符,\x20如\x20<!--\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span>到</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<input\x20type=\x22text\x22\x20class=\x22hly-imperial-brush\x22\x20value=\x22','查询宝库状态失败:\x20','input[name=\x22hly-injection-position\x22]','文书已成功录入宝库,新增\x20','hly-custom-api-url','\x20楼凝识至第\x20','1341062iepfdl','purgeStorage','warning','编纂任务已开始...','top_n','预览后文本录入成功,新增\x20','查看宝库状态成功集合ID=','hybrid_alpha','[翰林院-枢纽]\x20获取模型列表失败:','notify','\x0a<pre>\x0a翰林院宝库状态\x0a--------------------\x0a集合ID:\x20','abort','dataset','title','圣谕不明','text','文书录入失败:\x20','5484429ronoEe','click','change','N/A','hly-include-ai','batchSize','condensationHistory','closest','fa-check-circle','totalChunks','圣旨已达','确认并更新预览','enabled','.hly-preview-delete-btn-v2','apiEndpoint','收到手动录入请求,文本长度:\x20','神力连接通畅!','disabled','getChatId','exclusionRules','saveSettings','fa-times-circle','messageTypes','checked','files','未找到符合条件的消息可供凝识。','6776ZCRWeb','type','翰林院设定已重置为初始状态。','processed','filter','凝识完成!新增\x20','。进度已保存,可稍后重试。','beforeend','获取模型失败:\x20','addEventListener','1546648ykxlsZ','testHLYApi','[翰林院-枢纽]\x20更新忆识数量失败:','hly-tag-input','map','\x22></i>\x20[','hly-session-lock-btn','6aVFxfc','embeddingModel','正在查询宝库状态...','input[name=\x22','hly-log-output','getLoresForWorldbook','hly-log-entry\x20','getElementById','find','开始对《','depth','.hly-preview-item-v2','圣旨已下','会话已解锁。','scrollHeight','string','push','[断点续传]\x20用户选择继续任务\x20','<option\x20value=\x22\x22>正在加载条目...</option>','depth_role','span','\x20条忆识。','apiKey','大功告成','querySelectorAll','录入内容不能为空。','<option\x20value=\x22\x22>请选择一个条目...</option>','success','编纂任务已完成。','clearJob','\x0a忆识总数:\x20','...','log-error','预览并编辑凝识内容','fetchEmbeddingModels','获取Rerank模型失败:\x20','appendChild','scrollTop','style','2183730QqAeYW','成功录入\x20','getSettings','hly-layer-end','generateJobId','boolean','processCondensation',',从第\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22hly-exclusion-rule-row\x22\x20data-index=\x22','content','executeCompilation','getVectorCount','hly-tag-extraction-toggle','hly-embedding-model','textContent','createElement','settingKey','options','\x20个模型。','end','\x0a\x20\x20\x20\x20\x20\x20\x20\x20<div\x20id=\x22hly-exclusion-rules-container\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<p\x20class=\x22hly-notes\x22>在这里定义需要从提取内容中排除的文本片段。例如排除HTML注释可以设置开始字符为\x20`<!--`,结束字符为\x20`-->`。</p>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20id=\x22hly-rules-list\x22>','您确定要将所有设定恢复为出厂默认值吗?','checkbox','integer','hlyLog','hly-modal-container','\x20楼:\x20[','<option\x20value=\x22\x22>加载失败</option>','loadProgress','fas\x20fa-lock-open','\x20个Rerank模型。','hanlinyuan-ingest-novel-controls','fetchHLYRerankModels','hanlinyuan-ingest-novel-file-input','hly-rerank-top-n','<option\x20value=\x22\x22>此书库为空</option>','resetHLYSettings','display','[翰林院-枢纽]\x20获取Rerank模型列表失败:','[翰林院-枢纽]\x20核心法典未能提供初始化圣旨','】已成功编纂入库。','hly-locked-status','根据标签提取或内容排除条件,未找到任何有效内容。','》中的条目\x20(Key:\x20','</div>','hly-injection-role','finalText','检测到预览后待处理的文本,开始直接凝识...','amily2_open_rag_palace','成功获取\x20','<option\x20value=\x22\x22>未找到任何书库</option>','hanlinyuan-ingest-progress-bar','内容排除规则已保存。','正在处理预览后的文本...','none','未知错误','\x22\x20title=\x22删除此条\x22>&times;</button>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20','float','hanlinyuan-ingest-progress-container','radio',',\x20忆识总数=','hly-retrieval-enabled','chat_history','getCharacterName','className','position','翰林院使用教程','任务完成!成功录入\x20','锁定会话','retrieval','根据当前勾选条件,未找到符合的消息可供预览。','预览内容已更新,可随时开始凝识。','hly-hist-select-entry','当前所有操作都将指向这个锁定的宝库:','innerHTML','hly-layer-start','\x20个条目。','\x20进行编纂...','initialize','-tab','请先选择一个\x20.txt\x20文件','此操作将彻底清空当前角色的所有忆识(向量),且无法恢复。您确定要继续吗?','聊天记录\x20','manual','fas\x20fa-lock','hly-api-endpoint','key','点击以解锁,让翰林院跟随当前角色','hly-current-vector-count','message','开始获取模型列表...','》获取条目列表...','processedChunks','\x20楼。</i></p>','custom','\x20楼已成功凝识新增\x20','val','.hly-exclusion-rule-row','hly-condensation-enabled','用户尝试录入空文本。','getMessagesForCondensation','会话已锁定到宝库:\x20','815283jHBuEm','正在清空宝库...','start','info','\x20条消息开始凝识...','<div\x20class=\x22hly-preview-container-v2\x22>','已选择\x20','azure','正在准备凝识...','未选择文件','length','未找到符合条件的消息。','preventDefault','active','total','startHLYHistoriography','<option>正在获取...</option>','condensation','includes','toLocaleTimeString','warn','hanlinyuan-ingest-novel-start','name','\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<input\x20type=\x22text\x22\x20class=\x22hly-imperial-brush\x22\x20value=\x22','hly-hist-select-library','[翰林院-枢纽]\x20手动录入过程发生错误:','hly-current-character-name','remove','input[name=\x22hly-injection-position\x22]:checked','hly-retrieval-notify','overlap','flex','错误:\x20','contains','.hly-log-placeholder','已采集\x20','准备对《','[翰林院-枢纽]\x20未能获取SillyTavern上下文绑定失败。','isSessionLocked','template','翰林院设定已存档封印。','each','[翰林院-枢纽]\x20加载《','target','block','\x20个书库。','神力连接失败:\x20','true','解锁会话','hanlinyuan-ingest-novel-file-name','hly-','处理中:\x20','hly-rerank-notify','\x20(Key:\x20','[翰林院-枢纽]\x20预览过程发生错误:','user','\x20楼到第\x20','getCollectionId','hly-query-message-count','advanced','querySelector','hly-manual-text',')\x20进行编纂...',']\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</summary>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22hly-preview-content\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<textarea\x20class=\x22hly-preview-textarea\x22>','编纂失败:\x20','正在处理您提交的文书...','classList','翰林院启奏','model','split','hly-tag-input-container','<p\x20class=\x22hly-record-hint\x22>可在此预览凝识结果。</p>','tags','fa-circle-info','%。是否从上次中断之处继续?','stringify','严重错误','手动录入失败:\x20','222MQxHzD','use\x20strict','用户请求查看宝库状态。','请先选择一个书库和要编纂的条目。','ingestHLYManualText','is_user','[翰林院-枢纽]\x20加载书库列表失败:','手动录入','count','.hly-tab-pane','input','hly-injection-depth','hly-batch-size','hly-rerank-model','预览失败:\x20','加载条目失败:\x20','成功加载\x20','hly-match-threshold','preview-item-','hly-rerank-api-key','\x20条有效条目请点击“开始凝识”进入自动向量化流程。','log-info','forEach','#hly-add-rule-btn','AbortError','任务已中止。','<option>未找到模型</option>','\x27\x20已更新为:\x20','#hly-rules-list','[翰林院-枢纽]\x20已成功连接各部政令畅通。','join','value','rerank','chat','comment','手动录入成功,新增\x20','toggle','layerStart','trim','injection','hly-injection-template','未知的编纂错误','正在处理您确认后的文书...','hly-max-results','<option\x20value=\x22\x22>请先选择书库</option>','error','[翰林院-枢纽]\x20凝识过程发生错误:','input[name=\x22hly-injection-position\x22][value=\x22','add','[翰林院-枢纽]\x20编纂过程发生错误:','会话已锁定','tab','hly-condensation-results','toggleSessionLock','聊天记录从第\x20','<option>获取失败</option>','selectedIndex','mes','fa-exclamation-triangle','\x0a\x0a---\x0a\x0a','4640041wvuFzE','testApiConnection','queryMessageCount','getLockedSessionInfo','log-warn','fetchRerankModels'];_0x22ab=function(){return _0x5cf9be;};return _0x22ab();}import{extractBlocksByTags,applyExclusionRules}from'../core/utils/rag-tag-extractor.js';_0x34a9aa(0x128);function setupGlobalEventHandlers(){const _0x5d2a10=_0x34a9aa;window['saveHLYSettings']=()=>saveSettingsFromUI(![]),window[_0x5d2a10(0x203)]=resetSettingsToUI,window[_0x5d2a10(0x1b2)]=testApi,window['fetchHLYEmbeddingModels']=fetchHLYEmbeddingModels,window[_0x5d2a10(0x1ff)]=fetchHLYRerankModels,window['updateHLYMemoryCount']=updatePanelStatus,window['purgeHLYStorage']=purgeStorage,window['startHLYCondensation']=startCondensation,window['previewHLYCondensation']=previewCondensation,window[_0x5d2a10(0x12b)]=ingestManualText,window[_0x5d2a10(0x1f7)]=log,window['showHLYStats']=showStats,window[_0x5d2a10(0xe8)]=startHistoriography;}function updateAndSaveSetting(_0x4f6a9a,_0x348cf9){const _0x52b2c4=_0x34a9aa,_0x2ae122=_0x1750b8[_0x52b2c4(0x1e1)]();if(!_0x2ae122)return;const _0xdd281a=_0x4f6a9a[_0x52b2c4(0x11e)]('.');let _0x87009b=_0x2ae122;for(let _0x4c93d9=0x0;_0x4c93d9<_0xdd281a[_0x52b2c4(0xe3)]-0x1;_0x4c93d9++){_0x87009b=_0x87009b[_0xdd281a[_0x4c93d9]]=_0x87009b[_0xdd281a[_0x4c93d9]]||{};}_0x87009b[_0xdd281a[_0xdd281a[_0x52b2c4(0xe3)]-0x1]]=_0x348cf9,_0x1750b8[_0x52b2c4(0x1a1)](),log('[自动保存]\x20设置项\x20\x27'+_0x4f6a9a+_0x52b2c4(0x142)+JSON[_0x52b2c4(0x124)](_0x348cf9),_0x52b2c4(0x1d3));}function bindAutoSaveEvents(){const _0x4fc348=_0x34a9aa,_0x4b25c6=document['getElementById'](_0x4fc348(0x1f8));if(!_0x4b25c6)return;_0x4b25c6[_0x4fc348(0x1b0)](_0x4fc348(0x18f),_0x5d6aac=>{const _0x5e1ff7=_0x4fc348,_0x2da7d8=_0x5d6aac[_0x5e1ff7(0x104)],_0x1e3f45=_0x2da7d8[_0x5e1ff7(0x188)][_0x5e1ff7(0x1ef)];if(!_0x1e3f45)return;let _0x588b9a;const _0x2bf221=_0x2da7d8[_0x5e1ff7(0x188)]['type']||_0x5e1ff7(0x1c7);if(_0x2da7d8[_0x5e1ff7(0x1a8)]===_0x5e1ff7(0x1f5))_0x588b9a=_0x2da7d8[_0x5e1ff7(0x1a4)];else{if(_0x2da7d8[_0x5e1ff7(0x1a8)]==='radio'){if(_0x2da7d8['checked']){const _0x411feb=_0x4b25c6[_0x5e1ff7(0x1d0)](_0x5e1ff7(0x1bb)+_0x2da7d8['name']+'\x22]'),_0x384def=Array[_0x5e1ff7(0x169)](_0x411feb)[_0x5e1ff7(0x1c0)](_0x3501b3=>_0x3501b3[_0x5e1ff7(0x1a4)]);_0x588b9a=_0x384def[_0x5e1ff7(0x146)];}else return;}else _0x588b9a=_0x2da7d8[_0x5e1ff7(0x146)];}switch(_0x2bf221){case _0x5e1ff7(0x1f6):_0x588b9a=parseInt(_0x588b9a,0xa);break;case _0x5e1ff7(0x218):_0x588b9a=parseFloat(_0x588b9a);break;case _0x5e1ff7(0x1e4):typeof _0x588b9a!==_0x5e1ff7(0x1e4)&&(_0x588b9a=_0x588b9a===_0x5e1ff7(0x108));break;}if(_0x2da7d8[_0x5e1ff7(0x1a8)]===_0x5e1ff7(0x21a)&&!_0x2da7d8[_0x5e1ff7(0x1a4)])return;updateAndSaveSetting(_0x1e3f45,_0x588b9a);});}export function bindHanlinyuanEvents(){const _0x5745e2=_0x34a9aa,_0x506a83=getContext();if(!_0x506a83){console[_0x5745e2(0x154)](_0x5745e2(0xfe));return;}setupGlobalEventHandlers(),bindPanelToggleEvents(),bindInternalUIEvents(),bindTutorialEvents(),bindAutoSaveEvents(),bindSessionLockEvent();if(_0x1750b8[_0x5745e2(0x22d)])_0x1750b8[_0x5745e2(0x22d)]();else{console[_0x5745e2(0x154)](_0x5745e2(0x206));return;}loadSettingsToUI(),loadWorldbookList(),log(_0x5745e2(0x144),_0x5745e2(0xdc));const _0x47e735=document['getElementById'](_0x5745e2(0x200)),_0x43665e=document[_0x5745e2(0x1bf)](_0x5745e2(0x10a)),_0x567273=document[_0x5745e2(0x1bf)](_0x5745e2(0xee)),_0x36275c=document[_0x5745e2(0x1bf)]('hanlinyuan-ingest-abort'),_0x35e8f7=document['getElementById'](_0x5745e2(0x219)),_0x1c1c93=document[_0x5745e2(0x1bf)](_0x5745e2(0x212)),_0x33bafb=document[_0x5745e2(0x1bf)]('hanlinyuan-ingest-status'),_0x2a937e=document['getElementById'](_0x5745e2(0x1fe));let _0x5b28c6=null,_0x4b415c=null;_0x47e735['addEventListener']('change',_0x112de2=>{const _0x230c42=_0x5745e2;_0x5b28c6=_0x112de2['target'][_0x230c42(0x1a5)][0x0],_0x5b28c6?(_0x43665e[_0x230c42(0x1ed)]=_0x5b28c6[_0x230c42(0xef)],_0x43665e[_0x230c42(0x189)]=_0x5b28c6[_0x230c42(0xef)]):_0x43665e[_0x230c42(0x1ed)]='未选择文件';}),_0x567273[_0x5745e2(0x1b0)](_0x5745e2(0x18e),async()=>{const _0x2851e6=_0x5745e2;if(!_0x5b28c6){toastr['warning'](_0x2851e6(0x22f));return;}let _0x58f60f=0x0;const _0x3ba3fc=_0x58a2b6[_0x2851e6(0x1e3)](_0x5b28c6),_0x53052d=_0x58a2b6[_0x2851e6(0x1fb)](_0x3ba3fc);if(_0x53052d){const _0x1169a8=(_0x53052d['processedChunks']/_0x53052d[_0x2851e6(0x196)]*0x64)['toFixed'](0x1),_0x19459c=confirm('启禀大人,发现此书上次录入已完成\x20'+_0x1169a8+_0x2851e6(0x123));_0x19459c?(_0x58f60f=_0x53052d[_0x2851e6(0x23b)],toastr[_0x2851e6(0xdc)]('遵命,将从第\x20'+(_0x58f60f+0x1)+_0x2851e6(0x16e),_0x2851e6(0x197)),log(_0x2851e6(0x1c9)+_0x3ba3fc+_0x2851e6(0x1e6)+_0x58f60f+'\x20块开始。',_0x2851e6(0xdc))):(_0x58a2b6[_0x2851e6(0x1d5)](_0x3ba3fc),toastr[_0x2851e6(0xdc)]('遵命,将从头开始录入此书。','圣旨已达'),log('[断点续传]\x20用户选择放弃旧任务\x20'+_0x3ba3fc+',重新开始。',_0x2851e6(0xed)));}_0x4b415c=new AbortController();const _0x17efb7=_0x4b415c[_0x2851e6(0x175)];_0x2a937e[_0x2851e6(0x1de)]['display']=_0x2851e6(0x215),_0x35e8f7[_0x2851e6(0x1de)][_0x2851e6(0x204)]='block',_0x33bafb[_0x2851e6(0x1ed)]='正在读取文件...',_0x1c1c93[_0x2851e6(0x146)]=0x0;try{const _0x5efe7a=await _0x5b28c6[_0x2851e6(0x18b)](),_0x401bcd=_0x411fb6=>{const _0x5c6c23=_0x2851e6;_0x33bafb['textContent']=_0x5c6c23(0x10c)+_0x411fb6[_0x5c6c23(0x238)]+'\x20('+_0x411fb6[_0x5c6c23(0x1aa)]+'/'+_0x411fb6[_0x5c6c23(0xe7)]+')',_0x1c1c93[_0x5c6c23(0x146)]=_0x411fb6[_0x5c6c23(0x1aa)]/_0x411fb6['total']*0x64;},_0x2f33d3=()=>{const _0x547377=_0x2851e6;updatePanelStatus(),log('[实时刷新]\x20批次完成忆识总数已更新。',_0x547377(0xdc));},_0x48c08c=await _0x1750b8[_0x2851e6(0x172)](_0x5efe7a,'novel',_0x5b28c6[_0x2851e6(0xef)],_0x401bcd,_0x17efb7,log,_0x2f33d3,_0x3ba3fc,_0x58f60f);if(_0x48c08c[_0x2851e6(0x1d3)])toastr[_0x2851e6(0x1d3)](_0x2851e6(0x1e0)+_0x48c08c[_0x2851e6(0x12f)]+'\x20个知识块'),_0x33bafb[_0x2851e6(0x1ed)]=_0x2851e6(0x222)+_0x48c08c['count']+'\x20个知识块。',_0x1c1c93[_0x2851e6(0x146)]=0x64,updatePanelStatus();else throw new Error(_0x48c08c[_0x2851e6(0x154)]||'未知错误');}catch(_0x529ea8){_0x529ea8[_0x2851e6(0xef)]===_0x2851e6(0x13f)?(toastr[_0x2851e6(0xdc)]('任务已由用户中止。进度已保存,可随时继续。'),_0x33bafb[_0x2851e6(0x1ed)]=_0x2851e6(0x140)):(toastr[_0x2851e6(0x154)]('录入失败:\x20'+_0x529ea8[_0x2851e6(0x238)]+_0x2851e6(0x1ad)),_0x33bafb[_0x2851e6(0x1ed)]=_0x2851e6(0xf9)+_0x529ea8['message']);}finally{setTimeout(()=>{const _0x379c5a=_0x2851e6;_0x2a937e[_0x379c5a(0x1de)][_0x379c5a(0x204)]=_0x379c5a(0xf8),_0x35e8f7[_0x379c5a(0x1de)][_0x379c5a(0x204)]=_0x379c5a(0x215),_0x47e735[_0x379c5a(0x146)]='',_0x5b28c6=null,_0x43665e[_0x379c5a(0x1ed)]=_0x379c5a(0xe2);},0xbb8);}}),_0x36275c[_0x5745e2(0x1b0)]('click',()=>{const _0x4436f6=_0x5745e2;_0x4b415c&&_0x4b415c[_0x4436f6(0x187)]();});}function bindSessionLockEvent(){const _0x35824c=_0x34a9aa,_0x2c13a8=document[_0x35824c(0x1bf)](_0x35824c(0x1b7));if(!_0x2c13a8)return;_0x2c13a8['addEventListener'](_0x35824c(0x18e),()=>{const _0x1edf09=_0x35824c,_0x43142d=_0x1750b8[_0x1edf09(0x15c)]();updateSessionLockUI(_0x43142d);if(_0x43142d){const _0x2b031c=_0x1750b8[_0x1edf09(0x166)]();toastr[_0x1edf09(0x1d3)]('会话已锁定到:\x20'+_0x2b031c['id'],_0x1edf09(0x1c4)),log(_0x1edf09(0xd8)+_0x2b031c['id'],_0x1edf09(0x1d3));}else toastr[_0x1edf09(0xdc)]('会话已解锁,将跟随当前角色。','诏曰'),log(_0x1edf09(0x1c5),'info');updatePanelStatus();}),updateSessionLockUI(_0x1750b8[_0x35824c(0xff)]());}function _0x2a3e(_0x424898,_0x4029f0){const _0x22ab15=_0x22ab();return _0x2a3e=function(_0x2a3ec8,_0x19ddad){_0x2a3ec8=_0x2a3ec8-0xd3;let _0x459762=_0x22ab15[_0x2a3ec8];return _0x459762;},_0x2a3e(_0x424898,_0x4029f0);}function updateSessionLockUI(_0x2c99e5){const _0x205ebf=_0x34a9aa,_0x45a59e=document[_0x205ebf(0x1bf)](_0x205ebf(0x1b7));if(!_0x45a59e)return;const _0x3511e5=_0x45a59e[_0x205ebf(0x115)]('i'),_0x5465fb=_0x45a59e['querySelector'](_0x205ebf(0x1cc));_0x2c99e5?(_0x45a59e[_0x205ebf(0x11b)]['add'](_0x205ebf(0xe6)),_0x3511e5[_0x205ebf(0x21f)]=_0x205ebf(0x233),_0x5465fb[_0x205ebf(0x1ed)]=_0x205ebf(0x109),_0x45a59e[_0x205ebf(0x189)]=_0x205ebf(0x236)):(_0x45a59e[_0x205ebf(0x11b)][_0x205ebf(0xf4)](_0x205ebf(0xe6)),_0x3511e5[_0x205ebf(0x21f)]=_0x205ebf(0x1fc),_0x5465fb['textContent']=_0x205ebf(0x223),_0x45a59e[_0x205ebf(0x189)]='点击以锁定,让翰林院固定操作当前角色的宝库');}function bindPanelToggleEvents(){const _0x3338a8=_0x34a9aa,_0x2f7c52=document[_0x3338a8(0x1bf)](_0x3338a8(0x20f));if(_0x2f7c52){}}function bindTutorialEvents(){const _0x504026=_0x34a9aa,_0x192654=document[_0x504026(0x1bf)]('amily2_open_hanlin_tutorial');_0x192654&&_0x192654[_0x504026(0x1b0)](_0x504026(0x18e),()=>{const _0x416253=_0x504026;showContentModal(_0x416253(0x221),_0x416253(0x174));});}function bindInternalUIEvents(){const _0x589c4d=_0x34a9aa,_0xe3d428=document[_0x589c4d(0x1d0)]('.hly-nav-item');_0xe3d428[_0x589c4d(0x13d)](_0x42f33a=>{const _0x23a7ac=_0x589c4d;_0x42f33a[_0x23a7ac(0x1b0)]('click',()=>{const _0x7049bb=_0x23a7ac,_0x18d7f9=_0x42f33a[_0x7049bb(0x188)][_0x7049bb(0x15a)],_0x20107c=_0x7049bb(0x10b)+_0x18d7f9+_0x7049bb(0x22e);document[_0x7049bb(0x1d0)](_0x7049bb(0x130))[_0x7049bb(0x13d)](_0x377ed3=>{const _0x34a6fd=_0x7049bb;_0x377ed3['classList'][_0x34a6fd(0x14b)](_0x34a6fd(0xe6),_0x377ed3['id']===_0x20107c);}),_0xe3d428[_0x7049bb(0x13d)](_0x56dd80=>_0x56dd80['classList'][_0x7049bb(0x14b)](_0x7049bb(0xe6),_0x56dd80===_0x42f33a));});});const _0x598d14=document[_0x589c4d(0x1bf)](_0x589c4d(0x234));_0x598d14&&_0x598d14[_0x589c4d(0x1b0)](_0x589c4d(0x18f),toggleCustomEndpointDocket);const _0x40af14=document[_0x589c4d(0x1d0)](_0x589c4d(0x178));_0x40af14[_0x589c4d(0x13d)](_0x5219d5=>{const _0x2c22b6=_0x589c4d;_0x5219d5[_0x2c22b6(0x1b0)](_0x2c22b6(0x18f),toggleInjectionDetails);});const _0x41dc34=document[_0x589c4d(0x1bf)](_0x589c4d(0x1eb)),_0x2cb1a6=document[_0x589c4d(0x1bf)](_0x589c4d(0x11f));_0x41dc34&&_0x2cb1a6&&_0x41dc34[_0x589c4d(0x1b0)](_0x589c4d(0x18f),()=>{const _0x195067=_0x589c4d;_0x2cb1a6['style'][_0x195067(0x204)]=_0x41dc34[_0x195067(0x1a4)]?'block':_0x195067(0x215);});const _0x45a57f=document['getElementById'](_0x589c4d(0xf1));_0x45a57f&&_0x45a57f[_0x589c4d(0x1b0)]('change',handleWorldbookSelectionChange);const _0x20abd7=document[_0x589c4d(0x1bf)]('hly-exclusion-rules-btn');_0x20abd7&&_0x20abd7[_0x589c4d(0x1b0)](_0x589c4d(0x18e),showExclusionRulesModal);}function toggleInjectionDetails(){const _0x10fc24=_0x34a9aa,_0x17621d=document[_0x10fc24(0x115)](_0x10fc24(0xf5))[_0x10fc24(0x146)],_0x8f97e=document[_0x10fc24(0x1bf)](_0x10fc24(0x132)),_0xa5eb66=document[_0x10fc24(0x1bf)](_0x10fc24(0x20c)),_0x4e6bc0=_0x17621d==='1';_0x8f97e[_0x10fc24(0x19e)]=!_0x4e6bc0,_0xa5eb66[_0x10fc24(0x19e)]=!_0x4e6bc0;}function toggleCustomEndpointDocket(){const _0x1fdcd9=_0x34a9aa,_0x2723b8=document[_0x1fdcd9(0x1bf)](_0x1fdcd9(0x234))[_0x1fdcd9(0x146)],_0x31f9e9=document[_0x1fdcd9(0x1bf)]('hly-custom-endpoint-docket');_0x31f9e9&&(_0x31f9e9[_0x1fdcd9(0x1de)][_0x1fdcd9(0x204)]=_0x2723b8===_0x1fdcd9(0x23d)||_0x2723b8===_0x1fdcd9(0xe0)?_0x1fdcd9(0x105):_0x1fdcd9(0x215));}function loadSettingsToUI(){const _0x53ccfe=_0x34a9aa,_0x322a13=_0x1750b8[_0x53ccfe(0x1e1)]();if(!_0x322a13)return;document[_0x53ccfe(0x1bf)](_0x53ccfe(0x21c))[_0x53ccfe(0x1a4)]=_0x322a13[_0x53ccfe(0x224)][_0x53ccfe(0x199)],document['getElementById']('hly-api-endpoint')[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x224)][_0x53ccfe(0x19b)],document['getElementById'](_0x53ccfe(0x17a))[_0x53ccfe(0x146)]=_0x322a13['retrieval']['customApiUrl'],document[_0x53ccfe(0x1bf)]('hly-api-key')[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x224)][_0x53ccfe(0x1ce)];const _0x2b222e=document[_0x53ccfe(0x1bf)](_0x53ccfe(0x1ec));if(_0x2b222e['options'][_0x53ccfe(0xe3)]===0x0){const _0x30c757=_0x322a13[_0x53ccfe(0x224)]['embeddingModel'],_0x3216ca=new Option(_0x30c757,_0x30c757,!![],!![]);_0x2b222e[_0x53ccfe(0x157)](_0x3216ca);}_0x2b222e[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x224)]['embeddingModel'],document[_0x53ccfe(0x1bf)](_0x53ccfe(0xf6))[_0x53ccfe(0x1a4)]=_0x322a13[_0x53ccfe(0x224)][_0x53ccfe(0x185)],document[_0x53ccfe(0x1bf)]('hly-chunk-size')[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x114)]['chunkSize'],document[_0x53ccfe(0x1bf)](_0x53ccfe(0x16d))[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x114)][_0x53ccfe(0xf7)],document['getElementById'](_0x53ccfe(0x138))[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x114)]['matchThreshold'],document['getElementById'](_0x53ccfe(0x113))['value']=_0x322a13[_0x53ccfe(0x114)][_0x53ccfe(0x165)],document[_0x53ccfe(0x1bf)](_0x53ccfe(0x152))[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x114)]['maxResults'],document[_0x53ccfe(0x1bf)](_0x53ccfe(0x133))[_0x53ccfe(0x146)]=_0x322a13['retrieval'][_0x53ccfe(0x192)],document[_0x53ccfe(0x1bf)](_0x53ccfe(0x14f))[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x14e)][_0x53ccfe(0x100)];const _0x1ee224=document[_0x53ccfe(0x115)](_0x53ccfe(0x156)+_0x322a13[_0x53ccfe(0x14e)][_0x53ccfe(0x220)]+'\x22]');_0x1ee224&&(_0x1ee224[_0x53ccfe(0x1a4)]=!![]);document[_0x53ccfe(0x1bf)](_0x53ccfe(0x132))['value']=_0x322a13[_0x53ccfe(0x14e)][_0x53ccfe(0x1c2)],document['getElementById'](_0x53ccfe(0x20c))[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x14e)][_0x53ccfe(0x1cb)],toggleInjectionDetails(),document['getElementById'](_0x53ccfe(0xd5))[_0x53ccfe(0x1a4)]=_0x322a13[_0x53ccfe(0xea)][_0x53ccfe(0x199)],document['getElementById'](_0x53ccfe(0x22a))['value']=_0x322a13[_0x53ccfe(0xea)][_0x53ccfe(0x14c)],document[_0x53ccfe(0x1bf)]('hly-layer-end')[_0x53ccfe(0x146)]=_0x322a13['condensation']['layerEnd'],document[_0x53ccfe(0x1bf)]('hly-include-user')[_0x53ccfe(0x1a4)]=_0x322a13[_0x53ccfe(0xea)][_0x53ccfe(0x1a3)][_0x53ccfe(0x110)],document[_0x53ccfe(0x1bf)](_0x53ccfe(0x191))[_0x53ccfe(0x1a4)]=_0x322a13['condensation'][_0x53ccfe(0x1a3)]['ai'];const _0x57d9ce=document[_0x53ccfe(0x1bf)](_0x53ccfe(0x1eb)),_0x48f06a=document[_0x53ccfe(0x1bf)]('hly-tag-input'),_0x359330=document['getElementById'](_0x53ccfe(0x11f));_0x57d9ce[_0x53ccfe(0x1a4)]=_0x322a13[_0x53ccfe(0xea)]['tagExtractionEnabled'],_0x48f06a[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0xea)][_0x53ccfe(0x121)],_0x359330[_0x53ccfe(0x1de)][_0x53ccfe(0x204)]=_0x57d9ce[_0x53ccfe(0x1a4)]?_0x53ccfe(0x105):_0x53ccfe(0x215),document[_0x53ccfe(0x1bf)]('hly-rerank-enabled')[_0x53ccfe(0x1a4)]=_0x322a13[_0x53ccfe(0x147)]['enabled'],document[_0x53ccfe(0x1bf)]('hly-rerank-url')[_0x53ccfe(0x146)]=_0x322a13['rerank']['url'],document[_0x53ccfe(0x1bf)](_0x53ccfe(0x13a))[_0x53ccfe(0x146)]=_0x322a13[_0x53ccfe(0x147)][_0x53ccfe(0x1ce)];const _0x5a81ef=document['getElementById'](_0x53ccfe(0x134));if(_0x5a81ef[_0x53ccfe(0x1f0)][_0x53ccfe(0xe3)]===0x0){const _0x38a52f=_0x322a13[_0x53ccfe(0x147)][_0x53ccfe(0x11d)];if(_0x38a52f){const _0x352f00=new Option(_0x38a52f,_0x38a52f,!![],!![]);_0x5a81ef[_0x53ccfe(0x157)](_0x352f00);}}_0x5a81ef['value']=_0x322a13[_0x53ccfe(0x147)][_0x53ccfe(0x11d)],document[_0x53ccfe(0x1bf)](_0x53ccfe(0x201))['value']=_0x322a13[_0x53ccfe(0x147)][_0x53ccfe(0x180)],document['getElementById']('hly-rerank-hybrid-alpha')['value']=_0x322a13['rerank'][_0x53ccfe(0x183)],document['getElementById'](_0x53ccfe(0x10d))[_0x53ccfe(0x1a4)]=_0x322a13[_0x53ccfe(0x147)][_0x53ccfe(0x185)],toggleCustomEndpointDocket();}function saveSettingsFromUI(_0x1a629e=!![]){const _0x47879d=_0x34a9aa,_0x30a827=document[_0x47879d(0x1bf)]('hly-modal-container');if(!_0x30a827)return;const _0x52e951=_0x30a827[_0x47879d(0x1d0)]('[data-setting-key]');_0x52e951[_0x47879d(0x13d)](_0x53e076=>{const _0x126531=_0x47879d,_0x4d1123=_0x53e076[_0x126531(0x188)]['settingKey'];if(!_0x4d1123)return;let _0x12e2db;const _0x8d79a9=_0x53e076['dataset'][_0x126531(0x1a8)]||_0x126531(0x1c7);if(_0x53e076[_0x126531(0x1a8)]===_0x126531(0x1f5))_0x12e2db=_0x53e076[_0x126531(0x1a4)];else{if(_0x53e076[_0x126531(0x1a8)]==='radio'){if(!_0x53e076['checked'])return;_0x12e2db=_0x53e076['value'];}else _0x12e2db=_0x53e076[_0x126531(0x146)];}switch(_0x8d79a9){case _0x126531(0x1f6):_0x12e2db=parseInt(_0x12e2db,0xa);break;case _0x126531(0x218):_0x12e2db=parseFloat(_0x12e2db);break;case _0x126531(0x1e4):if(typeof _0x12e2db!==_0x126531(0x1e4))_0x12e2db=_0x12e2db===_0x126531(0x108);break;}const _0xa4699b=_0x1750b8[_0x126531(0x1e1)](),_0x4ee61f=_0x4d1123['split']('.');let _0x569222=_0xa4699b;for(let _0x2929a4=0x0;_0x2929a4<_0x4ee61f[_0x126531(0xe3)]-0x1;_0x2929a4++){_0x569222=_0x569222[_0x4ee61f[_0x2929a4]]=_0x569222[_0x4ee61f[_0x2929a4]]||{};}_0x569222[_0x4ee61f[_0x4ee61f[_0x126531(0xe3)]-0x1]]=_0x12e2db;}),_0x1750b8[_0x47879d(0x1a1)](),!_0x1a629e&&(log('【手动存档】所有设定已存档封印。',_0x47879d(0x1d3)),toastr['success'](_0x47879d(0x101),_0x47879d(0x197)));}function resetSettingsToUI(){const _0x1dd817=_0x34a9aa;confirm(_0x1dd817(0x1f4))&&(_0x1750b8['resetSettings'](),loadSettingsToUI(),toastr[_0x1dd817(0xdc)](_0x1dd817(0x1a9),'诏曰'));}async function updatePanelStatus(){const _0x25db05=_0x34a9aa,_0x488587=_0x1750b8['isSessionLocked'](),_0x18efd5=document['getElementById'](_0x25db05(0xf3)),_0x3ff3ca=document[_0x25db05(0x1bf)]('hly-current-chat-id');if(_0x488587){const _0x232c5f=_0x1750b8['getLockedSessionInfo']();_0x18efd5[_0x25db05(0x1ed)]=_0x25db05(0x159),_0x3ff3ca['textContent']=_0x232c5f['id'],_0x3ff3ca[_0x25db05(0x189)]=_0x25db05(0x228)+_0x232c5f['id'],_0x18efd5[_0x25db05(0x11b)]['add'](_0x25db05(0x208)),_0x3ff3ca[_0x25db05(0x11b)][_0x25db05(0x157)](_0x25db05(0x208));}else _0x18efd5[_0x25db05(0x1ed)]=_0x3e1193[_0x25db05(0x21e)](),_0x3ff3ca[_0x25db05(0x1ed)]=_0x3e1193[_0x25db05(0x19f)]()||'无',_0x3ff3ca['title']='',_0x18efd5[_0x25db05(0x11b)]['remove'](_0x25db05(0x208)),_0x3ff3ca[_0x25db05(0x11b)]['remove'](_0x25db05(0x208));const _0x5b8a63=document[_0x25db05(0x1bf)](_0x25db05(0x237));_0x5b8a63[_0x25db05(0x1ed)]=_0x25db05(0x1d7);try{const _0x5795ec=await _0x1750b8[_0x25db05(0x1ea)]();_0x5b8a63[_0x25db05(0x1ed)]=_0x5795ec;}catch(_0x5db4d0){console[_0x25db05(0x154)](_0x25db05(0x1b3),_0x5db4d0),_0x5b8a63[_0x25db05(0x1ed)]=_0x25db05(0x190),_0x5b8a63[_0x25db05(0x189)]='无法获取总数:\x20'+_0x5db4d0[_0x25db05(0x238)];}const _0x4d1e89=document[_0x25db05(0x1bf)](_0x25db05(0x15b));if(_0x4d1e89&&!_0x4d1e89['dataset'][_0x25db05(0x20d)]){const _0x1df04f=_0x1750b8['getSettings'](),_0xd9a31a=_0x1750b8['getCollectionId']();if(_0x1df04f[_0x25db05(0x193)]&&_0x1df04f[_0x25db05(0x193)][_0xd9a31a]){const _0x176b3f=_0x1df04f['condensationHistory'][_0xd9a31a];_0x4d1e89[_0x25db05(0x229)]='<p\x20class=\x22hly-record-hint\x22><i>上次已从第\x20'+_0x176b3f[_0x25db05(0xdb)]+_0x25db05(0x17b)+_0x176b3f['end']+_0x25db05(0x23c);}else _0x4d1e89[_0x25db05(0x229)]=_0x25db05(0x120);}}async function testApi(){const _0x33cac0=_0x34a9aa;toastr[_0x33cac0(0xdc)]('正在测试神力连接...','圣旨');try{await _0x1750b8[_0x33cac0(0x164)](),toastr[_0x33cac0(0x1d3)](_0x33cac0(0x19d),'圣意');}catch(_0xb41add){toastr['error'](_0x33cac0(0x107)+_0xb41add[_0x33cac0(0x238)],'警报');}}async function fetchHLYEmbeddingModels(){const _0x429a9f=_0x34a9aa,_0x5793c3=document[_0x429a9f(0x1bf)](_0x429a9f(0x1ec)),_0x1c1d07=_0x5793c3['value'];_0x5793c3['innerHTML']=_0x429a9f(0xe9),_0x5793c3[_0x429a9f(0x19e)]=!![];try{log(_0x429a9f(0x239),_0x429a9f(0xdc));const _0x11eb99=await _0x1750b8[_0x429a9f(0x1da)]();_0x5793c3[_0x429a9f(0x229)]='';if(_0x11eb99['length']===0x0){_0x5793c3[_0x429a9f(0x229)]='<option>未找到模型</option>',toastr[_0x429a9f(0xed)]('未能获取到任何模型。',_0x429a9f(0x11c)),log('未能获取到任何模型。','warn');return;}_0x11eb99['forEach'](_0xd8971a=>{const _0x5c907d=new Option(_0xd8971a,_0xd8971a);_0x5793c3['add'](_0x5c907d);}),_0x11eb99['includes'](_0x1c1d07)?_0x5793c3[_0x429a9f(0x146)]=_0x1c1d07:_0x5793c3[_0x429a9f(0x15f)]=0x0,toastr[_0x429a9f(0x1d3)](_0x429a9f(0x210)+_0x11eb99['length']+'\x20个模型。','圣意'),log(_0x429a9f(0x210)+_0x11eb99[_0x429a9f(0xe3)]+_0x429a9f(0x1f1),_0x429a9f(0x1d3));}catch(_0x5afd81){console[_0x429a9f(0x154)](_0x429a9f(0x184),_0x5afd81),toastr[_0x429a9f(0x154)](_0x429a9f(0x1af)+_0x5afd81[_0x429a9f(0x238)],_0x429a9f(0x125)),log(_0x429a9f(0x1af)+_0x5afd81['message'],_0x429a9f(0x154)),_0x5793c3[_0x429a9f(0x229)]=_0x429a9f(0x15e);}finally{_0x5793c3[_0x429a9f(0x19e)]=![];}}async function fetchHLYRerankModels(){const _0x339c0d=_0x34a9aa,_0x3edfd3=document[_0x339c0d(0x1bf)](_0x339c0d(0x134)),_0x589ece=_0x3edfd3[_0x339c0d(0x146)];_0x3edfd3[_0x339c0d(0x229)]=_0x339c0d(0xe9),_0x3edfd3[_0x339c0d(0x19e)]=!![];try{log(_0x339c0d(0x16f),_0x339c0d(0xdc));const _0x4b80ee=await _0x1750b8[_0x339c0d(0x168)]();_0x3edfd3['innerHTML']='';if(_0x4b80ee[_0x339c0d(0xe3)]===0x0){_0x3edfd3[_0x339c0d(0x229)]=_0x339c0d(0x141),toastr[_0x339c0d(0xed)](_0x339c0d(0x173),_0x339c0d(0x11c)),log(_0x339c0d(0x173),_0x339c0d(0xed));return;}_0x4b80ee['forEach'](_0x414326=>{const _0x4e70b5=new Option(_0x414326,_0x414326);_0x3edfd3['add'](_0x4e70b5);}),_0x4b80ee[_0x339c0d(0xeb)](_0x589ece)?_0x3edfd3[_0x339c0d(0x146)]=_0x589ece:_0x3edfd3[_0x339c0d(0x15f)]=0x0,toastr[_0x339c0d(0x1d3)]('成功获取\x20'+_0x4b80ee[_0x339c0d(0xe3)]+_0x339c0d(0x1fd),'圣意'),log(_0x339c0d(0x210)+_0x4b80ee[_0x339c0d(0xe3)]+_0x339c0d(0x1fd),_0x339c0d(0x1d3));}catch(_0x2318db){console['error'](_0x339c0d(0x205),_0x2318db),toastr['error'](_0x339c0d(0x1db)+_0x2318db[_0x339c0d(0x238)],_0x339c0d(0x125)),log('获取Rerank模型失败:\x20'+_0x2318db[_0x339c0d(0x238)],_0x339c0d(0x154)),_0x3edfd3[_0x339c0d(0x229)]=_0x339c0d(0x15e);}finally{_0x3edfd3[_0x339c0d(0x19e)]=![];}}async function purgeStorage(){const _0x3b7ea6=_0x34a9aa;if(confirm(_0x3b7ea6(0x230))){toastr[_0x3b7ea6(0xdc)](_0x3b7ea6(0xda),'圣旨');const _0x246a73=await _0x1750b8[_0x3b7ea6(0x17d)]();_0x246a73?toastr[_0x3b7ea6(0x1d3)]('宝库已清空。','圣意'):toastr[_0x3b7ea6(0x154)](_0x3b7ea6(0x16c),'警报'),await updatePanelStatus();}}async function startCondensation(){const _0x5076ea=_0x34a9aa,_0x37c567=document[_0x5076ea(0x1bf)]('hly-condensation-results'),_0x15e2a1=_0x37c567['dataset'][_0x5076ea(0x20d)],_0x14f74b=document[_0x5076ea(0x1bf)]('hly-layer-start')[_0x5076ea(0x146)],_0x5157cf=document[_0x5076ea(0x1bf)]('hly-layer-end')[_0x5076ea(0x146)],_0x26e650={'start':parseInt(_0x14f74b),'end':parseInt(_0x5157cf)};try{if(_0x15e2a1&&_0x15e2a1[_0x5076ea(0x14d)]()){log(_0x5076ea(0x20e),_0x5076ea(0xdc)),toastr[_0x5076ea(0xdc)](_0x5076ea(0x151),'圣旨'),_0x37c567['textContent']=_0x5076ea(0x214);const _0x22bc6c=await _0x1750b8['ingestTextToHanlinyuan'](_0x15e2a1,_0x5076ea(0x21d),_0x5076ea(0x231)+_0x26e650['start']+'-'+_0x26e650[_0x5076ea(0x1f2)],()=>{},null,log,()=>{},null,0x0,_0x26e650);if(_0x22bc6c[_0x5076ea(0x1d3)]){toastr[_0x5076ea(0x1d3)](_0x5076ea(0x179)+_0x22bc6c['count']+_0x5076ea(0x1cd),_0x5076ea(0x1cf)),log(_0x5076ea(0x181)+_0x22bc6c[_0x5076ea(0x12f)]+_0x5076ea(0x1cd),'success');const _0x341b60=_0x26e650['end']===0x0?getContext()[_0x5076ea(0x148)][_0x5076ea(0xe3)]:_0x26e650[_0x5076ea(0x1f2)];_0x37c567[_0x5076ea(0x1ed)]=_0x5076ea(0x15d)+_0x26e650[_0x5076ea(0xdb)]+'\x20楼到第\x20'+_0x341b60+'\x20楼已成功凝识新增\x20'+_0x22bc6c[_0x5076ea(0x12f)]+'\x20条忆识。',delete _0x37c567[_0x5076ea(0x188)][_0x5076ea(0x20d)];}else throw new Error(_0x22bc6c[_0x5076ea(0x154)]||_0x5076ea(0x216));}else{_0x37c567[_0x5076ea(0x1ed)]='正在采集消息...',toastr[_0x5076ea(0xdc)](_0x5076ea(0xe1),'圣旨'),log('未检测到预览文本,按标准流程采集消息...',_0x5076ea(0xdc));const _0xb1e147=_0x1750b8[_0x5076ea(0xd7)]();if(!_0xb1e147||_0xb1e147[_0x5076ea(0xe3)]===0x0){toastr[_0x5076ea(0x17e)](_0x5076ea(0x1a6),_0x5076ea(0x11c)),_0x37c567[_0x5076ea(0x1ed)]=_0x5076ea(0xe4);return;}_0x37c567[_0x5076ea(0x1ed)]=_0x5076ea(0xfc)+_0xb1e147[_0x5076ea(0xe3)]+_0x5076ea(0xdd),toastr[_0x5076ea(0xdc)](_0x5076ea(0xfc)+_0xb1e147[_0x5076ea(0xe3)]+'\x20条消息开始凝识...','翰林院启奏');const _0x3385e1=await _0x1750b8[_0x5076ea(0x1e5)](_0xb1e147,log,_0x26e650);if(_0x3385e1[_0x5076ea(0x1d3)]){toastr[_0x5076ea(0x1d3)](_0x5076ea(0x1ac)+_0x3385e1[_0x5076ea(0x12f)]+_0x5076ea(0x1cd),_0x5076ea(0x1cf));const _0x23075a=_0x26e650['end']===0x0?getContext()[_0x5076ea(0x148)][_0x5076ea(0xe3)]:_0x26e650[_0x5076ea(0x1f2)];_0x37c567[_0x5076ea(0x1ed)]=_0x5076ea(0x15d)+_0x26e650[_0x5076ea(0xdb)]+_0x5076ea(0x111)+_0x23075a+_0x5076ea(0x23e)+_0x3385e1['count']+_0x5076ea(0x1cd);}else throw new Error(_0x3385e1['error']||_0x5076ea(0x216));}}catch(_0x21b87f){console[_0x5076ea(0x154)](_0x5076ea(0x155),_0x21b87f),toastr['error']('凝识失败:\x20'+_0x21b87f['message'],_0x5076ea(0x125)),_0x37c567[_0x5076ea(0x1ed)]='凝识失败:\x20'+_0x21b87f['message'];}finally{await updatePanelStatus();}}async function loadWorldbookList(){const _0x308526=_0x34a9aa,_0x16947e=document[_0x308526(0x1bf)](_0x308526(0xf1));if(!_0x16947e)return;try{log('正在获取可用书库列表...','info');const _0x5d3d82=await _0x41ee77['getAvailableWorldbooks']();_0x16947e['innerHTML']=_0x308526(0x16b);if(_0x5d3d82['length']===0x0){_0x16947e['innerHTML']=_0x308526(0x211);return;}_0x5d3d82[_0x308526(0x13d)](_0x370e3d=>{const _0x20c0a1=_0x308526,_0x17fcf3=new Option(_0x370e3d,_0x370e3d);_0x16947e[_0x20c0a1(0x157)](_0x17fcf3);}),log(_0x308526(0x137)+_0x5d3d82[_0x308526(0xe3)]+_0x308526(0x106),_0x308526(0x1d3));}catch(_0x4dc907){console[_0x308526(0x154)](_0x308526(0x12d),_0x4dc907),log('加载书库列表失败:\x20'+_0x4dc907[_0x308526(0x238)],_0x308526(0x154)),_0x16947e[_0x308526(0x229)]=_0x308526(0x1fa);}}async function handleWorldbookSelectionChange(){const _0x209036=_0x34a9aa,_0x316f79=document[_0x209036(0x1bf)](_0x209036(0xf1)),_0x56d907=document[_0x209036(0x1bf)](_0x209036(0x227)),_0x4fe0df=_0x316f79['value'];_0x56d907[_0x209036(0x229)]=_0x209036(0x1ca),_0x56d907[_0x209036(0x19e)]=!![];if(!_0x4fe0df){_0x56d907[_0x209036(0x229)]=_0x209036(0x153);return;}try{log('正在为《'+_0x4fe0df+_0x209036(0x23a),'info');const _0x41b598=await _0x41ee77[_0x209036(0x1bd)](_0x4fe0df);_0x56d907[_0x209036(0x229)]=_0x209036(0x1d2);if(_0x41b598[_0x209036(0xe3)]===0x0){_0x56d907['innerHTML']=_0x209036(0x202);return;}_0x41b598[_0x209036(0x13d)](_0x1658a6=>{const _0x2a2a68=_0x209036,_0x255ebb=new Option(_0x1658a6[_0x2a2a68(0x149)]+_0x2a2a68(0x10e)+_0x1658a6[_0x2a2a68(0x235)]+')',_0x1658a6[_0x2a2a68(0x235)]);_0x56d907[_0x2a2a68(0x157)](_0x255ebb);}),log(_0x209036(0x137)+_0x41b598[_0x209036(0xe3)]+_0x209036(0x22b),_0x209036(0x1d3));}catch(_0x5cd36d){console[_0x209036(0x154)](_0x209036(0x103)+_0x4fe0df+'》的条目失败:',_0x5cd36d),log(_0x209036(0x136)+_0x5cd36d[_0x209036(0x238)],_0x209036(0x154)),_0x56d907[_0x209036(0x229)]='<option\x20value=\x22\x22>加载失败</option>';}finally{_0x56d907['disabled']=![];}}async function startHistoriography(){const _0x2fca0c=_0x34a9aa,_0x4f8ef6=document['getElementById'](_0x2fca0c(0xf1))[_0x2fca0c(0x146)],_0x44af13=document['getElementById'](_0x2fca0c(0x227))[_0x2fca0c(0x146)],_0x2e02ba=document[_0x2fca0c(0x1bf)]('hly-historiography-results');if(!_0x4f8ef6||!_0x44af13){toastr[_0x2fca0c(0x17e)](_0x2fca0c(0x12a),_0x2fca0c(0x18a));return;}_0x2e02ba['textContent']=_0x2fca0c(0xfd)+_0x4f8ef6+_0x2fca0c(0x20a)+_0x44af13+_0x2fca0c(0x117),toastr[_0x2fca0c(0xdc)](_0x2fca0c(0x17f),'圣旨'),log(_0x2fca0c(0x1c1)+_0x4f8ef6+'》-'+_0x44af13+_0x2fca0c(0x22c),_0x2fca0c(0xdc));try{const _0xbc959b=await _0x41ee77[_0x2fca0c(0x1e9)](_0x4f8ef6,_0x44af13);if(_0xbc959b[_0x2fca0c(0x1d3)]){const _0x2dca18=document[_0x2fca0c(0x1bf)](_0x2fca0c(0x227)),_0x59804f=_0x2dca18[_0x2fca0c(0x1f0)][_0x2dca18['selectedIndex']]['text'],_0x678382='《'+_0x4f8ef6+'》中的条目【'+_0x59804f+_0x2fca0c(0x207);_0x2e02ba[_0x2fca0c(0x1ed)]=_0x678382,toastr['success'](_0x2fca0c(0x1d4),'大功告成'),log('对《'+_0x4f8ef6+_0x2fca0c(0x171)+_0x44af13+')\x20的编纂任务已完成。',_0x2fca0c(0x1d3));}else throw new Error(_0xbc959b['error']||_0x2fca0c(0x150));}catch(_0x50d411){console[_0x2fca0c(0x154)](_0x2fca0c(0x158),_0x50d411),toastr[_0x2fca0c(0x154)](_0x2fca0c(0x119)+_0x50d411[_0x2fca0c(0x238)],_0x2fca0c(0x125)),_0x2e02ba['textContent']=_0x2fca0c(0x119)+_0x50d411[_0x2fca0c(0x238)];}}async function showStats(){const _0x1ae9d9=_0x34a9aa;try{log(_0x1ae9d9(0x129),_0x1ae9d9(0xdc)),toastr[_0x1ae9d9(0xdc)](_0x1ae9d9(0x1ba),'圣旨');const _0x57c968=await _0x1750b8[_0x1ae9d9(0x1ea)](),_0x5a3649=_0x1750b8[_0x1ae9d9(0x112)](),_0x3cf900=_0x1750b8['getSettings'](),_0x301d08=_0x1ae9d9(0x186)+_0x5a3649+_0x1ae9d9(0x1d6)+_0x57c968+'\x0a--------------------\x0aAPI端点:\x20'+_0x3cf900['retrieval'][_0x1ae9d9(0x19b)]+'\x0a所用模型:\x20'+_0x3cf900[_0x1ae9d9(0x224)][_0x1ae9d9(0x1b9)]+'\x0a</pre>\x0a\x20\x20\x20\x20\x20\x20\x20\x20';toastr[_0x1ae9d9(0xdc)](_0x301d08,'宝库状态',{'timeOut':0x3a98,'extendedTimeOut':0x1388,'tapToDismiss':!![],'closeButton':!![]}),log(_0x1ae9d9(0x182)+_0x5a3649+_0x1ae9d9(0x21b)+_0x57c968,'success');}catch(_0x1f3586){console[_0x1ae9d9(0x154)]('[翰林院-枢纽]\x20查询宝库状态失败:',_0x1f3586),toastr['error'](_0x1ae9d9(0x177)+_0x1f3586[_0x1ae9d9(0x238)],'严重错误'),log(_0x1ae9d9(0x177)+_0x1f3586[_0x1ae9d9(0x238)],_0x1ae9d9(0x154));}}function showExclusionRulesModal(){const _0x209f78=_0x34a9aa,_0x492ca8=_0x1750b8[_0x209f78(0x1e1)](),_0x4fd468=_0x492ca8['condensation'][_0x209f78(0x1a0)]||[],_0x26d5a6=(_0x261144={'start':'','end':''},_0x3aa8c9)=>_0x209f78(0x1e7)+_0x3aa8c9+_0x209f78(0xf0)+_0x261144[_0x209f78(0xdb)]+_0x209f78(0x176)+_0x261144['end']+'\x22\x20placeholder=\x22结束字符,\x20如\x20-->\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<button\x20class=\x22hly-delete-rule-btn\x22\x20title=\x22删除此规则\x22>&times;</button>\x0a\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20',_0x4e1d58=_0x4fd468[_0x209f78(0x1b5)](_0x26d5a6)[_0x209f78(0x145)](''),_0x356969=_0x209f78(0x1f3)+_0x4e1d58+'</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<button\x20id=\x22hly-add-rule-btn\x22\x20class=\x22hly-action-button\x22\x20style=\x22margin-top:\x2010px;\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<i\x20class=\x22fas\x20fa-plus\x22></i>\x20添加新规则\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</button>\x0a\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<style>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.hly-exclusion-rule-row\x20{\x20display:\x20flex;\x20align-items:\x20center;\x20gap:\x2010px;\x20margin-bottom:\x2010px;\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.hly-exclusion-rule-row\x20input\x20{\x20flex-grow:\x201;\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.hly-delete-rule-btn\x20{\x20background:\x20#c0392b;\x20color:\x20white;\x20border:\x20none;\x20border-radius:\x2050%;\x20width:\x2024px;\x20height:\x2024px;\x20cursor:\x20pointer;\x20font-size:\x2016px;\x20line-height:\x2024px;\x20text-align:\x20center;\x20padding:\x200;\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20</style>\x0a\x20\x20\x20\x20';showHtmlModal('编辑内容排除规则',_0x356969,{'okText':'保存规则','onOk':_0x459df0=>{const _0x3d108e=_0x209f78,_0xb478db=[];_0x459df0['find'](_0x3d108e(0xd4))[_0x3d108e(0x102)](function(){const _0x53f4fc=_0x3d108e,_0x453b55=$(this)[_0x53f4fc(0x1c0)](_0x53f4fc(0x131))['eq'](0x0)[_0x53f4fc(0xd3)]()[_0x53f4fc(0x14d)](),_0x1a1d51=$(this)[_0x53f4fc(0x1c0)]('input')['eq'](0x1)['val']()[_0x53f4fc(0x14d)]();_0x453b55&&_0x1a1d51&&_0xb478db[_0x53f4fc(0x1c8)]({'start':_0x453b55,'end':_0x1a1d51});}),updateAndSaveSetting('condensation.exclusionRules',_0xb478db),toastr[_0x3d108e(0x1d3)](_0x3d108e(0x213),_0x3d108e(0x197));}});const _0x24abb7=document[_0x209f78(0x1bf)]('hly-exclusion-rules-container'),_0x2a5308=_0x24abb7[_0x209f78(0x115)](_0x209f78(0x143));_0x24abb7[_0x209f78(0x115)](_0x209f78(0x13e))[_0x209f78(0x1b0)]('click',()=>{const _0xdd662=_0x209f78,_0x4e5237=_0x2a5308[_0xdd662(0x170)][_0xdd662(0xe3)],_0x5e5439=_0x26d5a6({'start':'','end':''},_0x4e5237);_0x2a5308['insertAdjacentHTML'](_0xdd662(0x1ae),_0x5e5439);}),_0x2a5308['addEventListener'](_0x209f78(0x18e),_0x46cad4=>{const _0x178666=_0x209f78;_0x46cad4['target']['classList'][_0x178666(0xfa)]('hly-delete-rule-btn')&&_0x46cad4[_0x178666(0x104)][_0x178666(0x194)](_0x178666(0xd4))[_0x178666(0xf4)]();});}function previewCondensation(){const _0x314d8d=_0x34a9aa,_0x148943=document['getElementById'](_0x314d8d(0x15b));try{const _0x21757a=_0x1750b8[_0x314d8d(0x1e1)](),_0x45b768=_0x21757a[_0x314d8d(0xea)]['exclusionRules']||[],_0x287f06={'user':document[_0x314d8d(0x1bf)]('hly-include-user')['checked'],'ai':document['getElementById'](_0x314d8d(0x191))['checked']},_0x50d2f2=document[_0x314d8d(0x1bf)]('hly-tag-extraction-toggle')['checked'],_0x41abcc=_0x50d2f2?document['getElementById'](_0x314d8d(0x1b4))[_0x314d8d(0x146)][_0x314d8d(0x11e)](',')['map'](_0x474c6b=>_0x474c6b[_0x314d8d(0x14d)]())[_0x314d8d(0x1ab)](Boolean):[],_0x13a751=_0x1750b8[_0x314d8d(0xd7)](_0x287f06);if(!_0x13a751||_0x13a751[_0x314d8d(0xe3)]===0x0){_0x148943[_0x314d8d(0x1ed)]=_0x314d8d(0x225),toastr[_0x314d8d(0x17e)](_0x314d8d(0xe4),_0x314d8d(0x11c));return;}const _0x37e283=_0x13a751[_0x314d8d(0x1b5)]((_0x2c7586,_0x1cc6aa)=>{const _0x335b95=_0x314d8d;let _0x1b9c7d;if(_0x2c7586[_0x335b95(0x12c)])_0x1b9c7d=_0x2c7586[_0x335b95(0x160)];else{if(_0x50d2f2&&_0x41abcc['length']>0x0){const _0x233549=extractBlocksByTags(_0x2c7586[_0x335b95(0x160)],_0x41abcc);_0x1b9c7d=_0x233549[_0x335b95(0x145)]('\x0a\x0a');}else _0x1b9c7d=_0x2c7586[_0x335b95(0x160)];_0x1b9c7d=applyExclusionRules(_0x1b9c7d,_0x45b768);}return{'id':_0x335b95(0x139)+_0x1cc6aa,'name':_0x2c7586[_0x335b95(0xef)],'content':_0x1b9c7d[_0x335b95(0x14d)]()};})[_0x314d8d(0x1ab)](_0x6c0b1b=>_0x6c0b1b['content']);if(_0x37e283['length']===0x0){_0x148943['textContent']='根据标签提取或内容排除条件,未找到任何有效内容。',toastr[_0x314d8d(0x17e)](_0x314d8d(0x209),_0x314d8d(0x11c));return;}const _0x35e20c=_0x37e283[_0x314d8d(0x1b5)]((_0x2d878c,_0x1f15b7)=>'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22hly-preview-item-v2\x22\x20id=\x22'+_0x2d878c['id']+'\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<details\x20class=\x22hly-preview-details\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<summary\x20class=\x22hly-preview-summary\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20第\x20'+(_0x1f15b7+0x1)+_0x314d8d(0x1f9)+_0x2d878c['name']+_0x314d8d(0x118)+_0x2d878c[_0x314d8d(0x1e8)]+'</textarea>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</details>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<button\x20class=\x22hly-preview-delete-btn-v2\x22\x20data-target=\x22'+_0x2d878c['id']+_0x314d8d(0x217))[_0x314d8d(0x145)]('');showHtmlModal(_0x314d8d(0x1d9),_0x314d8d(0xde)+_0x35e20c+_0x314d8d(0x20b),{'okText':_0x314d8d(0x198),'onOk':_0x41e1e8=>{const _0x28c145=_0x314d8d,_0x812433=[];_0x41e1e8[_0x28c145(0x1c0)](_0x28c145(0x1c3))[_0x28c145(0x102)](function(){const _0x43b049=_0x28c145,_0x3c6f09=$(this)[_0x43b049(0x1c0)]('.hly-preview-textarea')['val']();_0x3c6f09[_0x43b049(0x14d)]()&&_0x812433['push'](_0x3c6f09);});const _0x20eeb4=_0x812433[_0x28c145(0x145)](_0x28c145(0x162)),_0x5f28dc=document[_0x28c145(0x1bf)](_0x28c145(0x22a))[_0x28c145(0x146)],_0x2ad06b=document[_0x28c145(0x1bf)](_0x28c145(0x1e2))[_0x28c145(0x146)];_0x148943[_0x28c145(0x1ed)]=_0x28c145(0xdf)+_0x5f28dc+'\x20楼到\x20'+_0x2ad06b+'\x20楼的内容共\x20'+_0x812433[_0x28c145(0xe3)]+_0x28c145(0x13b),_0x148943[_0x28c145(0x188)][_0x28c145(0x20d)]=_0x20eeb4,toastr[_0x28c145(0x1d3)](_0x28c145(0x226),_0x28c145(0x197));}}),$(_0x314d8d(0x19a))['on'](_0x314d8d(0x18e),function(_0x5d6578){const _0x3ab938=_0x314d8d;_0x5d6578[_0x3ab938(0xe5)]();const _0x52045f=$(this)['data'](_0x3ab938(0x104));$('#'+_0x52045f)[_0x3ab938(0xf4)]();});}catch(_0x509b60){console['error'](_0x314d8d(0x10f),_0x509b60),_0x148943[_0x314d8d(0x1ed)]=_0x314d8d(0x135)+_0x509b60[_0x314d8d(0x238)],toastr['error'](_0x314d8d(0x135)+_0x509b60['message'],_0x314d8d(0x125));}}function log(_0x1a055c,_0x429d02=_0x34a9aa(0xdc)){const _0x5507be=_0x34a9aa,_0x4bc8a2=document[_0x5507be(0x1bf)](_0x5507be(0x1bc));if(!_0x4bc8a2)return;const _0x760fde=document[_0x5507be(0x1ee)]('p'),_0x3095c7=new Date()[_0x5507be(0xec)]();let _0x35beba=_0x5507be(0x122),_0x28908a=_0x5507be(0x13c);switch(_0x429d02){case _0x5507be(0x1d3):_0x35beba=_0x5507be(0x195),_0x28908a='log-success';break;case'error':_0x35beba=_0x5507be(0x1a2),_0x28908a=_0x5507be(0x1d8);break;case _0x5507be(0xed):_0x35beba=_0x5507be(0x161),_0x28908a=_0x5507be(0x167);break;}_0x760fde[_0x5507be(0x21f)]=_0x5507be(0x1be)+_0x28908a,_0x760fde['innerHTML']=_0x5507be(0x16a)+_0x35beba+_0x5507be(0x1b6)+_0x3095c7+']\x20'+_0x1a055c;const _0x207b33=_0x4bc8a2[_0x5507be(0x115)](_0x5507be(0xfb));_0x207b33&&_0x207b33[_0x5507be(0xf4)](),_0x4bc8a2[_0x5507be(0x1dc)](_0x760fde),_0x4bc8a2[_0x5507be(0x1dd)]=_0x4bc8a2[_0x5507be(0x1c6)];}async function ingestManualText(){const _0xb75136=_0x34a9aa,_0x48eaa0=document[_0xb75136(0x1bf)](_0xb75136(0x116)),_0x427ac7=_0x48eaa0['value'][_0xb75136(0x14d)]();if(!_0x427ac7){toastr['warning'](_0xb75136(0x1d1),_0xb75136(0x11c)),log(_0xb75136(0xd6),_0xb75136(0xed));return;}log(_0xb75136(0x19c)+_0x427ac7[_0xb75136(0xe3)],_0xb75136(0xdc)),toastr[_0xb75136(0xdc)](_0xb75136(0x11a),'圣旨');try{const _0x27aeee=await _0x1750b8['ingestTextToHanlinyuan'](_0x427ac7,_0xb75136(0x232),_0xb75136(0x12e));if(_0x27aeee[_0xb75136(0x1d3)])toastr[_0xb75136(0x1d3)](_0xb75136(0x179)+_0x27aeee[_0xb75136(0x12f)]+_0xb75136(0x1cd),_0xb75136(0x1cf)),log(_0xb75136(0x14a)+_0x27aeee[_0xb75136(0x12f)]+_0xb75136(0x1cd),_0xb75136(0x1d3)),_0x48eaa0[_0xb75136(0x146)]='';else throw new Error(_0x27aeee[_0xb75136(0x154)]||'未知错误');}catch(_0x5eda10){console[_0xb75136(0x154)](_0xb75136(0xf2),_0x5eda10),toastr[_0xb75136(0x154)](_0xb75136(0x18c)+_0x5eda10[_0xb75136(0x238)],_0xb75136(0x125)),log(_0xb75136(0x126)+_0x5eda10[_0xb75136(0x238)],_0xb75136(0x154));}finally{await updatePanelStatus();}}