wi-chat 0.3.0 → 0.5.0
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/core/index.cjs +1 -1
- package/dist/core/index.js +129 -123
- package/dist/core/useChat.d.ts +11 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +101 -68
- package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +8 -3
- package/dist/mobile-ui/chat/ChatMessagesView.vue.d.ts +5 -0
- package/dist/mobile-ui/index.cjs +1 -1
- package/dist/mobile-ui/index.d.ts +2 -2
- package/dist/mobile-ui/index.js +79 -71
- package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +1 -1
- package/dist/mobile-ui/style.css +1 -1
- package/dist/page-context/extArgs.d.ts +46 -0
- package/dist/page-context/index.cjs +2 -0
- package/dist/page-context/index.d.ts +18 -0
- package/dist/page-context/index.js +48 -0
- package/dist/page-context/state.d.ts +10 -0
- package/dist/page-context/types.d.ts +218 -0
- package/dist/parser/answerCom/actionExecute/actionProtocol.d.ts +38 -0
- package/dist/parser/answerCom/actionExecute/clarification.d.ts +67 -0
- package/dist/parser/answerCom/actionExecute/parseActionExecute.d.ts +28 -0
- package/dist/parser/answerCom/actionExecute/types.d.ts +153 -0
- package/dist/parser/answerCom/outputFile/parseOutputFile.d.ts +43 -0
- package/dist/parser/answerCom/outputFile/types.d.ts +17 -0
- package/dist/parser/index.cjs +2 -2
- package/dist/parser/index.d.ts +12 -0
- package/dist/parser/index.js +537 -211
- package/dist/parser/registry.d.ts +8 -1
- package/dist/parser/title.d.ts +27 -0
- package/dist/renderers/clarification/ClarificationCard.vue.d.ts +19 -0
- package/dist/renderers/index.cjs +1 -1
- package/dist/renderers/index.d.ts +4 -0
- package/dist/renderers/index.js +796 -143
- package/dist/renderers/outputFile/OutputFile.vue.d.ts +19 -0
- package/dist/renderers/outputFile/useOutputFile.d.ts +85 -0
- package/dist/renderers/style.css +1 -1
- package/dist/right-panel/RightPanel.vue.d.ts +43 -0
- package/dist/right-panel/RightPanelIcon.vue.d.ts +38 -0
- package/dist/right-panel/RightPanelTabs.vue.d.ts +39 -0
- package/dist/right-panel/icons.d.ts +48 -0
- package/dist/right-panel/index.cjs +2 -0
- package/dist/right-panel/index.d.ts +43 -0
- package/dist/right-panel/index.js +1004 -0
- package/dist/right-panel/panels/index.d.ts +7 -0
- package/dist/right-panel/panels/newtab/NewTabPanel.vue.d.ts +27 -0
- package/dist/right-panel/panels/newtab/defaults.d.ts +6 -0
- package/dist/right-panel/panels/newtab/index.d.ts +4 -0
- package/dist/right-panel/panels/web/WebPanel.vue.d.ts +28 -0
- package/dist/right-panel/panels/web/index.d.ts +4 -0
- package/dist/right-panel/panels/web/useWebview.d.ts +59 -0
- package/dist/right-panel/registry.d.ts +24 -0
- package/dist/right-panel/runtime.d.ts +45 -0
- package/dist/right-panel/scope.d.ts +34 -0
- package/dist/right-panel/shared/BrowserToolbar.vue.d.ts +23 -0
- package/dist/right-panel/shared/RightPanelToolList.vue.d.ts +48 -0
- package/dist/right-panel/style.css +1 -0
- package/dist/right-panel/types.d.ts +363 -0
- package/dist/right-panel/useRightPanel.d.ts +39 -0
- package/dist/right-panel/useRightPanelTabs.d.ts +14 -0
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +182 -162
- package/dist/tools/markdown/index.d.ts +1 -1
- package/dist/tools/markdown/renderMarkdown.d.ts +25 -0
- package/dist/web-ui/attach/AttachmentList.vue.d.ts +1 -1
- package/dist/web-ui/chat/ChatContainer.vue.d.ts +8 -3
- package/dist/web-ui/chat/ChatMessagesView.vue.d.ts +5 -0
- package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +2 -2
- package/dist/web-ui/index.cjs +1 -1
- package/dist/web-ui/index.d.ts +2 -2
- package/dist/web-ui/index.js +428 -408
- package/dist/web-ui/inputbox/Inputbox.vue.d.ts +4 -7
- package/dist/web-ui/style.css +1 -1
- package/package.json +13 -6
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AiAnswerReport } from '../../answer';
|
|
2
|
+
import { StreamChunk } from '../../sse';
|
|
3
|
+
import { AnswerParser } from '../../registry';
|
|
4
|
+
import { OutputFileValue } from './types';
|
|
5
|
+
|
|
6
|
+
/** output_file 类型的历史分发键 / 实时载荷有效类型 */
|
|
7
|
+
export declare const OUTPUT_FILE_ANSWER_TYPE = "output_file";
|
|
8
|
+
/**
|
|
9
|
+
* 防御性读取 output_file 载荷,兼容两种服务端形态:
|
|
10
|
+
* - 实时链路:`{ values: { file_id, file_name }, answer_type: 'output_file' }`;
|
|
11
|
+
* - 历史接口:`{ file_id, file_name, answer_type: 'output_file' }`(顶层字段)。
|
|
12
|
+
* 嵌套优先、顶层兜底;两者都取不到时返回空对象。
|
|
13
|
+
* @param value result chunk 载荷(或历史 report 元素)
|
|
14
|
+
* @returns 只含非空 file_id / file_name 的取值结构
|
|
15
|
+
*/
|
|
16
|
+
export declare const readOutputFilePayload: (value: any) => OutputFileValue;
|
|
17
|
+
/**
|
|
18
|
+
* 处理实时流的 `result` chunk:有效类型为 `output_file` 时把载荷归一成 `values`
|
|
19
|
+
* 并追加为新报告。
|
|
20
|
+
* `result` 是所有非流式答案类型的通用载体,故严格按有效类型 `=== 'output_file'` 门控;
|
|
21
|
+
* 载荷没有 file_id / file_name 时消费但不产生空报告。
|
|
22
|
+
* @param chunk 流式数据块
|
|
23
|
+
* @param reports 回答 reports 数组(registry 预取的 `answerValues.answer.reports` 同一引用,push 即累积)
|
|
24
|
+
* @returns 是否消费了该 chunk:`result` 且有效类型为 `output_file` 时 true,其余 false
|
|
25
|
+
*/
|
|
26
|
+
export declare const applyOutputFileChunk: (chunk: StreamChunk, reports: AiAnswerReport<any>[]) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 把历史接口返回的单个 `output_file` report 元素标准化成渲染层结构:
|
|
29
|
+
* 渲染层只读 `values`,故把顶层 file_id / file_name 收拢进 values。
|
|
30
|
+
*
|
|
31
|
+
* 幂等:values 已有 file_id / file_name(实时累积或此前已标准化)时原样跳过;
|
|
32
|
+
* 两处都取不到时不改写 values(不造空结构)。
|
|
33
|
+
* @param report 历史 reports 中的一个 `output_file` 元素(就地修改并返回)
|
|
34
|
+
* @returns 标准化后的同一 report 引用
|
|
35
|
+
*/
|
|
36
|
+
export declare const normalizeOutputFileReport: (report: AiAnswerReport<OutputFileValue>) => AiAnswerReport<OutputFileValue>;
|
|
37
|
+
/**
|
|
38
|
+
* output_file 答案类型的注册表条目(registry 内置):
|
|
39
|
+
* - 实时链路:`applyChunk` 复用 `applyOutputFileChunk`(只消费 `result`/`output_file` 载荷);
|
|
40
|
+
* - 历史链路:`answerType` 命中 `output_file` 时由 `normalizeReport` 复用
|
|
41
|
+
* `normalizeOutputFileReport` 把服务端原始形态映射成 values。
|
|
42
|
+
*/
|
|
43
|
+
export declare const outputFileParser: AnswerParser<OutputFileValue>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* output_file 答案类型的类型定义
|
|
3
|
+
*
|
|
4
|
+
* 后端在本地电脑模式下执行 sys_write_file 等操作后,会下发
|
|
5
|
+
* `answer_type = 'output_file'` 的 result 报告:
|
|
6
|
+
* `{ values: { file_id, file_name }, answer_type: 'output_file', ... }`。
|
|
7
|
+
* 渲染层据此展示文件卡片,点击后按文件类型预览(文本 / 图片 / PDF / HTML / 音视频)。
|
|
8
|
+
*/
|
|
9
|
+
/** output_file 回答的渲染层取值结构 */
|
|
10
|
+
export interface OutputFileValue {
|
|
11
|
+
/** 后端文件 id,用于按 id 下载文件二进制 */
|
|
12
|
+
file_id?: string;
|
|
13
|
+
/** 文件名(含扩展名),用于展示与判断预览类型 */
|
|
14
|
+
file_name?: string;
|
|
15
|
+
/** 其余字段原样保留 */
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
package/dist/parser/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=()=>({answer_type:"knowledge_stream_result",values:[{answer:""}]}),M=e=>(e.answer_type="knowledge_stream_result",(!Array.isArray(e.values)||!e.values.length)&&(e.values=[{answer:""}]),e),P=(e="",t="")=>({id:e,question:t,answer:{reports:[]}}),oe=["knowledge_stream_begin","knowledge_stream","knowledge_stream_result","knowledge_stream_end"],z=(e,t,n,r)=>{var u;if(!e.mode||!oe.includes(e.mode))return!1;if(e.mode==="knowledge_stream_result"||e.mode==="knowledge_stream_end")return!0;const s=r==null?void 0:r.beforeKnowledgeRender,o=l=>s?s(l):l;if(e.mode==="knowledge_stream_begin"){const l=t.at(-1);return(l==null?void 0:l.answer_type)==="knowledge_stream_result"?(l.values=l.values??[],l.values.push({answer:""}),!0):l&&!l.answer_type?(M(l),!0):(t.push($()),!0)}if(e.mode!=="knowledge_stream")return!1;let i=t.at(-1);i&&!i.answer_type?i=M(i):(!i||i.answer_type!=="knowledge_stream_result")&&(i=$(),t.push(i)),i.values=(u=i.values)!=null&&u.length?i.values:[{answer:""}];const a=i.values[i.values.length-1],c=`${a.raw??""}${e.value||""}`;return a.raw=c,a.answer=o(c),!0},O=(e,t)=>{if(Array.isArray(e.values)&&e.values.length)return e;const n=t==null?void 0:t.beforeKnowledgeRender,r=o=>n?n(o):o;let s=[];return Array.isArray(e.knowledge)&&(s=e.knowledge.map(o=>typeof o=="string"?o:o==null?void 0:o.answer).filter(o=>typeof o=="string"&&o!=="")),s.length===0&&typeof e.answer=="string"&&e.answer!==""&&(s=[e.answer]),s.length&&(e.values=s.map(o=>({answer:r(o),raw:o}))),e},x={id:"knowledge_stream",answerType:"knowledge_stream_result",applyChunk:z,normalizeReport:O},N=["begin","begin_stream","send_stream","end_stream"],L=(e,t)=>{if(!N.includes(e.mode||""))return!1;let n=t.at(-1);return(!n||n.answer_type)&&(n={exec_process:[]},t.push(n)),n.exec_process=n.exec_process??[],n.exec_process.push({mode:e.mode,type:e.type,value:e.value}),!0},H=e=>{const t=[];let n="",r=!1;for(const s of(e.exec_process??[]).filter(o=>N.includes(o.mode||""))){const o=typeof s.value=="string"?s.value:"";s.mode==="begin"?(r&&n.trim()&&t.push(n.trim()),r=!1,n="",o.trim()&&t.push(o.trim())):s.mode==="begin_stream"?(r&&n.trim()&&t.push(n.trim()),r=!0,n=o):s.mode==="send_stream"&&r?n+=o:s.mode==="end_stream"&&r&&(n+=o,n.trim()&&t.push(n.trim()),r=!1,n="")}return r&&n.trim()&&t.push(n.trim()),t},S=e=>{var t;return(((t=e.answer)==null?void 0:t.reports)??[]).flatMap(H)},D={id:"deep_thinking",applyChunk:L},B='/**\n * Skipped minification because the original files appears to be already minified.\n * Original file: /npm/@iframe-resizer/child@5.1.5/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n/*!\n * @preserve\n * \n * @module iframe-resizer/child 5.1.5 (umd) - 2024-07-09\n *\n * @license GPL-3.0 for non-commercial use only.\n * For commercial use, you must purchase a license from\n * https://iframe-resizer.com/pricing\n * \n * @desciption Keep same and cross domain iFrames sized to their content \n *\n * @author David J. Bradshaw <info@iframe-resizer.com>\n * \n * @see {@link https://iframe-resizer.com}\n * \n * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.\n */\n\n\n!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.5",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(de("Custom height calculation function not defined"),He.auto()),width:()=>(de("Custom width calculation function not defined"),Ue.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,C=!0,T=!1,k=1,I=f,x=!0,N="",R={},B=!0,q=!1,L=0,W=!1,D="",H="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{de("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e,re=new WeakSet,ae=e=>"object"==typeof e&&re.add(e);function le(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ce(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\\n"," ")}...`:e}const se=(...e)=>[`[iframe-resizer][${D}]`,...e].join(" "),ue=(...e)=>console?.info(se(...e)),de=(...e)=>console?.warn(se(...e)),me=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\\n").replaceAll("<rb>","\x1B[31;1m").replaceAll("</>","\x1B[m").replaceAll("<b>","\x1B[1m").replaceAll("<i>","\x1B[3m").replaceAll("<u>","\x1B[4m")):e(t.replaceAll("<br>","\\n").replaceAll(/<[/a-z]+>/gi,"")))(se)(...e)),fe=e=>me(e);function pe(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");D=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],I=void 0===t[8]?I:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),H=void 0===t[13]?H:t[13],K=void 0===t[14]?K:t[14],W=void 0===t[15]?W:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,I=e?.heightCalculationMethod||I,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),I=t(I,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);he("margin",function(e,t){t.includes("-")&&(de(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),he("background",S),he("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),ye(),L<0?fe(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&fe(a(3)),function(){if(!Y||""===Y||"false"===Y)return void me("<rb>Legacy version detected on parent page</>\\n\\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\\n\\nSee <u>https://iframe-resizer.com/setup/</> for more details.\\n");Y!==e&&me(`<rb>Version mismatch</>\\n\\nThe parent and child pages are running different versions of <i>iframe resizer</>.\\n\\nParent page: ${Y} - Child page: ${e}.\\n`)}(),ze(),Se(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&me("<rb>Deprecated Attributes</>\\n \\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===I&&(I="autoOverflow"),"auto"===K&&(K="autoOverflow")),be(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,$e()):!1===e&&!0===z&&(z=!1,ve("remove"),U?.disconnect(),E?.disconnect()),Xe(0,0,"autoResize",JSON.stringify(z)),z),close(){Xe(0,0,"close")},getId:()=>D,getPageInfo(e){if("function"==typeof e)return ne=e,Xe(0,0,"pageInfo"),void me("<rb>Deprecated Method</>\\n \\nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n");ne=null,Xe(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Xe(0,0,"parentInfo"),()=>{oe=null,Xe(0,0,"parentInfoStop")}},getParentProperties(e){me("<rb>Renamed Method</>\\n \\nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Qe()},scrollBy(e,t){Xe(t,e,"scrollBy")},scrollTo(e,t){Xe(t,e,"scrollTo")},scrollToOffset(e,t){Xe(t,e,"scrollToOffset")},sendMessage(e,t){Xe(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){I=e,ze()},setWidthCalculationMethod(e){K=e,Se()},setTargetOrigin(e){Z=e},resize(e,t){Ve("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){me("<rb>Deprecated Method</>\\n \\nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==W)return;function e(e){Xe(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),$e(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Xe(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Xe(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll(\'a[href^="#"]\').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?me("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),ae(document.documentElement),ae(document.body),Ve("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Xe(0,0,"title",document.title),te(),B=!1}function he(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function ye(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function ge(e){({add(t){function n(){Ve(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ve(e){ge({method:e,eventType:"After Print",eventName:"afterprint"}),ge({method:e,eventType:"Before Print",eventName:"beforeprint"}),ge({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function be(){const e=document.querySelectorAll(`[${n}]`);T=e.length>0,A=T?e:Re(document)()}function we(e,t,n,o){return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&me(`<rb>Deprecated ${o}CalculationMethod (${e})</>\\n\\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ze(){I=we(I,f,He,"height")}function Se(){K=we(K,v,Ue,"width")}function $e(){!0===z&&(ve("add"),E=function(){function e(e){e.forEach(Te),ye(),be()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(Ee),Ce(window.document))}let je;function Ee(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;je=()=>Ve("resizeObserver",`Resize Observed: ${le(t)}`),setTimeout((()=>{je&&je(),je=void 0}),0)}const Pe=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Oe=()=>[...Re(document)()].filter(Pe),Me=new WeakSet;function Ae(e){e&&(Me.has(e)||(U.observe(e),Me.add(e)))}function Ce(e){[...Oe(),...g.flatMap((t=>e.querySelector(t)))].forEach(Ae)}function Te(e){"childList"===e.type&&Ce(e.target)}let ke=4,Ie=4;function xe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o=0,i=A.length,r=document.documentElement,a=T?0:document.documentElement.getBoundingClientRect().bottom,c=performance.now();var s;A.forEach((t=>{T||!m||t.checkVisibility(l)?(o=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),o>a&&(a=o,r=t)):i-=1})),c=performance.now()-c,i>1&&(s=r,re.has(s)||(ae(s),ue(`\\nHeight calculated from: ${le(s)} (${ce(s)})`)));const u=`\\nParsed ${i} element${1===i?"":"s"} in ${c.toPrecision(3)}ms\\n${t} ${T?"tagged ":""}element found at: ${a}px\\nPosition calculated from HTML element: ${le(r)} (${ce(r,100)})`;return c<4||i<99||T||B||ke<c&&ke<Ie&&(ke=1.2*c,me(`<rb>Performance Warning</>\\n\\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\\n${u}`)),Ie=c,a}const Ne=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Re=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Be=!1;function qe({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Be)return Be=!0,n.taggedElement();const r=o?"bottom":"right";return me(`<rb>Detected content overflowing html element</>\\n \\nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \\n\\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \\n \\nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\\n\\nMore info: https://iframe-resizer.com/performance.\\n\\n(Page size: ${i} > document size: ${e})`),o?I="autoOverflow":K="autoOverflow",n.taggedElement()}const Le={height:0,width:0},We={height:0,width:0};function De(e,t){function n(){return We[i]=r,Le[i]=c,r}const o=e===He,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===We[i]&&0===Le[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===We[i]&&c===Le[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==We[i]&&c<=Le[i]:return n();case!o:return t?e.taggedElement():qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<We[i]:case c===l||c===a:case r>c:return n();case!t:return qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const He={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>De(He,!1),autoOverflow:()=>De(He,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>He.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ne(He)),min:()=>Math.min(...Ne(He)),grow:()=>He.max(),lowestElement:()=>xe("bottom"),taggedElement:()=>xe("bottom")},Ue={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>De(Ue,!1),autoOverflow:()=>De(Ue,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ne(Ue)),min:()=>Math.min(...Ne(Ue)),rightMostElement:()=>xe("right"),scroll:()=>Math.max(Ue.bodyScroll(),Ue.documentElementScroll()),taggedElement:()=>xe("right")};function Fe(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?He[I]():n,a=void 0===o?Ue[K]():o,O&&e(k,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&I in y||M&&K in y)&&Qe():(Je(),k=r,G=a,Xe(k,G,e,i))}function Ve(e,t,n,o,i){document.hidden||Fe(e,0,n,o,i)}function Je(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Ze(e){k=He[I](),G=Ue[K](),Xe(k,G,e)}function Qe(e){const t=I;I=f,Je(),Ze("reset"),I=t}function Xe(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${D}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ye(e){const t={init:function(){N=e.data,J=e.source,pe(),C=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Ze("resetPage")},resize(){Ve("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Xe(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Xe(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==C?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||de(`Unexpected message (${e.data})`)}())}function Ge(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ye({data:e,sameDomain:!0}),o(window,"message",Ye),o(window,"readystatechange",Ge),Ge())}));\n',se="iframe-resizer/child 5.1.5",ie=B,b=`<script>${B}<\/script>`,ae=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),U=e=>{if(!e||typeof e!="object")return{};const t=e.values,n=o=>{const i=t&&typeof t=="object"?t[o]:void 0;if(typeof i=="string"&&i)return i;const a=e[o];return typeof a=="string"&&a?a:void 0},r=n("url"),s=n("srcdoc");return{...r?{url:r}:{},...s?{srcdoc:s}:{}}},_=e=>e&&(e.includes("</head>")?e.replace("</head>",`${b}</head>`):e.includes("<body")?e.replace("<body",`${b}<body`):b+e),ce=e=>!e||typeof e!="object"||Array.isArray(e)||!e.url&&!e.srcdoc?!1:!e.srcdoc||e.srcdoc.includes(se),W=(e,t)=>{if(e.mode!=="result"||ae(e.value)!=="url")return!1;const n=U(e.value);return!n.url&&!n.srcdoc||(n.srcdoc&&(n.srcdoc=_(n.srcdoc)),t.push({answer_type:"url",values:n})),!0},G=e=>{if(ce(e.values))return e;const t=U(e);return!t.url&&!t.srcdoc||(t.srcdoc&&(t.srcdoc=_(t.srcdoc)),e.values=t),e},K={id:"iframe_page",answerType:"url",applyChunk:W,normalizeReport:G},y="recordset",le=["cols","values","chart","title","max_cols","parent_link_col","agent_key"],ue=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),g=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&(Array.isArray(e.cols)||Array.isArray(e.values)),q=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e.values;if(g(t))return t;if(g(e))return e},X=(e,t)=>{if(e.mode!=="result"||ue(e.value)!==y)return!1;const n=q(e.value);return n&&t.push({answer_type:y,values:n}),!0},V=e=>{if(g(e.values))return e;const t=e;if(!g(t))return e;const n={};for(const r of le)n[r]=t[r];return e.values=n,e},J={id:"recordset",answerType:y,applyChunk:X,normalizeReport:V},w=[D,x,K,J],de=e=>{const t=(e==null?void 0:e.parsers)??[];return t.length?[...w,...t]:w},me=(e,t,n)=>{var i;const r=(i=e.answer)==null?void 0:i.reports;if(!r)return[];const s=new Set(((n==null?void 0:n.parsers)??[]).filter(a=>a.applyChunk&&a.answerType).map(a=>a.answerType)),o=[];for(const a of de(n))a.applyChunk&&(w.includes(a)&&a.answerType&&s.has(a.answerType)||a.applyChunk(t,r,e,n)&&o.push(a.id));return o},Z=(e,t)=>{var o;const n=e.answer_type;if(!n)return;const s=((t==null?void 0:t.parsers)??[]).find(i=>i.answerType===n&&!!i.normalizeReport)??w.find(i=>i.answerType===n&&!!i.normalizeReport);(o=s==null?void 0:s.normalizeReport)==null||o.call(s,e,t)},A=(e,t="",n="",r)=>{var i;const s=(e==null?void 0:e.values)??e;if((i=s==null?void 0:s.answer)!=null&&i.reports){const a=s;for(const c of a.answer.reports)Z(c,r);return a}const o=P(t,n);return typeof s=="string"&&z({mode:"knowledge_stream",value:s},o.answer.reports,o,r),o},fe={User:"user",Assistant:"assistant"};let pe=0;const E=(e="msg")=>`${e}-${++pe}`,Y=e=>{const t=e.trim();if(!t||t==="[DONE]")return null;const n=t.replace(/^data:\s*/,"");try{return JSON.parse(n)}catch{try{return JSON.parse(decodeURIComponent(n))}catch{return null}}},Q=()=>{let e="";return{push(t){const n=(e+t).split(`
|
|
2
|
-
`);return e=n.pop()||"",n},flush(){const t=e;return e="",t?[t]:[]}}},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=()=>({answer_type:"knowledge_stream_result",values:[{answer:""}]}),q=e=>(e.answer_type="knowledge_stream_result",(!Array.isArray(e.values)||!e.values.length)&&(e.values=[{answer:""}]),e),X=(e="",t="")=>({id:e,question:t,answer:{reports:[]}}),je=["knowledge_stream_begin","knowledge_stream","knowledge_stream_result","knowledge_stream_end"],$=(e,t,n,r)=>{var l;if(!e.mode||!je.includes(e.mode))return!1;if(e.mode==="knowledge_stream_result"||e.mode==="knowledge_stream_end")return!0;const o=r==null?void 0:r.beforeKnowledgeRender,s=u=>o?o(u):u;if(e.mode==="knowledge_stream_begin"){const u=t.at(-1);return(u==null?void 0:u.answer_type)==="knowledge_stream_result"?(u.values=u.values??[],u.values.push({answer:""}),!0):u&&!u.answer_type?(q(u),!0):(t.push(W()),!0)}if(e.mode!=="knowledge_stream")return!1;let i=t.at(-1);i&&!i.answer_type?i=q(i):(!i||i.answer_type!=="knowledge_stream_result")&&(i=W(),t.push(i)),i.values=(l=i.values)!=null&&l.length?i.values:[{answer:""}];const a=i.values[i.values.length-1],c=`${a.raw??""}${e.value||""}`;return a.raw=c,a.answer=s(c),!0},K=(e,t)=>{if(Array.isArray(e.values)&&e.values.length)return e;const n=t==null?void 0:t.beforeKnowledgeRender,r=s=>n?n(s):s;let o=[];return Array.isArray(e.knowledge)&&(o=e.knowledge.map(s=>typeof s=="string"?s:s==null?void 0:s.answer).filter(s=>typeof s=="string"&&s!=="")),o.length===0&&typeof e.answer=="string"&&e.answer!==""&&(o=[e.answer]),o.length&&(e.values=o.map(s=>({answer:r(s),raw:s}))),e},Y={id:"knowledge_stream",answerType:"knowledge_stream_result",applyChunk:$,normalizeReport:K},V=["begin","begin_stream","send_stream","end_stream"],J=(e,t)=>{if(!V.includes(e.mode||""))return!1;let n=t.at(-1);return(!n||n.answer_type)&&(n={exec_process:[]},t.push(n)),n.exec_process=n.exec_process??[],n.exec_process.push({mode:e.mode,type:e.type,value:e.value}),!0},Z=e=>{const t=[];let n="",r=!1;for(const o of(e.exec_process??[]).filter(s=>V.includes(s.mode||""))){const s=typeof o.value=="string"?o.value:"";o.mode==="begin"?(r&&n.trim()&&t.push(n.trim()),r=!1,n="",s.trim()&&t.push(s.trim())):o.mode==="begin_stream"?(r&&n.trim()&&t.push(n.trim()),r=!0,n=s):o.mode==="send_stream"&&r?n+=s:o.mode==="end_stream"&&r&&(n+=s,n.trim()&&t.push(n.trim()),r=!1,n="")}return r&&n.trim()&&t.push(n.trim()),t},j=e=>{var t;return(((t=e.answer)==null?void 0:t.reports)??[]).flatMap(Z)},Q={id:"deep_thinking",applyChunk:J},F='/**\n * Skipped minification because the original files appears to be already minified.\n * Original file: /npm/@iframe-resizer/child@5.1.5/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n/*!\n * @preserve\n * \n * @module iframe-resizer/child 5.1.5 (umd) - 2024-07-09\n *\n * @license GPL-3.0 for non-commercial use only.\n * For commercial use, you must purchase a license from\n * https://iframe-resizer.com/pricing\n * \n * @desciption Keep same and cross domain iFrames sized to their content \n *\n * @author David J. Bradshaw <info@iframe-resizer.com>\n * \n * @see {@link https://iframe-resizer.com}\n * \n * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.\n */\n\n\n!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.5",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(de("Custom height calculation function not defined"),He.auto()),width:()=>(de("Custom width calculation function not defined"),Ue.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,C=!0,T=!1,k=1,I=f,x=!0,N="",R={},B=!0,q=!1,L=0,W=!1,D="",H="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{de("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e,re=new WeakSet,ae=e=>"object"==typeof e&&re.add(e);function le(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ce(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\\n"," ")}...`:e}const se=(...e)=>[`[iframe-resizer][${D}]`,...e].join(" "),ue=(...e)=>console?.info(se(...e)),de=(...e)=>console?.warn(se(...e)),me=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\\n").replaceAll("<rb>","\x1B[31;1m").replaceAll("</>","\x1B[m").replaceAll("<b>","\x1B[1m").replaceAll("<i>","\x1B[3m").replaceAll("<u>","\x1B[4m")):e(t.replaceAll("<br>","\\n").replaceAll(/<[/a-z]+>/gi,"")))(se)(...e)),fe=e=>me(e);function pe(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");D=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],I=void 0===t[8]?I:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),H=void 0===t[13]?H:t[13],K=void 0===t[14]?K:t[14],W=void 0===t[15]?W:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,I=e?.heightCalculationMethod||I,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),I=t(I,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);he("margin",function(e,t){t.includes("-")&&(de(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),he("background",S),he("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),ye(),L<0?fe(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&fe(a(3)),function(){if(!Y||""===Y||"false"===Y)return void me("<rb>Legacy version detected on parent page</>\\n\\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\\n\\nSee <u>https://iframe-resizer.com/setup/</> for more details.\\n");Y!==e&&me(`<rb>Version mismatch</>\\n\\nThe parent and child pages are running different versions of <i>iframe resizer</>.\\n\\nParent page: ${Y} - Child page: ${e}.\\n`)}(),ze(),Se(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&me("<rb>Deprecated Attributes</>\\n \\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===I&&(I="autoOverflow"),"auto"===K&&(K="autoOverflow")),be(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,$e()):!1===e&&!0===z&&(z=!1,ve("remove"),U?.disconnect(),E?.disconnect()),Xe(0,0,"autoResize",JSON.stringify(z)),z),close(){Xe(0,0,"close")},getId:()=>D,getPageInfo(e){if("function"==typeof e)return ne=e,Xe(0,0,"pageInfo"),void me("<rb>Deprecated Method</>\\n \\nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n");ne=null,Xe(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Xe(0,0,"parentInfo"),()=>{oe=null,Xe(0,0,"parentInfoStop")}},getParentProperties(e){me("<rb>Renamed Method</>\\n \\nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Qe()},scrollBy(e,t){Xe(t,e,"scrollBy")},scrollTo(e,t){Xe(t,e,"scrollTo")},scrollToOffset(e,t){Xe(t,e,"scrollToOffset")},sendMessage(e,t){Xe(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){I=e,ze()},setWidthCalculationMethod(e){K=e,Se()},setTargetOrigin(e){Z=e},resize(e,t){Ve("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){me("<rb>Deprecated Method</>\\n \\nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==W)return;function e(e){Xe(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),$e(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Xe(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Xe(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll(\'a[href^="#"]\').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?me("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),ae(document.documentElement),ae(document.body),Ve("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Xe(0,0,"title",document.title),te(),B=!1}function he(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function ye(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function ge(e){({add(t){function n(){Ve(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ve(e){ge({method:e,eventType:"After Print",eventName:"afterprint"}),ge({method:e,eventType:"Before Print",eventName:"beforeprint"}),ge({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function be(){const e=document.querySelectorAll(`[${n}]`);T=e.length>0,A=T?e:Re(document)()}function we(e,t,n,o){return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&me(`<rb>Deprecated ${o}CalculationMethod (${e})</>\\n\\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ze(){I=we(I,f,He,"height")}function Se(){K=we(K,v,Ue,"width")}function $e(){!0===z&&(ve("add"),E=function(){function e(e){e.forEach(Te),ye(),be()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(Ee),Ce(window.document))}let je;function Ee(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;je=()=>Ve("resizeObserver",`Resize Observed: ${le(t)}`),setTimeout((()=>{je&&je(),je=void 0}),0)}const Pe=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Oe=()=>[...Re(document)()].filter(Pe),Me=new WeakSet;function Ae(e){e&&(Me.has(e)||(U.observe(e),Me.add(e)))}function Ce(e){[...Oe(),...g.flatMap((t=>e.querySelector(t)))].forEach(Ae)}function Te(e){"childList"===e.type&&Ce(e.target)}let ke=4,Ie=4;function xe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o=0,i=A.length,r=document.documentElement,a=T?0:document.documentElement.getBoundingClientRect().bottom,c=performance.now();var s;A.forEach((t=>{T||!m||t.checkVisibility(l)?(o=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),o>a&&(a=o,r=t)):i-=1})),c=performance.now()-c,i>1&&(s=r,re.has(s)||(ae(s),ue(`\\nHeight calculated from: ${le(s)} (${ce(s)})`)));const u=`\\nParsed ${i} element${1===i?"":"s"} in ${c.toPrecision(3)}ms\\n${t} ${T?"tagged ":""}element found at: ${a}px\\nPosition calculated from HTML element: ${le(r)} (${ce(r,100)})`;return c<4||i<99||T||B||ke<c&&ke<Ie&&(ke=1.2*c,me(`<rb>Performance Warning</>\\n\\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\\n${u}`)),Ie=c,a}const Ne=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Re=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Be=!1;function qe({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Be)return Be=!0,n.taggedElement();const r=o?"bottom":"right";return me(`<rb>Detected content overflowing html element</>\\n \\nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \\n\\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \\n \\nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\\n\\nMore info: https://iframe-resizer.com/performance.\\n\\n(Page size: ${i} > document size: ${e})`),o?I="autoOverflow":K="autoOverflow",n.taggedElement()}const Le={height:0,width:0},We={height:0,width:0};function De(e,t){function n(){return We[i]=r,Le[i]=c,r}const o=e===He,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===We[i]&&0===Le[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===We[i]&&c===Le[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==We[i]&&c<=Le[i]:return n();case!o:return t?e.taggedElement():qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<We[i]:case c===l||c===a:case r>c:return n();case!t:return qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const He={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>De(He,!1),autoOverflow:()=>De(He,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>He.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ne(He)),min:()=>Math.min(...Ne(He)),grow:()=>He.max(),lowestElement:()=>xe("bottom"),taggedElement:()=>xe("bottom")},Ue={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>De(Ue,!1),autoOverflow:()=>De(Ue,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ne(Ue)),min:()=>Math.min(...Ne(Ue)),rightMostElement:()=>xe("right"),scroll:()=>Math.max(Ue.bodyScroll(),Ue.documentElementScroll()),taggedElement:()=>xe("right")};function Fe(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?He[I]():n,a=void 0===o?Ue[K]():o,O&&e(k,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&I in y||M&&K in y)&&Qe():(Je(),k=r,G=a,Xe(k,G,e,i))}function Ve(e,t,n,o,i){document.hidden||Fe(e,0,n,o,i)}function Je(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Ze(e){k=He[I](),G=Ue[K](),Xe(k,G,e)}function Qe(e){const t=I;I=f,Je(),Ze("reset"),I=t}function Xe(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${D}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ye(e){const t={init:function(){N=e.data,J=e.source,pe(),C=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Ze("resetPage")},resize(){Ve("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Xe(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Xe(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==C?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||de(`Unexpected message (${e.data})`)}())}function Ge(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ye({data:e,sameDomain:!0}),o(window,"message",Ye),o(window,"readystatechange",Ge),Ge())}));\n',Pe="iframe-resizer/child 5.1.5",Oe=F,C=`<script>${F}<\/script>`,xe=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),ee=e=>{if(!e||typeof e!="object")return{};const t=e.values,n=s=>{const i=t&&typeof t=="object"?t[s]:void 0;if(typeof i=="string"&&i)return i;const a=e[s];return typeof a=="string"&&a?a:void 0},r=n("url"),o=n("srcdoc");return{...r?{url:r}:{},...o?{srcdoc:o}:{}}},P=e=>e&&(e.includes("</head>")?e.replace("</head>",`${C}</head>`):e.includes("<body")?e.replace("<body",`${C}<body`):C+e),ke=e=>!e||typeof e!="object"||Array.isArray(e)||!e.url&&!e.srcdoc?!1:!e.srcdoc||e.srcdoc.includes(Pe),te=(e,t)=>{if(e.mode!=="result"||xe(e.value)!=="url")return!1;const n=ee(e.value);return!n.url&&!n.srcdoc||(n.srcdoc&&(n.srcdoc=P(n.srcdoc)),t.push({answer_type:"url",values:n})),!0},ne=e=>{if(ke(e.values))return e;const t=ee(e);return!t.url&&!t.srcdoc||(t.srcdoc&&(t.srcdoc=P(t.srcdoc)),e.values=t),e},re={id:"iframe_page",answerType:"url",applyChunk:te,normalizeReport:ne},E="recordset",Me=["cols","values","chart","title","max_cols","parent_link_col","agent_key"],Re=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),S=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&(Array.isArray(e.cols)||Array.isArray(e.values)),oe=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e.values;if(S(t))return t;if(S(e))return e},se=(e,t)=>{if(e.mode!=="result"||Re(e.value)!==E)return!1;const n=oe(e.value);return n&&t.push({answer_type:E,values:n}),!0},ie=e=>{if(S(e.values))return e;const t=e;if(!S(t))return e;const n={};for(const r of Me)n[r]=t[r];return e.values=n,e},ae={id:"recordset",answerType:E,applyChunk:se,normalizeReport:ie},w="output_file",Ne=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),_=(e,t)=>{if(!e||typeof e!="object")return;const n=e[t];return typeof n=="string"&&n?n:void 0},O=e=>{if(!e||typeof e!="object")return{};const t=e.values&&typeof e.values=="object"?e.values:void 0,n=_(t,"file_id")??_(e,"file_id"),r=_(t,"file_name")??_(e,"file_name");return{...n?{file_id:n}:{},...r?{file_name:r}:{}}},ce=(e,t)=>{if(e.mode!=="result"||Ne(e.value)!==w)return!1;const n=O(e.value);return!n.file_id&&!n.file_name||t.push({answer_type:w,values:n}),!0},le=e=>{const t=O(e);if(!t.file_id&&!t.file_name)return e;const n=e.values&&typeof e.values=="object"&&!Array.isArray(e.values)?e.values:{};return(!t.file_id||n.file_id)&&(!t.file_name||n.file_name)||(e.values={...n,...t}),e},ue={id:w,answerType:w,applyChunk:ce,normalizeReport:le},y=e=>({success:!1,message:e,data:null}),Le=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{throw new Error("执行指令不是合法的 JSON")}},de=e=>{const t=Le(e);if(!t||typeof t!="object")throw new Error("执行指令格式无效");const{type:n,executor:r,action:o}=t;if(n!=="action_execute")throw new Error(`不支持的指令类型:${String(n??"")}`);if(r!=="host"&&r!=="agent")throw new Error(`不支持的执行端:${String(r??"")}`);if(!o||typeof o!="object"||typeof o.name!="string"||!o.name.trim())throw new Error("执行指令缺少合法的 action.name");if(!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))throw new Error("执行指令的 action.arguments 必须是对象");return{type:n,executor:r,action:{name:o.name,arguments:o.arguments}}},fe=(e,t="执行端未返回有效的执行结果")=>{if(!e||typeof e!="object")return y(t);const n=e;return typeof n.success!="boolean"?y("执行端返回的 success 必须是布尔值"):{success:n.success,message:typeof n.message=="string"?n.message:n.success?"操作成功":"操作失败",data:Object.prototype.hasOwnProperty.call(n,"data")?n.data??null:null}},He=e=>{if(e&&typeof e=="object"){const t=e;if(typeof t.success=="boolean")return e;if(t.json_ok===!0)return{success:!0,message:"操作成功",data:e};if(t.json_ok===!1)return{success:!1,message:typeof t.error=="string"?t.error:"操作失败",data:e}}return y("系统操作返回了无法识别的报文帧")},De=e=>({name:e.name,arguments:e.arguments}),Ue=["single_select","multi_select","date","text"],h=new Map;let G=0;const b=e=>!!e&&typeof e=="object"&&!Array.isArray(e),g=e=>typeof e=="string"&&e.trim()?e:void 0,Be=(e,t)=>{if(!Array.isArray(e)||e.length===0)throw new Error(`确认项 ${t} 缺少可选项`);return e.map((n,r)=>{if(!b(n)||typeof n.label!="string"||!n.label.trim())throw new Error(`确认项 ${t} 的第 ${r+1} 个选项格式无效`);if(!Object.prototype.hasOwnProperty.call(n,"value"))throw new Error(`确认项 ${t} 的第 ${r+1} 个选项缺少 value`);return{label:n.label,value:n.value}})},We=e=>{if(e===void 0)return;if(!b(e))throw new Error("确认项的 binding 必须是对象");const t={};return typeof e.actionIndex=="number"&&(t.actionIndex=e.actionIndex),typeof e.actionName=="string"&&(t.actionName=e.actionName),typeof e.parameterPath=="string"&&(t.parameterPath=e.parameterPath),t},qe=(e,t)=>{if(!b(e)||!Ue.includes(e.type))throw new Error(`确认项 ${t} 的 input.type 无效`);const n=e.type,r={type:n,placeholder:g(e.placeholder)};if((n==="single_select"||n==="multi_select")&&(r.options=Be(e.options,t)),n==="date"){if(e.format!==void 0&&e.format!=="YYYY-MM-DD")throw new Error(`确认项 ${t} 暂不支持日期格式 ${String(e.format)}`);r.format="YYYY-MM-DD"}if(e.textInput!==void 0){if(!b(e.textInput))throw new Error(`确认项 ${t} 的 textInput 必须是对象`);r.textInput={placeholder:g(e.textInput.placeholder)}}return r},me=e=>{if(!Array.isArray(e.items)||e.items.length===0)throw new Error("collect_clarifications 至少需要一个确认项");const t=new Set,n=e.items.map((r,o)=>{if(!b(r))throw new Error(`第 ${o+1} 个确认项格式无效`);const s=typeof r.id=="string"?r.id.trim():"",i=typeof r.question=="string"?r.question.trim():"";if(!s)throw new Error(`第 ${o+1} 个确认项缺少 id`);if(t.has(s))throw new Error(`确认项 id 重复:${s}`);if(!i)throw new Error(`确认项 ${s} 缺少 question`);return t.add(s),{id:s,question:i,description:g(r.description),required:r.required!==!1,default:r.default,binding:We(r.binding),input:qe(r.input,s)}});return{title:g(e.title)??"需要你确认几项信息",description:g(e.description)??"请补充以下信息,我会据此继续完成操作。",items:n}},pe=e=>e!==void 0?String(e):(G+=1,`clarification-${Date.now()}-${G}`),he=e=>{h.set(e.reportId,e)},Ge=e=>h.has(e),x=(e,t)=>{const n=e.reports.findIndex(r=>{var o;return((o=r.values)==null?void 0:o.requestId)===e.reportId});n<0||e.reports.splice(n,1,{...e.reports[n],values:{...e.reports[n].values,...t}})},ye=(e,t)=>{var n;if(!e.reply)return!1;try{return e.reply({type:"wait_reply",reply_id:e.replyId,values:t})!==!1}catch(r){return(n=e.onError)==null||n.call(e,r),!1}},Xe=(e,t)=>{const n=h.get(e);if(!n)return!1;h.delete(e);const r=ye(n,{success:!0,message:"用户已提交补充信息",data:{answers:t}});return x(n,{status:"submitted",resultMessage:r?"补充信息已提交":"补充信息已提交,但结果回传失败(连接已关闭)",answers:t}),!0},Ke=e=>{const t=h.get(e);if(!t)return!1;h.delete(e);const n=ye(t,{success:!1,message:"用户取消了补充信息",data:null});return x(t,{status:"cancelled",resultMessage:n?"已取消补充信息":"已取消补充信息,但结果回传失败(连接已关闭)"}),!0},Ye=()=>{h.forEach(e=>{x(e,{status:"expired",resultMessage:"本次补充信息已失效(回答已结束)"})}),h.clear()},k="collect_clarifications",Ve=["collect_clarifications"],ge=(e,t,n)=>{var r;if(!(e!=null&&e.reply))return!1;try{const o={type:"wait_reply",reply_id:t,values:n};return e.reply(o)!==!1}catch(o){return(r=e.onError)==null||r.call(e,o),!1}},z=(e,t,n)=>{ge(e,t,y(n))},Je=async(e,t,n)=>{var o,s,i;let r;try{const a=await((o=n==null?void 0:n.execute)==null?void 0:o.call(n,e));r=fe(a,`宿主未返回 ${e.name} 的执行结果`)}catch(a){(s=n==null?void 0:n.onError)==null||s.call(n,a),r=y(a instanceof Error?a.message:`${e.name} 执行失败`)}ge(n,t,r)||(i=n==null?void 0:n.onError)==null||i.call(n,new Error(`${e.name} 已执行,但 wait_reply 回传失败(连接已关闭)`))},we=(e,t,n,r)=>{var a,c;if(e.mode!=="front_reply")return!1;const o=r==null?void 0:r.frontReply,s=typeof e.reply_id=="string"||typeof e.reply_id=="number"?e.reply_id:void 0;let i;try{i=de(e.values??e.value)}catch(l){return(a=o==null?void 0:o.onError)==null||a.call(o,l),z(o,s,l instanceof Error?l.message:"执行指令解析失败"),!0}if(i.executor==="agent"){if(!Ve.includes(i.action.name))return z(o,s,`暂不支持的 Agent 操作:${i.action.name}`),!0;let l;try{l=me(i.action.arguments)}catch(d){return(c=o==null?void 0:o.onError)==null||c.call(o,d),z(o,s,d instanceof Error?d.message:"确认项参数无效"),!0}const u=pe(s),p={requestId:u,...l,status:"pending",resultMessage:""};return he({reportId:u,replyId:s,reports:t,reply:o==null?void 0:o.reply,onError:o==null?void 0:o.onError}),t.push({answer_type:k,values:p}),!0}return o!=null&&o.execute?(Je(i.action,s,o),!0):(z(o,s,`宿主未注入执行器,无法执行:${i.action.name}`),!0)},be=e=>{const t=e.values;!t||typeof t!="object"||t.status==="pending"&&(t.status="expired",t.resultMessage="本次补充信息已失效(回答已结束)")},ve={id:"action_execute",answerType:k,applyChunk:we,normalizeReport:be},A=[Q,Y,re,ae,ue,ve],Ze=e=>{const t=(e==null?void 0:e.parsers)??[];return t.length?[...A,...t]:A},Qe=(e,t,n)=>{var i;const r=(i=e.answer)==null?void 0:i.reports;if(!r)return[];const o=new Set(((n==null?void 0:n.parsers)??[]).filter(a=>a.applyChunk&&a.answerType).map(a=>a.answerType)),s=[];for(const a of Ze(n))a.applyChunk&&(A.includes(a)&&a.answerType&&o.has(a.answerType)||a.applyChunk(t,r,e,n)&&s.push(a.id));return s},_e=(e,t)=>{var s;const n=e.answer_type;if(!n)return;const o=((t==null?void 0:t.parsers)??[]).find(i=>i.answerType===n&&!!i.normalizeReport)??A.find(i=>i.answerType===n&&!!i.normalizeReport);(s=o==null?void 0:o.normalizeReport)==null||s.call(o,e,t)},M=(e,t="",n="",r)=>{var i;const o=(e==null?void 0:e.values)??e;if((i=o==null?void 0:o.answer)!=null&&i.reports){const a=o;for(const c of a.answer.reports)_e(c,r);return a}const s=X(t,n);return typeof o=="string"&&$({mode:"knowledge_stream",value:o},s.answer.reports,s,r),s},Fe={User:"user",Assistant:"assistant"};let et=0;const R=(e="msg")=>`${e}-${++et}`,ze=e=>{const t=e.trim();if(!t||t==="[DONE]")return null;const n=t.replace(/^data:\s*/,"");try{return JSON.parse(n)}catch{try{return JSON.parse(decodeURIComponent(n))}catch{return null}}},Ee=()=>{let e="";return{push(t){const n=(e+t).split(`
|
|
2
|
+
`);return e=n.pop()||"",n},flush(){const t=e;return e="",t?[t]:[]}}},Se=30,tt=/[A-Za-z]:[\\/][^\s"'`,。;;、,()()【】\[\]<>|?*]*/g,nt=/\\\\[^\s"'`,。;;、,()()【】\[\]<>|?*]+/g,rt=/(^|[\s"'`((【\[::,,、])((?:\/[^\s"'`,。;;、,()()【】\[\]<>|?*\/]+){2,})/g,ot=/^(?:请帮忙|请帮我|帮我看看|帮我把|帮我|帮忙|请把|麻烦你|麻烦|劳驾|请你|请问|帮(?!助))\s*[::,,、\-—]?\s*/,T=e=>{const t=e.split(/[\\/]+/).filter(Boolean);return t.length?t[t.length-1]:""},st=e=>e.replace(nt,t=>T(t)).replace(tt,t=>T(t)).replace(rt,(t,n,r)=>n+T(r)),it=e=>{let t=String(e??"").replace(/\r\n|\r|\n/g," ").replace(/\s+/g," ").trim();if(!t)return"";t=st(t).replace(/\s+/g," ").trim();let n="";for(;n!==t;)n=t,t=t.replace(ot,"").trim(),t=t.replace(/^[::,,、\-—\s]+/,"").trim();return t.slice(0,Se)},at=async(e,t)=>{const n=e.getReader(),r=new TextDecoder,o=Ee(),s=i=>{const a=ze(i);a&&t(a)};try{for(;;){const{done:i,value:a}=await n.read();if(i)break;o.push(r.decode(a,{stream:!0})).forEach(s)}o.flush().forEach(s)}catch(i){throw await n.cancel().catch(()=>{}),i}finally{n.releaseLock()}},v=new Set(["png","jpg","jpeg","gif","webp","svg","bmp"]),N=e=>!e||isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,ct=e=>{var r;if(e.type&&e.type!=="file")return!1;const t=e.attachContent||{};if(t.groupType==="image")return!0;const n=(t.suffix||((r=e.name)!=null&&r.includes(".")?e.name.split(".").pop():"")||"").toLowerCase();return!!(v.has(n)||t.raw&&typeof t.raw.type=="string"&&t.raw.type.startsWith("image/"))},Ae=(e,t,n)=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?e:`${(t||"").replace(/\/$/,"")}${n}?file_id=${e}`,Ce=(e,t="",n)=>e?n?n(e):Ae(e,t,"/file/download_file"):"",lt=(e,t="",n)=>{const r=e.attachContent||{};return r.url?r.url:typeof r.fileContent=="string"&&r.fileContent.startsWith("data:image/")?r.fileContent:r.fileId?Ce(r.fileId,t,n):""},I=e=>{var a;const t=(e==null?void 0:e.name)||"",n=t.includes(".")&&((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"",r=v.has(n)||(e==null?void 0:e.type)&&typeof e.type=="string"&&e.type.startsWith("image/");let o;if(r&&typeof window<"u"&&typeof URL<"u"&&e instanceof Blob)try{o=URL.createObjectURL(e)}catch{o=void 0}const s=N(e==null?void 0:e.size),i=[n.toUpperCase(),s].filter(Boolean).join(" · ");return{type:"file",name:t,description:i,attachContent:{file_name:t,size:e==null?void 0:e.size,suffix:n,raw:e,url:o,groupType:r?"image":"file"}}},L=e=>{var s;const t=(e==null?void 0:e.file_name)??(e==null?void 0:e.name)??(e==null?void 0:e.title)??"",n=t.includes(".")&&((s=t.split(".").pop())==null?void 0:s.toLowerCase())||"",r=v.has(n)||(e==null?void 0:e.groupType)==="image",o=n?n.toUpperCase():"";return{type:"file",name:t,description:o,attachContent:{file_name:(e==null?void 0:e.file_name)??t,fileId:(e==null?void 0:e.file_id)??(e==null?void 0:e.id),fileContent:e==null?void 0:e.file_content,suffix:n,groupType:r?"image":"file"}}},Te=e=>{var r,o,s,i;const t=(e==null?void 0:e.values)??e,n=((r=t==null?void 0:t.attach)==null?void 0:r.files)??((s=(o=t==null?void 0:t.answer)==null?void 0:o.attach)==null?void 0:s.files)??(t==null?void 0:t.attach_files)??((i=t==null?void 0:t.answer)==null?void 0:i.attach_files)??[];return!Array.isArray(n)||n.length===0?[]:n.map(a=>L(a))},ut=e=>{var r,o;if(!e)return{type:"file",name:"",description:"",attachContent:{}};if(typeof Blob<"u"&&e instanceof Blob)return I(e);if(typeof e=="object"&&e.attachContent){const s=e.type||"file",i=e.name||e.attachContent.file_name||e.attachContent.name||"";let a=e.description||"";const c={...e.attachContent};if(s==="file"&&(!c.suffix&&i.includes(".")&&(c.suffix=((r=i.split(".").pop())==null?void 0:r.toLowerCase())||""),(c.groupType==="image"||c.suffix&&v.has(c.suffix.toLowerCase())||c.raw&&typeof c.raw.type=="string"&&c.raw.type.startsWith("image/"))&&(c.groupType="image"),!a)){const u=typeof c.size=="number"?N(c.size):c.size||"";a=[c.suffix?c.suffix.toUpperCase():"",u].filter(Boolean).join(" · ")}return{...e,type:s,name:i,description:a,attachContent:c}}if(e.file_id||e.fileId)return L(e);if(e.raw&&typeof Blob<"u"&&e.raw instanceof Blob){const s=I(e.raw);return{...s,...e,attachContent:{...s.attachContent,...e.attachContent}}}const t=e.name||e.title||"",n=t.includes(".")&&((o=t.split(".").pop())==null?void 0:o.toLowerCase())||"";return{type:e.type||"file",name:t,description:e.description||(n?n.toUpperCase():""),attachContent:{file_name:t,suffix:n,...e}}},H=e=>Te(e),dt=async e=>[...(await e.getHistoryGroups()).groups??[]].sort((r,o)=>String(o.create_time??"").localeCompare(String(r.create_time??""))),ft=async(e,t)=>{const n=await e.createHistoryGroup(t),r=(n==null?void 0:n.group_id)??(n==null?void 0:n.history_group_id)??"";if(!r)throw new Error("创建对话分组失败");return r},mt=(e,t)=>e.deleteHistoryGroup(t),pt=(e,t,n)=>e.setHistoryGroupTitle(t,n),Ie=5,$e=async(e,t,n)=>{const r=new Array(e.length);let o=0;const s=Array.from({length:Math.min(t,e.length)},async()=>{for(;o<e.length;){const i=o++;r[i]=await n(e[i],i)}});return await Promise.all(s),r},ht=async(e,t,n=10,r=0,o)=>{if(!t)return[];const i=[...await e.getHistoryDetail(t,r,n)].sort((l,u)=>String(l.create_time||"").localeCompare(String(u.create_time||""))),a=await $e(i,Ie,async l=>{try{return await e.getHistoryAnswer(l.history_id||"")}catch{return null}}),c=[];return i.forEach((l,u)=>{const p=l.history_id||R("h"),d=a[u],f=d!=null?H(d):[];if(c.push({id:p,historyId:l.history_id,role:"user",content:l.question??"",attachments:f.length>0?f:void 0}),d!=null){const m=M(d,p,l.question??"",o);c.push({id:`${p}-answer`,historyId:l.history_id,role:"assistant",answer:m,error:!1,stopped:!1,thinking:{steps:j(m),expanded:!1}})}}),c},yt=async(e,t,n=10,r,o=0,s)=>{if(!t)return r==null||r({type:"users",users:[]}),[];const a=[...await e.getHistoryDetail(t,o,n)].sort((d,f)=>String(d.create_time||"").localeCompare(String(f.create_time||""))),c=a.map(d=>d.history_id||R("h")),l=a.map((d,f)=>({id:c[f],historyId:d.history_id,role:"user",content:d.question??""}));r==null||r({type:"users",users:l});const u=new Array(a.length).fill(null);await $e(a,Ie,async(d,f)=>{let m=null;try{m=await e.getHistoryAnswer(d.history_id||"")}catch{m=null}if(m==null)return;const D=H(m);D.length>0&&(l[f].attachments=D);const U=M(m,c[f],d.question??"",s),B={id:`${c[f]}-answer`,historyId:d.history_id,role:"assistant",answer:U,error:!1,stopped:!1,thinking:{steps:j(U),expanded:!1}};u[f]=B,r==null||r({type:"assistant",index:f,user:l[f],assistant:B})});const p=[];return a.forEach((d,f)=>{p.push(l[f]);const m=u[f];m&&p.push(m)}),p};exports.ACTION_EXECUTE_ANSWER_TYPE=k;exports.CHAT_TITLE_MAX_LENGTH=Se;exports.IFRAME_RESIZER_CHILD_SCRIPT=Oe;exports.IMAGE_EXTENSIONS=v;exports.OUTPUT_FILE_ANSWER_TYPE=w;exports.RECORDSET_ANSWER_TYPE=E;exports.RoleEnum=Fe;exports.actionExecuteParser=ve;exports.applyActionExecuteChunk=we;exports.applyAnswerChunk=Qe;exports.applyDeepThinkingChunk=J;exports.applyIframePageChunk=te;exports.applyKnowledgeStreamChunk=$;exports.applyOutputFileChunk=ce;exports.applyRecordsetChunk=se;exports.buildChatTitle=it;exports.cancelClarification=Ke;exports.clearPendingClarifications=Ye;exports.collectDeepThinkingSteps=Z;exports.collectThinkingSteps=j;exports.consumeStream=at;exports.createEmptyAnswerValues=X;exports.createFailureResult=y;exports.createHistoryGroup=ft;exports.createLineSplitter=Ee;exports.deepThinkingParser=Q;exports.deleteHistoryGroup=mt;exports.extractAttachmentsFromHistory=H;exports.extractHistoryAttachments=Te;exports.formatFileSize=N;exports.getHistoryGroups=dt;exports.hasPendingClarification=Ge;exports.iframePageParser=re;exports.injectIframeResizerScript=P;exports.isImageAttachment=ct;exports.knowledgeStreamParser=Y;exports.loadGroupMessages=ht;exports.loadGroupMessagesByStep=yt;exports.nextClarificationRequestId=pe;exports.nextLocalMessageId=R;exports.normalizeActionDefinition=De;exports.normalizeActionExecuteReport=be;exports.normalizeActionResult=fe;exports.normalizeAnswer=M;exports.normalizeAnswerReport=_e;exports.normalizeAttachment=ut;exports.normalizeIframePageReport=ne;exports.normalizeKnowledgeStreamReport=K;exports.normalizeOutputFileReport=le;exports.normalizeRecordsetReport=ie;exports.outputFileParser=ue;exports.parseActionExecuteCommand=de;exports.parseClarificationArguments=me;exports.parseHistoryAttachment=L;exports.parseRealtimeAttachment=I;exports.parseSseLine=ze;exports.readOutputFilePayload=O;exports.readRecordsetPayload=oe;exports.recordsetParser=ae;exports.registerClarification=he;exports.resolveAttachDownloadUrl=Ce;exports.resolveAttachPreviewUrl=lt;exports.resolveRemoteFileUrl=Ae;exports.setHistoryGroupTitle=pt;exports.submitClarification=Xe;exports.wrapActionFrame=He;
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - 公共回答类型 / 聚合解析:`./answer`
|
|
7
7
|
* - 答案类型解析注册表(实时/历史双链路,AnswerParser 实例注入):`./registry`
|
|
8
8
|
* - 消息类型(对话 / 历史共用):`./message`
|
|
9
|
+
* - 会话标题清洗(首问原文 → 可读标题):`./title`
|
|
9
10
|
* - 流式解析(含 StreamChunk):`./sse`
|
|
10
11
|
* - SSE 字节流消费(consumeStream,依赖 WHATWG ReadableStream):`./stream`
|
|
11
12
|
* - 各答案类型的解析与专属类型按子目录收敛(answerCom / deepThinking / history 平级):
|
|
@@ -13,6 +14,9 @@
|
|
|
13
14
|
* - `./answerCom/knowledgeStream`:知识流(applyKnowledgeStreamChunk / createEmptyAnswerValues / types)
|
|
14
15
|
* - `./answerCom/iframePage`:iframe 页面(applyIframePageChunk / 注入 child 脚本 / types)
|
|
15
16
|
* - `./answerCom/recordset`:记录集表格(applyRecordsetChunk / normalizeRecordsetReport / types)
|
|
17
|
+
* - `./answerCom/outputFile`:输出文件(applyOutputFileChunk / normalizeOutputFileReport / types)
|
|
18
|
+
* - `./answerCom/actionExecute`:front_reply 指令(action_execute:host 执行器 + 确认卡片
|
|
19
|
+
* collect_clarifications;parseActionExecute / actionProtocol / clarification / types)
|
|
16
20
|
* - `./deepThinking`:思考(applyDeepThinkingChunk / collectDeepThinkingSteps / types)
|
|
17
21
|
* - `./history`:历史分组与会话的业务逻辑(依赖 wi-chat-request)
|
|
18
22
|
*
|
|
@@ -27,6 +31,7 @@ export { RoleEnum, nextLocalMessageId } from './message';
|
|
|
27
31
|
export type { Role, UserMessage, AssistantMessage, Message } from './message';
|
|
28
32
|
export { parseSseLine, createLineSplitter } from './sse';
|
|
29
33
|
export type { StreamChunk, LineSplitter } from './sse';
|
|
34
|
+
export { buildChatTitle, CHAT_TITLE_MAX_LENGTH } from './title';
|
|
30
35
|
export { consumeStream } from './stream';
|
|
31
36
|
export { IMAGE_EXTENSIONS, formatFileSize, isImageAttachment, resolveRemoteFileUrl, resolveAttachDownloadUrl, resolveAttachPreviewUrl, parseRealtimeAttachment, parseHistoryAttachment, extractHistoryAttachments, normalizeAttachment } from './attach';
|
|
32
37
|
export type { ChatAttachment, FileAttachContent, AttachmentType } from './attach';
|
|
@@ -36,6 +41,13 @@ export { IFRAME_RESIZER_CHILD_SCRIPT, injectIframeResizerScript, applyIframePage
|
|
|
36
41
|
export type { IframePageValue } from './answerCom/iframePage/types';
|
|
37
42
|
export { RECORDSET_ANSWER_TYPE, readRecordsetPayload, applyRecordsetChunk, normalizeRecordsetReport, recordsetParser } from './answerCom/recordset/parseRecordset';
|
|
38
43
|
export type { RecordsetColumn, RecordsetValue } from './answerCom/recordset/types';
|
|
44
|
+
export { OUTPUT_FILE_ANSWER_TYPE, readOutputFilePayload, applyOutputFileChunk, normalizeOutputFileReport, outputFileParser } from './answerCom/outputFile/parseOutputFile';
|
|
45
|
+
export type { OutputFileValue } from './answerCom/outputFile/types';
|
|
46
|
+
export { ACTION_EXECUTE_ANSWER_TYPE, applyActionExecuteChunk, normalizeActionExecuteReport, actionExecuteParser } from './answerCom/actionExecute/parseActionExecute';
|
|
47
|
+
export { createFailureResult, normalizeActionResult, parseActionExecuteCommand, wrapActionFrame, normalizeActionDefinition } from './answerCom/actionExecute/actionProtocol';
|
|
48
|
+
export { parseClarificationArguments, nextClarificationRequestId, registerClarification, hasPendingClarification, submitClarification, cancelClarification, clearPendingClarifications } from './answerCom/actionExecute/clarification';
|
|
49
|
+
export type { ParsedClarificationArguments } from './answerCom/actionExecute/clarification';
|
|
50
|
+
export type { ActionExecutor, ActionDefinition, ActionExecuteCommand, ActionResult, WaitReplyPayload, FrontReplyOptions, ClarificationInputType, ClarificationAnswerMode, ClarificationOption, ClarificationBinding, ClarificationInput, ClarificationItem, ClarificationAnswer, ClarificationStatus, ClarificationViewModel, } from './answerCom/actionExecute/types';
|
|
39
51
|
export { applyDeepThinkingChunk, collectDeepThinkingSteps, collectThinkingSteps, deepThinkingParser } from './deepThinking/parseDeepThinking';
|
|
40
52
|
export type { ExecProcessItem } from './deepThinking/types';
|
|
41
53
|
export { extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep } from './history';
|