1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./pptxgen.es-CN35CJsL.js","./main-Dck1T9BT.js","./react-vendor-CHQL15iE.js","./lucide-BFLOpGdB.js","./pdfjs-ji3DqnKJ.js","./markdown-W-rE_H7s.js","./katex-math-BxKHCrdI.js","./katex-math-CS4LK5N6.css","./main-IX1VYBlc.css"])))=>i.map(i=>d[i]); 2import{aj as L,p as D,h as z,_ as U}from"./main-Dck1T9BT.js";import{j as s,h as B,b as M}from"./react-vendor-CHQL15iE.js";import{c as G}from"./Tooltip-Bx_S1cbE-BOMbSZw3.js";import{c as W}from"./characterPerformance-Dba8tDt6.js";import Y from"./BlackboardMarkdown-Cizre-1w.js";import"./lucide-BFLOpGdB.js";import"./pdfjs-ji3DqnKJ.js";import"./markdown-W-rE_H7s.js";import"./katex-math-BxKHCrdI.js";function $({slide:e}){const{frame:n,blackboard:r}=e,t=!!r.trim(),o=W(n.action,{hasBlackboard:t});return s.jsxs("div",{className:"relative overflow-hidden bg-slate-900 text-white",style:{width:1600,height:900,fontFamily:'"Noto Sans SC", "Microsoft YaHei", sans-serif'},children:[s.jsx("img",{src:e.backgroundUrl,alt:"",crossOrigin:"anonymous",className:"absolute inset-0 h-full w-full object-cover"}),s.jsx("div",{className:"absolute inset-0 bg-black/10"}),e.characterUrl&&s.jsx("div",{className:"absolute bottom-0 flex h-[78%] items-end justify-center",style:{left:t?40:250,width:t?680:1100},children:s.jsx("img",{src:e.characterUrl,alt:e.characterName,crossOrigin:"anonymous",className:"h-full w-full object-contain object-bottom",style:{filter:"drop-shadow(0 10px 24px rgba(0,0,0,.35))",...o}})}),t&&s.jsx("div",{className:"absolute right-6 top-6 h-[530px] w-[720px] overflow-hidden rounded-l-xl border-8 border-amber-400 bg-black p-6 text-[22px] text-amber-50 shadow-2xl",children:s.jsx(Y,{content:r,className:"h-full overflow-hidden"})}),s.jsxs("div",{className:"absolute inset-x-12 bottom-10 h-[245px]",children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden rounded-2xl border-4 border-white/80 bg-slate-950/90 px-12 pb-10 pt-14 shadow-2xl backdrop-blur-sm",children:[s.jsx("div",{className:"text-[31px] font-semibold leading-[1.55] text-white [&_p]:m-0 [&_p]:p-0",children:s.jsx(G,{content:n.text||""})}),Array.isArray(n.choices)&&n.choices.length>0&&s.jsx("div",{className:"mt-5 flex flex-wrap gap-3 text-[19px] text-pink-100",children:n.choices.map((i,a)=>s.jsxs("span",{className:"rounded-lg border border-pink-200/50 bg-pink-500/20 px-4 py-2",children:[a+1,". ",i.text]},`${i.nextFrameId}-${a}`))})]}),s.jsx("div",{className:"absolute -top-8 left-10 z-10 min-w-[240px] rounded-xl border-4 border-white bg-pink-500 px-8 py-3 text-center text-[28px] font-black shadow-lg",children:n.speaker||e.characterName||"Narrator"})]}),s.jsxs("div",{className:"absolute right-5 top-3 rounded bg-black/45 px-3 py-1 text-sm font-bold text-white/80",children:[e.index+1," / ",e.total]})]})}const y=1600,A=900,H="/assets/local/backgrounds/default-scene.png";function v(e,n){const r=String(e||"").trim();if(!r||r.startsWith("data:")||r.startsWith("blob:"))return r;try{const t=new URL(r,n);return!["http:","https:"].includes(t.protocol)||t.origin===n?r:`/api/share/image?url=${encodeURIComponent(t.toString())}`}catch{return r}}const S=e=>typeof e=="string"?e.trim():"",X=(e,n)=>{var i;const r=e.charMetadata;if(r!=null&&r.avatarUrl||r!=null&&r.expressions)return{name:String(r.name||e.characterId||""),avatarUrl:S(r.avatarUrl),expressions:r.expressions||{}};const t=n.find(a=>a.id===String(e.characterId||"").toUpperCase()),o=z(t,e.defaultCharacterSkinId||(r==null?void 0:r.defaultSkinId));return{name:String((t==null?void 0:t.name)||((i=t==null?void 0:t.names)==null?void 0:i.zh)||(t==null?void 0:t.id)||e.characterId||""),avatarUrl:S((o==null?void 0:o.avatarUrl)||(t==null?void 0:t.avatarUrl)),expressions:(o==null?void 0:o.expressions)||(t==null?void 0:t.expressions)||{}}};function V(e,n){let r;try{r=JSON.parse(e)}catch{throw new Error("åæ¡£æ°æ®æ æ³è§£æ")}const t=r.script;if(!t||!Array.isArray(t.frames)||t.frames.length===0)throw new Error("åæ¡£ä¸æ²¡æå¯å¯¼åºçå§æ å 容");const o=String(t.title||"Paper2Gal å§æ ").trim()||"Paper2Gal å§æ ",i=String(t.summary||"").trim(),a=X(r,n),l=S(t.customBackgroun
2dUrl)||H,u=t.frames.map((c,p)=>({frame:c,index:p,total:t.frames.length,title:o,backgroundUrl:l,characterName:a.name,characterUrl:D(a.expressions,c.emotion,a.avatarUrl),blackboard:L({frames:t.frames,currentFrameIndex:p})}));return{title:o,summary:i,slides:u}}function q(e){return`${String(e).replace(/[<>:"/\\|?*\u0000-\u001f]/g,"_").trim()||"Paper2Gal"}.pptx`}const w="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",E=15e3,j=5e3,Q=2,J=["align-content","align-items","align-self","backdrop-filter","background","background-color","background-image","background-position","background-repeat","background-size","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","clear","clip","clip-path","color","content","direction","display","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","font","font-family","font-feature-settings","font-kerning","font-size","font-stretch","font-style","font-variant","font-weight","gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-row","grid-template-columns","grid-template-rows","height","inset","justify-content","justify-items","justify-self","left","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","max-height","max-width","min-height","min-width","object-fit","object-position","opacity","order","outline","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","pointer-events","position","quotes","right","row-gap","table-layout","text-align","text-decoration","text-indent","text-overflow","text-rendering","text-shadow","text-transform","top","transform","transform-origin","unicode-bidi","vertical-align","visibility","white-space","width","word-break","word-spacing","z-index"],x=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function N(e,n){let r=0;try{return await Promise.race([Promise.resolve(e),new Promise(t=>{r=window.setTimeout(t,n)})])}finally{window.clearTimeout(r)}}function K(){return Array.from(document.styleSheets).every(e=>{if(!e.href)return!0;try{return new URL(e.href,window.location.href).origin===window.location.origin}catch{return!1}})}function Z(e){return new Promise((n,r)=>{const t=new FileReader;t.onload=()=>n(String(t.result||w)),t.onerror=()=>r(t.error||new Error("å¾ç读å失败")),t.readAsDataURL(e)})}async function tt(e){if(e.startsWith("data:"))return e;const n=new AbortController,r=window.setTimeout(()=>n.abort(),E);try{const t=await fetch(e,{signal:n.signal,cache:"force-cache",credentials:"same-origin"});if(!t.ok)throw new Error(`å¾çå 载失败 (${t.status})`);return await Z(await t.blob())}catch{return w}finally{window.clearTimeout(r)}}async function et(e,n){const r=Array.from(e.querySelectorAll("img"));return await Promise.all(r.map(async t=>{const o=t.getAttribute("src")||"",i=v(o,window.location.origin);if(t.loading="eager",t.decoding="sync",t.removeAttribute("crossorigin"),!i){t.src=w;return}let a=n.get(i);a||(a=tt(i),n.set(i,a)),t.src=await a})),r}async function rt(e,n){var t;const r=await et(e,n);await x(),await x(),(t=document.fonts)!=null&&t.ready&&await N(document.fonts.ready,j),await Promise.all(r.map(o=>o.complete?Promise.resolve():new Promise(i=>{let a=0;const l=()=>{window.clearTimeout(a),o.removeEventListener("load",l),o.removeEventListener("error",l),i()};a=window.setTimeout(l,E),o.addEventListener("load",l,{once:!0}),o.addEventListener("error",l,{once:!0})}))),await Promise.race([Promise.allSettled(r.map(o=>o.decode())),new Promise(o=>window.setTimeout(o,E))]),await x()}function ot(){const e=document.createElement("div");return e.setAttribute("aria-hidden","true"),Object.assign(e.style,{position:"fixed",left:"-100000px",top:"0",width:`${y}px`,height:`${A}px`,pointerEvents:"none",overflow:"hidden"}),document.body.appendChild(e),e}async function ft({save:e,defaultCharacters:n,onProgress:r}
2){if(typeof document>"u")throw new Error("å½åç¯å¢ä¸æ¯æ PPT 导åº");const t=V(e.gameState,n),o=t.slides.length,i=new Map,a=Array.from({length:Math.min(Q,o)},()=>{const l=ot();return{mount:l,root:B.createRoot(l)}});try{const[{default:l},u]=await Promise.all([U(()=>import("./pptxgen.es-CN35CJsL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url),U(()=>import("./index-CgJtiJsK.js"),[],import.meta.url)]),c=new l;c.layout="LAYOUT_WIDE",c.author="Paper2Gal",c.company="Paper2Gal",c.title=t.title,c.subject=t.summary||t.title;let p=null;const I=d=>(p||(p=(async()=>{if(!K())return{skipFonts:!0};try{const m=await N(u.getFontEmbedCSS(d,{preferredFontFormat:"woff2"}),j);return m===void 0?{skipFonts:!0}:{fontEmbedCSS:m,skipFonts:!1}}catch{return{skipFonts:!0}}})()),p),R=async(d,m)=>{const{mount:f,root:C}=m,g=t.slides[d];M.flushSync(()=>{C.render(s.jsx($,{slide:{...g,backgroundUrl:v(g.backgroundUrl,window.location.origin),characterUrl:v(g.characterUrl,window.location.origin)}}))});const h=f.firstElementChild;if(!h)throw new Error("PPT 页颿¸²æå¤±è´¥");await rt(h,i);const{fontEmbedCSS:O,skipFonts:F}=await I(h);return u.toJpeg(h,{width:y,height:A,canvasWidth:y,canvasHeight:A,pixelRatio:1,quality:.92,backgroundColor:"#0f172a",cacheBust:!1,includeQueryParams:!0,imagePlaceholder:w,fontEmbedCSS:O,skipFonts:F,includeStyleProperties:J,skipAutoScale:!0})},P=new Array(o);let b=0,k=0,T=null;r==null||r({current:0,total:o});const _=(await Promise.allSettled(a.map(async d=>{for(;b<o&&!T;){const m=b;b+=1;try{P[m]=await R(m,d),k+=1,r==null||r({current:k,total:o})}catch(f){throw T=f,f}}}))).find(d=>d.status==="rejected");if(_)throw _.reason;for(const d of P){if(!d)throw new Error("PPT 页颿¸²æå¤±è´¥");c.addSlide().addImage({data:d,x:0,y:0,w:13.333,h:7.5})}await c.writeFile({fileName:q(e.displayTitle||e.chapterTitle||t.title),compression:!0})}finally{for(const{mount:l,root:u}of a)u.unmount(),l.remove()}}export{ft as exportSaveToPpt};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.