fika-editor 3.3.2 → 3.4.1

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.
@@ -1 +1 @@
1
- export const __rspack_esm_id=655;export const __rspack_esm_ids=[655];export const __webpack_modules__={93554(t,e,i){i.d(e,{exportMynaSvg:()=>C});var a=i(49615),r=i(86239),l=i(84970),o=i(90816),n=i(39581),s=i(14381);let h=t=>t.radius?(0,s.CQ)(t.radius,t.width,t.height):t.outline?.radius?(0,s.lo)(t.outline.radius,t.width,t.height):t.clip?.shape==="roundRect"?(0,s.CQ)(10,t.width,t.height):0,d=t=>{let e=t.clip?.shape;return e&&n.$R[e]?.type||"rect"},p=t=>{let e=t.clip?.shape,i=e?n.$R[e]:void 0;if(i?.type==="polygon"&&i.createPath)return i.createPath(t.width,t.height)};var c=i(17579),m=i(43004),g=i(57147),u=i(3775),$=i(1066),f=i(87239),w=i(57093),x=i(32729),y=i(17585),b=i(10987),v=i(72482);let S=t=>String(t??"").replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"})[t]),k=t=>Number.isFinite(t)?+t.toFixed(4):0,M=t=>new Promise((e,i)=>{let a=new FileReader;a.onload=()=>e(String(a.result)),a.onerror=i,a.readAsDataURL(t)});function A(t){let e=document.createElement("canvas").getContext("2d"),i=[],a=[],l="",o="",n=()=>` transform="${S(l)}" opacity="${e.globalAlpha}"`,s={save:()=>{e.save(),a.push(l)},restore:()=>{e.restore(),l=a.pop()||""},translate:(t,e)=>{l+=` translate(${k(t)} ${k(e)})`},rotate:t=>{l+=` rotate(${k(180*t/Math.PI)})`},fillText:(t,a,r)=>{let l=document.createElement("span").style;l.font=e.font;let o=`font-style="${S(l.fontStyle)}" font-weight="${S(l.fontWeight)}" font-size="${S(l.fontSize)}" font-family="${S(l.fontFamily)}"`;i.push(`<text x="${k(a)}" y="${k(r)}" ${o} fill="${S(e.fillStyle)}" letter-spacing="${S(e.letterSpacing||"0px")}" text-anchor="${"right"===e.textAlign?"end":"start"}" xml:space="preserve"${n()}>${S(t)}</text>`)},beginPath:()=>{o=""},moveTo:(t,e)=>{o+=`M${k(t)} ${k(e)}`},lineTo:(t,e)=>{o+=`L${k(t)} ${k(e)}`},stroke:()=>i.push(`<path d="${o}" fill="none" stroke="${S(e.strokeStyle)}" stroke-width="${e.lineWidth}"${n()}/>`),drawImage:(t,e,a,r,l)=>{let o=document.createElement("canvas");o.width=t.width,o.height=t.height,o.getContext("2d").drawImage(t,0,0),i.push(`<image href="${o.toDataURL()}" x="${k(e)}" y="${k(a)}" width="${k(r)}" height="${k(l)}"${n()}/>`)}},h=new Proxy(e,{get:(t,e)=>s[String(e)]||("function"==typeof Reflect.get(t,e)?Reflect.get(t,e).bind(t):Reflect.get(t,e)),set:(t,e,i)=>Reflect.set(t,e,i)});return(0,r.u)(h,t),i.join("")}async function C(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{slide:i,theme:r,viewportSize:n,viewportRatio:C}=t,X=n*C,Y=[],z=[],j=0,P=()=>`fika-svg-${++j}`,F=()=>e.signal?.throwIfAborted();F(),await document.fonts?.ready;let I=e.selectedIds?new Set(e.selectedIds):null,R=new Set(i.elements.filter(t=>I?.has(t.id)&&t.groupId).map(t=>t.groupId)),E=I?new Set((0,a.ly)(i.elements,i.elements.filter(t=>I.has(t.id)||t.groupId&&R.has(t.groupId)).map(t=>t.id))):null,W=i.elements.filter(t=>!E||E.has(t.id));if(!W.length&&I)throw Error("No elements selected for SVG export");let B=I?W.flatMap(t=>{let e=(0,o.a5)([t]),r=(0,a.Kn)(t,i.elements);if(!r)return[e];if(!r.length)return[];let l={minX:Math.max(e.minX,Math.min(...r.map(t=>t.x))),minY:Math.max(e.minY,Math.min(...r.map(t=>t.y))),maxX:Math.min(e.maxX,Math.max(...r.map(t=>t.x))),maxY:Math.min(e.maxY,Math.max(...r.map(t=>t.y)))};return l.maxX>=l.minX&&l.maxY>=l.minY?[l]:[]}):[],T=I&&B.length?{minX:Math.min(...B.map(t=>t.minX)),minY:Math.min(...B.map(t=>t.minY)),maxX:Math.max(...B.map(t=>t.maxX)),maxY:Math.max(...B.map(t=>t.maxY))}:I?(0,o.a5)(W):{minX:0,minY:0,maxX:n,maxY:X},O=I?Math.max(0,...W.map(t=>{let e="line"===t.type?t.width:"outline"in t&&t.outline?.width||0,i="shadow"in t?t.shadow:void 0;return("line"===t.type&&t.points.some(Boolean)?5*e:e/2)+(i?Math.max(Math.abs(i.h),Math.abs(i.v))+2*i.blur:0)})):0,_=T.minX-O,q=T.minY-O,L=Math.max(1,T.maxX-T.minX+2*O),N=Math.max(1,T.maxY-T.minY+2*O),H=new Map,G=t=>t.startsWith("data:")?Promise.resolve(t):(H.has(t)||H.set(t,(async()=>{try{let i=await fetch(t,{signal:e.signal?AbortSignal.any([e.signal,AbortSignal.timeout(15e3)]):AbortSignal.timeout(15e3)});if(!i.ok)throw Error(`${i.status}`);return await M(await i.blob())}catch(i){F();let e=await (0,$.w)()?.(t);if(e?.startsWith("data:"))return e;throw Error(`Cannot embed export image: ${t}`,{cause:i})}})()),H.get(t)),D=t=>{let e=P(),i=t.colors.map(t=>`<stop offset="${t.pos}%" stop-color="${S(t.color)}"/>`).join("");return z.push("radial"===t.type?`<radialGradient id="${e}">${i}</radialGradient>`:`<linearGradient id="${e}" x1="0" y1="0.5" x2="1" y2="0.5" gradientTransform="rotate(${k(t.rotate)} .5 .5)">${i}</linearGradient>`),`url(#${e})`},U=t=>{var e,i;return t?.width?`stroke="${S(t.color)}" stroke-width="${t.width}" stroke-dasharray="${(e=t.style,i=t.width,"dashed"===e?i<=6?[4.5*i,2*i]:[4*i,1.5*i]:"dotted"===e?i<=6?[1.8*i,1.6*i]:[1.5*i,1.2*i]:void 0)?.join(" ")||"none"}"`:'stroke="none"'},V=(t,e,i,a)=>`<rect width="${k(t)}" height="${k(e)}" fill="${S(i||"none")}" ${U(a)}/>`,K=t=>{let e="text"===t.type?t:t.text;if(!e?.content)return"";let a=(0,c.K5)(e.defaultColor||r.fontColor,e.content,{element:t,elements:i.elements,fill:t.fill,background:i.background,fallbackSurface:r.backgroundColor,themeFontColor:r.fontColor}),l="text"===t.type?(0,g.tl)(t,i.type):{vAlign:t.text?.align};return A({html:a.html,x:0,y:0,width:t.width,height:t.height,defaultFontFamily:(0,m.C0)(e.defaultFontName||r.fontName),defaultColor:a.ink,lineHeight:e.lineHeight,letterSpacing:e.wordSpace,paragraphSpace:e.paragraphSpace,inset:e.inset,vAlign:l.vAlign,fit:"text"===t.type?(0,u.j6)(t):!1!==e.fixedHeight,vertical:"text"===t.type&&t.vertical})},Q=async(e,a)=>{Y.push(`${e.name||e.id}: ${a}; embedded as a raster image.`);let r="shadow"in e?e.shadow:void 0,n=Math.max(32,r?Math.max(Math.abs(r.h),Math.abs(r.v))+2*r.blur:0),s=(0,o.a5)([e]),h=s.minX-n,d=s.minY-n,p=Math.max(1,s.maxX-s.minX+2*n),c=Math.max(1,s.maxY-s.minY+2*n),m={...e,left:e.left-h,top:e.top-d},g=await (0,l.t)({...t,slide:{...i,elements:[m],background:void 0},viewportSize:p,viewportRatio:c/p},{width:Math.ceil(2*p),transparentBackground:!0,fullResolutionImages:!0,timeoutMs:15e3});return`<image x="${k(h)}" y="${k(d)}" width="${k(p)}" height="${k(c)}" href="${await M(g.blob)}"/>`},J=t=>{let e=[],i=new Set,a=t.data.length,l=t.colWidths.length,n=t.colWidths.reduce((t,e)=>t+e,0)||1,s=t.colWidths.map(e=>e/n*t.width),h=Math.max(t.cellMinHeight,t.height/a);for(let n=0;n<a;n++){let a=0;for(let d=0;d<l;d++){let l=t.data[n][d],p=s[d];if(!l||i.has(`${n}:${d}`)){a+=p;continue}let g=Math.max(1,l.colspan),u=Math.max(1,l.rowspan),$=s.slice(d,d+g).reduce((t,e)=>t+e,0),f=h*u;for(let t=n;t<n+u;t++)for(let e=d;e<d+g;e++)i.add(`${t}:${e}`);let w=l.style||{},x=t.theme?(0,o.gk)(t.theme.color):void 0;for(let[i,r,l,o,s]of(e.push(`<g transform="translate(${k(a)} ${k(n*h)})">${V($,f,(0,c.mc)(t,n,d)||(x?n%2?x.stripe:x.stripeAlt:"none"))}`),[[w.borderTopWidth,0,0,$,0],[w.borderRightWidth,$,0,$,f],[w.borderBottomWidth,0,f,$,f],[w.borderLeftWidth,0,0,0,f]]))e.push(`<path d="M${r} ${l}L${o} ${s}" ${U({...t.outline,width:i??t.outline?.width})}/>`);let y=P();z.push(`<clipPath id="${y}">${V($,f,"#fff")}</clipPath>`);let b=`font-size:${w.fontsize||"14px"};color:${w.color||r.fontColor};font-family:${w.fontname||r.fontName};text-align:${w.align||"left"};font-weight:${w.bold?"bold":"normal"};font-style:${w.em?"italic":"normal"};text-decoration:${w.underline?"underline":""} ${w.strikethrough?"line-through":""}`;e.push(`<g clip-path="url(#${y})">${A({html:`<p style="${S(b)}">${S(l.text).replace(/\n/g,"<br>")}</p>`,x:0,y:0,width:$,height:f,defaultFontFamily:(0,m.C0)(w.fontname||r.fontName),defaultColor:w.color||r.fontColor,defaultSize:parseFloat(w.fontsize||"14"),lineHeight:1.45,paragraphSpace:0,inset:[10,14,10,14],vAlign:w.vAlign||"middle",align:w.align||"left"})}</g></g>`),a+=p}}return e.join("")},Z=[];if(!I&&!e.transparentBackground){let t=i.background;if(Z.push(V(n,X,t?.type==="gradient"&&t.gradient?D(t.gradient):t?.color||r.backgroundColor||"#fff")),t?.type==="image"&&t.image){let e=await G(t.image.src);if("repeat"===t.image.size){let t=new Image;t.src=e,await t.decode();let i=P();z.push(`<pattern id="${i}" patternUnits="userSpaceOnUse" width="${t.naturalWidth}" height="${t.naturalHeight}"><image href="${S(e)}" width="${t.naturalWidth}" height="${t.naturalHeight}"/></pattern>`),Z.push(V(n,X,`url(#${i})`))}else Z.push(`<image width="${n}" height="${X}" preserveAspectRatio="xMidYMid ${"contain"===t.image.size?"meet":"slice"}" href="${S(e)}"/>`)}}for(let t of(x.Y([b.a]),W)){F();let e=(0,a.Kn)(t,i.elements);if(e&&!e.length)continue;let l="";if(e){let t=P();z.push(`<clipPath id="${t}" clipPathUnits="userSpaceOnUse"><polygon points="${e.map(t=>`${k(t.x)},${k(t.y)}`).join(" ")}"/></clipPath>`),l=t}let n=e=>Z.push(l?`<g clip-path="url(#${l})" data-element-id="${S(t.id)}"${t.groupId?` data-group-id="${S(t.groupId)}"`:""}>${e}</g>`:e);if(t.effects&&Object.keys(t.effects).length||"text"===t.type&&/data-latex|math-inline|math-node/.test(t.content)){n(await Q(t,"Advanced effect or inline mathematics"));continue}let m="",g="",u=`translate(${k(t.left)} ${k(t.top)})`;if("line"!==t.type&&(u+=` rotate(${k(t.rotate||0)} ${k(t.width/2)} ${k(t.height/2)})`,"flipH"in t&&t.flipH&&(u+=` translate(${t.width} 0) scale(-1 1)`),"flipV"in t&&t.flipV&&(u+=` translate(0 ${t.height}) scale(1 -1)`)),"image"!==t.type&&"opacity"in t&&(g+=` opacity="${t.opacity??1}"`),"shadow"in t&&t.shadow){let e=P(),i=t.shadow;z.push(`<filter id="${e}" x="-100%" y="-100%" width="300%" height="300%"><feDropShadow dx="${i.h}" dy="${i.v}" stdDeviation="${i.blur/2}" flood-color="${S(i.color)}"/></filter>`),g+=` filter="url(#${e})"`}switch(t.type){case"text":m=V(t.width,t.height,t.fill||"none",t.outline)+K(t);break;case"shape":{let e=P(),i=`<path d="${S((0,s.js)(t))}" transform="scale(${t.width/t.viewBox[0]} ${t.height/t.viewBox[1]})" fill-rule="evenodd"`;m=`${i} fill="${S(t.gradient?D(t.gradient):t.fill||"none")}" ${U(t.outline)} vector-effect="non-scaling-stroke"/>`,t.pattern&&(z.push(`<clipPath id="${e}">${i}/></clipPath>`),m+=`<image width="${t.width}" height="${t.height}" preserveAspectRatio="xMidYMid slice" href="${S(await G(t.pattern))}" clip-path="url(#${e})"/>`),m+=K(t);break}case"image":{if(t.colorMask||t.filters&&Object.entries(t.filters).some(t=>{let[e,i]=t;return"opacity"!==e&&i&&parseFloat(i)!==(["brightness","contrast","saturate"].includes(e)?i.includes("%")?100:1:0)})){n(await Q(t,"Image color effect"));continue}let e=P(),i=d(t),a=p(t),r="ellipse"===i?`<ellipse cx="${t.width/2}" cy="${t.height/2}" rx="${t.width/2}" ry="${t.height/2}"/>`:a?`<path d="${S(a)}"/>`:`<rect width="${t.width}" height="${t.height}" rx="${h(t)}"/>`;z.push(`<clipPath id="${e}">${r}</clipPath>`);let[[l,o],[s,c]]=t.clip?.range||[[0,0],[100,100]],u=100*t.width/Math.max(.001,s-l),$=100*t.height/Math.max(.001,c-o),f=await G(t.src);m=`<g clip-path="url(#${e})">${function(t,e,i,a,r,l){if(!/^data:image\/svg\+xml[;,]/i.test(t))return null;let o=t.indexOf(","),n=t.slice(0,o).includes(";base64")?new TextDecoder().decode(Uint8Array.from(atob(t.slice(o+1)),t=>t.charCodeAt(0))):decodeURIComponent(t.slice(o+1)),s=new DOMParser().parseFromString(n,"image/svg+xml");if(s.querySelector("parsererror")||"svg"!==s.documentElement.localName)throw Error("Invalid SVG media");let h=s.documentElement;if(h.querySelector("style,foreignObject"))return null;for(let t of h.querySelectorAll("script,foreignObject,iframe,object,embed,animate,animateTransform,set"))t.remove();let d=new Map;for(let t of h.querySelectorAll("[id]")){let i=t.id;d.set(i,`${e}-${d.size}`),t.id=d.get(i)}for(let t of[h,...h.querySelectorAll("*")])for(let e of[...t.attributes]){if(/^on/i.test(e.name)){t.removeAttribute(e.name);continue}let i=e.value;if("href"===e.localName&&!i.startsWith("#")&&!i.startsWith("data:image/")){t.removeAttributeNode(e);continue}for(let[t,e]of d)(i=i.split(`url(#${t})`).join(`url(#${e})`))===`#${t}`&&(i=`#${e}`);t.setAttribute(e.name,i)}for(let t of h.querySelectorAll("style"))t.remove();return h.hasAttribute("viewBox")||h.setAttribute("viewBox",`0 0 ${parseFloat(h.getAttribute("width")||"")||r} ${parseFloat(h.getAttribute("height")||"")||l}`),h.setAttribute("x",String(i)),h.setAttribute("y",String(a)),h.setAttribute("width",String(r)),h.setAttribute("height",String(l)),h.setAttribute("preserveAspectRatio","none"),new XMLSerializer().serializeToString(h)}(f,P(),-u*l/100,-$*o/100,u,$)||`<image x="${-u*l/100}" y="${-$*o/100}" width="${u}" height="${$}" preserveAspectRatio="none" href="${S(f)}"/>`}</g>`,t.outline?.width&&(m+=r.replace("/>",` fill="none" ${U(t.outline)}/>`));let w="opacity"in t&&"number"==typeof t.opacity?t.opacity:1;(t.filters?.opacity||1!==w)&&(g+=` opacity="${w*(t.filters?.opacity?parseFloat(t.filters.opacity)/(t.filters.opacity.includes("%")?100:1):1)}"`);break}case"line":{let e=t.points.map((e,i)=>{if(!e)return"";let a=P();return z.push(`<marker id="${a}" viewBox="0 0 10 10" refX="${"dot"===e?5:9}" refY="5" markerWidth="${"dot"===e?3:5}" markerHeight="${"dot"===e?3:5}" orient="auto-start-reverse">${"dot"===e?`<circle cx="5" cy="5" r="4" fill="${S(t.color)}"/>`:`<path d="M0 0L10 5L0 10Z" fill="${S(t.color)}"/>`}</marker>`),`marker-${i?"end":"start"}="url(#${a})"`}).join(" ");m=`<path d="${S((0,o.QV)(t))}" fill="none" ${U({color:t.color,width:t.width,style:t.style})} ${e}/>`;break}case"table":m=J(t);break;case"chart":{let e=y.Ts(null,null,{renderer:"svg",ssr:!0,width:t.width,height:t.height});try{let a=(0,c.Kb)(t,{background:i.background,fallbackSurface:r.backgroundColor}),l=(0,w.Y1)({type:t.chartType,data:t.data,themeColors:(0,w.kt)(a),textColor:(0,c.gJ)(t,{background:i.background,fallbackSurface:r.backgroundColor,fontColor:r.fontColor}),lineColor:t.lineColor||v.ic,lineSmooth:t.options?.lineSmooth||!1,stack:t.options?.stack||!1,fontSize:t.options?.fontSize,width:t.width}),o=t=>Array.isArray(t)?t.map(o):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(t=>{let[e,i]=t;return[e,"fontFamily"===e&&"string"==typeof i?i.replace(/"/g,"'"):o(i)]})):t,n=o(l);e.setOption({...n,animation:!1});let s=new DOMParser().parseFromString(e.renderToSVGString(),"image/svg+xml");if(s.querySelector("parsererror"))throw Error("Chart SVG could not be serialized");let h=P(),d=new Map;for(let t of s.querySelectorAll("[id]"))d.set(t.id,`${h}-${d.size}`),t.id=d.get(t.id);for(let t of s.querySelectorAll("*")){for(let e of[...t.attributes]){let i=e.value;for(let[t,e]of d)(i=i.split(`url(#${t})`).join(`url(#${e})`))===`#${t}`&&(i=`#${e}`);"class"===e.name&&(i=i.split(/\s+/).map(t=>`${h}-${t}`).join(" ")),t.setAttribute(e.name,i)}"style"===t.localName&&(t.textContent=(t.textContent||"").replace(/\.(zr[\w-]+)/g,`.${h}-$1`))}m=V(t.width,t.height,t.fill||"none",t.outline)+new XMLSerializer().serializeToString(s.documentElement)}finally{e.dispose()}break}case"latex":if(t.path){m=`<path d="${S(t.path)}" fill="${S(t.color)}" stroke="${S(t.color)}" stroke-width="${t.strokeWidth||0}" transform="scale(${t.width/t.viewBox[0]} ${t.height/t.viewBox[1]})"/>`;break}n(await Q(t,"Typeset mathematics"));continue;default:n(await Q(t,"video"===t.type||"audio"===t.type?"Static media preview":`${t.type} rendering`));continue}n(`<g id="${P()}"${!l?` data-element-id="${S(t.id)}"${t.groupId?` data-group-id="${S(t.groupId)}"`:""}`:""} transform="${u}"${g}><title>${S(t.name||t.type)}</title>${m}</g>`)}F();let tt=P();z.push(`<clipPath id="${tt}"><rect x="${k(_)}" y="${k(q)}" width="${k(L)}" height="${k(N)}"/></clipPath>`);let te=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${k(L)}" height="${k(N)}" viewBox="${k(_)} ${k(q)} ${k(L)} ${k(N)}"><defs>${z.join("")}</defs><g clip-path="url(#${tt})">${Z.join("")}</g></svg>`,ti=new DOMParser().parseFromString(te,"image/svg+xml");if(ti.querySelector("parsererror"))throw Error("SVG export produced invalid XML");let ta=ti.documentElement.lastElementChild,tr=null;for(let t of[...ta.children]){let e=t.getAttribute("data-group-id");if(!e){tr=null;continue}tr&&tr.getAttribute("data-group-id")===e||((tr=ti.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("id",P()),tr.setAttribute("data-group-id",e),ta.insertBefore(tr,t)),tr.appendChild(t)}return te=await (0,f.gg)(new XMLSerializer().serializeToString(ti.documentElement)),F(),{svg:te,blob:new Blob([te],{type:"image/svg+xml"}),width:L,height:N,warnings:Y}}}};
1
+ export const __rspack_esm_id=655;export const __rspack_esm_ids=[655];export const __webpack_modules__={93554(e,t,i){i.d(t,{exportMynaSvg:()=>C});var a=i(49615),r=i(86239),l=i(84970),o=i(90816),n=i(39581),s=i(14381);let h=e=>e.radius?(0,s.CQ)(e.radius,e.width,e.height):e.outline?.radius?(0,s.lo)(e.outline.radius,e.width,e.height):e.clip?.shape==="roundRect"?(0,s.CQ)(10,e.width,e.height):0,d=e=>{let t=e.clip?.shape;return t&&n.$R[t]?.type||"rect"},p=e=>{let t=e.clip?.shape,i=t?n.$R[t]:void 0;if(i?.type==="polygon"&&i.createPath)return i.createPath(e.width,e.height)};var c=i(17579),m=i(43004),g=i(57147),u=i(3775),$=i(1066),f=i(87239),w=i(57093),x=i(32729),y=i(17585),b=i(10987),v=i(72482);let S=e=>String(e??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"})[e]),k=e=>Number.isFinite(e)?+e.toFixed(4):0,M=e=>new Promise((t,i)=>{let a=new FileReader;a.onload=()=>t(String(a.result)),a.onerror=i,a.readAsDataURL(e)});function A(e){let t=document.createElement("canvas").getContext("2d"),i=[],a=[],l="",o="",n=()=>` transform="${S(l)}" opacity="${t.globalAlpha}"`,s={save:()=>{t.save(),a.push(l)},restore:()=>{t.restore(),l=a.pop()||""},translate:(e,t)=>{l+=` translate(${k(e)} ${k(t)})`},rotate:e=>{l+=` rotate(${k(180*e/Math.PI)})`},fillText:(e,a,r)=>{let l=document.createElement("span").style;l.font=t.font;let o=`font-style="${S(l.fontStyle)}" font-weight="${S(l.fontWeight)}" font-size="${S(l.fontSize)}" font-family="${S(l.fontFamily)}"`;i.push(`<text x="${k(a)}" y="${k(r)}" ${o} fill="${S(t.fillStyle)}" letter-spacing="${S(t.letterSpacing||"0px")}" text-anchor="${"right"===t.textAlign?"end":"start"}" xml:space="preserve"${n()}>${S(e)}</text>`)},beginPath:()=>{o=""},moveTo:(e,t)=>{o+=`M${k(e)} ${k(t)}`},lineTo:(e,t)=>{o+=`L${k(e)} ${k(t)}`},stroke:()=>i.push(`<path d="${o}" fill="none" stroke="${S(t.strokeStyle)}" stroke-width="${t.lineWidth}"${n()}/>`),drawImage:(e,t,a,r,l)=>{let o=document.createElement("canvas");o.width=e.width,o.height=e.height,o.getContext("2d").drawImage(e,0,0),i.push(`<image href="${o.toDataURL()}" x="${k(t)}" y="${k(a)}" width="${k(r)}" height="${k(l)}"${n()}/>`)}},h=new Proxy(t,{get:(e,t)=>s[String(t)]||("function"==typeof Reflect.get(e,t)?Reflect.get(e,t).bind(e):Reflect.get(e,t)),set:(e,t,i)=>Reflect.set(e,t,i)});return(0,r.u)(h,e),i.join("")}async function C(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{slide:i,theme:r,viewportSize:n,viewportRatio:C}=e,X=n*C,Y=[],z=[],P=0,j=()=>`fika-svg-${++P}`,F=()=>t.signal?.throwIfAborted();F(),await document.fonts?.ready;let I=t.selectedIds?new Set(t.selectedIds):null,E=new Set(i.elements.filter(e=>I?.has(e.id)&&e.groupId).map(e=>e.groupId)),R=I?new Set((0,a.ly)(i.elements,i.elements.filter(e=>I.has(e.id)||e.groupId&&E.has(e.groupId)).map(e=>e.id))):null,W=i.elements.filter(e=>!R||R.has(e.id));if(!W.length&&I)throw Error("No elements selected for SVG export");let T=I?W.flatMap(e=>{let t=(0,o.a5)([e]),r=(0,a.Kn)(e,i.elements);if(!r)return[t];if(!r.length)return[];let l={minX:Math.max(t.minX,Math.min(...r.map(e=>e.x))),minY:Math.max(t.minY,Math.min(...r.map(e=>e.y))),maxX:Math.min(t.maxX,Math.max(...r.map(e=>e.x))),maxY:Math.min(t.maxY,Math.max(...r.map(e=>e.y)))};return l.maxX>=l.minX&&l.maxY>=l.minY?[l]:[]}):[],B=I&&T.length?{minX:Math.min(...T.map(e=>e.minX)),minY:Math.min(...T.map(e=>e.minY)),maxX:Math.max(...T.map(e=>e.maxX)),maxY:Math.max(...T.map(e=>e.maxY))}:I?(0,o.a5)(W):{minX:0,minY:0,maxX:n,maxY:X},L=I?Math.max(0,...W.map(e=>{let t="line"===e.type?e.width:"outline"in e&&e.outline?.width||0,i="shadow"in e?e.shadow:void 0;return("line"===e.type&&e.points.some(Boolean)?5*t:t/2)+(i?Math.max(Math.abs(i.h),Math.abs(i.v))+2*i.blur:0)})):0,O=B.minX-L,_=B.minY-L,q=Math.max(1,B.maxX-B.minX+2*L),N=Math.max(1,B.maxY-B.minY+2*L),H=new Map,G=e=>e.startsWith("data:")?Promise.resolve(e):(H.has(e)||H.set(e,(async()=>{try{let i=await fetch(e,{signal:t.signal?AbortSignal.any([t.signal,AbortSignal.timeout(15e3)]):AbortSignal.timeout(15e3)});if(!i.ok)throw Error(`${i.status}`);return await M(await i.blob())}catch(i){F();let t=await (0,$.w)()?.(e);if(t?.startsWith("data:"))return t;throw Error(`Cannot embed export image: ${e}`,{cause:i})}})()),H.get(e)),D=e=>{let t=j(),i=e.colors.map(e=>`<stop offset="${e.pos}%" stop-color="${S(e.color)}"/>`).join("");return z.push("radial"===e.type?`<radialGradient id="${t}">${i}</radialGradient>`:`<linearGradient id="${t}" x1="0" y1="0.5" x2="1" y2="0.5" gradientTransform="rotate(${k(e.rotate)} .5 .5)">${i}</linearGradient>`),`url(#${t})`},U=e=>{var t,i;return e?.width?`stroke="${S(e.color)}" stroke-width="${e.width}" stroke-dasharray="${(t=e.style,i=e.width,"dashed"===t?i<=6?[4.5*i,2*i]:[4*i,1.5*i]:"dotted"===t?i<=6?[1.8*i,1.6*i]:[1.5*i,1.2*i]:void 0)?.join(" ")||"none"}"`:'stroke="none"'},V=(e,t,i,a)=>`<rect width="${k(e)}" height="${k(t)}" fill="${S(i||"none")}" ${U(a)}/>`,Q=e=>{let t="text"===e.type?e:e.text;if(!t?.content)return"";let a=(0,c.resolveLiveTextPaint)(t.defaultColor||r.fontColor,t.content,{element:e,elements:i.elements,fill:e.fill,background:i.background,fallbackSurface:r.backgroundColor,themeFontColor:r.fontColor}),l="text"===e.type?(0,g.tl)(e,i.type):{vAlign:e.text?.align};return A({html:a.html,x:0,y:0,width:e.width,height:e.height,defaultFontFamily:(0,m.C0)(t.defaultFontName||r.fontName),defaultColor:a.ink,lineHeight:t.lineHeight,letterSpacing:t.wordSpace,paragraphSpace:t.paragraphSpace,inset:t.inset,vAlign:l.vAlign,fit:"text"===e.type?(0,u.j6)(e):!1!==t.fixedHeight,vertical:"text"===e.type&&e.vertical})},K=async(t,a)=>{Y.push(`${t.name||t.id}: ${a}; embedded as a raster image.`);let r="shadow"in t?t.shadow:void 0,n=Math.max(32,r?Math.max(Math.abs(r.h),Math.abs(r.v))+2*r.blur:0),s=(0,o.a5)([t]),h=s.minX-n,d=s.minY-n,p=Math.max(1,s.maxX-s.minX+2*n),c=Math.max(1,s.maxY-s.minY+2*n),m={...t,left:t.left-h,top:t.top-d},g=await (0,l.renderSlideImage)({...e,slide:{...i,elements:[m],background:void 0},viewportSize:p,viewportRatio:c/p},{width:Math.ceil(2*p),transparentBackground:!0,fullResolutionImages:!0,timeoutMs:15e3});return`<image x="${k(h)}" y="${k(d)}" width="${k(p)}" height="${k(c)}" href="${await M(g.blob)}"/>`},Z=e=>{let t=[],i=new Set,a=e.data.length,l=e.colWidths.length,n=e.colWidths.reduce((e,t)=>e+t,0)||1,s=e.colWidths.map(t=>t/n*e.width),h=Math.max(e.cellMinHeight,e.height/a);for(let n=0;n<a;n++){let a=0;for(let d=0;d<l;d++){let l=e.data[n][d],p=s[d];if(!l||i.has(`${n}:${d}`)){a+=p;continue}let g=Math.max(1,l.colspan),u=Math.max(1,l.rowspan),$=s.slice(d,d+g).reduce((e,t)=>e+t,0),f=h*u;for(let e=n;e<n+u;e++)for(let t=d;t<d+g;t++)i.add(`${e}:${t}`);let w=l.style||{},x=e.theme?(0,o.gk)(e.theme.color):void 0;for(let[i,r,l,o,s]of(t.push(`<g transform="translate(${k(a)} ${k(n*h)})">${V($,f,(0,c.resolveTableCellFill)(e,n,d)||(x?n%2?x.stripe:x.stripeAlt:"none"))}`),[[w.borderTopWidth,0,0,$,0],[w.borderRightWidth,$,0,$,f],[w.borderBottomWidth,0,f,$,f],[w.borderLeftWidth,0,0,0,f]]))t.push(`<path d="M${r} ${l}L${o} ${s}" ${U({...e.outline,width:i??e.outline?.width})}/>`);let y=j();z.push(`<clipPath id="${y}">${V($,f,"#fff")}</clipPath>`);let b=`font-size:${w.fontsize||"14px"};color:${w.color||r.fontColor};font-family:${w.fontname||r.fontName};text-align:${w.align||"left"};font-weight:${w.bold?"bold":"normal"};font-style:${w.em?"italic":"normal"};text-decoration:${w.underline?"underline":""} ${w.strikethrough?"line-through":""}`;t.push(`<g clip-path="url(#${y})">${A({html:`<p style="${S(b)}">${S(l.text).replace(/\n/g,"<br>")}</p>`,x:0,y:0,width:$,height:f,defaultFontFamily:(0,m.C0)(w.fontname||r.fontName),defaultColor:w.color||r.fontColor,defaultSize:parseFloat(w.fontsize||"14"),lineHeight:1.45,paragraphSpace:0,inset:[10,14,10,14],vAlign:w.vAlign||"middle",align:w.align||"left"})}</g></g>`),a+=p}}return t.join("")},J=[];if(!I&&!t.transparentBackground){let e=i.background;if(J.push(V(n,X,e?.type==="gradient"&&e.gradient?D(e.gradient):e?.color||r.backgroundColor||"#fff")),e?.type==="image"&&e.image){let t=await G(e.image.src);if("repeat"===e.image.size){let e=new Image;e.src=t,await e.decode();let i=j();z.push(`<pattern id="${i}" patternUnits="userSpaceOnUse" width="${e.naturalWidth}" height="${e.naturalHeight}"><image href="${S(t)}" width="${e.naturalWidth}" height="${e.naturalHeight}"/></pattern>`),J.push(V(n,X,`url(#${i})`))}else J.push(`<image width="${n}" height="${X}" preserveAspectRatio="xMidYMid ${"contain"===e.image.size?"meet":"slice"}" href="${S(t)}"/>`)}}for(let e of(x.Y([b.a]),W)){F();let t=(0,a.Kn)(e,i.elements);if(t&&!t.length)continue;let l="";if(t){let e=j();z.push(`<clipPath id="${e}" clipPathUnits="userSpaceOnUse"><polygon points="${t.map(e=>`${k(e.x)},${k(e.y)}`).join(" ")}"/></clipPath>`),l=e}let n=t=>J.push(l?`<g clip-path="url(#${l})" data-element-id="${S(e.id)}"${e.groupId?` data-group-id="${S(e.groupId)}"`:""}>${t}</g>`:t);if(e.effects&&Object.keys(e.effects).length||"text"===e.type&&/data-latex|math-inline|math-node/.test(e.content)){n(await K(e,"Advanced effect or inline mathematics"));continue}let m="",g="",u=`translate(${k(e.left)} ${k(e.top)})`;if("line"!==e.type&&(u+=` rotate(${k(e.rotate||0)} ${k(e.width/2)} ${k(e.height/2)})`,"flipH"in e&&e.flipH&&(u+=` translate(${e.width} 0) scale(-1 1)`),"flipV"in e&&e.flipV&&(u+=` translate(0 ${e.height}) scale(1 -1)`)),"image"!==e.type&&"opacity"in e&&(g+=` opacity="${e.opacity??1}"`),"shadow"in e&&e.shadow){let t=j(),i=e.shadow;z.push(`<filter id="${t}" x="-100%" y="-100%" width="300%" height="300%"><feDropShadow dx="${i.h}" dy="${i.v}" stdDeviation="${i.blur/2}" flood-color="${S(i.color)}"/></filter>`),g+=` filter="url(#${t})"`}switch(e.type){case"text":m=V(e.width,e.height,e.fill||"none",e.outline)+Q(e);break;case"shape":{let t=j(),i=`<path d="${S((0,s.js)(e))}" transform="scale(${e.width/e.viewBox[0]} ${e.height/e.viewBox[1]})" fill-rule="evenodd"`;m=`${i} fill="${S(e.gradient?D(e.gradient):e.fill||"none")}" ${U(e.outline)} vector-effect="non-scaling-stroke"/>`,e.pattern&&(z.push(`<clipPath id="${t}">${i}/></clipPath>`),m+=`<image width="${e.width}" height="${e.height}" preserveAspectRatio="xMidYMid slice" href="${S(await G(e.pattern))}" clip-path="url(#${t})"/>`),m+=Q(e);break}case"image":{if(e.colorMask||e.filters&&Object.entries(e.filters).some(e=>{let[t,i]=e;return"opacity"!==t&&i&&parseFloat(i)!==(["brightness","contrast","saturate"].includes(t)?i.includes("%")?100:1:0)})){n(await K(e,"Image color effect"));continue}let t=j(),i=d(e),a=p(e),r="ellipse"===i?`<ellipse cx="${e.width/2}" cy="${e.height/2}" rx="${e.width/2}" ry="${e.height/2}"/>`:a?`<path d="${S(a)}"/>`:`<rect width="${e.width}" height="${e.height}" rx="${h(e)}"/>`;z.push(`<clipPath id="${t}">${r}</clipPath>`);let[[l,o],[s,c]]=e.clip?.range||[[0,0],[100,100]],u=100*e.width/Math.max(.001,s-l),$=100*e.height/Math.max(.001,c-o),f=await G(e.src);m=`<g clip-path="url(#${t})">${function(e,t,i,a,r,l){if(!/^data:image\/svg\+xml[;,]/i.test(e))return null;let o=e.indexOf(","),n=e.slice(0,o).includes(";base64")?new TextDecoder().decode(Uint8Array.from(atob(e.slice(o+1)),e=>e.charCodeAt(0))):decodeURIComponent(e.slice(o+1)),s=new DOMParser().parseFromString(n,"image/svg+xml");if(s.querySelector("parsererror")||"svg"!==s.documentElement.localName)throw Error("Invalid SVG media");let h=s.documentElement;if(h.querySelector("style,foreignObject"))return null;for(let e of h.querySelectorAll("script,foreignObject,iframe,object,embed,animate,animateTransform,set"))e.remove();let d=new Map;for(let e of h.querySelectorAll("[id]")){let i=e.id;d.set(i,`${t}-${d.size}`),e.id=d.get(i)}for(let e of[h,...h.querySelectorAll("*")])for(let t of[...e.attributes]){if(/^on/i.test(t.name)){e.removeAttribute(t.name);continue}let i=t.value;if("href"===t.localName&&!i.startsWith("#")&&!i.startsWith("data:image/")){e.removeAttributeNode(t);continue}for(let[e,t]of d)(i=i.split(`url(#${e})`).join(`url(#${t})`))===`#${e}`&&(i=`#${t}`);e.setAttribute(t.name,i)}for(let e of h.querySelectorAll("style"))e.remove();return h.hasAttribute("viewBox")||h.setAttribute("viewBox",`0 0 ${parseFloat(h.getAttribute("width")||"")||r} ${parseFloat(h.getAttribute("height")||"")||l}`),h.setAttribute("x",String(i)),h.setAttribute("y",String(a)),h.setAttribute("width",String(r)),h.setAttribute("height",String(l)),h.setAttribute("preserveAspectRatio","none"),new XMLSerializer().serializeToString(h)}(f,j(),-u*l/100,-$*o/100,u,$)||`<image x="${-u*l/100}" y="${-$*o/100}" width="${u}" height="${$}" preserveAspectRatio="none" href="${S(f)}"/>`}</g>`,e.outline?.width&&(m+=r.replace("/>",` fill="none" ${U(e.outline)}/>`));let w="opacity"in e&&"number"==typeof e.opacity?e.opacity:1;(e.filters?.opacity||1!==w)&&(g+=` opacity="${w*(e.filters?.opacity?parseFloat(e.filters.opacity)/(e.filters.opacity.includes("%")?100:1):1)}"`);break}case"line":{let t=e.points.map((t,i)=>{if(!t)return"";let a=j();return z.push(`<marker id="${a}" viewBox="0 0 10 10" refX="${"dot"===t?5:9}" refY="5" markerWidth="${"dot"===t?3:5}" markerHeight="${"dot"===t?3:5}" orient="auto-start-reverse">${"dot"===t?`<circle cx="5" cy="5" r="4" fill="${S(e.color)}"/>`:`<path d="M0 0L10 5L0 10Z" fill="${S(e.color)}"/>`}</marker>`),`marker-${i?"end":"start"}="url(#${a})"`}).join(" ");m=`<path d="${S((0,o.QV)(e))}" fill="none" ${U({color:e.color,width:e.width,style:e.style})} ${t}/>`;break}case"table":m=Z(e);break;case"chart":{let t=y.Ts(null,null,{renderer:"svg",ssr:!0,width:e.width,height:e.height});try{let a=(0,c.resolveChartElementSeriesColors)(e,{background:i.background,fallbackSurface:r.backgroundColor}),l=(0,w.Y1)({type:e.chartType,data:e.data,themeColors:(0,w.kt)(a),textColor:(0,c.resolveChartLabelColor)(e,{background:i.background,fallbackSurface:r.backgroundColor,fontColor:r.fontColor}),lineColor:e.lineColor||v.ic,lineSmooth:e.options?.lineSmooth||!1,stack:e.options?.stack||!1,fontSize:e.options?.fontSize,width:e.width}),o=e=>Array.isArray(e)?e.map(o):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(e=>{let[t,i]=e;return[t,"fontFamily"===t&&"string"==typeof i?i.replace(/"/g,"'"):o(i)]})):e,n=o(l);t.setOption({...n,animation:!1});let s=new DOMParser().parseFromString(t.renderToSVGString(),"image/svg+xml");if(s.querySelector("parsererror"))throw Error("Chart SVG could not be serialized");let h=j(),d=new Map;for(let e of s.querySelectorAll("[id]"))d.set(e.id,`${h}-${d.size}`),e.id=d.get(e.id);for(let e of s.querySelectorAll("*")){for(let t of[...e.attributes]){let i=t.value;for(let[e,t]of d)(i=i.split(`url(#${e})`).join(`url(#${t})`))===`#${e}`&&(i=`#${t}`);"class"===t.name&&(i=i.split(/\s+/).map(e=>`${h}-${e}`).join(" ")),e.setAttribute(t.name,i)}"style"===e.localName&&(e.textContent=(e.textContent||"").replace(/\.(zr[\w-]+)/g,`.${h}-$1`))}m=V(e.width,e.height,e.fill||"none",e.outline)+new XMLSerializer().serializeToString(s.documentElement)}finally{t.dispose()}break}case"latex":if(e.path){m=`<path d="${S(e.path)}" fill="${S(e.color)}" stroke="${S(e.color)}" stroke-width="${e.strokeWidth||0}" transform="scale(${e.width/e.viewBox[0]} ${e.height/e.viewBox[1]})"/>`;break}n(await K(e,"Typeset mathematics"));continue;default:n(await K(e,"video"===e.type||"audio"===e.type?"Static media preview":`${e.type} rendering`));continue}n(`<g id="${j()}"${!l?` data-element-id="${S(e.id)}"${e.groupId?` data-group-id="${S(e.groupId)}"`:""}`:""} transform="${u}"${g}><title>${S(e.name||e.type)}</title>${m}</g>`)}F();let ee=j();z.push(`<clipPath id="${ee}"><rect x="${k(O)}" y="${k(_)}" width="${k(q)}" height="${k(N)}"/></clipPath>`);let et=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${k(q)}" height="${k(N)}" viewBox="${k(O)} ${k(_)} ${k(q)} ${k(N)}"><defs>${z.join("")}</defs><g clip-path="url(#${ee})">${J.join("")}</g></svg>`,ei=new DOMParser().parseFromString(et,"image/svg+xml");if(ei.querySelector("parsererror"))throw Error("SVG export produced invalid XML");let ea=ei.documentElement.lastElementChild,er=null;for(let e of[...ea.children]){let t=e.getAttribute("data-group-id");if(!t){er=null;continue}er&&er.getAttribute("data-group-id")===t||((er=ei.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("id",j()),er.setAttribute("data-group-id",t),ea.insertBefore(er,e)),er.appendChild(e)}return et=await (0,f.gg)(new XMLSerializer().serializeToString(ei.documentElement)),F(),{svg:et,blob:new Blob([et],{type:"image/svg+xml"}),width:q,height:N,warnings:Y}}}};