beatsad_Vault2Dify/main.js

123 lines
122 KiB
JavaScript
Raw Normal View History

2026-06-14 12:02:40 +00:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
2026-06-14 16:09:25 +00:00
var F=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var le=(a,r)=>{for(var e in r)F(a,e,{get:r[e],enumerable:!0})},ce=(a,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of re(r))!oe.call(a,i)&&i!==e&&F(a,i,{get:()=>r[i],enumerable:!(t=ae(r,i))||t.enumerable});return a};var de=a=>ce(F({},"__esModule",{value:!0}),a);var Ie={};le(Ie,{default:()=>R});module.exports=de(Ie);var p=require("obsidian");function k(a,r){return`${a}::${r}`}function B(a,r,e,t){let i=[];return a.forEach((n,s)=>{n.filePath===r&&i.push([s,{...n,filePath:e,remoteName:n.remoteName||t(r),deletedLocal:!1}])}),i.forEach(([n,s])=>{a.delete(n),a.set(k(s.datasetId,e),s)}),i.length>0}function H(a,r,e,t,i,n=new Date,s=3e4){let o=k(r,e);if(a.has(o))return!1;let l,c,d=-1;return a.forEach((u,h)=>{if(u.datasetId!==r||u.filePath===e||!u.documentId||!u.deletedLocal||u.hash!==t)return;let g=Date.parse(u.lastSyncedAt);if(!Number.isFinite(g))return;let y=n.getTime()-g;y<0||y>s||g<=d||(l=h,c=u,d=g)}),!l||!c?!1:(a.delete(l),a.set(o,{...c,filePath:e,remoteName:c.remoteName||i(c.filePath),deletedLocal:!1}),!0)}var Y=require("obsidian");function V(a,r=""){let e=P(a,r),t=j(a);if(!t)throw new Error(W(e));return t.filter(i=>!!(i!=null&&i.id)).map(i=>({id:i.id,name:i.name||i.id,description:i.description}))}function z(a,r=""){if(!j(a))throw new Error(W(P(a,r)))}function P(a,r=""){let e=/^\s*</.test(r||""),t=Array.isArray(a)?"array":a===null?"null":typeof a,i=Q(a)?a:void 0,n=i==null?void 0:i.data;return{topLevelType:t,topLevelKeys:i?Object.keys(i).slice(0,12):[],dataIsArray:Array.isArray(n),dataLength:Array.isArray(n)?n.length:void 0,looksLikeHtml:e}}function j(a){return Array.isArray(a)?a:Q(a)&&Array.isArray(a.data)?a.data:null}function W(a){let r=a.looksLikeHtml?"received an HTML page":`top-level type ${a.topLevelType}`,e=a.topLevelKeys.length>0?`; top-level fields: ${a.topLevelKeys.join(", ")}`:"";return`Current address did not return a Dify knowledge base API response (${r}${e}).`}function Q(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function b(a){let r=(a||"").trim().replace(/\/+$/,"").replace(/\/v1\/datasets$/i,"").replace(/\/v1$/i,"");return r?/^https?:\/\//i.test(r)?r:`http://${r}`:""}function M(a){return(a||"").trim().replace(/^\/+|\/+$/g,"")}function pe(a,r){let e=M(r);return e===""?!0:e.toLowerCase().endsWith(".md")?a===e:a===e||a.startsWith(`${e}/`)}function A(a){if(!a)return{};try{return JSON.parse(a)}catch(r){return{}}}function f(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function S(a,r){let e=a[r];return typeof e=="string"?e:void 0}function C(a,r){let e=a[r];return typeof e=="number"?e:void 0}function D(a){return Array.from(new Set(a.map(r=>r.trim()).filter(Boolean)))}function G(a,r){let e=[];return r.filter(t=>t.enabled&&Array.isArray(t.datasetIds)&&t.datasetIds.length>0).forEach(t=>{pe(a,t.folder)&&e.push(...t.datasetIds)}),D(e)}function J(a,r){return a.filter(e=>e.id!==r)}function v(a,r,e,t){let i=Number(a);return Number.isFinite(i)?Math.min(e,Math.max(r,i)):t}var m=class extends Error{constructor(e,t,i,n){super(e);this.name="DifyApiError",this.status=t,this.responseText=i,this.reason=n,Object.setPrototypeOf(this,m.prototype)}get isTransient(){return!this.status||this.status===408||this.status===429||this.status>=500}get isPathMismatch(){return this.status===404||this.status===405}},I=class{constructor(r){this.activeBaseUrl="";this.runtimePathStyle=null;this.host=r}getActiveBaseUrl(){return this.activeBaseUrl}setActiveBaseUrl(r){let e=this.getCandidateBaseUrls(!1);r&&e.includes(r)&&(this.activeBaseUrl=r)}clearActiveBaseUrl(){this.activeBaseUrl=""}async probeConnection(){let r=this.getCandidateBaseUrls(!1),e=new Date().toISOString(),t=[],i=null,n=null;for(let s of r){let o=Date.now();try{let l=await this.listDatasetsFromBaseUrl(s),c=Date.now()-o;return this.activeBaseUrl=s,t.push({baseUrl:s,ok:!0,latencyMs:c,datasetCount:l.length}),{status:"connected",checkedAt:e,activeBaseUrl:s,lastSuccessfulBaseUrl:s,datasetCount:l.length,latency
2026-06-14 12:02:40 +00:00
\u586B\u5199 Dify \u670D\u52A1\u5730\u5740\u3002
\u70B9\u51FB\u6D4B\u8BD5\u8FDE\u63A5\uFF0C\u63D2\u4EF6\u4F1A\u81EA\u52A8\u83B7\u53D6\u77E5\u8BC6\u5E93\u3002
\u65B0\u589E\u8DEF\u5F84\u6620\u5C04\u3002
\u6309\u9700\u70B9\u51FB\u7ACB\u5373\u540C\u6B65\uFF0C\u6216\u4FDD\u6301\u81EA\u52A8\u540C\u6B65\u5F00\u542F\u3002`,helpApiUrlTitle:"\u5730\u5740\u5982\u4F55\u586B\u5199",helpApiUrlBody:`Dify API Key\uFF1A\u5FC5\u586B\u9879\uFF0C\u7528\u4E8E\u8BBF\u95EE\u4F60\u7684 Dify \u77E5\u8BC6\u5E93\uFF0C\u8BF7\u4ECE Dify \u77E5\u8BC6\u5E93 API \u8BBE\u7F6E\u4E2D\u590D\u5236\u3002\u793A\u4F8B\uFF1Adataset-vtpB1fgqv************
Dify \u670D\u52A1\u5730\u5740\uFF1A\u5FC5\u586B\u9879\uFF0C\u662F\u63D2\u4EF6\u8FDE\u63A5 Dify \u7684\u4E3B\u5730\u5740\uFF0C\u9002\u7528\u4E8E Dify \u90E8\u7F72\u5728\u4E91\u670D\u52A1\u5668\u3001NAS\u3001\u672C\u5730 Docker \u7B49\u60C5\u51B5\u3002\u793A\u4F8B\uFF1Ahttp://dify-host.example.test:5000 \u6216 https://dify.example.com
\u5982\u679C\u4F60\u7684 Dify \u77E5\u8BC6\u5E93\u90E8\u7F72\u5728 NAS\uFF0C\u5E76\u5E0C\u671B\u5728\u5BB6\u4E2D\u3001\u516C\u53F8\u6216\u5916\u51FA\u65F6\u90FD\u80FD\u8BBF\u95EE\uFF0C\u53EF\u4EE5\u5728 NAS \u548C\u7B14\u8BB0\u672C\u4E0A\u5B89\u88C5\u5E76\u914D\u7F6E Tailscale\uFF0C\u7136\u540E\u586B\u5199\uFF1Ahttp://tailnet-device.example.test:Dify \u6620\u5C04\u7AEF\u53E3\u3002\u793A\u4F8B\uFF1Ahttp://tailnet-device.example.test:5000`,helpApiKeyTitle:"API Key \u8981\u6C42",helpApiKeyBody:"\u8BF7\u4F7F\u7528 Dify \u77E5\u8BC6\u5E93 API Key\uFF0C\u5E76\u786E\u8BA4\u5B83\u5177\u5907\u8BBF\u95EE\u77E5\u8BC6\u5E93\u3001\u67E5\u8BE2\u77E5\u8BC6\u5E93\u5217\u8868\u3001\u521B\u5EFA\u6587\u6863\u3001\u66F4\u65B0\u6587\u6863\u548C\u67E5\u8BE2\u6587\u6863\u5217\u8868\u6743\u9650\u3002\u5982\u679C\u6D4B\u8BD5\u8FDE\u63A5\u63D0\u793A\u6743\u9650\u4E0D\u8DB3\uFF0C\u8BF7\u68C0\u67E5 API Key \u662F\u5426\u6765\u81EA\u6B63\u786E\u7684 Dify \u5B9E\u4F8B\u3001\u5DE5\u4F5C\u533A\u548C\u77E5\u8BC6\u5E93\u3002",helpMappingTitle:"\u8DEF\u5F84\u6620\u5C04",helpMappingBody:"\u8DEF\u5F84\u6620\u5C04\u7528\u4E8E\u6307\u5B9A\u54EA\u4E9B Obsidian \u7B14\u8BB0\u540C\u6B65\u5230\u54EA\u4E9B Dify \u77E5\u8BC6\u5E93\u3002\u9009\u62E9\u5177\u4F53\u76EE\u5F55\u65F6\uFF0C\u4F1A\u540C\u6B65\u8BE5\u76EE\u5F55\u53CA\u5176\u5B50\u76EE\u5F55\u4E2D\u7684 Markdown \u6587\u4EF6\uFF1B\u9009\u62E9\u5355\u7BC7\u7B14\u8BB0\u65F6\uFF0C\u53EA\u540C\u6B65\u8FD9\u4E00\u7BC7\u3002\u6BCF\u6761\u6620\u5C04\u53EF\u4EE5\u5355\u72EC\u542F\u7528\u6216\u505C\u7528\u3002",helpMappingList:`\u4E00\u4E2A Obsidian \u76EE\u5F55\u6216\u7B14\u8BB0\u540C\u6B65\u5230\u4E00\u4E2A\u77E5\u8BC6\u5E93\u3002
\u4E00\u4E2A Obsidian \u76EE\u5F55\u6216\u7B14\u8BB0\u540C\u6B65\u5230\u591A\u4E2A\u77E5\u8BC6\u5E93\u3002
\u591A\u4E2A Obsidian \u8DEF\u5F84\u540C\u6B65\u5230\u540C\u4E00\u4E2A\u77E5\u8BC6\u5E93\u3002
\u9009\u62E9\u6574\u4E2A\u4ED3\u5E93\uFF0C\u540C\u6B65\u5168\u90E8 Markdown \u6587\u4EF6\u3002
\u505C\u7528\u6620\u5C04\u540E\uFF0C\u8BE5\u6620\u5C04\u4E0D\u4F1A\u53C2\u4E0E\u624B\u52A8\u540C\u6B65\u3001\u6587\u4EF6\u53D8\u66F4\u540C\u6B65\u3001\u542F\u52A8\u540E\u540C\u6B65\u6216\u5B9A\u65F6\u5168\u91CF\u6821\u9A8C\u3002`,helpSyncModesTitle:"\u540C\u6B65\u65B9\u5F0F",helpSyncModesList:`\u7ACB\u5373\u540C\u6B65\uFF1A\u624B\u52A8\u626B\u63CF\u5DF2\u542F\u7528\u6620\u5C04\u8303\u56F4\u5185\u7684 Markdown \u6587\u4EF6\u5E76\u540C\u6B65\u53D8\u66F4\u3002
\u6587\u4EF6\u53D8\u66F4\u540E\u540C\u6B65\uFF1A\u76D1\u542C\u65B0\u5EFA\u3001\u4FEE\u6539\u3001\u91CD\u547D\u540D\u4E8B\u4EF6\uFF0C\u7B49\u5F85\u9632\u6296\u65F6\u95F4\u7ED3\u675F\u540E\u540C\u6B65\u3002
\u542F\u52A8\u540E\u540C\u6B65\uFF1AObsidian \u542F\u52A8\u5E76\u5B8C\u6210\u52A0\u8F7D\u540E\u81EA\u52A8\u68C0\u67E5\u4E00\u6B21\u53D8\u66F4\u3002
\u5B9A\u65F6\u5168\u91CF\u6821\u9A8C\uFF1A\u6309\u56FA\u5B9A\u95F4\u9694\u626B\u63CF\u6240\u6709\u6620\u5C04\u8303\u56F4\u5185\u7684 Markdown \u6587\u4EF6\uFF0C\u4F5C\u4E3A\u4E8B\u4EF6\u540C\u6B65\u7684\u515C\u5E95\u3002`,helpSyncRecommendedTitle:"\u65E5\u5E38\u5EFA\u8BAE",helpSyncRecommendedList:`\u81EA\u52A8\u540C\u6B65\uFF1A\u5F00\u542F\u3002
\u542F\u52A8\u540E\u540C\u6B65\uFF1A\u5F00\u542F\u3002
\u5B9A\u65F6\u5168\u91CF\u6821\u9A8C\uFF1A\u5F00\u542F\u3002
\u540C\u6B65\u95F4\u9694\uFF1A30 \u5206\u949F\u3002
\u53D8\u66F4\u540E\u540C\u6B65\uFF1A8 \u5230 15 \u79D2\u3002
\u5E76\u53D1\u4E0A\u4F20\uFF1ANAS / Docker / \u5C0F\u578B\u81EA\u6258\u7BA1\u5EFA\u8BAE 1 \u5230 2\u3002`,helpSyncRulesTitle:"\u540C\u6B65\u89C4\u5219",helpSyncRulesBody:"\u63D2\u4EF6\u53EA\u540C\u6B65 .md \u6587\u4EF6\uFF0C\u4E0D\u4F1A\u4E0A\u4F20\u56FE\u7247\u3001PDF\u3001\u9644\u4EF6\u6216\u5176\u4ED6\u975E Markdown \u6587\u4EF6\u3002\u672C\u5730\u5220\u9664\u7B14\u8BB0\u65F6\uFF0C\u63D2\u4EF6\u4E0D\u4F1A\u81EA\u52A8\u5220\u9664 Dify \u8FDC\u7AEF\u6587\u6863\u3002\u5220\u9664\u8DEF\u5F84\u6620\u5C04\u4E5F\u53EA\u4F1A\u5220\u9664\u672C\u5730\u914D\u7F6E\uFF0C\u4E0D\u4F1A\u5220\u9664 Obsidian \u6587\u4EF6\u6216 Dify \u8FDC\u7AEF\u6587\u6863\u3002",helpSyncRulesList:`\u6839\u636E\u8DEF\u5F84\u6620\u5C04\u627E\u5230\u76EE\u6807\u77E5\u8BC6\u5E93\u3002
\u5BF9\u6587\u4EF6\u5185\u5BB9\u8BA1\u7B97\u54C8\u5E0C\u3002
\u5185\u5BB9\u672A\u53D8\u5316\u65F6\u8DF3\u8FC7\u3002
\u4F18\u5148\u66F4\u65B0\u5DF2\u6709 Dify \u6587\u6863\u3002
\u627E\u4E0D\u5230\u5DF2\u6709\u6587\u6863\u65F6\u521B\u5EFA\u65B0\u6587\u6863\u3002
\u4F7F\u7528 Obsidian \u6587\u4EF6\u8DEF\u5F84\u4F5C\u4E3A Dify \u6587\u6863\u540D\uFF0C\u907F\u514D\u540C\u540D\u6587\u4EF6\u4E92\u76F8\u8986\u76D6\u3002`,helpTroubleshootingTitle:"\u8FDE\u63A5\u5931\u8D25\u6392\u67E5",helpTroubleshootingList:`\u786E\u8BA4 API Key \u5DF2\u586B\u5199\u5B8C\u6574\uFF0C\u6CA1\u6709\u591A\u4F59\u7A7A\u683C\u6216\u6362\u884C\u3002
\u786E\u8BA4 Dify \u670D\u52A1\u5730\u5740\u662F\u8FD0\u884C Obsidian \u7684\u5F53\u524D\u8BBE\u5907\u53EF\u4EE5\u8BBF\u95EE\u7684\u5730\u5740\u3002
\u5728\u6D4F\u89C8\u5668\u8BBF\u95EE \u4F60\u7684\u5730\u5740 + /v1/datasets\u3002
\u5982\u679C\u8FD4\u56DE JSON\uFF0C\u8BF4\u660E\u5730\u5740\u5927\u6982\u7387\u6B63\u786E\u3002
\u5982\u679C\u8FD4\u56DE HTML\uFF0C\u901A\u5E38\u8BF4\u660E\u5730\u5740\u6216\u7AEF\u53E3\u6307\u5411\u4E86\u7F51\u9875\u670D\u52A1\u3002
\u5982\u679C\u8FD4\u56DE 404\uFF0C\u68C0\u67E5 Dify \u670D\u52A1\u5730\u5740\u3001\u7AEF\u53E3\u6216\u53CD\u5411\u4EE3\u7406\u662F\u5426\u8F6C\u53D1 /v1\u3002
\u5982\u679C\u8FD4\u56DE 401\uFF0C\u8BF4\u660E\u53EF\u80FD\u5DF2\u8BBF\u95EE\u5230 Dify API\uFF0C\u4F46\u63D2\u4EF6\u91CC\u4ECD\u9700\u8981\u6B63\u786E API Key\u3002
\u5982\u679C\u8FD4\u56DE 403\uFF0C\u68C0\u67E5 Key \u6743\u9650\u548C\u5DE5\u4F5C\u533A\u3002
\u5982\u679C\u6253\u4E0D\u5F00\uFF0C\u68C0\u67E5 IP\u3001\u57DF\u540D\u3001\u7AEF\u53E3\u3001\u9632\u706B\u5899\u3001Docker \u6620\u5C04\u3001Tailscale \u548C\u53CD\u5411\u4EE3\u7406\u3002`,helpCommonErrorsTitle:"\u5E38\u89C1\u9519\u8BEF\u63D0\u793A",helpCommonErrorsList:`\u8BF7\u5148\u586B\u5199 Dify API Key \u548C Dify \u670D\u52A1\u5730\u5740\uFF1A\u8FDE\u63A5\u4FE1\u606F\u4E0D\u5B8C\u6574\u3002\u8BF7\u586B\u5199 API Key \u548C Dify \u670D\u52A1\u5730\u5740\u3002
API Key \u65E0\u6548\uFF0C\u8BF7\u68C0\u67E5\u5BC6\u94A5\u662F\u5426\u6B63\u786E\uFF1ADify \u8FD4\u56DE 401\u3002\u8BF7\u91CD\u65B0\u590D\u5236 API Key\uFF0C\u786E\u8BA4\u6CA1\u6709\u591A\u4F59\u7A7A\u683C\u6216\u6362\u884C\u3002
API Key \u6CA1\u6709\u77E5\u8BC6\u5E93\u8BBF\u95EE\u6743\u9650\uFF1ADify \u8FD4\u56DE 403\u3002\u8BF7\u68C0\u67E5 Key \u6240\u5C5E\u5DE5\u4F5C\u533A\u548C\u77E5\u8BC6\u5E93\u6743\u9650\u3002
\u672A\u627E\u5230 Dify \u77E5\u8BC6\u5E93 API\uFF1ADify \u8FD4\u56DE 404\u3002\u8BF7\u786E\u8BA4 Dify \u670D\u52A1\u5730\u5740\u3001\u7AEF\u53E3\u548C\u53CD\u5411\u4EE3\u7406\u8F6C\u53D1\u6B63\u786E\u3002
\u5F53\u524D\u63A5\u53E3\u8DEF\u5F84\u4E0D\u517C\u5BB9\uFF1A\u8BF7\u786E\u8BA4\u63D2\u4EF6\u5DF2\u5347\u7EA7\u5230\u6700\u65B0\u6784\u5EFA\uFF0C\u91CD\u65B0\u70B9\u51FB\u6D4B\u8BD5\u8FDE\u63A5\u540E\u518D\u540C\u6B65\uFF1B\u4ECD\u5931\u8D25\u65F6\u5F00\u542F\u8C03\u8BD5\u65E5\u5FD7\u5E76\u53CD\u9988 Dify \u7248\u672C\u548C\u9519\u8BEF\u4FE1\u606F\u3002
\u5F53\u524D\u5730\u5740\u8FD4\u56DE\u7684\u4E0D\u662F Dify \u77E5\u8BC6\u5E93 API\uFF1A\u5730\u5740\u53EF\u80FD\u6307\u5411 NAS \u7BA1\u7406\u9875\u3001Dify \u524D\u7AEF\u9875\u9762\u3001\u767B\u5F55\u9875\u6216\u5176\u4ED6\u7F51\u9875\u670D\u52A1\u3002\u8BF7\u68C0\u67E5\u7AEF\u53E3\u548C\u53CD\u5411\u4EE3\u7406\u3002
\u8BF7\u6C42\u8D85\u65F6\uFF1A\u8BF7\u786E\u8BA4\u5F53\u524D\u8BBE\u5907\u80FD\u8BBF\u95EE Dify \u670D\u52A1\u5730\u5740\uFF1B\u68C0\u67E5 Dify \u670D\u52A1\u8D1F\u8F7D\u3001\u7AEF\u53E3\u3001\u9632\u706B\u5899\u3001Tailscale \u548C\u53CD\u5411\u4EE3\u7406\uFF1B\u540C\u6B65\u5927\u91CF\u6587\u4EF6\u65F6\u5148\u5C06\u5E76\u53D1\u4E0A\u4F20\u964D\u5230 1 \u6216 2\uFF0C\u6216\u5206\u6279\u540C\u6B65\u3002
\u7F51\u7EDC\u8FDE\u63A5\u5931\u8D25\uFF1A\u8BF7\u68C0\u67E5\u5730\u5740\u3001\u7AEF\u53E3\u3001\u9632\u706B\u5899\u3001Docker \u6620\u5C04\u3001NAS \u7F51\u7EDC\u3001Tailscale \u6216\u53CD\u5411\u4EE3\u7406\u3002
Dify \u8FD4\u56DE\u8BF7\u6C42\u8FC7\u591A\uFF1A\u53EF\u80FD\u89E6\u53D1\u9650\u6D41\u3002\u8BF7\u964D\u4F4E\u5E76\u53D1\u4E0A\u4F20\u6570\uFF0C\u7A0D\u540E\u91CD\u8BD5\uFF0C\u6216\u5206\u6279\u540C\u6B65\u5927\u76EE\u5F55\u3002
Dify \u670D\u52A1\u5F02\u5E38\uFF1ADify \u8FD4\u56DE 5xx\u3002\u8BF7\u68C0\u67E5 Dify \u5BB9\u5668\u3001\u670D\u52A1\u65E5\u5FD7\u6216\u53CD\u5411\u4EE3\u7406 upstream \u914D\u7F6E\u3002`,helpDatasetsTitle:"\u83B7\u53D6\u4E0D\u5230\u77E5\u8BC6\u5E93",helpDatasetsList:`API Key \u6CA1\u6709\u77E5\u8BC6\u5E93\u6743\u9650\u3002
Key \u5C5E\u4E8E\u9519\u8BEF\u7684\u5DE5\u4F5C\u533A\u3002
\u5F53\u524D Dify \u5B9E\u4F8B\u6CA1\u6709\u53EF\u8BBF\u95EE\u7684\u77E5\u8BC6\u5E93\u3002
Dify \u670D\u52A1\u5730\u5740\u4E0D\u662F\u5F53\u524D\u8BBE\u5907\u53EF\u8BBF\u95EE\u7684 Dify \u670D\u52A1\u3002
\u53CD\u5411\u4EE3\u7406\u6CA1\u6709\u6B63\u786E\u8F6C\u53D1 /v1/datasets\u3002
\u8FD4\u56DE\u7684\u662F\u7F51\u9875\u3001\u767B\u5F55\u9875\u6216\u5176\u4ED6\u975E Dify API \u54CD\u5E94\u3002
\u5EFA\u8BAE\u5148\u70B9\u51FB\u6D4B\u8BD5\u8FDE\u63A5\uFF1B\u8FDE\u63A5\u6210\u529F\u540E\u63D2\u4EF6\u4F1A\u81EA\u52A8\u83B7\u53D6\u77E5\u8BC6\u5E93\u3002`,helpFilesNotSyncingTitle:"\u6587\u4EF6\u6CA1\u6709\u540C\u6B65",helpFilesNotSyncingList:`\u6587\u4EF6\u662F\u5426\u4E3A .md\u3002
\u6587\u4EF6\u8DEF\u5F84\u662F\u5426\u547D\u4E2D\u5DF2\u542F\u7528\u7684\u8DEF\u5F84\u6620\u5C04\u3002
\u6620\u5C04\u4E2D\u662F\u5426\u9009\u62E9\u4E86\u81F3\u5C11\u4E00\u4E2A Dify \u77E5\u8BC6\u5E93\u3002
\u81EA\u52A8\u540C\u6B65\u662F\u5426\u5F00\u542F\u3002
\u5982\u679C\u4F9D\u8D56\u4E8B\u4EF6\u89E6\u53D1\uFF0C\u786E\u8BA4\u6587\u4EF6\u53D8\u66F4\u540E\u540C\u6B65\u662F\u5426\u5F00\u542F\u3002
\u5C1D\u8BD5\u70B9\u51FB\u7ACB\u5373\u540C\u6B65\uFF0C\u5224\u65AD\u662F\u4E8B\u4EF6\u89E6\u53D1\u95EE\u9898\u8FD8\u662F\u8FDE\u63A5 / \u6620\u5C04\u95EE\u9898\u3002`,helpSlowSyncTitle:"\u540C\u6B65\u5F88\u6162",helpSlowSyncList:`\u5C06\u5E76\u53D1\u4E0A\u4F20\u6570\u8C03\u4E3A 1 \u6216 2\u3002
\u907F\u514D\u4E00\u6B21\u540C\u6B65\u8FC7\u5927\u7684\u76EE\u5F55\u3002
\u5BF9\u5927\u77E5\u8BC6\u5E93\u5206\u76EE\u5F55\u3001\u5206\u6279\u540C\u6B65\u3002
\u5982\u679C\u8FDE\u63A5\u4E5F\u4E0D\u7A33\u5B9A\uFF0C\u5148\u70B9\u51FB\u6D4B\u8BD5\u8FDE\u63A5\u5E76\u6309\u8FDE\u63A5\u5931\u8D25\u6392\u67E5\u5904\u7406\u3002`,helpDuplicateDocsTitle:"\u51FA\u73B0\u91CD\u590D\u6587\u6863",helpDuplicateDocsBody:"\u53EF\u80FD\u539F\u56E0\u5305\u62EC\u65E7\u7248\u540C\u6B65\u8BB0\u5F55\u7F3A\u5931\u3001Dify \u8FDC\u7AEF\u6587\u6863\u540D\u66FE\u88AB\u624B\u52A8\u4FEE\u6539\u3001\u672C\u5730\u540C\u6B65\u8BB0\u5F55\u88AB\u91CD\u7F6E\u6216\u4E22\u5931\u3001\u8FDC\u7AEF\u6587\u6863\u66FE\u88AB\u624B\u52A8\u5220\u9664\u540E\u91CD\u65B0\u540C\u6B65\u3002",helpDuplicateDocsList:`\u5148\u5728 Dify \u63A7\u5236\u53F0\u786E\u8BA4\u91CD\u590D\u6587\u6863\u3002
\u4FDD\u7559\u9700\u8981\u7684\u6587\u6863\uFF0C\u5220\u9664\u591A\u4F59\u6587\u6863\u3002
\u56DE\u5230\u63D2\u4EF6\u8BBE\u7F6E\u9875\uFF0C\u70B9\u51FB\u91CD\u7F6E\u540C\u6B65\u8BB0\u5F55\u3002
\u518D\u6267\u884C\u4E00\u6B21\u7ACB\u5373\u540C\u6B65\uFF0C\u8BA9\u63D2\u4EF6\u91CD\u65B0\u5EFA\u7ACB\u8BB0\u5F55\u3002`,helpDebugTitle:"\u8C03\u8BD5\u65E5\u5FD7",helpDebugBody:"\u9047\u5230\u901A\u7528\u8FDE\u63A5\u5931\u8D25\u3001\u6D4F\u89C8\u5668\u8BBF\u95EE\u6B63\u5E38\u4F46\u63D2\u4EF6\u4ECD\u5931\u8D25\u3001NAS / Docker / \u53CD\u5411\u4EE3\u7406\u94FE\u8DEF\u590D\u6742\uFF0C\u6216\u9700\u8981\u53CD\u9988\u95EE\u9898\u7ED9\u5F00\u53D1\u8005\u65F6\uFF0C\u5EFA\u8BAE\u4E34\u65F6\u5F00\u542F\u8C03\u8BD5\u65E5\u5FD7\u3002\u53CD\u9988\u65E5\u5FD7\u65F6\u4E0D\u8981\u516C\u5F00 API Key\u3001\u79C1\u6709\u5730\u5740\u3001\u7B14\u8BB0\u5185\u5BB9\u6216\u5176\u4ED6\u654F\u611F\u4FE1\u606F\u3002",helpPrivacyTitle:"\u9690\u79C1\u4E0E\u5B89\u5168",helpPrivacyBody:"\u63D2\u4EF6\u53EA\u8BFB\u53D6\u5F53\u524D Obsidian \u4ED3\u5E93\u4E2D\u547D\u4E2D\u8DEF\u5F84\u6620\u5C04\u7684 Markdown \u6587\u4EF6\uFF0C\u53EA\u4F1A\u628A\u9700\u8981\u540C\u6B65\u7684 Markdown \u5185\u5BB9\u53D1\u9001\u5230\u4F60\u914D\u7F6E\u7684 Dify \u670D\u52A1\u5730\u5740\uFF0C\u4E0D\u4F1A\u628A\u7B14\u8BB0\u5185\u5BB9\u53D1\u9001\u7ED9\u63D2\u4EF6\u4F5C\u8005\uFF0C\u4E5F\u4E0D\u4F1A\u53D1\u9001\u5230\u9664\u4F60\u914D\u7F6E\u7684 Dify \u670D\u52A1\u4EE5\u5916\u7684\u7B2C\u4E09\u65B9\u670D\u52A1\u3002Dify API Key \u4FDD\u5B58\u5728 Obsidian \u63D2\u4EF6\u672C\u5730\u6570\u636E\u4E2D\uFF0C\u8BF7\u4E0D\u8981\u628A\u5305\u542B\u63D2\u4EF6\u914D\u7F6E\u7684 {configDir} \u76EE\u5F55\u63D0\u4EA4\u5230\u516C\u5F00\u4ED3\u5E93\u3002",navAria:"Obsidian \u8BBE\u7F6E\u5BFC\u822A",navAbout:"\u5173\u4E8E",navEditor:"\u7F16\u8F91\u5668",navFiles:"\u6587\u4EF6\u4E0E\u94FE\u63A5",navAppearance:"\u5916\u89C2",navHotkeys:"\u5FEB\u6377\u952E",navPlugins:"\u7B2C\u4E09\u65B9\u63D2\u4EF6",clearConnectionConfig:"\u6E05\u7A7A\u914D\u7F6E",selectPlaceholder:"\u8BF7\u9009\u62E9",showApiKey:"\u663E\u793A API Key",hideApiKey:"\u9690\u85CF API Key",healthConnection:"\u8FDE\u63A5\u72B6\u6001",healthActiveUrl:"\u5F53\u524D\u5730\u5740",healthRecentSync:"\u6700\u8FD1\u540C\u6B65",connectionUnknown:"\u5C1A\u672A\u6D4B\u8BD5",connectionMissing:"\u5F85\u914D\u7F6E",connectionConnected:"\u5DF2\u8FDE\u63A5",connectionFailedState:"\u8FDE\u63A5\u5931\u8D25",recentSyncNone:"\u5C1A\u672A\u540C\u6B65",quickStepKey:"\u586B\u5199 Key",quickStepKeyDesc:"Dify \u77E5\u8BC6\u5E93 API Key",quickStepTest:"\u6D4B\u8BD5\u8FDE\u63A5",quickStepTestDesc:"\u81EA\u52A8\u8BC6\u522B\u53EF\u7528\u5730\u5740\u5E76\u83B7\u53D6\u77E5\u8BC6\u5E93",quickStepMapping:"\u65B0\u589E\u6620\u5C04",quickStepMappingDesc:"\u9009\u62E9\u8DEF\u5F84\u4E0E\u77E5\u8BC6\u5E93",sectionBasicConnection:"\u57FA\u7840\u8FDE\u63A5",settingsReviewConnectionTitle:"\u8FDE\u63A5\u914D\u7F6E",settingsReviewMappingTitle:"\u8DEF\u5F84\u6620\u5C04",settingsReviewSyncTitle:"\u540C\u6B65\u8BBE\u7F6E",pendingMappingsTitle:"\u65B0\u589E\u7684\u6620\u5C04\u5173\u7CFB",bulkSet:"\u6279\u91CF\u8BBE\u7F6E",enableAll:"\u5168\u90E8\u542F\u7528",pauseAll:"\u5168\u90E8\u6682\u505C",chooseFolderFirst:"\u8BF7\u5148\u9009\u62E9\u76EE\u5F55\u6216\u7B14\u8BB0",pendingEmptyDesc:"\u8BF7\u5148\u9009\u62E9\u5DE6\u4FA7 Obsidian \u76EE\u5F55\u6216\u7B14\u8BB0\uFF0C\u518D\u9009\u62E9\u53F3\u4FA7 Dify \u77E5\u8BC6\u5E93\u5E76\u70B9\u51FB\u65B0\u589E\u3002",pendingAdded:"\u6620\u5C04\u5173\u7CFB\u5DF2\u52A0\u5165\u4E0B\u65B9\u5217\u8868\u3002",selectFolderPlaceholder:"\u8BF7\u9009\u62E9\u76EE\u5F55\u6216\u7B14\u8BB0",datasetsDropdownEmpty:"\u8BF7\u5148\u83B7\u53D6 Dify \u77E5\u8BC6\u5E93",folderSearch:"\u641C\u7D22\u76EE\u5F55\u6216\u7B14\u8BB0",addPendingMapping:"\u65B0\u589E",saveMapping:"\u4FDD\u5B58\u6620\u5C04",syncAfterChange:"\u53D8\u66F4\u540E\u540C\u6B65",fullScanCheck:"\u5168\u91CF\u6821\u9A8C",startupSyncShort:"\u542F\u52A8\u540E\u540C\u6B65",concurrentUpload:"\u5E76\u53D1\u4E0A\u4F20",debounceOption8:"8 \u79D2",debounceOption15:"15 \u79D2",debounceOption30:"30 \u79D2",fullScanOption30:"\u6BCF 30 \u5206\u949F",fullScanOption60:"\u6BCF 60 \u5206\u949F",fullScanOptionOff:"\u5173\u95ED",concurrencyOption2:"2 \u4E2A\u6587\u4EF6",concurrencyOption4:"4 \u4E2A\u6587\u4EF
2026-06-14 12:02:40 +00:00
Enter your Dify service URL.
Click Test connection to automatically load knowledge bases.
Add a path mapping.
Run Sync now when needed, or keep auto sync enabled.`,helpApiUrlTitle:"How to fill connection settings",helpApiUrlBody:`Dify API Key: required. It authorizes access to your Dify knowledge base. Copy it from the Dify knowledge base API settings. Example: dataset-vtpB1fgqv************
Dify service URL: required. This is the main address the plugin uses to connect to Dify. It works for Dify on a cloud server, NAS, local Docker, or another reachable host. Examples: http://dify-host.example.test:5000 or https://dify.example.com
If your Dify knowledge base runs on NAS and you want access from home, work, or outside networks, install and configure Tailscale on both the NAS and your laptop. Then enter: http://tailnet-device.example.test:Dify mapped port. Example: http://tailnet-device.example.test:5000`,helpApiKeyTitle:"API key requirements",helpApiKeyBody:"Use a Dify knowledge base API key with permission to access knowledge bases, list knowledge bases, create documents, update documents, and list documents. If the connection test reports insufficient permissions, check that the key belongs to the correct Dify instance, workspace, and knowledge base.",helpMappingTitle:"Path mappings",helpMappingBody:"Path mappings decide which Obsidian notes sync to which Dify knowledge bases. A folder syncs Markdown files in that folder and its subfolders; a note syncs only that note. Each mapping can be enabled or paused independently.",helpMappingList:`Sync one Obsidian folder or note to one knowledge base.
Sync one Obsidian folder or note to multiple knowledge bases.
Sync multiple Obsidian paths to the same knowledge base.
Choose the entire vault to sync all Markdown files.
Paused mappings do not participate in manual sync, file-change sync, startup sync, or periodic full checks.`,helpSyncModesTitle:"Sync modes",helpSyncModesList:`Sync now: manually scans mapped Markdown files and syncs changes.
Sync after file changes: listens for create, modify, and rename events, then syncs after the debounce period.
Sync after startup: checks changes once after Obsidian finishes loading.
Periodic full check: scans all mapped Markdown files at a fixed interval as a fallback for event sync.`,helpSyncRecommendedTitle:"Daily recommendations",helpSyncRecommendedList:`Auto sync: on.
Startup sync: on.
Periodic full check: on.
Sync interval: 30 minutes.
Sync after changes: 8 to 15 seconds.
Concurrent uploads: 1 to 2 for NAS / Docker / smaller self-hosted deployments.`,helpSyncRulesTitle:"Sync rules",helpSyncRulesBody:"The plugin only syncs .md files. It does not upload images, PDFs, attachments, or other non-Markdown files. Deleting a local note does not automatically delete the remote Dify document. Deleting a path mapping only removes local configuration and does not delete Obsidian files or remote Dify documents.",helpSyncRulesList:`Find target knowledge bases from path mappings.
Hash file content.
Skip unchanged content.
Prefer updating existing Dify documents.
Create a document when no existing match is found.
Use the Obsidian file path as the Dify document name to avoid same-name collisions.`,helpTroubleshootingTitle:"Connection troubleshooting",helpTroubleshootingList:`Confirm the API key is complete and has no extra spaces or newlines.
Confirm the Dify service URL is reachable from the device running Obsidian.
Open your URL + /v1/datasets in a browser.
JSON usually means the address is probably correct.
HTML usually means the address or port points to a web service.
404 usually means the Dify service URL, port, or reverse proxy /v1 forwarding is wrong.
401 can mean the request reached Dify API, but the plugin still needs a valid API key.
403 means you should check key permissions and workspace.
If it cannot open, check IP, domain, port, firewall, Docker mapping, Tailscale, and reverse proxy.`,helpCommonErrorsTitle:"Common error messages",helpCommonErrorsList:`Enter a Dify API key and service URL first: connection settings are incomplete.
The API key is invalid: Dify returned 401. Copy the key again and remove extra spaces or newlines.
The API key does not have knowledge base access: Dify returned 403. Check the key workspace and knowledge base permissions.
The Dify knowledge base API was not found: Dify returned 404. Check the Dify service URL, port, and reverse proxy forwarding.
The current API path is incompatible: confirm the plugin is on the latest build, retry Test connection, then sync; if it persists, enable debug logs and report the Dify version plus error details.
The current address did not return the Dify knowledge base API: it may point to a NAS admin page, Dify web page, login page, or another web service. Check the port and reverse proxy.
The request timed out: confirm this device can reach the Dify service URL; check Dify service load, ports, firewall, Tailscale, and reverse proxy; for large syncs, lower concurrent uploads to 1 or 2, or sync in batches.
Network connection failed: check the URL, port, firewall, Docker mapping, NAS network, Tailscale, or reverse proxy.
Dify returned too many requests: lower upload concurrency, try later, or sync large folders in batches.
Dify returned a server error: check the Dify container, service logs, or reverse proxy upstream.`,helpDatasetsTitle:"Knowledge bases do not appear",helpDatasetsList:`The API key lacks knowledge base permissions.
The key belongs to the wrong workspace.
The current Dify instance has no accessible knowledge bases.
The Dify service URL is not a Dify service reachable from this device.
The reverse proxy does not forward /v1/datasets correctly.
The response is a web page, login page, or other non-Dify API response.
Test the connection first, then get knowledge bases.`,helpFilesNotSyncingTitle:"Files do not sync",helpFilesNotSyncingList:`Confirm the file is .md.
Confirm the file path matches an enabled path mapping.
Confirm the mapping has at least one Dify knowledge base selected.
Confirm auto sync is enabled.
If relying on events, confirm sync after file changes is enabled.
Try Sync now to separate event-trigger issues from connection or mapping issues.`,helpSlowSyncTitle:"Sync is slow",helpSlowSyncList:`Set concurrent uploads to 1 or 2.
Avoid syncing very large folders all at once.
Split large knowledge bases by folder and sync in batches.
If the connection is also unstable, run Test connection and follow connection troubleshooting first.`,helpDuplicateDocsTitle:"Duplicate documents appear",helpDuplicateDocsBody:"Possible causes include missing legacy sync records, manually changed Dify document names, reset or lost local sync records, or remote documents that were manually deleted and then synced again.",helpDuplicateDocsList:`Confirm duplicate documents in the Dify console.
Keep the documents you need and delete extras.
Return to plugin settings and click Reset sync records.
2026-06-14 16:09:25 +00:00
Run Sync now again so the plugin rebuilds records.`,helpDebugTitle:"Debug logs",helpDebugBody:"Temporarily enable debug logs when the error stays generic, browser access works but the plugin still fails, NAS / Docker / reverse proxy routing is complex, or you need to report an issue. Do not share API keys, private addresses, note content, or other sensitive information in logs.",helpPrivacyTitle:"Privacy and safety",helpPrivacyBody:"The plugin only reads Markdown files in the current Obsidian vault that match enabled path mappings. It only sends required Markdown content to your configured Dify service URL. It does not send note content to the plugin author or any third-party service other than your configured Dify service. The Dify API key is stored in Obsidian plugin local data; do not commit a {configDir} directory containing plugin settings to a public repository.",navAria:"Obsidian settings navigation",navAbout:"About",navEditor:"Editor",navFiles:"Files and links",navAppearance:"Appearance",navHotkeys:"Hotkeys",navPlugins:"Third-party plugins",clearConnectionConfig:"Clear config",selectPlaceholder:"Please select",showApiKey:"Show API key",hideApiKey:"Hide API key",healthConnection:"Connection",healthActiveUrl:"Active URL",healthRecentSync:"Recent sync",connectionUnknown:"Not tested",connectionMissing:"Needs setup",connectionConnected:"Connected",connectionFailedState:"Failed",recentSyncNone:"No sync yet",quickStepKey:"Enter key",quickStepKeyDesc:"Dify knowledge API key",quickStepTest:"Test connection",quickStepTestDesc:"Find an endpoint and load bases",quickStepMapping:"Add mapping",quickStepMappingDesc:"Choose folder and bases",sectionBasicConnection:"Basic connection",settingsReviewConnectionTitle:"Connection",settingsReviewMappingTitle:"Directory mapping",settingsReviewSyncTitle:"Sync settings",pendingMappingsTitle:"New mappings",bulkSet:"Bulk set",enableAll:"Enable all",pauseAll:"Pause all",chooseFolderFirst:"Select a folder or note first",pendingEmptyDesc:"Select an Obsidian folder or note on the left, then choose Dify knowledge bases on the right and click Add.",pendingAdded:"Mapping added to the list below.",selectFolderPlaceholder:"Select a folder or note",datasetsDropdownEmpty:"Load Dify knowledge bases first",folderSearch:"Search folders or notes",addPendingMapping:"Add",saveMapping:"Save mapping",syncAfterChange:"After changes",fullScanCheck:"Full check",startupSyncShort:"Startup sync",concurrentUpload:"Concurrent uploads",debounceOption8:"8 seconds",debounceOption15:"15 seconds",debounceOption30:"30 seconds",fullScanOption30:"Every 30 minutes",fullScanOption60:"Every 60 minutes",fullScanOptionOff:"Off",concurrencyOption2:"2 files",concurrencyOption4:"4 files",optionOn:"On",optionOff:"Off",settingsReviewLanUrlName:"NAS LAN address",settingsReviewLanUrlPlaceholder:"Enter NAS LAN address",settingsReviewPublicUrlName:"NAS public address",settingsReviewPublicUrlPlaceholder:"Enter NAS public address",basicConnectionDesc:"First-time setup keeps only the essentials; advanced endpoint options are collapsed.",apiUrlName:"Dify service URL",apiUrlDesc:"Use the Dify service URL reachable from this Obsidian device. You may omit http:// or paste a URL ending in /v1 or /v1/datasets.",connectionNoteIdle:"Enter an API key and Dify service URL, then test the connection.",connectionNoteMissing:"Enter an API key and Dify service URL first.",connectionNoteSuccess:"Connected: {count} knowledge bases via {url}.",connectionNoteFailed:"Connection failed: {message}",advancedConnectionSummary:"Advanced connection: LAN/public fallback URLs, API path compatibility, timeout, retries",expand:"Expand",collapse:"Collapse",advancedSync:"Tune advanced options",syncCadenceName:"Sync cadence",syncCadenceDesc:"Sync {debounce}s after changes; run a full check every {interval} minutes.",syncCadenceEventOnly:"Sync {debounce}s after changes; periodic full checks are off.",syncCadenceIntervalOnly:"File change sync is off; run a full check every {interval} minutes.",syncCadenceOff:"Auto sync is off. Manual sync still works.",sectionDiagnostics:"Sy
${this.createProgressBar(n)} ${n}% (${t}/${i})`;this.showPersistentNotice(s)}showSyncNotice(e){this.showPersistentNotice(e)}showPersistentNotice(e){if(!this.syncProgressNotice){this.syncProgressNotice=new p.Notice(e,0),this.syncProgressNotice.messageEl.addClass("dify-sync-progress");return}this.syncProgressNotice.messageEl.textContent=e}showSyncComplete(e){this.hideProgressNotice();let t=e.total===0?this.t("syncNoChanges"):this.t("syncComplete",ee(e));new p.Notice(t,5e3).messageEl.addClass("dify-sync-complete")}showSyncError(e){this.hideProgressNotice(),new p.Notice(e,8e3).messageEl.addClass("dify-sync-error-notice")}hideProgressNotice(){this.syncProgressNotice&&(this.syncProgressNotice.hide(),this.syncProgressNotice=null)}createProgressBar(e){let i=Math.round(e/100*20);return`[${"\u2588".repeat(i)}${"\u2591".repeat(20-i)}]`}getDatasetLabel(e){let t=this.settings.knowledgeBases.find(i=>i.id===e);return t?`${t.name} (${t.id})`:`${this.t("datasetUnknown")} (${e})`}getDatasetName(e){let t=this.settings.knowledgeBases.find(i=>i.id===e);return(t==null?void 0:t.name)||e}},q=class extends p.PluginSettingTab{constructor(e,t){super(e,t);this.mainMappingPage=0;this.mainMappingPageSize=4;this.outerScrollHostClass="dify-sync-outer-scroll-host";this.innerScrollHostClass="dify-sync-inner-scroll-host";this.outerScrollHosts=new Set;this.scrollbarMarkToken=0;this.renderMode="legacy";this.plugin=t}getSettingDefinitions(){return[{name:this.plugin.t("settingsTitle"),desc:this.plugin.t("settingsSubtitle"),render:e=>(this.renderMode="declarative",this.renderSettingsApp(e.settingEl),()=>{this.scrollbarMarkToken++,this.clearScrollbarHosts()})}]}display(){this.renderLegacySettingsView()}refreshSettingsView(){if(this.renderMode==="declarative"){let e=this.update;if(typeof e=="function"){e.call(this);return}}this.renderLegacySettingsView()}renderLegacySettingsView(){this.renderMode="legacy",this.scrollbarMarkToken++,this.clearScrollbarHosts();let{containerEl:e}=this;e.empty(),this.renderSettingsApp(e)}renderSettingsApp(e){e.addClass("dify-sync-settings");let t=e.createDiv("app"),n=t.createEl("main",{cls:"main"}).createDiv("settings");this.renderTopbar(n),this.renderSyncSummary(n);let s=n.createDiv("dify-sync-content");this.renderConnectionSection(s),this.renderMappingSection(s),this.renderSyncSettingsSection(s),t.createDiv({cls:"toast-region",attr:{"aria-live":"polite","aria-atomic":"true"}}),this.scheduleScrollbarHostMarking(e)}hide(){this.scrollbarMarkToken++,this.clearScrollbarHosts(),super.hide()}scheduleScrollbarHostMarking(e){let t=++this.scrollbarMarkToken;this.clearScrollbarHosts(),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{t===this.scrollbarMarkToken&&e.isConnected&&this.markScrollbarHosts(e)})})}markScrollbarHosts(e){this.clearScrollbarHosts();let t=this.findScrollableAncestors(e);if(t.length===0)return;this.innerScrollHost=e,e.addClass(this.innerScrollHostClass),t.forEach(s=>this.addOuterScrollHost(s));let i=t[0],n=s=>this.handleSettingsWheel(s,e,i);e.addEventListener("wheel",n,{passive:!1}),this.wheelCleanup=()=>e.removeEventListener("wheel",n)}findScrollableAncestors(e){let t=[],i=e.parentElement;for(;i;)this.isVerticalScrollHost(i)&&t.push(i),i=i.parentElement;return t}isVerticalScrollHost(e){let t=window.getComputedStyle(e).overflowY;return e.scrollHeight>e.clientHeight+1&&["auto","scroll","overlay"].includes(t)}addOuterScrollHost(e){e.addClass(this.outerScrollHostClass),this.outerScrollHosts.add(e)}handleSettingsWheel(e,t,i){if(e.defaultPrevented||e.deltaY===0||this.targetCanScrollWithin(e.target,t,e.deltaY))return;let n=i.scrollTop;i.scrollTop+=e.deltaY,i.scrollTop!==n&&(e.preventDefault(),e.stopPropagation())}targetCanScrollWithin(e,t,i){let n=e instanceof HTMLElement?e:null;for(;n&&n!==t;){if(!this.outerScrollHosts.has(n)&&this.elementCanScrollInDirection(n,i))return!0;n=n.parentElement}return!1}elementCanScrollInDirection(e,t){return this.isVerticalScrollHost(e)?t<0?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1:!1}clearScrollbarHosts(){var e,t;(e=this.wheelCleanup)==null||e.call(this),this.
2026-06-14 16:09:25 +00:00
`).map(t=>t.trim()).filter(Boolean)}},_=class extends p.Modal{constructor(e,t,i,n,s,o,l,c=d=>d){super(e);this.title=t,this.message=i,this.confirmText=n,this.cancelText=s,this.onConfirm=o,this.preview=l,this.labelProvider=c}onOpen(){var h,g;let{contentEl:e}=this;e.empty(),this.modalEl.addClass("dify-sync-modal-shell"),this.modalEl.addClass("confirm-modal-shell"),e.addClass("dify-sync-modal"),e.addClass("confirm-modal"),e.createDiv("modal-head").createDiv("modal-title-line").createEl("h2",{text:this.title,attr:{id:"delete-modal-title"}});let s=e.createDiv("confirm-body").createDiv({cls:"confirm-mapping",attr:{"data-role":"delete-mapping-preview"}}),o=s.createDiv("confirm-mapping-item");o.createEl("strong",{text:this.pluginLabel("mappingFolderColumn"),cls:"confirm-mapping-label"}),o.createSpan({text:((h=this.preview)==null?void 0:h.folder)||"-",cls:"confirm-mapping-value"}).setAttr("data-role","delete-folder");let l=s.createDiv("confirm-mapping-item");l.createEl("strong",{text:this.pluginLabel("datasetName"),cls:"confirm-mapping-label"}),l.createSpan({text:((g=this.preview)==null?void 0:g.datasets)||"-",cls:"confirm-mapping-value"}).setAttr("data-role","delete-datasets");let c=e.createDiv("modal-actions");new p.ButtonComponent(c).setButtonText(this.cancelText).onClick(()=>this.close()).buttonEl.setAttr("data-action","close-delete-confirm"),Me(new p.ButtonComponent(c).setButtonText(this.confirmText)).setCta().onClick(()=>{(async()=>(await this.onConfirm(),this.close()))()}).buttonEl.setAttr("data-action","confirm-delete")}pluginLabel(e){return this.labelProvider(e)}},L=class extends p.Modal{constructor(e,t,i,n){super(e);this.selectedFolder="";this.folderSelected=!1;this.selectedDatasets=new Set;this.pendingMappings=[];this.plugin=t,this.isEditing=!!i,this.mapping=i?{id:i.id,folder:i.folder,datasetIds:[...i.datasetIds],enabled:i.enabled}:{id:N(),folder:"",datasetIds:[],enabled:!0},this.onSave=n}onOpen(){let{contentEl:e}=this;e.empty(),this.modalEl.addClass("dify-sync-modal-shell"),this.modalEl.addClass("mapping-modal-shell"),e.addClass("dify-sync-modal"),e.addClass("mapping-modal"),this.contentEl.addEventListener("click",()=>this.closeSiblingDropdowns()),e.createDiv("modal-head").createDiv("modal-title-line").createEl("h2",{text:this.plugin.t(this.isEditing?"mappingModalTitle":"addMappingModalTitle"),attr:{id:"mapping-modal-title"}});let n=e.createDiv("modal-body"),s=n.createDiv("mapping-builder");this.renderFolderPanel(s);let l=s.createDiv({cls:"mapping-arrow",attr:{"aria-hidden":"true"}}).createDiv("mapping-arrow-icon");(0,p.setIcon)(l,"arrow-right"),this.renderDatasetPanel(s),this.renderPendingMappings(n);let c=e.createDiv("modal-actions");new p.ButtonComponent(c).setButtonText(this.plugin.t("cancel")).onClick(()=>this.close()).buttonEl.setAttr("data-action","close-modal");let u=new p.ButtonComponent(c).setButtonText(this.plugin.t("refreshDatasets")).onClick(()=>{(async()=>{try{await this.plugin.refreshKnowledgeBases(),this.renderDatasetChoices(),new p.Notice(this.plugin.t("datasetsRefreshed",{count:this.plugin.settings.knowledgeBases.length}))}catch(g){this.plugin.showConnectionError(g)}})()});u.buttonEl.setAttr("data-action","refresh-modal-datasets"),u.buttonEl.setAttr("aria-label",this.plugin.t("refreshDatasets")),new p.ButtonComponent(c).setButtonText(this.plugin.t("saveMapping")).setCta().onClick(()=>{this.savePendingMappings()}).buttonEl.setAttr("data-action","save-mapping"),this.isEditing?(this.selectFolder(this.mapping.folder,!1),this.mapping.datasetIds.forEach(g=>this.selectedDatasets.add(g)),this.updateDatasetSummary(),this.addPendingMapping(!1,this.mapping.enabled,this.mapping.id)):(this.updateDatasetSummary(),this.updatePendingVisibility())}renderFolderPanel(e){let t=e.createDiv("mapping-panel");t.createDiv("label-line").createEl("label",{text:this.plugin.t("folderName"),attr:{id:"modal-folder-label"}}),this.folderInputEl=t.createEl("input",{attr:{id:"modal-folder",type:"hidden",value:""}});let n=t.createDiv("dropdown-box");n.addEventListener("click",c=>c.stopPropagation());let s=n.createEl("button",{cls:"drop