local-operator-ui 0.36.2 → 0.36.3
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/out/main/index.js +6155 -13
- package/out/preload/index.js +7 -0
- package/out/renderer/assets/{_basePickBy-CcO6nPxQ.js → _basePickBy-DVPdsJYh.js} +1 -1
- package/out/renderer/assets/{_baseUniq-BH2uaUcG.js → _baseUniq-DiBAxxuH.js} +1 -1
- package/out/renderer/assets/{agent-details-page-B3JXwv1Q.js → agent-details-page-Bbf-ap4W.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-DKgp42Gz.js → agent-hub-page-CYf0qdg8.js} +1 -1
- package/out/renderer/assets/{agents-page-Bcgw5NaE.js → agents-page-Ddhn0OiX.js} +3 -3
- package/out/renderer/assets/{arc-yBH7h1fW.js → arc-Dw2y_5Ul.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CHBovRWu.js → architectureDiagram-IEHRJDOE-DEF1EAW4.js} +1 -1
- package/out/renderer/assets/{arrow-up-Di0VTM6O.js → arrow-up-D8Tgt51O.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-vW3btTHI.js → blockDiagram-JOT3LUYC-Si8mcap-.js} +1 -1
- package/out/renderer/assets/{book-open-BklxnVnC.js → book-open-DeWHPw1t.js} +1 -1
- package/out/renderer/assets/browser-page-BXSI_6KL.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-BVQVtCyj.js → browser-webauthn-prompt-bdks5x_s.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-B-omeKTH.js → c4Diagram-VJAJSXHY-D1lx9sOj.js} +1 -1
- package/out/renderer/assets/channel-Cq3l3rsO.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-DbogYOtn.js → chunk-4BMEZGHF-B1OoXuiC.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-B99o2tMG.js → chunk-A2AXSNBT-Cr084INE.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BHrb34eS.js → chunk-AEK57VVT-6BBu10_U.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-COYEuoan.js → chunk-D6G4REZN-DIlAHP8p.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-D3q2lYwW.js → chunk-RZ5BOZE2-Da0rWE9o.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-CvTfujhG.js → chunk-XZIHB7SX-BtHW2mRW.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DoZsDzLJ.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DoZsDzLJ.js +1 -0
- package/out/renderer/assets/clone-aroLRPNj.js +1 -0
- package/out/renderer/assets/{console-mirror-BThuJoo1.js → console-mirror-BnHVC7eO.js} +1 -1
- package/out/renderer/assets/{consoleCapture-B6L7nb-J.js → consoleCapture-BxykZlLx.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-Csq2qdm5.js → conversation-input-sync-neD8lOHF.js} +5 -5
- package/out/renderer/assets/{dagre-OKDRZEBW-CvnmuVIi.js → dagre-OKDRZEBW-QJnzHJrX.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DUkL0seE.js → diagram-SSKATNLV-CblG8bwr.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DYQJ-990.js → diagram-VNBRO52H-D9VlUgES.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CQWWLpWe.js → erDiagram-Q7BY3M3F-CYdAsxl1.js} +1 -1
- package/out/renderer/assets/{error-boundary-D1EdrZoj.js → error-boundary-Tv9TlaZ8.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CHWTC3wr.js → flowDiagram-4HSFHLVR-EKGuFRMH.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CbYaNbcy.js → ganttDiagram-APWFNJXF-yTSMo4Sy.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-Dz5fATwZ.js → gitGraphDiagram-7IBYFJ6S-e48WwwO4.js} +1 -1
- package/out/renderer/assets/{graph-B4lGCZmF.js → graph-BFjFFISR.js} +1 -1
- package/out/renderer/assets/{index-DhrqAKsM.js → index-CY29neUf.js} +1 -1
- package/out/renderer/assets/index-CZI34YVW.js +829 -0
- package/out/renderer/assets/{index-CcD0LA0Q.js → index-Cb5EO4yE.js} +1 -1
- package/out/renderer/assets/index-hX_aZwq0.js +57 -0
- package/out/renderer/assets/index-vPvXCaIy.css +1 -0
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-CosR91M9.js → infoDiagram-PH2N3AL5-BWXZd-TM.js} +1 -1
- package/out/renderer/assets/{installer-JTz2AD89.js → installer-DjflOef5.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DTj6yC5Y.js → journeyDiagram-U35MCT3I-DKPVvkIm.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-fHLLpfWW.js → kanban-definition-NDS4AKOZ-ChDhsrXv.js} +1 -1
- package/out/renderer/assets/{layout-BUgJgJ17.js → layout-BOqocwgL.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-CSbcJE7R.js → legacy-agents-page-BSdAE-Bg.js} +1 -1
- package/out/renderer/assets/library-page-BHX5kaQb.js +162 -0
- package/out/renderer/assets/{mermaid.core-DXWoCulQ.js → mermaid.core-CWiad1OO.js} +5 -5
- package/out/renderer/assets/{mesh-page-CYwyEdW1.js → mesh-page-BEVPzgDt.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-C_r984Dl.js → mindmap-definition-ALO5MXBD-2i781X8G.js} +1 -1
- package/out/renderer/assets/{mini-B2a0S_aA.js → mini-Bs0TB08-.js} +1 -1
- package/out/renderer/assets/{notebook-pen-BeIeIauS.js → notebook-pen-CcH01r1l.js} +1 -1
- package/out/renderer/assets/{org-access-B4PFRWtx.js → org-access-CJm_anOl.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-OZbS0xfm.js → org-surface-gate-DbysPTcD.js} +1 -1
- package/out/renderer/assets/{page-header-3Jm521kq.js → page-header-ggruiR-O.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-pPG5qJ25.js → pieDiagram-IB7DONF6-B9lioqV6.js} +1 -1
- package/out/renderer/assets/projects-page-ZT73ye5v.js +40 -0
- package/out/renderer/assets/{publication-validation-r9TKDPj_.js → publication-validation-CyRIAFX-.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-LLUiR4wo.js → quadrantDiagram-7GDLP6J5-D2U4lJl9.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-DfSMH1dj.js → radar-MK3ICKWK-CGhy5L8a.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CEuhoAow.js → radient-auth-buttons-DneyxZkw.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DhHfvb40.js → requirementDiagram-KVF5MWMF-Cmc8UYRV.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DURUf6SV.js → sankeyDiagram-QLVOVGJD-B_CbdQsw.js} +1 -1
- package/out/renderer/assets/{schedules-page-DiiamPZ_.js → schedules-page-B4YBOXYX.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DTfgNRPc.js → sequenceDiagram-X6HHIX6F-Bafdaefv.js} +1 -1
- package/out/renderer/assets/{settings-page-C3aXNJLk.js → settings-page-7C4s3Pn-.js} +1 -1
- package/out/renderer/assets/{smartart-Dx8zw2rK.js → smartart-CrK5frje.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-Cp2owgQE.js → stateDiagram-DGXRK772-y86P6pOD.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CqZEeEIQ.js +1 -0
- package/out/renderer/assets/{tags-input-chips-Dwb2Ojmj.js → tags-input-chips-GdqiLTXD.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-112iCByD.js → timeline-definition-BDJGKUSR-QGAbBb-D.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-C6eXGzFs.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-BGMZQ6m9.js → use-download-agent-mutation-DS3LpOcX.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-Bz3KIW6D.js → use-memberships-query-DUb5oPXP.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-C3LrO077.js → use-session-snapshot-C_Px0a_8.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BfqNCG-d.js → xychartDiagram-VJFVF3MP-xB9WOxhm.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +2 -2
- package/out/renderer/assets/browser-page-dbyV2lDa.js +0 -1
- package/out/renderer/assets/channel-DseeJDH6.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-D-Nl2hgf.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-D-Nl2hgf.js +0 -1
- package/out/renderer/assets/clone-DYXRTfEl.js +0 -1
- package/out/renderer/assets/index-BqKNVosC.js +0 -57
- package/out/renderer/assets/index-C6uEPUVY.js +0 -829
- package/out/renderer/assets/index-CU8sWhx0.css +0 -1
- package/out/renderer/assets/library-page-97CGidrj.js +0 -162
- package/out/renderer/assets/projects-page-UaamBIPv.js +0 -40
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DD26TncZ.js +0 -1
- package/out/renderer/assets/ui-preferences-store-CfAtSgON.js +0 -1
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./smartart-Dx8zw2rK.js","./index-BqKNVosC.js","./index-CU8sWhx0.css","./index-C6uEPUVY.js","./conversation-input-sync-Csq2qdm5.js","./ui-preferences-store-CfAtSgON.js","./error-boundary-D1EdrZoj.js","./conversation-input-sync-CAX4_ErH.css","./console-mirror-BThuJoo1.js","./console-mirror-DOrYoP_4.css","./index-DHKnfVbX.css","./page-header-3Jm521kq.js","./tags-input-chips-Dwb2Ojmj.js","./arrow-up-Di0VTM6O.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as z,j as f,t as j,c as We}from"./index-BqKNVosC.js";import{bb as zt,h as xt,bc as En,aK as kn,bd as ht,be as ei,bf as ti,bg as ni,bh as si,bi as ii,aZ as Rn,bj as ri,bk as oi,b5 as ai,bl as Dt,bm as li,bn as ci,bo as fs}from"./index-C6uEPUVY.js";import{bU as di,bV as In,bW as ui,bX as fi,bY as hi,u as lt,aK as Be,bZ as Oe,d as Fe,C as xn,b_ as hs,D as Yt,aW as pi,b$ as hn,c0 as gi,c1 as mi,aP as rt,aL as pn,a4 as Se,c2 as ps,c3 as Nt,c4 as bi,c5 as yi,c6 as vi,c7 as _t,bN as zn,aN as _n,ar as wi,bF as Qt,c8 as gs,bG as Pn,c9 as ki,ca as xi,cb as _i,cc as Pi,cd as Si,bS as Ti,aO as ji,a as Fi,c as Ci,ce as Mi,bE as Ni}from"./conversation-input-sync-Csq2qdm5.js";import{P as Ai}from"./page-header-3Jm521kq.js";import{c as ct,r as ms,m as Lt,s as bs,a as te,t as ys,x as Ce,a5 as $i,a6 as Ei,a7 as Ri,w as Dn,B as st,X as mt,u as Sn,T as Ii,a8 as zi,z as Di,y as Li,S as Ln,A as Bn,I as Bi,h as Oi,a9 as Ui,aa as Gi}from"./error-boundary-D1EdrZoj.js";import"./ui-preferences-store-CfAtSgON.js";import{T as Wi}from"./tags-input-chips-Dwb2Ojmj.js";import{A as qi}from"./arrow-up-Di0VTM6O.js";var Ki=class extends di{constructor(e,n){super(e,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:In()})}getOptimisticResult(e){return e.behavior=In(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,n){const{state:t}=e,s=super.createResult(e,n),{isFetching:i,isRefetching:r,isError:o,isRefetchError:l}=s,a=t.fetchMeta?.fetchMore?.direction,c=o&&a==="forward",u=i&&a==="forward",h=o&&a==="backward",d=i&&a==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:fi(n,t.data),hasPreviousPage:ui(n,t.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:h,isFetchingPreviousPage:d,isRefetchError:l&&!c&&!h,isRefetching:r&&!u&&!d}}};function Xi(e,n){return hi(e,Ki,n)}/**
|
|
3
|
-
* @license lucide-react v0.507.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const Vi=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],On=ct("arrow-down-wide-narrow",Vi);/**
|
|
8
|
-
* @license lucide-react v0.507.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const Hi=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],Yi=ct("arrow-up-narrow-wide",Hi);/**
|
|
13
|
-
* @license lucide-react v0.507.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const Qi=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Zi=ct("hash",Qi);/**
|
|
18
|
-
* @license lucide-react v0.507.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const Ji=[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]],er=ct("presentation",Ji);/**
|
|
23
|
-
* @license lucide-react v0.507.0 - ISC
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the ISC license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const tr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]],nr=ct("sheet",tr);/**
|
|
28
|
-
* @license lucide-react v0.507.0 - ISC
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the ISC license.
|
|
31
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const sr=[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]],ir=ct("tags",sr),rr=["generated","created","mentioned"],Un=[{key:"image",labelKey:"ui.library.category.images",iconKind:"image"},{key:"sound",labelKey:"ui.library.category.sounds",iconKind:"audio"},{key:"document",labelKey:"ui.library.category.documents",iconKind:"markdown"},{key:"presentation",labelKey:"ui.library.category.presentations",iconKind:"pptx"},{key:"video",labelKey:"ui.library.category.video",iconKind:"video"},{key:"spreadsheet",labelKey:"ui.library.category.spreadsheets",iconKind:"spreadsheet"},{key:"code",labelKey:"ui.library.category.code",iconKind:"code"},{key:"other",labelKey:"ui.library.category.other",iconKind:"other"}],or=[{key:"recent",labelKey:"ui.library.sort.recent"},{key:"name",labelKey:"ui.library.sort.name"},{key:"kind",labelKey:"ui.library.sort.kind"},{key:"size",labelKey:"ui.library.sort.size"},{key:"created",labelKey:"ui.library.sort.created"},{key:"modified",labelKey:"ui.library.sort.modified"},{key:"organized",labelKey:"ui.library.sort.organized"}],Bt={q:"",tagMode:"all",highlighted:!1,sort:"recent",order:"desc"};function ar(e){return e==="name"||e==="kind"?"asc":"desc"}function Gn(e,n){return e.status===n}function lr(e){return!!(e.q.trim()||e.category||e.originGroup||e.tag||e.session||e.highlighted||e.status)}function cr(e){if(e==="unorganized")return!1}function Pt(e){return e.name.trim()||e.derived_name.trim()||e.id}function vs(e){const n=e.derived_name.trim();return n?n===e.name.trim()?e.ref.display_path:n:e.ref.display_path}function dr(e){const n=new Map;for(const i of e){const r=i.category||"custom",o=n.get(r);o?o.push(i):n.set(r,[i])}const t=["topic","project","type","source","custom"],s=i=>{const r=t.indexOf(i);return r===-1?t.length:r};return[...n.entries()].sort(([i],[r])=>s(i)-s(r)).map(([i,r])=>({category:i,tags:r}))}function Tn(e){if(!Number.isFinite(e)||e<=0)return"0 B";const n=["B","KB","MB","GB","TB"],t=Math.min(n.length-1,Math.floor(Math.log(e)/Math.log(1024))),s=e/1024**t;return`${s>=10||t===0?Math.round(s):s.toFixed(1)} ${n[t]}`}function ur(e,n){if(!e)return"";const t=n-e*1e3;if(t<6e4)return"just now";const s=Math.floor(t/6e4);if(s<60)return`${s}m ago`;const i=Math.floor(s/60);if(i<24)return`${i}h ago`;const r=Math.floor(i/24);if(r<30)return`${r}d ago`;const o=Math.floor(r/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}function fr(e){if(!e||e<0)return"";const n=Math.round(e),t=Math.floor(n/60),s=n%60;return`${t}:${String(s).padStart(2,"0")}`}function jn(e){switch(e){case"generated":return"ui.library.origin.generated";case"created":return"ui.library.origin.created";case"mentioned":return"ui.library.origin.mentioned";default:return"ui.library.origin.other"}}const Ue={all:["desktop","library"],list:e=>["desktop","library","list",e],detail:e=>["desktop","library","detail",e],tags:["desktop","library","tags"],librarian:["desktop","library","librarian"]},hr=60;function pr(e,n){return{op:"library.list",...e.q.trim()?{q:e.q.trim()}:{},...e.category?{category:e.category}:{},...e.originGroup?{origin_group:e.originGroup}:{},...e.tag?{tag:e.tag}:{},...e.session?{session_id:e.session}:{},...e.tag?{tag_mode:e.tagMode}:{},...e.highlighted?{highlighted:!0}:{},...e.status==="favorite"?{favorite:!0}:{},...(()=>{const t=cr(e.status);return t!==void 0?{organized:t}:{}})(),sort:e.sort,order:e.order,limit:hr,...n?{cursor:n}:{}}}function gr(e,n){return Xi({queryKey:Ue.list(e),enabled:n,initialPageParam:void 0,queryFn:({pageParam:t})=>Fe(pr(e,t)),getNextPageParam:t=>t.next_cursor??void 0,retry:Yt,refetchInterval:t=>t.state.data?.pages.at(-1)?.state==="building"?2e3:!1,staleTime:1e4})}function mr(e,n){return xn({queryKey:Ue.detail(e??""),enabled:n&&!!e,queryFn:()=>Fe({op:"library.get",id:e}),retry:Yt,staleTime:5e3})}function br(e){return xn({queryKey:Ue.tags,enabled:e,queryFn:()=>Fe({op:"library.tags"}),retry:Yt,staleTime:2e4})}function yr(e){return xn({queryKey:Ue.librarian,enabled:e,queryFn:()=>Fe({op:"library.librarian",action:"status"}).then(n=>"librarian"in n?n.librarian:n),retry:Yt,staleTime:3e4})}function qe(e){return e.invalidateQueries({queryKey:Ue.all})}function ws(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.update",id:n.id,fields:n.fields}),onSuccess:n=>(e.setQueryData(Ue.detail(n.id),n),qe(e)),onError:(n,t)=>{e.invalidateQueries({queryKey:Ue.detail(t.id)}),e.invalidateQueries({queryKey:Ue.all})},retry:Oe})}function vr(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.tags.assign",id:n.id,tags:n.tags,...n.primary?{primary:n.primary}:{}}),onSuccess:n=>(e.setQueryData(Ue.detail(n.id),n),qe(e)),onError:()=>qe(e),retry:Oe})}function wr(){const e=lt(),n=()=>qe(e),t=Be({mutationFn:o=>Fe({op:"library.tags.create",name:o.name,...o.category?{category:o.category}:{}}),onSuccess:n,retry:Oe}),s=Be({mutationFn:o=>Fe({op:"library.tags.update",id:o.id,...o.name!==void 0?{name:o.name}:{},...o.category!==void 0?{category:o.category}:{}}),onSuccess:n,retry:Oe}),i=Be({mutationFn:o=>Fe({op:"library.tags.delete",id:o.id}),onSuccess:n,retry:Oe}),r=Be({mutationFn:o=>Fe({op:"library.tags.merge",id:o.id,into:o.into}),onSuccess:n,retry:Oe});return{create:t,update:s,remove:i,merge:r}}function kr(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.chat.link",id:n.id,sessionId:n.sessionId}),onSuccess:()=>qe(e),onError:()=>qe(e),retry:Oe})}function xr(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.chat.clear",id:n.id}),onSuccess:()=>qe(e),retry:Oe})}function _r(){const e=lt();return Be({mutationFn:n=>Fe({op:"library.librarian",action:n}).then(t=>"librarian"in t?t.librarian:t),onSuccess:()=>qe(e),retry:Oe})}function Je(e,n,t,s=!1){const[i,r]=z.useState({bytes:null,mimeType:"",error:null,loading:!1});return z.useEffect(()=>{if(!t||!e){r({bytes:null,mimeType:"",error:null,loading:!1});return}let o=!1;return r({bytes:null,mimeType:"",error:null,loading:!0}),hs(n==="thumbnail"?{op:"library.thumbnail",assetId:e,width:480}:{op:"library.content",assetId:e,download:s},null).then(a=>{if(!o){if(a.kind==="bytes"){r({bytes:a.data,mimeType:a.mimeType,error:null,loading:!1});return}r({bytes:null,mimeType:"",error:a.kind==="error"?a.detail:"This preview could not be loaded.",loading:!1})}}),()=>{o=!0}},[e,n,t,s]),i}function Fn(e,n){const[t,s]=z.useState(null);return z.useEffect(()=>{if(!e){s(null);return}const i=new Blob([e],{type:n||"application/octet-stream"}),r=URL.createObjectURL(i);return s(r),()=>URL.revokeObjectURL(r)},[e,n]),t}const Pr=/[\\/]/;function Sr(e){const t=Pt(e).split(Pr).pop()||e.id;if(t.includes("."))return t;const s=e.ref.display_path||e.ref.path||"",i=s.includes(".")?s.slice(s.lastIndexOf(".")):"";return`${t}${i}`}async function ot(e){const n=await hs({op:"library.content",assetId:e.id,download:!0},null);if(n.kind!=="bytes")throw new Error(n.kind==="error"?n.detail:"The asset content could not be read.");const t=new Blob([n.data],{type:e.ref.content_type||n.mimeType||"application/octet-stream"}),s=URL.createObjectURL(t),i=document.createElement("a");i.href=s,i.download=Sr(e),i.rel="noopener",document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(s),3e4)}const Cn=({asset:e,onAsk:n,onEditMetadata:t,onEditTags:s,onToggleFavorite:i,onOpenConversation:r,onFilterSession:o,triggerClassName:l})=>{const a=async(d,p)=>{try{await navigator.clipboard.writeText(d),pn(p)}catch{Se(j("ui.library.menu.copy_failed"))}},c=async()=>{try{await ot(e),pn(j("ui.library.menu.saved_a_copy"))}catch{Se(j("ui.library.menu.save_failed"))}},u=!!(e.ref.type==="path"&&e.ref.path),h=e.occurrences;return f.jsxs(ms,{children:[f.jsx(Lt,{content:j("ui.library.menu.asset_actions"),children:f.jsx(bs,{asChild:!0,children:f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.menu.asset_actions_label",{name:e.name||e.derived_name}),className:l,onClick:d=>d.stopPropagation(),"data-library-asset-menu":"",children:f.jsx(pi,{"aria-hidden":"true"})})})}),f.jsxs(ys,{align:"end",className:"min-w-52",onClick:d=>d.stopPropagation(),children:[h.length===1?f.jsxs(Ce,{onSelect:()=>r(h[0].session_id),children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.open_source_conversation")})]}):h.length>1?f.jsxs($i,{children:[f.jsxs(Ei,{children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.open_source_conversation")})]}),f.jsx(Ri,{className:"min-w-60",children:h.map(d=>f.jsx(Ce,{onSelect:()=>r(d.session_id),children:f.jsx("span",{className:"truncate",children:d.session_title||d.session_id})},`${d.session_id}:${d.first_seq}`))})]}):null,f.jsxs(Ce,{onSelect:n,children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.ask_about_asset")})]}),h.length>0&&f.jsxs(Ce,{onSelect:()=>o(h[0].session_id),children:[f.jsx(hn,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.show_from_conversation")})]}),f.jsx(Dn,{}),f.jsxs(Ce,{onSelect:i,children:[f.jsx(xt,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0}),f.jsx("span",{children:e.favorite?j("ui.library.menu.unfavorite"):j("ui.library.menu.favorite")})]}),f.jsxs(Ce,{onSelect:t,children:[f.jsx(gi,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.edit_metadata")})]}),f.jsxs(Ce,{onSelect:s,children:[f.jsx(ir,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.edit_tags")})]}),f.jsx(Dn,{}),e.ref.path?f.jsxs(Ce,{onSelect:()=>void a(e.ref.path,j("ui.library.menu.path_copied")),children:[f.jsx(mi,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.copy_path")})]}):null,f.jsxs(Ce,{onSelect:()=>void a(e.id,j("ui.library.menu.asset_id_copied")),children:[f.jsx(Zi,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.copy_asset_id")})]}),u?f.jsxs(Ce,{onSelect:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(hn,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.reveal_in_finder")})]}):f.jsxs(Ce,{onSelect:()=>void c(),children:[f.jsx(rt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.download")})]}),e.ref.type==="artifact"&&f.jsxs(Ce,{onSelect:()=>void c(),children:[f.jsx(rt,{"aria-hidden":"true"}),f.jsx("span",{children:j("ui.library.menu.save_a_copy")})]})]})]})},Tr={image:vi,audio:yi,video:bi,pdf:Nt,pptx:er,docx:Nt,markdown:Nt,html:En,spreadsheet:nr,text:Nt,code:En,other:ps};function jr(e){return Tr[e]??ps}function dt({kind:e,size:n=20,className:t}){const s=jr(e);return f.jsx(s,{size:n,"aria-hidden":"true",className:t})}const ks=({group:e})=>f.jsx(st,{variant:e==="generated"?"accent":"neutral",children:j(jn(e))}),xs=({asset:e,large:n=!1})=>{const t=e.kind==="image"&&e.exists,s=Je(e.id,"thumbnail",t),i=Fn(s.bytes,s.mimeType);return f.jsx("div",{className:We("relative flex shrink-0 items-center justify-center overflow-hidden bg-canvas",n?"aspect-[16/10] w-full":"h-24 w-32"),children:i?f.jsx("img",{src:i,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(dt,{kind:e.kind,size:n?28:22,className:"text-ink-dim"})})},Fr=()=>f.jsx("span",{className:"absolute top-1.5 left-1.5 flex size-5 items-center justify-center rounded-full bg-elevated",title:j("ui.library.card.highlighted"),children:f.jsx(xt,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),_s=({asset:e})=>{if(e.tags.length===0)return null;const n=e.tags.slice(0,2);return f.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[n.map(t=>f.jsx(st,{variant:"outline",children:t.name},t.id)),e.tags.length>n.length&&f.jsxs("span",{className:"text-meta text-ink-dim",children:["+",e.tags.length-n.length]})]})},Cr=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:We("group relative flex flex-col overflow-hidden rounded-lg border border-hairline bg-surface",n&&kn),children:[f.jsxs("button",{type:"button",onClick:()=>t.onSelect(e.id),"aria-pressed":n,className:"flex w-full flex-col text-left focus-visible:outline-offset-2",children:[f.jsxs("div",{className:"relative",children:[f.jsx(xs,{asset:e,large:!0}),e.highlighted&&f.jsx(Fr,{}),f.jsx("div",{className:"absolute top-1.5 right-1.5"})]}),f.jsxs("div",{className:"flex w-full flex-col gap-1 p-3",children:[f.jsx("span",{className:"line-clamp-1 text-body-sm font-medium text-ink",children:Pt(e)}),f.jsx("span",{className:"line-clamp-1 text-meta text-ink-dim",children:vs(e)}),f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx("span",{className:"truncate",children:e.kind}),f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:Tn(e.size_bytes)}),e.duration_s?f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:fr(e.duration_s)})]}):null]}),f.jsx(_s,{asset:e}),e.occurrences[0]?.session_title&&f.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-meta text-ink-dim",children:[f.jsx(zt,{size:12,"aria-hidden":"true"}),f.jsx("span",{className:"truncate",children:e.occurrences[0].session_title})]}),f.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[f.jsx(ks,{group:e.origin_group}),e.session_count>1&&f.jsx("span",{className:"text-meta text-ink-dim",children:j("ui.library.card.conversations",{count:e.session_count})})]})]})]}),f.jsx("div",{className:"invisible absolute top-1.5 right-1.5 group-focus-within:visible group-hover:visible [@media(pointer:coarse)]:visible",children:f.jsx(Cn,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession,triggerClassName:"bg-elevated"})})]}),Mr=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:We("group relative flex items-center gap-3 rounded-md border border-hairline bg-surface px-3 py-2",n&&kn),children:[f.jsxs("button",{type:"button",onClick:()=>t.onSelect(e.id),"aria-pressed":n,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[f.jsx(xs,{asset:e}),f.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[f.jsxs("span",{className:"flex items-center gap-1.5 truncate text-body-sm font-medium text-ink",children:[e.highlighted&&f.jsx(xt,{size:12,"aria-hidden":"true",className:"shrink-0 fill-current text-accent"}),Pt(e)]}),f.jsx("span",{className:"truncate text-meta text-ink-dim",children:vs(e)})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-meta text-ink-muted",children:[f.jsx(_s,{asset:e}),f.jsx("span",{children:e.kind}),f.jsx("span",{children:Tn(e.size_bytes)}),f.jsx(ks,{group:e.origin_group})]})]}),f.jsx(Cn,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession})]}),Nr=({assets:e,selectedId:n,view:t,hasMore:s,loadingMore:i,onLoadMore:r,...o})=>{const l=z.useRef(null);return z.useEffect(()=>{const a=l.current;if(!a||!s)return;const c=new IntersectionObserver(u=>{u.some(h=>h.isIntersecting)&&r()},{rootMargin:"600px 0px"});return c.observe(a),()=>c.disconnect()},[s,r,e.length]),f.jsxs("div",{className:"flex flex-col gap-4",children:[t==="grid"?f.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(208px,1fr))] gap-4",children:e.map(a=>f.jsx(Cr,{asset:a,selected:a.id===n,...o},a.id))}):f.jsx("div",{className:"flex flex-col gap-1.5",children:e.map(a=>f.jsx(Mr,{asset:a,selected:a.id===n,...o},a.id))}),f.jsxs("div",{ref:l,className:"flex justify-center py-6",children:[i&&f.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[f.jsx(_t,{size:14,"aria-hidden":"true",className:"motion-safe:animate-spin"}),j("ui.library.grid.loading_more")]}),!i&&s&&f.jsx(te,{variant:"ghost",size:"sm",onClick:r,children:j("ui.library.grid.load_more")})]})]})},Ar=({view:e})=>e==="list"?f.jsx("div",{className:"flex flex-col gap-1.5","aria-hidden":"true","data-library-skeleton":"",children:Array.from({length:8},(n,t)=>f.jsxs("div",{className:"flex h-28 items-center gap-3 rounded-md border border-hairline bg-surface px-3",children:[f.jsx("div",{className:"h-24 w-32 rounded-sm bg-sunken"}),f.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[f.jsx("div",{className:"h-3 w-1/3 rounded-xs bg-sunken"}),f.jsx("div",{className:"h-3 w-1/2 rounded-xs bg-sunken"})]})]},t))}):f.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(208px,1fr))] gap-4","aria-hidden":"true","data-library-skeleton":"",children:Array.from({length:12},(n,t)=>f.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-hairline bg-surface",children:[f.jsx("div",{className:"aspect-[16/10] bg-sunken"}),f.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[f.jsx("div",{className:"h-3 w-2/3 rounded-xs bg-sunken"}),f.jsx("div",{className:"h-3 w-1/2 rounded-xs bg-sunken"}),f.jsx("div",{className:"h-3 w-1/3 rounded-xs bg-sunken"})]})]},t))}),$r=[{key:"highlighted",labelKey:"ui.library.status.highlighted"},{key:"unorganized",labelKey:"ui.library.status.unorganized"},{key:"favorite",labelKey:"ui.library.status.favorites"}],et=({label:e,count:n,active:t,onPress:s,icon:i,indent:r=!1})=>f.jsxs("button",{type:"button",onClick:s,"aria-pressed":t,className:We("flex h-7 w-full items-center gap-2 rounded-md px-2 text-left text-body-sm",r&&"pl-6",t?kn:"text-ink-muted hover:bg-row-hover hover:text-ink"),children:[i,f.jsx("span",{className:"min-w-0 flex-1 truncate",children:e}),n!==void 0&&f.jsx("span",{className:"text-meta tabular-nums text-ink-dim",children:n})]}),At=({label:e,children:n})=>f.jsxs("section",{className:"flex flex-col gap-1",children:[f.jsx("h3",{className:"px-2 text-meta font-medium tracking-wide text-ink-dim",children:e}),f.jsx("div",{className:"flex flex-col gap-0.5",children:n})]}),Er=({filters:e,onChange:n,counts:t,tags:s,total:i})=>{const r=dr(s),o=t?.category??{},l=c=>n({...e,...c}),a=!!(e.category||e.originGroup||e.status||e.tag||e.session||e.highlighted);return f.jsxs("div",{className:"flex h-full flex-col gap-5 overflow-y-auto px-2 py-4","data-library-filter-rail":"",children:[a&&f.jsxs(te,{variant:"ghost",size:"sm",className:"justify-start",onClick:()=>n({...e,category:void 0,originGroup:void 0,status:void 0,tag:void 0,session:void 0,highlighted:!1}),children:[f.jsx(mt,{"aria-hidden":"true"}),j("ui.library.filter.clear_filters")]}),e.session&&f.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-sunken px-2 py-1.5 text-meta text-ink-muted",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate",children:j("ui.library.filter.one_conversation")}),f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.filter.clear_conversation"),onClick:()=>l({session:void 0}),children:f.jsx(mt,{"aria-hidden":"true"})})]}),f.jsxs(At,{label:j("ui.library.filter.categories"),children:[f.jsx(et,{label:j("ui.library.category.all"),count:i,active:!e.category,onPress:()=>l({category:void 0})}),Un.map(c=>f.jsx(et,{label:j(c.labelKey),count:o[c.key]??0,active:e.category===c.key,onPress:()=>l({category:e.category===c.key?void 0:c.key}),icon:f.jsx(dt,{kind:c.iconKind,size:14,className:"text-ink-dim"})},c.key)),Object.keys(o).filter(c=>!Un.some(u=>u.key===c)).sort().map(c=>f.jsx(et,{label:c,count:o[c],active:e.category===c,onPress:()=>l({category:e.category===c?void 0:c}),icon:f.jsx(zn,{size:14,"aria-hidden":"true"})},c))]}),f.jsx(At,{label:j("ui.library.filter.status"),children:$r.map(c=>f.jsx(et,{label:j(c.labelKey),active:Gn(e,c.key),onPress:()=>l({status:Gn(e,c.key)?void 0:c.key}),icon:c.key==="favorite"||c.key==="highlighted"?f.jsx(xt,{size:14,"aria-hidden":"true"}):void 0},c.key))}),f.jsx(At,{label:j("ui.library.filter.source"),children:rr.map(c=>f.jsx(et,{label:j(jn(c)),count:t?.origin_group?.[c]??0,active:e.originGroup===c,onPress:()=>l({originGroup:e.originGroup===c?void 0:c})},c))}),r.length>0&&f.jsx(At,{label:j("ui.library.filter.tags"),children:r.map(c=>f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"px-2 pt-1 text-meta text-ink-dim",children:c.category}),c.tags.map(u=>f.jsx(et,{label:u.name,count:u.count??0,active:e.tag===u.id,onPress:()=>l({tag:e.tag===u.id?void 0:u.id}),icon:f.jsx(zn,{size:13,"aria-hidden":"true"}),indent:!0},u.id))]},c.category))}),e.tag&&f.jsx(st,{variant:"neutral",children:j("ui.library.filter.tag_mode",{mode:e.tagMode.toUpperCase()})})]})},Rr=new Set(["image/png","image/jpeg","image/gif","image/webp"]),Ir=1e6;function zr(e){let n="";for(let s=0;s<e.length;s+=32768)n+=String.fromCharCode(...e.subarray(s,Math.min(s+32768,e.length)));return btoa(n)}function Dr(e){const n=e.ref.display_path||e.ref.path||(e.ref.digest?`attachment digest ${e.ref.digest}`:e.id);return`${Pt(e)} (${n})`}const Lr=({asset:e,focusSignal:n,compact:t=!1})=>{Sn();const s=_n(),i=z.useRef(null),r=()=>{const k=i.current;k&&(k.style.height="24px",k.style.height=`${Math.min(72,Math.max(24,k.scrollHeight))}px`)},[o,l]=z.useState(""),[a,c]=z.useState(!1),[u,h]=z.useState({}),[d,p]=z.useState(null),g=u[e.id]??null,b=d===e.id,_=kr(),y=xr(),w=Je(e.id,"content",e.kind==="image");z.useEffect(()=>{l("")},[e.id]),z.useEffect(()=>{n!==0&&i.current?.focus()},[n]);const x=async()=>{const k=o.trim();if(!(!k||a)){c(!0);try{const S=wi.getState();let N=e.chat?.session_id??g??null;if(!N&&(N=await S.createSession(S.cwd||"~"),!N))throw new Error(S.error??j("ui.library.composer.could_not_start"));const M={op:"sessions.message",sessionId:N,requestId:crypto.randomUUID(),text:`${k}
|
|
33
|
-
|
|
34
|
-
${Dr(e)}`},F=e.ref.content_type||w.mimeType;if(e.kind==="image"&&w.bytes&&Rr.has(F)){const T=zr(w.bytes);T.length<=Ir&&(M.images=[{data_b64:T,mime_type:F}])}if(await Fe(M),l(""),!e.chat&&!g)try{await _.mutateAsync({id:e.id,sessionId:N})}catch(T){h($=>({...$,[e.id]:N})),p(e.id),Se(T instanceof Error&&T.message?j("ui.library.composer.link_failed",{message:T.message}):j("ui.library.composer.link_failed_short"));return}if(g)try{await _.mutateAsync({id:e.id,sessionId:N}),h(T=>{const $={...T};return delete $[e.id],$}),p(null)}catch{p(e.id),Se(j("ui.library.composer.link_failed_short"));return}await ht(s,N)}catch(S){Se(S instanceof Error&&S.message?S.message:j("ui.library.composer.not_sent"))}finally{c(!1)}}},P=e.chat,v=async()=>{const k=g??e.chat?.session_id;if(k)try{await _.mutateAsync({id:e.id,sessionId:k}),h(S=>{const N={...S};return delete N[e.id],N}),p(null)}catch{Se(j("ui.library.composer.link_failed_short"))}};return f.jsxs("div",{className:We("mx-auto flex w-[min(calc(100%-24px),720px)] flex-col justify-end gap-2 pb-4",t?"h-38":"h-44"),"data-library-composer":"",children:[b&&g&&f.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md bg-sunken px-2 py-1 text-meta text-ink","data-library-link-failed":"",children:[f.jsx("span",{className:"min-w-0 flex-1",children:j("ui.library.composer.message_sent_link_failed")}),f.jsx(te,{variant:"ghost",size:"sm",onClick:()=>void v(),children:j("ui.library.composer.retry_link")}),f.jsx(te,{variant:"ghost",size:"sm",onClick:()=>void ht(s,g),children:j("ui.library.composer.open_chat")})]}),P&&f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx(ei,{size:13,"aria-hidden":"true"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:j("ui.library.composer.chat_about",{title:P.title||P.session_id})}),f.jsx(te,{variant:"ghost",size:"sm",onClick:()=>void ht(s,P.session_id),children:j("ui.library.composer.open_chat")}),f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.composer.unlink"),onClick:()=>y.mutate({id:e.id}),children:f.jsx(mt,{"aria-hidden":"true"})})]}),f.jsxs("div",{"data-glass-region":"composer",className:We("flex items-end gap-2 rounded-lg bg-elevated p-2","focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-accent"),children:[f.jsx(Ii,{ref:i,rows:1,value:o,onChange:k=>{l(k.target.value),r()},onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),x())},placeholder:P?j("ui.library.composer.continue_placeholder"):j("ui.library.composer.ask_placeholder"),"aria-label":j("ui.library.composer.label"),className:"h-6 min-h-6 max-h-18 resize-none overflow-y-auto border-0 bg-transparent px-0 py-0 text-body leading-6 shadow-none focus-visible:outline-none"}),f.jsx(te,{variant:"primary",size:"icon-sm",disabled:!o.trim()||a,"aria-label":j("ui.library.composer.send"),onClick:()=>void x(),children:a?f.jsx(_t,{"aria-hidden":"true",className:"motion-safe:animate-spin"}):f.jsx(qi,{"aria-hidden":"true"})})]})]})};function Br(e,n,t){return{id:`library:${e.id}`,title:e.name.trim()||e.derived_name||e.ref.path||e.id,path:e.ref.path??"",content:n,type:"markdown",readMtimeMs:t??void 0,sizeBytes:e.size_bytes,availability:"present"}}async function Ps(e){const n=e instanceof Uint8Array?e:new Uint8Array(e),t=new DataView(n.buffer,n.byteOffset,n.byteLength),s=101010256,i=101075792,r=117853008;let o=-1;const l=Math.max(0,n.length-65557);for(let g=n.length-22;g>=l;g--)if(t.getUint32(g,!0)===s){o=g;break}if(o===-1)throw new Error("Not a valid ZIP file: EOCD not found");let a,c;const u=o-20;if(u>=0&&t.getUint32(u,!0)===r){const g=Number(t.getBigUint64(u+8,!0));if(t.getUint32(g,!0)!==i)throw new Error("Invalid ZIP64 end record");a=Number(t.getBigUint64(g+48,!0)),c=Number(t.getBigUint64(g+32,!0))}else a=t.getUint32(o+16,!0),c=t.getUint16(o+8,!0);if(a+4>n.length)throw new Error("ZIP central directory offset is outside the file");const h=33639248,d={};let p=a;for(let g=0;g<c&&!(p+46>n.length||t.getUint32(p,!0)!==h);g++){const b=t.getUint16(p+10,!0);let _=t.getUint32(p+20,!0),y=t.getUint32(p+24,!0);const w=t.getUint16(p+28,!0),x=t.getUint16(p+30,!0),P=t.getUint16(p+32,!0);let v=t.getUint32(p+42,!0);const k=Ur(n,p+46,w);if(_===4294967295||y===4294967295||v===4294967295){const T=p+46+w,$=T+x;let L=T;for(;L+4<=$;){const G=t.getUint16(L,!0),q=t.getUint16(L+2,!0);if(G===1){let B=L+4;y===4294967295&&B+8<=$&&(y=Number(t.getBigUint64(B,!0)),B+=8),_===4294967295&&B+8<=$&&(_=Number(t.getBigUint64(B,!0)),B+=8),v===4294967295&&B+8<=$&&(v=Number(t.getBigUint64(B,!0)));break}L+=4+q}}if(p+=46+w+x+P,k.endsWith("/")||b!==0&&b!==8||v+30>n.length)continue;const S=t.getUint16(v+26,!0),N=t.getUint16(v+28,!0),M=v+30+S+N;if(M+_>n.length)continue;const F=n.subarray(M,M+_);try{d[k]=b===0?F.slice():await Or(F)}catch(T){console.warn(`[zip.js] Failed to decompress "${k}":`,T.message)}}return d}async function Or(e){const n=new DecompressionStream("deflate-raw"),t=n.writable.getWriter(),s=n.readable.getReader();t.write(e),t.close();const i=[];let r=0;for(;;){const{value:a,done:c}=await s.read();if(c)break;i.push(a),r+=a.length}const o=new Uint8Array(r);let l=0;for(const a of i)o.set(a,l),l+=a.length;return o}function Ur(e,n,t){return new TextDecoder().decode(e.subarray(n,n+t))}function ke(e){return new DOMParser().parseFromString(e,"application/xml")}function ce(e,n){if(!e)return[];const t=[],s=e.getElementsByTagName("*");for(let i=0;i<s.length;i++)s[i].localName===n&&t.push(s[i]);return t}function m(e,n){return ce(e,n)[0]??null}function D(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function C(e,n,t=0){const s=D(e,n);return s!==null?parseInt(s,10):t}function Ie(e,n,t){return Math.max(n,Math.min(t,e))}const bt=12700,Gr=Object.freeze(Object.defineProperty({__proto__:null,EMU_PER_PT:bt,attr:D,attrInt:C,clamp:Ie,g1:m,gtn:ce,parseXml:ke},Symbol.toStringTag,{value:"Module"}));function Wr(e){if(!e)return{colors:{},majorFont:"Calibri Light",minorFont:"Calibri"};const n=m(e,"clrScheme"),t={};if(n){const o=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];for(const l of o){const a=m(n,l);if(!a)continue;const c=m(a,"srgbClr"),u=m(a,"sysClr");c?t[l]=c.getAttribute("val")||"":u&&(t[l]=u.getAttribute("lastClr")||"")}}const s=m(e,"fontScheme");let i="Calibri Light",r="Calibri";if(s){const o=m(s,"majorFont"),l=m(s,"minorFont");if(o){const a=m(o,"latin");a&&(i=a.getAttribute("typeface")||i)}if(l){const a=m(l,"latin");a&&(r=a.getAttribute("typeface")||r)}}return{colors:t,majorFont:i,minorFont:r}}function qr(e){if(!e)return{};const n=m(e,"clrMap");if(!n)return{};const t={},s=["bg1","tx1","bg2","tx2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];for(const i of s){const r=n.getAttribute(i);r&&(t[i]=r)}return t}function Kr(e,n){const t={...e.colors};for(const[s,i]of Object.entries(n))t[i]!==void 0&&(t[s]=t[i]);return t}const it={calibri:{google:"Carlito",weights:[400,700],generic:"sans-serif"},"calibri light":{google:"Carlito",weights:[300],generic:"sans-serif"},"calibri (body)":{google:"Carlito",weights:[400,700],generic:"sans-serif"},cambria:{google:"Caladea",weights:[400,700],generic:"serif"},"cambria math":{google:"Caladea",weights:[400],generic:"serif"},aptos:{google:"Inter",weights:[300,400,600,700],generic:"sans-serif"},"aptos display":{google:"Inter",weights:[700,800],generic:"sans-serif"},"aptos narrow":{google:"Inter",weights:[400,700],generic:"sans-serif"},"aptos serif":{google:"Lora",weights:[400,700],generic:"serif"},"aptos mono":{google:"Roboto Mono",weights:[400,700],generic:"monospace"},arial:{google:null,weights:[],generic:"sans-serif"},"arial black":{google:null,weights:[],generic:"sans-serif"},"times new roman":{google:null,weights:[],generic:"serif"},times:{google:null,weights:[],generic:"serif"},helvetica:{google:null,weights:[],generic:"sans-serif"},verdana:{google:null,weights:[],generic:"sans-serif"},tahoma:{google:null,weights:[],generic:"sans-serif"},"trebuchet ms":{google:null,weights:[],generic:"sans-serif"},georgia:{google:null,weights:[],generic:"serif"},"courier new":{google:null,weights:[],generic:"monospace"},courier:{google:null,weights:[],generic:"monospace"},impact:{google:null,weights:[],generic:"sans-serif"},"comic sans ms":{google:null,weights:[],generic:"cursive"},palatino:{google:null,weights:[],generic:"serif"},"lucida console":{google:null,weights:[],generic:"monospace"},"lucida sans unicode":{google:null,weights:[],generic:"sans-serif"},"arial narrow":{google:"Arimo",weights:[400,700],generic:"sans-serif"},candara:{google:"Nunito",weights:[300,400,700],generic:"sans-serif"},consolas:{google:"Roboto Mono",weights:[400,700],generic:"monospace"},constantia:{google:"Libre Baskerville",weights:[400,700],generic:"serif"},corbel:{google:"Lato",weights:[300,400,700],generic:"sans-serif"},"franklin gothic medium":{google:"Libre Franklin",weights:[500],generic:"sans-serif"},"franklin gothic book":{google:"Libre Franklin",weights:[400],generic:"sans-serif"},"franklin gothic heavy":{google:"Libre Franklin",weights:[800],generic:"sans-serif"},"gill sans mt":{google:"Quattrocento Sans",weights:[400,700],generic:"sans-serif"},"gill sans":{google:"Quattrocento Sans",weights:[400,700],generic:"sans-serif"},"century gothic":{google:"Josefin Sans",weights:[300,400,700],generic:"sans-serif"},"century schoolbook":{google:"EB Garamond",weights:[400,700],generic:"serif"},garamond:{google:"EB Garamond",weights:[400,700],generic:"serif"},"palatino linotype":{google:"EB Garamond",weights:[400,700],generic:"serif"},"book antiqua":{google:"EB Garamond",weights:[400,700],generic:"serif"},rockwell:{google:"Roboto Slab",weights:[400,700],generic:"serif"},"rockwell extra bold":{google:"Roboto Slab",weights:[800],generic:"serif"},"segoe ui":{google:"Inter",weights:[300,400,600,700],generic:"sans-serif"},"segoe ui light":{google:"Inter",weights:[300],generic:"sans-serif"},"segoe ui semibold":{google:"Inter",weights:[600],generic:"sans-serif"},"segoe ui semilight":{google:"Inter",weights:[350],generic:"sans-serif"},"helvetica neue":{google:"Nunito Sans",weights:[300,400,700],generic:"sans-serif"},"myriad pro":{google:"Source Sans 3",weights:[300,400,600,700],generic:"sans-serif"},futura:{google:"Josefin Sans",weights:[300,400,700],generic:"sans-serif"},"tw cen mt":{google:"Pathway Gothic One",weights:[400],generic:"sans-serif"},"bookman old style":{google:"Libre Baskerville",weights:[400,700],generic:"serif"},frutiger:{google:"Raleway",weights:[300,400,700],generic:"sans-serif"},optima:{google:"Questrial",weights:[400],generic:"sans-serif"},univers:{google:"Nunito Sans",weights:[300,400,700],generic:"sans-serif"},"open sans":{google:"Open Sans",weights:[300,400,600,700],generic:"sans-serif"},lato:{google:"Lato",weights:[300,400,700],generic:"sans-serif"},montserrat:{google:"Montserrat",weights:[300,400,600,700],generic:"sans-serif"},raleway:{google:"Raleway",weights:[300,400,700],generic:"sans-serif"},roboto:{google:"Roboto",weights:[300,400,700],generic:"sans-serif"},"roboto mono":{google:"Roboto Mono",weights:[400,700],generic:"monospace"},"roboto slab":{google:"Roboto Slab",weights:[300,400,700],generic:"serif"},oswald:{google:"Oswald",weights:[400,700],generic:"sans-serif"},"playfair display":{google:"Playfair Display",weights:[400,700],generic:"serif"},merriweather:{google:"Merriweather",weights:[300,400,700],generic:"serif"},nunito:{google:"Nunito",weights:[300,400,700],generic:"sans-serif"},"nunito sans":{google:"Nunito Sans",weights:[300,400,700],generic:"sans-serif"},poppins:{google:"Poppins",weights:[300,400,600,700],generic:"sans-serif"},inter:{google:"Inter",weights:[300,400,600,700],generic:"sans-serif"},"work sans":{google:"Work Sans",weights:[300,400,600,700],generic:"sans-serif"},"dm sans":{google:"DM Sans",weights:[300,400,500,700],generic:"sans-serif"},"dm serif display":{google:"DM Serif Display",weights:[400],generic:"serif"},ubuntu:{google:"Ubuntu",weights:[300,400,700],generic:"sans-serif"},"ubuntu mono":{google:"Ubuntu Mono",weights:[400,700],generic:"monospace"},"source sans pro":{google:"Source Sans 3",weights:[300,400,600,700],generic:"sans-serif"},"source serif pro":{google:"Source Serif 4",weights:[300,400,700],generic:"serif"},"source code pro":{google:"Source Code Pro",weights:[400,700],generic:"monospace"},"exo 2":{google:"Exo 2",weights:[300,400,700],generic:"sans-serif"},"titillium web":{google:"Titillium Web",weights:[300,400,600,700],generic:"sans-serif"},"fira sans":{google:"Fira Sans",weights:[300,400,600,700],generic:"sans-serif"},"fira mono":{google:"Fira Mono",weights:[400,700],generic:"monospace"},"josefin sans":{google:"Josefin Sans",weights:[300,400,700],generic:"sans-serif"},"josefin slab":{google:"Josefin Slab",weights:[300,400,700],generic:"serif"},barlow:{google:"Barlow",weights:[300,400,600,700],generic:"sans-serif"},"barlow condensed":{google:"Barlow Condensed",weights:[300,400,600,700],generic:"sans-serif"},cabin:{google:"Cabin",weights:[400,700],generic:"sans-serif"},"crimson text":{google:"Crimson Text",weights:[400,700],generic:"serif"},"libre baskerville":{google:"Libre Baskerville",weights:[400,700],generic:"serif"},"libre franklin":{google:"Libre Franklin",weights:[400,700],generic:"sans-serif"},"eb garamond":{google:"EB Garamond",weights:[400,700],generic:"serif"},spectral:{google:"Spectral",weights:[300,400,700],generic:"serif"},arvo:{google:"Arvo",weights:[400,700],generic:"serif"},"pt sans":{google:"PT Sans",weights:[400,700],generic:"sans-serif"},"pt serif":{google:"PT Serif",weights:[400,700],generic:"serif"},"pt mono":{google:"PT Mono",weights:[400],generic:"monospace"},karla:{google:"Karla",weights:[300,400,700],generic:"sans-serif"},mukta:{google:"Mukta",weights:[300,400,700],generic:"sans-serif"},hind:{google:"Hind",weights:[300,400,700],generic:"sans-serif"},"noto sans":{google:"Noto Sans",weights:[300,400,700],generic:"sans-serif"},"noto serif":{google:"Noto Serif",weights:[300,400,700],generic:"serif"}},Ot=new Set,yt=new Map,Ut=new Set;let Wn=null,un=null;function Xr(){return un||(Wn=typeof OffscreenCanvas<"u"?new OffscreenCanvas(300,10):Object.assign(document.createElement("canvas"),{width:300,height:10}),un=Wn.getContext("2d")),un}const qn="mmmmmmmmmmlllllllllliiiiiiiiiixxxxxxxxxx",Vr=[20,40];function Ss(e){if(Ut.has(e))return!0;if(typeof document<"u"&&document.fonts&&document.fonts.check(`16px "${e}"`))return Ut.add(e),!0;try{const n=Xr(),t=["monospace","serif"];for(const s of Vr)for(const i of t){n.font=`${s}px ${i}`;const r=n.measureText(qn).width;n.font=`${s}px "${e}", ${i}`;const o=n.measureText(qn).width;if(Math.abs(o-r)>.5)return Ut.add(e),!0}}catch{}return!1}async function gn(e,n,t={}){let s;if(typeof n=="string"||n instanceof URL)s=n.toString();else if(n instanceof File||n instanceof Blob)s=await n.arrayBuffer();else if(n instanceof Uint8Array)s=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);else if(n instanceof ArrayBuffer)s=n;else throw new TypeError("registerFont: unsupported source type. Expected string, URL, File, Blob, ArrayBuffer, or Uint8Array.");const i={weight:"normal",style:"normal",...t},r=new FontFace(e,typeof s=="string"?`url(${s})`:s,i);await r.load(),document.fonts.add(r);const o=yt.get(e)??[];o.push(r),yt.set(e,o),Ot.add(e),Ut.add(e);const l=e.toLowerCase().trim();return it[l]?it[l]._custom=!0:it[l]={google:null,weights:[],generic:"sans-serif",_custom:!0},console.log(`[pptx-canvas-renderer] Custom font registered: "${e}" (${i.weight} ${i.style})`),r}async function Hr(e){const n=[];for(const[t,s]of Object.entries(e))if(typeof s=="string")n.push(gn(t,s));else if(Array.isArray(s))for(const i of s){const{url:r,...o}=i;n.push(gn(t,r,o))}await Promise.all(n)}function Yr(e,n){if(!e)return[];const t=m(e,"embeddedFontLst");if(!t)return[];const s=[];for(const i of t.children){if(i.localName!=="embeddedFont")continue;const r=m(i,"font"),o=r?r.getAttribute("typeface"):null;if(!o)continue;const l={regular:!1,bold:!1,italic:!1,boldItalic:!1},a=[];for(const c of["regular","bold","italic","boldItalic"]){const u=m(i,c);if(!u)continue;const h=u.getAttribute("r:id")||u.getAttribute("id"),d=n?.[h];d&&(a.push(d.fullPath),l[c]=!0)}s.push({family:o,hasRegular:l.regular,hasBold:l.bold,hasItalic:l.italic,hasBoldItalic:l.boldItalic,paths:a,note:".fntdata files are a proprietary Microsoft format and cannot be used as web fonts directly. Use registerFont() with a compatible woff2/ttf version instead."})}return s}function Qr(e){if(!e)return"sans-serif";if(e==="+mj-lt"||e==="+mj")return"serif";if(e==="+mn-lt"||e==="+mn")return"sans-serif";if(yt.has(e))return e;const n=e.toLowerCase().trim(),t=it[n];return t?t._custom||t.google===null?e:t.google&&Ss(t.google)?t.google:t.google||e:e}function Zr(e){if(!e)return"sans-serif";const n=e.toLowerCase().trim();return it[n]?.generic??"sans-serif"}async function Jr(e,n){const t=[...e];n?.majorFont&&t.push(n.majorFont),n?.minorFont&&t.push(n.minorFont);const s=new Map;for(const o of t){if(!o||o.startsWith("+")||o==="+mj-lt"||o==="+mn-lt"||o==="+mj"||o==="+mn"||yt.has(o))continue;const l=o.toLowerCase().trim(),a=it[l];let c=null,u=[400,700];if(a){if(a._custom||a.google===null)continue;c=a.google,u=a.weights.length?a.weights:[400,700]}else c=o;if(!c||Ot.has(c))continue;if(Ss(c)){Ot.add(c);continue}const h=s.get(c)??new Set;u.forEach(d=>h.add(d)),s.set(c,h)}if(s.size===0)return;for(const o of s.keys())Ot.add(o);const r=`https://fonts.googleapis.com/css2?${[...s.entries()].map(([o,l])=>{const a=[...l].sort((u,h)=>u-h),c=[...a.map(u=>`0,${u}`),...a.map(u=>`1,${u}`)].join(";");return`family=${encodeURIComponent(`${o}:ital,wght@${c}`)}`}).join("&")}&display=swap`;try{const o=document.createElement("link");o.rel="stylesheet",o.href=r,document.head.appendChild(o),await new Promise(l=>{o.onload=l,o.onerror=()=>{console.warn("[pptx-canvas-renderer] Google Fonts failed to load:",r),l()},setTimeout(l,5e3)}),document.fonts?.ready&&await Promise.race([document.fonts.ready,new Promise(l=>setTimeout(l,2e3))])}catch(o){console.warn("[pptx-canvas-renderer] Font loading error:",o)}}function eo(e){const n=new Set;for(const t of e){if(!t)continue;const s=t.getElementsByTagName("*");for(let i=0;i<s.length;i++){const r=s[i],o=r.localName;if(o==="latin"||o==="ea"||o==="cs"){const l=r.getAttribute("typeface");l&&!l.startsWith("+")&&n.add(l)}}}return n}function Ts(e,n,t,s,i=1800,r=null){let o=i;if(r){const y=r.getAttribute("sz");y&&(o=parseInt(y,10))}if(n){const y=n.getAttribute("sz");y&&(o=parseInt(y,10))}if(e){const y=e.getAttribute("sz");y&&(o=parseInt(y,10))}let l=!1,a=!1;if(r&&(r.getAttribute("b")==="1"&&(l=!0),r.getAttribute("i")==="1"&&(a=!0)),n){const y=n.getAttribute("b"),w=n.getAttribute("i");y==="1"?l=!0:y==="0"&&(l=!1),w==="1"?a=!0:w==="0"&&(a=!1)}if(e){const y=e.getAttribute("b"),w=e.getAttribute("i");y==="1"?l=!0:y==="0"&&(l=!1),w==="1"?a=!0:w==="0"&&(a=!1)}let c=s?.minorFont??"Calibri";function u(y){if(!y)return;const w=m(y,"latin"),x=w?w.getAttribute("typeface"):y.getAttribute("typeface");if(x){if(x==="+mj-lt"||x==="+mj"){c=s?.majorFont??c;return}if(x==="+mn-lt"||x==="+mn"){c=s?.minorFont??c;return}c=x}}u(r),u(n),u(e);const h=Qr(c),d=Zr(c),p=o*127*t;return{fontStr:`${a?"italic ":""}${l?"bold":"normal"} ${p}px "${h}", ${d}`,sz:o,szPx:p,bold:l,italic:a,family:h,generic:d,rawFamily:c}}function to(){const e=[];for(const[n,t]of yt)for(const s of t)e.push({family:n,weight:s.weight,style:s.style,status:s.status});return e}function $t(e){const n=e.replace("#","");return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16)}}function Xe(e,n,t){e/=255,n/=255,t/=255;const s=Math.max(e,n,t),i=Math.min(e,n,t);let r=0,o=0;const l=(s+i)/2;if(s!==i){const a=s-i;switch(o=l>.5?a/(2-s-i):a/(s+i),s){case e:r=((n-t)/a+(n<t?6:0))/6;break;case n:r=((t-e)/a+2)/6;break;case t:r=((e-n)/a+4)/6;break}}return{h:r,l,s:o}}function Ge(e,n,t){if(t===0){const o=Math.round(n*255);return{r:o,g:o,b:o}}const s=n<.5?n*(1+t):n+t-n*t,i=2*n-s,r=(o,l,a)=>(a<0&&(a+=1),a>1&&(a-=1),a<1/6?o+(l-o)*6*a:a<1/2?l:a<2/3?o+(l-o)*(2/3-a)*6:o);return{r:Math.round(r(i,s,e+1/3)*255),g:Math.round(r(i,s,e)*255),b:Math.round(r(i,s,e-1/3)*255)}}const no={black:"000000",white:"FFFFFF",red:"FF0000",green:"008000",blue:"0000FF",yellow:"FFFF00",cyan:"00FFFF",magenta:"FF00FF",orange:"FFA500",purple:"800080",pink:"FFC0CB",brown:"A52A2A",gray:"808080",grey:"808080",navy:"000080",teal:"008080",maroon:"800000",olive:"808000",lime:"00FF00",aqua:"00FFFF",fuchsia:"FF00FF",silver:"C0C0C0",coral:"FF7F50",salmon:"FA8072",gold:"FFD700",khaki:"F0E68C",lavender:"E6E6FA",beige:"F5F5DC",ivory:"FFFFF0",mintcream:"F5FFFA",azure:"F0FFFF",aliceblue:"F0F8FF",ghostwhite:"F8F8FF",darkred:"8B0000",darkgreen:"006400",darkblue:"00008B",darkcyan:"008B8B",darkmagenta:"8B008B",darkorange:"FF8C00",darkgray:"A9A9A9",darkgrey:"A9A9A9",lightgray:"D3D3D3",lightgrey:"D3D3D3",lightblue:"ADD8E6",lightgreen:"90EE90",lightpink:"FFB6C1",lightyellow:"FFFFE0",lightcyan:"E0FFFF",deepskyblue:"00BFFF",royalblue:"4169E1",steelblue:"4682B4",skyblue:"87CEEB",dodgerblue:"1E90FF",cornflowerblue:"6495ED",mediumblue:"0000CD",midnightblue:"191970",indigo:"4B0082",slateblue:"6A5ACD",blueviolet:"8A2BE2",mediumpurple:"9370DB",orchid:"DA70D6",violet:"EE82EE",plum:"DDA0DD",thistle:"D8BFD8",hotpink:"FF69B4",deeppink:"FF1493",crimson:"DC143C",firebrick:"B22222",tomato:"FF6347",orangered:"FF4500",darkorange2:"FF8C00",chocolate:"D2691E",saddlebrown:"8B4513",sienna:"A0522D",tan:"D2B48C",burlywood:"DEB887",wheat:"F5DEB3",moccasin:"FFE4B5",peachpuff:"FFDAB9",papayawhip:"FFEFD5",mistyrose:"FFE4E1",linen:"FAF0E6",oldlace:"FDF5E6",floralwhite:"FFFAF0",antiquewhite:"FAEBD7",bisque:"FFE4C4",blanchedalmond:"FFEBCD",cornsilk:"FFF8DC",lemonchiffon:"FFFACD",honeydew:"F0FFF0",palegreen:"98FB98",lightseagreen:"20B2AA",mediumseagreen:"3CB371",seagreen:"2E8B57",forestgreen:"228B22",yellowgreen:"9ACD32",olivedrab:"6B8E23",greenyellow:"ADFF2F",chartreuse:"7FFF00",springgreen:"00FF7F",mediumspringgreen:"00FA9A",aquamarine:"7FFFD4",turquoise:"40E0D0",mediumturquoise:"48D1CC",paleturquoise:"AFEEEE",cadetblue:"5F9EA0",powderblue:"B0E0E6",lightsteelblue:"B0C4DE",slategray:"708090",slategrey:"708090",dimgray:"696969",dimgrey:"696969",snow:"FFFAFA",seashell:"FFF5EE",whitesmoke:"F5F5F5",gainsboro:"DCDCDC"};function so(e,n){if(!n)return e;let{r:t,g:s,b:i,a:r=1}=e;for(const o of n.children){const l=o.localName,a=parseInt(o.getAttribute("val")??"0",10);switch(l){case"lumMod":{const c=a/1e5,u=Xe(t,s,i),h=Ge(u.h,Ie(u.l*c,0,1),u.s);t=h.r,s=h.g,i=h.b;break}case"lumOff":{const c=a/1e5,u=Xe(t,s,i),h=Ge(u.h,Ie(u.l+c,0,1),u.s);t=h.r,s=h.g,i=h.b;break}case"tint":{const c=a/1e5;t=Math.round(t+(255-t)*(1-c)),s=Math.round(s+(255-s)*(1-c)),i=Math.round(i+(255-i)*(1-c));break}case"shade":{const c=a/1e5;t=Math.round(t*c),s=Math.round(s*c),i=Math.round(i*c);break}case"satMod":{const c=a/1e5,u=Xe(t,s,i),h=Ge(u.h,u.l,Ie(u.s*c,0,1));t=h.r,s=h.g,i=h.b;break}case"satOff":{const c=a/1e5,u=Xe(t,s,i),h=Ge(u.h,u.l,Ie(u.s+c,0,1));t=h.r,s=h.g,i=h.b;break}case"hueMod":{const c=a/1e5,u=Xe(t,s,i),h=Ge(u.h*c%1,u.l,u.s);t=h.r,s=h.g,i=h.b;break}case"hueOff":{const c=a/216e5,u=Xe(t,s,i),h=Ge(((u.h+c)%1+1)%1,u.l,u.s);t=h.r,s=h.g,i=h.b;break}case"alpha":{r=a/1e5;break}case"alphaOff":{r=Ie(r+a/1e5,0,1);break}case"alphaMod":{r=Ie(r*a/1e5,0,1);break}case"inv":{t=255-t,s=255-s,i=255-i;break}case"gray":{t=s=i=Math.round(.2126*t+.7152*s+.0722*i);break}case"comp":{const c=Xe(t,s,i),u=Ge((c.h+.5)%1,c.l,c.s);t=u.r,s=u.g,i=u.b;break}}}return{r:Ie(t,0,255),g:Ie(s,0,255),b:Ie(i,0,255),a:r}}function ve(e,n){if(!e)return null;const t=e.localName;let s=null,i=1;if(t==="srgbClr"){const r=e.getAttribute("val")||"";r.length>=6&&(s=$t(r))}else if(t==="schemeClr"){const o=e.getAttribute("val")||"",l=n?.[o];l?s=$t(l):s={r:0,g:0,b:0}}else if(t==="prstClr"){const r=(e.getAttribute("val")||"").toLowerCase(),o=no[r];o&&(s=$t(o))}else if(t==="sysClr"){const r=e.getAttribute("lastClr");r?.length>=6?s=$t(r):s={r:0,g:0,b:0}}else if(t==="hslClr"){const r=C(e,"hue",0)/216e5,o=C(e,"sat",0)/1e5,l=C(e,"lum",0)/1e5;s=Ge(r,l,o)}else if(t==="scRgbClr"){const r=C(e,"r",0)/1e5,o=C(e,"g",0)/1e5,l=C(e,"b",0)/1e5;s={r:Math.round(Math.pow(r,1/2.2)*255),g:Math.round(Math.pow(o,1/2.2)*255),b:Math.round(Math.pow(l,1/2.2)*255)}}return s?so({...s,a:i},e):null}function ge(e,n){if(!e)return"transparent";const t=n!==void 0?n:e.a??1;return t<1?`rgba(${e.r},${e.g},${e.b},${t.toFixed(3)})`:`rgb(${e.r},${e.g},${e.b})`}function me(e){if(!e)return null;const n=["srgbClr","schemeClr","prstClr","sysClr","hslClr","scRgbClr"];for(const t of n){const s=m(e,t);if(s)return s}return null}function Kn(e,n){if(!e)return null;const t=m(e,"solidFill");if(!t)return null;const s=me(t),i=ve(s,n);return i?ge(i):null}function io(e,n,t){const s=Kn(e,t);return s||Kn(n,t)}function Kt(e,n,t,s,i,r,o){const l=d=>d*Math.PI/180,a=(d,p=5e4)=>(o&&o[d]!==void 0?o[d]:p)/1e5,c=t+i/2,u=s+r/2,h=Math.min(i,r);switch(e.beginPath(),n){case"rect":case"snip1Rect":e.rect(t,s,i,r);break;case"roundRect":{const d=a(0,16667)*h*.5;e.moveTo(t+d,s),e.lineTo(t+i-d,s),e.arcTo(t+i,s,t+i,s+d,d),e.lineTo(t+i,s+r-d),e.arcTo(t+i,s+r,t+i-d,s+r,d),e.lineTo(t+d,s+r),e.arcTo(t,s+r,t,s+r-d,d),e.lineTo(t,s+d),e.arcTo(t,s,t+d,s,d),e.closePath();break}case"ellipse":case"oval":e.ellipse(c,u,i/2,r/2,0,0,Math.PI*2);break;case"triangle":case"isoscelesTriangle":e.moveTo(c,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break;case"rightTriangle":e.moveTo(t,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break;case"parallelogram":{const d=a(0,25e3),p=i*d;e.moveTo(t+p,s),e.lineTo(t+i,s),e.lineTo(t+i-p,s+r),e.lineTo(t,s+r),e.closePath();break}case"trapezoid":{const d=a(0,25e3),p=i*d;e.moveTo(t+p,s),e.lineTo(t+i-p,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break}case"diamond":e.moveTo(c,s),e.lineTo(t+i,u),e.lineTo(c,s+r),e.lineTo(t,u),e.closePath();break;case"pentagon":tt(e,c,u,i/2,r/2,5,-Math.PI/2);break;case"hexagon":tt(e,c,u,i/2,r/2,6,0);break;case"heptagon":tt(e,c,u,i/2,r/2,7,-Math.PI/2);break;case"octagon":tt(e,c,u,i/2,r/2,8,Math.PI/8);break;case"decagon":tt(e,c,u,i/2,r/2,10,-Math.PI/2);break;case"dodecagon":tt(e,c,u,i/2,r/2,12,0);break;case"plus":case"cross":{const d=a(0,25e3),p=h*d,g=c-p/2,b=c+p/2,_=u-p/2,y=u+p/2;e.moveTo(g,s),e.lineTo(b,s),e.lineTo(b,_),e.lineTo(t+i,_),e.lineTo(t+i,y),e.lineTo(b,y),e.lineTo(b,s+r),e.lineTo(g,s+r),e.lineTo(g,y),e.lineTo(t,y),e.lineTo(t,_),e.lineTo(g,_),e.closePath();break}case"star4":$e(e,c,u,i/2,r/2,4,a(0,37500));break;case"star5":$e(e,c,u,i/2,r/2,5,a(0,19098),-Math.PI/2);break;case"star6":$e(e,c,u,i/2,r/2,6,a(0,28868),0);break;case"star7":$e(e,c,u,i/2,r/2,7,a(0,34601),-Math.PI/2);break;case"star8":$e(e,c,u,i/2,r/2,8,a(0,29289),Math.PI/8);break;case"star10":$e(e,c,u,i/2,r/2,10,a(0,30902),-Math.PI/2);break;case"star12":$e(e,c,u,i/2,r/2,12,a(0,37720),0);break;case"star16":$e(e,c,u,i/2,r/2,16,a(0,37500),0);break;case"star24":$e(e,c,u,i/2,r/2,24,a(0,37500),0);break;case"star32":$e(e,c,u,i/2,r/2,32,a(0,37500),0);break;case"rightArrow":{const d=a(0,5e4),p=a(1,5e4),g=(r-r*p)/2,b=t+i*(1-d);e.moveTo(t,s+g),e.lineTo(b,s+g),e.lineTo(b,s),e.lineTo(t+i,u),e.lineTo(b,s+r),e.lineTo(b,s+r-g),e.lineTo(t,s+r-g),e.closePath();break}case"leftArrow":{const d=a(0,5e4),p=a(1,5e4),g=(r-r*p)/2,b=t+i*d;e.moveTo(t+i,s+g),e.lineTo(b,s+g),e.lineTo(b,s),e.lineTo(t,u),e.lineTo(b,s+r),e.lineTo(b,s+r-g),e.lineTo(t+i,s+r-g),e.closePath();break}case"upArrow":{const d=a(0,5e4),p=a(1,5e4),g=(i-i*p)/2,b=s+r*d;e.moveTo(t+g,s+r),e.lineTo(t+g,b),e.lineTo(t,b),e.lineTo(c,s),e.lineTo(t+i,b),e.lineTo(t+i-g,b),e.lineTo(t+i-g,s+r),e.closePath();break}case"downArrow":{const d=a(0,5e4),p=a(1,5e4),g=(i-i*p)/2,b=s+r*(1-d);e.moveTo(t+g,s),e.lineTo(t+g,b),e.lineTo(t,b),e.lineTo(c,s+r),e.lineTo(t+i,b),e.lineTo(t+i-g,b),e.lineTo(t+i-g,s),e.closePath();break}case"leftRightArrow":{const d=a(0,25e3),p=a(1,5e4),g=(r-r*p)/2,b=t+i*d,_=t+i*(1-d);e.moveTo(t,u),e.lineTo(b,s),e.lineTo(b,s+g),e.lineTo(_,s+g),e.lineTo(_,s),e.lineTo(t+i,u),e.lineTo(_,s+r),e.lineTo(_,s+r-g),e.lineTo(b,s+r-g),e.lineTo(b,s+r),e.closePath();break}case"upDownArrow":{const d=a(0,25e3),p=a(1,5e4),g=(i-i*p)/2,b=s+r*d,_=s+r*(1-d);e.moveTo(c,s),e.lineTo(t+i,b),e.lineTo(t+i-g,b),e.lineTo(t+i-g,_),e.lineTo(t+i,_),e.lineTo(c,s+r),e.lineTo(t,_),e.lineTo(t+g,_),e.lineTo(t+g,b),e.lineTo(t,b),e.closePath();break}case"chevron":{const d=a(0,5e4),p=i*d;e.moveTo(t,s),e.lineTo(t+i-p,s),e.lineTo(t+i,u),e.lineTo(t+i-p,s+r),e.lineTo(t,s+r),e.lineTo(t+p,u),e.closePath();break}case"pentagon5":case"homePlate":{const d=a(0,5e4);e.moveTo(t,s),e.lineTo(t+i*(1-d),s),e.lineTo(t+i,u),e.lineTo(t+i*(1-d),s+r),e.lineTo(t,s+r),e.closePath();break}case"arc":{const d=a(0,270)*Math.PI/180,p=a(1,288e5/6e4)*Math.PI/180;e.moveTo(c,u),e.arc(c,u,Math.min(i,r)/2,d,d+p),e.closePath();break}case"blockArc":{const d=(a(0,0)*360-90)*Math.PI/180,p=a(1,25e3)*360*Math.PI/180,g=a(2,25e3)*Math.min(i,r)/2,b=Math.min(i,r)/2,_=b-g;e.moveTo(c+b*Math.cos(d),u+b*Math.sin(d)),e.arc(c,u,b,d,d+p),e.arc(c,u,Math.max(1,_),d+p,d,!0),e.closePath();break}case"line":case"straightConnector1":e.moveTo(t,u),e.lineTo(t+i,u);break;case"bentConnector3":case"bentConnector4":case"bentConnector5":case"elbowConnector":e.moveTo(t,s),e.lineTo(t,u),e.lineTo(t+i,u),e.lineTo(t+i,s+r);break;case"curvedConnector3":case"curvedConnector4":e.moveTo(t,s),e.bezierCurveTo(t,s+r/2,t+i,s+r/2,t+i,s+r);break;case"heart":{ro(e,t,s,i,r);break}case"lightningBolt":{e.moveTo(t+i*.6,s),e.lineTo(t+i*.2,s+r*.45),e.lineTo(t+i*.5,s+r*.45),e.lineTo(t+i*.4,s+r),e.lineTo(t+i*.8,s+r*.55),e.lineTo(t+i*.5,s+r*.55),e.closePath();break}case"moon":{e.arc(c+i*.1,u,r*.5,l(-120),l(120)),e.arc(c+i*.4,u,r*.45,l(120),l(-120),!0),e.closePath();break}case"noSmoking":{const d=Math.min(i,r)/2;e.arc(c,u,d,0,Math.PI*2),e.moveTo(c-d*.7,u+d*.7),e.lineTo(c+d*.7,u-d*.7);break}case"flowChartProcess":e.rect(t,s,i,r);break;case"flowChartDecision":e.moveTo(c,s),e.lineTo(t+i,u),e.lineTo(c,s+r),e.lineTo(t,u),e.closePath();break;case"flowChartTerminator":{const d=r/2;e.moveTo(t+d,s),e.lineTo(t+i-d,s),e.arc(t+i-d,u,d,-Math.PI/2,Math.PI/2),e.lineTo(t+d,s+r),e.arc(t+d,u,d,Math.PI/2,-Math.PI/2),e.closePath();break}case"flowChartDocument":{e.moveTo(t,s),e.lineTo(t+i,s),e.lineTo(t+i,s+r*.8),e.bezierCurveTo(t+i*.75,s+r*.8,t+i*.75,s+r,t+i*.5,s+r),e.bezierCurveTo(t+i*.25,s+r,t+i*.25,s+r*.8,t,s+r*.8),e.closePath();break}case"flowChartDatabase":case"cylinder":{const d=r*.1;e.moveTo(t,s+d),e.ellipse(c,s+d,i/2,d,0,Math.PI,0),e.lineTo(t+i,s+r-d),e.ellipse(c,s+r-d,i/2,d,0,0,Math.PI),e.closePath();break}case"cube":{const d=i*.15;e.moveTo(t+d,s),e.lineTo(t+i,s),e.lineTo(t+i,s+r-d),e.lineTo(t+i-d,s+r),e.lineTo(t,s+r),e.lineTo(t,s+d),e.closePath(),e.moveTo(t+d,s),e.lineTo(t+d,s+d),e.lineTo(t,s+d),e.moveTo(t+d,s+d),e.lineTo(t+i,s+d);break}case"callout1":case"borderCallout1":case"wedgeRectCallout":{e.rect(t,s,i,r*.8),e.moveTo(c-i*.1,s+r*.8),e.lineTo(c,s+r),e.lineTo(c+i*.1,s+r*.8),e.closePath();break}case"wedgeRoundRectCallout":{const d=r*.05;e.moveTo(t+d,s),e.lineTo(t+i-d,s),e.arcTo(t+i,s,t+i,s+d,d),e.lineTo(t+i,s+r*.75-d),e.arcTo(t+i,s+r*.75,t+i-d,s+r*.75,d),e.lineTo(c+i*.1,s+r*.75),e.lineTo(c,s+r),e.lineTo(c-i*.1,s+r*.75),e.lineTo(t+d,s+r*.75),e.arcTo(t,s+r*.75,t,s+r*.75-d,d),e.lineTo(t,s+d),e.arcTo(t,s,t+d,s,d),e.closePath();break}case"wedgeEllipseCallout":{e.ellipse(c,u-r*.05,i/2,r*.45,0,0,Math.PI*2),e.moveTo(c-i*.1,u+r*.4),e.lineTo(c,s+r),e.lineTo(c+i*.1,u+r*.4),e.closePath();break}case"cloudCallout":case"cloud":{e.beginPath();const d=[{cx:c-i*.22,cy:u-r*.12,r:i*.16},{cx:c-i*.07,cy:u-r*.22,r:i*.18},{cx:c+i*.1,cy:u-r*.22,r:i*.17},{cx:c+i*.25,cy:u-r*.12,r:i*.15},{cx:c+i*.35,cy:u+r*.05,r:i*.13},{cx:c-i*.3,cy:u+r*.05,r:i*.13}];for(const p of d)e.arc(p.cx,p.cy,p.r,0,Math.PI*2);e.rect(c-i*.35,u,i*.7,r*.25);break}case"smileyFace":{e.arc(c,u,Math.min(i,r)/2,0,Math.PI*2);break}case"donut":{const d=Math.min(i,r)/2,p=d*a(0,25e3);e.arc(c,u,d,0,Math.PI*2),e.arc(c,u,p,Math.PI*2,0,!0);break}case"bracketPair":{const d=i*.2;e.moveTo(t+d,s),e.arcTo(t,s,t,s+d,d),e.lineTo(t,s+r-d),e.arcTo(t,s+r,t+d,s+r,d),e.moveTo(t+i-d,s),e.arcTo(t+i,s,t+i,s+d,d),e.lineTo(t+i,s+r-d),e.arcTo(t+i,s+r,t+i-d,s+r,d);break}case"bracePair":{const d=r*.15;e.moveTo(c-i*.35,s),e.bezierCurveTo(c-i*.45,s,c-i*.45,s,c-i*.45,s+d),e.lineTo(c-i*.45,u-d),e.bezierCurveTo(c-i*.45,u,c-i*.5,u,c-i*.5,u),e.bezierCurveTo(c-i*.5,u,c-i*.45,u,c-i*.45,u+d),e.lineTo(c-i*.45,s+r-d),e.bezierCurveTo(c-i*.45,s+r,c-i*.35,s+r,c-i*.35,s+r);break}case"irregularSeal1":case"irregularSeal2":{$e(e,c,u,i/2,r/2,12,a(0,42533),0);break}case"accentCallout1":case"accentCallout2":case"calloutWedgeRect":e.rect(t,s,i,r);break;case"flowChartAlternateProcess":{const d=r*.15;e.moveTo(t+d,s),e.lineTo(t+i-d,s),e.arcTo(t+i,s,t+i,s+d,d),e.lineTo(t+i,s+r-d),e.arcTo(t+i,s+r,t+i-d,s+r,d),e.lineTo(t+d,s+r),e.arcTo(t,s+r,t,s+r-d,d),e.lineTo(t,s+d),e.arcTo(t,s,t+d,s,d),e.closePath();break}case"flowChartConnector":e.arc(c,u,Math.min(i,r)/2,0,Math.PI*2);break;case"flowChartInputOutput":{const d=i*.2;e.moveTo(t+d,s),e.lineTo(t+i,s),e.lineTo(t+i-d,s+r),e.lineTo(t,s+r),e.closePath();break}case"flowChartPredefinedProcess":{e.rect(t,s,i,r),e.moveTo(t+i*.1,s),e.lineTo(t+i*.1,s+r),e.moveTo(t+i*.9,s),e.lineTo(t+i*.9,s+r);break}case"flowChartManualInput":{e.moveTo(t,s+r*.2),e.lineTo(t+i,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break}case"flowChartPreparation":{const d=i*.2;e.moveTo(t+d,s),e.lineTo(t+i-d,s),e.lineTo(t+i,u),e.lineTo(t+i-d,s+r),e.lineTo(t+d,s+r),e.lineTo(t,u),e.closePath();break}case"ribbon":case"ribbon2":{const d=r*.3;e.moveTo(t,s+d/2),e.lineTo(t+i*.1,s),e.lineTo(t+i*.1,s+r-d),e.lineTo(t,s+r),e.lineTo(t+i*.5,s+r-d),e.lineTo(t+i,s+r),e.lineTo(t+i-i*.1,s+r-d),e.lineTo(t+i-i*.1,s),e.lineTo(t+i,s+d/2),e.lineTo(t+i*.5,s+d),e.closePath();break}case"ellipseRibbon":case"ellipseRibbon2":{e.ellipse(c,u,i/2,r/2,0,0,Math.PI*2);break}case"teardrop":{const d=Math.min(i,r)*.45;e.arc(c,u+d,d,-Math.PI,0),e.bezierCurveTo(c+d,u+d-d*.55,c+d*.1,u-r*.4,c,s),e.bezierCurveTo(c-d*.1,u-r*.4,c-d,u+d-d*.55,c-d,u+d),e.closePath();break}default:return e.rect(t,s,i,r),!1}return!0}function tt(e,n,t,s,i,r,o=0){for(let l=0;l<r;l++){const a=o+l/r*Math.PI*2,c=n+s*Math.cos(a),u=t+i*Math.sin(a);l===0?e.moveTo(c,u):e.lineTo(c,u)}e.closePath()}function $e(e,n,t,s,i,r,o=.5,l=-Math.PI/2){for(let a=0;a<r*2;a++){const c=l+a/(r*2)*Math.PI*2,u=a%2===1,h=u?s*o:s,d=u?i*o:i,p=n+h*Math.cos(c),g=t+d*Math.sin(c);a===0?e.moveTo(p,g):e.lineTo(p,g)}e.closePath()}function ro(e,n,t,s,i){e.beginPath();const r=n+s/2,o=t+i*.25;e.moveTo(r,t+i*.9),e.bezierCurveTo(n-s*.1,t+i*.6,n-s*.1,o-i*.05,r-s*.25,o-i*.1),e.bezierCurveTo(r-s*.5+s*.05,t+i*.05,r-s*.03,t+i*.05,r,o-i*.15),e.bezierCurveTo(r+s*.03,t+i*.05,r+s*.5-s*.05,t+i*.05,r+s*.25,o-i*.1),e.bezierCurveTo(n+s*1.1,o-i*.05,n+s*1.1,t+i*.6,r,t+i*.9),e.closePath()}const Xn=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0","#FF7F00","#9E480E"];function oo(e){const n=e?.textContent?.trim();if(n==null||n==="")return null;const t=parseFloat(n);return isNaN(t)?n:t}function pt(e){if(!e)return[];const n=C(m(e,"ptCount"),"val",0),t=new Array(n).fill(null);for(const s of ce(e,"pt")){const i=C(s,"idx",0);t[i]=oo(m(s,"v"))}return t}function St(e){const n=m(e,"tx");if(!n)return null;const t=m(n,"v");if(t)return t.textContent.trim();const s=m(n,"strCache");if(s){const i=m(s,"pt"),r=i?m(i,"v"):null;return r?r.textContent.trim():null}return null}function Zt(e){const n=m(e,"cat")||m(e,"xVal");return n?pt(m(n,"strCache")||m(n,"numCache")):[]}function Tt(e){const n=m(e,"val")||m(e,"yVal");return n?pt(m(n,"numCache")):[]}function Ye(e,n,t){const s=m(e,"spPr");if(s){const r=m(s,"solidFill");if(r){const o=me(r),l=ve(o,t);if(l)return ge(l)}}const i=`accent${n%6+1}`;return t[i]?`#${t[i]}`:Xn[n%Xn.length]}function js(e,n){const t={};for(const s of ce(e,"dPt")){const i=C(m(s,"idx"),"val",-1);if(i<0)continue;const r=m(s,"spPr");if(!r)continue;const o=m(r,"solidFill");if(!o)continue;const l=me(o),a=ve(l,n);a&&(t[i]=ge(a))}return t}function Jt(e,n,t,s,i={}){const{padL:r=.12,padR:o=.06,padT:l=.08,padB:a=.1,legendH:c=.1,hasLegend:u=!0,hasTitle:h=!1}=i,d=h?s*.08:0,p=u?s*c:0;return{x:e+t*r,y:n+s*l+d,w:t*(1-r-o),h:s*(1-l-a)-p-d,legendY:n+s*(1-c*.7)}}function vt(e,n,t,s,i,r=3){s<0&&(n+=s,s=-s),i<0&&(t+=i,i=-i),r=Math.min(r,Math.abs(s)/2,Math.abs(i)/2),e.beginPath(),e.moveTo(n+r,t),e.arcTo(n+s,t,n+s,t+i,r),e.arcTo(n+s,t+i,n,t+i,r),e.arcTo(n,t+i,n,t,r),e.arcTo(n,t,n+s,t,r),e.closePath()}function Ee(e,n,t,s,i,r="#999",o=.7){e.save(),e.strokeStyle=r,e.lineWidth=o,e.setLineDash([]),e.beginPath(),e.moveTo(n,t),e.lineTo(s,i),e.stroke(),e.restore()}function Qe(e,n,t,s,i){e.save(),e.strokeStyle="rgba(0,0,0,0.10)",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(n,t),e.lineTo(s,i),e.stroke(),e.setLineDash([]),e.restore()}function Fs(e,n=5){const t=e/n,s=Math.pow(10,Math.floor(Math.log10(t))),i=t/s;let r;return i<1.5?r=1:i<3.5?r=2:i<7.5?r=5:r=10,r*s}function wt(e,n=!0){const t=e.filter(o=>typeof o=="number"&&isFinite(o));if(!t.length)return{min:0,max:100,step:20};let s=n?Math.min(0,...t):Math.min(...t),i=Math.max(...t);s===i&&(s-=1,i+=1);const r=Fs(i-s);return i=Math.ceil(i/r)*r,s=Math.floor(s/r)*r,{min:s,max:i,step:r}}function Ze(e){return typeof e!="number"?String(e??""):Math.abs(e)>=1e9?(e/1e9).toFixed(1).replace(/\.0$/,"")+"B":Math.abs(e)>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":Math.abs(e)>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"K":Number.isInteger(e)?String(e):e.toFixed(1)}function jt(e,n,t,s,i,r,o){if(!r.length)return;const l=Math.max(8,Math.min(14,s*.025))*o,a=s/Math.max(r.length,1);e.save(),e.font=`${l}px sans-serif`,e.textBaseline="middle";for(let c=0;c<r.length;c++){if(!r[c].name)continue;const u=n+a*c+l*.5;e.fillStyle=r[c].color,vt(e,u,i-l/2,l*1.2,l),e.fill(),e.fillStyle="#444",e.fillText(r[c].name,u+l*1.5,i)}e.restore()}function ao(e,n,t,s,i,r,o,l){const a=m(n,"barChart")||m(n,"bar3DChart"),c=!a||D(a,"barDir","col")!=="bar",u=D(a,"grouping","clustered"),h=u==="stacked"||u==="percentStacked",d=u==="percentStacked",p=ce(a,"ser"),g=p.map((k,S)=>({name:St(k),values:Tt(k),color:Ye(k,S,o),dptColors:js(k,o)}));if(!g.length)return;const b=Zt(p[0])||[],_=Math.max(b.length,g[0]?.values.length||0,1),y=Jt(t,s,i,r,{hasLegend:g.length>1});let w;h?(w=Array.from({length:_},(k,S)=>g.reduce((N,M)=>N+(M.values[S]||0),0)),d&&(w=w.map(()=>100))):w=g.flatMap(k=>k.values);const x=wt(w),P=Math.max(7,Math.min(11,y.w*.018))*l;e.font=`${P}px sans-serif`,e.textBaseline="middle";const v=Math.round((x.max-x.min)/x.step);if(c){e.save(),e.textAlign="right",e.fillStyle="#666";for(let T=0;T<=v;T++){const $=x.min+T*x.step,L=($-x.min)/(x.max-x.min),G=y.y+y.h-L*y.h;Qe(e,y.x,G,y.x+y.w,G),e.fillText(d?$+"%":Ze($),y.x-4*l,G)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";const k=y.w/_;for(let T=0;T<_;T++){const $=y.x+k*T+k/2,L=String(b[T]??T+1);e.fillText(L,$,y.y+y.h+P*1.5)}e.restore(),Ee(e,y.x,y.y,y.x,y.y+y.h),Ee(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h);const S=y.w/_,N=S*.15,M=S-N*2,F=h?M:M/g.length;for(let T=0;T<_;T++){const $=y.x+S*T+N;let L=0;for(let G=0;G<g.length;G++){const q=g[G];let B=q.values[T]??0;if(d){const ae=g.reduce((ue,re)=>ue+(re.values[T]||0),0);B=ae?B/ae*100:0}const U=q.dptColors[T]||q.color,H=Math.abs(B)/(x.max-x.min)*y.h,K=h?$:$+G*F,ee=h?(L-x.min)/(x.max-x.min):Math.max(0,-x.min)/(x.max-x.min),I=y.y+y.h-ee*y.h,X=B>=0?I-H:I;e.save(),e.fillStyle=U,vt(e,K,X,h?M:F-1*l,H,2*l),e.fill();const ne=e.createLinearGradient(K,X,K,X+H*.3);ne.addColorStop(0,"rgba(255,255,255,0.18)"),ne.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=ne,e.fill(),e.restore(),h&&(L+=Math.abs(B))}}}else{e.save(),e.textAlign="right",e.fillStyle="#666";const k=y.h/_;for(let T=0;T<_;T++){const $=y.y+k*T+k/2,L=String(b[T]??T+1);e.fillText(L,y.x-4*l,$)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";for(let T=0;T<=v;T++){const $=x.min+T*x.step,L=($-x.min)/(x.max-x.min),G=y.x+L*y.w;Qe(e,G,y.y,G,y.y+y.h),e.fillText(d?$+"%":Ze($),G,y.y+y.h+P*1.5)}e.restore(),Ee(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h),Ee(e,y.x,y.y,y.x,y.y+y.h);const S=k*.15,N=k-S*2,M=h?N:N/g.length,F=y.x+-x.min/(x.max-x.min)*y.w;for(let T=0;T<_;T++){const $=y.y+k*T+S;let L=0;for(let G=0;G<g.length;G++){const q=g[G];let B=q.values[T]??0;if(d){const X=g.reduce((ne,ae)=>ne+(ae.values[T]||0),0);B=X?B/X*100:0}const U=q.dptColors[T]||q.color,H=Math.abs(B)/(x.max-x.min)*y.w,K=h?$:$+G*M,ee=h?F+L/(x.max-x.min)*y.w:F,I=B>=0?ee:ee-H;e.save(),e.fillStyle=U,vt(e,I,K,H,h?N:M-1*l,2*l),e.fill(),e.restore(),h&&(L+=Math.abs(B))}}}g.length>1&&jt(e,t,s,i,y.legendY,g,l)}function lo(e,n,t,s,i,r,o,l){const a=m(n,"lineChart")||m(n,"line3DChart"),c=ce(a,"ser"),u=c.map((y,w)=>({name:St(y),values:Tt(y),color:Ye(y,w,o),marker:D(m(y,"marker"),"symbol","none")!=="none",smooth:D(m(y,"smooth"),"val","0")==="1"}));if(!u.length)return;const h=Zt(c[0])||[],d=Math.max(h.length,u[0]?.values.length||0,1),p=Jt(t,s,i,r,{hasLegend:!0}),g=wt(u.flatMap(y=>y.values)),b=Math.max(7,Math.min(11,p.w*.018))*l,_=Math.round((g.max-g.min)/g.step);e.save(),e.textAlign="right",e.fillStyle="#666",e.font=`${b}px sans-serif`;for(let y=0;y<=_;y++){const w=g.min+y*g.step,x=(w-g.min)/(g.max-g.min),P=p.y+p.h-x*p.h;Qe(e,p.x,P,p.x+p.w,P),e.fillText(Ze(w),p.x-4*l,P)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666",e.font=`${b}px sans-serif`;for(let y=0;y<d;y++){const w=p.x+y/(d-1||1)*p.w;Qe(e,w,p.y,w,p.y+p.h);const x=String(h[y]??y+1);e.fillText(x,w,p.y+p.h+b*1.5)}e.restore(),Ee(e,p.x,p.y,p.x,p.y+p.h),Ee(e,p.x,p.y+p.h,p.x+p.w,p.y+p.h);for(const y of u){const w=y.values.map((P,v)=>{const k=d>1?v/(d-1):.5,S=(P-g.min)/(g.max-g.min);return{x:p.x+k*p.w,y:p.y+p.h-S*p.h,v:P}}).filter(P=>typeof P.v=="number");if(w.length<2)continue;e.save(),e.beginPath(),e.moveTo(w[0].x,p.y+p.h);for(const P of w)e.lineTo(P.x,P.y);if(e.lineTo(w[w.length-1].x,p.y+p.h),e.closePath(),e.fillStyle=y.color+"22",e.fill(),e.restore(),e.save(),e.strokeStyle=y.color,e.lineWidth=2*l,e.lineJoin="round",e.lineCap="round",e.beginPath(),y.smooth&&w.length>2){e.moveTo(w[0].x,w[0].y);for(let P=1;P<w.length-1;P++){const v=(w[P].x+w[P+1].x)/2,k=(w[P].y+w[P+1].y)/2;e.quadraticCurveTo(w[P].x,w[P].y,v,k)}e.lineTo(w[w.length-1].x,w[w.length-1].y)}else{e.moveTo(w[0].x,w[0].y);for(const P of w.slice(1))e.lineTo(P.x,P.y)}e.stroke(),e.restore();const x=3.5*l;for(const P of w)e.save(),e.fillStyle=y.color,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.beginPath(),e.arc(P.x,P.y,x,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}jt(e,t,s,i,p.legendY,u,l)}function co(e,n,t,s,i,r,o,l){const a=m(n,"areaChart")||m(n,"area3DChart"),c=D(a,"grouping","standard"),u=c==="percentStacked",h=c==="stacked"||u,p=ce(a,"ser").map((v,k)=>({name:St(v),values:Tt(v),color:Ye(v,k,o)})).reverse();if(!p.length)return;const g=Math.max(...p.map(v=>v.values.length),1),b=Jt(t,s,i,r,{hasLegend:!0});let _=0;if(u)_=100;else for(let v=0;v<g;v++){const k=p.reduce((S,N)=>S+(N.values[v]||0),0);_=Math.max(_,k)}const y={min:0,max:_||100,step:Fs(_||100)},w=Math.round((y.max-y.min)/y.step),x=Math.max(7,Math.min(11,b.w*.018))*l;e.save(),e.font=`${x}px sans-serif`,e.textAlign="right",e.fillStyle="#666";for(let v=0;v<=w;v++){const k=y.min+v*y.step,S=(k-y.min)/(y.max-y.min),N=b.y+b.h-S*b.h;Qe(e,b.x,N,b.x+b.w,N),e.fillText(u?k+"%":Ze(k),b.x-4*l,N)}e.restore(),Ee(e,b.x,b.y,b.x,b.y+b.h),Ee(e,b.x,b.y+b.h,b.x+b.w,b.y+b.h);const P=new Array(g).fill(0);for(const v of p){e.save(),e.beginPath();const k=[];for(let S=0;S<g;S++){let N=v.values[S]??0;if(u){const G=p.reduce((q,B)=>q+(B.values[S]||0),0);N=G?N/G*100:0}const M=h?P[S]:0,F=M+Math.abs(N),T=(M-y.min)/(y.max-y.min),$=(F-y.min)/(y.max-y.min),L=b.x+S/(g-1||1)*b.w;k.push({x:L,y:b.y+b.h-$*b.h,baseY:b.y+b.h-T*b.h}),h&&(P[S]+=Math.abs(N))}e.moveTo(k[0].x,k[0].baseY);for(const S of k)e.lineTo(S.x,S.baseY);for(let S=k.length-1;S>=0;S--)e.lineTo(k[S].x,k[S].y);e.closePath(),e.fillStyle=v.color+"cc",e.fill(),e.beginPath(),e.moveTo(k[0].x,k[0].y);for(const S of k.slice(1))e.lineTo(S.x,S.y);e.strokeStyle=v.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}jt(e,t,s,i,b.legendY,[...p].reverse(),l)}function Vn(e,n,t,s,i,r,o,l){const a=m(n,"pieChart")||m(n,"pie3DChart"),c=m(n,"doughnutChart"),u=a||c,h=!!c,d=ce(u,"ser");if(!d.length)return;const p=d[0],g=Tt(p).map(T=>typeof T=="number"&&T>0?T:0),b=Zt(p),_=js(p,o),y=g.reduce((T,$)=>T+$,0);if(!y)return;const w=Math.min(i,r)*.38,x=t+i*.44,P=s+r*.5,v=h?w*.55:0;let k=-Math.PI/2;for(let T=0;T<g.length;T++){if(!g[T])continue;const $=g[T]/y*Math.PI*2,L=_[T]||Ye(p,T,o),G=k+$/2,q=T===0?w*.04:0,B=q*Math.cos(G),U=q*Math.sin(G);e.save(),e.beginPath(),e.moveTo(x+B,P+U),e.arc(x+B,P+U,w,k,k+$),e.closePath(),e.fillStyle=L,e.fill(),e.shadowColor="rgba(0,0,0,0.12)",e.shadowBlur=4*l,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.stroke(),e.restore(),v>0&&(e.save(),e.beginPath(),e.arc(x,P,v,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.restore());const H=g[T]/y;if(H>.05){const K=x+B+w*.65*Math.cos(G),ee=P+U+w*.65*Math.sin(G),I=Math.max(8,Math.min(13,w*.15))*l;e.save(),e.fillStyle="#fff",e.font=`bold ${I}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(Math.round(H*100)+"%",K,ee),e.restore()}k+=$}if(h){const T=Math.max(10,Math.min(16,w*.22))*l;e.save(),e.font=`bold ${T}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="middle",e.fillText(Ze(y),x,P),e.restore()}const S=t+i*.78,N=Math.max(8,Math.min(12,i*.022))*l;e.font=`${N}px sans-serif`,e.textBaseline="middle";const M=N*1.8,F=P-g.length*M/2;for(let T=0;T<g.length;T++){const $=S,L=F+T*M,G=_[T]||Ye(p,T,o);e.fillStyle=G,vt(e,$,L-N*.5,N*1.2,N),e.fill(),e.fillStyle="#444";const q=String(b[T]??`Item ${T+1}`);e.fillText(q,$+N*1.5,L)}}function uo(e,n,t,s,i,r,o,l){const a=m(n,"scatterChart")||m(n,"bubbleChart"),u=ce(a,"ser").map((k,S)=>{const N=pt(m(m(k,"xVal"),"numCache")),M=pt(m(m(k,"yVal"),"numCache")),F=pt(m(m(k,"bubbleSize"),"numCache"));return{name:St(k),color:Ye(k,S,o),points:N.map((T,$)=>({x:T,y:M[$],r:F[$]})).filter(T=>typeof T.x=="number"&&typeof T.y=="number")}});if(!u.length)return;const h=Jt(t,s,i,r,{hasLegend:u.length>1}),d=u.flatMap(k=>k.points.map(S=>S.x)),p=u.flatMap(k=>k.points.map(S=>S.y)),g=wt(d,!1),b=wt(p),_=Math.max(7,Math.min(11,h.w*.018))*l,y=Math.round((g.max-g.min)/g.step),w=Math.round((b.max-b.min)/b.step);e.font=`${_}px sans-serif`,e.save(),e.textAlign="center",e.fillStyle="#666";for(let k=0;k<=y;k++){const S=g.min+k*g.step,N=(S-g.min)/(g.max-g.min),M=h.x+N*h.w;Qe(e,M,h.y,M,h.y+h.h),e.fillText(Ze(S),M,h.y+h.h+_*1.5)}e.textAlign="right";for(let k=0;k<=w;k++){const S=b.min+k*b.step,N=(S-b.min)/(b.max-b.min),M=h.y+h.h-N*h.h;Qe(e,h.x,M,h.x+h.w,M),e.fillText(Ze(S),h.x-4*l,M)}e.restore(),Ee(e,h.x,h.y,h.x,h.y+h.h),Ee(e,h.x,h.y+h.h,h.x+h.w,h.y+h.h);const x=u.flatMap(k=>k.points.map(S=>S.r??1)),P=Math.max(...x.filter(k=>typeof k=="number"),1),v=Math.min(h.w,h.h)*.06;for(const k of u)for(const S of k.points){const N=h.x+(S.x-g.min)/(g.max-g.min)*h.w,M=h.y+h.h-(S.y-b.min)/(b.max-b.min)*h.h,F=S.r!=null?S.r/P*v:4*l;e.save(),e.fillStyle=k.color+"aa",e.strokeStyle=k.color,e.lineWidth=1*l,e.beginPath(),e.arc(N,M,F,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}u.length>1&&jt(e,t,s,i,h.legendY,u,l)}function fo(e,n,t,s,i,r,o,l){const a=m(n,"radarChart"),c=ce(a,"ser"),u=c.map((w,x)=>({name:St(w),values:Tt(w),color:Ye(w,x,o)}));if(!u.length)return;const h=Zt(c[0])||[],d=h.length||u[0]?.values.length||0;if(d<3)return;const p=t+i*.5,g=s+r*.5,b=Math.min(i,r)*.34,_=wt(u.flatMap(w=>w.values)),y=4;for(let w=1;w<=y;w++){const x=b*w/y;e.save(),e.beginPath();for(let P=0;P<d;P++){const v=P/d*Math.PI*2-Math.PI/2,k=p+x*Math.cos(v),S=g+x*Math.sin(v);P===0?e.moveTo(k,S):e.lineTo(k,S)}e.closePath(),e.strokeStyle="rgba(0,0,0,0.12)",e.lineWidth=.5,e.stroke(),e.restore()}for(let w=0;w<d;w++){const x=w/d*Math.PI*2-Math.PI/2;Ee(e,p,g,p+b*Math.cos(x),g+b*Math.sin(x));const P=p+(b+16*l)*Math.cos(x),v=g+(b+16*l)*Math.sin(x);e.save(),e.font=`${Math.max(7,11*l)}px sans-serif`,e.fillStyle="#555",e.textAlign="center",e.textBaseline="middle",e.fillText(String(h[w]??w+1),P,v),e.restore()}for(const w of u){const x=w.values.map((P,v)=>{const k=v/d*Math.PI*2-Math.PI/2,S=(P-_.min)/(_.max-_.min);return{x:p+b*S*Math.cos(k),y:g+b*S*Math.sin(k)}});e.save(),e.beginPath(),e.moveTo(x[0].x,x[0].y);for(const P of x.slice(1))e.lineTo(P.x,P.y);e.closePath(),e.fillStyle=w.color+"44",e.fill(),e.strokeStyle=w.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}jt(e,t,s,i,s+r-20*l,u,l)}function ho(e,n,t,s,i,r){const o=m(m(n,"chart"),"title");if(!o)return!1;const l=m(o,"tx");if(!l)return!1;let a="";for(const u of ce(l,"t"))a+=u.textContent;if(!a.trim())return!1;const c=Math.max(10,Math.min(16,i*.03))*r;return e.save(),e.font=`bold ${c}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="top",e.fillText(a,t+i/2,s+6*r),e.restore(),!0}function po(e,n,t,s,i,r,o,l){if(!n)return;const a=n;e.save(),e.fillStyle="#fff",vt(e,t,s,i,r,4*l),e.fill(),e.strokeStyle="#ddd",e.lineWidth=.5,e.stroke(),e.restore();const u=ho(e,a,t,s,i,l)?s+Math.min(r*.08,24*l):s,h=r-(u-s),d=m(a,"plotArea");if(!d)return;const p=m(d,"bar3DChart")||m(d,"barChart"),g=m(d,"line3DChart")||m(d,"lineChart"),b=m(d,"area3DChart")||m(d,"areaChart"),_=m(d,"pie3DChart")||m(d,"pieChart"),y=m(d,"doughnutChart"),w=m(d,"scatterChart")||m(d,"bubbleChart"),x=m(d,"radarChart");if(p)ao(e,d,t,u,i,h,o,l);else if(g)lo(e,d,t,u,i,h,o,l);else if(b)co(e,d,t,u,i,h,o,l);else if(y)Vn(e,d,t,u,i,h,o,l);else if(_)Vn(e,d,t,u,i,h,o,l);else if(w)uo(e,d,t,u,i,h,o,l);else if(x)fo(e,d,t,u,i,h,o,l);else{e.save(),e.fillStyle="#aaa",e.font=`${12*l}px sans-serif`,e.textAlign="center",e.textBaseline="middle";const P=d.firstElementChild;e.fillText(P?.localName??"Chart",t+i/2,s+r/2),e.restore()}}function Xt(e,n,t=0,s=1){return(e?parseInt(e.getAttribute(n)||t,10):t)*s}function Cs(e,n){if(!e)return null;const t=me(e);if(!t)return null;const s=ve(t,n);return s?ge(s):null}function go(e,n,t,s,i,r,o){const l=m(n,"bevelT"),a=m(n,"bevelB"),c=l||a;if(!c)return;const u=Math.max(2*o,Xt(c,"w",76200,o)),h=Math.max(2*o,Xt(c,"h",76200,o)),p=D(c,"prst","circle").toLowerCase().includes("in"),g=Math.min(u,i*.3),b=Math.min(h,r*.3),_=p?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.35)",y=p?"rgba(255,255,255,0.20)":"rgba(0,0,0,0.20)",w=e.createLinearGradient(t,s,t,s+b);w.addColorStop(0,_),w.addColorStop(1,"rgba(255,255,255,0)"),e.save(),e.fillStyle=w,e.fillRect(t,s,i,b);const x=e.createLinearGradient(t,s+r-b,t,s+r);x.addColorStop(0,"rgba(0,0,0,0)"),x.addColorStop(1,y),e.fillStyle=x,e.fillRect(t,s+r-b,i,b);const P=e.createLinearGradient(t,s,t+g,s);P.addColorStop(0,_),P.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=P,e.fillRect(t,s,g,r);const v=e.createLinearGradient(t+i-g,s,t+i,s);v.addColorStop(0,"rgba(0,0,0,0)"),v.addColorStop(1,y),e.fillStyle=v,e.fillRect(t+i-g,s,g,r),e.restore()}function mo(e,n,t,s,i,r,o,l){const a=Xt(n,"extrusionH",0,l);if(a<1*l)return;const c=m(n,"extrusionClr")||m(n,"contourClr"),u=Cs(c,t)||"rgba(0,0,0,0.3)",h=Math.min(a/914400*72*l,Math.min(r,o)*.15),d=h*.7,p=h*.7;e.save(),e.fillStyle=u,e.beginPath(),e.moveTo(s+r,i),e.lineTo(s+r+d,i+p),e.lineTo(s+r+d,i+o+p),e.lineTo(s+r,i+o),e.closePath(),e.fill(),e.beginPath(),e.moveTo(s,i+o),e.lineTo(s+d,i+o+p),e.lineTo(s+r+d,i+o+p),e.lineTo(s+r,i+o),e.closePath(),e.fill(),e.restore()}function bo(e,n,t,s,i,r,o,l){const a=Xt(n,"contourW",0,l);if(a<.5)return;const c=m(n,"contourClr"),u=Cs(c,t)||"#888888",h=Math.max(.5,a/914400*72*l);e.save(),e.strokeStyle=u,e.lineWidth=h,e.strokeRect(s,i,r,o),e.restore()}function yo(e,n,t,s,i,r){if(!n)return()=>{};const o=m(n,"camera");if(!o)return()=>{};const l=D(o,"prst","orthographicFront"),a=m(o,"rot");if(l.toLowerCase().includes("orthographic")&&!a)return()=>{};const u=a?C(a,"lat",0)/6e4:0,h=a?C(a,"lon",0)/6e4:0;a&&C(a,"rev",0)/6e4;const d=u*Math.PI/180,p=h*Math.PI/180,g=Math.sin(p)*.15,b=Math.sin(d)*.08;return e.save(),e.transform(1,b,g,1,t*-g,s*-b),()=>e.restore()}function vo(e,n,t,s,i,r){if(!n)return;const o=m(n,"lightRig");if(!o)return;const l=D(o,"dir","t"),a=D(o,"rig","balanced"),c={t:{gx:t+i/2,gy:s},b:{gx:t+i/2,gy:s+r},l:{gx:t,gy:s+r/2},r:{gx:t+i,gy:s+r/2},tl:{gx:t,gy:s},tr:{gx:t+i,gy:s},bl:{gx:t,gy:s+r},br:{gx:t+i,gy:s+r}},{gx:u,gy:h}=c[l]||c.t,d=a==="flat"?.08:a==="balanced"?.14:a==="sunrise"?.2:a==="harsh"?.28:.12,p=Math.sqrt(i*i+r*r),g=e.createRadialGradient(u,h,0,u,h,p);g.addColorStop(0,`rgba(255,255,255,${d})`),g.addColorStop(.5,"rgba(255,255,255,0)"),g.addColorStop(1,`rgba(0,0,0,${d*.5})`),e.save(),e.fillStyle=g,e.fillRect(t,s,i,r),e.restore()}function wo(e,n,t,s,i,r,o,l){if(!n)return{applyCamera:()=>()=>{},overlay:()=>{}};const a=m(n,"sp3d")||m(n,"scene3d")?.parentNode&&null,c=m(n,"scene3d");a&&mo(e,a,t,s,i,r,o,l);const u=yo(e,c,s,i);return{overlay(){a&&(go(e,a,s,i,r,o,l),bo(e,a,t,s,i,r,o,l)),c&&vo(e,c,s,i,r,o)},cleanup:u}}function ko(e){return e?!!(m(e,"sp3d")||m(e,"scene3d")):!1}async function kt(e,n,t,s,i,r,o,l,a){if(!n)return!1;const c=n.localName;if(c==="noFill")return!1;if(c==="solidFill"){const u=me(n),h=ve(u,l);return h?(e.fillStyle=ge(h),e.fill(),!0):!1}if(c==="gradFill"){const u=m(n,"gsLst");if(!u)return!1;const h=ce(u,"gs").map(y=>{const w=C(y,"pos",0)/1e5,x=me(y),P=ve(x,l);return{pos:w,color:P}}).sort((y,w)=>y.pos-w.pos);if(h.length<2)return!1;const d=m(n,"lin"),p=m(n,"path"),g=t+i/2,b=s+r/2;let _;if(d||!d&&!p){const x=(C(d,"ang",0)/6e4-90)*Math.PI/180,P=Math.cos(x),v=Math.sin(x),k=Math.abs(i*P)+Math.abs(r*v),S=g-k/2*P,N=b-k/2*v,M=g+k/2*P,F=b+k/2*v;_=e.createLinearGradient(S,N,M,F)}else{const y=m(p,"fillToRect"),w=C(y,"l",5e4)/1e5,x=C(y,"t",5e4)/1e5,P=C(y,"r",5e4)/1e5,v=C(y,"b",5e4)/1e5,k=t+i*(w+(1-w-P)/2),S=s+r*(x+(1-x-v)/2),N=Math.sqrt(i*i+r*r)/2;_=e.createRadialGradient(k,S,0,g,b,N)}for(const y of h)y.color&&_.addColorStop(y.pos,ge(y.color));return e.fillStyle=_,e.fill(),!0}if(c==="blipFill"){const u=m(n,"blip"),h=u?u.getAttribute("r:embed")||u.getAttribute("embed"):null;if(h&&a&&a[h]){const d=a[h],p=m(n,"stretch"),g=p?m(p,"fillRect"):null;let b=t,_=s,y=i,w=r;if(g){const k=C(g,"l",0)/1e5,S=C(g,"t",0)/1e5,N=C(g,"r",0)/1e5,M=C(g,"b",0)/1e5;b=t+i*k,_=s+r*S,y=i-i*k-i*N,w=r-r*S-r*M}if(m(n,"tile")){const k=e.createPattern(d,"repeat");if(k)return e.fillStyle=k,e.fill(),!0}const P=m(n,"alphaModFix")||m(u,"alphaModFix"),v=P?C(P,"amt",1e5)/1e5:1;return e.save(),e.clip(),v<1&&(e.globalAlpha=v),e.drawImage(d,b,_,y,w),e.restore(),!0}return!1}if(c==="pattFill"){const u=m(n,"fgClr"),h=m(n,"bgClr"),d=u?ve(me(u),l):{r:0,g:0,b:0,a:1},p=h?ve(me(h),l):{r:255,g:255,b:255,a:1},g=ge(d),b=ge(p),_=D(n,"prst","dotGrid");let y=null,w=null;try{w=typeof OffscreenCanvas<"u"?new OffscreenCanvas(8,8):document.createElement("canvas");const v=8;w.width=v,w.height=v,y=w.getContext("2d")}catch{}const x=8;if(!y)return e.fillStyle=ge(d),e.fill(),!0;switch(y.fillStyle=b,y.fillRect(0,0,x,x),y.fillStyle=g,_){case"smGrid":case"dotGrid":case"dotDmnd":for(let v=0;v<x;v+=2)for(let k=0;k<x;k+=2)y.fillRect(v,k,1,1);break;case"lgGrid":case"cross":y.fillRect(0,0,x,1),y.fillRect(0,0,1,x);break;case"diagBd":case"fwdDiag":for(let v=0;v<x*2;v++)y.fillRect(v%x,Math.floor(v/x)*2,1,1);break;case"bkDiag":case"ltDnDiag":for(let v=0;v<x*2;v++)y.fillRect(x-1-v%x,Math.floor(v/x)*2,1,1);break;case"horzBrick":case"horz":y.fillRect(0,x/2,x,1);break;case"vert":case"vertBrick":y.fillRect(x/2,0,1,x);break;case"smCheck":case"lgCheck":for(let v=0;v<x;v++)for(let k=0;k<x;k++)(v+k)%2===0&&y.fillRect(k,v,1,1);break;default:for(let v=0;v<x;v+=4)y.fillRect(v,v,2,2)}const P=e.createPattern(w,"repeat");return P?(e.fillStyle=P,e.fill(),!0):(e.fillStyle=ge(d,(d.a??1)*.4),e.fill(),!0)}return!1}async function Le(e,n){const t=n.split("/"),s=t.pop(),i=[...t,"_rels",s+".rels"].join("/"),r=e[i];if(!r)return{};const o=new TextDecoder().decode(r),l=ke(o),a={};for(const c of Array.from(l.getElementsByTagName("Relationship"))){const u=c.getAttribute("Id"),h=c.getAttribute("Target"),d=c.getAttribute("Type")||"",p=c.getAttribute("TargetMode")||"Internal";let g=h;if(p!=="External")if(h.startsWith("/"))g=h.slice(1);else{const b=n.split("/");b.pop();const _=h.split("/");for(const y of _)y===".."?b.pop():y!=="."&&b.push(y);g=b.join("/")}a[u]={target:h,fullPath:g,type:d,external:p==="External"}}return a}async function Gt(e,n){const t={},s=new Set(["png","jpg","jpeg","gif","webp","bmp","tiff","tif","svg"]);for(const[i,r]of Object.entries(n)){if(r.external)continue;const o=r.fullPath.split(".").pop().toLowerCase();if(s.has(o))try{const l=e[r.fullPath];if(!l)continue;const c={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",svg:"image/svg+xml"}[o]||"image/png",u=new Blob([l],{type:c}),h=URL.createObjectURL(u),d=await new Promise((p,g)=>{const b=new Image;b.onload=()=>p(b),b.onerror=()=>p(null),b.src=h});t[i]=d}catch{}}return t}function Ms(e,n,t){if(!e)return n*1.2;const s=m(e,"spcPct"),i=m(e,"spcPts");return s?n*(C(s,"val",1e5)/1e5):i?C(i,"val",0)/100*12700*(t||1):n*1.2}function xo(e,n,t,s){if(!e||m(e,"buNone"))return null;const i=m(e,"buChar"),r=m(e,"buAutoNum");if(!i&&!r)return null;let o=null;const l=m(e,"buClr");if(l){const g=me(l);o=ve(g,t)}const a=m(e,"buSzPct"),c=m(e,"buSzPts");let u=1;a&&(u=C(a,"val",1e5)/1e5);const h=c?C(c,"val",0)/100:null;let d=null;const p=m(e,"buFont");if(p){const g=p.getAttribute("typeface");g&&(d=g)}return i?{type:"char",char:i.getAttribute("char")||"•",color:o,sizePct:u,sizePts:h,fontFamily:d}:r?{type:"autoNum",numType:r.getAttribute("type")||"arabicPeriod",startAt:C(r,"startAt",1),color:o,sizePct:u,sizePts:h,fontFamily:d}:null}function _o(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return Hn(n).toLowerCase()+".";case"romanUcPeriod":return Hn(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";case"alphaLcPeriod":return String.fromCharCode(96+n)+".";case"alphaUcPeriod":return String.fromCharCode(64+n)+".";default:return n+"."}}function Hn(e){const n=[1e3,900,500,400,100,90,50,40,10,9,5,4,1],t=["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"];let s="";for(let i=0;i<n.length;i++)for(;e>=n[i];)s+=t[i],e-=n[i];return s}function Po(e,n,t,s,i){if(!n)return;const r=e.font.match(/(d+(?:.d+)?)px/),o=r?parseFloat(r[1]):16,l=n.sizePts!=null?n.sizePts*(o/12):o*n.sizePct;e.save(),n.color&&(e.fillStyle=ge(n.color),e.strokeStyle=e.fillStyle);const a=n.fontFamily?'"'+n.fontFamily+'", sans-serif':e.font.split(/\d+px\s+/)[1]||"sans-serif";if(e.font=l+"px "+a,n.type==="char")e.fillText(n.char,t,s);else if(n.type==="autoNum"){const c=n.numType+":"+n.startAt;i[c]===void 0&&(i[c]=n.startAt);const u=_o(n.numType,i[c]);i[c]++,e.fillText(u,t,s)}e.restore()}async function Vt(e,n,t,s,i,r,o,l,a,c=1800){if(!n)return;const u=m(n,"bodyPr"),h=D(u,"anchor","t"),d=D(u,"wrap","square"),p=D(u,"vert","horz"),g=C(u,"lIns",91440)*o,b=C(u,"tIns",45720)*o,_=C(u,"rIns",91440)*o,y=C(u,"bIns",45720)*o,w=t+g,x=s+b,P=i-g-_,v=r-b-y,k=d!=="none",S=p==="vert"||p==="vert270"||p==="eaVert";S&&(e.save(),p==="vert270"?(e.translate(t+i,s),e.rotate(Math.PI/2)):(e.translate(t,s+r),e.rotate(-Math.PI/2)));const N=m(u,"normAutoFit")||m(n,"normAutoFit");m(u,"spAutoFit")||m(n,"spAutoFit");const M=N?N.getAttribute("fontScale"):null;let F=M?parseInt(M,10)/1e5:1;const T=m(n,"lstStyle"),$=T?m(T,"defRPr"):null;function L(ee,I,X,ne){const ae=ee?ee.getAttribute(X):null;if(ae!==null&&ae!=="")return ae;const ue=I?I.getAttribute(X):null;if(ue!==null&&ue!=="")return ue;const re=$?$.getAttribute(X):null;return re!==null&&re!==""?re:ne}const G=ce(n,"p"),q=[];let B=0;for(const ee of G){const I=m(ee,"pPr"),X=D(I,"algn","l");C(I,"lvl",0);const ne=C(I,"marL",0)*o,ae=C(I,"indent",0)*o,ue=I?xo(I,se,l):null,re=m(I,"spcBef"),Y=m(I,"spcAft"),ye=m(I,"lnSpc"),se=m(I,"defRPr");let oe=c;if($){const V=$.getAttribute("sz");V&&(oe=parseInt(V,10))}if(se){const V=se.getAttribute("sz");V&&(oe=parseInt(V,10))}let de=0,we=0;if(re){const V=m(re,"spcPct"),J=m(re,"spcPts");V?de=oe*127*o*(C(V,"val",0)/1e5):J&&(de=C(J,"val",0)*bt*o/100)}if(Y){const V=m(Y,"spcPct"),J=m(Y,"spcPts");V?we=oe*127*o*(C(V,"val",0)/1e5):J&&(we=C(J,"val",0)*bt*o/100)}const be=[];for(const V of ee.children){const J=V.localName;(J==="r"||J==="br"||J==="fld")&&be.push(V)}if(be.length===0){const V=m(ee,"endParaRPr"),Z=C(V||se,"sz",oe)*127*o*F;q.push({lines:[""],algn:X,marL:ne,spaceBefore:de,spaceAfter:we,szPx:Z,lnSpc:ye,runs:[],emptyPara:!0,bullet:ue}),B+=de+Z*1.2+we;continue}let R=[],W=[],E=0;for(const V of be){if(V.localName==="br"){R.push({runs:W,maxSzPx:Math.max(E,oe*127*o)}),W=[],E=0;continue}const J=m(V,"rPr"),Z=m(V,"t");let fe=Z?Z.textContent:"";const he=Ts(J,se,o*F,a,oe,$);e.font=he.fontStr;const le=he.szPx;le>E&&(E=le);const xe=io(J,se,l),Te=L(J,se,"u","none")!=="none",Ne=L(J,se,"strike","noStrike")!=="noStrike",Ae=parseInt(L(J,se,"baseline","0"),10);if(k){const Ct=fe.split(" ");for(let cn=0;cn<Ct.length;cn++){const dn=Ct[cn];let $n=ae+ne;for(const Mt of W)e.font=Mt.fontInfo.fontStr,$n+=e.measureText(Mt.text).width;e.font=he.fontStr;const Zs=e.measureText(dn).width,Js=W.length?e.measureText(" ").width:0;if($n+Js+Zs>P&&W.length>0)R.push({runs:W,maxSzPx:Math.max(E,le)}),W=[{text:dn,rPr:J,fontInfo:he,color:xe,underline:Te,strikethrough:Ne,baseline:Ae}],E=le;else{if(W.length>0){const Mt={text:" ",rPr:J,fontInfo:he,color:xe,underline:!1,strikethrough:!1,baseline:Ae};W.push(Mt)}W.push({text:dn,rPr:J,fontInfo:he,color:xe,underline:Te,strikethrough:Ne,baseline:Ae})}}}else W.push({text:fe,rPr:J,fontInfo:he,color:xe,underline:Te,strikethrough:Ne,baseline:Ae}),le>E&&(E=le)}W.length>0&&R.push({runs:W,maxSzPx:Math.max(E,oe*127*o)});const Q=ye?Ms(ye,oe*127*o*F,o):null;q.push({lines:R,algn:X,marL:ne,indent:ae,spaceBefore:de,spaceAfter:we,lnSpcPx:Q,emptyPara:!1,bullet:ue});for(const V of R)B+=de+(Q||V.maxSzPx*1.2)+we}if(N&&!M&&B>v&&v>0){let ee=.3,I=1;for(let X=0;X<8;X++){const ne=(ee+I)/2;let ae=0;for(const ue of G){const re=m(ue,"pPr"),Y=re?m(re,"defRPr"):null;let ye=c;if($){const Q=$.getAttribute("sz");Q&&(ye=parseInt(Q,10))}if(Y){const Q=Y.getAttribute("sz");Q&&(ye=parseInt(Q,10))}const se=Array.from(ue.children).filter(Q=>["r","br","fld"].includes(Q.localName)),oe=ye*127*o*ne;if(se.length===0){ae+=oe*1.2;continue}const de=se.reduce((Q,V)=>{const J=m(V,"t");return Q+(J?J.textContent.length:0)},0),we=P>0?P:i,be=de>0?se.reduce((Q,V)=>{const J=m(V,"t");return Q+(J?J.textContent:"")},"").slice(0,20):"W";e.font=`${oe}px sans-serif`;const R=be.length>0?e.measureText(be).width/be.length:oe*.6,W=Math.max(1,Math.floor(we/R)),E=Math.max(1,Math.ceil(de/W));ae+=E*oe*1.2}ae<=v?ee=ne:I=ne}F=(ee+I)/2}let U=x;h==="ctr"?U=x+(v-B)/2:h==="b"&&(U=x+v-B);let H=U;const K={};for(const ee of q){const{lines:I,algn:X,marL:ne,indent:ae,spaceBefore:ue,spaceAfter:re,lnSpcPx:Y,emptyPara:ye,bullet:se}=ee;if(H+=ue,ye){H+=I[0]?Y||ee.szPx*1.2:12*o,H+=re;continue}for(const oe of I){const{runs:de,maxSzPx:we}=oe,be=Y||we*1.2,R=H+we*.85;let W=0;for(const Z of de)e.font=Z.fontInfo.fontStr,W+=e.measureText(Z.text).width;let E=w+ne;X==="ctr"?E=w+(P-W)/2:X==="r"&&(E=w+P-W);const Q=oe===I[0];if(se&&Q){const Z=w+ne+ae;Po(e,se,Z,R,K)}let V=0;if(X==="just"&&!(oe===I[I.length-1])){let fe=0;for(const le of de)e.font=le.fontInfo.fontStr,fe+=(le.text.match(/ /g)||[]).length;const he=P-ne-W;fe>0&&he>0&&(V=he/fe)}const J=(Z,fe,he,le,xe,Te)=>{e.font=le.fontStr;const Ne=e.measureText(Z).width;e.fillText(Z,fe,he);const Ae=Math.max(.5,le.szPx*.07);return xe&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Ae,e.beginPath(),e.moveTo(fe,he+Ae*1.5),e.lineTo(fe+Ne,he+Ae*1.5),e.stroke(),e.restore()),Te&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Ae,e.beginPath(),e.moveTo(fe,he-le.szPx*.3),e.lineTo(fe+Ne,he-le.szPx*.3),e.stroke(),e.restore()),Ne};for(const Z of de){const fe=Z.color;e.fillStyle=fe?ge(fe):"#000000";let he=R,le=Z.fontInfo;if(Z.baseline!==0){const xe=le.szPx*.65,Te=`${le.italic?"italic ":""}${le.bold?"bold ":""}${xe}px "${le.family}", sans-serif`;le={...le,szPx:xe,fontStr:Te},Z.baseline>0?he=R-Z.fontInfo.szPx*.38:he=R+Z.fontInfo.szPx*.12}if(V>0&&Z.text.includes(" ")){e.font=le.fontStr;const xe=Z.text.split(" ");for(let Te=0;Te<xe.length;Te++){const Ne=J(xe[Te],E,he,le,Z.underline,Z.strikethrough);E+=Ne,Te<xe.length-1&&(e.font=le.fontStr,E+=e.measureText(" ").width+V)}}else{e.font=le.fontStr;const xe=e.measureText(Z.text).width;J(Z.text,E,he,le,Z.underline,Z.strikethrough),E+=xe}}H+=be}H+=re}S&&e.restore()}function Ns(e,n,t,s){const i=m(n,"effectLst");if(!i)return()=>{};const r=m(i,"outerShdw"),o=m(i,"innerShdw"),l=r||o;if(l){const c=C(l,"blurRad",38100)*s,u=C(l,"dist",38100)*s,d=C(l,"dir",27e5)/6e4*Math.PI/180,p=u*Math.cos(d),g=u*Math.sin(d),b=me(l),_=ve(b,t),y=_?ge(_):"rgba(0,0,0,0.35)";e.shadowBlur=Math.min(c,40),e.shadowOffsetX=p,e.shadowOffsetY=g,e.shadowColor=y}const a=m(i,"glow");if(a){const c=C(a,"rad",0)*s,u=me(a),h=ve(u,t);h&&(e.shadowBlur=Math.min(c,30),e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor=ge(h))}return()=>{e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor="transparent"}}async function en(e,n,t,s,i,r,o,l=null,a=null){const c=m(n,"spPr"),u=m(c,"xfrm");let h=0,d=0,p=0,g=0,b=0,_=!1,y=!1;if(u){const U=m(u,"off"),H=m(u,"ext");U&&(h=C(U,"x",0)*o,d=C(U,"y",0)*o),H&&(p=C(H,"cx",0)*o,g=C(H,"cy",0)*o),b=C(u,"rot",0)/6e4,_=D(u,"flipH","0")==="1",y=D(u,"flipV","0")==="1"}else{const U=Rs(n,a);if(U)h=U.x*o,d=U.y*o,p=U.w*o,g=U.h*o;else return}if(p<=0||g<=0)return;if(l){const{grpOff:U,grpExt:H,chOff:K,chExt:ee}=l,I=H.cx/ee.cx,X=H.cy/ee.cy;h=U.x+(h/o-K.x)*I*o,d=U.y+(d/o-K.y)*X*o,p=p*I,g=g*X}const w=h+p/2,x=d+g/2;e.save(),(b!==0||_||y)&&(e.translate(w,x),b!==0&&e.rotate(b*Math.PI/180),_&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x));const P=m(c,"prstGeom"),v=m(c,"custGeom"),k=P?D(P,"prst","rect"):"rect",S={};if(P){const U=m(P,"avLst");if(U){let H=0;for(const K of ce(U,"gd")){const I=D(K,"fmla","").match(/val\s+(-?\d+)/);I&&(S[H]=parseInt(I[1])),H++}}}const N=()=>{const U=["noFill","solidFill","gradFill","blipFill","pattFill","grpFill"];for(const K of U){const ee=m(c,K);if(ee)return ee}const H=m(n,"style");if(H){const K=m(H,"fillRef");if(K){if(C(K,"idx",1)===0)return ke("<noFill/>").documentElement;const I=me(K);if(I)return ke('<solidFill xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'">'+I.outerHTML+"</solidFill>").documentElement}}return null},M=()=>{const U=m(c,"ln");if(U)return U;const H=m(n,"style");if(H){const K=m(H,"lnRef");if(K){if(C(K,"idx",1)===0)return null;const I=me(K);if(I)return ke('<ln xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'"><solidFill>'+I.outerHTML+"</solidFill></ln>").documentElement}}return null};if(v){const U=m(v,"pathLst");if(U)for(const K of ce(U,"path")){const ee=C(K,"w",1)||1,I=C(K,"h",1)||1,X=p/ee,ne=g/I;e.beginPath();for(const re of K.children)switch(re.localName){case"moveTo":{const Y=m(re,"pt");Y&&e.moveTo(h+C(Y,"x",0)*X,d+C(Y,"y",0)*ne);break}case"lnTo":{const Y=m(re,"pt");Y&&e.lineTo(h+C(Y,"x",0)*X,d+C(Y,"y",0)*ne);break}case"cubicBezTo":{const Y=ce(re,"pt");Y.length>=3&&e.bezierCurveTo(h+C(Y[0],"x",0)*X,d+C(Y[0],"y",0)*ne,h+C(Y[1],"x",0)*X,d+C(Y[1],"y",0)*ne,h+C(Y[2],"x",0)*X,d+C(Y[2],"y",0)*ne);break}case"quadBezTo":{const Y=ce(re,"pt");Y.length>=2&&e.quadraticCurveTo(h+C(Y[0],"x",0)*X,d+C(Y[0],"y",0)*ne,h+C(Y[1],"x",0)*X,d+C(Y[1],"y",0)*ne);break}case"arcTo":{const Y=C(re,"wR",0)*X,ye=C(re,"hR",0)*ne,se=C(re,"stAng",0)/6e4*Math.PI/180,oe=C(re,"swAng",0)/6e4*Math.PI/180,de=e._lastX||h,we=e._lastY||d,be=de-Y*Math.cos(se),R=we-ye*Math.sin(se);Y===ye?e.arc(be,R,Y,se,se+oe,oe<0):e.ellipse(be,R,Y,ye,0,se,se+oe,oe<0);break}case"close":e.closePath();break}const ae=N();ae&&await kt(e,ae,h,d,p,g,o,i,s);const ue=M();ue&&at(e,ue,i,o)}e.restore();const H=m(n,"txBody");if(H){e.save(),e.beginPath(),e.rect(h,d,p,g),e.clip();const K=mn(n);await Vt(e,H,h,d,p,g,o,i,r,K),e.restore()}return}e.beginPath(),Kt(e,k,h,d,p,g,S);const F=Ns(e,c,i,o),T=h,$=d,L=p,G=g,q=ko(c)?wo(e,c,i,T,$,L,G,o):null;try{const U=N();let H=!1;U&&(H=await kt(e,U,h,d,p,g,o,i,s)),q&&q.overlay();const K=M();K?at(e,K,i,o):H||(k==="line"||k==="straightConnector1")&&(e.strokeStyle="#000",e.lineWidth=1,e.stroke())}finally{F(),q?.cleanup&&q.cleanup()}e.restore();const B=m(n,"txBody");if(B){e.save(),(b!==0||_||y)&&(e.translate(w,x),b!==0&&e.rotate(b*Math.PI/180),_&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x)),e.beginPath(),e.rect(h,d,p,g),e.clip();const U=mn(n);await Vt(e,B,h,d,p,g,o,i,r,U),e.restore()}}function mn(e,n){const t=m(e,"nvSpPr"),s=t?m(t,"nvPr"):null,i=s?m(s,"ph"):null;if(i){const r=D(i,"type","body");if(r==="title"||r==="ctrTitle")return 4400;if(r==="subTitle"||r==="body")return 2800}return 1800}function at(e,n,t,s){if(!n||m(n,"noFill"))return;const r=m(n,"solidFill"),o=m(n,"gradFill"),l=C(n,"w",12700),a=Math.max(.5,l*s);let c="#000000";if(r){const p=me(r),g=ve(p,t);g&&(c=ge(g))}else o&&(c="#888888");const u=m(n,"prstDash"),h=u?D(u,"val","solid"):"solid",d=D(n,"cap","flat");switch(D(n,"cmpd","sng"),e.strokeStyle=c,e.lineWidth=a,e.lineCap=d==="rnd"?"round":d==="sq"?"square":"butt",e.lineJoin="round",h){case"dash":e.setLineDash([a*4,a*2]);break;case"dot":e.setLineDash([a,a*2]);break;case"dashDot":e.setLineDash([a*4,a*2,a,a*2]);break;case"lgDash":e.setLineDash([a*8,a*3]);break;case"lgDashDot":e.setLineDash([a*8,a*3,a,a*3]);break;default:e.setLineDash([])}e.stroke(),e.setLineDash([])}async function tn(e,n,t,s,i,r){const o=m(n,"spPr"),l=m(o,"xfrm");if(!l)return;const a=m(l,"off"),c=m(l,"ext");if(!a||!c)return;const u=C(a,"x",0)*r,h=C(a,"y",0)*r,d=C(c,"cx",0)*r,p=C(c,"cy",0)*r,g=C(l,"rot",0)/6e4,b=D(l,"flipH","0")==="1",_=D(l,"flipV","0")==="1";if(d<=0||p<=0)return;const y=m(n,"blipFill"),w=y?m(y,"blip"):null,x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,P=u+d/2,v=h+p/2;if(e.save(),(g!==0||b||_)&&(e.translate(P,v),g!==0&&e.rotate(g*Math.PI/180),b&&e.scale(-1,1),_&&e.scale(1,-1),e.translate(-P,-v)),x&&s[x]){const k=s[x],S=m(o,"prstGeom"),N=S?D(S,"prst","rect"):"rect",M={};if(S){const $=m(S,"avLst");if($){let L=0;for(const G of ce($,"gd")){const q=(D(G,"fmla","")||"").match(/val\s+(-?\d+)/);q&&(M[L]=parseInt(q[1])),L++}}}e.beginPath(),Kt(e,N,u,h,d,p,M),e.clip();const F=y?m(y,"srcRect"):null;if(F){const $=C(F,"l",0)/1e5,L=C(F,"t",0)/1e5,G=C(F,"r",0)/1e5,q=C(F,"b",0)/1e5,B=k.naturalWidth*(1-$-G),U=k.naturalHeight*(1-L-q);e.drawImage(k,k.naturalWidth*$,k.naturalHeight*L,B,U,u,h,d,p)}else e.drawImage(k,u,h,d,p);const T=m(o,"ln");T&&(e.beginPath(),Kt(e,N,u,h,d,p,M),at(e,T,i,r))}else e.fillStyle="#e0e0e0",e.fillRect(u,h,d,p),e.strokeStyle="#aaa",e.lineWidth=1,e.strokeRect(u,h,d,p),e.beginPath(),e.moveTo(u,h),e.lineTo(u+d,h+p),e.moveTo(u+d,h),e.lineTo(u,h+p),e.stroke();e.restore()}async function As(e,n,t,s,i){const r=m(n,"xfrm");if(!r)return;const o=m(r,"off"),l=m(r,"ext");if(!o||!l)return;const a=C(o,"x",0)*i,c=C(o,"y",0)*i;C(l,"cx",0)*i,C(l,"cy",0)*i;const u=m(n,"graphic"),h=u?m(u,"graphicData"):null,d=h?m(h,"tbl"):null;if(!d)return;const p=m(d,"tblPr"),g=p?D(p,"bandRow","0")==="1":!1;p&&D(p,"bandCol","0");const b=p?D(p,"firstRow","0")==="1":!1,_=p?D(p,"lastRow","0")==="1":!1;p&&D(p,"firstCol","0"),p&&D(p,"lastCol","0");const y=m(d,"tblGrid"),w=ce(y,"gridCol").map(v=>C(v,"w",0)*i),x=ce(d,"tr");let P=c;for(let v=0;v<x.length;v++){const k=x[v],S=C(k,"h",457200)*i,N=ce(k,"tc");let M=a;const F=v===0,T=v===x.length-1,$=v%2===1;for(let L=0;L<N.length;L++){const G=N[L],q=C(G,"gridSpan",1);D(G,"vMerge","0");let B=0;for(let I=0;I<q;I++)B+=w[L+I]||0;const U=m(G,"tcPr"),H=U?["noFill","solidFill","gradFill","blipFill","pattFill"].map(I=>m(U,I)).find(Boolean):null;if(e.save(),e.beginPath(),e.rect(M,P,B,S),H)await kt(e,H,M,P,B,S,i,t,null);else{let I=null;b&&F?I=t.accent1?"#"+t.accent1.toLowerCase():"#4472C4":_&&T?I="#e0e0e0":g&&$&&(I="rgba(0,0,0,0.06)"),e.fillStyle=I||"transparent",I&&e.fill()}const K=[{el:m(U,"lnL"),x1:M,y1:P,x2:M,y2:P+S},{el:m(U,"lnR"),x1:M+B,y1:P,x2:M+B,y2:P+S},{el:m(U,"lnT"),x1:M,y1:P,x2:M+B,y2:P},{el:m(U,"lnB"),x1:M,y1:P+S,x2:M+B,y2:P+S}];for(const I of K)I.el?m(I.el,"noFill")||(e.beginPath(),e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),at(e,I.el,t,i)):(e.beginPath(),e.strokeStyle="#cccccc",e.lineWidth=.5,e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),e.stroke());e.restore();const ee=m(G,"txBody");ee&&(e.save(),e.beginPath(),e.rect(M,P,B,S),e.clip(),await Vt(e,ee,M,P,B,S,i,t,s,1400),e.restore()),M+=B}P+=S}}async function nn(e,n,t,s,i,r,o){const l=m(n,"grpSpPr"),a=m(l,"xfrm");if(!a)return;const c=m(a,"off"),u=m(a,"ext"),h=m(a,"chOff"),d=m(a,"chExt");if(!c||!u||!h||!d)return;const p=C(a,"rot",0)/6e4,g=D(a,"flipH","0")==="1",b=D(a,"flipV","0")==="1",_={grpOff:{x:C(c,"x",0)*o,y:C(c,"y",0)*o},grpExt:{cx:C(u,"cx",0)*o,cy:C(u,"cy",0)*o},chOff:{x:C(h,"x",0),y:C(h,"y",0)},chExt:{cx:C(d,"cx",1),cy:C(d,"cy",1)}},y=_.grpOff.x+_.grpExt.cx/2,w=_.grpOff.y+_.grpExt.cy/2;e.save(),(p!==0||g||b)&&(e.translate(y,w),p!==0&&e.rotate(p*Math.PI/180),g&&e.scale(-1,1),b&&e.scale(1,-1),e.translate(-y,-w));for(const x of n.children){const P=x.localName;P==="sp"?await en(e,x,t,s,i,r,o,_):P==="pic"?await tn(e,x,t,s,i,o):P==="grpSp"?await nn(e,x,t,s,i,r,o):P==="graphicFrame"?await rn(e,x,i,r,o,files,t):P==="cxnSp"&&await sn(e,x,i,o)}e.restore()}function Yn(e,n,t,s,i,r,o,l,a){const c=m(n,t);if(!c)return;const u=c.getAttribute("type")||"none";if(u==="none")return;const h={sm:3,med:6,lg:9},d=Math.max(.5,C(n,"w",12700)*a),p=d*(h[c.getAttribute("w")||"med"]??6),g=d*(h[c.getAttribute("len")||"med"]??6),b=Math.atan2(o-i,r-s);switch(e.save(),e.fillStyle=e.strokeStyle,e.strokeStyle=e.strokeStyle,u){case"triangle":case"arrow":case"stealth":{const _=u==="arrow",y=u==="stealth"?g*.5:0;e.beginPath(),e.moveTo(s,i),e.lineTo(s+g*Math.cos(b)+p/2*Math.sin(b),i+g*Math.sin(b)-p/2*Math.cos(b)),_||e.lineTo(s+y*Math.cos(b),i+y*Math.sin(b)),e.lineTo(s+g*Math.cos(b)-p/2*Math.sin(b),i+g*Math.sin(b)+p/2*Math.cos(b)),e.closePath(),_?e.stroke():e.fill();break}case"diamond":{const _=g/2;e.beginPath(),e.moveTo(s,i),e.lineTo(s+_*Math.cos(b)+p/2*Math.sin(b),i+_*Math.sin(b)-p/2*Math.cos(b)),e.lineTo(s+g*Math.cos(b),i+g*Math.sin(b)),e.lineTo(s+_*Math.cos(b)-p/2*Math.sin(b),i+_*Math.sin(b)+p/2*Math.cos(b)),e.closePath(),e.fill();break}case"oval":{const _=g/2,y=p/2,w=s+_*Math.cos(b),x=i+_*Math.sin(b);e.beginPath(),e.save(),e.translate(w,x),e.rotate(b),e.scale(1,y/_),e.arc(0,0,_,0,Math.PI*2),e.restore(),e.fill();break}}e.restore()}async function sn(e,n,t,s){const i=m(n,"spPr"),r=m(i,"xfrm");if(!r)return;const o=m(r,"off"),l=m(r,"ext");if(!o||!l)return;const a=C(o,"x",0)*s,c=C(o,"y",0)*s,u=C(l,"cx",0)*s,h=C(l,"cy",0)*s,d=C(r,"rot",0)/6e4,p=D(r,"flipH","0")==="1",g=D(r,"flipV","0")==="1",b=a+u/2,_=c+h/2,y=m(i,"ln");e.save(),(d!==0||p||g)&&(e.translate(b,_),d!==0&&e.rotate(d*Math.PI/180),p&&e.scale(-1,1),g&&e.scale(1,-1),e.translate(-b,-_));const w=m(i,"prstGeom"),x=w?D(w,"prst","line"):"line",P=x==="line"||x==="straightConnector1";if(e.beginPath(),P){const v=p?a:a+u,k=g?c:c+h,S=p?a+u:a,N=g?c+h:c;e.moveTo(S,N),e.lineTo(v,k)}else Kt(e,x,a,c,u,h,{});if(y){if(at(e,y,t,s),P){const v=p?a+u:a,k=g?c+h:c,S=p?a:a+u,N=g?c:c+h;Yn(e,y,"headEnd",S,N,v,k,t,s),Yn(e,y,"tailEnd",v,k,S,N,t,s)}}else e.strokeStyle="#000",e.lineWidth=1,e.stroke();e.restore()}async function $s(e,n,t,s,i,r,o,l,a,c,u){const h=c*a,d=u*a,p=x=>{const P=m(x,"cSld");if(!P)return null;const v=m(P,"bg");if(!v)return null;const k=m(v,"bgPr"),S=m(v,"bgRef");return{bgPr:k,bgRef:S}},g=n?p(n):null,b=s?p(s):null,_=t?p(t):null,y=g||b||_;let w=!1;if(y){const{bgPr:x,bgRef:P}=y;if(x){const v=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const k of v){const S=m(x,k);if(S){e.beginPath(),e.rect(0,0,h,d);const N=y===_?Object.assign({},o):o;await kt(e,S,0,0,h,d,1,l,N)&&(w=!0);break}}}else if(P){C(P,"idx",0);const v=me(P),k=ve(v,l);k&&(e.fillStyle=ge(k),e.fillRect(0,0,h,d),w=!0)}}w||(e.fillStyle="#ffffff",e.fillRect(0,0,h,d))}function Es(e){const n={};for(const t of e){if(!t)continue;const s=m(t,"cSld"),i=s?m(s,"spTree"):null;if(i)for(const r of ce(i,"sp")){const o=m(r,"nvSpPr"),l=o?m(o,"nvPr"):null,a=l?m(l,"ph"):null;if(!a)continue;const c=D(a,"type","body"),u=D(a,"idx","0"),h=`${c}:${u}`;if(n[h])continue;const d=m(r,"spPr"),p=m(d,"xfrm");if(!p)continue;const g=m(p,"off"),b=m(p,"ext");!g||!b||(n[h]={x:C(g,"x",0),y:C(g,"y",0),w:C(b,"cx",0),h:C(b,"cy",0),txBody:m(r,"txBody")})}}return n}function Rs(e,n){if(!n)return null;const t=m(e,"nvSpPr"),s=t?m(t,"nvPr"):null,i=s?m(s,"ph"):null;if(!i)return null;const r=D(i,"type","body"),o=D(i,"idx","0");return n[`${r}:${o}`]||n[`${r}:0`]||n[`body:${o}`]||null}async function rn(e,n,t,s,i,r,o){const l=m(n,"graphic"),a=l?m(l,"graphicData"):null,c=a?D(a,"uri",""):"";if(m(n,"tbl")||a&&m(a,"tbl"))return As(e,n,t,s,i);const u=m(n,"xfrm");if(!u)return;const h=m(u,"off"),d=m(u,"ext");if(!h||!d)return;const p=C(h,"x",0)*i,g=C(h,"y",0)*i,b=C(d,"cx",0)*i,_=C(d,"cy",0)*i;if(b<=0||_<=0)return;const y=c.includes("chart"),w=c.includes("diagram");if(y&&r&&o){const P=a?m(a,"chart"):null,v=P?P.getAttribute("r:id")||P.getAttribute("id"):null,k=v?o[v]:null;if(k&&r[k.fullPath]){const S=new TextDecoder().decode(r[k.fullPath]),N=ke(S);po(e,N,p,g,b,_,t,i);return}}if(w&&r&&o){const P=a?m(a,"relIds"):null,v=P?P.getAttribute("r:dm")||P.getAttribute("dm"):null,k=v?o[v]:null;if(k&&r[k.fullPath]){const S=new TextDecoder().decode(r[k.fullPath]),N=ke(S),M=P?P.getAttribute("r:lo")||P.getAttribute("lo"):null,F=M?o[M]:null,T=F&&r[F.fullPath]?ke(new TextDecoder().decode(r[F.fullPath])):null,{renderSmartArt:$}=await Qt(async()=>{const{renderSmartArt:L}=await import("./smartart-Dx8zw2rK.js");return{renderSmartArt:L}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url);$(e,N,T,p,g,b,_,t,i);return}}const x=y?"📊 Chart":w?"🔷 Diagram":"⬛ Graphic";e.save(),e.fillStyle="#f4f4f8",e.strokeStyle="#ccccdd",e.lineWidth=1,e.fillRect(p,g,b,_),e.strokeRect(p,g,b,_),e.fillStyle="#999",e.font=`${Math.min(b*.07,16*i)}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(x,p+b/2,g+_/2),e.textAlign="start",e.textBaseline="alphabetic",e.restore()}async function Is(e,n,t,s,i,r,o,l,a){if(n)for(const c of n.children){const u=c.localName;try{u==="sp"?await en(e,c,t,s,i,r,o,null,l):u==="pic"?await tn(e,c,t,s,i,o):u==="grpSp"?await nn(e,c,t,s,i,r,o):u==="graphicFrame"?await rn(e,c,i,r,o,a,t):u==="cxnSp"&&await sn(e,c,i,o)}catch(h){console.warn("Error rendering shape:",u,h)}}}const So=Object.freeze(Object.defineProperty({__proto__:null,applyEffects:Ns,applyFill:kt,applyOutline:at,buildPlaceholderMap:Es,computeLineHeight:Ms,getDefaultFontSize:mn,getRels:Le,loadImages:Gt,renderBackground:$s,renderConnector:sn,renderGraphicFrame:rn,renderGroupShape:nn,renderPicture:tn,renderShape:en,renderSpTree:Is,renderTable:As,renderTextBody:Vt,resolvePlaceholderXfrm:Rs},Symbol.toStringTag,{value:"Module"}));async function To(e){const n=new CompressionStream("deflate-raw"),t=n.writable.getWriter(),s=n.readable.getReader();t.write(e),t.close();const i=[];let r=0;for(;;){const{value:a,done:c}=await s.read();if(c)break;i.push(a),r+=a.length}const o=new Uint8Array(r);let l=0;for(const a of i)o.set(a,l),l+=a.length;return o}const jo=(()=>{const e=new Uint32Array(256);for(let n=0;n<256;n++){let t=n;for(let s=0;s<8;s++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t}return e})();function Fo(e){let n=4294967295;for(let t=0;t<e.length;t++)n=jo[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}class Co{constructor(){this._chunks=[],this._size=0}append(n){this._chunks.push(n),this._size+=n.length}get size(){return this._size}concat(){const n=new Uint8Array(this._size);let t=0;for(const s of this._chunks)n.set(s,t),t+=s.length;return n}}function pe(e){return new Uint8Array([e&255,e>>8&255])}function Re(e){return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}const zs=new TextEncoder;function Mo(e){return zs.encode(e)}const Qn=18977,Zn=0;class No{constructor(){this._entries=[]}async addText(n,t){return this.addBytes(n,zs.encode(t))}async addBytes(n,t,s=!0){const i=Mo(n),r=Fo(t),o=t.length;let l,a;if(s&&t.length>32){const c=await To(t);c.length<t.length?(l=c,a=8):(l=t,a=0)}else l=t,a=0;this._entries.push({name:n,nameBytes:i,compData:l,uncompSize:o,crc:r,method:a,localOffset:0})}async finalize(){const n=new Co;for(const i of this._entries)i.localOffset=n.size,n.append(new Uint8Array([80,75,3,4])),n.append(pe(20)),n.append(pe(2048)),n.append(pe(i.method)),n.append(pe(Zn)),n.append(pe(Qn)),n.append(Re(i.crc)),n.append(Re(i.compData.length)),n.append(Re(i.uncompSize)),n.append(pe(i.nameBytes.length)),n.append(pe(0)),n.append(i.nameBytes),n.append(i.compData);const t=n.size;for(const i of this._entries)n.append(new Uint8Array([80,75,1,2])),n.append(pe(798)),n.append(pe(20)),n.append(pe(2048)),n.append(pe(i.method)),n.append(pe(Zn)),n.append(pe(Qn)),n.append(Re(i.crc)),n.append(Re(i.compData.length)),n.append(Re(i.uncompSize)),n.append(pe(i.nameBytes.length)),n.append(pe(0)),n.append(pe(0)),n.append(pe(0)),n.append(pe(0)),n.append(Re(0)),n.append(Re(i.localOffset)),n.append(i.nameBytes);const s=n.size-t;return n.append(new Uint8Array([80,75,5,6])),n.append(pe(0)),n.append(pe(0)),n.append(pe(this._entries.length)),n.append(pe(this._entries.length)),n.append(Re(s)),n.append(Re(t)),n.append(pe(0)),n.concat()}}async function Ao(e){const n=new No;for(const[t,s]of Object.entries(e))typeof s=="string"?await n.addText(t,s):await n.addBytes(t,s);return n.finalize()}const $o=new TextDecoder,Ds=new TextEncoder,_e={p:"http://schemas.openxmlformats.org/presentationml/2006/main",a:"http://schemas.openxmlformats.org/drawingml/2006/main",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",rel:"http://schemas.openxmlformats.org/package/2006/relationships",ct:"http://schemas.openxmlformats.org/package/2006/content-types"};function gt(e){return new DOMParser().parseFromString(e,"application/xml")}function Eo(e){const n=new XMLSerializer().serializeToString(e);return n.startsWith("<?xml")?n:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
|
|
35
|
-
`+n}function Me(e){return Ds.encode(Eo(e))}function ze(e,n){const t=e[n];return t?gt($o.decode(t)):null}function ie(e,n){if(!e)return null;const t=e.getElementsByTagName("*");for(let s=0;s<t.length;s++)if(t[s].localName===n)return t[s];return null}function De(e,n){if(!e)return[];const t=[],s=e.getElementsByTagName("*");for(let i=0;i<s.length;i++)s[i].localName===n&&t.push(s[i]);return t}function Ro(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function He(e){const n=e.split("/"),t=n.pop();return[...n,"_rels",t+".rels"].join("/")}function Ve(e,n){const t=ze(e,He(n));if(!t)return{};const s={};for(const i of Array.from(t.getElementsByTagName("Relationship"))){const r=i.getAttribute("Id"),o=i.getAttribute("Target"),l=i.getAttribute("Type")||"";let a=o;if(!o.startsWith("/")&&!o.startsWith("http")){const c=n.split("/").slice(0,-1).join("/");a=c?c+"/"+o.replace(/^\.\.\//,""):o;const u=a.split("/"),h=[];for(const d of u)d===".."?h.pop():h.push(d);a=h.join("/")}s[r]={id:r,target:o,type:l,fullPath:a}}return s}function Et(e){const n=gt('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>'),t=n.documentElement;for(const s of Object.values(e)){const i=n.createElementNS(_e.rel,"Relationship");i.setAttribute("Id",s.id),i.setAttribute("Type",s.type),i.setAttribute("Target",s.target),s.targetMode&&i.setAttribute("TargetMode",s.targetMode),t.appendChild(i)}return n}function Rt(e){const n=Object.keys(e).map(t=>parseInt(t.replace("rId",""),10)).filter(t=>!isNaN(t));return"rId"+((n.length?Math.max(...n):0)+1)}function Wt(e,n){for(const t of e.children){const s=t.localName;if(s==="sp"||s==="pic"||s==="cxnSp"){const i=ie(t,"nvSpPr")||ie(t,"nvPicPr")||ie(t,"nvCxnSpPr"),r=i?ie(i,"cNvPr"):null;if(r&&(r.getAttribute("name")||"")===n)return t}else if(s==="grpSp"){const i=Wt(t,n);if(i)return i}}return null}function nt(e){const n=ie(e,"cSld");return n?ie(n,"spTree"):null}function It(e,n,t,s=!0){for(const i of De(e,"t")){const r=i.textContent;if(!r)continue;const o=s?r.split(n).join(t):r.replace(new RegExp(Io(n),"gi"),t);o!==r&&(i.textContent=o)}}function Io(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Jn={"image/jpeg":"jpeg","image/jpg":"jpeg","image/png":"png","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"},zo={jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml"};function es(e,n,t){const s="[Content_Types].xml",i=ze(e,s);if(!i)return;const r=i.documentElement;for(const l of De(i,"Override"))if(l.getAttribute("PartName")==="/"+t)return;const o=i.createElementNS(_e.ct,"Override");o.setAttribute("PartName","/"+t),o.setAttribute("ContentType",zo[n]||"application/octet-stream"),r.appendChild(o),e[s]=Me(i)}class Ht{constructor(n){this._files=n,this._presPath="ppt/presentation.xml",this._presDoc=ze(n,this._presPath),this._presRels=Ve(n,this._presPath),this._slidePaths=this._buildSlidePaths()}static fromRenderer(n){const t={};for(const[s,i]of Object.entries(n._files))t[s]=i instanceof Uint8Array?i.slice():i;return new Ht(t)}static async fromBytes(n){const t=await Ps(n);return new Ht(t)}_buildSlidePaths(){if(!this._presDoc)return[];const n=ie(this._presDoc,"sldIdLst");if(!n)return[];const t=[];for(const s of n.children){if(s.localName!=="sldId")continue;const i=s.getAttribute("r:id")||s.getAttribute("id"),r=this._presRels[i];r&&t.push(r.fullPath)}return t}_savePresDoc(){this._files[this._presPath]=Me(this._presDoc)}_savePresRels(){this._files[He(this._presPath)]=Me(Et(this._presRels))}getSlidePaths(){return[...this._slidePaths]}getSlideCount(){return this._slidePaths.length}_slideDoc(n){const t=this._slidePaths[n];if(!t)throw new RangeError(`Slide ${n} out of range`);return ze(this._files,t)}_saveSlideDoc(n,t){this._files[this._slidePaths[n]]=Me(t)}applyTemplate(n,t={}){const{open:s="{{",close:i="}}",slides:r}=t,o=r??this._slidePaths.map((l,a)=>a);for(const l of o){const a=this._slideDoc(l);for(const[c,u]of Object.entries(n)){const h=s+c+i;It(a,h,String(u))}this._saveSlideDoc(l,a)}for(const l of o)this._applyTemplateToNotes(l,n,s,i)}_applyTemplateToNotes(n,t,s,i){const r=Ve(this._files,this._slidePaths[n]),o=Object.values(r).find(a=>a.type?.includes("notesSlide"));if(!o)return;const l=ze(this._files,o.fullPath);if(l){for(const[a,c]of Object.entries(t))It(l,s+a+i,String(c));this._files[o.fullPath]=Me(l)}}replaceText(n,t,s={}){const{caseSensitive:i=!0,includeNotes:r=!1,slides:o}=s,l=o??this._slidePaths.map((a,c)=>c);for(const a of l){const c=this._slideDoc(a);if(It(c,n,t,i),this._saveSlideDoc(a,c),r){const u=Ve(this._files,this._slidePaths[a]),h=Object.values(u).find(d=>d.type?.includes("notesSlide"));if(h){const d=ze(this._files,h.fullPath);d&&(It(d,n,t,i),this._files[h.fullPath]=Me(d))}}}}setShapeText(n,t,s,i={}){const{preserveFormatting:r=!0}=i,o=this._slideDoc(n),l=nt(o);if(!l)return this;const a=Wt(l,t);if(!a)throw new Error(`Shape "${t}" not found on slide ${n}`);const c=ie(a,"txBody");if(!c)return this;const u=ie(c,"r"),h=u?ie(u,"rPr"):null,d=ie(ie(c,"p"),"pPr");for(const b of De(c,"p"))b.parentNode.removeChild(b);const p=s.split(`
|
|
36
|
-
`),g=_e.a;for(const b of p){const _=o.createElementNS(g,"a:p");d&&r&&_.appendChild(d.cloneNode(!0));const y=o.createElementNS(g,"a:r");h&&r&&y.appendChild(h.cloneNode(!0));const w=o.createElementNS(g,"a:t");w.textContent=b,y.appendChild(w),_.appendChild(y),c.appendChild(_)}return this._saveSlideDoc(n,o),this}getShapeText(n,t){const s=this._slideDoc(n),i=nt(s);if(!i)return"";const r=Wt(i,t);return r?De(r,"t").map(o=>o.textContent).join(""):""}addTextBox(n,t,s={}){const{x:i=914400,y:r=914400,w:o=4572e3,h:l=914400,color:a="000000",fontSize:c=1800,bold:u=!1,align:h="l",fontFamily:d="Calibri"}=s,p=this._slideDoc(n),g=nt(p);if(!g)return this;const _=Math.max(0,...De(g,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,y=`TextBox ${_}`,w=_e.a,P=`<p:sp xmlns:p="${_e.p}" xmlns:a="${w}">
|
|
37
|
-
<p:nvSpPr>
|
|
38
|
-
<p:cNvPr id="${_}" name="${y}"/>
|
|
39
|
-
<p:cNvSpPr txBox="1"><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
40
|
-
<p:nvPr/>
|
|
41
|
-
</p:nvSpPr>
|
|
42
|
-
<p:spPr>
|
|
43
|
-
<a:xfrm><a:off x="${i}" y="${r}"/><a:ext cx="${o}" cy="${l}"/></a:xfrm>
|
|
44
|
-
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
45
|
-
<a:noFill/>
|
|
46
|
-
</p:spPr>
|
|
47
|
-
<p:txBody>
|
|
48
|
-
<a:bodyPr wrap="square" rtlCol="0"><a:spAutoFit/></a:bodyPr>
|
|
49
|
-
<a:lstStyle/>
|
|
50
|
-
<a:p>
|
|
51
|
-
<a:pPr algn="${h}"/>
|
|
52
|
-
<a:r>
|
|
53
|
-
<a:rPr lang="en-US" sz="${c}" b="${u?1:0}" dirty="0">
|
|
54
|
-
<a:solidFill><a:srgbClr val="${a}"/></a:solidFill>
|
|
55
|
-
<a:latin typeface="${d}"/>
|
|
56
|
-
</a:rPr>
|
|
57
|
-
<a:t>${t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</a:t>
|
|
58
|
-
</a:r>
|
|
59
|
-
</a:p>
|
|
60
|
-
</p:txBody>
|
|
61
|
-
</p:sp>`,v=gt(P);return g.appendChild(p.adoptNode(v.documentElement)),this._saveSlideDoc(n,p),this}async setShapeImage(n,t,s,i="image/jpeg"){const r=this._slideDoc(n),o=nt(r);if(!o)return this;const l=Wt(o,t);if(!l)throw new Error(`Shape "${t}" not found on slide ${n}`);const a=Ve(this._files,this._slidePaths[n]),c=ie(l,"blipFill"),u=c?ie(c,"blip"):null,h=u?u.getAttribute("r:embed")||u.getAttribute("embed"):null,d=h?a[h]:null,p=Jn[i]||"jpeg",g=Object.keys(this._files).filter(y=>y.startsWith("ppt/media/")).length+1,b=`ppt/media/image${g}.${p}`;this._files[b]=s;let _;return h&&d?(_=h,a[_]={id:_,type:d.type,target:`../media/image${g}.${p}`,fullPath:b}):(_=Rt(a),a[_]={id:_,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${g}.${p}`,fullPath:b}),u&&u.setAttribute("r:embed",_),this._files[He(this._slidePaths[n])]=Me(Et(a)),this._saveSlideDoc(n,r),es(this._files,p,b),this}async addImage(n,t,s="image/jpeg",i={}){const{x:r=914400,y:o=914400,w:l=2743200,h:a=2057400}=i,c=Jn[s]||"jpeg",u=Object.keys(this._files).filter(k=>k.startsWith("ppt/media/")).length+1,h=`ppt/media/image${u}.${c}`;this._files[h]=t;const d=Ve(this._files,this._slidePaths[n]),p=Rt(d);d[p]={id:p,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${u}.${c}`,fullPath:h},this._files[He(this._slidePaths[n])]=Me(Et(d));const g=this._slideDoc(n),b=nt(g);if(!b)return this;const y=Math.max(0,...De(b,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,w=_e.a,P=`<p:pic xmlns:p="${_e.p}" xmlns:a="${w}" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
62
|
-
<p:nvPicPr>
|
|
63
|
-
<p:cNvPr id="${y}" name="Picture ${y}"/>
|
|
64
|
-
<p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>
|
|
65
|
-
<p:nvPr/>
|
|
66
|
-
</p:nvPicPr>
|
|
67
|
-
<p:blipFill>
|
|
68
|
-
<a:blip r:embed="${p}"/>
|
|
69
|
-
<a:stretch><a:fillRect/></a:stretch>
|
|
70
|
-
</p:blipFill>
|
|
71
|
-
<p:spPr>
|
|
72
|
-
<a:xfrm><a:off x="${r}" y="${o}"/><a:ext cx="${l}" cy="${a}"/></a:xfrm>
|
|
73
|
-
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
74
|
-
</p:spPr>
|
|
75
|
-
</p:pic>`,v=gt(P);return b.appendChild(g.adoptNode(v.documentElement)),this._saveSlideDoc(n,g),es(this._files,c,h),this}setSlideBackground(n,t){const s=this._slideDoc(n),i=ie(s,"cSld");if(!i)return this;const r=ie(i,"bg");r&&i.removeChild(r);const o=_e.a,a=`<p:bg xmlns:p="${_e.p}" xmlns:a="${o}">
|
|
76
|
-
<p:bgPr><a:solidFill><a:srgbClr val="${t}"/></a:solidFill>
|
|
77
|
-
<a:effectLst/></p:bgPr></p:bg>`,c=s.adoptNode(gt(a).documentElement);return i.insertBefore(c,i.firstChild),this._saveSlideDoc(n,s),this}setThemeColor(n,t){const s=this._presRels;let i=Object.values(s).find(l=>l.type?.includes("theme"))?.fullPath;if(!i){const l=Object.values(s).find(a=>a.type?.includes("slideMaster"));if(l){const a=Ve(this._files,l.fullPath);i=Object.values(a).find(c=>c.type?.includes("theme"))?.fullPath}}if(!i)return this;const r=ze(this._files,i);if(!r)return this;ie(r,"fmtScheme");const o=ie(r,"clrScheme");if(!o)return this;for(const l of o.children)if(l.localName===n){const a=ie(l,"srgbClr");if(a)a.setAttribute("val",t);else{for(;l.firstChild;)l.removeChild(l.firstChild);const c=_e.a,u=r.createElementNS(c,"a:srgbClr");u.setAttribute("val",t),l.appendChild(u)}break}return this._files[i]=Me(r),this}duplicateSlide(n,t){const s=t??this._slidePaths.length,i=this._slidePaths[n];if(!i)throw new RangeError(`Slide ${n} out of range`);const r=Object.keys(this._files).map(b=>b.match(/ppt\/slides\/slide(\d+)\.xml/)).filter(Boolean).map(b=>parseInt(b[1],10)),o=(r.length?Math.max(...r):0)+1,l=`ppt/slides/slide${o}.xml`,a=He(l);this._files[l]=this._files[i].slice();const c=He(i);this._files[c]&&(this._files[a]=this._files[c].slice());const u=Rt(this._presRels),h=`slides/slide${o}.xml`;this._presRels[u]={id:u,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",target:h,fullPath:l},this._savePresRels();const d=ie(this._presDoc,"sldIdLst");if(d){const b=De(d,"sldId").map(P=>parseInt(P.getAttribute("id")||"0",10)),_=(b.length?Math.max(...b):255)+1,y=_e.p,w=this._presDoc.createElementNS(y,"p:sldId");w.setAttribute("id",String(_)),w.setAttributeNS(_e.r,"r:id",u);const x=Array.from(d.children);s>=x.length?d.appendChild(w):d.insertBefore(w,x[s])}this._savePresDoc(),this._slidePaths=this._buildSlidePaths();const p="[Content_Types].xml",g=ze(this._files,p);if(g){const b=g.documentElement,_=g.createElementNS(_e.ct,"Override");_.setAttribute("PartName","/"+l),_.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),b.appendChild(_),this._files[p]=Me(g)}return this}removeSlide(n){if(this._slidePaths.length<=1)throw new Error("Cannot remove the last slide");const t=this._slidePaths[n];if(!t)throw new RangeError(`Slide ${n} out of range`);const s=ie(this._presDoc,"sldIdLst");if(s)for(const i of Array.from(s.children)){const r=i.getAttribute("r:id")||i.getAttribute("id"),o=this._presRels[r];if(o&&o.fullPath===t){s.removeChild(i),delete this._presRels[r];break}}return this._savePresDoc(),this._savePresRels(),this._slidePaths=this._buildSlidePaths(),this}reorderSlides(n){if(n.length!==this._slidePaths.length)throw new Error("newOrder must have the same length as the current slide count");const t=ie(this._presDoc,"sldIdLst");if(!t)return this;const s=Array.from(t.children).filter(i=>i.localName==="sldId");for(const i of s)t.removeChild(i);for(const i of n)s[i]&&t.appendChild(s[i]);return this._savePresDoc(),this._slidePaths=this._buildSlidePaths(),this}setSlideNotes(n,t){const s=this._slidePaths[n],i=Ve(this._files,s),r=Object.values(i).find(o=>o.type?.includes("notesSlide"));if(r){const o=ze(this._files,r.fullPath);if(o){for(const l of De(o,"sp")){const a=ie(ie(l,"nvSpPr"),"nvPr"),c=a?ie(a,"ph"):null;if(c&&Ro(c,"type")!=="sldNum"){for(const h of De(l,"t"))h.textContent="";const u=ie(l,"t");u&&(u.textContent=t);break}}this._files[r.fullPath]=Me(o)}}else this._createNotesSlide(n,s,i,t);return this}_createNotesSlide(n,t,s,i){const r=Object.keys(this._files).filter(h=>h.startsWith("ppt/notesSlides/")).length+1,o=_e.p,l=_e.a,a=`ppt/notesSlides/notesSlide${r}.xml`,c=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
78
|
-
<p:notes xmlns:p="${o}" xmlns:a="${l}">
|
|
79
|
-
<p:cSld><p:spTree>
|
|
80
|
-
<p:sp>
|
|
81
|
-
<p:nvSpPr><p:cNvPr id="2" name="Notes Placeholder 1"/>
|
|
82
|
-
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
83
|
-
<p:nvPr><p:ph type="body" idx="1"/></p:nvPr>
|
|
84
|
-
</p:nvSpPr>
|
|
85
|
-
<p:spPr/>
|
|
86
|
-
<p:txBody><a:bodyPr/><a:lstStyle/>
|
|
87
|
-
<a:p><a:r><a:t>${i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</a:t></a:r></a:p>
|
|
88
|
-
</p:txBody>
|
|
89
|
-
</p:sp>
|
|
90
|
-
</p:spTree></p:cSld>
|
|
91
|
-
</p:notes>`;this._files[a]=Ds.encode(c);const u=Rt(s);s[u]={id:u,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",target:`../notesSlides/notesSlide${r}.xml`,fullPath:a},this._files[He(t)]=Me(Et(s))}async save(){return Ao(this._files)}async download(n="edited.pptx"){const t=await this.save(),s=new Blob([t],{type:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}),i=URL.createObjectURL(s),r=document.createElement("a");r.href=i,r.download=n,r.click(),setTimeout(()=>URL.revokeObjectURL(i),1e4)}listShapes(n){const t=this._slideDoc(n),s=nt(t);if(!s)return[];const i=[];for(const r of s.children){const o=r.localName;if(!["sp","pic","cxnSp","graphicFrame"].includes(o))continue;const l=ie(r,"nvSpPr")||ie(r,"nvPicPr")||ie(r,"nvGraphicFramePr")||ie(r,"nvCxnSpPr"),a=l?ie(l,"cNvPr"):null;i.push({id:a?.getAttribute("id")||"",name:a?.getAttribute("name")||"",type:o})}return i}}const Ls=new TextEncoder;function Do(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}class Lo{constructor(){this._parts=[],this._size=0}write(n){const t=typeof n=="string"?Ls.encode(n):n;return this._parts.push(t),this._size+=t.length,this._size}get size(){return this._size}concat(){const n=new Uint8Array(this._size);let t=0;for(const s of this._parts)n.set(s,t),t+=s.length;return n}}async function Bo(e,n=.92){if(typeof e.convertToBlob=="function"){const s=await(await e.convertToBlob({type:"image/jpeg",quality:n})).arrayBuffer();return new Uint8Array(s)}return new Promise((t,s)=>{e.toBlob(i=>{if(!i){s(new Error("canvas.toBlob failed"));return}i.arrayBuffer().then(r=>t(new Uint8Array(r))).catch(s)},"image/jpeg",n)})}async function Oo(e,n,t){const{cx:s,cy:i}=e.slideSize,r=Math.round(t*i/s),o=typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,r):Object.assign(document.createElement("canvas"),{width:t,height:r});return await e.renderSlide(n,o,t),o}function Uo(e,n){const t=e/914400*72,s=n/914400*72;return{w:t,h:s}}class Go{constructor(){this._buf=new Lo,this._xref=[],this._objNum=0}_nextObj(){return++this._objNum}_writeObj(n,t,s=null){const i=this._buf.size;if(this._xref[n]=i,this._buf.write(`${n} 0 obj
|
|
92
|
-
`),s){const r=s.length;this._buf.write(`${t.replace("__LEN__",r)}
|
|
93
|
-
`),this._buf.write(`stream\r
|
|
94
|
-
`),this._buf.write(s),this._buf.write(`\r
|
|
95
|
-
endstream
|
|
96
|
-
`)}else this._buf.write(`${t}
|
|
97
|
-
`);return this._buf.write(`endobj
|
|
98
|
-
|
|
99
|
-
`),n}_reserveObjs(n){const t=this._objNum+1;return this._objNum+=n,t}async build(n,t={}){const{widthPx:s=1920,quality:i=.92,slideList:r=null,onProgress:o=null}=t,l=r??Array.from({length:n.slideCount},(v,k)=>k),a=l.length,{cx:c,cy:u}=n.slideSize,{w:h,h:d}=Uo(c,u);this._buf.write(`%PDF-1.4
|
|
100
|
-
`),this._buf.write(`%ÿþýü
|
|
101
|
-
|
|
102
|
-
`);const p=this._nextObj(),g=this._nextObj(),b=Array.from({length:a},()=>this._nextObj()),_=Array.from({length:a},()=>this._nextObj()),y=Array.from({length:a},()=>this._nextObj());this._writeObj(p,`<< /Type /Catalog /Pages ${g} 0 R >>`);const w=b.map(v=>`${v} 0 R`).join(" ");this._writeObj(g,`<< /Type /Pages /Kids [${w}] /Count ${a} >>`);for(let v=0;v<a;v++){const k=l[v];o?.(v,a);const S=await Oo(n,k,s),N=await Bo(S,i),M=S.width,F=S.height;this._writeObj(b[v],`<< /Type /Page /Parent ${g} 0 R /MediaBox [0 0 ${h.toFixed(3)} ${d.toFixed(3)}] /Resources << /XObject << /Im${v} ${_[v]} 0 R >> >> /Contents ${y[v]} 0 R >>`),this._writeObj(_[v],`<< /Type /XObject /Subtype /Image /Width ${M} /Height ${F} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length __LEN__ >>`,N);const T=`q ${h.toFixed(3)} 0 0 ${d.toFixed(3)} 0 0 cm /Im${v} Do Q`;this._writeObj(y[v],"<< /Length __LEN__ >>",Ls.encode(T))}o?.(a,a);const x=this._buf.size,P=this._objNum+1;this._buf.write(`xref
|
|
103
|
-
0 ${P}
|
|
104
|
-
`),this._buf.write(`0000000000 65535 f \r
|
|
105
|
-
`);for(let v=1;v<P;v++){const k=this._xref[v]??0;this._buf.write(String(k).padStart(10,"0")+` 00000 n \r
|
|
106
|
-
`)}return this._buf.write(`trailer
|
|
107
|
-
<< /Size ${P} /Root ${p} 0 R >>
|
|
108
|
-
`),this._buf.write(`startxref
|
|
109
|
-
${x}
|
|
110
|
-
%%EOF
|
|
111
|
-
`),this._buf.concat()}}async function Mn(e,n={}){const{width:t=null,dpi:s=150,quality:i=.92,slides:r=null,onProgress:o=null}=n,l=t??Do(e,s);return new Go().build(e,{widthPx:l,quality:i,slideList:r,onProgress:o})}async function Wo(e,n="presentation.pdf",t={}){const s=await Mn(e,t),i=new Blob([s],{type:"application/pdf"}),r=URL.createObjectURL(i),o=document.createElement("a");o.href=r,o.download=n,o.click(),setTimeout(()=>URL.revokeObjectURL(r),1e4)}async function qo(e,n,t={}){return Mn(n,{...t,slides:[e]})}const Ko=500;function Nn(e){if(!e)return[];const n=m(e,"timing");if(!n)return[];const t=m(n,"tnLst");if(!t)return[];const s=[];function i(o,l,a){const c=m(o,"cTn");if(!c)return;const u=D(c,"nodeType","");u==="clickEffect"&&(l+=1),u==="withEffect"&&l===0&&(l=0);const h=C(c,"delay",0)+a,d=m(o,"childTnLst")||m(c,"childTnLst");if(d)for(const p of d.children){const g=p.localName;if(g==="par")i(p,l,h);else if(g==="seq"){const b=m(p,"cTn"),y=(b?D(b,"nodeType",""):"")==="clickEffect"?l+1:l,w=m(p,"childTnLst");if(w)for(const x of w.children)x.localName==="par"&&i(x,y,h)}else if(g==="set"||g==="animEffect"||g==="anim"||g==="animScale"||g==="animClr"){const b=ts(p,l,h);b&&s.push(b)}}}function r(o,l){const a=m(o,"childTnLst")||m(m(o,"cTn"),"childTnLst");if(!a)return;let c=l;for(const u of a.children)if(u.localName==="par"){const h=m(u,"cTn"),d=h?D(h,"nodeType",""):"";(d==="clickEffect"||d==="clickPar")&&c++,i(u,c,0)}}for(const o of t.children)o.localName==="par"?i(o,0,0):o.localName==="seq"&&r(o,0);for(const o of ce(t,"animEffect")){const l=ts(o,0,0);l&&s.push(l)}return s.sort((o,l)=>o.clickNum-l.clickNum||o.delay-l.delay)}function ts(e,n,t){const s=m(e,"cTn"),i=m(e,"tgt")||m(s,"tgt"),r=i?m(i,"spTgt"):null,o=r?D(r,"spid",null):null;if(!o)return null;const l=s?D(s,"dur",null):null,a=l==="indefinite"?2e3:l?parseInt(l,10):Ko,c=(s?C(s,"delay",0):0)+t,u=D(e,"filter",null),h=D(e,"type",null)||(u?"filter":"set"),d=D(e,"dir",null)||(u?u.split("(")[1]?.replace(")",""):null)||"";let p="emphasis";(h==="in"||e.localName==="set"&&D(m(e,"attrNameLst")||e,"attrName","")==="style.visibility"&&D(e,"to","")==="visible")&&(p="entrance"),(h==="out"||e.localName==="set"&&D(e,"to","")==="hidden")&&(p="exit");let g=u||e.localName;if(u){const b=u.toLowerCase();b.includes("fade")?g="fade":b.includes("fly")?g="fly":b.includes("appear")?g="appear":b.includes("zoom")?g="zoom":b.includes("wipe")?g="wipe":b.includes("wheel")?g="wheel":b.includes("blinds")?g="blinds":b.includes("box")?g="box":b.includes("dissolve")?g="dissolve":b.includes("split")?g="split":b.includes("stretch")?g="stretch":b.includes("diamond")?g="diamond":b.includes("plus")?g="plus":b.includes("wedge")?g="wedge":b.includes("random")?g="dissolve":b.includes("strips")?g="strips":b.includes("peek")?g="fly":b.includes("checkerboard")?g="dissolve":g="fade"}return{shapeId:o,type:p,effect:g,clickNum:n,delay:c,duration:a,dir:d,raw:e.localName}}function An(e){if(!e)return null;const n=m(e,"transition");if(!n)return null;const t=C(n,"dur",700),s=D(n,"spd","med"),i=s==="slow"?1200:s==="fast"?300:t,r=n.firstElementChild,o=r?.localName||"fade",l=r?D(r,"dir","l"):"l";return{type:o,duration:i,dir:l}}function Xo(e){return 1-Math.pow(1-e,2)}function Vo(e){return e*e}function Ho(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}function Bs(e,n,t,s){const i=Math.max(0,Math.min(1,n)),r=e.type==="entrance",o=r?Xo(i):Vo(i),l={opacity:1,tx:0,ty:0,scaleX:1,scaleY:1,clipProgress:1,clipDir:"none",spin:0},a=e.effect,c=e.dir;if(r)switch(a){case"appear":l.opacity=i>=.01?1:0;break;case"fade":case"dissolve":l.opacity=o;break;case"fly":case"flyIn":{l.opacity=Math.min(1,o*1.5);const u=1-o;c.includes("l")?l.tx=-t*u:c.includes("r")?l.tx=t*u:c.includes("t")?l.ty=-s*u:l.ty=s*u;break}case"zoom":l.opacity=o,l.scaleX=.1+o*.9,l.scaleY=.1+o*.9;break;case"wipe":l.clipProgress=o,l.clipDir=c||"r";break;case"split":l.clipProgress=o,l.clipDir=c.includes("v")?"split-v":"split-h";break;case"blinds":l.clipProgress=o,l.clipDir=c.includes("v")?"blinds-v":"blinds-h";break;case"box":l.clipProgress=o,l.clipDir="box";break;case"wheel":l.clipProgress=o,l.clipDir="wheel";break;case"wedge":l.clipProgress=o,l.clipDir="wedge";break;case"strips":l.clipProgress=o,l.clipDir=c.includes("r")?"strips-r":"strips-l";break;case"stretch":l.opacity=o,c.includes("h")?(l.scaleX=o,l.scaleY=1):(l.scaleX=1,l.scaleY=o);break;case"plus":case"diamond":l.clipProgress=o,l.clipDir=a;break;default:l.opacity=o}else if(e.type==="exit"){const u={...e,type:"entrance"};return Bs(u,1-i,t,s)}else switch(a){case"spin":l.spin=o*360;break;case"grow":case"shrink":{const u=a==="grow"?1.5:.5,h=i<.5?i*2:(1-i)*2;l.scaleX=1+(u-1)*h,l.scaleY=l.scaleX;break}case"flash":l.opacity=i<.5?i<.25?0:1:i<.75?0:1;break;default:l.opacity=.5+.5*Math.cos(i*Math.PI*4)}return l}function Os(e,n,t,s,i){const r=Ho(i),o=e.canvas.width,l=e.canvas.height;e.clearRect(0,0,o,l);const a=s?.type||"fade",c=s?.dir||"l";switch(a){case"cut":e.drawImage(r<.5?n:t,0,0,o,l);break;case"fade":case"fade_slow":default:e.drawImage(n,0,0,o,l),e.globalAlpha=r,e.drawImage(t,0,0,o,l),e.globalAlpha=1;break;case"push":{const u=c==="l"?-o*r:c==="r"?o*r:0,h=c==="u"?-l*r:c==="d"?l*r:0;e.drawImage(n,u,h,o,l),e.drawImage(t,u+(c==="l"?o:c==="r"?-o:0),h+(c==="u"?l:c==="d"?-l:0),o,l);break}case"cover":case"uncover":{const u=a==="uncover",h=c==="l"?-o*(1-r):c==="r"?o*(1-r):0,d=c==="u"?-l*(1-r):c==="d"?l*(1-r):0;u?(e.drawImage(t,0,0,o,l),e.drawImage(n,h,d,o,l)):(e.drawImage(n,0,0,o,l),e.drawImage(t,h,d,o,l));break}case"wipe":{e.drawImage(n,0,0,o,l),e.save(),e.beginPath(),c==="l"?e.rect(o*(1-r),0,o*r,l):c==="r"?e.rect(0,0,o*r,l):c==="u"?e.rect(0,l*(1-r),o,l*r):e.rect(0,0,o,l*r),e.clip(),e.drawImage(t,0,0,o,l),e.restore();break}case"zoom":case"newsflash":{e.drawImage(n,0,0,o,l),e.save(),e.globalAlpha=r;const u=a==="newsflash"?1+(1-r)*3:.05+r*.95;e.translate(o/2,l/2),e.scale(u,u),e.drawImage(t,-o/2,-l/2,o,l),e.restore(),e.globalAlpha=1;break}case"dissolve":case"wheel":case"blinds":{e.drawImage(n,0,0,o,l),e.globalAlpha=r,e.drawImage(t,0,0,o,l),e.globalAlpha=1;break}}}class Us{constructor(n,t){this.renderer=n,this.canvas=t,this.ctx=t.getContext("2d"),this._slideIndex=0,this._steps=[],this._transition=null,this._clickNum=0,this._activeAnimations=[],this._shapeStates=new Map,this._baseCanvas=null,this._playing=!1,this._rafId=null,this.onSlideComplete=null,this.onClickReady=null,this.onTransitionStart=null,this.onTransitionEnd=null}async loadSlide(n){this._slideIndex=n,this._clickNum=0,this._shapeStates.clear(),this._stopAnimations();const t=this.renderer._files,s=this.renderer.slidePaths[n];if(!s||!t)return;const i=t[s]?new TextDecoder().decode(t[s]):null;if(!i)return;const{parseXml:r}=await Qt(async()=>{const{parseXml:a}=await Promise.resolve().then(()=>Gr);return{parseXml:a}},void 0,import.meta.url).catch(()=>({parseXml:a=>new DOMParser().parseFromString(a,"application/xml")})),o=r(i);this._steps=Nn(o),this._transition=An(o);const l=new Set(this._steps.filter(a=>a.type==="entrance").map(a=>a.shapeId));this._initiallyHidden=l,this._baseCanvas=await this._renderBaseSlide(),this._drawBase(),await this._playClickGroup(0)}async nextClick(){this._clickNum++,await this._playClickGroup(this._clickNum)}async play(n=1500){this._playing=!0;const t=Math.max(...this._steps.map(s=>s.clickNum),0);for(;this._playing&&this._clickNum<=t;)await this._playClickGroup(this._clickNum),this._clickNum++,this._clickNum<=t&&await this._delay(n);this._playing=!1}pause(){this._playing=!1,this._stopAnimations()}async stop(){this._playing=!1,this._stopAnimations(),this._shapeStates.clear(),this._clickNum=0,this._baseCanvas&&this._drawBase()}async transitionTo(n){const t=document.createElement("canvas");t.width=this.canvas.width,t.height=this.canvas.height,t.getContext("2d").drawImage(this.canvas,0,0),await this.loadSlide(n);const s=this._baseCanvas,i=this._transition||{type:"fade",duration:700,dir:"l"};this.onTransitionStart?.({from:this._slideIndex-1,to:n,transition:i}),await this._animateTransition(t,s,i),this.onTransitionEnd?.({slideIndex:n})}async _renderBaseSlide(){const n=this.canvas.width,t=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,Math.round(n/(this.renderer.slideSize.cx/this.renderer.slideSize.cy))):Object.assign(document.createElement("canvas"),{width:n,height:Math.round(n/(this.renderer.slideSize.cx/this.renderer.slideSize.cy))});return await this.renderer.renderSlide(this._slideIndex,t,n),t}_drawBase(){this._baseCanvas&&(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.drawImage(this._baseCanvas,0,0,this.canvas.width,this.canvas.height))}async _playClickGroup(n){const t=this._steps.filter(s=>s.clickNum===n);t.length&&(this.onClickReady?.({clickNum:n,stepCount:t.length}),Math.max(...t.map(s=>s.delay+s.duration),0),await new Promise(s=>{const i=performance.now(),r=new Set,o=l=>{const a=l-i;for(const c of t){if(r.has(c))continue;const u=a-c.delay;if(u<0)continue;const h=Math.min(1,u/c.duration),d=this.canvas.width,p=this.canvas.height,g=Bs(c,h,d*.3,p*.3);this._shapeStates.set(c.shapeId,{...g,step:c}),h>=1&&r.add(c)}this._composite(),r.size<t.length?this._rafId=requestAnimationFrame(o):s()};this._rafId=requestAnimationFrame(o)}))}_composite(){this._drawBase();for(const[n,t]of this._shapeStates)t.opacity<.99}async _animateTransition(n,t,s){const i=s.duration;await new Promise(r=>{const o=performance.now(),l=a=>{const c=Math.min(1,(a-o)/i);Os(this.ctx,n,t,s,c),c<1?this._rafId=requestAnimationFrame(l):r()};this._rafId=requestAnimationFrame(l)})}_stopAnimations(){this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null)}_delay(n){return new Promise(t=>setTimeout(t,n))}}const Yo=Object.freeze(Object.defineProperty({__proto__:null,PptxPlayer:Us,parseAnimations:Nn,parseTransition:An,renderTransitionFrame:Os},Symbol.toStringTag,{value:"Module"}));let Qo=0;function on(e="el"){return`${e}${++Qo}`}function je(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function A(e){return`${+e.toFixed(3)}`}function bn(e){return e?ge(e):"none"}function Gs(e,n,t,s,i,r,o){if(!e)return{fill:"none",fillAttrs:""};const l=e.localName;if(l==="noFill")return{fill:"none",fillAttrs:""};if(l==="solidFill"){const a=me(e),c=ve(a,t),u=bn(c),h=c?.a!=null?c.a/255:1;return{fill:u,fillAttrs:h<1?` fill-opacity="${A(h)}"`:""}}if(l==="gradFill"){const a=m(e,"gsLst"),c=a?ce(a,"gs").map(g=>{const b=C(g,"pos",0)/1e5,_=me(g),y=ve(_,t);return{pos:b,color:bn(y),opacity:y?.a!=null?y.a/255:1}}):[],u=m(e,"lin"),h=m(e,"path"),d=on("grad");let p;if(h){const g=m(h,"fillToRect"),b=C(g,"l",5e4)/1e5,_=C(g,"t",5e4)/1e5,y=s+r*b,w=i+o*_,x=Math.sqrt(r*r+o*o)/2;p=`<radialGradient id="${d}" cx="${A(y)}" cy="${A(w)}" r="${A(x)}" gradientUnits="userSpaceOnUse">`;for(const P of c)p+=`<stop offset="${A(P.pos)}" stop-color="${je(P.color)}"${P.opacity<1?` stop-opacity="${A(P.opacity)}"`:""}/>`;p+="</radialGradient>"}else{const b=(C(u,"ang",0)/6e4-90)*(Math.PI/180),_=Math.cos(b),y=Math.sin(b),w=Math.sqrt(r*r+o*o)/2,x=s+r/2,P=i+o/2;p=`<linearGradient id="${d}" x1="${A(x-_*w)}" y1="${A(P-y*w)}" x2="${A(x+_*w)}" y2="${A(P+y*w)}" gradientUnits="userSpaceOnUse">`;for(const v of c)p+=`<stop offset="${A(v.pos)}" stop-color="${je(v.color)}"${v.opacity<1?` stop-opacity="${A(v.opacity)}"`:""}/>`;p+="</linearGradient>"}return n.push(p),{fill:`url(#${d})`,fillAttrs:""}}return l==="blipFill"?{fill:"none",fillAttrs:""}:{fill:"none",fillAttrs:""}}function Ws(e,n,t){if(!e)return"";if(m(e,"noFill"))return' stroke="none"';const s=m(e,"solidFill"),i=s?me(s):null,r=ve(i,n),o=bn(r)||"#000",l=Math.max(.5,C(e,"w",12700)/914400*96),a=m(e,"prstDash"),c=a?D(a,"val","solid"):"solid";let u="";c==="dash"?u=` stroke-dasharray="${A(l*4)},${A(l*2)}"`:c==="dot"?u=` stroke-dasharray="${A(l)},${A(l*2)}"`:c==="dashDot"?u=` stroke-dasharray="${A(l*4)},${A(l*2)},${A(l)},${A(l*2)}"`:c==="lgDash"&&(u=` stroke-dasharray="${A(l*8)},${A(l*3)}"`);const h=D(e,"cap","flat"),d=h==="rnd"?"round":h==="sq"?"square":"butt";return` stroke="${je(o)}" stroke-width="${A(l)}" stroke-linecap="${d}" stroke-linejoin="round"${u}`}function qs(e,n){if(!e)return"";const t=m(e,"outerShdw");if(!t)return"";const s=C(t,"dist",38100)/914400*96,i=C(t,"dir",27e5)/6e4,r=C(t,"blurRad",38100)/914400*96,o=i*Math.PI/180,l=Math.cos(o)*s,a=Math.sin(o)*s,c=me(t),u=ve(c,{}),h=u?ge(u):"rgba(0,0,0,0.5)",d=u?.a!=null?u.a/255:.5,p=on("shd");return n.push(`<filter id="${p}" x="-50%" y="-50%" width="200%" height="200%"><feDropShadow dx="${A(l)}" dy="${A(a)}" stdDeviation="${A(r/2)}" flood-color="${je(h)}" flood-opacity="${A(d)}"/></filter>`),` filter="url(#${p})"`}function Zo(e,n,t,s,i,r){const o=[],l={beginPath(){o.length=0},moveTo(a,c){o.push(`M${A(a)},${A(c)}`)},lineTo(a,c){o.push(`L${A(a)},${A(c)}`)},bezierCurveTo(a,c,u,h,d,p){o.push(`C${A(a)},${A(c)},${A(u)},${A(h)},${A(d)},${A(p)}`)},quadraticCurveTo(a,c,u,h){o.push(`Q${A(a)},${A(c)},${A(u)},${A(h)}`)},arc(a,c,u,h,d,p){const g=a+u*Math.cos(h),b=c+u*Math.sin(h),_=a+u*Math.cos(d),y=c+u*Math.sin(d);let w=d-h;p&&(w=-(Math.PI*2-Math.abs(w)));const x=Math.abs(w)>Math.PI?1:0,P=w>0?1:0;o.length===0&&o.push(`M${A(g)},${A(b)}`),o.push(`A${A(u)},${A(u)},0,${x},${P},${A(_)},${A(y)}`)},arcTo(a,c,u,h,d){o.push(`L${A(a)},${A(c)} L${A(u)},${A(h)}`)},closePath(){o.push("Z")},fill(){},stroke(){},save(){},restore(){},translate(){},rotate(){},scale(){},rect(a,c,u,h){o.push(`M${A(a)},${A(c)}L${A(a+u)},${A(c)}L${A(a+u)},${A(c+h)}L${A(a)},${A(c+h)}Z`)},setLineDash(){},measureText(){return{width:0}}};return o.join(" ")||`M${A(n)},${A(t)}L${A(n+s)},${A(t)}L${A(n+s)},${A(t+i)}L${A(n)},${A(t+i)}Z`}let Jo=null;function an(e){if(!e)return"";const n=C(e,"rot",0)/6e4,t=D(e,"flipH","0")==="1",s=D(e,"flipV","0")==="1",i=m(e,"off"),r=m(e,"ext");if(!i||!r)return"";const o=C(i,"x",0)/914400*96,l=C(i,"y",0)/914400*96,a=C(r,"cx",0)/914400*96,c=C(r,"cy",0)/914400*96,u=o+a/2,h=l+c/2,d=[];return n&&d.push(`rotate(${A(n)},${A(u)},${A(h)})`),t&&d.push(`scale(-1,1) translate(${A(-o*2-a)},0)`),s&&d.push(`scale(1,-1) translate(0,${A(-l*2-c)})`),d.length?` transform="${d.join(" ")}"`:""}function Ft(e){if(!e)return null;const n=m(e,"off"),t=m(e,"ext");return!n||!t?null:{x:C(n,"x",0)/914400*96,y:C(n,"y",0)/914400*96,w:C(t,"cx",0)/914400*96,h:C(t,"cy",0)/914400*96}}function ea(e,n,t,s,i,r,o,l){if(!e)return"";const a=m(e,"bodyPr"),c=D(a,"vert","horz"),u=c==="vert"||c==="vert270"||c==="wordArtVert";D(a,"anchor","t");const h=C(a,"lIns",91440)/914400*96,d=C(a,"rIns",91440)/914400*96,p=C(a,"tIns",45720)/914400*96;C(a,"bIns",45720)/914400*96;const g=n+h,b=s-h-d,_=t+p,y=1800,w=m(e,"lstStyle"),x=w?m(w,"defRPr"):null,P=ce(e,"p");let v="",k=_;const S=on("clip");l.push(`<clipPath id="${S}"><rect x="${A(n)}" y="${A(t)}" width="${A(s)}" height="${A(i)}"/></clipPath>`);const N=u?` transform="rotate(-90,${A(n+s/2)},${A(t+i/2)})"`:"",M={};for(const F of P){const T=m(F,"pPr"),$=D(T,"algn","l"),L=C(T,"marL",0)/914400*96,G=C(T,"indent",0)/914400*96,q=m(T,"defRPr");let B=y;if(x){const E=x.getAttribute("sz");E&&(B=parseInt(E,10))}if(q){const E=q.getAttribute("sz");E&&(B=parseInt(E,10))}const U=m(T,"spcBef"),H=m(T,"spcAft");m(T,"lnSpc");let K=0,ee=0;if(U){const E=m(U,"spcPct"),Q=m(U,"spcPts");E?K=B*bt/914400*96*(C(E,"val",0)/1e5):Q&&(K=C(Q,"val",0)/100/72*96)}if(H){const E=m(H,"spcPct"),Q=m(H,"spcPts");E?ee=B*bt/914400*96*(C(E,"val",0)/1e5):Q&&(ee=C(Q,"val",0)/100/72*96)}const I=T?m(T,"buChar"):null,X=T?m(T,"buAutoNum"):null,ae=!(T?m(T,"buNone"):null)&&(I||X);k+=K;const ue=[];for(const E of F.children)(E.localName==="r"||E.localName==="br"||E.localName==="fld")&&ue.push(E);if(!ue.length){const E=m(F,"endParaRPr"),J=C(E||q,"sz",B)/100/72*96*1.2;k+=J+ee;continue}let re="";for(const E of ue){if(E.localName==="br"){re+=`
|
|
112
|
-
`;continue}const Q=m(E,"t")||m(E,"fldVal");Q&&(re+=Q.textContent)}const Y=[];for(const E of ue){if(E.localName==="br"){Y.push({br:!0});continue}const Q=m(E,"rPr")||m(E,"r")?.firstElementChild,V=m(E,"t");if(!V)continue;const J=V.textContent;if(!J)continue;const Z=Ts(E,q,x,r,o,B),fe=Z?.szPx||B/100/72*96,he=Z?.family||"sans-serif",le=Z?.bold?"bold":"normal",xe=Z?.italic?"italic":"normal",Te=Z?.color?ge(Z.color):"#000000",Ne=Q?(Q.getAttribute("u")||"none")!=="none":!1,Ae=Q?(Q.getAttribute("strike")||"noStrike")!=="noStrike":!1,Ct=Q?parseInt(Q.getAttribute("baseline")||"0",10):0;Y.push({text:J,szPx:fe,family:he,bold:le,italic:xe,color:Te,underline:Ne,strike:Ae,baseline:Ct})}if(!Y.length){k+=ee;continue}const ye=Y.filter(E=>!E.br&&E.szPx).map(E=>E.szPx),se=ye.length?Math.max(...ye):B/100/72*96,oe=se*1.2,de=k+se*.85;let we="start",be=g+L;$==="ctr"?(we="middle",be=g+b/2):$==="r"&&(we="end",be=g+b);let R="";if(ae){const E=g+L+G;let Q="";if(I)Q=je(I.getAttribute("char")||"•");else if(X){const J=X.getAttribute("type")||"arabicPeriod",Z=C(X,"startAt",1),fe=J+":"+Z;M[fe]||(M[fe]=Z),Q=je(ta(J,M[fe]++))}const V=se;R=`<text x="${A(E)}" y="${A(de)}" font-size="${A(V)}" font-family="sans-serif" fill="#000">${Q}</text>`}let W="";for(const E of Y){if(E.br){k+=oe,W+=`<tspan x="${A(be)}" dy="${A(oe)}">`;continue}const Q=E.underline?"underline":E.strike?"line-through":"none";let V=de;E.baseline>0?V=de-E.szPx*.38:E.baseline<0&&(V=de+E.szPx*.12);const J=E.baseline!==0?E.szPx*.65:E.szPx;W+=`<tspan font-family="${je(E.family)}, sans-serif" font-size="${A(J)}" font-weight="${E.bold}" font-style="${E.italic}" fill="${je(E.color)}"`+(Q!=="none"?` text-decoration="${Q}"`:"")+(E.baseline!==0?` dy="${A(V-de)}"`:"")+`>${je(E.text)}</tspan>`}v+=R,v+=`<text x="${A(be)}" y="${A(de)}" text-anchor="${we}">${W}</text>`,k+=oe+ee}return`<g clip-path="url(#${S})"${N}>${v}</g>`}function ta(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return ns(n).toLowerCase()+".";case"romanUcPeriod":return ns(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";default:return n+"."}}function ns(e){const n=[1e3,900,500,400,100,90,50,40,10,9,5,4,1],t=["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"];let s="";for(let i=0;i<n.length;i++)for(;e>=n[i];)s+=t[i],e-=n[i];return s}async function qt(e,n,t,s,i,r){if(!e)return"";let o="";for(const l of e.children){const a=l.localName;a==="sp"?o+=await na(l,s,i,r):a==="pic"?o+=await sa(l,n,t,s,r):a==="cxnSp"?o+=await ia(l,s):a==="grpSp"?o+=await ra(l,n,t,s,i,r):a==="graphicFrame"&&(o+=await oa(l))}return o}async function na(e,n,t,s){const i=m(e,"spPr"),r=m(i,"xfrm"),o=Ft(r);if(!o)return"";const l=m(i,"prstGeom"),a=l?D(l,"prst","rect"):"rect",c=m(i,"custGeom"),u=["noFill","solidFill","gradFill","blipFill","pattFill"];let h=null;for(const k of u){const S=m(i,k);if(S){h=S;break}}if(!h){const k=m(e,"style"),S=k?m(k,"fillRef"):null;if(S&&C(S,"idx",1)!==0){const N=me(S),M=ve(N,n);M&&(h=new DOMParser().parseFromString(`<solidFill xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><srgbClr val="${ge(M).replace("#","")}"/></solidFill>`,"application/xml").documentElement)}}const{fill:d,fillAttrs:p}=Gs(h,s,n,o.x,o.y,o.w,o.h);let g=m(i,"ln");if(!g){const k=m(e,"style"),S=k?m(k,"lnRef"):null;if(S&&C(S,"idx",1)!==0){const N=me(S),M=ve(N,n);M&&(g=new DOMParser().parseFromString(`<ln xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><solidFill><srgbClr val="${ge(M).replace("#","")}"/></solidFill></ln>`,"application/xml").documentElement)}}const b=Ws(g,n),_=m(i,"effectLst"),y=qs(_,s),w=an(r);let x="";if(a==="rect"||!l&&!c)x=`<rect x="${A(o.x)}" y="${A(o.y)}" width="${A(o.w)}" height="${A(o.h)}" fill="${je(d)}"${p}${b}${y}${w}/>`;else{const k=Zo(a,o.x,o.y,o.w,o.h,{});x=`<path d="${je(k)}" fill="${je(d)}"${p}${b}${y}${w}/>`}const P=m(e,"txBody"),v=P?ea(P,o.x,o.y,o.w,o.h,n,t,s):"";return`<g>${x}${v}</g>`}async function sa(e,n,t,s,i){const r=m(e,"spPr"),o=m(r,"xfrm"),l=Ft(o);if(!l)return"";const a=m(e,"blipFill"),c=a?m(a,"blip"):null,u=c?c.getAttribute("r:embed")||c.getAttribute("embed"):null,h=u?n[u]:null,d=h?t[h.fullPath]:null,p=an(o),g=m(r,"effectLst"),b=qs(g,i);if(!d)return`<rect x="${A(l.x)}" y="${A(l.y)}" width="${A(l.w)}" height="${A(l.h)}" fill="#e0e0e0"${p}/>`;const _=h.fullPath.split(".").pop().toLowerCase(),y=_==="png"?"image/png":_==="gif"?"image/gif":_==="svg"?"image/svg+xml":"image/jpeg",w=d instanceof Uint8Array?d:new Uint8Array(d),x=btoa(Array.from(w,v=>String.fromCharCode(v)).join("")),P=on("pic");return i.push(`<clipPath id="${P}"><rect x="${A(l.x)}" y="${A(l.y)}" width="${A(l.w)}" height="${A(l.h)}"/></clipPath>`),`<image x="${A(l.x)}" y="${A(l.y)}" width="${A(l.w)}" height="${A(l.h)}" href="data:${y};base64,${x}" clip-path="url(#${P})"${b}${p} preserveAspectRatio="xMidYMid slice"/>`}async function ia(e,n,t){const s=m(e,"spPr"),i=m(s,"xfrm"),r=Ft(i);if(!r)return"";const o=m(s,"ln"),l=Ws(o,n),a=an(i);return`<line x1="${A(r.x)}" y1="${A(r.y)}" x2="${A(r.x+r.w)}" y2="${A(r.y+r.h)}" fill="none"${l}${a}/>`}async function ra(e,n,t,s,i,r){const o=m(e,"grpSpPr"),l=m(o,"xfrm");Ft(l);const a=l?an(l):"",c=await qt(e,n,t,s,i,r);return`<g${a}>${c}</g>`}async function oa(e,n,t){const s=m(e,"xfrm"),i=Ft(s);return i?`<rect x="${A(i.x)}" y="${A(i.y)}" width="${A(i.w)}" height="${A(i.h)}" fill="#f4f4f8" stroke="#ccc" stroke-width="1"/><text x="${A(i.x+i.w/2)}" y="${A(i.y+i.h/2)}" text-anchor="middle" font-size="14" fill="#999">Chart</text>`:""}async function aa(e,n,t,s,i,r,o,l,a){const c=p=>{const g=m(p,"cSld"),b=g?m(g,"bg"):null;return b?{bgPr:m(b,"bgPr"),bgRef:m(b,"bgRef")}:null},u=c(e)||c(t)||c(n);if(!u)return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`;const{bgPr:h,bgRef:d}=u;if(h){const p=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const g of p){const b=m(h,g);if(b){if(g==="blipFill"){const w=m(b,"blip"),x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,P=x&&i?i[x]:null,v=P?s[P.fullPath]:null;if(v){const S=P.fullPath.split(".").pop().toLowerCase()==="png"?"image/png":"image/jpeg",N=v instanceof Uint8Array?v:new Uint8Array(v),M=btoa(Array.from(N,F=>String.fromCharCode(F)).join(""));return`<image width="${A(o)}" height="${A(l)}" href="data:${S};base64,${M}" preserveAspectRatio="xMidYMid slice"/>`}}const{fill:_,fillAttrs:y}=Gs(b,a,r,0,0,o,l);return`<rect width="${A(o)}" height="${A(l)}" fill="${je(_)}"${y}/>`}}}if(d){const p=me(d),g=ve(p,r);if(g)return`<rect width="${A(o)}" height="${A(l)}" fill="${je(ge(g))}"/>`}return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`}async function Ks(e,n){const{_files:t,slidePaths:s,slideSize:i,themeColors:r,themeData:o,masterDoc:l,masterRels:a}=n;if(e<0||e>=s.length)throw new Error("Slide index out of range");const c=s[e],u=t[c]?new TextDecoder().decode(t[c]):null;if(!u)throw new Error(`Cannot read slide ${e}`);const h=ke(u),d=await Le(t,c),p=Object.values(d).find(T=>T.type?.includes("slideLayout")),g=p&&t[p.fullPath]?ke(new TextDecoder().decode(t[p.fullPath])):null,b=p?await Le(t,p.fullPath):{},_=i.cx/914400*96,y=i.cy/914400*96,w=[],x=await aa(h,l,g,t,a,r,_,y,w),P=m(m(l,"cSld"),"spTree"),v=g?m(m(g,"cSld"),"spTree"):null,k=m(m(h,"cSld"),"spTree"),S=P?await qt(P,a,t,r,o,w):"",N=v?await qt(v,b,t,r,o,w):"",M=k?await qt(k,d,t,r,o,w):"",F=w.length?`<defs>${w.join(`
|
|
113
|
-
`)}</defs>`:"";return['<?xml version="1.0" encoding="UTF-8"?>','<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"',` width="${A(_)}" height="${A(y)}" viewBox="0 0 ${A(_)} ${A(y)}">`,F,x,S,N,M,"</svg>"].join(`
|
|
114
|
-
`)}async function la(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await Ks(t,e));return n}function ss(e){const n=e.replace(/[{}\-]/g,"");if(n.length<32){const a=n.padEnd(32,"0");return ca(a.slice(0,32))}const t=n.slice(0,8),s=n.slice(8,12),i=n.slice(12,16),r=n.slice(16,32),o=new Uint8Array(16);o[0]=parseInt(t.slice(6,8),16),o[1]=parseInt(t.slice(4,6),16),o[2]=parseInt(t.slice(2,4),16),o[3]=parseInt(t.slice(0,2),16),o[4]=parseInt(s.slice(2,4),16),o[5]=parseInt(s.slice(0,2),16),o[6]=parseInt(i.slice(2,4),16),o[7]=parseInt(i.slice(0,2),16);for(let a=0;a<8;a++)o[8+a]=parseInt(r.slice(a*2,a*2+2),16);const l=new Uint8Array(32);return l.set(o),l.set(o,16),l}function ca(e){const n=new Uint8Array(e.length/2);for(let t=0;t<n.length;t++)n[t]=parseInt(e.slice(t*2,t*2+2),16);return n}function is(e,n){const t=new Uint8Array(e);for(let s=0;s<Math.min(32,t.length);s++)t[s]^=n[s];return t}function fn(e){if(e.length<4)return!1;const n=e[0]<<24|e[1]<<16|e[2]<<8|e[3];return n===65536||n===1330926671||n===1953658213||n===2001684038||n===2001684018}const yn=new Set;async function da(e,n){const t=[],s=e["ppt/presentation.xml"];if(!s)return t;const r=new DOMParser().parseFromString(new TextDecoder().decode(s),"application/xml"),o=r.querySelector("embeddedFontLst")||[...r.getElementsByTagName("*")].find(a=>a.localName==="embeddedFontLst");if(!o)return t;const l=[...o.children].filter(a=>a.localName==="embeddedFont");for(const a of l){const c=[...a.children].find(d=>d.localName==="font");if(!c)continue;const u=c.getAttribute("typeface")||c.getAttribute("t");if(!u)continue;const h=[{el:[...a.children].find(d=>d.localName==="regular"),weight:"400",style:"normal"},{el:[...a.children].find(d=>d.localName==="bold"),weight:"700",style:"normal"},{el:[...a.children].find(d=>d.localName==="italic"),weight:"400",style:"italic"},{el:[...a.children].find(d=>d.localName==="boldItalic"),weight:"700",style:"italic"}];for(const{el:d,weight:p,style:g}of h){if(!d)continue;const b=d.getAttribute("r:id")||d.getAttribute("id")||d.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id");if(!b)continue;const _=`${u}:${p}:${g}`;if(yn.has(_)){t.push({typeface:u,weight:p,style:g,status:"already-loaded"});continue}const y=n?n[b]:null;if(!y){t.push({typeface:u,weight:p,style:g,status:"rel-not-found",rId:b});continue}const w=e[y.fullPath];if(!w){t.push({typeface:u,weight:p,style:g,status:"file-not-found",path:y.fullPath});continue}let x=null;const P=ss(b),v=is(w,P);if(fn(v))x=v;else{const k=y.fullPath.split("/").pop().replace(".fntdata",""),S=ss(k),N=is(w,S);fn(N)?x=N:fn(w)&&(x=w)}if(!x){t.push({typeface:u,weight:p,style:g,status:"decode-failed",path:y.fullPath});continue}try{const k=new FontFace(u,x.buffer,{weight:p,style:g});await k.load(),document.fonts.add(k),yn.add(_),t.push({typeface:u,weight:p,style:g,status:"loaded",path:y.fullPath})}catch(k){t.push({typeface:u,weight:p,style:g,status:"load-failed",error:k.message})}}}return t}function ua(e){const n=e["ppt/presentation.xml"];return n?[...new DOMParser().parseFromString(new TextDecoder().decode(n),"application/xml").getElementsByTagName("*")].filter(i=>i.localName==="embeddedFont").map(i=>{const r=[...i.children].find(a=>a.localName==="font"),o=r&&(r.getAttribute("typeface")||r.getAttribute("t"))||"",l=["regular","bold","italic","boldItalic"].filter(a=>[...i.children].some(c=>c.localName===a));return{typeface:o,variants:l,loaded:l.some(a=>yn.has(`${o}:${a==="bold"||a==="boldItalic"?"700":"400"}:${a.includes("talic")?"italic":"normal"}`))}}).filter(i=>i.typeface):[]}function O(e,n){if(!e)return null;const t=e.getElementsByTagName("*");for(let s=0;s<t.length;s++)if(t[s].localName===n)return t[s];return null}function Ke(e,n){if(!e)return[];const t=[],s=e.getElementsByTagName("*");for(let i=0;i<s.length;i++)s[i].localName===n&&t.push(s[i]);return t}function Pe(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function vn(e,n,t=0){const s=Pe(e,n);return s!==null?parseInt(s,10):t}function fa(e,n){const t=O(e,"rPr"),s=O(e,"t");if(!s)return null;const i=s.textContent||"",r=t?parseInt(t.getAttribute("sz")||"0",10):n?parseInt(n.getAttribute("sz")||"0",10):0,o=r?r/100:12,l=t?t.getAttribute("b")==="1":!1,a=t?t.getAttribute("i")==="1":!1,c=t&&t.getAttribute("u")||"none";let u="#000000";if(t){const h=O(t,"solidFill")||O(t,"lumMod");if(h){const d=O(h,"srgbClr");d&&(u="#"+(d.getAttribute("val")||"000000"))}}return{text:i,bold:l,italic:a,underline:c!=="none",fontSize:o,color:u}}function ha(e){const n=O(e,"pPr"),t=Pe(n,"algn","l"),s=vn(n,"lvl",0),i=O(n,"defRPr");let r=null;if(n&&!O(n,"buNone")){const a=O(n,"buChar"),c=O(n,"buAutoNum");a?r=a.getAttribute("char")||"•":c&&(r="{auto}")}const o=[];for(const a of e.children)if(a.localName==="r"){const c=fa(a,i);c&&o.push(c)}else if(a.localName==="br")o.push({text:`
|
|
115
|
-
`,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#000"});else if(a.localName==="fld"){const c=O(a,"t");c&&o.push({text:c.textContent,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#555"})}const l=o.map(a=>a.text).join("");return{runs:o,text:l,align:t,level:s,bullet:r}}function wn(e){return e?Ke(e,"p").map(ha).filter(n=>n.text.trim()):[]}function rs(e){const n=O(e,"nvSpPr"),t=n?O(n,"nvPr"):null,s=t?O(t,"ph"):null;if(s){const r=Pe(s,"type","body");if(r==="title"||r==="ctrTitle")return"title";if(r==="subTitle")return"subtitle";if(r==="body")return"body"}return O(e,"txBody")?"textBox":"other"}function os(e){const n=O(e,"nvSpPr"),t=n?O(n,"cNvPr"):null;return t?Pe(t,"id",""):""}function as(e){const n=O(e,"nvSpPr"),t=n?O(n,"cNvPr"):null;return t?Pe(t,"name",""):""}function pa(e){const n=O(e,"tbl");if(!n)return null;const t=O(e,"nvGraphicFramePr"),s=t?O(t,"cNvPr"):null,i=s?Pe(s,"id",""):"",r=s?Pe(s,"name",""):"",o=[];let l=0;for(const c of Ke(n,"tr")){const u=[];let h=0;for(const d of Ke(c,"tc")){const p=vn(d,"gridSpan",1),g=vn(d,"rowSpan",1),b=wn(O(d,"txBody")),_=b.map(y=>y.text).join(`
|
|
116
|
-
`);u.push({row:l,col:h,rowSpan:g,colSpan:p,text:_,paragraphs:b}),h++}o.push(u),l++}const a=o.map(c=>c.map(u=>u.text).join(" ")).join(`
|
|
117
|
-
`);return{id:i,name:r,rows:o,text:a}}function ga(e,n){const t=O(e,"graphic"),s=t?O(t,"graphicData"):null,i=s?O(s,"chart"):null;if(!i)return null;const r=i.getAttribute("r:id")||i.getAttribute("id"),o=O(e,"nvGraphicFramePr"),l=o?O(o,"cNvPr"):null;return{id:l?Pe(l,"id",""):"",name:l?Pe(l,"name",""):"",rId:r}}function ma(e){if(!e)return{chartType:"unknown",seriesNames:[],categories:[]};const n=O(e,"plotArea");if(!n)return{chartType:"unknown",seriesNames:[],categories:[]};const t=["barChart","lineChart","pieChart","areaChart","scatterChart","doughnutChart","radarChart","bubbleChart","bar3DChart","line3DChart","pie3DChart","area3DChart"];let s="unknown",i=null;for(const a of t)if(i=O(n,a),i){s=a.replace("3DChart","Chart").replace("Chart","");break}const r=i?Ke(i,"ser"):[],o=r.map(a=>{const c=O(a,"tx");if(!c)return null;const u=O(c,"v");if(u)return u.textContent.trim();const h=O(c,"strCache"),d=h?O(h,"pt"):null,p=d?O(d,"v"):null;return p?p.textContent.trim():null}).filter(Boolean),l=r.length>0?(()=>{const a=O(r[0],"cat")||O(r[0],"xVal");if(!a)return[];const c=O(a,"strCache")||O(a,"numCache");return c?Ke(c,"pt").map(u=>O(u,"v")?.textContent||"").filter(Boolean):[]})():[];return{chartType:s,seriesNames:o,categories:l}}function ba(e){if(!e)return"";const n=O(e,"cSld"),t=n?O(n,"spTree"):null;if(!t)return"";const s=[];for(const i of Ke(t,"sp")){const r=O(i,"nvSpPr"),o=r?O(r,"nvPr"):null,l=o?O(o,"ph"):null;if(l&&Pe(l,"type")==="sldNum")continue;const a=O(i,"txBody");if(a){const c=Ke(a,"r").map(u=>O(u,"t")?.textContent||"").join("");c.trim()&&s.push(c.trim())}}return s.join(`
|
|
118
|
-
|
|
119
|
-
`)}async function ln(e,n){const{_files:t,slidePaths:s}=n;if(e<0||e>=s.length)throw new Error("Slide index out of range");const i=t[s[e]];if(!i)return ya(e);const r=new DOMParser().parseFromString(new TextDecoder().decode(i),"application/xml"),{getRels:o}=await Qt(async()=>{const{getRels:v}=await Promise.resolve().then(()=>So);return{getRels:v}},void 0,import.meta.url),l=await o(t,s[e]),a=Object.values(l).find(v=>v.type?.includes("notesSlide"));let c="";if(a&&t[a.fullPath]){const v=new DOMParser().parseFromString(new TextDecoder().decode(t[a.fullPath]),"application/xml");c=ba(v)}const u=O(r,"cSld"),h=u?O(u,"spTree"):null;if(!h)return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:c,text:c};const d=[],p=[],g=[],b=[];for(const v of h.children){const k=v.localName;if(k==="sp"){const S=O(v,"txBody");if(!S)continue;const N=rs(v),M=os(v),F=as(v),T=wn(S),$=T.map(L=>L.text).join(`
|
|
120
|
-
`);$.trim()&&d.push({id:M,name:F,type:N,paragraphs:T,text:$})}else if(k==="pic"){const S=O(v,"nvPicPr"),N=S?O(S,"cNvPr"):null,M=N?Pe(N,"id",""):"",F=N?Pe(N,"name",""):"",T=N?Pe(N,"descr","")||Pe(N,"title",""):"",$=S?O(S,"nvPr"):null;$&&O($,"extLst"),g.push({id:M,name:F,altText:T,title:F})}else if(k==="graphicFrame"){const S=(()=>{const N=O(v,"graphic"),M=N?O(N,"graphicData"):null;return M?Pe(M,"uri",""):""})();if(S.includes("table")||O(v,"tbl")){const N=pa(v);N&&p.push(N)}else if(S.includes("chart")){const N=ga(v);if(N){const M=N.rId?l[N.rId]:null;let F={chartType:"chart",seriesNames:[],categories:[]};if(M&&t[M.fullPath]){const T=new DOMParser().parseFromString(new TextDecoder().decode(t[M.fullPath]),"application/xml");F=ma(T)}b.push({id:N.id,name:N.name,...F})}}}else if(k==="grpSp")for(const S of Ke(v,"sp")){const N=O(S,"txBody");if(!N)continue;const M=rs(S),F=os(S),T=as(S),$=wn(N),L=$.map(G=>G.text).join(`
|
|
121
|
-
`);L.trim()&&d.push({id:F,name:T,type:M,paragraphs:$,text:L})}}const _=d.find(v=>v.type==="title"),y=d.find(v=>v.type==="subtitle"),w=_?.text||"",x=y?.text||"",P=[w,x,...d.filter(v=>v.type!=="title"&&v.type!=="subtitle").map(v=>v.text),...p.map(v=>v.text),...b.map(v=>[v.name,...v.seriesNames,...v.categories].join(" ")),c].filter(Boolean).join(`
|
|
122
|
-
|
|
123
|
-
`);return{index:e,title:w,subtitle:x,textShapes:d,tables:p,images:g,charts:b,notes:c,text:P}}function ya(e){return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:"",text:""}}async function va(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await ln(t,e));return n}async function wa(e,n){return(await ln(e,n)).text}async function ka(e,n){const t=e.toLowerCase().trim();if(!t)return[];const s=[];for(let i=0;i<n.slideCount;i++){const r=await ln(i,n),o=r.text.toLowerCase();if(!o.includes(t))continue;const l=[];let a=0;for(;(a=o.indexOf(t,a))!==-1;){const c=Math.max(0,a-60),u=Math.min(r.text.length,a+t.length+60),h=r.text.slice(c,a),d=r.text.slice(a,a+t.length),p=r.text.slice(a+t.length,u);if(l.push({before:(c>0?"…":"")+h,match:d,after:p+(u<r.text.length?"…":"")}),a+=t.length,l.length>=3)break}s.push({slideIndex:i,title:r.title,score:l.length+(r.title.toLowerCase().includes(t)?10:0),excerpts:l})}return s.sort((i,r)=>r.score-i.score)}class xa{constructor(n,t,s={}){this.renderer=n,this.container=t,this.opts={fullscreen:!0,showNotes:!1,showThumbs:!1,showHud:!0,loop:!1,autoAdvance:0,...s},this._index=0,this._playing=!1,this._player=null,this._autoTimer=null,this._el=null,this._canvas=null,this._notesEl=null,this._hudEl=null,this._thumbsEl=null,this._thumbnails=[],this._touchStartX=0,this._touchStartY=0,this._onKey=this._onKey.bind(this),this._onResize=this._onResize.bind(this),this._onFsChange=this._onFsChange.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this)}async start(n=0){this._playing=!0,this._index=Math.max(0,Math.min(n,this.renderer.slideCount-1)),this._buildDOM(),this._attachEvents(),this.opts.fullscreen&&await this._requestFullscreen(),this.opts.showThumbs&&this._generateThumbnails(),await this._renderCurrent(),this._updateHud(),this.opts.autoAdvance>0&&this._startAutoAdvance()}stop(){this._playing=!1,this._stopAutoAdvance(),this._detachEvents(),document.fullscreenElement===this._el&&document.exitFullscreen().catch(()=>{}),this._el&&this._el.parentNode&&this._el.parentNode.removeChild(this._el),this._el=null,this._canvas=null,this._player=null,this.opts.onSlideChange?.(null)}async goto(n){if(!this._playing)return;const t=Math.max(0,Math.min(n,this.renderer.slideCount-1));if(t===this._index)return;const s=this._index;this._index=t,this._resetAutoAdvance(),await this._renderCurrent(s),this._updateHud(),this.opts.onSlideChange?.(this._index)}async next(){if(this._playing){if(this._player){const n=this.renderer.getAnimations?.(this._index)||[];n.length&&Math.max(...n.map(t=>t.clickNum),0),await this._player.nextClick?.()}this._index<this.renderer.slideCount-1?await this.goto(this._index+1):this.opts.loop&&await this.goto(0)}}async prev(){this._playing&&(this._index>0?await this.goto(this._index-1):this.opts.loop&&await this.goto(this.renderer.slideCount-1))}get currentIndex(){return this._index}get isPlaying(){return this._playing}_buildDOM(){const n=document.createElement("div");n.style.cssText=["position:fixed","inset:0","z-index:999999","background:#000","display:flex","flex-direction:column","align-items:center","justify-content:center","user-select:none","touch-action:none"].join(";"),n.setAttribute("tabindex","0"),this._el=n;const t=document.createElement("div");t.style.cssText="position:relative; flex:1; display:flex; align-items:center; justify-content:center; width:100%; overflow:hidden;";const s=document.createElement("canvas");if(s.style.cssText="display:block; box-shadow:0 4px 32px rgba(0,0,0,0.6);",this._canvas=s,t.appendChild(s),n.appendChild(t),this.opts.showHud){const r=document.createElement("div");r.style.cssText=["position:absolute","bottom:24px","left:50%","transform:translateX(-50%)","display:flex","align-items:center","gap:12px","background:rgba(0,0,0,0.55)","backdrop-filter:blur(8px)","border-radius:24px","padding:8px 20px","color:white","font:500 14px/1 system-ui,sans-serif","pointer-events:none"].join(";"),this._hudEl=r,n.appendChild(r)}if(this.opts.showNotes){const r=document.createElement("div");r.style.cssText=["width:100%","max-height:22vh","overflow-y:auto","background:rgba(0,0,0,0.7)","backdrop-filter:blur(8px)","color:#e0e0e0","font:14px/1.5 system-ui,sans-serif","padding:12px 24px","white-space:pre-wrap","flex-shrink:0"].join(";"),this._notesEl=r,n.appendChild(r)}if(this.opts.showThumbs){const r=document.createElement("div");r.style.cssText=["display:flex","gap:6px","padding:8px 16px","overflow-x:auto","background:rgba(0,0,0,0.7)","width:100%","flex-shrink:0"].join(";"),this._thumbsEl=r,n.appendChild(r);for(let o=0;o<this.renderer.slideCount;o++){const l=document.createElement("canvas");l.width=120,l.height=Math.round(120/(this.renderer.slideSize.cx/this.renderer.slideSize.cy)),l.style.cssText="flex-shrink:0; cursor:pointer; border:2px solid transparent; border-radius:3px; opacity:0.6; transition:opacity 0.2s,border-color 0.2s;",l.title=`Slide ${o+1}`;const a=o;l.addEventListener("click",()=>this.goto(a)),r.appendChild(l),this._thumbnails.push(l)}}t.addEventListener("click",()=>this.next()),this._buildNavArrows(t);const i=document.createElement("button");i.textContent="✕",i.style.cssText=["position:absolute","top:16px","right:20px","background:rgba(255,255,255,0.15)","border:none","color:white","font-size:18px","width:36px","height:36px","border-radius:50%","cursor:pointer","opacity:0.7","transition:opacity 0.2s"].join(";"),i.addEventListener("mouseover",()=>i.style.opacity="1"),i.addEventListener("mouseout",()=>i.style.opacity="0.7"),i.addEventListener("click",r=>{r.stopPropagation(),this.stop()}),n.appendChild(i),this.container.appendChild(n),n.focus(),this._resizeCanvas()}_buildNavArrows(n){const t=s=>{const i=document.createElement("button");i.textContent=s==="prev"?"❮":"❯",i.style.cssText=["position:absolute",s==="prev"?"left:16px":"right:16px","top:50%","transform:translateY(-50%)","background:rgba(255,255,255,0.18)","border:none","color:white","font-size:22px","width:48px","height:64px","border-radius:8px","cursor:pointer","opacity:0","transition:opacity 0.2s"].join(";"),i.addEventListener("mouseenter",()=>i.style.opacity="1"),i.addEventListener("mouseleave",()=>i.style.opacity="0"),i.addEventListener("click",r=>{r.stopPropagation(),s==="prev"?this.prev():this.next()}),n.addEventListener("mouseenter",()=>i.style.opacity="0.5"),n.addEventListener("mouseleave",()=>i.style.opacity="0"),n.appendChild(i)};t("prev"),t("next")}_resizeCanvas(){if(!this._canvas||!this._el)return;const{cx:n,cy:t}=this.renderer.slideSize,s=n/t,i=this._canvas.parentElement,r=i.clientWidth||window.innerWidth,o=i.clientHeight||window.innerHeight*.75;let l=r,a=l/s;a>o&&(a=o,l=a*s),this._canvas.width=Math.round(l*window.devicePixelRatio),this._canvas.height=Math.round(a*window.devicePixelRatio),this._canvas.style.width=Math.round(l)+"px",this._canvas.style.height=Math.round(a)+"px"}async _renderCurrent(n=null){if(this._canvas){if(this._resizeCanvas(),n!==null&&this.renderer.getTransition){const t=this.renderer.getTransition(this._index);if(t&&t.type!=="cut"&&typeof OffscreenCanvas<"u"){const{renderTransitionFrame:s}=await Qt(async()=>{const{renderTransitionFrame:c}=await Promise.resolve().then(()=>Yo);return{renderTransitionFrame:c}},void 0,import.meta.url),i=new OffscreenCanvas(this._canvas.width,this._canvas.height);i.getContext("2d").drawImage(this._canvas,0,0),await this.renderer.renderSlide(this._index,this._canvas,this._canvas.width/window.devicePixelRatio);const r=new OffscreenCanvas(this._canvas.width,this._canvas.height);r.getContext("2d").drawImage(this._canvas,0,0);const o=this._canvas.getContext("2d"),l=t.duration||700,a=performance.now();await new Promise(c=>{const u=h=>{const d=Math.min(1,(h-a)/l);s(o,i,r,t,d),d<1?requestAnimationFrame(u):c()};requestAnimationFrame(u)}),this._updateThumbnail(this._index),this._updateNotes();return}}await this.renderer.renderSlide(this._index,this._canvas,this._canvas.width/window.devicePixelRatio),this._updateThumbnail(this._index),this._updateNotes()}}_updateThumbnail(n){const t=this._thumbnails[n];!t||!this._canvas||(t.getContext("2d").drawImage(this._canvas,0,0,t.width,t.height),this._thumbnails.forEach((s,i)=>{s.style.borderColor=i===this._index?"#4af":"transparent",s.style.opacity=i===this._index?"1":"0.6"}))}_updateHud(){if(!this._hudEl)return;const n=this.renderer.slideCount;this._hudEl.innerHTML=`
|
|
124
|
-
<span style="opacity:0.7">Slide</span>
|
|
125
|
-
<strong>${this._index+1}</strong>
|
|
126
|
-
<span style="opacity:0.5">of ${n}</span>
|
|
127
|
-
`}async _updateNotes(){if(this._notesEl)try{const n=await this.renderer.getSlideNotes(this._index);this._notesEl.textContent=n||"(no notes)"}catch{this._notesEl.textContent=""}}async _generateThumbnails(){for(let n=0;n<this.renderer.slideCount&&this._playing;n++){const t=this._thumbnails[n];if(t){try{await this.renderer.renderSlide(n,t,t.width)}catch{}await new Promise(s=>setTimeout(s,50))}}}_attachEvents(){document.addEventListener("keydown",this._onKey),window.addEventListener("resize",this._onResize),document.addEventListener("fullscreenchange",this._onFsChange),this._el&&(this._el.addEventListener("touchstart",this._onTouchStart,{passive:!0}),this._el.addEventListener("touchend",this._onTouchEnd,{passive:!0}))}_detachEvents(){document.removeEventListener("keydown",this._onKey),window.removeEventListener("resize",this._onResize),document.removeEventListener("fullscreenchange",this._onFsChange)}_onKey(n){if(this._playing)switch(n.key){case"ArrowRight":case"ArrowDown":case" ":case"PageDown":n.preventDefault(),this.next();break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"Backspace":n.preventDefault(),this.prev();break;case"Home":n.preventDefault(),this.goto(0);break;case"End":n.preventDefault(),this.goto(this.renderer.slideCount-1);break;case"Escape":case"q":case"Q":n.preventDefault(),this.stop();break;case"f":case"F":n.preventDefault(),this._toggleFullscreen();break}}_onResize(){this._resizeCanvas(),this._renderCurrent()}_onFsChange(){document.fullscreenElement||this.stop()}_onTouchStart(n){this._touchStartX=n.touches[0].clientX,this._touchStartY=n.touches[0].clientY}_onTouchEnd(n){const t=n.changedTouches[0].clientX-this._touchStartX,s=n.changedTouches[0].clientY-this._touchStartY;Math.abs(t)>40&&Math.abs(t)>Math.abs(s)?t<0?this.next():this.prev():Math.abs(t)<10&&Math.abs(s)<10&&this.next()}async _requestFullscreen(){try{const n=this._el;n.requestFullscreen?await n.requestFullscreen():n.webkitRequestFullscreen&&await n.webkitRequestFullscreen()}catch{}}async _toggleFullscreen(){document.fullscreenElement?await document.exitFullscreen().catch(()=>{}):await this._requestFullscreen()}_startAutoAdvance(){this._stopAutoAdvance(),this.opts.autoAdvance>0&&(this._autoTimer=setInterval(()=>this.next(),this.opts.autoAdvance))}_stopAutoAdvance(){this._autoTimer&&(clearInterval(this._autoTimer),this._autoTimer=null)}_resetAutoAdvance(){this.opts.autoAdvance>0&&this._startAutoAdvance()}}function Xs(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}async function _a(e,n,t={}){typeof t=="number"&&(t={width:t});const{width:s=null,dpi:i=150}=t,r=s??Xs(n,i),o=await Hs(e,n,r),l=o.toDataURL("image/png");if(navigator.clipboard&&window.ClipboardItem)try{const c=await new Promise(u=>o.toBlob(u,"image/png"));return await navigator.clipboard.write([new ClipboardItem({"image/png":c})]),{success:!0,method:"clipboard-api",dataUrl:l}}catch(c){if(c.name!=="NotAllowedError")throw c}if(document.execCommand)try{const c=new Image;c.src=l,await new Promise(g=>{c.onload=g});const u=document.createElement("div");u.contentEditable="true",u.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;",u.appendChild(c),document.body.appendChild(u);const h=document.createRange();h.selectNodeContents(u);const d=window.getSelection();d.removeAllRanges(),d.addRange(h);const p=document.execCommand("copy");if(document.body.removeChild(u),d.removeAllRanges(),p)return{success:!0,method:"execCommand",dataUrl:l}}catch{}const a=window.open();return a&&(a.document.write(`<img src="${l}" style="max-width:100%">`),a.document.title=`Slide ${e+1}`),{success:!1,method:"opened-tab",dataUrl:l}}async function Vs(e,n,t={},s){typeof t=="number"&&(t={width:t});const{width:i=null,dpi:r=300,filename:o}=t,l=i??Xs(n,r),c=(await Hs(e,n,l)).toDataURL("image/png"),u=o||`slide-${e+1}.png`,h=document.createElement("a");h.href=c,h.download=u,h.click()}async function Pa(e,n={},t){typeof n=="number"&&(n={width:n});const{onProgress:s,...i}=n,r=s,o=e.slideCount;for(let l=0;l<o;l++)await Vs(l,e,i),r?.(l+1,o),await new Promise(a=>setTimeout(a,100))}async function Hs(e,n,t){const{cx:s,cy:i}=n.slideSize,r=s/i,o=Math.round(t/r),l=document.createElement("canvas");return l.width=t,l.height=o,await n.renderSlide(e,l,t),l}function Sa(e,n,t={}){const{thumbWidth:s=320,fullWidth:i=1280,gap:r="24px",background:o="#1a1a1a",slideBackground:l="#fff",shadow:a=!0,clickToShow:c=!1,maxWidth:u="900px",rootMargin:h=200,onSlideVisible:d,onSlideRendered:p}=t,{cx:g,cy:b}=e.slideSize,_=g/b,y=e.slideCount;n.style.cssText=`
|
|
128
|
-
background:${o};
|
|
129
|
-
padding:${r};
|
|
130
|
-
display:flex;
|
|
131
|
-
flex-direction:column;
|
|
132
|
-
align-items:center;
|
|
133
|
-
gap:${r};
|
|
134
|
-
overflow-y:auto;
|
|
135
|
-
position:relative;
|
|
136
|
-
`;const w=[],x=[],P=[];for(let M=0;M<y;M++){const F=document.createElement("div");F.style.cssText=`
|
|
137
|
-
width:100%;
|
|
138
|
-
max-width:${u};
|
|
139
|
-
position:relative;
|
|
140
|
-
background:${l};
|
|
141
|
-
border-radius:4px;
|
|
142
|
-
${a?"box-shadow:0 4px 24px rgba(0,0,0,0.5);":""}
|
|
143
|
-
overflow:hidden;
|
|
144
|
-
aspect-ratio:${g}/${b};
|
|
145
|
-
flex-shrink:0;
|
|
146
|
-
`,F.setAttribute("data-slide",M);const T=document.createElement("div");T.style.cssText=`
|
|
147
|
-
position:absolute;bottom:8px;right:10px;
|
|
148
|
-
background:rgba(0,0,0,0.45);color:#fff;
|
|
149
|
-
font:11px/1.4 system-ui,sans-serif;
|
|
150
|
-
padding:2px 7px;border-radius:10px;
|
|
151
|
-
pointer-events:none;z-index:1;
|
|
152
|
-
`,T.textContent=M+1,F.appendChild(T);const $=document.createElement("canvas");$.style.cssText="display:block;width:100%;height:100%;",$.width=s,$.height=Math.round(s/_),F.appendChild($);const L=Ta(M,g,b,l);F.appendChild(L),c&&(F.style.cursor="pointer",F.addEventListener("click",()=>{new(require("./slideshow.js")).SlideShow(e,document.body).start(M)})),n.appendChild(F),w.push(F),x.push($),P.push("pending")}const v=[];let k=!1;async function S(){if(!(k||v.length===0)){for(k=!0;v.length>0;){const M=v.shift();if(P[M]==="full")continue;const F=x[M],$=w[M].querySelector("[data-placeholder]");try{F.width=i,F.height=Math.round(i/_),await e.renderSlide(M,F,i),P[M]="full",F.style.transition="opacity 0.3s",F.style.opacity="1",$&&($.style.display="none"),p?.(M)}catch(L){console.warn(`LazyDeck: failed to render slide ${M}`,L)}}k=!1}}const N=new IntersectionObserver(M=>{for(const F of M){if(!F.isIntersecting)continue;const T=parseInt(F.target.getAttribute("data-slide"),10);if(!(isNaN(T)||P[T]==="full")){d?.(T);for(const $ of[T,T-1,T+1,T+2].filter(L=>L>=0&&L<y))P[$]!=="full"&&!v.includes($)&&v.push($);S()}}},{root:n,rootMargin:`${h}px`,threshold:0});return w.forEach(M=>N.observe(M)),{destroy(){N.disconnect(),n.innerHTML=""},scrollTo(M,F="smooth"){const T=w[M];T&&T.scrollIntoView({behavior:F,block:"start"})},async renderAll(M){for(let F=0;F<y;F++)P[F]!=="full"&&v.push(F);await S()},getCanvas(M){return x[M]||null},get slideCount(){return y}}}function Ta(e,n,t,s){const i=document.createElement("div");i.setAttribute("data-placeholder","1"),i.style.cssText=`
|
|
153
|
-
position:absolute;inset:0;
|
|
154
|
-
display:flex;align-items:center;justify-content:center;
|
|
155
|
-
background:${s};
|
|
156
|
-
flex-direction:column;gap:12px;
|
|
157
|
-
`;const r=`
|
|
158
|
-
<div style="width:55%;height:18px;background:#e0e0e0;border-radius:3px;animation:pulse 1.4s ease-in-out infinite;"></div>
|
|
159
|
-
<div style="width:72%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.1s;"></div>
|
|
160
|
-
<div style="width:62%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.2s;"></div>
|
|
161
|
-
<div style="width:45%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.3s;"></div>
|
|
162
|
-
`;if(!document.getElementById("_pptx_lazy_css")){const o=document.createElement("style");o.id="_pptx_lazy_css",o.textContent="@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}",document.head.appendChild(o)}return i.innerHTML=r,i}class ja{constructor(){this._files={},this.slideSize={cx:9144e3,cy:5143500},this.slidePaths=[],this.slideCount=0,this.themeData=null,this.themeColors={},this.masterDoc=null,this.masterRels={},this.masterImages={},this._blobUrls=[],this.embeddedFonts=[]}async load(n,t=()=>{}){let s;if(n instanceof Uint8Array)s=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);else if(n instanceof ArrayBuffer)s=n;else if(typeof n.arrayBuffer=="function")s=await n.arrayBuffer();else throw new TypeError("PptxRenderer.load(): expected File, Blob, ArrayBuffer, or Uint8Array");t(.05,"Decompressing…"),this._files=await Ps(s),t(.1,"Parsing presentation…");const i=this._readText("ppt/presentation.xml");if(!i)throw new Error("Invalid PPTX: missing ppt/presentation.xml");const r=ke(i),o=m(r,"sldSz");o&&(this.slideSize={cx:C(o,"cx",9144e3),cy:C(o,"cy",5143500)});const l=await Le(this._files,"ppt/presentation.xml");if(this.embeddedFonts=Yr(r,l),this.embeddedFonts.length>0){const h=this.embeddedFonts.map(d=>d.family).join(", ");console.info("[pptx-browser] PPTX contains embedded fonts: "+h+". Use registerFont() to supply woff2/ttf versions.")}const a=m(r,"sldIdLst");if(a)for(const h of a.children){if(h.localName!=="sldId")continue;const d=h.getAttribute("r:id")||h.getAttribute("id"),p=l[d];p&&this.slidePaths.push(p.fullPath)}this.slideCount=this.slidePaths.length,t(.2,"Loading theme…");let c=Object.values(l).find(h=>h.type?.includes("theme"))?.fullPath;if(!c){const h=Object.values(l).find(d=>d.type?.includes("slideMaster"));if(h){const d=await Le(this._files,h.fullPath);c=Object.values(d).find(p=>p.type?.includes("theme"))?.fullPath}}if(c){const h=this._readText(c);h&&(this.themeData=Wr(ke(h)))}this.themeData||(this.themeData={colors:{},majorFont:"Calibri Light",minorFont:"Calibri"}),this.themeColors={...this.themeData.colors},t(.3,"Loading master…");const u=Object.values(l).find(h=>h.type?.includes("slideMaster"));if(u){const h=this._readText(u.fullPath);if(h){this.masterDoc=ke(h),this.masterRels=await Le(this._files,u.fullPath),this.masterImages=await Gt(this._files,this.masterRels),this._trackBlobs(this.masterImages);const d=qr(this.masterDoc);this.themeColors=Kr(this.themeData,d)}}t(1,"Ready")}async renderSlide(n,t,s=1280){if(n<0||n>=this.slidePaths.length)throw new RangeError(`Slide ${n} out of range (0–${this.slidePaths.length-1})`);const i=this.slidePaths[n],r=this._readText(i);if(!r)throw new Error(`Could not read slide: ${i}`);const o=ke(r),l=await Le(this._files,i),a=await Gt(this._files,l);this._trackBlobs(a);let c=null,u={},h={};const d=Object.values(l).find(v=>v.type?.includes("slideLayout"));if(d){const v=this._readText(d.fullPath);v&&(c=ke(v),u=await Le(this._files,d.fullPath),h=await Gt(this._files,u),this._trackBlobs(h))}const p={...this.masterImages,...h,...a},g=Es([c,this.masterDoc]),b=eo([o,c,this.masterDoc]);await Jr(b,this.themeData);const _=s/this.slideSize.cx,y=Math.round(this.slideSize.cy*_);t.width=s,t.height=y;const w=t.getContext("2d");w.clearRect(0,0,s,y),await $s(w,o,this.masterDoc,c,l,this.masterRels,p,this.themeColors,_,this.slideSize.cx,this.slideSize.cy),await this._renderNonPlaceholders(w,this.masterDoc,this.masterRels,this.masterImages,_),await this._renderNonPlaceholders(w,c,u,h,_);const x=m(o,"cSld"),P=x?m(x,"spTree"):null;P&&await Is(w,P,l,p,this.themeColors,this.themeData,_,g,this._files)}async renderAllSlides(n=320){const t=[];for(let s=0;s<this.slideCount;s++){const i=document.createElement("canvas");await this.renderSlide(s,i,n),t.push(i)}return t}registerFont(n,t,s){return gn(n,t,s)}registerFonts(n){return Hr(n)}listRegisteredFonts(){return to()}_readText(n){const t=this._files[n];return t?new TextDecoder().decode(t):null}_trackBlobs(n){for(const t of Object.values(n))t?.src?.startsWith("blob:")&&this._blobUrls.push(t.src)}async _renderNonPlaceholders(n,t,s,i,r){if(!t)return;const o=m(t,"cSld"),l=o?m(o,"spTree"):null;if(l)for(const a of l.children){const c=a.localName;if(!["sp","pic","grpSp","graphicFrame","cxnSp"].includes(c))continue;const u=m(a,"nvSpPr"),h=u?m(u,"nvPr"):null;if(!(h&&m(h,"ph")))try{c==="sp"?await en(n,a,s,i,this.themeColors,this.themeData,r):c==="pic"?await tn(n,a,s,i,this.themeColors,r):c==="grpSp"?await nn(n,a,s,i,this.themeColors,this.themeData,r):c==="graphicFrame"?await rn(n,a,this.themeColors,this.themeData,r):c==="cxnSp"&&await sn(n,a,this.themeColors,r)}catch(d){console.warn(`[PptxRenderer] master/layout shape error (${c}):`,d)}}}getAnimations(n){const t=this.slidePaths[n];if(!t||!this._files)return[];const s=this._files[t];if(!s)return[];const i=ke(new TextDecoder().decode(s));return Nn(i)}getTransition(n){const t=this.slidePaths[n];if(!t||!this._files)return null;const s=this._files[t];if(!s)return null;const i=ke(new TextDecoder().decode(s));return An(i)}createPlayer(n){return new Us(this,n)}async toSvg(n){return Ks(n,this)}async allToSvg(){return la(this)}async loadEmbeddedFonts(){const n=this._presRels||{};return da(this._files,n)}listEmbeddedFonts(){return ua(this._files)}async extractSlide(n){return ln(n,this)}async extractAll(){return va(this)}async extractText(n){return wa(n,this)}async searchSlides(n){return ka(n,this)}createShow(n,t={}){return new xa(this,n,t)}async copySlide(n,t={}){return _a(n,this,t)}async downloadSlide(n,t={}){return Vs(n,this,t)}async downloadAllSlides(n={}){return Pa(this,n)}createDeck(n,t={}){return Sa(this,n,t)}edit(){return Ht.fromRenderer(this)}async toPdf(n={}){return Mn(this,n)}async downloadPdf(n="presentation.pdf",t={}){return Wo(this,n,t)}async slideToPdf(n,t={}){return qo(n,this,t)}async getSlideNotes(n){if(n<0||n>=this.slidePaths.length)return"";const t=await Le(this._files,this.slidePaths[n]),s=Object.values(t).find(l=>l.type?.includes("notesSlide"));if(!s)return"";const i=this._readText(s.fullPath);if(!i)return"";const r=ke(i),o=[];for(const l of ce(r,"sp")){const a=m(m(l,"nvSpPr"),"nvPr"),c=a?m(a,"ph"):null;if(!(c&&D(c,"type")==="sldNum"))for(const u of ce(l,"t"))o.push(u.textContent)}return o.join("").trim()}getInfo(){return{slideCount:this.slideCount,widthEmu:this.slideSize.cx,heightEmu:this.slideSize.cy,width:this.slideSize.cx/914400,height:this.slideSize.cy/914400,aspectRatio:this.slideSize.cx/this.slideSize.cy}}async toDataURL(n,t=1280,s="image/png",i=.92){const r=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas");if(await this.renderSlide(n,r,t),r instanceof OffscreenCanvas){const o=await r.convertToBlob({type:s,quality:i});return new Promise(l=>{const a=new FileReader;a.onload=()=>l(a.result),a.readAsDataURL(o)})}return r.toDataURL(s,i)}async toBlob(n,t=1280,s="image/png"){const i=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas");return await this.renderSlide(n,i,t),i instanceof OffscreenCanvas?i.convertToBlob({type:s}):new Promise(r=>i.toBlob(r,s))}destroy(){for(const n of this._blobUrls)try{URL.revokeObjectURL(n)}catch{}this._blobUrls=[],this._files={},this.masterDoc=null,this.masterImages={}}}const Fa=({asset:e,bytes:n,onOpenExternal:t,dense:s=!1})=>{const i=z.useRef(null),r=z.useRef(null),[o,l]=z.useState({phase:"loading",progress:0}),[a,c]=z.useState(0),[u,h]=z.useState(1),[d,p]=z.useState(0),[g,b]=z.useState(!1),[_,y]=z.useState([]),[w,x]=z.useState(!s),P=z.useRef(null),[v,k]=z.useState(!1);z.useEffect(()=>{x(!s)},[s]),z.useLayoutEffect(()=>{const F=P.current;if(!F)return;const T=()=>k(F.getBoundingClientRect().height<360);T();const $=new ResizeObserver(T);return $.observe(F),()=>$.disconnect()},[]),z.useEffect(()=>{let F=!1;const T=new ja;return i.current=T,l({phase:"loading",progress:0}),c(0),h(1),T.load(n,$=>{F||l({phase:"loading",progress:$})}).then(async()=>{if(F)return;const $=T.slideCount,G=(await T.renderAllSlides(160)).map(q=>q.toDataURL("image/png"));F||l({phase:"ready",slideCount:$,thumbnails:G})}).catch($=>{F||l({phase:"error",detail:$ instanceof Error&&$.message?$.message:j("ui.library.preview.pptx_failed_detail")})}),()=>{F=!0,T.destroy(),i.current=null}},[n,d]);const S=z.useCallback(async()=>{const F=i.current,T=r.current;if(!(!F||!T||o.phase!=="ready"))try{await F.renderSlide(a,T,Math.round(960*u))}catch($){l({phase:"error",detail:$ instanceof Error&&$.message?$.message:j("ui.library.preview.pptx_failed_detail")})}},[a,o.phase,u]);z.useEffect(()=>{S()},[S]),z.useEffect(()=>{const F=i.current;if(!F||o.phase!=="ready")return;let T=!1;return F.extractSlide(a).then($=>{T||y($.textShapes.map(L=>L.text.trim()).filter(Boolean))}).catch(()=>{T||y([])}),()=>{T=!0}},[a,o.phase]);const N=o.phase==="ready"?o.slideCount:0,M=F=>{N!==0&&c(Math.min(Math.max(F,0),N-1))};return o.phase==="error"?f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx("p",{className:"text-body text-ink",children:j("ui.library.preview.pptx_failed")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:o.detail}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(te,{variant:"secondary",size:"sm",onClick:()=>p(F=>F+1),children:j("ui.library.preview.retry")}),f.jsxs(te,{variant:"secondary",size:"sm",disabled:g,onClick:()=>{b(!0),ot(e).catch(F=>Se(F instanceof Error&&F.message?F.message:j("ui.library.menu.save_failed"))).finally(()=>b(!1))},children:[f.jsx(rt,{"aria-hidden":"true"}),j("ui.library.menu.download")]}),t&&f.jsxs(te,{variant:"ghost",size:"sm",onClick:t,children:[f.jsx(gs,{"aria-hidden":"true"}),j("ui.library.preview.open_externally")]})]})]}):f.jsxs("div",{ref:P,className:"flex min-h-0 flex-1 flex-col gap-2 p-3","data-pptx-viewer":"",onKeyDown:F=>{F.key==="ArrowRight"||F.key==="PageDown"?(F.preventDefault(),M(a+1)):F.key==="ArrowLeft"||F.key==="PageUp"?(F.preventDefault(),M(a-1)):F.key==="Home"?(F.preventDefault(),M(0)):F.key==="End"&&(F.preventDefault(),M(N-1))},children:[f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[f.jsx("div",{"data-pptx-slide":"",className:"flex min-h-[120px] min-w-0 flex-1 flex-col items-center justify-center rounded-md bg-canvas p-2",children:o.phase==="loading"?f.jsxs("div",{className:"flex w-60 flex-col items-center gap-2",children:[f.jsx(_t,{size:18,"aria-hidden":"true",className:"motion-safe:animate-spin text-ink-muted"}),f.jsx(zi,{value:Math.round(o.progress*100)}),f.jsx("span",{className:"text-meta text-ink-muted",children:j("ui.library.preview.pptx_preparing")})]}):f.jsx("canvas",{ref:r,className:"max-h-full max-w-full rounded-xs bg-surface","aria-label":j("ui.library.preview.slide_of",{index:String(a+1),count:String(N)})})}),o.phase==="ready"&&!v&&!s&&f.jsx("div",{className:"flex h-[72px] shrink-0 flex-row gap-1 overflow-x-auto overflow-y-hidden",children:o.thumbnails.map((F,T)=>f.jsx("button",{type:"button",onClick:()=>c(T),"aria-pressed":T===a,"aria-label":j("ui.library.preview.go_to_slide",{index:String(T+1)}),className:We("h-16 w-24 shrink-0 rounded-xs border p-0.5",T===a?"border-accent":"border-hairline hover:border-control"),children:f.jsx("img",{src:F,alt:"",loading:"lazy",className:"h-full w-full rounded-xs object-contain"})},T))})]}),o.phase==="ready"&&f.jsxs("div",{className:"shrink-0 rounded-md bg-canvas px-2 py-1","data-pptx-transcript":"",children:[s?f.jsx(te,{variant:"ghost",size:"sm","aria-expanded":w,onClick:()=>x(F=>!F),children:j("ui.library.preview.pptx_text")}):null,w&&f.jsx("div",{className:"max-h-24 overflow-y-auto text-meta text-ink-muted",children:_.length?_.map((F,T)=>f.jsx("p",{"data-pptx-transcript-line":"",className:"truncate",children:F},`${T}:${F}`)):f.jsx("p",{children:j("ui.library.preview.pptx_no_text")})})]}),f.jsxs("div",{className:"flex min-h-10 shrink-0 flex-wrap items-center justify-between gap-1 px-1 py-1",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.previous_slide"),disabled:a===0||o.phase!=="ready",onClick:()=>M(a-1),children:f.jsx(Pn,{"aria-hidden":"true"})}),f.jsx("span",{className:"text-meta tabular-nums text-ink-muted",children:j("ui.library.preview.slide_of",{index:String(N?a+1:0),count:String(N)})}),f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.next_slide"),disabled:a>=N-1||o.phase!=="ready",onClick:()=>M(a+1),children:f.jsx(Di,{"aria-hidden":"true"})})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.zoom_out"),onClick:()=>h(F=>Math.max(.5,F-.25)),children:f.jsx(ki,{"aria-hidden":"true"})}),f.jsxs("span",{className:"w-10 text-center text-meta tabular-nums text-ink-muted",children:[Math.round(u*100),"%"]}),f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.zoom_in"),onClick:()=>h(F=>Math.min(2,F+.25)),children:f.jsx(xi,{"aria-hidden":"true"})}),f.jsx(te,{variant:"ghost",size:"sm",onClick:()=>h(1),disabled:u===1,children:j("ui.library.preview.fit")})]})]})]})},ut=({label:e})=>f.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 py-10 text-body-sm text-ink-muted",children:[f.jsx(_t,{size:16,"aria-hidden":"true",className:"motion-safe:animate-spin"}),e??j("ui.library.preview.loading")]}),ft=({detail:e,asset:n})=>{const[t,s]=z.useState(!1);return f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(dt,{kind:n.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:j("ui.library.preview.could_not_load")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:e}),f.jsxs(te,{variant:"secondary",size:"sm",disabled:t,onClick:()=>{s(!0),ot(n).catch(i=>Se(i instanceof Error&&i.message?i.message:j("ui.library.menu.save_failed"))).finally(()=>s(!1))},children:[f.jsx(rt,{"aria-hidden":"true"}),j("ui.library.menu.download")]})]})},ls=({asset:e})=>f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(dt,{kind:e.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"max-w-90 text-body text-ink",children:j("ui.library.preview.unsupported",{kind:e.kind})}),f.jsxs("div",{className:"flex items-center gap-2",children:[e.ref.type==="path"&&e.ref.path?f.jsx(te,{variant:"secondary",size:"sm",onClick:()=>{e.ref.path&&window.api.openFile(e.ref.path)},children:j("ui.library.preview.open_externally")}):null,f.jsxs(te,{variant:"secondary",size:"sm",onClick:()=>void ot(e),children:[f.jsx(rt,{"aria-hidden":"true"}),j("ui.library.menu.download")]})]})]}),Ca=({asset:e})=>{const{bytes:n,mimeType:t,error:s,loading:i}=Je(e.id,"content",!0),r=Fn(n,t||e.ref.content_type);if(i)return f.jsx(ut,{});if(s||!r)return f.jsx(ft,{detail:s||"The bytes were empty.",asset:e});switch(e.kind){case"image":return f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-canvas p-3",children:f.jsx("img",{src:r,alt:e.name||e.derived_name,className:"max-h-full max-w-full object-contain"})});case"audio":return f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6",children:[f.jsx(dt,{kind:"audio",size:32,className:"text-ink-dim"}),f.jsx("audio",{src:r,controls:!0,className:"w-full max-w-100",children:f.jsx("track",{kind:"captions"})})]});default:return f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-canvas p-3",children:f.jsx("video",{src:r,controls:!0,className:"max-h-full max-w-full rounded-sm",children:f.jsx("track",{kind:"captions"})})})}},Ma=({asset:e})=>{const{bytes:n,mimeType:t,error:s,loading:i}=Je(e.id,"content",!0),r=Fn(n,t||e.ref.content_type);return i?f.jsx(ut,{}):s||!r?f.jsx(ft,{detail:s||"The bytes were empty.",asset:e}):f.jsx("iframe",{title:e.name||e.derived_name,src:r,className:"size-full flex-1 border-0 bg-surface",sandbox:e.kind==="html"?"allow-scripts":void 0})},Na=({asset:e,text:n})=>{const t=e.ref.type==="path"&&!!e.ref.path&&e.exists,s=e.ref.path,[i,r]=z.useState({state:"pending"});z.useEffect(()=>{if(!t||!s)return;let l=!1;return ti(s).then(a=>{l||r({state:"done",mtimeMs:a?.mtimeMs??null})}),()=>{l=!0}},[t,s]);const o=z.useMemo(()=>!t||!s||i.state!=="done"?null:Br(e,n,i.mtimeMs),[e,t,s,i,n]);return t&&i.state==="pending"?f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center",children:f.jsx(ut,{label:j("ui.library.preview.checking_file")})}):o?f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto bg-canvas",children:f.jsxs("div",{className:"mx-auto flex w-full max-w-[760px] flex-col gap-4 px-6 py-8",children:[f.jsx("p",{className:"text-meta text-ink-dim",children:j("ui.library.preview.breadcrumb",{name:o.title})}),f.jsx(ni,{document:o})]})}):f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:f.jsxs("div",{className:"mx-auto max-w-[720px]",children:[f.jsx("p",{className:"mb-4 text-meta text-ink-muted",children:j("ui.library.preview.read_only_markdown")}),f.jsx("div",{className:"prose-lo max-w-none text-body text-ink",children:f.jsx(_i,{remarkPlugins:[Pi],children:n})})]})})},Aa=({asset:e})=>{const{bytes:n,error:t,loading:s}=Je(e.id,"content",!0);if(s)return f.jsx(ut,{});if(t||!n)return f.jsx(ft,{detail:t||"The bytes were empty.",asset:e});const i=new TextDecoder("utf-8",{fatal:!1}).decode(n);return e.kind==="markdown"?f.jsx(Na,{asset:e,text:i}):f.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-4 font-mono text-mono-sm whitespace-pre-wrap break-words text-ink",children:i})},$a=({asset:e})=>{const{bytes:n,error:t,loading:s}=Je(e.id,"content",!0);return s?f.jsx(ut,{}):t||!n?f.jsx(ft,{detail:t||"The bytes were empty.",asset:e}):f.jsx(Ea,{asset:e,bytes:n})},cs=200,ds=40,Ea=({asset:e,bytes:n})=>{const t=(()=>{try{const r=si(n,{type:"array"}),o=r.SheetNames[0];if(!o)return null;const l=ii.sheet_to_json(r.Sheets[o],{header:1,raw:!1,defval:""});return{name:o,rows:l}}catch{return null}})();if(!t)return f.jsx(ft,{detail:j("ui.library.preview.sheet_unreadable"),asset:e});const s=t.rows.slice(0,cs),i=t.rows.length>cs;return f.jsxs("div",{className:"min-h-0 flex-1 overflow-auto p-2",children:[f.jsxs("table",{className:"w-full border-collapse text-meta",children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{className:"sticky top-0 bg-sunken px-2 py-1 text-left text-ink-muted",children:"#"}),(s[0]??[]).slice(0,ds).map((r,o)=>f.jsx("th",{className:"sticky top-0 border-b border-hairline bg-sunken px-2 py-1 text-left font-medium text-ink-muted",children:String.fromCharCode(65+o%26)},o))]})}),f.jsx("tbody",{children:s.map((r,o)=>f.jsxs("tr",{className:"odd:bg-canvas",children:[f.jsx("td",{className:"px-2 py-1 text-right tabular-nums text-ink-dim",children:o+1}),r.slice(0,ds).map((l,a)=>f.jsx("td",{className:"max-w-60 truncate border-b border-hairline px-2 py-1 font-mono text-ink",children:String(l??"")},a))]},o))})]}),i&&f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:j("ui.library.preview.sheet_truncated")}),f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:j("ui.library.preview.sheet_name",{name:t.name})})]})},Ra=({asset:e,dense:n=!1})=>e.kind==="pptx"?f.jsx(Ia,{asset:e,dense:n}):e.kind==="image"||e.kind==="audio"||e.kind==="video"?f.jsx(Ca,{asset:e}):e.kind==="pdf"||e.kind==="html"?f.jsx(Ma,{asset:e}):e.kind==="markdown"||e.kind==="text"||e.kind==="code"?f.jsx(Aa,{asset:e}):e.kind==="spreadsheet"?f.jsx($a,{asset:e}):e.kind==="docx"?f.jsx(ls,{asset:e}):f.jsx(ls,{asset:e}),Ia=({asset:e,dense:n=!1})=>{const{bytes:t,error:s,loading:i}=Je(e.id,"content",!0);return i?f.jsx(ut,{label:j("ui.library.preview.pptx_opening")}):s||!t?f.jsx(ft,{detail:s||"The bytes were empty.",asset:e}):f.jsx(Fa,{asset:e,bytes:t,dense:n})};function za(e){const n=br(!0),t=wr().create,s=vr(),[i,r]=z.useState(!1);return{commit:async l=>{r(!0);try{const a=new Map([...n.data??[],...e.tags].map(u=>[u.name.toLowerCase(),u.id])),c=[];for(const u of l){const h=u.trim().toLowerCase();if(!h)continue;let d=a.get(h);d||(d=(await t.mutateAsync({name:h})).id,a.set(h,d)),c.includes(d)||c.push(d)}await s.mutateAsync({id:e.id,tags:c})}catch(a){Se(a instanceof Error&&a.message?a.message:j("ui.library.preview.tags_not_saved"))}finally{r(!1)}},saving:i}}const us=({asset:e,nowMs:n,onClose:t,onOpenConversation:s,onFilterSession:i,onAsk:r,onToggleFavorite:o,composerFocusSignal:l,focusRequest:a,standalone:c=!1,onExpand:u})=>{Sn();const h=ws(),{commit:d,saving:p}=za(e),g=z.useRef(null),b=z.useRef(null),_=z.useRef(null),[y,w]=z.useState(!1),[x,P]=z.useState(!1);z.useLayoutEffect(()=>{const M=g.current;if(!M)return;const F=()=>w(M.getBoundingClientRect().height<700);F();const T=new ResizeObserver(F);return T.observe(M),()=>T.disconnect()},[]);const v=z.useMemo(()=>e.tags.map(M=>M.name),[e.tags]);z.useEffect(()=>{a&&(a.field==="tags"?(_.current?.scrollIntoView({block:"center"}),_.current?.querySelector("input")?.focus()):(b.current?.scrollIntoView({block:"center"}),b.current?.querySelector("button")?.click()))},[a?.signal]);const k=async M=>{try{await h.mutateAsync({id:e.id,fields:M})}catch(F){throw Se(F instanceof Error&&F.message?F.message:j("ui.library.preview.not_saved")),F}},S=async M=>{try{await h.mutateAsync({id:e.id,fields:{[M]:!e[M]}})}catch(F){Se(F instanceof Error&&F.message?F.message:j("ui.library.preview.not_saved"))}},N=()=>{if(e.ref.type==="path"&&e.ref.path){window.api.openFile(e.ref.path);return}ot(e).catch(()=>Se(j("ui.library.menu.save_failed")))};return f.jsxs("div",{ref:g,className:"flex h-full min-h-0 flex-col bg-canvas","data-library-preview":e.id,"data-library-compact":y?"":void 0,"data-glass-region":"pane",children:[f.jsxs("header",{className:"flex shrink-0 flex-col gap-2 px-4 pt-3 pb-2",children:[c&&f.jsxs(te,{variant:"ghost",size:"sm",className:"self-start",onClick:t,children:[f.jsx(Pn,{"aria-hidden":"true"}),j("ui.library.page.back")]}),f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(dt,{kind:e.kind,size:18,className:"mt-1.5 text-ink-dim"}),f.jsx("div",{ref:b,className:"min-w-0 flex-1",children:f.jsx(Rn,{label:j("ui.library.preview.name"),value:Pt(e),onSave:M=>k({name:M}),isSaving:h.isPending})}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[f.jsx(Lt,{content:e.favorite?j("ui.library.menu.unfavorite"):j("ui.library.menu.favorite"),children:f.jsx(te,{variant:"ghost",size:"icon-sm","aria-pressed":e.favorite,"aria-label":e.favorite?j("ui.library.menu.unfavorite"):j("ui.library.menu.favorite"),onClick:()=>void S("favorite"),children:f.jsx(xt,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0})})}),f.jsx(Lt,{content:e.locked?j("ui.library.preview.unlock"):j("ui.library.preview.lock"),children:f.jsx(te,{variant:"ghost",size:"icon-sm","aria-pressed":e.locked,"aria-label":e.locked?j("ui.library.preview.unlock"):j("ui.library.preview.lock"),onClick:()=>void S("locked"),children:e.locked?f.jsx(ri,{"aria-hidden":"true",className:"text-accent"}):f.jsx(oi,{"aria-hidden":"true"})})}),u&&f.jsx(Lt,{content:j("ui.library.preview.expand"),children:f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.expand"),onClick:u,children:f.jsx(Si,{"aria-hidden":"true"})})}),f.jsx(Cn,{asset:e,onAsk:r,onEditMetadata:()=>{b.current?.querySelector("button")?.click()},onEditTags:()=>{_.current?.scrollIntoView({block:"center"}),_.current?.querySelector("input")?.focus()},onToggleFavorite:o,onOpenConversation:s,onFilterSession:i}),f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.preview.close"),onClick:t,children:f.jsx(mt,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta text-ink-muted",children:[f.jsx(st,{variant:"neutral",children:e.kind}),f.jsx(st,{variant:"neutral",children:j(jn(e.origin_group))}),f.jsx("span",{children:Tn(e.size_bytes)}),e.width&&e.height?f.jsxs("span",{children:[e.width,"×",e.height]}):null,e.organized?f.jsx("span",{children:j("ui.library.preview.organized_by",{by:e.organized.by??"librarian",at:ur(e.organized.at,n)})}):f.jsx("span",{children:j("ui.library.preview.unorganized")}),e.exists?null:f.jsx(st,{variant:"warning",children:j("ui.library.preview.missing_file")})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs(te,{variant:"secondary",size:"sm",onClick:N,children:[f.jsx(gs,{"aria-hidden":"true"}),j("ui.library.preview.open")]}),e.ref.type==="path"&&e.ref.path?f.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(hn,{"aria-hidden":"true"}),j("ui.library.preview.reveal")]}):null,f.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>void ot(e).then(()=>pn(j("ui.library.menu.saved_a_copy"))).catch(()=>Se(j("ui.library.menu.save_failed"))),children:[f.jsx(rt,{"aria-hidden":"true"}),j("ui.library.preview.download")]}),e.occurrences[0]?f.jsx(te,{variant:"link",size:"sm",onClick:()=>s(e.occurrences[0].session_id),children:j("ui.library.preview.from_conversation",{title:e.occurrences[0].session_title||e.occurrences[0].session_id})}):null]}),y&&f.jsxs(te,{variant:"ghost",size:"sm",className:"self-start","aria-expanded":x,onClick:()=>P(M=>!M),children:[f.jsx(Li,{"aria-hidden":"true",className:We("transition-transform duration-fast",x&&"rotate-180")}),j("ui.library.preview.details")]}),(!y||x)&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex flex-col gap-1",children:f.jsx(Rn,{label:j("ui.library.preview.description"),value:e.description,multiline:!0,rows:3,placeholder:j("ui.library.preview.add_description"),onSave:M=>k({description:M}),isSaving:h.isPending})}),f.jsxs("div",{ref:_,className:"flex items-start gap-2",children:[f.jsx("div",{className:"min-w-0 flex-1",children:f.jsx(Wi,{label:j("ui.library.preview.tags"),value:v,disabled:p,onChange:M=>void d(M),placeholder:j("ui.library.preview.add_tag")})}),p&&f.jsx(_t,{size:14,"aria-hidden":"true",className:"mt-6 motion-safe:animate-spin text-ink-muted"})]})]})]}),f.jsx("div",{className:"flex min-h-0 flex-1 flex-col bg-sunken",children:f.jsx(Ra,{asset:e,dense:y})}),f.jsx("div",{className:"shrink-0",children:f.jsx(Lr,{asset:e,focusSignal:l,compact:y})})]})},Ys="library-view",Qs="library-filters",Da=1152,La=1200,Ba=900;function Oa(){try{return localStorage.getItem(Ys)==="list"?"list":"grid"}catch{return"grid"}}function Ua(){try{const e=sessionStorage.getItem(Qs);if(!e)return Bt;const n=JSON.parse(e);return{...Bt,...n,q:""}}catch{return Bt}}function Ga(e){try{sessionStorage.setItem(Qs,JSON.stringify({...e,q:""}))}catch{}}function Wa(){const[e,n]=z.useState(null),[t,s]=z.useState(0);return z.useLayoutEffect(()=>{if(!e)return;s(e.getBoundingClientRect().width);const i=new ResizeObserver(r=>{const o=r[0];o&&s(o.contentRect.width)});return i.observe(e),()=>i.disconnect()},[e]),{ref:n,width:t}}function qa(){const[e,n]=z.useState(()=>window.innerWidth);return z.useEffect(()=>{const t=()=>n(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e}const Ka=({enabled:e,nowMs:n})=>{const t=yr(e),s=_r(),i=_n(),r=t.data;if(!r)return null;const o=r.last_run_at??r.last_run?.at??null,l=r.unorganized??r.library?.unorganized??null;return f.jsxs("div",{className:"flex h-10 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 overflow-hidden text-meta text-ink-muted","data-library-librarian":"",children:[f.jsx("span",{className:"font-medium text-ink",children:j("ui.library.librarian.title")}),f.jsx("span",{children:r.paused?j("ui.library.librarian.paused"):r.enabled?j("ui.library.librarian.enabled"):j("ui.library.librarian.disabled")}),f.jsx("span",{children:o?j("ui.library.librarian.last_organized",{at:Xa(o,n)}):j("ui.library.librarian.never_run")}),l!==null&&l>0&&f.jsx("span",{children:j("ui.library.librarian.unorganized",{count:l})}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsxs(te,{variant:"ghost",size:"sm",disabled:!r.enabled||s.isPending,onClick:()=>s.mutate("run",{onError:a=>Se(a instanceof Error?a.message:j("ui.library.librarian.control_failed"))}),children:[f.jsx(fs,{"aria-hidden":"true"}),j("ui.library.librarian.organize_now")]}),f.jsx(te,{variant:"ghost",size:"sm",disabled:!r.session_id||s.isPending,onClick:()=>s.mutate("open",{onSuccess:a=>{a?.session_id&&ht(i,a.session_id)},onError:a=>Se(a instanceof Error?a.message:j("ui.library.librarian.control_failed"))}),children:j("ui.library.librarian.open")})]})]})};function Xa(e,n){const t=Math.max(0,n-e*1e3),s=Math.floor(t/36e5);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}const Va=({onBack:e})=>f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Dt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:j("ui.library.preview.unavailable")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:j("ui.library.preview.unavailable_detail")}),f.jsxs(te,{variant:"secondary",size:"sm",onClick:e,children:[f.jsx(Pn,{"aria-hidden":"true"}),j("ui.library.page.back")]})]}),Ha=({nowMs:e})=>{Sn();const n=_n(),t=Ti(),s=ji(),i=Fi(),r=Ci(i.data,"library",1),o=e??Date.now(),{ref:l,width:a}=Wa(),c=qa(),u=new URLSearchParams(t.search).get("full")==="1",h=c>=La&&a>=Ba,[d,p]=z.useState(Ua),[g,b]=z.useState(""),_=ai(g,200),[y,w]=z.useState(Oa),[x,P]=z.useState(!1),[v,k]=z.useState(0),[S,N]=z.useState(null),M=z.useRef(null),F=s.assetId??null,T=a>=Da&&!!F&&!u;z.useEffect(()=>{p(R=>R.q===_?R:{...R,q:_})},[_]),z.useEffect(()=>Ga(d),[d]),z.useEffect(()=>{try{localStorage.setItem(Ys,y)}catch{}},[y]);const $=gr(d,r),L=ws(),G=mr(F,r),q=z.useMemo(()=>{const R=$.data?.pages??[],E=R.length>1&&R.at(-1)?.cursor_reset?[R.at(-1)]:R,Q=new Set,V=[];for(const J of E)for(const Z of J?.rows??[])Q.has(Z.id)||(Q.add(Z.id),V.push(Z));return V},[$.data]),B=$.data?.pages.at(-1),U=B?.total??0,H=q.find(R=>R.id===F)??null,K=G.data??H,ee=()=>void $.fetchNextPage(),I=!!(F&&!K&&!G.isLoading&&G.isError),X=!!F&&!T,ne=z.useCallback(R=>{n(`/library/assets/${R}${t.search}`,{state:t.state})},[n,t.search,t.state]),ae=z.useCallback(()=>{const R=new URLSearchParams(t.search);R.delete("full");const W=R.toString();n(`/library${W?`?${W}`:""}`)},[n,t.search]),ue=z.useCallback(()=>{if(!F)return;const R=new URLSearchParams(t.search);R.set("full","1"),n(`/library/assets/${F}?${R.toString()}`)},[n,F,t.search]),re=z.useCallback(R=>{ne(R.id),k(W=>W+1)},[ne]),Y=z.useCallback(R=>{L.mutate({id:R.id,fields:{favorite:!R.favorite}})},[L]),ye=z.useCallback(R=>void ht(n,R),[n]),se=z.useCallback(R=>{p(W=>({...W,session:R})),n("/library")},[n]),oe={onSelect:ne,onAsk:re,onEditMetadata:R=>{ne(R.id),N({field:"metadata",signal:Date.now()})},onEditTags:R=>{ne(R.id),N({field:"tags",signal:Date.now()})},onToggleFavorite:Y,onOpenConversation:ye,onFilterSession:se};if(z.useEffect(()=>{const R=W=>{const E=W.target,Q=E?.tagName==="INPUT"||E?.tagName==="TEXTAREA"||E?.isContentEditable;if(W.key==="f"&&(W.metaKey||W.ctrlKey)||W.key==="/"&&!Q){W.preventDefault(),M.current?.focus();return}if(!(Q||W.metaKey||W.ctrlKey||W.altKey)){if(W.key==="Escape"){F&&ae();return}if(W.key.toLowerCase()==="g"){W.preventDefault(),w(V=>V==="grid"?"list":"grid");return}if(W.key.toLowerCase()==="j"||W.key.toLowerCase()==="k"){if(X||q.length===0)return;W.preventDefault();const V=F?q.findIndex(fe=>fe.id===F):-1,J=W.key.toLowerCase()==="j"?1:-1,Z=Math.min(Math.max(V===-1?J===1?0:q.length-1:V+J,0),q.length-1);ne(q[Z].id)}}};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[ae,ne,q,F,X]),!r)return f.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[f.jsx(Ai,{title:j("ui.library.page.title"),icon:Dt}),i.isLoading?f.jsx("div",{className:"flex justify-center py-16",children:f.jsx(Ln,{label:j("ui.library.page.checking")})}):f.jsx(Bn,{variant:"warning",children:j("ui.library.page.unavailable")})]});const de=f.jsx(Er,{filters:d,onChange:R=>{p({...R,q:R.q}),b(R.q)},counts:B?.counts,tags:B?.tags??[],total:U}),we=q.length===0&&!$.isLoading,be=lr(d);return f.jsxs("div",{ref:l,"data-glass-region":"canvas","data-glass-split":"",className:"flex h-full min-h-0 flex-col overflow-hidden bg-canvas",children:[f.jsxs("header",{className:"flex shrink-0 flex-col gap-1 px-6 pt-4 pb-2 min-[800px]:h-[136px]",children:[f.jsxs("div",{className:"flex h-12 min-w-0 items-center gap-2",children:[f.jsx(Dt,{size:20,"aria-hidden":"true",className:"text-ink-muted"}),f.jsx("h1",{className:"text-title text-ink",children:j("ui.library.page.title")}),f.jsx("span",{className:"ml-2 text-meta tabular-nums text-ink-dim",children:j("ui.library.page.loaded_count",{loaded:String(q.length),total:String(U)})}),f.jsxs("div",{className:"ml-auto flex items-center rounded-sm border border-control",children:[f.jsx(te,{variant:"ghost",size:"icon-sm","aria-pressed":y==="grid","aria-label":j("ui.library.page.grid_view"),onClick:()=>w("grid"),children:f.jsx(Mi,{"aria-hidden":"true"})}),f.jsx(te,{variant:"ghost",size:"icon-sm","aria-pressed":y==="list","aria-label":j("ui.library.page.list_view"),onClick:()=>w("list"),children:f.jsx(li,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{className:"flex h-12 min-w-0 items-center gap-2",children:[f.jsxs("div",{className:"relative min-w-60 flex-1",children:[f.jsx(Ni,{size:14,"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-ink-dim"}),f.jsx(Bi,{ref:M,value:g,onChange:R=>b(R.target.value),onKeyDown:R=>{R.key==="Enter"&&R.preventDefault()},placeholder:j("ui.library.page.search"),"aria-label":j("ui.library.page.search"),"data-library-search":"",className:"pl-8"})]}),f.jsxs(ms,{children:[f.jsx(bs,{asChild:!0,children:f.jsxs(te,{variant:"secondary",size:"sm",children:[f.jsx(On,{"aria-hidden":"true"}),j("ui.library.page.sort")]})}),f.jsx(ys,{align:"end",className:"min-w-45",children:or.map(R=>f.jsxs(Ce,{onSelect:()=>p(W=>({...W,sort:R.key,order:ar(R.key)})),children:[d.sort===R.key?f.jsx(Oi,{"aria-hidden":"true"}):f.jsx("span",{className:"size-4"}),f.jsx("span",{children:j(R.labelKey)})]},R.key))})]}),f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.page.reverse_order"),onClick:()=>p(R=>({...R,order:R.order==="asc"?"desc":"asc"})),children:d.order==="asc"?f.jsx(Yi,{"aria-hidden":"true"}):f.jsx(On,{"aria-hidden":"true"})}),!h&&!X&&f.jsxs(te,{variant:"secondary",size:"sm",onClick:()=>P(!0),children:[f.jsx(ci,{"aria-hidden":"true"}),j("ui.library.page.filters")]})]}),f.jsx(Ka,{enabled:r,nowMs:o}),B?.state==="building"&&f.jsx("div",{className:"flex h-4 items-center gap-2 text-meta text-ink-muted","aria-live":"polite",children:f.jsx("span",{children:j("ui.library.page.building",{scanned:String(B.scan.sessions_scanned),total:String(B.scan.sessions_total)})})})]}),f.jsxs("div",{className:"flex min-h-0 flex-1",children:[h&&!X&&f.jsx("aside",{"data-glass-region":"page-sidebar","aria-label":j("ui.library.page.filters"),className:"w-48 shrink-0 overflow-hidden border-r border-hairline bg-surface",children:de}),f.jsxs("div",{className:"flex min-w-0 flex-1",children:[!X&&f.jsx("section",{"data-glass-region":"canvas-content","aria-label":j("ui.library.page.results"),"aria-busy":$.isLoading||$.isFetching,className:"min-w-0 flex-1 overflow-y-auto px-4 py-4 [scrollbar-gutter:stable]",children:$.isLoading?f.jsx(Ar,{view:y}):$.isError?f.jsxs("div",{className:"flex flex-col items-start gap-3 py-10",children:[f.jsx(Bn,{variant:"warning",children:$.error instanceof Error&&$.error.message?$.error.message:j("ui.library.page.load_failed")}),f.jsxs(te,{variant:"secondary",size:"sm",onClick:()=>void $.refetch(),children:[f.jsx(fs,{"aria-hidden":"true"}),j("ui.library.page.retry")]})]}):we?f.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-center",children:[f.jsx(Dt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:be?j("ui.library.page.no_matches"):j("ui.library.page.empty_title")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:be?j("ui.library.page.no_matches_detail"):j("ui.library.page.empty_detail")}),be&&f.jsx(te,{variant:"secondary",size:"sm",onClick:()=>{p(Bt),b("")},children:j("ui.library.page.clear_all")})]}):f.jsxs(f.Fragment,{children:[f.jsx(Nr,{assets:q,selectedId:F,view:y,hasMore:!!$.hasNextPage,loadingMore:$.isFetchingNextPage,onLoadMore:ee,...oe}),$.isFetchNextPageError&&f.jsxs("div",{className:"flex items-center gap-2 py-3 text-meta text-ink-muted",children:[f.jsx("span",{children:j("ui.library.page.load_more_failed")}),f.jsx(te,{variant:"ghost",size:"sm",onClick:ee,children:j("ui.library.page.retry")})]})]})}),T&&K&&f.jsx("aside",{className:"flex w-[448px] shrink-0 border-l border-hairline","aria-label":j("ui.library.page.preview"),children:f.jsx(us,{asset:K,nowMs:o,onClose:ae,onOpenConversation:ye,onFilterSession:se,onAsk:()=>k(R=>R+1),onToggleFavorite:()=>Y(K),composerFocusSignal:v,focusRequest:S,onExpand:ue})}),X&&f.jsx("div",{className:"min-w-0 flex-1","aria-label":j("ui.library.page.preview"),children:I?f.jsx(Va,{onBack:ae}):K?f.jsx(us,{asset:K,nowMs:o,onClose:ae,onOpenConversation:ye,onFilterSession:se,onAsk:()=>k(R=>R+1),onToggleFavorite:()=>Y(K),composerFocusSignal:v,focusRequest:S,standalone:!0}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(Ln,{label:j("ui.library.preview.loading")})})}),!X&&!K&&T&&f.jsx("div",{className:"hidden w-[448px] shrink-0 items-start justify-center border-l border-hairline p-8 lg:flex",children:f.jsx("p",{className:"max-w-60 text-center text-body-sm text-ink-dim",children:j("ui.library.page.select_asset")})})]})]}),f.jsx(Ui,{open:x,onOpenChange:P,children:f.jsx(Gi,{side:"left",className:"w-80 max-w-[calc(100vw-32px)] p-0",children:f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[f.jsx("span",{className:"text-heading text-ink",children:j("ui.library.page.filters")}),f.jsx(te,{variant:"ghost",size:"icon-sm","aria-label":j("ui.library.page.close_filters"),onClick:()=>P(!1),children:f.jsx(mt,{"aria-hidden":"true"})})]}),f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:de})]})})})]})},il=Object.freeze(Object.defineProperty({__proto__:null,LibraryPage:Ha},Symbol.toStringTag,{value:"Module"}));export{ce as a,D as b,m as g,il as l};
|