local-operator-ui 0.36.4 → 0.36.6
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 +3915 -150
- package/out/preload/index.js +120 -0
- package/out/renderer/assets/{_basePickBy-DQ6BzkJm.js → _basePickBy-B0B_HryP.js} +1 -1
- package/out/renderer/assets/{_baseUniq-D4Pzw8OZ.js → _baseUniq-BC6WfZEZ.js} +1 -1
- package/out/renderer/assets/{agent-details-page-vUtr6XRL.js → agent-details-page-CIKeI8ax.js} +2 -2
- package/out/renderer/assets/{agent-hub-page-DLfJB8ns.js → agent-hub-page-NKE7fJK1.js} +2 -7
- package/out/renderer/assets/agents-page-BIRTx9kB.js +7 -0
- package/out/renderer/assets/{arc-BvXLfjiv.js → arc-DyL52bz_.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DGO7ixLg.js → architectureDiagram-IEHRJDOE-OQsI3Nan.js} +1 -1
- package/out/renderer/assets/{arrow-up-D8Tgt51O.js → arrow-up-BpuHf_sB.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-Bpj3zFYQ.js → blockDiagram-JOT3LUYC-CS1fz58m.js} +1 -1
- package/out/renderer/assets/{book-open-DeWHPw1t.js → book-open-BiI_r4jM.js} +1 -1
- package/out/renderer/assets/browser-page-CvUjgYjV.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-CLrsocAn.js → browser-webauthn-prompt-ja8N1ehh.js} +1 -1
- package/out/renderer/assets/building-2-Dar5h3t0.js +6 -0
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-tA5p19nS.js → c4Diagram-VJAJSXHY-C6RZIvJP.js} +1 -1
- package/out/renderer/assets/channel-Ca9itbEI.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-CAtpoCnM.js → chunk-4BMEZGHF-Cpn-cLXo.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-CYHy7Mvk.js → chunk-A2AXSNBT-S8Vffyme.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-B2bXanTe.js → chunk-AEK57VVT-K1GcoFUy.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-DfhdrNKB.js → chunk-D6G4REZN-CyqTe7_6.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-BNdcLGHR.js → chunk-RZ5BOZE2-QWUc1JND.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-Caa_mRlB.js → chunk-XZIHB7SX-v3MFY8Qn.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BDSTmyjZ.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BDSTmyjZ.js +1 -0
- package/out/renderer/assets/clone-OIhREtCX.js +1 -0
- package/out/renderer/assets/{console-mirror-BnHVC7eO.js → console-mirror-BfM9Le8Y.js} +1 -1
- package/out/renderer/assets/{consoleCapture-BxykZlLx.js → consoleCapture-mqMk3W7y.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-CJiOSzCX.js → conversation-input-sync-BD8ZrQRq.js} +292 -262
- package/out/renderer/assets/{dagre-OKDRZEBW-pq4RiyaY.js → dagre-OKDRZEBW-D1-V7-Tj.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DnlzCGD2.js → diagram-SSKATNLV-D7jQdHV1.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DbJ2RTVe.js → diagram-VNBRO52H-DB_YZ9C8.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-C56WVcbc.js → erDiagram-Q7BY3M3F-Blv-3W3v.js} +1 -1
- package/out/renderer/assets/{error-boundary-Tv9TlaZ8.js → error-boundary-Bpk2r3Ma.js} +2 -2
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CL1GRaaq.js → flowDiagram-4HSFHLVR-BTShSZPF.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CES2U6dP.js → ganttDiagram-APWFNJXF-_SXfULy-.js} +4 -4
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-CRyPEqXz.js → gitGraphDiagram-7IBYFJ6S-9E7LTj7S.js} +1 -1
- package/out/renderer/assets/{graph-Dtsej9jG.js → graph-BhaFec28.js} +1 -1
- package/out/renderer/assets/hash-CrDnkZ9w.js +6 -0
- package/out/renderer/assets/index-BgwxrPpP.css +1 -0
- package/out/renderer/assets/index-BuM037wD.js +824 -0
- package/out/renderer/assets/index-ByYW6G08.js +57 -0
- package/out/renderer/assets/{index-BsV4LVu3.js → index-ClCIwVJj.js} +1 -1
- package/out/renderer/assets/{index-DAoplO_Z.js → index-Shz25Z8Y.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-BwRaN2ZH.js → infoDiagram-PH2N3AL5-CCsEuNFb.js} +1 -1
- package/out/renderer/assets/{installer-DjflOef5.js → installer-CJRb2tgb.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-CwrSuzth.js → journeyDiagram-U35MCT3I-LXUs-hfi.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-CjW130n-.js → kanban-definition-NDS4AKOZ-GLYV-Ku1.js} +1 -1
- package/out/renderer/assets/{layout-DnBx2qbk.js → layout-erSNWSH-.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-BiAHAYWZ.js → legacy-agents-page-CtFhdgCi.js} +7 -7
- package/out/renderer/assets/library-page-C6-aUarQ.js +157 -0
- package/out/renderer/assets/{mermaid.core-BHqZ2SZO.js → mermaid.core-BGROKqtx.js} +5 -5
- package/out/renderer/assets/mesh-page-CzSDWDfu.js +1 -0
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Ca2VY79V.js → mindmap-definition-ALO5MXBD-C1KlK3C5.js} +1 -1
- package/out/renderer/assets/{mini-Dd3N58po.js → mini-Dnf6EgXd.js} +1 -1
- package/out/renderer/assets/{notebook-pen-CcH01r1l.js → notebook-pen-CTurnI5u.js} +1 -1
- package/out/renderer/assets/{org-access-WIuI99P6.js → org-access-DTXfQgW5.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-BsP8aWCi.js → org-surface-gate-CDaexKo1.js} +1 -1
- package/out/renderer/assets/{page-header-ggruiR-O.js → page-header-Does21Km.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-C7lP9J7V.js → pieDiagram-IB7DONF6-DaaMC8-4.js} +1 -1
- package/out/renderer/assets/{projects-page-BIRVv4yi.js → projects-page-Bw0c4vc_.js} +6 -6
- package/out/renderer/assets/publication-validation-MxGQJEQj.js +1 -0
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CPMEK8EO.js → quadrantDiagram-7GDLP6J5-BVFqf3uw.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-sbfBaJo0.js → radar-MK3ICKWK-BbBjm1y3.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-C0ljZy4O.js → radient-auth-buttons-BeDvFHK7.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-S2rhrmTH.js → requirementDiagram-KVF5MWMF-luASPwgm.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-sNpc3Wfn.js → sankeyDiagram-QLVOVGJD-DJ-Xk1mH.js} +1 -1
- package/out/renderer/assets/{schedules-page-DbZSRb3g.js → schedules-page-D7XfeTME.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-Cv-47OeQ.js → sequenceDiagram-X6HHIX6F-C9vBEHGW.js} +1 -1
- package/out/renderer/assets/{settings-page-DH9sXfEW.js → settings-page-BubJ0gmV.js} +8 -8
- package/out/renderer/assets/smartart-DCxfy3Tv.js +1 -0
- package/out/renderer/assets/{stateDiagram-DGXRK772-DIBWf8qm.js → stateDiagram-DGXRK772-DCbA594R.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-P9yjg6o0.js +1 -0
- package/out/renderer/assets/{tags-input-chips-B4_gHGYO.js → tags-input-chips-BSg2kzIn.js} +1 -1
- package/out/renderer/assets/team-bridge-page-DshgiIxJ.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-CE8q2f33.js → timeline-definition-BDJGKUSR-AlhVX480.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-CAt3Nng3.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-LdjExo2g.js → use-download-agent-mutation-DmirSifx.js} +4 -4
- package/out/renderer/assets/{use-memberships-query-DcD9UeVY.js → use-memberships-query-fzcoT-92.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-Cqye2iDz.js → use-session-snapshot-DQQ3D8W6.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DlbgdRgT.js → xychartDiagram-VJFVF3MP-djayCUFZ.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/agents-page-B-PHMFxF.js +0 -7
- package/out/renderer/assets/browser-page-DAQis2Rt.js +0 -1
- package/out/renderer/assets/channel-CG3c-hsB.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BGWu-T14.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BGWu-T14.js +0 -1
- package/out/renderer/assets/clone-UwOnPjS7.js +0 -1
- package/out/renderer/assets/index-D0l2JJ6w.js +0 -829
- package/out/renderer/assets/index-hX_aZwq0.js +0 -57
- package/out/renderer/assets/index-vPvXCaIy.css +0 -1
- package/out/renderer/assets/library-page-BGmng_P-.js +0 -162
- package/out/renderer/assets/mesh-page-1yPLxWRO.js +0 -1
- package/out/renderer/assets/publication-validation-C73bqNja.js +0 -1
- package/out/renderer/assets/smartart-C2eRO4WK.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DBPLNjJl.js +0 -1
- package/out/renderer/assets/ui-preferences-store-C6eXGzFs.js +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./smartart-DCxfy3Tv.js","./index-ByYW6G08.js","./index-BgwxrPpP.css","./index-BuM037wD.js","./conversation-input-sync-BD8ZrQRq.js","./ui-preferences-store-CAt3Nng3.js","./error-boundary-Bpk2r3Ma.js","./conversation-input-sync-CAX4_ErH.css","./console-mirror-BfM9Le8Y.js","./console-mirror-DOrYoP_4.css","./index-DHKnfVbX.css","./page-header-Does21Km.js","./hash-CrDnkZ9w.js","./tags-input-chips-BSg2kzIn.js","./arrow-up-BpuHf_sB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as D,j as f,t as S,c as qe}from"./index-ByYW6G08.js";import{bp as zt,F as xt,bq as zn,aY as Sn,br as pt,bs as ti,bt as ni,bu as si,bv as ii,bw as ri,bb as Ln,bx as oi,by as ai,bj as li,bz as Lt,bA as ci,bB as di,bC as gn}from"./index-BuM037wD.js";import{c1 as ui,c2 as Dn,c3 as fi,c4 as hi,c5 as pi,C as Tn,u as ct,aN as Be,c6 as Oe,d as Ce,c7 as hs,D as Yt,b4 as gi,c8 as mn,c9 as mi,ca as bi,aS as rt,aO as bn,a7 as je,cb as ps,cc as At,cd as yi,ce as vi,cf as wi,cg as _t,ch as ki,bW as Bn,aQ as jn,au as xi,bO as Qt,ci as gs,bP as Fn,cj as _i,ck as Pi,cl as Si,cm as Ti,cn as ji,bI as Fi,b$ as Ci,aR as Mi,a as Ni,c as Ai,co as $i,bN as Ei}from"./conversation-input-sync-BD8ZrQRq.js";import{P as Ri}from"./page-header-Does21Km.js";import{c as Pt,h as ms,y as Dt,i as bs,a as K,k as ys,q as Ne,a9 as Ii,aa as zi,ab as Li,p as On,B as st,X as ot,u as Cn,T as Di,ac as Bi,J as Oi,j as Ui,S as Un,A as fn,I as Gi,s as Wi,ad as qi,ae as Ki}from"./error-boundary-Bpk2r3Ma.js";import"./ui-preferences-store-CAt3Nng3.js";import{H as Xi}from"./hash-CrDnkZ9w.js";import{T as Vi}from"./tags-input-chips-BSg2kzIn.js";import{A as Hi}from"./arrow-up-BpuHf_sB.js";var Yi=class extends ui{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:Dn()})}getOptimisticResult(e){return e.behavior=Dn(),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,d=o&&a==="forward",c=i&&a==="forward",h=o&&a==="backward",u=i&&a==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:hi(n,t.data),hasPreviousPage:fi(n,t.data),isFetchNextPageError:d,isFetchingNextPage:c,isFetchPreviousPageError:h,isFetchingPreviousPage:u,isRefetchError:l&&!d&&!h,isRefetching:r&&!c&&!u}}};function Qi(e,n){return pi(e,Yi,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 Zi=[["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"}]],Gn=Pt("arrow-down-wide-narrow",Zi);/**
|
|
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 Ji=[["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"}]],er=Pt("arrow-up-narrow-wide",Ji);/**
|
|
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 tr=[["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"}]],nr=Pt("presentation",tr);/**
|
|
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 sr=[["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"}]],ir=Pt("sheet",sr);/**
|
|
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 rr=[["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"}]],or=Pt("tags",rr),ar=["generated","created","mentioned"],yn=[{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"}],lr=[{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:"",scope:"final",tagMode:"all",highlighted:!1,sort:"recent",order:"desc"};function cr(e){return e==="name"||e==="kind"?"asc":"desc"}function Wn(e,n){return e.status===n}function dr(e){return!!(e.q.trim()||e.category||e.originGroup||e.tag||e.session||e.highlighted||e.status)}function ur(e){if(e==="unorganized")return!1}function St(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 fr(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 Mn(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 hr(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 pr(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 Zt(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"]},gr=60;function mr(e,n){return{op:"library.list",scope:e.scope,...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=ur(e.status);return t!==void 0?{organized:t}:{}})(),sort:e.sort,order:e.order,limit:gr,...n?{cursor:n}:{}}}function br(e,n){return Qi({queryKey:Ue.list(e),enabled:n,initialPageParam:void 0,queryFn:({pageParam:t})=>Ce(mr(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 yr(e,n){return Tn({queryKey:Ue.detail(e??""),enabled:n&&!!e,queryFn:()=>Ce({op:"library.get",id:e}),retry:Yt,staleTime:5e3})}function vr(e){return Tn({queryKey:Ue.tags,enabled:e,queryFn:()=>Ce({op:"library.tags"}),retry:Yt,staleTime:2e4})}function ws(e){return Tn({queryKey:Ue.librarian,enabled:e,queryFn:()=>Ce({op:"library.librarian",action:"status"}).then(n=>"librarian"in n?n.librarian:n),retry:Yt,staleTime:3e4})}function Ke(e){return e.invalidateQueries({queryKey:Ue.all})}function ks(){const e=ct();return Be({mutationFn:n=>Ce({op:"library.update",id:n.id,fields:n.fields}),onSuccess:n=>(e.setQueryData(Ue.detail(n.id),n),Ke(e)),onError:(n,t)=>{e.invalidateQueries({queryKey:Ue.detail(t.id)}),e.invalidateQueries({queryKey:Ue.all})},retry:Oe})}function wr(){const e=ct();return Be({mutationFn:n=>Ce({op:"library.tags.assign",id:n.id,tags:n.tags,...n.primary?{primary:n.primary}:{}}),onSuccess:n=>(e.setQueryData(Ue.detail(n.id),n),Ke(e)),onError:()=>Ke(e),retry:Oe})}function kr(){const e=ct(),n=()=>Ke(e),t=Be({mutationFn:o=>Ce({op:"library.tags.create",name:o.name,...o.category?{category:o.category}:{}}),onSuccess:n,retry:Oe}),s=Be({mutationFn:o=>Ce({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=>Ce({op:"library.tags.delete",id:o.id}),onSuccess:n,retry:Oe}),r=Be({mutationFn:o=>Ce({op:"library.tags.merge",id:o.id,into:o.into}),onSuccess:n,retry:Oe});return{create:t,update:s,remove:i,merge:r}}function xr(){const e=ct();return Be({mutationFn:n=>Ce({op:"library.chat.link",id:n.id,sessionId:n.sessionId}),onSuccess:()=>Ke(e),onError:()=>Ke(e),retry:Oe})}function _r(){const e=ct();return Be({mutationFn:n=>Ce({op:"library.chat.clear",id:n.id}),onSuccess:()=>Ke(e),retry:Oe})}function Pr(){const e=ct();return Be({mutationFn:n=>Ce({op:"library.librarian",action:n}).then(t=>"librarian"in t?t.librarian:t),onSuccess:()=>Ke(e),retry:Oe})}function et(e,n,t,s=!1){const[i,r]=D.useState({bytes:null,mimeType:"",error:null,loading:!1});return D.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 Nn(e,n){const[t,s]=D.useState(null);return D.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 Sr=/[\\/]/;function Tr(e){const t=St(e).split(Sr).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 at(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=Tr(e),i.rel="noopener",document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(s),3e4)}const An=({asset:e,onAsk:n,onEditMetadata:t,onEditTags:s,onToggleFavorite:i,onOpenConversation:r,onFilterSession:o,triggerClassName:l})=>{const a=async(u,g)=>{try{await navigator.clipboard.writeText(u),bn(g)}catch{je(S("ui.library.menu.copy_failed"))}},d=async()=>{try{await at(e),bn(S("ui.library.menu.saved_a_copy"))}catch{je(S("ui.library.menu.save_failed"))}},c=!!(e.ref.type==="path"&&e.ref.path),h=e.occurrences;return f.jsxs(ms,{children:[f.jsx(Dt,{content:S("ui.library.menu.asset_actions"),children:f.jsx(bs,{asChild:!0,children:f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.menu.asset_actions_label",{name:e.name||e.derived_name}),className:l,onClick:u=>u.stopPropagation(),"data-library-asset-menu":"",children:f.jsx(gi,{"aria-hidden":"true"})})})}),f.jsxs(ys,{align:"end",className:"min-w-52",onClick:u=>u.stopPropagation(),children:[h.length===1?f.jsxs(Ne,{onSelect:()=>r(h[0].session_id),children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.open_source_conversation")})]}):h.length>1?f.jsxs(Ii,{children:[f.jsxs(zi,{children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.open_source_conversation")})]}),f.jsx(Li,{className:"min-w-60",children:h.map(u=>f.jsx(Ne,{onSelect:()=>r(u.session_id),children:f.jsx("span",{className:"truncate",children:u.session_title||u.session_id})},`${u.session_id}:${u.first_seq}`))})]}):null,f.jsxs(Ne,{onSelect:n,children:[f.jsx(zt,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.ask_about_asset")})]}),h.length>0&&f.jsxs(Ne,{onSelect:()=>o(h[0].session_id),children:[f.jsx(mn,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.show_from_conversation")})]}),f.jsx(On,{}),f.jsxs(Ne,{onSelect:i,children:[f.jsx(xt,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0}),f.jsx("span",{children:e.favorite?S("ui.library.menu.unfavorite"):S("ui.library.menu.favorite")})]}),f.jsxs(Ne,{onSelect:t,children:[f.jsx(mi,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.edit_metadata")})]}),f.jsxs(Ne,{onSelect:s,children:[f.jsx(or,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.edit_tags")})]}),f.jsx(On,{}),e.ref.path?f.jsxs(Ne,{onSelect:()=>void a(e.ref.path,S("ui.library.menu.path_copied")),children:[f.jsx(bi,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.copy_path")})]}):null,f.jsxs(Ne,{onSelect:()=>void a(e.id,S("ui.library.menu.asset_id_copied")),children:[f.jsx(Xi,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.copy_asset_id")})]}),c?f.jsxs(Ne,{onSelect:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(mn,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.reveal_in_finder")})]}):f.jsxs(Ne,{onSelect:()=>void d(),children:[f.jsx(rt,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.download")})]}),e.ref.type==="artifact"&&f.jsxs(Ne,{onSelect:()=>void d(),children:[f.jsx(rt,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.save_a_copy")})]})]})]})},jr={image:wi,audio:vi,video:yi,pdf:At,pptx:nr,docx:At,markdown:At,html:zn,spreadsheet:ir,text:At,code:zn,other:ps};function Fr(e){return jr[e]??ps}function dt({kind:e,size:n=20,className:t}){const s=Fr(e);return f.jsx(s,{size:n,"aria-hidden":"true",className:t})}const xs=({group:e})=>f.jsx(st,{variant:e==="generated"?"accent":"neutral",children:S(Zt(e))}),_s=({asset:e,large:n=!1})=>{const[t,s]=ki("300px"),i=e.kind==="image"&&e.exists&&s,r=et(e.id,"thumbnail",i),o=Nn(r.bytes,r.mimeType);return f.jsx("div",{ref:t,className:qe("relative flex shrink-0 items-center justify-center overflow-hidden bg-canvas",n?"aspect-[16/10] w-full":"h-24 w-32"),children:o?f.jsx("img",{src:o,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(dt,{kind:e.kind,size:n?28:22,className:"text-ink-dim"})})},Cr=()=>f.jsx("span",{className:"absolute top-1.5 left-1.5 flex size-5 items-center justify-center rounded-full bg-elevated",title:S("ui.library.card.highlighted"),children:f.jsx(xt,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),Ps=({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]})]})},Mr=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:qe("group relative flex flex-col overflow-hidden rounded-lg border border-hairline bg-surface",n&&Sn),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(_s,{asset:e,large:!0}),e.highlighted&&f.jsx(Cr,{}),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:St(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:Mn(e.size_bytes)}),e.duration_s?f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:pr(e.duration_s)})]}):null]}),f.jsx(Ps,{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(xs,{group:e.origin_group}),e.session_count>1&&f.jsx("span",{className:"text-meta text-ink-dim",children:S("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(An,{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"})})]}),Nr=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:qe("group relative flex items-center gap-3 rounded-md border border-hairline bg-surface px-3 py-2",n&&Sn),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(_s,{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"}),St(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(Ps,{asset:e}),f.jsx("span",{children:e.kind}),f.jsx("span",{children:Mn(e.size_bytes)}),f.jsx(xs,{group:e.origin_group})]})]}),f.jsx(An,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession})]}),Ar=({assets:e,selectedId:n,view:t,hasMore:s,loadingMore:i,onLoadMore:r,...o})=>{const l=D.useRef(null);return D.useEffect(()=>{const a=l.current;if(!a||!s)return;const d=new IntersectionObserver(c=>{c.some(h=>h.isIntersecting)&&r()},{rootMargin:"600px 0px"});return d.observe(a),()=>d.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(Mr,{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(Nr,{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"}),S("ui.library.grid.loading_more")]}),!i&&s&&f.jsx(K,{variant:"ghost",size:"sm",onClick:r,children:S("ui.library.grid.load_more")})]})]})},$r=({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))}),Er=[{key:"highlighted",labelKey:"ui.library.status.highlighted"},{key:"unorganized",labelKey:"ui.library.status.unorganized"},{key:"favorite",labelKey:"ui.library.status.favorites"}],Ge=({label:e,count:n,active:t,onPress:s,icon:i,indent:r=!1})=>f.jsxs("button",{type:"button",onClick:s,"aria-pressed":t,className:qe("flex h-7 w-full items-center gap-2 rounded-md px-2 text-left text-body-sm",r&&"pl-6",t?Sn:"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})]}),ht=({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})]}),Rr=({filters:e,onChange:n,counts:t,tags:s,total:i,scopeTotal:r})=>{const o=fr(s),l=t?.category??{},a=c=>n({...e,...c}),d=!!(e.category||e.originGroup||e.status||e.tag||e.session||e.highlighted);return f.jsxs("div",{"data-lo-sidebar-edge-cues":!0,className:"flex h-full flex-col gap-5 overflow-y-auto px-2 py-4","data-library-filter-rail":"",children:[d&&f.jsxs(K,{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(ot,{"aria-hidden":"true"}),S("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:S("ui.library.filter.one_conversation")}),f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.filter.clear_conversation"),onClick:()=>a({session:void 0}),children:f.jsx(ot,{"aria-hidden":"true"})})]}),f.jsxs(ht,{label:S("ui.library.filter.scope"),children:[f.jsx(Ge,{label:S("ui.library.filter.scope_final"),active:e.scope==="final",onPress:()=>a({scope:"final"})}),f.jsx(Ge,{label:S("ui.library.filter.scope_all"),count:r??void 0,active:e.scope==="all",onPress:()=>a({scope:"all"})})]}),f.jsxs(ht,{label:S("ui.library.filter.categories"),children:[f.jsx(Ge,{label:S("ui.library.category.all"),count:i,active:!e.category,onPress:()=>a({category:void 0})}),yn.map(c=>f.jsx(Ge,{label:S(c.labelKey),count:l[c.key]??0,active:e.category===c.key,onPress:()=>a({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(l).filter(c=>!yn.some(h=>h.key===c)).sort().map(c=>f.jsx(Ge,{label:c,count:l[c],active:e.category===c,onPress:()=>a({category:e.category===c?void 0:c}),icon:f.jsx(Bn,{size:14,"aria-hidden":"true"})},c))]}),f.jsx(ht,{label:S("ui.library.filter.status"),children:Er.map(c=>f.jsx(Ge,{label:S(c.labelKey),active:Wn(e,c.key),onPress:()=>a({status:Wn(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(ht,{label:S("ui.library.filter.source"),children:ar.filter(c=>e.originGroup===c||e.scope==="all"||(t?.origin_group?.[c]??0)>0).map(c=>f.jsx(Ge,{label:S(Zt(c)),count:t?.origin_group?.[c]??0,active:e.originGroup===c,onPress:()=>a({originGroup:e.originGroup===c?void 0:c})},c))}),o.length>0&&f.jsx(ht,{label:S("ui.library.filter.tags"),children:o.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(h=>f.jsx(Ge,{label:h.name,count:h.count??0,active:e.tag===h.id,onPress:()=>a({tag:e.tag===h.id?void 0:h.id}),icon:f.jsx(Bn,{size:13,"aria-hidden":"true"}),indent:!0},h.id))]},c.category))}),e.tag&&f.jsx(st,{variant:"neutral",children:S("ui.library.filter.tag_mode",{mode:e.tagMode.toUpperCase()})})]})},Ir=new Set(["image/png","image/jpeg","image/gif","image/webp"]),zr=1e6;function Lr(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`${St(e)} (${n})`}const Br=({asset:e,focusSignal:n,compact:t=!1})=>{Cn();const s=jn(),i=D.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]=D.useState(""),[a,d]=D.useState(!1),[c,h]=D.useState({}),[u,g]=D.useState(null),p=c[e.id]??null,b=u===e.id,_=xr(),y=_r(),w=et(e.id,"content",e.kind==="image");D.useEffect(()=>{l("")},[e.id]),D.useEffect(()=>{n!==0&&i.current?.focus()},[n]);const x=async()=>{const k=o.trim();if(!(!k||a)){d(!0);try{const T=xi.getState();let N=e.chat?.session_id??p??null;if(!N&&(N=await T.createSession(T.cwd||"~"),!N))throw new Error(T.error??S("ui.library.composer.could_not_start"));const M={op:"sessions.message",sessionId:N,requestId:crypto.randomUUID(),text:`${k}
|
|
28
|
+
|
|
29
|
+
${Dr(e)}`},F=e.ref.content_type||w.mimeType;if(e.kind==="image"&&w.bytes&&Ir.has(F)){const j=Lr(w.bytes);j.length<=zr&&(M.images=[{data_b64:j,mime_type:F}])}if(await Ce(M),l(""),!e.chat&&!p)try{await _.mutateAsync({id:e.id,sessionId:N})}catch(j){h(E=>({...E,[e.id]:N})),g(e.id),je(j instanceof Error&&j.message?S("ui.library.composer.link_failed",{message:j.message}):S("ui.library.composer.link_failed_short"));return}if(p)try{await _.mutateAsync({id:e.id,sessionId:N}),h(j=>{const E={...j};return delete E[e.id],E}),g(null)}catch{g(e.id),je(S("ui.library.composer.link_failed_short"));return}await pt(s,N)}catch(T){je(T instanceof Error&&T.message?T.message:S("ui.library.composer.not_sent"))}finally{d(!1)}}},P=e.chat,v=async()=>{const k=p??e.chat?.session_id;if(k)try{await _.mutateAsync({id:e.id,sessionId:k}),h(T=>{const N={...T};return delete N[e.id],N}),g(null)}catch{je(S("ui.library.composer.link_failed_short"))}};return f.jsxs("div",{className:qe("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&&p&&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:S("ui.library.composer.message_sent_link_failed")}),f.jsx(K,{variant:"ghost",size:"sm",onClick:()=>void v(),children:S("ui.library.composer.retry_link")}),f.jsx(K,{variant:"ghost",size:"sm",onClick:()=>void pt(s,p),children:S("ui.library.composer.open_chat")})]}),P&&f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx(ti,{size:13,"aria-hidden":"true"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:S("ui.library.composer.chat_about",{title:P.title||P.session_id})}),f.jsx(K,{variant:"ghost",size:"sm",onClick:()=>void pt(s,P.session_id),children:S("ui.library.composer.open_chat")}),f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.composer.unlink"),onClick:()=>y.mutate({id:e.id}),children:f.jsx(ot,{"aria-hidden":"true"})})]}),f.jsxs("div",{"data-glass-region":"composer",className:qe("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(Di,{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?S("ui.library.composer.continue_placeholder"):S("ui.library.composer.ask_placeholder"),"aria-label":S("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(K,{variant:"primary",size:"icon-sm",disabled:!o.trim()||a,"aria-label":S("ui.library.composer.send"),onClick:()=>void x(),children:a?f.jsx(_t,{"aria-hidden":"true",className:"motion-safe:animate-spin"}):f.jsx(Hi,{"aria-hidden":"true"})})]})]})};function Or(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 Ss(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 p=n.length-22;p>=l;p--)if(t.getUint32(p,!0)===s){o=p;break}if(o===-1)throw new Error("Not a valid ZIP file: EOCD not found");let a,d;const c=o-20;if(c>=0&&t.getUint32(c,!0)===r){const p=Number(t.getBigUint64(c+8,!0));if(t.getUint32(p,!0)!==i)throw new Error("Invalid ZIP64 end record");a=Number(t.getBigUint64(p+48,!0)),d=Number(t.getBigUint64(p+32,!0))}else a=t.getUint32(o+16,!0),d=t.getUint16(o+8,!0);if(a+4>n.length)throw new Error("ZIP central directory offset is outside the file");const h=33639248,u={};let g=a;for(let p=0;p<d&&!(g+46>n.length||t.getUint32(g,!0)!==h);p++){const b=t.getUint16(g+10,!0);let _=t.getUint32(g+20,!0),y=t.getUint32(g+24,!0);const w=t.getUint16(g+28,!0),x=t.getUint16(g+30,!0),P=t.getUint16(g+32,!0);let v=t.getUint32(g+42,!0);const k=Gr(n,g+46,w);if(_===4294967295||y===4294967295||v===4294967295){const j=g+46+w,E=j+x;let L=j;for(;L+4<=E;){const z=t.getUint16(L,!0),Q=t.getUint16(L+2,!0);if(z===1){let G=L+4;y===4294967295&&G+8<=E&&(y=Number(t.getBigUint64(G,!0)),G+=8),_===4294967295&&G+8<=E&&(_=Number(t.getBigUint64(G,!0)),G+=8),v===4294967295&&G+8<=E&&(v=Number(t.getBigUint64(G,!0)));break}L+=4+Q}}if(g+=46+w+x+P,k.endsWith("/")||b!==0&&b!==8||v+30>n.length)continue;const T=t.getUint16(v+26,!0),N=t.getUint16(v+28,!0),M=v+30+T+N;if(M+_>n.length)continue;const F=n.subarray(M,M+_);try{u[k]=b===0?F.slice():await Ur(F)}catch(j){console.warn(`[zip.js] Failed to decompress "${k}":`,j.message)}}return u}async function Ur(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:d}=await s.read();if(d)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 Gr(e,n,t){return new TextDecoder().decode(e.subarray(n,n+t))}function _e(e){return new DOMParser().parseFromString(e,"application/xml")}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 m(e,n){return de(e,n)[0]??null}function B(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=B(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,Wr=Object.freeze(Object.defineProperty({__proto__:null,EMU_PER_PT:bt,attr:B,attrInt:C,clamp:Ie,g1:m,gtn:de,parseXml:_e},Symbol.toStringTag,{value:"Module"}));function qr(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 d=m(a,"srgbClr"),c=m(a,"sysClr");d?t[l]=d.getAttribute("val")||"":c&&(t[l]=c.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 Kr(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 Xr(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 qn=null,hn=null;function Vr(){return hn||(qn=typeof OffscreenCanvas<"u"?new OffscreenCanvas(300,10):Object.assign(document.createElement("canvas"),{width:300,height:10}),hn=qn.getContext("2d")),hn}const Kn="mmmmmmmmmmlllllllllliiiiiiiiiixxxxxxxxxx",Hr=[20,40];function Ts(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=Vr(),t=["monospace","serif"];for(const s of Hr)for(const i of t){n.font=`${s}px ${i}`;const r=n.measureText(Kn).width;n.font=`${s}px "${e}", ${i}`;const o=n.measureText(Kn).width;if(Math.abs(o-r)>.5)return Ut.add(e),!0}}catch{}return!1}async function vn(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 Yr(e){const n=[];for(const[t,s]of Object.entries(e))if(typeof s=="string")n.push(vn(t,s));else if(Array.isArray(s))for(const i of s){const{url:r,...o}=i;n.push(vn(t,r,o))}await Promise.all(n)}function Qr(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 d of["regular","bold","italic","boldItalic"]){const c=m(i,d);if(!c)continue;const h=c.getAttribute("r:id")||c.getAttribute("id"),u=n?.[h];u&&(a.push(u.fullPath),l[d]=!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 Zr(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&&Ts(t.google)?t.google:t.google||e:e}function Jr(e){if(!e)return"sans-serif";const n=e.toLowerCase().trim();return it[n]?.generic??"sans-serif"}async function eo(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 d=null,c=[400,700];if(a){if(a._custom||a.google===null)continue;d=a.google,c=a.weights.length?a.weights:[400,700]}else d=o;if(!d||Ot.has(d))continue;if(Ts(d)){Ot.add(d);continue}const h=s.get(d)??new Set;c.forEach(u=>h.add(u)),s.set(d,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((c,h)=>c-h),d=[...a.map(c=>`0,${c}`),...a.map(c=>`1,${c}`)].join(";");return`family=${encodeURIComponent(`${o}:ital,wght@${d}`)}`}).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 to(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 js(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 d=s?.minorFont??"Calibri";function c(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"){d=s?.majorFont??d;return}if(x==="+mn-lt"||x==="+mn"){d=s?.minorFont??d;return}d=x}}c(r),c(n),c(e);const h=Zr(d),u=Jr(d),g=o*127*t;return{fontStr:`${a?"italic ":""}${l?"bold":"normal"} ${g}px "${h}", ${u}`,sz:o,szPx:g,bold:l,italic:a,family:h,generic:u,rawFamily:d}}function no(){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 Ve(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 We(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 so={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 io(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 d=a/1e5,c=Ve(t,s,i),h=We(c.h,Ie(c.l*d,0,1),c.s);t=h.r,s=h.g,i=h.b;break}case"lumOff":{const d=a/1e5,c=Ve(t,s,i),h=We(c.h,Ie(c.l+d,0,1),c.s);t=h.r,s=h.g,i=h.b;break}case"tint":{const d=a/1e5;t=Math.round(t+(255-t)*(1-d)),s=Math.round(s+(255-s)*(1-d)),i=Math.round(i+(255-i)*(1-d));break}case"shade":{const d=a/1e5;t=Math.round(t*d),s=Math.round(s*d),i=Math.round(i*d);break}case"satMod":{const d=a/1e5,c=Ve(t,s,i),h=We(c.h,c.l,Ie(c.s*d,0,1));t=h.r,s=h.g,i=h.b;break}case"satOff":{const d=a/1e5,c=Ve(t,s,i),h=We(c.h,c.l,Ie(c.s+d,0,1));t=h.r,s=h.g,i=h.b;break}case"hueMod":{const d=a/1e5,c=Ve(t,s,i),h=We(c.h*d%1,c.l,c.s);t=h.r,s=h.g,i=h.b;break}case"hueOff":{const d=a/216e5,c=Ve(t,s,i),h=We(((c.h+d)%1+1)%1,c.l,c.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 d=Ve(t,s,i),c=We((d.h+.5)%1,d.l,d.s);t=c.r,s=c.g,i=c.b;break}}}return{r:Ie(t,0,255),g:Ie(s,0,255),b:Ie(i,0,255),a:r}}function ye(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=so[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=We(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?io({...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 Xn(e,n){if(!e)return null;const t=m(e,"solidFill");if(!t)return null;const s=me(t),i=ye(s,n);return i?ge(i):null}function ro(e,n,t){const s=Xn(e,t);return s||Xn(n,t)}function Kt(e,n,t,s,i,r,o){const l=u=>u*Math.PI/180,a=(u,g=5e4)=>(o&&o[u]!==void 0?o[u]:g)/1e5,d=t+i/2,c=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 u=a(0,16667)*h*.5;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.arcTo(t+i,s,t+i,s+u,u),e.lineTo(t+i,s+r-u),e.arcTo(t+i,s+r,t+i-u,s+r,u),e.lineTo(t+u,s+r),e.arcTo(t,s+r,t,s+r-u,u),e.lineTo(t,s+u),e.arcTo(t,s,t+u,s,u),e.closePath();break}case"ellipse":case"oval":e.ellipse(d,c,i/2,r/2,0,0,Math.PI*2);break;case"triangle":case"isoscelesTriangle":e.moveTo(d,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 u=a(0,25e3),g=i*u;e.moveTo(t+g,s),e.lineTo(t+i,s),e.lineTo(t+i-g,s+r),e.lineTo(t,s+r),e.closePath();break}case"trapezoid":{const u=a(0,25e3),g=i*u;e.moveTo(t+g,s),e.lineTo(t+i-g,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break}case"diamond":e.moveTo(d,s),e.lineTo(t+i,c),e.lineTo(d,s+r),e.lineTo(t,c),e.closePath();break;case"pentagon":tt(e,d,c,i/2,r/2,5,-Math.PI/2);break;case"hexagon":tt(e,d,c,i/2,r/2,6,0);break;case"heptagon":tt(e,d,c,i/2,r/2,7,-Math.PI/2);break;case"octagon":tt(e,d,c,i/2,r/2,8,Math.PI/8);break;case"decagon":tt(e,d,c,i/2,r/2,10,-Math.PI/2);break;case"dodecagon":tt(e,d,c,i/2,r/2,12,0);break;case"plus":case"cross":{const u=a(0,25e3),g=h*u,p=d-g/2,b=d+g/2,_=c-g/2,y=c+g/2;e.moveTo(p,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(p,s+r),e.lineTo(p,y),e.lineTo(t,y),e.lineTo(t,_),e.lineTo(p,_),e.closePath();break}case"star4":$e(e,d,c,i/2,r/2,4,a(0,37500));break;case"star5":$e(e,d,c,i/2,r/2,5,a(0,19098),-Math.PI/2);break;case"star6":$e(e,d,c,i/2,r/2,6,a(0,28868),0);break;case"star7":$e(e,d,c,i/2,r/2,7,a(0,34601),-Math.PI/2);break;case"star8":$e(e,d,c,i/2,r/2,8,a(0,29289),Math.PI/8);break;case"star10":$e(e,d,c,i/2,r/2,10,a(0,30902),-Math.PI/2);break;case"star12":$e(e,d,c,i/2,r/2,12,a(0,37720),0);break;case"star16":$e(e,d,c,i/2,r/2,16,a(0,37500),0);break;case"star24":$e(e,d,c,i/2,r/2,24,a(0,37500),0);break;case"star32":$e(e,d,c,i/2,r/2,32,a(0,37500),0);break;case"rightArrow":{const u=a(0,5e4),g=a(1,5e4),p=(r-r*g)/2,b=t+i*(1-u);e.moveTo(t,s+p),e.lineTo(b,s+p),e.lineTo(b,s),e.lineTo(t+i,c),e.lineTo(b,s+r),e.lineTo(b,s+r-p),e.lineTo(t,s+r-p),e.closePath();break}case"leftArrow":{const u=a(0,5e4),g=a(1,5e4),p=(r-r*g)/2,b=t+i*u;e.moveTo(t+i,s+p),e.lineTo(b,s+p),e.lineTo(b,s),e.lineTo(t,c),e.lineTo(b,s+r),e.lineTo(b,s+r-p),e.lineTo(t+i,s+r-p),e.closePath();break}case"upArrow":{const u=a(0,5e4),g=a(1,5e4),p=(i-i*g)/2,b=s+r*u;e.moveTo(t+p,s+r),e.lineTo(t+p,b),e.lineTo(t,b),e.lineTo(d,s),e.lineTo(t+i,b),e.lineTo(t+i-p,b),e.lineTo(t+i-p,s+r),e.closePath();break}case"downArrow":{const u=a(0,5e4),g=a(1,5e4),p=(i-i*g)/2,b=s+r*(1-u);e.moveTo(t+p,s),e.lineTo(t+p,b),e.lineTo(t,b),e.lineTo(d,s+r),e.lineTo(t+i,b),e.lineTo(t+i-p,b),e.lineTo(t+i-p,s),e.closePath();break}case"leftRightArrow":{const u=a(0,25e3),g=a(1,5e4),p=(r-r*g)/2,b=t+i*u,_=t+i*(1-u);e.moveTo(t,c),e.lineTo(b,s),e.lineTo(b,s+p),e.lineTo(_,s+p),e.lineTo(_,s),e.lineTo(t+i,c),e.lineTo(_,s+r),e.lineTo(_,s+r-p),e.lineTo(b,s+r-p),e.lineTo(b,s+r),e.closePath();break}case"upDownArrow":{const u=a(0,25e3),g=a(1,5e4),p=(i-i*g)/2,b=s+r*u,_=s+r*(1-u);e.moveTo(d,s),e.lineTo(t+i,b),e.lineTo(t+i-p,b),e.lineTo(t+i-p,_),e.lineTo(t+i,_),e.lineTo(d,s+r),e.lineTo(t,_),e.lineTo(t+p,_),e.lineTo(t+p,b),e.lineTo(t,b),e.closePath();break}case"chevron":{const u=a(0,5e4),g=i*u;e.moveTo(t,s),e.lineTo(t+i-g,s),e.lineTo(t+i,c),e.lineTo(t+i-g,s+r),e.lineTo(t,s+r),e.lineTo(t+g,c),e.closePath();break}case"pentagon5":case"homePlate":{const u=a(0,5e4);e.moveTo(t,s),e.lineTo(t+i*(1-u),s),e.lineTo(t+i,c),e.lineTo(t+i*(1-u),s+r),e.lineTo(t,s+r),e.closePath();break}case"arc":{const u=a(0,270)*Math.PI/180,g=a(1,288e5/6e4)*Math.PI/180;e.moveTo(d,c),e.arc(d,c,Math.min(i,r)/2,u,u+g),e.closePath();break}case"blockArc":{const u=(a(0,0)*360-90)*Math.PI/180,g=a(1,25e3)*360*Math.PI/180,p=a(2,25e3)*Math.min(i,r)/2,b=Math.min(i,r)/2,_=b-p;e.moveTo(d+b*Math.cos(u),c+b*Math.sin(u)),e.arc(d,c,b,u,u+g),e.arc(d,c,Math.max(1,_),u+g,u,!0),e.closePath();break}case"line":case"straightConnector1":e.moveTo(t,c),e.lineTo(t+i,c);break;case"bentConnector3":case"bentConnector4":case"bentConnector5":case"elbowConnector":e.moveTo(t,s),e.lineTo(t,c),e.lineTo(t+i,c),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":{oo(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(d+i*.1,c,r*.5,l(-120),l(120)),e.arc(d+i*.4,c,r*.45,l(120),l(-120),!0),e.closePath();break}case"noSmoking":{const u=Math.min(i,r)/2;e.arc(d,c,u,0,Math.PI*2),e.moveTo(d-u*.7,c+u*.7),e.lineTo(d+u*.7,c-u*.7);break}case"flowChartProcess":e.rect(t,s,i,r);break;case"flowChartDecision":e.moveTo(d,s),e.lineTo(t+i,c),e.lineTo(d,s+r),e.lineTo(t,c),e.closePath();break;case"flowChartTerminator":{const u=r/2;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.arc(t+i-u,c,u,-Math.PI/2,Math.PI/2),e.lineTo(t+u,s+r),e.arc(t+u,c,u,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 u=r*.1;e.moveTo(t,s+u),e.ellipse(d,s+u,i/2,u,0,Math.PI,0),e.lineTo(t+i,s+r-u),e.ellipse(d,s+r-u,i/2,u,0,0,Math.PI),e.closePath();break}case"cube":{const u=i*.15;e.moveTo(t+u,s),e.lineTo(t+i,s),e.lineTo(t+i,s+r-u),e.lineTo(t+i-u,s+r),e.lineTo(t,s+r),e.lineTo(t,s+u),e.closePath(),e.moveTo(t+u,s),e.lineTo(t+u,s+u),e.lineTo(t,s+u),e.moveTo(t+u,s+u),e.lineTo(t+i,s+u);break}case"callout1":case"borderCallout1":case"wedgeRectCallout":{e.rect(t,s,i,r*.8),e.moveTo(d-i*.1,s+r*.8),e.lineTo(d,s+r),e.lineTo(d+i*.1,s+r*.8),e.closePath();break}case"wedgeRoundRectCallout":{const u=r*.05;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.arcTo(t+i,s,t+i,s+u,u),e.lineTo(t+i,s+r*.75-u),e.arcTo(t+i,s+r*.75,t+i-u,s+r*.75,u),e.lineTo(d+i*.1,s+r*.75),e.lineTo(d,s+r),e.lineTo(d-i*.1,s+r*.75),e.lineTo(t+u,s+r*.75),e.arcTo(t,s+r*.75,t,s+r*.75-u,u),e.lineTo(t,s+u),e.arcTo(t,s,t+u,s,u),e.closePath();break}case"wedgeEllipseCallout":{e.ellipse(d,c-r*.05,i/2,r*.45,0,0,Math.PI*2),e.moveTo(d-i*.1,c+r*.4),e.lineTo(d,s+r),e.lineTo(d+i*.1,c+r*.4),e.closePath();break}case"cloudCallout":case"cloud":{e.beginPath();const u=[{cx:d-i*.22,cy:c-r*.12,r:i*.16},{cx:d-i*.07,cy:c-r*.22,r:i*.18},{cx:d+i*.1,cy:c-r*.22,r:i*.17},{cx:d+i*.25,cy:c-r*.12,r:i*.15},{cx:d+i*.35,cy:c+r*.05,r:i*.13},{cx:d-i*.3,cy:c+r*.05,r:i*.13}];for(const g of u)e.arc(g.cx,g.cy,g.r,0,Math.PI*2);e.rect(d-i*.35,c,i*.7,r*.25);break}case"smileyFace":{e.arc(d,c,Math.min(i,r)/2,0,Math.PI*2);break}case"donut":{const u=Math.min(i,r)/2,g=u*a(0,25e3);e.arc(d,c,u,0,Math.PI*2),e.arc(d,c,g,Math.PI*2,0,!0);break}case"bracketPair":{const u=i*.2;e.moveTo(t+u,s),e.arcTo(t,s,t,s+u,u),e.lineTo(t,s+r-u),e.arcTo(t,s+r,t+u,s+r,u),e.moveTo(t+i-u,s),e.arcTo(t+i,s,t+i,s+u,u),e.lineTo(t+i,s+r-u),e.arcTo(t+i,s+r,t+i-u,s+r,u);break}case"bracePair":{const u=r*.15;e.moveTo(d-i*.35,s),e.bezierCurveTo(d-i*.45,s,d-i*.45,s,d-i*.45,s+u),e.lineTo(d-i*.45,c-u),e.bezierCurveTo(d-i*.45,c,d-i*.5,c,d-i*.5,c),e.bezierCurveTo(d-i*.5,c,d-i*.45,c,d-i*.45,c+u),e.lineTo(d-i*.45,s+r-u),e.bezierCurveTo(d-i*.45,s+r,d-i*.35,s+r,d-i*.35,s+r);break}case"irregularSeal1":case"irregularSeal2":{$e(e,d,c,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 u=r*.15;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.arcTo(t+i,s,t+i,s+u,u),e.lineTo(t+i,s+r-u),e.arcTo(t+i,s+r,t+i-u,s+r,u),e.lineTo(t+u,s+r),e.arcTo(t,s+r,t,s+r-u,u),e.lineTo(t,s+u),e.arcTo(t,s,t+u,s,u),e.closePath();break}case"flowChartConnector":e.arc(d,c,Math.min(i,r)/2,0,Math.PI*2);break;case"flowChartInputOutput":{const u=i*.2;e.moveTo(t+u,s),e.lineTo(t+i,s),e.lineTo(t+i-u,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 u=i*.2;e.moveTo(t+u,s),e.lineTo(t+i-u,s),e.lineTo(t+i,c),e.lineTo(t+i-u,s+r),e.lineTo(t+u,s+r),e.lineTo(t,c),e.closePath();break}case"ribbon":case"ribbon2":{const u=r*.3;e.moveTo(t,s+u/2),e.lineTo(t+i*.1,s),e.lineTo(t+i*.1,s+r-u),e.lineTo(t,s+r),e.lineTo(t+i*.5,s+r-u),e.lineTo(t+i,s+r),e.lineTo(t+i-i*.1,s+r-u),e.lineTo(t+i-i*.1,s),e.lineTo(t+i,s+u/2),e.lineTo(t+i*.5,s+u),e.closePath();break}case"ellipseRibbon":case"ellipseRibbon2":{e.ellipse(d,c,i/2,r/2,0,0,Math.PI*2);break}case"teardrop":{const u=Math.min(i,r)*.45;e.arc(d,c+u,u,-Math.PI,0),e.bezierCurveTo(d+u,c+u-u*.55,d+u*.1,c-r*.4,d,s),e.bezierCurveTo(d-u*.1,c-r*.4,d-u,c+u-u*.55,d-u,c+u),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,d=n+s*Math.cos(a),c=t+i*Math.sin(a);l===0?e.moveTo(d,c):e.lineTo(d,c)}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 d=l+a/(r*2)*Math.PI*2,c=a%2===1,h=c?s*o:s,u=c?i*o:i,g=n+h*Math.cos(d),p=t+u*Math.sin(d);a===0?e.moveTo(g,p):e.lineTo(g,p)}e.closePath()}function oo(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 Vn=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0","#FF7F00","#9E480E"];function ao(e){const n=e?.textContent?.trim();if(n==null||n==="")return null;const t=parseFloat(n);return isNaN(t)?n:t}function gt(e){if(!e)return[];const n=C(m(e,"ptCount"),"val",0),t=new Array(n).fill(null);for(const s of de(e,"pt")){const i=C(s,"idx",0);t[i]=ao(m(s,"v"))}return t}function Tt(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 Jt(e){const n=m(e,"cat")||m(e,"xVal");return n?gt(m(n,"strCache")||m(n,"numCache")):[]}function jt(e){const n=m(e,"val")||m(e,"yVal");return n?gt(m(n,"numCache")):[]}function Qe(e,n,t){const s=m(e,"spPr");if(s){const r=m(s,"solidFill");if(r){const o=me(r),l=ye(o,t);if(l)return ge(l)}}const i=`accent${n%6+1}`;return t[i]?`#${t[i]}`:Vn[n%Vn.length]}function Fs(e,n){const t={};for(const s of de(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=ye(l,n);a&&(t[i]=ge(a))}return t}function en(e,n,t,s,i={}){const{padL:r=.12,padR:o=.06,padT:l=.08,padB:a=.1,legendH:d=.1,hasLegend:c=!0,hasTitle:h=!1}=i,u=h?s*.08:0,g=c?s*d:0;return{x:e+t*r,y:n+s*l+u,w:t*(1-r-o),h:s*(1-l-a)-g-u,legendY:n+s*(1-d*.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 Ze(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 Cs(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=Cs(i-s);return i=Math.ceil(i/r)*r,s=Math.floor(s/r)*r,{min:s,max:i,step:r}}function Je(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 Ft(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 d=0;d<r.length;d++){if(!r[d].name)continue;const c=n+a*d+l*.5;e.fillStyle=r[d].color,vt(e,c,i-l/2,l*1.2,l),e.fill(),e.fillStyle="#444",e.fillText(r[d].name,c+l*1.5,i)}e.restore()}function lo(e,n,t,s,i,r,o,l){const a=m(n,"barChart")||m(n,"bar3DChart"),d=!a||B(a,"barDir","col")!=="bar",c=B(a,"grouping","clustered"),h=c==="stacked"||c==="percentStacked",u=c==="percentStacked",g=de(a,"ser"),p=g.map((k,T)=>({name:Tt(k),values:jt(k),color:Qe(k,T,o),dptColors:Fs(k,o)}));if(!p.length)return;const b=Jt(g[0])||[],_=Math.max(b.length,p[0]?.values.length||0,1),y=en(t,s,i,r,{hasLegend:p.length>1});let w;h?(w=Array.from({length:_},(k,T)=>p.reduce((N,M)=>N+(M.values[T]||0),0)),u&&(w=w.map(()=>100))):w=p.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(d){e.save(),e.textAlign="right",e.fillStyle="#666";for(let j=0;j<=v;j++){const E=x.min+j*x.step,L=(E-x.min)/(x.max-x.min),z=y.y+y.h-L*y.h;Ze(e,y.x,z,y.x+y.w,z),e.fillText(u?E+"%":Je(E),y.x-4*l,z)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";const k=y.w/_;for(let j=0;j<_;j++){const E=y.x+k*j+k/2,L=String(b[j]??j+1);e.fillText(L,E,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 T=y.w/_,N=T*.15,M=T-N*2,F=h?M:M/p.length;for(let j=0;j<_;j++){const E=y.x+T*j+N;let L=0;for(let z=0;z<p.length;z++){const Q=p[z];let G=Q.values[j]??0;if(u){const re=p.reduce((ce,ne)=>ce+(ne.values[j]||0),0);G=re?G/re*100:0}const O=Q.dptColors[j]||Q.color,q=Math.abs(G)/(x.max-x.min)*y.h,Z=h?E:E+z*F,J=h?(L-x.min)/(x.max-x.min):Math.max(0,-x.min)/(x.max-x.min),R=y.y+y.h-J*y.h,H=G>=0?R-q:R;e.save(),e.fillStyle=O,vt(e,Z,H,h?M:F-1*l,q,2*l),e.fill();const ie=e.createLinearGradient(Z,H,Z,H+q*.3);ie.addColorStop(0,"rgba(255,255,255,0.18)"),ie.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=ie,e.fill(),e.restore(),h&&(L+=Math.abs(G))}}}else{e.save(),e.textAlign="right",e.fillStyle="#666";const k=y.h/_;for(let j=0;j<_;j++){const E=y.y+k*j+k/2,L=String(b[j]??j+1);e.fillText(L,y.x-4*l,E)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";for(let j=0;j<=v;j++){const E=x.min+j*x.step,L=(E-x.min)/(x.max-x.min),z=y.x+L*y.w;Ze(e,z,y.y,z,y.y+y.h),e.fillText(u?E+"%":Je(E),z,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 T=k*.15,N=k-T*2,M=h?N:N/p.length,F=y.x+-x.min/(x.max-x.min)*y.w;for(let j=0;j<_;j++){const E=y.y+k*j+T;let L=0;for(let z=0;z<p.length;z++){const Q=p[z];let G=Q.values[j]??0;if(u){const H=p.reduce((ie,re)=>ie+(re.values[j]||0),0);G=H?G/H*100:0}const O=Q.dptColors[j]||Q.color,q=Math.abs(G)/(x.max-x.min)*y.w,Z=h?E:E+z*M,J=h?F+L/(x.max-x.min)*y.w:F,R=G>=0?J:J-q;e.save(),e.fillStyle=O,vt(e,R,Z,q,h?N:M-1*l,2*l),e.fill(),e.restore(),h&&(L+=Math.abs(G))}}}p.length>1&&Ft(e,t,s,i,y.legendY,p,l)}function co(e,n,t,s,i,r,o,l){const a=m(n,"lineChart")||m(n,"line3DChart"),d=de(a,"ser"),c=d.map((y,w)=>({name:Tt(y),values:jt(y),color:Qe(y,w,o),marker:B(m(y,"marker"),"symbol","none")!=="none",smooth:B(m(y,"smooth"),"val","0")==="1"}));if(!c.length)return;const h=Jt(d[0])||[],u=Math.max(h.length,c[0]?.values.length||0,1),g=en(t,s,i,r,{hasLegend:!0}),p=wt(c.flatMap(y=>y.values)),b=Math.max(7,Math.min(11,g.w*.018))*l,_=Math.round((p.max-p.min)/p.step);e.save(),e.textAlign="right",e.fillStyle="#666",e.font=`${b}px sans-serif`;for(let y=0;y<=_;y++){const w=p.min+y*p.step,x=(w-p.min)/(p.max-p.min),P=g.y+g.h-x*g.h;Ze(e,g.x,P,g.x+g.w,P),e.fillText(Je(w),g.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<u;y++){const w=g.x+y/(u-1||1)*g.w;Ze(e,w,g.y,w,g.y+g.h);const x=String(h[y]??y+1);e.fillText(x,w,g.y+g.h+b*1.5)}e.restore(),Ee(e,g.x,g.y,g.x,g.y+g.h),Ee(e,g.x,g.y+g.h,g.x+g.w,g.y+g.h);for(const y of c){const w=y.values.map((P,v)=>{const k=u>1?v/(u-1):.5,T=(P-p.min)/(p.max-p.min);return{x:g.x+k*g.w,y:g.y+g.h-T*g.h,v:P}}).filter(P=>typeof P.v=="number");if(w.length<2)continue;e.save(),e.beginPath(),e.moveTo(w[0].x,g.y+g.h);for(const P of w)e.lineTo(P.x,P.y);if(e.lineTo(w[w.length-1].x,g.y+g.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()}Ft(e,t,s,i,g.legendY,c,l)}function uo(e,n,t,s,i,r,o,l){const a=m(n,"areaChart")||m(n,"area3DChart"),d=B(a,"grouping","standard"),c=d==="percentStacked",h=d==="stacked"||c,g=de(a,"ser").map((v,k)=>({name:Tt(v),values:jt(v),color:Qe(v,k,o)})).reverse();if(!g.length)return;const p=Math.max(...g.map(v=>v.values.length),1),b=en(t,s,i,r,{hasLegend:!0});let _=0;if(c)_=100;else for(let v=0;v<p;v++){const k=g.reduce((T,N)=>T+(N.values[v]||0),0);_=Math.max(_,k)}const y={min:0,max:_||100,step:Cs(_||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,T=(k-y.min)/(y.max-y.min),N=b.y+b.h-T*b.h;Ze(e,b.x,N,b.x+b.w,N),e.fillText(c?k+"%":Je(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(p).fill(0);for(const v of g){e.save(),e.beginPath();const k=[];for(let T=0;T<p;T++){let N=v.values[T]??0;if(c){const z=g.reduce((Q,G)=>Q+(G.values[T]||0),0);N=z?N/z*100:0}const M=h?P[T]:0,F=M+Math.abs(N),j=(M-y.min)/(y.max-y.min),E=(F-y.min)/(y.max-y.min),L=b.x+T/(p-1||1)*b.w;k.push({x:L,y:b.y+b.h-E*b.h,baseY:b.y+b.h-j*b.h}),h&&(P[T]+=Math.abs(N))}e.moveTo(k[0].x,k[0].baseY);for(const T of k)e.lineTo(T.x,T.baseY);for(let T=k.length-1;T>=0;T--)e.lineTo(k[T].x,k[T].y);e.closePath(),e.fillStyle=v.color+"cc",e.fill(),e.beginPath(),e.moveTo(k[0].x,k[0].y);for(const T of k.slice(1))e.lineTo(T.x,T.y);e.strokeStyle=v.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Ft(e,t,s,i,b.legendY,[...g].reverse(),l)}function Hn(e,n,t,s,i,r,o,l){const a=m(n,"pieChart")||m(n,"pie3DChart"),d=m(n,"doughnutChart"),c=a||d,h=!!d,u=de(c,"ser");if(!u.length)return;const g=u[0],p=jt(g).map(j=>typeof j=="number"&&j>0?j:0),b=Jt(g),_=Fs(g,o),y=p.reduce((j,E)=>j+E,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 j=0;j<p.length;j++){if(!p[j])continue;const E=p[j]/y*Math.PI*2,L=_[j]||Qe(g,j,o),z=k+E/2,Q=j===0?w*.04:0,G=Q*Math.cos(z),O=Q*Math.sin(z);e.save(),e.beginPath(),e.moveTo(x+G,P+O),e.arc(x+G,P+O,w,k,k+E),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 q=p[j]/y;if(q>.05){const Z=x+G+w*.65*Math.cos(z),J=P+O+w*.65*Math.sin(z),R=Math.max(8,Math.min(13,w*.15))*l;e.save(),e.fillStyle="#fff",e.font=`bold ${R}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(Math.round(q*100)+"%",Z,J),e.restore()}k+=E}if(h){const j=Math.max(10,Math.min(16,w*.22))*l;e.save(),e.font=`bold ${j}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="middle",e.fillText(Je(y),x,P),e.restore()}const T=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-p.length*M/2;for(let j=0;j<p.length;j++){const E=T,L=F+j*M,z=_[j]||Qe(g,j,o);e.fillStyle=z,vt(e,E,L-N*.5,N*1.2,N),e.fill(),e.fillStyle="#444";const Q=String(b[j]??`Item ${j+1}`);e.fillText(Q,E+N*1.5,L)}}function fo(e,n,t,s,i,r,o,l){const a=m(n,"scatterChart")||m(n,"bubbleChart"),c=de(a,"ser").map((k,T)=>{const N=gt(m(m(k,"xVal"),"numCache")),M=gt(m(m(k,"yVal"),"numCache")),F=gt(m(m(k,"bubbleSize"),"numCache"));return{name:Tt(k),color:Qe(k,T,o),points:N.map((j,E)=>({x:j,y:M[E],r:F[E]})).filter(j=>typeof j.x=="number"&&typeof j.y=="number")}});if(!c.length)return;const h=en(t,s,i,r,{hasLegend:c.length>1}),u=c.flatMap(k=>k.points.map(T=>T.x)),g=c.flatMap(k=>k.points.map(T=>T.y)),p=wt(u,!1),b=wt(g),_=Math.max(7,Math.min(11,h.w*.018))*l,y=Math.round((p.max-p.min)/p.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 T=p.min+k*p.step,N=(T-p.min)/(p.max-p.min),M=h.x+N*h.w;Ze(e,M,h.y,M,h.y+h.h),e.fillText(Je(T),M,h.y+h.h+_*1.5)}e.textAlign="right";for(let k=0;k<=w;k++){const T=b.min+k*b.step,N=(T-b.min)/(b.max-b.min),M=h.y+h.h-N*h.h;Ze(e,h.x,M,h.x+h.w,M),e.fillText(Je(T),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=c.flatMap(k=>k.points.map(T=>T.r??1)),P=Math.max(...x.filter(k=>typeof k=="number"),1),v=Math.min(h.w,h.h)*.06;for(const k of c)for(const T of k.points){const N=h.x+(T.x-p.min)/(p.max-p.min)*h.w,M=h.y+h.h-(T.y-b.min)/(b.max-b.min)*h.h,F=T.r!=null?T.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()}c.length>1&&Ft(e,t,s,i,h.legendY,c,l)}function ho(e,n,t,s,i,r,o,l){const a=m(n,"radarChart"),d=de(a,"ser"),c=d.map((w,x)=>({name:Tt(w),values:jt(w),color:Qe(w,x,o)}));if(!c.length)return;const h=Jt(d[0])||[],u=h.length||c[0]?.values.length||0;if(u<3)return;const g=t+i*.5,p=s+r*.5,b=Math.min(i,r)*.34,_=wt(c.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<u;P++){const v=P/u*Math.PI*2-Math.PI/2,k=g+x*Math.cos(v),T=p+x*Math.sin(v);P===0?e.moveTo(k,T):e.lineTo(k,T)}e.closePath(),e.strokeStyle="rgba(0,0,0,0.12)",e.lineWidth=.5,e.stroke(),e.restore()}for(let w=0;w<u;w++){const x=w/u*Math.PI*2-Math.PI/2;Ee(e,g,p,g+b*Math.cos(x),p+b*Math.sin(x));const P=g+(b+16*l)*Math.cos(x),v=p+(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 c){const x=w.values.map((P,v)=>{const k=v/u*Math.PI*2-Math.PI/2,T=(P-_.min)/(_.max-_.min);return{x:g+b*T*Math.cos(k),y:p+b*T*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()}Ft(e,t,s,i,s+r-20*l,c,l)}function po(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 c of de(l,"t"))a+=c.textContent;if(!a.trim())return!1;const d=Math.max(10,Math.min(16,i*.03))*r;return e.save(),e.font=`bold ${d}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 go(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 c=po(e,a,t,s,i,l)?s+Math.min(r*.08,24*l):s,h=r-(c-s),u=m(a,"plotArea");if(!u)return;const g=m(u,"bar3DChart")||m(u,"barChart"),p=m(u,"line3DChart")||m(u,"lineChart"),b=m(u,"area3DChart")||m(u,"areaChart"),_=m(u,"pie3DChart")||m(u,"pieChart"),y=m(u,"doughnutChart"),w=m(u,"scatterChart")||m(u,"bubbleChart"),x=m(u,"radarChart");if(g)lo(e,u,t,c,i,h,o,l);else if(p)co(e,u,t,c,i,h,o,l);else if(b)uo(e,u,t,c,i,h,o,l);else if(y)Hn(e,u,t,c,i,h,o,l);else if(_)Hn(e,u,t,c,i,h,o,l);else if(w)fo(e,u,t,c,i,h,o,l);else if(x)ho(e,u,t,c,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=u.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 Ms(e,n){if(!e)return null;const t=me(e);if(!t)return null;const s=ye(t,n);return s?ge(s):null}function mo(e,n,t,s,i,r,o){const l=m(n,"bevelT"),a=m(n,"bevelB"),d=l||a;if(!d)return;const c=Math.max(2*o,Xt(d,"w",76200,o)),h=Math.max(2*o,Xt(d,"h",76200,o)),g=B(d,"prst","circle").toLowerCase().includes("in"),p=Math.min(c,i*.3),b=Math.min(h,r*.3),_=g?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.35)",y=g?"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+p,s);P.addColorStop(0,_),P.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=P,e.fillRect(t,s,p,r);const v=e.createLinearGradient(t+i-p,s,t+i,s);v.addColorStop(0,"rgba(0,0,0,0)"),v.addColorStop(1,y),e.fillStyle=v,e.fillRect(t+i-p,s,p,r),e.restore()}function bo(e,n,t,s,i,r,o,l){const a=Xt(n,"extrusionH",0,l);if(a<1*l)return;const d=m(n,"extrusionClr")||m(n,"contourClr"),c=Ms(d,t)||"rgba(0,0,0,0.3)",h=Math.min(a/914400*72*l,Math.min(r,o)*.15),u=h*.7,g=h*.7;e.save(),e.fillStyle=c,e.beginPath(),e.moveTo(s+r,i),e.lineTo(s+r+u,i+g),e.lineTo(s+r+u,i+o+g),e.lineTo(s+r,i+o),e.closePath(),e.fill(),e.beginPath(),e.moveTo(s,i+o),e.lineTo(s+u,i+o+g),e.lineTo(s+r+u,i+o+g),e.lineTo(s+r,i+o),e.closePath(),e.fill(),e.restore()}function yo(e,n,t,s,i,r,o,l){const a=Xt(n,"contourW",0,l);if(a<.5)return;const d=m(n,"contourClr"),c=Ms(d,t)||"#888888",h=Math.max(.5,a/914400*72*l);e.save(),e.strokeStyle=c,e.lineWidth=h,e.strokeRect(s,i,r,o),e.restore()}function vo(e,n,t,s,i,r){if(!n)return()=>{};const o=m(n,"camera");if(!o)return()=>{};const l=B(o,"prst","orthographicFront"),a=m(o,"rot");if(l.toLowerCase().includes("orthographic")&&!a)return()=>{};const c=a?C(a,"lat",0)/6e4:0,h=a?C(a,"lon",0)/6e4:0;a&&C(a,"rev",0)/6e4;const u=c*Math.PI/180,g=h*Math.PI/180,p=Math.sin(g)*.15,b=Math.sin(u)*.08;return e.save(),e.transform(1,b,p,1,t*-p,s*-b),()=>e.restore()}function wo(e,n,t,s,i,r){if(!n)return;const o=m(n,"lightRig");if(!o)return;const l=B(o,"dir","t"),a=B(o,"rig","balanced"),d={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:c,gy:h}=d[l]||d.t,u=a==="flat"?.08:a==="balanced"?.14:a==="sunrise"?.2:a==="harsh"?.28:.12,g=Math.sqrt(i*i+r*r),p=e.createRadialGradient(c,h,0,c,h,g);p.addColorStop(0,`rgba(255,255,255,${u})`),p.addColorStop(.5,"rgba(255,255,255,0)"),p.addColorStop(1,`rgba(0,0,0,${u*.5})`),e.save(),e.fillStyle=p,e.fillRect(t,s,i,r),e.restore()}function ko(e,n,t,s,i,r,o,l){if(!n)return{applyCamera:()=>()=>{},overlay:()=>{}};const a=m(n,"sp3d")||m(n,"scene3d")?.parentNode&&null,d=m(n,"scene3d");a&&bo(e,a,t,s,i,r,o,l);const c=vo(e,d,s,i);return{overlay(){a&&(mo(e,a,s,i,r,o,l),yo(e,a,t,s,i,r,o,l)),d&&wo(e,d,s,i,r,o)},cleanup:c}}function xo(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 d=n.localName;if(d==="noFill")return!1;if(d==="solidFill"){const c=me(n),h=ye(c,l);return h?(e.fillStyle=ge(h),e.fill(),!0):!1}if(d==="gradFill"){const c=m(n,"gsLst");if(!c)return!1;const h=de(c,"gs").map(y=>{const w=C(y,"pos",0)/1e5,x=me(y),P=ye(x,l);return{pos:w,color:P}}).sort((y,w)=>y.pos-w.pos);if(h.length<2)return!1;const u=m(n,"lin"),g=m(n,"path"),p=t+i/2,b=s+r/2;let _;if(u||!u&&!g){const x=(C(u,"ang",0)/6e4-90)*Math.PI/180,P=Math.cos(x),v=Math.sin(x),k=Math.abs(i*P)+Math.abs(r*v),T=p-k/2*P,N=b-k/2*v,M=p+k/2*P,F=b+k/2*v;_=e.createLinearGradient(T,N,M,F)}else{const y=m(g,"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),T=s+r*(x+(1-x-v)/2),N=Math.sqrt(i*i+r*r)/2;_=e.createRadialGradient(k,T,0,p,b,N)}for(const y of h)y.color&&_.addColorStop(y.pos,ge(y.color));return e.fillStyle=_,e.fill(),!0}if(d==="blipFill"){const c=m(n,"blip"),h=c?c.getAttribute("r:embed")||c.getAttribute("embed"):null;if(h&&a&&a[h]){const u=a[h],g=m(n,"stretch"),p=g?m(g,"fillRect"):null;let b=t,_=s,y=i,w=r;if(p){const k=C(p,"l",0)/1e5,T=C(p,"t",0)/1e5,N=C(p,"r",0)/1e5,M=C(p,"b",0)/1e5;b=t+i*k,_=s+r*T,y=i-i*k-i*N,w=r-r*T-r*M}if(m(n,"tile")){const k=e.createPattern(u,"repeat");if(k)return e.fillStyle=k,e.fill(),!0}const P=m(n,"alphaModFix")||m(c,"alphaModFix"),v=P?C(P,"amt",1e5)/1e5:1;return e.save(),e.clip(),v<1&&(e.globalAlpha=v),e.drawImage(u,b,_,y,w),e.restore(),!0}return!1}if(d==="pattFill"){const c=m(n,"fgClr"),h=m(n,"bgClr"),u=c?ye(me(c),l):{r:0,g:0,b:0,a:1},g=h?ye(me(h),l):{r:255,g:255,b:255,a:1},p=ge(u),b=ge(g),_=B(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(u),e.fill(),!0;switch(y.fillStyle=b,y.fillRect(0,0,x,x),y.fillStyle=p,_){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(u,(u.a??1)*.4),e.fill(),!0)}return!1}async function De(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=_e(o),a={};for(const d of Array.from(l.getElementsByTagName("Relationship"))){const c=d.getAttribute("Id"),h=d.getAttribute("Target"),u=d.getAttribute("Type")||"",g=d.getAttribute("TargetMode")||"Internal";let p=h;if(g!=="External")if(h.startsWith("/"))p=h.slice(1);else{const b=n.split("/");b.pop();const _=h.split("/");for(const y of _)y===".."?b.pop():y!=="."&&b.push(y);p=b.join("/")}a[c]={target:h,fullPath:p,type:u,external:g==="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 d={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",c=new Blob([l],{type:d}),h=URL.createObjectURL(c),u=await new Promise((g,p)=>{const b=new Image;b.onload=()=>g(b),b.onerror=()=>g(null),b.src=h});t[i]=u}catch{}}return t}function Ns(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 _o(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 p=me(l);o=ye(p,t)}const a=m(e,"buSzPct"),d=m(e,"buSzPts");let c=1;a&&(c=C(a,"val",1e5)/1e5);const h=d?C(d,"val",0)/100:null;let u=null;const g=m(e,"buFont");if(g){const p=g.getAttribute("typeface");p&&(u=p)}return i?{type:"char",char:i.getAttribute("char")||"•",color:o,sizePct:c,sizePts:h,fontFamily:u}:r?{type:"autoNum",numType:r.getAttribute("type")||"arabicPeriod",startAt:C(r,"startAt",1),color:o,sizePct:c,sizePts:h,fontFamily:u}:null}function Po(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return Yn(n).toLowerCase()+".";case"romanUcPeriod":return Yn(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 Yn(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 So(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 d=n.numType+":"+n.startAt;i[d]===void 0&&(i[d]=n.startAt);const c=Po(n.numType,i[d]);i[d]++,e.fillText(c,t,s)}e.restore()}async function Vt(e,n,t,s,i,r,o,l,a,d=1800){if(!n)return;const c=m(n,"bodyPr"),h=B(c,"anchor","t"),u=B(c,"wrap","square"),g=B(c,"vert","horz"),p=C(c,"lIns",91440)*o,b=C(c,"tIns",45720)*o,_=C(c,"rIns",91440)*o,y=C(c,"bIns",45720)*o,w=t+p,x=s+b,P=i-p-_,v=r-b-y,k=u!=="none",T=g==="vert"||g==="vert270"||g==="eaVert";T&&(e.save(),g==="vert270"?(e.translate(t+i,s),e.rotate(Math.PI/2)):(e.translate(t,s+r),e.rotate(-Math.PI/2)));const N=m(c,"normAutoFit")||m(n,"normAutoFit");m(c,"spAutoFit")||m(n,"spAutoFit");const M=N?N.getAttribute("fontScale"):null;let F=M?parseInt(M,10)/1e5:1;const j=m(n,"lstStyle"),E=j?m(j,"defRPr"):null;function L(J,R,H,ie){const re=J?J.getAttribute(H):null;if(re!==null&&re!=="")return re;const ce=R?R.getAttribute(H):null;if(ce!==null&&ce!=="")return ce;const ne=E?E.getAttribute(H):null;return ne!==null&&ne!==""?ne:ie}const z=de(n,"p"),Q=[];let G=0;for(const J of z){const R=m(J,"pPr"),H=B(R,"algn","l");C(R,"lvl",0);const ie=C(R,"marL",0)*o,re=C(R,"indent",0)*o,ce=R?_o(R,oe,l):null,ne=m(R,"spcBef"),X=m(R,"spcAft"),xe=m(R,"lnSpc"),oe=m(R,"defRPr");let ae=d;if(E){const Y=E.getAttribute("sz");Y&&(ae=parseInt(Y,10))}if(oe){const Y=oe.getAttribute("sz");Y&&(ae=parseInt(Y,10))}let ue=0,ve=0;if(ne){const Y=m(ne,"spcPct"),ee=m(ne,"spcPts");Y?ue=ae*127*o*(C(Y,"val",0)/1e5):ee&&(ue=C(ee,"val",0)*bt*o/100)}if(X){const Y=m(X,"spcPct"),ee=m(X,"spcPts");Y?ve=ae*127*o*(C(Y,"val",0)/1e5):ee&&(ve=C(ee,"val",0)*bt*o/100)}const we=[];for(const Y of J.children){const ee=Y.localName;(ee==="r"||ee==="br"||ee==="fld")&&we.push(Y)}if(we.length===0){const Y=m(J,"endParaRPr"),$=C(Y||oe,"sz",ae)*127*o*F;Q.push({lines:[""],algn:H,marL:ie,spaceBefore:ue,spaceAfter:ve,szPx:$,lnSpc:xe,runs:[],emptyPara:!0,bullet:ce}),G+=ue+$*1.2+ve;continue}let be=[],fe=[],I=0;for(const Y of we){if(Y.localName==="br"){be.push({runs:fe,maxSzPx:Math.max(I,ae*127*o)}),fe=[],I=0;continue}const ee=m(Y,"rPr"),$=m(Y,"t");let U=$?$.textContent:"";const te=js(ee,oe,o*F,a,ae,E);e.font=te.fontStr;const se=te.szPx;se>I&&(I=se);const he=ro(ee,oe,l),ke=L(ee,oe,"u","none")!=="none",Pe=L(ee,oe,"strike","noStrike")!=="noStrike",Me=parseInt(L(ee,oe,"baseline","0"),10);if(k){const Mt=U.split(" ");for(let dn=0;dn<Mt.length;dn++){const un=Mt[dn];let In=re+ie;for(const Nt of fe)e.font=Nt.fontInfo.fontStr,In+=e.measureText(Nt.text).width;e.font=te.fontStr;const Js=e.measureText(un).width,ei=fe.length?e.measureText(" ").width:0;if(In+ei+Js>P&&fe.length>0)be.push({runs:fe,maxSzPx:Math.max(I,se)}),fe=[{text:un,rPr:ee,fontInfo:te,color:he,underline:ke,strikethrough:Pe,baseline:Me}],I=se;else{if(fe.length>0){const Nt={text:" ",rPr:ee,fontInfo:te,color:he,underline:!1,strikethrough:!1,baseline:Me};fe.push(Nt)}fe.push({text:un,rPr:ee,fontInfo:te,color:he,underline:ke,strikethrough:Pe,baseline:Me})}}}else fe.push({text:U,rPr:ee,fontInfo:te,color:he,underline:ke,strikethrough:Pe,baseline:Me}),se>I&&(I=se)}fe.length>0&&be.push({runs:fe,maxSzPx:Math.max(I,ae*127*o)});const V=xe?Ns(xe,ae*127*o*F,o):null;Q.push({lines:be,algn:H,marL:ie,indent:re,spaceBefore:ue,spaceAfter:ve,lnSpcPx:V,emptyPara:!1,bullet:ce});for(const Y of be)G+=ue+(V||Y.maxSzPx*1.2)+ve}if(N&&!M&&G>v&&v>0){let J=.3,R=1;for(let H=0;H<8;H++){const ie=(J+R)/2;let re=0;for(const ce of z){const ne=m(ce,"pPr"),X=ne?m(ne,"defRPr"):null;let xe=d;if(E){const V=E.getAttribute("sz");V&&(xe=parseInt(V,10))}if(X){const V=X.getAttribute("sz");V&&(xe=parseInt(V,10))}const oe=Array.from(ce.children).filter(V=>["r","br","fld"].includes(V.localName)),ae=xe*127*o*ie;if(oe.length===0){re+=ae*1.2;continue}const ue=oe.reduce((V,Y)=>{const ee=m(Y,"t");return V+(ee?ee.textContent.length:0)},0),ve=P>0?P:i,we=ue>0?oe.reduce((V,Y)=>{const ee=m(Y,"t");return V+(ee?ee.textContent:"")},"").slice(0,20):"W";e.font=`${ae}px sans-serif`;const be=we.length>0?e.measureText(we).width/we.length:ae*.6,fe=Math.max(1,Math.floor(ve/be)),I=Math.max(1,Math.ceil(ue/fe));re+=I*ae*1.2}re<=v?J=ie:R=ie}F=(J+R)/2}let O=x;h==="ctr"?O=x+(v-G)/2:h==="b"&&(O=x+v-G);let q=O;const Z={};for(const J of Q){const{lines:R,algn:H,marL:ie,indent:re,spaceBefore:ce,spaceAfter:ne,lnSpcPx:X,emptyPara:xe,bullet:oe}=J;if(q+=ce,xe){q+=R[0]?X||J.szPx*1.2:12*o,q+=ne;continue}for(const ae of R){const{runs:ue,maxSzPx:ve}=ae,we=X||ve*1.2,be=q+ve*.85;let fe=0;for(const $ of ue)e.font=$.fontInfo.fontStr,fe+=e.measureText($.text).width;let I=w+ie;H==="ctr"?I=w+(P-fe)/2:H==="r"&&(I=w+P-fe);const V=ae===R[0];if(oe&&V){const $=w+ie+re;So(e,oe,$,be,Z)}let Y=0;if(H==="just"&&!(ae===R[R.length-1])){let U=0;for(const se of ue)e.font=se.fontInfo.fontStr,U+=(se.text.match(/ /g)||[]).length;const te=P-ie-fe;U>0&&te>0&&(Y=te/U)}const ee=($,U,te,se,he,ke)=>{e.font=se.fontStr;const Pe=e.measureText($).width;e.fillText($,U,te);const Me=Math.max(.5,se.szPx*.07);return he&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Me,e.beginPath(),e.moveTo(U,te+Me*1.5),e.lineTo(U+Pe,te+Me*1.5),e.stroke(),e.restore()),ke&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=Me,e.beginPath(),e.moveTo(U,te-se.szPx*.3),e.lineTo(U+Pe,te-se.szPx*.3),e.stroke(),e.restore()),Pe};for(const $ of ue){const U=$.color;e.fillStyle=U?ge(U):"#000000";let te=be,se=$.fontInfo;if($.baseline!==0){const he=se.szPx*.65,ke=`${se.italic?"italic ":""}${se.bold?"bold ":""}${he}px "${se.family}", sans-serif`;se={...se,szPx:he,fontStr:ke},$.baseline>0?te=be-$.fontInfo.szPx*.38:te=be+$.fontInfo.szPx*.12}if(Y>0&&$.text.includes(" ")){e.font=se.fontStr;const he=$.text.split(" ");for(let ke=0;ke<he.length;ke++){const Pe=ee(he[ke],I,te,se,$.underline,$.strikethrough);I+=Pe,ke<he.length-1&&(e.font=se.fontStr,I+=e.measureText(" ").width+Y)}}else{e.font=se.fontStr;const he=e.measureText($.text).width;ee($.text,I,te,se,$.underline,$.strikethrough),I+=he}}q+=we}q+=ne}T&&e.restore()}function As(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 d=C(l,"blurRad",38100)*s,c=C(l,"dist",38100)*s,u=C(l,"dir",27e5)/6e4*Math.PI/180,g=c*Math.cos(u),p=c*Math.sin(u),b=me(l),_=ye(b,t),y=_?ge(_):"rgba(0,0,0,0.35)";e.shadowBlur=Math.min(d,40),e.shadowOffsetX=g,e.shadowOffsetY=p,e.shadowColor=y}const a=m(i,"glow");if(a){const d=C(a,"rad",0)*s,c=me(a),h=ye(c,t);h&&(e.shadowBlur=Math.min(d,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 tn(e,n,t,s,i,r,o,l=null,a=null){const d=m(n,"spPr"),c=m(d,"xfrm");let h=0,u=0,g=0,p=0,b=0,_=!1,y=!1;if(c){const O=m(c,"off"),q=m(c,"ext");O&&(h=C(O,"x",0)*o,u=C(O,"y",0)*o),q&&(g=C(q,"cx",0)*o,p=C(q,"cy",0)*o),b=C(c,"rot",0)/6e4,_=B(c,"flipH","0")==="1",y=B(c,"flipV","0")==="1"}else{const O=Is(n,a);if(O)h=O.x*o,u=O.y*o,g=O.w*o,p=O.h*o;else return}if(g<=0||p<=0)return;if(l){const{grpOff:O,grpExt:q,chOff:Z,chExt:J}=l,R=q.cx/J.cx,H=q.cy/J.cy;h=O.x+(h/o-Z.x)*R*o,u=O.y+(u/o-Z.y)*H*o,g=g*R,p=p*H}const w=h+g/2,x=u+p/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(d,"prstGeom"),v=m(d,"custGeom"),k=P?B(P,"prst","rect"):"rect",T={};if(P){const O=m(P,"avLst");if(O){let q=0;for(const Z of de(O,"gd")){const R=B(Z,"fmla","").match(/val\s+(-?\d+)/);R&&(T[q]=parseInt(R[1])),q++}}}const N=()=>{const O=["noFill","solidFill","gradFill","blipFill","pattFill","grpFill"];for(const Z of O){const J=m(d,Z);if(J)return J}const q=m(n,"style");if(q){const Z=m(q,"fillRef");if(Z){if(C(Z,"idx",1)===0)return _e("<noFill/>").documentElement;const R=me(Z);if(R)return _e('<solidFill xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'">'+R.outerHTML+"</solidFill>").documentElement}}return null},M=()=>{const O=m(d,"ln");if(O)return O;const q=m(n,"style");if(q){const Z=m(q,"lnRef");if(Z){if(C(Z,"idx",1)===0)return null;const R=me(Z);if(R)return _e('<ln xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'"><solidFill>'+R.outerHTML+"</solidFill></ln>").documentElement}}return null};if(v){const O=m(v,"pathLst");if(O)for(const Z of de(O,"path")){const J=C(Z,"w",1)||1,R=C(Z,"h",1)||1,H=g/J,ie=p/R;e.beginPath();for(const ne of Z.children)switch(ne.localName){case"moveTo":{const X=m(ne,"pt");X&&e.moveTo(h+C(X,"x",0)*H,u+C(X,"y",0)*ie);break}case"lnTo":{const X=m(ne,"pt");X&&e.lineTo(h+C(X,"x",0)*H,u+C(X,"y",0)*ie);break}case"cubicBezTo":{const X=de(ne,"pt");X.length>=3&&e.bezierCurveTo(h+C(X[0],"x",0)*H,u+C(X[0],"y",0)*ie,h+C(X[1],"x",0)*H,u+C(X[1],"y",0)*ie,h+C(X[2],"x",0)*H,u+C(X[2],"y",0)*ie);break}case"quadBezTo":{const X=de(ne,"pt");X.length>=2&&e.quadraticCurveTo(h+C(X[0],"x",0)*H,u+C(X[0],"y",0)*ie,h+C(X[1],"x",0)*H,u+C(X[1],"y",0)*ie);break}case"arcTo":{const X=C(ne,"wR",0)*H,xe=C(ne,"hR",0)*ie,oe=C(ne,"stAng",0)/6e4*Math.PI/180,ae=C(ne,"swAng",0)/6e4*Math.PI/180,ue=e._lastX||h,ve=e._lastY||u,we=ue-X*Math.cos(oe),be=ve-xe*Math.sin(oe);X===xe?e.arc(we,be,X,oe,oe+ae,ae<0):e.ellipse(we,be,X,xe,0,oe,oe+ae,ae<0);break}case"close":e.closePath();break}const re=N();re&&await kt(e,re,h,u,g,p,o,i,s);const ce=M();ce&<(e,ce,i,o)}e.restore();const q=m(n,"txBody");if(q){e.save(),e.beginPath(),e.rect(h,u,g,p),e.clip();const Z=wn(n);await Vt(e,q,h,u,g,p,o,i,r,Z),e.restore()}return}e.beginPath(),Kt(e,k,h,u,g,p,T);const F=As(e,d,i,o),j=h,E=u,L=g,z=p,Q=xo(d)?ko(e,d,i,j,E,L,z,o):null;try{const O=N();let q=!1;O&&(q=await kt(e,O,h,u,g,p,o,i,s)),Q&&Q.overlay();const Z=M();Z?lt(e,Z,i,o):q||(k==="line"||k==="straightConnector1")&&(e.strokeStyle="#000",e.lineWidth=1,e.stroke())}finally{F(),Q?.cleanup&&Q.cleanup()}e.restore();const G=m(n,"txBody");if(G){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,u,g,p),e.clip();const O=wn(n);await Vt(e,G,h,u,g,p,o,i,r,O),e.restore()}}function wn(e,n){const t=m(e,"nvSpPr"),s=t?m(t,"nvPr"):null,i=s?m(s,"ph"):null;if(i){const r=B(i,"type","body");if(r==="title"||r==="ctrTitle")return 4400;if(r==="subTitle"||r==="body")return 2800}return 1800}function lt(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 d="#000000";if(r){const g=me(r),p=ye(g,t);p&&(d=ge(p))}else o&&(d="#888888");const c=m(n,"prstDash"),h=c?B(c,"val","solid"):"solid",u=B(n,"cap","flat");switch(B(n,"cmpd","sng"),e.strokeStyle=d,e.lineWidth=a,e.lineCap=u==="rnd"?"round":u==="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 nn(e,n,t,s,i,r){const o=m(n,"spPr"),l=m(o,"xfrm");if(!l)return;const a=m(l,"off"),d=m(l,"ext");if(!a||!d)return;const c=C(a,"x",0)*r,h=C(a,"y",0)*r,u=C(d,"cx",0)*r,g=C(d,"cy",0)*r,p=C(l,"rot",0)/6e4,b=B(l,"flipH","0")==="1",_=B(l,"flipV","0")==="1";if(u<=0||g<=0)return;const y=m(n,"blipFill"),w=y?m(y,"blip"):null,x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,P=c+u/2,v=h+g/2;if(e.save(),(p!==0||b||_)&&(e.translate(P,v),p!==0&&e.rotate(p*Math.PI/180),b&&e.scale(-1,1),_&&e.scale(1,-1),e.translate(-P,-v)),x&&s[x]){const k=s[x],T=m(o,"prstGeom"),N=T?B(T,"prst","rect"):"rect",M={};if(T){const E=m(T,"avLst");if(E){let L=0;for(const z of de(E,"gd")){const Q=(B(z,"fmla","")||"").match(/val\s+(-?\d+)/);Q&&(M[L]=parseInt(Q[1])),L++}}}e.beginPath(),Kt(e,N,c,h,u,g,M),e.clip();const F=y?m(y,"srcRect"):null;if(F){const E=C(F,"l",0)/1e5,L=C(F,"t",0)/1e5,z=C(F,"r",0)/1e5,Q=C(F,"b",0)/1e5,G=k.naturalWidth*(1-E-z),O=k.naturalHeight*(1-L-Q);e.drawImage(k,k.naturalWidth*E,k.naturalHeight*L,G,O,c,h,u,g)}else e.drawImage(k,c,h,u,g);const j=m(o,"ln");j&&(e.beginPath(),Kt(e,N,c,h,u,g,M),lt(e,j,i,r))}else e.fillStyle="#e0e0e0",e.fillRect(c,h,u,g),e.strokeStyle="#aaa",e.lineWidth=1,e.strokeRect(c,h,u,g),e.beginPath(),e.moveTo(c,h),e.lineTo(c+u,h+g),e.moveTo(c+u,h),e.lineTo(c,h+g),e.stroke();e.restore()}async function $s(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,d=C(o,"y",0)*i;C(l,"cx",0)*i,C(l,"cy",0)*i;const c=m(n,"graphic"),h=c?m(c,"graphicData"):null,u=h?m(h,"tbl"):null;if(!u)return;const g=m(u,"tblPr"),p=g?B(g,"bandRow","0")==="1":!1;g&&B(g,"bandCol","0");const b=g?B(g,"firstRow","0")==="1":!1,_=g?B(g,"lastRow","0")==="1":!1;g&&B(g,"firstCol","0"),g&&B(g,"lastCol","0");const y=m(u,"tblGrid"),w=de(y,"gridCol").map(v=>C(v,"w",0)*i),x=de(u,"tr");let P=d;for(let v=0;v<x.length;v++){const k=x[v],T=C(k,"h",457200)*i,N=de(k,"tc");let M=a;const F=v===0,j=v===x.length-1,E=v%2===1;for(let L=0;L<N.length;L++){const z=N[L],Q=C(z,"gridSpan",1);B(z,"vMerge","0");let G=0;for(let R=0;R<Q;R++)G+=w[L+R]||0;const O=m(z,"tcPr"),q=O?["noFill","solidFill","gradFill","blipFill","pattFill"].map(R=>m(O,R)).find(Boolean):null;if(e.save(),e.beginPath(),e.rect(M,P,G,T),q)await kt(e,q,M,P,G,T,i,t,null);else{let R=null;b&&F?R=t.accent1?"#"+t.accent1.toLowerCase():"#4472C4":_&&j?R="#e0e0e0":p&&E&&(R="rgba(0,0,0,0.06)"),e.fillStyle=R||"transparent",R&&e.fill()}const Z=[{el:m(O,"lnL"),x1:M,y1:P,x2:M,y2:P+T},{el:m(O,"lnR"),x1:M+G,y1:P,x2:M+G,y2:P+T},{el:m(O,"lnT"),x1:M,y1:P,x2:M+G,y2:P},{el:m(O,"lnB"),x1:M,y1:P+T,x2:M+G,y2:P+T}];for(const R of Z)R.el?m(R.el,"noFill")||(e.beginPath(),e.moveTo(R.x1,R.y1),e.lineTo(R.x2,R.y2),lt(e,R.el,t,i)):(e.beginPath(),e.strokeStyle="#cccccc",e.lineWidth=.5,e.moveTo(R.x1,R.y1),e.lineTo(R.x2,R.y2),e.stroke());e.restore();const J=m(z,"txBody");J&&(e.save(),e.beginPath(),e.rect(M,P,G,T),e.clip(),await Vt(e,J,M,P,G,T,i,t,s,1400),e.restore()),M+=G}P+=T}}async function sn(e,n,t,s,i,r,o){const l=m(n,"grpSpPr"),a=m(l,"xfrm");if(!a)return;const d=m(a,"off"),c=m(a,"ext"),h=m(a,"chOff"),u=m(a,"chExt");if(!d||!c||!h||!u)return;const g=C(a,"rot",0)/6e4,p=B(a,"flipH","0")==="1",b=B(a,"flipV","0")==="1",_={grpOff:{x:C(d,"x",0)*o,y:C(d,"y",0)*o},grpExt:{cx:C(c,"cx",0)*o,cy:C(c,"cy",0)*o},chOff:{x:C(h,"x",0),y:C(h,"y",0)},chExt:{cx:C(u,"cx",1),cy:C(u,"cy",1)}},y=_.grpOff.x+_.grpExt.cx/2,w=_.grpOff.y+_.grpExt.cy/2;e.save(),(g!==0||p||b)&&(e.translate(y,w),g!==0&&e.rotate(g*Math.PI/180),p&&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 tn(e,x,t,s,i,r,o,_):P==="pic"?await nn(e,x,t,s,i,o):P==="grpSp"?await sn(e,x,t,s,i,r,o):P==="graphicFrame"?await on(e,x,i,r,o,files,t):P==="cxnSp"&&await rn(e,x,i,o)}e.restore()}function Qn(e,n,t,s,i,r,o,l,a){const d=m(n,t);if(!d)return;const c=d.getAttribute("type")||"none";if(c==="none")return;const h={sm:3,med:6,lg:9},u=Math.max(.5,C(n,"w",12700)*a),g=u*(h[d.getAttribute("w")||"med"]??6),p=u*(h[d.getAttribute("len")||"med"]??6),b=Math.atan2(o-i,r-s);switch(e.save(),e.fillStyle=e.strokeStyle,e.strokeStyle=e.strokeStyle,c){case"triangle":case"arrow":case"stealth":{const _=c==="arrow",y=c==="stealth"?p*.5:0;e.beginPath(),e.moveTo(s,i),e.lineTo(s+p*Math.cos(b)+g/2*Math.sin(b),i+p*Math.sin(b)-g/2*Math.cos(b)),_||e.lineTo(s+y*Math.cos(b),i+y*Math.sin(b)),e.lineTo(s+p*Math.cos(b)-g/2*Math.sin(b),i+p*Math.sin(b)+g/2*Math.cos(b)),e.closePath(),_?e.stroke():e.fill();break}case"diamond":{const _=p/2;e.beginPath(),e.moveTo(s,i),e.lineTo(s+_*Math.cos(b)+g/2*Math.sin(b),i+_*Math.sin(b)-g/2*Math.cos(b)),e.lineTo(s+p*Math.cos(b),i+p*Math.sin(b)),e.lineTo(s+_*Math.cos(b)-g/2*Math.sin(b),i+_*Math.sin(b)+g/2*Math.cos(b)),e.closePath(),e.fill();break}case"oval":{const _=p/2,y=g/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 rn(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,d=C(o,"y",0)*s,c=C(l,"cx",0)*s,h=C(l,"cy",0)*s,u=C(r,"rot",0)/6e4,g=B(r,"flipH","0")==="1",p=B(r,"flipV","0")==="1",b=a+c/2,_=d+h/2,y=m(i,"ln");e.save(),(u!==0||g||p)&&(e.translate(b,_),u!==0&&e.rotate(u*Math.PI/180),g&&e.scale(-1,1),p&&e.scale(1,-1),e.translate(-b,-_));const w=m(i,"prstGeom"),x=w?B(w,"prst","line"):"line",P=x==="line"||x==="straightConnector1";if(e.beginPath(),P){const v=g?a:a+c,k=p?d:d+h,T=g?a+c:a,N=p?d+h:d;e.moveTo(T,N),e.lineTo(v,k)}else Kt(e,x,a,d,c,h,{});if(y){if(lt(e,y,t,s),P){const v=g?a+c:a,k=p?d+h:d,T=g?a:a+c,N=p?d:d+h;Qn(e,y,"headEnd",T,N,v,k,t,s),Qn(e,y,"tailEnd",v,k,T,N,t,s)}}else e.strokeStyle="#000",e.lineWidth=1,e.stroke();e.restore()}async function Es(e,n,t,s,i,r,o,l,a,d,c){const h=d*a,u=c*a,g=x=>{const P=m(x,"cSld");if(!P)return null;const v=m(P,"bg");if(!v)return null;const k=m(v,"bgPr"),T=m(v,"bgRef");return{bgPr:k,bgRef:T}},p=n?g(n):null,b=s?g(s):null,_=t?g(t):null,y=p||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 T=m(x,k);if(T){e.beginPath(),e.rect(0,0,h,u);const N=y===_?Object.assign({},o):o;await kt(e,T,0,0,h,u,1,l,N)&&(w=!0);break}}}else if(P){C(P,"idx",0);const v=me(P),k=ye(v,l);k&&(e.fillStyle=ge(k),e.fillRect(0,0,h,u),w=!0)}}w||(e.fillStyle="#ffffff",e.fillRect(0,0,h,u))}function Rs(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 de(i,"sp")){const o=m(r,"nvSpPr"),l=o?m(o,"nvPr"):null,a=l?m(l,"ph"):null;if(!a)continue;const d=B(a,"type","body"),c=B(a,"idx","0"),h=`${d}:${c}`;if(n[h])continue;const u=m(r,"spPr"),g=m(u,"xfrm");if(!g)continue;const p=m(g,"off"),b=m(g,"ext");!p||!b||(n[h]={x:C(p,"x",0),y:C(p,"y",0),w:C(b,"cx",0),h:C(b,"cy",0),txBody:m(r,"txBody")})}}return n}function Is(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=B(i,"type","body"),o=B(i,"idx","0");return n[`${r}:${o}`]||n[`${r}:0`]||n[`body:${o}`]||null}async function on(e,n,t,s,i,r,o){const l=m(n,"graphic"),a=l?m(l,"graphicData"):null,d=a?B(a,"uri",""):"";if(m(n,"tbl")||a&&m(a,"tbl"))return $s(e,n,t,s,i);const c=m(n,"xfrm");if(!c)return;const h=m(c,"off"),u=m(c,"ext");if(!h||!u)return;const g=C(h,"x",0)*i,p=C(h,"y",0)*i,b=C(u,"cx",0)*i,_=C(u,"cy",0)*i;if(b<=0||_<=0)return;const y=d.includes("chart"),w=d.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 T=new TextDecoder().decode(r[k.fullPath]),N=_e(T);go(e,N,g,p,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 T=new TextDecoder().decode(r[k.fullPath]),N=_e(T),M=P?P.getAttribute("r:lo")||P.getAttribute("lo"):null,F=M?o[M]:null,j=F&&r[F.fullPath]?_e(new TextDecoder().decode(r[F.fullPath])):null,{renderSmartArt:E}=await Qt(async()=>{const{renderSmartArt:L}=await import("./smartart-DCxfy3Tv.js");return{renderSmartArt:L}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url);E(e,N,j,g,p,b,_,t,i);return}}const x=y?"📊 Chart":w?"🔷 Diagram":"⬛ Graphic";e.save(),e.fillStyle="#f4f4f8",e.strokeStyle="#ccccdd",e.lineWidth=1,e.fillRect(g,p,b,_),e.strokeRect(g,p,b,_),e.fillStyle="#999",e.font=`${Math.min(b*.07,16*i)}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(x,g+b/2,p+_/2),e.textAlign="start",e.textBaseline="alphabetic",e.restore()}async function zs(e,n,t,s,i,r,o,l,a){if(n)for(const d of n.children){const c=d.localName;try{c==="sp"?await tn(e,d,t,s,i,r,o,null,l):c==="pic"?await nn(e,d,t,s,i,o):c==="grpSp"?await sn(e,d,t,s,i,r,o):c==="graphicFrame"?await on(e,d,i,r,o,a,t):c==="cxnSp"&&await rn(e,d,i,o)}catch(h){console.warn("Error rendering shape:",c,h)}}}const To=Object.freeze(Object.defineProperty({__proto__:null,applyEffects:As,applyFill:kt,applyOutline:lt,buildPlaceholderMap:Rs,computeLineHeight:Ns,getDefaultFontSize:wn,getRels:De,loadImages:Gt,renderBackground:Es,renderConnector:rn,renderGraphicFrame:on,renderGroupShape:sn,renderPicture:nn,renderShape:tn,renderSpTree:zs,renderTable:$s,renderTextBody:Vt,resolvePlaceholderXfrm:Is},Symbol.toStringTag,{value:"Module"}));async function jo(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:d}=await s.read();if(d)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 Fo=(()=>{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 Co(e){let n=4294967295;for(let t=0;t<e.length;t++)n=Fo[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}class Mo{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 Ls=new TextEncoder;function No(e){return Ls.encode(e)}const Zn=18977,Jn=0;class Ao{constructor(){this._entries=[]}async addText(n,t){return this.addBytes(n,Ls.encode(t))}async addBytes(n,t,s=!0){const i=No(n),r=Co(t),o=t.length;let l,a;if(s&&t.length>32){const d=await jo(t);d.length<t.length?(l=d,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 Mo;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(Jn)),n.append(pe(Zn)),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(Jn)),n.append(pe(Zn)),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 $o(e){const n=new Ao;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 Eo=new TextDecoder,Ds=new TextEncoder,Se={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 mt(e){return new DOMParser().parseFromString(e,"application/xml")}function Ro(e){const n=new XMLSerializer().serializeToString(e);return n.startsWith("<?xml")?n:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
|
|
30
|
+
`+n}function Ae(e){return Ds.encode(Ro(e))}function ze(e,n){const t=e[n];return t?mt(Eo.decode(t)):null}function le(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 Le(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 Io(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function Ye(e){const n=e.split("/"),t=n.pop();return[...n,"_rels",t+".rels"].join("/")}function He(e,n){const t=ze(e,Ye(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 d=n.split("/").slice(0,-1).join("/");a=d?d+"/"+o.replace(/^\.\.\//,""):o;const c=a.split("/"),h=[];for(const u of c)u===".."?h.pop():h.push(u);a=h.join("/")}s[r]={id:r,target:o,type:l,fullPath:a}}return s}function Et(e){const n=mt('<?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(Se.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=le(t,"nvSpPr")||le(t,"nvPicPr")||le(t,"nvCxnSpPr"),r=i?le(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=le(e,"cSld");return n?le(n,"spTree"):null}function It(e,n,t,s=!0){for(const i of Le(e,"t")){const r=i.textContent;if(!r)continue;const o=s?r.split(n).join(t):r.replace(new RegExp(zo(n),"gi"),t);o!==r&&(i.textContent=o)}}function zo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const es={"image/jpeg":"jpeg","image/jpg":"jpeg","image/png":"png","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"},Lo={jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml"};function ts(e,n,t){const s="[Content_Types].xml",i=ze(e,s);if(!i)return;const r=i.documentElement;for(const l of Le(i,"Override"))if(l.getAttribute("PartName")==="/"+t)return;const o=i.createElementNS(Se.ct,"Override");o.setAttribute("PartName","/"+t),o.setAttribute("ContentType",Lo[n]||"application/octet-stream"),r.appendChild(o),e[s]=Ae(i)}class Ht{constructor(n){this._files=n,this._presPath="ppt/presentation.xml",this._presDoc=ze(n,this._presPath),this._presRels=He(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 Ss(n);return new Ht(t)}_buildSlidePaths(){if(!this._presDoc)return[];const n=le(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]=Ae(this._presDoc)}_savePresRels(){this._files[Ye(this._presPath)]=Ae(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]]=Ae(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[d,c]of Object.entries(n)){const h=s+d+i;It(a,h,String(c))}this._saveSlideDoc(l,a)}for(const l of o)this._applyTemplateToNotes(l,n,s,i)}_applyTemplateToNotes(n,t,s,i){const r=He(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,d]of Object.entries(t))It(l,s+a+i,String(d));this._files[o.fullPath]=Ae(l)}}replaceText(n,t,s={}){const{caseSensitive:i=!0,includeNotes:r=!1,slides:o}=s,l=o??this._slidePaths.map((a,d)=>d);for(const a of l){const d=this._slideDoc(a);if(It(d,n,t,i),this._saveSlideDoc(a,d),r){const c=He(this._files,this._slidePaths[a]),h=Object.values(c).find(u=>u.type?.includes("notesSlide"));if(h){const u=ze(this._files,h.fullPath);u&&(It(u,n,t,i),this._files[h.fullPath]=Ae(u))}}}}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 d=le(a,"txBody");if(!d)return this;const c=le(d,"r"),h=c?le(c,"rPr"):null,u=le(le(d,"p"),"pPr");for(const b of Le(d,"p"))b.parentNode.removeChild(b);const g=s.split(`
|
|
31
|
+
`),p=Se.a;for(const b of g){const _=o.createElementNS(p,"a:p");u&&r&&_.appendChild(u.cloneNode(!0));const y=o.createElementNS(p,"a:r");h&&r&&y.appendChild(h.cloneNode(!0));const w=o.createElementNS(p,"a:t");w.textContent=b,y.appendChild(w),_.appendChild(y),d.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?Le(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:d=1800,bold:c=!1,align:h="l",fontFamily:u="Calibri"}=s,g=this._slideDoc(n),p=nt(g);if(!p)return this;const _=Math.max(0,...Le(p,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,y=`TextBox ${_}`,w=Se.a,P=`<p:sp xmlns:p="${Se.p}" xmlns:a="${w}">
|
|
32
|
+
<p:nvSpPr>
|
|
33
|
+
<p:cNvPr id="${_}" name="${y}"/>
|
|
34
|
+
<p:cNvSpPr txBox="1"><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
35
|
+
<p:nvPr/>
|
|
36
|
+
</p:nvSpPr>
|
|
37
|
+
<p:spPr>
|
|
38
|
+
<a:xfrm><a:off x="${i}" y="${r}"/><a:ext cx="${o}" cy="${l}"/></a:xfrm>
|
|
39
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
40
|
+
<a:noFill/>
|
|
41
|
+
</p:spPr>
|
|
42
|
+
<p:txBody>
|
|
43
|
+
<a:bodyPr wrap="square" rtlCol="0"><a:spAutoFit/></a:bodyPr>
|
|
44
|
+
<a:lstStyle/>
|
|
45
|
+
<a:p>
|
|
46
|
+
<a:pPr algn="${h}"/>
|
|
47
|
+
<a:r>
|
|
48
|
+
<a:rPr lang="en-US" sz="${d}" b="${c?1:0}" dirty="0">
|
|
49
|
+
<a:solidFill><a:srgbClr val="${a}"/></a:solidFill>
|
|
50
|
+
<a:latin typeface="${u}"/>
|
|
51
|
+
</a:rPr>
|
|
52
|
+
<a:t>${t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</a:t>
|
|
53
|
+
</a:r>
|
|
54
|
+
</a:p>
|
|
55
|
+
</p:txBody>
|
|
56
|
+
</p:sp>`,v=mt(P);return p.appendChild(g.adoptNode(v.documentElement)),this._saveSlideDoc(n,g),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=He(this._files,this._slidePaths[n]),d=le(l,"blipFill"),c=d?le(d,"blip"):null,h=c?c.getAttribute("r:embed")||c.getAttribute("embed"):null,u=h?a[h]:null,g=es[i]||"jpeg",p=Object.keys(this._files).filter(y=>y.startsWith("ppt/media/")).length+1,b=`ppt/media/image${p}.${g}`;this._files[b]=s;let _;return h&&u?(_=h,a[_]={id:_,type:u.type,target:`../media/image${p}.${g}`,fullPath:b}):(_=Rt(a),a[_]={id:_,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${p}.${g}`,fullPath:b}),c&&c.setAttribute("r:embed",_),this._files[Ye(this._slidePaths[n])]=Ae(Et(a)),this._saveSlideDoc(n,r),ts(this._files,g,b),this}async addImage(n,t,s="image/jpeg",i={}){const{x:r=914400,y:o=914400,w:l=2743200,h:a=2057400}=i,d=es[s]||"jpeg",c=Object.keys(this._files).filter(k=>k.startsWith("ppt/media/")).length+1,h=`ppt/media/image${c}.${d}`;this._files[h]=t;const u=He(this._files,this._slidePaths[n]),g=Rt(u);u[g]={id:g,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${c}.${d}`,fullPath:h},this._files[Ye(this._slidePaths[n])]=Ae(Et(u));const p=this._slideDoc(n),b=nt(p);if(!b)return this;const y=Math.max(0,...Le(b,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,w=Se.a,P=`<p:pic xmlns:p="${Se.p}" xmlns:a="${w}" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
57
|
+
<p:nvPicPr>
|
|
58
|
+
<p:cNvPr id="${y}" name="Picture ${y}"/>
|
|
59
|
+
<p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>
|
|
60
|
+
<p:nvPr/>
|
|
61
|
+
</p:nvPicPr>
|
|
62
|
+
<p:blipFill>
|
|
63
|
+
<a:blip r:embed="${g}"/>
|
|
64
|
+
<a:stretch><a:fillRect/></a:stretch>
|
|
65
|
+
</p:blipFill>
|
|
66
|
+
<p:spPr>
|
|
67
|
+
<a:xfrm><a:off x="${r}" y="${o}"/><a:ext cx="${l}" cy="${a}"/></a:xfrm>
|
|
68
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
69
|
+
</p:spPr>
|
|
70
|
+
</p:pic>`,v=mt(P);return b.appendChild(p.adoptNode(v.documentElement)),this._saveSlideDoc(n,p),ts(this._files,d,h),this}setSlideBackground(n,t){const s=this._slideDoc(n),i=le(s,"cSld");if(!i)return this;const r=le(i,"bg");r&&i.removeChild(r);const o=Se.a,a=`<p:bg xmlns:p="${Se.p}" xmlns:a="${o}">
|
|
71
|
+
<p:bgPr><a:solidFill><a:srgbClr val="${t}"/></a:solidFill>
|
|
72
|
+
<a:effectLst/></p:bgPr></p:bg>`,d=s.adoptNode(mt(a).documentElement);return i.insertBefore(d,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=He(this._files,l.fullPath);i=Object.values(a).find(d=>d.type?.includes("theme"))?.fullPath}}if(!i)return this;const r=ze(this._files,i);if(!r)return this;le(r,"fmtScheme");const o=le(r,"clrScheme");if(!o)return this;for(const l of o.children)if(l.localName===n){const a=le(l,"srgbClr");if(a)a.setAttribute("val",t);else{for(;l.firstChild;)l.removeChild(l.firstChild);const d=Se.a,c=r.createElementNS(d,"a:srgbClr");c.setAttribute("val",t),l.appendChild(c)}break}return this._files[i]=Ae(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=Ye(l);this._files[l]=this._files[i].slice();const d=Ye(i);this._files[d]&&(this._files[a]=this._files[d].slice());const c=Rt(this._presRels),h=`slides/slide${o}.xml`;this._presRels[c]={id:c,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",target:h,fullPath:l},this._savePresRels();const u=le(this._presDoc,"sldIdLst");if(u){const b=Le(u,"sldId").map(P=>parseInt(P.getAttribute("id")||"0",10)),_=(b.length?Math.max(...b):255)+1,y=Se.p,w=this._presDoc.createElementNS(y,"p:sldId");w.setAttribute("id",String(_)),w.setAttributeNS(Se.r,"r:id",c);const x=Array.from(u.children);s>=x.length?u.appendChild(w):u.insertBefore(w,x[s])}this._savePresDoc(),this._slidePaths=this._buildSlidePaths();const g="[Content_Types].xml",p=ze(this._files,g);if(p){const b=p.documentElement,_=p.createElementNS(Se.ct,"Override");_.setAttribute("PartName","/"+l),_.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),b.appendChild(_),this._files[g]=Ae(p)}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=le(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=le(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=He(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 Le(o,"sp")){const a=le(le(l,"nvSpPr"),"nvPr"),d=a?le(a,"ph"):null;if(d&&Io(d,"type")!=="sldNum"){for(const h of Le(l,"t"))h.textContent="";const c=le(l,"t");c&&(c.textContent=t);break}}this._files[r.fullPath]=Ae(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=Se.p,l=Se.a,a=`ppt/notesSlides/notesSlide${r}.xml`,d=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
73
|
+
<p:notes xmlns:p="${o}" xmlns:a="${l}">
|
|
74
|
+
<p:cSld><p:spTree>
|
|
75
|
+
<p:sp>
|
|
76
|
+
<p:nvSpPr><p:cNvPr id="2" name="Notes Placeholder 1"/>
|
|
77
|
+
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
78
|
+
<p:nvPr><p:ph type="body" idx="1"/></p:nvPr>
|
|
79
|
+
</p:nvSpPr>
|
|
80
|
+
<p:spPr/>
|
|
81
|
+
<p:txBody><a:bodyPr/><a:lstStyle/>
|
|
82
|
+
<a:p><a:r><a:t>${i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</a:t></a:r></a:p>
|
|
83
|
+
</p:txBody>
|
|
84
|
+
</p:sp>
|
|
85
|
+
</p:spTree></p:cSld>
|
|
86
|
+
</p:notes>`;this._files[a]=Ds.encode(d);const c=Rt(s);s[c]={id:c,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",target:`../notesSlides/notesSlide${r}.xml`,fullPath:a},this._files[Ye(t)]=Ae(Et(s))}async save(){return $o(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=le(r,"nvSpPr")||le(r,"nvPicPr")||le(r,"nvGraphicFramePr")||le(r,"nvCxnSpPr"),a=l?le(l,"cNvPr"):null;i.push({id:a?.getAttribute("id")||"",name:a?.getAttribute("name")||"",type:o})}return i}}const Bs=new TextEncoder;function Do(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}class Bo{constructor(){this._parts=[],this._size=0}write(n){const t=typeof n=="string"?Bs.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 Oo(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 Uo(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 Go(e,n){const t=e/914400*72,s=n/914400*72;return{w:t,h:s}}class Wo{constructor(){this._buf=new Bo,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
|
|
87
|
+
`),s){const r=s.length;this._buf.write(`${t.replace("__LEN__",r)}
|
|
88
|
+
`),this._buf.write(`stream\r
|
|
89
|
+
`),this._buf.write(s),this._buf.write(`\r
|
|
90
|
+
endstream
|
|
91
|
+
`)}else this._buf.write(`${t}
|
|
92
|
+
`);return this._buf.write(`endobj
|
|
93
|
+
|
|
94
|
+
`),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:d,cy:c}=n.slideSize,{w:h,h:u}=Go(d,c);this._buf.write(`%PDF-1.4
|
|
95
|
+
`),this._buf.write(`%ÿþýü
|
|
96
|
+
|
|
97
|
+
`);const g=this._nextObj(),p=this._nextObj(),b=Array.from({length:a},()=>this._nextObj()),_=Array.from({length:a},()=>this._nextObj()),y=Array.from({length:a},()=>this._nextObj());this._writeObj(g,`<< /Type /Catalog /Pages ${p} 0 R >>`);const w=b.map(v=>`${v} 0 R`).join(" ");this._writeObj(p,`<< /Type /Pages /Kids [${w}] /Count ${a} >>`);for(let v=0;v<a;v++){const k=l[v];o?.(v,a);const T=await Uo(n,k,s),N=await Oo(T,i),M=T.width,F=T.height;this._writeObj(b[v],`<< /Type /Page /Parent ${p} 0 R /MediaBox [0 0 ${h.toFixed(3)} ${u.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 j=`q ${h.toFixed(3)} 0 0 ${u.toFixed(3)} 0 0 cm /Im${v} Do Q`;this._writeObj(y[v],"<< /Length __LEN__ >>",Bs.encode(j))}o?.(a,a);const x=this._buf.size,P=this._objNum+1;this._buf.write(`xref
|
|
98
|
+
0 ${P}
|
|
99
|
+
`),this._buf.write(`0000000000 65535 f \r
|
|
100
|
+
`);for(let v=1;v<P;v++){const k=this._xref[v]??0;this._buf.write(String(k).padStart(10,"0")+` 00000 n \r
|
|
101
|
+
`)}return this._buf.write(`trailer
|
|
102
|
+
<< /Size ${P} /Root ${g} 0 R >>
|
|
103
|
+
`),this._buf.write(`startxref
|
|
104
|
+
${x}
|
|
105
|
+
%%EOF
|
|
106
|
+
`),this._buf.concat()}}async function $n(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 Wo().build(e,{widthPx:l,quality:i,slideList:r,onProgress:o})}async function qo(e,n="presentation.pdf",t={}){const s=await $n(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 Ko(e,n,t={}){return $n(n,{...t,slides:[e]})}const Xo=500;function En(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 d=m(o,"cTn");if(!d)return;const c=B(d,"nodeType","");c==="clickEffect"&&(l+=1),c==="withEffect"&&l===0&&(l=0);const h=C(d,"delay",0)+a,u=m(o,"childTnLst")||m(d,"childTnLst");if(u)for(const g of u.children){const p=g.localName;if(p==="par")i(g,l,h);else if(p==="seq"){const b=m(g,"cTn"),y=(b?B(b,"nodeType",""):"")==="clickEffect"?l+1:l,w=m(g,"childTnLst");if(w)for(const x of w.children)x.localName==="par"&&i(x,y,h)}else if(p==="set"||p==="animEffect"||p==="anim"||p==="animScale"||p==="animClr"){const b=ns(g,l,h);b&&s.push(b)}}}function r(o,l){const a=m(o,"childTnLst")||m(m(o,"cTn"),"childTnLst");if(!a)return;let d=l;for(const c of a.children)if(c.localName==="par"){const h=m(c,"cTn"),u=h?B(h,"nodeType",""):"";(u==="clickEffect"||u==="clickPar")&&d++,i(c,d,0)}}for(const o of t.children)o.localName==="par"?i(o,0,0):o.localName==="seq"&&r(o,0);for(const o of de(t,"animEffect")){const l=ns(o,0,0);l&&s.push(l)}return s.sort((o,l)=>o.clickNum-l.clickNum||o.delay-l.delay)}function ns(e,n,t){const s=m(e,"cTn"),i=m(e,"tgt")||m(s,"tgt"),r=i?m(i,"spTgt"):null,o=r?B(r,"spid",null):null;if(!o)return null;const l=s?B(s,"dur",null):null,a=l==="indefinite"?2e3:l?parseInt(l,10):Xo,d=(s?C(s,"delay",0):0)+t,c=B(e,"filter",null),h=B(e,"type",null)||(c?"filter":"set"),u=B(e,"dir",null)||(c?c.split("(")[1]?.replace(")",""):null)||"";let g="emphasis";(h==="in"||e.localName==="set"&&B(m(e,"attrNameLst")||e,"attrName","")==="style.visibility"&&B(e,"to","")==="visible")&&(g="entrance"),(h==="out"||e.localName==="set"&&B(e,"to","")==="hidden")&&(g="exit");let p=c||e.localName;if(c){const b=c.toLowerCase();b.includes("fade")?p="fade":b.includes("fly")?p="fly":b.includes("appear")?p="appear":b.includes("zoom")?p="zoom":b.includes("wipe")?p="wipe":b.includes("wheel")?p="wheel":b.includes("blinds")?p="blinds":b.includes("box")?p="box":b.includes("dissolve")?p="dissolve":b.includes("split")?p="split":b.includes("stretch")?p="stretch":b.includes("diamond")?p="diamond":b.includes("plus")?p="plus":b.includes("wedge")?p="wedge":b.includes("random")?p="dissolve":b.includes("strips")?p="strips":b.includes("peek")?p="fly":b.includes("checkerboard")?p="dissolve":p="fade"}return{shapeId:o,type:g,effect:p,clickNum:n,delay:d,duration:a,dir:u,raw:e.localName}}function Rn(e){if(!e)return null;const n=m(e,"transition");if(!n)return null;const t=C(n,"dur",700),s=B(n,"spd","med"),i=s==="slow"?1200:s==="fast"?300:t,r=n.firstElementChild,o=r?.localName||"fade",l=r?B(r,"dir","l"):"l";return{type:o,duration:i,dir:l}}function Vo(e){return 1-Math.pow(1-e,2)}function Ho(e){return e*e}function Yo(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}function Os(e,n,t,s){const i=Math.max(0,Math.min(1,n)),r=e.type==="entrance",o=r?Vo(i):Ho(i),l={opacity:1,tx:0,ty:0,scaleX:1,scaleY:1,clipProgress:1,clipDir:"none",spin:0},a=e.effect,d=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 c=1-o;d.includes("l")?l.tx=-t*c:d.includes("r")?l.tx=t*c:d.includes("t")?l.ty=-s*c:l.ty=s*c;break}case"zoom":l.opacity=o,l.scaleX=.1+o*.9,l.scaleY=.1+o*.9;break;case"wipe":l.clipProgress=o,l.clipDir=d||"r";break;case"split":l.clipProgress=o,l.clipDir=d.includes("v")?"split-v":"split-h";break;case"blinds":l.clipProgress=o,l.clipDir=d.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=d.includes("r")?"strips-r":"strips-l";break;case"stretch":l.opacity=o,d.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 c={...e,type:"entrance"};return Os(c,1-i,t,s)}else switch(a){case"spin":l.spin=o*360;break;case"grow":case"shrink":{const c=a==="grow"?1.5:.5,h=i<.5?i*2:(1-i)*2;l.scaleX=1+(c-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 Us(e,n,t,s,i){const r=Yo(i),o=e.canvas.width,l=e.canvas.height;e.clearRect(0,0,o,l);const a=s?.type||"fade",d=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 c=d==="l"?-o*r:d==="r"?o*r:0,h=d==="u"?-l*r:d==="d"?l*r:0;e.drawImage(n,c,h,o,l),e.drawImage(t,c+(d==="l"?o:d==="r"?-o:0),h+(d==="u"?l:d==="d"?-l:0),o,l);break}case"cover":case"uncover":{const c=a==="uncover",h=d==="l"?-o*(1-r):d==="r"?o*(1-r):0,u=d==="u"?-l*(1-r):d==="d"?l*(1-r):0;c?(e.drawImage(t,0,0,o,l),e.drawImage(n,h,u,o,l)):(e.drawImage(n,0,0,o,l),e.drawImage(t,h,u,o,l));break}case"wipe":{e.drawImage(n,0,0,o,l),e.save(),e.beginPath(),d==="l"?e.rect(o*(1-r),0,o*r,l):d==="r"?e.rect(0,0,o*r,l):d==="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 c=a==="newsflash"?1+(1-r)*3:.05+r*.95;e.translate(o/2,l/2),e.scale(c,c),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 Gs{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(()=>Wr);return{parseXml:a}},void 0,import.meta.url).catch(()=>({parseXml:a=>new DOMParser().parseFromString(a,"application/xml")})),o=r(i);this._steps=En(o),this._transition=Rn(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 d of t){if(r.has(d))continue;const c=a-d.delay;if(c<0)continue;const h=Math.min(1,c/d.duration),u=this.canvas.width,g=this.canvas.height,p=Os(d,h,u*.3,g*.3);this._shapeStates.set(d.shapeId,{...p,step:d}),h>=1&&r.add(d)}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 d=Math.min(1,(a-o)/i);Us(this.ctx,n,t,s,d),d<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 Qo=Object.freeze(Object.defineProperty({__proto__:null,PptxPlayer:Gs,parseAnimations:En,parseTransition:Rn,renderTransitionFrame:Us},Symbol.toStringTag,{value:"Module"}));let Zo=0;function an(e="el"){return`${e}${++Zo}`}function Fe(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function A(e){return`${+e.toFixed(3)}`}function kn(e){return e?ge(e):"none"}function Ws(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),d=ye(a,t),c=kn(d),h=d?.a!=null?d.a/255:1;return{fill:c,fillAttrs:h<1?` fill-opacity="${A(h)}"`:""}}if(l==="gradFill"){const a=m(e,"gsLst"),d=a?de(a,"gs").map(p=>{const b=C(p,"pos",0)/1e5,_=me(p),y=ye(_,t);return{pos:b,color:kn(y),opacity:y?.a!=null?y.a/255:1}}):[],c=m(e,"lin"),h=m(e,"path"),u=an("grad");let g;if(h){const p=m(h,"fillToRect"),b=C(p,"l",5e4)/1e5,_=C(p,"t",5e4)/1e5,y=s+r*b,w=i+o*_,x=Math.sqrt(r*r+o*o)/2;g=`<radialGradient id="${u}" cx="${A(y)}" cy="${A(w)}" r="${A(x)}" gradientUnits="userSpaceOnUse">`;for(const P of d)g+=`<stop offset="${A(P.pos)}" stop-color="${Fe(P.color)}"${P.opacity<1?` stop-opacity="${A(P.opacity)}"`:""}/>`;g+="</radialGradient>"}else{const b=(C(c,"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;g=`<linearGradient id="${u}" x1="${A(x-_*w)}" y1="${A(P-y*w)}" x2="${A(x+_*w)}" y2="${A(P+y*w)}" gradientUnits="userSpaceOnUse">`;for(const v of d)g+=`<stop offset="${A(v.pos)}" stop-color="${Fe(v.color)}"${v.opacity<1?` stop-opacity="${A(v.opacity)}"`:""}/>`;g+="</linearGradient>"}return n.push(g),{fill:`url(#${u})`,fillAttrs:""}}return l==="blipFill"?{fill:"none",fillAttrs:""}:{fill:"none",fillAttrs:""}}function qs(e,n,t){if(!e)return"";if(m(e,"noFill"))return' stroke="none"';const s=m(e,"solidFill"),i=s?me(s):null,r=ye(i,n),o=kn(r)||"#000",l=Math.max(.5,C(e,"w",12700)/914400*96),a=m(e,"prstDash"),d=a?B(a,"val","solid"):"solid";let c="";d==="dash"?c=` stroke-dasharray="${A(l*4)},${A(l*2)}"`:d==="dot"?c=` stroke-dasharray="${A(l)},${A(l*2)}"`:d==="dashDot"?c=` stroke-dasharray="${A(l*4)},${A(l*2)},${A(l)},${A(l*2)}"`:d==="lgDash"&&(c=` stroke-dasharray="${A(l*8)},${A(l*3)}"`);const h=B(e,"cap","flat"),u=h==="rnd"?"round":h==="sq"?"square":"butt";return` stroke="${Fe(o)}" stroke-width="${A(l)}" stroke-linecap="${u}" stroke-linejoin="round"${c}`}function Ks(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,d=me(t),c=ye(d,{}),h=c?ge(c):"rgba(0,0,0,0.5)",u=c?.a!=null?c.a/255:.5,g=an("shd");return n.push(`<filter id="${g}" x="-50%" y="-50%" width="200%" height="200%"><feDropShadow dx="${A(l)}" dy="${A(a)}" stdDeviation="${A(r/2)}" flood-color="${Fe(h)}" flood-opacity="${A(u)}"/></filter>`),` filter="url(#${g})"`}function Jo(e,n,t,s,i,r){const o=[],l={beginPath(){o.length=0},moveTo(a,d){o.push(`M${A(a)},${A(d)}`)},lineTo(a,d){o.push(`L${A(a)},${A(d)}`)},bezierCurveTo(a,d,c,h,u,g){o.push(`C${A(a)},${A(d)},${A(c)},${A(h)},${A(u)},${A(g)}`)},quadraticCurveTo(a,d,c,h){o.push(`Q${A(a)},${A(d)},${A(c)},${A(h)}`)},arc(a,d,c,h,u,g){const p=a+c*Math.cos(h),b=d+c*Math.sin(h),_=a+c*Math.cos(u),y=d+c*Math.sin(u);let w=u-h;g&&(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(p)},${A(b)}`),o.push(`A${A(c)},${A(c)},0,${x},${P},${A(_)},${A(y)}`)},arcTo(a,d,c,h,u){o.push(`L${A(a)},${A(d)} L${A(c)},${A(h)}`)},closePath(){o.push("Z")},fill(){},stroke(){},save(){},restore(){},translate(){},rotate(){},scale(){},rect(a,d,c,h){o.push(`M${A(a)},${A(d)}L${A(a+c)},${A(d)}L${A(a+c)},${A(d+h)}L${A(a)},${A(d+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 ea=null;function ln(e){if(!e)return"";const n=C(e,"rot",0)/6e4,t=B(e,"flipH","0")==="1",s=B(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,d=C(r,"cy",0)/914400*96,c=o+a/2,h=l+d/2,u=[];return n&&u.push(`rotate(${A(n)},${A(c)},${A(h)})`),t&&u.push(`scale(-1,1) translate(${A(-o*2-a)},0)`),s&&u.push(`scale(1,-1) translate(0,${A(-l*2-d)})`),u.length?` transform="${u.join(" ")}"`:""}function Ct(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 ta(e,n,t,s,i,r,o,l){if(!e)return"";const a=m(e,"bodyPr"),d=B(a,"vert","horz"),c=d==="vert"||d==="vert270"||d==="wordArtVert";B(a,"anchor","t");const h=C(a,"lIns",91440)/914400*96,u=C(a,"rIns",91440)/914400*96,g=C(a,"tIns",45720)/914400*96;C(a,"bIns",45720)/914400*96;const p=n+h,b=s-h-u,_=t+g,y=1800,w=m(e,"lstStyle"),x=w?m(w,"defRPr"):null,P=de(e,"p");let v="",k=_;const T=an("clip");l.push(`<clipPath id="${T}"><rect x="${A(n)}" y="${A(t)}" width="${A(s)}" height="${A(i)}"/></clipPath>`);const N=c?` transform="rotate(-90,${A(n+s/2)},${A(t+i/2)})"`:"",M={};for(const F of P){const j=m(F,"pPr"),E=B(j,"algn","l"),L=C(j,"marL",0)/914400*96,z=C(j,"indent",0)/914400*96,Q=m(j,"defRPr");let G=y;if(x){const I=x.getAttribute("sz");I&&(G=parseInt(I,10))}if(Q){const I=Q.getAttribute("sz");I&&(G=parseInt(I,10))}const O=m(j,"spcBef"),q=m(j,"spcAft");m(j,"lnSpc");let Z=0,J=0;if(O){const I=m(O,"spcPct"),V=m(O,"spcPts");I?Z=G*bt/914400*96*(C(I,"val",0)/1e5):V&&(Z=C(V,"val",0)/100/72*96)}if(q){const I=m(q,"spcPct"),V=m(q,"spcPts");I?J=G*bt/914400*96*(C(I,"val",0)/1e5):V&&(J=C(V,"val",0)/100/72*96)}const R=j?m(j,"buChar"):null,H=j?m(j,"buAutoNum"):null,re=!(j?m(j,"buNone"):null)&&(R||H);k+=Z;const ce=[];for(const I of F.children)(I.localName==="r"||I.localName==="br"||I.localName==="fld")&&ce.push(I);if(!ce.length){const I=m(F,"endParaRPr"),ee=C(I||Q,"sz",G)/100/72*96*1.2;k+=ee+J;continue}let ne="";for(const I of ce){if(I.localName==="br"){ne+=`
|
|
107
|
+
`;continue}const V=m(I,"t")||m(I,"fldVal");V&&(ne+=V.textContent)}const X=[];for(const I of ce){if(I.localName==="br"){X.push({br:!0});continue}const V=m(I,"rPr")||m(I,"r")?.firstElementChild,Y=m(I,"t");if(!Y)continue;const ee=Y.textContent;if(!ee)continue;const $=js(I,Q,x,r,o,G),U=$?.szPx||G/100/72*96,te=$?.family||"sans-serif",se=$?.bold?"bold":"normal",he=$?.italic?"italic":"normal",ke=$?.color?ge($.color):"#000000",Pe=V?(V.getAttribute("u")||"none")!=="none":!1,Me=V?(V.getAttribute("strike")||"noStrike")!=="noStrike":!1,Mt=V?parseInt(V.getAttribute("baseline")||"0",10):0;X.push({text:ee,szPx:U,family:te,bold:se,italic:he,color:ke,underline:Pe,strike:Me,baseline:Mt})}if(!X.length){k+=J;continue}const xe=X.filter(I=>!I.br&&I.szPx).map(I=>I.szPx),oe=xe.length?Math.max(...xe):G/100/72*96,ae=oe*1.2,ue=k+oe*.85;let ve="start",we=p+L;E==="ctr"?(ve="middle",we=p+b/2):E==="r"&&(ve="end",we=p+b);let be="";if(re){const I=p+L+z;let V="";if(R)V=Fe(R.getAttribute("char")||"•");else if(H){const ee=H.getAttribute("type")||"arabicPeriod",$=C(H,"startAt",1),U=ee+":"+$;M[U]||(M[U]=$),V=Fe(na(ee,M[U]++))}const Y=oe;be=`<text x="${A(I)}" y="${A(ue)}" font-size="${A(Y)}" font-family="sans-serif" fill="#000">${V}</text>`}let fe="";for(const I of X){if(I.br){k+=ae,fe+=`<tspan x="${A(we)}" dy="${A(ae)}">`;continue}const V=I.underline?"underline":I.strike?"line-through":"none";let Y=ue;I.baseline>0?Y=ue-I.szPx*.38:I.baseline<0&&(Y=ue+I.szPx*.12);const ee=I.baseline!==0?I.szPx*.65:I.szPx;fe+=`<tspan font-family="${Fe(I.family)}, sans-serif" font-size="${A(ee)}" font-weight="${I.bold}" font-style="${I.italic}" fill="${Fe(I.color)}"`+(V!=="none"?` text-decoration="${V}"`:"")+(I.baseline!==0?` dy="${A(Y-ue)}"`:"")+`>${Fe(I.text)}</tspan>`}v+=be,v+=`<text x="${A(we)}" y="${A(ue)}" text-anchor="${ve}">${fe}</text>`,k+=ae+J}return`<g clip-path="url(#${T})"${N}>${v}</g>`}function na(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return ss(n).toLowerCase()+".";case"romanUcPeriod":return ss(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";default:return n+"."}}function ss(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 sa(l,s,i,r):a==="pic"?o+=await ia(l,n,t,s,r):a==="cxnSp"?o+=await ra(l,s):a==="grpSp"?o+=await oa(l,n,t,s,i,r):a==="graphicFrame"&&(o+=await aa(l))}return o}async function sa(e,n,t,s){const i=m(e,"spPr"),r=m(i,"xfrm"),o=Ct(r);if(!o)return"";const l=m(i,"prstGeom"),a=l?B(l,"prst","rect"):"rect",d=m(i,"custGeom"),c=["noFill","solidFill","gradFill","blipFill","pattFill"];let h=null;for(const k of c){const T=m(i,k);if(T){h=T;break}}if(!h){const k=m(e,"style"),T=k?m(k,"fillRef"):null;if(T&&C(T,"idx",1)!==0){const N=me(T),M=ye(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:u,fillAttrs:g}=Ws(h,s,n,o.x,o.y,o.w,o.h);let p=m(i,"ln");if(!p){const k=m(e,"style"),T=k?m(k,"lnRef"):null;if(T&&C(T,"idx",1)!==0){const N=me(T),M=ye(N,n);M&&(p=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=qs(p,n),_=m(i,"effectLst"),y=Ks(_,s),w=ln(r);let x="";if(a==="rect"||!l&&!d)x=`<rect x="${A(o.x)}" y="${A(o.y)}" width="${A(o.w)}" height="${A(o.h)}" fill="${Fe(u)}"${g}${b}${y}${w}/>`;else{const k=Jo(a,o.x,o.y,o.w,o.h,{});x=`<path d="${Fe(k)}" fill="${Fe(u)}"${g}${b}${y}${w}/>`}const P=m(e,"txBody"),v=P?ta(P,o.x,o.y,o.w,o.h,n,t,s):"";return`<g>${x}${v}</g>`}async function ia(e,n,t,s,i){const r=m(e,"spPr"),o=m(r,"xfrm"),l=Ct(o);if(!l)return"";const a=m(e,"blipFill"),d=a?m(a,"blip"):null,c=d?d.getAttribute("r:embed")||d.getAttribute("embed"):null,h=c?n[c]:null,u=h?t[h.fullPath]:null,g=ln(o),p=m(r,"effectLst"),b=Ks(p,i);if(!u)return`<rect x="${A(l.x)}" y="${A(l.y)}" width="${A(l.w)}" height="${A(l.h)}" fill="#e0e0e0"${g}/>`;const _=h.fullPath.split(".").pop().toLowerCase(),y=_==="png"?"image/png":_==="gif"?"image/gif":_==="svg"?"image/svg+xml":"image/jpeg",w=u instanceof Uint8Array?u:new Uint8Array(u),x=btoa(Array.from(w,v=>String.fromCharCode(v)).join("")),P=an("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}${g} preserveAspectRatio="xMidYMid slice"/>`}async function ra(e,n,t){const s=m(e,"spPr"),i=m(s,"xfrm"),r=Ct(i);if(!r)return"";const o=m(s,"ln"),l=qs(o,n),a=ln(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 oa(e,n,t,s,i,r){const o=m(e,"grpSpPr"),l=m(o,"xfrm");Ct(l);const a=l?ln(l):"",d=await qt(e,n,t,s,i,r);return`<g${a}>${d}</g>`}async function aa(e,n,t){const s=m(e,"xfrm"),i=Ct(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 la(e,n,t,s,i,r,o,l,a){const d=g=>{const p=m(g,"cSld"),b=p?m(p,"bg"):null;return b?{bgPr:m(b,"bgPr"),bgRef:m(b,"bgRef")}:null},c=d(e)||d(t)||d(n);if(!c)return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`;const{bgPr:h,bgRef:u}=c;if(h){const g=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const p of g){const b=m(h,p);if(b){if(p==="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 T=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:${T};base64,${M}" preserveAspectRatio="xMidYMid slice"/>`}}const{fill:_,fillAttrs:y}=Ws(b,a,r,0,0,o,l);return`<rect width="${A(o)}" height="${A(l)}" fill="${Fe(_)}"${y}/>`}}}if(u){const g=me(u),p=ye(g,r);if(p)return`<rect width="${A(o)}" height="${A(l)}" fill="${Fe(ge(p))}"/>`}return`<rect width="${A(o)}" height="${A(l)}" fill="white"/>`}async function Xs(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 d=s[e],c=t[d]?new TextDecoder().decode(t[d]):null;if(!c)throw new Error(`Cannot read slide ${e}`);const h=_e(c),u=await De(t,d),g=Object.values(u).find(j=>j.type?.includes("slideLayout")),p=g&&t[g.fullPath]?_e(new TextDecoder().decode(t[g.fullPath])):null,b=g?await De(t,g.fullPath):{},_=i.cx/914400*96,y=i.cy/914400*96,w=[],x=await la(h,l,p,t,a,r,_,y,w),P=m(m(l,"cSld"),"spTree"),v=p?m(m(p,"cSld"),"spTree"):null,k=m(m(h,"cSld"),"spTree"),T=P?await qt(P,a,t,r,o,w):"",N=v?await qt(v,b,t,r,o,w):"",M=k?await qt(k,u,t,r,o,w):"",F=w.length?`<defs>${w.join(`
|
|
108
|
+
`)}</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,T,N,M,"</svg>"].join(`
|
|
109
|
+
`)}async function ca(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await Xs(t,e));return n}function is(e){const n=e.replace(/[{}\-]/g,"");if(n.length<32){const a=n.padEnd(32,"0");return da(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 da(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 rs(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 pn(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 xn=new Set;async function ua(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 d=[...a.children].find(u=>u.localName==="font");if(!d)continue;const c=d.getAttribute("typeface")||d.getAttribute("t");if(!c)continue;const h=[{el:[...a.children].find(u=>u.localName==="regular"),weight:"400",style:"normal"},{el:[...a.children].find(u=>u.localName==="bold"),weight:"700",style:"normal"},{el:[...a.children].find(u=>u.localName==="italic"),weight:"400",style:"italic"},{el:[...a.children].find(u=>u.localName==="boldItalic"),weight:"700",style:"italic"}];for(const{el:u,weight:g,style:p}of h){if(!u)continue;const b=u.getAttribute("r:id")||u.getAttribute("id")||u.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id");if(!b)continue;const _=`${c}:${g}:${p}`;if(xn.has(_)){t.push({typeface:c,weight:g,style:p,status:"already-loaded"});continue}const y=n?n[b]:null;if(!y){t.push({typeface:c,weight:g,style:p,status:"rel-not-found",rId:b});continue}const w=e[y.fullPath];if(!w){t.push({typeface:c,weight:g,style:p,status:"file-not-found",path:y.fullPath});continue}let x=null;const P=is(b),v=rs(w,P);if(pn(v))x=v;else{const k=y.fullPath.split("/").pop().replace(".fntdata",""),T=is(k),N=rs(w,T);pn(N)?x=N:pn(w)&&(x=w)}if(!x){t.push({typeface:c,weight:g,style:p,status:"decode-failed",path:y.fullPath});continue}try{const k=new FontFace(c,x.buffer,{weight:g,style:p});await k.load(),document.fonts.add(k),xn.add(_),t.push({typeface:c,weight:g,style:p,status:"loaded",path:y.fullPath})}catch(k){t.push({typeface:c,weight:g,style:p,status:"load-failed",error:k.message})}}}return t}function fa(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(d=>d.localName===a));return{typeface:o,variants:l,loaded:l.some(a=>xn.has(`${o}:${a==="bold"||a==="boldItalic"?"700":"400"}:${a.includes("talic")?"italic":"normal"}`))}}).filter(i=>i.typeface):[]}function W(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 Xe(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 Te(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function _n(e,n,t=0){const s=Te(e,n);return s!==null?parseInt(s,10):t}function ha(e,n){const t=W(e,"rPr"),s=W(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,d=t&&t.getAttribute("u")||"none";let c="#000000";if(t){const h=W(t,"solidFill")||W(t,"lumMod");if(h){const u=W(h,"srgbClr");u&&(c="#"+(u.getAttribute("val")||"000000"))}}return{text:i,bold:l,italic:a,underline:d!=="none",fontSize:o,color:c}}function pa(e){const n=W(e,"pPr"),t=Te(n,"algn","l"),s=_n(n,"lvl",0),i=W(n,"defRPr");let r=null;if(n&&!W(n,"buNone")){const a=W(n,"buChar"),d=W(n,"buAutoNum");a?r=a.getAttribute("char")||"•":d&&(r="{auto}")}const o=[];for(const a of e.children)if(a.localName==="r"){const d=ha(a,i);d&&o.push(d)}else if(a.localName==="br")o.push({text:`
|
|
110
|
+
`,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#000"});else if(a.localName==="fld"){const d=W(a,"t");d&&o.push({text:d.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 Pn(e){return e?Xe(e,"p").map(pa).filter(n=>n.text.trim()):[]}function os(e){const n=W(e,"nvSpPr"),t=n?W(n,"nvPr"):null,s=t?W(t,"ph"):null;if(s){const r=Te(s,"type","body");if(r==="title"||r==="ctrTitle")return"title";if(r==="subTitle")return"subtitle";if(r==="body")return"body"}return W(e,"txBody")?"textBox":"other"}function as(e){const n=W(e,"nvSpPr"),t=n?W(n,"cNvPr"):null;return t?Te(t,"id",""):""}function ls(e){const n=W(e,"nvSpPr"),t=n?W(n,"cNvPr"):null;return t?Te(t,"name",""):""}function ga(e){const n=W(e,"tbl");if(!n)return null;const t=W(e,"nvGraphicFramePr"),s=t?W(t,"cNvPr"):null,i=s?Te(s,"id",""):"",r=s?Te(s,"name",""):"",o=[];let l=0;for(const d of Xe(n,"tr")){const c=[];let h=0;for(const u of Xe(d,"tc")){const g=_n(u,"gridSpan",1),p=_n(u,"rowSpan",1),b=Pn(W(u,"txBody")),_=b.map(y=>y.text).join(`
|
|
111
|
+
`);c.push({row:l,col:h,rowSpan:p,colSpan:g,text:_,paragraphs:b}),h++}o.push(c),l++}const a=o.map(d=>d.map(c=>c.text).join(" ")).join(`
|
|
112
|
+
`);return{id:i,name:r,rows:o,text:a}}function ma(e,n){const t=W(e,"graphic"),s=t?W(t,"graphicData"):null,i=s?W(s,"chart"):null;if(!i)return null;const r=i.getAttribute("r:id")||i.getAttribute("id"),o=W(e,"nvGraphicFramePr"),l=o?W(o,"cNvPr"):null;return{id:l?Te(l,"id",""):"",name:l?Te(l,"name",""):"",rId:r}}function ba(e){if(!e)return{chartType:"unknown",seriesNames:[],categories:[]};const n=W(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=W(n,a),i){s=a.replace("3DChart","Chart").replace("Chart","");break}const r=i?Xe(i,"ser"):[],o=r.map(a=>{const d=W(a,"tx");if(!d)return null;const c=W(d,"v");if(c)return c.textContent.trim();const h=W(d,"strCache"),u=h?W(h,"pt"):null,g=u?W(u,"v"):null;return g?g.textContent.trim():null}).filter(Boolean),l=r.length>0?(()=>{const a=W(r[0],"cat")||W(r[0],"xVal");if(!a)return[];const d=W(a,"strCache")||W(a,"numCache");return d?Xe(d,"pt").map(c=>W(c,"v")?.textContent||"").filter(Boolean):[]})():[];return{chartType:s,seriesNames:o,categories:l}}function ya(e){if(!e)return"";const n=W(e,"cSld"),t=n?W(n,"spTree"):null;if(!t)return"";const s=[];for(const i of Xe(t,"sp")){const r=W(i,"nvSpPr"),o=r?W(r,"nvPr"):null,l=o?W(o,"ph"):null;if(l&&Te(l,"type")==="sldNum")continue;const a=W(i,"txBody");if(a){const d=Xe(a,"r").map(c=>W(c,"t")?.textContent||"").join("");d.trim()&&s.push(d.trim())}}return s.join(`
|
|
113
|
+
|
|
114
|
+
`)}async function cn(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 va(e);const r=new DOMParser().parseFromString(new TextDecoder().decode(i),"application/xml"),{getRels:o}=await Qt(async()=>{const{getRels:v}=await Promise.resolve().then(()=>To);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 d="";if(a&&t[a.fullPath]){const v=new DOMParser().parseFromString(new TextDecoder().decode(t[a.fullPath]),"application/xml");d=ya(v)}const c=W(r,"cSld"),h=c?W(c,"spTree"):null;if(!h)return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:d,text:d};const u=[],g=[],p=[],b=[];for(const v of h.children){const k=v.localName;if(k==="sp"){const T=W(v,"txBody");if(!T)continue;const N=os(v),M=as(v),F=ls(v),j=Pn(T),E=j.map(L=>L.text).join(`
|
|
115
|
+
`);E.trim()&&u.push({id:M,name:F,type:N,paragraphs:j,text:E})}else if(k==="pic"){const T=W(v,"nvPicPr"),N=T?W(T,"cNvPr"):null,M=N?Te(N,"id",""):"",F=N?Te(N,"name",""):"",j=N?Te(N,"descr","")||Te(N,"title",""):"",E=T?W(T,"nvPr"):null;E&&W(E,"extLst"),p.push({id:M,name:F,altText:j,title:F})}else if(k==="graphicFrame"){const T=(()=>{const N=W(v,"graphic"),M=N?W(N,"graphicData"):null;return M?Te(M,"uri",""):""})();if(T.includes("table")||W(v,"tbl")){const N=ga(v);N&&g.push(N)}else if(T.includes("chart")){const N=ma(v);if(N){const M=N.rId?l[N.rId]:null;let F={chartType:"chart",seriesNames:[],categories:[]};if(M&&t[M.fullPath]){const j=new DOMParser().parseFromString(new TextDecoder().decode(t[M.fullPath]),"application/xml");F=ba(j)}b.push({id:N.id,name:N.name,...F})}}}else if(k==="grpSp")for(const T of Xe(v,"sp")){const N=W(T,"txBody");if(!N)continue;const M=os(T),F=as(T),j=ls(T),E=Pn(N),L=E.map(z=>z.text).join(`
|
|
116
|
+
`);L.trim()&&u.push({id:F,name:j,type:M,paragraphs:E,text:L})}}const _=u.find(v=>v.type==="title"),y=u.find(v=>v.type==="subtitle"),w=_?.text||"",x=y?.text||"",P=[w,x,...u.filter(v=>v.type!=="title"&&v.type!=="subtitle").map(v=>v.text),...g.map(v=>v.text),...b.map(v=>[v.name,...v.seriesNames,...v.categories].join(" ")),d].filter(Boolean).join(`
|
|
117
|
+
|
|
118
|
+
`);return{index:e,title:w,subtitle:x,textShapes:u,tables:g,images:p,charts:b,notes:d,text:P}}function va(e){return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:"",text:""}}async function wa(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await cn(t,e));return n}async function ka(e,n){return(await cn(e,n)).text}async function xa(e,n){const t=e.toLowerCase().trim();if(!t)return[];const s=[];for(let i=0;i<n.slideCount;i++){const r=await cn(i,n),o=r.text.toLowerCase();if(!o.includes(t))continue;const l=[];let a=0;for(;(a=o.indexOf(t,a))!==-1;){const d=Math.max(0,a-60),c=Math.min(r.text.length,a+t.length+60),h=r.text.slice(d,a),u=r.text.slice(a,a+t.length),g=r.text.slice(a+t.length,c);if(l.push({before:(d>0?"…":"")+h,match:u,after:g+(c<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 _a{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:d}=await Promise.resolve().then(()=>Qo);return{renderTransitionFrame:d}},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(d=>{const c=h=>{const u=Math.min(1,(h-a)/l);s(o,i,r,t,u),u<1?requestAnimationFrame(c):d()};requestAnimationFrame(c)}),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=`
|
|
119
|
+
<span style="opacity:0.7">Slide</span>
|
|
120
|
+
<strong>${this._index+1}</strong>
|
|
121
|
+
<span style="opacity:0.5">of ${n}</span>
|
|
122
|
+
`}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 Vs(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}async function Pa(e,n,t={}){typeof t=="number"&&(t={width:t});const{width:s=null,dpi:i=150}=t,r=s??Vs(n,i),o=await Ys(e,n,r),l=o.toDataURL("image/png");if(navigator.clipboard&&window.ClipboardItem)try{const d=await new Promise(c=>o.toBlob(c,"image/png"));return await navigator.clipboard.write([new ClipboardItem({"image/png":d})]),{success:!0,method:"clipboard-api",dataUrl:l}}catch(d){if(d.name!=="NotAllowedError")throw d}if(document.execCommand)try{const d=new Image;d.src=l,await new Promise(p=>{d.onload=p});const c=document.createElement("div");c.contentEditable="true",c.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;",c.appendChild(d),document.body.appendChild(c);const h=document.createRange();h.selectNodeContents(c);const u=window.getSelection();u.removeAllRanges(),u.addRange(h);const g=document.execCommand("copy");if(document.body.removeChild(c),u.removeAllRanges(),g)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 Hs(e,n,t={},s){typeof t=="number"&&(t={width:t});const{width:i=null,dpi:r=300,filename:o}=t,l=i??Vs(n,r),d=(await Ys(e,n,l)).toDataURL("image/png"),c=o||`slide-${e+1}.png`,h=document.createElement("a");h.href=d,h.download=c,h.click()}async function Sa(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 Hs(l,e,i),r?.(l+1,o),await new Promise(a=>setTimeout(a,100))}async function Ys(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 Ta(e,n,t={}){const{thumbWidth:s=320,fullWidth:i=1280,gap:r="24px",background:o="#1a1a1a",slideBackground:l="#fff",shadow:a=!0,clickToShow:d=!1,maxWidth:c="900px",rootMargin:h=200,onSlideVisible:u,onSlideRendered:g}=t,{cx:p,cy:b}=e.slideSize,_=p/b,y=e.slideCount;n.style.cssText=`
|
|
123
|
+
background:${o};
|
|
124
|
+
padding:${r};
|
|
125
|
+
display:flex;
|
|
126
|
+
flex-direction:column;
|
|
127
|
+
align-items:center;
|
|
128
|
+
gap:${r};
|
|
129
|
+
overflow-y:auto;
|
|
130
|
+
position:relative;
|
|
131
|
+
`;const w=[],x=[],P=[];for(let M=0;M<y;M++){const F=document.createElement("div");F.style.cssText=`
|
|
132
|
+
width:100%;
|
|
133
|
+
max-width:${c};
|
|
134
|
+
position:relative;
|
|
135
|
+
background:${l};
|
|
136
|
+
border-radius:4px;
|
|
137
|
+
${a?"box-shadow:0 4px 24px rgba(0,0,0,0.5);":""}
|
|
138
|
+
overflow:hidden;
|
|
139
|
+
aspect-ratio:${p}/${b};
|
|
140
|
+
flex-shrink:0;
|
|
141
|
+
`,F.setAttribute("data-slide",M);const j=document.createElement("div");j.style.cssText=`
|
|
142
|
+
position:absolute;bottom:8px;right:10px;
|
|
143
|
+
background:rgba(0,0,0,0.45);color:#fff;
|
|
144
|
+
font:11px/1.4 system-ui,sans-serif;
|
|
145
|
+
padding:2px 7px;border-radius:10px;
|
|
146
|
+
pointer-events:none;z-index:1;
|
|
147
|
+
`,j.textContent=M+1,F.appendChild(j);const E=document.createElement("canvas");E.style.cssText="display:block;width:100%;height:100%;",E.width=s,E.height=Math.round(s/_),F.appendChild(E);const L=ja(M,p,b,l);F.appendChild(L),d&&(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(E),P.push("pending")}const v=[];let k=!1;async function T(){if(!(k||v.length===0)){for(k=!0;v.length>0;){const M=v.shift();if(P[M]==="full")continue;const F=x[M],E=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",E&&(E.style.display="none"),g?.(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 j=parseInt(F.target.getAttribute("data-slide"),10);if(!(isNaN(j)||P[j]==="full")){u?.(j);for(const E of[j,j-1,j+1,j+2].filter(L=>L>=0&&L<y))P[E]!=="full"&&!v.includes(E)&&v.push(E);T()}}},{root:n,rootMargin:`${h}px`,threshold:0});return w.forEach(M=>N.observe(M)),{destroy(){N.disconnect(),n.innerHTML=""},scrollTo(M,F="smooth"){const j=w[M];j&&j.scrollIntoView({behavior:F,block:"start"})},async renderAll(M){for(let F=0;F<y;F++)P[F]!=="full"&&v.push(F);await T()},getCanvas(M){return x[M]||null},get slideCount(){return y}}}function ja(e,n,t,s){const i=document.createElement("div");i.setAttribute("data-placeholder","1"),i.style.cssText=`
|
|
148
|
+
position:absolute;inset:0;
|
|
149
|
+
display:flex;align-items:center;justify-content:center;
|
|
150
|
+
background:${s};
|
|
151
|
+
flex-direction:column;gap:12px;
|
|
152
|
+
`;const r=`
|
|
153
|
+
<div style="width:55%;height:18px;background:#e0e0e0;border-radius:3px;animation:pulse 1.4s ease-in-out infinite;"></div>
|
|
154
|
+
<div style="width:72%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.1s;"></div>
|
|
155
|
+
<div style="width:62%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.2s;"></div>
|
|
156
|
+
<div style="width:45%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.3s;"></div>
|
|
157
|
+
`;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 Fa{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 Ss(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=_e(i),o=m(r,"sldSz");o&&(this.slideSize={cx:C(o,"cx",9144e3),cy:C(o,"cy",5143500)});const l=await De(this._files,"ppt/presentation.xml");if(this.embeddedFonts=Qr(r,l),this.embeddedFonts.length>0){const h=this.embeddedFonts.map(u=>u.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 u=h.getAttribute("r:id")||h.getAttribute("id"),g=l[u];g&&this.slidePaths.push(g.fullPath)}this.slideCount=this.slidePaths.length,t(.2,"Loading theme…");let d=Object.values(l).find(h=>h.type?.includes("theme"))?.fullPath;if(!d){const h=Object.values(l).find(u=>u.type?.includes("slideMaster"));if(h){const u=await De(this._files,h.fullPath);d=Object.values(u).find(g=>g.type?.includes("theme"))?.fullPath}}if(d){const h=this._readText(d);h&&(this.themeData=qr(_e(h)))}this.themeData||(this.themeData={colors:{},majorFont:"Calibri Light",minorFont:"Calibri"}),this.themeColors={...this.themeData.colors},t(.3,"Loading master…");const c=Object.values(l).find(h=>h.type?.includes("slideMaster"));if(c){const h=this._readText(c.fullPath);if(h){this.masterDoc=_e(h),this.masterRels=await De(this._files,c.fullPath),this.masterImages=await Gt(this._files,this.masterRels),this._trackBlobs(this.masterImages);const u=Kr(this.masterDoc);this.themeColors=Xr(this.themeData,u)}}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=_e(r),l=await De(this._files,i),a=await Gt(this._files,l);this._trackBlobs(a);let d=null,c={},h={};const u=Object.values(l).find(v=>v.type?.includes("slideLayout"));if(u){const v=this._readText(u.fullPath);v&&(d=_e(v),c=await De(this._files,u.fullPath),h=await Gt(this._files,c),this._trackBlobs(h))}const g={...this.masterImages,...h,...a},p=Rs([d,this.masterDoc]),b=to([o,d,this.masterDoc]);await eo(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 Es(w,o,this.masterDoc,d,l,this.masterRels,g,this.themeColors,_,this.slideSize.cx,this.slideSize.cy),await this._renderNonPlaceholders(w,this.masterDoc,this.masterRels,this.masterImages,_),await this._renderNonPlaceholders(w,d,c,h,_);const x=m(o,"cSld"),P=x?m(x,"spTree"):null;P&&await zs(w,P,l,g,this.themeColors,this.themeData,_,p,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 vn(n,t,s)}registerFonts(n){return Yr(n)}listRegisteredFonts(){return no()}_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 d=a.localName;if(!["sp","pic","grpSp","graphicFrame","cxnSp"].includes(d))continue;const c=m(a,"nvSpPr"),h=c?m(c,"nvPr"):null;if(!(h&&m(h,"ph")))try{d==="sp"?await tn(n,a,s,i,this.themeColors,this.themeData,r):d==="pic"?await nn(n,a,s,i,this.themeColors,r):d==="grpSp"?await sn(n,a,s,i,this.themeColors,this.themeData,r):d==="graphicFrame"?await on(n,a,this.themeColors,this.themeData,r):d==="cxnSp"&&await rn(n,a,this.themeColors,r)}catch(u){console.warn(`[PptxRenderer] master/layout shape error (${d}):`,u)}}}getAnimations(n){const t=this.slidePaths[n];if(!t||!this._files)return[];const s=this._files[t];if(!s)return[];const i=_e(new TextDecoder().decode(s));return En(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=_e(new TextDecoder().decode(s));return Rn(i)}createPlayer(n){return new Gs(this,n)}async toSvg(n){return Xs(n,this)}async allToSvg(){return ca(this)}async loadEmbeddedFonts(){const n=this._presRels||{};return ua(this._files,n)}listEmbeddedFonts(){return fa(this._files)}async extractSlide(n){return cn(n,this)}async extractAll(){return wa(this)}async extractText(n){return ka(n,this)}async searchSlides(n){return xa(n,this)}createShow(n,t={}){return new _a(this,n,t)}async copySlide(n,t={}){return Pa(n,this,t)}async downloadSlide(n,t={}){return Hs(n,this,t)}async downloadAllSlides(n={}){return Sa(this,n)}createDeck(n,t={}){return Ta(this,n,t)}edit(){return Ht.fromRenderer(this)}async toPdf(n={}){return $n(this,n)}async downloadPdf(n="presentation.pdf",t={}){return qo(this,n,t)}async slideToPdf(n,t={}){return Ko(n,this,t)}async getSlideNotes(n){if(n<0||n>=this.slidePaths.length)return"";const t=await De(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=_e(i),o=[];for(const l of de(r,"sp")){const a=m(m(l,"nvSpPr"),"nvPr"),d=a?m(a,"ph"):null;if(!(d&&B(d,"type")==="sldNum"))for(const c of de(l,"t"))o.push(c.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 Ca=({asset:e,bytes:n,onOpenExternal:t,dense:s=!1})=>{const i=D.useRef(null),r=D.useRef(null),[o,l]=D.useState({phase:"loading",progress:0}),[a,d]=D.useState(0),[c,h]=D.useState(1),[u,g]=D.useState(0),[p,b]=D.useState(!1),[_,y]=D.useState([]),[w,x]=D.useState(!s),P=D.useRef(null),[v,k]=D.useState(!1);D.useEffect(()=>{x(!s)},[s]),D.useLayoutEffect(()=>{const F=P.current;if(!F)return;const j=()=>k(F.getBoundingClientRect().height<360);j();const E=new ResizeObserver(j);return E.observe(F),()=>E.disconnect()},[]),D.useEffect(()=>{let F=!1;const j=new Fa;return i.current=j,l({phase:"loading",progress:0}),d(0),h(1),j.load(n,E=>{F||l({phase:"loading",progress:E})}).then(async()=>{if(F)return;const E=j.slideCount,z=(await j.renderAllSlides(160)).map(Q=>Q.toDataURL("image/png"));F||l({phase:"ready",slideCount:E,thumbnails:z})}).catch(E=>{F||l({phase:"error",detail:E instanceof Error&&E.message?E.message:S("ui.library.preview.pptx_failed_detail")})}),()=>{F=!0,j.destroy(),i.current=null}},[n,u]);const T=D.useCallback(async()=>{const F=i.current,j=r.current;if(!(!F||!j||o.phase!=="ready"))try{await F.renderSlide(a,j,Math.round(960*c))}catch(E){l({phase:"error",detail:E instanceof Error&&E.message?E.message:S("ui.library.preview.pptx_failed_detail")})}},[a,o.phase,c]);D.useEffect(()=>{T()},[T]),D.useEffect(()=>{const F=i.current;if(!F||o.phase!=="ready")return;let j=!1;return F.extractSlide(a).then(E=>{j||y(E.textShapes.map(L=>L.text.trim()).filter(Boolean))}).catch(()=>{j||y([])}),()=>{j=!0}},[a,o.phase]);const N=o.phase==="ready"?o.slideCount:0,M=F=>{N!==0&&d(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:S("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(K,{variant:"secondary",size:"sm",onClick:()=>g(F=>F+1),children:S("ui.library.preview.retry")}),f.jsxs(K,{variant:"secondary",size:"sm",disabled:p,onClick:()=>{b(!0),at(e).catch(F=>je(F instanceof Error&&F.message?F.message:S("ui.library.menu.save_failed"))).finally(()=>b(!1))},children:[f.jsx(rt,{"aria-hidden":"true"}),S("ui.library.menu.download")]}),t&&f.jsxs(K,{variant:"ghost",size:"sm",onClick:t,children:[f.jsx(gs,{"aria-hidden":"true"}),S("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(Bi,{value:Math.round(o.progress*100)}),f.jsx("span",{className:"text-meta text-ink-muted",children:S("ui.library.preview.pptx_preparing")})]}):f.jsx("canvas",{ref:r,className:"max-h-full max-w-full rounded-xs bg-surface","aria-label":S("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,j)=>f.jsx("button",{type:"button",onClick:()=>d(j),"aria-pressed":j===a,"aria-label":S("ui.library.preview.go_to_slide",{index:String(j+1)}),className:qe("h-16 w-24 shrink-0 rounded-xs border p-0.5",j===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"})},j))})]}),o.phase==="ready"&&f.jsxs("div",{className:"shrink-0 rounded-md bg-canvas px-2 py-1","data-pptx-transcript":"",children:[s?f.jsx(K,{variant:"ghost",size:"sm","aria-expanded":w,onClick:()=>x(F=>!F),children:S("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,j)=>f.jsx("p",{"data-pptx-transcript-line":"",className:"truncate",children:F},`${j}:${F}`)):f.jsx("p",{children:S("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(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.previous_slide"),disabled:a===0||o.phase!=="ready",onClick:()=>M(a-1),children:f.jsx(Fn,{"aria-hidden":"true"})}),f.jsx("span",{className:"text-meta tabular-nums text-ink-muted",children:S("ui.library.preview.slide_of",{index:String(N?a+1:0),count:String(N)})}),f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.next_slide"),disabled:a>=N-1||o.phase!=="ready",onClick:()=>M(a+1),children:f.jsx(Oi,{"aria-hidden":"true"})})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.zoom_out"),onClick:()=>h(F=>Math.max(.5,F-.25)),children:f.jsx(_i,{"aria-hidden":"true"})}),f.jsxs("span",{className:"w-10 text-center text-meta tabular-nums text-ink-muted",children:[Math.round(c*100),"%"]}),f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.zoom_in"),onClick:()=>h(F=>Math.min(2,F+.25)),children:f.jsx(Pi,{"aria-hidden":"true"})}),f.jsx(K,{variant:"ghost",size:"sm",onClick:()=>h(1),disabled:c===1,children:S("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??S("ui.library.preview.loading")]}),ft=({detail:e,asset:n})=>{const[t,s]=D.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:S("ui.library.preview.could_not_load")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:e}),f.jsxs(K,{variant:"secondary",size:"sm",disabled:t,onClick:()=>{s(!0),at(n).catch(i=>je(i instanceof Error&&i.message?i.message:S("ui.library.menu.save_failed"))).finally(()=>s(!1))},children:[f.jsx(rt,{"aria-hidden":"true"}),S("ui.library.menu.download")]})]})},cs=({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:S("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(K,{variant:"secondary",size:"sm",onClick:()=>{e.ref.path&&window.api.openFile(e.ref.path)},children:S("ui.library.preview.open_externally")}):null,f.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>void at(e),children:[f.jsx(rt,{"aria-hidden":"true"}),S("ui.library.menu.download")]})]})]}),Ma=({asset:e})=>{const{bytes:n,mimeType:t,error:s,loading:i}=et(e.id,"content",!0),r=Nn(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 h-full min-h-0 w-full min-w-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:"block h-auto max-h-full w-auto 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 h-full min-h-0 w-full min-w-0 flex-1 items-center justify-center overflow-hidden 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"})})})}},Na=({asset:e})=>{const{bytes:n,mimeType:t,error:s,loading:i}=et(e.id,"content",!0),r=Nn(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})},Aa=({asset:e,text:n})=>{const t=e.ref.type==="path"&&!!e.ref.path&&e.exists,s=e.ref.path,[i,r]=D.useState({state:"pending"});D.useEffect(()=>{if(!t||!s)return;let l=!1;return ni(s).then(a=>{l||r({state:"done",mtimeMs:a?.mtimeMs??null})}),()=>{l=!0}},[t,s]);const o=D.useMemo(()=>!t||!s||i.state!=="done"?null:Or(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:S("ui.library.preview.checking_file")})}):o?f.jsx("div",{"data-lo-pane-edge-cues":!0,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:S("ui.library.preview.breadcrumb",{name:o.title})}),f.jsx(si,{document:o})]})}):f.jsx("div",{"data-lo-pane-edge-cues":!0,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:S("ui.library.preview.read_only_markdown")}),f.jsx("div",{className:"prose-lo max-w-none text-body text-ink",children:f.jsx(Si,{remarkPlugins:[Ti],children:n})})]})})},$a=({asset:e})=>{const{bytes:n,error:t,loading:s}=et(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(Aa,{asset:e,text:i}):f.jsx("pre",{"data-lo-pane-edge-cues":!0,className:"min-h-0 flex-1 overflow-auto p-4 font-mono text-mono-sm whitespace-pre-wrap break-words text-ink",children:i})},Ea=({asset:e})=>{const{bytes:n,error:t,loading:s}=et(e.id,"content",!0);return s?f.jsx(ut,{}):t||!n?f.jsx(ft,{detail:t||"The bytes were empty.",asset:e}):f.jsx(Ra,{asset:e,bytes:n})},ds=200,us=40,Ra=({asset:e,bytes:n})=>{const t=(()=>{try{const r=ii(n,{type:"array"}),o=r.SheetNames[0];if(!o)return null;const l=ri.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:S("ui.library.preview.sheet_unreadable"),asset:e});const s=t.rows.slice(0,ds),i=t.rows.length>ds;return f.jsxs("div",{"data-lo-pane-edge-cues":!0,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,us).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,us).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:S("ui.library.preview.sheet_truncated")}),f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:S("ui.library.preview.sheet_name",{name:t.name})})]})},Ia=({asset:e,dense:n=!1})=>e.kind==="pptx"?f.jsx(za,{asset:e,dense:n}):e.kind==="image"||e.kind==="audio"||e.kind==="video"?f.jsx(Ma,{asset:e}):e.kind==="pdf"||e.kind==="html"?f.jsx(Na,{asset:e}):e.kind==="markdown"||e.kind==="text"||e.kind==="code"?f.jsx($a,{asset:e}):e.kind==="spreadsheet"?f.jsx(Ea,{asset:e}):e.kind==="docx"?f.jsx(cs,{asset:e}):f.jsx(cs,{asset:e}),za=({asset:e,dense:n=!1})=>{const{bytes:t,error:s,loading:i}=et(e.id,"content",!0);return i?f.jsx(ut,{label:S("ui.library.preview.pptx_opening")}):s||!t?f.jsx(ft,{detail:s||"The bytes were empty.",asset:e}):f.jsx(Ca,{asset:e,bytes:t,dense:n})};function La(e){const n=vr(!0),t=kr().create,s=wr(),[i,r]=D.useState(!1);return{commit:async l=>{r(!0);try{const a=new Map([...n.data??[],...e.tags].map(c=>[c.name.toLowerCase(),c.id])),d=[];for(const c of l){const h=c.trim().toLowerCase();if(!h)continue;let u=a.get(h);u||(u=(await t.mutateAsync({name:h})).id,a.set(h,u)),d.includes(u)||d.push(u)}await s.mutateAsync({id:e.id,tags:d})}catch(a){je(a instanceof Error&&a.message?a.message:S("ui.library.preview.tags_not_saved"))}finally{r(!1)}},saving:i}}const fs=({asset:e,nowMs:n,onClose:t,onOpenConversation:s,onFilterSession:i,onAsk:r,onToggleFavorite:o,composerFocusSignal:l,focusRequest:a,standalone:d=!1,onExpand:c})=>{Cn();const h=ks(),{commit:u,saving:g}=La(e),p=D.useRef(null),b=D.useRef(null),_=D.useRef(null),[y,w]=D.useState(!1),[x,P]=D.useState(!1);D.useLayoutEffect(()=>{const M=p.current;if(!M)return;const F=()=>w(M.getBoundingClientRect().height<700);F();const j=new ResizeObserver(F);return j.observe(M),()=>j.disconnect()},[]);const v=D.useMemo(()=>e.tags.map(M=>M.name),[e.tags]);D.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 je(F instanceof Error&&F.message?F.message:S("ui.library.preview.not_saved")),F}},T=async M=>{try{await h.mutateAsync({id:e.id,fields:{[M]:!e[M]}})}catch(F){je(F instanceof Error&&F.message?F.message:S("ui.library.preview.not_saved"))}},N=()=>{if(e.ref.type==="path"&&e.ref.path){window.api.openFile(e.ref.path);return}at(e).catch(()=>je(S("ui.library.menu.save_failed")))};return f.jsxs("div",{ref:p,className:"flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-surface","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:[d&&f.jsxs(K,{variant:"ghost",size:"sm",className:"self-start",onClick:t,children:[f.jsx(Fn,{"aria-hidden":"true"}),S("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(Ln,{label:S("ui.library.preview.name"),value:St(e),onSave:M=>k({name:M}),isSaving:h.isPending})}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[f.jsx(Dt,{content:e.favorite?S("ui.library.menu.unfavorite"):S("ui.library.menu.favorite"),children:f.jsx(K,{variant:"ghost",size:"icon-sm","aria-pressed":e.favorite,"aria-label":e.favorite?S("ui.library.menu.unfavorite"):S("ui.library.menu.favorite"),onClick:()=>void T("favorite"),children:f.jsx(xt,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0})})}),f.jsx(Dt,{content:e.locked?S("ui.library.preview.unlock"):S("ui.library.preview.lock"),children:f.jsx(K,{variant:"ghost",size:"icon-sm","aria-pressed":e.locked,"aria-label":e.locked?S("ui.library.preview.unlock"):S("ui.library.preview.lock"),onClick:()=>void T("locked"),children:e.locked?f.jsx(oi,{"aria-hidden":"true",className:"text-accent"}):f.jsx(ai,{"aria-hidden":"true"})})}),c&&f.jsx(Dt,{content:S("ui.library.preview.expand"),children:f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.expand"),onClick:c,children:f.jsx(ji,{"aria-hidden":"true"})})}),f.jsx(An,{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(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.close"),onClick:t,children:f.jsx(ot,{"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:S(Zt(e.origin_group))}),f.jsx("span",{children:Mn(e.size_bytes)}),e.width&&e.height?f.jsxs("span",{children:[e.width,"×",e.height]}):null,e.organized?f.jsx("span",{children:S("ui.library.preview.organized_by",{by:e.organized.by??"librarian",at:hr(e.organized.at,n)})}):f.jsx("span",{children:S("ui.library.preview.unorganized")}),e.exists?null:f.jsx(st,{variant:"warning",children:S("ui.library.preview.missing_file")})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs(K,{variant:"secondary",size:"sm",onClick:N,children:[f.jsx(gs,{"aria-hidden":"true"}),S("ui.library.preview.open")]}),e.ref.type==="path"&&e.ref.path?f.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(mn,{"aria-hidden":"true"}),S("ui.library.preview.reveal")]}):null,f.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>void at(e).then(()=>bn(S("ui.library.menu.saved_a_copy"))).catch(()=>je(S("ui.library.menu.save_failed"))),children:[f.jsx(rt,{"aria-hidden":"true"}),S("ui.library.preview.download")]}),e.occurrences[0]?f.jsx(K,{variant:"link",size:"sm",className:"h-auto max-w-full min-w-0 justify-start whitespace-normal text-left",title:`${S("ui.library.preview.from_conversation",{title:e.occurrences[0].session_title||e.occurrences[0].session_id})}`,onClick:()=>s(e.occurrences[0].session_id),children:f.jsx("span",{className:"line-clamp-2 break-words",children:S("ui.library.preview.from_conversation",{title:e.occurrences[0].session_title||e.occurrences[0].session_id})})}):null]}),y&&f.jsxs(K,{variant:"ghost",size:"sm",className:"self-start","aria-expanded":x,onClick:()=>P(M=>!M),children:[f.jsx(Ui,{"aria-hidden":"true",className:qe("transition-transform duration-fast",x&&"rotate-180")}),S("ui.library.preview.details")]}),(!y||x)&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex flex-col gap-1",children:f.jsx(Ln,{label:S("ui.library.preview.description"),value:e.description,multiline:!0,rows:3,placeholder:S("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(Vi,{label:S("ui.library.preview.tags"),value:v,disabled:g,onChange:M=>void u(M),placeholder:S("ui.library.preview.add_tag")})}),g&&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 min-w-0 flex-1 flex-col overflow-hidden bg-sunken",children:f.jsx(Ia,{asset:e,dense:y})}),f.jsx("div",{className:"shrink-0",children:f.jsx(Br,{asset:e,focusSignal:l,compact:y})})]})},Qs="library-view",Zs="library-filters",Da=1152,Ba=1200,Oa=900;function Ua(){try{return localStorage.getItem(Qs)==="list"?"list":"grid"}catch{return"grid"}}function Ga(){try{const e=sessionStorage.getItem(Zs);if(!e)return Bt;const n=JSON.parse(e);return{...Bt,...n,scope:n.scope==="all"?"all":"final",q:""}}catch{return Bt}}function Wa(e){try{sessionStorage.setItem(Zs,JSON.stringify({...e,q:""}))}catch{}}function qa(){const[e,n]=D.useState(null),[t,s]=D.useState(0);return D.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 Ka(){const[e,n]=D.useState(()=>window.innerWidth);return D.useEffect(()=>{const t=()=>n(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e}const Xa=({enabled:e,nowMs:n})=>{const t=ws(e),s=Pr(),i=jn(),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:S("ui.library.librarian.title")}),f.jsx("span",{children:r.paused?S("ui.library.librarian.paused"):r.enabled?S("ui.library.librarian.enabled"):S("ui.library.librarian.disabled")}),f.jsx("span",{children:o?S("ui.library.librarian.last_organized",{at:Va(o,n)}):S("ui.library.librarian.never_run")}),l!==null&&l>0&&f.jsx("span",{children:S("ui.library.librarian.unorganized",{count:l})}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[f.jsxs(K,{variant:"ghost",size:"sm",disabled:!r.enabled||s.isPending,onClick:()=>s.mutate("run",{onError:a=>je(a instanceof Error?a.message:S("ui.library.librarian.control_failed"))}),children:[f.jsx(gn,{"aria-hidden":"true"}),S("ui.library.librarian.organize_now")]}),f.jsx(K,{variant:"ghost",size:"sm",disabled:!r.session_id||s.isPending,onClick:()=>s.mutate("open",{onSuccess:a=>{a?.session_id&&pt(i,a.session_id)},onError:a=>je(a instanceof Error?a.message:S("ui.library.librarian.control_failed"))}),children:S("ui.library.librarian.open")})]})]})};function Va(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 Ha=({onBack:e})=>f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Lt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:S("ui.library.preview.unavailable")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:S("ui.library.preview.unavailable_detail")}),f.jsxs(K,{variant:"secondary",size:"sm",onClick:e,children:[f.jsx(Fn,{"aria-hidden":"true"}),S("ui.library.page.back")]})]}),Ya=({nowMs:e})=>{Cn();const n=Fi("surface"),t=jn(),s=Ci(),i=Mi(),r=Ni(),o=Ai(r.data,"library",1),l=ws(o),a=e??Date.now(),{ref:d,width:c}=qa(),h=Ka(),u=new URLSearchParams(s.search).get("full")==="1",g=h>=Ba&&c>=Oa,[p,b]=D.useState(Ga),[_,y]=D.useState(""),w=li(_,200),[x,P]=D.useState(Ua),[v,k]=D.useState(!1),[T,N]=D.useState(0),[M,F]=D.useState(null),j=D.useRef(null),E=i.assetId??null,L=c>=Da&&!!E&&!u;D.useEffect(()=>{b($=>$.q===w?$:{...$,q:w})},[w]),D.useEffect(()=>Wa(p),[p]),D.useEffect(()=>{try{localStorage.setItem(Qs,x)}catch{}},[x]);const z=br(p,o),Q=ks(),G=yr(E,o),O=D.useMemo(()=>{const $=z.data?.pages??[],te=$.length>1&&$.at(-1)?.cursor_reset?[$.at(-1)]:$,se=new Set,he=[];for(const ke of te)for(const Pe of ke?.rows??[])se.has(Pe.id)||(se.add(Pe.id),he.push(Pe));return he},[z.data]),q=z.data?.pages.at(-1),Z=q?.total??0,J=O.find($=>$.id===E)??null,R=G.data??J,H=()=>void z.fetchNextPage(),ie=!!(E&&!R&&!G.isLoading&&G.isError),re=!!E&&!L,ce=D.useCallback($=>{t(`/library/assets/${$}${s.search}`,{state:s.state})},[t,s.search,s.state]),ne=D.useCallback(()=>{const $=new URLSearchParams(s.search);$.delete("full");const U=$.toString();t(`/library${U?`?${U}`:""}`)},[t,s.search]),X=D.useCallback(()=>{if(!E)return;const $=new URLSearchParams(s.search);$.set("full","1"),t(`/library/assets/${E}?${$.toString()}`)},[t,E,s.search]),xe=D.useCallback($=>{ce($.id),N(U=>U+1)},[ce]),oe=D.useCallback($=>{Q.mutate({id:$.id,fields:{favorite:!$.favorite}})},[Q]),ae=D.useCallback($=>void pt(t,$),[t]),ue=D.useCallback($=>{b(U=>({...U,session:$})),t("/library")},[t]),ve={onSelect:ce,onAsk:xe,onEditMetadata:$=>{ce($.id),F({field:"metadata",signal:Date.now()})},onEditTags:$=>{ce($.id),F({field:"tags",signal:Date.now()})},onToggleFavorite:oe,onOpenConversation:ae,onFilterSession:ue};if(D.useEffect(()=>{const $=U=>{const te=U.target,se=te?.tagName==="INPUT"||te?.tagName==="TEXTAREA"||te?.isContentEditable;if(U.key==="f"&&(U.metaKey||U.ctrlKey)||U.key==="/"&&!se){U.preventDefault(),j.current?.focus();return}if(!(se||U.metaKey||U.ctrlKey||U.altKey)){if(U.key==="Escape"){(E||R)&&ne();return}if(U.key.toLowerCase()==="g"){U.preventDefault(),P(he=>he==="grid"?"list":"grid");return}if(U.key.toLowerCase()==="j"||U.key.toLowerCase()==="k"){if(re||O.length===0)return;U.preventDefault();const he=E?O.findIndex(Me=>Me.id===E):-1,ke=U.key.toLowerCase()==="j"?1:-1,Pe=Math.min(Math.max(he===-1?ke===1?0:O.length-1:he+ke,0),O.length-1);ce(O[Pe].id)}}};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[ne,ce,O,R,E,re]),!o)return f.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[f.jsx(Ri,{title:S("ui.library.page.title"),icon:Lt}),r.isLoading?f.jsx("div",{className:"flex justify-center py-16",children:f.jsx(Un,{label:S("ui.library.page.checking")})}):f.jsx(fn,{variant:"warning",children:S("ui.library.page.unavailable")})]});const we=l.data?.library?.total??null,be=f.jsx(Rr,{filters:p,onChange:$=>{b({...$,q:$.q}),y($.q)},counts:q?.counts,tags:q?.tags??[],total:Z,scopeTotal:we}),fe=O.length===0&&!z.isLoading,I=dr(p)||!!_.trim(),V=(()=>{const $=[];if(_.trim()&&$.push({key:"search",label:`${S("ui.library.page.search")}: ${_.trim()}`,clear:()=>y("")}),p.category){const U=yn.find(te=>te.key===p.category);$.push({key:"category",label:U?S(U.labelKey):p.category,clear:()=>b(te=>({...te,category:void 0}))})}if(p.originGroup&&$.push({key:"origin",label:S(Zt(p.originGroup)),clear:()=>b(U=>({...U,originGroup:void 0}))}),p.status){const U=p.status==="highlighted"?"ui.library.status.highlighted":p.status==="unorganized"?"ui.library.status.unorganized":"ui.library.status.favorites";$.push({key:"status",label:S(U),clear:()=>b(te=>({...te,status:void 0}))})}return p.highlighted&&p.status!=="highlighted"&&$.push({key:"highlighted",label:S("ui.library.status.highlighted"),clear:()=>b(U=>({...U,highlighted:!1}))}),p.tag&&$.push({key:"tag",label:`${S("ui.library.filter.tags")}: ${p.tag}`,clear:()=>b(U=>({...U,tag:void 0}))}),p.session&&$.push({key:"session",label:S("ui.library.filter.one_conversation"),clear:()=>b(U=>({...U,session:void 0}))}),(p.scope!=="final"||$.length>0)&&$.push({key:"scope",label:`${S("ui.library.filter.scope")}: ${p.scope==="all"?S("ui.library.filter.scope_all"):S("ui.library.filter.scope_final")}`,clear:()=>b(U=>({...U,scope:"final"}))}),$})(),Y=()=>{b($=>({...Bt,scope:$.scope,sort:$.sort,order:$.order})),y("")},ee=z.error instanceof Error&&z.error.message?z.error.message:S("ui.library.page.load_failed");return f.jsxs("div",{ref:d,"data-glass-region":"canvas","data-glass-split":"",className:"flex h-full min-h-0 overflow-hidden bg-canvas",children:[g&&!re&&f.jsx("aside",{ref:n,"data-library-rail":"","data-glass-region":"page-sidebar","aria-label":S("ui.library.page.filters"),className:"flex h-full w-48 shrink-0 flex-col overflow-hidden bg-surface",children:be}),!re&&f.jsxs("div",{"data-glass-region":"canvas-content",className:"flex min-w-0 flex-1 flex-col",children:[f.jsxs("header",{"data-library-header":"",className:"flex shrink-0 flex-col gap-1 px-6 pt-4 pb-2 min-[800px]:min-h-[136px]",children:[f.jsxs("div",{className:"flex h-12 min-w-0 items-center gap-2",children:[f.jsx(Lt,{size:20,"aria-hidden":"true",className:"text-ink-muted"}),f.jsx("h1",{className:"text-title text-ink",children:S("ui.library.page.title")}),f.jsx("span",{className:"ml-2 text-meta tabular-nums text-ink-dim",children:S("ui.library.page.loaded_count",{loaded:String(O.length),total:String(Z)})}),f.jsxs("div",{className:"ml-auto flex items-center rounded-sm border border-control",children:[f.jsx(K,{variant:"ghost",size:"icon-sm","aria-pressed":x==="grid","aria-label":S("ui.library.page.grid_view"),onClick:()=>P("grid"),children:f.jsx($i,{"aria-hidden":"true"})}),f.jsx(K,{variant:"ghost",size:"icon-sm","aria-pressed":x==="list","aria-label":S("ui.library.page.list_view"),onClick:()=>P("list"),children:f.jsx(ci,{"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(Ei,{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(Gi,{ref:j,value:_,onChange:$=>y($.target.value),onKeyDown:$=>{$.key==="Enter"&&$.preventDefault()},placeholder:S("ui.library.page.search"),"aria-label":S("ui.library.page.search"),"data-library-search":"",className:"border-0 bg-elevated pl-8"})]}),f.jsxs(ms,{children:[f.jsx(bs,{asChild:!0,children:f.jsxs(K,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",children:[f.jsx(Gn,{"aria-hidden":"true"}),S("ui.library.page.sort")]})}),f.jsx(ys,{align:"end",className:"min-w-45",children:lr.map($=>f.jsxs(Ne,{onSelect:()=>b(U=>({...U,sort:$.key,order:cr($.key)})),children:[p.sort===$.key?f.jsx(Wi,{"aria-hidden":"true"}):f.jsx("span",{className:"size-4"}),f.jsx("span",{children:S($.labelKey)})]},$.key))})]}),f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.page.reverse_order"),onClick:()=>b($=>({...$,order:$.order==="asc"?"desc":"asc"})),children:p.order==="asc"?f.jsx(er,{"aria-hidden":"true"}):f.jsx(Gn,{"aria-hidden":"true"})}),!g&&!re&&f.jsxs(K,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",onClick:()=>k(!0),children:[f.jsx(di,{"aria-hidden":"true"}),S("ui.library.page.filters")]})]}),V.length>0&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[V.map(($,U)=>f.jsxs("span",{className:"contents",children:[U>0&&f.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"+"}),f.jsxs("span",{className:"inline-flex h-7 max-w-full items-center gap-1 rounded-sm bg-elevated px-2 text-meta text-ink-muted",children:[f.jsx("span",{className:"min-w-0 truncate",children:$.label}),f.jsx("button",{type:"button","aria-label":`${S("ui.library.filter.clear_filters")} — ${$.label}`,onClick:$.clear,className:"inline-flex size-6 shrink-0 items-center justify-center rounded-xs text-ink-dim hover:bg-row-hover hover:text-ink",children:f.jsx(ot,{size:12,"aria-hidden":"true"})})]})]},$.key)),f.jsx(K,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-meta",onClick:Y,children:S("ui.library.page.clear_all")})]}),f.jsx("div",{"data-library-librarian-track":"",className:"min-h-10 shrink-0",children:f.jsx(Xa,{enabled:o,nowMs:a})}),q?.state==="building"&&f.jsx("div",{"data-library-building":"",className:"flex h-4 items-center gap-2 text-meta text-ink-muted","aria-live":"polite",children:f.jsx("span",{children:S("ui.library.page.building",{scanned:String(q.scan.sessions_scanned),total:String(q.scan.sessions_total)})})})]}),f.jsx("div",{className:"flex min-h-0 flex-1",children:f.jsx("div",{className:"flex min-w-0 flex-1",children:!re&&f.jsx("section",{"data-library-results":"","aria-label":S("ui.library.page.results"),"aria-busy":z.isLoading||z.isFetching,className:"min-w-0 flex-1 overflow-y-auto px-4 py-4 [scrollbar-gutter:stable]",children:z.isLoading?f.jsx($r,{view:x}):z.isError&&O.length===0?f.jsxs("div",{className:"flex flex-col items-start gap-3 py-10",children:[f.jsx(fn,{variant:"warning",children:ee}),f.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>void z.refetch(),children:[f.jsx(gn,{"aria-hidden":"true"}),S("ui.library.page.retry")]})]}):fe?f.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-center",children:[f.jsx(Lt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:I?`${S("ui.library.page.no_matches")}: ${V.map($=>$.label).join(" + ")}`:S("ui.library.page.empty_title")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:I?S("ui.library.page.no_matches_detail"):S("ui.library.page.empty_detail")}),I&&f.jsx(K,{variant:"secondary",size:"sm",onClick:Y,children:S("ui.library.page.clear_all")})]}):f.jsxs(f.Fragment,{children:[z.isRefetchError&&f.jsx(fn,{variant:"warning",role:"alert","data-library-partial-error":"",className:"mb-3 items-center gap-2 py-2",children:f.jsxs("div",{"data-library-partial-row":"",className:"flex w-full min-w-0 items-center gap-2",children:[f.jsx("span",{className:"min-w-0 flex-1",children:ee}),f.jsxs(K,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void z.refetch(),children:[f.jsx(gn,{"aria-hidden":"true"}),S("ui.library.page.retry")]})]})}),f.jsx(Ar,{assets:O,selectedId:E,view:x,hasMore:!!z.hasNextPage,loadingMore:z.isFetchingNextPage,onLoadMore:H,...ve}),z.isFetchNextPageError&&f.jsxs("div",{className:"flex items-center gap-2 py-3 text-meta text-ink-muted",children:[f.jsx("span",{children:S("ui.library.page.load_more_failed")}),f.jsx(K,{variant:"ghost",size:"sm",onClick:H,children:S("ui.library.page.retry")})]})]})})})})]}),L&&R&&f.jsx("aside",{className:"flex h-full w-[448px] shrink-0 bg-surface","aria-label":S("ui.library.page.preview"),children:f.jsx(fs,{asset:R,nowMs:a,onClose:ne,onOpenConversation:ae,onFilterSession:ue,onAsk:()=>N($=>$+1),onToggleFavorite:()=>oe(R),composerFocusSignal:T,focusRequest:M,onExpand:X})}),re&&f.jsx("div",{className:"min-w-0 flex-1","aria-label":S("ui.library.page.preview"),children:ie?f.jsx(Ha,{onBack:ne}):R?f.jsx(fs,{asset:R,nowMs:a,onClose:ne,onOpenConversation:ae,onFilterSession:ue,onAsk:()=>N($=>$+1),onToggleFavorite:()=>oe(R),composerFocusSignal:T,focusRequest:M,standalone:!0}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(Un,{label:S("ui.library.preview.loading")})})}),!re&&!R&&L&&f.jsx("div",{className:"hidden h-full w-[448px] shrink-0 items-start justify-center bg-surface p-8 lg:flex",children:f.jsx("p",{className:"max-w-60 text-center text-body-sm text-ink-dim",children:S("ui.library.page.select_asset")})}),f.jsx(qi,{open:v,onOpenChange:k,children:f.jsx(Ki,{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:S("ui.library.page.filters")}),f.jsx(K,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.page.close_filters"),onClick:()=>k(!1),children:f.jsx(ot,{"aria-hidden":"true"})})]}),f.jsx("div",{"data-library-filter-sheet":"",className:"min-h-0 flex-1 overflow-y-auto bg-surface",children:be})]})})})]})},ol=Object.freeze(Object.defineProperty({__proto__:null,LibraryPage:Ya},Symbol.toStringTag,{value:"Module"}));export{de as a,B as b,m as g,ol as l};
|