rhua-chatgpt-web 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api_chain-CffeTgWj.js → api_chain-9SqnXtv4.js} +2 -2
- package/dist/{api_chain-Cm1-dyDV.cjs → api_chain-D-tSpWiT.cjs} +1 -1
- package/dist/{combine_docs_chain-CNJJ5sO6.js → combine_docs_chain-1CYZg8UW.js} +2 -2
- package/dist/{combine_docs_chain-D4MA21kb.cjs → combine_docs_chain-Cbo-3gBL.cjs} +1 -1
- package/dist/{few_shot-DnF0Cusl.js → few_shot-BJlxUHnJ.js} +1 -1
- package/dist/{few_shot-CGIBgJo3.cjs → few_shot-D_01BI__.cjs} +1 -1
- package/dist/{index-03gyPtMo.js → index-4Imsb_i7.js} +1 -1
- package/dist/index-4dt-xwnp.js +4 -0
- package/dist/{index-Bs9Wx9xK.cjs → index-6yNLBi3s.cjs} +1 -1
- package/dist/{index-6AkK2yHt.cjs → index-AkdTvhOX.cjs} +1 -1
- package/dist/index-B8_lGrCO.js +4 -0
- package/dist/{index-Cby-QMZi.js → index-B8wCTU8Z.js} +234 -13
- package/dist/{index-C69x0q_t.cjs → index-BBlS7TLT.cjs} +1 -1
- package/dist/{index-DglvVgbV.cjs → index-BFB-m0FZ.cjs} +2 -2
- package/dist/{index-DOAs6sQ6.cjs → index-B_5SevJt.cjs} +1 -1
- package/dist/{index-jH-J64bZ.js → index-BzhJ5gFa.js} +1 -1
- package/dist/{index-DDl8PJp8.js → index-CNyjNj_K.js} +2 -2
- package/dist/{index-ChDL7uuH.js → index-CP3XBXIw.js} +2 -2
- package/dist/{index-C7FsMglX.cjs → index-CWljpJs2.cjs} +1 -1
- package/dist/{index-BeNhKx5k.cjs → index-CpHzMw47.cjs} +1 -1
- package/dist/{index-D-aDzwZJ.cjs → index-DRTUTwgU.cjs} +1 -1
- package/dist/{index-Bj2WWBl4.cjs → index-DSHi0vNE.cjs} +1 -1
- package/dist/{index-DVHtJvql.cjs → index-DWcdXahf.cjs} +1 -1
- package/dist/{index-BKAYHaBv.js → index-DiZX1H03.js} +1 -1
- package/dist/index-DulcS07N.js +4 -0
- package/dist/{index-CewvW2xF.cjs → index-Oyv-pgaM.cjs} +1 -1
- package/dist/{index-D8GvOnAK.js → index-V78WqiFM.js} +1 -1
- package/dist/{index-DBDBwnS3.cjs → index-ecVIu8Ov.cjs} +1 -1
- package/dist/{index-BLKmhA-g.js → index-nHVdzjgX.js} +1 -1
- package/dist/index-oQ82N-WZ.js +4 -0
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-BATGIE5f.cjs → index.es-C9X4l3OX.cjs} +2 -2
- package/dist/{index.es-Dtu9mbH-.js → index.es-C_A9hjG2.js} +11 -11
- package/dist/index.esm.js +1 -1
- package/dist/{llm_chain-h83PuVpg.cjs → llm_chain-BMAomsq4.cjs} +1 -1
- package/dist/{llm_chain-DczGPxw-.js → llm_chain-BWjAYRks.js} +1 -1
- package/dist/{sequential_chain-BpWi4THb.js → sequential_chain-DGN6gGIS.js} +1 -1
- package/dist/{sequential_chain-CzxiZayE.cjs → sequential_chain-tz_17_S-.cjs} +1 -1
- package/dist/{vector_db_qa-DXjmgRtA.cjs → vector_db_qa-TAVzEWAO.cjs} +1 -1
- package/dist/{vector_db_qa-BEbFCJmw.js → vector_db_qa-nBcWEzVO.js} +3 -3
- package/package.json +1 -1
- package/dist/index-B-KHss7n.js +0 -4
- package/dist/index-BkOFbuiS.js +0 -4
- package/dist/index-CV6OeZ82.js +0 -4
- package/dist/index-CcNIYwQk.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PromptTemplate, i as BaseChain } from "./index-
|
|
2
|
-
import { LLMChain } from "./llm_chain-
|
|
1
|
+
import { P as PromptTemplate, i as BaseChain } from "./index-B8wCTU8Z.js";
|
|
2
|
+
import { LLMChain } from "./llm_chain-BWjAYRks.js";
|
|
3
3
|
import "zod";
|
|
4
4
|
const API_URL_RAW_PROMPT_TEMPLATE = `You are given the below API Documentation:
|
|
5
5
|
{api_docs}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BFB-m0FZ.cjs"),i=require("./llm_chain-BMAomsq4.cjs");require("zod");const t="You are given the below API Documentation:\n{api_docs}\nUsing this documentation, generate the full API url to call for answering the user question.\nYou should build the API url in order to get a response that is as short as possible, while still getting the necessary information to answer the question. Pay attention to deliberately exclude any unnecessary pieces of data in the API call.\n\nQuestion:{question}\nAPI url:",a=new e.PromptTemplate({inputVariables:["api_docs","question"],template:t}),n=`${t} {api_url}\n\nHere is the response from the API:\n\n{api_response}\n\nSummarize this response to answer the original question.\n\nSummary:`,s=new e.PromptTemplate({inputVariables:["api_docs","question","api_url","api_response"],template:n});class r extends e.BaseChain{get inputKeys(){return[this.inputKey]}get outputKeys(){return[this.outputKey]}constructor(e){super(e),Object.defineProperty(this,"apiAnswerChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiRequestChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"inputKey",{enumerable:!0,configurable:!0,writable:!0,value:"question"}),Object.defineProperty(this,"outputKey",{enumerable:!0,configurable:!0,writable:!0,value:"output"}),this.apiRequestChain=e.apiRequestChain,this.apiAnswerChain=e.apiAnswerChain,this.apiDocs=e.apiDocs,this.inputKey=e.inputKey??this.inputKey,this.outputKey=e.outputKey??this.outputKey,this.headers=e.headers??this.headers}async _call(e,i){const t=e[this.inputKey],a=await this.apiRequestChain.predict({question:t,api_docs:this.apiDocs},null==i?void 0:i.getChild("request")),n=await fetch(a,{headers:this.headers}),s=await n.text(),r=await this.apiAnswerChain.predict({question:t,api_docs:this.apiDocs,api_url:a,api_response:s},null==i?void 0:i.getChild("response"));return{[this.outputKey]:r}}_chainType(){return"api_chain"}static async deserialize(e){const{api_request_chain:t,api_answer_chain:a,api_docs:n}=e;if(!t)throw new Error("LLMChain must have api_request_chain");if(!a)throw new Error("LLMChain must have api_answer_chain");if(!n)throw new Error("LLMChain must have api_docs");return new r({apiAnswerChain:await i.LLMChain.deserialize(a),apiRequestChain:await i.LLMChain.deserialize(t),apiDocs:n})}serialize(){return{_type:this._chainType(),api_answer_chain:this.apiAnswerChain.serialize(),api_request_chain:this.apiRequestChain.serialize(),api_docs:this.apiDocs}}static fromLLMAndAPIDocs(e,t,n={}){const{apiUrlPrompt:r=a,apiResponsePrompt:o=s}=n,u=new i.LLMChain({prompt:r,llm:e});return new this({apiAnswerChain:new i.LLMChain({prompt:o,llm:e}),apiRequestChain:u,apiDocs:t,...n})}}exports.APIChain=r;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "zod";
|
|
2
|
-
import { i as BaseChain, P as PromptTemplate } from "./index-
|
|
3
|
-
import { LLMChain } from "./llm_chain-
|
|
2
|
+
import { i as BaseChain, P as PromptTemplate } from "./index-B8wCTU8Z.js";
|
|
3
|
+
import { LLMChain } from "./llm_chain-BWjAYRks.js";
|
|
4
4
|
class StuffDocumentsChain extends BaseChain {
|
|
5
5
|
static lc_name() {
|
|
6
6
|
return "StuffDocumentsChain";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("zod");const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("zod");const e=require("./index-BFB-m0FZ.cjs"),t=require("./llm_chain-BMAomsq4.cjs");class i extends e.BaseChain{static lc_name(){return"StuffDocumentsChain"}get inputKeys(){return[this.inputKey,...this.llmChain.inputKeys].filter(e=>e!==this.documentVariableName)}get outputKeys(){return this.llmChain.outputKeys}constructor(e){super(e),Object.defineProperty(this,"llmChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputKey",{enumerable:!0,configurable:!0,writable:!0,value:"input_documents"}),Object.defineProperty(this,"documentVariableName",{enumerable:!0,configurable:!0,writable:!0,value:"context"}),this.llmChain=e.llmChain,this.documentVariableName=e.documentVariableName??this.documentVariableName,this.inputKey=e.inputKey??this.inputKey}_prepInputs(e){if(!(this.inputKey in e))throw new Error(`Document key ${this.inputKey} not found.`);const{[this.inputKey]:t,...i}=e,n=t.map(({pageContent:e})=>e).join("\n\n");return{...i,[this.documentVariableName]:n}}async _call(e,t){return await this.llmChain.call(this._prepInputs(e),null==t?void 0:t.getChild("combine_documents"))}_chainType(){return"stuff_documents_chain"}static async deserialize(e){if(!e.llm_chain)throw new Error("Missing llm_chain");return new i({llmChain:await t.LLMChain.deserialize(e.llm_chain)})}serialize(){return{_type:this._chainType(),llm_chain:this.llmChain.serialize()}}}class n extends e.BaseChain{static lc_name(){return"MapReduceDocumentsChain"}get inputKeys(){return[this.inputKey,...this.combineDocumentChain.inputKeys]}get outputKeys(){return this.combineDocumentChain.outputKeys}constructor(e){super(e),Object.defineProperty(this,"llmChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputKey",{enumerable:!0,configurable:!0,writable:!0,value:"input_documents"}),Object.defineProperty(this,"documentVariableName",{enumerable:!0,configurable:!0,writable:!0,value:"context"}),Object.defineProperty(this,"returnIntermediateSteps",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"maxTokens",{enumerable:!0,configurable:!0,writable:!0,value:3e3}),Object.defineProperty(this,"maxIterations",{enumerable:!0,configurable:!0,writable:!0,value:10}),Object.defineProperty(this,"ensureMapStep",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"combineDocumentChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.llmChain=e.llmChain,this.combineDocumentChain=e.combineDocumentChain,this.documentVariableName=e.documentVariableName??this.documentVariableName,this.ensureMapStep=e.ensureMapStep??this.ensureMapStep,this.inputKey=e.inputKey??this.inputKey,this.maxTokens=e.maxTokens??this.maxTokens,this.maxIterations=e.maxIterations??this.maxIterations,this.returnIntermediateSteps=e.returnIntermediateSteps??!1}async _call(e,t){if(!(this.inputKey in e))throw new Error(`Document key ${this.inputKey} not found.`);const{[this.inputKey]:i,...n}=e;let a=i,r=[];for(let o=0;o<this.maxIterations;o+=1){const e=a.map(e=>({[this.documentVariableName]:e.pageContent,...n}));if(0!==o||!this.ensureMapStep){const e=await this.combineDocumentChain.llmChain.prompt.format(this.combineDocumentChain._prepInputs({[this.combineDocumentChain.inputKey]:a,...n}));if(await this.combineDocumentChain.llmChain._getNumTokens(e)<this.maxTokens)break}const i=await this.llmChain.apply(e,t?Array.from({length:e.length},(e,i)=>t.getChild(`map_${i+1}`)):void 0),{outputKey:s}=this.llmChain;this.returnIntermediateSteps&&(r=r.concat(i.map(e=>e[s]))),a=i.map(e=>({pageContent:e[s],metadata:{}}))}const s={[this.combineDocumentChain.inputKey]:a,...n},u=await this.combineDocumentChain.call(s,null==t?void 0:t.getChild("combine_documents"));return this.returnIntermediateSteps?{...u,intermediateSteps:r}:u}_chainType(){return"map_reduce_documents_chain"}static async deserialize(e){if(!e.llm_chain)throw new Error("Missing llm_chain");if(!e.combine_document_chain)throw new Error("Missing combine_document_chain");return new n({llmChain:await t.LLMChain.deserialize(e.llm_chain),combineDocumentChain:await i.deserialize(e.combine_document_chain)})}serialize(){return{_type:this._chainType(),llm_chain:this.llmChain.serialize(),combine_document_chain:this.combineDocumentChain.serialize()}}}class a extends e.BaseChain{static lc_name(){return"RefineDocumentsChain"}get defaultDocumentPrompt(){return new e.PromptTemplate({inputVariables:["page_content"],template:"{page_content}"})}get inputKeys(){return[...new Set([this.inputKey,...this.llmChain.inputKeys,...this.refineLLMChain.inputKeys])].filter(e=>e!==this.documentVariableName&&e!==this.initialResponseName)}get outputKeys(){return[this.outputKey]}constructor(e){super(e),Object.defineProperty(this,"llmChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputKey",{enumerable:!0,configurable:!0,writable:!0,value:"input_documents"}),Object.defineProperty(this,"outputKey",{enumerable:!0,configurable:!0,writable:!0,value:"output_text"}),Object.defineProperty(this,"documentVariableName",{enumerable:!0,configurable:!0,writable:!0,value:"context"}),Object.defineProperty(this,"initialResponseName",{enumerable:!0,configurable:!0,writable:!0,value:"existing_answer"}),Object.defineProperty(this,"refineLLMChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"documentPrompt",{enumerable:!0,configurable:!0,writable:!0,value:this.defaultDocumentPrompt}),this.llmChain=e.llmChain,this.refineLLMChain=e.refineLLMChain,this.documentVariableName=e.documentVariableName??this.documentVariableName,this.inputKey=e.inputKey??this.inputKey,this.outputKey=e.outputKey??this.outputKey,this.documentPrompt=e.documentPrompt??this.documentPrompt,this.initialResponseName=e.initialResponseName??this.initialResponseName}async _constructInitialInputs(e,t){const i={page_content:e.pageContent,...e.metadata},n={};this.documentPrompt.inputVariables.forEach(e=>{n[e]=i[e]});return{...{[this.documentVariableName]:await this.documentPrompt.format({...n})},...t}}async _constructRefineInputs(e,t){const i={page_content:e.pageContent,...e.metadata},n={};this.documentPrompt.inputVariables.forEach(e=>{n[e]=i[e]});const a={[this.documentVariableName]:await this.documentPrompt.format({...n})};return{[this.initialResponseName]:t,...a}}async _call(e,t){if(!(this.inputKey in e))throw new Error(`Document key ${this.inputKey} not found.`);const{[this.inputKey]:i,...n}=e,a=i,r=await this._constructInitialInputs(a[0],n);let s=await this.llmChain.predict({...r},null==t?void 0:t.getChild("answer"));for(let u=1;u<a.length;u+=1){const e={...await this._constructRefineInputs(a[u],s),...n};s=await this.refineLLMChain.predict({...e},null==t?void 0:t.getChild("refine"))}return{[this.outputKey]:s}}_chainType(){return"refine_documents_chain"}static async deserialize(e){const i=e.llm_chain;if(!i)throw new Error("Missing llm_chain");const n=e.refine_llm_chain;if(!n)throw new Error("Missing refine_llm_chain");return new a({llmChain:await t.LLMChain.deserialize(i),refineLLMChain:await t.LLMChain.deserialize(n)})}serialize(){return{_type:this._chainType(),llm_chain:this.llmChain.serialize(),refine_llm_chain:this.refineLLMChain.serialize()}}}exports.MapReduceDocumentsChain=n,exports.RefineDocumentsChain=a,exports.StuffDocumentsChain=i;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseStringPromptTemplate, e as checkValidTemplate, g as renderTemplate, P as PromptTemplate } from "./index-
|
|
1
|
+
import { B as BaseStringPromptTemplate, e as checkValidTemplate, g as renderTemplate, P as PromptTemplate } from "./index-B8wCTU8Z.js";
|
|
2
2
|
import "zod";
|
|
3
3
|
class FewShotPromptTemplate extends BaseStringPromptTemplate {
|
|
4
4
|
constructor(input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BFB-m0FZ.cjs");require("zod");class t extends e.BaseStringPromptTemplate{constructor(t){if(super(t),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"examples",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exampleSelector",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"examplePrompt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"suffix",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"exampleSeparator",{enumerable:!0,configurable:!0,writable:!0,value:"\n\n"}),Object.defineProperty(this,"prefix",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"templateFormat",{enumerable:!0,configurable:!0,writable:!0,value:"f-string"}),Object.defineProperty(this,"validateTemplate",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.assign(this,t),void 0!==this.examples&&void 0!==this.exampleSelector)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(void 0===this.examples&&void 0===this.exampleSelector)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let t=this.inputVariables;this.partialVariables&&(t=t.concat(Object.keys(this.partialVariables))),e.checkValidTemplate(this.prefix+this.suffix,this.templateFormat,t)}}_getPromptType(){return"few_shot"}static lc_name(){return"FewShotPromptTemplate"}async getExamples(e){if(void 0!==this.examples)return this.examples;if(void 0!==this.exampleSelector)return this.exampleSelector.selectExamples(e);throw new Error("One of 'examples' and 'example_selector' should be provided")}async partial(e){const r=this.inputVariables.filter(t=>!(t in e)),a={...this.partialVariables??{},...e},i={...this,inputVariables:r,partialVariables:a};return new t(i)}async format(t){const r=await this.mergePartialAndUserVariables(t),a=await this.getExamples(r),i=await Promise.all(a.map(e=>this.examplePrompt.format(e))),l=[this.prefix,...i,this.suffix].join(this.exampleSeparator);return e.renderTemplate(l,this.templateFormat,r)}serialize(){if(this.exampleSelector||!this.examples)throw new Error("Serializing an example selector is not currently supported");if(void 0!==this.outputParser)throw new Error("Serializing an output parser is not currently supported");return{_type:this._getPromptType(),input_variables:this.inputVariables,example_prompt:this.examplePrompt.serialize(),example_separator:this.exampleSeparator,suffix:this.suffix,prefix:this.prefix,template_format:this.templateFormat,examples:this.examples}}static async deserialize(r){const{example_prompt:a}=r;if(!a)throw new Error("Missing example prompt");const i=await e.PromptTemplate.deserialize(a);let l;if(!Array.isArray(r.examples))throw new Error("Invalid examples format. Only list or string are supported.");return l=r.examples,new t({inputVariables:r.input_variables,examplePrompt:i,examples:l,exampleSeparator:r.example_separator,prefix:r.prefix,suffix:r.suffix,templateFormat:r.template_format})}}exports.FewShotPromptTemplate=t;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z as zwitch } from "./index-BEZf1ZPW.js";
|
|
2
|
-
import { q as formatCodeAsIndented, s as formatHeadingAsSetext, t as decodeString, x as encodeCharacterReference, y as patternInScope, z as handle } from "./index-
|
|
2
|
+
import { q as formatCodeAsIndented, s as formatHeadingAsSetext, t as decodeString, x as encodeCharacterReference, y as patternInScope, z as handle } from "./index-B8wCTU8Z.js";
|
|
3
3
|
const own = {}.hasOwnProperty;
|
|
4
4
|
function configure(base, extension) {
|
|
5
5
|
let index = -1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-B_5SevJt.cjs"),t=require("./index-BFB-m0FZ.cjs"),n=["pre","script","style","textarea"],i={};function a(e,t){return Boolean(t&&"element"===t.type&&e.blanks.length>0&&e.blanks.includes(t.tagName))}function l(t,n){return"root"===n.type||"element"===n.type&&(t.head||"script"===n.tagName||e.embedded(n)||!e.phrasing(n))}exports.default=function(r){return function(c){!function(r,c){const d=c||i,s={blanks:d.blanks||[],head:!1,indentInitial:!1!==d.indentInitial,indent:"number"==typeof d.indent?" ".repeat(d.indent):"string"==typeof d.indent?d.indent:" "};function o(e,n,i){const l=e[e.length-1],r=l&&t.whitespace(l)?e[e.length-2]:l,c=(a(s,r)&&a(s,i)?"\n\n":"\n")+s.indent.repeat(Math.max(n,0));l&&"text"===l.type?l.value=t.whitespace(l)?c:l.value+c:e.push({type:"text",value:c})}e.minifyWhitespace(r,{newlines:!0}),t.visitParents(r,function(e,i){if(!("children"in e))return;if("element"===e.type&&"head"===e.tagName&&(s.head=!0),s.head&&"element"===e.type&&"body"===e.tagName&&(s.head=!1),"element"===e.type&&n.includes(e.tagName))return t.SKIP;if(0===e.children.length||!l(s,e))return;let a=i.length;s.indentInitial||a--;let r=!1;for(const t of e.children)"comment"!==t.type&&"text"!==t.type||(t.value.includes("\n")&&(r=!0),t.value=t.value.replace(/ *\n/g,"$&"+s.indent.repeat(a)));const c=[];let d;for(const t of e.children)(l(s,t)||r&&!d)&&(o(c,a,t),r=!0),d=t,c.push(t);d&&(r||l(s,d))&&(t.whitespace(d)&&(c.pop(),d=c[c.length-1]),o(c,a-1)),e.children=c})}(c,r)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BFB-m0FZ.cjs");exports.fromDom=e.fromDom;
|
|
@@ -46929,7 +46929,7 @@ const BlockEdit = ({
|
|
|
46929
46929
|
const initVueEditor = async () => {
|
|
46930
46930
|
if (editorRef.current) {
|
|
46931
46931
|
try {
|
|
46932
|
-
const BlockNoteEditorModule = await import("./index.es-
|
|
46932
|
+
const BlockNoteEditorModule = await import("./index.es-C_A9hjG2.js");
|
|
46933
46933
|
const BlockNoteEditor = BlockNoteEditorModule.BlockNoteEditor;
|
|
46934
46934
|
const theme = {
|
|
46935
46935
|
colors: {
|
|
@@ -47893,7 +47893,7 @@ const AiBlockEdit$1 = ({
|
|
|
47893
47893
|
const initVueEditor = async () => {
|
|
47894
47894
|
if (editorRef.current) {
|
|
47895
47895
|
try {
|
|
47896
|
-
const BlockNoteEditorModule = await import("./index.es-
|
|
47896
|
+
const BlockNoteEditorModule = await import("./index.es-C_A9hjG2.js");
|
|
47897
47897
|
const BlockNoteEditor = BlockNoteEditorModule.BlockNoteEditor;
|
|
47898
47898
|
const theme = {
|
|
47899
47899
|
colors: {
|
|
@@ -48653,7 +48653,7 @@ const AiBlockEditInner = ({ getSetBlockContent, baseUrl, token, onBack, onRegene
|
|
|
48653
48653
|
const initVueEditor = async () => {
|
|
48654
48654
|
if (editorRef.current) {
|
|
48655
48655
|
try {
|
|
48656
|
-
const BlockNoteEditorModule = await import("./index.es-
|
|
48656
|
+
const BlockNoteEditorModule = await import("./index.es-C_A9hjG2.js");
|
|
48657
48657
|
const BlockNoteEditor = BlockNoteEditorModule.BlockNoteEditor;
|
|
48658
48658
|
const theme = {
|
|
48659
48659
|
colors: {
|
|
@@ -48794,6 +48794,226 @@ const AiBlockEditInner = ({ getSetBlockContent, baseUrl, token, onBack, onRegene
|
|
|
48794
48794
|
});
|
|
48795
48795
|
return text2;
|
|
48796
48796
|
};
|
|
48797
|
+
const hasUnacceptedInsertInDocument = (content2) => {
|
|
48798
|
+
if (!Array.isArray(content2)) return false;
|
|
48799
|
+
const hasUnacceptedInsertInNode = (node2) => {
|
|
48800
|
+
if (!node2 || typeof node2 !== "object") return false;
|
|
48801
|
+
const props = node2.props || node2.attributes || {};
|
|
48802
|
+
const meta = node2.meta || node2.attrs || {};
|
|
48803
|
+
const isPendingFlag = (obj) => {
|
|
48804
|
+
if (!obj || typeof obj !== "object") return false;
|
|
48805
|
+
const status = obj.status || obj.insertStatus || obj.aiStatus || obj.aiInsertStatus || obj.changeStatus || obj.suggestionStatus;
|
|
48806
|
+
const type = obj.type || obj.changeType || obj.actionType;
|
|
48807
|
+
const accepted = obj.accepted ?? obj.resolved ?? obj.confirmed;
|
|
48808
|
+
if (typeof status === "string" && status.toLowerCase().includes("pending")) {
|
|
48809
|
+
return true;
|
|
48810
|
+
}
|
|
48811
|
+
if (typeof type === "string" && type.toLowerCase().includes("insert") && accepted === false) {
|
|
48812
|
+
return true;
|
|
48813
|
+
}
|
|
48814
|
+
if (obj.pending === true || obj.isPending === true) {
|
|
48815
|
+
return true;
|
|
48816
|
+
}
|
|
48817
|
+
if (obj.insertPending === true || obj.unacceptedInsert === true) {
|
|
48818
|
+
return true;
|
|
48819
|
+
}
|
|
48820
|
+
return false;
|
|
48821
|
+
};
|
|
48822
|
+
if (isPendingFlag(props) || isPendingFlag(meta) || isPendingFlag(node2)) {
|
|
48823
|
+
return true;
|
|
48824
|
+
}
|
|
48825
|
+
const marks = node2.marks;
|
|
48826
|
+
if (Array.isArray(marks) && marks.some((m) => isPendingFlag(m))) {
|
|
48827
|
+
return true;
|
|
48828
|
+
}
|
|
48829
|
+
const children = [];
|
|
48830
|
+
if (Array.isArray(node2.content)) {
|
|
48831
|
+
children.push(...node2.content);
|
|
48832
|
+
}
|
|
48833
|
+
if (Array.isArray(node2.children)) {
|
|
48834
|
+
children.push(...node2.children);
|
|
48835
|
+
}
|
|
48836
|
+
return children.some((child) => hasUnacceptedInsertInNode(child));
|
|
48837
|
+
};
|
|
48838
|
+
return content2.some((node2) => hasUnacceptedInsertInNode(node2));
|
|
48839
|
+
};
|
|
48840
|
+
const hasPendingInsertInDom = () => {
|
|
48841
|
+
try {
|
|
48842
|
+
const container = document.querySelector(
|
|
48843
|
+
".blocknote-editor-container"
|
|
48844
|
+
);
|
|
48845
|
+
if (!container) return false;
|
|
48846
|
+
if (container.querySelector(
|
|
48847
|
+
"[data-ai-insert-pending],[data-insert-pending],[data-pending-insert]"
|
|
48848
|
+
)) {
|
|
48849
|
+
return true;
|
|
48850
|
+
}
|
|
48851
|
+
if (container.querySelector(
|
|
48852
|
+
".ai-insert-pending,.bn-ai-suggestion,.bn-ai-pending"
|
|
48853
|
+
)) {
|
|
48854
|
+
return true;
|
|
48855
|
+
}
|
|
48856
|
+
const buttons = Array.from(
|
|
48857
|
+
container.querySelectorAll("button")
|
|
48858
|
+
);
|
|
48859
|
+
const hasReviewButtons = buttons.some((btn) => {
|
|
48860
|
+
const text2 = (btn.textContent || "").trim();
|
|
48861
|
+
return text2 === "接受" || text2 === "取消";
|
|
48862
|
+
});
|
|
48863
|
+
return hasReviewButtons;
|
|
48864
|
+
} catch (e) {
|
|
48865
|
+
console.warn("DOM 检查待确认插入内容失败:", e);
|
|
48866
|
+
return false;
|
|
48867
|
+
}
|
|
48868
|
+
};
|
|
48869
|
+
async function handleExportWord() {
|
|
48870
|
+
var _a2, _b;
|
|
48871
|
+
if (exporting) return;
|
|
48872
|
+
setExporting(true);
|
|
48873
|
+
try {
|
|
48874
|
+
const editor = (_b = (_a2 = editorVmRef.current) == null ? void 0 : _a2.getEditor) == null ? void 0 : _b.call(_a2);
|
|
48875
|
+
if (!editor) {
|
|
48876
|
+
Toast.error("编辑器尚未就绪,稍后再试");
|
|
48877
|
+
return;
|
|
48878
|
+
}
|
|
48879
|
+
let hasPendingInsert = false;
|
|
48880
|
+
try {
|
|
48881
|
+
const anyEditor = editor;
|
|
48882
|
+
if (typeof anyEditor.hasPendingInsert === "function") {
|
|
48883
|
+
hasPendingInsert = !!anyEditor.hasPendingInsert();
|
|
48884
|
+
} else if (typeof anyEditor.hasUnacceptedInsert === "function") {
|
|
48885
|
+
hasPendingInsert = !!anyEditor.hasUnacceptedInsert();
|
|
48886
|
+
} else if (Array.isArray(anyEditor.document)) {
|
|
48887
|
+
hasPendingInsert = hasUnacceptedInsertInDocument(anyEditor.document);
|
|
48888
|
+
}
|
|
48889
|
+
if (!hasPendingInsert) {
|
|
48890
|
+
hasPendingInsert = hasPendingInsertInDom();
|
|
48891
|
+
}
|
|
48892
|
+
} catch (checkErr) {
|
|
48893
|
+
console.warn("检查插入内容状态失败:", checkErr);
|
|
48894
|
+
}
|
|
48895
|
+
if (hasPendingInsert) {
|
|
48896
|
+
Toast.warning(
|
|
48897
|
+
"当前文档中存在待确认的插入内容,请在编辑器中接受或取消后再导出"
|
|
48898
|
+
);
|
|
48899
|
+
return;
|
|
48900
|
+
}
|
|
48901
|
+
const content2 = editor.document;
|
|
48902
|
+
const { Document, Packer, Paragraph, TextRun, HeadingLevel } = await import("docx");
|
|
48903
|
+
const paragraphs = [];
|
|
48904
|
+
let firstHeadingText = "";
|
|
48905
|
+
const processBlock = (block) => {
|
|
48906
|
+
var _a3;
|
|
48907
|
+
if (!block || typeof block !== "object") return;
|
|
48908
|
+
if (block.type === "heading") {
|
|
48909
|
+
const level = ((_a3 = block.props) == null ? void 0 : _a3.level) || 1;
|
|
48910
|
+
const text2 = extractTextFromContent(block.content || []);
|
|
48911
|
+
if (!firstHeadingText && text2.trim()) {
|
|
48912
|
+
firstHeadingText = text2.trim();
|
|
48913
|
+
}
|
|
48914
|
+
const headingLevels = [
|
|
48915
|
+
HeadingLevel.HEADING_1,
|
|
48916
|
+
HeadingLevel.HEADING_2,
|
|
48917
|
+
HeadingLevel.HEADING_3,
|
|
48918
|
+
HeadingLevel.HEADING_4,
|
|
48919
|
+
HeadingLevel.HEADING_5,
|
|
48920
|
+
HeadingLevel.HEADING_6
|
|
48921
|
+
];
|
|
48922
|
+
paragraphs.push(
|
|
48923
|
+
new Paragraph({
|
|
48924
|
+
text: text2,
|
|
48925
|
+
heading: headingLevels[Math.min(level - 1, 5)] || HeadingLevel.HEADING_1
|
|
48926
|
+
})
|
|
48927
|
+
);
|
|
48928
|
+
} else if (block.type === "paragraph") {
|
|
48929
|
+
const text2 = extractTextFromContent(block.content || []);
|
|
48930
|
+
if (text2.trim()) {
|
|
48931
|
+
paragraphs.push(
|
|
48932
|
+
new Paragraph({
|
|
48933
|
+
children: [new TextRun(text2)]
|
|
48934
|
+
})
|
|
48935
|
+
);
|
|
48936
|
+
}
|
|
48937
|
+
} else if (block.type === "bulletListItem") {
|
|
48938
|
+
const text2 = extractTextFromContent(block.content || []);
|
|
48939
|
+
if (text2.trim()) {
|
|
48940
|
+
paragraphs.push(
|
|
48941
|
+
new Paragraph({
|
|
48942
|
+
children: [new TextRun(`• ${text2}`)]
|
|
48943
|
+
})
|
|
48944
|
+
);
|
|
48945
|
+
}
|
|
48946
|
+
} else if (block.type === "numberedListItem") {
|
|
48947
|
+
const text2 = extractTextFromContent(block.content || []);
|
|
48948
|
+
if (text2.trim()) {
|
|
48949
|
+
paragraphs.push(
|
|
48950
|
+
new Paragraph({
|
|
48951
|
+
children: [new TextRun(`1. ${text2}`)]
|
|
48952
|
+
})
|
|
48953
|
+
);
|
|
48954
|
+
}
|
|
48955
|
+
} else if (block.type === "blockquote") {
|
|
48956
|
+
const text2 = extractTextFromContent(block.content || []);
|
|
48957
|
+
if (text2.trim()) {
|
|
48958
|
+
paragraphs.push(
|
|
48959
|
+
new Paragraph({
|
|
48960
|
+
children: [new TextRun(`> ${text2}`)]
|
|
48961
|
+
})
|
|
48962
|
+
);
|
|
48963
|
+
}
|
|
48964
|
+
} else if (block.type === "codeBlock") {
|
|
48965
|
+
const text2 = extractTextFromContent(block.content || []);
|
|
48966
|
+
if (text2.trim()) {
|
|
48967
|
+
paragraphs.push(
|
|
48968
|
+
new Paragraph({
|
|
48969
|
+
children: [new TextRun(text2)]
|
|
48970
|
+
})
|
|
48971
|
+
);
|
|
48972
|
+
}
|
|
48973
|
+
} else {
|
|
48974
|
+
const text2 = extractTextFromContent(block.content || []);
|
|
48975
|
+
if (text2.trim()) {
|
|
48976
|
+
paragraphs.push(
|
|
48977
|
+
new Paragraph({
|
|
48978
|
+
children: [new TextRun(text2)]
|
|
48979
|
+
})
|
|
48980
|
+
);
|
|
48981
|
+
}
|
|
48982
|
+
}
|
|
48983
|
+
};
|
|
48984
|
+
if (Array.isArray(content2)) {
|
|
48985
|
+
content2.forEach(processBlock);
|
|
48986
|
+
}
|
|
48987
|
+
const doc = new Document({
|
|
48988
|
+
sections: [
|
|
48989
|
+
{
|
|
48990
|
+
properties: {},
|
|
48991
|
+
children: paragraphs.length > 0 ? paragraphs : [
|
|
48992
|
+
new Paragraph({
|
|
48993
|
+
children: [new TextRun("文档内容为空")]
|
|
48994
|
+
})
|
|
48995
|
+
]
|
|
48996
|
+
}
|
|
48997
|
+
]
|
|
48998
|
+
});
|
|
48999
|
+
const blob = await Packer.toBlob(doc);
|
|
49000
|
+
const url = URL.createObjectURL(blob);
|
|
49001
|
+
const a = document.createElement("a");
|
|
49002
|
+
a.href = url;
|
|
49003
|
+
const sanitizedFileName = (firstHeadingText || "文档").replace(/[\\/:*?"<>|]/g, "_").trim() || "文档";
|
|
49004
|
+
a.download = `${sanitizedFileName}.docx`;
|
|
49005
|
+
document.body.appendChild(a);
|
|
49006
|
+
a.click();
|
|
49007
|
+
document.body.removeChild(a);
|
|
49008
|
+
URL.revokeObjectURL(url);
|
|
49009
|
+
Toast.success("Word 文档导出成功");
|
|
49010
|
+
} catch (err) {
|
|
49011
|
+
console.error("导出 Word 失败:", err);
|
|
49012
|
+
Toast.error("导出失败,请重试或查看控制台日志");
|
|
49013
|
+
} finally {
|
|
49014
|
+
setExporting(false);
|
|
49015
|
+
}
|
|
49016
|
+
}
|
|
48797
49017
|
const setBlockContent = (content2, type) => {
|
|
48798
49018
|
var _a2;
|
|
48799
49019
|
try {
|
|
@@ -48841,7 +49061,8 @@ const AiBlockEditInner = ({ getSetBlockContent, baseUrl, token, onBack, onRegene
|
|
|
48841
49061
|
useImperativeHandle(ref, () => ({
|
|
48842
49062
|
getBlockContent,
|
|
48843
49063
|
setBlockContent,
|
|
48844
|
-
clearBlockContent
|
|
49064
|
+
clearBlockContent,
|
|
49065
|
+
handleExportWord
|
|
48845
49066
|
}));
|
|
48846
49067
|
useEffect(() => {
|
|
48847
49068
|
if (getSetBlockContent) {
|
|
@@ -49181,7 +49402,7 @@ class BasePromptTemplate extends Runnable {
|
|
|
49181
49402
|
return PromptTemplate2.deserialize({ ...data, _type: "prompt" });
|
|
49182
49403
|
}
|
|
49183
49404
|
case "few_shot": {
|
|
49184
|
-
const { FewShotPromptTemplate } = await import("./few_shot-
|
|
49405
|
+
const { FewShotPromptTemplate } = await import("./few_shot-BJlxUHnJ.js");
|
|
49185
49406
|
return FewShotPromptTemplate.deserialize(data);
|
|
49186
49407
|
}
|
|
49187
49408
|
default:
|
|
@@ -50753,35 +50974,35 @@ class BaseChain extends BaseLangChain {
|
|
|
50753
50974
|
static async deserialize(data, values = {}) {
|
|
50754
50975
|
switch (data._type) {
|
|
50755
50976
|
case "llm_chain": {
|
|
50756
|
-
const { LLMChain } = await import("./llm_chain-
|
|
50977
|
+
const { LLMChain } = await import("./llm_chain-BWjAYRks.js");
|
|
50757
50978
|
return LLMChain.deserialize(data);
|
|
50758
50979
|
}
|
|
50759
50980
|
case "sequential_chain": {
|
|
50760
|
-
const { SequentialChain } = await import("./sequential_chain-
|
|
50981
|
+
const { SequentialChain } = await import("./sequential_chain-DGN6gGIS.js");
|
|
50761
50982
|
return SequentialChain.deserialize(data);
|
|
50762
50983
|
}
|
|
50763
50984
|
case "simple_sequential_chain": {
|
|
50764
|
-
const { SimpleSequentialChain } = await import("./sequential_chain-
|
|
50985
|
+
const { SimpleSequentialChain } = await import("./sequential_chain-DGN6gGIS.js");
|
|
50765
50986
|
return SimpleSequentialChain.deserialize(data);
|
|
50766
50987
|
}
|
|
50767
50988
|
case "stuff_documents_chain": {
|
|
50768
|
-
const { StuffDocumentsChain } = await import("./combine_docs_chain-
|
|
50989
|
+
const { StuffDocumentsChain } = await import("./combine_docs_chain-1CYZg8UW.js");
|
|
50769
50990
|
return StuffDocumentsChain.deserialize(data);
|
|
50770
50991
|
}
|
|
50771
50992
|
case "map_reduce_documents_chain": {
|
|
50772
|
-
const { MapReduceDocumentsChain } = await import("./combine_docs_chain-
|
|
50993
|
+
const { MapReduceDocumentsChain } = await import("./combine_docs_chain-1CYZg8UW.js");
|
|
50773
50994
|
return MapReduceDocumentsChain.deserialize(data);
|
|
50774
50995
|
}
|
|
50775
50996
|
case "refine_documents_chain": {
|
|
50776
|
-
const { RefineDocumentsChain } = await import("./combine_docs_chain-
|
|
50997
|
+
const { RefineDocumentsChain } = await import("./combine_docs_chain-1CYZg8UW.js");
|
|
50777
50998
|
return RefineDocumentsChain.deserialize(data);
|
|
50778
50999
|
}
|
|
50779
51000
|
case "vector_db_qa": {
|
|
50780
|
-
const { VectorDBQAChain } = await import("./vector_db_qa-
|
|
51001
|
+
const { VectorDBQAChain } = await import("./vector_db_qa-nBcWEzVO.js");
|
|
50781
51002
|
return VectorDBQAChain.deserialize(data, values);
|
|
50782
51003
|
}
|
|
50783
51004
|
case "api_chain": {
|
|
50784
|
-
const { APIChain } = await import("./api_chain-
|
|
51005
|
+
const { APIChain } = await import("./api_chain-9SqnXtv4.js");
|
|
50785
51006
|
return APIChain.deserialize(data);
|
|
50786
51007
|
}
|
|
50787
51008
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-2yo2kUGy.cjs"),t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-2yo2kUGy.cjs"),t=require("./index-BFB-m0FZ.cjs"),n={}.hasOwnProperty;function r(e,t){let o,i=-1;if(t.extensions)for(;++i<t.extensions.length;)r(e,t.extensions[i]);for(o in t)if(n.call(t,o))switch(o){case"extensions":break;case"unsafe":case"join":c(e[o],t[o]);break;case"handlers":a(e[o],t[o]);break;default:e.options[o]=t[o]}return e}function c(e,t){t&&e.push(...t)}function a(e,t){t&&Object.assign(e,t)}const o=[function(e,n,r,c){if("code"===n.type&&t.formatCodeAsIndented(n,c)&&("list"===e.type||e.type===n.type&&t.formatCodeAsIndented(e,c)))return!1;if("spread"in r&&"boolean"==typeof r.spread){if("paragraph"===e.type&&(e.type===n.type||"definition"===n.type||"heading"===n.type&&t.formatHeadingAsSetext(n,c)))return;return r.spread?1:0}}];const i=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],s=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:i},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:i},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:i},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:i},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:i},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:i},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:i},{atBreak:!0,character:"~"}];function h(e){return e.label||!e.identifier?e.label||"":t.decodeString(e.identifier)}function u(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function f(e,t,n,r){let c=r.join.length;for(;c--;){const a=r.join[c](e,t,n,r);if(!0===a||1===a)break;if("number"==typeof a)return"\n".repeat(1+a);if(!1===a)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const l=/\r?\n|\r/g;function d(e,t){const n=[];let r,c=0,a=0;for(;r=l.exec(e);)o(e.slice(c,r.index)),n.push(r[0]),c=r.index+r[0].length,a++;return o(e.slice(c)),n.join("");function o(e){n.push(t(e,a,!e))}}function p(e,t){return e-t}function g(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,r=[],c=[],a=e+t;let o,i=-1,s=0;for(;o=n.exec(a);)r.push(o.index);for(;++i<r.length;)s!==r[i]&&c.push(e.slice(s,r[i])),c.push("\\"),s=r[i];return c.push(e.slice(s)),c.join("")}function C(e){const t=e||{},n=t.now||{};let r=t.lineShift||0,c=n.line||1,a=n.column||1;return{move:function(e){const t=e||"",n=t.split(/\r?\n|\r/g),o=n[n.length-1];return c+=n.length-1,a=1===n.length?a+o.length:1+o.length+r,t},current:function(){return{now:{line:c,column:a},lineShift:r}},shift:function(e){r+=e}}}function b(n,c){const a=c||{},i={associationId:h,containerPhrasing:y,containerFlow:v,createTracker:C,compilePattern:u,enter:function(e){return i.stack.push(e),function(){i.stack.pop()}},handlers:{...t.handle},handle:void 0,indentLines:d,indexStack:[],join:[...o],options:{},safe:m,stack:[],unsafe:[...s]};r(i,a),i.options.tightDefinitions&&i.join.push(A),i.handle=e.zwitch("type",{invalid:k,unknown:x,handlers:i.handlers});let f=i.handle(n,void 0,i,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return f&&10!==f.charCodeAt(f.length-1)&&13!==f.charCodeAt(f.length-1)&&(f+="\n"),f}function k(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function x(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function A(e,t){if("definition"===e.type&&e.type===t.type)return 0}function y(e,n){return function(e,n,r){const c=n.indexStack,a=e.children||[],o=[];let i,s=-1,h=r.before;c.push(-1);let u=n.createTracker(r);for(;++s<a.length;){const f=a[s];let l;if(c[c.length-1]=s,s+1<a.length){let t=n.handle.handlers[a[s+1].type];t&&t.peek&&(t=t.peek),l=t?t(a[s+1],e,n,{before:"",after:"",...u.current()}).charAt(0):""}else l=r.after;o.length>0&&("\r"===h||"\n"===h)&&"html"===f.type&&(o[o.length-1]=o[o.length-1].replace(/(\r?\n|\r)$/," "),h=" ",u=n.createTracker(r),u.move(o.join("")));let d=n.handle(f,e,n,{...u.current(),after:l,before:h});i&&i===d.slice(0,1)&&(d=t.encodeCharacterReference(i.charCodeAt(0))+d.slice(1));const p=n.attentionEncodeSurroundingInfo;n.attentionEncodeSurroundingInfo=void 0,i=void 0,p&&(o.length>0&&p.before&&h===o[o.length-1].slice(-1)&&(o[o.length-1]=o[o.length-1].slice(0,-1)+t.encodeCharacterReference(h.charCodeAt(0))),p.after&&(i=l)),u.move(d),o.push(d),h=d.slice(-1)}return c.pop(),o.join("")}(e,this,n)}function v(e,t){return function(e,t,n){const r=t.indexStack,c=e.children||[],a=t.createTracker(n),o=[];let i=-1;for(r.push(-1);++i<c.length;){const n=c[i];r[r.length-1]=i,o.push(a.move(t.handle(n,e,t,{before:"\n",after:"\n",...a.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),i<c.length-1&&o.push(a.move(f(n,c[i+1],e,t)))}return r.pop(),o.join("")}(e,this,t)}function m(e,n){return function(e,n,r){const c=(r.before||"")+(n||"")+(r.after||""),a=[],o=[],i={};let s=-1;for(;++s<e.unsafe.length;){const n=e.unsafe[s];if(!t.patternInScope(e.stack,n))continue;const r=e.compilePattern(n);let o;for(;o=r.exec(c);){const e="before"in n||Boolean(n.atBreak),t="after"in n,r=o.index+(e?o[1].length:0);a.includes(r)?(i[r].before&&!e&&(i[r].before=!1),i[r].after&&!t&&(i[r].after=!1)):(a.push(r),i[r]={before:e,after:t})}}a.sort(p);let h=r.before?r.before.length:0;const u=c.length-(r.after?r.after.length:0);for(s=-1;++s<a.length;){const e=a[s];e<h||e>=u||e+1<u&&a[s+1]===e+1&&i[e].after&&!i[e+1].before&&!i[e+1].after||a[s-1]===e-1&&i[e].before&&!i[e-1].before&&!i[e-1].after||(h!==e&&o.push(g(c.slice(h,e),"\\")),h=e,!/[!-/:-@[-`{-~]/.test(c.charAt(e))||r.encode&&r.encode.includes(c.charAt(e))?(o.push(t.encodeCharacterReference(c.charCodeAt(e))),h++):o.push("\\"))}return o.push(g(c.slice(h,u),r.after)),o.join("")}(this,e,n)}exports.default=function(e){const t=this;t.compiler=function(n){return b(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}};
|