dal-code 1.0.41 → 1.0.43
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/CHANGELOG.md +13 -0
- package/NOTICE +2 -1
- package/PRIVACY.md +6 -0
- package/dist/cli/startup-ui.js +1 -1
- package/dist/core/agent-session.js +9 -9
- package/dist/core/bug-report.js +5 -5
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/types.d.ts +17 -0
- package/dist/core/sandbox/shell-sandbox.js +7 -5
- package/dist/core/settings-manager.d.ts +0 -5
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/tools/bash.d.ts +1 -0
- package/dist/core/tools/bash.js +13 -13
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.js +1 -1
- package/dist/dal/manifest.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/main.js +3 -3
- package/dist/modes/rpc/approvals.js +1 -0
- package/dist/modes/rpc/message-meta.js +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +19 -1
- package/dist/modes/rpc/rpc-client.js +3 -3
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +80 -1
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/src/install.js +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-guard/src/index.js +2 -1
- package/dist/node_modules/@dalcode/dal-guard/src/workspace.js +2 -2
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/index.d.ts +1 -0
- package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/deck-source.d.ts +10 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/deck-source.js +2 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +3 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-remote/package.json +32 -0
- package/dist/node_modules/@dalcode/dal-remote/src/cli.js +10 -0
- package/dist/node_modules/@dalcode/dal-remote/src/index.js +1 -0
- package/dist/node_modules/@dalcode/dal-remote/src/install.js +8 -0
- package/dist/node_modules/@dalcode/dal-remote/src/paths.js +1 -0
- package/dist/node_modules/@dalcode/dal-remote/src/service.js +8 -0
- package/dist/node_modules/@dalcode/dal-remote/src/spec.js +1 -0
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-subagent/src/background.js +8 -8
- package/dist/node_modules/@dalcode/dal-subagent/src/index.js +19 -19
- package/dist/node_modules/@dalcode/dal-subagent/src/progress.js +1 -0
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -3
- package/dist/node_modules/@dalcode/dal-telemetry/src/config.js +3 -3
- package/dist/node_modules/@dalcode/dal-telemetry/src/consent.js +1 -0
- package/dist/node_modules/@dalcode/dal-telemetry/src/failure-reporting.js +2 -2
- package/dist/node_modules/@dalcode/dal-telemetry/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-telemetry/src/reporter.js +1 -1
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/lean-code.js +1 -1
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/chord/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/office.d.ts +1 -1
- package/dist/sdk/office.js +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-compat",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Claude Code compatibility: the user's and project's .claude/rules/ and .claude/CLAUDE.md apply in DAL. Grown from the claude-rules extension example.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
22
22
|
"minimatch": "10.2.6"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-dap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Debugger for DAL: breakpoints, stepping, call stacks and variables in Node.js and Python programs over the Debug Adapter Protocol, installing the adapter on first use. The DAP client is adapted from oh-my-pi's src/dap (MIT).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
27
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
28
28
|
"typebox": "1.3.27"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);const
|
|
1
|
+
var M=Object.defineProperty;var i=(e,r)=>M(e,"name",{value:r,configurable:!0});var L=Object.defineProperty,l=i((e,r)=>L(e,"name",{value:r,configurable:!0}),"l");import{spawn as T}from"node:child_process";import{createHash as U,randomBytes as _}from"node:crypto";import{existsSync as G,mkdirSync as v,readFileSync as H,renameSync as W,rmSync as F,writeFileSync as S}from"node:fs";import{join as m}from"node:path";import{gunzipSync as J}from"node:zlib";import{t as p}from"@dalcode/dal-pi-kit";import{getAgentDir as V}from"@earendil-works/pi-coding-agent";const A=["https://registry.npmmirror.com","https://registry.npmjs.org"];function B(e,r,t){const o=r.includes("/")?r.slice(r.indexOf("/")+1):r;return`${e.replace(/\/+$/,"")}/${r}/-/${o}-${t}.tgz`}i(B,"D"),l(B,"npmTarballUrl");const Y={id:"debugpy-1.8.21",label:"debugpy 1.8.21",file:"debugpy-1.8.21-py2.py3-none-any.whl",sha256:"b1e37d333663c8851516a47364ef473da127f9caebe4417e6df6f5825a7e9a92",bytes:5374e3,urls:["https://mirrors.aliyun.com/pypi/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl","https://files.pythonhosted.org/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl"],format:"wheel"},q={id:"js-debug-1.140.0",label:"vscode-js-debug 1.140.0",file:"js-debug-dap-v1.140.0.tar.gz",sha256:"27dab92937ec1ab35821ae955aac867544fe06a1b6307229049f2d789af10968",bytes:1249709,urls:["https://github.com/microsoft/vscode-js-debug/releases/download/v1.140.0/js-debug-dap-v1.140.0.tar.gz"],format:"tar.gz",npm:{name:"@deepailab/js-debug-dap",version:"1.140.0"}},x=20*1024*1024,K=12e4,P=".dal-installed";function E(){return m(V(),"tools","dap")}i(E,"E"),l(E,"adapterInstallRoot");function y(e,r=E()){const t=m(r,e.id);try{return H(m(t,P),"utf8").trim()===e.sha256?t:void 0}catch{return}}i(y,"w"),l(y,"installedArtifactDir");function k(){return process.env.DALCODE_MCP_MIRROR?.trim().toLowerCase()==="off"}i(k,"F"),l(k,"mirrorsOff");function j(){const e=process.env.PI_OFFLINE?.toLowerCase();return e==="1"||e==="true"||e==="yes"}i(j,"j"),l(j,"offline");function C(e){try{return new URL(e).host}catch{return e}}i(C,"v"),l(C,"hostOf");function I(e){if(k())return e.urls.slice(-1).map(t=>({url:t,inNpmPackage:!1}));const r=e.npm;return[...r?A.map(t=>({url:B(t,r.name,r.version),inNpmPackage:!0})):[],...e.urls.map(t=>({url:t,inNpmPackage:!1}))]}i(I,"T"),l(I,"sourcesOf");function D(e,r){let t=0,o;for(;t+512<=e.length;){const d=e.subarray(t,t+512);if(d.every(b=>b===0))return;const c=l((b,h)=>{const w=d.subarray(b,b+h),g=w.indexOf(0);return w.subarray(0,g===-1?h:g).toString("utf8")},"field"),n=Number.parseInt(c(124,12).trim()||"0",8),a=t+512;if(!Number.isFinite(n)||n<0||a+n>e.length)return;const u=String.fromCharCode(d[156]??0),s=c(345,155),f=o??(s?`${s}/${c(0,100)}`:c(0,100));if(o=void 0,u==="x")o=/(?:^|\n)\d+ path=([^\n]*)\n/.exec(e.subarray(a,a+n).toString("utf8"))?.[1];else if((u==="0"||u==="\0")&&f===r)return Buffer.from(e.subarray(a,a+n));t=a+Math.ceil(n/512)*512}}i(D,"U"),l(D,"tarMember");function O(e,r){let t;try{t=J(e,{maxOutputLength:x*2})}catch{throw new Error(p("npm \u5305\u65E0\u6CD5\u89E3\u5F00"))}const o=D(t,`package/${r.file}`);if(!o)throw new Error(p("npm \u5305\u91CC\u6CA1\u6709 {file}").replace("{file}",r.file));return o}i(O,"G"),l(O,"fromNpmPackage");async function R(e,r,t,o){const d=e.url,c=AbortSignal.timeout(K),n=await t(d,{signal:o?AbortSignal.any([o,c]):c});if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status}`);const a=n.body?.getReader();if(!a)throw new Error(p("\u54CD\u5E94\u6CA1\u6709\u5185\u5BB9"));const u=[];let s=0;for(;;){const{done:w,value:g}=await a.read();if(w)break;if(s+=g.byteLength,s>x)throw await a.cancel(),new Error(p("\u6587\u4EF6\u8D85\u8FC7 20 MB\uFF0C\u5DF2\u505C\u6B62\u4E0B\u8F7D"));u.push(g)}const f=Buffer.concat(u),b=e.inNpmPackage?O(f,r):f,h=U("sha256").update(b).digest("hex");if(h!==r.sha256)throw new Error(p("\u6821\u9A8C\u503C\u4E0D\u7B26\uFF08\u4E0B\u8F7D\u5230\u7684 {got}\uFF0C\u5E94\u4E3A {want}\uFF09\uFF0C\u5DF2\u4E22\u5F03").replace("{got}",h.slice(0,12)).replace("{want}",r.sha256.slice(0,12)));return b}i(R,"H"),l(R,"downloadVerified");function $(e,r,t){return new Promise((o,d)=>{const c=T(e,r,{cwd:t,stdio:["ignore","ignore","pipe"],windowsHide:!0});let n="";c.stderr.on("data",a=>{n=(n+a.toString("utf8")).slice(-2e3)}),c.once("error",d),c.once("exit",a=>a===0?o():d(new Error(`${e} exited ${a}: ${n.trim()}`)))})}i($,"P"),l($,"run");function z(){if(process.platform!=="win32")return"tar";const e=m(process.env.SystemRoot??"C:\\Windows","System32","tar.exe");return G(e)?e:"tar.exe"}i(z,"W"),l(z,"tarCommand");async function N(e,r={}){const t=r.root??E(),o=y(e,t);if(o)return o;if(j())throw new Error(p("\u79BB\u7EBF\u6A21\u5F0F\u4E0B\u4E0D\u80FD\u4E0B\u8F7D\u8C03\u8BD5\u5668 {label}\u3002").replace("{label}",e.label));const d=r.fetchImpl??((u,s)=>fetch(u,s)),c=[];let n;for(const u of I(e)){const s=u.url;r.onProgress?.(p("\u6B63\u5728\u5B89\u88C5\u8C03\u8BD5\u5668 {label}\uFF08\u7EA6 {size} MB\uFF0C\u6765\u6E90 {host}\uFF09\u2026").replace("{label}",e.label).replace("{size}",(e.bytes/1024/1024).toFixed(1)).replace("{host}",C(s)));try{n=await R(u,e,d,r.signal);break}catch(f){if(r.signal?.aborted)throw f;c.push(`${C(s)}: ${f instanceof Error?f.message:String(f)}`)}}if(!n)throw new Error(`${p("\u8C03\u8BD5\u5668 {label} \u4E0B\u8F7D\u5931\u8D25\uFF1A").replace("{label}",e.label)}${c.join("\uFF1B")}${p("\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u8BBE\u7F6E\u540E\u91CD\u8BD5\u3002")}`);v(t,{recursive:!0});const a=m(t,`.${e.id}-${process.pid}-${_(4).toString("hex")}`);v(a,{recursive:!0});try{const u=m(a,e.file);if(S(u,n),e.format==="wheel"){if(!r.python)throw new Error(p("\u89E3\u538B debugpy \u9700\u8981 Python"));await $(r.python,["-I","-m","zipfile","-e",u,a],a)}else await $(z(),["-xzf",u,"-C",a],a);F(u,{force:!0}),S(m(a,P),`${e.sha256}
|
|
2
|
+
`);const s=m(t,e.id);if(y(e,t))return s;F(s,{recursive:!0,force:!0});try{W(a,s)}catch(f){if(y(e,t))return s;throw f}return s}catch(u){throw new Error(`${p("\u8C03\u8BD5\u5668 {label} \u89E3\u538B\u5931\u8D25\uFF1A").replace("{label}",e.label)}${u instanceof Error?u.message:String(u)}`)}finally{F(a,{recursive:!0,force:!0})}}i(N,"te"),l(N,"ensureArtifact");export{Y as DEBUGPY,q as JS_DEBUG,A as NPM_REGISTRIES,E as adapterInstallRoot,N as ensureArtifact,y as installedArtifactDir,B as npmTarballUrl,D as tarMember};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-gateway",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dalcode/deepailab": "1.0.
|
|
20
|
+
"@dalcode/deepailab": "1.0.43"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-goal",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Goal mode for DAL: /goal keeps the agent working on one objective until it is verified complete, with token and continuation limits. Adapted from @narumitw/pi-goal 0.54.11 (MIT, narumiruna); the independent completion check adapts pi-goal-x 0.32.3 (MIT, Lucas).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
25
|
-
"@dalcode/dal-subagent": "1.0.
|
|
24
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
25
|
+
"@dalcode/dal-subagent": "1.0.43",
|
|
26
26
|
"typebox": "1.3.27"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-guard",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
24
|
-
"@dalcode/dal-bridge": "1.0.
|
|
25
|
-
"@dalcode/dal-halo": "1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
24
|
+
"@dalcode/dal-bridge": "1.0.43",
|
|
25
|
+
"@dalcode/dal-halo": "1.0.43"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
var V=Object.defineProperty;var l=(u,a)=>V(u,"name",{value:a,configurable:!0});var q=Object.defineProperty,n=l((u,a)=>q(u,"name",{value:a,configurable:!0}),"l");import{realpathSync as G}from"node:fs";import{basename as J,dirname as K,isAbsolute as Z,join as X,relative as Y,resolve as Q,sep as uu}from"node:path";import{readBridgeConfig as C}from"@dalcode/dal-bridge/client";import{getOwnTty as eu,requestHaloApproval as au}from"@dalcode/dal-halo";import{hasChosenLanguage as ou,t as e}from"@dalcode/dal-pi-kit";import{DAL_HOOK_NOTIFICATION_CHANNEL as tu,getAgentDir as D,registerSandboxEscalationHandler as su,resolveToCwd as ru}from"@earendil-works/pi-coding-agent";import{DAL_CO_AUTHOR as O,foreignAttributionInMessageFile as iu,rewriteCommitAttribution as nu}from"./attribution.js";import{credentialBlockReason as lu,namesDalCredential as du,readsDalSecretCopy as Fu,redactContent as cu,secretCopyBlockReason as Eu}from"./credentials.js";import{exportGuardMode as Au,saveGuardMode as N,shouldAskGuardMode as mu,startupGuardMode as fu}from"./mode.js";import{wrongPackageManager as Cu}from"./package-manager.js";import{reviewBashCommand as Du}from"./review.js";import{createWorkspaceGate as pu}from"./workspace.js";import{DAL_CO_AUTHOR as Bu,foreignAttributionInMessageFile as gu,foreignCoAuthors as hu,isGitCommit as bu,rewriteCommitAttribution as yu}from"./attribution.js";import{dalSecretValues as wu,fileHoldsDalSecret as vu,namesDalCredential as $u,REDACTED as ku,readsDalSecretCopy as _u,redactContent as Mu,redactDalSecrets as Iu,shellPathCandidates as Su}from"./credentials.js";import{GUARD_MODE_ENV as Gu,savedGuardMode as Ou,saveGuardMode as Nu,shouldAskGuardMode as Pu,startupGuardMode as Tu}from"./mode.js";import{installingManager as Uu,wrongPackageManager as Ru}from"./package-manager.js";import{reviewBashCommand as xu,suspicionFor as Hu}from"./review.js";import{createWorkspaceGate as Lu,modifiedDirectory as ju}from"./workspace.js";const P=new Set;function T(u,a){if(u.toolName!=="bash"&&u.toolName!=="powershell")return;const s=u.input;if(typeof s.command!="string")return;const r=iu(s.command,a);if(r)return{block:!0,reason:e("dal-guard\uFF1A\u63D0\u4EA4\u8BF4\u660E\u6587\u4EF6 {file} \u628A\u53E6\u4E00\u4E2A\u4EA7\u54C1\u7684\u52A9\u624B\uFF08Claude\u3001Codex\u3001Copilot \u7B49\uFF09\u5199\u6210\u4E86\u5171\u540C\u4F5C\u8005\u3002\u4F60\u662F DAL Code\uFF1A\u628A\u90A3\u884C\u6539\u6210 {trailer} \u6216\u5220\u6389\uFF0C\u518D\u63D0\u4EA4\u3002").replace("{file}",r).replace("{trailer}",O)};const o=nu(s.command);o!==void 0&&(s.command=o,P.add(u.toolCallId))}l(T,"de"),n(T,"checkCommitAttribution");function b(u){try{return G(u)}catch{try{return X(G(K(u)),J(u))}catch{return u}}}l(b,"v"),n(b,"realPathBestEffort");const E=n(u=>a=>u.test(a),"has"),zu=[{id:"sudo",label:e("\u7279\u6743\u6267\u884C\uFF08sudo/doas\uFF09"),test:E(/(^|[;&|\n]\s*)(sudo|doas)\s/)},{id:"force-push",label:e("\u5F3A\u5236\u63A8\u9001\u5C06\u6539\u5199\u8FDC\u7A0B\u5386\u53F2"),test:E(/git\s+push\b[^;&|]*(--force\b|--force-with-lease\b|\s-f\b)/)},{id:"hard-reset",label:e("\u786C\u91CD\u7F6E\u4F1A\u4E22\u5F03\u672C\u5730\u6539\u52A8"),test:E(/git\s+reset\b[^;&|]*--hard/)},{id:"git-clean",label:e("git clean \u4F1A\u5220\u9664\u672A\u8DDF\u8E2A\u6587\u4EF6"),test:E(/git\s+clean\b[^;&|]*(-[a-z]*f|--force)/)},{id:"pipe-to-shell",label:e("\u5C06\u4E0B\u8F7D\u5185\u5BB9\u76F4\u63A5\u7BA1\u9053\u6267\u884C"),test:E(/(curl|wget)\b[^;&|]*\|\s*(ba|z|da|fi)?sh\b/)},{id:"exec-download",label:e("\u6267\u884C\u4E0B\u8F7D\u7684\u811A\u672C"),test:E(/\b(ba|z|da|fi)?sh\s+<\(\s*(curl|wget)\b|eval\b[^;&|\n]*\$\(\s*(curl|wget)\b/)},{id:"recursive-perms",label:e("\u9012\u5F52\u4FEE\u6539\u6743\u9650/\u5C5E\u4E3B"),test:E(/(chmod|chown)\b[^;&|]*-[a-zA-Z]*R/)},{id:"publish",label:e("\u53D1\u5E03\u8F6F\u4EF6\u5305"),test:E(/(npm|pnpm|yarn)\s+publish\b/)},{id:"kill",label:e("\u6309\u540D\u79F0\u7ED3\u675F\u8FDB\u7A0B"),test:E(/(^|[;&|\n]\s*)(killall|pkill)\s/)},{id:"disk",label:e("\u5E95\u5C42\u78C1\u76D8\u64CD\u4F5C"),test:E(/(^|[;&|\n]\s*)(dd|mkfs\w*|diskutil|fdisk)\s/)}];function y(u){return zu.find(a=>a.test(u))}l(y,"ce"),n(y,"riskForBash");function w(u,a){const s=b(ru(u,a)),r=b(Q(a)),o=Y(r,s);return o===".."||o.startsWith(`..${uu}`)||Z(o)}l(w,"fe"),n(w,"pathOutsideProject");function v(u,a){if(u.toolName.startsWith("mcp__")){const s=u.toolName.split("__")[1]||"unknown",r=JSON.stringify(u.input??{});return{ruleId:`mcp:${s}`,title:`${e("\u7B2C\u4E09\u65B9 MCP \u5DE5\u5177\u8C03\u7528\uFF08")}${s}${e("\uFF09")}`,detail:`${u.toolName} ${r.length>200?`${r.slice(0,200)}\u2026`:r}`}}if(u.toolName==="bash"){const s=String(u.input.command??""),r=y(s);return r?{ruleId:`bash:${r.id}`,title:r.label,detail:s}:void 0}if(u.toolName==="edit"||u.toolName==="write"){const s=String(u.input.path??u.input.file_path??"");if(s&&w(s,a))return{ruleId:`${u.toolName}:outside-project`,title:e("\u9879\u76EE\u76EE\u5F55\u4E4B\u5916\u7684\u6587\u4EF6\u6539\u52A8"),detail:s}}}l(v,"me"),n(v,"classify");async function U(u,a){if(u.toolName!=="bash")return;const s=String(u.input.command??""),r=await Du(s,a);if(r)return{ruleId:`bash:jev-${r.suspicion.id}`,title:`${e("jev \u590D\u6838\u5224\u5B9A\u53EF\u7591")} (${Math.round(r.confidence*100)}%)`,detail:s}}l(U,"pe"),n(U,"secondOpinion");const Wu=n(()=>e("\u4EC5\u672C\u6B21\u5141\u8BB8"),"allowOnce"),Vu=n(()=>e("\u672C\u6B21\u4F1A\u8BDD\u5185\u5141\u8BB8\uFF08\u540C\u7C7B\u64CD\u4F5C\uFF09"),"allowSession"),qu=n(()=>e("\u62D2\u7EDD"),"deny"),R=Symbol.for("dalcode.guard.state"),x=globalThis;x[R]??={mode:"default",sessionAllows:new Set};const d=x[R];function p(u){d.mode=u,Au(u)}l(p,"k"),n(p,"setGuardMode");function H(){d.escalationApprover||(d.escalationApprover=su(()=>{if(!(d.mode!=="yolo"||C(process.env)))return{approved:!0,scope:"once"}}))}l(H,"ye"),n(H,"registerEscalationApprover");const B=d.sessionAllows;async function $(u,a,s,r,o,t=process.env,i){if(du(u,a))return{block:!0,reason:lu()};const F=Fu(u,a);if(F)return{block:!0,reason:Eu(F)};const c=T(u,a);if(c)return c;const m=Cu(u,a);if(m)return{block:!0,reason:m};if(d.mode==="yolo"||C(t))return;const A=v(u,a)??await U(u,a);if(!A||B.has(A.ruleId))return;if(!s||!r)return{block:!0,reason:`${e('dal-guard\uFF1A"')}${A.title}${e('"\u9700\u8981\u4EA4\u4E92\u5F0F\u5BA1\u6279\uFF08')}${A.detail}${e("\uFF09\u3002\u8BF7\u5728\u4EA4\u4E92\u6A21\u5F0F\u4E0B\u91CD\u8BD5\uFF0C\u6216\u7528 /guard yolo \u5173\u95ED\u5BA1\u6279\u95E8\u3002")}`};const g=o?au({session_id:o.sessionId,cwd:a,event:"PermissionRequest",status:"waiting_for_approval",pid:process.pid,tty:eu(),tool:u.toolName,tool_input:{command:A.detail},tool_use_id:u.toolCallId,productName:"dal"}):void 0;i?.({type:"permission_prompt",message:`DAL needs your permission to use ${u.toolName}`});const k=new AbortController,[h,_,M]=[Wu(),Vu(),qu()],z=r.select(`${e("\u9700\u8981\u5BA1\u6279\uFF1A")}${A.title} \u2014 ${A.detail}`,[h,_,M],{signal:k.signal}).then(f=>({surface:"terminal",choice:f})),W=g?g.decision.then(f=>f===void 0?new Promise(()=>{}):{surface:"halo",choice:f==="allow"?h:M}):new Promise(()=>{}),I=await Promise.race([z,W]);I.surface==="halo"?k.abort():g?.cancel();const S=I.choice;if(S!==h){if(S===_){B.add(A.ruleId);return}return{block:!0,reason:`${e("dal-guard\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\uFF08")}${A.title}${e("\uFF09\u3002")}`}}}l($,"Ce"),n($,"evaluateToolCall");async function L(u){const a=e("\u5168\u81EA\u52A8\uFF1A\u4E0D\u518D\u8BE2\u95EE\uFF0C\u53EA\u62E6\u622A\u7834\u574F\u6027\u547D\u4EE4\uFF08\u63A8\u8350\u719F\u6089\u7684\u7528\u6237\uFF09"),s=e("\u6BCF\u6B21\u8BE2\u95EE\uFF1A\u9AD8\u98CE\u9669\u64CD\u4F5C\u548C\u8D8A\u51FA\u6C99\u7BB1\u524D\u5148\u95EE\u6211"),r=await u.ui.select(e("\u9009\u62E9 dal \u7684\u5DE5\u4F5C\u65B9\u5F0F\uFF08\u4EE5\u540E\u53EF\u7528 /guard \u4FEE\u6539\uFF09"),[a,s]);if(r===void 0)return;const o=r===a?"yolo":"default";p(o);try{N(D(),o)}catch(t){u.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${t instanceof Error?t.message:String(t)}`,"error");return}u.ui.notify(o==="yolo"?e("\u5DF2\u8BBE\u4E3A\u5168\u81EA\u52A8\u3002\u6539\u56DE\u6BCF\u6B21\u8BE2\u95EE\uFF1A/guard default save"):e("\u5DF2\u8BBE\u4E3A\u6BCF\u6B21\u8BE2\u95EE\u3002\u6539\u6210\u5168\u81EA\u52A8\uFF1A/guard yolo save"),"info")}l(L,"we"),n(L,"askGuardModeOnce");function j(u){u.registerFlag("yolo",{description:e("\u4EE5\u5168\u81EA\u52A8\u6A21\u5F0F\u542F\u52A8\uFF1A\u4E0D\u518D\u5F39\u51FA\u4EFB\u4F55\u5BA1\u6279\uFF08\u542B\u6C99\u7BB1\u8D8A\u6743\uFF09\uFF0C\u53EA\u62E6\u622A\u7834\u574F\u6027\u547D\u4EE4\u548C\u767B\u5F55\u51ED\u636E"),type:"boolean",default:!1}),H();let a="default";u.on("session_start",async(o,t)=>{if(a="default",d.started)return;d.started=!0;const i=u.getFlag("yolo")===!0;p(fu(D(),i)),o.reason==="startup"&&mu({agentDir:D(),mode:t.mode,hasUI:t.hasUI,flag:i,underDalCode:!!C(process.env),languageChosen:ou()})&&await L(t)}),u.on("before_agent_start",async()=>{if(!(d.mode===a||C(process.env)))return a=d.mode,{message:{customType:"dal-guard-mode",content:d.mode==="yolo"?e("[\u5168\u81EA\u52A8\u6A21\u5F0F] \u7528\u6237\u5F00\u542F\u4E86\u5168\u81EA\u52A8\uFF1A\u6240\u6709\u5BA1\u6279\uFF08\u5305\u62EC sandbox_escalation \u8D8A\u6743\uFF09\u90FD\u4F1A\u81EA\u52A8\u901A\u8FC7\uFF0C\u4E0D\u4F1A\u6709\u4EBA\u6765\u786E\u8BA4\u3002\u547D\u4EE4\u88AB\u6C99\u7BB1\u6321\u4F4F\u3001\u800C\u4EFB\u52A1\u786E\u5B9E\u9700\u8981\u65F6\uFF0C\u76F4\u63A5\u5E26 sandbox_escalation \u91CD\u8BD5\uFF0C\u4E0D\u8981\u505C\u4E0B\u6765\u95EE\u7528\u6237\u8981\u4E0D\u8981\u653E\u884C\u3002\u7834\u574F\u6027\u547D\u4EE4\u548C\u767B\u5F55\u51ED\u636E\u4ECD\u4F1A\u88AB\u62E6\u622A\u3002"):e("[\u5BA1\u6279\u5DF2\u6062\u590D] \u5168\u81EA\u52A8\u5DF2\u5173\u95ED\uFF1A\u8D8A\u6743\u548C\u9AD8\u98CE\u9669\u547D\u4EE4\u4F1A\u5148\u8BE2\u95EE\u7528\u6237\u3002"),display:!1}}});const s=pu(),r=new Map;u.on("tool_call",async(o,t)=>{const i=await $(o,t.cwd,t.hasUI,t.ui,{sessionId:t.sessionManager.getSessionId()},process.env,c=>u.events.emit(tu,c));if(i?.block)return i;const F=await s.check(o,t.cwd,t.sessionManager.getSessionId(),{hasUI:t.hasUI,confirm:t.hasUI?(c,m)=>t.ui.confirm(c,m):void 0});return F?.block?{block:!0,reason:F.reason}:(F?.note&&r.set(o.toolCallId,F.note),i)}),u.on("session_shutdown",async()=>{s.releaseAll()}),u.on("tool_result",async o=>{const t=cu(o.content),i=[];P.delete(o.toolCallId)&&i.push(e("[dal-guard] \u63D0\u4EA4\u91CC\u53E6\u4E00\u4E2A\u4EA7\u54C1\u52A9\u624B\u7684\u5171\u540C\u4F5C\u8005\u884C\u5DF2\u6539\u4E3A {trailer}\uFF1A\u4F60\u662F DAL Code\u3002").replace("{trailer}",O));const F=r.get(o.toolCallId);return F&&(r.delete(o.toolCallId),i.push(`[dal-guard] ${F}`)),i.length===0?t?{content:t}:void 0:{content:[...t??o.content,...i.map(c=>({type:"text",text:c}))]}}),u.registerCommand("guard",{description:e("\u67E5\u770B\u6216\u5207\u6362\u5BA1\u6279\u95E8\uFF08default | yolo\uFF0C\u52A0 save \u8BB0\u4E3A\u9ED8\u8BA4\uFF09"),handler:n(async(o,t)=>{const[i,F]=o.trim().split(/\s+/);if((i==="yolo"||i==="default")&&(p(i),F==="save"))try{N(D(),i),t.ui.notify(i==="yolo"?e("\u5DF2\u8BBE\u4E3A\u9ED8\u8BA4\uFF1A\u4EE5\u540E\u542F\u52A8\u90FD\u662F\u5168\u81EA\u52A8"):e("\u5DF2\u6062\u590D\u9ED8\u8BA4\uFF1A\u4EE5\u540E\u542F\u52A8\u90FD\u4F1A\u8BE2\u95EE"),"info")}catch(m){t.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${m instanceof Error?m.message:String(m)}`,"error")}const c=B.size?`${e(" \xB7 \u672C\u6B21\u4F1A\u8BDD\u5DF2\u5141\u8BB8\uFF1A")}${[...B].join(", ")}`:"";t.ui.notify(`${e("dal-guard \u6A21\u5F0F\uFF1A")}${d.mode}${c}`,d.mode==="yolo"?"warning":"info")},"handler")})}l(j,"ke"),n(j,"default");export{Bu as DAL_CO_AUTHOR,Gu as GUARD_MODE_ENV,ku as REDACTED,v as classify,Lu as createWorkspaceGate,wu as dalSecretValues,j as default,$ as evaluateToolCall,vu as fileHoldsDalSecret,gu as foreignAttributionInMessageFile,hu as foreignCoAuthors,Uu as installingManager,bu as isGitCommit,ju as modifiedDirectory,$u as namesDalCredential,w as pathOutsideProject,_u as readsDalSecretCopy,Mu as redactContent,Iu as redactDalSecrets,xu as reviewBashCommand,yu as rewriteCommitAttribution,y as riskForBash,Nu as saveGuardMode,Ou as savedGuardMode,Su as shellPathCandidates,Pu as shouldAskGuardMode,Tu as startupGuardMode,Hu as suspicionFor,Ru as wrongPackageManager};
|
|
1
|
+
var J=Object.defineProperty;var d=(u,a)=>J(u,"name",{value:a,configurable:!0});var K=Object.defineProperty,i=d((u,a)=>K(u,"name",{value:a,configurable:!0}),"l");import{realpathSync as G}from"node:fs";import{basename as Z,dirname as Q,isAbsolute as X,join as Y,relative as uu,resolve as eu,sep as au}from"node:path";import{readBridgeConfig as p}from"@dalcode/dal-bridge/client";import{getOwnTty as ou,requestHaloApproval as tu}from"@dalcode/dal-halo";import{hasChosenLanguage as su,t as e}from"@dalcode/dal-pi-kit";import{DAL_HOOK_NOTIFICATION_CHANNEL as ru,getAgentDir as D,registerSandboxEscalationHandler as nu,resolveToCwd as iu,shellExecutionRefusal as lu}from"@earendil-works/pi-coding-agent";import{DAL_CO_AUTHOR as O,foreignAttributionInMessageFile as du,rewriteCommitAttribution as Fu}from"./attribution.js";import{credentialBlockReason as cu,namesDalCredential as Eu,readsDalSecretCopy as Au,redactContent as mu,secretCopyBlockReason as fu}from"./credentials.js";import{exportGuardMode as Cu,saveGuardMode as P,shouldAskGuardMode as pu,startupGuardMode as Du}from"./mode.js";import{wrongPackageManager as Bu}from"./package-manager.js";import{reviewBashCommand as gu}from"./review.js";import{createWorkspaceGate as hu}from"./workspace.js";import{DAL_CO_AUTHOR as bu,foreignAttributionInMessageFile as vu,foreignCoAuthors as yu,isGitCommit as wu,rewriteCommitAttribution as $u}from"./attribution.js";import{dalSecretValues as ku,fileHoldsDalSecret as _u,namesDalCredential as Iu,REDACTED as Mu,readsDalSecretCopy as Nu,redactContent as Su,redactDalSecrets as Gu,shellPathCandidates as Ou}from"./credentials.js";import{GUARD_MODE_ENV as Pu,savedGuardMode as Ru,saveGuardMode as Tu,shouldAskGuardMode as xu,startupGuardMode as Uu}from"./mode.js";import{installingManager as ju,wrongPackageManager as Hu}from"./package-manager.js";import{reviewBashCommand as Lu,suspicionFor as zu}from"./review.js";import{createWorkspaceGate as Wu,modifiedDirectory as Vu}from"./workspace.js";const R=new Set;function T(u,a){if(u.toolName!=="bash"&&u.toolName!=="powershell")return;const o=u.input;if(typeof o.command!="string")return;const t=du(o.command,a);if(t)return{block:!0,reason:e("dal-guard\uFF1A\u63D0\u4EA4\u8BF4\u660E\u6587\u4EF6 {file} \u628A\u53E6\u4E00\u4E2A\u4EA7\u54C1\u7684\u52A9\u624B\uFF08Claude\u3001Codex\u3001Copilot \u7B49\uFF09\u5199\u6210\u4E86\u5171\u540C\u4F5C\u8005\u3002\u4F60\u662F DAL Code\uFF1A\u628A\u90A3\u884C\u6539\u6210 {trailer} \u6216\u5220\u6389\uFF0C\u518D\u63D0\u4EA4\u3002").replace("{file}",t).replace("{trailer}",O)};const s=Fu(o.command);s!==void 0&&(o.command=s,R.add(u.toolCallId))}d(T,"ce"),i(T,"checkCommitAttribution");function v(u){try{return G(u)}catch{try{return Y(G(Q(u)),Z(u))}catch{return u}}}d(v,"G"),i(v,"realPathBestEffort");const A=i(u=>a=>u.test(a),"has"),qu=[{id:"sudo",level:"high",label:e("\u7279\u6743\u6267\u884C\uFF08sudo/doas\uFF09"),test:A(/(^|[;&|\n]\s*)(sudo|doas)\s/)},{id:"force-push",level:"high",label:e("\u5F3A\u5236\u63A8\u9001\u5C06\u6539\u5199\u8FDC\u7A0B\u5386\u53F2"),test:A(/git\s+push\b[^;&|]*(--force\b|--force-with-lease\b|\s-f\b)/)},{id:"hard-reset",level:"high",label:e("\u786C\u91CD\u7F6E\u4F1A\u4E22\u5F03\u672C\u5730\u6539\u52A8"),test:A(/git\s+reset\b[^;&|]*--hard/)},{id:"git-clean",level:"high",label:e("git clean \u4F1A\u5220\u9664\u672A\u8DDF\u8E2A\u6587\u4EF6"),test:A(/git\s+clean\b[^;&|]*(-[a-z]*f|--force)/)},{id:"pipe-to-shell",level:"high",label:e("\u5C06\u4E0B\u8F7D\u5185\u5BB9\u76F4\u63A5\u7BA1\u9053\u6267\u884C"),test:A(/(curl|wget)\b[^;&|]*\|\s*(ba|z|da|fi)?sh\b/)},{id:"exec-download",level:"high",label:e("\u6267\u884C\u4E0B\u8F7D\u7684\u811A\u672C"),test:A(/\b(ba|z|da|fi)?sh\s+<\(\s*(curl|wget)\b|eval\b[^;&|\n]*\$\(\s*(curl|wget)\b/)},{id:"recursive-perms",label:e("\u9012\u5F52\u4FEE\u6539\u6743\u9650/\u5C5E\u4E3B"),test:A(/(chmod|chown)\b[^;&|]*-[a-zA-Z]*R/)},{id:"publish",label:e("\u53D1\u5E03\u8F6F\u4EF6\u5305"),test:A(/(npm|pnpm|yarn)\s+publish\b/)},{id:"kill",label:e("\u6309\u540D\u79F0\u7ED3\u675F\u8FDB\u7A0B"),test:A(/(^|[;&|\n]\s*)(killall|pkill)\s/)},{id:"disk",level:"high",label:e("\u5E95\u5C42\u78C1\u76D8\u64CD\u4F5C"),test:A(/(^|[;&|\n]\s*)(dd|mkfs\w*|diskutil|fdisk)\s/)}];function y(u){return qu.find(a=>a.test(u))}d(y,"me"),i(y,"riskForBash");function w(u,a){const o=v(iu(u,a)),t=v(eu(a)),s=uu(t,o);return s===".."||s.startsWith(`..${au}`)||X(s)}d(w,"pe"),i(w,"pathOutsideProject");function $(u,a){if(u.toolName.startsWith("mcp__")){const o=u.toolName.split("__")[1]||"unknown",t=JSON.stringify(u.input??{});return{ruleId:`mcp:${o}`,title:`${e("\u7B2C\u4E09\u65B9 MCP \u5DE5\u5177\u8C03\u7528\uFF08")}${o}${e("\uFF09")}`,detail:`${u.toolName} ${t.length>200?`${t.slice(0,200)}\u2026`:t}`,level:"medium"}}if(u.toolName==="bash"){const o=String(u.input.command??""),t=y(o);return t?{ruleId:`bash:${t.id}`,title:t.label,detail:o,level:t.level??"medium"}:void 0}if(u.toolName==="edit"||u.toolName==="write"){const o=String(u.input.path??u.input.file_path??"");if(o&&w(o,a))return{ruleId:`${u.toolName}:outside-project`,title:e("\u9879\u76EE\u76EE\u5F55\u4E4B\u5916\u7684\u6587\u4EF6\u6539\u52A8"),detail:o,level:"medium"}}}d($,"ge"),i($,"classify");async function x(u,a){if(u.toolName!=="bash")return;const o=String(u.input.command??""),t=await gu(o,a);if(t)return{ruleId:`bash:jev-${t.suspicion.id}`,title:`${e("jev \u590D\u6838\u5224\u5B9A\u53EF\u7591")} (${Math.round(t.confidence*100)}%)`,detail:o,level:"medium"}}d(x,"he"),i(x,"secondOpinion");const Ju=i(()=>e("\u4EC5\u672C\u6B21\u5141\u8BB8"),"allowOnce"),Ku=i(()=>e("\u672C\u6B21\u4F1A\u8BDD\u5185\u5141\u8BB8\uFF08\u540C\u7C7B\u64CD\u4F5C\uFF09"),"allowSession"),Zu=i(()=>e("\u62D2\u7EDD"),"deny"),U=Symbol.for("dalcode.guard.state"),j=globalThis;j[U]??={mode:"default",sessionAllows:new Set};const F=j[U];function B(u){F.mode=u,Cu(u)}d(B,"A"),i(B,"setGuardMode");function H(){F.escalationApprover||(F.escalationApprover=nu(()=>{if(!(F.mode!=="yolo"||p(process.env)))return{approved:!0,scope:"once"}}))}d(H,"we"),i(H,"registerEscalationApprover");const g=F.sessionAllows;async function k(u,a,o,t,s,r=process.env,n){if(Eu(u,a))return{block:!0,reason:cu()};const c=Au(u,a);if(c)return{block:!0,reason:fu(c)};const E=T(u,a);if(E)return E;const m=Bu(u,a);if(m)return{block:!0,reason:m};const f=await L(u,a);if(f)return f;if(F.mode==="yolo"||p(r))return;const l=$(u,a)??await x(u,a);if(!l||g.has(l.ruleId))return;if(!o||!t)return{block:!0,reason:`${e('dal-guard\uFF1A"')}${l.title}${e('"\u9700\u8981\u4EA4\u4E92\u5F0F\u5BA1\u6279\uFF08')}${l.detail}${e("\uFF09\u3002\u8BF7\u5728\u4EA4\u4E92\u6A21\u5F0F\u4E0B\u91CD\u8BD5\uFF0C\u6216\u7528 /guard yolo \u5173\u95ED\u5BA1\u6279\u95E8\u3002")}`};const h=s?tu({session_id:s.sessionId,cwd:a,event:"PermissionRequest",status:"waiting_for_approval",pid:process.pid,tty:ou(),tool:u.toolName,tool_input:{command:l.detail},tool_use_id:u.toolCallId,productName:"dal"}):void 0;n?.({type:"permission_prompt",message:`DAL needs your permission to use ${u.toolName}`});const _=new AbortController,[b,I,M]=[Ju(),Ku(),Zu()],V=t.select(`${e("\u9700\u8981\u5BA1\u6279\uFF1A")}${l.title} \u2014 ${l.detail}`,[b,I,M],{signal:_.signal,approval:{source:"guard",toolCallId:u.toolCallId,toolName:u.toolName,args:u.input,risk:{level:l.level,reason:l.title,ruleId:l.ruleId},title:l.title,description:l.detail,options:["allow_once","allow_session","deny"]}}).then(C=>({surface:"terminal",choice:C})),q=h?h.decision.then(C=>C===void 0?new Promise(()=>{}):{surface:"halo",choice:C==="allow"?b:M}):new Promise(()=>{}),N=await Promise.race([V,q]);N.surface==="halo"?_.abort():h?.cancel();const S=N.choice;if(S!==b){if(S===I){g.add(l.ruleId);return}return{block:!0,reason:`${e("dal-guard\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\uFF08")}${l.title}${e("\uFF09\u3002")}`}}}d(k,"ke"),i(k,"evaluateToolCall");const Qu=new Set(["bash","powershell"]);async function L(u,a){if(!Qu.has(u.toolName))return;const o=u.input.command;if(typeof o!="string"||!o.trim())return;const t=await lu({toolName:u.toolName,command:o,cwd:a});if(t!==void 0)return{block:!0,reason:`${e("dal-guard\uFF1A\u8FD9\u6761\u547D\u4EE4\u4F1A\u88AB\u5371\u9669\u547D\u4EE4\u62E6\u622A\u6321\u4E0B\uFF0C\u6CA1\u6709\u8FD0\u884C\uFF0C\u4E5F\u4E0D\u518D\u8BF7\u4F60\u786E\u8BA4\u3002")}
|
|
2
|
+
${t}`}}d(L,"_e"),i(L,"destructiveCommandRefusal");async function z(u){const a=e("\u5168\u81EA\u52A8\uFF1A\u4E0D\u518D\u8BE2\u95EE\uFF0C\u53EA\u62E6\u622A\u7834\u574F\u6027\u547D\u4EE4\uFF08\u63A8\u8350\u719F\u6089\u7684\u7528\u6237\uFF09"),o=e("\u6BCF\u6B21\u8BE2\u95EE\uFF1A\u9AD8\u98CE\u9669\u64CD\u4F5C\u548C\u8D8A\u51FA\u6C99\u7BB1\u524D\u5148\u95EE\u6211"),t=await u.ui.select(e("\u9009\u62E9 dal \u7684\u5DE5\u4F5C\u65B9\u5F0F\uFF08\u4EE5\u540E\u53EF\u7528 /guard \u4FEE\u6539\uFF09"),[a,o]);if(t===void 0)return;const s=t===a?"yolo":"default";B(s);try{P(D(),s)}catch(r){u.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${r instanceof Error?r.message:String(r)}`,"error");return}u.ui.notify(s==="yolo"?e("\u5DF2\u8BBE\u4E3A\u5168\u81EA\u52A8\u3002\u6539\u56DE\u6BCF\u6B21\u8BE2\u95EE\uFF1A/guard default save"):e("\u5DF2\u8BBE\u4E3A\u6BCF\u6B21\u8BE2\u95EE\u3002\u6539\u6210\u5168\u81EA\u52A8\uFF1A/guard yolo save"),"info")}d(z,"Ie"),i(z,"askGuardModeOnce");function W(u){u.registerFlag("yolo",{description:e("\u4EE5\u5168\u81EA\u52A8\u6A21\u5F0F\u542F\u52A8\uFF1A\u4E0D\u518D\u5F39\u51FA\u4EFB\u4F55\u5BA1\u6279\uFF08\u542B\u6C99\u7BB1\u8D8A\u6743\uFF09\uFF0C\u53EA\u62E6\u622A\u7834\u574F\u6027\u547D\u4EE4\u548C\u767B\u5F55\u51ED\u636E"),type:"boolean",default:!1}),H();let a="default";u.on("session_start",async(s,r)=>{if(a="default",F.started)return;F.started=!0;const n=u.getFlag("yolo")===!0;B(Du(D(),n)),s.reason==="startup"&&pu({agentDir:D(),mode:r.mode,hasUI:r.hasUI,flag:n,underDalCode:!!p(process.env),languageChosen:su()})&&await z(r)}),u.on("before_agent_start",async()=>{if(!(F.mode===a||p(process.env)))return a=F.mode,{message:{customType:"dal-guard-mode",content:F.mode==="yolo"?e("[\u5168\u81EA\u52A8\u6A21\u5F0F] \u7528\u6237\u5F00\u542F\u4E86\u5168\u81EA\u52A8\uFF1A\u6240\u6709\u5BA1\u6279\uFF08\u5305\u62EC sandbox_escalation \u8D8A\u6743\uFF09\u90FD\u4F1A\u81EA\u52A8\u901A\u8FC7\uFF0C\u4E0D\u4F1A\u6709\u4EBA\u6765\u786E\u8BA4\u3002\u547D\u4EE4\u88AB\u6C99\u7BB1\u6321\u4F4F\u3001\u800C\u4EFB\u52A1\u786E\u5B9E\u9700\u8981\u65F6\uFF0C\u76F4\u63A5\u5E26 sandbox_escalation \u91CD\u8BD5\uFF0C\u4E0D\u8981\u505C\u4E0B\u6765\u95EE\u7528\u6237\u8981\u4E0D\u8981\u653E\u884C\u3002\u7834\u574F\u6027\u547D\u4EE4\u548C\u767B\u5F55\u51ED\u636E\u4ECD\u4F1A\u88AB\u62E6\u622A\u3002"):e("[\u5BA1\u6279\u5DF2\u6062\u590D] \u5168\u81EA\u52A8\u5DF2\u5173\u95ED\uFF1A\u8D8A\u6743\u548C\u9AD8\u98CE\u9669\u547D\u4EE4\u4F1A\u5148\u8BE2\u95EE\u7528\u6237\u3002"),display:!1}}});const o=hu(),t=new Map;u.on("tool_call",async(s,r)=>{const n=await k(s,r.cwd,r.hasUI,r.ui,{sessionId:r.sessionManager.getSessionId()},process.env,E=>u.events.emit(ru,E));if(n?.block)return n;const c=await o.check(s,r.cwd,r.sessionManager.getSessionId(),{hasUI:r.hasUI,confirm:r.hasUI?(E,m,f)=>r.ui.confirm(E,m,f?{approval:f}:void 0):void 0});return c?.block?{block:!0,reason:c.reason}:(c?.note&&t.set(s.toolCallId,c.note),n)}),u.on("session_shutdown",async()=>{o.releaseAll()}),u.on("tool_result",async s=>{const r=mu(s.content),n=[];R.delete(s.toolCallId)&&n.push(e("[dal-guard] \u63D0\u4EA4\u91CC\u53E6\u4E00\u4E2A\u4EA7\u54C1\u52A9\u624B\u7684\u5171\u540C\u4F5C\u8005\u884C\u5DF2\u6539\u4E3A {trailer}\uFF1A\u4F60\u662F DAL Code\u3002").replace("{trailer}",O));const c=t.get(s.toolCallId);return c&&(t.delete(s.toolCallId),n.push(`[dal-guard] ${c}`)),n.length===0?r?{content:r}:void 0:{content:[...r??s.content,...n.map(E=>({type:"text",text:E}))]}}),u.registerCommand("guard",{description:e("\u67E5\u770B\u6216\u5207\u6362\u5BA1\u6279\u95E8\uFF08default | yolo\uFF0C\u52A0 save \u8BB0\u4E3A\u9ED8\u8BA4\uFF09"),handler:i(async(s,r)=>{const[n,c]=s.trim().split(/\s+/);if((n==="yolo"||n==="default")&&(B(n),c==="save"))try{P(D(),n),r.ui.notify(n==="yolo"?e("\u5DF2\u8BBE\u4E3A\u9ED8\u8BA4\uFF1A\u4EE5\u540E\u542F\u52A8\u90FD\u662F\u5168\u81EA\u52A8"):e("\u5DF2\u6062\u590D\u9ED8\u8BA4\uFF1A\u4EE5\u540E\u542F\u52A8\u90FD\u4F1A\u8BE2\u95EE"),"info")}catch(m){r.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${m instanceof Error?m.message:String(m)}`,"error")}const E=g.size?`${e(" \xB7 \u672C\u6B21\u4F1A\u8BDD\u5DF2\u5141\u8BB8\uFF1A")}${[...g].join(", ")}`:"";r.ui.notify(`${e("dal-guard \u6A21\u5F0F\uFF1A")}${F.mode}${E}`,F.mode==="yolo"?"warning":"info")},"handler")})}d(W,"$e"),i(W,"default");export{bu as DAL_CO_AUTHOR,Pu as GUARD_MODE_ENV,Mu as REDACTED,$ as classify,Wu as createWorkspaceGate,ku as dalSecretValues,W as default,k as evaluateToolCall,_u as fileHoldsDalSecret,vu as foreignAttributionInMessageFile,yu as foreignCoAuthors,ju as installingManager,wu as isGitCommit,Vu as modifiedDirectory,Iu as namesDalCredential,w as pathOutsideProject,Nu as readsDalSecretCopy,Su as redactContent,Gu as redactDalSecrets,Lu as reviewBashCommand,$u as rewriteCommitAttribution,y as riskForBash,Tu as saveGuardMode,Ru as savedGuardMode,Ou as shellPathCandidates,xu as shouldAskGuardMode,Uu as startupGuardMode,zu as suspicionFor,Hu as wrongPackageManager};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var B=Object.defineProperty;var o=(u,
|
|
2
|
-
`),{note:`${
|
|
1
|
+
var B=Object.defineProperty;var o=(u,t)=>B(u,"name",{value:t,configurable:!0});var g=Object.defineProperty,c=o((u,t)=>g(u,"name",{value:t,configurable:!0}),"d");import{dirname as E}from"node:path";import{t as n}from"@dalcode/dal-pi-kit";import{claimWorkspace as k,releaseWorkspace as y,resolveToCwd as b,shellCommandDirectory as v}from"@earendil-works/pi-coding-agent";import{isGitCommit as $}from"./attribution.js";const N=new Set(["ls","cat","head","tail","wc","grep","rg","find","echo","pwd","stat","file","which","du","df","sort","uniq","jq","tree","less","diff","true","date","cd"]),W=new Set(["status","log","diff","show","branch","rev-parse","remote","blame","ls-files","describe","shortlog","reflog","fetch"]);function C(u){return u.trim().split(/\s+/).filter(Boolean)}o(C,"W"),c(C,"words");function A(u){if(/(^|[^>&0-9])>{1,2}(?!\s*\/dev\/null)/.test(u))return!1;const t=C(u).filter(e=>!/^\w+=/.test(e)),r=t[0];if(!r)return!0;if(r==="git"){const e=t.slice(1).find((i,d,l)=>!i.startsWith("-")&&l[d-1]!=="-C");return e==="worktree"?t.includes("list"):e==="stash"?t.includes("list")||t.includes("show"):e!==void 0&&W.has(e)}return r==="sed"?!t.some(e=>e.startsWith("-i")):N.has(r)}o(A,"$"),c(A,"segmentReadsOnly");function f(u,t){if(u.toolName==="write"||u.toolName==="edit"){const e=u.input,i=e.path??e.file_path;return typeof i=="string"&&i?E(b(i,t)):void 0}if(u.toolName!=="bash"&&u.toolName!=="powershell")return;const r=u.input.command;if(!(typeof r!="string"||!r.trim())&&!r.split(/&&|\|\||[;|\n]/).every(A))return v(r,t)}o(f,"A"),c(f,"modifiedDirectory");function p(u,t){return n("\u5DE5\u4F5C\u533A {worktree} \u6B63\u88AB\u53E6\u4E00\u4E2A dal \u4F1A\u8BDD\u4F7F\u7528\uFF08\u8FDB\u7A0B {pid}@{host}\uFF0C\u4F1A\u8BDD {session}\uFF0C{started} \u5F00\u59CB\uFF09\u3002").replace("{worktree}",t).replace("{pid}",String(u.pid)).replace("{host}",u.host).replace("{session}",u.sessionId.slice(0,8)).replace("{started}",u.startedAt)}o(p,"I"),c(p,"describeHolder");function h(){const u=new Set,t=new Set,r=new Set;return{async check(e,i,d,l){const m=f(e,i);if(!m)return;const s=k(m,d);if(!s)return;if(!s.heldBy){u.add(s.gitDir);return}if(t.has(s.gitDir))return;const a=p(s.heldBy,s.worktree??s.gitDir),F=e.input.command,w=typeof F=="string"&&$(F);if(l.hasUI&&l.confirm){const D=`${a}${n("\u4E24\u4E2A\u4F1A\u8BDD\u540C\u65F6\u6539\u52A8\u4F1A\u4E92\u76F8\u8986\u76D6\u3002\u4ECD\u8981\u5728\u8FD9\u91CC\u6539\u52A8\u5E76\u63D0\u4EA4\u5417\uFF1F")}`;if(await l.confirm(n("\u5DE5\u4F5C\u533A\u88AB\u5360\u7528"),D,{source:"workspace",toolCallId:e.toolCallId,toolName:e.toolName,args:e.input,risk:{level:"medium",reason:a,ruleId:"workspace:occupied"},title:n("\u5DE5\u4F5C\u533A\u88AB\u5360\u7528"),description:D,options:["allow_session","deny"]})){t.add(s.gitDir);return}return{block:!0,reason:`${a}${n("\u7528\u6237\u6CA1\u6709\u540C\u610F\u5728\u8FD9\u91CC\u6539\u52A8\u3002\u505C\u4E0B\u6765\u544A\u8BC9\u7528\u6237\u3002")}`}}if(w)return{block:!0,reason:`${a}${n("\u6CA1\u6709\u7528\u6237\u786E\u8BA4\uFF0C\u62D2\u7EDD\u5728\u8FD9\u91CC\u63D0\u4EA4\u3002\u505C\u4E0B\u6765\u544A\u8BC9\u7528\u6237\uFF0C\u7531\u7528\u6237\u51B3\u5B9A\u3002")}`};if(!r.has(s.gitDir))return r.add(s.gitDir),process.stderr.write(`dal: ${a}
|
|
2
|
+
`),{note:`${a}${n("\u8FD9\u6B21\u6539\u52A8\u5DF2\u6267\u884C\uFF1B\u544A\u8BC9\u7528\u6237\uFF0C\u63D0\u4EA4\u524D\u9700\u8981\u7528\u6237\u786E\u8BA4\u3002")}`}},releaseAll(){for(const e of u)y(e);u.clear()}}}o(h,"x"),c(h,"createWorkspaceGate");export{h as createWorkspaceGate,p as describeHolder,f as modifiedDirectory};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-interactive",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Terminal-UI conveniences adopted from pi's example extensions: the questionnaire tool (the model asks you questions), /handoff (carry context into a new session) and interactive ! commands (vim, git rebase -i, htop). Active only in the TUI; stands down under DAL Code.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
24
24
|
"typebox": "1.3.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-lang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
-
"@dalcode/dal-bridge": "1.0.
|
|
20
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
21
|
+
"@dalcode/dal-bridge": "1.0.43"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-learn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Self-evolution for DAL: lessons learned from earlier sessions (project and personal), a project map of verified commands and locations, effect tracking, and skill proposals for recurring procedures (/lessons).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
]
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
28
|
+
"@dalcode/dal-pi-kit": "1.0.43"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-lsp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dalcode/dal-bridge": "1.0.
|
|
24
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
23
|
+
"@dalcode/dal-bridge": "1.0.43",
|
|
24
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
25
25
|
"cross-spawn": "7.0.6",
|
|
26
26
|
"typebox": "1.3.7",
|
|
27
27
|
"typescript": "5.9.3",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@dalcode/dal-bridge": "1.0.
|
|
31
|
-
"@dalcode/dal-guard": "1.0.
|
|
32
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
33
|
-
"@dalcode/deepailab": "1.0.
|
|
30
|
+
"@dalcode/dal-bridge": "1.0.43",
|
|
31
|
+
"@dalcode/dal-guard": "1.0.43",
|
|
32
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
33
|
+
"@dalcode/deepailab": "1.0.43",
|
|
34
34
|
"cross-spawn": "7.0.6"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-office",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
20
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
21
21
|
"docx": "9.7.1",
|
|
22
22
|
"echarts": "6.1.0",
|
|
23
23
|
"exceljs": "4.4.0",
|
|
@@ -5,6 +5,7 @@ export { detectDelimiter, parseDelimited } from "./extract/csv.js";
|
|
|
5
5
|
export { sanitizeFilename } from "./paths.js";
|
|
6
6
|
export { buildChartOption, chartHtml, renderChartSvg } from "./render/chart.js";
|
|
7
7
|
export { CHART_FONT_FAMILY, CHART_TOKENS, type ChartThemeMode, echartsTheme } from "./render/chart-theme.js";
|
|
8
|
+
export { DECK_SOURCE_PROPERTY, type DeckSource, readDeckSource, writeDeckSource } from "./render/deck-source.js";
|
|
8
9
|
export { type DocOutputInput, type DocSectionInput, type DocStyle, type DocTableInput, renderDocx, } from "./render/docx.js";
|
|
9
10
|
export { applyDiagramStyle, DIAGRAM_ROLES, styleDiagramCell } from "./render/drawio-style.js";
|
|
10
11
|
export { type ChartSpec, layoutSlides, renderPptx, resolveLayout, type ShapeSpec, type SlideElement, type TableSpec, type TextSpec, themeThumbnailSvg, } from "./render/pptx.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var o=Object.defineProperty;var s=(e,a)=>o(e,"name",{value:a,configurable:!0});var m=Object.defineProperty,
|
|
1
|
+
var o=Object.defineProperty;var s=(e,a)=>o(e,"name",{value:a,configurable:!0});var m=Object.defineProperty,l=s((e,a)=>m(e,"name",{value:a,configurable:!0}),"n");import{THUMBNAIL_CHANNEL as n,thumbnailSvg as p}from"./render/thumbnails.js";import{clearPresentationPlan as f}from"./scratchpad.js";import{registerChartGenerate as S}from"./tools/chart-generate.js";import{registerDocGenerate as d}from"./tools/doc-generate.js";import{registerDocxEdit as c}from"./tools/docx-edit.js";import{registerDrawioGenerate as g}from"./tools/drawio-generate.js";import{registerMdGenerate as E}from"./tools/md-generate.js";import{registerPptGenerate as u}from"./tools/ppt-generate.js";import{registerPptPlan as h}from"./tools/ppt-plan.js";import{registerPptxEdit as T}from"./tools/pptx-edit.js";import{registerReadFile as D}from"./tools/read-file.js";import{registerSheetGenerate as y}from"./tools/sheet-generate.js";import{registerXlsxEdit as _}from"./tools/xlsx-edit.js";import{default as C}from"exceljs";import{default as A}from"jszip";import{detectDelimiter as v,parseDelimited as P}from"./extract/csv.js";import{sanitizeFilename as N}from"./paths.js";import{buildChartOption as R,chartHtml as x,renderChartSvg as H}from"./render/chart.js";import{CHART_FONT_FAMILY as L,CHART_TOKENS as M,echartsTheme as O}from"./render/chart-theme.js";import{DECK_SOURCE_PROPERTY as I,readDeckSource as b,writeDeckSource as G}from"./render/deck-source.js";import{renderDocx as F}from"./render/docx.js";import{applyDiagramStyle as Y,DIAGRAM_ROLES as U,styleDiagramCell as k}from"./render/drawio-style.js";import{layoutSlides as w,renderPptx as K,resolveLayout as X,themeThumbnailSvg as z}from"./render/pptx.js";import{THUMBNAIL_CHANNEL as B,thumbnailSvg as J}from"./render/thumbnails.js";import{renderXlsx as Z}from"./render/xlsx.js";import{designTheme as j,inferStyle as Q,resolveStyle as V,STYLE_IDS as W,THEME_NAMES as q,themePalettes as $}from"./themes.js";function i(e){h(e),u(e),d(e),E(e),y(e),S(e),g(e),D(e),c(e),T(e),_(e),e.events.on(n,a=>{const r=a;if(typeof r.ref!="string"||typeof r.reply!="function")return;const t=p(r.ref,r.title);t!==void 0&&r.reply(t)}),e.on("session_shutdown",async(a,r)=>{f(r.sessionManager.getSessionId())})}s(i,"T"),l(i,"officeExtension");export{L as CHART_FONT_FAMILY,M as CHART_TOKENS,I as DECK_SOURCE_PROPERTY,U as DIAGRAM_ROLES,C as ExcelJS,A as JSZip,W as STYLE_IDS,q as THEME_NAMES,B as THUMBNAIL_CHANNEL,Y as applyDiagramStyle,R as buildChartOption,x as chartHtml,i as default,j as designTheme,v as detectDelimiter,O as echartsTheme,Q as inferStyle,w as layoutSlides,P as parseDelimited,b as readDeckSource,H as renderChartSvg,F as renderDocx,K as renderPptx,Z as renderXlsx,X as resolveLayout,V as resolveStyle,N as sanitizeFilename,k as styleDiagramCell,$ as themePalettes,z as themeThumbnailSvg,J as thumbnailSvg,G as writeDeckSource};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type JSZip from "jszip";
|
|
2
|
+
import type { OfficePresentationPlan } from "../scratchpad.js";
|
|
3
|
+
export declare const DECK_SOURCE_PROPERTY = "DalOfficeDeckSource";
|
|
4
|
+
export interface DeckSource {
|
|
5
|
+
readonly version: 1;
|
|
6
|
+
readonly style: string;
|
|
7
|
+
readonly plan: OfficePresentationPlan;
|
|
8
|
+
}
|
|
9
|
+
export declare function writeDeckSource(zip: JSZip, source: DeckSource): Promise<void>;
|
|
10
|
+
export declare function readDeckSource(zip: JSZip): Promise<DeckSource | undefined>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g=Object.defineProperty;var c=(e,t)=>g(e,"name",{value:t,configurable:!0});var $=Object.defineProperty,n=c((e,t)=>$(e,"name",{value:t,configurable:!0}),"i");const l="DalOfficeDeckSource",a="docProps/custom.xml",x="application/vnd.openxmlformats-officedocument.custom-properties+xml",f="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",P="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",h="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",D="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",S=n(e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),"escapeXml"),v=n(e=>e.replace(/&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g,(t,r)=>r.startsWith("#x")?String.fromCodePoint(Number.parseInt(r.slice(2),16)):r.startsWith("#")?String.fromCodePoint(Number.parseInt(r.slice(1),10)):{amp:"&",lt:"<",gt:">",quot:'"',apos:"'"}[r]??t),"decodeXml");async function u(e,t){const r=n(o=>`<property fmtid="${D}" pid="${o}" name="${l}"><vt:lpwstr>${S(JSON.stringify(t))}</vt:lpwstr></property>`,"property"),s=await e.file(a)?.async("string");let m;if(s){const o=s.replace(new RegExp(`<property\\b[^>]*name="${l}"[^>]*>[\\s\\S]*?</property>`),""),i=[...o.matchAll(/\bpid="(\d+)"/g)].map(y=>Number(y[1])),p=r(Math.max(1,...i)+1);m=/<\/Properties>\s*$/.test(o)?o.replace(/<\/Properties>\s*$/,`${p}</Properties>`):o.replace(/<Properties\b([^>]*)\/>/,`<Properties$1>${p}</Properties>`)}else{m=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2
|
+
<Properties xmlns="${P}" xmlns:vt="${h}">${r(2)}</Properties>`;const o=await e.file("[Content_Types].xml")?.async("string")??"";o.includes(`PartName="/${a}"`)||e.file("[Content_Types].xml",o.replace(/<\/Types>\s*$/,`<Override PartName="/${a}" ContentType="${x}"/></Types>`));const i=await e.file("_rels/.rels")?.async("string")??"";if(!i.includes(f)){let p=1;for(;i.includes(`Id="rIdDalSrc${p}"`);)p++;e.file("_rels/.rels",i.replace(/<\/Relationships>\s*$/,`<Relationship Id="rIdDalSrc${p}" Type="${f}" Target="${a}"/></Relationships>`))}}e.file(a,m)}c(u,"h"),n(u,"writeDeckSource");async function d(e){const t=await e.file(a)?.async("string");if(!t)return;const r=new RegExp(`<property\\b[^>]*name="${l}"[^>]*>\\s*<vt:lpwstr>([\\s\\S]*?)</vt:lpwstr>`).exec(t);if(r)try{const s=JSON.parse(v(r[1]));return s&&s.version===1&&typeof s.style=="string"&&s.plan&&typeof s.plan.title=="string"&&Array.isArray(s.plan.slides)?s:void 0}catch{return}}c(d,"D"),n(d,"readDeckSource");export{l as DECK_SOURCE_PROPERTY,d as readDeckSource,u as writeDeckSource};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var Pe=Object.defineProperty;var
|
|
2
|
-
`).reduce((i,a)=>i+Math.max(1,Math.ceil(j(a)/o)),0)}p(P,"_"),f(P,"wrappedLines");function $(e,t,n,o,i,a=1.2){for(let s=o;s>i;s-=1)if(P(e,s,t)*s*a*1.12/72<=n)return s;return i}p($,"z"),f($,"fitSize");function F(e,t,n,o,i,a=1.2){return e.reduce((s,r)=>Math.min(s,$(r,t,n,o,i,a)),o)}p(F,"E"),f(F,"fitAll");function k(e,t,n,o){const i=Math.max(j(e),1);return Math.max(o,Math.min(n,Math.floor(t*72/i)))}p(k,"C"),f(k,"fitLine");function Q(e){const t=/^(.{1,18}?)[::]\s*(.+)$/u.exec(e);if(t)return{lead:t[1].trim(),detail:t[2].trim()}}p(Q,"Z"),f(Q,"splitLead");function Y(e){const t=e.map(Q);return t.every(n=>n!==void 0)?t:void 0}p(Y,"D"),f(Y,"allLeads");const Ne=/^[-+约~≈]?[¥$¥€]?\d[\d,]*(\.\d+)?\s*(%|×|x|倍|pp|个百分点|万亿|亿元|万元|亿|万|千|元|k|m|b|天|小时|人|家|个|项|次|分)?\+?$/iu,Ve=/^(\d{4}(\s*年)?(\s*(Q[1-4]|H[12]|\d{1,2}\s*月))?|Q[1-4]|H[12]|\d{1,2}\s*月|第[一二三四五六七八九十\d]+(阶段|期|周|月|季度|年|步)|阶段\s*[一二三四五六七八九十\d]+|phase\s*\d+|M\d+|W\d+|day\s*\d+|D\d+|(近期|中期|远期|短期|长期)(\s*[((].*[))])?|本周|下周|本月|下月|本季度|下季度)$/iu;function U(e){if(e.length<2||e.length>4)return;const t=Y(e);if(!(!t||!t.every(n=>Ne.test(n.lead))))return t.map(n=>({value:n.lead,label:n.detail}))}p(U,"ee"),f(U,"inferStats");function X(e){if(e.length<2||e.length>6)return;const t=Y(e);return t?.every(n=>Ve.test(n.lead))?t:void 0}p(X,"te"),f(X,"inferTimeline");function K(e){if(e.length<4||e.length>9)return;const t=Y(e);if(!t)return;const n=[],o=new Map;for(const i of t){if(i.lead.length>10)return;o.has(i.lead)||(o.set(i.lead,[]),n.push(i.lead)),o.get(i.lead).push(i.detail)}if(!(n.length<2||n.length>3)&&!n.some(i=>o.get(i).length<2))return n.map(i=>({heading:i,points:o.get(i)}))}p(K,"ne"),f(K,"inferColumns");const _e=/^(.{1,14}?)[\s::]+[约~≈]?(-?\d[\d,]*(?:\.\d+)?)\s*(%|亿元|万元|元|亿|万|个|家|人|台|次|件|吨|天)?\s*([((].{0,12}[))])?$/u;function I(e){if(e.length<3||e.length>8)return;const t=e.map(i=>_e.exec(i));if(t.some(i=>i===null))return;const n=t,o=n[0][3]??"";if(!n.some(i=>(i[3]??"")!==o))return{type:"bar",categories:n.map(i=>i[1].trim()+(i[4]?i[4].replace(/[(())]/g,""):"")),series:[{name:"",values:n.map(i=>Number(i[2].replace(/,/g,"")))}],...o?{unit:o}:{}}}p(I,"I"),f(I,"inferChart");function de(e){if(!e||e.categories.length===0)return;const t=e.series.filter(n=>n.values.length===e.categories.length&&n.values.every(o=>Number.isFinite(o)));return t.length>0?{...e,series:t}:void 0}p(de,"ye"),f(de,"validChart");function pe(e){const t=(e??[]).filter(n=>n.value.trim()&&n.label.trim()).slice(0,4);return t.length>0?t:void 0}p(pe,"be"),f(pe,"validStats");function fe(e){const t=(e??[]).filter(n=>n.heading.trim()).slice(0,3);return t.length>=2?t:void 0}p(fe,"Se"),f(fe,"validColumns");function ye(e){if(!(!e||e.headers.length===0||e.rows.length===0))return{headers:e.headers.slice(0,8),rows:e.rows.slice(0,12).map(t=>t.slice(0,8))}}p(ye,"xe"),f(ye,"validTable");const Qe=/^(目录|目 录|议程|大纲|contents?|agenda|outline)$/iu,Ue=/(谢谢|感谢|致谢|thank|q\s*&\s*a|问答|结束)/iu,Xe=/^[“"「『].+[”"」』]$/u;function Z(e,t,n){const o=T(e.points,9),i=de(e.chart),a=pe(e.stats),s=fe(e.columns),r=ye(e.table),c=e.layout;if(c==="title"||t===0&&c===void 0)return{layout:"title"};switch(c){case"section":case"agenda":case"quote":case"closing":case"content":case"two-column":return{layout:c};case"chart":{const m=i??I(o);return m?{layout:"chart",chart:m}:{layout:"content"}}case"stats":{const m=a??U(o);return m?{layout:"stats",stats:m}:{layout:"content"}}case"comparison":{const m=s??K(o);return m?{layout:"comparison",columns:m}:{layout:"two-column"}}case"timeline":{const m=X(o)??(o.length>=2?o.map((x,w)=>({lead:W(w+1),detail:x})):void 0);return m?{layout:"timeline",timeline:m}:{layout:"content"}}case"table":return r?{layout:"table",table:r}:{layout:"content"}}if(i)return{layout:"chart",chart:i};if(a)return{layout:"stats",stats:a};if(s)return{layout:"comparison",columns:s};if(r)return{layout:"table",table:r};if(Qe.test(e.title.trim()))return{layout:"agenda"};const u=U(o);if(u)return{layout:"stats",stats:u};const h=X(o);if(h)return{layout:"timeline",timeline:h};const l=K(o);if(l)return{layout:"comparison",columns:l};const d=I(o);return d?{layout:"chart",chart:d}:o.length===0&&Xe.test(e.title.trim())?{layout:"quote"}:t===n-1&&t>0&&Ue.test(e.title)?{layout:"closing"}:{layout:"content"}}p(Z,"Ee"),f(Z,"resolveLayout");function C(e){return{x:0,y:0,w:S,h:R,fill:e,shape:"rect"}}p(C,"F"),f(C,"background");function A(e,t){const{t:n,slide:o}=e;t.push(C(n.bg)),n.topBand&&t.push({x:0,y:0,w:S,h:.16,fill:n.primary,shape:"rect"},{x:0,y:.16,w:S,h:.035,fill:n.accent,shape:"rect"}),e.tracker&&t.push({x:y,y:.34,w:8,h:.26,content:e.tracker,fontSize:11,color:n.primary,bold:!0,charSpacing:1});const i=.92,a=$(o.title,g,i,n.titleSize,18,1.15);t.push({x:y,y:De,w:g,h:i,content:o.title,fontSize:a,color:n.ink,bold:!0,valign:"middle",lineSpacingMultiple:1.05,font:"head"}),n.titleRule&&t.push({x:y,y:O,w:g,h:0,fill:n.line,shape:"line",lineWidth:.75});let s=O+.33;const r=v(o.subtitle);r&&(t.push({x:y,y:O+.2,w:g,h:.42,content:r,fontSize:k(r,g,16,12),color:n.muted,valign:"middle"}),s=O+.82);const c=v(o.source);return c&&t.push({x:y,y:6.95,w:g-1.2,h:.3,content:c,fontSize:9,color:n.muted,valign:"middle"}),t.push({x:S-y-1,y:6.95,w:1,h:.3,content:String(e.index+1),fontSize:10,color:n.muted,align:"right",valign:"middle"}),s}p(A,"L"),f(A,"contentChrome");function B(e,t,n){if(!t)return L;const o=L-.62;return n.push({x:y,y:o,w:g,h:.62,fill:e.surface,shape:e.radius>0?"roundRect":"rect",rectRadius:e.radius},{x:y+.25,y:o+.24,w:.14,h:.14,fill:e.accent,shape:"rect"},{x:y+.55,y:o,w:g-.8,h:.62,content:t,fontSize:k(t,g-.8,16,12),color:e.ink,bold:!0,valign:"middle"}),o-.25}p(B,"O"),f(B,"takeawayBand");function ge(e,t,n,o=1.4){return P(e,t,n)*t*o/72}p(ge,"ke"),f(ge,"blockHeight");function N(e,t,n,o){const i=k(e,n*.96,o,28),a=i>=o*.75?i:$(e,n,2.2,o,28,1.35),s=ge(e,a,n,1.4)+.05,r=3.45-(.3+s+(t?.3+.5:0))/2;return{size:a,top:r,titleY:r+.3,titleH:s,subtitleY:r+.3+s+.3}}p(N,"Y"),f(N,"coverGroup");function me(e){const{t,slide:n}=e,o=v(n.subtitle),i=[];switch(t.cover){case"dark-center":{i.push(C(t.inverseBg));const a=N(n.title,o,11.2,54);return i.push({x:1.06,y:a.titleY,w:11.2,h:a.titleH,content:n.title,fontSize:a.size,color:t.inverseInk,bold:!0,align:"center",lineSpacingMultiple:1.05,font:"head"},{x:S/2-.3,y:a.titleY+a.titleH+.08,w:.6,h:.04,fill:t.primary,shape:"rect"}),o&&i.push({x:1.06,y:a.subtitleY+.1,w:11.2,h:.6,content:o,fontSize:k(o,11.2,20,13),color:t.inverseMuted,align:"center"}),i}case"white-left":case"panel-right":{const a=t.cover==="panel-right",s=a?7.7:10.8;i.push(C(t.bg)),a?i.push({x:9,y:0,w:S-9,h:R,fill:t.inverseBg,shape:"rect"},{x:10.35,y:4.35,w:2.4,h:2.4,fill:t.accent,shape:"ellipse"},{x:9.55,y:1,w:1.1,h:1.1,fill:t.inverseMuted,shape:"ellipse",transparency:55}):i.push({x:y,y:6.7,w:g,h:0,fill:t.ink,shape:"line",lineWidth:1});const r=N(n.title,o,s,a?42:48);return i.push({x:y,y:r.top,w:.8,h:.08,fill:t.accent,shape:"rect"},{x:y,y:r.titleY,w:s,h:r.titleH,content:n.title,fontSize:r.size,color:t.ink,bold:!0,valign:"top",lineSpacingMultiple:1.05,font:"head"}),o&&i.push({x:y,y:r.subtitleY,w:s,h:.9,content:o,fontSize:$(o,s,.9,20,12),color:a?t.body:t.muted}),i}case"gov-band":return i.push(C(t.bg)),i.push({x:0,y:0,w:S,h:1.1,fill:t.primary,shape:"rect"},{x:0,y:1.1,w:S,h:.06,fill:t.accent,shape:"rect"},{x:0,y:R-.4,w:S,h:.4,fill:t.primary,shape:"rect"},{x:0,y:R-.46,w:S,h:.06,fill:t.accent,shape:"rect"}),i.push({x:y,y:2.3,w:g,h:1.8,content:n.title,fontSize:$(n.title,g,1.8,44,28,1.1),color:t.primary,bold:!0,align:"center",valign:"bottom",lineSpacingMultiple:1.05,font:"head"}),i.push({x:S/2-1.6,y:4.3,w:3.2,h:0,fill:t.accent,shape:"line",lineWidth:1.5}),o&&i.push({x:y,y:4.5,w:g,h:.6,content:o,fontSize:k(o,g,20,13),color:t.body,align:"center"}),i;default:{i.push(C(t.inverseBg));const a=N(n.title,o,10.6,48);return i.push({x:y,y:a.top,w:.9,h:.07,fill:t.accent,shape:"rect"},{x:y,y:a.titleY,w:10.6,h:a.titleH,content:n.title,fontSize:a.size,color:t.inverseInk,bold:!0,lineSpacingMultiple:1.05,font:"head"}),o&&i.push({x:y,y:a.subtitleY,w:10.6,h:.9,content:o,fontSize:$(o,10.6,.9,20,12),color:t.inverseMuted}),i.push({x:y,y:6.75,w:g,h:0,fill:t.inverseMuted,shape:"line",lineWidth:.75}),i}}}p(me,"Ce"),f(me,"coverElements");function xe(e){const{t,slide:n}=e,o=v(n.subtitle),i=[C(t.inverseBg)];return t.topBand&&i.push({x:0,y:R-.5,w:S,h:.06,fill:t.accent,shape:"rect"}),i.push({x:y,y:1.7,w:4,h:1.2,content:W(e.sectionOrdinal),fontSize:66,color:t.accent,bold:!0,font:"head"},{x:y+.05,y:3.1,w:1.2,h:.05,fill:t.accent,shape:"rect"},{x:y,y:3.35,w:10.8,h:1.3,content:n.title,fontSize:$(n.title,10.8,1.3,40,26,1.1),color:t.inverseInk,bold:!0,font:"head"}),o&&i.push({x:y,y:4.75,w:10.8,h:.6,content:o,fontSize:k(o,10.8,18,12),color:t.inverseMuted}),i}p(xe,"Te"),f(xe,"sectionElements");function we(e){const{t}=e,n=[],o=A(e,n),i=T(e.slide.points,8),a=i.length>0?i:e.sections.slice(0,8);if(a.length===0)return n.push({x:y,y:o,w:g,h:.6,content:he,fontSize:18,color:t.muted}),n;const s=Math.min(.82,(L-o)/a.length),r=y+1.6,c=g-1.6,u=F(a,c-1.1,s-.12,22,14);return a.forEach((h,l)=>{const d=o+l*s;n.push({x:r,y:d,w:.9,h:s,content:W(l+1),fontSize:u+2,color:t.primary,bold:!0,valign:"middle",font:"head"},{x:r+1.1,y:d,w:c-1.1,h:s,content:h,fontSize:u,color:t.ink,valign:"middle"},{x:r,y:d+s,w:c,h:0,fill:t.line,shape:"line",lineWidth:.75})}),n}p(we,"$e"),f(we,"agendaElements");function J(e,t,n=!1){const o=Q(e),i=n?t.inverseInk:t.ink,a=n?t.inverseMuted:t.body;return o?[{text:`${o.lead}\uFF1A`,options:{color:i,bold:!0}},{text:o.detail,options:{color:a}}]:[{text:e,options:{color:n?t.inverseInk:t.body}}]}p(J,"ie"),f(J,"pointRuns");function H(e,t,n,o,i,a,s,r=20){const c=Math.min(1.15,(a-o)/e.length),u=F(e,i-.45,c-.18,r,12,1.25);e.forEach((h,l)=>{const d=o+l*c,m=P(h,u,i-.45)*u*1.25/72,x=d+(c-m)/2+u*1.25/72/2;s.push({x:n,y:x-.055,w:.11,h:.11,fill:t.primary,shape:"rect"},{x:n+.35,y:d,w:i-.35,h:c,content:J(h,t),fontSize:u,valign:"middle",lineSpacingMultiple:1.15}),l<e.length-1&&s.push({x:n,y:d+c,w:i,h:0,fill:t.line,shape:"line",lineWidth:.5})})}p(H,"W"),f(H,"pointList");function ee(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i)+.1,s=B(n,v(o.takeaway),i),r=T(o.points,8);if(r.length===0)return i.push({x:y,y:a,w:g,h:.6,content:he,fontSize:18,color:n.muted}),i;const c=Y(r),u=s-a;if(!t&&c&&r.length>=2&&r.length<=3){const h=(g-.5*(r.length-1))/r.length,l=F(c.map(w=>w.lead),h,.95,26,16,1.15),d=F(c.map(w=>w.detail),h,u-1.75,19,12,1.35),m=Math.max(...c.map(w=>P(w.detail,d,h)*d*1.35/72)),x=a+Math.max(0,(u-1.75-m-.2)/3);return c.forEach((w,z)=>{const M=y+z*(h+.5);i.push({x:M,y:x+.1,w:h,h:.05,fill:z===0?n.primary:n.line,shape:"rect"},{x:M,y:x+.3,w:h,h:.4,content:W(z+1),fontSize:15,color:n.primary,bold:!0,font:"head"},{x:M,y:x+.75,w:h,h:.95,content:w.lead,fontSize:l,color:n.ink,bold:!0,lineSpacingMultiple:1.05,font:"head"},{x:M,y:x+1.75,w:h,h:s-x-1.75,content:w.detail,fontSize:d,color:n.body,lineSpacingMultiple:1.25})}),i}if(!t&&c&&r.length===4){const h=(g-.6)/2,l=(u-.3)/2,d=F(c.map(x=>x.lead),h-.9,.5,20,14),m=F(c.map(x=>x.detail),h-.9,l-.8,16,11,1.3);return i.push({x:y+h+.3,y:a,w:0,h:u,fill:n.line,shape:"line",lineWidth:.75},{x:y,y:a+l+.15,w:g,h:0,fill:n.line,shape:"line",lineWidth:.75}),c.forEach((x,w)=>{const z=y+w%2*(h+.6),M=a+Math.floor(w/2)*(l+.3)+.1;i.push({x:z,y:M,w:.8,h:.55,content:W(w+1),fontSize:24,color:n.primary,bold:!0,font:"head"},{x:z+.9,y:M,w:h-.9,h:.55,content:x.lead,fontSize:d,color:n.ink,bold:!0,valign:"middle",font:"head"},{x:z+.9,y:M+.65,w:h-.9,h:l-.8,content:x.detail,fontSize:m,color:n.body,lineSpacingMultiple:1.2})}),i}if(t||r.length>5){const h=Math.ceil(r.length/2),l=(g-.6)/2;return H(r.slice(0,h),n,y,a,l,s,i,18),r.length>h&&H(r.slice(h),n,y+l+.6,a,l,s,i,18),i}return H(r,n,y,a,g*.86,s,i),i}p(ee,"oe"),f(ee,"contentElements");function be(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i),s=B(n,v(o.takeaway),i),r=g/t.length,c=2.7,u=a+Math.max(.2,(s-a-c)/2),h=Math.min(...t.map(d=>k(d.value,r-.5,t.length<=2?80:64,28))),l=F(t.map(d=>d.label),r-.5,.8,18,12);return t.forEach((d,m)=>{const x=y+m*r;m>0&&i.push({x,y:u,w:0,h:c,fill:n.line,shape:"line",lineWidth:.75});const w=m>0?.4:0;i.push({x:x+w,y:u,w:r-w-.1,h:1.35,content:d.value,fontSize:h,color:m===0?n.primary:n.ink,bold:!0,valign:"bottom",font:"head"},{x:x+w,y:u+1.5,w:r-w-.3,h:.8,content:d.label,fontSize:l,color:n.ink,bold:!0});const z=v(d.note);z&&i.push({x:x+w,y:u+2.3,w:r-w-.3,h:.4,content:z,fontSize:12,color:n.muted})}),i}p(be,"Fe"),f(be,"statsElements");function ve(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i),s=v(o.takeaway),r=T(o.points,8),c=s||I(r)?[]:r.slice(0,3),u=s!==void 0||c.length>0,h=u?g*.64:g;let l=a;t.unit&&(i.push({x:y,y:a-.05,w:4,h:.3,content:`${/[\u3400-\u9fff]/u.test(o.title)?"\u5355\u4F4D\uFF1A":"Unit: "}${t.unit}`,fontSize:11,color:n.muted}),l+=.3);const d=t.type==="pie"||t.type==="doughnut",m=Math.max(...t.categories.map(x=>j(x)))>6||t.categories.length>8;if(i.push({x:y-.1,y:l,w:h,h:L-l,chartType:t.type,categories:t.categories,series:t.series,colors:d||t.series.length>1?n.chart:[n.primary],labelColor:n.muted,valueColor:n.ink,gridColor:n.line,horizontal:!d&&t.type!=="line"&&m}),u){const x=y+g*.69,w=g*.31;i.push({x:x-.3,y:a,w:0,h:L-a,fill:n.line,shape:"line",lineWidth:.75}),s?i.push({x,y:a+.1,w:.5,h:.05,fill:n.accent,shape:"rect"},{x,y:a+.35,w,h:L-a-.5,content:s,fontSize:$(s,w,L-a-.5,22,14,1.3),color:n.ink,bold:!0,lineSpacingMultiple:1.2,font:"head"}):H(c,n,x,a,w,Math.min(L,a+c.length*1.1),i,16)}return i}p(ve,"Me"),f(ve,"chartElements");function Se(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i)+.05,s=B(n,v(o.takeaway),i),r=.4,c=(g-r*(t.length-1))/t.length,u=.62;return t.forEach((h,l)=>{const d=y+l*(c+r),m=l===t.length-1;i.push({x:d,y:a,w:c,h:u,fill:m?n.primary:n.surface,shape:n.radius>0?"roundRect":"rect",rectRadius:n.radius},{x:d+.3,y:a,w:c-.6,h:u,content:h.heading,fontSize:k(h.heading,c-.6,20,13),color:m?n.inverseInk:n.ink,bold:!0,valign:"middle",font:"head"});const x=T(h.points,5);x.length>0&&H(x,n,d+.15,a+u+.15,c-.15,s,i,18)}),i}p(Se,"Le"),f(Se,"comparisonElements");function ze(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i),s=B(n,v(o.takeaway),i),r=g/t.length,c=a+Math.max(1.35,(s-a)*.4);i.push({x:y,y:c,w:g,h:0,fill:n.line,shape:"line",lineWidth:1.5});const u=F(t.map(l=>l.lead),r-.2,.6,26,14),h=F(t.map(l=>l.detail),r-.3,s-c-.5,19,11,1.3);return t.forEach((l,d)=>{const m=y+r*(d+.5),x=d===t.length-1;i.push({x:m-r/2+.1,y:c-1,w:r-.2,h:.6,content:l.lead,fontSize:u,color:x?n.accent:n.primary,bold:!0,align:"center",valign:"bottom",font:"head"},{x:m-.14,y:c-.14,w:.28,h:.28,fill:x?n.accent:n.primary,shape:"ellipse"},{x:m-r/2+.15,y:c+.4,w:r-.3,h:s-c-.5,content:l.detail,fontSize:h,color:n.body,align:"center",lineSpacingMultiple:1.2})}),i}p(ze,"Pe"),f(ze,"timelineElements");function $e(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i),s=B(n,v(o.takeaway),i),r=t.rows.length,c=r<=5?15:r<=8?13:11,u=Math.min(.55,(s-a)/(r+1));return i.push({x:y,y:a,w:g,h:u*(r+1),headers:t.headers,rows:t.rows,fontSize:c,headerFill:n.primary,headerColor:n.inverseInk,stripeFill:n.surface,bodyColor:n.body,lineColor:n.line}),i}p($e,"Re"),f($e,"tableElements");function Fe(e){const{t,slide:n}=e,o=n.title.trim().replace(/^[“"「『]|[”"」』]$/gu,""),i=v(n.subtitle),a=[C(t.bg)];return t.topBand&&a.push({x:0,y:0,w:S,h:.16,fill:t.primary,shape:"rect"}),a.push({x:y+.6,y:.9,w:2,h:1.6,content:"\u201C",fontSize:140,color:t.accent,bold:!0,font:"head"},{x:y+1,y:2.35,w:g-2,h:2.6,content:o,fontSize:$(o,g-2,2.6,34,20,1.3),color:t.ink,bold:!0,lineSpacingMultiple:1.2,font:"head"}),i&&a.push({x:y+1,y:5.3,w:.5,h:.04,fill:t.primary,shape:"rect"},{x:y+1,y:5.45,w:g-2,h:.5,content:i,fontSize:16,color:t.muted}),a}p(Fe,"He"),f(Fe,"quoteElements");function Me(e){const{t,slide:n}=e,o=T(n.points,5),i=[C(t.inverseBg)];if(o.length===0){i.push({x:y,y:2.6,w:g,h:1.6,content:n.title,fontSize:$(n.title,g,1.6,54,28,1.1),color:t.inverseInk,bold:!0,align:"center",valign:"middle",font:"head"});const c=v(n.subtitle);return c&&i.push({x:y,y:4.3,w:g,h:.6,content:c,fontSize:k(c,g,18,12),color:t.inverseMuted,align:"center"}),i}i.push({x:y,y:.85,w:.9,h:.07,fill:t.accent,shape:"rect"},{x:y,y:1.05,w:g,h:1.4,content:n.title,fontSize:$(n.title,g,1.4,34,22,1.15),color:t.inverseInk,bold:!0,lineSpacingMultiple:1.1,font:"head"});const a=2.95,s=Math.min(.85,(6.7-a)/o.length),r=F(o,g-1.1,s-.15,20,13);return o.forEach((c,u)=>{const h=a+u*s;i.push({x:y,y:h,w:.9,h:s,content:W(u+1),fontSize:r+2,color:t.accent,bold:!0,valign:"middle",font:"head"},{x:y+1,y:h,w:g-1,h:s,content:J(c,t,!0),fontSize:r,valign:"middle"},{x:y,y:h+s,w:g,h:0,fill:t.inverseMuted,shape:"line",lineWidth:.5,transparency:50})}),i}p(Me,"Oe"),f(Me,"closingElements");function te(e,t,n=""){const o=se(t,`${e.title} ${n}`),i=e.slides.length,a=e.slides.map((u,h)=>Z(u,h,i)),s=e.slides.filter((u,h)=>a[h].layout==="section").map(u=>u.title.trim());let r,c=0;return{slides:e.slides.map((u,h)=>{const l=a[h];l.layout==="section"&&(c+=1,r=u.title.trim());const d={t:o,slide:u,deckTitle:e.title,index:h,total:i,tracker:r,sections:s,sectionOrdinal:c};switch(l.layout){case"title":return me(d);case"section":return xe(d);case"agenda":return we({...d,tracker:void 0});case"stats":return be(d,l.stats);case"chart":return ve(d,l.chart);case"comparison":return Se(d,l.columns);case"timeline":return ze(d,l.timeline);case"table":return $e(d,l.table);case"quote":return Fe(d);case"closing":return Me(d);case"two-column":return ee(d,!0);default:return ee(d,!1)}}),layouts:a}}p(te,"re"),f(te,"layoutDeck");function ne(e,t,n=""){return te(e,t,n).slides}p(ne,"We"),f(ne,"layoutSlides");function ke(e,t){const n=T(e.points,20);return n.length===0?[]:e.stats||e.chart||e.columns||e.table?t.layout==="chart"&&!v(e.takeaway)&&!I(n)?n.slice(3):["stats","chart","comparison","table"].includes(t.layout)?n:[]:[]}p(ke,"Ae"),f(ke,"displacedPoints");function Ce(e){if(e.chartType==="pie"||e.chartType==="doughnut"){const t=e.series[0];return[{name:t.name,labels:e.categories,values:t.values}]}return e.series.map(t=>({name:t.name||" ",labels:e.categories,values:t.values}))}p(Ce,"Be"),f(Ce,"chartData");function Le(e){const t={x:e.x,y:e.y,w:e.w,h:e.h,chartColors:e.colors,catAxisLabelColor:e.labelColor,valAxisLabelColor:e.labelColor,catAxisLabelFontFace:E,valAxisLabelFontFace:E,dataLabelFontFace:E,legendFontFace:E,catAxisLabelFontSize:12,valAxisLabelFontSize:11,dataLabelFontSize:12,legendFontSize:12,legendColor:e.labelColor,dataLabelColor:e.valueColor,showLegend:e.series.length>1,legendPos:"t",showTitle:!1};switch(e.chartType){case"pie":case"doughnut":return{...t,holeSize:62,showLegend:!0,legendPos:"r",legendFontSize:16,showPercent:!0,showValue:!1,dataLabelColor:"FFFFFF",dataLabelFontSize:13,dataLabelFontBold:!0,dataBorder:{pt:1.5,color:"FFFFFF"}};case"line":return{...t,lineSize:3,lineDataSymbol:"circle",lineDataSymbolSize:8,showValue:e.series.length===1&&e.categories.length<=8,dataLabelPosition:"t",valGridLine:{color:e.gridColor,style:"solid",size:.5},catGridLine:{style:"none"},catAxisLineColor:e.gridColor,valAxisHidden:!1,valAxisLineShow:!1};default:return{...t,barDir:e.horizontal?"bar":"col",barGrouping:e.chartType==="stacked"?"stacked":"clustered",barGapWidthPct:55,showValue:!0,dataLabelPosition:e.chartType==="stacked"?"ctr":"outEnd",dataLabelFormatCode:"#,##0.##",valAxisHidden:!0,valGridLine:{style:"none"},catGridLine:{style:"none"},catAxisLineColor:e.gridColor,catAxisOrientation:e.horizontal?"maxMin":"minMax"}}}p(Le,"_e"),f(Le,"chartOptions");function Ee(e){return e==="line"?"line":e==="pie"?"pie":e==="doughnut"?"doughnut":"bar"}p(Ee,"De"),f(Ee,"chartKind");const Ke=/^[-+]?[¥$¥€]?\d[\d,]*(\.\d+)?\s*(%|pp|万|亿|元|万元|亿元)?$/u;function Te(e){const t=f(i=>[{type:"none"},{type:"none"},{pt:.75,color:i},{type:"none"}],"border"),n=e.headers.map((i,a)=>({text:i,options:{bold:!0,color:e.headerColor,fill:{color:e.headerFill},align:a===0?"left":"center",border:t(e.headerFill)}})),o=e.rows.map((i,a)=>e.headers.map((s,r)=>{const c=i[r]??"";return{text:c,options:{color:e.bodyColor,fill:{color:a%2===1?e.stripeFill:"FFFFFF"},align:r>0&&Ke.test(c.trim())?"right":"left",border:t(e.lineColor)}}}));return[n,...o]}p(Te,"Ne"),f(Te,"tableRows");async function Ae(e,t){const n=await Ie.loadAsync(e),o={[_]:t.headFont,[E]:t.bodyFont},i=new RegExp(`<a:(latin|ea|cs) typeface="(${_}|${E})"`,"g"),a=Object.keys(n.files).filter(r=>/^ppt\/(slides|charts|notesSlides)\/[^/]+\.xml$/.test(r));for(const r of a){const c=await n.file(r).async("string"),u=c.replace(i,(h,l,d)=>{const m=o[d];return`<a:${l} typeface="${l==="ea"?m.ea:m.latin}"`});u!==c&&n.file(r,u)}const s=Object.keys(n.files).filter(r=>/^ppt\/theme\/theme\d+\.xml$/.test(r));for(const r of s){const c=await n.file(r).async("string"),u=f((l,d)=>l.replace(/<a:latin typeface="[^"]*"/,`<a:latin typeface="${d.latin}"`).replace(/<a:ea typeface="[^"]*"/,`<a:ea typeface="${d.ea}"`).replace(/<a:font script="Hans" typeface="[^"]*"/,`<a:font script="Hans" typeface="${d.ea}"`),"patchScheme"),h=c.replace(/<a:majorFont>[\s\S]*?<\/a:majorFont>/,l=>u(l,t.headFont)).replace(/<a:minorFont>[\s\S]*?<\/a:minorFont>/,l=>u(l,t.bodyFont));n.file(r,h)}return n.generateAsync({type:"nodebuffer",compression:"DEFLATE"})}p(Ae,"Ye"),f(Ae,"applyFonts");async function We(e,t,n=""){const o=se(t,`${e.title} ${n}`),i=new Oe;i.defineLayout({name:"W16x9",width:13.333,height:7.5}),i.layout="W16x9",i.title=e.title,i.subject="",i.author="",i.company="",i.theme={headFontFace:o.headFont.latin,bodyFontFace:o.bodyFont.latin};const a=te(e,t,n);e.slides.forEach((r,c)=>{const u=i.addSlide();for(const l of a.slides[c])if(D(l))u.addText(l.content,{x:l.x,y:l.y,w:l.w,h:l.h,fontSize:l.fontSize,fontFace:l.font==="head"?_:E,...l.color!==void 0?{color:l.color}:{},bold:l.bold??!1,align:l.align??"left",valign:l.valign??"top",margin:0,...l.transparency!==void 0?{transparency:l.transparency}:{},...l.charSpacing!==void 0?{charSpacing:l.charSpacing}:{},...l.lineSpacingMultiple!==void 0?{lineSpacingMultiple:l.lineSpacingMultiple}:{}});else if(G(l))u.addChart(Ee(l.chartType),Ce(l),Le(l));else if(q(l))u.addTable(Te(l),{x:l.x,y:l.y,w:l.w,rowH:l.h/(l.rows.length+1),fontSize:l.fontSize,fontFace:E,valign:"middle",margin:[0,.12,0,.12]});else{const d={x:l.x,y:l.y,w:l.w,h:l.h,fill:{color:l.fill,...l.transparency!==void 0?{transparency:l.transparency}:{}}};l.shape==="line"&&(d.line={color:l.fill,width:l.lineWidth??1,...l.transparency!==void 0?{transparency:l.transparency}:{}}),l.rectRadius!==void 0&&(d.rectRadius=l.rectRadius),l.shadowOpacity!==void 0&&l.shadowOpacity>0&&(d.shadow={type:"outer",angle:90,blur:14,offset:4,color:"0F172A",opacity:l.shadowOpacity}),u.addShape(l.shape,d)}const h=[v(r.goal),v(r.visual),...ke(r,a.layouts[c])].filter(l=>l!==void 0);h.length>0&&u.addNotes(h.join(`
|
|
3
|
-
`))});const
|
|
1
|
+
var Pe=Object.defineProperty;var d=(e,t)=>Pe(e,"name",{value:t,configurable:!0});var Ye=Object.defineProperty,p=d((e,t)=>Ye(e,"name",{value:t,configurable:!0}),"f");import De from"jszip";import*as re from"pptxgenjs";import{designTheme as se,resolveStyle as Ie}from"../themes.js";import{writeDeckSource as Oe}from"./deck-source.js";const ce=re.default??re,Ge=ce.default??ce,S=13.33,R=7.5,y=.75,m=S-2*y,qe=.62,I=1.62,L=6.55,_="zzHeadFace",E="zzBodyFace",he="[\u5F85\u586B\u5199]";function O(e){return"content"in e}d(O,"X"),p(O,"isText");function G(e){return"chartType"in e}d(G,"K"),p(G,"isChart");function q(e){return"headers"in e&&"rows"in e}d(q,"Q"),p(q,"isTable");function Ne(e){return e}d(Ne,"Ze"),p(Ne,"text");function Ve(e){return e}d(Ve,"et"),p(Ve,"shape");function W(e){return String(e).padStart(2,"0")}d(W,"R"),p(W,"marker");function v(e){return e?.trim()||void 0}d(v,"w"),p(v,"filled");function T(e,t){return(e??[]).map(n=>n.trim()).filter(n=>n.length>0).slice(0,t)}d(T,"M"),p(T,"cleanList");function ue(e){return/[⺀-鿿豈-- -〿]/u.test(e)?1:/[A-Z]/.test(e)?.72:/[0-9]/.test(e)?.58:e==="%"?.9:e===" "?.3:.56}d(ue,"ge"),p(ue,"charEm");function j(e){let t=0;for(const n of e)t+=ue(n);return t}d(j,"B"),p(j,"textEm");function P(e,t,n){const o=n*72/t*.96;return e.split(`
|
|
2
|
+
`).reduce((i,a)=>i+Math.max(1,Math.ceil(j(a)/o)),0)}d(P,"D"),p(P,"wrappedLines");function z(e,t,n,o,i,a=1.2){for(let c=o;c>i;c-=1)if(P(e,c,t)*c*a*1.12/72<=n)return c;return i}d(z,"z"),p(z,"fitSize");function F(e,t,n,o,i,a=1.2){return e.reduce((c,r)=>Math.min(c,z(r,t,n,o,i,a)),o)}d(F,"k"),p(F,"fitAll");function k(e,t,n,o){const i=Math.max(j(e),1);return Math.max(o,Math.min(n,Math.floor(t*72/i)))}d(k,"C"),p(k,"fitLine");function U(e){const t=/^(.{1,18}?)[::]\s*(.+)$/u.exec(e);if(t)return{lead:t[1].trim(),detail:t[2].trim()}}d(U,"Z"),p(U,"splitLead");function Y(e){const t=e.map(U);return t.every(n=>n!==void 0)?t:void 0}d(Y,"_"),p(Y,"allLeads");const _e=/^[-+约~≈]?[¥$¥€]?\d[\d,]*(\.\d+)?\s*(%|×|x|倍|pp|个百分点|万亿|亿元|万元|亿|万|千|元|k|m|b|天|小时|人|家|个|项|次|分)?\+?$/iu,Ue=/^(\d{4}(\s*年)?(\s*(Q[1-4]|H[12]|\d{1,2}\s*月))?|Q[1-4]|H[12]|\d{1,2}\s*月|第[一二三四五六七八九十\d]+(阶段|期|周|月|季度|年|步)|阶段\s*[一二三四五六七八九十\d]+|phase\s*\d+|M\d+|W\d+|day\s*\d+|D\d+|(近期|中期|远期|短期|长期)(\s*[((].*[))])?|本周|下周|本月|下月|本季度|下季度)$/iu;function Q(e){if(e.length<2||e.length>4)return;const t=Y(e);if(!(!t||!t.every(n=>_e.test(n.lead))))return t.map(n=>({value:n.lead,label:n.detail}))}d(Q,"ee"),p(Q,"inferStats");function X(e){if(e.length<2||e.length>6)return;const t=Y(e);return t?.every(n=>Ue.test(n.lead))?t:void 0}d(X,"te"),p(X,"inferTimeline");function Z(e){if(e.length<4||e.length>9)return;const t=Y(e);if(!t)return;const n=[],o=new Map;for(const i of t){if(i.lead.length>10)return;o.has(i.lead)||(o.set(i.lead,[]),n.push(i.lead)),o.get(i.lead).push(i.detail)}if(!(n.length<2||n.length>3)&&!n.some(i=>o.get(i).length<2))return n.map(i=>({heading:i,points:o.get(i)}))}d(Z,"ne"),p(Z,"inferColumns");const Qe=/^(.{1,14}?)[\s::]+[约~≈]?(-?\d[\d,]*(?:\.\d+)?)\s*(%|亿元|万元|元|亿|万|个|家|人|台|次|件|吨|天)?\s*([((].{0,12}[))])?$/u;function D(e){if(e.length<3||e.length>8)return;const t=e.map(i=>Qe.exec(i));if(t.some(i=>i===null))return;const n=t,o=n[0][3]??"";if(!n.some(i=>(i[3]??"")!==o))return{type:"bar",categories:n.map(i=>i[1].trim()+(i[4]?i[4].replace(/[(())]/g,""):"")),series:[{name:"",values:n.map(i=>Number(i[2].replace(/,/g,"")))}],...o?{unit:o}:{}}}d(D,"I"),p(D,"inferChart");function de(e){if(!e||e.categories.length===0)return;const t=e.series.filter(n=>n.values.length===e.categories.length&&n.values.every(o=>Number.isFinite(o)));return t.length>0?{...e,series:t}:void 0}d(de,"Se"),p(de,"validChart");function pe(e){const t=(e??[]).filter(n=>n.value.trim()&&n.label.trim()).slice(0,4);return t.length>0?t:void 0}d(pe,"xe"),p(pe,"validStats");function fe(e){const t=(e??[]).filter(n=>n.heading.trim()).slice(0,3);return t.length>=2?t:void 0}d(fe,"we"),p(fe,"validColumns");function ye(e){if(!(!e||e.headers.length===0||e.rows.length===0))return{headers:e.headers.slice(0,8),rows:e.rows.slice(0,12).map(t=>t.slice(0,8))}}d(ye,"ve"),p(ye,"validTable");const Xe=/^(目录|目 录|议程|大纲|contents?|agenda|outline)$/iu,Ze=/(谢谢|感谢|致谢|thank|q\s*&\s*a|问答|结束)/iu,Je=/^[“"「『].+[”"」』]$/u;function J(e,t,n){const o=T(e.points,9),i=de(e.chart),a=pe(e.stats),c=fe(e.columns),r=ye(e.table),s=e.layout;if(s==="title"||t===0&&s===void 0)return{layout:"title"};switch(s){case"section":case"agenda":case"quote":case"closing":case"content":case"two-column":return{layout:s};case"chart":{const g=i??D(o);return g?{layout:"chart",chart:g}:{layout:"content"}}case"stats":{const g=a??Q(o);return g?{layout:"stats",stats:g}:{layout:"content"}}case"comparison":{const g=c??Z(o);return g?{layout:"comparison",columns:g}:{layout:"two-column"}}case"timeline":{const g=X(o)??(o.length>=2?o.map((x,w)=>({lead:W(w+1),detail:x})):void 0);return g?{layout:"timeline",timeline:g}:{layout:"content"}}case"table":return r?{layout:"table",table:r}:{layout:"content"}}if(i)return{layout:"chart",chart:i};if(a)return{layout:"stats",stats:a};if(c)return{layout:"comparison",columns:c};if(r)return{layout:"table",table:r};if(Xe.test(e.title.trim()))return{layout:"agenda"};const u=Q(o);if(u)return{layout:"stats",stats:u};const h=X(o);if(h)return{layout:"timeline",timeline:h};const f=Z(o);if(f)return{layout:"comparison",columns:f};const l=D(o);return l?{layout:"chart",chart:l}:o.length===0&&Je.test(e.title.trim())?{layout:"quote"}:t===n-1&&t>0&&Ze.test(e.title)?{layout:"closing"}:{layout:"content"}}d(J,"Ce"),p(J,"resolveLayout");function C(e){return{x:0,y:0,w:S,h:R,fill:e,shape:"rect"}}d(C,"F"),p(C,"background");function A(e,t){const{t:n,slide:o}=e;t.push(C(n.bg)),n.topBand&&t.push({x:0,y:0,w:S,h:.16,fill:n.primary,shape:"rect"},{x:0,y:.16,w:S,h:.035,fill:n.accent,shape:"rect"}),e.tracker&&t.push({x:y,y:.34,w:8,h:.26,content:e.tracker,fontSize:11,color:n.primary,bold:!0,charSpacing:1});const i=.92,a=z(o.title,m,i,n.titleSize,18,1.15);t.push({x:y,y:qe,w:m,h:i,content:o.title,fontSize:a,color:n.ink,bold:!0,valign:"middle",lineSpacingMultiple:1.05,font:"head"}),n.titleRule&&t.push({x:y,y:I,w:m,h:0,fill:n.line,shape:"line",lineWidth:.75});let c=I+.33;const r=v(o.subtitle);r&&(t.push({x:y,y:I+.2,w:m,h:.42,content:r,fontSize:k(r,m,16,12),color:n.muted,valign:"middle"}),c=I+.82);const s=v(o.source);return s&&t.push({x:y,y:6.95,w:m-1.2,h:.3,content:s,fontSize:9,color:n.muted,valign:"middle"}),t.push({x:S-y-1,y:6.95,w:1,h:.3,content:String(e.index+1),fontSize:10,color:n.muted,align:"right",valign:"middle"}),c}d(A,"L"),p(A,"contentChrome");function B(e,t,n){if(!t)return L;const o=L-.62;return n.push({x:y,y:o,w:m,h:.62,fill:e.surface,shape:e.radius>0?"roundRect":"rect",rectRadius:e.radius},{x:y+.25,y:o+.24,w:.14,h:.14,fill:e.accent,shape:"rect"},{x:y+.55,y:o,w:m-.8,h:.62,content:t,fontSize:k(t,m-.8,16,12),color:e.ink,bold:!0,valign:"middle"}),o-.25}d(B,"O"),p(B,"takeawayBand");function ge(e,t,n,o=1.4){return P(e,t,n)*t*o/72}d(ge,"$e"),p(ge,"blockHeight");function N(e,t,n,o){const i=k(e,n*.96,o,28),a=i>=o*.75?i:z(e,n,2.2,o,28,1.35),c=ge(e,a,n,1.4)+.05,r=3.45-(.3+c+(t?.3+.5:0))/2;return{size:a,top:r,titleY:r+.3,titleH:c,subtitleY:r+.3+c+.3}}d(N,"Y"),p(N,"coverGroup");function me(e){const{t,slide:n}=e,o=v(n.subtitle),i=[];switch(t.cover){case"dark-center":{i.push(C(t.inverseBg));const a=N(n.title,o,11.2,54);return i.push({x:1.06,y:a.titleY,w:11.2,h:a.titleH,content:n.title,fontSize:a.size,color:t.inverseInk,bold:!0,align:"center",lineSpacingMultiple:1.05,font:"head"},{x:S/2-.3,y:a.titleY+a.titleH+.08,w:.6,h:.04,fill:t.primary,shape:"rect"}),o&&i.push({x:1.06,y:a.subtitleY+.1,w:11.2,h:.6,content:o,fontSize:k(o,11.2,20,13),color:t.inverseMuted,align:"center"}),i}case"white-left":case"panel-right":{const a=t.cover==="panel-right",c=a?7.7:10.8;i.push(C(t.bg)),a?i.push({x:9,y:0,w:S-9,h:R,fill:t.inverseBg,shape:"rect"},{x:10.35,y:4.35,w:2.4,h:2.4,fill:t.accent,shape:"ellipse"},{x:9.55,y:1,w:1.1,h:1.1,fill:t.inverseMuted,shape:"ellipse",transparency:55}):i.push({x:y,y:6.7,w:m,h:0,fill:t.ink,shape:"line",lineWidth:1});const r=N(n.title,o,c,a?42:48);return i.push({x:y,y:r.top,w:.8,h:.08,fill:t.accent,shape:"rect"},{x:y,y:r.titleY,w:c,h:r.titleH,content:n.title,fontSize:r.size,color:t.ink,bold:!0,valign:"top",lineSpacingMultiple:1.05,font:"head"}),o&&i.push({x:y,y:r.subtitleY,w:c,h:.9,content:o,fontSize:z(o,c,.9,20,12),color:a?t.body:t.muted}),i}case"gov-band":return i.push(C(t.bg)),i.push({x:0,y:0,w:S,h:1.1,fill:t.primary,shape:"rect"},{x:0,y:1.1,w:S,h:.06,fill:t.accent,shape:"rect"},{x:0,y:R-.4,w:S,h:.4,fill:t.primary,shape:"rect"},{x:0,y:R-.46,w:S,h:.06,fill:t.accent,shape:"rect"}),i.push({x:y,y:2.3,w:m,h:1.8,content:n.title,fontSize:z(n.title,m,1.8,44,28,1.1),color:t.primary,bold:!0,align:"center",valign:"bottom",lineSpacingMultiple:1.05,font:"head"}),i.push({x:S/2-1.6,y:4.3,w:3.2,h:0,fill:t.accent,shape:"line",lineWidth:1.5}),o&&i.push({x:y,y:4.5,w:m,h:.6,content:o,fontSize:k(o,m,20,13),color:t.body,align:"center"}),i;default:{i.push(C(t.inverseBg));const a=N(n.title,o,10.6,48);return i.push({x:y,y:a.top,w:.9,h:.07,fill:t.accent,shape:"rect"},{x:y,y:a.titleY,w:10.6,h:a.titleH,content:n.title,fontSize:a.size,color:t.inverseInk,bold:!0,lineSpacingMultiple:1.05,font:"head"}),o&&i.push({x:y,y:a.subtitleY,w:10.6,h:.9,content:o,fontSize:z(o,10.6,.9,20,12),color:t.inverseMuted}),i.push({x:y,y:6.75,w:m,h:0,fill:t.inverseMuted,shape:"line",lineWidth:.75}),i}}}d(me,"Te"),p(me,"coverElements");function xe(e){const{t,slide:n}=e,o=v(n.subtitle),i=[C(t.inverseBg)];return t.topBand&&i.push({x:0,y:R-.5,w:S,h:.06,fill:t.accent,shape:"rect"}),i.push({x:y,y:1.7,w:4,h:1.2,content:W(e.sectionOrdinal),fontSize:66,color:t.accent,bold:!0,font:"head"},{x:y+.05,y:3.1,w:1.2,h:.05,fill:t.accent,shape:"rect"},{x:y,y:3.35,w:10.8,h:1.3,content:n.title,fontSize:z(n.title,10.8,1.3,40,26,1.1),color:t.inverseInk,bold:!0,font:"head"}),o&&i.push({x:y,y:4.75,w:10.8,h:.6,content:o,fontSize:k(o,10.8,18,12),color:t.inverseMuted}),i}d(xe,"Fe"),p(xe,"sectionElements");function we(e){const{t}=e,n=[],o=A(e,n),i=T(e.slide.points,8),a=i.length>0?i:e.sections.slice(0,8);if(a.length===0)return n.push({x:y,y:o,w:m,h:.6,content:he,fontSize:18,color:t.muted}),n;const c=Math.min(.82,(L-o)/a.length),r=y+1.6,s=m-1.6,u=F(a,s-1.1,c-.12,22,14);return a.forEach((h,f)=>{const l=o+f*c;n.push({x:r,y:l,w:.9,h:c,content:W(f+1),fontSize:u+2,color:t.primary,bold:!0,valign:"middle",font:"head"},{x:r+1.1,y:l,w:s-1.1,h:c,content:h,fontSize:u,color:t.ink,valign:"middle"},{x:r,y:l+c,w:s,h:0,fill:t.line,shape:"line",lineWidth:.75})}),n}d(we,"Me"),p(we,"agendaElements");function K(e,t,n=!1){const o=U(e),i=n?t.inverseInk:t.ink,a=n?t.inverseMuted:t.body;return o?[{text:`${o.lead}\uFF1A`,options:{color:i,bold:!0}},{text:o.detail,options:{color:a}}]:[{text:e,options:{color:n?t.inverseInk:t.body}}]}d(K,"ie"),p(K,"pointRuns");function H(e,t,n,o,i,a,c,r=20){const s=Math.min(1.15,(a-o)/e.length),u=F(e,i-.45,s-.18,r,12,1.25);e.forEach((h,f)=>{const l=o+f*s,g=P(h,u,i-.45)*u*1.25/72,x=l+(s-g)/2+u*1.25/72/2;c.push({x:n,y:x-.055,w:.11,h:.11,fill:t.primary,shape:"rect"},{x:n+.35,y:l,w:i-.35,h:s,content:K(h,t),fontSize:u,valign:"middle",lineSpacingMultiple:1.15}),f<e.length-1&&c.push({x:n,y:l+s,w:i,h:0,fill:t.line,shape:"line",lineWidth:.5})})}d(H,"W"),p(H,"pointList");function ee(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i)+.1,c=B(n,v(o.takeaway),i),r=T(o.points,8);if(r.length===0)return i.push({x:y,y:a,w:m,h:.6,content:he,fontSize:18,color:n.muted}),i;const s=Y(r),u=c-a;if(!t&&s&&r.length>=2&&r.length<=3){const h=(m-.5*(r.length-1))/r.length,f=F(s.map(w=>w.lead),h,.95,26,16,1.15),l=F(s.map(w=>w.detail),h,u-1.75,19,12,1.35),g=Math.max(...s.map(w=>P(w.detail,l,h)*l*1.35/72)),x=a+Math.max(0,(u-1.75-g-.2)/3);return s.forEach((w,$)=>{const M=y+$*(h+.5);i.push({x:M,y:x+.1,w:h,h:.05,fill:$===0?n.primary:n.line,shape:"rect"},{x:M,y:x+.3,w:h,h:.4,content:W($+1),fontSize:15,color:n.primary,bold:!0,font:"head"},{x:M,y:x+.75,w:h,h:.95,content:w.lead,fontSize:f,color:n.ink,bold:!0,lineSpacingMultiple:1.05,font:"head"},{x:M,y:x+1.75,w:h,h:c-x-1.75,content:w.detail,fontSize:l,color:n.body,lineSpacingMultiple:1.25})}),i}if(!t&&s&&r.length===4){const h=(m-.6)/2,f=(u-.3)/2,l=F(s.map(x=>x.lead),h-.9,.5,20,14),g=F(s.map(x=>x.detail),h-.9,f-.8,16,11,1.3);return i.push({x:y+h+.3,y:a,w:0,h:u,fill:n.line,shape:"line",lineWidth:.75},{x:y,y:a+f+.15,w:m,h:0,fill:n.line,shape:"line",lineWidth:.75}),s.forEach((x,w)=>{const $=y+w%2*(h+.6),M=a+Math.floor(w/2)*(f+.3)+.1;i.push({x:$,y:M,w:.8,h:.55,content:W(w+1),fontSize:24,color:n.primary,bold:!0,font:"head"},{x:$+.9,y:M,w:h-.9,h:.55,content:x.lead,fontSize:l,color:n.ink,bold:!0,valign:"middle",font:"head"},{x:$+.9,y:M+.65,w:h-.9,h:f-.8,content:x.detail,fontSize:g,color:n.body,lineSpacingMultiple:1.2})}),i}if(t||r.length>5){const h=Math.ceil(r.length/2),f=(m-.6)/2;return H(r.slice(0,h),n,y,a,f,c,i,18),r.length>h&&H(r.slice(h),n,y+f+.6,a,f,c,i,18),i}return H(r,n,y,a,m*.86,c,i),i}d(ee,"oe"),p(ee,"contentElements");function be(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i),c=B(n,v(o.takeaway),i),r=m/t.length,s=2.7,u=a+Math.max(.2,(c-a-s)/2),h=Math.min(...t.map(l=>k(l.value,r-.5,t.length<=2?80:64,28))),f=F(t.map(l=>l.label),r-.5,.8,18,12);return t.forEach((l,g)=>{const x=y+g*r;g>0&&i.push({x,y:u,w:0,h:s,fill:n.line,shape:"line",lineWidth:.75});const w=g>0?.4:0;i.push({x:x+w,y:u,w:r-w-.1,h:1.35,content:l.value,fontSize:h,color:g===0?n.primary:n.ink,bold:!0,valign:"bottom",font:"head"},{x:x+w,y:u+1.5,w:r-w-.3,h:.8,content:l.label,fontSize:f,color:n.ink,bold:!0});const $=v(l.note);$&&i.push({x:x+w,y:u+2.3,w:r-w-.3,h:.4,content:$,fontSize:12,color:n.muted})}),i}d(be,"Le"),p(be,"statsElements");function ve(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i),c=v(o.takeaway),r=T(o.points,8),s=c||D(r)?[]:r.slice(0,3),u=c!==void 0||s.length>0,h=u?m*.64:m;let f=a;t.unit&&(i.push({x:y,y:a-.05,w:4,h:.3,content:`${/[\u3400-\u9fff]/u.test(o.title)?"\u5355\u4F4D\uFF1A":"Unit: "}${t.unit}`,fontSize:11,color:n.muted}),f+=.3);const l=t.type==="pie"||t.type==="doughnut",g=Math.max(...t.categories.map(x=>j(x)))>6||t.categories.length>8;if(i.push({x:y-.1,y:f,w:h,h:L-f,chartType:t.type,categories:t.categories,series:t.series,colors:l||t.series.length>1?n.chart:[n.primary],labelColor:n.muted,valueColor:n.ink,gridColor:n.line,horizontal:!l&&t.type!=="line"&&g}),u){const x=y+m*.69,w=m*.31;i.push({x:x-.3,y:a,w:0,h:L-a,fill:n.line,shape:"line",lineWidth:.75}),c?i.push({x,y:a+.1,w:.5,h:.05,fill:n.accent,shape:"rect"},{x,y:a+.35,w,h:L-a-.5,content:c,fontSize:z(c,w,L-a-.5,22,14,1.3),color:n.ink,bold:!0,lineSpacingMultiple:1.2,font:"head"}):H(s,n,x,a,w,Math.min(L,a+s.length*1.1),i,16)}return i}d(ve,"Pe"),p(ve,"chartElements");function Se(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i)+.05,c=B(n,v(o.takeaway),i),r=.4,s=(m-r*(t.length-1))/t.length,u=.62;return t.forEach((h,f)=>{const l=y+f*(s+r),g=f===t.length-1;i.push({x:l,y:a,w:s,h:u,fill:g?n.primary:n.surface,shape:n.radius>0?"roundRect":"rect",rectRadius:n.radius},{x:l+.3,y:a,w:s-.6,h:u,content:h.heading,fontSize:k(h.heading,s-.6,20,13),color:g?n.inverseInk:n.ink,bold:!0,valign:"middle",font:"head"});const x=T(h.points,5);x.length>0&&H(x,n,l+.15,a+u+.15,s-.15,c,i,18)}),i}d(Se,"Re"),p(Se,"comparisonElements");function $e(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i),c=B(n,v(o.takeaway),i),r=m/t.length,s=a+Math.max(1.35,(c-a)*.4);i.push({x:y,y:s,w:m,h:0,fill:n.line,shape:"line",lineWidth:1.5});const u=F(t.map(f=>f.lead),r-.2,.6,26,14),h=F(t.map(f=>f.detail),r-.3,c-s-.5,19,11,1.3);return t.forEach((f,l)=>{const g=y+r*(l+.5),x=l===t.length-1;i.push({x:g-r/2+.1,y:s-1,w:r-.2,h:.6,content:f.lead,fontSize:u,color:x?n.accent:n.primary,bold:!0,align:"center",valign:"bottom",font:"head"},{x:g-.14,y:s-.14,w:.28,h:.28,fill:x?n.accent:n.primary,shape:"ellipse"},{x:g-r/2+.15,y:s+.4,w:r-.3,h:c-s-.5,content:f.detail,fontSize:h,color:n.body,align:"center",lineSpacingMultiple:1.2})}),i}d($e,"He"),p($e,"timelineElements");function ze(e,t){const{t:n,slide:o}=e,i=[],a=A(e,i),c=B(n,v(o.takeaway),i),r=t.rows.length,s=r<=5?15:r<=8?13:11,u=Math.min(.55,(c-a)/(r+1));return i.push({x:y,y:a,w:m,h:u*(r+1),headers:t.headers,rows:t.rows,fontSize:s,headerFill:n.primary,headerColor:n.inverseInk,stripeFill:n.surface,bodyColor:n.body,lineColor:n.line}),i}d(ze,"Oe"),p(ze,"tableElements");function Fe(e){const{t,slide:n}=e,o=n.title.trim().replace(/^[“"「『]|[”"」』]$/gu,""),i=v(n.subtitle),a=[C(t.bg)];return t.topBand&&a.push({x:0,y:0,w:S,h:.16,fill:t.primary,shape:"rect"}),a.push({x:y+.6,y:.9,w:2,h:1.6,content:"\u201C",fontSize:140,color:t.accent,bold:!0,font:"head"},{x:y+1,y:2.35,w:m-2,h:2.6,content:o,fontSize:z(o,m-2,2.6,34,20,1.3),color:t.ink,bold:!0,lineSpacingMultiple:1.2,font:"head"}),i&&a.push({x:y+1,y:5.3,w:.5,h:.04,fill:t.primary,shape:"rect"},{x:y+1,y:5.45,w:m-2,h:.5,content:i,fontSize:16,color:t.muted}),a}d(Fe,"We"),p(Fe,"quoteElements");function Me(e){const{t,slide:n}=e,o=T(n.points,5),i=[C(t.inverseBg)];if(o.length===0){i.push({x:y,y:2.6,w:m,h:1.6,content:n.title,fontSize:z(n.title,m,1.6,54,28,1.1),color:t.inverseInk,bold:!0,align:"center",valign:"middle",font:"head"});const s=v(n.subtitle);return s&&i.push({x:y,y:4.3,w:m,h:.6,content:s,fontSize:k(s,m,18,12),color:t.inverseMuted,align:"center"}),i}i.push({x:y,y:.85,w:.9,h:.07,fill:t.accent,shape:"rect"},{x:y,y:1.05,w:m,h:1.4,content:n.title,fontSize:z(n.title,m,1.4,34,22,1.15),color:t.inverseInk,bold:!0,lineSpacingMultiple:1.1,font:"head"});const a=2.95,c=Math.min(.85,(6.7-a)/o.length),r=F(o,m-1.1,c-.15,20,13);return o.forEach((s,u)=>{const h=a+u*c;i.push({x:y,y:h,w:.9,h:c,content:W(u+1),fontSize:r+2,color:t.accent,bold:!0,valign:"middle",font:"head"},{x:y+1,y:h,w:m-1,h:c,content:K(s,t,!0),fontSize:r,valign:"middle"},{x:y,y:h+c,w:m,h:0,fill:t.inverseMuted,shape:"line",lineWidth:.5,transparency:50})}),i}d(Me,"Ae"),p(Me,"closingElements");function te(e,t,n=""){const o=se(t,`${e.title} ${n}`),i=e.slides.length,a=e.slides.map((u,h)=>J(u,h,i)),c=e.slides.filter((u,h)=>a[h].layout==="section").map(u=>u.title.trim());let r,s=0;return{slides:e.slides.map((u,h)=>{const f=a[h];f.layout==="section"&&(s+=1,r=u.title.trim());const l={t:o,slide:u,deckTitle:e.title,index:h,total:i,tracker:r,sections:c,sectionOrdinal:s};switch(f.layout){case"title":return me(l);case"section":return xe(l);case"agenda":return we({...l,tracker:void 0});case"stats":return be(l,f.stats);case"chart":return ve(l,f.chart);case"comparison":return Se(l,f.columns);case"timeline":return $e(l,f.timeline);case"table":return ze(l,f.table);case"quote":return Fe(l);case"closing":return Me(l);case"two-column":return ee(l,!0);default:return ee(l,!1)}}),layouts:a}}d(te,"re"),p(te,"layoutDeck");function ne(e,t,n=""){return te(e,t,n).slides}d(ne,"Be"),p(ne,"layoutSlides");function ke(e,t){const n=T(e.points,20);return n.length===0?[]:e.stats||e.chart||e.columns||e.table?t.layout==="chart"&&!v(e.takeaway)&&!D(n)?n.slice(3):["stats","chart","comparison","table"].includes(t.layout)?n:[]:[]}d(ke,"De"),p(ke,"displacedPoints");function Ce(e){if(e.chartType==="pie"||e.chartType==="doughnut"){const t=e.series[0];return[{name:t.name,labels:e.categories,values:t.values}]}return e.series.map(t=>({name:t.name||" ",labels:e.categories,values:t.values}))}d(Ce,"_e"),p(Ce,"chartData");function Le(e){const t={x:e.x,y:e.y,w:e.w,h:e.h,chartColors:e.colors,catAxisLabelColor:e.labelColor,valAxisLabelColor:e.labelColor,catAxisLabelFontFace:E,valAxisLabelFontFace:E,dataLabelFontFace:E,legendFontFace:E,catAxisLabelFontSize:12,valAxisLabelFontSize:11,dataLabelFontSize:12,legendFontSize:12,legendColor:e.labelColor,dataLabelColor:e.valueColor,showLegend:e.series.length>1,legendPos:"t",showTitle:!1};switch(e.chartType){case"pie":case"doughnut":return{...t,holeSize:62,showLegend:!0,legendPos:"r",legendFontSize:16,showPercent:!0,showValue:!1,dataLabelColor:"FFFFFF",dataLabelFontSize:13,dataLabelFontBold:!0,dataBorder:{pt:1.5,color:"FFFFFF"}};case"line":return{...t,lineSize:3,lineDataSymbol:"circle",lineDataSymbolSize:8,showValue:e.series.length===1&&e.categories.length<=8,dataLabelPosition:"t",valGridLine:{color:e.gridColor,style:"solid",size:.5},catGridLine:{style:"none"},catAxisLineColor:e.gridColor,valAxisHidden:!1,valAxisLineShow:!1};default:return{...t,barDir:e.horizontal?"bar":"col",barGrouping:e.chartType==="stacked"?"stacked":"clustered",barGapWidthPct:55,showValue:!0,dataLabelPosition:e.chartType==="stacked"?"ctr":"outEnd",dataLabelFormatCode:"#,##0.##",valAxisHidden:!0,valGridLine:{style:"none"},catGridLine:{style:"none"},catAxisLineColor:e.gridColor,catAxisOrientation:e.horizontal?"maxMin":"minMax"}}}d(Le,"Ie"),p(Le,"chartOptions");function Ee(e){return e==="line"?"line":e==="pie"?"pie":e==="doughnut"?"doughnut":"bar"}d(Ee,"Ne"),p(Ee,"chartKind");const Ke=/^[-+]?[¥$¥€]?\d[\d,]*(\.\d+)?\s*(%|pp|万|亿|元|万元|亿元)?$/u;function Te(e){const t=p(i=>[{type:"none"},{type:"none"},{pt:.75,color:i},{type:"none"}],"border"),n=e.headers.map((i,a)=>({text:i,options:{bold:!0,color:e.headerColor,fill:{color:e.headerFill},align:a===0?"left":"center",border:t(e.headerFill)}})),o=e.rows.map((i,a)=>e.headers.map((c,r)=>{const s=i[r]??"";return{text:s,options:{color:e.bodyColor,fill:{color:a%2===1?e.stripeFill:"FFFFFF"},align:r>0&&Ke.test(s.trim())?"right":"left",border:t(e.lineColor)}}}));return[n,...o]}d(Te,"Ge"),p(Te,"tableRows");async function Ae(e,t,n){const o=await De.loadAsync(e),i={[_]:t.headFont,[E]:t.bodyFont},a=new RegExp(`<a:(latin|ea|cs) typeface="(${_}|${E})"`,"g"),c=Object.keys(o.files).filter(s=>/^ppt\/(slides|charts|notesSlides)\/[^/]+\.xml$/.test(s));for(const s of c){const u=await o.file(s).async("string"),h=u.replace(a,(f,l,g)=>{const x=i[g];return`<a:${l} typeface="${l==="ea"?x.ea:x.latin}"`});h!==u&&o.file(s,h)}const r=Object.keys(o.files).filter(s=>/^ppt\/theme\/theme\d+\.xml$/.test(s));for(const s of r){const u=await o.file(s).async("string"),h=p((l,g)=>l.replace(/<a:latin typeface="[^"]*"/,`<a:latin typeface="${g.latin}"`).replace(/<a:ea typeface="[^"]*"/,`<a:ea typeface="${g.ea}"`).replace(/<a:font script="Hans" typeface="[^"]*"/,`<a:font script="Hans" typeface="${g.ea}"`),"patchScheme"),f=u.replace(/<a:majorFont>[\s\S]*?<\/a:majorFont>/,l=>h(l,t.headFont)).replace(/<a:minorFont>[\s\S]*?<\/a:minorFont>/,l=>h(l,t.bodyFont));o.file(s,f)}return await Oe(o,n),o.generateAsync({type:"nodebuffer",compression:"DEFLATE"})}d(Ae,"je"),p(Ae,"finishDeck");async function We(e,t,n=""){const o=se(t,`${e.title} ${n}`),i=new Ge;i.defineLayout({name:"W16x9",width:13.333,height:7.5}),i.layout="W16x9",i.title=e.title,i.subject="",i.author="",i.company="",i.theme={headFontFace:o.headFont.latin,bodyFontFace:o.bodyFont.latin};const a=te(e,t,n);e.slides.forEach((s,u)=>{const h=i.addSlide();for(const l of a.slides[u])if(O(l))h.addText(l.content,{x:l.x,y:l.y,w:l.w,h:l.h,fontSize:l.fontSize,fontFace:l.font==="head"?_:E,...l.color!==void 0?{color:l.color}:{},bold:l.bold??!1,align:l.align??"left",valign:l.valign??"top",margin:0,...l.transparency!==void 0?{transparency:l.transparency}:{},...l.charSpacing!==void 0?{charSpacing:l.charSpacing}:{},...l.lineSpacingMultiple!==void 0?{lineSpacingMultiple:l.lineSpacingMultiple}:{}});else if(G(l))h.addChart(Ee(l.chartType),Ce(l),Le(l));else if(q(l))h.addTable(Te(l),{x:l.x,y:l.y,w:l.w,rowH:l.h/(l.rows.length+1),fontSize:l.fontSize,fontFace:E,valign:"middle",margin:[0,.12,0,.12]});else{const g={x:l.x,y:l.y,w:l.w,h:l.h,fill:{color:l.fill,...l.transparency!==void 0?{transparency:l.transparency}:{}}};l.shape==="line"&&(g.line={color:l.fill,width:l.lineWidth??1,...l.transparency!==void 0?{transparency:l.transparency}:{}}),l.rectRadius!==void 0&&(g.rectRadius=l.rectRadius),l.shadowOpacity!==void 0&&l.shadowOpacity>0&&(g.shadow={type:"outer",angle:90,blur:14,offset:4,color:"0F172A",opacity:l.shadowOpacity}),h.addShape(l.shape,g)}const f=[v(s.goal),v(s.visual),...ke(s,a.layouts[u])].filter(l=>l!==void 0);f.length>0&&h.addNotes(f.join(`
|
|
3
|
+
`))});const c=await i.write({outputType:"nodebuffer"}),r=Ie(t,`${e.title} ${n}`);return Ae(c,o,{version:1,style:r,plan:e})}d(We,"tt"),p(We,"renderPptx");const ie=320,Be=180,et=20*1024;function He(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}d(He,"Ue"),p(He,"escapeXml");function b(e){return String(Math.round(e*100)/100)}d(b,"S"),p(b,"svgNumber");function oe(e,t){return j(e)*t}d(oe,"se"),p(oe,"estimateTextWidth");function Re(e,t,n){if(oe(e,t)<=n)return e;const o=[...e];for(;o.length>0&&oe(`${o.join("")}\u2026`,t)>n;)o.pop();return`${o.join("")}\u2026`}d(Re,"qe"),p(Re,"fitText");function V(e,t){return e===void 0?"":` ${t}="${b(1-e/100)}"`}d(V,"j"),p(V,"opacityAttr");function le(e,t,n,o,i){return`<rect x="${b(e)}" y="${b(t)}" width="${b(n)}" height="${b(o)}" fill="#${i}"/>`}d(le,"ae"),p(le,"rectSvg");function ae(e){const t=ie/S,n=[];for(const o of e){const i=o.x*t,a=o.y*t,c=o.w*t,r=o.h*t;if(G(o)){const u=o.series[0]?.values??[],h=Math.max(...u,1),f=c/Math.max(u.length,1);u.forEach((l,g)=>{const x=Math.max(l,0)/h*r*.85;n.push(le(i+g*f+f*.2,a+r-x,f*.6,x,o.colors[g%o.colors.length]))});continue}if(q(o)){const u=r/(o.rows.length+1);n.push(le(i,a,c,u,o.headerFill));for(let h=1;h<=o.rows.length;h++)n.push(`<line x1="${b(i)}" y1="${b(a+u*(h+1))}" x2="${b(i+c)}" y2="${b(a+u*(h+1))}" stroke="#${o.lineColor}" stroke-width="0.5"/>`);continue}if(O(o)){const u=(typeof o.content=="string"?o.content:o.content.map(M=>M.text).join("")).replace(/\s+/g," ").trim();if(u.length===0)continue;const h=o.fontSize/72*t,f=Re(u,h,Math.max(c,h)),l=o.align==="right"?"end":o.align==="center"?"middle":"start",g=l==="end"?i+c:l==="middle"?i+c/2:i,x=o.valign==="middle"?a+r/2+h*.35:o.valign==="bottom"?a+r-h*.25:a+h*.9,w=typeof o.content=="string"?void 0:o.content[0]?.options?.color,$=o.color??w??"333333";n.push(`<text x="${b(g)}" y="${b(x)}" font-size="${b(h)}" fill="#${$}"${o.bold?' font-weight="700"':""} text-anchor="${l}"${V(o.transparency,"fill-opacity")}>${He(f)}</text>`);continue}const s=`#${o.fill}`;switch(o.shape){case"ellipse":n.push(`<ellipse cx="${b(i+c/2)}" cy="${b(a+r/2)}" rx="${b(c/2)}" ry="${b(r/2)}" fill="${s}"${V(o.transparency,"fill-opacity")}/>`);break;case"line":n.push(`<line x1="${b(i)}" y1="${b(a)}" x2="${b(i+c)}" y2="${b(a+r)}" stroke="${s}" stroke-width="${b(Math.max((o.lineWidth??1)/72*t,.5))}"/>`);break;default:{const u=o.shape==="roundRect"?` rx="${b((o.rectRadius??.1)*t)}"`:"";n.push(`<rect x="${b(i)}" y="${b(a)}" width="${b(c)}" height="${b(r)}"${u} fill="${s}"${V(o.transparency,"fill-opacity")}/>`)}}}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${ie} ${Be}" width="${ie}" height="${Be}" font-family="Microsoft YaHei, PingFang SC, sans-serif">${n.join("")}</svg>`}d(ae,"Je"),p(ae,"slideElementsSvg");function je(e,t,n){const[o]=ne({title:t,slides:[{title:t,layout:"title",...n?{subtitle:n}:{}}]},e);return ae(o)}d(je,"it"),p(je,"themeThumbnailSvg");export{et as MAX_THUMBNAIL_SVG_BYTES,G as isChart,q as isTable,O as isText,ne as layoutSlides,We as renderPptx,J as resolveLayout,ae as slideElementsSvg,je as themeThumbnailSvg};
|