local-operator-ui 0.42.2 → 0.42.4
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 +2344 -173
- package/out/preload/browser-approvals-overlay.js +15 -0
- package/out/preload/index.js +45 -1
- package/out/renderer/assets/{_basePickBy-BA9uepHv.js → _basePickBy-CvLnUv7q.js} +1 -1
- package/out/renderer/assets/{_baseUniq-CVACH15m.js → _baseUniq-BKrt6A4N.js} +1 -1
- package/out/renderer/assets/{agent-details-page-xNTNJ7kP.js → agent-details-page-BWSojjKJ.js} +2 -2
- package/out/renderer/assets/{agent-hub-page-B-zE3Ln0.js → agent-hub-page-aubDNr6m.js} +1 -1
- package/out/renderer/assets/agents-page-DeOCoJow.js +7 -0
- package/out/renderer/assets/{approvalsOverlay-BBr6f98F.css → approvalsOverlay-CX3DxhSv.css} +1 -1
- package/out/renderer/assets/approvalsOverlay-jdsSQYbC.js +1 -0
- package/out/renderer/assets/{arc-DYIy54Kn.js → arc-Bo9HqcA4.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CmfaKw-J.js → architectureDiagram-IEHRJDOE-CjpgkGSs.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-bQf90tJr.js → blockDiagram-JOT3LUYC-CkF9oOcr.js} +1 -1
- package/out/renderer/assets/{book-open-iGajLTwQ.js → book-open-CPvwVqAp.js} +1 -1
- package/out/renderer/assets/browser-page-DUwB_Shx.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-DX5l4JNA.js → browser-webauthn-prompt-D90b-ibP.js} +1 -1
- package/out/renderer/assets/{building-2-bjja6JTC.js → building-2-CTbbzJRN.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-BxIFIYVW.js → c4Diagram-VJAJSXHY-Br-J2zii.js} +1 -1
- package/out/renderer/assets/channel-bs4gvJO_.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-C2LQ_mlD.js → chunk-4BMEZGHF-Cch4oIqI.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-BKH53MbC.js → chunk-A2AXSNBT-BpTLsrEt.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-CuB5dlAL.js → chunk-AEK57VVT-BA_p-1wW.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-CECeg3Wn.js → chunk-D6G4REZN-C85KCEHq.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-D-zkJWYc.js → chunk-RZ5BOZE2-Y0y4RocF.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-DstteBuH.js → chunk-XZIHB7SX-DK_cB1Vj.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-CEJVrd67.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-CEJVrd67.js +1 -0
- package/out/renderer/assets/clone-BAbNoxcV.js +1 -0
- package/out/renderer/assets/{console-mirror-gqAdwBWl.js → console-mirror-BiiClM8r.js} +1 -1
- package/out/renderer/assets/{consoleCapture-BQQVRcXT.js → consoleCapture-OAXBv_kp.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-grry80zS.js → conversation-input-sync-BXv32NfB.js} +253 -253
- package/out/renderer/assets/{dagre-OKDRZEBW-D6RBxeJd.js → dagre-OKDRZEBW-C9TMqwJP.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV--xUREIPn.js → diagram-SSKATNLV-SI8XWzeq.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-BYjZ86BM.js → diagram-VNBRO52H-DnvHZL8L.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CmajcoOO.js → erDiagram-Q7BY3M3F-nWqxZ0l9.js} +1 -1
- package/out/renderer/assets/error-boundary-CqZRoe9S.js +126 -0
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CtQab7ap.js → flowDiagram-4HSFHLVR-DKJUboz2.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CuKez3d0.js → ganttDiagram-APWFNJXF-D0s8LZxz.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-D9QOaWwN.js → gitGraphDiagram-7IBYFJ6S-DOu6eUhN.js} +1 -1
- package/out/renderer/assets/{graph-Ccifoj7G.js → graph-D4HJHitc.js} +1 -1
- package/out/renderer/assets/{hash-EZ0d40pW.js → hash-CzjTtP10.js} +1 -1
- package/out/renderer/assets/{heart-Bo3ZudoI.js → heart-B3mi-jou.js} +1 -1
- package/out/renderer/assets/{index-Dw4hyitu.js → index-CmbVW2m7.js} +1 -1
- package/out/renderer/assets/{index-CLJ4-1jd.js → index-D8glNEcT.js} +1 -1
- package/out/renderer/assets/index-UXcKfWo6.css +1 -0
- package/out/renderer/assets/index-wz2cjW5P.js +830 -0
- package/out/renderer/assets/infoDiagram-PH2N3AL5-DzTCSaMw.js +2 -0
- package/out/renderer/assets/{installer-B7DhTrnG.js → installer-DmYDl1Bg.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-YTjOSo-b.js → journeyDiagram-U35MCT3I-BXdBmrLL.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-C1UmNEaT.js → kanban-definition-NDS4AKOZ-B-oT4qjy.js} +1 -1
- package/out/renderer/assets/{layout-CWPZ7noV.js → layout-C35xWGut.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-ikCownYN.js → legacy-agents-page-zQ2FJ-pr.js} +4 -4
- package/out/renderer/assets/library-page-CB9dDvmn.js +157 -0
- package/out/renderer/assets/{mermaid.core-B_nZt27J.js → mermaid.core-5QYeuhdV.js} +5 -5
- package/out/renderer/assets/mesh-page-SxvMrMpp.js +1 -0
- package/out/renderer/assets/messages-Cq_3N7VC.js +3 -0
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-D-Y3n0RT.js → mindmap-definition-ALO5MXBD-B-cLhV3I.js} +1 -1
- package/out/renderer/assets/{mini-BdCfujvn.js → mini-BH-IxQ6K.js} +1 -1
- package/out/renderer/assets/{notebook-pen-BvZPJ7Yv.js → notebook-pen-FphG2dMG.js} +1 -1
- package/out/renderer/assets/{org-access-C1u_2VVY.js → org-access-DVt3GFMX.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-CyIC6H59.js → org-surface-gate-tHnRzD9A.js} +1 -1
- package/out/renderer/assets/{page-header-C9IFgiIB.js → page-header-B3bOo0UX.js} +1 -1
- package/out/renderer/assets/path-utils-BkJr3--b.js +58 -0
- package/out/renderer/assets/{pieDiagram-IB7DONF6-BJ2PZoWa.js → pieDiagram-IB7DONF6-CrHoOvO2.js} +1 -1
- package/out/renderer/assets/projects-page-ACh1mgoo.js +45 -0
- package/out/renderer/assets/{publication-validation-DAffiuLy.js → publication-validation-D2z_zWQT.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-Dpr0N86G.js → quadrantDiagram-7GDLP6J5-DYDa1ECN.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-CwLLK6fK.js → radar-MK3ICKWK-vDf2Es_C.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-DN7K_uGZ.js → radient-auth-buttons-Di1zLV23.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-LI2fP6nJ.js → requirementDiagram-KVF5MWMF-ChyAHYwK.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-uUOWgFO1.js → sankeyDiagram-QLVOVGJD-D9wd8zQP.js} +1 -1
- package/out/renderer/assets/{schedules-page-Cf1PQGDR.js → schedules-page-BA4nO5Tw.js} +2 -2
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DperbqVG.js → sequenceDiagram-X6HHIX6F-CBIVQtEP.js} +1 -1
- package/out/renderer/assets/{settings-page-CrnST8YF.js → settings-page-D5KhLQHE.js} +3 -3
- package/out/renderer/assets/{smartart-qEAWtDlk.js → smartart-58otsUWh.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-RvRbNkSX.js → stateDiagram-DGXRK772-DxVyPUM2.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BAggpoNG.js +1 -0
- package/out/renderer/assets/team-bridge-page-CJdJd9cs.js +16 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-CeQ3AsWj.js → timeline-definition-BDJGKUSR-DRQlSiWd.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-C_zDZ6-1.js → use-download-agent-mutation-BAzM19BL.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-BMDB4uZ0.js → use-session-snapshot-0k6Oot8j.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-C6-d6maF.js → xychartDiagram-VJFVF3MP-DbSrp_cQ.js} +1 -1
- package/out/renderer/browser-approvals-overlay.html +53 -15
- package/out/renderer/console-capture.html +6 -6
- package/out/renderer/index.html +8 -8
- package/out/renderer/installer.html +5 -5
- package/out/renderer/mini.html +8 -8
- package/package.json +3 -3
- package/out/renderer/assets/agents-page-BeZQ1S7f.js +0 -7
- package/out/renderer/assets/approvalsOverlay-BmSmF8Ga.js +0 -1
- package/out/renderer/assets/browser-page-B63Z8oE2.js +0 -1
- package/out/renderer/assets/channel-Blax8LQd.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DA1IQG_V.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DA1IQG_V.js +0 -1
- package/out/renderer/assets/clone-mVVuLCMS.js +0 -1
- package/out/renderer/assets/error-boundary-DfTTKe65.js +0 -126
- package/out/renderer/assets/index-ByZv232u.css +0 -1
- package/out/renderer/assets/index-LBzSehKd.js +0 -830
- package/out/renderer/assets/infoDiagram-PH2N3AL5-DrTRSok5.js +0 -2
- package/out/renderer/assets/library-page-DBSSkZvn.js +0 -157
- package/out/renderer/assets/mesh-page-CgjL4HIw.js +0 -1
- package/out/renderer/assets/messages-Bswe4yCX.js +0 -3
- package/out/renderer/assets/path-utils-DC6z9Ymz.js +0 -58
- package/out/renderer/assets/projects-page-CwwrR-j7.js +0 -45
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-fK1yLl-v.js +0 -1
- package/out/renderer/assets/team-bridge-page-BgcLwc5M.js +0 -16
- /package/out/renderer/assets/{index-DXk6NfLu.js → index-DhltrflG.js} +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./smartart-58otsUWh.js","./index-DhltrflG.js","./index-UXcKfWo6.css","./console-mirror-BiiClM8r.js","./path-utils-BkJr3--b.js","./messages-Cq_3N7VC.js","./console-mirror-DOrYoP_4.css","./page-header-B3bOo0UX.js","./conversation-input-sync-BXv32NfB.js","./error-boundary-CqZRoe9S.js","./conversation-input-sync-CAX4_ErH.css","./index-wz2cjW5P.js","./index-DHKnfVbX.css","./heart-B3mi-jou.js","./hash-CzjTtP10.js","./use-session-snapshot-0k6Oot8j.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as E,j as f,c as ye}from"./index-DhltrflG.js";import{o as Cs}from"./console-mirror-BiiClM8r.js";import{a3 as Pi,a4 as Vn,a5 as Ti,a6 as ji,a7 as Ci,h as Rn,u as gt,a8 as Ke,d as $e,a9 as In,r as on,a as zn,c as kt,q as Fi,_ as Ni,A as Fs,V as Mi,B as Ai}from"./path-utils-BkJr3--b.js";import{P as $i}from"./page-header-B3bOo0UX.js";import{aq as Xe,bx as Ei,aA as Ri,by as Pn,bz as Ns,bA as Ii,at as ht,ar as Tn,T as Te,bB as Ms,bC as Dt,bD as zi,bE as Li,bF as Di,bG as Ln,bH as Dn,bI as As,br as Hn,ag as Bi,a7 as Oi,a8 as Ui,a9 as Wi,aa as Gi,ai as qi,bJ as Ki,bK as Xi,bL as Vi,bM as Yn,bd as ln,bN as $s,bk as Bn,bO as Hi,bP as Yi,bQ as Es,be as Qi,bg as Zi,bR as Ji,bc as er,bS as Qn}from"./conversation-input-sync-BXv32NfB.js";import{c as At,q as Rs,l as Gt,r as Is,B as J,s as zs,w as Ee,a9 as tr,aa as nr,ab as sr,v as Zn,z as rt,X as Ve,u as ct,S as Tt,x as Ls,ac as ir,y as rr,A as kn,I as ar,g as or,ad as lr,ae as cr}from"./error-boundary-CqZRoe9S.js";import{ck as qt,cl as Jn,aO as On,z as Un,aL as dr,cm as Ds,cn as ur,co as fr,cp as hr,cq as pr,cr as mr,cs as gr,ce as br,ct as Kt,cu as yr,cv as vr,cw as jn}from"./index-wz2cjW5P.js";import{t as S}from"./messages-Cq_3N7VC.js";import{H as cn}from"./heart-B3mi-jou.js";import{H as wr}from"./hash-CzjTtP10.js";import{u as xr}from"./use-session-snapshot-0k6Oot8j.js";var kr=class extends Pi{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:Vn()})}getOptimisticResult(e){return e.behavior=Vn(),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:a,isRefetchError:l}=s,o=t.fetchMeta?.fetchMore?.direction,c=a&&o==="forward",d=i&&o==="forward",h=a&&o==="backward",u=i&&o==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ji(n,t.data),hasPreviousPage:Ti(n,t.data),isFetchNextPageError:c,isFetchingNextPage:d,isFetchPreviousPageError:h,isFetchingPreviousPage:u,isRefetchError:l&&!c&&!h,isRefetching:r&&!d&&!u}}};function _r(e,n){return Ci(e,kr,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 Sr=[["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"}]],es=At("arrow-down-wide-narrow",Sr);/**
|
|
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 Pr=[["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"}]],Tr=At("arrow-up-narrow-wide",Pr);/**
|
|
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 jr=[["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"}]],Cr=At("presentation",jr);/**
|
|
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 Fr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]],Nr=At("sheet",Fr);/**
|
|
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 Mr=[["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"}]],Ar=At("tags",Mr),$r=["generated","created","mentioned"],Cn=[{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"}],Er=[{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"}],Xt={q:"",scope:"final",tagMode:"all",highlighted:!1,sort:"recent",order:"desc"};function Rr(e){return e==="name"||e==="kind"?"asc":"desc"}function ts(e,n){return e.status===n}function Ir(e){return!!(e.q.trim()||e.category||e.originGroup||e.tag||e.session||e.highlighted||e.status)}function zr(e){if(e==="unorganized")return!1}function Oe(e){return e.name.trim()||e.derived_name.trim()||e.id}function Bs(e){const n=e.derived_name.trim();return n?n===e.name.trim()?e.ref.display_path:n:e.ref.display_path}function Lr(e){const n=new Map;for(const i of e){const r=i.category||"custom",a=n.get(r);a?a.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 en(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 Dr(e,n){if(!e)return"";const t=n-e*1e3;if(t<6e4)return S("ui.library.time.just_now");const s=Math.floor(t/6e4);if(s<60)return S("ui.library.time.minutes_m_ago",{minutes:s});const i=Math.floor(s/60);if(i<24)return S("ui.library.time.hours_h_ago",{hours:i});const r=Math.floor(i/24);if(r<30)return S("ui.library.time.days_d_ago",{days:r});const a=Math.floor(r/30);return a<12?S("ui.library.time.months_mo_ago",{months:a}):S("ui.library.time.years_y_ago",{years:Math.floor(a/12)})}function Br(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 dn(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 Me={all:["desktop","library"],list:e=>["desktop","library","list",e],detail:e=>["desktop","library","detail",e],tags:["desktop","library","tags"],librarian:["desktop","library","librarian"]},Or=60;function Ur(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=zr(e.status);return t!==void 0?{organized:t}:{}})(),sort:e.sort,order:e.order,limit:Or,...n?{cursor:n}:{}}}function Wr(e,n){return _r({queryKey:Me.list(e),enabled:n,initialPageParam:void 0,queryFn:({pageParam:t})=>$e(Ur(e,t)),getNextPageParam:t=>t.next_cursor??void 0,retry:on,refetchInterval:t=>t.state.data?.pages.at(-1)?.state==="building"?2e3:!1,staleTime:1e4})}function Gr(e,n){return Rn({queryKey:Me.detail(e??""),enabled:n&&!!e,queryFn:()=>$e({op:"library.get",id:e}),retry:on,staleTime:5e3})}function qr(e){return Rn({queryKey:Me.tags,enabled:e,queryFn:()=>$e({op:"library.tags"}),retry:on,staleTime:2e4})}function Os(e){return Rn({queryKey:Me.librarian,enabled:e,queryFn:()=>$e({op:"library.librarian",action:"status"}).then(n=>"librarian"in n?n.librarian:n),retry:on,staleTime:3e4})}function Qe(e){return e.invalidateQueries({queryKey:Me.all})}function ns(e,n){return{...e,...n}}function Us(){const e=gt();return Xe({mutationFn:n=>$e({op:"library.update",id:n.id,fields:n.fields}),onMutate:async n=>{await e.cancelQueries({queryKey:Me.all});const t=e.getQueryData(Me.detail(n.id)),s=e.getQueriesData({queryKey:[...Me.all,"list"]});t&&e.setQueryData(Me.detail(n.id),ns(t,n.fields));for(const[i,r]of s)r&&e.setQueryData(i,{...r,pages:r.pages.map(a=>({...a,rows:a.rows.map(l=>l.id===n.id?ns(l,n.fields):l)}))});return{detail:t,lists:s}},onSuccess:n=>(e.setQueryData(Me.detail(n.id),n),Qe(e)),onError:(n,t,s)=>{s?.detail&&e.setQueryData(Me.detail(t.id),s.detail);for(const[i,r]of s?.lists??[])e.setQueryData(i,r);e.invalidateQueries({queryKey:Me.detail(t.id)}),e.invalidateQueries({queryKey:Me.all})},retry:Ke})}function Kr(){const e=gt();return Xe({mutationFn:n=>$e({op:"library.tags.assign",id:n.id,tags:n.tags,...n.primary?{primary:n.primary}:{}}),onSuccess:n=>(e.setQueryData(Me.detail(n.id),n),Qe(e)),onError:()=>Qe(e),retry:Ke})}function Xr(){const e=gt(),n=()=>Qe(e),t=Xe({mutationFn:a=>$e({op:"library.tags.create",name:a.name,...a.category?{category:a.category}:{}}),onSuccess:n,retry:Ke}),s=Xe({mutationFn:a=>$e({op:"library.tags.update",id:a.id,...a.name!==void 0?{name:a.name}:{},...a.category!==void 0?{category:a.category}:{}}),onSuccess:n,retry:Ke}),i=Xe({mutationFn:a=>$e({op:"library.tags.delete",id:a.id}),onSuccess:n,retry:Ke}),r=Xe({mutationFn:a=>$e({op:"library.tags.merge",id:a.id,into:a.into}),onSuccess:n,retry:Ke});return{create:t,update:s,remove:i,merge:r}}function Vr(){const e=gt();return Xe({mutationFn:n=>$e({op:"library.chat.link",id:n.id,sessionId:n.sessionId}),onSuccess:()=>Qe(e),onError:()=>Qe(e),retry:Ke})}function Ws(){const e=gt();return Xe({mutationFn:n=>$e({op:"library.chat.clear",id:n.id}),onSuccess:()=>Qe(e),retry:Ke})}function Hr(){const e=gt();return Xe({mutationFn:n=>$e({op:"library.librarian",action:n}).then(t=>"librarian"in t?t.librarian:t),onSuccess:()=>Qe(e),retry:Ke})}function bt(e,n,t,s=!1){const[i,r]=E.useState({bytes:null,mimeType:"",error:null,loading:!1});return E.useEffect(()=>{if(!t||!e){r({bytes:null,mimeType:"",error:null,loading:!1});return}let a=!1;return r({bytes:null,mimeType:"",error:null,loading:!0}),In(n==="thumbnail"?{op:"library.thumbnail",assetId:e,width:480}:{op:"library.content",assetId:e,download:s},null).then(o=>{if(!a){if(o.kind==="bytes"){r({bytes:o.data,mimeType:o.mimeType,error:null,loading:!1});return}r({bytes:null,mimeType:"",error:o.kind==="error"?o.detail:"This preview could not be loaded.",loading:!1})}}),()=>{a=!0}},[e,n,t,s]),i}function Gs(e,n=!0){const[t,s]=E.useState(()=>e?tn.get(e)??null:null);return E.useEffect(()=>{if(!e){s(null);return}if(s(tn.get(e)??null),!n)return;let i=!0;return Qr(e).then(r=>{i&&s(r)}),()=>{i=!1}},[e,n]),t}const tn=new Map,ss=new Map;async function Yr(e){try{const n=await In({op:"library.waveform",assetId:e},null);return n.kind==="json"?Ei(n.body):null}catch{return null}}function Qr(e){const n=ss.get(e);if(n)return n;const t=Yr(e).then(s=>(tn.set(e,s),s)).catch(()=>(tn.set(e,null),null));return ss.set(e,t),t}function yt(e,n){const[t,s]=E.useState(null);return E.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 Zr=/[\\/]/;function Jr(e){const t=Oe(e).split(Zr).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 pt(e){const n=await In({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=Jr(e),i.rel="noopener",document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(s),3e4)}const Wn=({asset:e,onAsk:n,onEditMetadata:t,onEditTags:s,onToggleFavorite:i,onOpenConversation:r,onFilterSession:a,triggerClassName:l})=>{const o=async(u,p)=>{try{await navigator.clipboard.writeText(u),Tn(p)}catch{Te(S("ui.library.menu.copy_failed"))}},c=async()=>{try{await pt(e),Tn(S("ui.library.menu.saved_a_copy"))}catch{Te(S("ui.library.menu.save_failed"))}},d=!!(e.ref.type==="path"&&e.ref.path),h=e.occurrences;return f.jsxs(Rs,{children:[f.jsx(Gt,{content:S("ui.library.menu.asset_actions"),children:f.jsx(Is,{asChild:!0,children:f.jsx(J,{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(Ri,{"aria-hidden":"true"})})})}),f.jsxs(zs,{align:"end",className:"min-w-52",onClick:u=>u.stopPropagation(),children:[h.length===1?f.jsxs(Ee,{onSelect:()=>r(h[0].session_id),children:[f.jsx(qt,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.open_source_conversation")})]}):h.length>1?f.jsxs(tr,{children:[f.jsxs(nr,{children:[f.jsx(qt,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.open_source_conversation")})]}),f.jsx(sr,{className:"min-w-60",children:h.map(u=>f.jsx(Ee,{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(Ee,{onSelect:n,children:[f.jsx(qt,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.ask_about_asset")})]}),h.length>0&&f.jsxs(Ee,{onSelect:()=>a(h[0].session_id),children:[f.jsx(Pn,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.show_from_conversation")})]}),f.jsx(Zn,{}),f.jsxs(Ee,{onSelect:i,children:[f.jsx(cn,{"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(Ee,{onSelect:t,children:[f.jsx(Ns,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.edit_metadata")})]}),f.jsxs(Ee,{onSelect:s,children:[f.jsx(Ar,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.edit_tags")})]}),f.jsx(Zn,{}),e.ref.path?f.jsxs(Ee,{onSelect:()=>void o(e.ref.path,S("ui.library.menu.path_copied")),children:[f.jsx(Ii,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.copy_path")})]}):null,f.jsxs(Ee,{onSelect:()=>void o(e.id,S("ui.library.menu.asset_id_copied")),children:[f.jsx(wr,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.copy_asset_id")})]}),d?f.jsxs(Ee,{onSelect:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(Pn,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.reveal_in_finder")})]}):f.jsxs(Ee,{onSelect:()=>void c(),children:[f.jsx(ht,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.download")})]}),e.ref.type==="artifact"&&f.jsxs(Ee,{onSelect:()=>void c(),children:[f.jsx(ht,{"aria-hidden":"true"}),f.jsx("span",{children:S("ui.library.menu.save_a_copy")})]})]})]})},ea={image:Di,audio:Li,video:zi,pdf:Dt,pptx:Cr,docx:Dt,markdown:Dt,html:Jn,spreadsheet:Nr,text:Dt,code:Jn,other:Ms};function ta(e){return ea[e]??Ms}function Je({kind:e,size:n=20,className:t}){const s=ta(e);return f.jsx(s,{size:n,"aria-hidden":"true",className:t})}const qs=({group:e})=>f.jsx(rt,{variant:e==="generated"?"accent":"neutral",children:S(dn(e))}),Ks=({asset:e,large:n=!1})=>{const[t,s]=Dn("300px"),i=e.kind==="image"&&e.exists&&s,r=bt(e.id,"thumbnail",i),a=yt(r.bytes,r.mimeType);return f.jsx("div",{ref:t,className:ye("relative flex shrink-0 items-center justify-center overflow-hidden bg-canvas",n?"aspect-[16/10] w-full":"h-24 w-32"),children:a?f.jsx("img",{src:a,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(Je,{kind:e.kind,size:n?28:22,className:"text-ink-dim"})})},is=()=>f.jsx("span",{className:"absolute top-1.5 start-1.5 flex size-5 items-center justify-center rounded-full bg-elevated",title:S("ui.library.card.highlighted"),children:f.jsx(Un,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),Xs=()=>f.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-elevated",title:S("ui.library.menu.favorite"),"data-library-favorite-mark":"",children:f.jsx(cn,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),Vs=({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(rt,{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]})]})},na=({asset:e})=>{const[n,t]=Dn("300px"),s=e.exists&&t,i=bt(e.id,"content",s),r=Gs(e.id,s),a=yt(i.bytes,i.mimeType||e.ref.content_type);return f.jsx("div",{ref:n,"data-library-audio-well":"",className:"relative flex aspect-[16/10] w-full shrink-0 items-center justify-center overflow-hidden bg-canvas px-2",children:a?f.jsx(As,{variant:"compact",ownerId:`sound:library:${e.id}`,src:a,label:Oe(e),peaks:r,durationHint:e.duration_s}):f.jsx(Je,{kind:e.kind,size:28,className:"text-ink-dim"})})},sa=({asset:e,selected:n,...t})=>{const s=e.kind==="audio",i=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:Oe(e)}),f.jsx("span",{className:"line-clamp-1 text-meta text-ink-dim",children:Bs(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:en(e.size_bytes)}),e.duration_s?f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:Br(e.duration_s)})]}):null]}),f.jsx(Vs,{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(qt,{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(qs,{group:e.origin_group}),f.jsxs("div",{className:"flex items-center gap-2",children:[e.session_count>1&&f.jsx("span",{className:"text-meta text-ink-dim",children:S("ui.library.card.conversations",{count:e.session_count})}),e.favorite&&f.jsx(Xs,{})]})]})]}),r=f.jsxs("button",{type:"button",onClick:()=>t.onSelect(e.id),"aria-pressed":n,className:"flex w-full flex-1 flex-col text-start focus-visible:outline-offset-2",children:[s?null:f.jsxs("div",{className:"relative",children:[f.jsx(Ks,{asset:e,large:!0}),e.highlighted&&f.jsx(is,{})]}),i]});return f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:ye("group relative flex flex-col overflow-hidden rounded-lg border border-hairline bg-surface",n&&On),children:[s&&f.jsxs("div",{className:"relative",children:[f.jsx(na,{asset:e}),e.highlighted&&f.jsx(is,{})]}),r,f.jsx("div",{className:"invisible absolute top-1.5 end-1.5 group-focus-within:visible group-hover:visible [@media(pointer:coarse)]:visible",children:f.jsx(Wn,{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"})})]})},ia=({asset:e,selected:n,...t})=>f.jsxs("article",{"data-library-card-id":e.id,"data-glass-block":"",className:ye("group relative flex items-center gap-3 rounded-md border border-hairline bg-surface px-3 py-2",n&&On),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-start",children:[f.jsx(Ks,{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(Un,{size:12,"aria-hidden":"true",className:"shrink-0 fill-current text-accent"}),Oe(e)]}),f.jsx("span",{className:"truncate text-meta text-ink-dim",children:Bs(e)})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-meta text-ink-muted",children:[f.jsx(Vs,{asset:e}),f.jsx("span",{children:e.kind}),f.jsx("span",{children:en(e.size_bytes)}),f.jsx(qs,{group:e.origin_group}),e.favorite&&f.jsx(Xs,{})]})]}),f.jsx(Wn,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession})]}),ra=({assets:e,selectedId:n,view:t,hasMore:s,loadingMore:i,onLoadMore:r,...a})=>{const l=E.useRef(null);return E.useEffect(()=>{const o=l.current;if(!o||!s)return;const c=new IntersectionObserver(d=>{d.some(h=>h.isIntersecting)&&r()},{rootMargin:"600px 0px"});return c.observe(o),()=>c.disconnect()},[s,r,e.length]),f.jsxs("div",{className:"flex flex-col gap-4",children:[t==="grid"?f.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(208px,1fr))] gap-4",children:e.map(o=>f.jsx(sa,{asset:o,selected:o.id===n,...a},o.id))}):f.jsx("div",{className:"flex flex-col gap-1.5",children:e.map(o=>f.jsx(ia,{asset:o,selected:o.id===n,...a},o.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(Ln,{size:14,"aria-hidden":"true",className:"motion-safe:animate-spin"}),S("ui.library.grid.loading_more")]}),!i&&s&&f.jsx(J,{variant:"ghost",size:"sm",onClick:r,children:S("ui.library.grid.load_more")})]})]})},aa=({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))}),oa=[{key:"highlighted",labelKey:"ui.library.status.highlighted"},{key:"unorganized",labelKey:"ui.library.status.unorganized"},{key:"favorite",labelKey:"ui.library.status.favorites"}],He=({label:e,count:n,active:t,onPress:s,icon:i,indent:r=!1})=>f.jsxs("button",{type:"button",onClick:s,"aria-pressed":t,className:ye("flex h-7 w-full items-center gap-2 rounded-md px-2 text-start text-body-sm",r&&"ps-6",t?On:"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})]}),xt=({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})]}),la=({filters:e,onChange:n,counts:t,tags:s,total:i,scopeTotal:r})=>{const a=Lr(s),l=t?.category??{},o=d=>n({...e,...d}),c=!!(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:[c&&f.jsxs(J,{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(Ve,{"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(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.filter.clear_conversation"),onClick:()=>o({session:void 0}),children:f.jsx(Ve,{"aria-hidden":"true"})})]}),f.jsxs(xt,{label:S("ui.library.filter.scope"),children:[f.jsx(He,{label:S("ui.library.filter.scope_final"),active:e.scope==="final",onPress:()=>o({scope:"final"})}),f.jsx(He,{label:S("ui.library.filter.scope_all"),count:r??void 0,active:e.scope==="all",onPress:()=>o({scope:"all"})})]}),f.jsxs(xt,{label:S("ui.library.filter.categories"),children:[f.jsx(He,{label:S("ui.library.category.all"),count:i,active:!e.category,onPress:()=>o({category:void 0})}),Cn.map(d=>f.jsx(He,{label:S(d.labelKey),count:l[d.key]??0,active:e.category===d.key,onPress:()=>o({category:e.category===d.key?void 0:d.key}),icon:f.jsx(Je,{kind:d.iconKind,size:14,className:"text-ink-dim"})},d.key)),Object.keys(l).filter(d=>!Cn.some(h=>h.key===d)).sort().map(d=>f.jsx(He,{label:d,count:l[d],active:e.category===d,onPress:()=>o({category:e.category===d?void 0:d}),icon:f.jsx(Hn,{size:14,"aria-hidden":"true"})},d))]}),f.jsx(xt,{label:S("ui.library.filter.status"),children:oa.map(d=>f.jsx(He,{label:S(d.labelKey),active:ts(e,d.key),onPress:()=>o({status:ts(e,d.key)?void 0:d.key}),icon:d.key==="favorite"?f.jsx(cn,{size:14,"aria-hidden":"true"}):d.key==="highlighted"?f.jsx(Un,{size:14,"aria-hidden":"true"}):void 0},d.key))}),f.jsx(xt,{label:S("ui.library.filter.source"),children:$r.filter(d=>e.originGroup===d||e.scope==="all"||(t?.origin_group?.[d]??0)>0).map(d=>f.jsx(He,{label:S(dn(d)),count:t?.origin_group?.[d]??0,active:e.originGroup===d,onPress:()=>o({originGroup:e.originGroup===d?void 0:d})},d))}),a.length>0&&f.jsx(xt,{label:S("ui.library.filter.tags"),children:a.map(d=>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:d.category}),d.tags.map(h=>f.jsx(He,{label:h.name,count:h.count??0,active:e.tag===h.id,onPress:()=>o({tag:e.tag===h.id?void 0:h.id}),icon:f.jsx(Hn,{size:13,"aria-hidden":"true"}),indent:!0},h.id))]},d.category))}),e.tag&&f.jsx(rt,{variant:"neutral",children:S("ui.library.filter.tag_mode",{mode:e.tagMode.toUpperCase()})})]})},rs=({value:e,onSave:n,label:t,placeholder:s="",multiline:i=!1,rows:r=3,textClassName:a,allowEmpty:l=!1,startSignal:o,field:c,className:d})=>{ct();const[h,u]=E.useState(!1),[p,m]=E.useState(e),[g,P]=E.useState(!1),y=E.useRef("closed"),w=E.useRef(null),x=E.useRef(null),_=()=>{y.current==="closed"&&(m(e),y.current="edit",u(!0))},v=$=>{y.current="closed",$&&x.current?.focus(),u(!1)},k=async $=>{if(y.current!=="edit")return;const z=p.trim();if(!z&&!l||z===e){v($);return}y.current="saving",P(!0);try{await n(z),y.current==="saving"&&v($)}catch{y.current==="saving"&&(y.current="edit",w.current?.focus())}finally{P(!1)}};E.useEffect(()=>{if(!h)return;const $=setTimeout(()=>{const z=w.current;z&&(z.focus(),z.select(),z.scrollLeft=0,z instanceof HTMLTextAreaElement&&(z.scrollTop=0))},0);return()=>clearTimeout($)},[h]),E.useEffect(()=>{y.current==="closed"&&m(e)},[e]);const j=E.useRef(o);E.useEffect(()=>{const $=j.current;j.current=o,!(o===$||!o)&&_()},[o]);const N=$=>{if(!($.nativeEvent.isComposing||$.keyCode===229)){if($.key==="Enter"){if(i&&$.shiftKey)return;$.preventDefault(),k(!0)}else if($.key==="Escape"){if($.preventDefault(),y.current==="saving")return;v(!0)}}},F=$=>{h&&$.preventDefault()},R=$=>{m($.target.value)},A=e.trim()?f.jsx("span",{onDoubleClick:_,className:ye("block min-w-0 cursor-default select-none",i?"whitespace-pre-wrap break-words":"truncate",a),children:e}):f.jsx("button",{type:"button",onClick:_,className:ye("block min-w-0 cursor-pointer truncate text-start text-ink-dim","transition-colors duration-fast ease-out-quart hover:text-ink-muted",a),children:s});return f.jsxs("div",{"data-inline-edit":c,className:ye("group/inline flex min-w-0 items-center gap-1",!h&&"w-fit max-w-full",h&&"w-full",i&&h&&"items-start",d),children:[h?i?f.jsx("textarea",{"data-inline-edit-input":"",ref:$=>{w.current=$},value:p,rows:r,readOnly:g,"aria-label":t,"aria-busy":g||void 0,onChange:R,onKeyDown:N,onBlur:()=>void k(!1),spellCheck:!1,className:ye("min-w-0 flex-1 resize-none border-0 bg-transparent p-0 outline-none","text-ink",a)}):f.jsx("input",{"data-inline-edit-input":"",ref:$=>{w.current=$},value:p,readOnly:g,"aria-label":t,"aria-busy":g||void 0,onChange:R,onKeyDown:N,onBlur:()=>void k(!1),spellCheck:!1,className:ye("min-w-0 flex-1 border-0 bg-transparent p-0 outline-none","text-ink",a)}):f.jsx("div",{className:"min-w-0 flex-1",children:A}),f.jsx("button",{type:"button",ref:x,"data-inline-edit-control":"","aria-label":g?S("ui.common.forms.editable_field.saving"):h?S("ui.common.forms.autocomplete_field.cancel_editing",{label:t}):S("ui.common.forms.editable_field.edit_v2",{label:t}),title:g?S("ui.common.forms.editable_field.saving"):h?S("ui.common.forms.editable_field.cancel_escape"):S("ui.common.forms.editable_field.edit"),"aria-busy":g||void 0,"aria-disabled":g||void 0,onMouseDown:F,onClick:$=>{if(!($.detail>1)&&y.current!=="saving"){if(h){v(!0);return}_()}},className:ye("inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-xs","text-ink-dim transition-opacity duration-base ease-out-quart","hover:text-ink-muted",!h&&"opacity-0 group-hover/inline:opacity-100 group-hover/inline:duration-fast",!h&&"group-focus-within/inline:opacity-100 group-focus-within/inline:duration-fast"),children:g?f.jsx(Tt,{size:"xs"}):h?f.jsx(Ve,{className:"size-3","aria-hidden":"true"}):f.jsx(Ns,{className:"size-3","aria-hidden":"true"})})]})},ca=({value:e,onChange:n,label:t,addLabel:s,saving:i=!1,startSignal:r})=>{ct();const[a,l]=E.useState(!1),[o,c]=E.useState(""),d=E.useRef(null),h=E.useRef(null),u=()=>{i||a||l(!0)},p=()=>{c(""),l(!1)},m=x=>{const _=o.trim().toLowerCase();_&&!e.some(v=>v.toLowerCase()===_)&&n([...e,_]),c(""),x?d.current?.focus():l(!1)},g=E.useRef(!1);E.useEffect(()=>{if(i){g.current=!0;return}if(!a){g.current=!1;return}const x=g.current;g.current=!1;const _=setTimeout(()=>{if(x){const v=document.activeElement,k=h.current;if(!(!v||v===document.body||!!k?.contains(v)))return}d.current?.focus()},0);return()=>clearTimeout(_)},[a,i]);const P=E.useRef(r);E.useEffect(()=>{const x=P.current;P.current=r,!(r===x||!r)&&u()},[r]);const y=x=>{x.nativeEvent.isComposing||x.keyCode===229||(x.key==="Enter"?(x.preventDefault(),m(!0)):x.key==="Escape"&&(x.preventDefault(),p()))},w=i?f.jsx(Tt,{size:"xs"}):a?f.jsx("input",{ref:d,value:o,"aria-label":t,onChange:x=>c(x.target.value),onKeyDown:y,onBlur:()=>o.trim()?m(!1):p(),spellCheck:!1,className:ye("w-28 min-w-0 border-0 bg-transparent p-0 outline-none","text-body-sm text-ink placeholder:text-ink-dim"),placeholder:s}):f.jsxs("button",{type:"button",onClick:u,className:ye("inline-flex items-center gap-1 rounded-xs text-ink-dim","text-body-sm transition-colors duration-fast ease-out-quart hover:text-ink-muted"),children:[f.jsx(dr,{className:"size-3","aria-hidden":"true"}),s]});return f.jsxs("div",{ref:h,"data-inline-tags":"",className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.map(x=>f.jsxs(rt,{variant:"neutral",shape:"pill",className:"gap-1 pe-1 text-ink",children:[x,f.jsx("button",{type:"button","aria-label":S("ui.chat.tags.remove_named",{name:x}),disabled:i,onClick:()=>n(e.filter(_=>_!==x)),className:ye("inline-flex size-5 -m-1 items-center justify-center rounded-xs","text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:f.jsx(Ve,{className:"size-3","aria-hidden":"true"})})]},x)),w]})},da=2e3;function Gn(e){return e.ref.type==="path"&&!!e.ref.path&&e.exists===!0}function ua(e,n){const t=Gn(e)?e.ref.path:null,[s,i]=E.useState({mtimeMs:null,sizeBytes:null,revision:0,missing:!1}),r=E.useRef(null),a=E.useRef(!1);E.useEffect(()=>{r.current=null,i({mtimeMs:null,sizeBytes:null,revision:0,missing:!1})},[t]);const l=E.useCallback(async()=>{if(!(!t||!window.api?.probeFiles)&&!a.current){a.current=!0;try{const[o]=await window.api.probeFiles([t],void 0,{fresh:!0});if(!o)return;const c=o.exists===!1&&!o.error,d=o.mtimeMs??null,h=d!==null&&d!==r.current;r.current=d,i(u=>({mtimeMs:d,sizeBytes:o.sizeBytes??null,revision:h?u.revision+1:u.revision,missing:c}))}finally{a.current=!1}}},[t]);return E.useEffect(()=>{l()},[l,n]),E.useEffect(()=>{if(!t)return;const o=()=>void l(),c=()=>{document.visibilityState==="visible"&&l()};window.addEventListener("focus",o),document.addEventListener("visibilitychange",c);const d=window.setInterval(()=>{document.visibilityState==="visible"&&l()},da);return()=>{window.removeEventListener("focus",o),document.removeEventListener("visibilitychange",c),window.clearInterval(d)}},[t,l]),s}const fa=[];function ha(e){const n=e.ref.display_path||e.ref.path||(e.ref.digest?`attachment digest ${e.ref.digest}`:e.id);return`${Oe(e)} (${n})`}function pa(e,n,t){if(e.kind!=="image"||!n||n.length===0)return null;let s="";const i=32768;for(let a=0;a<n.length;a+=i)s+=String.fromCharCode(...n.subarray(a,Math.min(a+i,n.length)));return`data:${e.ref.content_type||t};base64,${btoa(s)}`}const ma=({asset:e,focusSignal:n,onSessionChange:t,showLinkedRow:s,onOpenChat:i,refreshSignal:r=0,streaming:a})=>{ct();const l=E.useRef(null),o=zn(),{frontend:c,refresh:d}=xr(),h=E.useRef(!1),[u,p]=E.useState(!1),[m,g]=E.useState({}),[P,y]=E.useState(null),w=e.chat?.session_id??m[e.id]??null,x=m[e.id]??null,_=P===e.id,v=Vr(),k=Ws(),j=bt(e.id,"content",e.kind==="image"),N=w??`library:${e.id}`;E.useEffect(()=>{w&&d(w)},[w,d,r]),E.useEffect(()=>{n!==0&&l.current?.focusInput()},[n]);const F=async()=>{const A=x??e.chat?.session_id;if(A)try{await v.mutateAsync({id:e.id,sessionId:A}),g($=>{const z={...$};return delete z[e.id],z}),y(null)}catch{Te(S("ui.library.composer.link_failed_short"))}},R=async(A,$,z)=>{const Y=A.trim();if(!Y||h.current)return!1;h.current=!0,p(!0);const O=a??c?.streaming===!0;let W=w;try{const B=pa(e,j.bytes,j.mimeType),{images:Z,files:Q,failures:L,overflow:X,fileOverflow:ae}=await Oi(B?[...$,B]:$,A),oe=Ui(L);if(oe)return Te(oe),!1;const fe=Wi(X);if(fe)return Te(fe),!1;const ee=Gi(ae);if(ee)return Te(ee),!1;if(!W){const H=Fi.getState();if(W=await H.createSession(H.cwd||"~"),!W)throw new Error(H.error??S("ui.library.composer.could_not_start"))}const V=W,be={op:"sessions.message",sessionId:V,requestId:crypto.randomUUID(),text:`${Y}
|
|
28
|
+
|
|
29
|
+
${ha(e)}`};if(Z.length>0&&(be.images=Z),Q.length>0&&(be.files=Q),O&&(be.mode="steer"),await $e(be),z?.(),g(H=>({...H,[e.id]:V})),t(e.id,V),!e.chat)try{await v.mutateAsync({id:e.id,sessionId:V}),g(H=>{const re={...H};return delete re[e.id],re}),y(null)}catch(H){y(e.id),Te(H instanceof Error&&H.message?S("ui.library.composer.link_failed",{message:H.message}):S("ui.library.composer.link_failed_short"))}return!0}catch(B){return Te(B instanceof Error&&B.message?B.message:S("ui.library.composer.not_sent")),!1}finally{h.current=!1,p(!1)}},T=e.chat;return f.jsxs("div",{className:"flex flex-col gap-2 bg-sunken px-4 pt-3 pb-1","data-library-composer":"","data-sending":u?"":void 0,children:[_&&x&&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(J,{variant:"ghost",size:"sm",onClick:()=>void F(),children:S("ui.library.composer.retry_link")}),f.jsx(J,{variant:"ghost",size:"sm",onClick:()=>i(x),children:S("ui.library.composer.open_chat")})]}),T&&s&&f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx(Ds,{size:13,"aria-hidden":"true"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:S("ui.library.composer.chat_about",{title:T.title||T.session_id})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.composer.unlink"),onClick:()=>k.mutate({id:e.id}),children:f.jsx(Ve,{"aria-hidden":"true"})})]}),f.jsx("div",{className:"min-w-0","data-sending":u?"":void 0,children:f.jsx(Bi,{ref:l,conversationId:N,messages:fa,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:T||w?S("ui.library.composer.continue_placeholder"):S("ui.library.composer.ask_placeholder"),cwd:c?.cwd,cwdReadOnlyReason:S("ui.projects.project_quick_send.quick_send_follows_the_conversation_s_directory"),sessionStatus:c&&w?{frontend:c,costChannels:kt(o.data,"cost_channels")}:void 0,onSendMessage:R})})]})},ga=({sessionId:e,title:n,collapsed:t,onToggleCollapsed:s,onOpenChat:i,onUnlink:r,onTurnSettled:a,onStreamingChange:l})=>{ct();const o=zn(),c=Ni(e,!0,!0,e,{openFrame:kt(o.data,"open_frame"),journalOrder:kt(o.data,"journal_order"),peerJournalSource:kt(o.data,"peer_journal_source")}),d=E.useRef(null),u=(c.frontend??c.heldFrontend)?.streaming===!0,p=qi(c.frontend??c.heldFrontend),m=E.useRef(u);E.useEffect(()=>{m.current!==u&&(l(u),u||a()),m.current=u},[u,a,l]);const g=c.transcript.records.length===0&&c.awaitingHydration&&!c.missing;return f.jsxs("section",{"data-library-trajectory":"","data-collapsed":t?"":void 0,className:ye("flex min-h-0 flex-col bg-sunken",t?"shrink-0":"min-h-40 max-h-80 shrink-0 basis-[38%]"),children:[f.jsxs("header",{className:"flex shrink-0 items-center gap-2 px-4 py-1.5",children:[f.jsx(Ds,{size:13,"aria-hidden":"true",className:"text-ink-dim"}),f.jsxs("button",{type:"button","aria-expanded":!t,onClick:s,className:"flex min-w-0 flex-1 items-center gap-1 rounded-sm text-start text-meta text-ink-muted hover:text-ink focus-visible:outline-offset-1",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate",children:S("ui.library.composer.chat_about",{title:n})}),f.jsx(Ls,{"aria-hidden":"true",className:ye("size-3.5 shrink-0 transition-transform duration-fast",t&&"rotate-180")})]}),f.jsx(J,{variant:"ghost",size:"sm",onClick:i,children:S("ui.library.composer.open_chat")}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.composer.unlink"),onClick:r,children:f.jsx(Ve,{"aria-hidden":"true"})})]}),!t&&p&&f.jsxs("div",{"data-library-trajectory-gate":"",className:"flex shrink-0 items-center gap-2 px-4 pb-1.5",children:[f.jsx("span",{className:"min-w-0 flex-1 text-meta text-ink",children:S("ui.mesh.mesh_approvals.waiting_for_you")}),f.jsx(J,{variant:"secondary",size:"sm",onClick:i,children:S("ui.library.composer.open_chat")})]}),!t&&f.jsx("div",{"data-lo-sidebar-edge-cues":!0,className:"flex min-h-0 grow flex-col overflow-hidden",children:g?f.jsx("div",{className:"flex flex-1 items-center justify-center",children:f.jsx(Tt,{label:S("ui.library.preview.loading")})}):f.jsx(Ki,{frontend:c.frontend,transcript:c.transcript,gate:p,waiting:u,starting:!1,loadingOlder:c.loadingOlder,onLoadOlder:c.loadOlder,onLoadOlderOutcome:c.loadOlderDetailed,olderFailed:c.olderFailed,containerRef:d,isSmallView:!1,status:c.status,failure:c.failure,awaitingHydration:c.awaitingHydration,hydrationProven:c.hydrated,missing:c.missing,onReconnect:c.retry})})]})};function ba(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"}}const ya="h-[78px] w-[117px]",va=({asset:e,active:n,onSelect:t})=>{const[s,i]=Dn("300px"),r=bt(e.id,"thumbnail",e.kind==="image"&&e.exists&&i),a=yt(r.bytes,r.mimeType),l=Oe(e);return f.jsx("li",{ref:s,className:ye("flex shrink-0 rounded-sm leading-none",n&&"ring-1 ring-ink"),children:f.jsx("button",{type:"button","aria-label":l,title:l,"aria-current":n?"true":void 0,onClick:t,"data-library-lightbox-tile":e.id,className:"block cursor-pointer overflow-hidden rounded-sm leading-none",children:f.jsx("div",{className:ye("flex items-center justify-center overflow-hidden bg-canvas",ya),children:a?f.jsx("img",{src:a,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(Je,{kind:e.kind,size:20,className:"text-ink-dim"})})})})},wa=({siblings:e,index:n,onSelect:t})=>f.jsx("ul",{role:"list","data-library-lightbox-strip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((s,i)=>f.jsx(va,{asset:s,active:i===n,onSelect:()=>t(i)},s.id))}),xa=({open:e,siblings:n,index:t,onIndexChange:s,onClose:i,restoreFocusTo:r,resolved:a})=>{ct();const l=Xi(t,n.length),o=n[l],c=a?.assetId===o.id,d=bt(o.id,"content",!c),h=yt(d.bytes,d.mimeType||o.ref.content_type),u=c?a?.url:h??void 0,p=Oe(o);return f.jsx(Vi,{open:e,onOpenChange:m=>{m||i()},src:u,pending:!c&&(d.loading||u===void 0&&!d.error),label:p,mediaKind:o.kind==="video"?"video":"image",mediaLabel:"asset",restoreFocusTo:r,layerAttributes:{"data-library-lightbox":""},fallback:d.error||u!==void 0?f.jsx("p",{className:"max-w-90 text-center text-body-sm text-ink-muted",children:S("ui.library.preview.could_not_load")}):void 0,group:{index:l,count:n.length,onPrev:()=>s(Yn(l,n.length,-1)),onNext:()=>s(Yn(l,n.length,1)),filmstrip:n.length>1?f.jsx(wa,{siblings:n,index:l,onSelect:s}):void 0}})};async function Hs(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 a=-1;const l=Math.max(0,n.length-65557);for(let m=n.length-22;m>=l;m--)if(t.getUint32(m,!0)===s){a=m;break}if(a===-1)throw new Error("Not a valid ZIP file: EOCD not found");let o,c;const d=a-20;if(d>=0&&t.getUint32(d,!0)===r){const m=Number(t.getBigUint64(d+8,!0));if(t.getUint32(m,!0)!==i)throw new Error("Invalid ZIP64 end record");o=Number(t.getBigUint64(m+48,!0)),c=Number(t.getBigUint64(m+32,!0))}else o=t.getUint32(a+16,!0),c=t.getUint16(a+8,!0);if(o+4>n.length)throw new Error("ZIP central directory offset is outside the file");const h=33639248,u={};let p=o;for(let m=0;m<c&&!(p+46>n.length||t.getUint32(p,!0)!==h);m++){const g=t.getUint16(p+10,!0);let P=t.getUint32(p+20,!0),y=t.getUint32(p+24,!0);const w=t.getUint16(p+28,!0),x=t.getUint16(p+30,!0),_=t.getUint16(p+32,!0);let v=t.getUint32(p+42,!0);const k=_a(n,p+46,w);if(P===4294967295||y===4294967295||v===4294967295){const T=p+46+w,A=T+x;let $=T;for(;$+4<=A;){const z=t.getUint16($,!0),Y=t.getUint16($+2,!0);if(z===1){let O=$+4;y===4294967295&&O+8<=A&&(y=Number(t.getBigUint64(O,!0)),O+=8),P===4294967295&&O+8<=A&&(P=Number(t.getBigUint64(O,!0)),O+=8),v===4294967295&&O+8<=A&&(v=Number(t.getBigUint64(O,!0)));break}$+=4+Y}}if(p+=46+w+x+_,k.endsWith("/")||g!==0&&g!==8||v+30>n.length)continue;const j=t.getUint16(v+26,!0),N=t.getUint16(v+28,!0),F=v+30+j+N;if(F+P>n.length)continue;const R=n.subarray(F,F+P);try{u[k]=g===0?R.slice():await ka(R)}catch(T){console.warn(`[zip.js] Failed to decompress "${k}":`,T.message)}}return u}async function ka(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:o,done:c}=await s.read();if(c)break;i.push(o),r+=o.length}const a=new Uint8Array(r);let l=0;for(const o of i)a.set(o,l),l+=o.length;return a}function _a(e,n,t){return new TextDecoder().decode(e.subarray(n,n+t))}function Pe(e){return new DOMParser().parseFromString(e,"application/xml")}function ge(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 b(e,n){return ge(e,n)[0]??null}function U(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=U(e,n);return s!==null?parseInt(s,10):t}function Be(e,n,t){return Math.max(n,Math.min(t,e))}const jt=12700,Sa=Object.freeze(Object.defineProperty({__proto__:null,EMU_PER_PT:jt,attr:U,attrInt:C,clamp:Be,g1:b,gtn:ge,parseXml:Pe},Symbol.toStringTag,{value:"Module"}));function Pa(e){if(!e)return{colors:{},majorFont:"Calibri Light",minorFont:"Calibri"};const n=b(e,"clrScheme"),t={};if(n){const a=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];for(const l of a){const o=b(n,l);if(!o)continue;const c=b(o,"srgbClr"),d=b(o,"sysClr");c?t[l]=c.getAttribute("val")||"":d&&(t[l]=d.getAttribute("lastClr")||"")}}const s=b(e,"fontScheme");let i="Calibri Light",r="Calibri";if(s){const a=b(s,"majorFont"),l=b(s,"minorFont");if(a){const o=b(a,"latin");o&&(i=o.getAttribute("typeface")||i)}if(l){const o=b(l,"latin");o&&(r=o.getAttribute("typeface")||r)}}return{colors:t,majorFont:i,minorFont:r}}function Ta(e){if(!e)return{};const n=b(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 ja(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 ft={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"}},Vt=new Set,Ct=new Map,Ht=new Set;let as=null,_n=null;function Ca(){return _n||(as=typeof OffscreenCanvas<"u"?new OffscreenCanvas(300,10):Object.assign(document.createElement("canvas"),{width:300,height:10}),_n=as.getContext("2d")),_n}const os="mmmmmmmmmmlllllllllliiiiiiiiiixxxxxxxxxx",Fa=[20,40];function Ys(e){if(Ht.has(e))return!0;if(typeof document<"u"&&document.fonts&&document.fonts.check(`16px "${e}"`))return Ht.add(e),!0;try{const n=Ca(),t=["monospace","serif"];for(const s of Fa)for(const i of t){n.font=`${s}px ${i}`;const r=n.measureText(os).width;n.font=`${s}px "${e}", ${i}`;const a=n.measureText(os).width;if(Math.abs(a-r)>.5)return Ht.add(e),!0}}catch{}return!1}async function Fn(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 a=Ct.get(e)??[];a.push(r),Ct.set(e,a),Vt.add(e),Ht.add(e);const l=e.toLowerCase().trim();return ft[l]?ft[l]._custom=!0:ft[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 Na(e){const n=[];for(const[t,s]of Object.entries(e))if(typeof s=="string")n.push(Fn(t,s));else if(Array.isArray(s))for(const i of s){const{url:r,...a}=i;n.push(Fn(t,r,a))}await Promise.all(n)}function Ma(e,n){if(!e)return[];const t=b(e,"embeddedFontLst");if(!t)return[];const s=[];for(const i of t.children){if(i.localName!=="embeddedFont")continue;const r=b(i,"font"),a=r?r.getAttribute("typeface"):null;if(!a)continue;const l={regular:!1,bold:!1,italic:!1,boldItalic:!1},o=[];for(const c of["regular","bold","italic","boldItalic"]){const d=b(i,c);if(!d)continue;const h=d.getAttribute("r:id")||d.getAttribute("id"),u=n?.[h];u&&(o.push(u.fullPath),l[c]=!0)}s.push({family:a,hasRegular:l.regular,hasBold:l.bold,hasItalic:l.italic,hasBoldItalic:l.boldItalic,paths:o,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 Aa(e){if(!e)return"sans-serif";if(e==="+mj-lt"||e==="+mj")return"serif";if(e==="+mn-lt"||e==="+mn")return"sans-serif";if(Ct.has(e))return e;const n=e.toLowerCase().trim(),t=ft[n];return t?t._custom||t.google===null?e:t.google&&Ys(t.google)?t.google:t.google||e:e}function $a(e){if(!e)return"sans-serif";const n=e.toLowerCase().trim();return ft[n]?.generic??"sans-serif"}async function Ea(e,n){const t=[...e];n?.majorFont&&t.push(n.majorFont),n?.minorFont&&t.push(n.minorFont);const s=new Map;for(const a of t){if(!a||a.startsWith("+")||a==="+mj-lt"||a==="+mn-lt"||a==="+mj"||a==="+mn"||Ct.has(a))continue;const l=a.toLowerCase().trim(),o=ft[l];let c=null,d=[400,700];if(o){if(o._custom||o.google===null)continue;c=o.google,d=o.weights.length?o.weights:[400,700]}else c=a;if(!c||Vt.has(c))continue;if(Ys(c)){Vt.add(c);continue}const h=s.get(c)??new Set;d.forEach(u=>h.add(u)),s.set(c,h)}if(s.size===0)return;for(const a of s.keys())Vt.add(a);const r=`https://fonts.googleapis.com/css2?${[...s.entries()].map(([a,l])=>{const o=[...l].sort((d,h)=>d-h),c=[...o.map(d=>`0,${d}`),...o.map(d=>`1,${d}`)].join(";");return`family=${encodeURIComponent(`${a}:ital,wght@${c}`)}`}).join("&")}&display=swap`;try{const a=document.createElement("link");a.rel="stylesheet",a.href=r,document.head.appendChild(a),await new Promise(l=>{a.onload=l,a.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(a){console.warn("[pptx-canvas-renderer] Font loading error:",a)}}function Ra(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],a=r.localName;if(a==="latin"||a==="ea"||a==="cs"){const l=r.getAttribute("typeface");l&&!l.startsWith("+")&&n.add(l)}}}return n}function Qs(e,n,t,s,i=1800,r=null){let a=i;if(r){const y=r.getAttribute("sz");y&&(a=parseInt(y,10))}if(n){const y=n.getAttribute("sz");y&&(a=parseInt(y,10))}if(e){const y=e.getAttribute("sz");y&&(a=parseInt(y,10))}let l=!1,o=!1;if(r&&(r.getAttribute("b")==="1"&&(l=!0),r.getAttribute("i")==="1"&&(o=!0)),n){const y=n.getAttribute("b"),w=n.getAttribute("i");y==="1"?l=!0:y==="0"&&(l=!1),w==="1"?o=!0:w==="0"&&(o=!1)}if(e){const y=e.getAttribute("b"),w=e.getAttribute("i");y==="1"?l=!0:y==="0"&&(l=!1),w==="1"?o=!0:w==="0"&&(o=!1)}let c=s?.minorFont??"Calibri";function d(y){if(!y)return;const w=b(y,"latin"),x=w?w.getAttribute("typeface"):y.getAttribute("typeface");if(x){if(x==="+mj-lt"||x==="+mj"){c=s?.majorFont??c;return}if(x==="+mn-lt"||x==="+mn"){c=s?.minorFont??c;return}c=x}}d(r),d(n),d(e);const h=Aa(c),u=$a(c),p=a*127*t;return{fontStr:`${o?"italic ":""}${l?"bold":"normal"} ${p}px "${h}", ${u}`,sz:a,szPx:p,bold:l,italic:o,family:h,generic:u,rawFamily:c}}function Ia(){const e=[];for(const[n,t]of Ct)for(const s of t)e.push({family:n,weight:s.weight,style:s.style,status:s.status});return e}function Bt(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 nt(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,a=0;const l=(s+i)/2;if(s!==i){const o=s-i;switch(a=l>.5?o/(2-s-i):o/(s+i),s){case e:r=((n-t)/o+(n<t?6:0))/6;break;case n:r=((t-e)/o+2)/6;break;case t:r=((e-n)/o+4)/6;break}}return{h:r,l,s:a}}function Ye(e,n,t){if(t===0){const a=Math.round(n*255);return{r:a,g:a,b:a}}const s=n<.5?n*(1+t):n+t-n*t,i=2*n-s,r=(a,l,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?a+(l-a)*6*o:o<1/2?l:o<2/3?a+(l-a)*(2/3-o)*6:a);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 za={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 La(e,n){if(!n)return e;let{r:t,g:s,b:i,a:r=1}=e;for(const a of n.children){const l=a.localName,o=parseInt(a.getAttribute("val")??"0",10);switch(l){case"lumMod":{const c=o/1e5,d=nt(t,s,i),h=Ye(d.h,Be(d.l*c,0,1),d.s);t=h.r,s=h.g,i=h.b;break}case"lumOff":{const c=o/1e5,d=nt(t,s,i),h=Ye(d.h,Be(d.l+c,0,1),d.s);t=h.r,s=h.g,i=h.b;break}case"tint":{const c=o/1e5;t=Math.round(t+(255-t)*(1-c)),s=Math.round(s+(255-s)*(1-c)),i=Math.round(i+(255-i)*(1-c));break}case"shade":{const c=o/1e5;t=Math.round(t*c),s=Math.round(s*c),i=Math.round(i*c);break}case"satMod":{const c=o/1e5,d=nt(t,s,i),h=Ye(d.h,d.l,Be(d.s*c,0,1));t=h.r,s=h.g,i=h.b;break}case"satOff":{const c=o/1e5,d=nt(t,s,i),h=Ye(d.h,d.l,Be(d.s+c,0,1));t=h.r,s=h.g,i=h.b;break}case"hueMod":{const c=o/1e5,d=nt(t,s,i),h=Ye(d.h*c%1,d.l,d.s);t=h.r,s=h.g,i=h.b;break}case"hueOff":{const c=o/216e5,d=nt(t,s,i),h=Ye(((d.h+c)%1+1)%1,d.l,d.s);t=h.r,s=h.g,i=h.b;break}case"alpha":{r=o/1e5;break}case"alphaOff":{r=Be(r+o/1e5,0,1);break}case"alphaMod":{r=Be(r*o/1e5,0,1);break}case"inv":{t=255-t,s=255-s,i=255-i;break}case"gray":{t=s=i=Math.round(.2126*t+.7152*s+.0722*i);break}case"comp":{const c=nt(t,s,i),d=Ye((c.h+.5)%1,c.l,c.s);t=d.r,s=d.g,i=d.b;break}}}return{r:Be(t,0,255),g:Be(s,0,255),b:Be(i,0,255),a:r}}function Se(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=Bt(r))}else if(t==="schemeClr"){const a=e.getAttribute("val")||"",l=n?.[a];l?s=Bt(l):s={r:0,g:0,b:0}}else if(t==="prstClr"){const r=(e.getAttribute("val")||"").toLowerCase(),a=za[r];a&&(s=Bt(a))}else if(t==="sysClr"){const r=e.getAttribute("lastClr");r?.length>=6?s=Bt(r):s={r:0,g:0,b:0}}else if(t==="hslClr"){const r=C(e,"hue",0)/216e5,a=C(e,"sat",0)/1e5,l=C(e,"lum",0)/1e5;s=Ye(r,l,a)}else if(t==="scRgbClr"){const r=C(e,"r",0)/1e5,a=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(a,1/2.2)*255),b:Math.round(Math.pow(l,1/2.2)*255)}}return s?La({...s,a:i},e):null}function xe(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 ke(e){if(!e)return null;const n=["srgbClr","schemeClr","prstClr","sysClr","hslClr","scRgbClr"];for(const t of n){const s=b(e,t);if(s)return s}return null}function ls(e,n){if(!e)return null;const t=b(e,"solidFill");if(!t)return null;const s=ke(t),i=Se(s,n);return i?xe(i):null}function Da(e,n,t){const s=ls(e,t);return s||ls(n,t)}function nn(e,n,t,s,i,r,a){const l=u=>u*Math.PI/180,o=(u,p=5e4)=>(a&&a[u]!==void 0?a[u]:p)/1e5,c=t+i/2,d=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=o(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(c,d,i/2,r/2,0,0,Math.PI*2);break;case"triangle":case"isoscelesTriangle":e.moveTo(c,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break;case"rightTriangle":e.moveTo(t,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break;case"parallelogram":{const u=o(0,25e3),p=i*u;e.moveTo(t+p,s),e.lineTo(t+i,s),e.lineTo(t+i-p,s+r),e.lineTo(t,s+r),e.closePath();break}case"trapezoid":{const u=o(0,25e3),p=i*u;e.moveTo(t+p,s),e.lineTo(t+i-p,s),e.lineTo(t+i,s+r),e.lineTo(t,s+r),e.closePath();break}case"diamond":e.moveTo(c,s),e.lineTo(t+i,d),e.lineTo(c,s+r),e.lineTo(t,d),e.closePath();break;case"pentagon":dt(e,c,d,i/2,r/2,5,-Math.PI/2);break;case"hexagon":dt(e,c,d,i/2,r/2,6,0);break;case"heptagon":dt(e,c,d,i/2,r/2,7,-Math.PI/2);break;case"octagon":dt(e,c,d,i/2,r/2,8,Math.PI/8);break;case"decagon":dt(e,c,d,i/2,r/2,10,-Math.PI/2);break;case"dodecagon":dt(e,c,d,i/2,r/2,12,0);break;case"plus":case"cross":{const u=o(0,25e3),p=h*u,m=c-p/2,g=c+p/2,P=d-p/2,y=d+p/2;e.moveTo(m,s),e.lineTo(g,s),e.lineTo(g,P),e.lineTo(t+i,P),e.lineTo(t+i,y),e.lineTo(g,y),e.lineTo(g,s+r),e.lineTo(m,s+r),e.lineTo(m,y),e.lineTo(t,y),e.lineTo(t,P),e.lineTo(m,P),e.closePath();break}case"star4":ze(e,c,d,i/2,r/2,4,o(0,37500));break;case"star5":ze(e,c,d,i/2,r/2,5,o(0,19098),-Math.PI/2);break;case"star6":ze(e,c,d,i/2,r/2,6,o(0,28868),0);break;case"star7":ze(e,c,d,i/2,r/2,7,o(0,34601),-Math.PI/2);break;case"star8":ze(e,c,d,i/2,r/2,8,o(0,29289),Math.PI/8);break;case"star10":ze(e,c,d,i/2,r/2,10,o(0,30902),-Math.PI/2);break;case"star12":ze(e,c,d,i/2,r/2,12,o(0,37720),0);break;case"star16":ze(e,c,d,i/2,r/2,16,o(0,37500),0);break;case"star24":ze(e,c,d,i/2,r/2,24,o(0,37500),0);break;case"star32":ze(e,c,d,i/2,r/2,32,o(0,37500),0);break;case"rightArrow":{const u=o(0,5e4),p=o(1,5e4),m=(r-r*p)/2,g=t+i*(1-u);e.moveTo(t,s+m),e.lineTo(g,s+m),e.lineTo(g,s),e.lineTo(t+i,d),e.lineTo(g,s+r),e.lineTo(g,s+r-m),e.lineTo(t,s+r-m),e.closePath();break}case"leftArrow":{const u=o(0,5e4),p=o(1,5e4),m=(r-r*p)/2,g=t+i*u;e.moveTo(t+i,s+m),e.lineTo(g,s+m),e.lineTo(g,s),e.lineTo(t,d),e.lineTo(g,s+r),e.lineTo(g,s+r-m),e.lineTo(t+i,s+r-m),e.closePath();break}case"upArrow":{const u=o(0,5e4),p=o(1,5e4),m=(i-i*p)/2,g=s+r*u;e.moveTo(t+m,s+r),e.lineTo(t+m,g),e.lineTo(t,g),e.lineTo(c,s),e.lineTo(t+i,g),e.lineTo(t+i-m,g),e.lineTo(t+i-m,s+r),e.closePath();break}case"downArrow":{const u=o(0,5e4),p=o(1,5e4),m=(i-i*p)/2,g=s+r*(1-u);e.moveTo(t+m,s),e.lineTo(t+m,g),e.lineTo(t,g),e.lineTo(c,s+r),e.lineTo(t+i,g),e.lineTo(t+i-m,g),e.lineTo(t+i-m,s),e.closePath();break}case"leftRightArrow":{const u=o(0,25e3),p=o(1,5e4),m=(r-r*p)/2,g=t+i*u,P=t+i*(1-u);e.moveTo(t,d),e.lineTo(g,s),e.lineTo(g,s+m),e.lineTo(P,s+m),e.lineTo(P,s),e.lineTo(t+i,d),e.lineTo(P,s+r),e.lineTo(P,s+r-m),e.lineTo(g,s+r-m),e.lineTo(g,s+r),e.closePath();break}case"upDownArrow":{const u=o(0,25e3),p=o(1,5e4),m=(i-i*p)/2,g=s+r*u,P=s+r*(1-u);e.moveTo(c,s),e.lineTo(t+i,g),e.lineTo(t+i-m,g),e.lineTo(t+i-m,P),e.lineTo(t+i,P),e.lineTo(c,s+r),e.lineTo(t,P),e.lineTo(t+m,P),e.lineTo(t+m,g),e.lineTo(t,g),e.closePath();break}case"chevron":{const u=o(0,5e4),p=i*u;e.moveTo(t,s),e.lineTo(t+i-p,s),e.lineTo(t+i,d),e.lineTo(t+i-p,s+r),e.lineTo(t,s+r),e.lineTo(t+p,d),e.closePath();break}case"pentagon5":case"homePlate":{const u=o(0,5e4);e.moveTo(t,s),e.lineTo(t+i*(1-u),s),e.lineTo(t+i,d),e.lineTo(t+i*(1-u),s+r),e.lineTo(t,s+r),e.closePath();break}case"arc":{const u=o(0,270)*Math.PI/180,p=o(1,288e5/6e4)*Math.PI/180;e.moveTo(c,d),e.arc(c,d,Math.min(i,r)/2,u,u+p),e.closePath();break}case"blockArc":{const u=(o(0,0)*360-90)*Math.PI/180,p=o(1,25e3)*360*Math.PI/180,m=o(2,25e3)*Math.min(i,r)/2,g=Math.min(i,r)/2,P=g-m;e.moveTo(c+g*Math.cos(u),d+g*Math.sin(u)),e.arc(c,d,g,u,u+p),e.arc(c,d,Math.max(1,P),u+p,u,!0),e.closePath();break}case"line":case"straightConnector1":e.moveTo(t,d),e.lineTo(t+i,d);break;case"bentConnector3":case"bentConnector4":case"bentConnector5":case"elbowConnector":e.moveTo(t,s),e.lineTo(t,d),e.lineTo(t+i,d),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":{Ba(e,t,s,i,r);break}case"lightningBolt":{e.moveTo(t+i*.6,s),e.lineTo(t+i*.2,s+r*.45),e.lineTo(t+i*.5,s+r*.45),e.lineTo(t+i*.4,s+r),e.lineTo(t+i*.8,s+r*.55),e.lineTo(t+i*.5,s+r*.55),e.closePath();break}case"moon":{e.arc(c+i*.1,d,r*.5,l(-120),l(120)),e.arc(c+i*.4,d,r*.45,l(120),l(-120),!0),e.closePath();break}case"noSmoking":{const u=Math.min(i,r)/2;e.arc(c,d,u,0,Math.PI*2),e.moveTo(c-u*.7,d+u*.7),e.lineTo(c+u*.7,d-u*.7);break}case"flowChartProcess":e.rect(t,s,i,r);break;case"flowChartDecision":e.moveTo(c,s),e.lineTo(t+i,d),e.lineTo(c,s+r),e.lineTo(t,d),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,d,u,-Math.PI/2,Math.PI/2),e.lineTo(t+u,s+r),e.arc(t+u,d,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(c,s+u,i/2,u,0,Math.PI,0),e.lineTo(t+i,s+r-u),e.ellipse(c,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(c-i*.1,s+r*.8),e.lineTo(c,s+r),e.lineTo(c+i*.1,s+r*.8),e.closePath();break}case"wedgeRoundRectCallout":{const 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(c+i*.1,s+r*.75),e.lineTo(c,s+r),e.lineTo(c-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(c,d-r*.05,i/2,r*.45,0,0,Math.PI*2),e.moveTo(c-i*.1,d+r*.4),e.lineTo(c,s+r),e.lineTo(c+i*.1,d+r*.4),e.closePath();break}case"cloudCallout":case"cloud":{e.beginPath();const u=[{cx:c-i*.22,cy:d-r*.12,r:i*.16},{cx:c-i*.07,cy:d-r*.22,r:i*.18},{cx:c+i*.1,cy:d-r*.22,r:i*.17},{cx:c+i*.25,cy:d-r*.12,r:i*.15},{cx:c+i*.35,cy:d+r*.05,r:i*.13},{cx:c-i*.3,cy:d+r*.05,r:i*.13}];for(const p of u)e.arc(p.cx,p.cy,p.r,0,Math.PI*2);e.rect(c-i*.35,d,i*.7,r*.25);break}case"smileyFace":{e.arc(c,d,Math.min(i,r)/2,0,Math.PI*2);break}case"donut":{const u=Math.min(i,r)/2,p=u*o(0,25e3);e.arc(c,d,u,0,Math.PI*2),e.arc(c,d,p,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(c-i*.35,s),e.bezierCurveTo(c-i*.45,s,c-i*.45,s,c-i*.45,s+u),e.lineTo(c-i*.45,d-u),e.bezierCurveTo(c-i*.45,d,c-i*.5,d,c-i*.5,d),e.bezierCurveTo(c-i*.5,d,c-i*.45,d,c-i*.45,d+u),e.lineTo(c-i*.45,s+r-u),e.bezierCurveTo(c-i*.45,s+r,c-i*.35,s+r,c-i*.35,s+r);break}case"irregularSeal1":case"irregularSeal2":{ze(e,c,d,i/2,r/2,12,o(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(c,d,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,d),e.lineTo(t+i-u,s+r),e.lineTo(t+u,s+r),e.lineTo(t,d),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(c,d,i/2,r/2,0,0,Math.PI*2);break}case"teardrop":{const u=Math.min(i,r)*.45;e.arc(c,d+u,u,-Math.PI,0),e.bezierCurveTo(c+u,d+u-u*.55,c+u*.1,d-r*.4,c,s),e.bezierCurveTo(c-u*.1,d-r*.4,c-u,d+u-u*.55,c-u,d+u),e.closePath();break}default:return e.rect(t,s,i,r),!1}return!0}function dt(e,n,t,s,i,r,a=0){for(let l=0;l<r;l++){const o=a+l/r*Math.PI*2,c=n+s*Math.cos(o),d=t+i*Math.sin(o);l===0?e.moveTo(c,d):e.lineTo(c,d)}e.closePath()}function ze(e,n,t,s,i,r,a=.5,l=-Math.PI/2){for(let o=0;o<r*2;o++){const c=l+o/(r*2)*Math.PI*2,d=o%2===1,h=d?s*a:s,u=d?i*a:i,p=n+h*Math.cos(c),m=t+u*Math.sin(c);o===0?e.moveTo(p,m):e.lineTo(p,m)}e.closePath()}function Ba(e,n,t,s,i){e.beginPath();const r=n+s/2,a=t+i*.25;e.moveTo(r,t+i*.9),e.bezierCurveTo(n-s*.1,t+i*.6,n-s*.1,a-i*.05,r-s*.25,a-i*.1),e.bezierCurveTo(r-s*.5+s*.05,t+i*.05,r-s*.03,t+i*.05,r,a-i*.15),e.bezierCurveTo(r+s*.03,t+i*.05,r+s*.5-s*.05,t+i*.05,r+s*.25,a-i*.1),e.bezierCurveTo(n+s*1.1,a-i*.05,n+s*1.1,t+i*.6,r,t+i*.9),e.closePath()}const cs=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0","#FF7F00","#9E480E"];function Oa(e){const n=e?.textContent?.trim();if(n==null||n==="")return null;const t=parseFloat(n);return isNaN(t)?n:t}function _t(e){if(!e)return[];const n=C(b(e,"ptCount"),"val",0),t=new Array(n).fill(null);for(const s of ge(e,"pt")){const i=C(s,"idx",0);t[i]=Oa(b(s,"v"))}return t}function $t(e){const n=b(e,"tx");if(!n)return null;const t=b(n,"v");if(t)return t.textContent.trim();const s=b(n,"strCache");if(s){const i=b(s,"pt"),r=i?b(i,"v"):null;return r?r.textContent.trim():null}return null}function un(e){const n=b(e,"cat")||b(e,"xVal");return n?_t(b(n,"strCache")||b(n,"numCache")):[]}function Et(e){const n=b(e,"val")||b(e,"yVal");return n?_t(b(n,"numCache")):[]}function at(e,n,t){const s=b(e,"spPr");if(s){const r=b(s,"solidFill");if(r){const a=ke(r),l=Se(a,t);if(l)return xe(l)}}const i=`accent${n%6+1}`;return t[i]?`#${t[i]}`:cs[n%cs.length]}function Zs(e,n){const t={};for(const s of ge(e,"dPt")){const i=C(b(s,"idx"),"val",-1);if(i<0)continue;const r=b(s,"spPr");if(!r)continue;const a=b(r,"solidFill");if(!a)continue;const l=ke(a),o=Se(l,n);o&&(t[i]=xe(o))}return t}function fn(e,n,t,s,i={}){const{padL:r=.12,padR:a=.06,padT:l=.08,padB:o=.1,legendH:c=.1,hasLegend:d=!0,hasTitle:h=!1}=i,u=h?s*.08:0,p=d?s*c:0;return{x:e+t*r,y:n+s*l+u,w:t*(1-r-a),h:s*(1-l-o)-p-u,legendY:n+s*(1-c*.7)}}function Ft(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 Le(e,n,t,s,i,r="#999",a=.7){e.save(),e.strokeStyle=r,e.lineWidth=a,e.setLineDash([]),e.beginPath(),e.moveTo(n,t),e.lineTo(s,i),e.stroke(),e.restore()}function ot(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 Js(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 Nt(e,n=!0){const t=e.filter(a=>typeof a=="number"&&isFinite(a));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=Js(i-s);return i=Math.ceil(i/r)*r,s=Math.floor(s/r)*r,{min:s,max:i,step:r}}function lt(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 Rt(e,n,t,s,i,r,a){if(!r.length)return;const l=Math.max(8,Math.min(14,s*.025))*a,o=s/Math.max(r.length,1);e.save(),e.font=`${l}px sans-serif`,e.textBaseline="middle";for(let c=0;c<r.length;c++){if(!r[c].name)continue;const d=n+o*c+l*.5;e.fillStyle=r[c].color,Ft(e,d,i-l/2,l*1.2,l),e.fill(),e.fillStyle="#444",e.fillText(r[c].name,d+l*1.5,i)}e.restore()}function Ua(e,n,t,s,i,r,a,l){const o=b(n,"barChart")||b(n,"bar3DChart"),c=!o||U(o,"barDir","col")!=="bar",d=U(o,"grouping","clustered"),h=d==="stacked"||d==="percentStacked",u=d==="percentStacked",p=ge(o,"ser"),m=p.map((k,j)=>({name:$t(k),values:Et(k),color:at(k,j,a),dptColors:Zs(k,a)}));if(!m.length)return;const g=un(p[0])||[],P=Math.max(g.length,m[0]?.values.length||0,1),y=fn(t,s,i,r,{hasLegend:m.length>1});let w;h?(w=Array.from({length:P},(k,j)=>m.reduce((N,F)=>N+(F.values[j]||0),0)),u&&(w=w.map(()=>100))):w=m.flatMap(k=>k.values);const x=Nt(w),_=Math.max(7,Math.min(11,y.w*.018))*l;e.font=`${_}px sans-serif`,e.textBaseline="middle";const v=Math.round((x.max-x.min)/x.step);if(c){e.save(),e.textAlign="right",e.fillStyle="#666";for(let T=0;T<=v;T++){const A=x.min+T*x.step,$=(A-x.min)/(x.max-x.min),z=y.y+y.h-$*y.h;ot(e,y.x,z,y.x+y.w,z),e.fillText(u?A+"%":lt(A),y.x-4*l,z)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";const k=y.w/P;for(let T=0;T<P;T++){const A=y.x+k*T+k/2,$=String(g[T]??T+1);e.fillText($,A,y.y+y.h+_*1.5)}e.restore(),Le(e,y.x,y.y,y.x,y.y+y.h),Le(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h);const j=y.w/P,N=j*.15,F=j-N*2,R=h?F:F/m.length;for(let T=0;T<P;T++){const A=y.x+j*T+N;let $=0;for(let z=0;z<m.length;z++){const Y=m[z];let O=Y.values[T]??0;if(u){const oe=m.reduce((fe,ee)=>fe+(ee.values[T]||0),0);O=oe?O/oe*100:0}const W=Y.dptColors[T]||Y.color,B=Math.abs(O)/(x.max-x.min)*y.h,Z=h?A:A+z*R,Q=h?($-x.min)/(x.max-x.min):Math.max(0,-x.min)/(x.max-x.min),L=y.y+y.h-Q*y.h,X=O>=0?L-B:L;e.save(),e.fillStyle=W,Ft(e,Z,X,h?F:R-1*l,B,2*l),e.fill();const ae=e.createLinearGradient(Z,X,Z,X+B*.3);ae.addColorStop(0,"rgba(255,255,255,0.18)"),ae.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=ae,e.fill(),e.restore(),h&&($+=Math.abs(O))}}}else{e.save(),e.textAlign="right",e.fillStyle="#666";const k=y.h/P;for(let T=0;T<P;T++){const A=y.y+k*T+k/2,$=String(g[T]??T+1);e.fillText($,y.x-4*l,A)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";for(let T=0;T<=v;T++){const A=x.min+T*x.step,$=(A-x.min)/(x.max-x.min),z=y.x+$*y.w;ot(e,z,y.y,z,y.y+y.h),e.fillText(u?A+"%":lt(A),z,y.y+y.h+_*1.5)}e.restore(),Le(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h),Le(e,y.x,y.y,y.x,y.y+y.h);const j=k*.15,N=k-j*2,F=h?N:N/m.length,R=y.x+-x.min/(x.max-x.min)*y.w;for(let T=0;T<P;T++){const A=y.y+k*T+j;let $=0;for(let z=0;z<m.length;z++){const Y=m[z];let O=Y.values[T]??0;if(u){const X=m.reduce((ae,oe)=>ae+(oe.values[T]||0),0);O=X?O/X*100:0}const W=Y.dptColors[T]||Y.color,B=Math.abs(O)/(x.max-x.min)*y.w,Z=h?A:A+z*F,Q=h?R+$/(x.max-x.min)*y.w:R,L=O>=0?Q:Q-B;e.save(),e.fillStyle=W,Ft(e,L,Z,B,h?N:F-1*l,2*l),e.fill(),e.restore(),h&&($+=Math.abs(O))}}}m.length>1&&Rt(e,t,s,i,y.legendY,m,l)}function Wa(e,n,t,s,i,r,a,l){const o=b(n,"lineChart")||b(n,"line3DChart"),c=ge(o,"ser"),d=c.map((y,w)=>({name:$t(y),values:Et(y),color:at(y,w,a),marker:U(b(y,"marker"),"symbol","none")!=="none",smooth:U(b(y,"smooth"),"val","0")==="1"}));if(!d.length)return;const h=un(c[0])||[],u=Math.max(h.length,d[0]?.values.length||0,1),p=fn(t,s,i,r,{hasLegend:!0}),m=Nt(d.flatMap(y=>y.values)),g=Math.max(7,Math.min(11,p.w*.018))*l,P=Math.round((m.max-m.min)/m.step);e.save(),e.textAlign="right",e.fillStyle="#666",e.font=`${g}px sans-serif`;for(let y=0;y<=P;y++){const w=m.min+y*m.step,x=(w-m.min)/(m.max-m.min),_=p.y+p.h-x*p.h;ot(e,p.x,_,p.x+p.w,_),e.fillText(lt(w),p.x-4*l,_)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666",e.font=`${g}px sans-serif`;for(let y=0;y<u;y++){const w=p.x+y/(u-1||1)*p.w;ot(e,w,p.y,w,p.y+p.h);const x=String(h[y]??y+1);e.fillText(x,w,p.y+p.h+g*1.5)}e.restore(),Le(e,p.x,p.y,p.x,p.y+p.h),Le(e,p.x,p.y+p.h,p.x+p.w,p.y+p.h);for(const y of d){const w=y.values.map((_,v)=>{const k=u>1?v/(u-1):.5,j=(_-m.min)/(m.max-m.min);return{x:p.x+k*p.w,y:p.y+p.h-j*p.h,v:_}}).filter(_=>typeof _.v=="number");if(w.length<2)continue;e.save(),e.beginPath(),e.moveTo(w[0].x,p.y+p.h);for(const _ of w)e.lineTo(_.x,_.y);if(e.lineTo(w[w.length-1].x,p.y+p.h),e.closePath(),e.fillStyle=y.color+"22",e.fill(),e.restore(),e.save(),e.strokeStyle=y.color,e.lineWidth=2*l,e.lineJoin="round",e.lineCap="round",e.beginPath(),y.smooth&&w.length>2){e.moveTo(w[0].x,w[0].y);for(let _=1;_<w.length-1;_++){const v=(w[_].x+w[_+1].x)/2,k=(w[_].y+w[_+1].y)/2;e.quadraticCurveTo(w[_].x,w[_].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 _ of w.slice(1))e.lineTo(_.x,_.y)}e.stroke(),e.restore();const x=3.5*l;for(const _ of w)e.save(),e.fillStyle=y.color,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.beginPath(),e.arc(_.x,_.y,x,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}Rt(e,t,s,i,p.legendY,d,l)}function Ga(e,n,t,s,i,r,a,l){const o=b(n,"areaChart")||b(n,"area3DChart"),c=U(o,"grouping","standard"),d=c==="percentStacked",h=c==="stacked"||d,p=ge(o,"ser").map((v,k)=>({name:$t(v),values:Et(v),color:at(v,k,a)})).reverse();if(!p.length)return;const m=Math.max(...p.map(v=>v.values.length),1),g=fn(t,s,i,r,{hasLegend:!0});let P=0;if(d)P=100;else for(let v=0;v<m;v++){const k=p.reduce((j,N)=>j+(N.values[v]||0),0);P=Math.max(P,k)}const y={min:0,max:P||100,step:Js(P||100)},w=Math.round((y.max-y.min)/y.step),x=Math.max(7,Math.min(11,g.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,j=(k-y.min)/(y.max-y.min),N=g.y+g.h-j*g.h;ot(e,g.x,N,g.x+g.w,N),e.fillText(d?k+"%":lt(k),g.x-4*l,N)}e.restore(),Le(e,g.x,g.y,g.x,g.y+g.h),Le(e,g.x,g.y+g.h,g.x+g.w,g.y+g.h);const _=new Array(m).fill(0);for(const v of p){e.save(),e.beginPath();const k=[];for(let j=0;j<m;j++){let N=v.values[j]??0;if(d){const z=p.reduce((Y,O)=>Y+(O.values[j]||0),0);N=z?N/z*100:0}const F=h?_[j]:0,R=F+Math.abs(N),T=(F-y.min)/(y.max-y.min),A=(R-y.min)/(y.max-y.min),$=g.x+j/(m-1||1)*g.w;k.push({x:$,y:g.y+g.h-A*g.h,baseY:g.y+g.h-T*g.h}),h&&(_[j]+=Math.abs(N))}e.moveTo(k[0].x,k[0].baseY);for(const j of k)e.lineTo(j.x,j.baseY);for(let j=k.length-1;j>=0;j--)e.lineTo(k[j].x,k[j].y);e.closePath(),e.fillStyle=v.color+"cc",e.fill(),e.beginPath(),e.moveTo(k[0].x,k[0].y);for(const j of k.slice(1))e.lineTo(j.x,j.y);e.strokeStyle=v.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Rt(e,t,s,i,g.legendY,[...p].reverse(),l)}function ds(e,n,t,s,i,r,a,l){const o=b(n,"pieChart")||b(n,"pie3DChart"),c=b(n,"doughnutChart"),d=o||c,h=!!c,u=ge(d,"ser");if(!u.length)return;const p=u[0],m=Et(p).map(T=>typeof T=="number"&&T>0?T:0),g=un(p),P=Zs(p,a),y=m.reduce((T,A)=>T+A,0);if(!y)return;const w=Math.min(i,r)*.38,x=t+i*.44,_=s+r*.5,v=h?w*.55:0;let k=-Math.PI/2;for(let T=0;T<m.length;T++){if(!m[T])continue;const A=m[T]/y*Math.PI*2,$=P[T]||at(p,T,a),z=k+A/2,Y=T===0?w*.04:0,O=Y*Math.cos(z),W=Y*Math.sin(z);e.save(),e.beginPath(),e.moveTo(x+O,_+W),e.arc(x+O,_+W,w,k,k+A),e.closePath(),e.fillStyle=$,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,_,v,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.restore());const B=m[T]/y;if(B>.05){const Z=x+O+w*.65*Math.cos(z),Q=_+W+w*.65*Math.sin(z),L=Math.max(8,Math.min(13,w*.15))*l;e.save(),e.fillStyle="#fff",e.font=`bold ${L}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(Math.round(B*100)+"%",Z,Q),e.restore()}k+=A}if(h){const T=Math.max(10,Math.min(16,w*.22))*l;e.save(),e.font=`bold ${T}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="middle",e.fillText(lt(y),x,_),e.restore()}const j=t+i*.78,N=Math.max(8,Math.min(12,i*.022))*l;e.font=`${N}px sans-serif`,e.textBaseline="middle";const F=N*1.8,R=_-m.length*F/2;for(let T=0;T<m.length;T++){const A=j,$=R+T*F,z=P[T]||at(p,T,a);e.fillStyle=z,Ft(e,A,$-N*.5,N*1.2,N),e.fill(),e.fillStyle="#444";const Y=String(g[T]??`Item ${T+1}`);e.fillText(Y,A+N*1.5,$)}}function qa(e,n,t,s,i,r,a,l){const o=b(n,"scatterChart")||b(n,"bubbleChart"),d=ge(o,"ser").map((k,j)=>{const N=_t(b(b(k,"xVal"),"numCache")),F=_t(b(b(k,"yVal"),"numCache")),R=_t(b(b(k,"bubbleSize"),"numCache"));return{name:$t(k),color:at(k,j,a),points:N.map((T,A)=>({x:T,y:F[A],r:R[A]})).filter(T=>typeof T.x=="number"&&typeof T.y=="number")}});if(!d.length)return;const h=fn(t,s,i,r,{hasLegend:d.length>1}),u=d.flatMap(k=>k.points.map(j=>j.x)),p=d.flatMap(k=>k.points.map(j=>j.y)),m=Nt(u,!1),g=Nt(p),P=Math.max(7,Math.min(11,h.w*.018))*l,y=Math.round((m.max-m.min)/m.step),w=Math.round((g.max-g.min)/g.step);e.font=`${P}px sans-serif`,e.save(),e.textAlign="center",e.fillStyle="#666";for(let k=0;k<=y;k++){const j=m.min+k*m.step,N=(j-m.min)/(m.max-m.min),F=h.x+N*h.w;ot(e,F,h.y,F,h.y+h.h),e.fillText(lt(j),F,h.y+h.h+P*1.5)}e.textAlign="right";for(let k=0;k<=w;k++){const j=g.min+k*g.step,N=(j-g.min)/(g.max-g.min),F=h.y+h.h-N*h.h;ot(e,h.x,F,h.x+h.w,F),e.fillText(lt(j),h.x-4*l,F)}e.restore(),Le(e,h.x,h.y,h.x,h.y+h.h),Le(e,h.x,h.y+h.h,h.x+h.w,h.y+h.h);const x=d.flatMap(k=>k.points.map(j=>j.r??1)),_=Math.max(...x.filter(k=>typeof k=="number"),1),v=Math.min(h.w,h.h)*.06;for(const k of d)for(const j of k.points){const N=h.x+(j.x-m.min)/(m.max-m.min)*h.w,F=h.y+h.h-(j.y-g.min)/(g.max-g.min)*h.h,R=j.r!=null?j.r/_*v:4*l;e.save(),e.fillStyle=k.color+"aa",e.strokeStyle=k.color,e.lineWidth=1*l,e.beginPath(),e.arc(N,F,R,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}d.length>1&&Rt(e,t,s,i,h.legendY,d,l)}function Ka(e,n,t,s,i,r,a,l){const o=b(n,"radarChart"),c=ge(o,"ser"),d=c.map((w,x)=>({name:$t(w),values:Et(w),color:at(w,x,a)}));if(!d.length)return;const h=un(c[0])||[],u=h.length||d[0]?.values.length||0;if(u<3)return;const p=t+i*.5,m=s+r*.5,g=Math.min(i,r)*.34,P=Nt(d.flatMap(w=>w.values)),y=4;for(let w=1;w<=y;w++){const x=g*w/y;e.save(),e.beginPath();for(let _=0;_<u;_++){const v=_/u*Math.PI*2-Math.PI/2,k=p+x*Math.cos(v),j=m+x*Math.sin(v);_===0?e.moveTo(k,j):e.lineTo(k,j)}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;Le(e,p,m,p+g*Math.cos(x),m+g*Math.sin(x));const _=p+(g+16*l)*Math.cos(x),v=m+(g+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),_,v),e.restore()}for(const w of d){const x=w.values.map((_,v)=>{const k=v/u*Math.PI*2-Math.PI/2,j=(_-P.min)/(P.max-P.min);return{x:p+g*j*Math.cos(k),y:m+g*j*Math.sin(k)}});e.save(),e.beginPath(),e.moveTo(x[0].x,x[0].y);for(const _ of x.slice(1))e.lineTo(_.x,_.y);e.closePath(),e.fillStyle=w.color+"44",e.fill(),e.strokeStyle=w.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}Rt(e,t,s,i,s+r-20*l,d,l)}function Xa(e,n,t,s,i,r){const a=b(b(n,"chart"),"title");if(!a)return!1;const l=b(a,"tx");if(!l)return!1;let o="";for(const d of ge(l,"t"))o+=d.textContent;if(!o.trim())return!1;const c=Math.max(10,Math.min(16,i*.03))*r;return e.save(),e.font=`bold ${c}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="top",e.fillText(o,t+i/2,s+6*r),e.restore(),!0}function Va(e,n,t,s,i,r,a,l){if(!n)return;const o=n;e.save(),e.fillStyle="#fff",Ft(e,t,s,i,r,4*l),e.fill(),e.strokeStyle="#ddd",e.lineWidth=.5,e.stroke(),e.restore();const d=Xa(e,o,t,s,i,l)?s+Math.min(r*.08,24*l):s,h=r-(d-s),u=b(o,"plotArea");if(!u)return;const p=b(u,"bar3DChart")||b(u,"barChart"),m=b(u,"line3DChart")||b(u,"lineChart"),g=b(u,"area3DChart")||b(u,"areaChart"),P=b(u,"pie3DChart")||b(u,"pieChart"),y=b(u,"doughnutChart"),w=b(u,"scatterChart")||b(u,"bubbleChart"),x=b(u,"radarChart");if(p)Ua(e,u,t,d,i,h,a,l);else if(m)Wa(e,u,t,d,i,h,a,l);else if(g)Ga(e,u,t,d,i,h,a,l);else if(y)ds(e,u,t,d,i,h,a,l);else if(P)ds(e,u,t,d,i,h,a,l);else if(w)qa(e,u,t,d,i,h,a,l);else if(x)Ka(e,u,t,d,i,h,a,l);else{e.save(),e.fillStyle="#aaa",e.font=`${12*l}px sans-serif`,e.textAlign="center",e.textBaseline="middle";const _=u.firstElementChild;e.fillText(_?.localName??"Chart",t+i/2,s+r/2),e.restore()}}function sn(e,n,t=0,s=1){return(e?parseInt(e.getAttribute(n)||t,10):t)*s}function ei(e,n){if(!e)return null;const t=ke(e);if(!t)return null;const s=Se(t,n);return s?xe(s):null}function Ha(e,n,t,s,i,r,a){const l=b(n,"bevelT"),o=b(n,"bevelB"),c=l||o;if(!c)return;const d=Math.max(2*a,sn(c,"w",76200,a)),h=Math.max(2*a,sn(c,"h",76200,a)),p=U(c,"prst","circle").toLowerCase().includes("in"),m=Math.min(d,i*.3),g=Math.min(h,r*.3),P=p?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.35)",y=p?"rgba(255,255,255,0.20)":"rgba(0,0,0,0.20)",w=e.createLinearGradient(t,s,t,s+g);w.addColorStop(0,P),w.addColorStop(1,"rgba(255,255,255,0)"),e.save(),e.fillStyle=w,e.fillRect(t,s,i,g);const x=e.createLinearGradient(t,s+r-g,t,s+r);x.addColorStop(0,"rgba(0,0,0,0)"),x.addColorStop(1,y),e.fillStyle=x,e.fillRect(t,s+r-g,i,g);const _=e.createLinearGradient(t,s,t+m,s);_.addColorStop(0,P),_.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=_,e.fillRect(t,s,m,r);const v=e.createLinearGradient(t+i-m,s,t+i,s);v.addColorStop(0,"rgba(0,0,0,0)"),v.addColorStop(1,y),e.fillStyle=v,e.fillRect(t+i-m,s,m,r),e.restore()}function Ya(e,n,t,s,i,r,a,l){const o=sn(n,"extrusionH",0,l);if(o<1*l)return;const c=b(n,"extrusionClr")||b(n,"contourClr"),d=ei(c,t)||"rgba(0,0,0,0.3)",h=Math.min(o/914400*72*l,Math.min(r,a)*.15),u=h*.7,p=h*.7;e.save(),e.fillStyle=d,e.beginPath(),e.moveTo(s+r,i),e.lineTo(s+r+u,i+p),e.lineTo(s+r+u,i+a+p),e.lineTo(s+r,i+a),e.closePath(),e.fill(),e.beginPath(),e.moveTo(s,i+a),e.lineTo(s+u,i+a+p),e.lineTo(s+r+u,i+a+p),e.lineTo(s+r,i+a),e.closePath(),e.fill(),e.restore()}function Qa(e,n,t,s,i,r,a,l){const o=sn(n,"contourW",0,l);if(o<.5)return;const c=b(n,"contourClr"),d=ei(c,t)||"#888888",h=Math.max(.5,o/914400*72*l);e.save(),e.strokeStyle=d,e.lineWidth=h,e.strokeRect(s,i,r,a),e.restore()}function Za(e,n,t,s,i,r){if(!n)return()=>{};const a=b(n,"camera");if(!a)return()=>{};const l=U(a,"prst","orthographicFront"),o=b(a,"rot");if(l.toLowerCase().includes("orthographic")&&!o)return()=>{};const d=o?C(o,"lat",0)/6e4:0,h=o?C(o,"lon",0)/6e4:0;o&&C(o,"rev",0)/6e4;const u=d*Math.PI/180,p=h*Math.PI/180,m=Math.sin(p)*.15,g=Math.sin(u)*.08;return e.save(),e.transform(1,g,m,1,t*-m,s*-g),()=>e.restore()}function Ja(e,n,t,s,i,r){if(!n)return;const a=b(n,"lightRig");if(!a)return;const l=U(a,"dir","t"),o=U(a,"rig","balanced"),c={t:{gx:t+i/2,gy:s},b:{gx:t+i/2,gy:s+r},l:{gx:t,gy:s+r/2},r:{gx:t+i,gy:s+r/2},tl:{gx:t,gy:s},tr:{gx:t+i,gy:s},bl:{gx:t,gy:s+r},br:{gx:t+i,gy:s+r}},{gx:d,gy:h}=c[l]||c.t,u=o==="flat"?.08:o==="balanced"?.14:o==="sunrise"?.2:o==="harsh"?.28:.12,p=Math.sqrt(i*i+r*r),m=e.createRadialGradient(d,h,0,d,h,p);m.addColorStop(0,`rgba(255,255,255,${u})`),m.addColorStop(.5,"rgba(255,255,255,0)"),m.addColorStop(1,`rgba(0,0,0,${u*.5})`),e.save(),e.fillStyle=m,e.fillRect(t,s,i,r),e.restore()}function eo(e,n,t,s,i,r,a,l){if(!n)return{applyCamera:()=>()=>{},overlay:()=>{}};const o=b(n,"sp3d")||b(n,"scene3d")?.parentNode&&null,c=b(n,"scene3d");o&&Ya(e,o,t,s,i,r,a,l);const d=Za(e,c,s,i);return{overlay(){o&&(Ha(e,o,s,i,r,a,l),Qa(e,o,t,s,i,r,a,l)),c&&Ja(e,c,s,i,r,a)},cleanup:d}}function to(e){return e?!!(b(e,"sp3d")||b(e,"scene3d")):!1}async function Mt(e,n,t,s,i,r,a,l,o){if(!n)return!1;const c=n.localName;if(c==="noFill")return!1;if(c==="solidFill"){const d=ke(n),h=Se(d,l);return h?(e.fillStyle=xe(h),e.fill(),!0):!1}if(c==="gradFill"){const d=b(n,"gsLst");if(!d)return!1;const h=ge(d,"gs").map(y=>{const w=C(y,"pos",0)/1e5,x=ke(y),_=Se(x,l);return{pos:w,color:_}}).sort((y,w)=>y.pos-w.pos);if(h.length<2)return!1;const u=b(n,"lin"),p=b(n,"path"),m=t+i/2,g=s+r/2;let P;if(u||!u&&!p){const x=(C(u,"ang",0)/6e4-90)*Math.PI/180,_=Math.cos(x),v=Math.sin(x),k=Math.abs(i*_)+Math.abs(r*v),j=m-k/2*_,N=g-k/2*v,F=m+k/2*_,R=g+k/2*v;P=e.createLinearGradient(j,N,F,R)}else{const y=b(p,"fillToRect"),w=C(y,"l",5e4)/1e5,x=C(y,"t",5e4)/1e5,_=C(y,"r",5e4)/1e5,v=C(y,"b",5e4)/1e5,k=t+i*(w+(1-w-_)/2),j=s+r*(x+(1-x-v)/2),N=Math.sqrt(i*i+r*r)/2;P=e.createRadialGradient(k,j,0,m,g,N)}for(const y of h)y.color&&P.addColorStop(y.pos,xe(y.color));return e.fillStyle=P,e.fill(),!0}if(c==="blipFill"){const d=b(n,"blip"),h=d?d.getAttribute("r:embed")||d.getAttribute("embed"):null;if(h&&o&&o[h]){const u=o[h],p=b(n,"stretch"),m=p?b(p,"fillRect"):null;let g=t,P=s,y=i,w=r;if(m){const k=C(m,"l",0)/1e5,j=C(m,"t",0)/1e5,N=C(m,"r",0)/1e5,F=C(m,"b",0)/1e5;g=t+i*k,P=s+r*j,y=i-i*k-i*N,w=r-r*j-r*F}if(b(n,"tile")){const k=e.createPattern(u,"repeat");if(k)return e.fillStyle=k,e.fill(),!0}const _=b(n,"alphaModFix")||b(d,"alphaModFix"),v=_?C(_,"amt",1e5)/1e5:1;return e.save(),e.clip(),v<1&&(e.globalAlpha=v),e.drawImage(u,g,P,y,w),e.restore(),!0}return!1}if(c==="pattFill"){const d=b(n,"fgClr"),h=b(n,"bgClr"),u=d?Se(ke(d),l):{r:0,g:0,b:0,a:1},p=h?Se(ke(h),l):{r:255,g:255,b:255,a:1},m=xe(u),g=xe(p),P=U(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=xe(u),e.fill(),!0;switch(y.fillStyle=g,y.fillRect(0,0,x,x),y.fillStyle=m,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 _=e.createPattern(w,"repeat");return _?(e.fillStyle=_,e.fill(),!0):(e.fillStyle=xe(u,(u.a??1)*.4),e.fill(),!0)}return!1}async function qe(e,n){const t=n.split("/"),s=t.pop(),i=[...t,"_rels",s+".rels"].join("/"),r=e[i];if(!r)return{};const a=new TextDecoder().decode(r),l=Pe(a),o={};for(const c of Array.from(l.getElementsByTagName("Relationship"))){const d=c.getAttribute("Id"),h=c.getAttribute("Target"),u=c.getAttribute("Type")||"",p=c.getAttribute("TargetMode")||"Internal";let m=h;if(p!=="External")if(h.startsWith("/"))m=h.slice(1);else{const g=n.split("/");g.pop();const P=h.split("/");for(const y of P)y===".."?g.pop():y!=="."&&g.push(y);m=g.join("/")}o[d]={target:h,fullPath:m,type:u,external:p==="External"}}return o}async function Yt(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 a=r.fullPath.split(".").pop().toLowerCase();if(s.has(a))try{const l=e[r.fullPath];if(!l)continue;const c={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",svg:"image/svg+xml"}[a]||"image/png",d=new Blob([l],{type:c}),h=URL.createObjectURL(d),u=await new Promise((p,m)=>{const g=new Image;g.onload=()=>p(g),g.onerror=()=>p(null),g.src=h});t[i]=u}catch{}}return t}function ti(e,n,t){if(!e)return n*1.2;const s=b(e,"spcPct"),i=b(e,"spcPts");return s?n*(C(s,"val",1e5)/1e5):i?C(i,"val",0)/100*12700*(t||1):n*1.2}function no(e,n,t,s){if(!e||b(e,"buNone"))return null;const i=b(e,"buChar"),r=b(e,"buAutoNum");if(!i&&!r)return null;let a=null;const l=b(e,"buClr");if(l){const m=ke(l);a=Se(m,t)}const o=b(e,"buSzPct"),c=b(e,"buSzPts");let d=1;o&&(d=C(o,"val",1e5)/1e5);const h=c?C(c,"val",0)/100:null;let u=null;const p=b(e,"buFont");if(p){const m=p.getAttribute("typeface");m&&(u=m)}return i?{type:"char",char:i.getAttribute("char")||"•",color:a,sizePct:d,sizePts:h,fontFamily:u}:r?{type:"autoNum",numType:r.getAttribute("type")||"arabicPeriod",startAt:C(r,"startAt",1),color:a,sizePct:d,sizePts:h,fontFamily:u}:null}function so(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return us(n).toLowerCase()+".";case"romanUcPeriod":return us(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 us(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 io(e,n,t,s,i){if(!n)return;const r=e.font.match(/(d+(?:.d+)?)px/),a=r?parseFloat(r[1]):16,l=n.sizePts!=null?n.sizePts*(a/12):a*n.sizePct;e.save(),n.color&&(e.fillStyle=xe(n.color),e.strokeStyle=e.fillStyle);const o=n.fontFamily?'"'+n.fontFamily+'", sans-serif':e.font.split(/\d+px\s+/)[1]||"sans-serif";if(e.font=l+"px "+o,n.type==="char")e.fillText(n.char,t,s);else if(n.type==="autoNum"){const c=n.numType+":"+n.startAt;i[c]===void 0&&(i[c]=n.startAt);const d=so(n.numType,i[c]);i[c]++,e.fillText(d,t,s)}e.restore()}async function rn(e,n,t,s,i,r,a,l,o,c=1800){if(!n)return;const d=b(n,"bodyPr"),h=U(d,"anchor","t"),u=U(d,"wrap","square"),p=U(d,"vert","horz"),m=C(d,"lIns",91440)*a,g=C(d,"tIns",45720)*a,P=C(d,"rIns",91440)*a,y=C(d,"bIns",45720)*a,w=t+m,x=s+g,_=i-m-P,v=r-g-y,k=u!=="none",j=p==="vert"||p==="vert270"||p==="eaVert";j&&(e.save(),p==="vert270"?(e.translate(t+i,s),e.rotate(Math.PI/2)):(e.translate(t,s+r),e.rotate(-Math.PI/2)));const N=b(d,"normAutoFit")||b(n,"normAutoFit");b(d,"spAutoFit")||b(n,"spAutoFit");const F=N?N.getAttribute("fontScale"):null;let R=F?parseInt(F,10)/1e5:1;const T=b(n,"lstStyle"),A=T?b(T,"defRPr"):null;function $(Q,L,X,ae){const oe=Q?Q.getAttribute(X):null;if(oe!==null&&oe!=="")return oe;const fe=L?L.getAttribute(X):null;if(fe!==null&&fe!=="")return fe;const ee=A?A.getAttribute(X):null;return ee!==null&&ee!==""?ee:ae}const z=ge(n,"p"),Y=[];let O=0;for(const Q of z){const L=b(Q,"pPr"),X=U(L,"algn","l");C(L,"lvl",0);const ae=C(L,"marL",0)*a,oe=C(L,"indent",0)*a,fe=L?no(L,H,l):null,ee=b(L,"spcBef"),V=b(L,"spcAft"),be=b(L,"lnSpc"),H=b(L,"defRPr");let re=c;if(A){const ne=A.getAttribute("sz");ne&&(re=parseInt(ne,10))}if(H){const ne=H.getAttribute("sz");ne&&(re=parseInt(ne,10))}let ue=0,K=0;if(ee){const ne=b(ee,"spcPct"),ie=b(ee,"spcPts");ne?ue=re*127*a*(C(ne,"val",0)/1e5):ie&&(ue=C(ie,"val",0)*jt*a/100)}if(V){const ne=b(V,"spcPct"),ie=b(V,"spcPts");ne?K=re*127*a*(C(ne,"val",0)/1e5):ie&&(K=C(ie,"val",0)*jt*a/100)}const le=[];for(const ne of Q.children){const ie=ne.localName;(ie==="r"||ie==="br"||ie==="fld")&&le.push(ne)}if(le.length===0){const ne=b(Q,"endParaRPr"),se=C(ne||H,"sz",re)*127*a*R;Y.push({lines:[""],algn:X,marL:ae,spaceBefore:ue,spaceAfter:K,szPx:se,lnSpc:be,runs:[],emptyPara:!0,bullet:fe}),O+=ue+se*1.2+K;continue}let pe=[],he=[],D=0;for(const ne of le){if(ne.localName==="br"){pe.push({runs:he,maxSzPx:Math.max(D,re*127*a)}),he=[],D=0;continue}const ie=b(ne,"rPr"),se=b(ne,"t");let ve=se?se.textContent:"";const me=Qs(ie,H,a*R,o,re,A);e.font=me.fontStr;const ce=me.szPx;ce>D&&(D=ce);const _e=Da(ie,H,l),je=$(ie,H,"u","none")!=="none",I=$(ie,H,"strike","noStrike")!=="noStrike",G=parseInt($(ie,H,"baseline","0"),10);if(k){const Ce=ve.split(" ");for(let Ue=0;Ue<Ce.length;Ue++){const Ie=Ce[Ue];let et=oe+ae;for(const Lt of he)e.font=Lt.fontInfo.fontStr,et+=e.measureText(Lt.text).width;e.font=me.fontStr;const tt=e.measureText(Ie).width,xn=he.length?e.measureText(" ").width:0;if(et+xn+tt>_&&he.length>0)pe.push({runs:he,maxSzPx:Math.max(D,ce)}),he=[{text:Ie,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:I,baseline:G}],D=ce;else{if(he.length>0){const Lt={text:" ",rPr:ie,fontInfo:me,color:_e,underline:!1,strikethrough:!1,baseline:G};he.push(Lt)}he.push({text:Ie,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:I,baseline:G})}}}else he.push({text:ve,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:I,baseline:G}),ce>D&&(D=ce)}he.length>0&&pe.push({runs:he,maxSzPx:Math.max(D,re*127*a)});const te=be?ti(be,re*127*a*R,a):null;Y.push({lines:pe,algn:X,marL:ae,indent:oe,spaceBefore:ue,spaceAfter:K,lnSpcPx:te,emptyPara:!1,bullet:fe});for(const ne of pe)O+=ue+(te||ne.maxSzPx*1.2)+K}if(N&&!F&&O>v&&v>0){let Q=.3,L=1;for(let X=0;X<8;X++){const ae=(Q+L)/2;let oe=0;for(const fe of z){const ee=b(fe,"pPr"),V=ee?b(ee,"defRPr"):null;let be=c;if(A){const te=A.getAttribute("sz");te&&(be=parseInt(te,10))}if(V){const te=V.getAttribute("sz");te&&(be=parseInt(te,10))}const H=Array.from(fe.children).filter(te=>["r","br","fld"].includes(te.localName)),re=be*127*a*ae;if(H.length===0){oe+=re*1.2;continue}const ue=H.reduce((te,ne)=>{const ie=b(ne,"t");return te+(ie?ie.textContent.length:0)},0),K=_>0?_:i,le=ue>0?H.reduce((te,ne)=>{const ie=b(ne,"t");return te+(ie?ie.textContent:"")},"").slice(0,20):"W";e.font=`${re}px sans-serif`;const pe=le.length>0?e.measureText(le).width/le.length:re*.6,he=Math.max(1,Math.floor(K/pe)),D=Math.max(1,Math.ceil(ue/he));oe+=D*re*1.2}oe<=v?Q=ae:L=ae}R=(Q+L)/2}let W=x;h==="ctr"?W=x+(v-O)/2:h==="b"&&(W=x+v-O);let B=W;const Z={};for(const Q of Y){const{lines:L,algn:X,marL:ae,indent:oe,spaceBefore:fe,spaceAfter:ee,lnSpcPx:V,emptyPara:be,bullet:H}=Q;if(B+=fe,be){B+=L[0]?V||Q.szPx*1.2:12*a,B+=ee;continue}for(const re of L){const{runs:ue,maxSzPx:K}=re,le=V||K*1.2,pe=B+K*.85;let he=0;for(const se of ue)e.font=se.fontInfo.fontStr,he+=e.measureText(se.text).width;let D=w+ae;X==="ctr"?D=w+(_-he)/2:X==="r"&&(D=w+_-he);const te=re===L[0];if(H&&te){const se=w+ae+oe;io(e,H,se,pe,Z)}let ne=0;if(X==="just"&&!(re===L[L.length-1])){let ve=0;for(const ce of ue)e.font=ce.fontInfo.fontStr,ve+=(ce.text.match(/ /g)||[]).length;const me=_-ae-he;ve>0&&me>0&&(ne=me/ve)}const ie=(se,ve,me,ce,_e,je)=>{e.font=ce.fontStr;const I=e.measureText(se).width;e.fillText(se,ve,me);const G=Math.max(.5,ce.szPx*.07);return _e&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=G,e.beginPath(),e.moveTo(ve,me+G*1.5),e.lineTo(ve+I,me+G*1.5),e.stroke(),e.restore()),je&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=G,e.beginPath(),e.moveTo(ve,me-ce.szPx*.3),e.lineTo(ve+I,me-ce.szPx*.3),e.stroke(),e.restore()),I};for(const se of ue){const ve=se.color;e.fillStyle=ve?xe(ve):"#000000";let me=pe,ce=se.fontInfo;if(se.baseline!==0){const _e=ce.szPx*.65,je=`${ce.italic?"italic ":""}${ce.bold?"bold ":""}${_e}px "${ce.family}", sans-serif`;ce={...ce,szPx:_e,fontStr:je},se.baseline>0?me=pe-se.fontInfo.szPx*.38:me=pe+se.fontInfo.szPx*.12}if(ne>0&&se.text.includes(" ")){e.font=ce.fontStr;const _e=se.text.split(" ");for(let je=0;je<_e.length;je++){const I=ie(_e[je],D,me,ce,se.underline,se.strikethrough);D+=I,je<_e.length-1&&(e.font=ce.fontStr,D+=e.measureText(" ").width+ne)}}else{e.font=ce.fontStr;const _e=e.measureText(se.text).width;ie(se.text,D,me,ce,se.underline,se.strikethrough),D+=_e}}B+=le}B+=ee}j&&e.restore()}function ni(e,n,t,s){const i=b(n,"effectLst");if(!i)return()=>{};const r=b(i,"outerShdw"),a=b(i,"innerShdw"),l=r||a;if(l){const c=C(l,"blurRad",38100)*s,d=C(l,"dist",38100)*s,u=C(l,"dir",27e5)/6e4*Math.PI/180,p=d*Math.cos(u),m=d*Math.sin(u),g=ke(l),P=Se(g,t),y=P?xe(P):"rgba(0,0,0,0.35)";e.shadowBlur=Math.min(c,40),e.shadowOffsetX=p,e.shadowOffsetY=m,e.shadowColor=y}const o=b(i,"glow");if(o){const c=C(o,"rad",0)*s,d=ke(o),h=Se(d,t);h&&(e.shadowBlur=Math.min(c,30),e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor=xe(h))}return()=>{e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor="transparent"}}async function hn(e,n,t,s,i,r,a,l=null,o=null){const c=b(n,"spPr"),d=b(c,"xfrm");let h=0,u=0,p=0,m=0,g=0,P=!1,y=!1;if(d){const W=b(d,"off"),B=b(d,"ext");W&&(h=C(W,"x",0)*a,u=C(W,"y",0)*a),B&&(p=C(B,"cx",0)*a,m=C(B,"cy",0)*a),g=C(d,"rot",0)/6e4,P=U(d,"flipH","0")==="1",y=U(d,"flipV","0")==="1"}else{const W=ai(n,o);if(W)h=W.x*a,u=W.y*a,p=W.w*a,m=W.h*a;else return}if(p<=0||m<=0)return;if(l){const{grpOff:W,grpExt:B,chOff:Z,chExt:Q}=l,L=B.cx/Q.cx,X=B.cy/Q.cy;h=W.x+(h/a-Z.x)*L*a,u=W.y+(u/a-Z.y)*X*a,p=p*L,m=m*X}const w=h+p/2,x=u+m/2;e.save(),(g!==0||P||y)&&(e.translate(w,x),g!==0&&e.rotate(g*Math.PI/180),P&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x));const _=b(c,"prstGeom"),v=b(c,"custGeom"),k=_?U(_,"prst","rect"):"rect",j={};if(_){const W=b(_,"avLst");if(W){let B=0;for(const Z of ge(W,"gd")){const L=U(Z,"fmla","").match(/val\s+(-?\d+)/);L&&(j[B]=parseInt(L[1])),B++}}}const N=()=>{const W=["noFill","solidFill","gradFill","blipFill","pattFill","grpFill"];for(const Z of W){const Q=b(c,Z);if(Q)return Q}const B=b(n,"style");if(B){const Z=b(B,"fillRef");if(Z){if(C(Z,"idx",1)===0)return Pe("<noFill/>").documentElement;const L=ke(Z);if(L)return Pe('<solidFill xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'">'+L.outerHTML+"</solidFill>").documentElement}}return null},F=()=>{const W=b(c,"ln");if(W)return W;const B=b(n,"style");if(B){const Z=b(B,"lnRef");if(Z){if(C(Z,"idx",1)===0)return null;const L=ke(Z);if(L)return Pe('<ln xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'"><solidFill>'+L.outerHTML+"</solidFill></ln>").documentElement}}return null};if(v){const W=b(v,"pathLst");if(W)for(const Z of ge(W,"path")){const Q=C(Z,"w",1)||1,L=C(Z,"h",1)||1,X=p/Q,ae=m/L;e.beginPath();for(const ee of Z.children)switch(ee.localName){case"moveTo":{const V=b(ee,"pt");V&&e.moveTo(h+C(V,"x",0)*X,u+C(V,"y",0)*ae);break}case"lnTo":{const V=b(ee,"pt");V&&e.lineTo(h+C(V,"x",0)*X,u+C(V,"y",0)*ae);break}case"cubicBezTo":{const V=ge(ee,"pt");V.length>=3&&e.bezierCurveTo(h+C(V[0],"x",0)*X,u+C(V[0],"y",0)*ae,h+C(V[1],"x",0)*X,u+C(V[1],"y",0)*ae,h+C(V[2],"x",0)*X,u+C(V[2],"y",0)*ae);break}case"quadBezTo":{const V=ge(ee,"pt");V.length>=2&&e.quadraticCurveTo(h+C(V[0],"x",0)*X,u+C(V[0],"y",0)*ae,h+C(V[1],"x",0)*X,u+C(V[1],"y",0)*ae);break}case"arcTo":{const V=C(ee,"wR",0)*X,be=C(ee,"hR",0)*ae,H=C(ee,"stAng",0)/6e4*Math.PI/180,re=C(ee,"swAng",0)/6e4*Math.PI/180,ue=e._lastX||h,K=e._lastY||u,le=ue-V*Math.cos(H),pe=K-be*Math.sin(H);V===be?e.arc(le,pe,V,H,H+re,re<0):e.ellipse(le,pe,V,be,0,H,H+re,re<0);break}case"close":e.closePath();break}const oe=N();oe&&await Mt(e,oe,h,u,p,m,a,i,s);const fe=F();fe&&mt(e,fe,i,a)}e.restore();const B=b(n,"txBody");if(B){e.save(),e.beginPath(),e.rect(h,u,p,m),e.clip();const Z=Nn(n);await rn(e,B,h,u,p,m,a,i,r,Z),e.restore()}return}e.beginPath(),nn(e,k,h,u,p,m,j);const R=ni(e,c,i,a),T=h,A=u,$=p,z=m,Y=to(c)?eo(e,c,i,T,A,$,z,a):null;try{const W=N();let B=!1;W&&(B=await Mt(e,W,h,u,p,m,a,i,s)),Y&&Y.overlay();const Z=F();Z?mt(e,Z,i,a):B||(k==="line"||k==="straightConnector1")&&(e.strokeStyle="#000",e.lineWidth=1,e.stroke())}finally{R(),Y?.cleanup&&Y.cleanup()}e.restore();const O=b(n,"txBody");if(O){e.save(),(g!==0||P||y)&&(e.translate(w,x),g!==0&&e.rotate(g*Math.PI/180),P&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x)),e.beginPath(),e.rect(h,u,p,m),e.clip();const W=Nn(n);await rn(e,O,h,u,p,m,a,i,r,W),e.restore()}}function Nn(e,n){const t=b(e,"nvSpPr"),s=t?b(t,"nvPr"):null,i=s?b(s,"ph"):null;if(i){const r=U(i,"type","body");if(r==="title"||r==="ctrTitle")return 4400;if(r==="subTitle"||r==="body")return 2800}return 1800}function mt(e,n,t,s){if(!n||b(n,"noFill"))return;const r=b(n,"solidFill"),a=b(n,"gradFill"),l=C(n,"w",12700),o=Math.max(.5,l*s);let c="#000000";if(r){const p=ke(r),m=Se(p,t);m&&(c=xe(m))}else a&&(c="#888888");const d=b(n,"prstDash"),h=d?U(d,"val","solid"):"solid",u=U(n,"cap","flat");switch(U(n,"cmpd","sng"),e.strokeStyle=c,e.lineWidth=o,e.lineCap=u==="rnd"?"round":u==="sq"?"square":"butt",e.lineJoin="round",h){case"dash":e.setLineDash([o*4,o*2]);break;case"dot":e.setLineDash([o,o*2]);break;case"dashDot":e.setLineDash([o*4,o*2,o,o*2]);break;case"lgDash":e.setLineDash([o*8,o*3]);break;case"lgDashDot":e.setLineDash([o*8,o*3,o,o*3]);break;default:e.setLineDash([])}e.stroke(),e.setLineDash([])}async function pn(e,n,t,s,i,r){const a=b(n,"spPr"),l=b(a,"xfrm");if(!l)return;const o=b(l,"off"),c=b(l,"ext");if(!o||!c)return;const d=C(o,"x",0)*r,h=C(o,"y",0)*r,u=C(c,"cx",0)*r,p=C(c,"cy",0)*r,m=C(l,"rot",0)/6e4,g=U(l,"flipH","0")==="1",P=U(l,"flipV","0")==="1";if(u<=0||p<=0)return;const y=b(n,"blipFill"),w=y?b(y,"blip"):null,x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,_=d+u/2,v=h+p/2;if(e.save(),(m!==0||g||P)&&(e.translate(_,v),m!==0&&e.rotate(m*Math.PI/180),g&&e.scale(-1,1),P&&e.scale(1,-1),e.translate(-_,-v)),x&&s[x]){const k=s[x],j=b(a,"prstGeom"),N=j?U(j,"prst","rect"):"rect",F={};if(j){const A=b(j,"avLst");if(A){let $=0;for(const z of ge(A,"gd")){const Y=(U(z,"fmla","")||"").match(/val\s+(-?\d+)/);Y&&(F[$]=parseInt(Y[1])),$++}}}e.beginPath(),nn(e,N,d,h,u,p,F),e.clip();const R=y?b(y,"srcRect"):null;if(R){const A=C(R,"l",0)/1e5,$=C(R,"t",0)/1e5,z=C(R,"r",0)/1e5,Y=C(R,"b",0)/1e5,O=k.naturalWidth*(1-A-z),W=k.naturalHeight*(1-$-Y);e.drawImage(k,k.naturalWidth*A,k.naturalHeight*$,O,W,d,h,u,p)}else e.drawImage(k,d,h,u,p);const T=b(a,"ln");T&&(e.beginPath(),nn(e,N,d,h,u,p,F),mt(e,T,i,r))}else e.fillStyle="#e0e0e0",e.fillRect(d,h,u,p),e.strokeStyle="#aaa",e.lineWidth=1,e.strokeRect(d,h,u,p),e.beginPath(),e.moveTo(d,h),e.lineTo(d+u,h+p),e.moveTo(d+u,h),e.lineTo(d,h+p),e.stroke();e.restore()}async function si(e,n,t,s,i){const r=b(n,"xfrm");if(!r)return;const a=b(r,"off"),l=b(r,"ext");if(!a||!l)return;const o=C(a,"x",0)*i,c=C(a,"y",0)*i;C(l,"cx",0)*i,C(l,"cy",0)*i;const d=b(n,"graphic"),h=d?b(d,"graphicData"):null,u=h?b(h,"tbl"):null;if(!u)return;const p=b(u,"tblPr"),m=p?U(p,"bandRow","0")==="1":!1;p&&U(p,"bandCol","0");const g=p?U(p,"firstRow","0")==="1":!1,P=p?U(p,"lastRow","0")==="1":!1;p&&U(p,"firstCol","0"),p&&U(p,"lastCol","0");const y=b(u,"tblGrid"),w=ge(y,"gridCol").map(v=>C(v,"w",0)*i),x=ge(u,"tr");let _=c;for(let v=0;v<x.length;v++){const k=x[v],j=C(k,"h",457200)*i,N=ge(k,"tc");let F=o;const R=v===0,T=v===x.length-1,A=v%2===1;for(let $=0;$<N.length;$++){const z=N[$],Y=C(z,"gridSpan",1);U(z,"vMerge","0");let O=0;for(let L=0;L<Y;L++)O+=w[$+L]||0;const W=b(z,"tcPr"),B=W?["noFill","solidFill","gradFill","blipFill","pattFill"].map(L=>b(W,L)).find(Boolean):null;if(e.save(),e.beginPath(),e.rect(F,_,O,j),B)await Mt(e,B,F,_,O,j,i,t,null);else{let L=null;g&&R?L=t.accent1?"#"+t.accent1.toLowerCase():"#4472C4":P&&T?L="#e0e0e0":m&&A&&(L="rgba(0,0,0,0.06)"),e.fillStyle=L||"transparent",L&&e.fill()}const Z=[{el:b(W,"lnL"),x1:F,y1:_,x2:F,y2:_+j},{el:b(W,"lnR"),x1:F+O,y1:_,x2:F+O,y2:_+j},{el:b(W,"lnT"),x1:F,y1:_,x2:F+O,y2:_},{el:b(W,"lnB"),x1:F,y1:_+j,x2:F+O,y2:_+j}];for(const L of Z)L.el?b(L.el,"noFill")||(e.beginPath(),e.moveTo(L.x1,L.y1),e.lineTo(L.x2,L.y2),mt(e,L.el,t,i)):(e.beginPath(),e.strokeStyle="#cccccc",e.lineWidth=.5,e.moveTo(L.x1,L.y1),e.lineTo(L.x2,L.y2),e.stroke());e.restore();const Q=b(z,"txBody");Q&&(e.save(),e.beginPath(),e.rect(F,_,O,j),e.clip(),await rn(e,Q,F,_,O,j,i,t,s,1400),e.restore()),F+=O}_+=j}}async function mn(e,n,t,s,i,r,a){const l=b(n,"grpSpPr"),o=b(l,"xfrm");if(!o)return;const c=b(o,"off"),d=b(o,"ext"),h=b(o,"chOff"),u=b(o,"chExt");if(!c||!d||!h||!u)return;const p=C(o,"rot",0)/6e4,m=U(o,"flipH","0")==="1",g=U(o,"flipV","0")==="1",P={grpOff:{x:C(c,"x",0)*a,y:C(c,"y",0)*a},grpExt:{cx:C(d,"cx",0)*a,cy:C(d,"cy",0)*a},chOff:{x:C(h,"x",0),y:C(h,"y",0)},chExt:{cx:C(u,"cx",1),cy:C(u,"cy",1)}},y=P.grpOff.x+P.grpExt.cx/2,w=P.grpOff.y+P.grpExt.cy/2;e.save(),(p!==0||m||g)&&(e.translate(y,w),p!==0&&e.rotate(p*Math.PI/180),m&&e.scale(-1,1),g&&e.scale(1,-1),e.translate(-y,-w));for(const x of n.children){const _=x.localName;_==="sp"?await hn(e,x,t,s,i,r,a,P):_==="pic"?await pn(e,x,t,s,i,a):_==="grpSp"?await mn(e,x,t,s,i,r,a):_==="graphicFrame"?await bn(e,x,i,r,a,files,t):_==="cxnSp"&&await gn(e,x,i,a)}e.restore()}function fs(e,n,t,s,i,r,a,l,o){const c=b(n,t);if(!c)return;const d=c.getAttribute("type")||"none";if(d==="none")return;const h={sm:3,med:6,lg:9},u=Math.max(.5,C(n,"w",12700)*o),p=u*(h[c.getAttribute("w")||"med"]??6),m=u*(h[c.getAttribute("len")||"med"]??6),g=Math.atan2(a-i,r-s);switch(e.save(),e.fillStyle=e.strokeStyle,e.strokeStyle=e.strokeStyle,d){case"triangle":case"arrow":case"stealth":{const P=d==="arrow",y=d==="stealth"?m*.5:0;e.beginPath(),e.moveTo(s,i),e.lineTo(s+m*Math.cos(g)+p/2*Math.sin(g),i+m*Math.sin(g)-p/2*Math.cos(g)),P||e.lineTo(s+y*Math.cos(g),i+y*Math.sin(g)),e.lineTo(s+m*Math.cos(g)-p/2*Math.sin(g),i+m*Math.sin(g)+p/2*Math.cos(g)),e.closePath(),P?e.stroke():e.fill();break}case"diamond":{const P=m/2;e.beginPath(),e.moveTo(s,i),e.lineTo(s+P*Math.cos(g)+p/2*Math.sin(g),i+P*Math.sin(g)-p/2*Math.cos(g)),e.lineTo(s+m*Math.cos(g),i+m*Math.sin(g)),e.lineTo(s+P*Math.cos(g)-p/2*Math.sin(g),i+P*Math.sin(g)+p/2*Math.cos(g)),e.closePath(),e.fill();break}case"oval":{const P=m/2,y=p/2,w=s+P*Math.cos(g),x=i+P*Math.sin(g);e.beginPath(),e.save(),e.translate(w,x),e.rotate(g),e.scale(1,y/P),e.arc(0,0,P,0,Math.PI*2),e.restore(),e.fill();break}}e.restore()}async function gn(e,n,t,s){const i=b(n,"spPr"),r=b(i,"xfrm");if(!r)return;const a=b(r,"off"),l=b(r,"ext");if(!a||!l)return;const o=C(a,"x",0)*s,c=C(a,"y",0)*s,d=C(l,"cx",0)*s,h=C(l,"cy",0)*s,u=C(r,"rot",0)/6e4,p=U(r,"flipH","0")==="1",m=U(r,"flipV","0")==="1",g=o+d/2,P=c+h/2,y=b(i,"ln");e.save(),(u!==0||p||m)&&(e.translate(g,P),u!==0&&e.rotate(u*Math.PI/180),p&&e.scale(-1,1),m&&e.scale(1,-1),e.translate(-g,-P));const w=b(i,"prstGeom"),x=w?U(w,"prst","line"):"line",_=x==="line"||x==="straightConnector1";if(e.beginPath(),_){const v=p?o:o+d,k=m?c:c+h,j=p?o+d:o,N=m?c+h:c;e.moveTo(j,N),e.lineTo(v,k)}else nn(e,x,o,c,d,h,{});if(y){if(mt(e,y,t,s),_){const v=p?o+d:o,k=m?c+h:c,j=p?o:o+d,N=m?c:c+h;fs(e,y,"headEnd",j,N,v,k,t,s),fs(e,y,"tailEnd",v,k,j,N,t,s)}}else e.strokeStyle="#000",e.lineWidth=1,e.stroke();e.restore()}async function ii(e,n,t,s,i,r,a,l,o,c,d){const h=c*o,u=d*o,p=x=>{const _=b(x,"cSld");if(!_)return null;const v=b(_,"bg");if(!v)return null;const k=b(v,"bgPr"),j=b(v,"bgRef");return{bgPr:k,bgRef:j}},m=n?p(n):null,g=s?p(s):null,P=t?p(t):null,y=m||g||P;let w=!1;if(y){const{bgPr:x,bgRef:_}=y;if(x){const v=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const k of v){const j=b(x,k);if(j){e.beginPath(),e.rect(0,0,h,u);const N=y===P?Object.assign({},a):a;await Mt(e,j,0,0,h,u,1,l,N)&&(w=!0);break}}}else if(_){C(_,"idx",0);const v=ke(_),k=Se(v,l);k&&(e.fillStyle=xe(k),e.fillRect(0,0,h,u),w=!0)}}w||(e.fillStyle="#ffffff",e.fillRect(0,0,h,u))}function ri(e){const n={};for(const t of e){if(!t)continue;const s=b(t,"cSld"),i=s?b(s,"spTree"):null;if(i)for(const r of ge(i,"sp")){const a=b(r,"nvSpPr"),l=a?b(a,"nvPr"):null,o=l?b(l,"ph"):null;if(!o)continue;const c=U(o,"type","body"),d=U(o,"idx","0"),h=`${c}:${d}`;if(n[h])continue;const u=b(r,"spPr"),p=b(u,"xfrm");if(!p)continue;const m=b(p,"off"),g=b(p,"ext");!m||!g||(n[h]={x:C(m,"x",0),y:C(m,"y",0),w:C(g,"cx",0),h:C(g,"cy",0),txBody:b(r,"txBody")})}}return n}function ai(e,n){if(!n)return null;const t=b(e,"nvSpPr"),s=t?b(t,"nvPr"):null,i=s?b(s,"ph"):null;if(!i)return null;const r=U(i,"type","body"),a=U(i,"idx","0");return n[`${r}:${a}`]||n[`${r}:0`]||n[`body:${a}`]||null}async function bn(e,n,t,s,i,r,a){const l=b(n,"graphic"),o=l?b(l,"graphicData"):null,c=o?U(o,"uri",""):"";if(b(n,"tbl")||o&&b(o,"tbl"))return si(e,n,t,s,i);const d=b(n,"xfrm");if(!d)return;const h=b(d,"off"),u=b(d,"ext");if(!h||!u)return;const p=C(h,"x",0)*i,m=C(h,"y",0)*i,g=C(u,"cx",0)*i,P=C(u,"cy",0)*i;if(g<=0||P<=0)return;const y=c.includes("chart"),w=c.includes("diagram");if(y&&r&&a){const _=o?b(o,"chart"):null,v=_?_.getAttribute("r:id")||_.getAttribute("id"):null,k=v?a[v]:null;if(k&&r[k.fullPath]){const j=new TextDecoder().decode(r[k.fullPath]),N=Pe(j);Va(e,N,p,m,g,P,t,i);return}}if(w&&r&&a){const _=o?b(o,"relIds"):null,v=_?_.getAttribute("r:dm")||_.getAttribute("dm"):null,k=v?a[v]:null;if(k&&r[k.fullPath]){const j=new TextDecoder().decode(r[k.fullPath]),N=Pe(j),F=_?_.getAttribute("r:lo")||_.getAttribute("lo"):null,R=F?a[F]:null,T=R&&r[R.fullPath]?Pe(new TextDecoder().decode(r[R.fullPath])):null,{renderSmartArt:A}=await ln(async()=>{const{renderSmartArt:$}=await import("./smartart-58otsUWh.js");return{renderSmartArt:$}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]),import.meta.url);A(e,N,T,p,m,g,P,t,i);return}}const x=y?"📊 Chart":w?"🔷 Diagram":"⬛ Graphic";e.save(),e.fillStyle="#f4f4f8",e.strokeStyle="#ccccdd",e.lineWidth=1,e.fillRect(p,m,g,P),e.strokeRect(p,m,g,P),e.fillStyle="#999",e.font=`${Math.min(g*.07,16*i)}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(x,p+g/2,m+P/2),e.textAlign="start",e.textBaseline="alphabetic",e.restore()}async function oi(e,n,t,s,i,r,a,l,o){if(n)for(const c of n.children){const d=c.localName;try{d==="sp"?await hn(e,c,t,s,i,r,a,null,l):d==="pic"?await pn(e,c,t,s,i,a):d==="grpSp"?await mn(e,c,t,s,i,r,a):d==="graphicFrame"?await bn(e,c,i,r,a,o,t):d==="cxnSp"&&await gn(e,c,i,a)}catch(h){console.warn("Error rendering shape:",d,h)}}}const ro=Object.freeze(Object.defineProperty({__proto__:null,applyEffects:ni,applyFill:Mt,applyOutline:mt,buildPlaceholderMap:ri,computeLineHeight:ti,getDefaultFontSize:Nn,getRels:qe,loadImages:Yt,renderBackground:ii,renderConnector:gn,renderGraphicFrame:bn,renderGroupShape:mn,renderPicture:pn,renderShape:hn,renderSpTree:oi,renderTable:si,renderTextBody:rn,resolvePlaceholderXfrm:ai},Symbol.toStringTag,{value:"Module"}));async function ao(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:o,done:c}=await s.read();if(c)break;i.push(o),r+=o.length}const a=new Uint8Array(r);let l=0;for(const o of i)a.set(o,l),l+=o.length;return a}const oo=(()=>{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 lo(e){let n=4294967295;for(let t=0;t<e.length;t++)n=oo[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}class co{constructor(){this._chunks=[],this._size=0}append(n){this._chunks.push(n),this._size+=n.length}get size(){return this._size}concat(){const n=new Uint8Array(this._size);let t=0;for(const s of this._chunks)n.set(s,t),t+=s.length;return n}}function we(e){return new Uint8Array([e&255,e>>8&255])}function De(e){return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}const li=new TextEncoder;function uo(e){return li.encode(e)}const hs=18977,ps=0;class fo{constructor(){this._entries=[]}async addText(n,t){return this.addBytes(n,li.encode(t))}async addBytes(n,t,s=!0){const i=uo(n),r=lo(t),a=t.length;let l,o;if(s&&t.length>32){const c=await ao(t);c.length<t.length?(l=c,o=8):(l=t,o=0)}else l=t,o=0;this._entries.push({name:n,nameBytes:i,compData:l,uncompSize:a,crc:r,method:o,localOffset:0})}async finalize(){const n=new co;for(const i of this._entries)i.localOffset=n.size,n.append(new Uint8Array([80,75,3,4])),n.append(we(20)),n.append(we(2048)),n.append(we(i.method)),n.append(we(ps)),n.append(we(hs)),n.append(De(i.crc)),n.append(De(i.compData.length)),n.append(De(i.uncompSize)),n.append(we(i.nameBytes.length)),n.append(we(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(we(798)),n.append(we(20)),n.append(we(2048)),n.append(we(i.method)),n.append(we(ps)),n.append(we(hs)),n.append(De(i.crc)),n.append(De(i.compData.length)),n.append(De(i.uncompSize)),n.append(we(i.nameBytes.length)),n.append(we(0)),n.append(we(0)),n.append(we(0)),n.append(we(0)),n.append(De(0)),n.append(De(i.localOffset)),n.append(i.nameBytes);const s=n.size-t;return n.append(new Uint8Array([80,75,5,6])),n.append(we(0)),n.append(we(0)),n.append(we(this._entries.length)),n.append(we(this._entries.length)),n.append(De(s)),n.append(De(t)),n.append(we(0)),n.concat()}}async function ho(e){const n=new fo;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 po=new TextDecoder,ci=new TextEncoder,Fe={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 St(e){return new DOMParser().parseFromString(e,"application/xml")}function mo(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 Re(e){return ci.encode(mo(e))}function We(e,n){const t=e[n];return t?St(po.decode(t)):null}function de(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 Ge(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 go(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function it(e){const n=e.split("/"),t=n.pop();return[...n,"_rels",t+".rels"].join("/")}function st(e,n){const t=We(e,it(n));if(!t)return{};const s={};for(const i of Array.from(t.getElementsByTagName("Relationship"))){const r=i.getAttribute("Id"),a=i.getAttribute("Target"),l=i.getAttribute("Type")||"";let o=a;if(!a.startsWith("/")&&!a.startsWith("http")){const c=n.split("/").slice(0,-1).join("/");o=c?c+"/"+a.replace(/^\.\.\//,""):a;const d=o.split("/"),h=[];for(const u of d)u===".."?h.pop():h.push(u);o=h.join("/")}s[r]={id:r,target:a,type:l,fullPath:o}}return s}function Ot(e){const n=St('<?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(Fe.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 Ut(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 Qt(e,n){for(const t of e.children){const s=t.localName;if(s==="sp"||s==="pic"||s==="cxnSp"){const i=de(t,"nvSpPr")||de(t,"nvPicPr")||de(t,"nvCxnSpPr"),r=i?de(i,"cNvPr"):null;if(r&&(r.getAttribute("name")||"")===n)return t}else if(s==="grpSp"){const i=Qt(t,n);if(i)return i}}return null}function ut(e){const n=de(e,"cSld");return n?de(n,"spTree"):null}function Wt(e,n,t,s=!0){for(const i of Ge(e,"t")){const r=i.textContent;if(!r)continue;const a=s?r.split(n).join(t):r.replace(new RegExp(bo(n),"gi"),t);a!==r&&(i.textContent=a)}}function bo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const ms={"image/jpeg":"jpeg","image/jpg":"jpeg","image/png":"png","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"},yo={jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml"};function gs(e,n,t){const s="[Content_Types].xml",i=We(e,s);if(!i)return;const r=i.documentElement;for(const l of Ge(i,"Override"))if(l.getAttribute("PartName")==="/"+t)return;const a=i.createElementNS(Fe.ct,"Override");a.setAttribute("PartName","/"+t),a.setAttribute("ContentType",yo[n]||"application/octet-stream"),r.appendChild(a),e[s]=Re(i)}class an{constructor(n){this._files=n,this._presPath="ppt/presentation.xml",this._presDoc=We(n,this._presPath),this._presRels=st(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 an(t)}static async fromBytes(n){const t=await Hs(n);return new an(t)}_buildSlidePaths(){if(!this._presDoc)return[];const n=de(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]=Re(this._presDoc)}_savePresRels(){this._files[it(this._presPath)]=Re(Ot(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 We(this._files,t)}_saveSlideDoc(n,t){this._files[this._slidePaths[n]]=Re(t)}applyTemplate(n,t={}){const{open:s="{{",close:i="}}",slides:r}=t,a=r??this._slidePaths.map((l,o)=>o);for(const l of a){const o=this._slideDoc(l);for(const[c,d]of Object.entries(n)){const h=s+c+i;Wt(o,h,String(d))}this._saveSlideDoc(l,o)}for(const l of a)this._applyTemplateToNotes(l,n,s,i)}_applyTemplateToNotes(n,t,s,i){const r=st(this._files,this._slidePaths[n]),a=Object.values(r).find(o=>o.type?.includes("notesSlide"));if(!a)return;const l=We(this._files,a.fullPath);if(l){for(const[o,c]of Object.entries(t))Wt(l,s+o+i,String(c));this._files[a.fullPath]=Re(l)}}replaceText(n,t,s={}){const{caseSensitive:i=!0,includeNotes:r=!1,slides:a}=s,l=a??this._slidePaths.map((o,c)=>c);for(const o of l){const c=this._slideDoc(o);if(Wt(c,n,t,i),this._saveSlideDoc(o,c),r){const d=st(this._files,this._slidePaths[o]),h=Object.values(d).find(u=>u.type?.includes("notesSlide"));if(h){const u=We(this._files,h.fullPath);u&&(Wt(u,n,t,i),this._files[h.fullPath]=Re(u))}}}}setShapeText(n,t,s,i={}){const{preserveFormatting:r=!0}=i,a=this._slideDoc(n),l=ut(a);if(!l)return this;const o=Qt(l,t);if(!o)throw new Error(`Shape "${t}" not found on slide ${n}`);const c=de(o,"txBody");if(!c)return this;const d=de(c,"r"),h=d?de(d,"rPr"):null,u=de(de(c,"p"),"pPr");for(const g of Ge(c,"p"))g.parentNode.removeChild(g);const p=s.split(`
|
|
31
|
+
`),m=Fe.a;for(const g of p){const P=a.createElementNS(m,"a:p");u&&r&&P.appendChild(u.cloneNode(!0));const y=a.createElementNS(m,"a:r");h&&r&&y.appendChild(h.cloneNode(!0));const w=a.createElementNS(m,"a:t");w.textContent=g,y.appendChild(w),P.appendChild(y),c.appendChild(P)}return this._saveSlideDoc(n,a),this}getShapeText(n,t){const s=this._slideDoc(n),i=ut(s);if(!i)return"";const r=Qt(i,t);return r?Ge(r,"t").map(a=>a.textContent).join(""):""}addTextBox(n,t,s={}){const{x:i=914400,y:r=914400,w:a=4572e3,h:l=914400,color:o="000000",fontSize:c=1800,bold:d=!1,align:h="l",fontFamily:u="Calibri"}=s,p=this._slideDoc(n),m=ut(p);if(!m)return this;const P=Math.max(0,...Ge(m,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,y=`TextBox ${P}`,w=Fe.a,_=`<p:sp xmlns:p="${Fe.p}" xmlns:a="${w}">
|
|
32
|
+
<p:nvSpPr>
|
|
33
|
+
<p:cNvPr id="${P}" 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="${a}" 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="${c}" b="${d?1:0}" dirty="0">
|
|
49
|
+
<a:solidFill><a:srgbClr val="${o}"/></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=St(_);return m.appendChild(p.adoptNode(v.documentElement)),this._saveSlideDoc(n,p),this}async setShapeImage(n,t,s,i="image/jpeg"){const r=this._slideDoc(n),a=ut(r);if(!a)return this;const l=Qt(a,t);if(!l)throw new Error(`Shape "${t}" not found on slide ${n}`);const o=st(this._files,this._slidePaths[n]),c=de(l,"blipFill"),d=c?de(c,"blip"):null,h=d?d.getAttribute("r:embed")||d.getAttribute("embed"):null,u=h?o[h]:null,p=ms[i]||"jpeg",m=Object.keys(this._files).filter(y=>y.startsWith("ppt/media/")).length+1,g=`ppt/media/image${m}.${p}`;this._files[g]=s;let P;return h&&u?(P=h,o[P]={id:P,type:u.type,target:`../media/image${m}.${p}`,fullPath:g}):(P=Ut(o),o[P]={id:P,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${m}.${p}`,fullPath:g}),d&&d.setAttribute("r:embed",P),this._files[it(this._slidePaths[n])]=Re(Ot(o)),this._saveSlideDoc(n,r),gs(this._files,p,g),this}async addImage(n,t,s="image/jpeg",i={}){const{x:r=914400,y:a=914400,w:l=2743200,h:o=2057400}=i,c=ms[s]||"jpeg",d=Object.keys(this._files).filter(k=>k.startsWith("ppt/media/")).length+1,h=`ppt/media/image${d}.${c}`;this._files[h]=t;const u=st(this._files,this._slidePaths[n]),p=Ut(u);u[p]={id:p,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`../media/image${d}.${c}`,fullPath:h},this._files[it(this._slidePaths[n])]=Re(Ot(u));const m=this._slideDoc(n),g=ut(m);if(!g)return this;const y=Math.max(0,...Ge(g,"cNvPr").map(k=>parseInt(k.getAttribute("id")||"0",10)))+1,w=Fe.a,_=`<p:pic xmlns:p="${Fe.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="${p}"/>
|
|
64
|
+
<a:stretch><a:fillRect/></a:stretch>
|
|
65
|
+
</p:blipFill>
|
|
66
|
+
<p:spPr>
|
|
67
|
+
<a:xfrm><a:off x="${r}" y="${a}"/><a:ext cx="${l}" cy="${o}"/></a:xfrm>
|
|
68
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
69
|
+
</p:spPr>
|
|
70
|
+
</p:pic>`,v=St(_);return g.appendChild(m.adoptNode(v.documentElement)),this._saveSlideDoc(n,m),gs(this._files,c,h),this}setSlideBackground(n,t){const s=this._slideDoc(n),i=de(s,"cSld");if(!i)return this;const r=de(i,"bg");r&&i.removeChild(r);const a=Fe.a,o=`<p:bg xmlns:p="${Fe.p}" xmlns:a="${a}">
|
|
71
|
+
<p:bgPr><a:solidFill><a:srgbClr val="${t}"/></a:solidFill>
|
|
72
|
+
<a:effectLst/></p:bgPr></p:bg>`,c=s.adoptNode(St(o).documentElement);return i.insertBefore(c,i.firstChild),this._saveSlideDoc(n,s),this}setThemeColor(n,t){const s=this._presRels;let i=Object.values(s).find(l=>l.type?.includes("theme"))?.fullPath;if(!i){const l=Object.values(s).find(o=>o.type?.includes("slideMaster"));if(l){const o=st(this._files,l.fullPath);i=Object.values(o).find(c=>c.type?.includes("theme"))?.fullPath}}if(!i)return this;const r=We(this._files,i);if(!r)return this;de(r,"fmtScheme");const a=de(r,"clrScheme");if(!a)return this;for(const l of a.children)if(l.localName===n){const o=de(l,"srgbClr");if(o)o.setAttribute("val",t);else{for(;l.firstChild;)l.removeChild(l.firstChild);const c=Fe.a,d=r.createElementNS(c,"a:srgbClr");d.setAttribute("val",t),l.appendChild(d)}break}return this._files[i]=Re(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(g=>g.match(/ppt\/slides\/slide(\d+)\.xml/)).filter(Boolean).map(g=>parseInt(g[1],10)),a=(r.length?Math.max(...r):0)+1,l=`ppt/slides/slide${a}.xml`,o=it(l);this._files[l]=this._files[i].slice();const c=it(i);this._files[c]&&(this._files[o]=this._files[c].slice());const d=Ut(this._presRels),h=`slides/slide${a}.xml`;this._presRels[d]={id:d,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",target:h,fullPath:l},this._savePresRels();const u=de(this._presDoc,"sldIdLst");if(u){const g=Ge(u,"sldId").map(_=>parseInt(_.getAttribute("id")||"0",10)),P=(g.length?Math.max(...g):255)+1,y=Fe.p,w=this._presDoc.createElementNS(y,"p:sldId");w.setAttribute("id",String(P)),w.setAttributeNS(Fe.r,"r:id",d);const x=Array.from(u.children);s>=x.length?u.appendChild(w):u.insertBefore(w,x[s])}this._savePresDoc(),this._slidePaths=this._buildSlidePaths();const p="[Content_Types].xml",m=We(this._files,p);if(m){const g=m.documentElement,P=m.createElementNS(Fe.ct,"Override");P.setAttribute("PartName","/"+l),P.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),g.appendChild(P),this._files[p]=Re(m)}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=de(this._presDoc,"sldIdLst");if(s)for(const i of Array.from(s.children)){const r=i.getAttribute("r:id")||i.getAttribute("id"),a=this._presRels[r];if(a&&a.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=de(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=st(this._files,s),r=Object.values(i).find(a=>a.type?.includes("notesSlide"));if(r){const a=We(this._files,r.fullPath);if(a){for(const l of Ge(a,"sp")){const o=de(de(l,"nvSpPr"),"nvPr"),c=o?de(o,"ph"):null;if(c&&go(c,"type")!=="sldNum"){for(const h of Ge(l,"t"))h.textContent="";const d=de(l,"t");d&&(d.textContent=t);break}}this._files[r.fullPath]=Re(a)}}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,a=Fe.p,l=Fe.a,o=`ppt/notesSlides/notesSlide${r}.xml`,c=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
73
|
+
<p:notes xmlns:p="${a}" 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[o]=ci.encode(c);const d=Ut(s);s[d]={id:d,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",target:`../notesSlides/notesSlide${r}.xml`,fullPath:o},this._files[it(t)]=Re(Ot(s))}async save(){return ho(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=ut(t);if(!s)return[];const i=[];for(const r of s.children){const a=r.localName;if(!["sp","pic","cxnSp","graphicFrame"].includes(a))continue;const l=de(r,"nvSpPr")||de(r,"nvPicPr")||de(r,"nvGraphicFramePr")||de(r,"nvCxnSpPr"),o=l?de(l,"cNvPr"):null;i.push({id:o?.getAttribute("id")||"",name:o?.getAttribute("name")||"",type:a})}return i}}const di=new TextEncoder;function vo(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}class wo{constructor(){this._parts=[],this._size=0}write(n){const t=typeof n=="string"?di.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 xo(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 ko(e,n,t){const{cx:s,cy:i}=e.slideSize,r=Math.round(t*i/s),a=typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,r):Object.assign(document.createElement("canvas"),{width:t,height:r});return await e.renderSlide(n,a,t),a}function _o(e,n){const t=e/914400*72,s=n/914400*72;return{w:t,h:s}}class So{constructor(){this._buf=new wo,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:a=null}=t,l=r??Array.from({length:n.slideCount},(v,k)=>k),o=l.length,{cx:c,cy:d}=n.slideSize,{w:h,h:u}=_o(c,d);this._buf.write(`%PDF-1.4
|
|
95
|
+
`),this._buf.write(`%ÿþýü
|
|
96
|
+
|
|
97
|
+
`);const p=this._nextObj(),m=this._nextObj(),g=Array.from({length:o},()=>this._nextObj()),P=Array.from({length:o},()=>this._nextObj()),y=Array.from({length:o},()=>this._nextObj());this._writeObj(p,`<< /Type /Catalog /Pages ${m} 0 R >>`);const w=g.map(v=>`${v} 0 R`).join(" ");this._writeObj(m,`<< /Type /Pages /Kids [${w}] /Count ${o} >>`);for(let v=0;v<o;v++){const k=l[v];a?.(v,o);const j=await ko(n,k,s),N=await xo(j,i),F=j.width,R=j.height;this._writeObj(g[v],`<< /Type /Page /Parent ${m} 0 R /MediaBox [0 0 ${h.toFixed(3)} ${u.toFixed(3)}] /Resources << /XObject << /Im${v} ${P[v]} 0 R >> >> /Contents ${y[v]} 0 R >>`),this._writeObj(P[v],`<< /Type /XObject /Subtype /Image /Width ${F} /Height ${R} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length __LEN__ >>`,N);const T=`q ${h.toFixed(3)} 0 0 ${u.toFixed(3)} 0 0 cm /Im${v} Do Q`;this._writeObj(y[v],"<< /Length __LEN__ >>",di.encode(T))}a?.(o,o);const x=this._buf.size,_=this._objNum+1;this._buf.write(`xref
|
|
98
|
+
0 ${_}
|
|
99
|
+
`),this._buf.write(`0000000000 65535 f \r
|
|
100
|
+
`);for(let v=1;v<_;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 ${_} /Root ${p} 0 R >>
|
|
103
|
+
`),this._buf.write(`startxref
|
|
104
|
+
${x}
|
|
105
|
+
%%EOF
|
|
106
|
+
`),this._buf.concat()}}async function qn(e,n={}){const{width:t=null,dpi:s=150,quality:i=.92,slides:r=null,onProgress:a=null}=n,l=t??vo(e,s);return new So().build(e,{widthPx:l,quality:i,slideList:r,onProgress:a})}async function Po(e,n="presentation.pdf",t={}){const s=await qn(e,t),i=new Blob([s],{type:"application/pdf"}),r=URL.createObjectURL(i),a=document.createElement("a");a.href=r,a.download=n,a.click(),setTimeout(()=>URL.revokeObjectURL(r),1e4)}async function To(e,n,t={}){return qn(n,{...t,slides:[e]})}const jo=500;function Kn(e){if(!e)return[];const n=b(e,"timing");if(!n)return[];const t=b(n,"tnLst");if(!t)return[];const s=[];function i(a,l,o){const c=b(a,"cTn");if(!c)return;const d=U(c,"nodeType","");d==="clickEffect"&&(l+=1),d==="withEffect"&&l===0&&(l=0);const h=C(c,"delay",0)+o,u=b(a,"childTnLst")||b(c,"childTnLst");if(u)for(const p of u.children){const m=p.localName;if(m==="par")i(p,l,h);else if(m==="seq"){const g=b(p,"cTn"),y=(g?U(g,"nodeType",""):"")==="clickEffect"?l+1:l,w=b(p,"childTnLst");if(w)for(const x of w.children)x.localName==="par"&&i(x,y,h)}else if(m==="set"||m==="animEffect"||m==="anim"||m==="animScale"||m==="animClr"){const g=bs(p,l,h);g&&s.push(g)}}}function r(a,l){const o=b(a,"childTnLst")||b(b(a,"cTn"),"childTnLst");if(!o)return;let c=l;for(const d of o.children)if(d.localName==="par"){const h=b(d,"cTn"),u=h?U(h,"nodeType",""):"";(u==="clickEffect"||u==="clickPar")&&c++,i(d,c,0)}}for(const a of t.children)a.localName==="par"?i(a,0,0):a.localName==="seq"&&r(a,0);for(const a of ge(t,"animEffect")){const l=bs(a,0,0);l&&s.push(l)}return s.sort((a,l)=>a.clickNum-l.clickNum||a.delay-l.delay)}function bs(e,n,t){const s=b(e,"cTn"),i=b(e,"tgt")||b(s,"tgt"),r=i?b(i,"spTgt"):null,a=r?U(r,"spid",null):null;if(!a)return null;const l=s?U(s,"dur",null):null,o=l==="indefinite"?2e3:l?parseInt(l,10):jo,c=(s?C(s,"delay",0):0)+t,d=U(e,"filter",null),h=U(e,"type",null)||(d?"filter":"set"),u=U(e,"dir",null)||(d?d.split("(")[1]?.replace(")",""):null)||"";let p="emphasis";(h==="in"||e.localName==="set"&&U(b(e,"attrNameLst")||e,"attrName","")==="style.visibility"&&U(e,"to","")==="visible")&&(p="entrance"),(h==="out"||e.localName==="set"&&U(e,"to","")==="hidden")&&(p="exit");let m=d||e.localName;if(d){const g=d.toLowerCase();g.includes("fade")?m="fade":g.includes("fly")?m="fly":g.includes("appear")?m="appear":g.includes("zoom")?m="zoom":g.includes("wipe")?m="wipe":g.includes("wheel")?m="wheel":g.includes("blinds")?m="blinds":g.includes("box")?m="box":g.includes("dissolve")?m="dissolve":g.includes("split")?m="split":g.includes("stretch")?m="stretch":g.includes("diamond")?m="diamond":g.includes("plus")?m="plus":g.includes("wedge")?m="wedge":g.includes("random")?m="dissolve":g.includes("strips")?m="strips":g.includes("peek")?m="fly":g.includes("checkerboard")?m="dissolve":m="fade"}return{shapeId:a,type:p,effect:m,clickNum:n,delay:c,duration:o,dir:u,raw:e.localName}}function Xn(e){if(!e)return null;const n=b(e,"transition");if(!n)return null;const t=C(n,"dur",700),s=U(n,"spd","med"),i=s==="slow"?1200:s==="fast"?300:t,r=n.firstElementChild,a=r?.localName||"fade",l=r?U(r,"dir","l"):"l";return{type:a,duration:i,dir:l}}function Co(e){return 1-Math.pow(1-e,2)}function Fo(e){return e*e}function No(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}function ui(e,n,t,s){const i=Math.max(0,Math.min(1,n)),r=e.type==="entrance",a=r?Co(i):Fo(i),l={opacity:1,tx:0,ty:0,scaleX:1,scaleY:1,clipProgress:1,clipDir:"none",spin:0},o=e.effect,c=e.dir;if(r)switch(o){case"appear":l.opacity=i>=.01?1:0;break;case"fade":case"dissolve":l.opacity=a;break;case"fly":case"flyIn":{l.opacity=Math.min(1,a*1.5);const d=1-a;c.includes("l")?l.tx=-t*d:c.includes("r")?l.tx=t*d:c.includes("t")?l.ty=-s*d:l.ty=s*d;break}case"zoom":l.opacity=a,l.scaleX=.1+a*.9,l.scaleY=.1+a*.9;break;case"wipe":l.clipProgress=a,l.clipDir=c||"r";break;case"split":l.clipProgress=a,l.clipDir=c.includes("v")?"split-v":"split-h";break;case"blinds":l.clipProgress=a,l.clipDir=c.includes("v")?"blinds-v":"blinds-h";break;case"box":l.clipProgress=a,l.clipDir="box";break;case"wheel":l.clipProgress=a,l.clipDir="wheel";break;case"wedge":l.clipProgress=a,l.clipDir="wedge";break;case"strips":l.clipProgress=a,l.clipDir=c.includes("r")?"strips-r":"strips-l";break;case"stretch":l.opacity=a,c.includes("h")?(l.scaleX=a,l.scaleY=1):(l.scaleX=1,l.scaleY=a);break;case"plus":case"diamond":l.clipProgress=a,l.clipDir=o;break;default:l.opacity=a}else if(e.type==="exit"){const d={...e,type:"entrance"};return ui(d,1-i,t,s)}else switch(o){case"spin":l.spin=a*360;break;case"grow":case"shrink":{const d=o==="grow"?1.5:.5,h=i<.5?i*2:(1-i)*2;l.scaleX=1+(d-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 fi(e,n,t,s,i){const r=No(i),a=e.canvas.width,l=e.canvas.height;e.clearRect(0,0,a,l);const o=s?.type||"fade",c=s?.dir||"l";switch(o){case"cut":e.drawImage(r<.5?n:t,0,0,a,l);break;case"fade":case"fade_slow":default:e.drawImage(n,0,0,a,l),e.globalAlpha=r,e.drawImage(t,0,0,a,l),e.globalAlpha=1;break;case"push":{const d=c==="l"?-a*r:c==="r"?a*r:0,h=c==="u"?-l*r:c==="d"?l*r:0;e.drawImage(n,d,h,a,l),e.drawImage(t,d+(c==="l"?a:c==="r"?-a:0),h+(c==="u"?l:c==="d"?-l:0),a,l);break}case"cover":case"uncover":{const d=o==="uncover",h=c==="l"?-a*(1-r):c==="r"?a*(1-r):0,u=c==="u"?-l*(1-r):c==="d"?l*(1-r):0;d?(e.drawImage(t,0,0,a,l),e.drawImage(n,h,u,a,l)):(e.drawImage(n,0,0,a,l),e.drawImage(t,h,u,a,l));break}case"wipe":{e.drawImage(n,0,0,a,l),e.save(),e.beginPath(),c==="l"?e.rect(a*(1-r),0,a*r,l):c==="r"?e.rect(0,0,a*r,l):c==="u"?e.rect(0,l*(1-r),a,l*r):e.rect(0,0,a,l*r),e.clip(),e.drawImage(t,0,0,a,l),e.restore();break}case"zoom":case"newsflash":{e.drawImage(n,0,0,a,l),e.save(),e.globalAlpha=r;const d=o==="newsflash"?1+(1-r)*3:.05+r*.95;e.translate(a/2,l/2),e.scale(d,d),e.drawImage(t,-a/2,-l/2,a,l),e.restore(),e.globalAlpha=1;break}case"dissolve":case"wheel":case"blinds":{e.drawImage(n,0,0,a,l),e.globalAlpha=r,e.drawImage(t,0,0,a,l),e.globalAlpha=1;break}}}class hi{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 ln(async()=>{const{parseXml:o}=await Promise.resolve().then(()=>Sa);return{parseXml:o}},void 0,import.meta.url).catch(()=>({parseXml:o=>new DOMParser().parseFromString(o,"application/xml")})),a=r(i);this._steps=Kn(a),this._transition=Xn(a);const l=new Set(this._steps.filter(o=>o.type==="entrance").map(o=>o.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,a=l=>{const o=l-i;for(const c of t){if(r.has(c))continue;const d=o-c.delay;if(d<0)continue;const h=Math.min(1,d/c.duration),u=this.canvas.width,p=this.canvas.height,m=ui(c,h,u*.3,p*.3);this._shapeStates.set(c.shapeId,{...m,step:c}),h>=1&&r.add(c)}this._composite(),r.size<t.length?this._rafId=requestAnimationFrame(a):s()};this._rafId=requestAnimationFrame(a)}))}_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 a=performance.now(),l=o=>{const c=Math.min(1,(o-a)/i);fi(this.ctx,n,t,s,c),c<1?this._rafId=requestAnimationFrame(l):r()};this._rafId=requestAnimationFrame(l)})}_stopAnimations(){this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null)}_delay(n){return new Promise(t=>setTimeout(t,n))}}const Mo=Object.freeze(Object.defineProperty({__proto__:null,PptxPlayer:hi,parseAnimations:Kn,parseTransition:Xn,renderTransitionFrame:fi},Symbol.toStringTag,{value:"Module"}));let Ao=0;function yn(e="el"){return`${e}${++Ao}`}function Ae(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function M(e){return`${+e.toFixed(3)}`}function Mn(e){return e?xe(e):"none"}function pi(e,n,t,s,i,r,a){if(!e)return{fill:"none",fillAttrs:""};const l=e.localName;if(l==="noFill")return{fill:"none",fillAttrs:""};if(l==="solidFill"){const o=ke(e),c=Se(o,t),d=Mn(c),h=c?.a!=null?c.a/255:1;return{fill:d,fillAttrs:h<1?` fill-opacity="${M(h)}"`:""}}if(l==="gradFill"){const o=b(e,"gsLst"),c=o?ge(o,"gs").map(m=>{const g=C(m,"pos",0)/1e5,P=ke(m),y=Se(P,t);return{pos:g,color:Mn(y),opacity:y?.a!=null?y.a/255:1}}):[],d=b(e,"lin"),h=b(e,"path"),u=yn("grad");let p;if(h){const m=b(h,"fillToRect"),g=C(m,"l",5e4)/1e5,P=C(m,"t",5e4)/1e5,y=s+r*g,w=i+a*P,x=Math.sqrt(r*r+a*a)/2;p=`<radialGradient id="${u}" cx="${M(y)}" cy="${M(w)}" r="${M(x)}" gradientUnits="userSpaceOnUse">`;for(const _ of c)p+=`<stop offset="${M(_.pos)}" stop-color="${Ae(_.color)}"${_.opacity<1?` stop-opacity="${M(_.opacity)}"`:""}/>`;p+="</radialGradient>"}else{const g=(C(d,"ang",0)/6e4-90)*(Math.PI/180),P=Math.cos(g),y=Math.sin(g),w=Math.sqrt(r*r+a*a)/2,x=s+r/2,_=i+a/2;p=`<linearGradient id="${u}" x1="${M(x-P*w)}" y1="${M(_-y*w)}" x2="${M(x+P*w)}" y2="${M(_+y*w)}" gradientUnits="userSpaceOnUse">`;for(const v of c)p+=`<stop offset="${M(v.pos)}" stop-color="${Ae(v.color)}"${v.opacity<1?` stop-opacity="${M(v.opacity)}"`:""}/>`;p+="</linearGradient>"}return n.push(p),{fill:`url(#${u})`,fillAttrs:""}}return l==="blipFill"?{fill:"none",fillAttrs:""}:{fill:"none",fillAttrs:""}}function mi(e,n,t){if(!e)return"";if(b(e,"noFill"))return' stroke="none"';const s=b(e,"solidFill"),i=s?ke(s):null,r=Se(i,n),a=Mn(r)||"#000",l=Math.max(.5,C(e,"w",12700)/914400*96),o=b(e,"prstDash"),c=o?U(o,"val","solid"):"solid";let d="";c==="dash"?d=` stroke-dasharray="${M(l*4)},${M(l*2)}"`:c==="dot"?d=` stroke-dasharray="${M(l)},${M(l*2)}"`:c==="dashDot"?d=` stroke-dasharray="${M(l*4)},${M(l*2)},${M(l)},${M(l*2)}"`:c==="lgDash"&&(d=` stroke-dasharray="${M(l*8)},${M(l*3)}"`);const h=U(e,"cap","flat"),u=h==="rnd"?"round":h==="sq"?"square":"butt";return` stroke="${Ae(a)}" stroke-width="${M(l)}" stroke-linecap="${u}" stroke-linejoin="round"${d}`}function gi(e,n){if(!e)return"";const t=b(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,a=i*Math.PI/180,l=Math.cos(a)*s,o=Math.sin(a)*s,c=ke(t),d=Se(c,{}),h=d?xe(d):"rgba(0,0,0,0.5)",u=d?.a!=null?d.a/255:.5,p=yn("shd");return n.push(`<filter id="${p}" x="-50%" y="-50%" width="200%" height="200%"><feDropShadow dx="${M(l)}" dy="${M(o)}" stdDeviation="${M(r/2)}" flood-color="${Ae(h)}" flood-opacity="${M(u)}"/></filter>`),` filter="url(#${p})"`}function $o(e,n,t,s,i,r){const a=[],l={beginPath(){a.length=0},moveTo(o,c){a.push(`M${M(o)},${M(c)}`)},lineTo(o,c){a.push(`L${M(o)},${M(c)}`)},bezierCurveTo(o,c,d,h,u,p){a.push(`C${M(o)},${M(c)},${M(d)},${M(h)},${M(u)},${M(p)}`)},quadraticCurveTo(o,c,d,h){a.push(`Q${M(o)},${M(c)},${M(d)},${M(h)}`)},arc(o,c,d,h,u,p){const m=o+d*Math.cos(h),g=c+d*Math.sin(h),P=o+d*Math.cos(u),y=c+d*Math.sin(u);let w=u-h;p&&(w=-(Math.PI*2-Math.abs(w)));const x=Math.abs(w)>Math.PI?1:0,_=w>0?1:0;a.length===0&&a.push(`M${M(m)},${M(g)}`),a.push(`A${M(d)},${M(d)},0,${x},${_},${M(P)},${M(y)}`)},arcTo(o,c,d,h,u){a.push(`L${M(o)},${M(c)} L${M(d)},${M(h)}`)},closePath(){a.push("Z")},fill(){},stroke(){},save(){},restore(){},translate(){},rotate(){},scale(){},rect(o,c,d,h){a.push(`M${M(o)},${M(c)}L${M(o+d)},${M(c)}L${M(o+d)},${M(c+h)}L${M(o)},${M(c+h)}Z`)},setLineDash(){},measureText(){return{width:0}}};return a.join(" ")||`M${M(n)},${M(t)}L${M(n+s)},${M(t)}L${M(n+s)},${M(t+i)}L${M(n)},${M(t+i)}Z`}let Eo=null;function vn(e){if(!e)return"";const n=C(e,"rot",0)/6e4,t=U(e,"flipH","0")==="1",s=U(e,"flipV","0")==="1",i=b(e,"off"),r=b(e,"ext");if(!i||!r)return"";const a=C(i,"x",0)/914400*96,l=C(i,"y",0)/914400*96,o=C(r,"cx",0)/914400*96,c=C(r,"cy",0)/914400*96,d=a+o/2,h=l+c/2,u=[];return n&&u.push(`rotate(${M(n)},${M(d)},${M(h)})`),t&&u.push(`scale(-1,1) translate(${M(-a*2-o)},0)`),s&&u.push(`scale(1,-1) translate(0,${M(-l*2-c)})`),u.length?` transform="${u.join(" ")}"`:""}function It(e){if(!e)return null;const n=b(e,"off"),t=b(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 Ro(e,n,t,s,i,r,a,l){if(!e)return"";const o=b(e,"bodyPr"),c=U(o,"vert","horz"),d=c==="vert"||c==="vert270"||c==="wordArtVert";U(o,"anchor","t");const h=C(o,"lIns",91440)/914400*96,u=C(o,"rIns",91440)/914400*96,p=C(o,"tIns",45720)/914400*96;C(o,"bIns",45720)/914400*96;const m=n+h,g=s-h-u,P=t+p,y=1800,w=b(e,"lstStyle"),x=w?b(w,"defRPr"):null,_=ge(e,"p");let v="",k=P;const j=yn("clip");l.push(`<clipPath id="${j}"><rect x="${M(n)}" y="${M(t)}" width="${M(s)}" height="${M(i)}"/></clipPath>`);const N=d?` transform="rotate(-90,${M(n+s/2)},${M(t+i/2)})"`:"",F={};for(const R of _){const T=b(R,"pPr"),A=U(T,"algn","l"),$=C(T,"marL",0)/914400*96,z=C(T,"indent",0)/914400*96,Y=b(T,"defRPr");let O=y;if(x){const D=x.getAttribute("sz");D&&(O=parseInt(D,10))}if(Y){const D=Y.getAttribute("sz");D&&(O=parseInt(D,10))}const W=b(T,"spcBef"),B=b(T,"spcAft");b(T,"lnSpc");let Z=0,Q=0;if(W){const D=b(W,"spcPct"),te=b(W,"spcPts");D?Z=O*jt/914400*96*(C(D,"val",0)/1e5):te&&(Z=C(te,"val",0)/100/72*96)}if(B){const D=b(B,"spcPct"),te=b(B,"spcPts");D?Q=O*jt/914400*96*(C(D,"val",0)/1e5):te&&(Q=C(te,"val",0)/100/72*96)}const L=T?b(T,"buChar"):null,X=T?b(T,"buAutoNum"):null,oe=!(T?b(T,"buNone"):null)&&(L||X);k+=Z;const fe=[];for(const D of R.children)(D.localName==="r"||D.localName==="br"||D.localName==="fld")&&fe.push(D);if(!fe.length){const D=b(R,"endParaRPr"),ie=C(D||Y,"sz",O)/100/72*96*1.2;k+=ie+Q;continue}let ee="";for(const D of fe){if(D.localName==="br"){ee+=`
|
|
107
|
+
`;continue}const te=b(D,"t")||b(D,"fldVal");te&&(ee+=te.textContent)}const V=[];for(const D of fe){if(D.localName==="br"){V.push({br:!0});continue}const te=b(D,"rPr")||b(D,"r")?.firstElementChild,ne=b(D,"t");if(!ne)continue;const ie=ne.textContent;if(!ie)continue;const se=Qs(D,Y,x,r,a,O),ve=se?.szPx||O/100/72*96,me=se?.family||"sans-serif",ce=se?.bold?"bold":"normal",_e=se?.italic?"italic":"normal",je=se?.color?xe(se.color):"#000000",I=te?(te.getAttribute("u")||"none")!=="none":!1,G=te?(te.getAttribute("strike")||"noStrike")!=="noStrike":!1,Ce=te?parseInt(te.getAttribute("baseline")||"0",10):0;V.push({text:ie,szPx:ve,family:me,bold:ce,italic:_e,color:je,underline:I,strike:G,baseline:Ce})}if(!V.length){k+=Q;continue}const be=V.filter(D=>!D.br&&D.szPx).map(D=>D.szPx),H=be.length?Math.max(...be):O/100/72*96,re=H*1.2,ue=k+H*.85;let K="start",le=m+$;A==="ctr"?(K="middle",le=m+g/2):A==="r"&&(K="end",le=m+g);let pe="";if(oe){const D=m+$+z;let te="";if(L)te=Ae(L.getAttribute("char")||"•");else if(X){const ie=X.getAttribute("type")||"arabicPeriod",se=C(X,"startAt",1),ve=ie+":"+se;F[ve]||(F[ve]=se),te=Ae(Io(ie,F[ve]++))}const ne=H;pe=`<text x="${M(D)}" y="${M(ue)}" font-size="${M(ne)}" font-family="sans-serif" fill="#000">${te}</text>`}let he="";for(const D of V){if(D.br){k+=re,he+=`<tspan x="${M(le)}" dy="${M(re)}">`;continue}const te=D.underline?"underline":D.strike?"line-through":"none";let ne=ue;D.baseline>0?ne=ue-D.szPx*.38:D.baseline<0&&(ne=ue+D.szPx*.12);const ie=D.baseline!==0?D.szPx*.65:D.szPx;he+=`<tspan font-family="${Ae(D.family)}, sans-serif" font-size="${M(ie)}" font-weight="${D.bold}" font-style="${D.italic}" fill="${Ae(D.color)}"`+(te!=="none"?` text-decoration="${te}"`:"")+(D.baseline!==0?` dy="${M(ne-ue)}"`:"")+`>${Ae(D.text)}</tspan>`}v+=pe,v+=`<text x="${M(le)}" y="${M(ue)}" text-anchor="${K}">${he}</text>`,k+=re+Q}return`<g clip-path="url(#${j})"${N}>${v}</g>`}function Io(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return ys(n).toLowerCase()+".";case"romanUcPeriod":return ys(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";default:return n+"."}}function ys(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 Zt(e,n,t,s,i,r){if(!e)return"";let a="";for(const l of e.children){const o=l.localName;o==="sp"?a+=await zo(l,s,i,r):o==="pic"?a+=await Lo(l,n,t,s,r):o==="cxnSp"?a+=await Do(l,s):o==="grpSp"?a+=await Bo(l,n,t,s,i,r):o==="graphicFrame"&&(a+=await Oo(l))}return a}async function zo(e,n,t,s){const i=b(e,"spPr"),r=b(i,"xfrm"),a=It(r);if(!a)return"";const l=b(i,"prstGeom"),o=l?U(l,"prst","rect"):"rect",c=b(i,"custGeom"),d=["noFill","solidFill","gradFill","blipFill","pattFill"];let h=null;for(const k of d){const j=b(i,k);if(j){h=j;break}}if(!h){const k=b(e,"style"),j=k?b(k,"fillRef"):null;if(j&&C(j,"idx",1)!==0){const N=ke(j),F=Se(N,n);F&&(h=new DOMParser().parseFromString(`<solidFill xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><srgbClr val="${xe(F).replace("#","")}"/></solidFill>`,"application/xml").documentElement)}}const{fill:u,fillAttrs:p}=pi(h,s,n,a.x,a.y,a.w,a.h);let m=b(i,"ln");if(!m){const k=b(e,"style"),j=k?b(k,"lnRef"):null;if(j&&C(j,"idx",1)!==0){const N=ke(j),F=Se(N,n);F&&(m=new DOMParser().parseFromString(`<ln xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"><solidFill><srgbClr val="${xe(F).replace("#","")}"/></solidFill></ln>`,"application/xml").documentElement)}}const g=mi(m,n),P=b(i,"effectLst"),y=gi(P,s),w=vn(r);let x="";if(o==="rect"||!l&&!c)x=`<rect x="${M(a.x)}" y="${M(a.y)}" width="${M(a.w)}" height="${M(a.h)}" fill="${Ae(u)}"${p}${g}${y}${w}/>`;else{const k=$o(o,a.x,a.y,a.w,a.h,{});x=`<path d="${Ae(k)}" fill="${Ae(u)}"${p}${g}${y}${w}/>`}const _=b(e,"txBody"),v=_?Ro(_,a.x,a.y,a.w,a.h,n,t,s):"";return`<g>${x}${v}</g>`}async function Lo(e,n,t,s,i){const r=b(e,"spPr"),a=b(r,"xfrm"),l=It(a);if(!l)return"";const o=b(e,"blipFill"),c=o?b(o,"blip"):null,d=c?c.getAttribute("r:embed")||c.getAttribute("embed"):null,h=d?n[d]:null,u=h?t[h.fullPath]:null,p=vn(a),m=b(r,"effectLst"),g=gi(m,i);if(!u)return`<rect x="${M(l.x)}" y="${M(l.y)}" width="${M(l.w)}" height="${M(l.h)}" fill="#e0e0e0"${p}/>`;const P=h.fullPath.split(".").pop().toLowerCase(),y=P==="png"?"image/png":P==="gif"?"image/gif":P==="svg"?"image/svg+xml":"image/jpeg",w=u instanceof Uint8Array?u:new Uint8Array(u),x=btoa(Array.from(w,v=>String.fromCharCode(v)).join("")),_=yn("pic");return i.push(`<clipPath id="${_}"><rect x="${M(l.x)}" y="${M(l.y)}" width="${M(l.w)}" height="${M(l.h)}"/></clipPath>`),`<image x="${M(l.x)}" y="${M(l.y)}" width="${M(l.w)}" height="${M(l.h)}" href="data:${y};base64,${x}" clip-path="url(#${_})"${g}${p} preserveAspectRatio="xMidYMid slice"/>`}async function Do(e,n,t){const s=b(e,"spPr"),i=b(s,"xfrm"),r=It(i);if(!r)return"";const a=b(s,"ln"),l=mi(a,n),o=vn(i);return`<line x1="${M(r.x)}" y1="${M(r.y)}" x2="${M(r.x+r.w)}" y2="${M(r.y+r.h)}" fill="none"${l}${o}/>`}async function Bo(e,n,t,s,i,r){const a=b(e,"grpSpPr"),l=b(a,"xfrm");It(l);const o=l?vn(l):"",c=await Zt(e,n,t,s,i,r);return`<g${o}>${c}</g>`}async function Oo(e,n,t){const s=b(e,"xfrm"),i=It(s);return i?`<rect x="${M(i.x)}" y="${M(i.y)}" width="${M(i.w)}" height="${M(i.h)}" fill="#f4f4f8" stroke="#ccc" stroke-width="1"/><text x="${M(i.x+i.w/2)}" y="${M(i.y+i.h/2)}" text-anchor="middle" font-size="14" fill="#999">Chart</text>`:""}async function Uo(e,n,t,s,i,r,a,l,o){const c=p=>{const m=b(p,"cSld"),g=m?b(m,"bg"):null;return g?{bgPr:b(g,"bgPr"),bgRef:b(g,"bgRef")}:null},d=c(e)||c(t)||c(n);if(!d)return`<rect width="${M(a)}" height="${M(l)}" fill="white"/>`;const{bgPr:h,bgRef:u}=d;if(h){const p=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const m of p){const g=b(h,m);if(g){if(m==="blipFill"){const w=b(g,"blip"),x=w?w.getAttribute("r:embed")||w.getAttribute("embed"):null,_=x&&i?i[x]:null,v=_?s[_.fullPath]:null;if(v){const j=_.fullPath.split(".").pop().toLowerCase()==="png"?"image/png":"image/jpeg",N=v instanceof Uint8Array?v:new Uint8Array(v),F=btoa(Array.from(N,R=>String.fromCharCode(R)).join(""));return`<image width="${M(a)}" height="${M(l)}" href="data:${j};base64,${F}" preserveAspectRatio="xMidYMid slice"/>`}}const{fill:P,fillAttrs:y}=pi(g,o,r,0,0,a,l);return`<rect width="${M(a)}" height="${M(l)}" fill="${Ae(P)}"${y}/>`}}}if(u){const p=ke(u),m=Se(p,r);if(m)return`<rect width="${M(a)}" height="${M(l)}" fill="${Ae(xe(m))}"/>`}return`<rect width="${M(a)}" height="${M(l)}" fill="white"/>`}async function bi(e,n){const{_files:t,slidePaths:s,slideSize:i,themeColors:r,themeData:a,masterDoc:l,masterRels:o}=n;if(e<0||e>=s.length)throw new Error("Slide index out of range");const c=s[e],d=t[c]?new TextDecoder().decode(t[c]):null;if(!d)throw new Error(`Cannot read slide ${e}`);const h=Pe(d),u=await qe(t,c),p=Object.values(u).find(T=>T.type?.includes("slideLayout")),m=p&&t[p.fullPath]?Pe(new TextDecoder().decode(t[p.fullPath])):null,g=p?await qe(t,p.fullPath):{},P=i.cx/914400*96,y=i.cy/914400*96,w=[],x=await Uo(h,l,m,t,o,r,P,y,w),_=b(b(l,"cSld"),"spTree"),v=m?b(b(m,"cSld"),"spTree"):null,k=b(b(h,"cSld"),"spTree"),j=_?await Zt(_,o,t,r,a,w):"",N=v?await Zt(v,g,t,r,a,w):"",F=k?await Zt(k,u,t,r,a,w):"",R=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="${M(P)}" height="${M(y)}" viewBox="0 0 ${M(P)} ${M(y)}">`,R,x,j,N,F,"</svg>"].join(`
|
|
109
|
+
`)}async function Wo(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await bi(t,e));return n}function vs(e){const n=e.replace(/[{}\-]/g,"");if(n.length<32){const o=n.padEnd(32,"0");return Go(o.slice(0,32))}const t=n.slice(0,8),s=n.slice(8,12),i=n.slice(12,16),r=n.slice(16,32),a=new Uint8Array(16);a[0]=parseInt(t.slice(6,8),16),a[1]=parseInt(t.slice(4,6),16),a[2]=parseInt(t.slice(2,4),16),a[3]=parseInt(t.slice(0,2),16),a[4]=parseInt(s.slice(2,4),16),a[5]=parseInt(s.slice(0,2),16),a[6]=parseInt(i.slice(2,4),16),a[7]=parseInt(i.slice(0,2),16);for(let o=0;o<8;o++)a[8+o]=parseInt(r.slice(o*2,o*2+2),16);const l=new Uint8Array(32);return l.set(a),l.set(a,16),l}function Go(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 ws(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 Sn(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 An=new Set;async function qo(e,n){const t=[],s=e["ppt/presentation.xml"];if(!s)return t;const r=new DOMParser().parseFromString(new TextDecoder().decode(s),"application/xml"),a=r.querySelector("embeddedFontLst")||[...r.getElementsByTagName("*")].find(o=>o.localName==="embeddedFontLst");if(!a)return t;const l=[...a.children].filter(o=>o.localName==="embeddedFont");for(const o of l){const c=[...o.children].find(u=>u.localName==="font");if(!c)continue;const d=c.getAttribute("typeface")||c.getAttribute("t");if(!d)continue;const h=[{el:[...o.children].find(u=>u.localName==="regular"),weight:"400",style:"normal"},{el:[...o.children].find(u=>u.localName==="bold"),weight:"700",style:"normal"},{el:[...o.children].find(u=>u.localName==="italic"),weight:"400",style:"italic"},{el:[...o.children].find(u=>u.localName==="boldItalic"),weight:"700",style:"italic"}];for(const{el:u,weight:p,style:m}of h){if(!u)continue;const g=u.getAttribute("r:id")||u.getAttribute("id")||u.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id");if(!g)continue;const P=`${d}:${p}:${m}`;if(An.has(P)){t.push({typeface:d,weight:p,style:m,status:"already-loaded"});continue}const y=n?n[g]:null;if(!y){t.push({typeface:d,weight:p,style:m,status:"rel-not-found",rId:g});continue}const w=e[y.fullPath];if(!w){t.push({typeface:d,weight:p,style:m,status:"file-not-found",path:y.fullPath});continue}let x=null;const _=vs(g),v=ws(w,_);if(Sn(v))x=v;else{const k=y.fullPath.split("/").pop().replace(".fntdata",""),j=vs(k),N=ws(w,j);Sn(N)?x=N:Sn(w)&&(x=w)}if(!x){t.push({typeface:d,weight:p,style:m,status:"decode-failed",path:y.fullPath});continue}try{const k=new FontFace(d,x.buffer,{weight:p,style:m});await k.load(),document.fonts.add(k),An.add(P),t.push({typeface:d,weight:p,style:m,status:"loaded",path:y.fullPath})}catch(k){t.push({typeface:d,weight:p,style:m,status:"load-failed",error:k.message})}}}return t}function Ko(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(o=>o.localName==="font"),a=r&&(r.getAttribute("typeface")||r.getAttribute("t"))||"",l=["regular","bold","italic","boldItalic"].filter(o=>[...i.children].some(c=>c.localName===o));return{typeface:a,variants:l,loaded:l.some(o=>An.has(`${a}:${o==="bold"||o==="boldItalic"?"700":"400"}:${o.includes("talic")?"italic":"normal"}`))}}).filter(i=>i.typeface):[]}function q(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 Ze(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 Ne(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=Ne(e,n);return s!==null?parseInt(s,10):t}function Xo(e,n){const t=q(e,"rPr"),s=q(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,a=r?r/100:12,l=t?t.getAttribute("b")==="1":!1,o=t?t.getAttribute("i")==="1":!1,c=t&&t.getAttribute("u")||"none";let d="#000000";if(t){const h=q(t,"solidFill")||q(t,"lumMod");if(h){const u=q(h,"srgbClr");u&&(d="#"+(u.getAttribute("val")||"000000"))}}return{text:i,bold:l,italic:o,underline:c!=="none",fontSize:a,color:d}}function Vo(e){const n=q(e,"pPr"),t=Ne(n,"algn","l"),s=$n(n,"lvl",0),i=q(n,"defRPr");let r=null;if(n&&!q(n,"buNone")){const o=q(n,"buChar"),c=q(n,"buAutoNum");o?r=o.getAttribute("char")||"•":c&&(r="{auto}")}const a=[];for(const o of e.children)if(o.localName==="r"){const c=Xo(o,i);c&&a.push(c)}else if(o.localName==="br")a.push({text:`
|
|
110
|
+
`,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#000"});else if(o.localName==="fld"){const c=q(o,"t");c&&a.push({text:c.textContent,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#555"})}const l=a.map(o=>o.text).join("");return{runs:a,text:l,align:t,level:s,bullet:r}}function En(e){return e?Ze(e,"p").map(Vo).filter(n=>n.text.trim()):[]}function xs(e){const n=q(e,"nvSpPr"),t=n?q(n,"nvPr"):null,s=t?q(t,"ph"):null;if(s){const r=Ne(s,"type","body");if(r==="title"||r==="ctrTitle")return"title";if(r==="subTitle")return"subtitle";if(r==="body")return"body"}return q(e,"txBody")?"textBox":"other"}function ks(e){const n=q(e,"nvSpPr"),t=n?q(n,"cNvPr"):null;return t?Ne(t,"id",""):""}function _s(e){const n=q(e,"nvSpPr"),t=n?q(n,"cNvPr"):null;return t?Ne(t,"name",""):""}function Ho(e){const n=q(e,"tbl");if(!n)return null;const t=q(e,"nvGraphicFramePr"),s=t?q(t,"cNvPr"):null,i=s?Ne(s,"id",""):"",r=s?Ne(s,"name",""):"",a=[];let l=0;for(const c of Ze(n,"tr")){const d=[];let h=0;for(const u of Ze(c,"tc")){const p=$n(u,"gridSpan",1),m=$n(u,"rowSpan",1),g=En(q(u,"txBody")),P=g.map(y=>y.text).join(`
|
|
111
|
+
`);d.push({row:l,col:h,rowSpan:m,colSpan:p,text:P,paragraphs:g}),h++}a.push(d),l++}const o=a.map(c=>c.map(d=>d.text).join(" ")).join(`
|
|
112
|
+
`);return{id:i,name:r,rows:a,text:o}}function Yo(e,n){const t=q(e,"graphic"),s=t?q(t,"graphicData"):null,i=s?q(s,"chart"):null;if(!i)return null;const r=i.getAttribute("r:id")||i.getAttribute("id"),a=q(e,"nvGraphicFramePr"),l=a?q(a,"cNvPr"):null;return{id:l?Ne(l,"id",""):"",name:l?Ne(l,"name",""):"",rId:r}}function Qo(e){if(!e)return{chartType:"unknown",seriesNames:[],categories:[]};const n=q(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 o of t)if(i=q(n,o),i){s=o.replace("3DChart","Chart").replace("Chart","");break}const r=i?Ze(i,"ser"):[],a=r.map(o=>{const c=q(o,"tx");if(!c)return null;const d=q(c,"v");if(d)return d.textContent.trim();const h=q(c,"strCache"),u=h?q(h,"pt"):null,p=u?q(u,"v"):null;return p?p.textContent.trim():null}).filter(Boolean),l=r.length>0?(()=>{const o=q(r[0],"cat")||q(r[0],"xVal");if(!o)return[];const c=q(o,"strCache")||q(o,"numCache");return c?Ze(c,"pt").map(d=>q(d,"v")?.textContent||"").filter(Boolean):[]})():[];return{chartType:s,seriesNames:a,categories:l}}function Zo(e){if(!e)return"";const n=q(e,"cSld"),t=n?q(n,"spTree"):null;if(!t)return"";const s=[];for(const i of Ze(t,"sp")){const r=q(i,"nvSpPr"),a=r?q(r,"nvPr"):null,l=a?q(a,"ph"):null;if(l&&Ne(l,"type")==="sldNum")continue;const o=q(i,"txBody");if(o){const c=Ze(o,"r").map(d=>q(d,"t")?.textContent||"").join("");c.trim()&&s.push(c.trim())}}return s.join(`
|
|
113
|
+
|
|
114
|
+
`)}async function wn(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 Jo(e);const r=new DOMParser().parseFromString(new TextDecoder().decode(i),"application/xml"),{getRels:a}=await ln(async()=>{const{getRels:v}=await Promise.resolve().then(()=>ro);return{getRels:v}},void 0,import.meta.url),l=await a(t,s[e]),o=Object.values(l).find(v=>v.type?.includes("notesSlide"));let c="";if(o&&t[o.fullPath]){const v=new DOMParser().parseFromString(new TextDecoder().decode(t[o.fullPath]),"application/xml");c=Zo(v)}const d=q(r,"cSld"),h=d?q(d,"spTree"):null;if(!h)return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:c,text:c};const u=[],p=[],m=[],g=[];for(const v of h.children){const k=v.localName;if(k==="sp"){const j=q(v,"txBody");if(!j)continue;const N=xs(v),F=ks(v),R=_s(v),T=En(j),A=T.map($=>$.text).join(`
|
|
115
|
+
`);A.trim()&&u.push({id:F,name:R,type:N,paragraphs:T,text:A})}else if(k==="pic"){const j=q(v,"nvPicPr"),N=j?q(j,"cNvPr"):null,F=N?Ne(N,"id",""):"",R=N?Ne(N,"name",""):"",T=N?Ne(N,"descr","")||Ne(N,"title",""):"",A=j?q(j,"nvPr"):null;A&&q(A,"extLst"),m.push({id:F,name:R,altText:T,title:R})}else if(k==="graphicFrame"){const j=(()=>{const N=q(v,"graphic"),F=N?q(N,"graphicData"):null;return F?Ne(F,"uri",""):""})();if(j.includes("table")||q(v,"tbl")){const N=Ho(v);N&&p.push(N)}else if(j.includes("chart")){const N=Yo(v);if(N){const F=N.rId?l[N.rId]:null;let R={chartType:"chart",seriesNames:[],categories:[]};if(F&&t[F.fullPath]){const T=new DOMParser().parseFromString(new TextDecoder().decode(t[F.fullPath]),"application/xml");R=Qo(T)}g.push({id:N.id,name:N.name,...R})}}}else if(k==="grpSp")for(const j of Ze(v,"sp")){const N=q(j,"txBody");if(!N)continue;const F=xs(j),R=ks(j),T=_s(j),A=En(N),$=A.map(z=>z.text).join(`
|
|
116
|
+
`);$.trim()&&u.push({id:R,name:T,type:F,paragraphs:A,text:$})}}const P=u.find(v=>v.type==="title"),y=u.find(v=>v.type==="subtitle"),w=P?.text||"",x=y?.text||"",_=[w,x,...u.filter(v=>v.type!=="title"&&v.type!=="subtitle").map(v=>v.text),...p.map(v=>v.text),...g.map(v=>[v.name,...v.seriesNames,...v.categories].join(" ")),c].filter(Boolean).join(`
|
|
117
|
+
|
|
118
|
+
`);return{index:e,title:w,subtitle:x,textShapes:u,tables:p,images:m,charts:g,notes:c,text:_}}function Jo(e){return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:"",text:""}}async function el(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await wn(t,e));return n}async function tl(e,n){return(await wn(e,n)).text}async function nl(e,n){const t=e.toLowerCase().trim();if(!t)return[];const s=[];for(let i=0;i<n.slideCount;i++){const r=await wn(i,n),a=r.text.toLowerCase();if(!a.includes(t))continue;const l=[];let o=0;for(;(o=a.indexOf(t,o))!==-1;){const c=Math.max(0,o-60),d=Math.min(r.text.length,o+t.length+60),h=r.text.slice(c,o),u=r.text.slice(o,o+t.length),p=r.text.slice(o+t.length,d);if(l.push({before:(c>0?"…":"")+h,match:u,after:p+(d<r.text.length?"…":"")}),o+=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 sl{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 a=0;a<this.renderer.slideCount;a++){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 ${a+1}`;const o=a;l.addEventListener("click",()=>this.goto(o)),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,a=i.clientHeight||window.innerHeight*.75;let l=r,o=l/s;o>a&&(o=a,l=o*s),this._canvas.width=Math.round(l*window.devicePixelRatio),this._canvas.height=Math.round(o*window.devicePixelRatio),this._canvas.style.width=Math.round(l)+"px",this._canvas.style.height=Math.round(o)+"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 ln(async()=>{const{renderTransitionFrame:c}=await Promise.resolve().then(()=>Mo);return{renderTransitionFrame:c}},void 0,import.meta.url),i=new OffscreenCanvas(this._canvas.width,this._canvas.height);i.getContext("2d").drawImage(this._canvas,0,0),await this.renderer.renderSlide(this._index,this._canvas,this._canvas.width/window.devicePixelRatio);const r=new OffscreenCanvas(this._canvas.width,this._canvas.height);r.getContext("2d").drawImage(this._canvas,0,0);const a=this._canvas.getContext("2d"),l=t.duration||700,o=performance.now();await new Promise(c=>{const d=h=>{const u=Math.min(1,(h-o)/l);s(a,i,r,t,u),u<1?requestAnimationFrame(d):c()};requestAnimationFrame(d)}),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 yi(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}async function il(e,n,t={}){typeof t=="number"&&(t={width:t});const{width:s=null,dpi:i=150}=t,r=s??yi(n,i),a=await wi(e,n,r),l=a.toDataURL("image/png");if(navigator.clipboard&&window.ClipboardItem)try{const c=await new Promise(d=>a.toBlob(d,"image/png"));return await navigator.clipboard.write([new ClipboardItem({"image/png":c})]),{success:!0,method:"clipboard-api",dataUrl:l}}catch(c){if(c.name!=="NotAllowedError")throw c}if(document.execCommand)try{const c=new Image;c.src=l,await new Promise(m=>{c.onload=m});const d=document.createElement("div");d.contentEditable="true",d.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;",d.appendChild(c),document.body.appendChild(d);const h=document.createRange();h.selectNodeContents(d);const u=window.getSelection();u.removeAllRanges(),u.addRange(h);const p=document.execCommand("copy");if(document.body.removeChild(d),u.removeAllRanges(),p)return{success:!0,method:"execCommand",dataUrl:l}}catch{}const o=window.open();return o&&(o.document.write(`<img src="${l}" style="max-width:100%">`),o.document.title=`Slide ${e+1}`),{success:!1,method:"opened-tab",dataUrl:l}}async function vi(e,n,t={},s){typeof t=="number"&&(t={width:t});const{width:i=null,dpi:r=300,filename:a}=t,l=i??yi(n,r),c=(await wi(e,n,l)).toDataURL("image/png"),d=a||`slide-${e+1}.png`,h=document.createElement("a");h.href=c,h.download=d,h.click()}async function rl(e,n={},t){typeof n=="number"&&(n={width:n});const{onProgress:s,...i}=n,r=s,a=e.slideCount;for(let l=0;l<a;l++)await vi(l,e,i),r?.(l+1,a),await new Promise(o=>setTimeout(o,100))}async function wi(e,n,t){const{cx:s,cy:i}=n.slideSize,r=s/i,a=Math.round(t/r),l=document.createElement("canvas");return l.width=t,l.height=a,await n.renderSlide(e,l,t),l}function al(e,n,t={}){const{thumbWidth:s=320,fullWidth:i=1280,gap:r="24px",background:a="#1a1a1a",slideBackground:l="#fff",shadow:o=!0,clickToShow:c=!1,maxWidth:d="900px",rootMargin:h=200,onSlideVisible:u,onSlideRendered:p}=t,{cx:m,cy:g}=e.slideSize,P=m/g,y=e.slideCount;n.style.cssText=`
|
|
123
|
+
background:${a};
|
|
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=[],_=[];for(let F=0;F<y;F++){const R=document.createElement("div");R.style.cssText=`
|
|
132
|
+
width:100%;
|
|
133
|
+
max-width:${d};
|
|
134
|
+
position:relative;
|
|
135
|
+
background:${l};
|
|
136
|
+
border-radius:4px;
|
|
137
|
+
${o?"box-shadow:0 4px 24px rgba(0,0,0,0.5);":""}
|
|
138
|
+
overflow:hidden;
|
|
139
|
+
aspect-ratio:${m}/${g};
|
|
140
|
+
flex-shrink:0;
|
|
141
|
+
`,R.setAttribute("data-slide",F);const T=document.createElement("div");T.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
|
+
`,T.textContent=F+1,R.appendChild(T);const A=document.createElement("canvas");A.style.cssText="display:block;width:100%;height:100%;",A.width=s,A.height=Math.round(s/P),R.appendChild(A);const $=ol(F,m,g,l);R.appendChild($),c&&(R.style.cursor="pointer",R.addEventListener("click",()=>{new(require("./slideshow.js")).SlideShow(e,document.body).start(F)})),n.appendChild(R),w.push(R),x.push(A),_.push("pending")}const v=[];let k=!1;async function j(){if(!(k||v.length===0)){for(k=!0;v.length>0;){const F=v.shift();if(_[F]==="full")continue;const R=x[F],A=w[F].querySelector("[data-placeholder]");try{R.width=i,R.height=Math.round(i/P),await e.renderSlide(F,R,i),_[F]="full",R.style.transition="opacity 0.3s",R.style.opacity="1",A&&(A.style.display="none"),p?.(F)}catch($){console.warn(`LazyDeck: failed to render slide ${F}`,$)}}k=!1}}const N=new IntersectionObserver(F=>{for(const R of F){if(!R.isIntersecting)continue;const T=parseInt(R.target.getAttribute("data-slide"),10);if(!(isNaN(T)||_[T]==="full")){u?.(T);for(const A of[T,T-1,T+1,T+2].filter($=>$>=0&&$<y))_[A]!=="full"&&!v.includes(A)&&v.push(A);j()}}},{root:n,rootMargin:`${h}px`,threshold:0});return w.forEach(F=>N.observe(F)),{destroy(){N.disconnect(),n.innerHTML=""},scrollTo(F,R="smooth"){const T=w[F];T&&T.scrollIntoView({behavior:R,block:"start"})},async renderAll(F){for(let R=0;R<y;R++)_[R]!=="full"&&v.push(R);await j()},getCanvas(F){return x[F]||null},get slideCount(){return y}}}function ol(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 a=document.createElement("style");a.id="_pptx_lazy_css",a.textContent="@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}",document.head.appendChild(a)}return i.innerHTML=r,i}class ll{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 Hs(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=Pe(i),a=b(r,"sldSz");a&&(this.slideSize={cx:C(a,"cx",9144e3),cy:C(a,"cy",5143500)});const l=await qe(this._files,"ppt/presentation.xml");if(this.embeddedFonts=Ma(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 o=b(r,"sldIdLst");if(o)for(const h of o.children){if(h.localName!=="sldId")continue;const u=h.getAttribute("r:id")||h.getAttribute("id"),p=l[u];p&&this.slidePaths.push(p.fullPath)}this.slideCount=this.slidePaths.length,t(.2,"Loading theme…");let c=Object.values(l).find(h=>h.type?.includes("theme"))?.fullPath;if(!c){const h=Object.values(l).find(u=>u.type?.includes("slideMaster"));if(h){const u=await qe(this._files,h.fullPath);c=Object.values(u).find(p=>p.type?.includes("theme"))?.fullPath}}if(c){const h=this._readText(c);h&&(this.themeData=Pa(Pe(h)))}this.themeData||(this.themeData={colors:{},majorFont:"Calibri Light",minorFont:"Calibri"}),this.themeColors={...this.themeData.colors},t(.3,"Loading master…");const d=Object.values(l).find(h=>h.type?.includes("slideMaster"));if(d){const h=this._readText(d.fullPath);if(h){this.masterDoc=Pe(h),this.masterRels=await qe(this._files,d.fullPath),this.masterImages=await Yt(this._files,this.masterRels),this._trackBlobs(this.masterImages);const u=Ta(this.masterDoc);this.themeColors=ja(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 a=Pe(r),l=await qe(this._files,i),o=await Yt(this._files,l);this._trackBlobs(o);let c=null,d={},h={};const u=Object.values(l).find(v=>v.type?.includes("slideLayout"));if(u){const v=this._readText(u.fullPath);v&&(c=Pe(v),d=await qe(this._files,u.fullPath),h=await Yt(this._files,d),this._trackBlobs(h))}const p={...this.masterImages,...h,...o},m=ri([c,this.masterDoc]),g=Ra([a,c,this.masterDoc]);await Ea(g,this.themeData);const P=s/this.slideSize.cx,y=Math.round(this.slideSize.cy*P);t.width=s,t.height=y;const w=t.getContext("2d");w.clearRect(0,0,s,y),await ii(w,a,this.masterDoc,c,l,this.masterRels,p,this.themeColors,P,this.slideSize.cx,this.slideSize.cy),await this._renderNonPlaceholders(w,this.masterDoc,this.masterRels,this.masterImages,P),await this._renderNonPlaceholders(w,c,d,h,P);const x=b(a,"cSld"),_=x?b(x,"spTree"):null;_&&await oi(w,_,l,p,this.themeColors,this.themeData,P,m,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 Fn(n,t,s)}registerFonts(n){return Na(n)}listRegisteredFonts(){return Ia()}_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 a=b(t,"cSld"),l=a?b(a,"spTree"):null;if(l)for(const o of l.children){const c=o.localName;if(!["sp","pic","grpSp","graphicFrame","cxnSp"].includes(c))continue;const d=b(o,"nvSpPr"),h=d?b(d,"nvPr"):null;if(!(h&&b(h,"ph")))try{c==="sp"?await hn(n,o,s,i,this.themeColors,this.themeData,r):c==="pic"?await pn(n,o,s,i,this.themeColors,r):c==="grpSp"?await mn(n,o,s,i,this.themeColors,this.themeData,r):c==="graphicFrame"?await bn(n,o,this.themeColors,this.themeData,r):c==="cxnSp"&&await gn(n,o,this.themeColors,r)}catch(u){console.warn(`[PptxRenderer] master/layout shape error (${c}):`,u)}}}getAnimations(n){const t=this.slidePaths[n];if(!t||!this._files)return[];const s=this._files[t];if(!s)return[];const i=Pe(new TextDecoder().decode(s));return Kn(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=Pe(new TextDecoder().decode(s));return Xn(i)}createPlayer(n){return new hi(this,n)}async toSvg(n){return bi(n,this)}async allToSvg(){return Wo(this)}async loadEmbeddedFonts(){const n=this._presRels||{};return qo(this._files,n)}listEmbeddedFonts(){return Ko(this._files)}async extractSlide(n){return wn(n,this)}async extractAll(){return el(this)}async extractText(n){return tl(n,this)}async searchSlides(n){return nl(n,this)}createShow(n,t={}){return new sl(this,n,t)}async copySlide(n,t={}){return il(n,this,t)}async downloadSlide(n,t={}){return vi(n,this,t)}async downloadAllSlides(n={}){return rl(this,n)}createDeck(n,t={}){return al(this,n,t)}edit(){return an.fromRenderer(this)}async toPdf(n={}){return qn(this,n)}async downloadPdf(n="presentation.pdf",t={}){return Po(this,n,t)}async slideToPdf(n,t={}){return To(n,this,t)}async getSlideNotes(n){if(n<0||n>=this.slidePaths.length)return"";const t=await qe(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=Pe(i),a=[];for(const l of ge(r,"sp")){const o=b(b(l,"nvSpPr"),"nvPr"),c=o?b(o,"ph"):null;if(!(c&&U(c,"type")==="sldNum"))for(const d of ge(l,"t"))a.push(d.textContent)}return a.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 a=await r.convertToBlob({type:s,quality:i});return new Promise(l=>{const o=new FileReader;o.onload=()=>l(o.result),o.readAsDataURL(a)})}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 cl=({asset:e,bytes:n,onOpenExternal:t,dense:s=!1,expanded:i=!1})=>{const r=E.useRef(null),a=E.useRef(null),[l,o]=E.useState({phase:"loading",progress:0}),[c,d]=E.useState(0),[h,u]=E.useState(1),[p,m]=E.useState(0),[g,P]=E.useState(!1),[y,w]=E.useState([]),[x,_]=E.useState(!s),v=E.useRef(null),[k,j]=E.useState(!1);E.useEffect(()=>{_(!s)},[s]),E.useLayoutEffect(()=>{const T=v.current;if(!T)return;const A=()=>j(T.getBoundingClientRect().height<360);A();const $=new ResizeObserver(A);return $.observe(T),()=>$.disconnect()},[]),E.useEffect(()=>{let T=!1;const A=new ll;return r.current=A,o({phase:"loading",progress:0}),d(0),u(1),A.load(n,$=>{T||o({phase:"loading",progress:$})}).then(async()=>{if(T)return;const $=A.slideCount,Y=(await A.renderAllSlides(160)).map(O=>O.toDataURL("image/png"));T||o({phase:"ready",slideCount:$,thumbnails:Y})}).catch($=>{T||o({phase:"error",detail:$ instanceof Error&&$.message?$.message:S("ui.library.preview.pptx_failed_detail")})}),()=>{T=!0,A.destroy(),r.current=null}},[n,p]);const N=E.useCallback(async()=>{const T=r.current,A=a.current;if(!(!T||!A||l.phase!=="ready"))try{await T.renderSlide(c,A,Math.round(960*h))}catch($){o({phase:"error",detail:$ instanceof Error&&$.message?$.message:S("ui.library.preview.pptx_failed_detail")})}},[c,l.phase,h]);E.useEffect(()=>{N()},[N]),E.useEffect(()=>{const T=r.current;if(!T||l.phase!=="ready")return;let A=!1;return T.extractSlide(c).then($=>{A||w($.textShapes.map(z=>z.text.trim()).filter(Boolean))}).catch(()=>{A||w([])}),()=>{A=!0}},[c,l.phase]);const F=l.phase==="ready"?l.slideCount:0,R=T=>{F!==0&&d(Math.min(Math.max(T,0),F-1))};return l.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:l.detail}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(J,{variant:"secondary",size:"sm",onClick:()=>m(T=>T+1),children:S("ui.library.preview.retry")}),f.jsxs(J,{variant:"secondary",size:"sm",disabled:g,onClick:()=>{P(!0),pt(e).catch(T=>Te(T instanceof Error&&T.message?T.message:S("ui.library.menu.save_failed"))).finally(()=>P(!1))},children:[f.jsx(ht,{"aria-hidden":"true"}),S("ui.library.menu.download")]}),t&&f.jsxs(J,{variant:"ghost",size:"sm",onClick:t,children:[f.jsx($s,{"aria-hidden":"true"}),S("ui.library.preview.open_externally")]})]})]}):f.jsxs("div",{ref:v,className:"flex min-h-0 flex-1 flex-col gap-2 p-3","data-pptx-viewer":"",onKeyDown:T=>{T.key==="ArrowRight"||T.key==="PageDown"?(T.preventDefault(),R(c+1)):T.key==="ArrowLeft"||T.key==="PageUp"?(T.preventDefault(),R(c-1)):T.key==="Home"?(T.preventDefault(),R(0)):T.key==="End"&&(T.preventDefault(),R(F-1))},children:[f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[f.jsx("div",{"data-pptx-slide":"",className:ye("flex min-h-[120px] min-w-0 flex-1 flex-col items-center rounded-md bg-canvas p-2",i?"justify-start overflow-y-auto":"justify-center"),children:l.phase==="loading"?f.jsxs("div",{className:"flex w-60 flex-col items-center gap-2",children:[f.jsx(Ln,{size:18,"aria-hidden":"true",className:"motion-safe:animate-spin text-ink-muted"}),f.jsx(ir,{value:Math.round(l.progress*100)}),f.jsx("span",{className:"text-meta text-ink-muted",children:S("ui.library.preview.pptx_preparing")})]}):f.jsx("canvas",{ref:a,className:ye("rounded-xs bg-surface",i?"h-auto max-w-full w-full":"max-h-full max-w-full"),"aria-label":S("ui.library.preview.slide_of",{index:String(c+1),count:String(F)})})}),l.phase==="ready"&&!k&&!s&&f.jsx("div",{className:"flex h-[72px] shrink-0 flex-row gap-1 overflow-x-auto overflow-y-hidden",children:l.thumbnails.map((T,A)=>f.jsx("button",{type:"button",onClick:()=>d(A),"aria-pressed":A===c,"aria-label":S("ui.library.preview.go_to_slide",{index:String(A+1)}),className:ye("h-16 w-24 shrink-0 rounded-xs border p-0.5",A===c?"border-accent":"border-hairline hover:border-control"),children:f.jsx("img",{src:T,alt:"",loading:"lazy",className:"h-full w-full rounded-xs object-contain"})},A))})]}),l.phase==="ready"&&f.jsxs("div",{className:"shrink-0 rounded-md bg-canvas px-2 py-1","data-pptx-transcript":"",children:[s?f.jsx(J,{variant:"ghost",size:"sm","aria-expanded":x,onClick:()=>_(T=>!T),children:S("ui.library.preview.pptx_text")}):null,x&&f.jsx("div",{className:"max-h-24 overflow-y-auto text-meta text-ink-muted",children:y.length?y.map((T,A)=>f.jsx("p",{"data-pptx-transcript-line":"",className:"truncate",children:T},`${A}:${T}`)):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(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.previous_slide"),disabled:c===0||l.phase!=="ready",onClick:()=>R(c-1),children:f.jsx(Bn,{"aria-hidden":"true"})}),f.jsx("span",{className:"text-meta tabular-nums text-ink-muted",children:S("ui.library.preview.slide_of",{index:String(F?c+1:0),count:String(F)})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.next_slide"),disabled:c>=F-1||l.phase!=="ready",onClick:()=>R(c+1),children:f.jsx(rr,{"aria-hidden":"true"})})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.zoom_out"),onClick:()=>u(T=>Math.max(.5,T-.25)),children:f.jsx(Hi,{"aria-hidden":"true"})}),f.jsxs("span",{className:"w-10 text-center text-meta tabular-nums text-ink-muted",children:[Math.round(h*100),"%"]}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.zoom_in"),onClick:()=>u(T=>Math.min(2,T+.25)),children:f.jsx(Yi,{"aria-hidden":"true"})}),f.jsx(J,{variant:"ghost",size:"sm",onClick:()=>u(1),disabled:h===1,children:S("ui.library.preview.fit")})]})]})]})},vt=({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(Ln,{size:16,"aria-hidden":"true",className:"motion-safe:animate-spin"}),e??S("ui.library.preview.loading")]}),wt=({detail:e,asset:n})=>{const[t,s]=E.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(Je,{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(J,{variant:"secondary",size:"sm",disabled:t,onClick:()=>{s(!0),pt(n).catch(i=>Te(i instanceof Error&&i.message?i.message:S("ui.library.menu.save_failed"))).finally(()=>s(!1))},children:[f.jsx(ht,{"aria-hidden":"true"}),S("ui.library.menu.download")]})]})},Ss=({asset:e})=>f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Je,{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(J,{variant:"secondary",size:"sm",onClick:()=>{e.ref.path&&window.api.openFile(e.ref.path)},children:S("ui.library.preview.open_externally")}):null,f.jsxs(J,{variant:"secondary",size:"sm",onClick:()=>void pt(e),children:[f.jsx(ht,{"aria-hidden":"true"}),S("ui.library.menu.download")]})]})]}),dl=72;function zt(e,n){const t=Gn(e)?e.ref.path:null,[s,i]=E.useState(!1),r=bt(e.id,"content",!t||s),[a,l]=E.useState({bytes:null,mimeType:"",error:null,loading:!!t}),o=e.ref.content_type;return E.useEffect(()=>{if(!t)return;if(!window.api?.readFileBytes){i(!0),l({bytes:null,mimeType:"",error:S("ui.library.preview.could_not_load"),loading:!1});return}let c=!1;return i(!1),l(d=>({...d,loading:!0})),window.api.readFileBytes(t).then(d=>{c||(d.success||i(!0),l(d.success?{bytes:d.data,mimeType:o||"",error:null,loading:!1}:{bytes:null,mimeType:"",error:d.error,loading:!1}))}),()=>{c=!0}},[t,n,o]),t&&!s?a:r}const ul=({asset:e,mediaSiblings:n,revision:t,expanded:s})=>{const{bytes:i,mimeType:r,error:a,loading:l}=zt(e,t),o=yt(i,r||e.ref.content_type),c=Gs(e.id,e.kind==="audio"),d=E.useRef(null),h=E.useRef(null),u=E.useRef(null),p=E.useRef(null),[m,g]=E.useState(null),[P,y]=E.useState(null),w=E.useMemo(()=>{const k=(n??[]).filter(j=>j.kind==="image"||j.kind==="video");return k.some(j=>j.id===e.id)?[...k]:[e]},[n,e]),x=Math.max(0,w.findIndex(k=>k.id===e.id)),_=Oe(e);if(E.useEffect(()=>{if(e.kind!=="video"||!o)return;const k=u.current,j=p.current;if(!k||!j)return;const N=()=>{const R=k.getBoundingClientRect(),T=j.getBoundingClientRect(),A=Math.max(0,T.height-dl);if(A<=0||T.width<=0){g(z=>z===null?z:null);return}const $={top:T.top-R.top,left:T.left-R.left,width:T.width,height:A};g(z=>z&&z.top===$.top&&z.left===$.left&&z.width===$.width&&z.height===$.height?z:$)};N(),j.addEventListener("loadedmetadata",N),j.addEventListener("loadeddata",N),j.addEventListener("canplay",N),window.addEventListener("resize",N);const F=typeof ResizeObserver>"u"?null:new ResizeObserver(N);return F?.observe(j),F?.observe(k),()=>{F?.disconnect(),j.removeEventListener("loadedmetadata",N),j.removeEventListener("loadeddata",N),j.removeEventListener("canplay",N),window.removeEventListener("resize",N)}},[e.kind,o]),l)return f.jsx(vt,{});if(a||!o)return f.jsx(wt,{detail:a||"The bytes were empty.",asset:e});const v=f.jsx(xa,{open:P!==null,siblings:w,index:P??x,onIndexChange:y,onClose:()=>y(null),resolved:{assetId:e.id,url:o},restoreFocusTo:e.kind==="video"?h:d});switch(e.kind){case"image":return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",ref:d,"aria-label":_,title:_,onClick:()=>y(x),"data-library-media-trigger":"image",className:"flex h-full min-h-0 w-full min-w-0 flex-1 cursor-zoom-in items-center justify-center overflow-hidden bg-canvas p-3",children:f.jsx("img",{src:o,alt:e.name||e.derived_name,className:"block h-auto max-h-full w-auto max-w-full object-contain"})}),v]});case"audio":return f.jsxs("div",{className:"flex w-full max-w-100 flex-1 flex-col items-center justify-center gap-3 p-6",children:[f.jsx(Je,{kind:"audio",size:32,className:"text-ink-dim"}),f.jsx(As,{variant:"full",ownerId:`sound:library:${e.id}`,src:o,label:Oe(e),peaks:c,durationHint:e.duration_s,className:s?void 0:"max-w-100"})]});default:return f.jsxs(f.Fragment,{children:[f.jsxs("div",{ref:u,className:"relative 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",{ref:p,src:o,controls:!0,className:"max-h-full max-w-full rounded-sm",children:f.jsx("track",{kind:"captions"})}),m?f.jsx("button",{type:"button",tabIndex:-1,"aria-hidden":"true",onClick:()=>y(x),"data-library-media-trigger":"video-surface",className:"absolute z-[1] cursor-zoom-in bg-transparent",style:{top:m.top,left:m.left,width:m.width,height:m.height}}):null,f.jsx(J,{variant:"ghost",size:"icon-sm",ref:h,"aria-label":_,title:_,onClick:()=>y(x),"data-library-media-trigger":"video",className:"absolute top-2 end-2 z-[2]",children:f.jsx(Es,{"aria-hidden":"true"})})]}),v]})}},fl=({asset:e,revision:n})=>{const{bytes:t,mimeType:s,error:i,loading:r}=zt(e,n),a=yt(t,s||e.ref.content_type);return r?f.jsx(vt,{}):i||!a?f.jsx(wt,{detail:i||"The bytes were empty.",asset:e}):f.jsx("iframe",{title:e.name||e.derived_name,src:a,className:"size-full flex-1 border-0 bg-surface",sandbox:e.kind==="html"?"allow-scripts":void 0})},hl=({asset:e,text:n,expanded:t,revision:s,mtimeMs:i})=>{const r=e.ref.type==="path"&&!!e.ref.path&&e.exists,a=e.ref.path,[l,o]=E.useState({state:"pending"});E.useEffect(()=>{if(!r||!a||i!==null)return;let h=!1;return ur(a).then(u=>{h||o({state:"done",mtimeMs:u?.mtimeMs??null})}),()=>{h=!0}},[r,a,s,i]);const c=i??(l.state==="done"?l.mtimeMs:null),d=E.useMemo(()=>!r||!a||i===null&&l.state!=="done"?null:ba(e,n,c),[e,r,a,l,n,i,c]);return r&&d===null?f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center",children:f.jsx(vt,{label:S("ui.library.preview.checking_file")})}):d?f.jsx("div",{"data-lo-pane-edge-cues":!0,className:"min-h-0 flex-1 overflow-y-auto bg-sunken",children:f.jsxs("div",{className:ye("mx-auto flex w-full flex-col gap-4 px-6 py-8",t?"max-w-none":"max-w-[760px]"),children:[f.jsx("p",{className:"text-meta text-ink-dim",children:S("ui.library.preview.breadcrumb",{name:d.title})}),f.jsx(fr,{document:d,measure:t?"fill":"reading"})]})}):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:ye("mx-auto",t?"max-w-[980px]":"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(Qi,{remarkPlugins:[Zi],children:n})})]})})},pl=({asset:e,expanded:n,revision:t,mtimeMs:s})=>{const{bytes:i,error:r,loading:a}=zt(e,t);if(a)return f.jsx(vt,{});if(r||!i)return f.jsx(wt,{detail:r||"The bytes were empty.",asset:e});const l=new TextDecoder("utf-8",{fatal:!1}).decode(i);return e.kind==="markdown"?f.jsx(hl,{asset:e,text:l,expanded:n,revision:t,mtimeMs:s}):f.jsx("pre",{"data-lo-pane-edge-cues":!0,className:ye("min-h-0 w-full flex-1 overflow-auto p-4 font-mono text-mono-sm text-ink",e.kind==="code"?"whitespace-pre":"whitespace-pre-wrap break-words"),children:l})},ml=({asset:e,revision:n})=>{const{bytes:t,error:s,loading:i}=zt(e,n);return i?f.jsx(vt,{}):s||!t?f.jsx(wt,{detail:s||"The bytes were empty.",asset:e}):f.jsx(gl,{asset:e,bytes:t})},Ps=200,Ts=40,gl=({asset:e,bytes:n})=>{const t=(()=>{try{const r=hr(n,{type:"array"}),a=r.SheetNames[0];if(!a)return null;const l=pr.sheet_to_json(r.Sheets[a],{header:1,raw:!1,defval:""});return{name:a,rows:l}}catch{return null}})();if(!t)return f.jsx(wt,{detail:S("ui.library.preview.sheet_unreadable"),asset:e});const s=t.rows.slice(0,Ps),i=t.rows.length>Ps;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-max min-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-start text-ink-muted",children:"#"}),(s[0]??[]).slice(0,Ts).map((r,a)=>f.jsx("th",{className:"sticky top-0 border-b border-hairline bg-sunken px-2 py-1 text-start font-medium text-ink-muted",children:String.fromCharCode(65+a%26)},a))]})}),f.jsx("tbody",{children:s.map((r,a)=>f.jsxs("tr",{className:"odd:bg-canvas",children:[f.jsx("td",{className:"px-2 py-1 text-right tabular-nums text-ink-dim",children:a+1}),r.slice(0,Ts).map((l,o)=>f.jsx("td",{className:"whitespace-nowrap border-b border-hairline px-2 py-1 font-mono text-ink",children:String(l??"")},o))]},a))})]}),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})})]})},bl=({asset:e,dense:n=!1,expanded:t=!1,revision:s=0,mtimeMs:i=null,mediaSiblings:r})=>e.kind==="pptx"?f.jsx(yl,{asset:e,dense:n,expanded:t,revision:s}):e.kind==="image"||e.kind==="audio"||e.kind==="video"?f.jsx(ul,{asset:e,mediaSiblings:r,revision:s,expanded:t}):e.kind==="pdf"||e.kind==="html"?f.jsx(fl,{asset:e,revision:s}):e.kind==="markdown"||e.kind==="text"||e.kind==="code"?f.jsx(pl,{asset:e,expanded:t,revision:s,mtimeMs:i}):e.kind==="spreadsheet"?f.jsx(ml,{asset:e,revision:s}):e.kind==="docx"?f.jsx(Ss,{asset:e}):f.jsx(Ss,{asset:e}),yl=({asset:e,dense:n=!1,expanded:t,revision:s})=>{const{bytes:i,error:r,loading:a}=zt(e,s);return a?f.jsx(vt,{label:S("ui.library.preview.pptx_opening")}):r||!i?f.jsx(wt,{detail:r||"The bytes were empty.",asset:e}):f.jsx(cl,{asset:e,bytes:i,dense:n,expanded:t})};function vl(e){const n=qr(!0),t=Xr().create,s=Kr(),[i,r]=E.useState(!1);return{commit:async l=>{r(!0);try{const o=new Map([...n.data??[],...e.tags].map(d=>[d.name.toLowerCase(),d.id])),c=[];for(const d of l){const h=d.trim().toLowerCase();if(!h)continue;let u=o.get(h);u||(u=(await t.mutateAsync({name:h})).id,o.set(h,u)),c.includes(u)||c.push(u)}await s.mutateAsync({id:e.id,tags:c})}catch(o){Te(o instanceof Error&&o.message?o.message:S("ui.library.preview.tags_not_saved"))}finally{r(!1)}},saving:i}}const js=({asset:e,nowMs:n,onClose:t,onOpenConversation:s,onFilterSession:i,onAsk:r,onToggleFavorite:a,composerFocusSignal:l,focusRequest:o,standalone:c=!1,onExpand:d,mediaSiblings:h})=>{ct();const u=Us(),{commit:p,saving:m}=vl(e),g=E.useRef(null),P=E.useRef(null),y=E.useRef(null),[w,x]=E.useState(0),[_,v]=E.useState(0),[k,j]=E.useState(!1),[N,F]=E.useState(e.id);N!==e.id&&(F(e.id),x(0),v(0),j(!1));const[R,T]=E.useState(!1),[A,$]=E.useState(!1),[z,Y]=E.useState({}),[O,W]=E.useState({}),[B,Z]=E.useState(0),[Q,L]=E.useState({}),X=ua(e,B),ae=Ws(),oe=e.chat?.session_id??z[e.id]??null,fe=O[e.id]??R;E.useLayoutEffect(()=>{const K=g.current;if(!K)return;const le=()=>T(K.getBoundingClientRect().height<700);le();const pe=new ResizeObserver(le);return pe.observe(K),()=>pe.disconnect()},[]);const ee=E.useMemo(()=>e.tags.map(K=>K.name),[e.tags]),V=!R||A,be=()=>{j(!0),$(!0)};E.useEffect(()=>{if(!k||!V)return;const K=y.current;K&&(j(!1),K.scrollIntoView({block:"center"}),v(le=>le+1))},[k,V]),E.useEffect(()=>{o&&(o.field==="tags"?be():(P.current?.scrollIntoView({block:"center"}),x(K=>K+1)))},[o?.signal]);const H=async K=>{try{await u.mutateAsync({id:e.id,fields:K})}catch(le){throw Te(le instanceof Error&&le.message?le.message:S("ui.library.preview.not_saved")),le}},re=async()=>{try{await u.mutateAsync({id:e.id,fields:{locked:!e.locked}})}catch(K){Te(K instanceof Error&&K.message?K.message:S("ui.library.preview.not_saved"))}},ue=()=>{if(e.ref.type==="path"&&e.ref.path){window.api.openFile(e.ref.path);return}pt(e).catch(()=>Te(S("ui.library.menu.save_failed")))};return f.jsxs("div",{ref:g,className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden bg-surface","data-library-preview":e.id,"data-library-compact":R?"":void 0,"data-glass-region":"pane",children:[f.jsxs("header",{className:"flex shrink-0 flex-col gap-2 px-4 pt-3 pb-2",children:[c&&f.jsxs(J,{variant:"ghost",size:"sm",className:"self-start",onClick:t,children:[f.jsx(Bn,{"aria-hidden":"true"}),S("ui.library.page.back")]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Je,{kind:e.kind,size:18,className:"text-ink-dim"}),f.jsx("div",{ref:P,className:"min-w-0 flex-1",children:f.jsx(rs,{value:Oe(e),onSave:K=>H({name:K}),label:S("ui.library.preview.name"),textClassName:"text-heading font-medium",field:"name",startSignal:w,className:"min-w-0"},`${e.id}:name`)}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[f.jsx(Gt,{content:e.favorite?S("ui.library.menu.unfavorite"):S("ui.library.menu.favorite"),children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":e.favorite,"aria-label":e.favorite?S("ui.library.menu.unfavorite"):S("ui.library.menu.favorite"),onClick:a,children:f.jsx(cn,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0})})}),f.jsx(Gt,{content:e.locked?S("ui.library.preview.unlock"):S("ui.library.preview.lock"),children:f.jsx(J,{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 re(),children:e.locked?f.jsx(mr,{"aria-hidden":"true",className:"text-accent"}):f.jsx(gr,{"aria-hidden":"true"})})}),d&&f.jsx(Gt,{content:S("ui.library.preview.expand"),children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.expand"),onClick:d,children:f.jsx(Es,{"aria-hidden":"true"})})}),f.jsx(Wn,{asset:e,onAsk:r,onEditMetadata:()=>x(K=>K+1),onEditTags:be,onToggleFavorite:a,onOpenConversation:s,onFilterSession:i}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.preview.close"),onClick:t,children:f.jsx(Ve,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta text-ink-muted",children:[f.jsx(rt,{variant:"neutral",children:e.kind}),f.jsx(rt,{variant:"neutral",children:S(dn(e.origin_group))}),Gn(e)&&X.mtimeMs!==null&&Math.floor(X.mtimeMs/1e3)!==Math.floor(e.modified_at)?f.jsx("span",{"data-library-file-live":"",children:en(X.sizeBytes??e.size_bytes)}):f.jsx("span",{children:en(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:Dr(e.organized.at,n)})}):f.jsx("span",{children:S("ui.library.preview.unorganized")}),e.exists?null:f.jsx(rt,{variant:"warning",children:S("ui.library.preview.missing_file")})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsxs(J,{variant:"secondary",size:"sm",onClick:ue,children:[f.jsx($s,{"aria-hidden":"true"}),S("ui.library.preview.open")]}),e.ref.type==="path"&&e.ref.path?f.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(Pn,{"aria-hidden":"true"}),S("ui.library.preview.reveal")]}):null,f.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>void pt(e).then(()=>Tn(S("ui.library.menu.saved_a_copy"))).catch(()=>Te(S("ui.library.menu.save_failed"))),children:[f.jsx(ht,{"aria-hidden":"true"}),S("ui.library.preview.download")]}),e.occurrences[0]?f.jsx(J,{variant:"link",size:"sm",className:"h-auto max-w-full min-w-0 justify-start whitespace-normal text-start",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]}),R&&f.jsxs(J,{variant:"ghost",size:"sm",className:"self-start","aria-expanded":A,onClick:()=>$(K=>!K),children:[f.jsx(Ls,{"aria-hidden":"true",className:ye("transition-transform duration-fast",A&&"rotate-180")}),S("ui.library.preview.details")]}),(!R||A)&&f.jsxs(f.Fragment,{children:[f.jsx(rs,{value:e.description,onSave:K=>H({description:K}),label:S("ui.library.preview.description"),placeholder:S("ui.library.preview.add_description"),multiline:!0,rows:3,allowEmpty:!0,textClassName:"text-body-sm",field:"description"},`${e.id}:description`),f.jsx("div",{ref:y,className:"min-w-0",children:f.jsx(ca,{value:ee,onChange:K=>void p(K),label:S("ui.library.preview.tags"),addLabel:S("ui.library.preview.add_tag"),saving:m,startSignal:_},`${e.id}:tags`)})]})]}),f.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-sunken",children:f.jsx(bl,{asset:e,dense:R,expanded:c,revision:X.revision,mtimeMs:X.mtimeMs,mediaSiblings:h})}),oe&&f.jsx(ga,{sessionId:oe,title:e.chat?.title??oe,collapsed:fe,onToggleCollapsed:()=>W(K=>({...K,[e.id]:!fe})),onOpenChat:()=>s(oe),onUnlink:()=>{Y(K=>{const le={...K};return delete le[e.id],le}),ae.mutate({id:e.id})},onTurnSettled:()=>Z(K=>K+1),onStreamingChange:K=>L(le=>({...le,[oe]:K}))}),f.jsx("div",{className:"shrink-0",children:f.jsx(ma,{asset:e,focusSignal:l,showLinkedRow:!oe,onOpenChat:s,refreshSignal:B,streaming:oe?Q[oe]:!1,onSessionChange:(K,le)=>Y(pe=>({...pe,[K]:le}))})})]})},xi="library-view",ki="library-filters",_i="library-details-width",wl=1152,Pt=448,Jt=320,Si=720,xl=320,kl=192,_l=1200,Sl=900;function Pl(){try{return localStorage.getItem(xi)==="list"?"list":"grid"}catch{return"grid"}}function Tl(){try{const e=localStorage.getItem(_i);if(!e)return Pt;const n=Number(e);return Number.isFinite(n)?Math.min(Si,Math.max(Jt,Math.round(n))):Pt}catch{return Pt}}function jl(){try{const e=sessionStorage.getItem(ki);if(!e)return Xt;const n=JSON.parse(e);return{...Xt,...n,scope:n.scope==="all"?"all":"final",q:""}}catch{return Xt}}function Cl(e){try{localStorage.setItem(_i,String(e))}catch{}}function Fl(e){try{sessionStorage.setItem(ki,JSON.stringify({...e,q:""}))}catch{}}function Nl(){const[e,n]=E.useState(null),[t,s]=E.useState(0);return E.useLayoutEffect(()=>{if(!e)return;s(e.getBoundingClientRect().width);const i=new ResizeObserver(r=>{const a=r[0];a&&s(a.contentRect.width)});return i.observe(e),()=>i.disconnect()},[e]),{ref:n,width:t}}function Ml(){const[e,n]=E.useState(()=>window.innerWidth);return E.useEffect(()=>{const t=()=>n(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e}const Al=({enabled:e,nowMs:n})=>{const t=Os(e),s=Hr(),i=Fs(),r=t.data;if(!r)return null;const a=r.last_run_at??r.last_run?.at??null,l=r.unorganized??r.library?.unorganized??null;return f.jsxs("div",{className:"flex min-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:a?S("ui.library.librarian.last_organized",{at:$l(a,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:"ms-auto flex items-center gap-1",children:[f.jsxs(J,{variant:"ghost",size:"sm",disabled:!r.enabled||s.isPending,onClick:()=>s.mutate("run",{onError:o=>Te(o instanceof Error?o.message:S("ui.library.librarian.control_failed"))}),children:[f.jsx(jn,{"aria-hidden":"true"}),S("ui.library.librarian.organize_now")]}),f.jsx(J,{variant:"ghost",size:"sm",disabled:!r.session_id||s.isPending,onClick:()=>s.mutate("open",{onSuccess:o=>{o?.session_id&&Cs(i,o.session_id)},onError:o=>Te(o instanceof Error?o.message:S("ui.library.librarian.control_failed"))}),children:S("ui.library.librarian.open")})]})]})};function $l(e,n){const t=Math.max(0,n-e*1e3),s=Math.floor(t/36e5);return s<24?S("ui.library.time.hours_h_ago",{hours:s}):S("ui.library.time.days_d_ago",{days:Math.floor(s/24)})}const El=({onBack:e})=>f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Kt,{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(J,{variant:"secondary",size:"sm",onClick:e,children:[f.jsx(Bn,{"aria-hidden":"true"}),S("ui.library.page.back")]})]}),Rl=({nowMs:e})=>{ct();const n=Fs(),t=Mi(),s=Ai(),i=zn(),r=kt(i.data,"library",1),a=Os(r),l=e??Date.now(),{ref:o,width:c}=Nl(),d=Ml(),h=new URLSearchParams(t.search).get("full")==="1",u=d>=_l&&c>=Sl,[p,m]=E.useState(jl),[g,P]=E.useState(""),y=br(g,200),[w,x]=E.useState(Pl),[_,v]=E.useState(Tl),k=E.useCallback(I=>{v(I),Cl(I)},[]),[j,N]=E.useState(!1),[F,R]=E.useState(0),[T,A]=E.useState(null),$=E.useRef(null),z=s.assetId??null,Y=c>=wl&&!!z&&!h,O=Math.max(Jt,Math.min(Si,c-(u?kl:0)-xl)),W=Math.min(_,O);E.useEffect(()=>{m(I=>I.q===y?I:{...I,q:y})},[y]),E.useEffect(()=>Fl(p),[p]),E.useEffect(()=>{try{localStorage.setItem(xi,w)}catch{}},[w]);const B=Wr(p,r),Z=Us(),Q=Gr(z,r),L=E.useMemo(()=>{const I=B.data?.pages??[],Ce=I.length>1&&I.at(-1)?.cursor_reset?[I.at(-1)]:I,Ue=new Set,Ie=[];for(const et of Ce)for(const tt of et?.rows??[])Ue.has(tt.id)||(Ue.add(tt.id),Ie.push(tt));return Ie},[B.data]),X=B.data?.pages.at(-1),ae=X?.total??0,oe=E.useMemo(()=>L.filter(I=>I.kind==="image"||I.kind==="video"),[L]),fe=L.find(I=>I.id===z)??null,ee=Q.data??fe,V=()=>void B.fetchNextPage(),be=!!(z&&!ee&&!Q.isLoading&&Q.isError),H=!!z&&!Y,re=E.useCallback(I=>{n(`/library/assets/${I}${t.search}`,{state:t.state})},[n,t.search,t.state]),ue=E.useCallback(()=>{const I=new URLSearchParams(t.search);I.delete("full");const G=I.toString();n(`/library${G?`?${G}`:""}`)},[n,t.search]),K=E.useCallback(()=>{if(!z)return;const I=new URLSearchParams(t.search);I.set("full","1"),n(`/library/assets/${z}?${I.toString()}`)},[n,z,t.search]),le=E.useCallback(I=>{re(I.id),R(G=>G+1)},[re]),pe=E.useRef(new Set),he=E.useCallback(I=>{pe.current.has(I.id)||(pe.current.add(I.id),Z.mutate({id:I.id,fields:{favorite:!I.favorite}},{onSettled:()=>{pe.current.delete(I.id)},onError:G=>{Te(G instanceof Error&&G.message?G.message:S("ui.library.preview.not_saved"))}}))},[Z]),D=E.useCallback(I=>void Cs(n,I),[n]),te=E.useCallback(I=>{m(G=>({...G,session:I})),n("/library")},[n]),ne={onSelect:re,onAsk:le,onEditMetadata:I=>{re(I.id),A({field:"metadata",signal:Date.now()})},onEditTags:I=>{re(I.id),A({field:"tags",signal:Date.now()})},onToggleFavorite:he,onOpenConversation:D,onFilterSession:te};if(E.useEffect(()=>{const I=G=>{const Ce=G.target;if(Ce?.closest('[role="dialog"]'))return;const Ue=Ce?.tagName==="INPUT"||Ce?.tagName==="TEXTAREA"||Ce?.isContentEditable;if(G.key==="f"&&(G.metaKey||G.ctrlKey)||G.key==="/"&&!Ue){G.preventDefault(),$.current?.focus();return}if(!(Ue||G.metaKey||G.ctrlKey||G.altKey)){if(G.key==="Escape"){(z||ee)&&ue();return}if(G.key.toLowerCase()==="g"){G.preventDefault(),x(Ie=>Ie==="grid"?"list":"grid");return}if(G.key.toLowerCase()==="j"||G.key.toLowerCase()==="k"){if(H||L.length===0)return;G.preventDefault();const Ie=z?L.findIndex(xn=>xn.id===z):-1,et=G.key.toLowerCase()==="j"?1:-1,tt=Math.min(Math.max(Ie===-1?et===1?0:L.length-1:Ie+et,0),L.length-1);re(L[tt].id)}}};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[ue,re,L,ee,z,H]),!r)return f.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[f.jsx($i,{title:S("ui.library.page.title"),icon:Kt}),i.isLoading?f.jsx("div",{className:"flex justify-center py-16",children:f.jsx(Tt,{label:S("ui.library.page.checking")})}):f.jsx(kn,{variant:"warning",children:S("ui.library.page.unavailable")})]});const ie=a.data?.library?.total??null,se=f.jsx(la,{filters:p,onChange:I=>{m({...I,q:I.q}),P(I.q)},counts:X?.counts,tags:X?.tags??[],total:ae,scopeTotal:ie}),ve=L.length===0&&!B.isLoading,me=Ir(p)||!!g.trim(),ce=(()=>{const I=[];if(g.trim()&&I.push({key:"search",label:`${S("ui.library.page.search")}: ${g.trim()}`,clear:()=>P("")}),p.category){const G=Cn.find(Ce=>Ce.key===p.category);I.push({key:"category",label:G?S(G.labelKey):p.category,clear:()=>m(Ce=>({...Ce,category:void 0}))})}if(p.originGroup&&I.push({key:"origin",label:S(dn(p.originGroup)),clear:()=>m(G=>({...G,originGroup:void 0}))}),p.status){const G=p.status==="highlighted"?"ui.library.status.highlighted":p.status==="unorganized"?"ui.library.status.unorganized":"ui.library.status.favorites";I.push({key:"status",label:S(G),clear:()=>m(Ce=>({...Ce,status:void 0}))})}return p.highlighted&&p.status!=="highlighted"&&I.push({key:"highlighted",label:S("ui.library.status.highlighted"),clear:()=>m(G=>({...G,highlighted:!1}))}),p.tag&&I.push({key:"tag",label:`${S("ui.library.filter.tags")}: ${p.tag}`,clear:()=>m(G=>({...G,tag:void 0}))}),p.session&&I.push({key:"session",label:S("ui.library.filter.one_conversation"),clear:()=>m(G=>({...G,session:void 0}))}),(p.scope!=="final"||I.length>0)&&I.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:()=>m(G=>({...G,scope:"final"}))}),I})(),_e=()=>{m(I=>({...Xt,scope:I.scope,sort:I.sort,order:I.order})),P("")},je=B.error instanceof Error&&B.error.message?B.error.message:S("ui.library.page.load_failed");return f.jsxs("div",{ref:o,"data-library-page":"","data-glass-region":"canvas","data-glass-split":"",className:"panel-flush flex min-h-0 flex-1 overflow-hidden bg-canvas",children:[u&&!H&&f.jsx("aside",{"data-library-rail":"","data-glass-region":"page-sidebar","aria-label":S("ui.library.page.filters"),className:"panel-top-pad flex h-full w-48 shrink-0 flex-col overflow-hidden bg-surface",children:se}),!H&&f.jsxs("div",{"data-glass-region":"canvas-content",className:"panel-top-pad 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(Kt,{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:"ms-2 text-meta tabular-nums text-ink-dim",children:S("ui.library.page.loaded_count",{loaded:String(L.length),total:String(ae)})}),f.jsxs("div",{className:"ms-auto flex items-center rounded-sm border border-control",children:[f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":w==="grid","aria-label":S("ui.library.page.grid_view"),onClick:()=>x("grid"),children:f.jsx(Ji,{"aria-hidden":"true"})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":w==="list","aria-label":S("ui.library.page.list_view"),onClick:()=>x("list"),children:f.jsx(yr,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{"data-library-toolbar":"",className:"flex h-12 min-w-0 items-center gap-2",children:[f.jsxs("div",{className:"relative min-w-0 flex-1",children:[f.jsx(er,{size:14,"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 start-2.5 -translate-y-1/2 text-ink-dim"}),f.jsx(ar,{ref:$,value:g,onChange:I=>P(I.target.value),onKeyDown:I=>{I.key==="Enter"&&I.preventDefault()},placeholder:S("ui.library.page.search"),"aria-label":S("ui.library.page.search"),"data-library-search":"",className:"border-0 bg-elevated ps-8"})]}),f.jsxs(Rs,{children:[f.jsx(Is,{asChild:!0,children:f.jsxs(J,{variant:"ghost",size:"sm",className:"shrink-0 bg-elevated text-ink",children:[f.jsx(es,{"aria-hidden":"true"}),S("ui.library.page.sort")]})}),f.jsx(zs,{align:"end",className:"min-w-45",children:Er.map(I=>f.jsxs(Ee,{onSelect:()=>m(G=>({...G,sort:I.key,order:Rr(I.key)})),children:[p.sort===I.key?f.jsx(or,{"aria-hidden":"true"}):f.jsx("span",{className:"size-4"}),f.jsx("span",{children:S(I.labelKey)})]},I.key))})]}),f.jsx(J,{variant:"ghost",size:"icon-sm",className:"shrink-0","aria-label":S("ui.library.page.reverse_order"),onClick:()=>m(I=>({...I,order:I.order==="asc"?"desc":"asc"})),children:p.order==="asc"?f.jsx(Tr,{"aria-hidden":"true"}):f.jsx(es,{"aria-hidden":"true"})}),!u&&!H&&f.jsxs(J,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",onClick:()=>N(!0),children:[f.jsx(vr,{"aria-hidden":"true"}),S("ui.library.page.filters")]})]}),ce.length>0&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[ce.map((I,G)=>f.jsxs("span",{className:"contents",children:[G>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:I.label}),f.jsx("button",{type:"button","aria-label":`${S("ui.library.filter.clear_filters")} — ${I.label}`,onClick:I.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(Ve,{size:12,"aria-hidden":"true"})})]})]},I.key)),f.jsx(J,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-meta",onClick:_e,children:S("ui.library.page.clear_all")})]}),f.jsx("div",{"data-library-librarian-track":"",className:"min-h-10 shrink-0",children:f.jsx(Al,{enabled:r,nowMs:l})}),X?.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(X.scan.sessions_scanned),total:String(X.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:!H&&f.jsx("section",{"data-library-results":"","aria-label":S("ui.library.page.results"),"aria-busy":B.isLoading||B.isFetching,className:"min-w-0 flex-1 overflow-y-auto px-4 py-4 [scrollbar-gutter:stable]",children:B.isLoading?f.jsx(aa,{view:w}):B.isError&&L.length===0?f.jsxs("div",{className:"flex flex-col items-start gap-3 py-10",children:[f.jsx(kn,{variant:"warning",children:je}),f.jsxs(J,{variant:"secondary",size:"sm",onClick:()=>void B.refetch(),children:[f.jsx(jn,{"aria-hidden":"true"}),S("ui.library.page.retry")]})]}):ve?f.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-center",children:[f.jsx(Kt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:me?`${S("ui.library.page.no_matches")}: ${ce.map(I=>I.label).join(" + ")}`:S("ui.library.page.empty_title")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:me?S("ui.library.page.no_matches_detail"):S("ui.library.page.empty_detail")}),me&&f.jsx(J,{variant:"secondary",size:"sm",onClick:_e,children:S("ui.library.page.clear_all")})]}):f.jsxs(f.Fragment,{children:[B.isRefetchError&&f.jsx(kn,{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:je}),f.jsxs(J,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void B.refetch(),children:[f.jsx(jn,{"aria-hidden":"true"}),S("ui.library.page.retry")]})]})}),f.jsx(ra,{assets:L,selectedId:z,view:w,hasMore:!!B.hasNextPage,loadingMore:B.isFetchingNextPage,onLoadMore:V,...ne}),B.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(J,{variant:"ghost",size:"sm",onClick:V,children:S("ui.library.page.retry")})]})]})})})})]}),Y&&ee&&f.jsxs(f.Fragment,{children:[f.jsx(Qn,{sidebarWidth:W,onSidebarWidthChange:k,minWidth:Jt,maxWidth:O,side:"left",homeEnd:"value",onDoubleClick:()=>k(Pt),label:S("ui.library.page.resize_preview")}),f.jsx("aside",{"data-library-dock":"","data-glass-region":"pane",style:{width:W},className:"panel-top-pad flex h-full shrink-0 bg-surface","aria-label":S("ui.library.page.preview"),children:f.jsx(js,{asset:ee,nowMs:l,onClose:ue,onOpenConversation:D,onFilterSession:te,onAsk:()=>R(I=>I+1),onToggleFavorite:()=>he(ee),composerFocusSignal:F,focusRequest:T,onExpand:K,mediaSiblings:oe})})]}),H&&f.jsx("div",{"data-glass-region":"pane",className:"panel-top-pad min-w-0 flex-1 bg-surface","aria-label":S("ui.library.page.preview"),children:be?f.jsx(El,{onBack:ue}):ee?f.jsx(js,{asset:ee,nowMs:l,onClose:ue,onOpenConversation:D,onFilterSession:te,onAsk:()=>R(I=>I+1),onToggleFavorite:()=>he(ee),composerFocusSignal:F,focusRequest:T,mediaSiblings:oe,standalone:!0}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(Tt,{label:S("ui.library.preview.loading")})})}),!H&&!ee&&Y&&f.jsxs(f.Fragment,{children:[f.jsx(Qn,{sidebarWidth:W,onSidebarWidthChange:k,minWidth:Jt,maxWidth:O,side:"left",homeEnd:"value",onDoubleClick:()=>k(Pt),label:S("ui.library.page.resize_preview")}),f.jsx("div",{"data-library-dock":"","data-glass-region":"pane",style:{width:W},className:"panel-top-pad hidden h-full 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(lr,{open:j,onOpenChange:N,children:f.jsx(cr,{side:"start",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(J,{variant:"ghost",size:"icon-sm","aria-label":S("ui.library.page.close_filters"),onClick:()=>N(!1),children:f.jsx(Ve,{"aria-hidden":"true"})})]}),f.jsx("div",{"data-library-filter-sheet":"",className:"min-h-0 flex-1 overflow-y-auto bg-surface",children:se})]})})})]})},Xl=Object.freeze(Object.defineProperty({__proto__:null,LibraryPage:Rl},Symbol.toStringTag,{value:"Module"}));export{ge as a,U as b,b as g,Xl as l};
|