import{X as e,al as t,an as r,E as n,ae as o,aN as a,as as i,a1 as s,q as l,ap as c,aV as d,S as u,a2 as p,a0 as h,cp as g,dx as m,dy as w,cY as f,U as v}from"./index-WdfADTOW.js";import{V as x,a as y}from"./index-ddUXWqR4.js";var b=c("<div style=width:100%;height:100%;overflow:auto;position:relative;background:#f5f5f5><div id=docx-container style=width:100%;height:100%;padding:20px>");const j=()=>{const c=l(),[j,E]=e(!0),[F,k]=e(!1),[z,C]=e(!1);let L,_;const P=(e,t)=>new Promise((r,n)=>{if(document.getElementById(t))return void r();const o=document.createElement("script");o.src=e,o.id=t,o.type="text/javascript",o.onload=()=>r(),o.onerror=()=>n(new h(`Failed to load script: ${e}`)),document.head.appendChild(o)}),$=()=>{L&&(document.fullscreenElement?document.exitFullscreen().then(()=>{C(!1)}):L.requestFullscreen().then(()=>{C(!0)}))},B=()=>{document.fullscreenElement||C(!1)};return t(()=>{(async()=>{try{if(E(!0),k(!1),await P("static/jszip/jszip.min.js","jszip-script"),await P("static/docxjs/dist/docx-preview.min.js","docx-preview-script"),!window.docx)throw new h("docx-preview library not loaded");const e=v.raw_url,t=await fetch(e);if(!t.ok)throw new h("Failed to fetch document file");const r=await t.blob();_&&(await window.docx.renderAsync(r,_,void 0,{className:"docx-preview-container",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,ignoreFonts:!1,breakPages:!0,ignoreLastRenderedPageBreak:!0,experimental:!1,trimXmlDeclaration:!0,useBase64URL:!1,useMathMLPolyfill:!1,renderChanges:!1,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0}),E(!1))}catch(e){console.error("DOCX初始化失败:",e),k(!0),E(!1);if(location.hash){let o=document.querySelector(location.hash);o&&o.scrollIntoView()}}})(),document.addEventListener("fullscreenchange",B)}),r(()=>{document.removeEventListener("fullscreenchange",B)}),n(f,{w:"$full",h:"70vh",pos:"relative",get children(){return[n(o,{pos:"absolute",top:"$2",right:"$2",zIndex:"10",opacity:"0.7",transition:"opacity 0.2s",_hover:{opacity:"1"},get children(){return n(a,{withArrow:!0,get label(){return s(()=>!!z())()?c("home.preview.exit_fullscreen"):c("home.preview.fullscreen")},get children(){return n(i,{size:"sm",colorScheme:"neutral","aria-label":"Toggle Fullscreen",get icon(){return s(()=>!!z())()?n(x,{}):n(y,{})},onClick:$})}})}}),(e=b(),t=e.firstChild,"function"==typeof L?w(L,e):L=e,"function"==typeof _?w(_,t):_=t,d(e,n(u,{get when(){return j()},get children(){return n(p,{})}}),null),d(e,n(u,{get when(){return F()},get children(){return n(h,{get msg(){return c("preview.failed_load_doc")},h:"70vh"})}}),null),g(e=>m(t,"display",j()||F()?"none":"block")),e)];var e,t}})};export{j as default};
