From 8cadf5ad2229b2686669d6488794157c8e3cbd0a Mon Sep 17 00:00:00 2001 From: Wx-2025 <351320169@qq.com> Date: Wed, 3 Sep 2025 12:38:37 +0800 Subject: [PATCH] Update cwb_uiManager.js --- CharacterWorldBook/src/cwb_uiManager.js | 560 +----------------------- 1 file changed, 1 insertion(+), 559 deletions(-) diff --git a/CharacterWorldBook/src/cwb_uiManager.js b/CharacterWorldBook/src/cwb_uiManager.js index ce14d5e..772a2d2 100644 --- a/CharacterWorldBook/src/cwb_uiManager.js +++ b/CharacterWorldBook/src/cwb_uiManager.js @@ -1,559 +1 @@ -import { SCRIPT_ID_PREFIX, CHAR_CARD_VIEWER_BUTTON_ID, CHAR_CARD_VIEWER_POPUP_ID, state } from './cwb_state.js'; -import { logDebug, logError, showToastr, escapeHtml, parseCustomFormat, buildCustomFormat, isCwbEnabled } from './cwb_utils.js'; -import { deleteLorebookEntries, getTargetWorldBook } from './cwb_lorebookManager.js'; -import { manualUpdateLogic } from './cwb_core.js'; - -const { jQuery: $, SillyTavern, TavernHelper } = window; - -function createCharCardViewerPopupHtml(displayItems) { - const pathToLabelMap = { - 'narrative_essence.core_traits.name': '特质名称', - 'narrative_essence.key_relationships.name': '关系人姓名', - }; - const keyToLabelMap = { - 'name': '姓名', - 'archetype': '身份原型', - 'gender': '性别', - 'age': '年龄', - 'race': '种族', - 'current_status': '当前状态', - - 'first_impression': '第一印象', - 'key_features': '显著特征', - 'attire': '衣着风格', - 'mannerisms': '习惯举止', - 'voice': '声音特征', - - 'tags': '性格标签', - 'description': '性格详述', - 'motivation': '内在驱动', - 'values': '价值观', - 'inner_conflict': '内心挣扎', - - 'interaction_style': '互动风格', - 'skills': '技能能力', - 'reputation': '他人声望', - - 'core_traits': '核心特质', - 'verbal_patterns': '语言范式', - 'key_relationships': '关键关系', - 'definition': '特质定义', - 'evidence': '具体事例', - 'style_summary': '风格总结', - 'quotes': '代表性引言', - 'summary': '关系概述', - }; - const getLabel = (key, path) => { - const pathKey = path.replace(/\.\d+\./g, '.'); - if (pathToLabelMap[pathKey]) { - return pathToLabelMap[pathKey]; - } - return keyToLabelMap[key] || key.replace(/_/g, ' '); - }; - - const renderField = (label, path, value, isTextarea = false, isArray = false) => { - const escapedLabel = escapeHtml(label); - const escapedValue = escapeHtml(isArray ? value.join('\n') : value || ''); - - const isLongContent = (value && String(value).length > 50) || (Array.isArray(value) && value.length > 1); - const rows = isArray ? Math.max(3, value.length) : (isLongContent ? 4 : 2); - - const inputElement = ``; - - return `
- - ${inputElement} -
`; - }; - - const renderCard = (title, data, pathPrefix) => { - if (!data || typeof data !== 'object' || Object.keys(data).length === 0) return ''; - let cardHtml = `

${escapeHtml(title)}

`; - for (const [key, value] of Object.entries(data)) { - const currentPath = pathPrefix ? `${pathPrefix}.${key}` : key; - const label = getLabel(key, currentPath); - if (typeof value === 'object' && value !== null && !Array.isArray(value)) { - cardHtml += renderCard(label, value, currentPath); // Recursive call for nested objects - } else if (Array.isArray(value) && value.length > 0 && typeof value[0] === 'object') { - cardHtml += `
${escapeHtml(label)}
`; - value.forEach((item, itemIndex) => { - cardHtml += `
`; - for (const [itemKey, itemValue] of Object.entries(item)) { - const itemPath = `${currentPath}.${itemIndex}.${itemKey}`; - cardHtml += renderField(getLabel(itemKey, itemPath), itemPath, itemValue, false, Array.isArray(itemValue)); - } - cardHtml += `
`; - }); - cardHtml += `
`; - } else { - cardHtml += renderField(label, currentPath, value, false, Array.isArray(value)); - } - } - cardHtml += `
`; - return cardHtml; - }; - - let html = `
`; - html += `
-

角色数据核心

-
- - - - -
-
`; - - if (!displayItems || displayItems.length === 0) { - html += `

数据链路中断...未在当前世界书协议中找到角色数据。请执行一次手动更新以初始化链接。

`; - return html; - } - - html += `
`; - html += `
`; - displayItems.forEach((item, index) => { - const itemName = item.isRoster ? '人物总览' : (item.parsed?.name || `未知实体 ${index + 1}`); - const wrapperClass = index === 0 ? 'cwb-cyber-tab active' : 'cwb-cyber-tab'; - html += `
- - -
`; - }); - html += `
`; - - html += `
`; - displayItems.forEach((item, index) => { - html += `
`; - if (item.isRoster) { - html += `
-

人物总览 (只读)

-
- -
-
`; - } else { - const charData = item.parsed; - if (charData) { - const charName = charData.name || `角色 ${index + 1}`; - if (charData.name) html += renderCard('姓名', { name: charData.name }, ''); - if (charData.core_identity) html += renderCard('核心认同', charData.core_identity, 'core_identity'); - if (charData.physical_imprint) html += renderCard('物理印记', charData.physical_imprint, 'physical_imprint'); - if (charData.psyche_profile) html += renderCard('心智侧写', charData.psyche_profile, 'psyche_profile'); - if (charData.social_matrix) html += renderCard('社交矩阵', charData.social_matrix, 'social_matrix'); - if (charData.narrative_essence) html += renderCard('叙事精粹', charData.narrative_essence, 'narrative_essence'); - - html += `
-

注入设置

-
-
- - -
-
- - -
-
- - -
-
-
`; - - html += ``; - } - } - html += `
`; - }); - html += `
`; - return html; -} - -function bindCharCardViewerPopupEvents($popup) { - $popup.on('change', '.cwb-insertion-position', function() { - const $this = $(this); - const $depthContainer = $this.closest('.cwb-insertion-settings-content').find('.cwb-insertion-depth-container'); - if ($this.val() === 'at_depth') { - $depthContainer.show(); - } else { - $depthContainer.hide(); - } - }); - - $popup.on('click', '.cwb-viewer-popup-close-button', closeCharCardViewerPopup); - $popup.find('#cwb-viewer-refresh').on('click', () => { - showToastr('info', '正在刷新角色数据...'); - showCharCardViewerPopup(); - }); - - $popup.find('#cwb-manual-update-btn').on('click', async function() { - const $button = $(this); - $button.prop('disabled', true).html(' 更新中...'); - await manualUpdateLogic(); - showToastr('info', '更新完成,正在刷新查看器...'); - showCharCardViewerPopup(); - }); - - $popup.find('.cwb-cyber-tab__button').on('click', function () { - const $this = $(this); - const targetUid = $this.data('char-uid'); - $popup.find('.cwb-cyber-tab').removeClass('active'); - $this.closest('.cwb-cyber-tab').addClass('active'); - $popup.find('.cwb-cyber-content-pane').removeClass('active'); - $popup.find(`#cwb-char-content-${targetUid}`).addClass('active'); - }); - - $popup.find('.cwb-cyber-tab__delete').on('click', async function(e) { - e.stopPropagation(); - const uidToDelete = $(this).data('char-uid'); - await deleteLorebookEntries([uidToDelete]); - const $wrapper = $(this).closest('.cwb-cyber-tab'); - const $pane = $popup.find(`#cwb-char-content-${uidToDelete}`); - const wasActive = $wrapper.hasClass('active'); - $wrapper.remove(); - $pane.remove(); - if (wasActive && $popup.find('.cwb-cyber-tab').length > 0) { - $popup.find('.cwb-cyber-tab').first().find('.cwb-cyber-tab__button').trigger('click'); - } else if ($popup.find('.cwb-cyber-tab').length === 0) { - showCharCardViewerPopup(); - } - }); - - $popup.find('#cwb-viewer-delete-all').on('click', async function() { - const allUids = $popup.find('.cwb-cyber-tab__button').map(function() { - return $(this).data('char-uid'); - }).get(); - if (allUids.length > 0) { - await deleteLorebookEntries(allUids); - } - showCharCardViewerPopup(); - }); - - $popup.find('.cwb-save-button').on('click', async function () { - const $button = $(this); - const targetUid = $button.data('uid'); - $button.prop('disabled', true).html(' 保存中...'); - try { - const book = await getTargetWorldBook(); - if (!book) throw new Error('未找到目标世界书。'); - const $activePane = $popup.find(`#cwb-char-content-${targetUid}`); - const collectedData = {}; - const setNestedValue = (obj, path, value) => { - const keys = path.split('.'); - let current = obj; - keys.forEach((key, index) => { - if (index === keys.length - 1) { - current[key] = value === '' ? null : value; - } else { - const nextKeyIsNumber = /^\d+$/.test(keys[index + 1]); - if (!current[key]) { - current[key] = nextKeyIsNumber ? [] : {}; - } - current = current[key]; - } - }); - }; - $activePane.find('.cwb-cyber-field__input').each(function () { - const $field = $(this); - const path = $field.data('path'); - let value = $field.val(); - if ($field.data('is-array')) { - value = value.split('\n').map(l => l.trim()).filter(Boolean); - } - if(path){ - setNestedValue(collectedData, path, value); - } - }); - const finalContentToSave = buildCustomFormat(collectedData); - const allEntries = await TavernHelper.getLorebookEntries(book); - const entryToUpdate = allEntries.find(e => e.uid === targetUid); - if (!entryToUpdate) throw new Error('无法在世界书中找到原始条目。'); - - const insertionPosition = $activePane.find('.cwb-insertion-position').val(); - const insertionDepth = parseInt($activePane.find('.cwb-insertion-depth').val(), 10); - const insertionOrder = parseInt($activePane.find('.cwb-insertion-order').val(), 10); - - logDebug(`[DEBUG] 界面收集值 UID:${targetUid}`, { - insertionPosition: insertionPosition, - insertionDepth: insertionDepth, - insertionOrder: insertionOrder - }); - - const positionMap = { - 'before_char': 'before_character_definition', - 'after_char': 'after_character_definition', - 'before_an': 'before_author_note', - 'after_an': 'after_author_note', - 'at_depth': 'at_depth_as_system' - }; - - const finalEntryData = { ...entryToUpdate }; - - finalEntryData.content = finalContentToSave; - finalEntryData.uid = targetUid; - - const newPosition = positionMap[insertionPosition]; - finalEntryData.position = newPosition || 'before_character_definition'; - if (insertionPosition === 'at_depth') { - finalEntryData.depth = isNaN(insertionDepth) ? 0 : insertionDepth; - } else { - finalEntryData.depth = null; - } - - finalEntryData.order = isNaN(insertionOrder) ? 7001 : insertionOrder; - - logDebug(`[DEBUG] 最终保存数据 UID:${targetUid}`, { - position: finalEntryData.position, - depth: finalEntryData.depth, - order: finalEntryData.order, - hasDepthField: 'depth' in finalEntryData - }); - - await TavernHelper.setLorebookEntries(book, [finalEntryData]); - showToastr('success', '角色卡已成功保存!'); - } catch (error) { - logError('保存角色卡失败:', error); - showToastr('error', `保存失败: ${error.message}`); - } finally { - $button.prop('disabled', false).text(`保存修改`); - } - }); -} - -function closeCharCardViewerPopup() { - $(`#${CHAR_CARD_VIEWER_POPUP_ID}`).remove(); -} - -export async function showCharCardViewerPopup() { - if (!isCwbEnabled()) return; - closeCharCardViewerPopup(); - try { - const book = await getTargetWorldBook(); - if (!book) { - showToastr('warning', '当前角色未设置主世界书或自定义世界书。'); - $('body').append(createCharCardViewerPopupHtml([])); - bindCharCardViewerPopupEvents($(`#${CHAR_CARD_VIEWER_POPUP_ID}`)); - return; - } - const allEntries = await TavernHelper.getLorebookEntries(book); - let currentChatId = state.currentChatFileIdentifier; - - if (!currentChatId || currentChatId.startsWith('unknown_chat')) { - logError(`Invalid chat identifier "${currentChatId}" for viewer.`); - $('body').append(createCharCardViewerPopupHtml([])); - bindCharCardViewerPopupEvents($(`#${CHAR_CARD_VIEWER_POPUP_ID}`)); - return; - } - - const cleanChatId = currentChatId.replace(/ imported/g, ''); - let displayItems = []; - - let relevantEntries; - if (state.worldbookTarget === 'custom' && state.customWorldBook) { - relevantEntries = allEntries.filter(entry => { - if (!entry.enabled || !Array.isArray(entry.keys)) return false; - if (entry.keys.includes('Amily2角色总集') || entry.keys.includes('角色总览')) return true; - if (entry.content) { - try { - const parsed = parseCustomFormat(entry.content); - return parsed && Object.keys(parsed).length > 0; - } catch (e) { - return false; - } - } - - return false; - }); - } else { - relevantEntries = allEntries.filter(entry => - entry.enabled && - Array.isArray(entry.keys) && - entry.keys.includes(cleanChatId) - ); - } - - const rosterEntries = relevantEntries.filter(entry => - entry.keys.includes('Amily2角色总集') && entry.keys.includes('角色总览') - ); - - rosterEntries.forEach((entry, index) => { - displayItems.push({ - uid: entry.uid, - isRoster: true, - comment: entry.comment, - content: entry.content, - rosterIndex: index - }); - }); - - const characterEntries = relevantEntries - .filter(entry => !entry.keys.includes('Amily2角色总集')) - .map(entry => { - logDebug(`[DEBUG] 原始条目数据 UID:${entry.uid}`, { - position: entry.position, - depth: entry.depth, - order: entry.order, - comment: entry.comment - }); - - const positionStringMap = { - 0: 'before_char', - 1: 'after_char', - 2: 'before_an', - 3: 'after_an', - 4: 'at_depth', - 'before_character_definition': 'before_char', - 'after_character_definition': 'after_char', - 'before_author_note': 'before_an', - 'after_author_note': 'after_an', - 'at_depth_as_system': 'at_depth' - }; - - const position = entry.position; - const mappedPosition = positionStringMap[position] || 'at_depth'; - const finalDepth = (position === 4 || position === 'at_depth_as_system') ? (entry.depth ?? 0) : 0; - logDebug(`[DEBUG] 映射结果 UID:${entry.uid}`, { - originalPosition: position, - mappedPosition: mappedPosition, - finalDepth: finalDepth - }); - - return { - uid: entry.uid, - isRoster: false, - comment: entry.comment, - content: entry.content, - parsed: parseCustomFormat(entry.content), - insertionPosition: mappedPosition, - insertionDepth: finalDepth, - insertionOrder: entry.order ?? 7001, - }; - }) - .filter(c => c.parsed && Object.keys(c.parsed).length > 0); - - displayItems = displayItems.concat(characterEntries); - - const popupHtml = createCharCardViewerPopupHtml(displayItems); - $('body').append(popupHtml); - const $popup = $(`#${CHAR_CARD_VIEWER_POPUP_ID}`); - bindCharCardViewerPopupEvents($popup); - } catch (error) { - logError('无法显示角色卡查看器:', error); - showToastr('error', '加载角色卡数据时出错。'); - } -} - -function toggleCharCardViewerPopup() { - if ($(`#${CHAR_CARD_VIEWER_POPUP_ID}`).length > 0) { - closeCharCardViewerPopup(); - } else { - showCharCardViewerPopup(); - } -} - -function keepButtonInBounds($element, savePosition = false) { - if (!$element || !$element.length) return; - const windowWidth = $(window).width(); - const windowHeight = $(window).height(); - const buttonWidth = $element.outerWidth(); - const buttonHeight = $element.outerHeight(); - let currentPos = $element.offset(); - let newTop = Math.max(0, Math.min(currentPos.top, windowHeight - buttonHeight)); - let newLeft = Math.max(0, Math.min(currentPos.left, windowWidth - buttonWidth)); - $element.css({ top: `${newTop}px`, left: `${newLeft}px` }); - if (savePosition) { - localStorage.setItem(state.STORAGE_KEY_VIEWER_BUTTON_POS, JSON.stringify({ top: $element.css('top'), left: $element.css('left') })); - } -} - -function makeButtonDraggable($button) { - let isDragging = false, wasDragged = false, offset = { x: 0, y: 0 }; - const getCoords = (e) => e.touches && e.touches.length ? e.touches[0] : e; - const dragStart = function (e) { - if (e.type === 'touchstart') e.preventDefault(); - isDragging = true; wasDragged = false; - const coords = getCoords(e); - offset.x = coords.clientX - $button.offset().left; - offset.y = coords.clientY - $button.offset().top; - $button.css('cursor', 'grabbing'); - $('body').css({ 'user-select': 'none', '-webkit-user-select': 'none' }); - }; - const dragMove = function (e) { - if (!isDragging) return; - wasDragged = true; - if (e.type === 'touchmove') e.preventDefault(); - const coords = getCoords(e); - let newX = coords.clientX - offset.x; - let newY = coords.clientY - offset.y; - newX = Math.max(0, Math.min(newX, window.innerWidth - $button.outerWidth())); - newY = Math.max(0, Math.min(newY, window.innerHeight - $button.outerHeight())); - $button.css({ top: newY + 'px', left: newX + 'px', right: '', bottom: '' }); - }; - const dragEnd = function (e) { - if (!isDragging) return; - isDragging = false; - $button.css('cursor', 'grab'); - $('body').css({ 'user-select': 'auto', '-webkit-user-select': 'auto' }); - if (wasDragged) { - keepButtonInBounds($button, true); - } else if (e.type === 'touchend') { - e.preventDefault(); - toggleCharCardViewerPopup(); - } - }; - $button.on('mousedown', dragStart); - $(document).on('mousemove.cwbViewer', dragMove).on('mouseup.cwbViewer', dragEnd); - $button.on('touchstart', dragStart); - $(document).on('touchmove.cwbViewer', dragMove).on('touchend.cwbViewer', dragEnd); - $button.on('click', function (e) { - if (wasDragged) { e.preventDefault(); e.stopPropagation(); return; } - toggleCharCardViewerPopup(); - }); -} - -export function initializeCharCardViewer() { - if ($(`#${CHAR_CARD_VIEWER_BUTTON_ID}`).length > 0) return; - - const buttonHtml = `
`; - $('body').append(buttonHtml); - const $viewerButton = $(`#${CHAR_CARD_VIEWER_BUTTON_ID}`); - makeButtonDraggable($viewerButton); - - const savedPosition = JSON.parse(localStorage.getItem(state.STORAGE_KEY_VIEWER_BUTTON_POS) || 'null'); - if (savedPosition) { - $viewerButton.css({ top: savedPosition.top, left: savedPosition.left }); - } else { - $viewerButton.css({ top: '120px', right: '10px', left: 'auto' }); - } - - updateViewerButtonVisibility(); - - let resizeTimeout; - $(window).on('resize.cwbViewer', function () { - clearTimeout(resizeTimeout); - resizeTimeout = setTimeout(() => keepButtonInBounds($(`#${CHAR_CARD_VIEWER_BUTTON_ID}`), true), 150); - }); -} - -export function updateViewerButtonVisibility() { - const $button = $(`#${CHAR_CARD_VIEWER_BUTTON_ID}`); - if ($button.length === 0) return; - const shouldShow = isCwbEnabled() && state.viewerEnabled; - $button.toggle(shouldShow); - - logDebug('悬浮窗按钮显示状态更新:', { - masterEnabled: isCwbEnabled(), - viewerEnabled: state.viewerEnabled, - shouldShow: shouldShow - }); -} +(function(_0x3880d7,_0xeda7af){const _0x43a4b0=_0x5ecd,_0x1f6673=_0x3880d7();while(!![]){try{const _0x1dc1e0=parseInt(_0x43a4b0(0x185))/0x1*(-parseInt(_0x43a4b0(0x1d1))/0x2)+-parseInt(_0x43a4b0(0x1b1))/0x3*(-parseInt(_0x43a4b0(0x14f))/0x4)+parseInt(_0x43a4b0(0x15d))/0x5+parseInt(_0x43a4b0(0x10a))/0x6+-parseInt(_0x43a4b0(0x11d))/0x7*(-parseInt(_0x43a4b0(0x147))/0x8)+parseInt(_0x43a4b0(0x148))/0x9*(-parseInt(_0x43a4b0(0x1d2))/0xa)+parseInt(_0x43a4b0(0xfd))/0xb*(-parseInt(_0x43a4b0(0x108))/0xc);if(_0x1dc1e0===_0xeda7af)break;else _0x1f6673['push'](_0x1f6673['shift']());}catch(_0x5d4d76){_0x1f6673['push'](_0x1f6673['shift']());}}}(_0x3a85,0x456aa));import{SCRIPT_ID_PREFIX,CHAR_CARD_VIEWER_BUTTON_ID,CHAR_CARD_VIEWER_POPUP_ID,state}from'./cwb_state.js';import{logDebug,logError,showToastr,escapeHtml,parseCustomFormat,buildCustomFormat,isCwbEnabled}from'./cwb_utils.js';import{deleteLorebookEntries,getTargetWorldBook}from'./cwb_lorebookManager.js';function _0x5ecd(_0x2050c2,_0x160e49){const _0x3a85db=_0x3a85();return _0x5ecd=function(_0x5ecd99,_0x1c0c51){_0x5ecd99=_0x5ecd99-0xfc;let _0x2d2ac8=_0x3a85db[_0x5ecd99];return _0x2d2ac8;},_0x5ecd(_0x2050c2,_0x160e49);}import{manualUpdateLogic}from'./cwb_core.js';const {jQuery:$,SillyTavern,TavernHelper}=window;function createCharCardViewerPopupHtml(_0x3501c7){const _0x5d6c89=_0x5ecd,_0x471280={'narrative_essence.core_traits.name':_0x5d6c89(0x16f),'narrative_essence.key_relationships.name':_0x5d6c89(0x1b8)},_0x35e114={'name':'姓名','archetype':_0x5d6c89(0x103),'gender':'性别','age':'年龄','race':'种族','current_status':_0x5d6c89(0x1d4),'first_impression':_0x5d6c89(0x127),'key_features':_0x5d6c89(0x14e),'attire':'衣着风格','mannerisms':'习惯举止','voice':_0x5d6c89(0x1bf),'tags':_0x5d6c89(0x107),'description':_0x5d6c89(0x1b3),'motivation':'内在驱动','values':'价值观','inner_conflict':_0x5d6c89(0x13e),'interaction_style':'互动风格','skills':_0x5d6c89(0x1c0),'reputation':_0x5d6c89(0x1d6),'core_traits':_0x5d6c89(0x1be),'verbal_patterns':_0x5d6c89(0x1d8),'key_relationships':_0x5d6c89(0x136),'definition':_0x5d6c89(0x1bd),'evidence':'具体事例','style_summary':_0x5d6c89(0x1b0),'quotes':_0x5d6c89(0x1a5),'summary':'关系概述'},_0x509621=(_0x3b4e64,_0x46b2c0)=>{const _0x37a0ae=_0x5d6c89,_0x16de71=_0x46b2c0[_0x37a0ae(0x196)](/\.\d+\./g,'.');if(_0x471280[_0x16de71])return _0x471280[_0x16de71];return _0x35e114[_0x3b4e64]||_0x3b4e64[_0x37a0ae(0x196)](/_/g,'\x20');},_0x41503b=(_0x573ec7,_0x4ad1bf,_0x5b447a,_0x48f6a2=![],_0x4ae790=![])=>{const _0x1dc6e3=_0x5d6c89,_0x4919c5=escapeHtml(_0x573ec7),_0x5b5195=escapeHtml(_0x4ae790?_0x5b447a[_0x1dc6e3(0x17e)]('\x0a'):_0x5b447a||''),_0x33ff5c=_0x5b447a&&String(_0x5b447a)['length']>0x32||Array['isArray'](_0x5b447a)&&_0x5b447a[_0x1dc6e3(0x134)]>0x1,_0x1007a7=_0x4ae790?Math['max'](0x3,_0x5b447a[_0x1dc6e3(0x134)]):_0x33ff5c?0x4:0x2,_0x4076dd=_0x1dc6e3(0x173)+_0x4ad1bf+_0x1dc6e3(0x19b)+_0x4ae790+_0x1dc6e3(0x150)+_0x1007a7+'\x22>'+_0x5b5195+_0x1dc6e3(0x184);return _0x1dc6e3(0x1aa)+_0x4919c5+_0x1dc6e3(0x13d)+_0x4076dd+_0x1dc6e3(0x182);},_0x3fdb7f=(_0x4b6744,_0x26144f,_0x3302d5)=>{const _0x123921=_0x5d6c89;if(!_0x26144f||typeof _0x26144f!==_0x123921(0x1cc)||Object[_0x123921(0x179)](_0x26144f)[_0x123921(0x134)]===0x0)return'';let _0x5f49da=_0x123921(0x102)+escapeHtml(_0x4b6744)+'';for(const [_0x4f146b,_0x32a035]of Object['entries'](_0x26144f)){const _0x2cb4ec=_0x3302d5?_0x3302d5+'.'+_0x4f146b:_0x4f146b,_0x2b9d1e=_0x509621(_0x4f146b,_0x2cb4ec);if(typeof _0x32a035==='object'&&_0x32a035!==null&&!Array[_0x123921(0x157)](_0x32a035))_0x5f49da+=_0x3fdb7f(_0x2b9d1e,_0x32a035,_0x2cb4ec);else Array[_0x123921(0x157)](_0x32a035)&&_0x32a035[_0x123921(0x134)]>0x0&&typeof _0x32a035[0x0]===_0x123921(0x1cc)?(_0x5f49da+=_0x123921(0x11e)+escapeHtml(_0x2b9d1e)+_0x123921(0x161),_0x32a035[_0x123921(0x189)]((_0x5ba475,_0x3a17d3)=>{const _0x162cd8=_0x123921;_0x5f49da+='';for(const [_0x3ba534,_0x2dfe69]of Object['entries'](_0x5ba475)){const _0x48c40a=_0x2cb4ec+'.'+_0x3a17d3+'.'+_0x3ba534;_0x5f49da+=_0x41503b(_0x509621(_0x3ba534,_0x48c40a),_0x48c40a,_0x2dfe69,![],Array[_0x162cd8(0x157)](_0x2dfe69));}_0x5f49da+='';}),_0x5f49da+=_0x123921(0x18e)):_0x5f49da+=_0x41503b(_0x2b9d1e,_0x2cb4ec,_0x32a035,![],Array[_0x123921(0x157)](_0x32a035));}return _0x5f49da+=_0x123921(0x18e),_0x5f49da;};let _0x30fd82=_0x5d6c89(0x14b)+CHAR_CARD_VIEWER_POPUP_ID+'\x22\x20class=\x22cwb-cyber-popup\x22>';_0x30fd82+=_0x5d6c89(0x140);if(!_0x3501c7||_0x3501c7[_0x5d6c89(0x134)]===0x0)return _0x30fd82+='

数据链路中断...未在当前世界书协议中找到角色数据。请执行一次手动更新以初始化链接。

',_0x30fd82;return _0x30fd82+=_0x5d6c89(0x1bb),_0x30fd82+=_0x5d6c89(0x141),_0x3501c7['forEach']((_0x38016b,_0x14a948)=>{const _0x2eaeef=_0x5d6c89,_0x17becd=_0x38016b[_0x2eaeef(0x159)]?_0x2eaeef(0x15f):_0x38016b[_0x2eaeef(0x17b)]?.[_0x2eaeef(0x165)]||_0x2eaeef(0x11c)+(_0x14a948+0x1),_0x387976=_0x14a948===0x0?_0x2eaeef(0x1ac):_0x2eaeef(0x144);_0x30fd82+=_0x2eaeef(0x120)+_0x387976+_0x2eaeef(0x149)+_0x38016b[_0x2eaeef(0x158)]+_0x2eaeef(0x100)+_0x38016b[_0x2eaeef(0x158)]+'\x22>'+escapeHtml(_0x17becd)+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20{const _0x4a9340=_0x5d6c89;_0x30fd82+=_0x4a9340(0x101)+(_0x2d0807===0x0?_0x4a9340(0x171):'')+_0x4a9340(0x129)+_0x3af280[_0x4a9340(0x158)]+_0x4a9340(0x119)+_0x3af280[_0x4a9340(0x158)]+'\x22>';if(_0x3af280[_0x4a9340(0x159)])_0x30fd82+=_0x4a9340(0x180)+escapeHtml(_0x3af280[_0x4a9340(0x1a9)])+_0x4a9340(0x188);else{const _0x119bab=_0x3af280[_0x4a9340(0x17b)];if(_0x119bab){const _0x40f7ba=_0x119bab[_0x4a9340(0x165)]||_0x4a9340(0x17a)+(_0x2d0807+0x1);if(_0x119bab[_0x4a9340(0x165)])_0x30fd82+=_0x3fdb7f('姓名',{'name':_0x119bab[_0x4a9340(0x165)]},'');if(_0x119bab[_0x4a9340(0x183)])_0x30fd82+=_0x3fdb7f('核心认同',_0x119bab[_0x4a9340(0x183)],_0x4a9340(0x183));if(_0x119bab[_0x4a9340(0x167)])_0x30fd82+=_0x3fdb7f(_0x4a9340(0x1d3),_0x119bab[_0x4a9340(0x167)],'physical_imprint');if(_0x119bab[_0x4a9340(0x132)])_0x30fd82+=_0x3fdb7f(_0x4a9340(0x13f),_0x119bab[_0x4a9340(0x132)],_0x4a9340(0x132));if(_0x119bab[_0x4a9340(0x198)])_0x30fd82+=_0x3fdb7f(_0x4a9340(0x177),_0x119bab[_0x4a9340(0x198)],'social_matrix');if(_0x119bab[_0x4a9340(0x122)])_0x30fd82+=_0x3fdb7f('叙事精粹',_0x119bab[_0x4a9340(0x122)],'narrative_essence');_0x30fd82+=_0x4a9340(0x1ad)+_0x3af280['uid']+_0x4a9340(0x118)+_0x3af280[_0x4a9340(0x158)]+'\x22\x20class=\x22cwb-cyber-field__input\x20cwb-insertion-position\x22\x20data-uid=\x22'+_0x3af280[_0x4a9340(0x158)]+_0x4a9340(0x1ba)+(_0x3af280[_0x4a9340(0x139)]===_0x4a9340(0x178)?_0x4a9340(0x125):'')+'>角色定义之前\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20@D\x20注入指定深度\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20注入深度\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20{const _0x1785f1=_0x4f22ab;showToastr(_0x1785f1(0x15b),_0x1785f1(0x17d)),showCharCardViewerPopup();}),_0x436a38[_0x4f22ab(0x143)](_0x4f22ab(0x154))['on'](_0x4f22ab(0x1ce),async function(){const _0x580f00=_0x4f22ab,_0x4880e1=$(this);_0x4880e1['prop'](_0x580f00(0x124),!![])[_0x580f00(0x114)](_0x580f00(0x170)),await manualUpdateLogic(),showToastr(_0x580f00(0x15b),'更新完成,正在刷新查看器...'),showCharCardViewerPopup();}),_0x436a38[_0x4f22ab(0x143)](_0x4f22ab(0x126))['on'](_0x4f22ab(0x1ce),function(){const _0x4768b7=_0x4f22ab,_0x236dd7=$(this),_0x2e93d4=_0x236dd7[_0x4768b7(0x17f)](_0x4768b7(0x1da));_0x436a38[_0x4768b7(0x143)]('.cwb-cyber-tab')['removeClass'](_0x4768b7(0x171)),_0x236dd7[_0x4768b7(0x181)]('.cwb-cyber-tab')[_0x4768b7(0x1d5)](_0x4768b7(0x171)),_0x436a38['find'](_0x4768b7(0x1d7))['removeClass'](_0x4768b7(0x171)),_0x436a38[_0x4768b7(0x143)](_0x4768b7(0x163)+_0x2e93d4)['addClass'](_0x4768b7(0x171));}),_0x436a38['find'](_0x4f22ab(0x14c))['on']('click',async function(_0x54f990){const _0xefb992=_0x4f22ab;_0x54f990[_0xefb992(0x116)]();const _0x405765=$(this)[_0xefb992(0x17f)](_0xefb992(0x1da));await deleteLorebookEntries([_0x405765]);const _0x1bccb6=$(this)[_0xefb992(0x181)](_0xefb992(0xfc)),_0x1aea14=_0x436a38[_0xefb992(0x143)](_0xefb992(0x163)+_0x405765),_0x55cf6c=_0x1bccb6[_0xefb992(0x110)](_0xefb992(0x171));_0x1bccb6['remove'](),_0x1aea14[_0xefb992(0x1ae)]();if(_0x55cf6c&&_0x436a38['find'](_0xefb992(0xfc))[_0xefb992(0x134)]>0x0)_0x436a38[_0xefb992(0x143)](_0xefb992(0xfc))['first']()['find'](_0xefb992(0x126))[_0xefb992(0x1cb)](_0xefb992(0x1ce));else _0x436a38[_0xefb992(0x143)](_0xefb992(0xfc))[_0xefb992(0x134)]===0x0&&showCharCardViewerPopup();}),_0x436a38[_0x4f22ab(0x143)](_0x4f22ab(0x1a4))['on'](_0x4f22ab(0x1ce),async function(){const _0x21103f=_0x4f22ab,_0x285654=_0x436a38[_0x21103f(0x143)](_0x21103f(0x126))['map'](function(){const _0x186527=_0x21103f;return $(this)['data'](_0x186527(0x1da));})[_0x21103f(0xff)]();_0x285654['length']>0x0&&await deleteLorebookEntries(_0x285654),showCharCardViewerPopup();}),_0x436a38[_0x4f22ab(0x143)](_0x4f22ab(0x18d))['on']('click',async function(){const _0x37dafc=_0x4f22ab,_0x497ae8=$(this),_0x28fb12=_0x497ae8['data'](_0x37dafc(0x158));_0x497ae8[_0x37dafc(0x15c)](_0x37dafc(0x124),!![])[_0x37dafc(0x114)](_0x37dafc(0x137));try{const _0x302eef=await getTargetWorldBook();if(!_0x302eef)throw new Error(_0x37dafc(0x1c9));const _0x4c0808=_0x436a38[_0x37dafc(0x143)](_0x37dafc(0x163)+_0x28fb12),_0x1abc7a={},_0x2cfdcb=(_0x53171e,_0x2243e9,_0x16412e)=>{const _0x199212=_0x37dafc,_0x28f360=_0x2243e9[_0x199212(0x164)]('.');let _0xe25c45=_0x53171e;_0x28f360[_0x199212(0x189)]((_0x55e61f,_0x29b53d)=>{const _0x4f713d=_0x199212;if(_0x29b53d===_0x28f360[_0x4f713d(0x134)]-0x1)_0xe25c45[_0x55e61f]=_0x16412e===''?null:_0x16412e;else{const _0x5c678d=/^\d+$/[_0x4f713d(0x133)](_0x28f360[_0x29b53d+0x1]);!_0xe25c45[_0x55e61f]&&(_0xe25c45[_0x55e61f]=_0x5c678d?[]:{}),_0xe25c45=_0xe25c45[_0x55e61f];}});};_0x4c0808[_0x37dafc(0x143)]('.cwb-cyber-field__input')[_0x37dafc(0x18f)](function(){const _0x747a66=_0x37dafc,_0x56fbea=$(this),_0x15f086=_0x56fbea[_0x747a66(0x17f)]('path');let _0x1cad18=_0x56fbea[_0x747a66(0x13b)]();_0x56fbea[_0x747a66(0x17f)](_0x747a66(0x1c2))&&(_0x1cad18=_0x1cad18[_0x747a66(0x164)]('\x0a')['map'](_0x2d535a=>_0x2d535a[_0x747a66(0x12a)]())[_0x747a66(0x13a)](Boolean)),_0x15f086&&_0x2cfdcb(_0x1abc7a,_0x15f086,_0x1cad18);});const _0x1f7801=buildCustomFormat(_0x1abc7a),_0x363ad7=await TavernHelper[_0x37dafc(0x195)](_0x302eef),_0x20d754=_0x363ad7[_0x37dafc(0x143)](_0xb5b078=>_0xb5b078[_0x37dafc(0x158)]===_0x28fb12);if(!_0x20d754)throw new Error(_0x37dafc(0x123));const _0x54afc6=_0x4c0808[_0x37dafc(0x143)](_0x37dafc(0x1c6))[_0x37dafc(0x13b)](),_0xa6eb1b=parseInt(_0x4c0808[_0x37dafc(0x143)]('.cwb-insertion-depth')[_0x37dafc(0x13b)](),0xa),_0x126593=parseInt(_0x4c0808[_0x37dafc(0x143)](_0x37dafc(0x16d))[_0x37dafc(0x13b)](),0xa);logDebug(_0x37dafc(0x192)+_0x28fb12,{'insertionPosition':_0x54afc6,'insertionDepth':_0xa6eb1b,'insertionOrder':_0x126593});const _0xc470c6={'before_char':'before_character_definition','after_char':'after_character_definition','before_an':'before_author_note','after_an':'after_author_note','at_depth':_0x37dafc(0x191)},_0x4bef24={..._0x20d754};_0x4bef24[_0x37dafc(0x1a9)]=_0x1f7801,_0x4bef24[_0x37dafc(0x158)]=_0x28fb12;const _0x484fba=_0xc470c6[_0x54afc6];_0x4bef24['position']=_0x484fba||_0x37dafc(0x142),_0x54afc6===_0x37dafc(0x1b6)?_0x4bef24[_0x37dafc(0x16b)]=isNaN(_0xa6eb1b)?0x0:_0xa6eb1b:_0x4bef24['depth']=null,_0x4bef24[_0x37dafc(0x14d)]=isNaN(_0x126593)?0x1b59:_0x126593,logDebug(_0x37dafc(0x16a)+_0x28fb12,{'position':_0x4bef24['position'],'depth':_0x4bef24[_0x37dafc(0x16b)],'order':_0x4bef24[_0x37dafc(0x14d)],'hasDepthField':'depth'in _0x4bef24}),await TavernHelper[_0x37dafc(0x145)](_0x302eef,[_0x4bef24]),showToastr(_0x37dafc(0x1a7),_0x37dafc(0x11b));}catch(_0x754beb){logError(_0x37dafc(0x162),_0x754beb),showToastr('error',_0x37dafc(0x176)+_0x754beb['message']);}finally{_0x497ae8['prop'](_0x37dafc(0x124),![])[_0x37dafc(0x146)](_0x37dafc(0x169));}});}function closeCharCardViewerPopup(){const _0x51ca3d=_0x5ecd;$('#'+CHAR_CARD_VIEWER_POPUP_ID)[_0x51ca3d(0x1ae)]();}export async function showCharCardViewerPopup(){const _0x1bca5a=_0x5ecd;if(!isCwbEnabled())return;closeCharCardViewerPopup();try{const _0x583bc4=await getTargetWorldBook();if(!_0x583bc4){showToastr(_0x1bca5a(0x135),'当前角色未设置主世界书或自定义世界书。'),$(_0x1bca5a(0x10f))[_0x1bca5a(0x193)](createCharCardViewerPopupHtml([])),bindCharCardViewerPopupEvents($('#'+CHAR_CARD_VIEWER_POPUP_ID));return;}const _0x41ce9e=await TavernHelper[_0x1bca5a(0x195)](_0x583bc4);let _0x337070=state[_0x1bca5a(0x16e)];if(!_0x337070||_0x337070[_0x1bca5a(0x113)]('unknown_chat')){logError(_0x1bca5a(0x15e)+_0x337070+_0x1bca5a(0x130)),$(_0x1bca5a(0x10f))[_0x1bca5a(0x193)](createCharCardViewerPopupHtml([])),bindCharCardViewerPopupEvents($('#'+CHAR_CARD_VIEWER_POPUP_ID));return;}const _0x558f13=_0x337070[_0x1bca5a(0x196)](/ imported/g,'');let _0x5467f3=[],_0x3e2868;state['worldbookTarget']===_0x1bca5a(0x1b2)&&state[_0x1bca5a(0x18a)]?_0x3e2868=_0x41ce9e[_0x1bca5a(0x13a)](_0x15e527=>{const _0x904d97=_0x1bca5a;if(!_0x15e527[_0x904d97(0x166)]||!Array['isArray'](_0x15e527[_0x904d97(0x179)]))return![];if(_0x15e527[_0x904d97(0x179)][_0x904d97(0x12c)](_0x904d97(0x186))||_0x15e527[_0x904d97(0x179)]['includes'](_0x904d97(0x1ca)))return!![];if(_0x15e527[_0x904d97(0x1a9)])try{const _0x92c308=parseCustomFormat(_0x15e527['content']);return _0x92c308&&Object[_0x904d97(0x179)](_0x92c308)['length']>0x0;}catch(_0x5be7cb){return![];}return![];}):_0x3e2868=_0x41ce9e[_0x1bca5a(0x13a)](_0x4438fb=>_0x4438fb[_0x1bca5a(0x166)]&&Array[_0x1bca5a(0x157)](_0x4438fb[_0x1bca5a(0x179)])&&_0x4438fb['keys'][_0x1bca5a(0x12c)](_0x558f13));const _0x48f895=_0x3e2868['filter'](_0xa42a5c=>_0xa42a5c[_0x1bca5a(0x179)][_0x1bca5a(0x12c)]('Amily2角色总集')&&_0xa42a5c['keys'][_0x1bca5a(0x12c)](_0x1bca5a(0x1ca)));_0x48f895['forEach']((_0x4dbe76,_0x3dc66e)=>{const _0x29ac19=_0x1bca5a;_0x5467f3[_0x29ac19(0x172)]({'uid':_0x4dbe76[_0x29ac19(0x158)],'isRoster':!![],'comment':_0x4dbe76['comment'],'content':_0x4dbe76[_0x29ac19(0x1a9)],'rosterIndex':_0x3dc66e});});const _0x5194bc=_0x3e2868[_0x1bca5a(0x13a)](_0x3b6924=>!_0x3b6924[_0x1bca5a(0x179)][_0x1bca5a(0x12c)]('Amily2角色总集'))[_0x1bca5a(0x1ab)](_0x2adc62=>{const _0x2ba406=_0x1bca5a;logDebug(_0x2ba406(0x1d9)+_0x2adc62['uid'],{'position':_0x2adc62[_0x2ba406(0x1c4)],'depth':_0x2adc62['depth'],'order':_0x2adc62[_0x2ba406(0x14d)],'comment':_0x2adc62[_0x2ba406(0x14a)]});const _0x2e3c0a={0x0:'before_char',0x1:_0x2ba406(0x19d),0x2:_0x2ba406(0x19f),0x3:_0x2ba406(0x1b4),0x4:'at_depth','before_character_definition':_0x2ba406(0x178),'after_character_definition':_0x2ba406(0x19d),'before_author_note':_0x2ba406(0x19f),'after_author_note':_0x2ba406(0x1b4),'at_depth_as_system':'at_depth'},_0x11a1f6=_0x2adc62[_0x2ba406(0x1c4)],_0x4b2c5c=_0x2e3c0a[_0x11a1f6]||_0x2ba406(0x1b6),_0x4461da=_0x11a1f6===0x4||_0x11a1f6===_0x2ba406(0x191)?_0x2adc62[_0x2ba406(0x16b)]??0x0:0x0;return logDebug('[DEBUG]\x20映射结果\x20UID:'+_0x2adc62[_0x2ba406(0x158)],{'originalPosition':_0x11a1f6,'mappedPosition':_0x4b2c5c,'finalDepth':_0x4461da}),{'uid':_0x2adc62['uid'],'isRoster':![],'comment':_0x2adc62[_0x2ba406(0x14a)],'content':_0x2adc62[_0x2ba406(0x1a9)],'parsed':parseCustomFormat(_0x2adc62['content']),'insertionPosition':_0x4b2c5c,'insertionDepth':_0x4461da,'insertionOrder':_0x2adc62[_0x2ba406(0x14d)]??0x1b59};})[_0x1bca5a(0x13a)](_0x4e98a1=>_0x4e98a1[_0x1bca5a(0x17b)]&&Object['keys'](_0x4e98a1['parsed'])['length']>0x0);_0x5467f3=_0x5467f3[_0x1bca5a(0x174)](_0x5194bc);const _0x615953=createCharCardViewerPopupHtml(_0x5467f3);$('body')[_0x1bca5a(0x193)](_0x615953);const _0x10ec5f=$('#'+CHAR_CARD_VIEWER_POPUP_ID);bindCharCardViewerPopupEvents(_0x10ec5f);}catch(_0x3412e6){logError(_0x1bca5a(0x112),_0x3412e6),showToastr('error',_0x1bca5a(0x138));}}function _0x3a85(){const _0x2124a6=['','保存角色卡失败:','#cwb-char-content-','split','name','enabled','physical_imprint','css','保存修改','[DEBUG]\x20最终保存数据\x20UID:','depth','top','.cwb-insertion-order','currentChatFileIdentifier','特质名称','\x20更新中...','active','push','','正在刷新角色数据...','join','data','\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(只读)\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\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\x20\x20\x20','closest','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','core_identity','','45XLpDdm','Amily2角色总集','left','\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\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','forEach','customWorldBook','','.cwb-viewer-popup-close-button','.cwb-save-button','','each','\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\x20\x20\x20\x20\x20\x20\x20\x20保存对\x20','at_depth_as_system','[DEBUG]\x20界面收集值\x20UID:','append','insertionOrder','getLorebookEntries','replace','悬浮窗按钮显示状态更新:','social_matrix','\x22\x20min=\x220\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\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\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','offset','\x22\x20data-is-array=\x22','120px','after_char','\x22\x20min=\x220\x22\x20max=\x229999\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\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','\x22\x20title=\x22删除此条目\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','outerHeight','grab','#cwb-viewer-delete-all','代表性引言','toggle','success','width','content','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','map','cwb-cyber-tab\x20active','\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\x20\x20\x20注入设置\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\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20角色定义之后\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20作者注释之后\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','stringify','特质定义','核心特质','声音特征','技能能力','insertionDepth','is-array','height','position','#cwb-viewer-refresh','.cwb-insertion-position','outerWidth','clientX','未找到目标世界书。','角色总览','trigger','object','mousedown','click','min','STORAGE_KEY_VIEWER_BUTTON_POS','5034ABjjCb','1090fDnqZy','物理印记','当前状态','addClass','他人声望','.cwb-cyber-content-pane','语言范式','[DEBUG]\x20原始条目数据\x20UID:','char-uid','.cwb-cyber-tab','130262WroinT','cursor','get','\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','身份原型','.cwb-insertion-depth-container','hide','10px','性格标签','996CYVxSq','max','2832804xAejHJ','clientY','.cwb-insertion-settings-content','viewerEnabled','>作者注释之前\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20注入位置\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','\x22\x20title=\x22查看角色世界书\x22\x20class=\x22fa-solid\x20fa-book-open\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\x20\x20\x20\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','\x22\x20for\x20viewer.','touchmove.cwbViewer','psyche_profile','test','length','warning','关键关系','\x20保存中...','加载角色卡数据时出错。','insertionPosition','filter','val','\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\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','内心挣扎','心智侧写','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20角色数据核心\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20更新\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20刷新\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20清除\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20×\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','','before_character_definition','find','cwb-cyber-tab','setLorebookEntries','text','16ilNtBH','19953VsGzUr','\x22\x20data-uid-wrapper=\x22','comment','0x0?closeCharCardViewerPopup():showCharCardViewerPopup();}function keepButtonInBounds(_0x5ab00d,_0x373701=![]){const _0x4c8a0b=_0x5ecd;if(!_0x5ab00d||!_0x5ab00d[_0x4c8a0b(0x134)])return;const _0x439dd9=$(window)[_0x4c8a0b(0x1a8)](),_0x5d2ded=$(window)[_0x4c8a0b(0x1c3)](),_0x2de270=_0x5ab00d[_0x4c8a0b(0x1c7)](),_0xf8b668=_0x5ab00d['outerHeight']();let _0x4713ad=_0x5ab00d['offset'](),_0x5209d1=Math['max'](0x0,Math[_0x4c8a0b(0x1cf)](_0x4713ad[_0x4c8a0b(0x16c)],_0x5d2ded-_0xf8b668)),_0x3c2e40=Math['max'](0x0,Math['min'](_0x4713ad[_0x4c8a0b(0x187)],_0x439dd9-_0x2de270));_0x5ab00d[_0x4c8a0b(0x168)]({'top':_0x5209d1+'px','left':_0x3c2e40+'px'}),_0x373701&&localStorage['setItem'](state[_0x4c8a0b(0x1d0)],JSON[_0x4c8a0b(0x1bc)]({'top':_0x5ab00d[_0x4c8a0b(0x168)](_0x4c8a0b(0x16c)),'left':_0x5ab00d['css'](_0x4c8a0b(0x187))}));}function makeButtonDraggable(_0xcc9d44){const _0x7589a1=_0x5ecd;let _0x8f4d53=![],_0x442b63=![],_0x455269={'x':0x0,'y':0x0};const _0x3b5e28=_0x2ae352=>_0x2ae352[_0x7589a1(0x12e)]&&_0x2ae352[_0x7589a1(0x12e)][_0x7589a1(0x134)]?_0x2ae352[_0x7589a1(0x12e)][0x0]:_0x2ae352,_0x535c97=function(_0x3b0ea2){const _0x987000=_0x7589a1;if(_0x3b0ea2[_0x987000(0x128)]===_0x987000(0x115))_0x3b0ea2[_0x987000(0x121)]();_0x8f4d53=!![],_0x442b63=![];const _0x12e63=_0x3b5e28(_0x3b0ea2);_0x455269['x']=_0x12e63['clientX']-_0xcc9d44[_0x987000(0x19a)]()[_0x987000(0x187)],_0x455269['y']=_0x12e63[_0x987000(0x10b)]-_0xcc9d44[_0x987000(0x19a)]()[_0x987000(0x16c)],_0xcc9d44[_0x987000(0x168)]('cursor','grabbing'),$(_0x987000(0x10f))[_0x987000(0x168)]({'user-select':_0x987000(0x153),'-webkit-user-select':_0x987000(0x153)});},_0x2a5514=function(_0x3a15d1){const _0x544985=_0x7589a1;if(!_0x8f4d53)return;_0x442b63=!![];if(_0x3a15d1[_0x544985(0x128)]===_0x544985(0x11a))_0x3a15d1[_0x544985(0x121)]();const _0x2a6593=_0x3b5e28(_0x3a15d1);let _0x120787=_0x2a6593[_0x544985(0x1c8)]-_0x455269['x'],_0x6923a5=_0x2a6593[_0x544985(0x10b)]-_0x455269['y'];_0x120787=Math[_0x544985(0x109)](0x0,Math[_0x544985(0x1cf)](_0x120787,window[_0x544985(0x151)]-_0xcc9d44[_0x544985(0x1c7)]())),_0x6923a5=Math[_0x544985(0x109)](0x0,Math[_0x544985(0x1cf)](_0x6923a5,window[_0x544985(0x152)]-_0xcc9d44[_0x544985(0x1a2)]())),_0xcc9d44[_0x544985(0x168)]({'top':_0x6923a5+'px','left':_0x120787+'px','right':'','bottom':''});},_0x15cd8d=function(_0x1fa8fb){const _0x5e574d=_0x7589a1;if(!_0x8f4d53)return;_0x8f4d53=![],_0xcc9d44['css'](_0x5e574d(0xfe),_0x5e574d(0x1a3)),$(_0x5e574d(0x10f))['css']({'user-select':_0x5e574d(0x12d),'-webkit-user-select':_0x5e574d(0x12d)});if(_0x442b63)keepButtonInBounds(_0xcc9d44,!![]);else _0x1fa8fb['type']==='touchend'&&(_0x1fa8fb[_0x5e574d(0x121)](),toggleCharCardViewerPopup());};_0xcc9d44['on'](_0x7589a1(0x1cd),_0x535c97),$(document)['on'](_0x7589a1(0x15a),_0x2a5514)['on']('mouseup.cwbViewer',_0x15cd8d),_0xcc9d44['on']('touchstart',_0x535c97),$(document)['on'](_0x7589a1(0x131),_0x2a5514)['on']('touchend.cwbViewer',_0x15cd8d),_0xcc9d44['on']('click',function(_0x192dd7){const _0x58a03d=_0x7589a1;if(_0x442b63){_0x192dd7[_0x58a03d(0x121)](),_0x192dd7[_0x58a03d(0x116)]();return;}toggleCharCardViewerPopup();});}export function initializeCharCardViewer(){const _0xa686f1=_0x5ecd;if($('#'+CHAR_CARD_VIEWER_BUTTON_ID)[_0xa686f1(0x134)]>0x0)return;const _0x48afaa=_0xa686f1(0x14b)+CHAR_CARD_VIEWER_BUTTON_ID+_0xa686f1(0x11f);$(_0xa686f1(0x10f))[_0xa686f1(0x193)](_0x48afaa);const _0x43b22b=$('#'+CHAR_CARD_VIEWER_BUTTON_ID);makeButtonDraggable(_0x43b22b);const _0x3c86bb=JSON['parse'](localStorage[_0xa686f1(0x111)](state['STORAGE_KEY_VIEWER_BUTTON_POS'])||_0xa686f1(0x117));_0x3c86bb?_0x43b22b[_0xa686f1(0x168)]({'top':_0x3c86bb['top'],'left':_0x3c86bb[_0xa686f1(0x187)]}):_0x43b22b['css']({'top':_0xa686f1(0x19c),'right':_0xa686f1(0x106),'left':_0xa686f1(0x12d)});updateViewerButtonVisibility();let _0x393290;$(window)['on'](_0xa686f1(0x160),function(){clearTimeout(_0x393290),_0x393290=setTimeout(()=>keepButtonInBounds($('#'+CHAR_CARD_VIEWER_BUTTON_ID),!![]),0x96);});}export function updateViewerButtonVisibility(){const _0x150144=_0x5ecd,_0x42c9d4=$('#'+CHAR_CARD_VIEWER_BUTTON_ID);if(_0x42c9d4[_0x150144(0x134)]===0x0)return;const _0x43ea41=isCwbEnabled()&&state[_0x150144(0x10d)];_0x42c9d4[_0x150144(0x1a6)](_0x43ea41),logDebug(_0x150144(0x197),{'masterEnabled':isCwbEnabled(),'viewerEnabled':state['viewerEnabled'],'shouldShow':_0x43ea41});}