polotno 4.0.0-beta.46 → 4.0.0-beta.47
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/package.json +2 -2
- package/polotno.bundle.js +1 -1
- package/utils/validate-key.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.47",
|
|
4
4
|
"description": "Design Editor Framework",
|
|
5
5
|
"author": "Anton Lavrenov",
|
|
6
6
|
"keywords": [
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"react-konva-utils": "^2.0.0",
|
|
115
115
|
"react-sortablejs": "6.1.4",
|
|
116
116
|
"react-window": "^1.8.11",
|
|
117
|
-
"render-tag": "^0.1.
|
|
117
|
+
"render-tag": "^0.1.15",
|
|
118
118
|
"sortablejs": "^1.15.7",
|
|
119
119
|
"svg-round-corners": "^0.4.3",
|
|
120
120
|
"swr": "^2.4.1",
|
package/polotno.bundle.js
CHANGED
|
@@ -510,7 +510,7 @@ https://polotno.com/docs/server-api`,n_={unsplashList:({query:e,page:t=1})=>`${Q
|
|
|
510
510
|
`);for(let t=0;t<a.length;t++)if(t>0&&n.push({text:`
|
|
511
511
|
`,width:0,style:r.style,isSpace:!1,boxStyle:r.boxStyle}),a[t]){let o=n.length;oM(e,a[t],r,n),i(o)}}else{let a=n.length;oM(e,t,r,n),i(a)}}return n}function cM(e){let t=e.codePointAt(0)||0;return t>=19968&&t<=40959||t>=13312&&t<=19903||t>=12288&&t<=12351||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=44032&&t<=55215||t>=65280&&t<=65519||t>=131072&&t<=173791}var lM;function uM(){return lM||(typeof Intl<`u`&&Intl.Segmenter?(lM=new Intl.Segmenter(void 0,{granularity:`grapheme`}),lM):null)}var dM=/\p{Extended_Pictographic}/u;function fM(e){for(let t of e)if(t.codePointAt(0)>=126976)return!0;return e.includes(``)||e.includes(`️`)?dM.test(e):!1}function pM(e,t,n,r){let i=[...t.text].some(cM),a=dM.test(t.text)&&!!uM(),o=t.width>n&&(t.style.overflowWrap===`break-word`||t.style.wordBreak===`break-all`);if(!i&&!a&&!o)return[t];if(o&&t.style.wordBreak!==`break-all`&&t.style.overflowWrap===`break-word`){let r=t.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/).filter(e=>e.length);if(r.length>1){e.font=Fj(t.style),e.letterSpacing=Nj(t.style.letterSpacing);let i=[];for(let a of r){let r=jj(e,a);r<=n?i.push({...t,text:a,width:r}):i.push(...pM(e,{...t,text:a,width:r},n,0))}return i}}e.font=Fj(t.style),e.letterSpacing=Nj(t.style.letterSpacing);let s=a?uM():null,c=s?[...s.segment(t.text)].map(e=>e.segment):[...t.text],l=[],u=``,d=0;for(let r of c){if(a&&fM(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0),l.push({...t,text:r,width:jj(e,r)});continue}if(cM(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0);let n=jj(e,r);l.push({...t,text:r,width:n});continue}let i=u+r,s=jj(e,i);if(o&&s>n&&u){l.push({...t,text:u,width:d}),u=r,d=jj(e,r);continue}u=i,d=s}return u&&l.push({...t,text:u,width:d}),l}var mM=/^[,.\;:!?\)\]\}'"»›]+$/;function hM(e,t,n,r,i=!1,a=0){let o=[],s={words:[],totalWidth:0,lineHeight:0},c=r===`nowrap`||r===`pre`,l=()=>n-(o.length===0?a:0),u=r===`pre-wrap`||r===`pre`||r===`pre-line`,d=r===`pre`||r===`pre-wrap`||r===`break-spaces`;function f(t=!1){let i=s.words.length>0;if(!(r===`break-spaces`||d&&!t))for(;s.words.length>0&&s.words[s.words.length-1].isSpace;)s.totalWidth-=s.words[s.words.length-1].width,s.words.pop();if(t&&s.words.length>0){let t=s.words[s.words.length-1];if(t.isSoftHyphenBreak){Mj(e,t.style);let n=jj(e,`-`);s.words.push({text:`-`,width:n,style:t.style,isSpace:!1}),s.totalWidth+=n}}if(s.words.length>0||i&&u){if(Oj){let e=s.words.map(e=>e.text).join(``);Oj({type:`line-commit`,message:`Line ${o.length}: "${e}" width=${s.totalWidth.toFixed(2)} / ${n}`,data:{lineIndex:o.length,text:e,totalWidth:s.totalWidth,contentWidth:n}})}o.push(s)}s={words:[],totalWidth:0,lineHeight:0}}let p=!0;for(let r=0;r<t.length;r++){let a=t[r],u=Hj(e,a.style,i);if(a.boxStyle&&a.boxStyle.display===`inline-block`){let e=a.boxStyle;u=Math.max(u,u+e.paddingTop+e.paddingBottom+e.marginTop+e.marginBottom+e.borderTopWidth+e.borderBottomWidth)}if(a.text===`
|
|
512
512
|
`){s.words.length===0?(s.lineHeight=u,s.endedByHardBreak=!0,o.push(s),s={words:[],totalWidth:0,lineHeight:0}):(s.endedByHardBreak=!0,f()),p=!0;continue}if(c){s.words.push(a),s.totalWidth+=a.width,s.lineHeight=Math.max(s.lineHeight,u);continue}if(!a.isSpace&&a.text&&!a.noBreakBefore&&!a.boxOpen&&!a.boxClose){let n=r;for(;n+1<t.length;){let e=t[n+1];if(!e.text||e.isSpace||e.boxOpen||e.boxClose||!e.noBreakBefore)break;n++}if(n>r){let o=a.style.overflowWrap===`break-word`||a.style.wordBreak===`break-all`,c=0;for(let e=r;e<=n;e++)c+=t[e].width;let u=[];for(let e=r;e<=n;e++)for(let n of[...t[e].text])u.push({ch:n,style:t[e].style});let d=u.map(e=>e.ch).join(``).split(/(?<=-)(?!\d)|(?<=[^\d]-)/).filter(e=>e.length),m=d.length>1;if(!(s.totalWidth+c<=l())&&(m||o&&c>l())){let t=[],a=0;for(let e of d){let n=[...e].length;t.push(u.slice(a,a+n)),a+=n}let c=(t,n)=>{let r=0;for(;r<t.length;){let a=t[r].style;Mj(e,a),e.letterSpacing=Nj(a.letterSpacing);let o=Hj(e,a,i),c=``,u=0;for(;r<t.length&&t[r].style===a;){let i=t[r].ch,d=jj(e,c+i);n&&s.totalWidth+d>l()&&(s.words.length>0||c)?(c&&(s.words.push({text:c,width:u,style:a,isSpace:!1}),s.totalWidth+=u,s.lineHeight=Math.max(s.lineHeight,o)),f(!0),p=!1,c=i,u=jj(e,i)):(c+=i,u=d),r++}c&&(s.words.push({text:c,width:u,style:a,isSpace:!1}),s.totalWidth+=u,s.lineHeight=Math.max(s.lineHeight,o),p=!1)}},h=t=>{let n=0,r=0;for(;r<t.length;){let i=t[r].style,a=``;for(;r<t.length&&t[r].style===i;)a+=t[r].ch,r++;Mj(e,i),e.letterSpacing=Nj(i.letterSpacing),n+=jj(e,a)}return n};!m&&s.words.length>0&&(f(!0),p=!1);for(let e of t){let t=h(e);s.words.length>0&&s.totalWidth+t>l()&&(f(!0),p=!1),c(e,o&&t>l())}r=n;continue}}}let m=!a.isSpace&&a.text.length>1?pM(e,a,l(),s.totalWidth):[a],h=0;for(let e=r+1;e<t.length;e++){let n=t[e];if(n.isSpace||n.text===`
|
|
513
|
-
`)break;let r=!!n.text&&mM.test(n.text),i=!n.text&&!!n.boxClose,a=!!n.text&&!!n.noBreakBefore;if(r||i||a){h+=n.width;continue}break}for(let i of m){let a=i===m[m.length-1]?h:0,o=!i.isSpace&&i.text.length>0&&mM.test(i.text)&&s.words.length>0&&!s.words[s.words.length-1].isSpace,c=i===m[0]&&i.noBreakBefore&&s.words.length>0&&!s.words[s.words.length-1].isSpace,g=0;if(!i.text&&i.boxOpen){let n=t[r+1];n&&!n.isSpace&&n.text&&(g=(n.text.length>1?pM(e,n,l(),0):[n])[0].width)}let _=0;if(i.isSoftHyphenBreak&&(Mj(e,i.style),e.letterSpacing=Nj(i.style.letterSpacing),_=jj(e,`-`)),!i.isSpace&&!o&&!c&&s.words.length>0&&s.totalWidth+i.width+_+a+g>l()){let t=s.totalWidth+i.width+_+a+g-l(),r=!0;if(t<1&&!dse([...s.words,i])){Mj(e,i.style);let t=s.words.map(e=>e.text).join(``)+i.text+(i.isSoftHyphenBreak?`-`:``),n=0;for(let e of s.words)e.text||(n+=e.width);i.text||(n+=i.width),jj(e,t)+n+a+g<=l()+.02&&(r=!1)}if(r&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){Mj(e,i.style);let n=``,r=0,a=0,o=l()-s.totalWidth;for(;a<t.length;a++){let i=n+t[a],s=jj(e,i);if(s>o)break;n=i,r=s}if(a>0&&a<t.length){s.words.push({...i,text:n,width:r}),s.totalWidth+=r,s.lineHeight=Math.max(s.lineHeight,u),f(!0),p=!1;let o=t.slice(a).join(``),c=jj(e,o);s.words.push({...i,text:o,width:c}),s.totalWidth+=c,s.lineHeight=Math.max(s.lineHeight,u);continue}}}if(r){if(Oj){let e=s.words.map(e=>e.text).join(``);Oj({type:`line-wrap`,message:`"${i.text}" overflow=${t.toFixed(2)} wrap=true lineWidth=${s.totalWidth.toFixed(2)} pieceWidth=${i.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:i.text,overflow:t,lineWidth:s.totalWidth,pieceWidth:i.width,contentWidth:n,lineText:e}})}f(!0),p=!1}}if(i.isSpace&&s.words.length===0&&(!p||!d))continue;let v=i.width;if(i.isTab){let e=i.width,t=s.totalWidth;v=Math.ceil((t+.1)/e)*e-t,i.width=v}if(s.words.length===0&&v>l()&&!i.isSpace&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){Mj(e,i.style);let n=t.filter(e=>e).map(t=>({...i,text:t,width:jj(e,t)})),r=!0;for(let e of n)r?(r=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u)):s.totalWidth+e.width>l()?(f(!0),p=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u)):(s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u));continue}}s.words.push(i),s.totalWidth+=v,s.lineHeight=Math.max(s.lineHeight,u),i.isSpace||(p=!1)}}return f(),o}function gM(e,t,n,r,i,a=!1){let o=[],s=nM(t);if(s.length===0)return{nodes:o,height:0};let c=sM(e,s),l=t.style.textIndent||0,u=hM(e,c,i,t.style.whiteSpace,a,l),d=t.style.lineClamp;if(d>0&&u.length>d){u.length=d;let t=u[d-1];tM(e,t,i-(d===1?l:0)),t.endedByHardBreak=!0}let f=t.style.direction===`rtl`,p=e=>e===`start`?f?`right`:`left`:e===`end`?f?`left`:`right`:e,m=p(t.style.textAlign),h=t.style.textAlignLast||`auto`;h=h===`auto`?t.style.textAlign===`justify`?f?`right`:`left`:m:p(h);let g=r;for(let t=0;t<u.length;t++){let r=u[t];if(r.words.length===0){g+=r.lineHeight;continue}let a=r.lineHeight,s=t===u.length-1,c=t===0,d=s||r.endedByHardBreak?h:m,p=c?l:0,_=i-p,v=0;if(d===`justify`&&r.totalWidth<_){let e=r.words.filter(e=>e.isSpace).length;e>0&&(v=(_-r.totalWidth)/e)}let y=r.totalWidth>_+.5,b=n+p;y?b=f?n+_-r.totalWidth:n+p:d===`center`?b=n+p+(_-r.totalWidth)/2:d===`right`?b=(f?n+_:n+p+_)-r.totalWidth:d===`justify`&&f&&(b=n+_-r.totalWidth);let x=b,S=0,C=0;for(let t of r.words){if(t.text===``||Zj(t.style.verticalAlign))continue;let{ascent:n,descent:r}=Yj(e,t.style);n>S&&(S=n),r>C&&(C=r)}if(S===0)for(let t of r.words){if(t.text===``)continue;let{ascent:n,descent:r}=Yj(e,t.style);S=n,C=r;break}let w=S+C,T=g+(a-w)/2+S,E=r.words.filter(e=>e.text!==``&&!Zj(e.style.verticalAlign)),D=E.length>0?Math.max(...E.map(e=>e.style.fontSize)):0,O=g,k=g+a;for(let t of r.words){if(t.text===``)continue;let n=t.style.verticalAlign;if(!Zj(n))continue;if(D===0)break;let{ascent:r,descent:i}=Yj(e,t.style),o=T+Xj(n,r,i,D,S,C,a),s=o-r,c=o+i;s<O&&(O=s),c>k&&(k=c)}let A=k-O,j=(t,n,r)=>{let{ascent:i,descent:a}=Yj(e,t),s=t.paddingTop+t.borderTopWidth,c=t.paddingBottom+t.borderBottomWidth,l=i+a+s+c,u;u=t.display===`inline-block`?g+t.marginTop:T-i-s,o.push({type:`box`,style:t,x:n,y:u,width:r,height:l,tagName:`span`,children:[]})};if(!f){let e=b,t=e,n,i=!1;for(let a of r.words){if(a.boxOpen&&a.boxClose&&a.text){n&&(i&&j(n,t,e-t),n=void 0,i=!1);let r=a.style,o=a.width-r.marginLeft-r.borderLeftWidth-r.paddingLeft-r.paddingRight-r.borderRightWidth-r.marginRight;j(r,e+r.marginLeft,r.borderLeftWidth+r.paddingLeft+o+r.paddingRight+r.borderRightWidth),i=!1,e+=a.width;continue}a.boxStyle!==n&&(n&&i&&j(n,t,e-t),n=a.boxStyle,t=e,i=!1),a.text&&!a.isSpace&&(i=!0),e+=a.width+(a.isSpace?v:0)}n&&i&&j(n,t,e-t)}let M=r.words.filter(e=>e.text!==``),ee=M.length>0&&M.every(e=>Qj(e.style,M[0].style));if(f){let t=[],n=null,i=0;for(let e of r.words){if(e.text===``){n&&=(t.push(n),null),i+=e.width;continue}if(e.isSpace&&v>0){n&&=(t.push(n),null),i+=e.width+v;continue}n&&Qj(n.style,e.style)?(n.text+=e.text,n.width+=e.width):(n&&t.push(n),n={text:e.text,style:e.style,width:e.width,boxStyle:e.boxStyle,x:0,padBefore:i},i=0)}n&&t.push(n);let a=b+r.totalWidth;for(let n of t){a-=n.padBefore,Mj(e,n.style);let t=jj(e,n.text);a-=t,n.x=a,n.width=t}for(let e of t)if(e.boxStyle&&$j(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;j(t,e.x-n,e.width+n+r)}for(let e of t)o.push({type:`text`,text:e.text,x:e.x+e.width,y:T,width:e.width,style:{...e.style,direction:`rtl`}})}else{let t=r.words.map(e=>e.text).join(``);if(ee&&/[\u0590-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(t)&&!r.words.some(e=>e.boxOpen||e.boxClose||e.style.verticalAlign===`super`||e.style.verticalAlign===`sub`)){Mj(e,M[0].style);let n=jj(e,t);o.push({type:`text`,text:t,x:b,y:T,width:n,style:{...M[0].style,direction:`ltr`}})}else for(let t of r.words){if(t.text===``){b+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=b+n.marginLeft+n.borderLeftWidth+n.paddingLeft;o.push({type:`text`,text:t.text,x:r,y:T,width:jj(e,t.text),style:t.style}),b+=t.width;continue}let n=T,r=t.style.verticalAlign;if(Zj(r)){let i=D||t.style.fontSize,{ascent:o,descent:s}=Yj(e,t.style);n+=Xj(r,o,s,i,S,C,a)}let i=t.width+(t.isSpace?v:0);o.push({type:`text`,text:t.text,x:b,y:n,width:i,style:t.style}),b+=i}}let N=d===`justify`&&v>0?_:r.totalWidth;kj.push({y:Math.round(T),text:r.words.map(e=>e.text).join(``),bounds:{x,y:O,width:N,height:A}}),g+=A}return{nodes:o,height:g-r}}function _M(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+t}function vM(e,t,n,r,i){let a=t.style,o=a.marginLeft,s=a.marginRight,c=a.borderLeftWidth,l=a.borderRightWidth,u=a.borderTopWidth,d=a.borderBottomWidth,f=a.paddingLeft,p=a.paddingRight,m=a.paddingTop,h=a.paddingBottom,g=n+o,_=a.width>0?a.width:i-o-s,v=g+c+f,y=Math.max(0,_-c-l-f-p),b=r,x=b+u+m,S={type:`box`,style:a,x:g,y:b,width:_,height:0,tagName:t.tagName,children:[],listMarker:t.listMarker};if(a.display===`flex`){let n=bM(e,t,v,x,y);return S.children=n.children,S.height=u+m+n.height+h+d,{box:S,height:S.height,marginBottomOut:a.marginBottom}}if(a.display===`table`){let n=yM(e,t,v,x,y);return S.children=n.children,S.height=u+m+n.height+h+d,{box:S,height:S.height,marginBottomOut:a.marginBottom}}if(t.children.length===0)return S.height=u+m+h+d,a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:a.marginBottom};if(Kj(t)){let{nodes:n,height:r}=gM(e,t,v,x,y,t.tagName===`li`&&Bj.has(a.listStyleType));S.children=n,S.height=u+m+r+h+d}else{let n=x,r=0,i=!1,o=t.tagName===`li`||t.tagName===`ul`||t.tagName===`ol`||t.tagName===`dd`||t.tagName===`dt`;for(let s=0;s<t.children.length;s++){let c=t.children[s];if(c.tagName===`#text`||Gj(c)){let o=[c];for(;s+1<t.children.length;){let e=t.children[s+1];if(e.tagName===`#text`||Gj(e))o.push(e),s++;else break}r>0&&(n+=r,r=0);let l={element:null,tagName:`div`,style:{...t.style,display:`block`,marginTop:0,marginBottom:0,paddingTop:0,paddingBottom:0,borderTopWidth:0,borderBottomWidth:0},children:o,textContent:null},u=t.tagName===`li`&&Bj.has(a.listStyleType),{nodes:d,height:f}=gM(e,l,v,n,y,u);S.children.push(...d),n+=f,r=0,i=!0;continue}let l=c.style.marginTop;if(!(!i&&m===0&&u===0&&o)){let e=_M(r,l);n+=e}let{box:d,height:f,marginBottomOut:p}=vM(e,c,v,n,y);S.children.push(d),n+=f,r=p,i=!0}let s=a.marginBottom,c=h===0&&d===0&&o;c&&r>0&&(s=Math.max(a.marginBottom,r));let l=n-x;return!c&&r>0&&(l+=r),S.height=u+m+l+h+d,a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:s}}return a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:a.marginBottom}}function yM(e,t,n,r,i){let a=[],o=[];for(let e of t.children)if(e.tagName===`tr`)o.push(e);else if([`thead`,`tbody`,`tfoot`].includes(e.tagName))for(let t of e.children)t.tagName===`tr`&&o.push(t);if(o.length===0)return{children:a,height:0};let s=Math.max(...o.map(e=>e.children.filter(e=>e.tagName===`td`||e.tagName===`th`).length));if(s===0)return{children:a,height:0};let c=i/s,l=r;for(let t of o){let r=t.children.filter(e=>e.tagName===`td`||e.tagName===`th`),i=0,o=[];for(let t=0;t<r.length;t++){let a=r[t],{box:s,height:u}=vM(e,a,n+t*c,l,c);o.push(s),i=Math.max(i,u)}for(let e of o)e.height=i,a.push(e);l+=i}return{children:a,height:l-r}}function bM(e,t,n,r,i){let a=t.style,o=a.gap,s=[],c=t.children.filter(e=>e.tagName!==`#text`||e.textContent?.trim());if(c.length===0)return{children:s,height:0};if(a.flexDirection===`row`||a.flexDirection===``){let t=o*(c.length-1),a=c.reduce((e,t)=>e+(t.style.flexGrow||0),0),l=(i-t)/(a||c.length),u=n,d=0;for(let t of c){if(t.tagName===`#text`)continue;let n=l*(t.style.flexGrow||+(a===0)),{box:i,height:c}=vM(e,t,u,r,n);s.push(i),d=Math.max(d,c),u+=n+o}return{children:s,height:d}}let l=r;for(let t of c){if(t.tagName===`#text`)continue;let{box:r,height:a}=vM(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function xM(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=Fj(a);let o=Hj(e,r),s=t.y+r.borderTopWidth+r.paddingTop+Uj(e,r,o),c=jj(e,n.listMarker),l=r.direction===`rtl`,u=Bj.has(r.listStyleType),d=l?i?.paddingLeft:i?.paddingRight,f,p=s,m=`ltr`,h=t.x+r.borderLeftWidth+r.paddingLeft,g=t.x+t.width;if(u){let{ascent:t}=Yj(e,a),r=e.measureText(n.listMarker),i=d===void 0?7+t/3:d;f=l?g+i+(r.actualBoundingBoxLeft??0):h-i-(r.actualBoundingBoxRight??c);let o=((r.actualBoundingBoxAscent??0)-(r.actualBoundingBoxDescent??0))/2;p=s-t/3+o}else{let t=d===void 0?jj(e,` `):d;l?/\d/.test(n.listMarker)?(m=`rtl`,f=g+t+c):f=g+t:f=h-c-t}t.children.unshift({type:`text`,text:n.listMarker,x:f,y:p,width:c,style:{...a,textDecorationLine:`none`,fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:m}});let _=m===`rtl`?f-c:f;kj.push({y:Math.round(s),text:n.listMarker,bounds:{x:_,y:t.y+r.borderTopWidth+r.paddingTop,width:c,height:o}})}function SM(e,t,n,r=!0,i){Dj=r,Oj=i,Ij.clear(),Jj.clear(),Pj.clear(),Aj.clear(),kj=[];let{box:a,height:o}=vM(e,t,0,0,n);CM(e,a,t);let s=kj.slice().sort((e,t)=>e.y-t.y||e.bounds.x-t.bounds.x),c=[];for(let e of s){let t=c[c.length-1],n=e.bounds.height*.5;if(t&&Math.abs(e.y-t.y)<n){let n=t.text.length>0&&e.text.length>0&&!/\s$/.test(t.text)&&!/^\s/.test(e.text);t.text+=(n?` `:``)+e.text,t.y=Math.max(t.y,e.y);let r=Math.min(t.bounds.x,e.bounds.x),i=Math.min(t.bounds.y,e.bounds.y),a=Math.max(t.bounds.x+t.bounds.width,e.bounds.x+e.bounds.width),o=Math.max(t.bounds.y+t.bounds.height,e.bounds.y+e.bounds.height);t.bounds={x:r,y:i,width:a-r,height:o-i}}else c.push({y:e.y,text:e.text,bounds:{...e.bounds}})}return{root:a,height:o,lines:c}}function CM(e,t,n){xM(e,t,n);let r=0;for(let i of n.children)if(!(i.tagName===`#text`||Gj(i)))for(;r<t.children.length;){let n=t.children[r];if(n.type===`box`&&n.tagName===i.tagName){CM(e,n,i),r++;break}r++}}function wM(e){if(!e||e===`none`)return[];let t=[],n=e.split(/,(?![^(]*\))/);for(let e of n){let n=e.trim(),r=n.match(/(rgb[a]?\([^)]+\)|#[0-9a-fA-F]+|\b[a-z]+\b)(?:\s|$)/i),i=n.match(/-?[\d.]+px/g);if(i&&i.length>=2){let e=i.map(e=>parseFloat(e));t.push({offsetX:e[0],offsetY:e[1],blur:e[2]||0,color:r?r[1]:`rgba(0,0,0,1)`})}}return t}function TM(e,t){return e[`border${t}Width`]>0&&e[`border${t}Style`]!==`none`}function EM(e,t,n,r,i,a,o){if(e.save(),e.strokeStyle=o,e.lineWidth=i,a===`double`){let a=Math.max(i,2);e.lineWidth=Math.max(.5,i*.5),e.beginPath(),e.moveTo(t,n-a/2),e.lineTo(t+r,n-a/2),e.moveTo(t,n+a/2),e.lineTo(t+r,n+a/2),e.stroke()}else if(a===`wavy`){let a=Math.max(1.5,i),o=a*4;e.beginPath(),e.moveTo(t,n);for(let i=t;i<t+r;i+=o)e.quadraticCurveTo(i+o/4,n-a,i+o/2,n),e.quadraticCurveTo(i+o*3/4,n+a,i+o,n);e.stroke()}else a===`dotted`?e.setLineDash([i,i*2]):a===`dashed`&&e.setLineDash([i*3,i*2]),e.beginPath(),e.moveTo(t,n),e.lineTo(t+r,n),e.stroke();e.setLineDash([]),e.restore()}function DM(e,t,n,r,i,a){let o=t.indexOf(`linear-gradient(`);if(o===-1)return null;let s=0,c=-1;for(let e=o+16;e<t.length;e++)if(t[e]===`(`)s++;else if(t[e]===`)`){if(s===0){c=e;break}s--}if(c===-1)return null;let l=t.slice(o+16,c),u=[];s=0;let d=0,f=l;for(let e=0;e<f.length;e++)f[e]===`(`?s++:f[e]===`)`?s--:f[e]===`,`&&s===0&&(u.push(f.slice(d,e).trim()),d=e+1);u.push(f.slice(d).trim());let p=180,m=0,h=u[0];h.endsWith(`deg`)?(p=parseFloat(h),m=1):h===`to right`?(p=90,m=1):h===`to left`?(p=270,m=1):h===`to bottom`?(p=180,m=1):h===`to top`&&(p=0,m=1);let g=(p-90)*Math.PI/180,_=n+r/2,v=i+a/2,y=Math.abs(r*Math.cos(g))+Math.abs(a*Math.sin(g)),b=Math.cos(g)*y/2,x=Math.sin(g)*y/2,S=e.createLinearGradient(_-b,v-x,_+b,v+x),C=u.slice(m);for(let e=0;e<C.length;e++){let t=C[e].trim(),n=t,r=e/Math.max(1,C.length-1),i=t.match(/\s+([\d.]+%)\s*$/);i&&(r=parseFloat(i[1])/100,n=t.slice(0,t.length-i[0].length).trim());try{S.addColorStop(r,n)}catch{}}return S}function OM(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}function kM(e,t){e.strokeStyle=t.webkitTextStrokeColor||t.color,e.lineWidth=t.webkitTextStrokeWidth,e.lineJoin=`round`}function AM(e,t,n){let{style:r}=t;e.save(),e.font=Fj(r),e.textBaseline=`alphabetic`,e.fontKerning=r.fontKerning===`none`?`none`:`normal`,Number.isFinite(r.letterSpacing)&&r.letterSpacing!==0&&(e.letterSpacing=`${r.letterSpacing}px`),r.wordSpacing&&(e.wordSpacing=`${r.wordSpacing}px`),r.direction===`rtl`&&(e.direction=`rtl`,e.textAlign=`right`);let i=r.webkitBackgroundClip===`text`&&r.backgroundImage&&r.backgroundImage!==`none`,a=r.webkitTextStrokeWidth>0,o=r.webkitTextFillColor===`transparent`||r.color===`transparent`,s=wM(r.textShadow);if(s.length>0){let c=i||!o;for(let o of s)e.save(),e.shadowOffsetX=o.offsetX,e.shadowOffsetY=o.offsetY,e.shadowBlur=o.blur,e.shadowColor=o.color,c&&(e.fillStyle=i&&n?n:OM(r),e.fillText(t.text,t.x,t.y)),a&&(kM(e,r),e.strokeText(t.text,t.x,t.y)),e.restore()}let c=()=>{if(i){if(e.save(),n)e.fillStyle=n;else{let{ascent:n,descent:i}=Yj(e,r);e.fillStyle=DM(e,r.backgroundImage,t.x,t.width,t.y-n,n+i)||r.color}e.fillText(t.text,t.x,t.y),e.restore()}else (!o||!a)&&(e.fillStyle=OM(r),e.fillText(t.text,t.x,t.y))},l=()=>{a&&(e.save(),kM(e,r),e.strokeText(t.text,t.x,t.y),e.restore())};yj(r.paintOrder)?(l(),c()):(c(),l());let u=t.width,d=r.fontSize,f=r.textDecorationColor||r.color,p=r.textDecorationStyle||`solid`,m=Math.max(1,d/15),h=r.direction===`rtl`?t.x-u:t.x;if(r.textDecorationLine!==`none`){let{ascent:n}=Yj(e,r);e.font=Fj(r);let i=e.measureText(`x`).actualBoundingBoxAscent;if(r.textDecorationLine.includes(`underline`)){let n=d*.1;EM(e,h,t.y+n,u,m,p,f)}if(r.textDecorationLine.includes(`line-through`)){let n=-(i*.5);EM(e,h,t.y+n,u,m,p,f)}r.textDecorationLine.includes(`overline`)&&EM(e,h,t.y-n,u,m,p,f)}e.restore()}function jM(e,t){let{style:n}=t;qj(n.backgroundColor)||(e.fillStyle=n.backgroundColor,e.fillRect(t.x,t.y,t.width,t.height));let r=[[`Top`,t.x,t.y+n.borderTopWidth/2,t.x+t.width,t.y+n.borderTopWidth/2],[`Right`,t.x+t.width-n.borderRightWidth/2,t.y,t.x+t.width-n.borderRightWidth/2,t.y+t.height],[`Bottom`,t.x,t.y+t.height-n.borderBottomWidth/2,t.x+t.width,t.y+t.height-n.borderBottomWidth/2],[`Left`,t.x+n.borderLeftWidth/2,t.y,t.x+n.borderLeftWidth/2,t.y+t.height]];for(let[t,i,a,o,s]of r)TM(n,t)&&(e.strokeStyle=n[`border${t}Color`],e.lineWidth=n[`border${t}Width`],e.beginPath(),e.moveTo(i,a),e.lineTo(o,s),e.stroke());let i=null;n.webkitBackgroundClip===`text`&&n.backgroundImage&&n.backgroundImage!==`none`&&(i=DM(e,n.backgroundImage,t.x,t.width,t.y,t.height));for(let n of t.children)MM(e,n,i)}function MM(e,t,n){t.type===`text`?AM(e,t,n):jM(e,t)}function NM(e){let{html:t,width:n,height:r,accuracy:i=`performance`,debug:a}=e;if(!n||n<=0||Number.isNaN(n))throw TypeError(`layout: width must be a positive number, got ${n}`);let o=i===`balanced`,{fragment:s,css:c}=mj(t),{tree:l,cleanup:u}=Ej(s,c,n),d=document.createElement(`canvas`).getContext(`2d`);d.fontKerning=`normal`;let{root:f,height:p,lines:m}=SM(d,l,n,o,a),h=r||p;return u(),{layoutRoot:f,height:h,lines:m}}function PM(e){let{layout:t,width:n,pixelRatio:r=globalThis.devicePixelRatio??1}=e;if(e.ctx&&e.canvas)throw TypeError(`drawLayout: ctx and canvas are mutually exclusive — provide one or neither`);let i=t.height,a,o;return e.ctx?(o=e.ctx,a=e.ctx.canvas):(a=e.canvas??document.createElement(`canvas`),a.width=Math.ceil(n*r),a.height=Math.ceil(i*r),`style`in a&&(a.style.width=`${n}px`,a.style.height=`${i}px`),o=a.getContext(`2d`),o.scale(r,r)),MM(o,t.layoutRoot),{canvas:a}}var FM=/[MmLlHhVvCcSsQqTtAaZz]/,IM=/-?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-+]?\d+)?/g;function LM(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(FM.test(r)){let i=n+1;for(;i<e.length&&!FM.test(e[i]);)i++;let a=e.slice(n+1,i),o=[],s;for(IM.lastIndex=0;s=IM.exec(a);)o.push(Number(s[0]));t.push({cmd:r,args:o}),n=i}else n++}return t}function RM(e){let t=LM(e),n=[],r=0,i=0,a=0,o=0,s=null,c=null;for(let e of t){let t=e.cmd,l=t.toUpperCase(),u=t!==l,d=e.args,f=e=>u?r+e:e,p=e=>u?i+e:e,m=!0,h=!0;switch(l){case`M`:for(let e=0;e<d.length;e+=2){let t=u&&e>0?r+d[e]:f(d[e]),s=u&&e>0?i+d[e+1]:p(d[e+1]);e===0?(r=t,i=s,a=t,o=s):(n.push({type:`L`,x0:r,y0:i,x1:t,y1:s}),r=t,i=s)}break;case`L`:for(let e=0;e<d.length;e+=2){let t=f(d[e]),a=p(d[e+1]);n.push({type:`L`,x0:r,y0:i,x1:t,y1:a}),r=t,i=a}break;case`H`:for(let e=0;e<d.length;e++){let t=u?r+d[e]:d[e];n.push({type:`L`,x0:r,y0:i,x1:t,y1:i}),r=t}break;case`V`:for(let e=0;e<d.length;e++){let t=u?i+d[e]:d[e];n.push({type:`L`,x0:r,y0:i,x1:r,y1:t}),i=t}break;case`C`:for(let e=0;e<d.length;e+=6){let t=f(d[e]),a=p(d[e+1]),o=f(d[e+2]),c=p(d[e+3]),l=f(d[e+4]),u=p(d[e+5]);n.push({type:`C`,x0:r,y0:i,c1x:t,c1y:a,c2x:o,c2y:c,x1:l,y1:u}),s={x:o,y:c},r=l,i=u}m=!1;break;case`S`:for(let e=0;e<d.length;e+=4){let t=s?2*r-s.x:r,a=s?2*i-s.y:i,o=f(d[e]),c=p(d[e+1]),l=f(d[e+2]),u=p(d[e+3]);n.push({type:`C`,x0:r,y0:i,c1x:t,c1y:a,c2x:o,c2y:c,x1:l,y1:u}),s={x:o,y:c},r=l,i=u}m=!1;break;case`Q`:for(let e=0;e<d.length;e+=4){let t=f(d[e]),a=p(d[e+1]),o=f(d[e+2]),s=p(d[e+3]);n.push({type:`Q`,x0:r,y0:i,cx:t,cy:a,x1:o,y1:s}),c={x:t,y:a},r=o,i=s}h=!1;break;case`T`:for(let e=0;e<d.length;e+=2){let t=c?2*r-c.x:r,a=c?2*i-c.y:i,o=f(d[e]),s=p(d[e+1]);n.push({type:`Q`,x0:r,y0:i,cx:t,cy:a,x1:o,y1:s}),c={x:t,y:a},r=o,i=s}h=!1;break;case`A`:for(let e=0;e<d.length;e+=7){let t=d[e],a=d[e+1],o=d[e+2],s=d[e+3]!==0,c=d[e+4]!==0,l=f(d[e+5]),u=p(d[e+6]);t===0||a===0?(r!==l||i!==u)&&n.push({type:`L`,x0:r,y0:i,x1:l,y1:u}):r===l&&i===u||n.push({type:`A`,x0:r,y0:i,rx:t,ry:a,xAxisRotation:o,largeArc:s,sweep:c,x1:l,y1:u}),r=l,i=u}break;case`Z`:(r!==a||i!==o)&&n.push({type:`L`,x0:r,y0:i,x1:a,y1:o}),r=a,i=o;break;default:break}m&&(s=null),h&&(c=null)}return n}function zM(e,t){let n=1-t,r=n*n,i=t*t;return{x:n*r*e.x0+3*r*t*e.c1x+3*n*i*e.c2x+i*t*e.x1,y:n*r*e.y0+3*r*t*e.c1y+3*n*i*e.c2y+i*t*e.y1}}function BM(e,t){let n=1-t;return{x:n*n*e.x0+2*n*t*e.cx+t*t*e.x1,y:n*n*e.y0+2*n*t*e.cy+t*t*e.y1}}function VM(e){let t=Math.abs(e.rx),n=Math.abs(e.ry),r=e.xAxisRotation*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=(e.x0-e.x1)/2,s=(e.y0-e.y1)/2,c=i*o+a*s,l=-a*o+i*s,u=c*c/(t*t)+l*l/(n*n);if(u>1){let e=Math.sqrt(u);t*=e,n*=e}let d=e.largeArc===e.sweep?-1:1,f=t*t*n*n-t*t*l*l-n*n*c*c,p=t*t*l*l+n*n*c*c,m=Math.sqrt(Math.max(0,f/p)),h=d*m*(t*l/n),g=d*m*(-(n*c)/t),_=i*h-a*g+(e.x0+e.x1)/2,v=a*h+i*g+(e.y0+e.y1)/2,y=(e,t,n,r)=>{let i=e*n+t*r,a=Math.sqrt((e*e+t*t)*(n*n+r*r)),o=Math.acos(Math.min(1,Math.max(-1,i/a)));return e*r-t*n<0&&(o=-o),o},b=y(1,0,(c-h)/t,(l-g)/n),x=y((c-h)/t,(l-g)/n,(-c-h)/t,(-l-g)/n);return x%=2*Math.PI,!e.sweep&&x>0?x-=2*Math.PI:e.sweep&&x<0&&(x+=2*Math.PI),{cx:_,cy:v,rx:t,ry:n,phi:r,theta1:b,deltaTheta:x,cosPhi:i,sinPhi:a}}function HM(e,t){let{cx:n,cy:r,rx:i,ry:a,cosPhi:o,sinPhi:s,theta1:c,deltaTheta:l}=VM(e),u=c+t*l,d=i*Math.cos(u),f=a*Math.sin(u);return{x:o*d-s*f+n,y:s*d+o*f+r}}var UM=40;function WM(e){let t=[],n=0;for(let r of e){if(r.type===`L`){let e=Math.hypot(r.x1-r.x0,r.y1-r.y0);t.push({startLen:n,length:e,seg:r}),n+=e;continue}let e=[],i=0,a;a=r.type===`C`||r.type===`Q`?{x:r.x0,y:r.y0}:HM(r,0),e.push({t:0,len:0});for(let t=1;t<=UM;t++){let n=t/UM,o;o=r.type===`C`?zM(r,n):r.type===`Q`?BM(r,n):HM(r,n),i+=Math.hypot(o.x-a.x,o.y-a.y),e.push({t:n,len:i}),a=o}t.push({startLen:n,length:i,seg:r,samples:e}),n+=i}function r(e){if(!Number.isFinite(e)||e<0||e>n+1e-6)return null;if(e===0&&t.length>0){let e=t[0].seg;return e.type===`L`||e.type===`C`||e.type===`Q`?{x:e.x0,y:e.y0}:HM(e,0)}for(let n=0;n<t.length;n++){let r=t[n];if(e>r.startLen+r.length+1e-6)continue;let i=e-r.startLen;if(r.seg.type===`L`){let e=r.length===0?0:Math.max(0,Math.min(1,i/r.length));return{x:r.seg.x0+(r.seg.x1-r.seg.x0)*e,y:r.seg.y0+(r.seg.y1-r.seg.y0)*e}}let a=r.samples,o=0,s=a.length-1;for(;s-o>1;){let e=o+s>>1;a[e].len<=i?o=e:s=e}let c=a[o],l=a[s],u=l.len-c.len,d=u===0?0:(i-c.len)/u,f=Math.max(0,Math.min(1,c.t+(l.t-c.t)*d));return r.seg.type===`C`?zM(r.seg,f):r.seg.type===`Q`?BM(r.seg,f):HM(r.seg,f)}return null}return{length:n,getPointAtLength:r}}function GM(e){return WM(RM(e))}var KM;function qM(){if(KM!==void 0)return KM;if(typeof Intl<`u`&&typeof Intl.Segmenter==`function`)try{KM=new Intl.Segmenter(void 0,{granularity:`grapheme`})}catch{KM=null}else KM=null;return KM}function JM(e){if(!e)return[];let t=qM();if(t){let n=[];for(let r of t.segment(e))n.push(r.segment);return n}return Array.from(e)}function YM(e,t,n){switch(e){case`alphabetic`:return 0;case`middle`:return(t-n)/2;case`top`:return t;case`bottom`:return-n;case`hanging`:return t*.8;case`ideographic`:return-n*.5}}function XM(e){let t=[];function n(e,r){let i=e.style.direction===`rtl`||r;if(e.tagName===`#text`&&e.textContent){t.push({text:e.textContent,style:e.style,rtl:i});return}for(let t of e.children)n(t,i)}return n(e,!1),t}var ZM=RegExp(`[\\u0590-\\u05FF\\u0600-\\u06FF\\u0700-\\u074F\\u0750-\\u077F\\u0780-\\u07BF\\u07C0-\\u07FF\\u0800-\\u083F\\u0840-\\u085F\\u0860-\\u086F\\u08A0-\\u08FF\\u0900-\\u097F\\u0980-\\u09FF\\u0A00-\\u0A7F\\u0A80-\\u0AFF\\u0B00-\\u0B7F\\u0B80-\\u0BFF\\u0C00-\\u0C7F\\u0C80-\\u0CFF\\u0D00-\\u0D7F\\u0D80-\\u0DFF\\u0E00-\\u0E7F\\u0E80-\\u0EFF\\u0F00-\\u0FFF\\u1000-\\u109F\\u1780-\\u17FF\\u1800-\\u18AF\\uFB1D-\\uFB4F\\uFB50-\\uFDFF\\uFE70-\\uFEFF]`);function QM(e){return ZM.test(e)}function $M(e,t){let n=JM(t.text);if(n.length===0)return[];Mj(e,t.style),e.letterSpacing=`${t.style.letterSpacing||0}px`;let{ascent:r,descent:i}=Yj(e,t.style),a=[],o=``;for(let e of n){let t=e===` `;QM(e)&&!t?o+=e:(o&&=(a.push({text:o,shaped:!0,isSpace:!1}),``),a.push({text:e,shaped:!1,isSpace:t}))}o&&a.push({text:o,shaped:!0,isSpace:!1}),t.rtl&&a.reverse();let s=[];for(let n of a){let a=e.measureText(n.text).width;s.push({text:n.text,width:a,style:t.style,isSpace:n.isSpace,ascent:r,descent:i,shaped:n.shaped})}return s}function eN(e){let{segments:t,path:n,ctx:r,align:i,textBaseline:a}=e,o=[],s=0,c=0;for(let e of t){if(!e.text)continue;let t=e.style.lineHeight>0?e.style.lineHeight:e.style.fontSize;t>c&&(c=t);let n=$M(r,e);n.length!==0&&(o.push(...n),s+=r.measureText(e.text).width)}let l=0;for(let e of o)l+=e.width+(e.style.letterSpacing||0);o.length>0&&(l-=o[o.length-1].style.letterSpacing||0);let u=Math.max(0,l-s),d=n.length,f=0,p=0;if(i===`center`)f=Math.max(0,(d-l)/2);else if(i===`right`)f=Math.max(0,d-l);else if(i===`justify`){let e=o.filter(e=>e.isSpace).length;e>0&&d>l&&(p=(d-l)/e)}let m=[],h=f,g=0;for(let e=0;e<o.length;e++){let t=o[e],r=t.width+(t.isSpace?p:0),i=n.getPointAtLength(h);if(!i)break;let a=h+r,s;if(a>d)if(a-d<=u+.5)s=n.getPointAtLength(d);else break;else s=n.getPointAtLength(a);if(!s)break;let c=Math.atan2(s.y-i.y,s.x-i.x);m.push({char:t.text,x:i.x,y:i.y,rotation:c,width:t.width,style:t.style,ascent:t.ascent,descent:t.descent,pathOffset:g,shaped:t.shaped}),h=a+(t.style.letterSpacing||0),g+=t.width+(t.style.letterSpacing||0)}let _=tN(m,a);return{glyphs:m,textWidth:l,pathLength:d,lineHeight:c,bounds:_,textBaseline:a}}function tN(e,t){if(e.length===0)return{x:0,y:0,width:0,height:0};let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let o of e){let e=o.style.lineHeight>0?o.style.lineHeight:o.style.fontSize,s=o.ascent+o.descent,c=s>0?o.ascent/s:.75,l=e*c,u=e*(1-c),d=YM(t,o.ascent,o.descent),f=d-l,p=d+u,m=Math.cos(o.rotation),h=Math.sin(o.rotation),g=[{x:o.x+-h*f,y:o.y+m*f},{x:o.x+m*o.width+-h*f,y:o.y+h*o.width+m*f},{x:o.x+m*o.width+-h*p,y:o.y+h*o.width+m*p},{x:o.x+-h*p,y:o.y+m*p}];for(let e of g)e.x<n&&(n=e.x),e.y<r&&(r=e.y),e.x>i&&(i=e.x),e.y>a&&(a=e.y)}return{x:n,y:r,width:i-n,height:a-r}}function nN(e){let{html:t,align:n=`left`,textBaseline:r=`alphabetic`}=e,i=typeof e.path==`string`?GM(e.path):e.path,a=e.ctx??iN(),o=e.ctx===void 0,{fragment:s,css:c}=mj(t),{tree:l,cleanup:u}=Ej(s,c,2**53-1);o||a.save();try{return eN({segments:XM(l),path:i,ctx:a,align:n,textBaseline:r})}finally{o||a.restore(),u()}}function rN(e){let{layout:t,ctx:n}=e;if(t.glyphs.length===0)return;let r=t.textBaseline;n.save();try{sN(n,t.glyphs,r),uN(n,t.glyphs,t.textWidth,r),pN(n,t.glyphs,r)}finally{n.restore()}}function iN(){return(typeof OffscreenCanvas<`u`?new OffscreenCanvas(1,1):document.createElement(`canvas`)).getContext(`2d`)}var aN=new WeakMap;function oN(e,t){if(!t)return``;let n=aN.get(e);n||(n=new Map,aN.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=e.fillStyle;try{e.fillStyle=t;let r=typeof e.fillStyle==`string`?e.fillStyle:t;return n.set(t,r),r}catch{return n.set(t,t),t}finally{e.fillStyle=i}}function sN(e,t,n){let r=0;for(;r<t.length;){let i=t[r].style.backgroundColor;if(!i||qj(i)){r++;continue}let a=oN(e,i),o=r+1;for(;o<t.length&&oN(e,t[o].style.backgroundColor)===a;)o++;lN(e,t.slice(r,o),i,n),r=o}}function cN(e,t){let n=Math.cos(e.rotation),r=Math.sin(e.rotation),i=YM(t,e.ascent,e.descent),a=i-e.ascent,o=i+e.descent,s=e.width;return{tl:{x:e.x+-r*a,y:e.y+n*a},tr:{x:e.x+n*s+-r*a,y:e.y+r*s+n*a},br:{x:e.x+n*s+-r*o,y:e.y+r*s+n*o},bl:{x:e.x+-r*o,y:e.y+n*o}}}function lN(e,t,n,r){if(t.length===0)return;e.save(),e.fillStyle=n,e.beginPath();let i=cN(t[0],r);e.moveTo(i.tl.x,i.tl.y);for(let n=0;n<t.length;n++){let i=cN(t[n],r);e.lineTo(i.tl.x,i.tl.y),e.lineTo(i.tr.x,i.tr.y)}for(let n=t.length-1;n>=0;n--){let i=cN(t[n],r);e.lineTo(i.br.x,i.br.y),e.lineTo(i.bl.x,i.bl.y)}e.closePath(),e.fill(),e.restore()}function uN(e,t,n,r){for(let i of t){e.save(),e.translate(i.x,i.y),e.rotate(i.rotation),Mj(e,i.style),e.textBaseline=`alphabetic`,e.letterSpacing=`${i.style.letterSpacing||0}px`;let t=YM(r,i.ascent,i.descent),a=wM(i.style.textShadow);if(a.length>0)for(let n=a.length-1;n>=0;n--){let r=a[n];e.save(),e.shadowOffsetX=r.offsetX,e.shadowOffsetY=r.offsetY,e.shadowBlur=r.blur,e.shadowColor=r.color,e.fillStyle=hN(i.style),e.fillText(i.char,0,t),e.restore()}dN(e,i,n,t),e.restore()}}function dN(e,t,n,r){let{style:i}=t,a=i.webkitTextFillColor===`transparent`||i.color===`transparent`||qj(hN(i)),o=i.webkitTextStrokeWidth>0,s=i.webkitBackgroundClip===`text`&&i.backgroundImage&&i.backgroundImage!==`none`,c=yj(i.paintOrder||``),l=()=>{if(s){fN(e,t,n,r);return}if(a){if(o)return;e.fillStyle=`transparent`,e.fillText(t.char,0,r);return}e.fillStyle=hN(i),e.fillText(t.char,0,r)},u=()=>{o&&(e.save(),e.lineJoin=`round`,e.lineWidth=i.webkitTextStrokeWidth,e.strokeStyle=i.webkitTextStrokeColor||i.color,e.strokeText(t.char,0,r),e.restore())};c?(u(),l()):(l(),u())}function fN(e,t,n,r){let i=DM(e,t.style.backgroundImage,-t.pathOffset,n,r-t.ascent,t.ascent+t.descent);if(!i){e.fillStyle=hN(t.style),e.fillText(t.char,0,r);return}e.fillStyle=i,e.fillText(t.char,0,r)}function pN(e,t,n){for(let r of[`underline`,`line-through`,`overline`]){let i=0;for(;i<t.length;){let a=t[i].style;if(!a.textDecorationLine||!a.textDecorationLine.includes(r)){i++;continue}let o=a.textDecorationColor||a.color,s=a.textDecorationStyle||`solid`,c=oN(e,o),l=i+1;for(;l<t.length&&t[l].style.textDecorationLine&&t[l].style.textDecorationLine.includes(r)&&oN(e,t[l].style.textDecorationColor||t[l].style.color)===c&&(t[l].style.textDecorationStyle||`solid`)===s;)l++;mN(e,t.slice(i,l),r,s,o,n),i=l}}}function mN(e,t,n,r,i,a){if(t.length===0)return;let o=Math.max(1,t[0].style.fontSize/15),s=e=>{let t=YM(a,e.ascent,e.descent);return n===`underline`?t+e.descent*.5:n===`line-through`?t-e.ascent*.3:t-e.ascent*.9};if(r===`double`||r===`wavy`){for(let n of t)e.save(),e.translate(n.x,n.y),e.rotate(n.rotation),EM(e,0,s(n),n.width,o,r,i),e.restore();return}e.save(),e.strokeStyle=i,e.lineWidth=o,r===`dotted`?e.setLineDash([o,o*2]):r===`dashed`&&e.setLineDash([o*3,o*2]),e.beginPath();for(let n=0;n<t.length;n++){let r=t[n],i=s(r),a=Math.cos(r.rotation),o=Math.sin(r.rotation),c={x:r.x+-o*i,y:r.y+a*i},l={x:r.x+a*r.width+-o*i,y:r.y+o*r.width+a*i};n===0?e.moveTo(c.x,c.y):e.lineTo(c.x,c.y),e.lineTo(l.x,l.y)}e.stroke(),e.setLineDash([]),e.restore()}function hN(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}var gN=`<style>${Py}
|
|
513
|
+
`)break;let r=!!n.text&&mM.test(n.text),i=!n.text&&!!n.boxClose,a=!!n.text&&!!n.noBreakBefore;if(r||i||a){h+=n.width;continue}break}for(let i of m){let a=i===m[m.length-1]?h:0,o=!i.isSpace&&i.text.length>0&&mM.test(i.text)&&s.words.length>0&&!s.words[s.words.length-1].isSpace,c=i===m[0]&&i.noBreakBefore&&s.words.length>0&&!s.words[s.words.length-1].isSpace,g=0;if(!i.text&&i.boxOpen){let n=t[r+1];n&&!n.isSpace&&n.text&&(g=(n.text.length>1?pM(e,n,l(),0):[n])[0].width)}let _=0;if(i.isSoftHyphenBreak&&(Mj(e,i.style),e.letterSpacing=Nj(i.style.letterSpacing),_=jj(e,`-`)),!i.isSpace&&!o&&!c&&s.words.length>0&&s.totalWidth+i.width+_+a+g>l()){let t=s.totalWidth+i.width+_+a+g-l(),r=!0;if(t<1&&!dse([...s.words,i])){Mj(e,i.style);let t=s.words.map(e=>e.text).join(``)+i.text+(i.isSoftHyphenBreak?`-`:``),n=0;for(let e of s.words)e.text||(n+=e.width);i.text||(n+=i.width),jj(e,t)+n+a+g<=l()+.02&&(r=!1)}if(r&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){Mj(e,i.style);let n=``,r=0,a=0,o=l()-s.totalWidth;for(;a<t.length;a++){let i=n+t[a],s=jj(e,i);if(s>o)break;n=i,r=s}if(a>0&&a<t.length){s.words.push({...i,text:n,width:r}),s.totalWidth+=r,s.lineHeight=Math.max(s.lineHeight,u),f(!0),p=!1;let o=t.slice(a).join(``),c=jj(e,o);s.words.push({...i,text:o,width:c}),s.totalWidth+=c,s.lineHeight=Math.max(s.lineHeight,u);continue}}}if(r){if(Oj){let e=s.words.map(e=>e.text).join(``);Oj({type:`line-wrap`,message:`"${i.text}" overflow=${t.toFixed(2)} wrap=true lineWidth=${s.totalWidth.toFixed(2)} pieceWidth=${i.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:i.text,overflow:t,lineWidth:s.totalWidth,pieceWidth:i.width,contentWidth:n,lineText:e}})}f(!0),p=!1}}if(i.isSpace&&s.words.length===0&&(!p||!d))continue;let v=i.width;if(i.isTab){let e=i.width,t=s.totalWidth;v=Math.ceil((t+.1)/e)*e-t,i.width=v}if(s.words.length===0&&v>l()&&!i.isSpace&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){Mj(e,i.style);let n=t.filter(e=>e).map(t=>({...i,text:t,width:jj(e,t)})),r=!0;for(let e of n)r?(r=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u)):s.totalWidth+e.width>l()?(f(!0),p=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u)):(s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u));continue}}s.words.push(i),s.totalWidth+=v,s.lineHeight=Math.max(s.lineHeight,u),i.isSpace||(p=!1)}}return f(),o}function gM(e,t,n,r,i,a=!1,o){let s=[];if(o&&(o.exhausted||o.remaining<=0))return o.exhausted=!0,{nodes:s,height:0};let c=nM(t);if(c.length===0)return{nodes:s,height:0};let l=sM(e,c),u=t.style.textIndent||0,d=hM(e,l,i,t.style.whiteSpace,a,u),f=o?o.remaining:t.style.lineClamp;if(f>0&&d.length>f){d.length=f;let t=d[f-1];tM(e,t,i-(f===1?u:0)),t.endedByHardBreak=!0,o&&(o.remaining=0,o.exhausted=!0)}else o&&(o.remaining-=d.length);let p=t.style.direction===`rtl`,m=e=>e===`start`?p?`right`:`left`:e===`end`?p?`left`:`right`:e,h=m(t.style.textAlign),g=t.style.textAlignLast||`auto`;g=g===`auto`?t.style.textAlign===`justify`?p?`right`:`left`:h:m(g);let _=r;for(let t=0;t<d.length;t++){let r=d[t];if(r.words.length===0){_+=r.lineHeight;continue}let a=r.lineHeight,o=t===d.length-1,c=t===0,l=o||r.endedByHardBreak?g:h,f=c?u:0,m=i-f,v=0;if(l===`justify`&&r.totalWidth<m){let e=r.words.filter(e=>e.isSpace).length;e>0&&(v=(m-r.totalWidth)/e)}let y=r.totalWidth>m+.5,b=n+f;y?b=p?n+m-r.totalWidth:n+f:l===`center`?b=n+f+(m-r.totalWidth)/2:l===`right`?b=(p?n+m:n+f+m)-r.totalWidth:l===`justify`&&p&&(b=n+m-r.totalWidth);let x=b,S=0,C=0;for(let t of r.words){if(t.text===``||Zj(t.style.verticalAlign))continue;let{ascent:n,descent:r}=Yj(e,t.style);n>S&&(S=n),r>C&&(C=r)}if(S===0)for(let t of r.words){if(t.text===``)continue;let{ascent:n,descent:r}=Yj(e,t.style);S=n,C=r;break}let w=S+C,T=_+(a-w)/2+S,E=r.words.filter(e=>e.text!==``&&!Zj(e.style.verticalAlign)),D=E.length>0?Math.max(...E.map(e=>e.style.fontSize)):0,O=_,k=_+a;for(let t of r.words){if(t.text===``)continue;let n=t.style.verticalAlign;if(!Zj(n))continue;if(D===0)break;let{ascent:r,descent:i}=Yj(e,t.style),o=T+Xj(n,r,i,D,S,C,a),s=o-r,c=o+i;s<O&&(O=s),c>k&&(k=c)}let A=k-O,j=(t,n,r)=>{let{ascent:i,descent:a}=Yj(e,t),o=t.paddingTop+t.borderTopWidth,c=t.paddingBottom+t.borderBottomWidth,l=i+a+o+c,u;u=t.display===`inline-block`?_+t.marginTop:T-i-o,s.push({type:`box`,style:t,x:n,y:u,width:r,height:l,tagName:`span`,children:[]})};if(!p){let e=b,t=e,n,i=!1;for(let a of r.words){if(a.boxOpen&&a.boxClose&&a.text){n&&(i&&j(n,t,e-t),n=void 0,i=!1);let r=a.style,o=a.width-r.marginLeft-r.borderLeftWidth-r.paddingLeft-r.paddingRight-r.borderRightWidth-r.marginRight;j(r,e+r.marginLeft,r.borderLeftWidth+r.paddingLeft+o+r.paddingRight+r.borderRightWidth),i=!1,e+=a.width;continue}a.boxStyle!==n&&(n&&i&&j(n,t,e-t),n=a.boxStyle,t=e,i=!1),a.text&&!a.isSpace&&(i=!0),e+=a.width+(a.isSpace?v:0)}n&&i&&j(n,t,e-t)}let M=r.words.filter(e=>e.text!==``),ee=M.length>0&&M.every(e=>Qj(e.style,M[0].style));if(p){let t=[],n=null,i=0;for(let e of r.words){if(e.text===``){n&&=(t.push(n),null),i+=e.width;continue}if(e.isSpace&&v>0){n&&=(t.push(n),null),i+=e.width+v;continue}n&&Qj(n.style,e.style)?(n.text+=e.text,n.width+=e.width):(n&&t.push(n),n={text:e.text,style:e.style,width:e.width,boxStyle:e.boxStyle,x:0,padBefore:i},i=0)}n&&t.push(n);let a=b+r.totalWidth;for(let n of t){a-=n.padBefore,Mj(e,n.style);let t=jj(e,n.text);a-=t,n.x=a,n.width=t}for(let e of t)if(e.boxStyle&&$j(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;j(t,e.x-n,e.width+n+r)}for(let e of t)s.push({type:`text`,text:e.text,x:e.x+e.width,y:T,width:e.width,style:{...e.style,direction:`rtl`}})}else{let t=r.words.map(e=>e.text).join(``);if(ee&&/[\u0590-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(t)&&!r.words.some(e=>e.boxOpen||e.boxClose||e.style.verticalAlign===`super`||e.style.verticalAlign===`sub`)){Mj(e,M[0].style);let n=jj(e,t);s.push({type:`text`,text:t,x:b,y:T,width:n,style:{...M[0].style,direction:`ltr`}})}else for(let t of r.words){if(t.text===``){b+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=b+n.marginLeft+n.borderLeftWidth+n.paddingLeft;s.push({type:`text`,text:t.text,x:r,y:T,width:jj(e,t.text),style:t.style}),b+=t.width;continue}let n=T,r=t.style.verticalAlign;if(Zj(r)){let i=D||t.style.fontSize,{ascent:o,descent:s}=Yj(e,t.style);n+=Xj(r,o,s,i,S,C,a)}let i=t.width+(t.isSpace?v:0);s.push({type:`text`,text:t.text,x:b,y:n,width:i,style:t.style}),b+=i}}let N=l===`justify`&&v>0?m:r.totalWidth;kj.push({y:Math.round(T),text:r.words.map(e=>e.text).join(``),bounds:{x,y:O,width:N,height:A}}),_+=A}return{nodes:s,height:_-r}}function _M(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+t}function vM(e,t,n,r,i,a){let o=t.style;!a&&o.lineClamp>0&&(a={remaining:o.lineClamp,exhausted:!1});let s=o.marginLeft,c=o.marginRight,l=o.borderLeftWidth,u=o.borderRightWidth,d=o.borderTopWidth,f=o.borderBottomWidth,p=o.paddingLeft,m=o.paddingRight,h=o.paddingTop,g=o.paddingBottom,_=n+s,v=o.width>0?o.width:i-s-c,y=_+l+p,b=Math.max(0,v-l-u-p-m),x=r,S=x+d+h,C={type:`box`,style:o,x:_,y:x,width:v,height:0,tagName:t.tagName,children:[],listMarker:t.listMarker};if(o.display===`flex`){let n=bM(e,t,y,S,b);return C.children=n.children,C.height=d+h+n.height+g+f,{box:C,height:C.height,marginBottomOut:o.marginBottom}}if(o.display===`table`){let n=yM(e,t,y,S,b);return C.children=n.children,C.height=d+h+n.height+g+f,{box:C,height:C.height,marginBottomOut:o.marginBottom}}if(t.children.length===0)return C.height=d+h+g+f,o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:o.marginBottom};if(Kj(t)){let{nodes:n,height:r}=gM(e,t,y,S,b,t.tagName===`li`&&Bj.has(o.listStyleType),a);C.children=n,C.height=d+h+r+g+f}else{let n=S,r=0,i=!1,s=t.tagName===`li`||t.tagName===`ul`||t.tagName===`ol`||t.tagName===`dd`||t.tagName===`dt`;for(let c=0;c<t.children.length;c++){let l=t.children[c];if(a&&(a.exhausted||a.remaining<=0)){a.exhausted=!0,r=0;break}if(l.tagName===`#text`||Gj(l)){let s=[l];for(;c+1<t.children.length;){let e=t.children[c+1];if(e.tagName===`#text`||Gj(e))s.push(e),c++;else break}r>0&&(n+=r,r=0);let u={element:null,tagName:`div`,style:{...t.style,display:`block`,marginTop:0,marginBottom:0,paddingTop:0,paddingBottom:0,borderTopWidth:0,borderBottomWidth:0},children:s,textContent:null},d=t.tagName===`li`&&Bj.has(o.listStyleType),{nodes:f,height:p}=gM(e,u,y,n,b,d,a);C.children.push(...f),n+=p,r=0,i=!0;continue}let u=l.style.marginTop;if(!(!i&&h===0&&d===0&&s)){let e=_M(r,u);n+=e}let{box:f,height:p,marginBottomOut:m}=vM(e,l,y,n,b,a);C.children.push(f),n+=p,r=a?.exhausted?0:m,i=!0}let c=o.marginBottom,l=g===0&&f===0&&s;l&&r>0&&(c=Math.max(o.marginBottom,r));let u=n-S;return!l&&r>0&&(u+=r),C.height=d+h+u+g+f,o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:c}}return o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:o.marginBottom}}function yM(e,t,n,r,i){let a=[],o=[];for(let e of t.children)if(e.tagName===`tr`)o.push(e);else if([`thead`,`tbody`,`tfoot`].includes(e.tagName))for(let t of e.children)t.tagName===`tr`&&o.push(t);if(o.length===0)return{children:a,height:0};let s=Math.max(...o.map(e=>e.children.filter(e=>e.tagName===`td`||e.tagName===`th`).length));if(s===0)return{children:a,height:0};let c=i/s,l=r;for(let t of o){let r=t.children.filter(e=>e.tagName===`td`||e.tagName===`th`),i=0,o=[];for(let t=0;t<r.length;t++){let a=r[t],{box:s,height:u}=vM(e,a,n+t*c,l,c);o.push(s),i=Math.max(i,u)}for(let e of o)e.height=i,a.push(e);l+=i}return{children:a,height:l-r}}function bM(e,t,n,r,i){let a=t.style,o=a.gap,s=[],c=t.children.filter(e=>e.tagName!==`#text`||e.textContent?.trim());if(c.length===0)return{children:s,height:0};if(a.flexDirection===`row`||a.flexDirection===``){let t=o*(c.length-1),a=c.reduce((e,t)=>e+(t.style.flexGrow||0),0),l=(i-t)/(a||c.length),u=n,d=0;for(let t of c){if(t.tagName===`#text`)continue;let n=l*(t.style.flexGrow||+(a===0)),{box:i,height:c}=vM(e,t,u,r,n);s.push(i),d=Math.max(d,c),u+=n+o}return{children:s,height:d}}let l=r;for(let t of c){if(t.tagName===`#text`)continue;let{box:r,height:a}=vM(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function xM(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=Fj(a);let o=Hj(e,r),s=t.y+r.borderTopWidth+r.paddingTop+Uj(e,r,o),c=jj(e,n.listMarker),l=r.direction===`rtl`,u=Bj.has(r.listStyleType),d=l?i?.paddingLeft:i?.paddingRight,f,p=s,m=`ltr`,h=t.x+r.borderLeftWidth+r.paddingLeft,g=t.x+t.width;if(u){let{ascent:t}=Yj(e,a),r=e.measureText(n.listMarker),i=d===void 0?7+t/3:d;f=l?g+i+(r.actualBoundingBoxLeft??0):h-i-(r.actualBoundingBoxRight??c);let o=((r.actualBoundingBoxAscent??0)-(r.actualBoundingBoxDescent??0))/2;p=s-t/3+o}else{let t=d===void 0?jj(e,` `):d;l?/\d/.test(n.listMarker)?(m=`rtl`,f=g+t+c):f=g+t:f=h-c-t}t.children.unshift({type:`text`,text:n.listMarker,x:f,y:p,width:c,style:{...a,textDecorationLine:`none`,fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:m}});let _=m===`rtl`?f-c:f;kj.push({y:Math.round(s),text:n.listMarker,bounds:{x:_,y:t.y+r.borderTopWidth+r.paddingTop,width:c,height:o}})}function SM(e,t,n,r=!0,i){Dj=r,Oj=i,Ij.clear(),Jj.clear(),Pj.clear(),Aj.clear(),kj=[];let{box:a,height:o}=vM(e,t,0,0,n);CM(e,a,t);let s=kj.slice().sort((e,t)=>e.y-t.y||e.bounds.x-t.bounds.x),c=[];for(let e of s){let t=c[c.length-1],n=e.bounds.height*.5;if(t&&Math.abs(e.y-t.y)<n){let n=t.text.length>0&&e.text.length>0&&!/\s$/.test(t.text)&&!/^\s/.test(e.text);t.text+=(n?` `:``)+e.text,t.y=Math.max(t.y,e.y);let r=Math.min(t.bounds.x,e.bounds.x),i=Math.min(t.bounds.y,e.bounds.y),a=Math.max(t.bounds.x+t.bounds.width,e.bounds.x+e.bounds.width),o=Math.max(t.bounds.y+t.bounds.height,e.bounds.y+e.bounds.height);t.bounds={x:r,y:i,width:a-r,height:o-i}}else c.push({y:e.y,text:e.text,bounds:{...e.bounds}})}return{root:a,height:o,lines:c}}function CM(e,t,n){xM(e,t,n);let r=0;for(let i of n.children)if(!(i.tagName===`#text`||Gj(i)))for(;r<t.children.length;){let n=t.children[r];if(n.type===`box`&&n.tagName===i.tagName){CM(e,n,i),r++;break}r++}}function wM(e){if(!e||e===`none`)return[];let t=[],n=e.split(/,(?![^(]*\))/);for(let e of n){let n=e.trim(),r=n.match(/(rgb[a]?\([^)]+\)|#[0-9a-fA-F]+|\b[a-z]+\b)(?:\s|$)/i),i=n.match(/-?[\d.]+px/g);if(i&&i.length>=2){let e=i.map(e=>parseFloat(e));t.push({offsetX:e[0],offsetY:e[1],blur:e[2]||0,color:r?r[1]:`rgba(0,0,0,1)`})}}return t}function TM(e,t){return e[`border${t}Width`]>0&&e[`border${t}Style`]!==`none`}function EM(e,t,n,r,i,a,o){if(e.save(),e.strokeStyle=o,e.lineWidth=i,a===`double`){let a=Math.max(i,2);e.lineWidth=Math.max(.5,i*.5),e.beginPath(),e.moveTo(t,n-a/2),e.lineTo(t+r,n-a/2),e.moveTo(t,n+a/2),e.lineTo(t+r,n+a/2),e.stroke()}else if(a===`wavy`){let a=Math.max(1.5,i),o=a*4;e.beginPath(),e.moveTo(t,n);for(let i=t;i<t+r;i+=o)e.quadraticCurveTo(i+o/4,n-a,i+o/2,n),e.quadraticCurveTo(i+o*3/4,n+a,i+o,n);e.stroke()}else a===`dotted`?e.setLineDash([i,i*2]):a===`dashed`&&e.setLineDash([i*3,i*2]),e.beginPath(),e.moveTo(t,n),e.lineTo(t+r,n),e.stroke();e.setLineDash([]),e.restore()}function DM(e,t,n,r,i,a){let o=t.indexOf(`linear-gradient(`);if(o===-1)return null;let s=0,c=-1;for(let e=o+16;e<t.length;e++)if(t[e]===`(`)s++;else if(t[e]===`)`){if(s===0){c=e;break}s--}if(c===-1)return null;let l=t.slice(o+16,c),u=[];s=0;let d=0,f=l;for(let e=0;e<f.length;e++)f[e]===`(`?s++:f[e]===`)`?s--:f[e]===`,`&&s===0&&(u.push(f.slice(d,e).trim()),d=e+1);u.push(f.slice(d).trim());let p=180,m=0,h=u[0];h.endsWith(`deg`)?(p=parseFloat(h),m=1):h===`to right`?(p=90,m=1):h===`to left`?(p=270,m=1):h===`to bottom`?(p=180,m=1):h===`to top`&&(p=0,m=1);let g=(p-90)*Math.PI/180,_=n+r/2,v=i+a/2,y=Math.abs(r*Math.cos(g))+Math.abs(a*Math.sin(g)),b=Math.cos(g)*y/2,x=Math.sin(g)*y/2,S=e.createLinearGradient(_-b,v-x,_+b,v+x),C=u.slice(m);for(let e=0;e<C.length;e++){let t=C[e].trim(),n=t,r=e/Math.max(1,C.length-1),i=t.match(/\s+([\d.]+%)\s*$/);i&&(r=parseFloat(i[1])/100,n=t.slice(0,t.length-i[0].length).trim());try{S.addColorStop(r,n)}catch{}}return S}function OM(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}function kM(e,t){e.strokeStyle=t.webkitTextStrokeColor||t.color,e.lineWidth=t.webkitTextStrokeWidth,e.lineJoin=`round`}function AM(e,t,n){let{style:r}=t;e.save(),e.font=Fj(r),e.textBaseline=`alphabetic`,e.fontKerning=r.fontKerning===`none`?`none`:`normal`,Number.isFinite(r.letterSpacing)&&r.letterSpacing!==0&&(e.letterSpacing=`${r.letterSpacing}px`),r.wordSpacing&&(e.wordSpacing=`${r.wordSpacing}px`),r.direction===`rtl`&&(e.direction=`rtl`,e.textAlign=`right`);let i=r.webkitBackgroundClip===`text`&&r.backgroundImage&&r.backgroundImage!==`none`,a=r.webkitTextStrokeWidth>0,o=r.webkitTextFillColor===`transparent`||r.color===`transparent`,s=wM(r.textShadow);if(s.length>0){let c=i||!o;for(let o of s)e.save(),e.shadowOffsetX=o.offsetX,e.shadowOffsetY=o.offsetY,e.shadowBlur=o.blur,e.shadowColor=o.color,c&&(e.fillStyle=i&&n?n:OM(r),e.fillText(t.text,t.x,t.y)),a&&(kM(e,r),e.strokeText(t.text,t.x,t.y)),e.restore()}let c=()=>{if(i){if(e.save(),n)e.fillStyle=n;else{let{ascent:n,descent:i}=Yj(e,r);e.fillStyle=DM(e,r.backgroundImage,t.x,t.width,t.y-n,n+i)||r.color}e.fillText(t.text,t.x,t.y),e.restore()}else (!o||!a)&&(e.fillStyle=OM(r),e.fillText(t.text,t.x,t.y))},l=()=>{a&&(e.save(),kM(e,r),e.strokeText(t.text,t.x,t.y),e.restore())};yj(r.paintOrder)?(l(),c()):(c(),l());let u=t.width,d=r.fontSize,f=r.textDecorationColor||r.color,p=r.textDecorationStyle||`solid`,m=Math.max(1,d/15),h=r.direction===`rtl`?t.x-u:t.x;if(r.textDecorationLine!==`none`){let{ascent:n}=Yj(e,r);e.font=Fj(r);let i=e.measureText(`x`).actualBoundingBoxAscent;if(r.textDecorationLine.includes(`underline`)){let n=d*.1;EM(e,h,t.y+n,u,m,p,f)}if(r.textDecorationLine.includes(`line-through`)){let n=-(i*.5);EM(e,h,t.y+n,u,m,p,f)}r.textDecorationLine.includes(`overline`)&&EM(e,h,t.y-n,u,m,p,f)}e.restore()}function jM(e,t){let{style:n}=t;qj(n.backgroundColor)||(e.fillStyle=n.backgroundColor,e.fillRect(t.x,t.y,t.width,t.height));let r=[[`Top`,t.x,t.y+n.borderTopWidth/2,t.x+t.width,t.y+n.borderTopWidth/2],[`Right`,t.x+t.width-n.borderRightWidth/2,t.y,t.x+t.width-n.borderRightWidth/2,t.y+t.height],[`Bottom`,t.x,t.y+t.height-n.borderBottomWidth/2,t.x+t.width,t.y+t.height-n.borderBottomWidth/2],[`Left`,t.x+n.borderLeftWidth/2,t.y,t.x+n.borderLeftWidth/2,t.y+t.height]];for(let[t,i,a,o,s]of r)TM(n,t)&&(e.strokeStyle=n[`border${t}Color`],e.lineWidth=n[`border${t}Width`],e.beginPath(),e.moveTo(i,a),e.lineTo(o,s),e.stroke());let i=null;n.webkitBackgroundClip===`text`&&n.backgroundImage&&n.backgroundImage!==`none`&&(i=DM(e,n.backgroundImage,t.x,t.width,t.y,t.height));for(let n of t.children)MM(e,n,i)}function MM(e,t,n){t.type===`text`?AM(e,t,n):jM(e,t)}function NM(e){let{html:t,width:n,height:r,accuracy:i=`performance`,debug:a}=e;if(!n||n<=0||Number.isNaN(n))throw TypeError(`layout: width must be a positive number, got ${n}`);let o=i===`balanced`,{fragment:s,css:c}=mj(t),{tree:l,cleanup:u}=Ej(s,c,n),d=document.createElement(`canvas`).getContext(`2d`);d.fontKerning=`normal`;let{root:f,height:p,lines:m}=SM(d,l,n,o,a),h=r||p;return u(),{layoutRoot:f,height:h,lines:m}}function PM(e){let{layout:t,width:n,pixelRatio:r=globalThis.devicePixelRatio??1}=e;if(e.ctx&&e.canvas)throw TypeError(`drawLayout: ctx and canvas are mutually exclusive — provide one or neither`);let i=t.height,a,o;return e.ctx?(o=e.ctx,a=e.ctx.canvas):(a=e.canvas??document.createElement(`canvas`),a.width=Math.ceil(n*r),a.height=Math.ceil(i*r),`style`in a&&(a.style.width=`${n}px`,a.style.height=`${i}px`),o=a.getContext(`2d`),o.scale(r,r)),MM(o,t.layoutRoot),{canvas:a}}var FM=/[MmLlHhVvCcSsQqTtAaZz]/,IM=/-?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-+]?\d+)?/g;function LM(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(FM.test(r)){let i=n+1;for(;i<e.length&&!FM.test(e[i]);)i++;let a=e.slice(n+1,i),o=[],s;for(IM.lastIndex=0;s=IM.exec(a);)o.push(Number(s[0]));t.push({cmd:r,args:o}),n=i}else n++}return t}function RM(e){let t=LM(e),n=[],r=0,i=0,a=0,o=0,s=null,c=null;for(let e of t){let t=e.cmd,l=t.toUpperCase(),u=t!==l,d=e.args,f=e=>u?r+e:e,p=e=>u?i+e:e,m=!0,h=!0;switch(l){case`M`:for(let e=0;e<d.length;e+=2){let t=u&&e>0?r+d[e]:f(d[e]),s=u&&e>0?i+d[e+1]:p(d[e+1]);e===0?(r=t,i=s,a=t,o=s):(n.push({type:`L`,x0:r,y0:i,x1:t,y1:s}),r=t,i=s)}break;case`L`:for(let e=0;e<d.length;e+=2){let t=f(d[e]),a=p(d[e+1]);n.push({type:`L`,x0:r,y0:i,x1:t,y1:a}),r=t,i=a}break;case`H`:for(let e=0;e<d.length;e++){let t=u?r+d[e]:d[e];n.push({type:`L`,x0:r,y0:i,x1:t,y1:i}),r=t}break;case`V`:for(let e=0;e<d.length;e++){let t=u?i+d[e]:d[e];n.push({type:`L`,x0:r,y0:i,x1:r,y1:t}),i=t}break;case`C`:for(let e=0;e<d.length;e+=6){let t=f(d[e]),a=p(d[e+1]),o=f(d[e+2]),c=p(d[e+3]),l=f(d[e+4]),u=p(d[e+5]);n.push({type:`C`,x0:r,y0:i,c1x:t,c1y:a,c2x:o,c2y:c,x1:l,y1:u}),s={x:o,y:c},r=l,i=u}m=!1;break;case`S`:for(let e=0;e<d.length;e+=4){let t=s?2*r-s.x:r,a=s?2*i-s.y:i,o=f(d[e]),c=p(d[e+1]),l=f(d[e+2]),u=p(d[e+3]);n.push({type:`C`,x0:r,y0:i,c1x:t,c1y:a,c2x:o,c2y:c,x1:l,y1:u}),s={x:o,y:c},r=l,i=u}m=!1;break;case`Q`:for(let e=0;e<d.length;e+=4){let t=f(d[e]),a=p(d[e+1]),o=f(d[e+2]),s=p(d[e+3]);n.push({type:`Q`,x0:r,y0:i,cx:t,cy:a,x1:o,y1:s}),c={x:t,y:a},r=o,i=s}h=!1;break;case`T`:for(let e=0;e<d.length;e+=2){let t=c?2*r-c.x:r,a=c?2*i-c.y:i,o=f(d[e]),s=p(d[e+1]);n.push({type:`Q`,x0:r,y0:i,cx:t,cy:a,x1:o,y1:s}),c={x:t,y:a},r=o,i=s}h=!1;break;case`A`:for(let e=0;e<d.length;e+=7){let t=d[e],a=d[e+1],o=d[e+2],s=d[e+3]!==0,c=d[e+4]!==0,l=f(d[e+5]),u=p(d[e+6]);t===0||a===0?(r!==l||i!==u)&&n.push({type:`L`,x0:r,y0:i,x1:l,y1:u}):r===l&&i===u||n.push({type:`A`,x0:r,y0:i,rx:t,ry:a,xAxisRotation:o,largeArc:s,sweep:c,x1:l,y1:u}),r=l,i=u}break;case`Z`:(r!==a||i!==o)&&n.push({type:`L`,x0:r,y0:i,x1:a,y1:o}),r=a,i=o;break;default:break}m&&(s=null),h&&(c=null)}return n}function zM(e,t){let n=1-t,r=n*n,i=t*t;return{x:n*r*e.x0+3*r*t*e.c1x+3*n*i*e.c2x+i*t*e.x1,y:n*r*e.y0+3*r*t*e.c1y+3*n*i*e.c2y+i*t*e.y1}}function BM(e,t){let n=1-t;return{x:n*n*e.x0+2*n*t*e.cx+t*t*e.x1,y:n*n*e.y0+2*n*t*e.cy+t*t*e.y1}}function VM(e){let t=Math.abs(e.rx),n=Math.abs(e.ry),r=e.xAxisRotation*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=(e.x0-e.x1)/2,s=(e.y0-e.y1)/2,c=i*o+a*s,l=-a*o+i*s,u=c*c/(t*t)+l*l/(n*n);if(u>1){let e=Math.sqrt(u);t*=e,n*=e}let d=e.largeArc===e.sweep?-1:1,f=t*t*n*n-t*t*l*l-n*n*c*c,p=t*t*l*l+n*n*c*c,m=Math.sqrt(Math.max(0,f/p)),h=d*m*(t*l/n),g=d*m*(-(n*c)/t),_=i*h-a*g+(e.x0+e.x1)/2,v=a*h+i*g+(e.y0+e.y1)/2,y=(e,t,n,r)=>{let i=e*n+t*r,a=Math.sqrt((e*e+t*t)*(n*n+r*r)),o=Math.acos(Math.min(1,Math.max(-1,i/a)));return e*r-t*n<0&&(o=-o),o},b=y(1,0,(c-h)/t,(l-g)/n),x=y((c-h)/t,(l-g)/n,(-c-h)/t,(-l-g)/n);return x%=2*Math.PI,!e.sweep&&x>0?x-=2*Math.PI:e.sweep&&x<0&&(x+=2*Math.PI),{cx:_,cy:v,rx:t,ry:n,phi:r,theta1:b,deltaTheta:x,cosPhi:i,sinPhi:a}}function HM(e,t){let{cx:n,cy:r,rx:i,ry:a,cosPhi:o,sinPhi:s,theta1:c,deltaTheta:l}=VM(e),u=c+t*l,d=i*Math.cos(u),f=a*Math.sin(u);return{x:o*d-s*f+n,y:s*d+o*f+r}}var UM=40;function WM(e){let t=[],n=0;for(let r of e){if(r.type===`L`){let e=Math.hypot(r.x1-r.x0,r.y1-r.y0);t.push({startLen:n,length:e,seg:r}),n+=e;continue}let e=[],i=0,a;a=r.type===`C`||r.type===`Q`?{x:r.x0,y:r.y0}:HM(r,0),e.push({t:0,len:0});for(let t=1;t<=UM;t++){let n=t/UM,o;o=r.type===`C`?zM(r,n):r.type===`Q`?BM(r,n):HM(r,n),i+=Math.hypot(o.x-a.x,o.y-a.y),e.push({t:n,len:i}),a=o}t.push({startLen:n,length:i,seg:r,samples:e}),n+=i}function r(e){if(!Number.isFinite(e)||e<0||e>n+1e-6)return null;if(e===0&&t.length>0){let e=t[0].seg;return e.type===`L`||e.type===`C`||e.type===`Q`?{x:e.x0,y:e.y0}:HM(e,0)}for(let n=0;n<t.length;n++){let r=t[n];if(e>r.startLen+r.length+1e-6)continue;let i=e-r.startLen;if(r.seg.type===`L`){let e=r.length===0?0:Math.max(0,Math.min(1,i/r.length));return{x:r.seg.x0+(r.seg.x1-r.seg.x0)*e,y:r.seg.y0+(r.seg.y1-r.seg.y0)*e}}let a=r.samples,o=0,s=a.length-1;for(;s-o>1;){let e=o+s>>1;a[e].len<=i?o=e:s=e}let c=a[o],l=a[s],u=l.len-c.len,d=u===0?0:(i-c.len)/u,f=Math.max(0,Math.min(1,c.t+(l.t-c.t)*d));return r.seg.type===`C`?zM(r.seg,f):r.seg.type===`Q`?BM(r.seg,f):HM(r.seg,f)}return null}return{length:n,getPointAtLength:r}}function GM(e){return WM(RM(e))}var KM;function qM(){if(KM!==void 0)return KM;if(typeof Intl<`u`&&typeof Intl.Segmenter==`function`)try{KM=new Intl.Segmenter(void 0,{granularity:`grapheme`})}catch{KM=null}else KM=null;return KM}function JM(e){if(!e)return[];let t=qM();if(t){let n=[];for(let r of t.segment(e))n.push(r.segment);return n}return Array.from(e)}function YM(e,t,n){switch(e){case`alphabetic`:return 0;case`middle`:return(t-n)/2;case`top`:return t;case`bottom`:return-n;case`hanging`:return t*.8;case`ideographic`:return-n*.5}}function XM(e){let t=[];function n(e,r){let i=e.style.direction===`rtl`||r;if(e.tagName===`#text`&&e.textContent){t.push({text:e.textContent,style:e.style,rtl:i});return}for(let t of e.children)n(t,i)}return n(e,!1),t}var ZM=RegExp(`[\\u0590-\\u05FF\\u0600-\\u06FF\\u0700-\\u074F\\u0750-\\u077F\\u0780-\\u07BF\\u07C0-\\u07FF\\u0800-\\u083F\\u0840-\\u085F\\u0860-\\u086F\\u08A0-\\u08FF\\u0900-\\u097F\\u0980-\\u09FF\\u0A00-\\u0A7F\\u0A80-\\u0AFF\\u0B00-\\u0B7F\\u0B80-\\u0BFF\\u0C00-\\u0C7F\\u0C80-\\u0CFF\\u0D00-\\u0D7F\\u0D80-\\u0DFF\\u0E00-\\u0E7F\\u0E80-\\u0EFF\\u0F00-\\u0FFF\\u1000-\\u109F\\u1780-\\u17FF\\u1800-\\u18AF\\uFB1D-\\uFB4F\\uFB50-\\uFDFF\\uFE70-\\uFEFF]`);function QM(e){return ZM.test(e)}function $M(e,t){let n=JM(t.text);if(n.length===0)return[];Mj(e,t.style),e.letterSpacing=`${t.style.letterSpacing||0}px`;let{ascent:r,descent:i}=Yj(e,t.style),a=[],o=``;for(let e of n){let t=e===` `;QM(e)&&!t?o+=e:(o&&=(a.push({text:o,shaped:!0,isSpace:!1}),``),a.push({text:e,shaped:!1,isSpace:t}))}o&&a.push({text:o,shaped:!0,isSpace:!1}),t.rtl&&a.reverse();let s=[];for(let n of a){let a=e.measureText(n.text).width;s.push({text:n.text,width:a,style:t.style,isSpace:n.isSpace,ascent:r,descent:i,shaped:n.shaped})}return s}function eN(e){let{segments:t,path:n,ctx:r,align:i,textBaseline:a}=e,o=[],s=0,c=0;for(let e of t){if(!e.text)continue;let t=e.style.lineHeight>0?e.style.lineHeight:e.style.fontSize;t>c&&(c=t);let n=$M(r,e);n.length!==0&&(o.push(...n),s+=r.measureText(e.text).width)}let l=0;for(let e of o)l+=e.width+(e.style.letterSpacing||0);o.length>0&&(l-=o[o.length-1].style.letterSpacing||0);let u=Math.max(0,l-s),d=n.length,f=0,p=0;if(i===`center`)f=Math.max(0,(d-l)/2);else if(i===`right`)f=Math.max(0,d-l);else if(i===`justify`){let e=o.filter(e=>e.isSpace).length;e>0&&d>l&&(p=(d-l)/e)}let m=[],h=f,g=0;for(let e=0;e<o.length;e++){let t=o[e],r=t.width+(t.isSpace?p:0),i=n.getPointAtLength(h);if(!i)break;let a=h+r,s;if(a>d)if(a-d<=u+.5)s=n.getPointAtLength(d);else break;else s=n.getPointAtLength(a);if(!s)break;let c=Math.atan2(s.y-i.y,s.x-i.x);m.push({char:t.text,x:i.x,y:i.y,rotation:c,width:t.width,style:t.style,ascent:t.ascent,descent:t.descent,pathOffset:g,shaped:t.shaped}),h=a+(t.style.letterSpacing||0),g+=t.width+(t.style.letterSpacing||0)}let _=tN(m,a);return{glyphs:m,textWidth:l,pathLength:d,lineHeight:c,bounds:_,textBaseline:a}}function tN(e,t){if(e.length===0)return{x:0,y:0,width:0,height:0};let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let o of e){let e=o.style.lineHeight>0?o.style.lineHeight:o.style.fontSize,s=o.ascent+o.descent,c=s>0?o.ascent/s:.75,l=e*c,u=e*(1-c),d=YM(t,o.ascent,o.descent),f=d-l,p=d+u,m=Math.cos(o.rotation),h=Math.sin(o.rotation),g=[{x:o.x+-h*f,y:o.y+m*f},{x:o.x+m*o.width+-h*f,y:o.y+h*o.width+m*f},{x:o.x+m*o.width+-h*p,y:o.y+h*o.width+m*p},{x:o.x+-h*p,y:o.y+m*p}];for(let e of g)e.x<n&&(n=e.x),e.y<r&&(r=e.y),e.x>i&&(i=e.x),e.y>a&&(a=e.y)}return{x:n,y:r,width:i-n,height:a-r}}function nN(e){let{html:t,align:n=`left`,textBaseline:r=`alphabetic`}=e,i=typeof e.path==`string`?GM(e.path):e.path,a=e.ctx??iN(),o=e.ctx===void 0,{fragment:s,css:c}=mj(t),{tree:l,cleanup:u}=Ej(s,c,2**53-1);o||a.save();try{return eN({segments:XM(l),path:i,ctx:a,align:n,textBaseline:r})}finally{o||a.restore(),u()}}function rN(e){let{layout:t,ctx:n}=e;if(t.glyphs.length===0)return;let r=t.textBaseline;n.save();try{sN(n,t.glyphs,r),uN(n,t.glyphs,t.textWidth,r),pN(n,t.glyphs,r)}finally{n.restore()}}function iN(){return(typeof OffscreenCanvas<`u`?new OffscreenCanvas(1,1):document.createElement(`canvas`)).getContext(`2d`)}var aN=new WeakMap;function oN(e,t){if(!t)return``;let n=aN.get(e);n||(n=new Map,aN.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=e.fillStyle;try{e.fillStyle=t;let r=typeof e.fillStyle==`string`?e.fillStyle:t;return n.set(t,r),r}catch{return n.set(t,t),t}finally{e.fillStyle=i}}function sN(e,t,n){let r=0;for(;r<t.length;){let i=t[r].style.backgroundColor;if(!i||qj(i)){r++;continue}let a=oN(e,i),o=r+1;for(;o<t.length&&oN(e,t[o].style.backgroundColor)===a;)o++;lN(e,t.slice(r,o),i,n),r=o}}function cN(e,t){let n=Math.cos(e.rotation),r=Math.sin(e.rotation),i=YM(t,e.ascent,e.descent),a=i-e.ascent,o=i+e.descent,s=e.width;return{tl:{x:e.x+-r*a,y:e.y+n*a},tr:{x:e.x+n*s+-r*a,y:e.y+r*s+n*a},br:{x:e.x+n*s+-r*o,y:e.y+r*s+n*o},bl:{x:e.x+-r*o,y:e.y+n*o}}}function lN(e,t,n,r){if(t.length===0)return;e.save(),e.fillStyle=n,e.beginPath();let i=cN(t[0],r);e.moveTo(i.tl.x,i.tl.y);for(let n=0;n<t.length;n++){let i=cN(t[n],r);e.lineTo(i.tl.x,i.tl.y),e.lineTo(i.tr.x,i.tr.y)}for(let n=t.length-1;n>=0;n--){let i=cN(t[n],r);e.lineTo(i.br.x,i.br.y),e.lineTo(i.bl.x,i.bl.y)}e.closePath(),e.fill(),e.restore()}function uN(e,t,n,r){for(let i of t){e.save(),e.translate(i.x,i.y),e.rotate(i.rotation),Mj(e,i.style),e.textBaseline=`alphabetic`,e.letterSpacing=`${i.style.letterSpacing||0}px`;let t=YM(r,i.ascent,i.descent),a=wM(i.style.textShadow);if(a.length>0)for(let n=a.length-1;n>=0;n--){let r=a[n];e.save(),e.shadowOffsetX=r.offsetX,e.shadowOffsetY=r.offsetY,e.shadowBlur=r.blur,e.shadowColor=r.color,e.fillStyle=hN(i.style),e.fillText(i.char,0,t),e.restore()}dN(e,i,n,t),e.restore()}}function dN(e,t,n,r){let{style:i}=t,a=i.webkitTextFillColor===`transparent`||i.color===`transparent`||qj(hN(i)),o=i.webkitTextStrokeWidth>0,s=i.webkitBackgroundClip===`text`&&i.backgroundImage&&i.backgroundImage!==`none`,c=yj(i.paintOrder||``),l=()=>{if(s){fN(e,t,n,r);return}if(a){if(o)return;e.fillStyle=`transparent`,e.fillText(t.char,0,r);return}e.fillStyle=hN(i),e.fillText(t.char,0,r)},u=()=>{o&&(e.save(),e.lineJoin=`round`,e.lineWidth=i.webkitTextStrokeWidth,e.strokeStyle=i.webkitTextStrokeColor||i.color,e.strokeText(t.char,0,r),e.restore())};c?(u(),l()):(l(),u())}function fN(e,t,n,r){let i=DM(e,t.style.backgroundImage,-t.pathOffset,n,r-t.ascent,t.ascent+t.descent);if(!i){e.fillStyle=hN(t.style),e.fillText(t.char,0,r);return}e.fillStyle=i,e.fillText(t.char,0,r)}function pN(e,t,n){for(let r of[`underline`,`line-through`,`overline`]){let i=0;for(;i<t.length;){let a=t[i].style;if(!a.textDecorationLine||!a.textDecorationLine.includes(r)){i++;continue}let o=a.textDecorationColor||a.color,s=a.textDecorationStyle||`solid`,c=oN(e,o),l=i+1;for(;l<t.length&&t[l].style.textDecorationLine&&t[l].style.textDecorationLine.includes(r)&&oN(e,t[l].style.textDecorationColor||t[l].style.color)===c&&(t[l].style.textDecorationStyle||`solid`)===s;)l++;mN(e,t.slice(i,l),r,s,o,n),i=l}}}function mN(e,t,n,r,i,a){if(t.length===0)return;let o=Math.max(1,t[0].style.fontSize/15),s=e=>{let t=YM(a,e.ascent,e.descent);return n===`underline`?t+e.descent*.5:n===`line-through`?t-e.ascent*.3:t-e.ascent*.9};if(r===`double`||r===`wavy`){for(let n of t)e.save(),e.translate(n.x,n.y),e.rotate(n.rotation),EM(e,0,s(n),n.width,o,r,i),e.restore();return}e.save(),e.strokeStyle=i,e.lineWidth=o,r===`dotted`?e.setLineDash([o,o*2]):r===`dashed`&&e.setLineDash([o*3,o*2]),e.beginPath();for(let n=0;n<t.length;n++){let r=t[n],i=s(r),a=Math.cos(r.rotation),o=Math.sin(r.rotation),c={x:r.x+-o*i,y:r.y+a*i},l={x:r.x+a*r.width+-o*i,y:r.y+o*r.width+a*i};n===0?e.moveTo(c.x,c.y):e.lineTo(c.x,c.y),e.lineTo(l.x,l.y)}e.stroke(),e.setLineDash([]),e.restore()}function hN(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}var gN=`<style>${Py}
|
|
514
514
|
/* render-tag draws list markers natively from the <ol>/<ul> tag + tree position
|
|
515
515
|
(it ignores the polotno reset's ::before + counter() markers, which only work
|
|
516
516
|
in real DOM — the Quill editor and the foreignObject rasterizer). The shared
|
package/utils/validate-key.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"mobx";import{getAPI as o}from"./api.js";import{setRemoveBackgroundEnabled as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const p=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let u=fetch;export const __=e=>{u=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await u(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.0.0-beta.
|
|
1
|
+
import*as e from"mobx";import{getAPI as o}from"./api.js";import{setRemoveBackgroundEnabled as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const p=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let u=fetch;export const __=e=>{u=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await u(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.0.0-beta.47"})});if(e.runInAction(()=>{a.value=r.headers.get("x-api-version")||""}),!n){return console.error("Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1}),!1}if(200!==r.status){await new Promise(e=>setTimeout(e,3e3));continue}const s=await r.json();return s.is_valid||(console.error("Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1})),s.is_paid||(console.log("%cPolotno Free Version. For development usage only. https://polotno.com/","background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{0===i.value&&(i.value=2)})),s.is_domain_valid||console.log(p,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),t(s.remove_background_enabled),s.is_paid||!1}catch(r){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e,o){s=e,await isKeyPaid(e)&&!o||r()}
|