local-operator-ui 0.57.5 → 0.57.7
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/renderer/assets/{_basePickBy-D2upKftS.js → _basePickBy-D1tae6TD.js} +1 -1
- package/out/renderer/assets/{_baseUniq-BGD19KIN.js → _baseUniq-Dqwg6YCA.js} +1 -1
- package/out/renderer/assets/{agent-details-page-OPyFw_dI.js → agent-details-page-BjZ7m7WV.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-B3V1y16n.js → agent-hub-page-BPTC6O0g.js} +1 -1
- package/out/renderer/assets/{agents-page-CowgZsSO.js → agents-page-2PqIiOop.js} +3 -3
- package/out/renderer/assets/{arc-Cv6N9gTJ.js → arc-CI5kHP39.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DHtB5fE0.js → architectureDiagram-IEHRJDOE-eLXhTv9y.js} +1 -1
- package/out/renderer/assets/{avatar-cropper-Bjo9zUPg.js → avatar-cropper-CX77SP37.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-4WEK73Je.js → blockDiagram-JOT3LUYC-DP4tinRN.js} +1 -1
- package/out/renderer/assets/{browser-page-2S7sbehs.js → browser-page-D8Qne_jz.js} +1 -1
- package/out/renderer/assets/{browser-webauthn-prompt-D8Tgtg83.js → browser-webauthn-prompt-BFT0r-N3.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-kaGHtOK6.js → c4Diagram-VJAJSXHY-1cHhY0DK.js} +1 -1
- package/out/renderer/assets/channel-DNk_hzpt.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-CpC8J2AT.js → chunk-4BMEZGHF-xyVnm8de.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-DKmX4atq.js → chunk-A2AXSNBT-CCp5Cfzr.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-Dtej3BD4.js → chunk-AEK57VVT-CS0s86Fq.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-DUXxF-pw.js → chunk-D6G4REZN-0OHQRG_d.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-DeeJjU3w.js → chunk-RZ5BOZE2-VEv3pyRd.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-D4R6kzHb.js → chunk-XZIHB7SX-LeYzGnO2.js} +1 -1
- package/out/renderer/assets/{classDiagram-GIVACNV2-Cs0VSRpc.js → classDiagram-GIVACNV2-Cab_hjm_.js} +1 -1
- package/out/renderer/assets/{classDiagram-v2-COTLJTTW-Cs0VSRpc.js → classDiagram-v2-COTLJTTW-Cab_hjm_.js} +1 -1
- package/out/renderer/assets/clone-Bs7bHp6e.js +1 -0
- package/out/renderer/assets/{conversation-input-sync-FnnZiNnd.js → conversation-input-sync-DGRJrS5U.js} +307 -304
- package/out/renderer/assets/{dagre-OKDRZEBW-DDY_IkmM.js → dagre-OKDRZEBW-DW0ckFtl.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-D7AGoSSj.js → diagram-SSKATNLV-zHzzTLdD.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-CcgAGaBN.js → diagram-VNBRO52H-ITKMWXE4.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-LEYxek3-.js → erDiagram-Q7BY3M3F-Bv7G9ync.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CQLUaH8T.js → flowDiagram-4HSFHLVR-CPE8yDo8.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-Ole27PT-.js → ganttDiagram-APWFNJXF-CtIAfAsa.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BNYa___9.js → gitGraphDiagram-7IBYFJ6S-BJdv3O5i.js} +1 -1
- package/out/renderer/assets/{graph-Bibb0aeq.js → graph-DVEeevJk.js} +1 -1
- package/out/renderer/assets/index-C56ky7e6.js +856 -0
- package/out/renderer/assets/{index-CMJfInon.js → index-CQp2KnyE.js} +1 -1
- package/out/renderer/assets/{index-C9UzsV82.js → index-CpIFRblO.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-BXhry1Gr.js → infoDiagram-PH2N3AL5-D92y3EJB.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DI32aDKT.js → journeyDiagram-U35MCT3I-CCvE_pAn.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-CZ-ELIdr.js → kanban-definition-NDS4AKOZ-B8Si35EL.js} +1 -1
- package/out/renderer/assets/{layout-Dza9PMRJ.js → layout-CbPE3gih.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-CPFGYWOZ.js → legacy-agents-page-CabpEmvg.js} +1 -1
- package/out/renderer/assets/{library-page-DiaLon0b.js → library-page-DQe7kOLq.js} +24 -24
- package/out/renderer/assets/{mermaid.core-BcJdc-X6.js → mermaid.core-B_TP914x.js} +5 -5
- package/out/renderer/assets/{mesh-page-7T5BtRTh.js → mesh-page-DnLeBAfa.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-D2CXGzTD.js → mindmap-definition-ALO5MXBD-BqzgtHTf.js} +1 -1
- package/out/renderer/assets/{mini-CJlFVLUZ.js → mini-BpkQ6IM4.js} +1 -1
- package/out/renderer/assets/{notifications-page-BjrfZb8l.js → notifications-page-CLWbRjR3.js} +1 -1
- package/out/renderer/assets/{org-access-B9_h9w7n.js → org-access-BfTWCbBm.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-DUG4cv-v.js → pieDiagram-IB7DONF6-BddlCswk.js} +1 -1
- package/out/renderer/assets/{projects-page-DlCYJUiP.js → projects-page-Btnqgau5.js} +1 -1
- package/out/renderer/assets/{publication-validation-Bn7rmCS6.js → publication-validation-DTRJzxOb.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DaYms9_B.js → quadrantDiagram-7GDLP6J5-BAHfg6fS.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-B97TgRmB.js → radar-MK3ICKWK-CpYYCJB2.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CEfTJcvg.js → radient-auth-buttons-WUinuUX3.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DgyICZXf.js → requirementDiagram-KVF5MWMF-CFWvpL6s.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DHgZL_Zc.js → sankeyDiagram-QLVOVGJD-C623D-M_.js} +1 -1
- package/out/renderer/assets/{schedules-page-CNdkudlY.js → schedules-page-BuA_neic.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-pU2H-s2W.js → sequenceDiagram-X6HHIX6F-D8ZMC786.js} +1 -1
- package/out/renderer/assets/{settings-page-B9GORgXK.js → settings-page-BvoQV41f.js} +1 -1
- package/out/renderer/assets/{smartart-gFtvTNRW.js → smartart-DHG8mviv.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-HwW2OpHh.js → stateDiagram-DGXRK772-QfneJmpt.js} +1 -1
- package/out/renderer/assets/{stateDiagram-v2-YXO3MK2T-BwCPC1S5.js → stateDiagram-v2-YXO3MK2T-DJSDYDMK.js} +1 -1
- package/out/renderer/assets/{team-bridge-page-ChcIcnje.js → team-bridge-page--GiW3xff.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-CPNzpTN8.js → timeline-definition-BDJGKUSR-CGDMUIew.js} +1 -1
- package/out/renderer/assets/{use-default-on-banner-CuXTqN3l.js → use-default-on-banner-7FaKiG4F.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-BCbr9wLe.js → use-download-agent-mutation-CQRgJ9P4.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-TZFrKw4j.js → xychartDiagram-VJFVF3MP-BiKK9yQH.js} +1 -1
- package/out/renderer/index.html +2 -2
- package/out/renderer/mini.html +2 -2
- package/package.json +1 -1
- package/out/renderer/assets/channel-DRHru1K8.js +0 -1
- package/out/renderer/assets/clone-_NlCUljT.js +0 -1
- package/out/renderer/assets/index-BKh47kLl.js +0 -857
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./smartart-
|
|
2
|
-
import{r as $,j as f,c as ye}from"./index-D0qlrLIs.js";import{aw as Jn,m as In,r as cn,j as $e,u as vt,ax as Xe,ay as Dn,a as Bn,d as Tt,A as Ei,ap as Ri,f as Rs,aa as Li,e as zi,o as Ls}from"./appearance-DO4VPBSi.js";import{P as Ii}from"./page-header-DXwYxMB-.js";import{cC as Di,bf as Ve,cD as Bi,cE as Oi,cF as Ui,cG as Wi,bt as Gi,cH as Kt,cI as jn,cJ as zs,cK as qi,bi as mt,ac as Cn,aj as Pe,cL as Is,cM as Ot,cN as Ki,cO as Xi,cP as Vi,cQ as On,cR as Un,cS as Ds,c5 as es,aM as Hi,b2 as Yi,aU as Qi,aV as Zi,aW as Ji,aX as er,b4 as tr,cT as nr,cU as sr,cV as ir,cW as ts,cu as dn,cX as Bs,bT as Wn,cY as rr,cZ as ar,c_ as Os,c$ as or,d0 as lr,d1 as cr,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./smartart-DHG8mviv.js","./index-D0qlrLIs.js","./messages-BYDbMAVA.js","./index-BKLUTBo0.css","./appearance-DO4VPBSi.js","./roles-D1pcbxAx.js","./page-header-DXwYxMB-.js","./conversation-input-sync-DGRJrS5U.js","./error-boundary-BsWceBKP.js","./conversation-input-sync-CwRrAMVk.css","./index-C56ky7e6.js","./console-mirror-Bp3thuUi.js","./console-mirror-C58ni4_c.css","./index-CruN78l1.css","./heart-Cix0tXFr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as $,j as f,c as ye}from"./index-D0qlrLIs.js";import{aw as Jn,m as In,r as cn,j as $e,u as vt,ax as Xe,ay as Dn,a as Bn,d as Tt,A as Ei,ap as Ri,f as Rs,aa as Li,e as zi,o as Ls}from"./appearance-DO4VPBSi.js";import{P as Ii}from"./page-header-DXwYxMB-.js";import{cC as Di,bf as Ve,cD as Bi,cE as Oi,cF as Ui,cG as Wi,bt as Gi,cH as Kt,cI as jn,cJ as zs,cK as qi,bi as mt,ac as Cn,aj as Pe,cL as Is,cM as Ot,cN as Ki,cO as Xi,cP as Vi,cQ as On,cR as Un,cS as Ds,c5 as es,aM as Hi,b2 as Yi,aU as Qi,aV as Zi,aW as Ji,aX as er,b4 as tr,cT as nr,cU as sr,cV as ir,cW as ts,cu as dn,cX as Bs,bT as Wn,cY as rr,cZ as ar,c_ as Os,c$ as or,d0 as lr,d1 as cr,d2 as dr,bU as ur,d3 as ns}from"./conversation-input-sync-DGRJrS5U.js";import{c as Et,D as Us,w as Xt,g as Ws,B as J,i as Gs,I as Ee,_ as fr,$ as hr,a0 as pr,H as ss,u as Ue,e as ot,S as gt,X as He,h as qs,ah as mr,J as gr,A as Sn,K as br,b as yr,ai as vr,aj as wr}from"./error-boundary-BsWceBKP.js";import{cK as xr,cL as is,cM as Gn,aU as qn,x as Kn,b as kr,cN as Ks,cO as _r,cP as Sr,cQ as Tr,cR as Pr,cS as jr,cT as Cr,b1 as Fr,cU as Vt,cV as Nr,cW as Mr,R as Fn}from"./index-C56ky7e6.js";import{t as k}from"./messages-BYDbMAVA.js";import{H as un}from"./heart-Cix0tXFr.js";/**
|
|
3
3
|
* @license lucide-react v0.507.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const
|
|
7
|
+
*/const Ar=[["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"}]],rs=Et("arrow-down-wide-narrow",Ar);/**
|
|
8
8
|
* @license lucide-react v0.507.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
11
|
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const
|
|
12
|
+
*/const $r=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],Er=Et("arrow-up-narrow-wide",$r);/**
|
|
13
13
|
* @license lucide-react v0.507.0 - ISC
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the ISC license.
|
|
16
16
|
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const
|
|
17
|
+
*/const Rr=[["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"}]],Lr=Et("presentation",Rr);/**
|
|
18
18
|
* @license lucide-react v0.507.0 - ISC
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the ISC license.
|
|
21
21
|
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const
|
|
22
|
+
*/const zr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]],Ir=Et("sheet",zr);/**
|
|
23
23
|
* @license lucide-react v0.507.0 - ISC
|
|
24
24
|
*
|
|
25
25
|
* This source code is licensed under the ISC license.
|
|
26
26
|
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const Ir=[["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"}]],Dr=Et("tags",Ir),Br=["generated","created","mentioned"],Nn=[{key:"image",labelKey:"ui.library.category.images",iconKind:"image"},{key:"sound",labelKey:"ui.library.category.sounds",iconKind:"audio"},{key:"document",labelKey:"ui.library.category.documents",iconKind:"markdown"},{key:"presentation",labelKey:"ui.library.category.presentations",iconKind:"pptx"},{key:"video",labelKey:"ui.library.category.video",iconKind:"video"},{key:"spreadsheet",labelKey:"ui.library.category.spreadsheets",iconKind:"spreadsheet"},{key:"code",labelKey:"ui.library.category.code",iconKind:"code"},{key:"other",labelKey:"ui.library.category.other",iconKind:"other"}],Or=[{key:"recent",labelKey:"ui.library.sort.recent"},{key:"name",labelKey:"ui.library.sort.name"},{key:"kind",labelKey:"ui.library.sort.kind"},{key:"size",labelKey:"ui.library.sort.size"},{key:"created",labelKey:"ui.library.sort.created"},{key:"modified",labelKey:"ui.library.sort.modified"},{key:"organized",labelKey:"ui.library.sort.organized"}],Ht={q:"",scope:"final",tagMode:"all",highlighted:!1,sort:"recent",order:"desc"};function Ur(e){return e==="name"||e==="kind"?"asc":"desc"}function as(e,n){return e.status===n}function Wr(e){return!!(e.q.trim()||e.category||e.originGroup||e.tag||e.session||e.highlighted||e.status)}function Gr(e){if(e==="unorganized")return!1}function Je(e){return e.remote?.device_name||e.remote?.device_id||""}function lt(e){return e.remote?null:e.ref.type==="path"&&e.ref.path?e.ref.path:null}function De(e){return e.name.trim()||e.derived_name.trim()||e.id}function Xs(e){const n=e.derived_name.trim();return n?n===e.name.trim()?e.ref.display_path:n:e.ref.display_path}function qr(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}))}const os={audio:"ui.library.kind.audio",code:"ui.library.kind.code",docx:"ui.library.kind.docx",html:"ui.library.kind.html",image:"ui.library.kind.image",markdown:"ui.library.kind.markdown",other:"ui.library.kind.other",pdf:"ui.library.kind.pdf",pptx:"ui.library.kind.pptx",spreadsheet:"ui.library.kind.spreadsheet",text:"ui.library.kind.text",video:"ui.library.kind.video"},ls={custom:"ui.library.tag_category.custom",format:"ui.library.tag_category.format",project:"ui.library.tag_category.project",source:"ui.library.tag_category.source",status:"ui.library.tag_category.status",topic:"ui.library.tag_category.topic",type:"ui.library.tag_category.type"};function Xn(e){return Object.prototype.hasOwnProperty.call(os,e)?k(os[e]):e}function Kr(e){const n=e||"custom";return Object.prototype.hasOwnProperty.call(ls,n)?k(ls[n]):n}function Xr(e,n){switch(e){case"user":return k("ui.library.preview.organized_by_user",{at:n});case"librarian":return k("ui.library.preview.organized_by_librarian",{at:n});case"agent":return k("ui.library.preview.organized_by_agent",{at:n});case"system":return k("ui.library.preview.organized_by_system",{at:n});default:return k("ui.library.preview.organized_unattributed",{at:n})}}function nn(e){if(!Number.isFinite(e)||e<=0)return Jn(0,"B",{maximumFractionDigits:0});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,i=s>=10||t===0?0:1;return Jn(s,n[t]??"B",{minimumFractionDigits:i,maximumFractionDigits:i})}function Vr(e,n){if(!e)return"";const t=n-e*1e3;if(t<6e4)return k("ui.library.time.just_now");const s=Math.floor(t/6e4);if(s<60)return k("ui.library.time.minutes_m_ago",{minutes:s});const i=Math.floor(s/60);if(i<24)return k("ui.library.time.hours_h_ago",{hours:i});const r=Math.floor(i/24);if(r<30)return k("ui.library.time.days_d_ago",{days:r});const a=Math.floor(r/30);return a<12?k("ui.library.time.months_mo_ago",{months:a}):k("ui.library.time.years_y_ago",{years:Math.floor(a/12)})}function Hr(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 fn(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"]},Yr=60;function Qr(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=Gr(e.status);return t!==void 0?{organized:t}:{}})(),sort:e.sort,order:e.order,limit:Yr,...n?{cursor:n}:{}}}function Zr(e,n){return Di({queryKey:Me.list(e),enabled:n,initialPageParam:void 0,queryFn:({pageParam:t})=>$e(Qr(e,t)),getNextPageParam:t=>t.next_cursor??void 0,retry:cn,refetchInterval:t=>t.state.data?.pages.at(-1)?.state==="building"?2e3:!1,staleTime:1e4})}function Jr(e,n){return In({queryKey:Me.detail(e??""),enabled:n&&!!e,queryFn:()=>$e({op:"library.get",id:e}),retry:cn,staleTime:5e3})}function ea(e){return In({queryKey:Me.tags,enabled:e,queryFn:()=>$e({op:"library.tags"}),retry:cn,staleTime:2e4})}function Vs(e){return In({queryKey:Me.librarian,enabled:e,queryFn:()=>$e({op:"library.librarian",action:"status"}).then(n=>"librarian"in n?n.librarian:n),retry:cn,staleTime:3e4})}function et(e){return e.invalidateQueries({queryKey:Me.all})}function cs(e,n){return{...e,...n}}function Hs(){const e=vt();return Ve({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),cs(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?cs(l,n.fields):l)}))});return{detail:t,lists:s}},onSuccess:n=>(e.setQueryData(Me.detail(n.id),n),et(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:Xe})}function ta(){const e=vt();return Ve({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),et(e)),onError:()=>et(e),retry:Xe})}function na(){const e=vt(),n=()=>et(e),t=Ve({mutationFn:a=>$e({op:"library.tags.create",name:a.name,...a.category?{category:a.category}:{}}),onSuccess:n,retry:Xe}),s=Ve({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:Xe}),i=Ve({mutationFn:a=>$e({op:"library.tags.delete",id:a.id}),onSuccess:n,retry:Xe}),r=Ve({mutationFn:a=>$e({op:"library.tags.merge",id:a.id,into:a.into}),onSuccess:n,retry:Xe});return{create:t,update:s,remove:i,merge:r}}function sa(){const e=vt();return Ve({mutationFn:n=>$e({op:"library.chat.link",id:n.id,sessionId:n.sessionId}),onSuccess:()=>et(e),onError:()=>et(e),retry:Xe})}function Ys(){const e=vt();return Ve({mutationFn:n=>$e({op:"library.chat.clear",id:n.id}),onSuccess:()=>et(e),retry:Xe})}function ia(){const e=vt();return Ve({mutationFn:n=>$e({op:"library.librarian",action:n}).then(t=>"librarian"in t?t.librarian:t),onSuccess:()=>et(e),retry:Xe})}function wt(e,n,t,s=!1){const[i,r]=$.useState({bytes:null,mimeType:"",error:null,loading:!1});return $.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}),Dn(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:k("ui.library.errors.preview_load"),loading:!1})}}),()=>{a=!0}},[e,n,t,s]),i}function Qs(e,n=!0){const[t,s]=$.useState(()=>e?sn.get(e)??null:null);return $.useEffect(()=>{if(!e){s(null);return}if(s(sn.get(e)??null),!n)return;let i=!0;return aa(e).then(r=>{i&&s(r)}),()=>{i=!1}},[e,n]),t}const sn=new Map,ds=new Map;async function ra(e){try{const n=await Dn({op:"library.waveform",assetId:e},null);return n.kind==="json"?Bi(n.body):null}catch{return null}}function aa(e){const n=ds.get(e);if(n)return n;const t=ra(e).then(s=>(sn.set(e,s),s)).catch(()=>(sn.set(e,null),null));return ds.set(e,t),t}function xt(e,n){const[t,s]=$.useState(null);return $.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}class Zs extends Error{constructor(n){super(Wi(n)),this.name="RemoteAssetUnreachableError"}}function Mn(e,n){return e instanceof Zs?e.message:n}const oa=/[\\/]/;function la(e){const t=De(e).split(oa).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 bt(e){const n=e.remote?Oi(k("ui.canvas.files.remoteDownloading",{name:De(e),device:Je(e)}),{id:`library-remote-save:${e.id}`}):null;let t;try{t=await Dn({op:"library.content",assetId:e.id,download:!0},null)}finally{n!==null&&Ui(n)}if(t.kind!=="bytes")throw e.remote&&t.kind==="error"&&t.status===504?new Zs(Je(e)):new Error(t.kind==="error"?t.detail:k("ui.library.errors.asset_read"));const s=new Blob([t.data],{type:e.ref.content_type||t.mimeType||"application/octet-stream"}),i=URL.createObjectURL(s),r=document.createElement("a");r.href=i,r.download=la(e),r.rel="noopener",document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(i),3e4)}const Vn=({asset:e,onAsk:n,onEditMetadata:t,onEditTags:s,onToggleFavorite:i,onOpenConversation:r,onFilterSession:a,triggerClassName:l})=>{const o=async(p,m)=>{try{await navigator.clipboard.writeText(p),Cn(m)}catch{Pe(k("ui.library.menu.copy_failed"))}},c=async()=>{try{await bt(e),Cn(k("ui.library.menu.saved_a_copy"))}catch(p){Pe(Mn(p,k("ui.library.menu.save_failed")))}},d=!!e.remote,h=!!(!d&&e.ref.type==="path"&&e.ref.path),u=e.occurrences;return f.jsxs(Us,{children:[f.jsx(Xt,{content:k("ui.library.menu.asset_actions"),children:f.jsx(Ws,{asChild:!0,children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.menu.asset_actions_label",{name:e.name||e.derived_name}),className:l,onClick:p=>p.stopPropagation(),"data-library-asset-menu":"",children:f.jsx(Gi,{"aria-hidden":"true"})})})}),f.jsxs(Gs,{align:"end",className:"min-w-52",onClick:p=>p.stopPropagation(),children:[u.length===1?f.jsxs(Ee,{onSelect:()=>r(u[0].session_id),children:[f.jsx(Kt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.open_source_conversation")})]}):u.length>1?f.jsxs(ur,{children:[f.jsxs(fr,{children:[f.jsx(Kt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.open_source_conversation")})]}),f.jsx(hr,{className:"min-w-60",children:u.map(p=>f.jsx(Ee,{onSelect:()=>r(p.session_id),children:f.jsx("span",{className:"truncate",children:p.session_title||p.session_id})},`${p.session_id}:${p.first_seq}`))})]}):null,f.jsxs(Ee,{onSelect:n,children:[f.jsx(Kt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.ask_about_asset")})]}),u.length>0&&f.jsxs(Ee,{onSelect:()=>a(u[0].session_id),children:[f.jsx(jn,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.show_from_conversation")})]}),f.jsx(ss,{}),f.jsxs(Ee,{onSelect:i,children:[f.jsx(un,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0}),f.jsx("span",{children:e.favorite?k("ui.library.menu.unfavorite"):k("ui.library.menu.favorite")})]}),f.jsxs(Ee,{onSelect:t,children:[f.jsx(zs,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.edit_metadata")})]}),f.jsxs(Ee,{onSelect:s,children:[f.jsx(Dr,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.edit_tags")})]}),f.jsx(ss,{}),e.ref.path&&!d?f.jsxs(Ee,{onSelect:()=>void o(e.ref.path,k("ui.library.menu.path_copied")),children:[f.jsx(qi,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.copy_path")})]}):null,f.jsxs(Ee,{onSelect:()=>void o(e.id,k("ui.library.menu.asset_id_copied")),children:[f.jsx(wr,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.copy_asset_id")})]}),h?f.jsxs(Ee,{onSelect:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(jn,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.reveal_in_finder")})]}):f.jsxs(Ee,{onSelect:()=>void c(),children:[f.jsx(mt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.download")})]}),e.ref.type==="artifact"&&f.jsxs(Ee,{onSelect:()=>void c(),children:[f.jsx(mt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.save_a_copy")})]})]})]})},ca={image:Vi,audio:Xi,video:Ki,pdf:Ot,pptx:Rr,docx:Ot,markdown:Ot,html:is,spreadsheet:zr,text:Ot,code:is,other:Is};function da(e){return ca[e]??Is}function Ye({kind:e,size:n=20,className:t}){const s=da(e);return f.jsx(s,{size:n,"aria-hidden":"true",className:t})}const Js=({group:e})=>f.jsx(ot,{variant:e==="generated"?"accent":"neutral",children:k(fn(e))}),ei=({asset:e,large:n=!1})=>{const[t,s]=Un("300px"),i=e.kind==="image"&&e.exists&&s,r=wt(e.id,"thumbnail",i),a=xt(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(Ye,{kind:e.kind,size:n?28:22,className:"text-ink-dim"})})},us=()=>f.jsx("span",{className:"absolute top-1.5 start-1.5 flex size-5 items-center justify-center rounded-full bg-elevated",title:k("ui.library.card.highlighted"),children:f.jsx(Kn,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),ti=()=>f.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-elevated",title:k("ui.library.menu.favorite"),"data-library-favorite-mark":"",children:f.jsx(un,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),ni=({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(ot,{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]})]})},ua=({asset:e})=>{const[n,t]=Un("300px"),[s,i]=$.useState(!1),r=e.exists&&(e.remote?s:t),a=wt(e.id,"content",r),l=Qs(e.id,r),o=xt(a.bytes,a.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:o?f.jsx(Ds,{variant:"compact",ownerId:`sound:library:${e.id}`,src:o,label:De(e),peaks:l,durationHint:e.duration_s}):e.remote&&e.exists&&!s?f.jsx("button",{type:"button","data-library-remote-play":"","aria-label":k("ui.canvas.files.remotePlay",{device:Je(e)}),title:k("ui.canvas.files.remotePlay",{device:Je(e)}),onClick:c=>{c.stopPropagation(),i(!0)},className:"flex size-full items-center justify-center rounded-sm text-ink-dim hover:text-ink",children:f.jsx(Ye,{kind:e.kind,size:28})}):s&&a.loading?f.jsx(gt,{size:"sm",label:k("ui.canvas.files.remoteFetching",{device:Je(e)})}):f.jsx(Ye,{kind:e.kind,size:28,className:"text-ink-dim"})})},si=({kind:e})=>(Ue(),f.jsx(f.Fragment,{children:Xn(e)})),fa=({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:De(e)}),f.jsx("span",{className:"line-clamp-1 text-meta text-ink-dim",children:Xs(e)}),f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx("span",{className:"truncate",children:f.jsx(si,{kind:e.kind})}),f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:f.jsx("bdi",{children:nn(e.size_bytes)})}),e.duration_s?f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:Hr(e.duration_s)})]}):null]}),f.jsx(ni,{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(Kt,{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(Js,{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:k("ui.library.card.conversations",{count:e.session_count})}),e.remote?f.jsx(Gn,{device:Je(e)}):null,e.favorite&&f.jsx(ti,{})]})]})]}),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(ei,{asset:e,large:!0}),e.highlighted&&f.jsx(us,{})]}),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&&qn),children:[s&&f.jsxs("div",{className:"relative",children:[f.jsx(ua,{asset:e}),e.highlighted&&f.jsx(us,{})]}),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(Vn,{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"})})]})},ha=({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&&qn),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(ei,{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(Kn,{size:12,"aria-hidden":"true",className:"shrink-0 fill-current text-accent"}),De(e)]}),f.jsx("span",{className:"truncate text-meta text-ink-dim",children:Xs(e)})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-meta text-ink-muted",children:[f.jsx(ni,{asset:e}),f.jsx("span",{children:f.jsx(si,{kind:e.kind})}),f.jsx("span",{children:f.jsx("bdi",{children:nn(e.size_bytes)})}),f.jsx(Js,{group:e.origin_group}),e.remote?f.jsx(Gn,{device:Je(e)}):null,e.favorite&&f.jsx(ti,{})]})]}),f.jsx(Vn,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession})]}),pa=({assets:e,selectedId:n,view:t,hasMore:s,loadingMore:i,onLoadMore:r,...a})=>{const l=$.useRef(null);return $.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(fa,{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(ha,{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(On,{size:14,"aria-hidden":"true",className:"motion-safe:animate-spin"}),k("ui.library.grid.loading_more")]}),!i&&s&&f.jsx(J,{variant:"ghost",size:"sm",onClick:r,children:k("ui.library.grid.load_more")})]})]})},ma=({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))}),ga=[{key:"highlighted",labelKey:"ui.library.status.highlighted"},{key:"unorganized",labelKey:"ui.library.status.unorganized"},{key:"favorite",labelKey:"ui.library.status.favorites"}],Qe=({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?qn:"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})]}),St=({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})]}),ba=({category:e})=>(Ue(),f.jsx(f.Fragment,{children:Kr(e)})),ya=({filters:e,onChange:n,counts:t,tags:s,total:i,scopeTotal:r})=>{const a=qr(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(He,{"aria-hidden":"true"}),k("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:k("ui.library.filter.one_conversation")}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.filter.clear_conversation"),onClick:()=>o({session:void 0}),children:f.jsx(He,{"aria-hidden":"true"})})]}),f.jsxs(St,{label:k("ui.library.filter.scope"),children:[f.jsx(Qe,{label:k("ui.library.filter.scope_final"),active:e.scope==="final",onPress:()=>o({scope:"final"})}),f.jsx(Qe,{label:k("ui.library.filter.scope_all"),count:r??void 0,active:e.scope==="all",onPress:()=>o({scope:"all"})})]}),f.jsxs(St,{label:k("ui.library.filter.categories"),children:[f.jsx(Qe,{label:k("ui.library.category.all"),count:i,active:!e.category,onPress:()=>o({category:void 0})}),Nn.map(d=>f.jsx(Qe,{label:k(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(Ye,{kind:d.iconKind,size:14,className:"text-ink-dim"})},d.key)),Object.keys(l).filter(d=>!Nn.some(h=>h.key===d)).sort().map(d=>f.jsx(Qe,{label:d,count:l[d],active:e.category===d,onPress:()=>o({category:e.category===d?void 0:d}),icon:f.jsx(es,{size:14,"aria-hidden":"true"})},d))]}),f.jsx(St,{label:k("ui.library.filter.status"),children:ga.map(d=>f.jsx(Qe,{label:k(d.labelKey),active:as(e,d.key),onPress:()=>o({status:as(e,d.key)?void 0:d.key}),icon:d.key==="favorite"?f.jsx(un,{size:14,"aria-hidden":"true"}):d.key==="highlighted"?f.jsx(Kn,{size:14,"aria-hidden":"true"}):void 0},d.key))}),f.jsx(St,{label:k("ui.library.filter.source"),children:Br.filter(d=>e.originGroup===d||e.scope==="all"||(t?.origin_group?.[d]??0)>0).map(d=>f.jsx(Qe,{label:k(fn(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(St,{label:k("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:f.jsx(ba,{category:d.category})}),d.tags.map(h=>f.jsx(Qe,{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(es,{size:13,"aria-hidden":"true"}),indent:!0},h.id))]},d.category))}),e.tag&&f.jsx(ot,{variant:"neutral",children:k("ui.library.filter.tag_mode",{mode:e.tagMode.toUpperCase()})})]})},fs=({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})=>{Ue();const[h,u]=$.useState(!1),[p,m]=$.useState(e),[g,T]=$.useState(!1),y=$.useRef("closed"),w=$.useRef(null),x=$.useRef(null),S=()=>{y.current==="closed"&&(m(e),y.current="edit",u(!0))},v=E=>{y.current="closed",E&&x.current?.focus(),u(!1)},_=async E=>{if(y.current!=="edit")return;const z=p.trim();if(!z&&!l||z===e){v(E);return}y.current="saving",T(!0);try{await n(z),y.current==="saving"&&v(E)}catch{y.current==="saving"&&(y.current="edit",w.current?.focus())}finally{T(!1)}};$.useEffect(()=>{if(!h)return;const E=setTimeout(()=>{const z=w.current;z&&(z.focus(),z.select(),z.scrollLeft=0,z instanceof HTMLTextAreaElement&&(z.scrollTop=0))},0);return()=>clearTimeout(E)},[h]),$.useEffect(()=>{y.current==="closed"&&m(e)},[e]);const j=$.useRef(o);$.useEffect(()=>{const E=j.current;j.current=o,!(o===E||!o)&&S()},[o]);const N=E=>{if(!(E.nativeEvent.isComposing||E.keyCode===229)){if(E.key==="Enter"){if(i&&E.shiftKey)return;E.preventDefault(),_(!0)}else if(E.key==="Escape"){if(E.preventDefault(),y.current==="saving")return;v(!0)}}},F=E=>{h&&E.preventDefault()},R=E=>{m(E.target.value)},A=e.trim()?f.jsx("span",{onDoubleClick:S,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:S,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:E=>{w.current=E},value:p,rows:r,readOnly:g,"aria-label":t,"aria-busy":g||void 0,onChange:R,onKeyDown:N,onBlur:()=>void _(!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:E=>{w.current=E},value:p,readOnly:g,"aria-label":t,"aria-busy":g||void 0,onChange:R,onKeyDown:N,onBlur:()=>void _(!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?k("ui.common.forms.editable_field.saving"):h?k("ui.common.forms.autocomplete_field.cancel_editing",{label:t}):k("ui.common.forms.editable_field.edit_v2",{label:t}),title:g?k("ui.common.forms.editable_field.saving"):h?k("ui.common.forms.editable_field.cancel_escape"):k("ui.common.forms.editable_field.edit"),"aria-busy":g||void 0,"aria-disabled":g||void 0,onMouseDown:F,onClick:E=>{if(!(E.detail>1)&&y.current!=="saving"){if(h){v(!0);return}S()}},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(gt,{size:"xs"}):h?f.jsx(He,{className:"size-3","aria-hidden":"true"}):f.jsx(zs,{className:"size-3","aria-hidden":"true"})})]})},va=({value:e,onChange:n,label:t,addLabel:s,saving:i=!1,startSignal:r})=>{Ue();const[a,l]=$.useState(!1),[o,c]=$.useState(""),d=$.useRef(null),h=$.useRef(null),u=()=>{i||a||l(!0)},p=()=>{c(""),l(!1)},m=x=>{const S=o.trim().toLowerCase();S&&!e.some(v=>v.toLowerCase()===S)&&n([...e,S]),c(""),x?d.current?.focus():l(!1)},g=$.useRef(!1);$.useEffect(()=>{if(i){g.current=!0;return}if(!a){g.current=!1;return}const x=g.current;g.current=!1;const S=setTimeout(()=>{if(x){const v=document.activeElement,_=h.current;if(!(!v||v===document.body||!!_?.contains(v)))return}d.current?.focus()},0);return()=>clearTimeout(S)},[a,i]);const T=$.useRef(r);$.useEffect(()=>{const x=T.current;T.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(gt,{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(xr,{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(ot,{variant:"neutral",shape:"pill",className:"gap-1 pe-1 text-ink",children:[x,f.jsx("button",{type:"button","aria-label":k("ui.chat.tags.remove_named",{name:x}),disabled:i,onClick:()=>n(e.filter(S=>S!==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(He,{className:"size-3","aria-hidden":"true"})})]},x)),w]})},wa=2e3;function Hn(e){return lt(e)!==null&&e.exists===!0}function xa(e,n){const t=Hn(e)?e.ref.path:null,[s,i]=$.useState({mtimeMs:null,sizeBytes:null,revision:0,missing:!1}),r=$.useRef(null),a=$.useRef(!1);$.useEffect(()=>{r.current=null,i({mtimeMs:null,sizeBytes:null,revision:0,missing:!1})},[t]);const l=$.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 $.useEffect(()=>{l()},[l,n]),$.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()},wa);return()=>{window.removeEventListener("focus",o),document.removeEventListener("visibilitychange",c),window.clearInterval(d)}},[t,l]),s}const ka=[];function _a(e){const n=e.ref.display_path||e.ref.path||(e.ref.digest?`attachment digest ${e.ref.digest}`:e.id);return`${De(e)} (${n})`}function Sa(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 Ta=({asset:e,focusSignal:n,onSessionChange:t,showLinkedRow:s,onOpenChat:i,refreshSignal:r=0,streaming:a})=>{Ue();const l=$.useRef(null),o=Bn(),{frontend:c,refresh:d}=Hi(),h=$.useRef(!1),[u,p]=$.useState(!1),[m,g]=$.useState({}),[T,y]=$.useState(null),w=e.chat?.session_id??m[e.id]??null,x=m[e.id]??null,S=T===e.id,v=sa(),_=Ys(),j=wt(e.id,"content",e.kind==="image"),N=w??`library:${e.id}`;$.useEffect(()=>{w&&d(w)},[w,d,r]),$.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(E=>{const z={...E};return delete z[e.id],z}),y(null)}catch{Pe(k("ui.library.composer.link_failed_short"))}},R=async(A,E,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=Sa(e,j.bytes,j.mimeType),{images:Z,files:Q,failures:I,overflow:X,fileOverflow:ae}=await Qi(B?[...E,B]:E,A),le=Zi(I);if(le)return Pe(le),!1;const fe=Ji(X);if(fe)return Pe(fe),!1;const ee=er(ae);if(ee)return Pe(ee),!1;if(!W){const H=Ei.getState();if(W=await H.createSession(H.cwd||"~"),!W)throw new Error(H.error??k("ui.library.composer.could_not_start"))}const V=W,be={op:"sessions.message",sessionId:V,requestId:crypto.randomUUID(),text:`${Y}
|
|
27
|
+
*/const Dr=[["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"}]],Br=Et("tags",Dr),Or=["generated","created","mentioned"],Nn=[{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"}],Ur=[{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"}],Ht={q:"",scope:"final",tagMode:"all",highlighted:!1,sort:"recent",order:"desc"};function Wr(e){return e==="name"||e==="kind"?"asc":"desc"}function as(e,n){return e.status===n}function Gr(e){return!!(e.q.trim()||e.category||e.originGroup||e.tag||e.session||e.highlighted||e.status)}function qr(e){if(e==="unorganized")return!1}function Je(e){return e.remote?.device_name||e.remote?.device_id||""}function lt(e){return e.remote?null:e.ref.type==="path"&&e.ref.path?e.ref.path:null}function De(e){return e.name.trim()||e.derived_name.trim()||e.id}function Xs(e){const n=e.derived_name.trim();return n?n===e.name.trim()?e.ref.display_path:n:e.ref.display_path}function Kr(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}))}const os={audio:"ui.library.kind.audio",code:"ui.library.kind.code",docx:"ui.library.kind.docx",html:"ui.library.kind.html",image:"ui.library.kind.image",markdown:"ui.library.kind.markdown",other:"ui.library.kind.other",pdf:"ui.library.kind.pdf",pptx:"ui.library.kind.pptx",spreadsheet:"ui.library.kind.spreadsheet",text:"ui.library.kind.text",video:"ui.library.kind.video"},ls={custom:"ui.library.tag_category.custom",format:"ui.library.tag_category.format",project:"ui.library.tag_category.project",source:"ui.library.tag_category.source",status:"ui.library.tag_category.status",topic:"ui.library.tag_category.topic",type:"ui.library.tag_category.type"};function Xn(e){return Object.prototype.hasOwnProperty.call(os,e)?k(os[e]):e}function Xr(e){const n=e||"custom";return Object.prototype.hasOwnProperty.call(ls,n)?k(ls[n]):n}function Vr(e,n){switch(e){case"user":return k("ui.library.preview.organized_by_user",{at:n});case"librarian":return k("ui.library.preview.organized_by_librarian",{at:n});case"agent":return k("ui.library.preview.organized_by_agent",{at:n});case"system":return k("ui.library.preview.organized_by_system",{at:n});default:return k("ui.library.preview.organized_unattributed",{at:n})}}function nn(e){if(!Number.isFinite(e)||e<=0)return Jn(0,"B",{maximumFractionDigits:0});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,i=s>=10||t===0?0:1;return Jn(s,n[t]??"B",{minimumFractionDigits:i,maximumFractionDigits:i})}function Hr(e,n){if(!e)return"";const t=n-e*1e3;if(t<6e4)return k("ui.library.time.just_now");const s=Math.floor(t/6e4);if(s<60)return k("ui.library.time.minutes_m_ago",{minutes:s});const i=Math.floor(s/60);if(i<24)return k("ui.library.time.hours_h_ago",{hours:i});const r=Math.floor(i/24);if(r<30)return k("ui.library.time.days_d_ago",{days:r});const a=Math.floor(r/30);return a<12?k("ui.library.time.months_mo_ago",{months:a}):k("ui.library.time.years_y_ago",{years:Math.floor(a/12)})}function Yr(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 fn(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"]},Qr=60;function Zr(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=qr(e.status);return t!==void 0?{organized:t}:{}})(),sort:e.sort,order:e.order,limit:Qr,...n?{cursor:n}:{}}}function Jr(e,n){return Di({queryKey:Me.list(e),enabled:n,initialPageParam:void 0,queryFn:({pageParam:t})=>$e(Zr(e,t)),getNextPageParam:t=>t.next_cursor??void 0,retry:cn,refetchInterval:t=>t.state.data?.pages.at(-1)?.state==="building"?2e3:!1,staleTime:1e4})}function ea(e,n){return In({queryKey:Me.detail(e??""),enabled:n&&!!e,queryFn:()=>$e({op:"library.get",id:e}),retry:cn,staleTime:5e3})}function ta(e){return In({queryKey:Me.tags,enabled:e,queryFn:()=>$e({op:"library.tags"}),retry:cn,staleTime:2e4})}function Vs(e){return In({queryKey:Me.librarian,enabled:e,queryFn:()=>$e({op:"library.librarian",action:"status"}).then(n=>"librarian"in n?n.librarian:n),retry:cn,staleTime:3e4})}function et(e){return e.invalidateQueries({queryKey:Me.all})}function cs(e,n){return{...e,...n}}function Hs(){const e=vt();return Ve({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),cs(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?cs(l,n.fields):l)}))});return{detail:t,lists:s}},onSuccess:n=>(e.setQueryData(Me.detail(n.id),n),et(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:Xe})}function na(){const e=vt();return Ve({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),et(e)),onError:()=>et(e),retry:Xe})}function sa(){const e=vt(),n=()=>et(e),t=Ve({mutationFn:a=>$e({op:"library.tags.create",name:a.name,...a.category?{category:a.category}:{}}),onSuccess:n,retry:Xe}),s=Ve({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:Xe}),i=Ve({mutationFn:a=>$e({op:"library.tags.delete",id:a.id}),onSuccess:n,retry:Xe}),r=Ve({mutationFn:a=>$e({op:"library.tags.merge",id:a.id,into:a.into}),onSuccess:n,retry:Xe});return{create:t,update:s,remove:i,merge:r}}function ia(){const e=vt();return Ve({mutationFn:n=>$e({op:"library.chat.link",id:n.id,sessionId:n.sessionId}),onSuccess:()=>et(e),onError:()=>et(e),retry:Xe})}function Ys(){const e=vt();return Ve({mutationFn:n=>$e({op:"library.chat.clear",id:n.id}),onSuccess:()=>et(e),retry:Xe})}function ra(){const e=vt();return Ve({mutationFn:n=>$e({op:"library.librarian",action:n}).then(t=>"librarian"in t?t.librarian:t),onSuccess:()=>et(e),retry:Xe})}function wt(e,n,t,s=!1){const[i,r]=$.useState({bytes:null,mimeType:"",error:null,loading:!1});return $.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}),Dn(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:k("ui.library.errors.preview_load"),loading:!1})}}),()=>{a=!0}},[e,n,t,s]),i}function Qs(e,n=!0){const[t,s]=$.useState(()=>e?sn.get(e)??null:null);return $.useEffect(()=>{if(!e){s(null);return}if(s(sn.get(e)??null),!n)return;let i=!0;return oa(e).then(r=>{i&&s(r)}),()=>{i=!1}},[e,n]),t}const sn=new Map,ds=new Map;async function aa(e){try{const n=await Dn({op:"library.waveform",assetId:e},null);return n.kind==="json"?Bi(n.body):null}catch{return null}}function oa(e){const n=ds.get(e);if(n)return n;const t=aa(e).then(s=>(sn.set(e,s),s)).catch(()=>(sn.set(e,null),null));return ds.set(e,t),t}function xt(e,n){const[t,s]=$.useState(null);return $.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}class Zs extends Error{constructor(n){super(Wi(n)),this.name="RemoteAssetUnreachableError"}}function Mn(e,n){return e instanceof Zs?e.message:n}const la=/[\\/]/;function ca(e){const t=De(e).split(la).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 bt(e){const n=e.remote?Oi(k("ui.canvas.files.remoteDownloading",{name:De(e),device:Je(e)}),{id:`library-remote-save:${e.id}`}):null;let t;try{t=await Dn({op:"library.content",assetId:e.id,download:!0},null)}finally{n!==null&&Ui(n)}if(t.kind!=="bytes")throw e.remote&&t.kind==="error"&&t.status===504?new Zs(Je(e)):new Error(t.kind==="error"?t.detail:k("ui.library.errors.asset_read"));const s=new Blob([t.data],{type:e.ref.content_type||t.mimeType||"application/octet-stream"}),i=URL.createObjectURL(s),r=document.createElement("a");r.href=i,r.download=ca(e),r.rel="noopener",document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(i),3e4)}const Vn=({asset:e,onAsk:n,onEditMetadata:t,onEditTags:s,onToggleFavorite:i,onOpenConversation:r,onFilterSession:a,triggerClassName:l})=>{const o=async(p,m)=>{try{await navigator.clipboard.writeText(p),Cn(m)}catch{Pe(k("ui.library.menu.copy_failed"))}},c=async()=>{try{await bt(e),Cn(k("ui.library.menu.saved_a_copy"))}catch(p){Pe(Mn(p,k("ui.library.menu.save_failed")))}},d=!!e.remote,h=!!(!d&&e.ref.type==="path"&&e.ref.path),u=e.occurrences;return f.jsxs(Us,{children:[f.jsx(Xt,{content:k("ui.library.menu.asset_actions"),children:f.jsx(Ws,{asChild:!0,children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.menu.asset_actions_label",{name:e.name||e.derived_name}),className:l,onClick:p=>p.stopPropagation(),"data-library-asset-menu":"",children:f.jsx(Gi,{"aria-hidden":"true"})})})}),f.jsxs(Gs,{align:"end",className:"min-w-52",onClick:p=>p.stopPropagation(),children:[u.length===1?f.jsxs(Ee,{onSelect:()=>r(u[0].session_id),children:[f.jsx(Kt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.open_source_conversation")})]}):u.length>1?f.jsxs(fr,{children:[f.jsxs(hr,{children:[f.jsx(Kt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.open_source_conversation")})]}),f.jsx(pr,{className:"min-w-60",children:u.map(p=>f.jsx(Ee,{onSelect:()=>r(p.session_id),children:f.jsx("span",{className:"truncate",children:p.session_title||p.session_id})},`${p.session_id}:${p.first_seq}`))})]}):null,f.jsxs(Ee,{onSelect:n,children:[f.jsx(Kt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.ask_about_asset")})]}),u.length>0&&f.jsxs(Ee,{onSelect:()=>a(u[0].session_id),children:[f.jsx(jn,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.show_from_conversation")})]}),f.jsx(ss,{}),f.jsxs(Ee,{onSelect:i,children:[f.jsx(un,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0}),f.jsx("span",{children:e.favorite?k("ui.library.menu.unfavorite"):k("ui.library.menu.favorite")})]}),f.jsxs(Ee,{onSelect:t,children:[f.jsx(zs,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.edit_metadata")})]}),f.jsxs(Ee,{onSelect:s,children:[f.jsx(Br,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.edit_tags")})]}),f.jsx(ss,{}),e.ref.path&&!d?f.jsxs(Ee,{onSelect:()=>void o(e.ref.path,k("ui.library.menu.path_copied")),children:[f.jsx(qi,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.copy_path")})]}):null,f.jsxs(Ee,{onSelect:()=>void o(e.id,k("ui.library.menu.asset_id_copied")),children:[f.jsx(xr,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.copy_asset_id")})]}),h?f.jsxs(Ee,{onSelect:()=>{e.ref.path&&window.api.showItemInFolder(e.ref.path)},children:[f.jsx(jn,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.reveal_in_finder")})]}):f.jsxs(Ee,{onSelect:()=>void c(),children:[f.jsx(mt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.download")})]}),e.ref.type==="artifact"&&f.jsxs(Ee,{onSelect:()=>void c(),children:[f.jsx(mt,{"aria-hidden":"true"}),f.jsx("span",{children:k("ui.library.menu.save_a_copy")})]})]})]})},da={image:Vi,audio:Xi,video:Ki,pdf:Ot,pptx:Lr,docx:Ot,markdown:Ot,html:is,spreadsheet:Ir,text:Ot,code:is,other:Is};function ua(e){return da[e]??Is}function Ye({kind:e,size:n=20,className:t}){const s=ua(e);return f.jsx(s,{size:n,"aria-hidden":"true",className:t})}const Js=({group:e})=>f.jsx(ot,{variant:e==="generated"?"accent":"neutral",children:k(fn(e))}),ei=({asset:e,large:n=!1})=>{const[t,s]=Un("300px"),i=e.kind==="image"&&e.exists&&s,r=wt(e.id,"thumbnail",i),a=xt(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(Ye,{kind:e.kind,size:n?28:22,className:"text-ink-dim"})})},us=()=>f.jsx("span",{className:"absolute top-1.5 start-1.5 flex size-5 items-center justify-center rounded-full bg-elevated",title:k("ui.library.card.highlighted"),children:f.jsx(Kn,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),ti=()=>f.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-elevated",title:k("ui.library.menu.favorite"),"data-library-favorite-mark":"",children:f.jsx(un,{size:12,"aria-hidden":"true",className:"fill-current text-accent"})}),ni=({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(ot,{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]})]})},fa=({asset:e})=>{const[n,t]=Un("300px"),[s,i]=$.useState(!1),r=e.exists&&(e.remote?s:t),a=wt(e.id,"content",r),l=Qs(e.id,r),o=xt(a.bytes,a.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:o?f.jsx(Ds,{variant:"compact",ownerId:`sound:library:${e.id}`,src:o,label:De(e),peaks:l,durationHint:e.duration_s}):e.remote&&e.exists&&!s?f.jsx("button",{type:"button","data-library-remote-play":"","aria-label":k("ui.canvas.files.remotePlay",{device:Je(e)}),title:k("ui.canvas.files.remotePlay",{device:Je(e)}),onClick:c=>{c.stopPropagation(),i(!0)},className:"flex size-full items-center justify-center rounded-sm text-ink-dim hover:text-ink",children:f.jsx(Ye,{kind:e.kind,size:28})}):s&&a.loading?f.jsx(gt,{size:"sm",label:k("ui.canvas.files.remoteFetching",{device:Je(e)})}):f.jsx(Ye,{kind:e.kind,size:28,className:"text-ink-dim"})})},si=({kind:e})=>(Ue(),f.jsx(f.Fragment,{children:Xn(e)})),ha=({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:De(e)}),f.jsx("span",{className:"line-clamp-1 text-meta text-ink-dim",children:Xs(e)}),f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx("span",{className:"truncate",children:f.jsx(si,{kind:e.kind})}),f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:f.jsx("bdi",{children:nn(e.size_bytes)})}),e.duration_s?f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{children:Yr(e.duration_s)})]}):null]}),f.jsx(ni,{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(Kt,{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(Js,{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:k("ui.library.card.conversations",{count:e.session_count})}),e.remote?f.jsx(Gn,{device:Je(e)}):null,e.favorite&&f.jsx(ti,{})]})]})]}),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(ei,{asset:e,large:!0}),e.highlighted&&f.jsx(us,{})]}),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&&qn),children:[s&&f.jsxs("div",{className:"relative",children:[f.jsx(fa,{asset:e}),e.highlighted&&f.jsx(us,{})]}),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(Vn,{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"})})]})},pa=({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&&qn),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(ei,{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(Kn,{size:12,"aria-hidden":"true",className:"shrink-0 fill-current text-accent"}),De(e)]}),f.jsx("span",{className:"truncate text-meta text-ink-dim",children:Xs(e)})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-meta text-ink-muted",children:[f.jsx(ni,{asset:e}),f.jsx("span",{children:f.jsx(si,{kind:e.kind})}),f.jsx("span",{children:f.jsx("bdi",{children:nn(e.size_bytes)})}),f.jsx(Js,{group:e.origin_group}),e.remote?f.jsx(Gn,{device:Je(e)}):null,e.favorite&&f.jsx(ti,{})]})]}),f.jsx(Vn,{asset:e,onAsk:()=>t.onAsk(e),onEditMetadata:()=>t.onEditMetadata(e),onEditTags:()=>t.onEditTags(e),onToggleFavorite:()=>t.onToggleFavorite(e),onOpenConversation:t.onOpenConversation,onFilterSession:t.onFilterSession})]}),ma=({assets:e,selectedId:n,view:t,hasMore:s,loadingMore:i,onLoadMore:r,...a})=>{const l=$.useRef(null);return $.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(ha,{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(pa,{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(On,{size:14,"aria-hidden":"true",className:"motion-safe:animate-spin"}),k("ui.library.grid.loading_more")]}),!i&&s&&f.jsx(J,{variant:"ghost",size:"sm",onClick:r,children:k("ui.library.grid.load_more")})]})]})},ga=({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))}),ba=[{key:"highlighted",labelKey:"ui.library.status.highlighted"},{key:"unorganized",labelKey:"ui.library.status.unorganized"},{key:"favorite",labelKey:"ui.library.status.favorites"}],Qe=({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?qn:"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})]}),St=({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})]}),ya=({category:e})=>(Ue(),f.jsx(f.Fragment,{children:Xr(e)})),va=({filters:e,onChange:n,counts:t,tags:s,total:i,scopeTotal:r})=>{const a=Kr(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(He,{"aria-hidden":"true"}),k("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:k("ui.library.filter.one_conversation")}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.filter.clear_conversation"),onClick:()=>o({session:void 0}),children:f.jsx(He,{"aria-hidden":"true"})})]}),f.jsxs(St,{label:k("ui.library.filter.scope"),children:[f.jsx(Qe,{label:k("ui.library.filter.scope_final"),active:e.scope==="final",onPress:()=>o({scope:"final"})}),f.jsx(Qe,{label:k("ui.library.filter.scope_all"),count:r??void 0,active:e.scope==="all",onPress:()=>o({scope:"all"})})]}),f.jsxs(St,{label:k("ui.library.filter.categories"),children:[f.jsx(Qe,{label:k("ui.library.category.all"),count:i,active:!e.category,onPress:()=>o({category:void 0})}),Nn.map(d=>f.jsx(Qe,{label:k(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(Ye,{kind:d.iconKind,size:14,className:"text-ink-dim"})},d.key)),Object.keys(l).filter(d=>!Nn.some(h=>h.key===d)).sort().map(d=>f.jsx(Qe,{label:d,count:l[d],active:e.category===d,onPress:()=>o({category:e.category===d?void 0:d}),icon:f.jsx(es,{size:14,"aria-hidden":"true"})},d))]}),f.jsx(St,{label:k("ui.library.filter.status"),children:ba.map(d=>f.jsx(Qe,{label:k(d.labelKey),active:as(e,d.key),onPress:()=>o({status:as(e,d.key)?void 0:d.key}),icon:d.key==="favorite"?f.jsx(un,{size:14,"aria-hidden":"true"}):d.key==="highlighted"?f.jsx(Kn,{size:14,"aria-hidden":"true"}):void 0},d.key))}),f.jsx(St,{label:k("ui.library.filter.source"),children:Or.filter(d=>e.originGroup===d||e.scope==="all"||(t?.origin_group?.[d]??0)>0).map(d=>f.jsx(Qe,{label:k(fn(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(St,{label:k("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:f.jsx(ya,{category:d.category})}),d.tags.map(h=>f.jsx(Qe,{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(es,{size:13,"aria-hidden":"true"}),indent:!0},h.id))]},d.category))}),e.tag&&f.jsx(ot,{variant:"neutral",children:k("ui.library.filter.tag_mode",{mode:e.tagMode.toUpperCase()})})]})},fs=({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})=>{Ue();const[h,u]=$.useState(!1),[p,m]=$.useState(e),[g,T]=$.useState(!1),y=$.useRef("closed"),w=$.useRef(null),x=$.useRef(null),S=()=>{y.current==="closed"&&(m(e),y.current="edit",u(!0))},v=E=>{y.current="closed",E&&x.current?.focus(),u(!1)},_=async E=>{if(y.current!=="edit")return;const z=p.trim();if(!z&&!l||z===e){v(E);return}y.current="saving",T(!0);try{await n(z),y.current==="saving"&&v(E)}catch{y.current==="saving"&&(y.current="edit",w.current?.focus())}finally{T(!1)}};$.useEffect(()=>{if(!h)return;const E=setTimeout(()=>{const z=w.current;z&&(z.focus(),z.select(),z.scrollLeft=0,z instanceof HTMLTextAreaElement&&(z.scrollTop=0))},0);return()=>clearTimeout(E)},[h]),$.useEffect(()=>{y.current==="closed"&&m(e)},[e]);const j=$.useRef(o);$.useEffect(()=>{const E=j.current;j.current=o,!(o===E||!o)&&S()},[o]);const N=E=>{if(!(E.nativeEvent.isComposing||E.keyCode===229)){if(E.key==="Enter"){if(i&&E.shiftKey)return;E.preventDefault(),_(!0)}else if(E.key==="Escape"){if(E.preventDefault(),y.current==="saving")return;v(!0)}}},F=E=>{h&&E.preventDefault()},R=E=>{m(E.target.value)},A=e.trim()?f.jsx("span",{onDoubleClick:S,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:S,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:E=>{w.current=E},value:p,rows:r,readOnly:g,"aria-label":t,"aria-busy":g||void 0,onChange:R,onKeyDown:N,onBlur:()=>void _(!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:E=>{w.current=E},value:p,readOnly:g,"aria-label":t,"aria-busy":g||void 0,onChange:R,onKeyDown:N,onBlur:()=>void _(!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?k("ui.common.forms.editable_field.saving"):h?k("ui.common.forms.autocomplete_field.cancel_editing",{label:t}):k("ui.common.forms.editable_field.edit_v2",{label:t}),title:g?k("ui.common.forms.editable_field.saving"):h?k("ui.common.forms.editable_field.cancel_escape"):k("ui.common.forms.editable_field.edit"),"aria-busy":g||void 0,"aria-disabled":g||void 0,onMouseDown:F,onClick:E=>{if(!(E.detail>1)&&y.current!=="saving"){if(h){v(!0);return}S()}},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(gt,{size:"xs"}):h?f.jsx(He,{className:"size-3","aria-hidden":"true"}):f.jsx(zs,{className:"size-3","aria-hidden":"true"})})]})},wa=({value:e,onChange:n,label:t,addLabel:s,saving:i=!1,startSignal:r})=>{Ue();const[a,l]=$.useState(!1),[o,c]=$.useState(""),d=$.useRef(null),h=$.useRef(null),u=()=>{i||a||l(!0)},p=()=>{c(""),l(!1)},m=x=>{const S=o.trim().toLowerCase();S&&!e.some(v=>v.toLowerCase()===S)&&n([...e,S]),c(""),x?d.current?.focus():l(!1)},g=$.useRef(!1);$.useEffect(()=>{if(i){g.current=!0;return}if(!a){g.current=!1;return}const x=g.current;g.current=!1;const S=setTimeout(()=>{if(x){const v=document.activeElement,_=h.current;if(!(!v||v===document.body||!!_?.contains(v)))return}d.current?.focus()},0);return()=>clearTimeout(S)},[a,i]);const T=$.useRef(r);$.useEffect(()=>{const x=T.current;T.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(gt,{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(kr,{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(ot,{variant:"neutral",shape:"pill",className:"gap-1 pe-1 text-ink",children:[x,f.jsx("button",{type:"button","aria-label":k("ui.chat.tags.remove_named",{name:x}),disabled:i,onClick:()=>n(e.filter(S=>S!==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(He,{className:"size-3","aria-hidden":"true"})})]},x)),w]})},xa=2e3;function Hn(e){return lt(e)!==null&&e.exists===!0}function ka(e,n){const t=Hn(e)?e.ref.path:null,[s,i]=$.useState({mtimeMs:null,sizeBytes:null,revision:0,missing:!1}),r=$.useRef(null),a=$.useRef(!1);$.useEffect(()=>{r.current=null,i({mtimeMs:null,sizeBytes:null,revision:0,missing:!1})},[t]);const l=$.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 $.useEffect(()=>{l()},[l,n]),$.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()},xa);return()=>{window.removeEventListener("focus",o),document.removeEventListener("visibilitychange",c),window.clearInterval(d)}},[t,l]),s}const _a=[];function Sa(e){const n=e.ref.display_path||e.ref.path||(e.ref.digest?`attachment digest ${e.ref.digest}`:e.id);return`${De(e)} (${n})`}function Ta(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 Pa=({asset:e,focusSignal:n,onSessionChange:t,showLinkedRow:s,onOpenChat:i,refreshSignal:r=0,streaming:a})=>{Ue();const l=$.useRef(null),o=Bn(),{frontend:c,refresh:d}=Hi(),h=$.useRef(!1),[u,p]=$.useState(!1),[m,g]=$.useState({}),[T,y]=$.useState(null),w=e.chat?.session_id??m[e.id]??null,x=m[e.id]??null,S=T===e.id,v=ia(),_=Ys(),j=wt(e.id,"content",e.kind==="image"),N=w??`library:${e.id}`;$.useEffect(()=>{w&&d(w)},[w,d,r]),$.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(E=>{const z={...E};return delete z[e.id],z}),y(null)}catch{Pe(k("ui.library.composer.link_failed_short"))}},R=async(A,E,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=Ta(e,j.bytes,j.mimeType),{images:Z,files:Q,failures:I,overflow:X,fileOverflow:ae}=await Qi(B?[...E,B]:E,A),le=Zi(I);if(le)return Pe(le),!1;const fe=Ji(X);if(fe)return Pe(fe),!1;const ee=er(ae);if(ee)return Pe(ee),!1;if(!W){const H=Ei.getState();if(W=await H.createSession(H.cwd||"~"),!W)throw new Error(H.error??k("ui.library.composer.could_not_start"))}const V=W,be={op:"sessions.message",sessionId:V,requestId:crypto.randomUUID(),text:`${Y}
|
|
28
28
|
|
|
29
|
-
${_a(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),Pe(H instanceof Error&&H.message?k("ui.library.composer.link_failed",{message:H.message}):k("ui.library.composer.link_failed_short"))}return!0}catch(B){return Pe(B instanceof Error&&B.message?B.message:k("ui.library.composer.not_sent")),!1}finally{h.current=!1,p(!1)}},P=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:[S&&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:k("ui.library.composer.message_sent_link_failed")}),f.jsx(J,{variant:"ghost",size:"sm",onClick:()=>void F(),children:k("ui.library.composer.retry_link")}),f.jsx(J,{variant:"ghost",size:"sm",onClick:()=>i(x),children:k("ui.library.composer.open_chat")})]}),P&&s&&f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx(Ks,{size:13,"aria-hidden":"true"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:k("ui.library.composer.chat_about",{title:P.title||P.session_id})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.composer.unlink"),onClick:()=>_.mutate({id:e.id}),children:f.jsx(He,{"aria-hidden":"true"})})]}),f.jsx("div",{className:"min-w-0","data-sending":u?"":void 0,children:f.jsx(Yi,{ref:l,conversationId:N,messages:ka,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:P||w?k("ui.library.composer.continue_placeholder"):k("ui.library.composer.ask_placeholder"),cwd:c?.cwd,cwdReadOnlyReason:k("ui.projects.project_quick_send.quick_send_follows_the_conversation_s_directory"),sessionStatus:c&&w?{frontend:c,costChannels:Tt(o.data,"cost_channels")}:void 0,onSendMessage:R})})]})},Pa=({sessionId:e,title:n,collapsed:t,onToggleCollapsed:s,onOpenChat:i,onUnlink:r,onTurnSettled:a,onStreamingChange:l})=>{Ue();const o=Bn(),c=Ri(e,!0,!0,e,{openFrame:Tt(o.data,"open_frame"),journalOrder:Tt(o.data,"journal_order"),peerJournalSource:Tt(o.data,"peer_journal_source")}),d=$.useRef(null),u=(c.frontend??c.heldFrontend)?.streaming===!0,p=tr(c.frontend??c.heldFrontend),m=$.useRef(u);$.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(Ks,{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:k("ui.library.composer.chat_about",{title:n})}),f.jsx(qs,{"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:k("ui.library.composer.open_chat")}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.composer.unlink"),onClick:r,children:f.jsx(He,{"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:k("ui.mesh.mesh_approvals.waiting_for_you")}),f.jsx(J,{variant:"secondary",size:"sm",onClick:i,children:k("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(gt,{label:k("ui.library.preview.loading")})}):f.jsx(nr,{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 ja(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 Ca="h-[78px] w-[117px]",Fa=({asset:e,active:n,onSelect:t})=>{const[s,i]=Un("300px"),r=wt(e.id,"thumbnail",e.kind==="image"&&e.exists&&i),a=xt(r.bytes,r.mimeType),l=De(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",Ca),children:a?f.jsx("img",{src:a,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(Ye,{kind:e.kind,size:20,className:"text-ink-dim"})})})})},Na=({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(Fa,{asset:s,active:i===n,onSelect:()=>t(i)},s.id))}),Ma=({open:e,siblings:n,index:t,onIndexChange:s,onClose:i,restoreFocusTo:r,resolved:a})=>{Ue();const l=sr(t,n.length),o=n[l],c=a?.assetId===o.id,d=wt(o.id,"content",!c),h=xt(d.bytes,d.mimeType||o.ref.content_type),u=c?a?.url:h??void 0,p=De(o);return f.jsx(ir,{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:k("ui.library.preview.could_not_load")}):void 0,group:{index:l,count:n.length,onPrev:()=>s(ts(l,n.length,-1)),onNext:()=>s(ts(l,n.length,1)),filmstrip:n.length>1?f.jsx(Na,{siblings:n,index:l,onSelect:s}):void 0}})};async function ii(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 T=t.getUint32(p+20,!0),y=t.getUint32(p+24,!0);const w=t.getUint16(p+28,!0),x=t.getUint16(p+30,!0),S=t.getUint16(p+32,!0);let v=t.getUint32(p+42,!0);const _=$a(n,p+46,w);if(T===4294967295||y===4294967295||v===4294967295){const P=p+46+w,A=P+x;let E=P;for(;E+4<=A;){const z=t.getUint16(E,!0),Y=t.getUint16(E+2,!0);if(z===1){let O=E+4;y===4294967295&&O+8<=A&&(y=Number(t.getBigUint64(O,!0)),O+=8),T===4294967295&&O+8<=A&&(T=Number(t.getBigUint64(O,!0)),O+=8),v===4294967295&&O+8<=A&&(v=Number(t.getBigUint64(O,!0)));break}E+=4+Y}}if(p+=46+w+x+S,_.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+T>n.length)continue;const R=n.subarray(F,F+T);try{u[_]=g===0?R.slice():await Aa(R)}catch(P){console.warn(`[zip.js] Failed to decompress "${_}":`,P.message)}}return u}async function Aa(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 Te(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 Oe(e,n,t){return Math.max(n,Math.min(t,e))}const Ft=12700,Ea=Object.freeze(Object.defineProperty({__proto__:null,EMU_PER_PT:Ft,attr:U,attrInt:C,clamp:Oe,g1:b,gtn:ge,parseXml:Te},Symbol.toStringTag,{value:"Module"}));function Ra(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 La(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 za(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 pt={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"}},Yt=new Set,Nt=new Map,Qt=new Set;let hs=null,Tn=null;function Ia(){return Tn||(hs=typeof OffscreenCanvas<"u"?new OffscreenCanvas(300,10):Object.assign(document.createElement("canvas"),{width:300,height:10}),Tn=hs.getContext("2d")),Tn}const ps="mmmmmmmmmmlllllllllliiiiiiiiiixxxxxxxxxx",Da=[20,40];function ri(e){if(Qt.has(e))return!0;if(typeof document<"u"&&document.fonts&&document.fonts.check(`16px "${e}"`))return Qt.add(e),!0;try{const n=Ia(),t=["monospace","serif"];for(const s of Da)for(const i of t){n.font=`${s}px ${i}`;const r=n.measureText(ps).width;n.font=`${s}px "${e}", ${i}`;const a=n.measureText(ps).width;if(Math.abs(a-r)>.5)return Qt.add(e),!0}}catch{}return!1}async function An(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=Nt.get(e)??[];a.push(r),Nt.set(e,a),Yt.add(e),Qt.add(e);const l=e.toLowerCase().trim();return pt[l]?pt[l]._custom=!0:pt[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 Ba(e){const n=[];for(const[t,s]of Object.entries(e))if(typeof s=="string")n.push(An(t,s));else if(Array.isArray(s))for(const i of s){const{url:r,...a}=i;n.push(An(t,r,a))}await Promise.all(n)}function Oa(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 Ua(e){if(!e)return"sans-serif";if(e==="+mj-lt"||e==="+mj")return"serif";if(e==="+mn-lt"||e==="+mn")return"sans-serif";if(Nt.has(e))return e;const n=e.toLowerCase().trim(),t=pt[n];return t?t._custom||t.google===null?e:t.google&&ri(t.google)?t.google:t.google||e:e}function Wa(e){if(!e)return"sans-serif";const n=e.toLowerCase().trim();return pt[n]?.generic??"sans-serif"}async function Ga(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"||Nt.has(a))continue;const l=a.toLowerCase().trim(),o=pt[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||Yt.has(c))continue;if(ri(c)){Yt.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())Yt.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 qa(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 ai(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=Ua(c),u=Wa(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 Ka(){const e=[];for(const[n,t]of Nt)for(const s of t)e.push({family:n,weight:s.weight,style:s.style,status:s.status});return e}function Ut(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 it(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 Ze(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 Xa={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 Va(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=it(t,s,i),h=Ze(d.h,Oe(d.l*c,0,1),d.s);t=h.r,s=h.g,i=h.b;break}case"lumOff":{const c=o/1e5,d=it(t,s,i),h=Ze(d.h,Oe(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=it(t,s,i),h=Ze(d.h,d.l,Oe(d.s*c,0,1));t=h.r,s=h.g,i=h.b;break}case"satOff":{const c=o/1e5,d=it(t,s,i),h=Ze(d.h,d.l,Oe(d.s+c,0,1));t=h.r,s=h.g,i=h.b;break}case"hueMod":{const c=o/1e5,d=it(t,s,i),h=Ze(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=it(t,s,i),h=Ze(((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=Oe(r+o/1e5,0,1);break}case"alphaMod":{r=Oe(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=it(t,s,i),d=Ze((c.h+.5)%1,c.l,c.s);t=d.r,s=d.g,i=d.b;break}}}return{r:Oe(t,0,255),g:Oe(s,0,255),b:Oe(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=Ut(r))}else if(t==="schemeClr"){const a=e.getAttribute("val")||"",l=n?.[a];l?s=Ut(l):s={r:0,g:0,b:0}}else if(t==="prstClr"){const r=(e.getAttribute("val")||"").toLowerCase(),a=Xa[r];a&&(s=Ut(a))}else if(t==="sysClr"){const r=e.getAttribute("lastClr");r?.length>=6?s=Ut(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=Ze(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?Va({...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 ms(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 Ha(e,n,t){const s=ms(e,t);return s||ms(n,t)}function rn(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":ft(e,c,d,i/2,r/2,5,-Math.PI/2);break;case"hexagon":ft(e,c,d,i/2,r/2,6,0);break;case"heptagon":ft(e,c,d,i/2,r/2,7,-Math.PI/2);break;case"octagon":ft(e,c,d,i/2,r/2,8,Math.PI/8);break;case"decagon":ft(e,c,d,i/2,r/2,10,-Math.PI/2);break;case"dodecagon":ft(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,T=d-p/2,y=d+p/2;e.moveTo(m,s),e.lineTo(g,s),e.lineTo(g,T),e.lineTo(t+i,T),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,T),e.lineTo(m,T),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,T=t+i*(1-u);e.moveTo(t,d),e.lineTo(g,s),e.lineTo(g,s+m),e.lineTo(T,s+m),e.lineTo(T,s),e.lineTo(t+i,d),e.lineTo(T,s+r),e.lineTo(T,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,T=s+r*(1-u);e.moveTo(c,s),e.lineTo(t+i,g),e.lineTo(t+i-m,g),e.lineTo(t+i-m,T),e.lineTo(t+i,T),e.lineTo(c,s+r),e.lineTo(t,T),e.lineTo(t+m,T),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,T=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,T),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":{Ya(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 ft(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 Ya(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 gs=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0","#FF7F00","#9E480E"];function Qa(e){const n=e?.textContent?.trim();if(n==null||n==="")return null;const t=parseFloat(n);return isNaN(t)?n:t}function Pt(e){if(!e)return[];const n=C(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]=Qa(b(s,"v"))}return t}function Rt(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 hn(e){const n=b(e,"cat")||b(e,"xVal");return n?Pt(b(n,"strCache")||b(n,"numCache")):[]}function Lt(e){const n=b(e,"val")||b(e,"yVal");return n?Pt(b(n,"numCache")):[]}function ct(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]}`:gs[n%gs.length]}function oi(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 pn(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 Mt(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 Ie(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 dt(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 li(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 At(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=li(i-s);return i=Math.ceil(i/r)*r,s=Math.floor(s/r)*r,{min:s,max:i,step:r}}function ut(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 zt(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,Mt(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 Za(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((_,j)=>({name:Rt(_),values:Lt(_),color:ct(_,j,a),dptColors:oi(_,a)}));if(!m.length)return;const g=hn(p[0])||[],T=Math.max(g.length,m[0]?.values.length||0,1),y=pn(t,s,i,r,{hasLegend:m.length>1});let w;h?(w=Array.from({length:T},(_,j)=>m.reduce((N,F)=>N+(F.values[j]||0),0)),u&&(w=w.map(()=>100))):w=m.flatMap(_=>_.values);const x=At(w),S=Math.max(7,Math.min(11,y.w*.018))*l;e.font=`${S}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 P=0;P<=v;P++){const A=x.min+P*x.step,E=(A-x.min)/(x.max-x.min),z=y.y+y.h-E*y.h;dt(e,y.x,z,y.x+y.w,z),e.fillText(u?A+"%":ut(A),y.x-4*l,z)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";const _=y.w/T;for(let P=0;P<T;P++){const A=y.x+_*P+_/2,E=String(g[P]??P+1);e.fillText(E,A,y.y+y.h+S*1.5)}e.restore(),Ie(e,y.x,y.y,y.x,y.y+y.h),Ie(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h);const j=y.w/T,N=j*.15,F=j-N*2,R=h?F:F/m.length;for(let P=0;P<T;P++){const A=y.x+j*P+N;let E=0;for(let z=0;z<m.length;z++){const Y=m[z];let O=Y.values[P]??0;if(u){const le=m.reduce((fe,ee)=>fe+(ee.values[P]||0),0);O=le?O/le*100:0}const W=Y.dptColors[P]||Y.color,B=Math.abs(O)/(x.max-x.min)*y.h,Z=h?A:A+z*R,Q=h?(E-x.min)/(x.max-x.min):Math.max(0,-x.min)/(x.max-x.min),I=y.y+y.h-Q*y.h,X=O>=0?I-B:I;e.save(),e.fillStyle=W,Mt(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&&(E+=Math.abs(O))}}}else{e.save(),e.textAlign="right",e.fillStyle="#666";const _=y.h/T;for(let P=0;P<T;P++){const A=y.y+_*P+_/2,E=String(g[P]??P+1);e.fillText(E,y.x-4*l,A)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";for(let P=0;P<=v;P++){const A=x.min+P*x.step,E=(A-x.min)/(x.max-x.min),z=y.x+E*y.w;dt(e,z,y.y,z,y.y+y.h),e.fillText(u?A+"%":ut(A),z,y.y+y.h+S*1.5)}e.restore(),Ie(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h),Ie(e,y.x,y.y,y.x,y.y+y.h);const j=_*.15,N=_-j*2,F=h?N:N/m.length,R=y.x+-x.min/(x.max-x.min)*y.w;for(let P=0;P<T;P++){const A=y.y+_*P+j;let E=0;for(let z=0;z<m.length;z++){const Y=m[z];let O=Y.values[P]??0;if(u){const X=m.reduce((ae,le)=>ae+(le.values[P]||0),0);O=X?O/X*100:0}const W=Y.dptColors[P]||Y.color,B=Math.abs(O)/(x.max-x.min)*y.w,Z=h?A:A+z*F,Q=h?R+E/(x.max-x.min)*y.w:R,I=O>=0?Q:Q-B;e.save(),e.fillStyle=W,Mt(e,I,Z,B,h?N:F-1*l,2*l),e.fill(),e.restore(),h&&(E+=Math.abs(O))}}}m.length>1&&zt(e,t,s,i,y.legendY,m,l)}function Ja(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:Rt(y),values:Lt(y),color:ct(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=hn(c[0])||[],u=Math.max(h.length,d[0]?.values.length||0,1),p=pn(t,s,i,r,{hasLegend:!0}),m=At(d.flatMap(y=>y.values)),g=Math.max(7,Math.min(11,p.w*.018))*l,T=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<=T;y++){const w=m.min+y*m.step,x=(w-m.min)/(m.max-m.min),S=p.y+p.h-x*p.h;dt(e,p.x,S,p.x+p.w,S),e.fillText(ut(w),p.x-4*l,S)}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;dt(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(),Ie(e,p.x,p.y,p.x,p.y+p.h),Ie(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((S,v)=>{const _=u>1?v/(u-1):.5,j=(S-m.min)/(m.max-m.min);return{x:p.x+_*p.w,y:p.y+p.h-j*p.h,v:S}}).filter(S=>typeof S.v=="number");if(w.length<2)continue;e.save(),e.beginPath(),e.moveTo(w[0].x,p.y+p.h);for(const S of w)e.lineTo(S.x,S.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 S=1;S<w.length-1;S++){const v=(w[S].x+w[S+1].x)/2,_=(w[S].y+w[S+1].y)/2;e.quadraticCurveTo(w[S].x,w[S].y,v,_)}e.lineTo(w[w.length-1].x,w[w.length-1].y)}else{e.moveTo(w[0].x,w[0].y);for(const S of w.slice(1))e.lineTo(S.x,S.y)}e.stroke(),e.restore();const x=3.5*l;for(const S of w)e.save(),e.fillStyle=y.color,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.beginPath(),e.arc(S.x,S.y,x,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}zt(e,t,s,i,p.legendY,d,l)}function eo(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,_)=>({name:Rt(v),values:Lt(v),color:ct(v,_,a)})).reverse();if(!p.length)return;const m=Math.max(...p.map(v=>v.values.length),1),g=pn(t,s,i,r,{hasLegend:!0});let T=0;if(d)T=100;else for(let v=0;v<m;v++){const _=p.reduce((j,N)=>j+(N.values[v]||0),0);T=Math.max(T,_)}const y={min:0,max:T||100,step:li(T||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 _=y.min+v*y.step,j=(_-y.min)/(y.max-y.min),N=g.y+g.h-j*g.h;dt(e,g.x,N,g.x+g.w,N),e.fillText(d?_+"%":ut(_),g.x-4*l,N)}e.restore(),Ie(e,g.x,g.y,g.x,g.y+g.h),Ie(e,g.x,g.y+g.h,g.x+g.w,g.y+g.h);const S=new Array(m).fill(0);for(const v of p){e.save(),e.beginPath();const _=[];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?S[j]:0,R=F+Math.abs(N),P=(F-y.min)/(y.max-y.min),A=(R-y.min)/(y.max-y.min),E=g.x+j/(m-1||1)*g.w;_.push({x:E,y:g.y+g.h-A*g.h,baseY:g.y+g.h-P*g.h}),h&&(S[j]+=Math.abs(N))}e.moveTo(_[0].x,_[0].baseY);for(const j of _)e.lineTo(j.x,j.baseY);for(let j=_.length-1;j>=0;j--)e.lineTo(_[j].x,_[j].y);e.closePath(),e.fillStyle=v.color+"cc",e.fill(),e.beginPath(),e.moveTo(_[0].x,_[0].y);for(const j of _.slice(1))e.lineTo(j.x,j.y);e.strokeStyle=v.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}zt(e,t,s,i,g.legendY,[...p].reverse(),l)}function bs(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=Lt(p).map(P=>typeof P=="number"&&P>0?P:0),g=hn(p),T=oi(p,a),y=m.reduce((P,A)=>P+A,0);if(!y)return;const w=Math.min(i,r)*.38,x=t+i*.44,S=s+r*.5,v=h?w*.55:0;let _=-Math.PI/2;for(let P=0;P<m.length;P++){if(!m[P])continue;const A=m[P]/y*Math.PI*2,E=T[P]||ct(p,P,a),z=_+A/2,Y=P===0?w*.04:0,O=Y*Math.cos(z),W=Y*Math.sin(z);e.save(),e.beginPath(),e.moveTo(x+O,S+W),e.arc(x+O,S+W,w,_,_+A),e.closePath(),e.fillStyle=E,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,S,v,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.restore());const B=m[P]/y;if(B>.05){const Z=x+O+w*.65*Math.cos(z),Q=S+W+w*.65*Math.sin(z),I=Math.max(8,Math.min(13,w*.15))*l;e.save(),e.fillStyle="#fff",e.font=`bold ${I}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(Math.round(B*100)+"%",Z,Q),e.restore()}_+=A}if(h){const P=Math.max(10,Math.min(16,w*.22))*l;e.save(),e.font=`bold ${P}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="middle",e.fillText(ut(y),x,S),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=S-m.length*F/2;for(let P=0;P<m.length;P++){const A=j,E=R+P*F,z=T[P]||ct(p,P,a);e.fillStyle=z,Mt(e,A,E-N*.5,N*1.2,N),e.fill(),e.fillStyle="#444";const Y=String(g[P]??`Item ${P+1}`);e.fillText(Y,A+N*1.5,E)}}function to(e,n,t,s,i,r,a,l){const o=b(n,"scatterChart")||b(n,"bubbleChart"),d=ge(o,"ser").map((_,j)=>{const N=Pt(b(b(_,"xVal"),"numCache")),F=Pt(b(b(_,"yVal"),"numCache")),R=Pt(b(b(_,"bubbleSize"),"numCache"));return{name:Rt(_),color:ct(_,j,a),points:N.map((P,A)=>({x:P,y:F[A],r:R[A]})).filter(P=>typeof P.x=="number"&&typeof P.y=="number")}});if(!d.length)return;const h=pn(t,s,i,r,{hasLegend:d.length>1}),u=d.flatMap(_=>_.points.map(j=>j.x)),p=d.flatMap(_=>_.points.map(j=>j.y)),m=At(u,!1),g=At(p),T=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=`${T}px sans-serif`,e.save(),e.textAlign="center",e.fillStyle="#666";for(let _=0;_<=y;_++){const j=m.min+_*m.step,N=(j-m.min)/(m.max-m.min),F=h.x+N*h.w;dt(e,F,h.y,F,h.y+h.h),e.fillText(ut(j),F,h.y+h.h+T*1.5)}e.textAlign="right";for(let _=0;_<=w;_++){const j=g.min+_*g.step,N=(j-g.min)/(g.max-g.min),F=h.y+h.h-N*h.h;dt(e,h.x,F,h.x+h.w,F),e.fillText(ut(j),h.x-4*l,F)}e.restore(),Ie(e,h.x,h.y,h.x,h.y+h.h),Ie(e,h.x,h.y+h.h,h.x+h.w,h.y+h.h);const x=d.flatMap(_=>_.points.map(j=>j.r??1)),S=Math.max(...x.filter(_=>typeof _=="number"),1),v=Math.min(h.w,h.h)*.06;for(const _ of d)for(const j of _.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/S*v:4*l;e.save(),e.fillStyle=_.color+"aa",e.strokeStyle=_.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&&zt(e,t,s,i,h.legendY,d,l)}function no(e,n,t,s,i,r,a,l){const o=b(n,"radarChart"),c=ge(o,"ser"),d=c.map((w,x)=>({name:Rt(w),values:Lt(w),color:ct(w,x,a)}));if(!d.length)return;const h=hn(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,T=At(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 S=0;S<u;S++){const v=S/u*Math.PI*2-Math.PI/2,_=p+x*Math.cos(v),j=m+x*Math.sin(v);S===0?e.moveTo(_,j):e.lineTo(_,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;Ie(e,p,m,p+g*Math.cos(x),m+g*Math.sin(x));const S=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),S,v),e.restore()}for(const w of d){const x=w.values.map((S,v)=>{const _=v/u*Math.PI*2-Math.PI/2,j=(S-T.min)/(T.max-T.min);return{x:p+g*j*Math.cos(_),y:m+g*j*Math.sin(_)}});e.save(),e.beginPath(),e.moveTo(x[0].x,x[0].y);for(const S of x.slice(1))e.lineTo(S.x,S.y);e.closePath(),e.fillStyle=w.color+"44",e.fill(),e.strokeStyle=w.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}zt(e,t,s,i,s+r-20*l,d,l)}function so(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 io(e,n,t,s,i,r,a,l){if(!n)return;const o=n;e.save(),e.fillStyle="#fff",Mt(e,t,s,i,r,4*l),e.fill(),e.strokeStyle="#ddd",e.lineWidth=.5,e.stroke(),e.restore();const d=so(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"),T=b(u,"pie3DChart")||b(u,"pieChart"),y=b(u,"doughnutChart"),w=b(u,"scatterChart")||b(u,"bubbleChart"),x=b(u,"radarChart");if(p)Za(e,u,t,d,i,h,a,l);else if(m)Ja(e,u,t,d,i,h,a,l);else if(g)eo(e,u,t,d,i,h,a,l);else if(y)bs(e,u,t,d,i,h,a,l);else if(T)bs(e,u,t,d,i,h,a,l);else if(w)to(e,u,t,d,i,h,a,l);else if(x)no(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 S=u.firstElementChild;e.fillText(S?.localName??"Chart",t+i/2,s+r/2),e.restore()}}function an(e,n,t=0,s=1){return(e?parseInt(e.getAttribute(n)||t,10):t)*s}function ci(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 ro(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,an(c,"w",76200,a)),h=Math.max(2*a,an(c,"h",76200,a)),p=U(c,"prst","circle").toLowerCase().includes("in"),m=Math.min(d,i*.3),g=Math.min(h,r*.3),T=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,T),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 S=e.createLinearGradient(t,s,t+m,s);S.addColorStop(0,T),S.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=S,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 ao(e,n,t,s,i,r,a,l){const o=an(n,"extrusionH",0,l);if(o<1*l)return;const c=b(n,"extrusionClr")||b(n,"contourClr"),d=ci(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 oo(e,n,t,s,i,r,a,l){const o=an(n,"contourW",0,l);if(o<.5)return;const c=b(n,"contourClr"),d=ci(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 lo(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 co(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 uo(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&&ao(e,o,t,s,i,r,a,l);const d=lo(e,c,s,i);return{overlay(){o&&(ro(e,o,s,i,r,a,l),oo(e,o,t,s,i,r,a,l)),c&&co(e,c,s,i,r,a)},cleanup:d}}function fo(e){return e?!!(b(e,"sp3d")||b(e,"scene3d")):!1}async function $t(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),S=Se(x,l);return{pos:w,color:S}}).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 T;if(u||!u&&!p){const x=(C(u,"ang",0)/6e4-90)*Math.PI/180,S=Math.cos(x),v=Math.sin(x),_=Math.abs(i*S)+Math.abs(r*v),j=m-_/2*S,N=g-_/2*v,F=m+_/2*S,R=g+_/2*v;T=e.createLinearGradient(j,N,F,R)}else{const y=b(p,"fillToRect"),w=C(y,"l",5e4)/1e5,x=C(y,"t",5e4)/1e5,S=C(y,"r",5e4)/1e5,v=C(y,"b",5e4)/1e5,_=t+i*(w+(1-w-S)/2),j=s+r*(x+(1-x-v)/2),N=Math.sqrt(i*i+r*r)/2;T=e.createRadialGradient(_,j,0,m,g,N)}for(const y of h)y.color&&T.addColorStop(y.pos,xe(y.color));return e.fillStyle=T,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,T=s,y=i,w=r;if(m){const _=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*_,T=s+r*j,y=i-i*_-i*N,w=r-r*j-r*F}if(b(n,"tile")){const _=e.createPattern(u,"repeat");if(_)return e.fillStyle=_,e.fill(),!0}const S=b(n,"alphaModFix")||b(d,"alphaModFix"),v=S?C(S,"amt",1e5)/1e5:1;return e.save(),e.clip(),v<1&&(e.globalAlpha=v),e.drawImage(u,g,T,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),T=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,T){case"smGrid":case"dotGrid":case"dotDmnd":for(let v=0;v<x;v+=2)for(let _=0;_<x;_+=2)y.fillRect(v,_,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 _=0;_<x;_++)(v+_)%2===0&&y.fillRect(_,v,1,1);break;default:for(let v=0;v<x;v+=4)y.fillRect(v,v,2,2)}const S=e.createPattern(w,"repeat");return S?(e.fillStyle=S,e.fill(),!0):(e.fillStyle=xe(u,(u.a??1)*.4),e.fill(),!0)}return!1}async function Ke(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=Te(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 T=h.split("/");for(const y of T)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 Zt(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 di(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 ho(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 po(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)+")";case"alphaLcPeriod":return String.fromCharCode(96+n)+".";case"alphaUcPeriod":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}function mo(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=po(n.numType,i[c]);i[c]++,e.fillText(d,t,s)}e.restore()}async function on(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,T=C(d,"rIns",91440)*a,y=C(d,"bIns",45720)*a,w=t+m,x=s+g,S=i-m-T,v=r-g-y,_=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 P=b(n,"lstStyle"),A=P?b(P,"defRPr"):null;function E(Q,I,X,ae){const le=Q?Q.getAttribute(X):null;if(le!==null&&le!=="")return le;const fe=I?I.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 I=b(Q,"pPr"),X=U(I,"algn","l");C(I,"lvl",0);const ae=C(I,"marL",0)*a,le=C(I,"indent",0)*a,fe=I?ho(I,H,l):null,ee=b(I,"spcBef"),V=b(I,"spcAft"),be=b(I,"lnSpc"),H=b(I,"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,G=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)*Ft*a/100)}if(V){const ne=b(V,"spcPct"),ie=b(V,"spcPts");ne?G=re*127*a*(C(ne,"val",0)/1e5):ie&&(G=C(ie,"val",0)*Ft*a/100)}const oe=[];for(const ne of Q.children){const ie=ne.localName;(ie==="r"||ie==="br"||ie==="fld")&&oe.push(ne)}if(oe.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:G,szPx:se,lnSpc:be,runs:[],emptyPara:!0,bullet:fe}),O+=ue+se*1.2+G;continue}let pe=[],he=[],D=0;for(const ne of oe){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=ai(ie,H,a*R,o,re,A);e.font=me.fontStr;const ce=me.szPx;ce>D&&(D=ce);const _e=Ha(ie,H,l),je=E(ie,H,"u","none")!=="none",L=E(ie,H,"strike","noStrike")!=="noStrike",q=parseInt(E(ie,H,"baseline","0"),10);if(_){const Ce=ve.split(" ");for(let We=0;We<Ce.length;We++){const Le=Ce[We];let nt=le+ae;for(const Bt of he)e.font=Bt.fontInfo.fontStr,nt+=e.measureText(Bt.text).width;e.font=me.fontStr;const st=e.measureText(Le).width,_n=he.length?e.measureText(" ").width:0;if(nt+_n+st>S&&he.length>0)pe.push({runs:he,maxSzPx:Math.max(D,ce)}),he=[{text:Le,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:L,baseline:q}],D=ce;else{if(he.length>0){const Bt={text:" ",rPr:ie,fontInfo:me,color:_e,underline:!1,strikethrough:!1,baseline:q};he.push(Bt)}he.push({text:Le,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:L,baseline:q})}}}else he.push({text:ve,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:L,baseline:q}),ce>D&&(D=ce)}he.length>0&&pe.push({runs:he,maxSzPx:Math.max(D,re*127*a)});const te=be?di(be,re*127*a*R,a):null;Y.push({lines:pe,algn:X,marL:ae,indent:le,spaceBefore:ue,spaceAfter:G,lnSpcPx:te,emptyPara:!1,bullet:fe});for(const ne of pe)O+=ue+(te||ne.maxSzPx*1.2)+G}if(N&&!F&&O>v&&v>0){let Q=.3,I=1;for(let X=0;X<8;X++){const ae=(Q+I)/2;let le=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){le+=re*1.2;continue}const ue=H.reduce((te,ne)=>{const ie=b(ne,"t");return te+(ie?ie.textContent.length:0)},0),G=S>0?S:i,oe=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=oe.length>0?e.measureText(oe).width/oe.length:re*.6,he=Math.max(1,Math.floor(G/pe)),D=Math.max(1,Math.ceil(ue/he));le+=D*re*1.2}le<=v?Q=ae:I=ae}R=(Q+I)/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:I,algn:X,marL:ae,indent:le,spaceBefore:fe,spaceAfter:ee,lnSpcPx:V,emptyPara:be,bullet:H}=Q;if(B+=fe,be){B+=I[0]?V||Q.szPx*1.2:12*a,B+=ee;continue}for(const re of I){const{runs:ue,maxSzPx:G}=re,oe=V||G*1.2,pe=B+G*.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+(S-he)/2:X==="r"&&(D=w+S-he);const te=re===I[0];if(H&&te){const se=w+ae+le;mo(e,H,se,pe,Z)}let ne=0;if(X==="just"&&!(re===I[I.length-1])){let ve=0;for(const ce of ue)e.font=ce.fontInfo.fontStr,ve+=(ce.text.match(/ /g)||[]).length;const me=S-ae-he;ve>0&&me>0&&(ne=me/ve)}const ie=(se,ve,me,ce,_e,je)=>{e.font=ce.fontStr;const L=e.measureText(se).width;e.fillText(se,ve,me);const q=Math.max(.5,ce.szPx*.07);return _e&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=q,e.beginPath(),e.moveTo(ve,me+q*1.5),e.lineTo(ve+L,me+q*1.5),e.stroke(),e.restore()),je&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=q,e.beginPath(),e.moveTo(ve,me-ce.szPx*.3),e.lineTo(ve+L,me-ce.szPx*.3),e.stroke(),e.restore()),L};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 L=ie(_e[je],D,me,ce,se.underline,se.strikethrough);D+=L,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+=oe}B+=ee}j&&e.restore()}function ui(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),T=Se(g,t),y=T?xe(T):"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 mn(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,T=!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,T=U(d,"flipH","0")==="1",y=U(d,"flipV","0")==="1"}else{const W=mi(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,I=B.cx/Q.cx,X=B.cy/Q.cy;h=W.x+(h/a-Z.x)*I*a,u=W.y+(u/a-Z.y)*X*a,p=p*I,m=m*X}const w=h+p/2,x=u+m/2;e.save(),(g!==0||T||y)&&(e.translate(w,x),g!==0&&e.rotate(g*Math.PI/180),T&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x));const S=b(c,"prstGeom"),v=b(c,"custGeom"),_=S?U(S,"prst","rect"):"rect",j={};if(S){const W=b(S,"avLst");if(W){let B=0;for(const Z of ge(W,"gd")){const I=U(Z,"fmla","").match(/val\s+(-?\d+)/);I&&(j[B]=parseInt(I[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 Te("<noFill/>").documentElement;const I=ke(Z);if(I)return Te('<solidFill xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'">'+I.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 I=ke(Z);if(I)return Te('<ln xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'"><solidFill>'+I.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,I=C(Z,"h",1)||1,X=p/Q,ae=m/I;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,G=e._lastY||u,oe=ue-V*Math.cos(H),pe=G-be*Math.sin(H);V===be?e.arc(oe,pe,V,H,H+re,re<0):e.ellipse(oe,pe,V,be,0,H,H+re,re<0);break}case"close":e.closePath();break}const le=N();le&&await $t(e,le,h,u,p,m,a,i,s);const fe=F();fe&&yt(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=$n(n);await on(e,B,h,u,p,m,a,i,r,Z),e.restore()}return}e.beginPath(),rn(e,_,h,u,p,m,j);const R=ui(e,c,i,a),P=h,A=u,E=p,z=m,Y=fo(c)?uo(e,c,i,P,A,E,z,a):null;try{const W=N();let B=!1;W&&(B=await $t(e,W,h,u,p,m,a,i,s)),Y&&Y.overlay();const Z=F();Z?yt(e,Z,i,a):B||(_==="line"||_==="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||T||y)&&(e.translate(w,x),g!==0&&e.rotate(g*Math.PI/180),T&&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=$n(n);await on(e,O,h,u,p,m,a,i,r,W),e.restore()}}function $n(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 yt(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 gn(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",T=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,S=d+u/2,v=h+p/2;if(e.save(),(m!==0||g||T)&&(e.translate(S,v),m!==0&&e.rotate(m*Math.PI/180),g&&e.scale(-1,1),T&&e.scale(1,-1),e.translate(-S,-v)),x&&s[x]){const _=s[x],j=b(a,"prstGeom"),N=j?U(j,"prst","rect"):"rect",F={};if(j){const A=b(j,"avLst");if(A){let E=0;for(const z of ge(A,"gd")){const Y=(U(z,"fmla","")||"").match(/val\s+(-?\d+)/);Y&&(F[E]=parseInt(Y[1])),E++}}}e.beginPath(),rn(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,E=C(R,"t",0)/1e5,z=C(R,"r",0)/1e5,Y=C(R,"b",0)/1e5,O=_.naturalWidth*(1-A-z),W=_.naturalHeight*(1-E-Y);e.drawImage(_,_.naturalWidth*A,_.naturalHeight*E,O,W,d,h,u,p)}else e.drawImage(_,d,h,u,p);const P=b(a,"ln");P&&(e.beginPath(),rn(e,N,d,h,u,p,F),yt(e,P,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 fi(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,T=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 S=c;for(let v=0;v<x.length;v++){const _=x[v],j=C(_,"h",457200)*i,N=ge(_,"tc");let F=o;const R=v===0,P=v===x.length-1,A=v%2===1;for(let E=0;E<N.length;E++){const z=N[E],Y=C(z,"gridSpan",1);U(z,"vMerge","0");let O=0;for(let I=0;I<Y;I++)O+=w[E+I]||0;const W=b(z,"tcPr"),B=W?["noFill","solidFill","gradFill","blipFill","pattFill"].map(I=>b(W,I)).find(Boolean):null;if(e.save(),e.beginPath(),e.rect(F,S,O,j),B)await $t(e,B,F,S,O,j,i,t,null);else{let I=null;g&&R?I=t.accent1?"#"+t.accent1.toLowerCase():"#4472C4":T&&P?I="#e0e0e0":m&&A&&(I="rgba(0,0,0,0.06)"),e.fillStyle=I||"transparent",I&&e.fill()}const Z=[{el:b(W,"lnL"),x1:F,y1:S,x2:F,y2:S+j},{el:b(W,"lnR"),x1:F+O,y1:S,x2:F+O,y2:S+j},{el:b(W,"lnT"),x1:F,y1:S,x2:F+O,y2:S},{el:b(W,"lnB"),x1:F,y1:S+j,x2:F+O,y2:S+j}];for(const I of Z)I.el?b(I.el,"noFill")||(e.beginPath(),e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),yt(e,I.el,t,i)):(e.beginPath(),e.strokeStyle="#cccccc",e.lineWidth=.5,e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),e.stroke());e.restore();const Q=b(z,"txBody");Q&&(e.save(),e.beginPath(),e.rect(F,S,O,j),e.clip(),await on(e,Q,F,S,O,j,i,t,s,1400),e.restore()),F+=O}S+=j}}async function bn(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",T={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=T.grpOff.x+T.grpExt.cx/2,w=T.grpOff.y+T.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 S=x.localName;S==="sp"?await mn(e,x,t,s,i,r,a,T):S==="pic"?await gn(e,x,t,s,i,a):S==="grpSp"?await bn(e,x,t,s,i,r,a):S==="graphicFrame"?await vn(e,x,i,r,a,files,t):S==="cxnSp"&&await yn(e,x,i,a)}e.restore()}function vs(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 T=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)),T||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(),T?e.stroke():e.fill();break}case"diamond":{const T=m/2;e.beginPath(),e.moveTo(s,i),e.lineTo(s+T*Math.cos(g)+p/2*Math.sin(g),i+T*Math.sin(g)-p/2*Math.cos(g)),e.lineTo(s+m*Math.cos(g),i+m*Math.sin(g)),e.lineTo(s+T*Math.cos(g)-p/2*Math.sin(g),i+T*Math.sin(g)+p/2*Math.cos(g)),e.closePath(),e.fill();break}case"oval":{const T=m/2,y=p/2,w=s+T*Math.cos(g),x=i+T*Math.sin(g);e.beginPath(),e.save(),e.translate(w,x),e.rotate(g),e.scale(1,y/T),e.arc(0,0,T,0,Math.PI*2),e.restore(),e.fill();break}}e.restore()}async function yn(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,T=c+h/2,y=b(i,"ln");e.save(),(u!==0||p||m)&&(e.translate(g,T),u!==0&&e.rotate(u*Math.PI/180),p&&e.scale(-1,1),m&&e.scale(1,-1),e.translate(-g,-T));const w=b(i,"prstGeom"),x=w?U(w,"prst","line"):"line",S=x==="line"||x==="straightConnector1";if(e.beginPath(),S){const v=p?o:o+d,_=m?c:c+h,j=p?o+d:o,N=m?c+h:c;e.moveTo(j,N),e.lineTo(v,_)}else rn(e,x,o,c,d,h,{});if(y){if(yt(e,y,t,s),S){const v=p?o+d:o,_=m?c+h:c,j=p?o:o+d,N=m?c:c+h;vs(e,y,"headEnd",j,N,v,_,t,s),vs(e,y,"tailEnd",v,_,j,N,t,s)}}else e.strokeStyle="#000",e.lineWidth=1,e.stroke();e.restore()}async function hi(e,n,t,s,i,r,a,l,o,c,d){const h=c*o,u=d*o,p=x=>{const S=b(x,"cSld");if(!S)return null;const v=b(S,"bg");if(!v)return null;const _=b(v,"bgPr"),j=b(v,"bgRef");return{bgPr:_,bgRef:j}},m=n?p(n):null,g=s?p(s):null,T=t?p(t):null,y=m||g||T;let w=!1;if(y){const{bgPr:x,bgRef:S}=y;if(x){const v=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const _ of v){const j=b(x,_);if(j){e.beginPath(),e.rect(0,0,h,u);const N=y===T?Object.assign({},a):a;await $t(e,j,0,0,h,u,1,l,N)&&(w=!0);break}}}else if(S){C(S,"idx",0);const v=ke(S),_=Se(v,l);_&&(e.fillStyle=xe(_),e.fillRect(0,0,h,u),w=!0)}}w||(e.fillStyle="#ffffff",e.fillRect(0,0,h,u))}function pi(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 mi(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 vn(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 fi(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,T=C(u,"cy",0)*i;if(g<=0||T<=0)return;const y=c.includes("chart"),w=c.includes("diagram");if(y&&r&&a){const S=o?b(o,"chart"):null,v=S?S.getAttribute("r:id")||S.getAttribute("id"):null,_=v?a[v]:null;if(_&&r[_.fullPath]){const j=new TextDecoder().decode(r[_.fullPath]),N=Te(j);io(e,N,p,m,g,T,t,i);return}}if(w&&r&&a){const S=o?b(o,"relIds"):null,v=S?S.getAttribute("r:dm")||S.getAttribute("dm"):null,_=v?a[v]:null;if(_&&r[_.fullPath]){const j=new TextDecoder().decode(r[_.fullPath]),N=Te(j),F=S?S.getAttribute("r:lo")||S.getAttribute("lo"):null,R=F?a[F]:null,P=R&&r[R.fullPath]?Te(new TextDecoder().decode(r[R.fullPath])):null,{renderSmartArt:A}=await dn(async()=>{const{renderSmartArt:E}=await import("./smartart-gFtvTNRW.js");return{renderSmartArt:E}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url);A(e,N,P,p,m,g,T,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,T),e.strokeRect(p,m,g,T),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+T/2),e.textAlign="start",e.textBaseline="alphabetic",e.restore()}async function gi(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 mn(e,c,t,s,i,r,a,null,l):d==="pic"?await gn(e,c,t,s,i,a):d==="grpSp"?await bn(e,c,t,s,i,r,a):d==="graphicFrame"?await vn(e,c,i,r,a,o,t):d==="cxnSp"&&await yn(e,c,i,a)}catch(h){console.warn("Error rendering shape:",d,h)}}}const go=Object.freeze(Object.defineProperty({__proto__:null,applyEffects:ui,applyFill:$t,applyOutline:yt,buildPlaceholderMap:pi,computeLineHeight:di,getDefaultFontSize:$n,getRels:Ke,loadImages:Zt,renderBackground:hi,renderConnector:yn,renderGraphicFrame:vn,renderGroupShape:bn,renderPicture:gn,renderShape:mn,renderSpTree:gi,renderTable:fi,renderTextBody:on,resolvePlaceholderXfrm:mi},Symbol.toStringTag,{value:"Module"}));async function bo(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 yo=(()=>{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 vo(e){let n=4294967295;for(let t=0;t<e.length;t++)n=yo[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}class wo{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 Be(e){return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}const bi=new TextEncoder;function xo(e){return bi.encode(e)}const ws=18977,xs=0;class ko{constructor(){this._entries=[]}async addText(n,t){return this.addBytes(n,bi.encode(t))}async addBytes(n,t,s=!0){const i=xo(n),r=vo(t),a=t.length;let l,o;if(s&&t.length>32){const c=await bo(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 wo;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(xs)),n.append(we(ws)),n.append(Be(i.crc)),n.append(Be(i.compData.length)),n.append(Be(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(xs)),n.append(we(ws)),n.append(Be(i.crc)),n.append(Be(i.compData.length)),n.append(Be(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(Be(0)),n.append(Be(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(Be(s)),n.append(Be(t)),n.append(we(0)),n.concat()}}async function _o(e){const n=new ko;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 So=new TextDecoder,yi=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 jt(e){return new DOMParser().parseFromString(e,"application/xml")}function To(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 yi.encode(
|
|
29
|
+
${Sa(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),Pe(H instanceof Error&&H.message?k("ui.library.composer.link_failed",{message:H.message}):k("ui.library.composer.link_failed_short"))}return!0}catch(B){return Pe(B instanceof Error&&B.message?B.message:k("ui.library.composer.not_sent")),!1}finally{h.current=!1,p(!1)}},P=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:[S&&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:k("ui.library.composer.message_sent_link_failed")}),f.jsx(J,{variant:"ghost",size:"sm",onClick:()=>void F(),children:k("ui.library.composer.retry_link")}),f.jsx(J,{variant:"ghost",size:"sm",onClick:()=>i(x),children:k("ui.library.composer.open_chat")})]}),P&&s&&f.jsxs("div",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[f.jsx(Ks,{size:13,"aria-hidden":"true"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:k("ui.library.composer.chat_about",{title:P.title||P.session_id})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.composer.unlink"),onClick:()=>_.mutate({id:e.id}),children:f.jsx(He,{"aria-hidden":"true"})})]}),f.jsx("div",{className:"min-w-0","data-sending":u?"":void 0,children:f.jsx(Yi,{ref:l,conversationId:N,messages:_a,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:P||w?k("ui.library.composer.continue_placeholder"):k("ui.library.composer.ask_placeholder"),cwd:c?.cwd,cwdReadOnlyReason:k("ui.projects.project_quick_send.quick_send_follows_the_conversation_s_directory"),sessionStatus:c&&w?{frontend:c,costChannels:Tt(o.data,"cost_channels")}:void 0,onSendMessage:R})})]})},ja=({sessionId:e,title:n,collapsed:t,onToggleCollapsed:s,onOpenChat:i,onUnlink:r,onTurnSettled:a,onStreamingChange:l})=>{Ue();const o=Bn(),c=Ri(e,!0,!0,e,{openFrame:Tt(o.data,"open_frame"),journalOrder:Tt(o.data,"journal_order"),peerJournalSource:Tt(o.data,"peer_journal_source")}),d=$.useRef(null),u=(c.frontend??c.heldFrontend)?.streaming===!0,p=tr(c.frontend??c.heldFrontend),m=$.useRef(u);$.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(Ks,{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:k("ui.library.composer.chat_about",{title:n})}),f.jsx(qs,{"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:k("ui.library.composer.open_chat")}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.composer.unlink"),onClick:r,children:f.jsx(He,{"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:k("ui.mesh.mesh_approvals.waiting_for_you")}),f.jsx(J,{variant:"secondary",size:"sm",onClick:i,children:k("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(gt,{label:k("ui.library.preview.loading")})}):f.jsx(nr,{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 Ca(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 Fa="h-[78px] w-[117px]",Na=({asset:e,active:n,onSelect:t})=>{const[s,i]=Un("300px"),r=wt(e.id,"thumbnail",e.kind==="image"&&e.exists&&i),a=xt(r.bytes,r.mimeType),l=De(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",Fa),children:a?f.jsx("img",{src:a,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover"}):f.jsx(Ye,{kind:e.kind,size:20,className:"text-ink-dim"})})})})},Ma=({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(Na,{asset:s,active:i===n,onSelect:()=>t(i)},s.id))}),Aa=({open:e,siblings:n,index:t,onIndexChange:s,onClose:i,restoreFocusTo:r,resolved:a})=>{Ue();const l=sr(t,n.length),o=n[l],c=a?.assetId===o.id,d=wt(o.id,"content",!c),h=xt(d.bytes,d.mimeType||o.ref.content_type),u=c?a?.url:h??void 0,p=De(o);return f.jsx(ir,{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:k("ui.library.preview.could_not_load")}):void 0,group:{index:l,count:n.length,onPrev:()=>s(ts(l,n.length,-1)),onNext:()=>s(ts(l,n.length,1)),filmstrip:n.length>1?f.jsx(Ma,{siblings:n,index:l,onSelect:s}):void 0}})};async function ii(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 T=t.getUint32(p+20,!0),y=t.getUint32(p+24,!0);const w=t.getUint16(p+28,!0),x=t.getUint16(p+30,!0),S=t.getUint16(p+32,!0);let v=t.getUint32(p+42,!0);const _=Ea(n,p+46,w);if(T===4294967295||y===4294967295||v===4294967295){const P=p+46+w,A=P+x;let E=P;for(;E+4<=A;){const z=t.getUint16(E,!0),Y=t.getUint16(E+2,!0);if(z===1){let O=E+4;y===4294967295&&O+8<=A&&(y=Number(t.getBigUint64(O,!0)),O+=8),T===4294967295&&O+8<=A&&(T=Number(t.getBigUint64(O,!0)),O+=8),v===4294967295&&O+8<=A&&(v=Number(t.getBigUint64(O,!0)));break}E+=4+Y}}if(p+=46+w+x+S,_.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+T>n.length)continue;const R=n.subarray(F,F+T);try{u[_]=g===0?R.slice():await $a(R)}catch(P){console.warn(`[zip.js] Failed to decompress "${_}":`,P.message)}}return u}async function $a(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 Ea(e,n,t){return new TextDecoder().decode(e.subarray(n,n+t))}function Te(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 Oe(e,n,t){return Math.max(n,Math.min(t,e))}const Ft=12700,Ra=Object.freeze(Object.defineProperty({__proto__:null,EMU_PER_PT:Ft,attr:U,attrInt:C,clamp:Oe,g1:b,gtn:ge,parseXml:Te},Symbol.toStringTag,{value:"Module"}));function La(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 za(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 Ia(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 pt={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"}},Yt=new Set,Nt=new Map,Qt=new Set;let hs=null,Tn=null;function Da(){return Tn||(hs=typeof OffscreenCanvas<"u"?new OffscreenCanvas(300,10):Object.assign(document.createElement("canvas"),{width:300,height:10}),Tn=hs.getContext("2d")),Tn}const ps="mmmmmmmmmmlllllllllliiiiiiiiiixxxxxxxxxx",Ba=[20,40];function ri(e){if(Qt.has(e))return!0;if(typeof document<"u"&&document.fonts&&document.fonts.check(`16px "${e}"`))return Qt.add(e),!0;try{const n=Da(),t=["monospace","serif"];for(const s of Ba)for(const i of t){n.font=`${s}px ${i}`;const r=n.measureText(ps).width;n.font=`${s}px "${e}", ${i}`;const a=n.measureText(ps).width;if(Math.abs(a-r)>.5)return Qt.add(e),!0}}catch{}return!1}async function An(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=Nt.get(e)??[];a.push(r),Nt.set(e,a),Yt.add(e),Qt.add(e);const l=e.toLowerCase().trim();return pt[l]?pt[l]._custom=!0:pt[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 Oa(e){const n=[];for(const[t,s]of Object.entries(e))if(typeof s=="string")n.push(An(t,s));else if(Array.isArray(s))for(const i of s){const{url:r,...a}=i;n.push(An(t,r,a))}await Promise.all(n)}function Ua(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 Wa(e){if(!e)return"sans-serif";if(e==="+mj-lt"||e==="+mj")return"serif";if(e==="+mn-lt"||e==="+mn")return"sans-serif";if(Nt.has(e))return e;const n=e.toLowerCase().trim(),t=pt[n];return t?t._custom||t.google===null?e:t.google&&ri(t.google)?t.google:t.google||e:e}function Ga(e){if(!e)return"sans-serif";const n=e.toLowerCase().trim();return pt[n]?.generic??"sans-serif"}async function qa(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"||Nt.has(a))continue;const l=a.toLowerCase().trim(),o=pt[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||Yt.has(c))continue;if(ri(c)){Yt.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())Yt.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 Ka(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 ai(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=Wa(c),u=Ga(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 Xa(){const e=[];for(const[n,t]of Nt)for(const s of t)e.push({family:n,weight:s.weight,style:s.style,status:s.status});return e}function Ut(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 it(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 Ze(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 Va={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 Ha(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=it(t,s,i),h=Ze(d.h,Oe(d.l*c,0,1),d.s);t=h.r,s=h.g,i=h.b;break}case"lumOff":{const c=o/1e5,d=it(t,s,i),h=Ze(d.h,Oe(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=it(t,s,i),h=Ze(d.h,d.l,Oe(d.s*c,0,1));t=h.r,s=h.g,i=h.b;break}case"satOff":{const c=o/1e5,d=it(t,s,i),h=Ze(d.h,d.l,Oe(d.s+c,0,1));t=h.r,s=h.g,i=h.b;break}case"hueMod":{const c=o/1e5,d=it(t,s,i),h=Ze(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=it(t,s,i),h=Ze(((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=Oe(r+o/1e5,0,1);break}case"alphaMod":{r=Oe(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=it(t,s,i),d=Ze((c.h+.5)%1,c.l,c.s);t=d.r,s=d.g,i=d.b;break}}}return{r:Oe(t,0,255),g:Oe(s,0,255),b:Oe(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=Ut(r))}else if(t==="schemeClr"){const a=e.getAttribute("val")||"",l=n?.[a];l?s=Ut(l):s={r:0,g:0,b:0}}else if(t==="prstClr"){const r=(e.getAttribute("val")||"").toLowerCase(),a=Va[r];a&&(s=Ut(a))}else if(t==="sysClr"){const r=e.getAttribute("lastClr");r?.length>=6?s=Ut(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=Ze(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?Ha({...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 ms(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 Ya(e,n,t){const s=ms(e,t);return s||ms(n,t)}function rn(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":ft(e,c,d,i/2,r/2,5,-Math.PI/2);break;case"hexagon":ft(e,c,d,i/2,r/2,6,0);break;case"heptagon":ft(e,c,d,i/2,r/2,7,-Math.PI/2);break;case"octagon":ft(e,c,d,i/2,r/2,8,Math.PI/8);break;case"decagon":ft(e,c,d,i/2,r/2,10,-Math.PI/2);break;case"dodecagon":ft(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,T=d-p/2,y=d+p/2;e.moveTo(m,s),e.lineTo(g,s),e.lineTo(g,T),e.lineTo(t+i,T),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,T),e.lineTo(m,T),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,T=t+i*(1-u);e.moveTo(t,d),e.lineTo(g,s),e.lineTo(g,s+m),e.lineTo(T,s+m),e.lineTo(T,s),e.lineTo(t+i,d),e.lineTo(T,s+r),e.lineTo(T,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,T=s+r*(1-u);e.moveTo(c,s),e.lineTo(t+i,g),e.lineTo(t+i-m,g),e.lineTo(t+i-m,T),e.lineTo(t+i,T),e.lineTo(c,s+r),e.lineTo(t,T),e.lineTo(t+m,T),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,T=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,T),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":{Qa(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 ft(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 Qa(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 gs=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0","#FF7F00","#9E480E"];function Za(e){const n=e?.textContent?.trim();if(n==null||n==="")return null;const t=parseFloat(n);return isNaN(t)?n:t}function Pt(e){if(!e)return[];const n=C(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]=Za(b(s,"v"))}return t}function Rt(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 hn(e){const n=b(e,"cat")||b(e,"xVal");return n?Pt(b(n,"strCache")||b(n,"numCache")):[]}function Lt(e){const n=b(e,"val")||b(e,"yVal");return n?Pt(b(n,"numCache")):[]}function ct(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]}`:gs[n%gs.length]}function oi(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 pn(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 Mt(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 Ie(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 dt(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 li(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 At(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=li(i-s);return i=Math.ceil(i/r)*r,s=Math.floor(s/r)*r,{min:s,max:i,step:r}}function ut(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 zt(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,Mt(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 Ja(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((_,j)=>({name:Rt(_),values:Lt(_),color:ct(_,j,a),dptColors:oi(_,a)}));if(!m.length)return;const g=hn(p[0])||[],T=Math.max(g.length,m[0]?.values.length||0,1),y=pn(t,s,i,r,{hasLegend:m.length>1});let w;h?(w=Array.from({length:T},(_,j)=>m.reduce((N,F)=>N+(F.values[j]||0),0)),u&&(w=w.map(()=>100))):w=m.flatMap(_=>_.values);const x=At(w),S=Math.max(7,Math.min(11,y.w*.018))*l;e.font=`${S}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 P=0;P<=v;P++){const A=x.min+P*x.step,E=(A-x.min)/(x.max-x.min),z=y.y+y.h-E*y.h;dt(e,y.x,z,y.x+y.w,z),e.fillText(u?A+"%":ut(A),y.x-4*l,z)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";const _=y.w/T;for(let P=0;P<T;P++){const A=y.x+_*P+_/2,E=String(g[P]??P+1);e.fillText(E,A,y.y+y.h+S*1.5)}e.restore(),Ie(e,y.x,y.y,y.x,y.y+y.h),Ie(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h);const j=y.w/T,N=j*.15,F=j-N*2,R=h?F:F/m.length;for(let P=0;P<T;P++){const A=y.x+j*P+N;let E=0;for(let z=0;z<m.length;z++){const Y=m[z];let O=Y.values[P]??0;if(u){const le=m.reduce((fe,ee)=>fe+(ee.values[P]||0),0);O=le?O/le*100:0}const W=Y.dptColors[P]||Y.color,B=Math.abs(O)/(x.max-x.min)*y.h,Z=h?A:A+z*R,Q=h?(E-x.min)/(x.max-x.min):Math.max(0,-x.min)/(x.max-x.min),I=y.y+y.h-Q*y.h,X=O>=0?I-B:I;e.save(),e.fillStyle=W,Mt(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&&(E+=Math.abs(O))}}}else{e.save(),e.textAlign="right",e.fillStyle="#666";const _=y.h/T;for(let P=0;P<T;P++){const A=y.y+_*P+_/2,E=String(g[P]??P+1);e.fillText(E,y.x-4*l,A)}e.restore(),e.save(),e.textAlign="center",e.fillStyle="#666";for(let P=0;P<=v;P++){const A=x.min+P*x.step,E=(A-x.min)/(x.max-x.min),z=y.x+E*y.w;dt(e,z,y.y,z,y.y+y.h),e.fillText(u?A+"%":ut(A),z,y.y+y.h+S*1.5)}e.restore(),Ie(e,y.x,y.y+y.h,y.x+y.w,y.y+y.h),Ie(e,y.x,y.y,y.x,y.y+y.h);const j=_*.15,N=_-j*2,F=h?N:N/m.length,R=y.x+-x.min/(x.max-x.min)*y.w;for(let P=0;P<T;P++){const A=y.y+_*P+j;let E=0;for(let z=0;z<m.length;z++){const Y=m[z];let O=Y.values[P]??0;if(u){const X=m.reduce((ae,le)=>ae+(le.values[P]||0),0);O=X?O/X*100:0}const W=Y.dptColors[P]||Y.color,B=Math.abs(O)/(x.max-x.min)*y.w,Z=h?A:A+z*F,Q=h?R+E/(x.max-x.min)*y.w:R,I=O>=0?Q:Q-B;e.save(),e.fillStyle=W,Mt(e,I,Z,B,h?N:F-1*l,2*l),e.fill(),e.restore(),h&&(E+=Math.abs(O))}}}m.length>1&&zt(e,t,s,i,y.legendY,m,l)}function eo(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:Rt(y),values:Lt(y),color:ct(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=hn(c[0])||[],u=Math.max(h.length,d[0]?.values.length||0,1),p=pn(t,s,i,r,{hasLegend:!0}),m=At(d.flatMap(y=>y.values)),g=Math.max(7,Math.min(11,p.w*.018))*l,T=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<=T;y++){const w=m.min+y*m.step,x=(w-m.min)/(m.max-m.min),S=p.y+p.h-x*p.h;dt(e,p.x,S,p.x+p.w,S),e.fillText(ut(w),p.x-4*l,S)}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;dt(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(),Ie(e,p.x,p.y,p.x,p.y+p.h),Ie(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((S,v)=>{const _=u>1?v/(u-1):.5,j=(S-m.min)/(m.max-m.min);return{x:p.x+_*p.w,y:p.y+p.h-j*p.h,v:S}}).filter(S=>typeof S.v=="number");if(w.length<2)continue;e.save(),e.beginPath(),e.moveTo(w[0].x,p.y+p.h);for(const S of w)e.lineTo(S.x,S.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 S=1;S<w.length-1;S++){const v=(w[S].x+w[S+1].x)/2,_=(w[S].y+w[S+1].y)/2;e.quadraticCurveTo(w[S].x,w[S].y,v,_)}e.lineTo(w[w.length-1].x,w[w.length-1].y)}else{e.moveTo(w[0].x,w[0].y);for(const S of w.slice(1))e.lineTo(S.x,S.y)}e.stroke(),e.restore();const x=3.5*l;for(const S of w)e.save(),e.fillStyle=y.color,e.strokeStyle="#fff",e.lineWidth=1.5*l,e.beginPath(),e.arc(S.x,S.y,x,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}zt(e,t,s,i,p.legendY,d,l)}function to(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,_)=>({name:Rt(v),values:Lt(v),color:ct(v,_,a)})).reverse();if(!p.length)return;const m=Math.max(...p.map(v=>v.values.length),1),g=pn(t,s,i,r,{hasLegend:!0});let T=0;if(d)T=100;else for(let v=0;v<m;v++){const _=p.reduce((j,N)=>j+(N.values[v]||0),0);T=Math.max(T,_)}const y={min:0,max:T||100,step:li(T||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 _=y.min+v*y.step,j=(_-y.min)/(y.max-y.min),N=g.y+g.h-j*g.h;dt(e,g.x,N,g.x+g.w,N),e.fillText(d?_+"%":ut(_),g.x-4*l,N)}e.restore(),Ie(e,g.x,g.y,g.x,g.y+g.h),Ie(e,g.x,g.y+g.h,g.x+g.w,g.y+g.h);const S=new Array(m).fill(0);for(const v of p){e.save(),e.beginPath();const _=[];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?S[j]:0,R=F+Math.abs(N),P=(F-y.min)/(y.max-y.min),A=(R-y.min)/(y.max-y.min),E=g.x+j/(m-1||1)*g.w;_.push({x:E,y:g.y+g.h-A*g.h,baseY:g.y+g.h-P*g.h}),h&&(S[j]+=Math.abs(N))}e.moveTo(_[0].x,_[0].baseY);for(const j of _)e.lineTo(j.x,j.baseY);for(let j=_.length-1;j>=0;j--)e.lineTo(_[j].x,_[j].y);e.closePath(),e.fillStyle=v.color+"cc",e.fill(),e.beginPath(),e.moveTo(_[0].x,_[0].y);for(const j of _.slice(1))e.lineTo(j.x,j.y);e.strokeStyle=v.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}zt(e,t,s,i,g.legendY,[...p].reverse(),l)}function bs(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=Lt(p).map(P=>typeof P=="number"&&P>0?P:0),g=hn(p),T=oi(p,a),y=m.reduce((P,A)=>P+A,0);if(!y)return;const w=Math.min(i,r)*.38,x=t+i*.44,S=s+r*.5,v=h?w*.55:0;let _=-Math.PI/2;for(let P=0;P<m.length;P++){if(!m[P])continue;const A=m[P]/y*Math.PI*2,E=T[P]||ct(p,P,a),z=_+A/2,Y=P===0?w*.04:0,O=Y*Math.cos(z),W=Y*Math.sin(z);e.save(),e.beginPath(),e.moveTo(x+O,S+W),e.arc(x+O,S+W,w,_,_+A),e.closePath(),e.fillStyle=E,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,S,v,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.restore());const B=m[P]/y;if(B>.05){const Z=x+O+w*.65*Math.cos(z),Q=S+W+w*.65*Math.sin(z),I=Math.max(8,Math.min(13,w*.15))*l;e.save(),e.fillStyle="#fff",e.font=`bold ${I}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(Math.round(B*100)+"%",Z,Q),e.restore()}_+=A}if(h){const P=Math.max(10,Math.min(16,w*.22))*l;e.save(),e.font=`bold ${P}px sans-serif`,e.fillStyle="#333",e.textAlign="center",e.textBaseline="middle",e.fillText(ut(y),x,S),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=S-m.length*F/2;for(let P=0;P<m.length;P++){const A=j,E=R+P*F,z=T[P]||ct(p,P,a);e.fillStyle=z,Mt(e,A,E-N*.5,N*1.2,N),e.fill(),e.fillStyle="#444";const Y=String(g[P]??`Item ${P+1}`);e.fillText(Y,A+N*1.5,E)}}function no(e,n,t,s,i,r,a,l){const o=b(n,"scatterChart")||b(n,"bubbleChart"),d=ge(o,"ser").map((_,j)=>{const N=Pt(b(b(_,"xVal"),"numCache")),F=Pt(b(b(_,"yVal"),"numCache")),R=Pt(b(b(_,"bubbleSize"),"numCache"));return{name:Rt(_),color:ct(_,j,a),points:N.map((P,A)=>({x:P,y:F[A],r:R[A]})).filter(P=>typeof P.x=="number"&&typeof P.y=="number")}});if(!d.length)return;const h=pn(t,s,i,r,{hasLegend:d.length>1}),u=d.flatMap(_=>_.points.map(j=>j.x)),p=d.flatMap(_=>_.points.map(j=>j.y)),m=At(u,!1),g=At(p),T=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=`${T}px sans-serif`,e.save(),e.textAlign="center",e.fillStyle="#666";for(let _=0;_<=y;_++){const j=m.min+_*m.step,N=(j-m.min)/(m.max-m.min),F=h.x+N*h.w;dt(e,F,h.y,F,h.y+h.h),e.fillText(ut(j),F,h.y+h.h+T*1.5)}e.textAlign="right";for(let _=0;_<=w;_++){const j=g.min+_*g.step,N=(j-g.min)/(g.max-g.min),F=h.y+h.h-N*h.h;dt(e,h.x,F,h.x+h.w,F),e.fillText(ut(j),h.x-4*l,F)}e.restore(),Ie(e,h.x,h.y,h.x,h.y+h.h),Ie(e,h.x,h.y+h.h,h.x+h.w,h.y+h.h);const x=d.flatMap(_=>_.points.map(j=>j.r??1)),S=Math.max(...x.filter(_=>typeof _=="number"),1),v=Math.min(h.w,h.h)*.06;for(const _ of d)for(const j of _.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/S*v:4*l;e.save(),e.fillStyle=_.color+"aa",e.strokeStyle=_.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&&zt(e,t,s,i,h.legendY,d,l)}function so(e,n,t,s,i,r,a,l){const o=b(n,"radarChart"),c=ge(o,"ser"),d=c.map((w,x)=>({name:Rt(w),values:Lt(w),color:ct(w,x,a)}));if(!d.length)return;const h=hn(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,T=At(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 S=0;S<u;S++){const v=S/u*Math.PI*2-Math.PI/2,_=p+x*Math.cos(v),j=m+x*Math.sin(v);S===0?e.moveTo(_,j):e.lineTo(_,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;Ie(e,p,m,p+g*Math.cos(x),m+g*Math.sin(x));const S=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),S,v),e.restore()}for(const w of d){const x=w.values.map((S,v)=>{const _=v/u*Math.PI*2-Math.PI/2,j=(S-T.min)/(T.max-T.min);return{x:p+g*j*Math.cos(_),y:m+g*j*Math.sin(_)}});e.save(),e.beginPath(),e.moveTo(x[0].x,x[0].y);for(const S of x.slice(1))e.lineTo(S.x,S.y);e.closePath(),e.fillStyle=w.color+"44",e.fill(),e.strokeStyle=w.color,e.lineWidth=1.5*l,e.stroke(),e.restore()}zt(e,t,s,i,s+r-20*l,d,l)}function io(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 ro(e,n,t,s,i,r,a,l){if(!n)return;const o=n;e.save(),e.fillStyle="#fff",Mt(e,t,s,i,r,4*l),e.fill(),e.strokeStyle="#ddd",e.lineWidth=.5,e.stroke(),e.restore();const d=io(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"),T=b(u,"pie3DChart")||b(u,"pieChart"),y=b(u,"doughnutChart"),w=b(u,"scatterChart")||b(u,"bubbleChart"),x=b(u,"radarChart");if(p)Ja(e,u,t,d,i,h,a,l);else if(m)eo(e,u,t,d,i,h,a,l);else if(g)to(e,u,t,d,i,h,a,l);else if(y)bs(e,u,t,d,i,h,a,l);else if(T)bs(e,u,t,d,i,h,a,l);else if(w)no(e,u,t,d,i,h,a,l);else if(x)so(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 S=u.firstElementChild;e.fillText(S?.localName??"Chart",t+i/2,s+r/2),e.restore()}}function an(e,n,t=0,s=1){return(e?parseInt(e.getAttribute(n)||t,10):t)*s}function ci(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 ao(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,an(c,"w",76200,a)),h=Math.max(2*a,an(c,"h",76200,a)),p=U(c,"prst","circle").toLowerCase().includes("in"),m=Math.min(d,i*.3),g=Math.min(h,r*.3),T=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,T),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 S=e.createLinearGradient(t,s,t+m,s);S.addColorStop(0,T),S.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=S,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 oo(e,n,t,s,i,r,a,l){const o=an(n,"extrusionH",0,l);if(o<1*l)return;const c=b(n,"extrusionClr")||b(n,"contourClr"),d=ci(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 lo(e,n,t,s,i,r,a,l){const o=an(n,"contourW",0,l);if(o<.5)return;const c=b(n,"contourClr"),d=ci(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 co(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 uo(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 fo(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&&oo(e,o,t,s,i,r,a,l);const d=co(e,c,s,i);return{overlay(){o&&(ao(e,o,s,i,r,a,l),lo(e,o,t,s,i,r,a,l)),c&&uo(e,c,s,i,r,a)},cleanup:d}}function ho(e){return e?!!(b(e,"sp3d")||b(e,"scene3d")):!1}async function $t(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),S=Se(x,l);return{pos:w,color:S}}).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 T;if(u||!u&&!p){const x=(C(u,"ang",0)/6e4-90)*Math.PI/180,S=Math.cos(x),v=Math.sin(x),_=Math.abs(i*S)+Math.abs(r*v),j=m-_/2*S,N=g-_/2*v,F=m+_/2*S,R=g+_/2*v;T=e.createLinearGradient(j,N,F,R)}else{const y=b(p,"fillToRect"),w=C(y,"l",5e4)/1e5,x=C(y,"t",5e4)/1e5,S=C(y,"r",5e4)/1e5,v=C(y,"b",5e4)/1e5,_=t+i*(w+(1-w-S)/2),j=s+r*(x+(1-x-v)/2),N=Math.sqrt(i*i+r*r)/2;T=e.createRadialGradient(_,j,0,m,g,N)}for(const y of h)y.color&&T.addColorStop(y.pos,xe(y.color));return e.fillStyle=T,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,T=s,y=i,w=r;if(m){const _=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*_,T=s+r*j,y=i-i*_-i*N,w=r-r*j-r*F}if(b(n,"tile")){const _=e.createPattern(u,"repeat");if(_)return e.fillStyle=_,e.fill(),!0}const S=b(n,"alphaModFix")||b(d,"alphaModFix"),v=S?C(S,"amt",1e5)/1e5:1;return e.save(),e.clip(),v<1&&(e.globalAlpha=v),e.drawImage(u,g,T,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),T=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,T){case"smGrid":case"dotGrid":case"dotDmnd":for(let v=0;v<x;v+=2)for(let _=0;_<x;_+=2)y.fillRect(v,_,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 _=0;_<x;_++)(v+_)%2===0&&y.fillRect(_,v,1,1);break;default:for(let v=0;v<x;v+=4)y.fillRect(v,v,2,2)}const S=e.createPattern(w,"repeat");return S?(e.fillStyle=S,e.fill(),!0):(e.fillStyle=xe(u,(u.a??1)*.4),e.fill(),!0)}return!1}async function Ke(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=Te(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 T=h.split("/");for(const y of T)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 Zt(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 di(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 po(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 mo(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)+")";case"alphaLcPeriod":return String.fromCharCode(96+n)+".";case"alphaUcPeriod":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}function go(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=mo(n.numType,i[c]);i[c]++,e.fillText(d,t,s)}e.restore()}async function on(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,T=C(d,"rIns",91440)*a,y=C(d,"bIns",45720)*a,w=t+m,x=s+g,S=i-m-T,v=r-g-y,_=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 P=b(n,"lstStyle"),A=P?b(P,"defRPr"):null;function E(Q,I,X,ae){const le=Q?Q.getAttribute(X):null;if(le!==null&&le!=="")return le;const fe=I?I.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 I=b(Q,"pPr"),X=U(I,"algn","l");C(I,"lvl",0);const ae=C(I,"marL",0)*a,le=C(I,"indent",0)*a,fe=I?po(I,H,l):null,ee=b(I,"spcBef"),V=b(I,"spcAft"),be=b(I,"lnSpc"),H=b(I,"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,G=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)*Ft*a/100)}if(V){const ne=b(V,"spcPct"),ie=b(V,"spcPts");ne?G=re*127*a*(C(ne,"val",0)/1e5):ie&&(G=C(ie,"val",0)*Ft*a/100)}const oe=[];for(const ne of Q.children){const ie=ne.localName;(ie==="r"||ie==="br"||ie==="fld")&&oe.push(ne)}if(oe.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:G,szPx:se,lnSpc:be,runs:[],emptyPara:!0,bullet:fe}),O+=ue+se*1.2+G;continue}let pe=[],he=[],D=0;for(const ne of oe){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=ai(ie,H,a*R,o,re,A);e.font=me.fontStr;const ce=me.szPx;ce>D&&(D=ce);const _e=Ya(ie,H,l),je=E(ie,H,"u","none")!=="none",L=E(ie,H,"strike","noStrike")!=="noStrike",q=parseInt(E(ie,H,"baseline","0"),10);if(_){const Ce=ve.split(" ");for(let We=0;We<Ce.length;We++){const Le=Ce[We];let nt=le+ae;for(const Bt of he)e.font=Bt.fontInfo.fontStr,nt+=e.measureText(Bt.text).width;e.font=me.fontStr;const st=e.measureText(Le).width,_n=he.length?e.measureText(" ").width:0;if(nt+_n+st>S&&he.length>0)pe.push({runs:he,maxSzPx:Math.max(D,ce)}),he=[{text:Le,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:L,baseline:q}],D=ce;else{if(he.length>0){const Bt={text:" ",rPr:ie,fontInfo:me,color:_e,underline:!1,strikethrough:!1,baseline:q};he.push(Bt)}he.push({text:Le,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:L,baseline:q})}}}else he.push({text:ve,rPr:ie,fontInfo:me,color:_e,underline:je,strikethrough:L,baseline:q}),ce>D&&(D=ce)}he.length>0&&pe.push({runs:he,maxSzPx:Math.max(D,re*127*a)});const te=be?di(be,re*127*a*R,a):null;Y.push({lines:pe,algn:X,marL:ae,indent:le,spaceBefore:ue,spaceAfter:G,lnSpcPx:te,emptyPara:!1,bullet:fe});for(const ne of pe)O+=ue+(te||ne.maxSzPx*1.2)+G}if(N&&!F&&O>v&&v>0){let Q=.3,I=1;for(let X=0;X<8;X++){const ae=(Q+I)/2;let le=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){le+=re*1.2;continue}const ue=H.reduce((te,ne)=>{const ie=b(ne,"t");return te+(ie?ie.textContent.length:0)},0),G=S>0?S:i,oe=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=oe.length>0?e.measureText(oe).width/oe.length:re*.6,he=Math.max(1,Math.floor(G/pe)),D=Math.max(1,Math.ceil(ue/he));le+=D*re*1.2}le<=v?Q=ae:I=ae}R=(Q+I)/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:I,algn:X,marL:ae,indent:le,spaceBefore:fe,spaceAfter:ee,lnSpcPx:V,emptyPara:be,bullet:H}=Q;if(B+=fe,be){B+=I[0]?V||Q.szPx*1.2:12*a,B+=ee;continue}for(const re of I){const{runs:ue,maxSzPx:G}=re,oe=V||G*1.2,pe=B+G*.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+(S-he)/2:X==="r"&&(D=w+S-he);const te=re===I[0];if(H&&te){const se=w+ae+le;go(e,H,se,pe,Z)}let ne=0;if(X==="just"&&!(re===I[I.length-1])){let ve=0;for(const ce of ue)e.font=ce.fontInfo.fontStr,ve+=(ce.text.match(/ /g)||[]).length;const me=S-ae-he;ve>0&&me>0&&(ne=me/ve)}const ie=(se,ve,me,ce,_e,je)=>{e.font=ce.fontStr;const L=e.measureText(se).width;e.fillText(se,ve,me);const q=Math.max(.5,ce.szPx*.07);return _e&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=q,e.beginPath(),e.moveTo(ve,me+q*1.5),e.lineTo(ve+L,me+q*1.5),e.stroke(),e.restore()),je&&(e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=q,e.beginPath(),e.moveTo(ve,me-ce.szPx*.3),e.lineTo(ve+L,me-ce.szPx*.3),e.stroke(),e.restore()),L};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 L=ie(_e[je],D,me,ce,se.underline,se.strikethrough);D+=L,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+=oe}B+=ee}j&&e.restore()}function ui(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),T=Se(g,t),y=T?xe(T):"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 mn(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,T=!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,T=U(d,"flipH","0")==="1",y=U(d,"flipV","0")==="1"}else{const W=mi(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,I=B.cx/Q.cx,X=B.cy/Q.cy;h=W.x+(h/a-Z.x)*I*a,u=W.y+(u/a-Z.y)*X*a,p=p*I,m=m*X}const w=h+p/2,x=u+m/2;e.save(),(g!==0||T||y)&&(e.translate(w,x),g!==0&&e.rotate(g*Math.PI/180),T&&e.scale(-1,1),y&&e.scale(1,-1),e.translate(-w,-x));const S=b(c,"prstGeom"),v=b(c,"custGeom"),_=S?U(S,"prst","rect"):"rect",j={};if(S){const W=b(S,"avLst");if(W){let B=0;for(const Z of ge(W,"gd")){const I=U(Z,"fmla","").match(/val\s+(-?\d+)/);I&&(j[B]=parseInt(I[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 Te("<noFill/>").documentElement;const I=ke(Z);if(I)return Te('<solidFill xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'">'+I.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 I=ke(Z);if(I)return Te('<ln xmlns="'+"http://schemas.openxmlformats.org/drawingml/2006/main"+'"><solidFill>'+I.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,I=C(Z,"h",1)||1,X=p/Q,ae=m/I;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,G=e._lastY||u,oe=ue-V*Math.cos(H),pe=G-be*Math.sin(H);V===be?e.arc(oe,pe,V,H,H+re,re<0):e.ellipse(oe,pe,V,be,0,H,H+re,re<0);break}case"close":e.closePath();break}const le=N();le&&await $t(e,le,h,u,p,m,a,i,s);const fe=F();fe&&yt(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=$n(n);await on(e,B,h,u,p,m,a,i,r,Z),e.restore()}return}e.beginPath(),rn(e,_,h,u,p,m,j);const R=ui(e,c,i,a),P=h,A=u,E=p,z=m,Y=ho(c)?fo(e,c,i,P,A,E,z,a):null;try{const W=N();let B=!1;W&&(B=await $t(e,W,h,u,p,m,a,i,s)),Y&&Y.overlay();const Z=F();Z?yt(e,Z,i,a):B||(_==="line"||_==="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||T||y)&&(e.translate(w,x),g!==0&&e.rotate(g*Math.PI/180),T&&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=$n(n);await on(e,O,h,u,p,m,a,i,r,W),e.restore()}}function $n(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 yt(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 gn(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",T=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,S=d+u/2,v=h+p/2;if(e.save(),(m!==0||g||T)&&(e.translate(S,v),m!==0&&e.rotate(m*Math.PI/180),g&&e.scale(-1,1),T&&e.scale(1,-1),e.translate(-S,-v)),x&&s[x]){const _=s[x],j=b(a,"prstGeom"),N=j?U(j,"prst","rect"):"rect",F={};if(j){const A=b(j,"avLst");if(A){let E=0;for(const z of ge(A,"gd")){const Y=(U(z,"fmla","")||"").match(/val\s+(-?\d+)/);Y&&(F[E]=parseInt(Y[1])),E++}}}e.beginPath(),rn(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,E=C(R,"t",0)/1e5,z=C(R,"r",0)/1e5,Y=C(R,"b",0)/1e5,O=_.naturalWidth*(1-A-z),W=_.naturalHeight*(1-E-Y);e.drawImage(_,_.naturalWidth*A,_.naturalHeight*E,O,W,d,h,u,p)}else e.drawImage(_,d,h,u,p);const P=b(a,"ln");P&&(e.beginPath(),rn(e,N,d,h,u,p,F),yt(e,P,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 fi(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,T=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 S=c;for(let v=0;v<x.length;v++){const _=x[v],j=C(_,"h",457200)*i,N=ge(_,"tc");let F=o;const R=v===0,P=v===x.length-1,A=v%2===1;for(let E=0;E<N.length;E++){const z=N[E],Y=C(z,"gridSpan",1);U(z,"vMerge","0");let O=0;for(let I=0;I<Y;I++)O+=w[E+I]||0;const W=b(z,"tcPr"),B=W?["noFill","solidFill","gradFill","blipFill","pattFill"].map(I=>b(W,I)).find(Boolean):null;if(e.save(),e.beginPath(),e.rect(F,S,O,j),B)await $t(e,B,F,S,O,j,i,t,null);else{let I=null;g&&R?I=t.accent1?"#"+t.accent1.toLowerCase():"#4472C4":T&&P?I="#e0e0e0":m&&A&&(I="rgba(0,0,0,0.06)"),e.fillStyle=I||"transparent",I&&e.fill()}const Z=[{el:b(W,"lnL"),x1:F,y1:S,x2:F,y2:S+j},{el:b(W,"lnR"),x1:F+O,y1:S,x2:F+O,y2:S+j},{el:b(W,"lnT"),x1:F,y1:S,x2:F+O,y2:S},{el:b(W,"lnB"),x1:F,y1:S+j,x2:F+O,y2:S+j}];for(const I of Z)I.el?b(I.el,"noFill")||(e.beginPath(),e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),yt(e,I.el,t,i)):(e.beginPath(),e.strokeStyle="#cccccc",e.lineWidth=.5,e.moveTo(I.x1,I.y1),e.lineTo(I.x2,I.y2),e.stroke());e.restore();const Q=b(z,"txBody");Q&&(e.save(),e.beginPath(),e.rect(F,S,O,j),e.clip(),await on(e,Q,F,S,O,j,i,t,s,1400),e.restore()),F+=O}S+=j}}async function bn(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",T={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=T.grpOff.x+T.grpExt.cx/2,w=T.grpOff.y+T.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 S=x.localName;S==="sp"?await mn(e,x,t,s,i,r,a,T):S==="pic"?await gn(e,x,t,s,i,a):S==="grpSp"?await bn(e,x,t,s,i,r,a):S==="graphicFrame"?await vn(e,x,i,r,a,files,t):S==="cxnSp"&&await yn(e,x,i,a)}e.restore()}function vs(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 T=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)),T||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(),T?e.stroke():e.fill();break}case"diamond":{const T=m/2;e.beginPath(),e.moveTo(s,i),e.lineTo(s+T*Math.cos(g)+p/2*Math.sin(g),i+T*Math.sin(g)-p/2*Math.cos(g)),e.lineTo(s+m*Math.cos(g),i+m*Math.sin(g)),e.lineTo(s+T*Math.cos(g)-p/2*Math.sin(g),i+T*Math.sin(g)+p/2*Math.cos(g)),e.closePath(),e.fill();break}case"oval":{const T=m/2,y=p/2,w=s+T*Math.cos(g),x=i+T*Math.sin(g);e.beginPath(),e.save(),e.translate(w,x),e.rotate(g),e.scale(1,y/T),e.arc(0,0,T,0,Math.PI*2),e.restore(),e.fill();break}}e.restore()}async function yn(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,T=c+h/2,y=b(i,"ln");e.save(),(u!==0||p||m)&&(e.translate(g,T),u!==0&&e.rotate(u*Math.PI/180),p&&e.scale(-1,1),m&&e.scale(1,-1),e.translate(-g,-T));const w=b(i,"prstGeom"),x=w?U(w,"prst","line"):"line",S=x==="line"||x==="straightConnector1";if(e.beginPath(),S){const v=p?o:o+d,_=m?c:c+h,j=p?o+d:o,N=m?c+h:c;e.moveTo(j,N),e.lineTo(v,_)}else rn(e,x,o,c,d,h,{});if(y){if(yt(e,y,t,s),S){const v=p?o+d:o,_=m?c+h:c,j=p?o:o+d,N=m?c:c+h;vs(e,y,"headEnd",j,N,v,_,t,s),vs(e,y,"tailEnd",v,_,j,N,t,s)}}else e.strokeStyle="#000",e.lineWidth=1,e.stroke();e.restore()}async function hi(e,n,t,s,i,r,a,l,o,c,d){const h=c*o,u=d*o,p=x=>{const S=b(x,"cSld");if(!S)return null;const v=b(S,"bg");if(!v)return null;const _=b(v,"bgPr"),j=b(v,"bgRef");return{bgPr:_,bgRef:j}},m=n?p(n):null,g=s?p(s):null,T=t?p(t):null,y=m||g||T;let w=!1;if(y){const{bgPr:x,bgRef:S}=y;if(x){const v=["noFill","solidFill","gradFill","blipFill","pattFill"];for(const _ of v){const j=b(x,_);if(j){e.beginPath(),e.rect(0,0,h,u);const N=y===T?Object.assign({},a):a;await $t(e,j,0,0,h,u,1,l,N)&&(w=!0);break}}}else if(S){C(S,"idx",0);const v=ke(S),_=Se(v,l);_&&(e.fillStyle=xe(_),e.fillRect(0,0,h,u),w=!0)}}w||(e.fillStyle="#ffffff",e.fillRect(0,0,h,u))}function pi(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 mi(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 vn(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 fi(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,T=C(u,"cy",0)*i;if(g<=0||T<=0)return;const y=c.includes("chart"),w=c.includes("diagram");if(y&&r&&a){const S=o?b(o,"chart"):null,v=S?S.getAttribute("r:id")||S.getAttribute("id"):null,_=v?a[v]:null;if(_&&r[_.fullPath]){const j=new TextDecoder().decode(r[_.fullPath]),N=Te(j);ro(e,N,p,m,g,T,t,i);return}}if(w&&r&&a){const S=o?b(o,"relIds"):null,v=S?S.getAttribute("r:dm")||S.getAttribute("dm"):null,_=v?a[v]:null;if(_&&r[_.fullPath]){const j=new TextDecoder().decode(r[_.fullPath]),N=Te(j),F=S?S.getAttribute("r:lo")||S.getAttribute("lo"):null,R=F?a[F]:null,P=R&&r[R.fullPath]?Te(new TextDecoder().decode(r[R.fullPath])):null,{renderSmartArt:A}=await dn(async()=>{const{renderSmartArt:E}=await import("./smartart-DHG8mviv.js");return{renderSmartArt:E}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url);A(e,N,P,p,m,g,T,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,T),e.strokeRect(p,m,g,T),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+T/2),e.textAlign="start",e.textBaseline="alphabetic",e.restore()}async function gi(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 mn(e,c,t,s,i,r,a,null,l):d==="pic"?await gn(e,c,t,s,i,a):d==="grpSp"?await bn(e,c,t,s,i,r,a):d==="graphicFrame"?await vn(e,c,i,r,a,o,t):d==="cxnSp"&&await yn(e,c,i,a)}catch(h){console.warn("Error rendering shape:",d,h)}}}const bo=Object.freeze(Object.defineProperty({__proto__:null,applyEffects:ui,applyFill:$t,applyOutline:yt,buildPlaceholderMap:pi,computeLineHeight:di,getDefaultFontSize:$n,getRels:Ke,loadImages:Zt,renderBackground:hi,renderConnector:yn,renderGraphicFrame:vn,renderGroupShape:bn,renderPicture:gn,renderShape:mn,renderSpTree:gi,renderTable:fi,renderTextBody:on,resolvePlaceholderXfrm:mi},Symbol.toStringTag,{value:"Module"}));async function yo(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 vo=(()=>{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 wo(e){let n=4294967295;for(let t=0;t<e.length;t++)n=vo[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}class xo{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 Be(e){return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}const bi=new TextEncoder;function ko(e){return bi.encode(e)}const ws=18977,xs=0;class _o{constructor(){this._entries=[]}async addText(n,t){return this.addBytes(n,bi.encode(t))}async addBytes(n,t,s=!0){const i=ko(n),r=wo(t),a=t.length;let l,o;if(s&&t.length>32){const c=await yo(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 xo;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(xs)),n.append(we(ws)),n.append(Be(i.crc)),n.append(Be(i.compData.length)),n.append(Be(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(xs)),n.append(we(ws)),n.append(Be(i.crc)),n.append(Be(i.compData.length)),n.append(Be(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(Be(0)),n.append(Be(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(Be(s)),n.append(Be(t)),n.append(we(0)),n.concat()}}async function So(e){const n=new _o;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 To=new TextDecoder,yi=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 jt(e){return new DOMParser().parseFromString(e,"application/xml")}function Po(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 yi.encode(Po(e))}function Ge(e,n){const t=e[n];return t?jt(To.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 qe(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 jo(e,n,t=null){if(!e)return t;const s=e.getAttribute(n);return s!==null?s:t}function at(e){const n=e.split("/"),t=n.pop();return[...n,"_rels",t+".rels"].join("/")}function rt(e,n){const t=Ge(e,at(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 Wt(e){const n=jt('<?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 Gt(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 Jt(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=Jt(t,n);if(i)return i}}return null}function ht(e){const n=de(e,"cSld");return n?de(n,"spTree"):null}function qt(e,n,t,s=!0){for(const i of qe(e,"t")){const r=i.textContent;if(!r)continue;const a=s?r.split(n).join(t):r.replace(new RegExp(Co(n),"gi"),t);a!==r&&(i.textContent=a)}}function Co(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const ks={"image/jpeg":"jpeg","image/jpg":"jpeg","image/png":"png","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"},Fo={jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml"};function _s(e,n,t){const s="[Content_Types].xml",i=Ge(e,s);if(!i)return;const r=i.documentElement;for(const l of qe(i,"Override"))if(l.getAttribute("PartName")==="/"+t)return;const a=i.createElementNS(Fe.ct,"Override");a.setAttribute("PartName","/"+t),a.setAttribute("ContentType",Fo[n]||"application/octet-stream"),r.appendChild(a),e[s]=Re(i)}class ln{constructor(n){this._files=n,this._presPath="ppt/presentation.xml",this._presDoc=Ge(n,this._presPath),this._presRels=rt(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 ln(t)}static async fromBytes(n){const t=await ii(n);return new ln(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[at(this._presPath)]=Re(Wt(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 Ge(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;qt(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=rt(this._files,this._slidePaths[n]),a=Object.values(r).find(o=>o.type?.includes("notesSlide"));if(!a)return;const l=Ge(this._files,a.fullPath);if(l){for(const[o,c]of Object.entries(t))qt(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(qt(c,n,t,i),this._saveSlideDoc(o,c),r){const d=rt(this._files,this._slidePaths[o]),h=Object.values(d).find(u=>u.type?.includes("notesSlide"));if(h){const u=Ge(this._files,h.fullPath);u&&(qt(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=ht(a);if(!l)return this;const o=Jt(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 qe(c,"p"))g.parentNode.removeChild(g);const p=s.split(`
|
|
31
31
|
`),m=Fe.a;for(const g of p){const T=a.createElementNS(m,"a:p");u&&r&&T.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),T.appendChild(y),c.appendChild(T)}return this._saveSlideDoc(n,a),this}getShapeText(n,t){const s=this._slideDoc(n),i=ht(s);if(!i)return"";const r=Jt(i,t);return r?qe(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=ht(p);if(!m)return this;const T=Math.max(0,...qe(m,"cNvPr").map(_=>parseInt(_.getAttribute("id")||"0",10)))+1,y=`TextBox ${T}`,w=Fe.a,S=`<p:sp xmlns:p="${Fe.p}" xmlns:a="${w}">
|
|
32
32
|
<p:nvSpPr>
|
|
33
33
|
<p:cNvPr id="${T}" name="${y}"/>
|
|
@@ -69,7 +69,7 @@ ${_a(e)}`};if(Z.length>0&&(be.images=Z),Q.length>0&&(be.files=Q),O&&(be.mode="st
|
|
|
69
69
|
</p:spPr>
|
|
70
70
|
</p:pic>`,v=jt(S);return g.appendChild(m.adoptNode(v.documentElement)),this._saveSlideDoc(n,m),_s(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
71
|
<p:bgPr><a:solidFill><a:srgbClr val="${t}"/></a:solidFill>
|
|
72
|
-
<a:effectLst/></p:bgPr></p:bg>`,c=s.adoptNode(jt(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=rt(this._files,l.fullPath);i=Object.values(o).find(c=>c.type?.includes("theme"))?.fullPath}}if(!i)return this;const r=Ge(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=at(l);this._files[l]=this._files[i].slice();const c=at(i);this._files[c]&&(this._files[o]=this._files[c].slice());const d=Gt(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=qe(u,"sldId").map(S=>parseInt(S.getAttribute("id")||"0",10)),T=(g.length?Math.max(...g):255)+1,y=Fe.p,w=this._presDoc.createElementNS(y,"p:sldId");w.setAttribute("id",String(T)),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=Ge(this._files,p);if(m){const g=m.documentElement,T=m.createElementNS(Fe.ct,"Override");T.setAttribute("PartName","/"+l),T.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),g.appendChild(T),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=rt(this._files,s),r=Object.values(i).find(a=>a.type?.includes("notesSlide"));if(r){const a=Ge(this._files,r.fullPath);if(a){for(const l of qe(a,"sp")){const o=de(de(l,"nvSpPr"),"nvPr"),c=o?de(o,"ph"):null;if(c&&
|
|
72
|
+
<a:effectLst/></p:bgPr></p:bg>`,c=s.adoptNode(jt(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=rt(this._files,l.fullPath);i=Object.values(o).find(c=>c.type?.includes("theme"))?.fullPath}}if(!i)return this;const r=Ge(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=at(l);this._files[l]=this._files[i].slice();const c=at(i);this._files[c]&&(this._files[o]=this._files[c].slice());const d=Gt(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=qe(u,"sldId").map(S=>parseInt(S.getAttribute("id")||"0",10)),T=(g.length?Math.max(...g):255)+1,y=Fe.p,w=this._presDoc.createElementNS(y,"p:sldId");w.setAttribute("id",String(T)),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=Ge(this._files,p);if(m){const g=m.documentElement,T=m.createElementNS(Fe.ct,"Override");T.setAttribute("PartName","/"+l),T.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.presentationml.slide+xml"),g.appendChild(T),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=rt(this._files,s),r=Object.values(i).find(a=>a.type?.includes("notesSlide"));if(r){const a=Ge(this._files,r.fullPath);if(a){for(const l of qe(a,"sp")){const o=de(de(l,"nvSpPr"),"nvPr"),c=o?de(o,"ph"):null;if(c&&jo(c,"type")!=="sldNum"){for(const h of qe(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
73
|
<p:notes xmlns:p="${a}" xmlns:a="${l}">
|
|
74
74
|
<p:cSld><p:spTree>
|
|
75
75
|
<p:sp>
|
|
@@ -83,7 +83,7 @@ ${_a(e)}`};if(Z.length>0&&(be.images=Z),Q.length>0&&(be.files=Q),O&&(be.mode="st
|
|
|
83
83
|
</p:txBody>
|
|
84
84
|
</p:sp>
|
|
85
85
|
</p:spTree></p:cSld>
|
|
86
|
-
</p:notes>`;this._files[o]=yi.encode(c);const d=Gt(s);s[d]={id:d,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",target:`../notesSlides/notesSlide${r}.xml`,fullPath:o},this._files[at(t)]=Re(Wt(s))}async save(){return
|
|
86
|
+
</p:notes>`;this._files[o]=yi.encode(c);const d=Gt(s);s[d]={id:d,type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",target:`../notesSlides/notesSlide${r}.xml`,fullPath:o},this._files[at(t)]=Re(Wt(s))}async save(){return So(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=ht(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 vi=new TextEncoder;function No(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}class Mo{constructor(){this._parts=[],this._size=0}write(n){const t=typeof n=="string"?vi.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 Ao(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 $o(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 Eo(e,n){const t=e/914400*72,s=n/914400*72;return{w:t,h:s}}class Ro{constructor(){this._buf=new Mo,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
87
|
`),s){const r=s.length;this._buf.write(`${t.replace("__LEN__",r)}
|
|
88
88
|
`),this._buf.write(`stream\r
|
|
89
89
|
`),this._buf.write(s),this._buf.write(`\r
|
|
@@ -91,10 +91,10 @@ endstream
|
|
|
91
91
|
`)}else this._buf.write(`${t}
|
|
92
92
|
`);return this._buf.write(`endobj
|
|
93
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,_)=>_),o=l.length,{cx:c,cy:d}=n.slideSize,{w:h,h:u}
|
|
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,_)=>_),o=l.length,{cx:c,cy:d}=n.slideSize,{w:h,h:u}=Eo(c,d);this._buf.write(`%PDF-1.4
|
|
95
95
|
`),this._buf.write(`%ÿþýü
|
|
96
96
|
|
|
97
|
-
`);const p=this._nextObj(),m=this._nextObj(),g=Array.from({length:o},()=>this._nextObj()),T=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 _=l[v];a?.(v,o);const j=await
|
|
97
|
+
`);const p=this._nextObj(),m=this._nextObj(),g=Array.from({length:o},()=>this._nextObj()),T=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 _=l[v];a?.(v,o);const j=await $o(n,_,s),N=await Ao(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} ${T[v]} 0 R >> >> /Contents ${y[v]} 0 R >>`),this._writeObj(T[v],`<< /Type /XObject /Subtype /Image /Width ${F} /Height ${R} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length __LEN__ >>`,N);const P=`q ${h.toFixed(3)} 0 0 ${u.toFixed(3)} 0 0 cm /Im${v} Do Q`;this._writeObj(y[v],"<< /Length __LEN__ >>",vi.encode(P))}a?.(o,o);const x=this._buf.size,S=this._objNum+1;this._buf.write(`xref
|
|
98
98
|
0 ${S}
|
|
99
99
|
`),this._buf.write(`0000000000 65535 f \r
|
|
100
100
|
`);for(let v=1;v<S;v++){const _=this._xref[v]??0;this._buf.write(String(_).padStart(10,"0")+` 00000 n \r
|
|
@@ -103,23 +103,23 @@ endstream
|
|
|
103
103
|
`),this._buf.write(`startxref
|
|
104
104
|
${x}
|
|
105
105
|
%%EOF
|
|
106
|
-
`),this._buf.concat()}}async function Yn(e,n={}){const{width:t=null,dpi:s=150,quality:i=.92,slides:r=null,onProgress:a=null}=n,l=t??Fo(e,s);return new Eo().build(e,{widthPx:l,quality:i,slideList:r,onProgress:a})}async function Ro(e,n="presentation.pdf",t={}){const s=await Yn(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 Lo(e,n,t={}){return Yn(n,{...t,slides:[e]})}const zo=500;function Qn(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=Ss(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=Ss(a,0,0);l&&s.push(l)}return s.sort((a,l)=>a.clickNum-l.clickNum||a.delay-l.delay)}function Ss(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):zo,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 Zn(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 Io(e){return 1-Math.pow(1-e,2)}function Do(e){return e*e}function Bo(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}function wi(e,n,t,s){const i=Math.max(0,Math.min(1,n)),r=e.type==="entrance",a=r?Io(i):Do(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 wi(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 xi(e,n,t,s,i){const r=Bo(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 ki{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 dn(async()=>{const{parseXml:o}=await Promise.resolve().then(()=>Ea);return{parseXml:o}},void 0,import.meta.url).catch(()=>({parseXml:o=>new DOMParser().parseFromString(o,"application/xml")})),a=r(i);this._steps=Qn(a),this._transition=Zn(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=wi(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);xi(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 Oo=Object.freeze(Object.defineProperty({__proto__:null,PptxPlayer:ki,parseAnimations:Qn,parseTransition:Zn,renderTransitionFrame:xi},Symbol.toStringTag,{value:"Module"}));let Uo=0;function wn(e="el"){return`${e}${++Uo}`}function Ae(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function M(e){return`${+e.toFixed(3)}`}function En(e){return e?xe(e):"none"}function _i(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=En(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,T=ke(m),y=Se(T,t);return{pos:g,color:En(y),opacity:y?.a!=null?y.a/255:1}}):[],d=b(e,"lin"),h=b(e,"path"),u=wn("grad");let p;if(h){const m=b(h,"fillToRect"),g=C(m,"l",5e4)/1e5,T=C(m,"t",5e4)/1e5,y=s+r*g,w=i+a*T,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 S of c)p+=`<stop offset="${M(S.pos)}" stop-color="${Ae(S.color)}"${S.opacity<1?` stop-opacity="${M(S.opacity)}"`:""}/>`;p+="</radialGradient>"}else{const g=(C(d,"ang",0)/6e4-90)*(Math.PI/180),T=Math.cos(g),y=Math.sin(g),w=Math.sqrt(r*r+a*a)/2,x=s+r/2,S=i+a/2;p=`<linearGradient id="${u}" x1="${M(x-T*w)}" y1="${M(S-y*w)}" x2="${M(x+T*w)}" y2="${M(S+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 Si(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=En(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 Ti(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=wn("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 Wo(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),T=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,S=w>0?1:0;a.length===0&&a.push(`M${M(m)},${M(g)}`),a.push(`A${M(d)},${M(d)},0,${x},${S},${M(T)},${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 Go=null;function xn(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 qo(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,T=t+p,y=1800,w=b(e,"lstStyle"),x=w?b(w,"defRPr"):null,S=ge(e,"p");let v="",_=T;const j=wn("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 S){const P=b(R,"pPr"),A=U(P,"algn","l"),E=C(P,"marL",0)/914400*96,z=C(P,"indent",0)/914400*96,Y=b(P,"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(P,"spcBef"),B=b(P,"spcAft");b(P,"lnSpc");let Z=0,Q=0;if(W){const D=b(W,"spcPct"),te=b(W,"spcPts");D?Z=O*Ft/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*Ft/914400*96*(C(D,"val",0)/1e5):te&&(Q=C(te,"val",0)/100/72*96)}const I=P?b(P,"buChar"):null,X=P?b(P,"buAutoNum"):null,le=!(P?b(P,"buNone"):null)&&(I||X);_+=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;_+=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=ai(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",L=te?(te.getAttribute("u")||"none")!=="none":!1,q=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:L,strike:q,baseline:Ce})}if(!V.length){_+=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=_+H*.85;let G="start",oe=m+E;A==="ctr"?(G="middle",oe=m+g/2):A==="r"&&(G="end",oe=m+g);let pe="";if(le){const D=m+E+z;let te="";if(I)te=Ae(I.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(
|
|
106
|
+
`),this._buf.concat()}}async function Yn(e,n={}){const{width:t=null,dpi:s=150,quality:i=.92,slides:r=null,onProgress:a=null}=n,l=t??No(e,s);return new Ro().build(e,{widthPx:l,quality:i,slideList:r,onProgress:a})}async function Lo(e,n="presentation.pdf",t={}){const s=await Yn(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 zo(e,n,t={}){return Yn(n,{...t,slides:[e]})}const Io=500;function Qn(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=Ss(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=Ss(a,0,0);l&&s.push(l)}return s.sort((a,l)=>a.clickNum-l.clickNum||a.delay-l.delay)}function Ss(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):Io,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 Zn(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 Do(e){return 1-Math.pow(1-e,2)}function Bo(e){return e*e}function Oo(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}function wi(e,n,t,s){const i=Math.max(0,Math.min(1,n)),r=e.type==="entrance",a=r?Do(i):Bo(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 wi(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 xi(e,n,t,s,i){const r=Oo(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 ki{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 dn(async()=>{const{parseXml:o}=await Promise.resolve().then(()=>Ra);return{parseXml:o}},void 0,import.meta.url).catch(()=>({parseXml:o=>new DOMParser().parseFromString(o,"application/xml")})),a=r(i);this._steps=Qn(a),this._transition=Zn(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=wi(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);xi(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 Uo=Object.freeze(Object.defineProperty({__proto__:null,PptxPlayer:ki,parseAnimations:Qn,parseTransition:Zn,renderTransitionFrame:xi},Symbol.toStringTag,{value:"Module"}));let Wo=0;function wn(e="el"){return`${e}${++Wo}`}function Ae(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function M(e){return`${+e.toFixed(3)}`}function En(e){return e?xe(e):"none"}function _i(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=En(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,T=ke(m),y=Se(T,t);return{pos:g,color:En(y),opacity:y?.a!=null?y.a/255:1}}):[],d=b(e,"lin"),h=b(e,"path"),u=wn("grad");let p;if(h){const m=b(h,"fillToRect"),g=C(m,"l",5e4)/1e5,T=C(m,"t",5e4)/1e5,y=s+r*g,w=i+a*T,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 S of c)p+=`<stop offset="${M(S.pos)}" stop-color="${Ae(S.color)}"${S.opacity<1?` stop-opacity="${M(S.opacity)}"`:""}/>`;p+="</radialGradient>"}else{const g=(C(d,"ang",0)/6e4-90)*(Math.PI/180),T=Math.cos(g),y=Math.sin(g),w=Math.sqrt(r*r+a*a)/2,x=s+r/2,S=i+a/2;p=`<linearGradient id="${u}" x1="${M(x-T*w)}" y1="${M(S-y*w)}" x2="${M(x+T*w)}" y2="${M(S+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 Si(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=En(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 Ti(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=wn("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 Go(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),T=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,S=w>0?1:0;a.length===0&&a.push(`M${M(m)},${M(g)}`),a.push(`A${M(d)},${M(d)},0,${x},${S},${M(T)},${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 qo=null;function xn(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 Ko(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,T=t+p,y=1800,w=b(e,"lstStyle"),x=w?b(w,"defRPr"):null,S=ge(e,"p");let v="",_=T;const j=wn("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 S){const P=b(R,"pPr"),A=U(P,"algn","l"),E=C(P,"marL",0)/914400*96,z=C(P,"indent",0)/914400*96,Y=b(P,"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(P,"spcBef"),B=b(P,"spcAft");b(P,"lnSpc");let Z=0,Q=0;if(W){const D=b(W,"spcPct"),te=b(W,"spcPts");D?Z=O*Ft/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*Ft/914400*96*(C(D,"val",0)/1e5):te&&(Q=C(te,"val",0)/100/72*96)}const I=P?b(P,"buChar"):null,X=P?b(P,"buAutoNum"):null,le=!(P?b(P,"buNone"):null)&&(I||X);_+=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;_+=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=ai(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",L=te?(te.getAttribute("u")||"none")!=="none":!1,q=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:L,strike:q,baseline:Ce})}if(!V.length){_+=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=_+H*.85;let G="start",oe=m+E;A==="ctr"?(G="middle",oe=m+g/2):A==="r"&&(G="end",oe=m+g);let pe="";if(le){const D=m+E+z;let te="";if(I)te=Ae(I.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(Xo(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){_+=re,he+=`<tspan x="${M(oe)}" 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(oe)}" y="${M(ue)}" text-anchor="${G}">${he}</text>`,_+=re+Q}return`<g clip-path="url(#${j})"${N}>${v}</g>`}function Xo(e,n){switch(e){case"arabicPeriod":return n+".";case"arabicParenR":return n+")";case"arabicParenBoth":return"("+n+")";case"romanLcPeriod":return Ts(n).toLowerCase()+".";case"romanUcPeriod":return Ts(n)+".";case"alphaLcParenR":return String.fromCharCode(96+n)+")";case"alphaUcParenR":return String.fromCharCode(64+n)+")";default:return n+"."}}function Ts(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 en(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 Vo(l,s,i,r):o==="pic"?a+=await Ho(l,n,t,s,r):o==="cxnSp"?a+=await Yo(l,s):o==="grpSp"?a+=await Qo(l,n,t,s,i,r):o==="graphicFrame"&&(a+=await Zo(l))}return a}async function Vo(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 _ of d){const j=b(i,_);if(j){h=j;break}}if(!h){const _=b(e,"style"),j=_?b(_,"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}=_i(h,s,n,a.x,a.y,a.w,a.h);let m=b(i,"ln");if(!m){const _=b(e,"style"),j=_?b(_,"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=Si(m,n),T=b(i,"effectLst"),y=Ti(T,s),w=xn(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 _=Go(o,a.x,a.y,a.w,a.h,{});x=`<path d="${Ae(_)}" fill="${Ae(u)}"${p}${g}${y}${w}/>`}const S=b(e,"txBody"),v=S?Ko(S,a.x,a.y,a.w,a.h,n,t,s):"";return`<g>${x}${v}</g>`}async function Ho(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=xn(a),m=b(r,"effectLst"),g=Ti(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 T=h.fullPath.split(".").pop().toLowerCase(),y=T==="png"?"image/png":T==="gif"?"image/gif":T==="svg"?"image/svg+xml":"image/jpeg",w=u instanceof Uint8Array?u:new Uint8Array(u),x=btoa(Array.from(w,v=>String.fromCharCode(v)).join("")),S=wn("pic");return i.push(`<clipPath id="${S}"><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(#${S})"${g}${p} preserveAspectRatio="xMidYMid slice"/>`}async function Yo(e,n,t){const s=b(e,"spPr"),i=b(s,"xfrm"),r=It(i);if(!r)return"";const a=b(s,"ln"),l=Si(a,n),o=xn(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 Qo(e,n,t,s,i,r){const a=b(e,"grpSpPr"),l=b(a,"xfrm");It(l);const o=l?xn(l):"",c=await en(e,n,t,s,i,r);return`<g${o}>${c}</g>`}async function Zo(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 Jo(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,S=x&&i?i[x]:null,v=S?s[S.fullPath]:null;if(v){const j=S.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:T,fillAttrs:y}=_i(g,o,r,0,0,a,l);return`<rect width="${M(a)}" height="${M(l)}" fill="${Ae(T)}"${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 Pi(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=Te(d),u=await Ke(t,c),p=Object.values(u).find(P=>P.type?.includes("slideLayout")),m=p&&t[p.fullPath]?Te(new TextDecoder().decode(t[p.fullPath])):null,g=p?await Ke(t,p.fullPath):{},T=i.cx/914400*96,y=i.cy/914400*96,w=[],x=await Jo(h,l,m,t,o,r,T,y,w),S=b(b(l,"cSld"),"spTree"),v=m?b(b(m,"cSld"),"spTree"):null,_=b(b(h,"cSld"),"spTree"),j=S?await en(S,o,t,r,a,w):"",N=v?await en(v,g,t,r,a,w):"",F=_?await en(_,u,t,r,a,w):"",R=w.length?`<defs>${w.join(`
|
|
108
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(T)}" height="${M(y)}" viewBox="0 0 ${M(T)} ${M(y)}">`,R,x,j,N,F,"</svg>"].join(`
|
|
109
|
-
`)}async function
|
|
110
|
-
`,bold:!1,italic:!1,underline:!1,fontSize:12,color:"#000"});else if(o.localName==="fld"){const c=K(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 zn(e){return e?tt(e,"p").map(
|
|
109
|
+
`)}async function el(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await Pi(t,e));return n}function Ps(e){const n=e.replace(/[{}\-]/g,"");if(n.length<32){const o=n.padEnd(32,"0");return tl(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 tl(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 js(e,n){const t=new Uint8Array(e);for(let s=0;s<Math.min(32,t.length);s++)t[s]^=n[s];return t}function Pn(e){if(e.length<4)return!1;const n=e[0]<<24|e[1]<<16|e[2]<<8|e[3];return n===65536||n===1330926671||n===1953658213||n===2001684038||n===2001684018}const Rn=new Set;async function nl(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 T=`${d}:${p}:${m}`;if(Rn.has(T)){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 S=Ps(g),v=js(w,S);if(Pn(v))x=v;else{const _=y.fullPath.split("/").pop().replace(".fntdata",""),j=Ps(_),N=js(w,j);Pn(N)?x=N:Pn(w)&&(x=w)}if(!x){t.push({typeface:d,weight:p,style:m,status:"decode-failed",path:y.fullPath});continue}try{const _=new FontFace(d,x.buffer,{weight:p,style:m});await _.load(),document.fonts.add(_),Rn.add(T),t.push({typeface:d,weight:p,style:m,status:"loaded",path:y.fullPath})}catch(_){t.push({typeface:d,weight:p,style:m,status:"load-failed",error:_.message})}}}return t}function sl(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=>Rn.has(`${a}:${o==="bold"||o==="boldItalic"?"700":"400"}:${o.includes("talic")?"italic":"normal"}`))}}).filter(i=>i.typeface):[]}function K(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 tt(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 Ln(e,n,t=0){const s=Ne(e,n);return s!==null?parseInt(s,10):t}function il(e,n){const t=K(e,"rPr"),s=K(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=K(t,"solidFill")||K(t,"lumMod");if(h){const u=K(h,"srgbClr");u&&(d="#"+(u.getAttribute("val")||"000000"))}}return{text:i,bold:l,italic:o,underline:c!=="none",fontSize:a,color:d}}function rl(e){const n=K(e,"pPr"),t=Ne(n,"algn","l"),s=Ln(n,"lvl",0),i=K(n,"defRPr");let r=null;if(n&&!K(n,"buNone")){const o=K(n,"buChar"),c=K(n,"buAutoNum");o?r=o.getAttribute("char")||"•":c&&(r="{auto}")}const a=[];for(const o of e.children)if(o.localName==="r"){const c=il(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=K(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 zn(e){return e?tt(e,"p").map(rl).filter(n=>n.text.trim()):[]}function Cs(e){const n=K(e,"nvSpPr"),t=n?K(n,"nvPr"):null,s=t?K(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 K(e,"txBody")?"textBox":"other"}function Fs(e){const n=K(e,"nvSpPr"),t=n?K(n,"cNvPr"):null;return t?Ne(t,"id",""):""}function Ns(e){const n=K(e,"nvSpPr"),t=n?K(n,"cNvPr"):null;return t?Ne(t,"name",""):""}function al(e){const n=K(e,"tbl");if(!n)return null;const t=K(e,"nvGraphicFramePr"),s=t?K(t,"cNvPr"):null,i=s?Ne(s,"id",""):"",r=s?Ne(s,"name",""):"",a=[];let l=0;for(const c of tt(n,"tr")){const d=[];let h=0;for(const u of tt(c,"tc")){const p=Ln(u,"gridSpan",1),m=Ln(u,"rowSpan",1),g=zn(K(u,"txBody")),T=g.map(y=>y.text).join(`
|
|
111
111
|
`);d.push({row:l,col:h,rowSpan:m,colSpan:p,text:T,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
|
|
112
|
+
`);return{id:i,name:r,rows:a,text:o}}function ol(e,n){const t=K(e,"graphic"),s=t?K(t,"graphicData"):null,i=s?K(s,"chart"):null;if(!i)return null;const r=i.getAttribute("r:id")||i.getAttribute("id"),a=K(e,"nvGraphicFramePr"),l=a?K(a,"cNvPr"):null;return{id:l?Ne(l,"id",""):"",name:l?Ne(l,"name",""):"",rId:r}}function ll(e){if(!e)return{chartType:"unknown",seriesNames:[],categories:[]};const n=K(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=K(n,o),i){s=o.replace("3DChart","Chart").replace("Chart","");break}const r=i?tt(i,"ser"):[],a=r.map(o=>{const c=K(o,"tx");if(!c)return null;const d=K(c,"v");if(d)return d.textContent.trim();const h=K(c,"strCache"),u=h?K(h,"pt"):null,p=u?K(u,"v"):null;return p?p.textContent.trim():null}).filter(Boolean),l=r.length>0?(()=>{const o=K(r[0],"cat")||K(r[0],"xVal");if(!o)return[];const c=K(o,"strCache")||K(o,"numCache");return c?tt(c,"pt").map(d=>K(d,"v")?.textContent||"").filter(Boolean):[]})():[];return{chartType:s,seriesNames:a,categories:l}}function cl(e){if(!e)return"";const n=K(e,"cSld"),t=n?K(n,"spTree"):null;if(!t)return"";const s=[];for(const i of tt(t,"sp")){const r=K(i,"nvSpPr"),a=r?K(r,"nvPr"):null,l=a?K(a,"ph"):null;if(l&&Ne(l,"type")==="sldNum")continue;const o=K(i,"txBody");if(o){const c=tt(o,"r").map(d=>K(d,"t")?.textContent||"").join("");c.trim()&&s.push(c.trim())}}return s.join(`
|
|
113
113
|
|
|
114
|
-
`)}async function kn(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
|
|
115
|
-
`);A.trim()&&u.push({id:F,name:R,type:N,paragraphs:P,text:A})}else if(_==="pic"){const j=K(v,"nvPicPr"),N=j?K(j,"cNvPr"):null,F=N?Ne(N,"id",""):"",R=N?Ne(N,"name",""):"",P=N?Ne(N,"descr","")||Ne(N,"title",""):"",A=j?K(j,"nvPr"):null;A&&K(A,"extLst"),m.push({id:F,name:R,altText:P,title:R})}else if(_==="graphicFrame"){const j=(()=>{const N=K(v,"graphic"),F=N?K(N,"graphicData"):null;return F?Ne(F,"uri",""):""})();if(j.includes("table")||K(v,"tbl")){const N=
|
|
114
|
+
`)}async function kn(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 dl(e);const r=new DOMParser().parseFromString(new TextDecoder().decode(i),"application/xml"),{getRels:a}=await dn(async()=>{const{getRels:v}=await Promise.resolve().then(()=>bo);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=cl(v)}const d=K(r,"cSld"),h=d?K(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 _=v.localName;if(_==="sp"){const j=K(v,"txBody");if(!j)continue;const N=Cs(v),F=Fs(v),R=Ns(v),P=zn(j),A=P.map(E=>E.text).join(`
|
|
115
|
+
`);A.trim()&&u.push({id:F,name:R,type:N,paragraphs:P,text:A})}else if(_==="pic"){const j=K(v,"nvPicPr"),N=j?K(j,"cNvPr"):null,F=N?Ne(N,"id",""):"",R=N?Ne(N,"name",""):"",P=N?Ne(N,"descr","")||Ne(N,"title",""):"",A=j?K(j,"nvPr"):null;A&&K(A,"extLst"),m.push({id:F,name:R,altText:P,title:R})}else if(_==="graphicFrame"){const j=(()=>{const N=K(v,"graphic"),F=N?K(N,"graphicData"):null;return F?Ne(F,"uri",""):""})();if(j.includes("table")||K(v,"tbl")){const N=al(v);N&&p.push(N)}else if(j.includes("chart")){const N=ol(v);if(N){const F=N.rId?l[N.rId]:null;let R={chartType:"chart",seriesNames:[],categories:[]};if(F&&t[F.fullPath]){const P=new DOMParser().parseFromString(new TextDecoder().decode(t[F.fullPath]),"application/xml");R=ll(P)}g.push({id:N.id,name:N.name,...R})}}}else if(_==="grpSp")for(const j of tt(v,"sp")){const N=K(j,"txBody");if(!N)continue;const F=Cs(j),R=Fs(j),P=Ns(j),A=zn(N),E=A.map(z=>z.text).join(`
|
|
116
116
|
`);E.trim()&&u.push({id:R,name:P,type:F,paragraphs:A,text:E})}}const T=u.find(v=>v.type==="title"),y=u.find(v=>v.type==="subtitle"),w=T?.text||"",x=y?.text||"",S=[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
117
|
|
|
118
|
-
`);return{index:e,title:w,subtitle:x,textShapes:u,tables:p,images:m,charts:g,notes:c,text:S}}function
|
|
118
|
+
`);return{index:e,title:w,subtitle:x,textShapes:u,tables:p,images:m,charts:g,notes:c,text:S}}function dl(e){return{index:e,title:"",subtitle:"",textShapes:[],tables:[],images:[],charts:[],notes:"",text:""}}async function ul(e){const n=[];for(let t=0;t<e.slideCount;t++)n.push(await kn(t,e));return n}async function fl(e,n){return(await kn(e,n)).text}async function hl(e,n){const t=e.toLowerCase().trim();if(!t)return[];const s=[];for(let i=0;i<n.slideCount;i++){const r=await kn(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 pl{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 dn(async()=>{const{renderTransitionFrame:c}=await Promise.resolve().then(()=>Uo);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
119
|
<span style="opacity:0.7">Slide</span>
|
|
120
120
|
<strong>${this._index+1}</strong>
|
|
121
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 ji(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}async function
|
|
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 ji(e,n){const t=e.slideSize.cx/914400;return Math.round(t*n)}async function ml(e,n,t={}){typeof t=="number"&&(t={width:t});const{width:s=null,dpi:i=150}=t,r=s??ji(n,i),a=await Fi(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 Ci(e,n,t={},s){typeof t=="number"&&(t={width:t});const{width:i=null,dpi:r=300,filename:a}=t,l=i??ji(n,r),c=(await Fi(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 gl(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 Ci(l,e,i),r?.(l+1,a),await new Promise(o=>setTimeout(o,100))}async function Fi(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 bl(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,T=m/g,y=e.slideCount;n.style.cssText=`
|
|
123
123
|
background:${a};
|
|
124
124
|
padding:${r};
|
|
125
125
|
display:flex;
|
|
@@ -144,7 +144,7 @@ ${x}
|
|
|
144
144
|
font:11px/1.4 system-ui,sans-serif;
|
|
145
145
|
padding:2px 7px;border-radius:10px;
|
|
146
146
|
pointer-events:none;z-index:1;
|
|
147
|
-
`,P.textContent=F+1,R.appendChild(P);const A=document.createElement("canvas");A.style.cssText="display:block;width:100%;height:100%;",A.width=s,A.height=Math.round(s/T),R.appendChild(A);const E=
|
|
147
|
+
`,P.textContent=F+1,R.appendChild(P);const A=document.createElement("canvas");A.style.cssText="display:block;width:100%;height:100%;",A.width=s,A.height=Math.round(s/T),R.appendChild(A);const E=yl(F,m,g,l);R.appendChild(E),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),S.push("pending")}const v=[];let _=!1;async function j(){if(!(_||v.length===0)){for(_=!0;v.length>0;){const F=v.shift();if(S[F]==="full")continue;const R=x[F],A=w[F].querySelector("[data-placeholder]");try{R.width=i,R.height=Math.round(i/T),await e.renderSlide(F,R,i),S[F]="full",R.style.transition="opacity 0.3s",R.style.opacity="1",A&&(A.style.display="none"),p?.(F)}catch(E){console.warn(`LazyDeck: failed to render slide ${F}`,E)}}_=!1}}const N=new IntersectionObserver(F=>{for(const R of F){if(!R.isIntersecting)continue;const P=parseInt(R.target.getAttribute("data-slide"),10);if(!(isNaN(P)||S[P]==="full")){u?.(P);for(const A of[P,P-1,P+1,P+2].filter(E=>E>=0&&E<y))S[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 P=w[F];P&&P.scrollIntoView({behavior:R,block:"start"})},async renderAll(F){for(let R=0;R<y;R++)S[R]!=="full"&&v.push(R);await j()},getCanvas(F){return x[F]||null},get slideCount(){return y}}}function yl(e,n,t,s){const i=document.createElement("div");i.setAttribute("data-placeholder","1"),i.style.cssText=`
|
|
148
148
|
position:absolute;inset:0;
|
|
149
149
|
display:flex;align-items:center;justify-content:center;
|
|
150
150
|
background:${s};
|
|
@@ -154,4 +154,4 @@ ${x}
|
|
|
154
154
|
<div style="width:72%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.1s;"></div>
|
|
155
155
|
<div style="width:62%;height:10px;background:#ebebeb;border-radius:3px;animation:pulse 1.4s ease-in-out infinite 0.2s;"></div>
|
|
156
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 yl{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 ii(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=Te(i),a=b(r,"sldSz");a&&(this.slideSize={cx:C(a,"cx",9144e3),cy:C(a,"cy",5143500)});const l=await Ke(this._files,"ppt/presentation.xml");if(this.embeddedFonts=Oa(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 Ke(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=Ra(Te(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=Te(h),this.masterRels=await Ke(this._files,d.fullPath),this.masterImages=await Zt(this._files,this.masterRels),this._trackBlobs(this.masterImages);const u=La(this.masterDoc);this.themeColors=za(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=Te(r),l=await Ke(this._files,i),o=await Zt(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=Te(v),d=await Ke(this._files,u.fullPath),h=await Zt(this._files,d),this._trackBlobs(h))}const p={...this.masterImages,...h,...o},m=pi([c,this.masterDoc]),g=qa([a,c,this.masterDoc]);await Ga(g,this.themeData);const T=s/this.slideSize.cx,y=Math.round(this.slideSize.cy*T);t.width=s,t.height=y;const w=t.getContext("2d");w.clearRect(0,0,s,y),await hi(w,a,this.masterDoc,c,l,this.masterRels,p,this.themeColors,T,this.slideSize.cx,this.slideSize.cy),await this._renderNonPlaceholders(w,this.masterDoc,this.masterRels,this.masterImages,T),await this._renderNonPlaceholders(w,c,d,h,T);const x=b(a,"cSld"),S=x?b(x,"spTree"):null;S&&await gi(w,S,l,p,this.themeColors,this.themeData,T,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 An(n,t,s)}registerFonts(n){return Ba(n)}listRegisteredFonts(){return Ka()}_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 mn(n,o,s,i,this.themeColors,this.themeData,r):c==="pic"?await gn(n,o,s,i,this.themeColors,r):c==="grpSp"?await bn(n,o,s,i,this.themeColors,this.themeData,r):c==="graphicFrame"?await vn(n,o,this.themeColors,this.themeData,r):c==="cxnSp"&&await yn(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=Te(new TextDecoder().decode(s));return Qn(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=Te(new TextDecoder().decode(s));return Zn(i)}createPlayer(n){return new ki(this,n)}async toSvg(n){return Pi(n,this)}async allToSvg(){return Jo(this)}async loadEmbeddedFonts(){const n=this._presRels||{};return tl(this._files,n)}listEmbeddedFonts(){return nl(this._files)}async extractSlide(n){return kn(n,this)}async extractAll(){return dl(this)}async extractText(n){return ul(n,this)}async searchSlides(n){return fl(n,this)}createShow(n,t={}){return new hl(this,n,t)}async copySlide(n,t={}){return pl(n,this,t)}async downloadSlide(n,t={}){return Ci(n,this,t)}async downloadAllSlides(n={}){return ml(this,n)}createDeck(n,t={}){return gl(this,n,t)}edit(){return ln.fromRenderer(this)}async toPdf(n={}){return Yn(this,n)}async downloadPdf(n="presentation.pdf",t={}){return Ro(this,n,t)}async slideToPdf(n,t={}){return Lo(n,this,t)}async getSlideNotes(n){if(n<0||n>=this.slidePaths.length)return"";const t=await Ke(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=Te(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 vl=({asset:e,bytes:n,onOpenExternal:t,dense:s=!1,expanded:i=!1})=>{const r=$.useRef(null),a=$.useRef(null),[l,o]=$.useState({phase:"loading",progress:0}),[c,d]=$.useState(0),[h,u]=$.useState(1),[p,m]=$.useState(0),[g,T]=$.useState(!1),[y,w]=$.useState([]),[x,S]=$.useState(!s),v=$.useRef(null),[_,j]=$.useState(!1);$.useEffect(()=>{S(!s)},[s]),$.useLayoutEffect(()=>{const P=v.current;if(!P)return;const A=()=>j(P.getBoundingClientRect().height<360);A();const E=new ResizeObserver(A);return E.observe(P),()=>E.disconnect()},[]),$.useEffect(()=>{let P=!1;const A=new yl;return r.current=A,o({phase:"loading",progress:0}),d(0),u(1),A.load(n,E=>{P||o({phase:"loading",progress:E})}).then(async()=>{if(P)return;const E=A.slideCount,Y=(await A.renderAllSlides(160)).map(O=>O.toDataURL("image/png"));P||o({phase:"ready",slideCount:E,thumbnails:Y})}).catch(E=>{P||o({phase:"error",detail:E instanceof Error&&E.message?E.message:k("ui.library.preview.pptx_failed_detail")})}),()=>{P=!0,A.destroy(),r.current=null}},[n,p]);const N=$.useCallback(async()=>{const P=r.current,A=a.current;if(!(!P||!A||l.phase!=="ready"))try{await P.renderSlide(c,A,Math.round(960*h))}catch(E){o({phase:"error",detail:E instanceof Error&&E.message?E.message:k("ui.library.preview.pptx_failed_detail")})}},[c,l.phase,h]);$.useEffect(()=>{N()},[N]),$.useEffect(()=>{const P=r.current;if(!P||l.phase!=="ready")return;let A=!1;return P.extractSlide(c).then(E=>{A||w(E.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=P=>{F!==0&&d(Math.min(Math.max(P,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:k("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(P=>P+1),children:k("ui.library.preview.retry")}),f.jsxs(J,{variant:"secondary",size:"sm",disabled:g,onClick:()=>{T(!0),bt(e).catch(P=>Pe(P instanceof Error&&P.message?P.message:k("ui.library.menu.save_failed"))).finally(()=>T(!1))},children:[f.jsx(mt,{"aria-hidden":"true"}),k("ui.library.menu.download")]}),t&&f.jsxs(J,{variant:"ghost",size:"sm",onClick:t,children:[f.jsx(Bs,{"aria-hidden":"true"}),k("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:P=>{P.key==="ArrowRight"||P.key==="PageDown"?(P.preventDefault(),R(c+1)):P.key==="ArrowLeft"||P.key==="PageUp"?(P.preventDefault(),R(c-1)):P.key==="Home"?(P.preventDefault(),R(0)):P.key==="End"&&(P.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(On,{size:18,"aria-hidden":"true",className:"motion-safe:animate-spin text-ink-muted"}),f.jsx(pr,{value:Math.round(l.progress*100)}),f.jsx("span",{className:"text-meta text-ink-muted",children:k("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":k("ui.library.preview.slide_of",{index:String(c+1),count:String(F)})})}),l.phase==="ready"&&!_&&!s&&f.jsx("div",{className:"flex h-[72px] shrink-0 flex-row gap-1 overflow-x-auto overflow-y-hidden",children:l.thumbnails.map((P,A)=>f.jsx("button",{type:"button",onClick:()=>d(A),"aria-pressed":A===c,"aria-label":k("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:P,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:()=>S(P=>!P),children:k("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((P,A)=>f.jsx("p",{"data-pptx-transcript-line":"",className:"truncate",children:P},`${A}:${P}`)):f.jsx("p",{children:k("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":k("ui.library.preview.previous_slide"),disabled:c===0||l.phase!=="ready",onClick:()=>R(c-1),children:f.jsx(Wn,{"aria-hidden":"true"})}),f.jsx("span",{className:"text-meta tabular-nums text-ink-muted",children:k("ui.library.preview.slide_of",{index:String(F?c+1:0),count:String(F)})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.preview.next_slide"),disabled:c>=F-1||l.phase!=="ready",onClick:()=>R(c+1),children:f.jsx(mr,{"aria-hidden":"true"})})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.preview.zoom_out"),onClick:()=>u(P=>Math.max(.5,P-.25)),children:f.jsx(rr,{"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":k("ui.library.preview.zoom_in"),onClick:()=>u(P=>Math.min(2,P+.25)),children:f.jsx(ar,{"aria-hidden":"true"})}),f.jsx(J,{variant:"ghost",size:"sm",onClick:()=>u(1),disabled:h===1,children:k("ui.library.preview.fit")})]})]})]})},kt=({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(On,{size:16,"aria-hidden":"true",className:"motion-safe:animate-spin"}),e??k("ui.library.preview.loading")]}),_t=({detail:e,asset:n})=>{const[t,s]=$.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(Ye,{kind:n.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:k("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),bt(n).catch(i=>Pe(i instanceof Error&&i.message?i.message:k("ui.library.menu.save_failed"))).finally(()=>s(!1))},children:[f.jsx(mt,{"aria-hidden":"true"}),k("ui.library.menu.download")]})]})},Ms=({asset:e})=>(Ue(),f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Ye,{kind:e.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"max-w-90 text-body text-ink",children:e.kind==="other"?k("ui.library.preview.unsupported_generic"):k("ui.library.preview.unsupported",{kind:Xn(e.kind)})}),f.jsxs("div",{className:"flex items-center gap-2",children:[lt(e)?f.jsx(J,{variant:"secondary",size:"sm",onClick:()=>{const n=lt(e);n&&window.api.openFile(n)},children:k("ui.library.preview.open_externally")}):null,f.jsxs(J,{variant:"secondary",size:"sm",onClick:()=>void bt(e),children:[f.jsx(mt,{"aria-hidden":"true"}),k("ui.library.menu.download")]})]})]})),wl=72;function Dt(e,n){const t=Hn(e)?e.ref.path:null,[s,i]=$.useState(!1),r=wt(e.id,"content",!t||s),[a,l]=$.useState({bytes:null,mimeType:"",error:null,loading:!!t}),o=e.ref.content_type;return $.useEffect(()=>{if(!t)return;if(!window.api?.readFileBytes){i(!0),l({bytes:null,mimeType:"",error:k("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 xl=({asset:e,mediaSiblings:n,revision:t,expanded:s})=>{const{bytes:i,mimeType:r,error:a,loading:l}=Dt(e,t),o=xt(i,r||e.ref.content_type),c=Qs(e.id,e.kind==="audio"),d=$.useRef(null),h=$.useRef(null),u=$.useRef(null),p=$.useRef(null),[m,g]=$.useState(null),[T,y]=$.useState(null),w=$.useMemo(()=>{const _=(n??[]).filter(j=>j.kind==="image"||j.kind==="video");return _.some(j=>j.id===e.id)?[..._]:[e]},[n,e]),x=Math.max(0,w.findIndex(_=>_.id===e.id)),S=De(e);if($.useEffect(()=>{if(e.kind!=="video"||!o)return;const _=u.current,j=p.current;if(!_||!j)return;const N=()=>{const R=_.getBoundingClientRect(),P=j.getBoundingClientRect(),A=Math.max(0,P.height-wl);if(A<=0||P.width<=0){g(z=>z===null?z:null);return}const E={top:P.top-R.top,left:P.left-R.left,width:P.width,height:A};g(z=>z&&z.top===E.top&&z.left===E.left&&z.width===E.width&&z.height===E.height?z:E)};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(_),()=>{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(kt,{});if(a||!o)return f.jsx(_t,{detail:a||k("ui.library.errors.empty_bytes"),asset:e});const v=f.jsx(Ma,{open:T!==null,siblings:w,index:T??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":S,title:S,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(Ye,{kind:"audio",size:32,className:"text-ink-dim"}),f.jsx(Ds,{variant:"full",ownerId:`sound:library:${e.id}`,src:o,label:De(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":S,title:S,onClick:()=>y(x),"data-library-media-trigger":"video",className:"absolute top-2 end-2 z-[2]",children:f.jsx(Os,{"aria-hidden":"true"})})]}),v]})}},kl=({asset:e,revision:n})=>{const{bytes:t,mimeType:s,error:i,loading:r}=Dt(e,n),a=xt(t,s||e.ref.content_type);return r?f.jsx(kt,{}):i||!a?f.jsx(_t,{detail:i||k("ui.library.errors.empty_bytes"),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})},_l=({asset:e,text:n,expanded:t,revision:s,mtimeMs:i})=>{const r=lt(e),a=r!==null&&e.exists,[l,o]=$.useState({state:"pending"});$.useEffect(()=>{if(!a||!r||i!==null)return;let h=!1;return kr(r).then(u=>{h||o({state:"done",mtimeMs:u?.mtimeMs??null})}),()=>{h=!0}},[a,r,s,i]);const c=i??(l.state==="done"?l.mtimeMs:null),d=$.useMemo(()=>!a||!r||i===null&&l.state!=="done"?null:ja(e,n,c),[e,a,r,l,n,i,c]);return a&&d===null?f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center",children:f.jsx(kt,{label:k("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:k("ui.library.preview.breadcrumb",{name:d.title})}),f.jsx(_r,{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:k("ui.library.preview.read_only_markdown")}),f.jsx("div",{className:"prose-lo max-w-none text-body text-ink",children:f.jsx(or,{remarkPlugins:[lr],children:n})})]})})},Sl=({asset:e,expanded:n,revision:t,mtimeMs:s})=>{const{bytes:i,error:r,loading:a}=Dt(e,t);if(a)return f.jsx(kt,{});if(r||!i)return f.jsx(_t,{detail:r||k("ui.library.errors.empty_bytes"),asset:e});const l=new TextDecoder("utf-8",{fatal:!1}).decode(i);return e.kind==="markdown"?f.jsx(_l,{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})},Tl=({asset:e,revision:n})=>{const{bytes:t,error:s,loading:i}=Dt(e,n);return i?f.jsx(kt,{}):s||!t?f.jsx(_t,{detail:s||k("ui.library.errors.empty_bytes"),asset:e}):f.jsx(Pl,{asset:e,bytes:t})},As=200,$s=40,Pl=({asset:e,bytes:n})=>{const t=(()=>{try{const r=Sr(n,{type:"array"}),a=r.SheetNames[0];if(!a)return null;const l=Tr.sheet_to_json(r.Sheets[a],{header:1,raw:!1,defval:""});return{name:a,rows:l}}catch{return null}})();if(!t)return f.jsx(_t,{detail:k("ui.library.preview.sheet_unreadable"),asset:e});const s=t.rows.slice(0,As),i=t.rows.length>As;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,$s).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,$s).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:k("ui.library.preview.sheet_truncated")}),f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:k("ui.library.preview.sheet_name",{name:t.name})})]})},jl=({asset:e,dense:n=!1,expanded:t=!1,revision:s=0,mtimeMs:i=null,mediaSiblings:r})=>e.kind==="pptx"?f.jsx(Cl,{asset:e,dense:n,expanded:t,revision:s}):e.kind==="image"||e.kind==="audio"||e.kind==="video"?f.jsx(xl,{asset:e,mediaSiblings:r,revision:s,expanded:t}):e.kind==="pdf"||e.kind==="html"?f.jsx(kl,{asset:e,revision:s}):e.kind==="markdown"||e.kind==="text"||e.kind==="code"?f.jsx(Sl,{asset:e,expanded:t,revision:s,mtimeMs:i}):e.kind==="spreadsheet"?f.jsx(Tl,{asset:e,revision:s}):e.kind==="docx"?f.jsx(Ms,{asset:e}):f.jsx(Ms,{asset:e}),Cl=({asset:e,dense:n=!1,expanded:t,revision:s})=>{const{bytes:i,error:r,loading:a}=Dt(e,s);return a?f.jsx(kt,{label:k("ui.library.preview.pptx_opening")}):r||!i?f.jsx(_t,{detail:r||k("ui.library.errors.empty_bytes"),asset:e}):f.jsx(vl,{asset:e,bytes:i,dense:n,expanded:t})};function Fl(e){const n=ea(!0),t=na().create,s=ta(),[i,r]=$.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){Pe(o instanceof Error&&o.message?o.message:k("ui.library.preview.tags_not_saved"))}finally{r(!1)}},saving:i}}const Es=({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})=>{Ue();const u=Hs(),{commit:p,saving:m}=Fl(e),g=$.useRef(null),T=$.useRef(null),y=$.useRef(null),[w,x]=$.useState(0),[S,v]=$.useState(0),[_,j]=$.useState(!1),[N,F]=$.useState(e.id);N!==e.id&&(F(e.id),x(0),v(0),j(!1));const[R,P]=$.useState(!1),[A,E]=$.useState(!1),[z,Y]=$.useState({}),[O,W]=$.useState({}),[B,Z]=$.useState(0),[Q,I]=$.useState({}),X=xa(e,B),ae=Ys(),le=e.chat?.session_id??z[e.id]??null,fe=O[e.id]??R;$.useLayoutEffect(()=>{const G=g.current;if(!G)return;const oe=()=>P(G.getBoundingClientRect().height<700);oe();const pe=new ResizeObserver(oe);return pe.observe(G),()=>pe.disconnect()},[]);const ee=$.useMemo(()=>e.tags.map(G=>G.name),[e.tags]),V=!R||A,be=()=>{j(!0),E(!0)};$.useEffect(()=>{if(!_||!V)return;const G=y.current;G&&(j(!1),G.scrollIntoView({block:"center"}),v(oe=>oe+1))},[_,V]),$.useEffect(()=>{o&&(o.field==="tags"?be():(T.current?.scrollIntoView({block:"center"}),x(G=>G+1)))},[o?.signal]);const H=async G=>{try{await u.mutateAsync({id:e.id,fields:G})}catch(oe){throw Pe(oe instanceof Error&&oe.message?oe.message:k("ui.library.preview.not_saved")),oe}},re=async()=>{try{await u.mutateAsync({id:e.id,fields:{locked:!e.locked}})}catch(G){Pe(G instanceof Error&&G.message?G.message:k("ui.library.preview.not_saved"))}},ue=()=>{const G=lt(e);if(G){window.api.openFile(G);return}bt(e).catch(oe=>Pe(Mn(oe,k("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(Wn,{"aria-hidden":"true"}),k("ui.library.page.back")]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ye,{kind:e.kind,size:18,className:"text-ink-dim"}),f.jsx("div",{ref:T,className:"min-w-0 flex-1",children:f.jsx(fs,{value:De(e),onSave:G=>H({name:G}),label:k("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(Xt,{content:e.favorite?k("ui.library.menu.unfavorite"):k("ui.library.menu.favorite"),children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":e.favorite,"aria-label":e.favorite?k("ui.library.menu.unfavorite"):k("ui.library.menu.favorite"),onClick:a,children:f.jsx(un,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0})})}),f.jsx(Xt,{content:e.locked?k("ui.library.preview.unlock"):k("ui.library.preview.lock"),children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":e.locked,"aria-label":e.locked?k("ui.library.preview.unlock"):k("ui.library.preview.lock"),onClick:()=>void re(),children:e.locked?f.jsx(Pr,{"aria-hidden":"true",className:"text-accent"}):f.jsx(jr,{"aria-hidden":"true"})})}),d&&f.jsx(Xt,{content:k("ui.library.preview.expand"),children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.preview.expand"),onClick:d,children:f.jsx(Os,{"aria-hidden":"true"})})}),f.jsx(Vn,{asset:e,onAsk:r,onEditMetadata:()=>x(G=>G+1),onEditTags:be,onToggleFavorite:a,onOpenConversation:s,onFilterSession:i}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.preview.close"),onClick:t,children:f.jsx(He,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta text-ink-muted",children:[f.jsx(ot,{variant:"neutral",children:Xn(e.kind)}),f.jsx(ot,{variant:"neutral",children:k(fn(e.origin_group))}),Hn(e)&&X.mtimeMs!==null&&Math.floor(X.mtimeMs/1e3)!==Math.floor(e.modified_at)?f.jsx("span",{"data-library-file-live":"",children:f.jsx("bdi",{children:nn(X.sizeBytes??e.size_bytes)})}):f.jsx("span",{children:f.jsx("bdi",{children:nn(e.size_bytes)})}),e.width&&e.height?f.jsxs("span",{children:[e.width,"×",e.height]}):null,e.remote?f.jsx(Gn,{device:Je(e),withLabel:!0}):null,e.organized?f.jsx("span",{children:Xr(e.organized.by,Vr(e.organized.at,n))}):f.jsx("span",{children:k("ui.library.preview.unorganized")}),e.exists?null:f.jsx(ot,{variant:"warning",children:k("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(Bs,{"aria-hidden":"true"}),k("ui.library.preview.open")]}),lt(e)?f.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>{const G=lt(e);G&&window.api.showItemInFolder(G)},children:[f.jsx(jn,{"aria-hidden":"true"}),k("ui.library.preview.reveal")]}):null,f.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>void bt(e).then(()=>Cn(k("ui.library.menu.saved_a_copy"))).catch(G=>Pe(Mn(G,k("ui.library.menu.save_failed")))),children:[f.jsx(mt,{"aria-hidden":"true"}),e.remote?k("ui.canvas.files.remoteDownload"):k("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:`${k("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:k("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:()=>E(G=>!G),children:[f.jsx(qs,{"aria-hidden":"true",className:ye("transition-transform duration-fast",A&&"rotate-180")}),k("ui.library.preview.details")]}),(!R||A)&&f.jsxs(f.Fragment,{children:[f.jsx(fs,{value:e.description,onSave:G=>H({description:G}),label:k("ui.library.preview.description"),placeholder:k("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(va,{value:ee,onChange:G=>void p(G),label:k("ui.library.preview.tags"),addLabel:k("ui.library.preview.add_tag"),saving:m,startSignal:S},`${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(jl,{asset:e,dense:R,expanded:c,revision:X.revision,mtimeMs:X.mtimeMs,mediaSiblings:h})}),le&&f.jsx(Pa,{sessionId:le,title:e.chat?.title??le,collapsed:fe,onToggleCollapsed:()=>W(G=>({...G,[e.id]:!fe})),onOpenChat:()=>s(le),onUnlink:()=>{Y(G=>{const oe={...G};return delete oe[e.id],oe}),ae.mutate({id:e.id})},onTurnSettled:()=>Z(G=>G+1),onStreamingChange:G=>I(oe=>({...oe,[le]:G}))}),f.jsx("div",{className:"shrink-0",children:f.jsx(Ta,{asset:e,focusSignal:l,showLinkedRow:!le,onOpenChat:s,refreshSignal:B,streaming:le?Q[le]:!1,onSessionChange:(G,oe)=>Y(pe=>({...pe,[G]:oe}))})})]})},Ni="library-view",Mi="library-filters",Ai="library-details-width",Nl=1152,Ct=448,tn=320,$i=720,Ml=320,Al=192,$l=1200,El=900;function Rl(){try{return localStorage.getItem(Ni)==="list"?"list":"grid"}catch{return"grid"}}function Ll(){try{const e=localStorage.getItem(Ai);if(!e)return Ct;const n=Number(e);return Number.isFinite(n)?Math.min($i,Math.max(tn,Math.round(n))):Ct}catch{return Ct}}function zl(){try{const e=sessionStorage.getItem(Mi);if(!e)return Ht;const n=JSON.parse(e);return{...Ht,...n,scope:n.scope==="all"?"all":"final",q:""}}catch{return Ht}}function Il(e){try{localStorage.setItem(Ai,String(e))}catch{}}function Dl(e){try{sessionStorage.setItem(Mi,JSON.stringify({...e,q:""}))}catch{}}function Bl(){const[e,n]=$.useState(null),[t,s]=$.useState(0);return $.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 Ol(){const[e,n]=$.useState(()=>window.innerWidth);return $.useEffect(()=>{const t=()=>n(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e}const Ul=({enabled:e,nowMs:n})=>{const t=Vs(e),s=ia(),i=Rs(),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:k("ui.library.librarian.title")}),f.jsx("span",{children:r.paused?k("ui.library.librarian.paused"):r.enabled?k("ui.library.librarian.enabled"):k("ui.library.librarian.disabled")}),f.jsx("span",{children:a?k("ui.library.librarian.last_organized",{at:Wl(a,n)}):k("ui.library.librarian.never_run")}),l!==null&&l>0&&f.jsx("span",{children:k("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=>Pe(o instanceof Error?o.message:k("ui.library.librarian.control_failed"))}),children:[f.jsx(Fn,{"aria-hidden":"true"}),k("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&&Ls(i,o.session_id)},onError:o=>Pe(o instanceof Error?o.message:k("ui.library.librarian.control_failed"))}),children:k("ui.library.librarian.open")})]})]})};function Wl(e,n){const t=Math.max(0,n-e*1e3),s=Math.floor(t/36e5);return s<24?k("ui.library.time.hours_h_ago",{hours:s}):k("ui.library.time.days_d_ago",{days:Math.floor(s/24)})}const Gl=({onBack:e})=>f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Vt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:k("ui.library.preview.unavailable")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:k("ui.library.preview.unavailable_detail")}),f.jsxs(J,{variant:"secondary",size:"sm",onClick:e,children:[f.jsx(Wn,{"aria-hidden":"true"}),k("ui.library.page.back")]})]}),ql=({nowMs:e})=>{Ue();const n=Rs(),t=Li(),s=zi(),i=Bn(),r=Tt(i.data,"library",1),a=Vs(r),l=e??Date.now(),{ref:o,width:c}=Bl(),d=Ol(),h=new URLSearchParams(t.search).get("full")==="1",u=d>=$l&&c>=El,[p,m]=$.useState(zl),[g,T]=$.useState(""),y=Cr(g,200),[w,x]=$.useState(Rl),[S,v]=$.useState(Ll),_=$.useCallback(L=>{v(L),Il(L)},[]),[j,N]=$.useState(!1),[F,R]=$.useState(0),[P,A]=$.useState(null),E=$.useRef(null),z=s.assetId??null,Y=c>=Nl&&!!z&&!h,O=Math.max(tn,Math.min($i,c-(u?Al:0)-Ml)),W=Math.min(S,O);$.useEffect(()=>{m(L=>L.q===y?L:{...L,q:y})},[y]),$.useEffect(()=>Dl(p),[p]),$.useEffect(()=>{try{localStorage.setItem(Ni,w)}catch{}},[w]);const B=Zr(p,r),Z=Hs(),Q=Jr(z,r),I=$.useMemo(()=>{const L=B.data?.pages??[],Ce=L.length>1&&L.at(-1)?.cursor_reset?[L.at(-1)]:L,We=new Set,Le=[];for(const nt of Ce)for(const st of nt?.rows??[])We.has(st.id)||(We.add(st.id),Le.push(st));return Le},[B.data]),X=B.data?.pages.at(-1),ae=X?.total??0,le=$.useMemo(()=>I.filter(L=>L.kind==="image"||L.kind==="video"),[I]),fe=I.find(L=>L.id===z)??null,ee=Q.data??fe,V=()=>void B.fetchNextPage(),be=!!(z&&!ee&&!Q.isLoading&&Q.isError),H=!!z&&!Y,re=$.useCallback(L=>{n(`/library/assets/${L}${t.search}`,{state:t.state})},[n,t.search,t.state]),ue=$.useCallback(()=>{const L=new URLSearchParams(t.search);L.delete("full");const q=L.toString();n(`/library${q?`?${q}`:""}`)},[n,t.search]),G=$.useCallback(()=>{if(!z)return;const L=new URLSearchParams(t.search);L.set("full","1"),n(`/library/assets/${z}?${L.toString()}`)},[n,z,t.search]),oe=$.useCallback(L=>{re(L.id),R(q=>q+1)},[re]),pe=$.useRef(new Set),he=$.useCallback(L=>{pe.current.has(L.id)||(pe.current.add(L.id),Z.mutate({id:L.id,fields:{favorite:!L.favorite}},{onSettled:()=>{pe.current.delete(L.id)},onError:q=>{Pe(q instanceof Error&&q.message?q.message:k("ui.library.preview.not_saved"))}}))},[Z]),D=$.useCallback(L=>void Ls(n,L),[n]),te=$.useCallback(L=>{m(q=>({...q,session:L})),n("/library")},[n]),ne={onSelect:re,onAsk:oe,onEditMetadata:L=>{re(L.id),A({field:"metadata",signal:Date.now()})},onEditTags:L=>{re(L.id),A({field:"tags",signal:Date.now()})},onToggleFavorite:he,onOpenConversation:D,onFilterSession:te};if($.useEffect(()=>{const L=q=>{const Ce=q.target;if(Ce?.closest('[role="dialog"]'))return;const We=Ce?.tagName==="INPUT"||Ce?.tagName==="TEXTAREA"||Ce?.isContentEditable;if(q.key==="f"&&(q.metaKey||q.ctrlKey)||q.key==="/"&&!We){q.preventDefault(),E.current?.focus();return}if(!(We||q.metaKey||q.ctrlKey||q.altKey)){if(q.key==="Escape"){(z||ee)&&ue();return}if(q.key.toLowerCase()==="g"){q.preventDefault(),x(Le=>Le==="grid"?"list":"grid");return}if(q.key.toLowerCase()==="j"||q.key.toLowerCase()==="k"){if(H||I.length===0)return;q.preventDefault();const Le=z?I.findIndex(_n=>_n.id===z):-1,nt=q.key.toLowerCase()==="j"?1:-1,st=Math.min(Math.max(Le===-1?nt===1?0:I.length-1:Le+nt,0),I.length-1);re(I[st].id)}}};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[ue,re,I,ee,z,H]),!r)return f.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[f.jsx(Ii,{title:k("ui.library.page.title"),icon:Vt}),i.isLoading?f.jsx("div",{className:"flex justify-center py-16",children:f.jsx(gt,{label:k("ui.library.page.checking")})}):f.jsx(Sn,{variant:"warning",children:k("ui.library.page.unavailable")})]});const ie=a.data?.library?.total??null,se=f.jsx(ya,{filters:p,onChange:L=>{m({...L,q:L.q}),T(L.q)},counts:X?.counts,tags:X?.tags??[],total:ae,scopeTotal:ie}),ve=I.length===0&&!B.isLoading,me=Wr(p)||!!g.trim(),ce=(()=>{const L=[];if(g.trim()&&L.push({key:"search",label:`${k("ui.library.page.search")}: ${g.trim()}`,clear:()=>T("")}),p.category){const q=Nn.find(Ce=>Ce.key===p.category);L.push({key:"category",label:q?k(q.labelKey):p.category,clear:()=>m(Ce=>({...Ce,category:void 0}))})}if(p.originGroup&&L.push({key:"origin",label:k(fn(p.originGroup)),clear:()=>m(q=>({...q,originGroup:void 0}))}),p.status){const q=p.status==="highlighted"?"ui.library.status.highlighted":p.status==="unorganized"?"ui.library.status.unorganized":"ui.library.status.favorites";L.push({key:"status",label:k(q),clear:()=>m(Ce=>({...Ce,status:void 0}))})}return p.highlighted&&p.status!=="highlighted"&&L.push({key:"highlighted",label:k("ui.library.status.highlighted"),clear:()=>m(q=>({...q,highlighted:!1}))}),p.tag&&L.push({key:"tag",label:`${k("ui.library.filter.tags")}: ${p.tag}`,clear:()=>m(q=>({...q,tag:void 0}))}),p.session&&L.push({key:"session",label:k("ui.library.filter.one_conversation"),clear:()=>m(q=>({...q,session:void 0}))}),(p.scope!=="final"||L.length>0)&&L.push({key:"scope",label:`${k("ui.library.filter.scope")}: ${p.scope==="all"?k("ui.library.filter.scope_all"):k("ui.library.filter.scope_final")}`,clear:()=>m(q=>({...q,scope:"final"}))}),L})(),_e=()=>{m(L=>({...Ht,scope:L.scope,sort:L.sort,order:L.order})),T("")},je=B.error instanceof Error&&B.error.message?B.error.message:k("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":k("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(Vt,{size:20,"aria-hidden":"true",className:"text-ink-muted"}),f.jsx("h1",{className:"text-title text-ink",children:k("ui.library.page.title")}),f.jsx("span",{className:"ms-2 text-meta tabular-nums text-ink-dim",children:k("ui.library.page.loaded_count",{loaded:String(I.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":k("ui.library.page.grid_view"),onClick:()=>x("grid"),children:f.jsx(cr,{"aria-hidden":"true"})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":w==="list","aria-label":k("ui.library.page.list_view"),onClick:()=>x("list"),children:f.jsx(Fr,{"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(dr,{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(gr,{ref:E,value:g,onChange:L=>T(L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.preventDefault()},placeholder:k("ui.library.page.search"),"aria-label":k("ui.library.page.search"),"data-library-search":"",className:"border-0 bg-elevated ps-8"})]}),f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsxs(J,{variant:"ghost",size:"sm",className:"shrink-0 bg-elevated text-ink",children:[f.jsx(rs,{"aria-hidden":"true"}),k("ui.library.page.sort")]})}),f.jsx(Gs,{align:"end",className:"min-w-45",children:Or.map(L=>f.jsxs(Ee,{onSelect:()=>m(q=>({...q,sort:L.key,order:Ur(L.key)})),children:[p.sort===L.key?f.jsx(br,{"aria-hidden":"true"}):f.jsx("span",{className:"size-4"}),f.jsx("span",{children:k(L.labelKey)})]},L.key))})]}),f.jsx(J,{variant:"ghost",size:"icon-sm",className:"shrink-0","aria-label":k("ui.library.page.reverse_order"),onClick:()=>m(L=>({...L,order:L.order==="asc"?"desc":"asc"})),children:p.order==="asc"?f.jsx($r,{"aria-hidden":"true"}):f.jsx(rs,{"aria-hidden":"true"})}),!u&&!H&&f.jsxs(J,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",onClick:()=>N(!0),children:[f.jsx(Nr,{"aria-hidden":"true"}),k("ui.library.page.filters")]})]}),ce.length>0&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[ce.map((L,q)=>f.jsxs("span",{className:"contents",children:[q>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:L.label}),f.jsx("button",{type:"button","aria-label":`${k("ui.library.filter.clear_filters")} — ${L.label}`,onClick:L.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(He,{size:12,"aria-hidden":"true"})})]})]},L.key)),f.jsx(J,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-meta",onClick:_e,children:k("ui.library.page.clear_all")})]}),f.jsx("div",{"data-library-librarian-track":"",className:"min-h-10 shrink-0",children:f.jsx(Ul,{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:k("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":k("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(ma,{view:w}):B.isError&&I.length===0?f.jsxs("div",{className:"flex flex-col items-start gap-3 py-10",children:[f.jsx(Sn,{variant:"warning",children:je}),f.jsxs(J,{variant:"secondary",size:"sm",onClick:()=>void B.refetch(),children:[f.jsx(Fn,{"aria-hidden":"true"}),k("ui.library.page.retry")]})]}):ve?f.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-center",children:[f.jsx(Vt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:me?`${k("ui.library.page.no_matches")}: ${ce.map(L=>L.label).join(" + ")}`:k("ui.library.page.empty_title")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:me?k("ui.library.page.no_matches_detail"):k("ui.library.page.empty_detail")}),me&&f.jsx(J,{variant:"secondary",size:"sm",onClick:_e,children:k("ui.library.page.clear_all")})]}):f.jsxs(f.Fragment,{children:[B.isRefetchError&&f.jsx(Sn,{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(Fn,{"aria-hidden":"true"}),k("ui.library.page.retry")]})]})}),f.jsx(pa,{assets:I,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:k("ui.library.page.load_more_failed")}),f.jsx(J,{variant:"ghost",size:"sm",onClick:V,children:k("ui.library.page.retry")})]})]})})})})]}),Y&&ee&&f.jsxs(f.Fragment,{children:[f.jsx(ns,{sidebarWidth:W,onSidebarWidthChange:_,minWidth:tn,maxWidth:O,side:"left",homeEnd:"value",onDoubleClick:()=>_(Ct),label:k("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":k("ui.library.page.preview"),children:f.jsx(Es,{asset:ee,nowMs:l,onClose:ue,onOpenConversation:D,onFilterSession:te,onAsk:()=>R(L=>L+1),onToggleFavorite:()=>he(ee),composerFocusSignal:F,focusRequest:P,onExpand:G,mediaSiblings:le})})]}),H&&f.jsx("div",{"data-glass-region":"pane",className:"panel-top-pad min-w-0 flex-1 bg-surface","aria-label":k("ui.library.page.preview"),children:be?f.jsx(Gl,{onBack:ue}):ee?f.jsx(Es,{asset:ee,nowMs:l,onClose:ue,onOpenConversation:D,onFilterSession:te,onAsk:()=>R(L=>L+1),onToggleFavorite:()=>he(ee),composerFocusSignal:F,focusRequest:P,mediaSiblings:le,standalone:!0}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(gt,{label:k("ui.library.preview.loading")})})}),!H&&!ee&&Y&&f.jsxs(f.Fragment,{children:[f.jsx(ns,{sidebarWidth:W,onSidebarWidthChange:_,minWidth:tn,maxWidth:O,side:"left",homeEnd:"value",onDoubleClick:()=>_(Ct),label:k("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:k("ui.library.page.select_asset")})})]}),f.jsx(yr,{open:j,onOpenChange:N,children:f.jsx(vr,{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:k("ui.library.page.filters")}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.page.close_filters"),onClick:()=>N(!1),children:f.jsx(He,{"aria-hidden":"true"})})]}),f.jsx("div",{"data-library-filter-sheet":"",className:"min-h-0 flex-1 overflow-y-auto bg-surface",children:se})]})})})]})},ec=Object.freeze(Object.defineProperty({__proto__:null,LibraryPage:ql},Symbol.toStringTag,{value:"Module"}));export{ge as a,U as b,b as g,ec as l};
|
|
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 vl{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 ii(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=Te(i),a=b(r,"sldSz");a&&(this.slideSize={cx:C(a,"cx",9144e3),cy:C(a,"cy",5143500)});const l=await Ke(this._files,"ppt/presentation.xml");if(this.embeddedFonts=Ua(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 Ke(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=La(Te(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=Te(h),this.masterRels=await Ke(this._files,d.fullPath),this.masterImages=await Zt(this._files,this.masterRels),this._trackBlobs(this.masterImages);const u=za(this.masterDoc);this.themeColors=Ia(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=Te(r),l=await Ke(this._files,i),o=await Zt(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=Te(v),d=await Ke(this._files,u.fullPath),h=await Zt(this._files,d),this._trackBlobs(h))}const p={...this.masterImages,...h,...o},m=pi([c,this.masterDoc]),g=Ka([a,c,this.masterDoc]);await qa(g,this.themeData);const T=s/this.slideSize.cx,y=Math.round(this.slideSize.cy*T);t.width=s,t.height=y;const w=t.getContext("2d");w.clearRect(0,0,s,y),await hi(w,a,this.masterDoc,c,l,this.masterRels,p,this.themeColors,T,this.slideSize.cx,this.slideSize.cy),await this._renderNonPlaceholders(w,this.masterDoc,this.masterRels,this.masterImages,T),await this._renderNonPlaceholders(w,c,d,h,T);const x=b(a,"cSld"),S=x?b(x,"spTree"):null;S&&await gi(w,S,l,p,this.themeColors,this.themeData,T,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 An(n,t,s)}registerFonts(n){return Oa(n)}listRegisteredFonts(){return Xa()}_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 mn(n,o,s,i,this.themeColors,this.themeData,r):c==="pic"?await gn(n,o,s,i,this.themeColors,r):c==="grpSp"?await bn(n,o,s,i,this.themeColors,this.themeData,r):c==="graphicFrame"?await vn(n,o,this.themeColors,this.themeData,r):c==="cxnSp"&&await yn(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=Te(new TextDecoder().decode(s));return Qn(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=Te(new TextDecoder().decode(s));return Zn(i)}createPlayer(n){return new ki(this,n)}async toSvg(n){return Pi(n,this)}async allToSvg(){return el(this)}async loadEmbeddedFonts(){const n=this._presRels||{};return nl(this._files,n)}listEmbeddedFonts(){return sl(this._files)}async extractSlide(n){return kn(n,this)}async extractAll(){return ul(this)}async extractText(n){return fl(n,this)}async searchSlides(n){return hl(n,this)}createShow(n,t={}){return new pl(this,n,t)}async copySlide(n,t={}){return ml(n,this,t)}async downloadSlide(n,t={}){return Ci(n,this,t)}async downloadAllSlides(n={}){return gl(this,n)}createDeck(n,t={}){return bl(this,n,t)}edit(){return ln.fromRenderer(this)}async toPdf(n={}){return Yn(this,n)}async downloadPdf(n="presentation.pdf",t={}){return Lo(this,n,t)}async slideToPdf(n,t={}){return zo(n,this,t)}async getSlideNotes(n){if(n<0||n>=this.slidePaths.length)return"";const t=await Ke(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=Te(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 wl=({asset:e,bytes:n,onOpenExternal:t,dense:s=!1,expanded:i=!1})=>{const r=$.useRef(null),a=$.useRef(null),[l,o]=$.useState({phase:"loading",progress:0}),[c,d]=$.useState(0),[h,u]=$.useState(1),[p,m]=$.useState(0),[g,T]=$.useState(!1),[y,w]=$.useState([]),[x,S]=$.useState(!s),v=$.useRef(null),[_,j]=$.useState(!1);$.useEffect(()=>{S(!s)},[s]),$.useLayoutEffect(()=>{const P=v.current;if(!P)return;const A=()=>j(P.getBoundingClientRect().height<360);A();const E=new ResizeObserver(A);return E.observe(P),()=>E.disconnect()},[]),$.useEffect(()=>{let P=!1;const A=new vl;return r.current=A,o({phase:"loading",progress:0}),d(0),u(1),A.load(n,E=>{P||o({phase:"loading",progress:E})}).then(async()=>{if(P)return;const E=A.slideCount,Y=(await A.renderAllSlides(160)).map(O=>O.toDataURL("image/png"));P||o({phase:"ready",slideCount:E,thumbnails:Y})}).catch(E=>{P||o({phase:"error",detail:E instanceof Error&&E.message?E.message:k("ui.library.preview.pptx_failed_detail")})}),()=>{P=!0,A.destroy(),r.current=null}},[n,p]);const N=$.useCallback(async()=>{const P=r.current,A=a.current;if(!(!P||!A||l.phase!=="ready"))try{await P.renderSlide(c,A,Math.round(960*h))}catch(E){o({phase:"error",detail:E instanceof Error&&E.message?E.message:k("ui.library.preview.pptx_failed_detail")})}},[c,l.phase,h]);$.useEffect(()=>{N()},[N]),$.useEffect(()=>{const P=r.current;if(!P||l.phase!=="ready")return;let A=!1;return P.extractSlide(c).then(E=>{A||w(E.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=P=>{F!==0&&d(Math.min(Math.max(P,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:k("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(P=>P+1),children:k("ui.library.preview.retry")}),f.jsxs(J,{variant:"secondary",size:"sm",disabled:g,onClick:()=>{T(!0),bt(e).catch(P=>Pe(P instanceof Error&&P.message?P.message:k("ui.library.menu.save_failed"))).finally(()=>T(!1))},children:[f.jsx(mt,{"aria-hidden":"true"}),k("ui.library.menu.download")]}),t&&f.jsxs(J,{variant:"ghost",size:"sm",onClick:t,children:[f.jsx(Bs,{"aria-hidden":"true"}),k("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:P=>{P.key==="ArrowRight"||P.key==="PageDown"?(P.preventDefault(),R(c+1)):P.key==="ArrowLeft"||P.key==="PageUp"?(P.preventDefault(),R(c-1)):P.key==="Home"?(P.preventDefault(),R(0)):P.key==="End"&&(P.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(On,{size:18,"aria-hidden":"true",className:"motion-safe:animate-spin text-ink-muted"}),f.jsx(mr,{value:Math.round(l.progress*100)}),f.jsx("span",{className:"text-meta text-ink-muted",children:k("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":k("ui.library.preview.slide_of",{index:String(c+1),count:String(F)})})}),l.phase==="ready"&&!_&&!s&&f.jsx("div",{className:"flex h-[72px] shrink-0 flex-row gap-1 overflow-x-auto overflow-y-hidden",children:l.thumbnails.map((P,A)=>f.jsx("button",{type:"button",onClick:()=>d(A),"aria-pressed":A===c,"aria-label":k("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:P,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:()=>S(P=>!P),children:k("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((P,A)=>f.jsx("p",{"data-pptx-transcript-line":"",className:"truncate",children:P},`${A}:${P}`)):f.jsx("p",{children:k("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":k("ui.library.preview.previous_slide"),disabled:c===0||l.phase!=="ready",onClick:()=>R(c-1),children:f.jsx(Wn,{"aria-hidden":"true"})}),f.jsx("span",{className:"text-meta tabular-nums text-ink-muted",children:k("ui.library.preview.slide_of",{index:String(F?c+1:0),count:String(F)})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.preview.next_slide"),disabled:c>=F-1||l.phase!=="ready",onClick:()=>R(c+1),children:f.jsx(gr,{"aria-hidden":"true"})})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.preview.zoom_out"),onClick:()=>u(P=>Math.max(.5,P-.25)),children:f.jsx(rr,{"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":k("ui.library.preview.zoom_in"),onClick:()=>u(P=>Math.min(2,P+.25)),children:f.jsx(ar,{"aria-hidden":"true"})}),f.jsx(J,{variant:"ghost",size:"sm",onClick:()=>u(1),disabled:h===1,children:k("ui.library.preview.fit")})]})]})]})},kt=({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(On,{size:16,"aria-hidden":"true",className:"motion-safe:animate-spin"}),e??k("ui.library.preview.loading")]}),_t=({detail:e,asset:n})=>{const[t,s]=$.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(Ye,{kind:n.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:k("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),bt(n).catch(i=>Pe(i instanceof Error&&i.message?i.message:k("ui.library.menu.save_failed"))).finally(()=>s(!1))},children:[f.jsx(mt,{"aria-hidden":"true"}),k("ui.library.menu.download")]})]})},Ms=({asset:e})=>(Ue(),f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Ye,{kind:e.kind,size:28,className:"text-ink-dim"}),f.jsx("p",{className:"max-w-90 text-body text-ink",children:e.kind==="other"?k("ui.library.preview.unsupported_generic"):k("ui.library.preview.unsupported",{kind:Xn(e.kind)})}),f.jsxs("div",{className:"flex items-center gap-2",children:[lt(e)?f.jsx(J,{variant:"secondary",size:"sm",onClick:()=>{const n=lt(e);n&&window.api.openFile(n)},children:k("ui.library.preview.open_externally")}):null,f.jsxs(J,{variant:"secondary",size:"sm",onClick:()=>void bt(e),children:[f.jsx(mt,{"aria-hidden":"true"}),k("ui.library.menu.download")]})]})]})),xl=72;function Dt(e,n){const t=Hn(e)?e.ref.path:null,[s,i]=$.useState(!1),r=wt(e.id,"content",!t||s),[a,l]=$.useState({bytes:null,mimeType:"",error:null,loading:!!t}),o=e.ref.content_type;return $.useEffect(()=>{if(!t)return;if(!window.api?.readFileBytes){i(!0),l({bytes:null,mimeType:"",error:k("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 kl=({asset:e,mediaSiblings:n,revision:t,expanded:s})=>{const{bytes:i,mimeType:r,error:a,loading:l}=Dt(e,t),o=xt(i,r||e.ref.content_type),c=Qs(e.id,e.kind==="audio"),d=$.useRef(null),h=$.useRef(null),u=$.useRef(null),p=$.useRef(null),[m,g]=$.useState(null),[T,y]=$.useState(null),w=$.useMemo(()=>{const _=(n??[]).filter(j=>j.kind==="image"||j.kind==="video");return _.some(j=>j.id===e.id)?[..._]:[e]},[n,e]),x=Math.max(0,w.findIndex(_=>_.id===e.id)),S=De(e);if($.useEffect(()=>{if(e.kind!=="video"||!o)return;const _=u.current,j=p.current;if(!_||!j)return;const N=()=>{const R=_.getBoundingClientRect(),P=j.getBoundingClientRect(),A=Math.max(0,P.height-xl);if(A<=0||P.width<=0){g(z=>z===null?z:null);return}const E={top:P.top-R.top,left:P.left-R.left,width:P.width,height:A};g(z=>z&&z.top===E.top&&z.left===E.left&&z.width===E.width&&z.height===E.height?z:E)};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(_),()=>{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(kt,{});if(a||!o)return f.jsx(_t,{detail:a||k("ui.library.errors.empty_bytes"),asset:e});const v=f.jsx(Aa,{open:T!==null,siblings:w,index:T??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":S,title:S,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(Ye,{kind:"audio",size:32,className:"text-ink-dim"}),f.jsx(Ds,{variant:"full",ownerId:`sound:library:${e.id}`,src:o,label:De(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":S,title:S,onClick:()=>y(x),"data-library-media-trigger":"video",className:"absolute top-2 end-2 z-[2]",children:f.jsx(Os,{"aria-hidden":"true"})})]}),v]})}},_l=({asset:e,revision:n})=>{const{bytes:t,mimeType:s,error:i,loading:r}=Dt(e,n),a=xt(t,s||e.ref.content_type);return r?f.jsx(kt,{}):i||!a?f.jsx(_t,{detail:i||k("ui.library.errors.empty_bytes"),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})},Sl=({asset:e,text:n,expanded:t,revision:s,mtimeMs:i})=>{const r=lt(e),a=r!==null&&e.exists,[l,o]=$.useState({state:"pending"});$.useEffect(()=>{if(!a||!r||i!==null)return;let h=!1;return _r(r).then(u=>{h||o({state:"done",mtimeMs:u?.mtimeMs??null})}),()=>{h=!0}},[a,r,s,i]);const c=i??(l.state==="done"?l.mtimeMs:null),d=$.useMemo(()=>!a||!r||i===null&&l.state!=="done"?null:Ca(e,n,c),[e,a,r,l,n,i,c]);return a&&d===null?f.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center",children:f.jsx(kt,{label:k("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:k("ui.library.preview.breadcrumb",{name:d.title})}),f.jsx(Sr,{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:k("ui.library.preview.read_only_markdown")}),f.jsx("div",{className:"prose-lo max-w-none text-body text-ink",children:f.jsx(or,{remarkPlugins:[lr,cr],children:n})})]})})},Tl=({asset:e,expanded:n,revision:t,mtimeMs:s})=>{const{bytes:i,error:r,loading:a}=Dt(e,t);if(a)return f.jsx(kt,{});if(r||!i)return f.jsx(_t,{detail:r||k("ui.library.errors.empty_bytes"),asset:e});const l=new TextDecoder("utf-8",{fatal:!1}).decode(i);return e.kind==="markdown"?f.jsx(Sl,{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})},Pl=({asset:e,revision:n})=>{const{bytes:t,error:s,loading:i}=Dt(e,n);return i?f.jsx(kt,{}):s||!t?f.jsx(_t,{detail:s||k("ui.library.errors.empty_bytes"),asset:e}):f.jsx(jl,{asset:e,bytes:t})},As=200,$s=40,jl=({asset:e,bytes:n})=>{const t=(()=>{try{const r=Tr(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(_t,{detail:k("ui.library.preview.sheet_unreadable"),asset:e});const s=t.rows.slice(0,As),i=t.rows.length>As;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,$s).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,$s).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:k("ui.library.preview.sheet_truncated")}),f.jsx("p",{className:"px-2 py-2 text-meta text-ink-dim",children:k("ui.library.preview.sheet_name",{name:t.name})})]})},Cl=({asset:e,dense:n=!1,expanded:t=!1,revision:s=0,mtimeMs:i=null,mediaSiblings:r})=>e.kind==="pptx"?f.jsx(Fl,{asset:e,dense:n,expanded:t,revision:s}):e.kind==="image"||e.kind==="audio"||e.kind==="video"?f.jsx(kl,{asset:e,mediaSiblings:r,revision:s,expanded:t}):e.kind==="pdf"||e.kind==="html"?f.jsx(_l,{asset:e,revision:s}):e.kind==="markdown"||e.kind==="text"||e.kind==="code"?f.jsx(Tl,{asset:e,expanded:t,revision:s,mtimeMs:i}):e.kind==="spreadsheet"?f.jsx(Pl,{asset:e,revision:s}):e.kind==="docx"?f.jsx(Ms,{asset:e}):f.jsx(Ms,{asset:e}),Fl=({asset:e,dense:n=!1,expanded:t,revision:s})=>{const{bytes:i,error:r,loading:a}=Dt(e,s);return a?f.jsx(kt,{label:k("ui.library.preview.pptx_opening")}):r||!i?f.jsx(_t,{detail:r||k("ui.library.errors.empty_bytes"),asset:e}):f.jsx(wl,{asset:e,bytes:i,dense:n,expanded:t})};function Nl(e){const n=ta(!0),t=sa().create,s=na(),[i,r]=$.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){Pe(o instanceof Error&&o.message?o.message:k("ui.library.preview.tags_not_saved"))}finally{r(!1)}},saving:i}}const Es=({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})=>{Ue();const u=Hs(),{commit:p,saving:m}=Nl(e),g=$.useRef(null),T=$.useRef(null),y=$.useRef(null),[w,x]=$.useState(0),[S,v]=$.useState(0),[_,j]=$.useState(!1),[N,F]=$.useState(e.id);N!==e.id&&(F(e.id),x(0),v(0),j(!1));const[R,P]=$.useState(!1),[A,E]=$.useState(!1),[z,Y]=$.useState({}),[O,W]=$.useState({}),[B,Z]=$.useState(0),[Q,I]=$.useState({}),X=ka(e,B),ae=Ys(),le=e.chat?.session_id??z[e.id]??null,fe=O[e.id]??R;$.useLayoutEffect(()=>{const G=g.current;if(!G)return;const oe=()=>P(G.getBoundingClientRect().height<700);oe();const pe=new ResizeObserver(oe);return pe.observe(G),()=>pe.disconnect()},[]);const ee=$.useMemo(()=>e.tags.map(G=>G.name),[e.tags]),V=!R||A,be=()=>{j(!0),E(!0)};$.useEffect(()=>{if(!_||!V)return;const G=y.current;G&&(j(!1),G.scrollIntoView({block:"center"}),v(oe=>oe+1))},[_,V]),$.useEffect(()=>{o&&(o.field==="tags"?be():(T.current?.scrollIntoView({block:"center"}),x(G=>G+1)))},[o?.signal]);const H=async G=>{try{await u.mutateAsync({id:e.id,fields:G})}catch(oe){throw Pe(oe instanceof Error&&oe.message?oe.message:k("ui.library.preview.not_saved")),oe}},re=async()=>{try{await u.mutateAsync({id:e.id,fields:{locked:!e.locked}})}catch(G){Pe(G instanceof Error&&G.message?G.message:k("ui.library.preview.not_saved"))}},ue=()=>{const G=lt(e);if(G){window.api.openFile(G);return}bt(e).catch(oe=>Pe(Mn(oe,k("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(Wn,{"aria-hidden":"true"}),k("ui.library.page.back")]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ye,{kind:e.kind,size:18,className:"text-ink-dim"}),f.jsx("div",{ref:T,className:"min-w-0 flex-1",children:f.jsx(fs,{value:De(e),onSave:G=>H({name:G}),label:k("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(Xt,{content:e.favorite?k("ui.library.menu.unfavorite"):k("ui.library.menu.favorite"),children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":e.favorite,"aria-label":e.favorite?k("ui.library.menu.unfavorite"):k("ui.library.menu.favorite"),onClick:a,children:f.jsx(un,{"aria-hidden":"true",className:e.favorite?"fill-current text-accent":void 0})})}),f.jsx(Xt,{content:e.locked?k("ui.library.preview.unlock"):k("ui.library.preview.lock"),children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":e.locked,"aria-label":e.locked?k("ui.library.preview.unlock"):k("ui.library.preview.lock"),onClick:()=>void re(),children:e.locked?f.jsx(jr,{"aria-hidden":"true",className:"text-accent"}):f.jsx(Cr,{"aria-hidden":"true"})})}),d&&f.jsx(Xt,{content:k("ui.library.preview.expand"),children:f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.preview.expand"),onClick:d,children:f.jsx(Os,{"aria-hidden":"true"})})}),f.jsx(Vn,{asset:e,onAsk:r,onEditMetadata:()=>x(G=>G+1),onEditTags:be,onToggleFavorite:a,onOpenConversation:s,onFilterSession:i}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.preview.close"),onClick:t,children:f.jsx(He,{"aria-hidden":"true"})})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta text-ink-muted",children:[f.jsx(ot,{variant:"neutral",children:Xn(e.kind)}),f.jsx(ot,{variant:"neutral",children:k(fn(e.origin_group))}),Hn(e)&&X.mtimeMs!==null&&Math.floor(X.mtimeMs/1e3)!==Math.floor(e.modified_at)?f.jsx("span",{"data-library-file-live":"",children:f.jsx("bdi",{children:nn(X.sizeBytes??e.size_bytes)})}):f.jsx("span",{children:f.jsx("bdi",{children:nn(e.size_bytes)})}),e.width&&e.height?f.jsxs("span",{children:[e.width,"×",e.height]}):null,e.remote?f.jsx(Gn,{device:Je(e),withLabel:!0}):null,e.organized?f.jsx("span",{children:Vr(e.organized.by,Hr(e.organized.at,n))}):f.jsx("span",{children:k("ui.library.preview.unorganized")}),e.exists?null:f.jsx(ot,{variant:"warning",children:k("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(Bs,{"aria-hidden":"true"}),k("ui.library.preview.open")]}),lt(e)?f.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>{const G=lt(e);G&&window.api.showItemInFolder(G)},children:[f.jsx(jn,{"aria-hidden":"true"}),k("ui.library.preview.reveal")]}):null,f.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>void bt(e).then(()=>Cn(k("ui.library.menu.saved_a_copy"))).catch(G=>Pe(Mn(G,k("ui.library.menu.save_failed")))),children:[f.jsx(mt,{"aria-hidden":"true"}),e.remote?k("ui.canvas.files.remoteDownload"):k("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:`${k("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:k("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:()=>E(G=>!G),children:[f.jsx(qs,{"aria-hidden":"true",className:ye("transition-transform duration-fast",A&&"rotate-180")}),k("ui.library.preview.details")]}),(!R||A)&&f.jsxs(f.Fragment,{children:[f.jsx(fs,{value:e.description,onSave:G=>H({description:G}),label:k("ui.library.preview.description"),placeholder:k("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(wa,{value:ee,onChange:G=>void p(G),label:k("ui.library.preview.tags"),addLabel:k("ui.library.preview.add_tag"),saving:m,startSignal:S},`${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(Cl,{asset:e,dense:R,expanded:c,revision:X.revision,mtimeMs:X.mtimeMs,mediaSiblings:h})}),le&&f.jsx(ja,{sessionId:le,title:e.chat?.title??le,collapsed:fe,onToggleCollapsed:()=>W(G=>({...G,[e.id]:!fe})),onOpenChat:()=>s(le),onUnlink:()=>{Y(G=>{const oe={...G};return delete oe[e.id],oe}),ae.mutate({id:e.id})},onTurnSettled:()=>Z(G=>G+1),onStreamingChange:G=>I(oe=>({...oe,[le]:G}))}),f.jsx("div",{className:"shrink-0",children:f.jsx(Pa,{asset:e,focusSignal:l,showLinkedRow:!le,onOpenChat:s,refreshSignal:B,streaming:le?Q[le]:!1,onSessionChange:(G,oe)=>Y(pe=>({...pe,[G]:oe}))})})]})},Ni="library-view",Mi="library-filters",Ai="library-details-width",Ml=1152,Ct=448,tn=320,$i=720,Al=320,$l=192,El=1200,Rl=900;function Ll(){try{return localStorage.getItem(Ni)==="list"?"list":"grid"}catch{return"grid"}}function zl(){try{const e=localStorage.getItem(Ai);if(!e)return Ct;const n=Number(e);return Number.isFinite(n)?Math.min($i,Math.max(tn,Math.round(n))):Ct}catch{return Ct}}function Il(){try{const e=sessionStorage.getItem(Mi);if(!e)return Ht;const n=JSON.parse(e);return{...Ht,...n,scope:n.scope==="all"?"all":"final",q:""}}catch{return Ht}}function Dl(e){try{localStorage.setItem(Ai,String(e))}catch{}}function Bl(e){try{sessionStorage.setItem(Mi,JSON.stringify({...e,q:""}))}catch{}}function Ol(){const[e,n]=$.useState(null),[t,s]=$.useState(0);return $.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 Ul(){const[e,n]=$.useState(()=>window.innerWidth);return $.useEffect(()=>{const t=()=>n(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e}const Wl=({enabled:e,nowMs:n})=>{const t=Vs(e),s=ra(),i=Rs(),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:k("ui.library.librarian.title")}),f.jsx("span",{children:r.paused?k("ui.library.librarian.paused"):r.enabled?k("ui.library.librarian.enabled"):k("ui.library.librarian.disabled")}),f.jsx("span",{children:a?k("ui.library.librarian.last_organized",{at:Gl(a,n)}):k("ui.library.librarian.never_run")}),l!==null&&l>0&&f.jsx("span",{children:k("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=>Pe(o instanceof Error?o.message:k("ui.library.librarian.control_failed"))}),children:[f.jsx(Fn,{"aria-hidden":"true"}),k("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&&Ls(i,o.session_id)},onError:o=>Pe(o instanceof Error?o.message:k("ui.library.librarian.control_failed"))}),children:k("ui.library.librarian.open")})]})]})};function Gl(e,n){const t=Math.max(0,n-e*1e3),s=Math.floor(t/36e5);return s<24?k("ui.library.time.hours_h_ago",{hours:s}):k("ui.library.time.days_d_ago",{days:Math.floor(s/24)})}const ql=({onBack:e})=>f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[f.jsx(Vt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:k("ui.library.preview.unavailable")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:k("ui.library.preview.unavailable_detail")}),f.jsxs(J,{variant:"secondary",size:"sm",onClick:e,children:[f.jsx(Wn,{"aria-hidden":"true"}),k("ui.library.page.back")]})]}),Kl=({nowMs:e})=>{Ue();const n=Rs(),t=Li(),s=zi(),i=Bn(),r=Tt(i.data,"library",1),a=Vs(r),l=e??Date.now(),{ref:o,width:c}=Ol(),d=Ul(),h=new URLSearchParams(t.search).get("full")==="1",u=d>=El&&c>=Rl,[p,m]=$.useState(Il),[g,T]=$.useState(""),y=Fr(g,200),[w,x]=$.useState(Ll),[S,v]=$.useState(zl),_=$.useCallback(L=>{v(L),Dl(L)},[]),[j,N]=$.useState(!1),[F,R]=$.useState(0),[P,A]=$.useState(null),E=$.useRef(null),z=s.assetId??null,Y=c>=Ml&&!!z&&!h,O=Math.max(tn,Math.min($i,c-(u?$l:0)-Al)),W=Math.min(S,O);$.useEffect(()=>{m(L=>L.q===y?L:{...L,q:y})},[y]),$.useEffect(()=>Bl(p),[p]),$.useEffect(()=>{try{localStorage.setItem(Ni,w)}catch{}},[w]);const B=Jr(p,r),Z=Hs(),Q=ea(z,r),I=$.useMemo(()=>{const L=B.data?.pages??[],Ce=L.length>1&&L.at(-1)?.cursor_reset?[L.at(-1)]:L,We=new Set,Le=[];for(const nt of Ce)for(const st of nt?.rows??[])We.has(st.id)||(We.add(st.id),Le.push(st));return Le},[B.data]),X=B.data?.pages.at(-1),ae=X?.total??0,le=$.useMemo(()=>I.filter(L=>L.kind==="image"||L.kind==="video"),[I]),fe=I.find(L=>L.id===z)??null,ee=Q.data??fe,V=()=>void B.fetchNextPage(),be=!!(z&&!ee&&!Q.isLoading&&Q.isError),H=!!z&&!Y,re=$.useCallback(L=>{n(`/library/assets/${L}${t.search}`,{state:t.state})},[n,t.search,t.state]),ue=$.useCallback(()=>{const L=new URLSearchParams(t.search);L.delete("full");const q=L.toString();n(`/library${q?`?${q}`:""}`)},[n,t.search]),G=$.useCallback(()=>{if(!z)return;const L=new URLSearchParams(t.search);L.set("full","1"),n(`/library/assets/${z}?${L.toString()}`)},[n,z,t.search]),oe=$.useCallback(L=>{re(L.id),R(q=>q+1)},[re]),pe=$.useRef(new Set),he=$.useCallback(L=>{pe.current.has(L.id)||(pe.current.add(L.id),Z.mutate({id:L.id,fields:{favorite:!L.favorite}},{onSettled:()=>{pe.current.delete(L.id)},onError:q=>{Pe(q instanceof Error&&q.message?q.message:k("ui.library.preview.not_saved"))}}))},[Z]),D=$.useCallback(L=>void Ls(n,L),[n]),te=$.useCallback(L=>{m(q=>({...q,session:L})),n("/library")},[n]),ne={onSelect:re,onAsk:oe,onEditMetadata:L=>{re(L.id),A({field:"metadata",signal:Date.now()})},onEditTags:L=>{re(L.id),A({field:"tags",signal:Date.now()})},onToggleFavorite:he,onOpenConversation:D,onFilterSession:te};if($.useEffect(()=>{const L=q=>{const Ce=q.target;if(Ce?.closest('[role="dialog"]'))return;const We=Ce?.tagName==="INPUT"||Ce?.tagName==="TEXTAREA"||Ce?.isContentEditable;if(q.key==="f"&&(q.metaKey||q.ctrlKey)||q.key==="/"&&!We){q.preventDefault(),E.current?.focus();return}if(!(We||q.metaKey||q.ctrlKey||q.altKey)){if(q.key==="Escape"){(z||ee)&&ue();return}if(q.key.toLowerCase()==="g"){q.preventDefault(),x(Le=>Le==="grid"?"list":"grid");return}if(q.key.toLowerCase()==="j"||q.key.toLowerCase()==="k"){if(H||I.length===0)return;q.preventDefault();const Le=z?I.findIndex(_n=>_n.id===z):-1,nt=q.key.toLowerCase()==="j"?1:-1,st=Math.min(Math.max(Le===-1?nt===1?0:I.length-1:Le+nt,0),I.length-1);re(I[st].id)}}};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[ue,re,I,ee,z,H]),!r)return f.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[f.jsx(Ii,{title:k("ui.library.page.title"),icon:Vt}),i.isLoading?f.jsx("div",{className:"flex justify-center py-16",children:f.jsx(gt,{label:k("ui.library.page.checking")})}):f.jsx(Sn,{variant:"warning",children:k("ui.library.page.unavailable")})]});const ie=a.data?.library?.total??null,se=f.jsx(va,{filters:p,onChange:L=>{m({...L,q:L.q}),T(L.q)},counts:X?.counts,tags:X?.tags??[],total:ae,scopeTotal:ie}),ve=I.length===0&&!B.isLoading,me=Gr(p)||!!g.trim(),ce=(()=>{const L=[];if(g.trim()&&L.push({key:"search",label:`${k("ui.library.page.search")}: ${g.trim()}`,clear:()=>T("")}),p.category){const q=Nn.find(Ce=>Ce.key===p.category);L.push({key:"category",label:q?k(q.labelKey):p.category,clear:()=>m(Ce=>({...Ce,category:void 0}))})}if(p.originGroup&&L.push({key:"origin",label:k(fn(p.originGroup)),clear:()=>m(q=>({...q,originGroup:void 0}))}),p.status){const q=p.status==="highlighted"?"ui.library.status.highlighted":p.status==="unorganized"?"ui.library.status.unorganized":"ui.library.status.favorites";L.push({key:"status",label:k(q),clear:()=>m(Ce=>({...Ce,status:void 0}))})}return p.highlighted&&p.status!=="highlighted"&&L.push({key:"highlighted",label:k("ui.library.status.highlighted"),clear:()=>m(q=>({...q,highlighted:!1}))}),p.tag&&L.push({key:"tag",label:`${k("ui.library.filter.tags")}: ${p.tag}`,clear:()=>m(q=>({...q,tag:void 0}))}),p.session&&L.push({key:"session",label:k("ui.library.filter.one_conversation"),clear:()=>m(q=>({...q,session:void 0}))}),(p.scope!=="final"||L.length>0)&&L.push({key:"scope",label:`${k("ui.library.filter.scope")}: ${p.scope==="all"?k("ui.library.filter.scope_all"):k("ui.library.filter.scope_final")}`,clear:()=>m(q=>({...q,scope:"final"}))}),L})(),_e=()=>{m(L=>({...Ht,scope:L.scope,sort:L.sort,order:L.order})),T("")},je=B.error instanceof Error&&B.error.message?B.error.message:k("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":k("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(Vt,{size:20,"aria-hidden":"true",className:"text-ink-muted"}),f.jsx("h1",{className:"text-title text-ink",children:k("ui.library.page.title")}),f.jsx("span",{className:"ms-2 text-meta tabular-nums text-ink-dim",children:k("ui.library.page.loaded_count",{loaded:String(I.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":k("ui.library.page.grid_view"),onClick:()=>x("grid"),children:f.jsx(dr,{"aria-hidden":"true"})}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-pressed":w==="list","aria-label":k("ui.library.page.list_view"),onClick:()=>x("list"),children:f.jsx(Nr,{"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(ur,{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(br,{ref:E,value:g,onChange:L=>T(L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.preventDefault()},placeholder:k("ui.library.page.search"),"aria-label":k("ui.library.page.search"),"data-library-search":"",className:"border-0 bg-elevated ps-8"})]}),f.jsxs(Us,{children:[f.jsx(Ws,{asChild:!0,children:f.jsxs(J,{variant:"ghost",size:"sm",className:"shrink-0 bg-elevated text-ink",children:[f.jsx(rs,{"aria-hidden":"true"}),k("ui.library.page.sort")]})}),f.jsx(Gs,{align:"end",className:"min-w-45",children:Ur.map(L=>f.jsxs(Ee,{onSelect:()=>m(q=>({...q,sort:L.key,order:Wr(L.key)})),children:[p.sort===L.key?f.jsx(yr,{"aria-hidden":"true"}):f.jsx("span",{className:"size-4"}),f.jsx("span",{children:k(L.labelKey)})]},L.key))})]}),f.jsx(J,{variant:"ghost",size:"icon-sm",className:"shrink-0","aria-label":k("ui.library.page.reverse_order"),onClick:()=>m(L=>({...L,order:L.order==="asc"?"desc":"asc"})),children:p.order==="asc"?f.jsx(Er,{"aria-hidden":"true"}):f.jsx(rs,{"aria-hidden":"true"})}),!u&&!H&&f.jsxs(J,{variant:"ghost",size:"sm",className:"bg-elevated text-ink",onClick:()=>N(!0),children:[f.jsx(Mr,{"aria-hidden":"true"}),k("ui.library.page.filters")]})]}),ce.length>0&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[ce.map((L,q)=>f.jsxs("span",{className:"contents",children:[q>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:L.label}),f.jsx("button",{type:"button","aria-label":`${k("ui.library.filter.clear_filters")} — ${L.label}`,onClick:L.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(He,{size:12,"aria-hidden":"true"})})]})]},L.key)),f.jsx(J,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-meta",onClick:_e,children:k("ui.library.page.clear_all")})]}),f.jsx("div",{"data-library-librarian-track":"",className:"min-h-10 shrink-0",children:f.jsx(Wl,{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:k("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":k("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(ga,{view:w}):B.isError&&I.length===0?f.jsxs("div",{className:"flex flex-col items-start gap-3 py-10",children:[f.jsx(Sn,{variant:"warning",children:je}),f.jsxs(J,{variant:"secondary",size:"sm",onClick:()=>void B.refetch(),children:[f.jsx(Fn,{"aria-hidden":"true"}),k("ui.library.page.retry")]})]}):ve?f.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-center",children:[f.jsx(Vt,{size:28,"aria-hidden":"true",className:"text-ink-dim"}),f.jsx("p",{className:"text-body text-ink",children:me?`${k("ui.library.page.no_matches")}: ${ce.map(L=>L.label).join(" + ")}`:k("ui.library.page.empty_title")}),f.jsx("p",{className:"max-w-90 text-body-sm text-ink-muted",children:me?k("ui.library.page.no_matches_detail"):k("ui.library.page.empty_detail")}),me&&f.jsx(J,{variant:"secondary",size:"sm",onClick:_e,children:k("ui.library.page.clear_all")})]}):f.jsxs(f.Fragment,{children:[B.isRefetchError&&f.jsx(Sn,{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(Fn,{"aria-hidden":"true"}),k("ui.library.page.retry")]})]})}),f.jsx(ma,{assets:I,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:k("ui.library.page.load_more_failed")}),f.jsx(J,{variant:"ghost",size:"sm",onClick:V,children:k("ui.library.page.retry")})]})]})})})})]}),Y&&ee&&f.jsxs(f.Fragment,{children:[f.jsx(ns,{sidebarWidth:W,onSidebarWidthChange:_,minWidth:tn,maxWidth:O,side:"left",homeEnd:"value",onDoubleClick:()=>_(Ct),label:k("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":k("ui.library.page.preview"),children:f.jsx(Es,{asset:ee,nowMs:l,onClose:ue,onOpenConversation:D,onFilterSession:te,onAsk:()=>R(L=>L+1),onToggleFavorite:()=>he(ee),composerFocusSignal:F,focusRequest:P,onExpand:G,mediaSiblings:le})})]}),H&&f.jsx("div",{"data-glass-region":"pane",className:"panel-top-pad min-w-0 flex-1 bg-surface","aria-label":k("ui.library.page.preview"),children:be?f.jsx(ql,{onBack:ue}):ee?f.jsx(Es,{asset:ee,nowMs:l,onClose:ue,onOpenConversation:D,onFilterSession:te,onAsk:()=>R(L=>L+1),onToggleFavorite:()=>he(ee),composerFocusSignal:F,focusRequest:P,mediaSiblings:le,standalone:!0}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(gt,{label:k("ui.library.preview.loading")})})}),!H&&!ee&&Y&&f.jsxs(f.Fragment,{children:[f.jsx(ns,{sidebarWidth:W,onSidebarWidthChange:_,minWidth:tn,maxWidth:O,side:"left",homeEnd:"value",onDoubleClick:()=>_(Ct),label:k("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:k("ui.library.page.select_asset")})})]}),f.jsx(vr,{open:j,onOpenChange:N,children:f.jsx(wr,{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:k("ui.library.page.filters")}),f.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":k("ui.library.page.close_filters"),onClick:()=>N(!1),children:f.jsx(He,{"aria-hidden":"true"})})]}),f.jsx("div",{"data-library-filter-sheet":"",className:"min-h-0 flex-1 overflow-y-auto bg-surface",children:se})]})})})]})},tc=Object.freeze(Object.defineProperty({__proto__:null,LibraryPage:Kl},Symbol.toStringTag,{value:"Module"}));export{ge as a,U as b,b as g,tc as l};
|