ultisuite-client/out/_next/static/chunks/4461.b0b1ab0ce5cc7e91.js
R3D347HR4Y d6d18f911b
Some checks failed
E2E / Playwright e2e (push) Has been cancelled
Lots of stuff and mobile app
2026-06-17 00:13:28 +02:00

31 lines
13 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4461],{94461:(e,t,r)=>{r.d(t,{exportDocsToDocx:()=>S});var n=r(72050),a=r(30640),o=r(79535);function i(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}async function l(e){if(!e)return null;if(e.startsWith("data:"))return e;try{var t;let r=await fetch(e,{credentials:"include"});if(!r.ok)return null;return t=await r.blob(),new Promise((e,r)=>{let n=new FileReader;n.onload=()=>e(String(n.result)),n.onerror=r,n.readAsDataURL(t)})}catch{return null}}function s(e){let t=[];e.bold&&t.push({type:"bold"}),e.italic&&t.push({type:"italic"}),e.underline&&t.push({type:"underline"});let r={};return e.fontFamily&&(r.fontFamily=e.fontFamily),null!=e.fontSizePx&&(r.fontSize=`${e.fontSizePx}px`),e.color&&(r.color=e.color),Object.keys(r).length>0&&t.push({type:"textStyle",attrs:r}),t}function c(e,t){if("text"===e.type){let r=Array.isArray(e.marks)?e.marks:[];return{...e,marks:[...r,...t]}}return Array.isArray(e.content)?{...e,content:e.content.map(e=>c(e,t))}:e}function p(e){return Array.isArray(e.content)?e.content:[]}async function d(e,t){let r=(0,o.Oy)(e);if("image"!==r.graphicType||!r.src)return"shape"===r.graphicType||r.graphicType,null;let n=await l(r.src);if(!n)return null;let a={src:n,alt:r.alt||r.altTitle||"",width:r.width,height:r.height};return("absolute"===r.placement||"fixed-on-page"===r.positionMode)&&(a.placement="absolute",a.x=r.pageX||r.x,a.y=r.pageY||r.y,a.wrap=r.wrap,a.floatSide=r.floatSide,a.rotationDeg=r.rotationDeg),{type:"image",attrs:a}}async function m(e){let t=[],r=0,n=async e=>{let a=e.type;if("docsGraphic"===a||"docsInlineGraphic"===a){let n=i(e.attrs)?e.attrs:{},s=(0,o.Oy)(n);if(("absolute"===s.placement||"fixed-on-page"===s.positionMode||"behind"===s.wrap||"in-front"===s.wrap)&&s.src){let e=await l(s.src);return t.push({nodeIndex:r,attrs:e?{...s,src:e}:s}),r+=1,null}let c=await d(n,"docsInlineGraphic"===a);return r+=1,c}if("image"===a){let t=i(e.attrs)?{...e.attrs}:{};if("string"==typeof t.src){let e=await l(t.src);e&&(t.src=e)}return r+=1,{...e,attrs:t}}if(Array.isArray(e.content)){let t=[];for(let r of e.content){let e=await n(r);e&&t.push(e)}return{...e,content:t}}return r+=1,e};return{content:await n(e)??{type:"doc",content:[]},anchoredGraphics:t}}async function w(e,t){var r;let o,l,d=(o=e=>{if("docsPageFlowSpacer"===e.type)return null;if(!Array.isArray(e.content))return e;let t=e.content.map(e=>o(e)).filter(e=>null!=e);return{...e,content:t}})(e)??{type:"doc",content:[]};return r=d,d=d=(l=e=>{let r=e.type,a=i(e.attrs)?{...e.attrs}:void 0;if(("paragraph"===r||"heading"===r)&&a){let r="string"==typeof a.styleId?a.styleId:null;if(r){let o=(0,n.v9)(t,r);if(o){if("heading"===o.blockType&&o.level)return l({type:"heading",attrs:{level:o.level,textAlign:o.textAlign??a.textAlign},content:p(e).map(e=>c(e,s(o)))});let t={...a};delete t.styleId,o.textAlign&&(t.textAlign=o.textAlign);let r={...e,attrs:t,content:p(e).map(e=>c(e,s(o)))};return Array.isArray(r.content)&&(r={...r,content:r.content.map(e=>l(e))}),r}}}return Array.isArray(e.content)?{...e,content:e.content.map(e=>l(e))}:e})(r),m(d=(0,a.G)(d))}let f=1440/25.4;function h(e){return Math.round(e*f)}async function u(e,t){var n,a;let o,i,l,s,c,p,d,m,w,f,u,{unzipSync:g,zipSync:y}=await r.e(6951).then(r.bind(r,86951)),x={...g(new Uint8Array(e))},b="word/document.xml",$=(n=x[b])?new TextDecoder().decode(n):"";return $?(x[b]=(o=h(t.widthMm),i=h(t.heightMm),l="landscape"===t.orientation||t.widthMm>t.heightMm?' w:orient="landscape"':"",s=h(t.marginsMm.top),c=h(t.marginsMm.right),p=h(t.marginsMm.bottom),d=h(t.marginsMm.left),m=h(t.headerMarginMm??t.marginsMm.top),w=h(t.footerMarginMm??t.marginsMm.bottom),f=`<w:pgSz w:w="${o}" w:h="${i}"${l}/>`,u=`<w:pgMar w:top="${s}" w:right="${c}" w:bottom="${p}" w:left="${d}" w:header="${m}" w:footer="${w}" w:gutter="0"/>`,a=/<w:sectPr\b[^>]*>[\s\S]*?<\/w:sectPr>/i.test($)?$.replace(/<w:sectPr\b[^>]*>[\s\S]*?<\/w:sectPr>/i,e=>{let t=e.replace(/<w:pgSz\b[^>]*\/?>/gi,"").replace(/<w:pgMar\b[^>]*\/?>/gi,"");return t.replace("</w:sectPr>",`${f}${u}</w:sectPr>`)}):/<w:sectPr\b[^>]*\/>/i.test($)?$.replace(/<w:sectPr\b[^>]*\/>/i,`<w:sectPr>${f}${u}</w:sectPr>`):$.replace(/<\/w:body>/i,`<w:sectPr>${f}${u}</w:sectPr></w:body>`),new TextEncoder().encode(a)),y(x)):new Uint8Array(e)}function g(e){return e?new TextDecoder().decode(e):""}function y(e){return new TextEncoder().encode(e)}async function x(e){try{let{generateDOCX:t}=await Promise.all([r.e(2184),r.e(1062),r.e(8112)]).then(r.bind(r,6304)),n=(0,a.G)(e),o=await t(n,{outputType:"uint8array"}),{unzipSync:i}=await r.e(6951).then(r.bind(r,86951)),l=i(o),s=g(l["word/document.xml"]).match(/<w:body>([\s\S]*?)<\/w:body>/i);if(s?.[1])return s[1].replace(/<w:sectPr\b[\s\S]*?<\/w:sectPr>/gi,"").replace(/<w:sectPr\b[^>]*\/>/gi,"")}catch{}let t=[],n=e=>{if(e&&"object"==typeof e){if("paragraph"===e.type||"heading"===e.type){let r=[],n=e=>{e&&"object"==typeof e&&("text"===e.type&&"string"==typeof e.text&&r.push(e.text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")),Array.isArray(e.content)&&e.content.forEach(n))};Array.isArray(e.content)&&e.content.forEach(n),t.push(`<w:p><w:r><w:t xml:space="preserve">${r.join("")}</w:t></w:r></w:p>`)}Array.isArray(e.content)&&e.content.forEach(n)}};return n(e),t.join("")}async function b(e,t,r){var n;let a;if(!e?.content)return null;let o=await x(e.content);if(r?.enabled&&r.placement===("hdr"===t?"header":"footer")){let e="center"===r.align?"center":"right"===r.align?"right":"left";o+=`<w:p><w:pPr><w:jc w:val="${e}"/></w:pPr><w:r><w:fldSimple w:instr=" PAGE "><w:r><w:t>1</w:t></w:r></w:fldSimple></w:r></w:p>`}return o.trim()?(n=o,a="hdr"===t?"header":"footer",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:${a} xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">${n}</w:${a}>`):null}function $(e,t,r,n){if(e.includes(`Id="${t}"`))return e;let a=`<Relationship Id="${t}" Type="${r}" Target="${n}"/>`;return e.replace("</Relationships>",`${a}</Relationships>`)}function P(e,t,r){if(e.includes(`PartName="/${t}"`))return e;let n=`<Override PartName="/${t}" ContentType="${r}"/>`;return e.replace("</Types>",`${n}</Types>`)}async function A(e,t){var n;let a,o,{unzipSync:i,zipSync:l}=await r.e(6951).then(r.bind(r,86951)),s={...i(e)},c=await b(t.header,"hdr",t.pageNumbers),p=await b(t.footer,"ftr",t.pageNumbers),d=t.headerFooterDifferentFirstPage?await b(t.headerFirstPage,"hdr",t.pageNumbers):null,m=t.headerFooterDifferentFirstPage?await b(t.footerFirstPage,"ftr",t.pageNumbers):null;if(!c&&!p&&!d&&!m)return e;let w=g(s["word/_rels/document.xml.rels"])||'<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>',f=g(s["[Content_Types].xml"])||'<?xml version="1.0" encoding="UTF-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>',h={};c&&(s["word/header1.xml"]=y(c),w=$(w,"rIdHeader1","http://schemas.openxmlformats.org/officeDocument/2006/relationships/header","header1.xml"),f=P(f,"word/header1.xml","application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"),h.header="rIdHeader1"),p&&(s["word/footer1.xml"]=y(p),w=$(w,"rIdFooter1","http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer","footer1.xml"),f=P(f,"word/footer1.xml","application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"),h.footer="rIdFooter1"),d&&(s["word/header2.xml"]=y(d),w=$(w,"rIdHeader2","http://schemas.openxmlformats.org/officeDocument/2006/relationships/header","header2.xml"),f=P(f,"word/header2.xml","application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"),h.headerFirst="rIdHeader2"),m&&(s["word/footer2.xml"]=y(m),w=$(w,"rIdFooter2","http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer","footer2.xml"),f=P(f,"word/footer2.xml","application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"),h.footerFirst="rIdFooter2"),s["word/_rels/document.xml.rels"]=y(w),s["[Content_Types].xml"]=y(f);let u=g(s["word/document.xml"]);return s["word/document.xml"]=y((n=!!t.headerFooterDifferentFirstPage,a=[],h.header&&a.push(`<w:headerReference w:type="default" r:id="${h.header}"/>`),h.footer&&a.push(`<w:footerReference w:type="default" r:id="${h.footer}"/>`),n&&h.headerFirst&&a.push(`<w:headerReference w:type="first" r:id="${h.headerFirst}"/>`),n&&h.footerFirst&&a.push(`<w:footerReference w:type="first" r:id="${h.footerFirst}"/>`),n&&a.push("<w:titlePg/>"),o=a.join(""),/<w:sectPr\b[^>]*>[\s\S]*?<\/w:sectPr>/i.test(u)?u.replace(/<w:sectPr\b[^>]*>([\s\S]*?)<\/w:sectPr>/i,(e,t)=>`<w:sectPr>${t.replace(/<w:headerReference\b[^>]*\/?>/gi,"").replace(/<w:footerReference\b[^>]*\/?>/gi,"").replace(/<w:titlePg\b[^>]*\/?>/gi,"")}${o}</w:sectPr>`):u.replace(/<\/w:body>/i,`<w:sectPr>${o}</w:sectPr></w:body>`))),l(s)}function v(e){return Math.round(9525*e)}function F(e){return e?new TextDecoder().decode(e):""}function T(e){return new TextEncoder().encode(e)}async function M(e,t){if(0===t.length)return e;let{unzipSync:n,zipSync:a}=await r.e(6951).then(r.bind(r,86951)),o={...n(e)},i=F(o["word/_rels/document.xml.rels"])||'<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>',l=F(o["word/document.xml"]);if(!l)return e;let s=[];for(let{attrs:e}of t){if(!e.src)continue;let t=e.src.startsWith("data:")?function(e){let t=e.match(/^data:[^;]+;base64,(.+)$/);if(!t?.[1])return null;let r=atob(t[1]),n=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)n[e]=r.charCodeAt(e);return n}(e.src):null;if(!t)continue;let r=function(e){let t=Object.keys(e).filter(e=>/^word\/media\/image\d+\./i.test(e)).map(e=>Number.parseInt(e.match(/image(\d+)/i)?.[1]??"0",10)),r=t.length>0?Math.max(...t)+1:1;return`image${r}.png`}(o);o[`word/media/${r}`]=t;let n=function(e){let t=[...e.matchAll(/Id="rId(\d+)"/gi)].map(e=>Number.parseInt(e[1]??"0",10)),r=t.length>0?Math.max(...t):0;return`rId${r+1}`}(i);i=i.replace("</Relationships>",`<Relationship Id="${n}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/${r}"/></Relationships>`),s.push(function(e,t,r){let n=v(t.width),a=v(t.height),o=v(t.pageX||t.x),i=v(t.pageY||t.y),l=6e4*t.rotationDeg,s="behind"===t.wrap?' behindDoc="1"':"",c=function(e){switch(e){case"tight":return"wrapTight";case"through":return"wrapThrough";case"top-bottom":return"wrapTopAndBottom";case"behind":case"in-front":return"wrapNone";default:return"wrapSquare"}}(t.wrap);return`<w:p><w:r><w:drawing>
<wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="${0xf000000+t.zIndex}"${s} locked="0" layoutInCell="1" allowOverlap="1">
<wp:simplePos x="0" y="0"/>
<wp:positionH relativeFrom="page"><wp:posOffset>${o}</wp:posOffset></wp:positionH>
<wp:positionV relativeFrom="page"><wp:posOffset>${i}</wp:posOffset></wp:positionV>
<wp:extent cx="${n}" cy="${a}"/>
<wp:effectExtent l="0" t="0" r="0" b="0"/>
<wp:${c} wrapText="bothSides"/>
<wp:docPr id="${Math.floor(1e5*Math.random())}" name="${r}"/>
<wp:cNvGraphicFramePr><a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/></wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="0" name="${r}"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="${e}"/>
<a:stretch><a:fillRect/></a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm rot="${l}"><a:off x="0" y="0"/><a:ext cx="${n}" cy="${a}"/></a:xfrm>
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:anchor>
</w:drawing></w:r></w:p>`}(n,e,r))}return 0===s.length?e:(o["word/_rels/document.xml.rels"]=T(i),l=l.replace(/<\/w:body>/i,`${s.join("")}</w:body>`),o["word/document.xml"]=T(l),a(o))}async function S(e){let{content:t,anchoredGraphics:n}=await w(e.body,e.paragraphStyles),{generateDOCX:a}=await Promise.all([r.e(2184),r.e(1062),r.e(8112)]).then(r.bind(r,6304)),o=await a(t,{outputType:"uint8array",title:e.title});return e.pageSetup&&(o=await u(o,e.pageSetup),o=await A(o,e.pageSetup)),n.length>0&&(o=await M(o,n)),new Blob([o],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}}}]);