@sigma-studio/viewer 0.305.0 → 0.306.0
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/dist/index.js +44 -11
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,47 @@
|
|
|
1
|
-
import{Component as lT,useEffect as ni,useId as cT,useLayoutEffect as xs,useMemo as lm,useRef as mm,useState as mr}from"react";var FT=Math.PI/12;function Ct(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function di(e,t,n){if(!t)return e;let r=bm(e,t,n),o=r.map(d=>d.x),i=r.map(d=>d.y),a=Math.min(...o),s=Math.min(...i),c=Math.max(...o),l=Math.max(...i);return{x:a,y:s,w:Math.max(1,c-a),h:Math.max(1,l-s)}}function bm(e,t,n){let r=n??Ct(e),o=Math.cos(t),i=Math.sin(t);return[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}].map(a=>{let s=a.x-r.x,c=a.y-r.y;return{x:r.x+s*o-c*i,y:r.y+s*i+c*o}})}function Lt(e){let t=e.map(s=>s.x),n=e.map(s=>s.y),r=Math.min(...t),o=Math.min(...n),i=Math.max(...t),a=Math.max(...n);return{x:r,y:o,w:i-r,h:a-o}}function pi(e,t,n){let r=Se(e),o=Se(t),i=Se(n);return o<=i?r>=o&&r<=i:r>=o||r<=i}function Se(e){let t=Math.PI*2;return(e%t+t)%t}function Nt(e,t,n){return Math.min(Math.max(e,t),n)}var On="plot",dt={left:46,top:18,right:18,bottom:34},Sm={left:34,top:20,right:28,bottom:30};function le(e){return e.kind==="numberLine"?Sm:dt}function mi(e){if(e.props.boundsMode!==On)return e.props.preserveSpecSize===!0?e.props.spec:{...e.props.spec,width:e.props.w,height:e.props.h};if(e.props.preserveSpecSize===!0)return e.props.spec;let t=le(e.props.spec);return{...e.props.spec,width:e.props.w+t.left+t.right,height:e.props.h+t.top+t.bottom}}function Ge(e){let t=mi(e),n=le(t),r=Math.max(1,t.width-n.left-n.right),o=Math.max(1,t.height-n.top-n.bottom);if(e.props.boundsMode!==On)return{spec:t,plotBox:n,renderBounds:{x:e.x,y:e.y,w:e.props.w,h:e.props.h},scaleX:e.props.w/Math.max(1,t.width),scaleY:e.props.h/Math.max(1,t.height)};let i=e.props.w/r,a=e.props.h/o;return{spec:t,plotBox:n,renderBounds:{x:e.x-n.left*i,y:e.y-n.top*a,w:t.width*i,h:t.height*a},scaleX:i,scaleY:a}}var As={arrow:{idPrefix:"arrowhead",markerWidth:9,markerHeight:8,tipX:8.45,lineStopX:7,refY:4,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:1.5,y:1.5},{x:7,y:4},{x:1.5,y:6.5}],closed:!1,filled:!1,strokeWidth:1.2}},triangle:{idPrefix:"triangle",markerWidth:8,markerHeight:8,tipX:7,lineStopX:1.5,refY:4,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:1,y:1},{x:7,y:4},{x:1,y:7}],closed:!0,filled:!0,strokeWidth:0}},openArrow:{idPrefix:"openArrow",markerWidth:9,markerHeight:10,tipX:8.07,lineStopX:7,refY:5,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:.8,y:.8},{x:7,y:5},{x:.8,y:9.2}],closed:!1,filled:!1,strokeWidth:1.2}},thinArrow:{idPrefix:"thinArrow",markerWidth:11,markerHeight:8,tipX:10.7,lineStopX:9,refY:4,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:1,y:1.8},{x:9,y:4},{x:1,y:6.2}],closed:!1,filled:!1,strokeWidth:.9}},diamond:{idPrefix:"diamond",markerWidth:10,markerHeight:8,tipX:9,lineStopX:1.5,refY:4,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:1,y:4},{x:5,y:1},{x:9,y:4},{x:5,y:7}],closed:!0,filled:!0,strokeWidth:0}},dot:{idPrefix:"dot",markerWidth:8,markerHeight:8,tipX:4,lineStopX:4,refY:4,reversibleOrient:!1,geometry:{kind:"circle",cx:4,cy:4,r:3,filled:!0}},bar:{idPrefix:"bar",markerWidth:8,markerHeight:12,tipX:4,lineStopX:4,refY:6,reversibleOrient:!1,geometry:{kind:"polyline",points:[{x:4,y:0},{x:4,y:12}],closed:!1,filled:!1,strokeWidth:2}}},Ns=Object.keys(As).map(e=>({kind:e,...As[e]})),vm=new Map(Ns.map(e=>[e.kind,e]));function wn(e){return typeof e!="string"?null:vm.get(e)??null}function kn(e,t,n){let r=wn(e);return r?`${r.idPrefix}-${t}-${n}`:null}function Fs(e){let t=wn(e);return t?Math.max(0,t.tipX-t.lineStopX):0}var xr={spec:null,trimPx:0,refX:0},Pm=.9,Mm=.8;function br(e,t,n,r,o,i){let a=wn(e),s=wn(t),c=Number.isFinite(n)&&n>0?n:0,l=Cs(Es(Is(a,c),i?.start),o.start),d=Cs(Es(Is(s,c),i?.end),o.end),u=Number.isFinite(r)&&r>0?r*Mm:0,m=l+d;if(m>u){let h=m>0?u/m:0;l*=h,d*=h}return{start:Ls(a,l,c),end:Ls(s,d,c)}}function Is(e,t){return!e||t<=0?0:Math.max(0,e.tipX-e.lineStopX)*t}function Es(e,t){return t===void 0?e:Number.isFinite(t)&&t>0?Math.min(e,t):0}function Cs(e,t){return!Number.isFinite(t)||t<=0?0:Math.min(e,t*Pm)}function Ls(e,t,n){if(!e)return xr;let r=Number.isFinite(t)&&t>0&&n>0?t:0;return{spec:e,trimPx:r,refX:e.tipX-(n>0?r/n:0)}}function Sr(e,t){let n=[];for(let[r,o]of[["start",t.start],["end",t.end]]){let i=o.spec,a=i?kn(i.kind,e,r):null;i&&a&&n.push({spec:i,endpoint:r,id:a,refX:o.refX})}return n}function vr(e,t){return t==="start"&&e.reversibleOrient?"auto-start-reverse":"auto"}function Bn(e){let[t,...n]=e.points,r=[`M ${gr(t.x)} ${gr(t.y)}`];for(let o of n)r.push(`L ${gr(o.x)} ${gr(o.y)}`);return e.closed&&r.push("Z"),r.join(" ")}var Tm=Math.max(...Ns.map(Om));function Om(e){return Math.max(e.markerWidth,e.markerHeight)}function gr(e){return String(Number(e.toFixed(4)))}var wm=/[\u200B-\u200D\uFEFF]/g;function Pr(e,t){return!Number.isFinite(t)||t===1||t<=0?e:e.map(n=>({...n,top:n.top/t,bottom:n.bottom/t,height:n.height/t}))}function Ds(e,t={}){return km(e,Em,t).map(n=>({boxedRun:n.boxedRun,index:n.index,node:n.item}))}function km(e,t,n={}){let r=e.map((c,l)=>({index:l,item:c})),o=n.runIdPrefix?`${Lm(n.runIdPrefix)}-`:"",i=0,a=[],s=()=>{if(a.length===0)return;let c=`${o}boxed-run-${i}`,l=a.length;a.forEach((d,u)=>{r[d.index].boxedRun={connectLeft:u>0,connectRight:u<l-1,runId:c,segmentCount:l,segmentId:`${c}-segment-${u}-${d.index}`,segmentIndex:u,styleKey:d.styleKey}}),a=[],i+=1};return e.forEach((c,l)=>{let d=t(c);if(d.kind!=="ignored"){if(d.kind==="break"){s();return}a.length>0&&a[0].styleKey!==d.styleKey&&s(),a.push({index:l,styleKey:d.styleKey})}}),s(),r}function fi(e){return e.map(t=>t.type==="text"?["text",t.text,t.marks?.join(",")??"",t.boxedPaddingY??"",t.boxedVariant??"",t.boxedTone??"",t.color??"",t.backgroundColor??"",t.fontFamily??"",t.fontSize??""].join(":"):["math",t.id,t.tex,t.marks?.join(",")??"",t.boxedPaddingY??"",t.boxedVariant??"",t.boxedTone??""].join(":")).join("|")}function Bm(e){let t=Mr(e),n=t.paddingY??0,r=t.variant??"frame",o=t.tone??"";return`${n}|${r}|${o}`}function Mr(e){return{paddingY:Cm(e.boxedPaddingY,e.paddingY),variant:_s(e.boxedVariant,e.variant),tone:_s(e.boxedTone,e.tone)}}function Ft(e){return e.replace(wm,"").length>0}function Rm(e){let t=[];for(let n of e){if(!Number.isFinite(n.top)||!Number.isFinite(n.bottom)||n.height<=0)continue;let r=t[t.length-1];if(!r||n.top>r.bottom-1||n.bottom<r.top+1){t.push({top:n.top,bottom:n.bottom,rects:[n]});continue}r.top=Math.min(r.top,n.top),r.bottom=Math.max(r.bottom,n.bottom),r.rects.push(n)}return t.map(n=>n.rects)}function Am(e,t){return Math.max(0,e-t)}function Im(e,t){return Math.max(0,t-e)}function Gs(e){let t=new Map;for(let n of Rm(e)){let r=Math.min(...n.map(a=>a.top)),o=Math.max(...n.map(a=>a.bottom)),i=o-r;if(!(!Number.isFinite(i)||i<=0))for(let a of n){if(a.boxedTarget===void 0)continue;let s=t.get(a.boxedTarget);t.set(a.boxedTarget,{targetHeight:Math.max(s?.targetHeight??0,i),ownHeight:Math.max(s?.ownHeight??0,a.height),extraPaddingTop:Math.max(s?.extraPaddingTop??0,Am(a.top,r)),extraPaddingBottom:Math.max(s?.extraPaddingBottom??0,Im(a.bottom,o))})}}return t}function Em(e){return e.type==="text"&&!Ft(e.text)?{kind:"ignored"}:e.marks?.includes("boxed")?{kind:"boxed",styleKey:Bm(e)}:{kind:"break"}}function Cm(...e){for(let t of e){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""){let n=Number.parseFloat(t);if(Number.isFinite(n))return n}}}function _s(...e){for(let t of e)if(typeof t=="string"&&t.length>0)return t}function Lm(e){return e.replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"inline"}function $s(e){let t=[],n=0,r=i=>{i.length>0&&t.push({type:"text",text:i})},o=i=>{let a=i.trim();a.length>0&&t.push({type:"math",tex:a})};for(let i=0;i<e.length;i+=1){let a=Nm(e,i);if(!a)continue;let s=Fm(e,i+a.open.length,a.close);s<0||(r(e.slice(n,i)),o(e.slice(i+a.open.length,s)),i=s+a.close.length-1,n=i+1)}return r(e.slice(n)),t.length>0?t:[{type:"text",text:e}]}function Nm(e,t){return e.startsWith("\\(",t)?{open:"\\(",close:"\\)"}:e.startsWith("\\[",t)?{open:"\\[",close:"\\]"}:e.startsWith("$$",t)&&e[t-1]!=="\\"?{open:"$$",close:"$$"}:e[t]==="$"&&e[t-1]!=="\\"&&e[t+1]!=="$"?{open:"$",close:"$"}:null}function Fm(e,t,n){for(let r=t;r<e.length;r+=1)if(e.startsWith(n,r)&&!(n==="$"&&(e[r-1]==="\\"||e[r+1]==="$")))return r;return-1}var _m=200,pt=new Map,Dm=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han} -〿!-⦆¢-○]/u,Gm=/(?:^|\s)[a-z]{2,}(?:\s|$)/,$m=/^\s*[-+*/<>=,&|]|[-+*/<>=,&|]\s*$/;function yi(e){let t=pt.get(e);if(t!==void 0)return pt.delete(e),pt.set(e,t),t;let n=zm(e);if(pt.size>=_m){let r=pt.keys().next().value;r!==void 0&&pt.delete(r)}return pt.set(e,n),n}function zm(e){let t=$s(e),n=t.filter(o=>o.type==="math");if(n.length===0||n.some(o=>Um(o.tex)))return null;let r=t.map((o,i)=>o.type==="text"?{type:"text",text:o.text}:{type:"mathInline",id:`t${i}`,tex:o.tex,display:"inline"});return Hm(r)===e?r:null}function Hm(e){return e.map(t=>t.type==="text"?t.text:`$${t.tex}$`).join("")}function Um(e){return e.includes("\\")?!1:Dm.test(e)||Gm.test(e)||$m.test(e)}function zs(e){let t=e.find(r=>r.hasGlyph);if(!t)return;let n={};return t.kind==="text"&&t.fontFamily&&(n.fontFamily=t.fontFamily),t.fontSizePt!==void 0&&Number.isFinite(t.fontSizePt)&&t.fontSizePt>0&&(n.fontSizePt=t.fontSizePt),n.fontFamily===void 0&&n.fontSizePt===void 0?void 0:n}function Vm(e){return Ft(e.replace(/[\n\r]/g,""))}function Hs(e){return e.map(t=>({kind:t.type==="mathInline"?"math":"text",hasGlyph:Vm(t.type==="mathInline"?t.tex:t.text),fontFamily:t.fontFamily,fontSizePt:t.fontSize}))}var hi="displaystyle",Wm={displaystyle:"\\displaystyle",textstyle:"\\textstyle"};function Tr(e){return e==="texDefault"?"textstyle":hi}function mt(e,t){return`${Wm[t]} ${e}`}function Or(e,t={}){return{kind:"fragment",children:(t.annotateBoxedRuns?Ds(e,{runIdPrefix:t.runIdPrefix}):e.map((r,o)=>({index:o,node:r}))).map(({boxedRun:r,index:o,node:i})=>Xm(i,o,r))}}function Us(e,t,n,r,o){let i=Km(e);return{type:"box",...i!==void 0?{paddingY:i}:{},math:t,connectLeft:n?.connectLeft,connectRight:n?.connectRight,run:n,variant:typeof r=="string"?r:void 0,tone:typeof o=="string"?o:void 0}}function Xm(e,t,n){let r=Ym(e);if(e.type==="mathInline"){let i=[];return r&&i.push({type:"style",style:r}),e.marks?.includes("underline")&&i.push({type:"underline"}),e.marks?.includes("boxed")&&i.push(Us(e.boxedPaddingY,!0,n,e.boxedVariant,e.boxedTone)),{kind:"math",id:e.id,tex:e.tex,decorations:i,sourceIndex:t}}let o=(e.marks??[]).flatMap(i=>i==="bold"||i==="italic"||i==="underline"?[{type:i}]:i==="boxed"?[Us(e.boxedPaddingY,!1,n,e.boxedVariant,e.boxedTone)]:[]);return r&&o.push({type:"style",style:r}),{kind:"text",text:e.text,decorations:o,sourceIndex:t}}function Ym(e){let t=typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?e.fontSize:void 0,n={backgroundColor:e.backgroundColor,color:e.color,fontFamily:e.fontFamily,fontSizePt:t};return Object.values(n).some(r=>r!==void 0)?n:void 0}function Km(e){let t=typeof e=="number"?e:Number.parseFloat(String(e));return Number.isFinite(t)&&t>=0?t:void 0}var Vs=new WeakMap;function gi(e,t={}){let n=t.runIdPrefix??"overlay",r=Vs.get(e);r||(r=new Map,Vs.set(e,r));let o=r.get(n);if(o)return o;let i=jm(e,n);return r.set(n,i),i}function jm(e,t){return{kind:"fragment",children:e.blocks.map((n,r)=>({kind:"block",blockType:n.type,headingLevel:n.type==="heading"?n.level:void 0,isBlank:qm(n),textAlign:n.align,lineHeight:Zm(n.lineHeight),children:Or(n.children,{annotateBoxedRuns:!0,runIdPrefix:`${t}-${r}`}).children}))}}function qm(e){return e.children.every(t=>t.type==="text"&&t.text.length===0)}function Zm(e){let t=typeof e=="number"?String(e):String(e??"").trim();if(!/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})$/u.test(t))return;let n=Number(t);if(!(!Number.isFinite(n)||n<.8||n>3))return n.toFixed(2).replace(/\.?0+$/u,"")}function re(e){return e==="s"?1.25:e==="l"?3:e==="xl"?5:2}function $e(e){return e==="s"?14:e==="l"?22:e==="xl"?28:18}function Jm(e,t){return Ks(e.columns.map(n=>n.width),t)}function Qm(e,t){return Ks(e.rows.map(n=>n.height),t)}function Dt(e,t){return t<0||t>e.columns.length?null:t===0?{axis:"vertical",edge:"left"}:t===e.columns.length?{axis:"vertical",edge:"right"}:{axis:"vertical",beforeColumnId:e.columns[t].id}}function Gt(e,t){return t<0||t>e.rows.length?null:t===0?{axis:"horizontal",edge:"top"}:t===e.rows.length?{axis:"horizontal",edge:"bottom"}:{axis:"horizontal",beforeRowId:e.rows[t].id}}function ef(e,t){let n=e.grid.lineOverrides??[];for(let r=n.length-1;r>=0;r-=1){let o=n[r];if(nf(o,t))return o}}function Ae(e,t){let r="edge"in t?e.grid.showOuterBorder!==!1:e.grid.showInnerBorders!==!1,o=ef(e,t)?.style,i=o?.borderWidth??e.grid.borderWidth;return{visible:o?.visible??r,borderColor:o?.borderColor??e.grid.borderColor,borderWidth:Number.isFinite(i)?Math.max(0,i):0,borderStyle:o?.borderStyle??e.grid.borderStyle??"solid"}}function xi(e){return!e.visible||e.borderWidth<=0?"0":`${e.borderWidth}px ${e.borderStyle} ${e.borderColor}`}function tf(e,t,n,r=1,o=1){return{borderTop:wr(e,"horizontal",t),borderRight:wr(e,"vertical",n+o),borderBottom:wr(e,"horizontal",t+r),borderLeft:wr(e,"vertical",n)}}function nf(e,t){return e.axis!==t.axis?!1:"edge"in e||"edge"in t?"edge"in e&&"edge"in t&&e.edge===t.edge:e.axis==="vertical"&&t.axis==="vertical"?e.beforeColumnId===t.beforeColumnId:e.axis==="horizontal"&&t.axis==="horizontal"?e.beforeRowId===t.beforeRowId:!1}function wr(e,t,n){let r=t==="vertical"?Dt(e,n):Gt(e,n);if(!r)return"0";let o=Ae(e,r);return o.visible&&o.borderWidth>0&&o.borderStyle==="double"?"0":xi(o)}var kr=1e-6;function Ks(e,t){if(e.length===0)return[];let n=e.map(rf),r=n.reduce((c,l)=>c+l,0),o=Number.isFinite(t)?Math.max(1,t):Math.max(1,r);if(r>o){let c=o/r;return n.map(l=>l*c)}let i=o-r;if(i<=kr)return n;if(r<=0){let c=o/e.length;return Ws(e.map(l=>Math.min(c,Br(l))),e,o)}let a=e.reduce((c,l)=>c+(l.mode==="fr"?Math.max(0,l.value):0),0),s=a>0?e.map((c,l)=>{if(c.mode!=="fr")return n[l];let d=n[l]+i*(Math.max(0,c.value)/a);return js(d,c.min,c.max)}):n.map((c,l)=>Math.min(c*o/r,Math.max(c,Br(e[l]))));return Ws(s,e,o)}function Ws(e,t,n){let r=[...e];for(let i=0;i<=r.length;i+=1){let a=n-r.reduce((l,d)=>l+d,0);if(a<=kr)break;let s=r.map((l,d)=>d).filter(l=>r[l]<Br(t[l])-kr);if(s.length===0)break;let c=s.reduce((l,d)=>l+Math.max(1,r[d]),0);for(let l of s){let d=a*(Math.max(1,r[l])/c);r[l]=Math.min(r[l]+d,Math.max(r[l],Br(t[l])))}}let o=r.reduce((i,a)=>i+a,0);return o>0&&Math.abs(n-o)>kr?r.map(i=>i*n/o):r}function Br(e){return e.mode==="fixed"?Number.POSITIVE_INFINITY:e.max??Number.POSITIVE_INFINITY}function rf(e){return e.mode==="fixed"?Math.max(1,e.value):js(e.min??1,e.min,e.max)}function js(e,t,n){return Math.max(t??1,Math.min(e,n??Number.POSITIVE_INFINITY))}function qs(e,t,n){let r=Jm(e,t),o=Qm(e,n),i=new Map(e.cells.map(c=>[`${c.rowId}:${c.columnId}`,c])),a=new Set,s=e.rows.map((c,l)=>{let d=[];return e.columns.forEach((u,m)=>{if(a.has(`${l}:${m}`))return;let h=i.get(`${c.id}:${u.id}`),y=h?.rowSpan??1,g=h?.colSpan??1;for(let x=l;x<l+y;x+=1)for(let S=m;S<m+g;S+=1)(x!==l||S!==m)&&a.add(`${x}:${S}`);d.push({cell:h,colSpan:g,columnIndex:m,rowIndex:l,rowSpan:y})}),{cells:d,height:o[l],rowId:c.id}});return{columnOffsets:Xs(r),columnWidths:r,rowHeights:o,rowOffsets:Xs(o),rows:s}}function Xs(e){let t=[0];for(let n of e)t.push(t[t.length-1]+n);return t}function Zs(e,t){let n=Math.max(42,t>1?38*t:44),r=24,o=e==="up"?18:e==="down"?6:12,i=e==="up"?6:e==="down"?18:12,a=e==="up"?`${n-6},${i} ${n-12},${i-1.5} ${n-9},${i+4}`:e==="down"?`${n-6},${i} ${n-12},${i+1.5} ${n-9},${i-4}`:`${n-6},${i} ${n-12},${i-3} ${n-12},${i+3}`;return{width:n,height:r,line:{x1:6,y1:o,x2:n-7,y2:i},arrowPoints:a,color:"#111827",strokeWidth:1}}function _t(e){return"edge"in e?`${e.axis}:edge:${e.edge}`:e.axis==="vertical"?`${e.axis}:before:${e.beforeColumnId}`:`${e.axis}:before:${e.beforeRowId}`}var Js={boxSizing:"border-box",position:"relative",minWidth:"0",overflow:"hidden"},Qs={color:"#111827",fontSize:"15pt",lineHeight:"1.35"},el={position:"absolute",inset:"0",display:"flex",minWidth:"0",minHeight:"0",flexDirection:"column",overflow:"hidden"};function tl(e,t,n,r,o,i){let a={...e.defaultCellStyle,...t?.style??{}},s=tf(e,n,r,o,i);return{textAlign:a.align??"center",verticalAlign:a.verticalAlign??"middle",padding:"0",...a.color?{color:a.color}:{},...a.backgroundColor?{background:a.backgroundColor}:{},...a.fontFamily?{fontFamily:a.fontFamily}:{},...a.fontSize?{fontSize:`${a.fontSize}pt`}:{},...a.fontWeight?{fontWeight:String(a.fontWeight)}:{},borderTop:s.borderTop,borderRight:s.borderRight,borderBottom:s.borderBottom,borderLeft:s.borderLeft}}function nl(e,t){let n={...e.defaultCellStyle,...t?.style??{}};return{justifyContent:of(n.verticalAlign??"middle"),padding:`${n.paddingY??5}px ${n.paddingX??8}px`}}function of(e){return e==="top"?"flex-start":e==="bottom"?"flex-end":"center"}function Rr(e){return e.visible&&e.borderWidth>0&&e.borderStyle==="double"}function Ys(e,t,n){let r=Math.max(0,n.borderWidth),o=`${r}px ${n.borderStyle} ${n.borderColor}`;return e==="vertical"?{left:`${t-r/2}px`,borderLeft:o}:{top:`${t-r/2}px`,borderTop:o}}function rl(e,t,n){let r=[];return t.forEach((o,i)=>{let a=Dt(e,i);if(!a)return;let s=Ae(e,a);Rr(s)&&r.push({axis:"vertical",key:a,domKey:_t(a),style:Ys("vertical",o,s)})}),n.forEach((o,i)=>{let a=Gt(e,i);if(!a)return;let s=Ae(e,a);Rr(s)&&r.push({axis:"horizontal",key:a,domKey:_t(a),style:Ys("horizontal",o,s)})}),r}function ol(e,t,n){let r=[];return t.forEach((o,i)=>{let a=Dt(e,i);if(!a)return;let s=Ae(e,a);Rr(s)&&n.forEach((c,l)=>{let d=Gt(e,l);if(!d)return;let u=Ae(e,d);!u.visible||u.borderWidth<=0||r.push({axis:"horizontal",id:`connector-horizontal-${_t(a)}-${_t(d)}`,style:{left:`${o-s.borderWidth/2}px`,top:`${c-u.borderWidth/2}px`,width:`${s.borderWidth}px`,height:"0px",borderTop:xi(u)}})})}),n.forEach((o,i)=>{let a=Gt(e,i);if(!a)return;let s=Ae(e,a);Rr(s)&&t.forEach((c,l)=>{let d=Dt(e,l);if(!d)return;let u=Ae(e,d);!u.visible||u.borderWidth<=0||r.push({axis:"vertical",id:`connector-vertical-${_t(a)}-${_t(d)}`,style:{left:`${c-u.borderWidth/2}px`,top:`${o-s.borderWidth/2}px`,width:"0px",height:`${s.borderWidth}px`,borderLeft:xi(u)}})})}),r}function Ar(e){return e.split(/\r\n|\r|\n/)}var il=new WeakMap;function al(e){if(e.inlineContent)return af(e.inlineContent);if(e.richText){let t=il.get(e.richText);if(t)return t;let n=sf(e.richText);return il.set(e.richText,n),n}if(e.lines&&e.lines.length>0){let t=[];for(let n of e.lines)for(let r of Ar(n))t.push(r.length>0?[{kind:"text",text:r}]:[]);return t}return[[]]}function af(e){let t=[[]];for(let n of e)sl(t,n);return t}function sf(e){let t=Array.isArray(e.blocks)?e.blocks:[],n=[[]];return t.forEach((r,o)=>{o>0&&n.push([]);for(let i of r?.children??[])sl(n,i)}),n}function sl(e,t){if(t?.type==="text"){lf(e,t.text??"");return}t?.type==="mathInline"&&e[e.length-1].push({kind:"math",tex:t.tex})}function lf(e,t){Ar(t).forEach((r,o)=>{o>0&&e.push([]),r.length>0&&e[e.length-1].push({kind:"text",text:r})})}function bi(e){let t=Array.isArray(e.blocks)?e.blocks:[];return t.length===0?1:Math.max(1,t.reduce((n,r)=>n+cf(r?.children??[]),0))}function cf(e){return 1+e.reduce((t,n)=>n?.type==="text"?t+Math.max(0,(n.text??"").split(`
|
|
2
|
-
`).length-1):t,0)}function
|
|
3
|
-
`).length-1):t,0)}var
|
|
4
|
-
`).map(
|
|
1
|
+
import{Component as vT,useEffect as ai,useId as MT,useLayoutEffect as Ts,useMemo as ym,useRef as Sm,useState as gr}from"react";var jT=Math.PI/12;function Ft(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function yi(e,t,n){if(!t)return e;let r=wm(e,t,n),o=r.map(d=>d.x),i=r.map(d=>d.y),a=Math.min(...o),s=Math.min(...i),c=Math.max(...o),l=Math.max(...i);return{x:a,y:s,w:Math.max(1,c-a),h:Math.max(1,l-s)}}function wm(e,t,n){let r=n??Ft(e),o=Math.cos(t),i=Math.sin(t);return[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}].map(a=>{let s=a.x-r.x,c=a.y-r.y;return{x:r.x+s*o-c*i,y:r.y+s*i+c*o}})}function _t(e){let t=e.map(s=>s.x),n=e.map(s=>s.y),r=Math.min(...t),o=Math.min(...n),i=Math.max(...t),a=Math.max(...n);return{x:r,y:o,w:i-r,h:a-o}}function hi(e,t,n){let r=Se(e),o=Se(t),i=Se(n);return o<=i?r>=o&&r<=i:r>=o||r<=i}function Se(e){let t=Math.PI*2;return(e%t+t)%t}function Dt(e,t,n){return Math.min(Math.max(e,t),n)}var kn="plot",pt={left:46,top:18,right:18,bottom:34},km={left:34,top:20,right:28,bottom:30};function le(e){return e.kind==="numberLine"?km:pt}var Fs=new WeakMap;function gi(e){let t=Fs.get(e);if(t)return t;let n=Bm(e);return Fs.set(e,n),n}function Bm(e){if(e.props.boundsMode!==kn)return e.props.preserveSpecSize===!0?e.props.spec:{...e.props.spec,width:e.props.w,height:e.props.h};if(e.props.preserveSpecSize===!0)return e.props.spec;let t=le(e.props.spec);return{...e.props.spec,width:e.props.w+t.left+t.right,height:e.props.h+t.top+t.bottom}}function Ge(e){let t=gi(e),n=le(t),r=Math.max(1,t.width-n.left-n.right),o=Math.max(1,t.height-n.top-n.bottom);if(e.props.boundsMode!==kn)return{spec:t,plotBox:n,renderBounds:{x:e.x,y:e.y,w:e.props.w,h:e.props.h},scaleX:e.props.w/Math.max(1,t.width),scaleY:e.props.h/Math.max(1,t.height)};let i=e.props.w/r,a=e.props.h/o;return{spec:t,plotBox:n,renderBounds:{x:e.x-n.left*i,y:e.y-n.top*a,w:t.width*i,h:t.height*a},scaleX:i,scaleY:a}}var _s={arrow:{idPrefix:"arrowhead",markerWidth:9,markerHeight:8,tipX:8.45,lineStopX:7,refY:4,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:1.5,y:1.5},{x:7,y:4},{x:1.5,y:6.5}],closed:!1,filled:!1,strokeWidth:1.2}},triangle:{idPrefix:"triangle",markerWidth:8,markerHeight:8,tipX:7,lineStopX:1.5,refY:4,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:1,y:1},{x:7,y:4},{x:1,y:7}],closed:!0,filled:!0,strokeWidth:0}},openArrow:{idPrefix:"openArrow",markerWidth:9,markerHeight:10,tipX:8.07,lineStopX:7,refY:5,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:.8,y:.8},{x:7,y:5},{x:.8,y:9.2}],closed:!1,filled:!1,strokeWidth:1.2}},thinArrow:{idPrefix:"thinArrow",markerWidth:11,markerHeight:8,tipX:10.7,lineStopX:9,refY:4,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:1,y:1.8},{x:9,y:4},{x:1,y:6.2}],closed:!1,filled:!1,strokeWidth:.9}},diamond:{idPrefix:"diamond",markerWidth:10,markerHeight:8,tipX:9,lineStopX:1.5,refY:4,reversibleOrient:!0,geometry:{kind:"polyline",points:[{x:1,y:4},{x:5,y:1},{x:9,y:4},{x:5,y:7}],closed:!0,filled:!0,strokeWidth:0}},dot:{idPrefix:"dot",markerWidth:8,markerHeight:8,tipX:4,lineStopX:4,refY:4,reversibleOrient:!1,geometry:{kind:"circle",cx:4,cy:4,r:3,filled:!0}},bar:{idPrefix:"bar",markerWidth:8,markerHeight:12,tipX:4,lineStopX:4,refY:6,reversibleOrient:!1,geometry:{kind:"polyline",points:[{x:4,y:0},{x:4,y:12}],closed:!1,filled:!1,strokeWidth:2}}},Hs=Object.keys(_s).map(e=>({kind:e,..._s[e]})),Rm=new Map(Hs.map(e=>[e.kind,e]));function Bn(e){return typeof e!="string"?null:Rm.get(e)??null}function Rn(e,t,n){let r=Bn(e);return r?`${r.idPrefix}-${t}-${n}`:null}function Us(e){let t=Bn(e);return t?Math.max(0,t.tipX-t.lineStopX):0}var Mr={spec:null,trimPx:0,refX:0},Am=.9,Im=.8;function Pr(e,t,n,r,o,i){let a=Bn(e),s=Bn(t),c=Number.isFinite(n)&&n>0?n:0,l=$s(Gs(Ds(a,c),i?.start),o.start),d=$s(Gs(Ds(s,c),i?.end),o.end),u=Number.isFinite(r)&&r>0?r*Im:0,m=l+d;if(m>u){let h=m>0?u/m:0;l*=h,d*=h}return{start:zs(a,l,c),end:zs(s,d,c)}}function Ds(e,t){return!e||t<=0?0:Math.max(0,e.tipX-e.lineStopX)*t}function Gs(e,t){return t===void 0?e:Number.isFinite(t)&&t>0?Math.min(e,t):0}function $s(e,t){return!Number.isFinite(t)||t<=0?0:Math.min(e,t*Am)}function zs(e,t,n){if(!e)return Mr;let r=Number.isFinite(t)&&t>0&&n>0?t:0;return{spec:e,trimPx:r,refX:e.tipX-(n>0?r/n:0)}}function Tr(e,t){let n=[];for(let[r,o]of[["start",t.start],["end",t.end]]){let i=o.spec,a=i?Rn(i.kind,e,r):null;i&&a&&n.push({spec:i,endpoint:r,id:a,refX:o.refX})}return n}function Or(e,t){return t==="start"&&e.reversibleOrient?"auto-start-reverse":"auto"}function An(e){let[t,...n]=e.points,r=[`M ${vr(t.x)} ${vr(t.y)}`];for(let o of n)r.push(`L ${vr(o.x)} ${vr(o.y)}`);return e.closed&&r.push("Z"),r.join(" ")}var Em=Math.max(...Hs.map(Cm));function Cm(e){return Math.max(e.markerWidth,e.markerHeight)}function vr(e){return String(Number(e.toFixed(4)))}var Lm=/[\u200B-\u200D\uFEFF]/g;function wr(e,t){return!Number.isFinite(t)||t===1||t<=0?e:e.map(n=>({...n,top:n.top/t,bottom:n.bottom/t,height:n.height/t}))}function Ws(e,t={}){return Nm(e,$m,t).map(n=>({boxedRun:n.boxedRun,index:n.index,node:n.item}))}function Nm(e,t,n={}){let r=e.map((c,l)=>({index:l,item:c})),o=n.runIdPrefix?`${Hm(n.runIdPrefix)}-`:"",i=0,a=[],s=()=>{if(a.length===0)return;let c=`${o}boxed-run-${i}`,l=a.length;a.forEach((d,u)=>{r[d.index].boxedRun={connectLeft:u>0,connectRight:u<l-1,runId:c,segmentCount:l,segmentId:`${c}-segment-${u}-${d.index}`,segmentIndex:u,styleKey:d.styleKey}}),a=[],i+=1};return e.forEach((c,l)=>{let d=t(c);if(d.kind!=="ignored"){if(d.kind==="break"){s();return}a.length>0&&a[0].styleKey!==d.styleKey&&s(),a.push({index:l,styleKey:d.styleKey})}}),s(),r}function xi(e){return e.map(t=>t.type==="text"?["text",t.text,t.marks?.join(",")??"",t.boxedPaddingY??"",t.boxedVariant??"",t.boxedTone??"",t.color??"",t.backgroundColor??"",t.fontFamily??"",t.fontSize??""].join(":"):["math",t.id,t.tex,t.marks?.join(",")??"",t.boxedPaddingY??"",t.boxedVariant??"",t.boxedTone??""].join(":")).join("|")}function Fm(e){let t=kr(e),n=t.paddingY??0,r=t.variant??"frame",o=t.tone??"";return`${n}|${r}|${o}`}function kr(e){return{paddingY:zm(e.boxedPaddingY,e.paddingY),variant:Vs(e.boxedVariant,e.variant),tone:Vs(e.boxedTone,e.tone)}}function Gt(e){return e.replace(Lm,"").length>0}function _m(e){let t=[];for(let n of e){if(!Number.isFinite(n.top)||!Number.isFinite(n.bottom)||n.height<=0)continue;let r=t[t.length-1];if(!r||n.top>r.bottom-1||n.bottom<r.top+1){t.push({top:n.top,bottom:n.bottom,rects:[n]});continue}r.top=Math.min(r.top,n.top),r.bottom=Math.max(r.bottom,n.bottom),r.rects.push(n)}return t.map(n=>n.rects)}function Dm(e,t){return Math.max(0,e-t)}function Gm(e,t){return Math.max(0,t-e)}function Xs(e){let t=new Map;for(let n of _m(e)){let r=Math.min(...n.map(a=>a.top)),o=Math.max(...n.map(a=>a.bottom)),i=o-r;if(!(!Number.isFinite(i)||i<=0))for(let a of n){if(a.boxedTarget===void 0)continue;let s=t.get(a.boxedTarget);t.set(a.boxedTarget,{targetHeight:Math.max(s?.targetHeight??0,i),ownHeight:Math.max(s?.ownHeight??0,a.height),extraPaddingTop:Math.max(s?.extraPaddingTop??0,Dm(a.top,r)),extraPaddingBottom:Math.max(s?.extraPaddingBottom??0,Gm(a.bottom,o))})}}return t}function $m(e){return e.type==="text"&&!Gt(e.text)?{kind:"ignored"}:e.marks?.includes("boxed")?{kind:"boxed",styleKey:Fm(e)}:{kind:"break"}}function zm(...e){for(let t of e){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""){let n=Number.parseFloat(t);if(Number.isFinite(n))return n}}}function Vs(...e){for(let t of e)if(typeof t=="string"&&t.length>0)return t}function Hm(e){return e.replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"inline"}function Ys(e){let t=[],n=0,r=i=>{i.length>0&&t.push({type:"text",text:i})},o=i=>{let a=i.trim();a.length>0&&t.push({type:"math",tex:a})};for(let i=0;i<e.length;i+=1){let a=Um(e,i);if(!a)continue;let s=Vm(e,i+a.open.length,a.close);s<0||(r(e.slice(n,i)),o(e.slice(i+a.open.length,s)),i=s+a.close.length-1,n=i+1)}return r(e.slice(n)),t.length>0?t:[{type:"text",text:e}]}function Um(e,t){return e.startsWith("\\(",t)?{open:"\\(",close:"\\)"}:e.startsWith("\\[",t)?{open:"\\[",close:"\\]"}:e.startsWith("$$",t)&&e[t-1]!=="\\"?{open:"$$",close:"$$"}:e[t]==="$"&&e[t-1]!=="\\"&&e[t+1]!=="$"?{open:"$",close:"$"}:null}function Vm(e,t,n){for(let r=t;r<e.length;r+=1)if(e.startsWith(n,r)&&!(n==="$"&&(e[r-1]==="\\"||e[r+1]==="$")))return r;return-1}var Wm=200,mt=new Map,Xm=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han} -〿!-⦆¢-○]/u,Ym=/(?:^|\s)[a-z]{2,}(?:\s|$)/,Km=/^\s*[-+*/<>=,&|]|[-+*/<>=,&|]\s*$/;function bi(e){let t=mt.get(e);if(t!==void 0)return mt.delete(e),mt.set(e,t),t;let n=jm(e);if(mt.size>=Wm){let r=mt.keys().next().value;r!==void 0&&mt.delete(r)}return mt.set(e,n),n}function jm(e){let t=Ys(e),n=t.filter(o=>o.type==="math");if(n.length===0||n.some(o=>Zm(o.tex)))return null;let r=t.map((o,i)=>o.type==="text"?{type:"text",text:o.text}:{type:"mathInline",id:`t${i}`,tex:o.tex,display:"inline"});return qm(r)===e?r:null}function qm(e){return e.map(t=>t.type==="text"?t.text:`$${t.tex}$`).join("")}function Zm(e){return e.includes("\\")?!1:Xm.test(e)||Ym.test(e)||Km.test(e)}function Ks(e){let t=e.find(r=>r.hasGlyph);if(!t)return;let n={};return t.kind==="text"&&t.fontFamily&&(n.fontFamily=t.fontFamily),t.fontSizePt!==void 0&&Number.isFinite(t.fontSizePt)&&t.fontSizePt>0&&(n.fontSizePt=t.fontSizePt),n.fontFamily===void 0&&n.fontSizePt===void 0?void 0:n}function Jm(e){return Gt(e.replace(/[\n\r]/g,""))}function js(e){return e.map(t=>({kind:t.type==="mathInline"?"math":"text",hasGlyph:Jm(t.type==="mathInline"?t.tex:t.text),fontFamily:t.fontFamily,fontSizePt:t.fontSize}))}var Si="displaystyle",Qm={displaystyle:"\\displaystyle",textstyle:"\\textstyle"};function Br(e){return e==="texDefault"?"textstyle":Si}function ft(e,t){return`${Qm[t]} ${e}`}function Rr(e,t={}){return{kind:"fragment",children:(t.annotateBoxedRuns?Ws(e,{runIdPrefix:t.runIdPrefix}):e.map((r,o)=>({index:o,node:r}))).map(({boxedRun:r,index:o,node:i})=>ef(i,o,r))}}function qs(e,t,n,r,o){let i=nf(e);return{type:"box",...i!==void 0?{paddingY:i}:{},math:t,connectLeft:n?.connectLeft,connectRight:n?.connectRight,run:n,variant:typeof r=="string"?r:void 0,tone:typeof o=="string"?o:void 0}}function ef(e,t,n){let r=tf(e);if(e.type==="mathInline"){let i=[];return r&&i.push({type:"style",style:r}),e.marks?.includes("underline")&&i.push({type:"underline"}),e.marks?.includes("boxed")&&i.push(qs(e.boxedPaddingY,!0,n,e.boxedVariant,e.boxedTone)),{kind:"math",id:e.id,tex:e.tex,decorations:i,sourceIndex:t}}let o=(e.marks??[]).flatMap(i=>i==="bold"||i==="italic"||i==="underline"?[{type:i}]:i==="boxed"?[qs(e.boxedPaddingY,!1,n,e.boxedVariant,e.boxedTone)]:[]);return r&&o.push({type:"style",style:r}),{kind:"text",text:e.text,decorations:o,sourceIndex:t}}function tf(e){let t=typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?e.fontSize:void 0,n={backgroundColor:e.backgroundColor,color:e.color,fontFamily:e.fontFamily,fontSizePt:t};return Object.values(n).some(r=>r!==void 0)?n:void 0}function nf(e){let t=typeof e=="number"?e:Number.parseFloat(String(e));return Number.isFinite(t)&&t>=0?t:void 0}var Zs=new WeakMap;function vi(e,t={}){let n=t.runIdPrefix??"overlay",r=Zs.get(e);r||(r=new Map,Zs.set(e,r));let o=r.get(n);if(o)return o;let i=rf(e,n);return r.set(n,i),i}function rf(e,t){return{kind:"fragment",children:e.blocks.map((n,r)=>({kind:"block",blockType:n.type,headingLevel:n.type==="heading"?n.level:void 0,isBlank:of(n),textAlign:n.align,lineHeight:af(n.lineHeight),children:Rr(n.children,{annotateBoxedRuns:!0,runIdPrefix:`${t}-${r}`}).children}))}}function of(e){return e.children.every(t=>t.type==="text"&&t.text.length===0)}function af(e){let t=typeof e=="number"?String(e):String(e??"").trim();if(!/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})$/u.test(t))return;let n=Number(t);if(!(!Number.isFinite(n)||n<.8||n>3))return n.toFixed(2).replace(/\.?0+$/u,"")}function re(e){return e==="s"?1.25:e==="l"?3:e==="xl"?5:2}function $e(e){return e==="s"?14:e==="l"?22:e==="xl"?28:18}function sf(e,t){return tl(e.columns.map(n=>n.width),t)}function lf(e,t){return tl(e.rows.map(n=>n.height),t)}function zt(e,t){return t<0||t>e.columns.length?null:t===0?{axis:"vertical",edge:"left"}:t===e.columns.length?{axis:"vertical",edge:"right"}:{axis:"vertical",beforeColumnId:e.columns[t].id}}function Ht(e,t){return t<0||t>e.rows.length?null:t===0?{axis:"horizontal",edge:"top"}:t===e.rows.length?{axis:"horizontal",edge:"bottom"}:{axis:"horizontal",beforeRowId:e.rows[t].id}}function cf(e,t){let n=e.grid.lineOverrides??[];for(let r=n.length-1;r>=0;r-=1){let o=n[r];if(df(o,t))return o}}function Ae(e,t){let r="edge"in t?e.grid.showOuterBorder!==!1:e.grid.showInnerBorders!==!1,o=cf(e,t)?.style,i=o?.borderWidth??e.grid.borderWidth;return{visible:o?.visible??r,borderColor:o?.borderColor??e.grid.borderColor,borderWidth:Number.isFinite(i)?Math.max(0,i):0,borderStyle:o?.borderStyle??e.grid.borderStyle??"solid"}}function Mi(e){return!e.visible||e.borderWidth<=0?"0":`${e.borderWidth}px ${e.borderStyle} ${e.borderColor}`}function uf(e,t,n,r=1,o=1){return{borderTop:Ar(e,"horizontal",t),borderRight:Ar(e,"vertical",n+o),borderBottom:Ar(e,"horizontal",t+r),borderLeft:Ar(e,"vertical",n)}}function df(e,t){return e.axis!==t.axis?!1:"edge"in e||"edge"in t?"edge"in e&&"edge"in t&&e.edge===t.edge:e.axis==="vertical"&&t.axis==="vertical"?e.beforeColumnId===t.beforeColumnId:e.axis==="horizontal"&&t.axis==="horizontal"?e.beforeRowId===t.beforeRowId:!1}function Ar(e,t,n){let r=t==="vertical"?zt(e,n):Ht(e,n);if(!r)return"0";let o=Ae(e,r);return o.visible&&o.borderWidth>0&&o.borderStyle==="double"?"0":Mi(o)}var Ir=1e-6;function tl(e,t){if(e.length===0)return[];let n=e.map(pf),r=n.reduce((c,l)=>c+l,0),o=Number.isFinite(t)?Math.max(1,t):Math.max(1,r);if(r>o){let c=o/r;return n.map(l=>l*c)}let i=o-r;if(i<=Ir)return n;if(r<=0){let c=o/e.length;return Js(e.map(l=>Math.min(c,Er(l))),e,o)}let a=e.reduce((c,l)=>c+(l.mode==="fr"?Math.max(0,l.value):0),0),s=a>0?e.map((c,l)=>{if(c.mode!=="fr")return n[l];let d=n[l]+i*(Math.max(0,c.value)/a);return nl(d,c.min,c.max)}):n.map((c,l)=>Math.min(c*o/r,Math.max(c,Er(e[l]))));return Js(s,e,o)}function Js(e,t,n){let r=[...e];for(let i=0;i<=r.length;i+=1){let a=n-r.reduce((l,d)=>l+d,0);if(a<=Ir)break;let s=r.map((l,d)=>d).filter(l=>r[l]<Er(t[l])-Ir);if(s.length===0)break;let c=s.reduce((l,d)=>l+Math.max(1,r[d]),0);for(let l of s){let d=a*(Math.max(1,r[l])/c);r[l]=Math.min(r[l]+d,Math.max(r[l],Er(t[l])))}}let o=r.reduce((i,a)=>i+a,0);return o>0&&Math.abs(n-o)>Ir?r.map(i=>i*n/o):r}function Er(e){return e.mode==="fixed"?Number.POSITIVE_INFINITY:e.max??Number.POSITIVE_INFINITY}function pf(e){return e.mode==="fixed"?Math.max(1,e.value):nl(e.min??1,e.min,e.max)}function nl(e,t,n){return Math.max(t??1,Math.min(e,n??Number.POSITIVE_INFINITY))}function rl(e,t,n){let r=sf(e,t),o=lf(e,n),i=new Map(e.cells.map(c=>[`${c.rowId}:${c.columnId}`,c])),a=new Set,s=e.rows.map((c,l)=>{let d=[];return e.columns.forEach((u,m)=>{if(a.has(`${l}:${m}`))return;let h=i.get(`${c.id}:${u.id}`),y=h?.rowSpan??1,g=h?.colSpan??1;for(let x=l;x<l+y;x+=1)for(let S=m;S<m+g;S+=1)(x!==l||S!==m)&&a.add(`${x}:${S}`);d.push({cell:h,colSpan:g,columnIndex:m,rowIndex:l,rowSpan:y})}),{cells:d,height:o[l],rowId:c.id}});return{columnOffsets:Qs(r),columnWidths:r,rowHeights:o,rowOffsets:Qs(o),rows:s}}function Qs(e){let t=[0];for(let n of e)t.push(t[t.length-1]+n);return t}function ol(e,t){let n=Math.max(42,t>1?38*t:44),r=24,o=e==="up"?18:e==="down"?6:12,i=e==="up"?6:e==="down"?18:12,a=e==="up"?`${n-6},${i} ${n-12},${i-1.5} ${n-9},${i+4}`:e==="down"?`${n-6},${i} ${n-12},${i+1.5} ${n-9},${i-4}`:`${n-6},${i} ${n-12},${i-3} ${n-12},${i+3}`;return{width:n,height:r,line:{x1:6,y1:o,x2:n-7,y2:i},arrowPoints:a,color:"#111827",strokeWidth:1}}function $t(e){return"edge"in e?`${e.axis}:edge:${e.edge}`:e.axis==="vertical"?`${e.axis}:before:${e.beforeColumnId}`:`${e.axis}:before:${e.beforeRowId}`}var il={boxSizing:"border-box",position:"relative",minWidth:"0",overflow:"hidden"},al={color:"#111827",fontSize:"15pt",lineHeight:"1.35"},sl={position:"absolute",inset:"0",display:"flex",minWidth:"0",minHeight:"0",flexDirection:"column",overflow:"hidden"};function ll(e,t,n,r,o,i){let a={...e.defaultCellStyle,...t?.style??{}},s=uf(e,n,r,o,i);return{textAlign:a.align??"center",verticalAlign:a.verticalAlign??"middle",padding:"0",...a.color?{color:a.color}:{},...a.backgroundColor?{background:a.backgroundColor}:{},...a.fontFamily?{fontFamily:a.fontFamily}:{},...a.fontSize?{fontSize:`${a.fontSize}pt`}:{},...a.fontWeight?{fontWeight:String(a.fontWeight)}:{},borderTop:s.borderTop,borderRight:s.borderRight,borderBottom:s.borderBottom,borderLeft:s.borderLeft}}function cl(e,t){let n={...e.defaultCellStyle,...t?.style??{}};return{justifyContent:mf(n.verticalAlign??"middle"),padding:`${n.paddingY??5}px ${n.paddingX??8}px`}}function mf(e){return e==="top"?"flex-start":e==="bottom"?"flex-end":"center"}function Cr(e){return e.visible&&e.borderWidth>0&&e.borderStyle==="double"}function el(e,t,n){let r=Math.max(0,n.borderWidth),o=`${r}px ${n.borderStyle} ${n.borderColor}`;return e==="vertical"?{left:`${t-r/2}px`,borderLeft:o}:{top:`${t-r/2}px`,borderTop:o}}function ul(e,t,n){let r=[];return t.forEach((o,i)=>{let a=zt(e,i);if(!a)return;let s=Ae(e,a);Cr(s)&&r.push({axis:"vertical",key:a,domKey:$t(a),style:el("vertical",o,s)})}),n.forEach((o,i)=>{let a=Ht(e,i);if(!a)return;let s=Ae(e,a);Cr(s)&&r.push({axis:"horizontal",key:a,domKey:$t(a),style:el("horizontal",o,s)})}),r}function dl(e,t,n){let r=[];return t.forEach((o,i)=>{let a=zt(e,i);if(!a)return;let s=Ae(e,a);Cr(s)&&n.forEach((c,l)=>{let d=Ht(e,l);if(!d)return;let u=Ae(e,d);!u.visible||u.borderWidth<=0||r.push({axis:"horizontal",id:`connector-horizontal-${$t(a)}-${$t(d)}`,style:{left:`${o-s.borderWidth/2}px`,top:`${c-u.borderWidth/2}px`,width:`${s.borderWidth}px`,height:"0px",borderTop:Mi(u)}})})}),n.forEach((o,i)=>{let a=Ht(e,i);if(!a)return;let s=Ae(e,a);Cr(s)&&t.forEach((c,l)=>{let d=zt(e,l);if(!d)return;let u=Ae(e,d);!u.visible||u.borderWidth<=0||r.push({axis:"vertical",id:`connector-vertical-${$t(a)}-${$t(d)}`,style:{left:`${c-u.borderWidth/2}px`,top:`${o-s.borderWidth/2}px`,width:"0px",height:`${s.borderWidth}px`,borderLeft:Mi(u)}})})}),r}function Lr(e){return e.split(/\r\n|\r|\n/)}var pl=new WeakMap;function ml(e){if(e.inlineContent)return ff(e.inlineContent);if(e.richText){let t=pl.get(e.richText);if(t)return t;let n=yf(e.richText);return pl.set(e.richText,n),n}if(e.lines&&e.lines.length>0){let t=[];for(let n of e.lines)for(let r of Lr(n))t.push(r.length>0?[{kind:"text",text:r}]:[]);return t}return[[]]}function ff(e){let t=[[]];for(let n of e)fl(t,n);return t}function yf(e){let t=Array.isArray(e.blocks)?e.blocks:[],n=[[]];return t.forEach((r,o)=>{o>0&&n.push([]);for(let i of r?.children??[])fl(n,i)}),n}function fl(e,t){if(t?.type==="text"){hf(e,t.text??"");return}t?.type==="mathInline"&&e[e.length-1].push({kind:"math",tex:t.tex})}function hf(e,t){Lr(t).forEach((r,o)=>{o>0&&e.push([]),r.length>0&&e[e.length-1].push({kind:"text",text:r})})}function Pi(e){let t=Array.isArray(e.blocks)?e.blocks:[];return t.length===0?1:Math.max(1,t.reduce((n,r)=>n+gf(r?.children??[]),0))}function gf(e){return 1+e.reduce((t,n)=>n?.type==="text"?t+Math.max(0,(n.text??"").split(`
|
|
2
|
+
`).length-1):t,0)}function xf(e){return e.type==="group"}function Nr(e){return e.filter(t=>!xf(t)&&!bf(e,t))}function yl(e,t){return t.stackLayer==="background"||_r(e,t).some(n=>n.stackLayer==="background")}function gl(e,t){if(t==="foreground")return e.filter(r=>!yl(e,r));let n=new Set;for(let r of e)if(yl(e,r)){n.add(r.id);for(let o of _r(e,r))n.add(o.id)}return e.filter(r=>n.has(r.id))}function Fr(e,t){let n=t.opacity??1;for(let r of _r(e,t))n*=r.opacity??1;return n===1?void 0:n}function bf(e,t){return t.hidden?!0:_r(e,t).some(n=>n.hidden)}var hl=new WeakMap;function Sf(e){let t=hl.get(e);if(t)return t;let n=new Map;for(let r of e)n.has(r.id)||n.set(r.id,r);return hl.set(e,n),n}function _r(e,t){let n=[],r=t.parentId,o=new Set([t.id]),i=Sf(e);for(;r;){let a=i.get(r);if(!a||o.has(a.id))break;n.push(a),o.add(a.id),r=a.parentId}return n}function Ti(e){return e.some((t,n)=>n>0&&t.pagination?.break===!0)}function xl({isFullSpan:e,isFramedArea:t,blocks:n}){return!(e||t)||Ti(n)}function bl(e){return e==="s"?13:e==="l"?20:e==="xl"?24:16}function Sl(e){let t=Array.isArray(e.blocks)?e.blocks:[];return t.length===0?1:Math.max(1,t.reduce((n,r)=>n+vf(r?.children??[]),0))}function vf(e){return 1+e.reduce((t,n)=>n?.type==="text"?t+Math.max(0,(n.text??"").split(`
|
|
3
|
+
`).length-1):t,0)}var vl=.25,Ml=8,Dr=96/72,Ie=1;function In(e){return Oi(e/Dr)}function Ut(e){return e*Dr}function Oi(e){return Math.round(e*1e3)/1e3}function wi(e){return typeof e!="number"||!Number.isFinite(e)?1:Math.max(vl,Math.min(Ml,e))}function ki(e){return wi(e.type==="text"?e.props.scale:1)}function yt(e){return(typeof e.props.fontSize=="number"&&Number.isFinite(e.props.fontSize)&&e.props.fontSize>0?e.props.fontSize:In(bl(e.props.size)))*ki(e)}function ze(e){return Ut(yt(e))}function ht(e){return Math.ceil(ze(e)*Ie)}var En=8,He=12;var Tl=null;function Ol(e){Tl=e}var Cn=.8,Ln=.2,wl=/\\begin\{[^}]*\}([\s\S]*?)\\end\{[^}]*\}/,Mf=/\\(?:frac|dfrac|tfrac|cfrac|sqrt|int|oint|iint|iiint|sum|prod|coprod|lim|begin|binom|dbinom|tbinom|overbrace|underbrace)\b/,Pf=1.6,Tf=1;function Nn(e){let t=If(e.fontSizePx,1),n=e.mathMetrics??Tl,r=Of(e,n),o=Ef(e.maxWidthPx),i=Math.ceil(t*Ie);if(o===void 0){let d=Math.max(0,...r.map(Bf)),u=r.reduce((m,h)=>m+Rf(h,t),0);return{w:Math.ceil(d*t),h:Math.max(i,u),wrapped:!1}}let a=o/t,s=!1,c=0,l=0;for(let d of r){let u=Af(d,a,t);s||=u.wrapped,l=Math.max(l,u.widestMathAtomUnits),c+=u.heightPx}return{w:Math.max(o,Math.ceil(l*t)),h:Math.max(i,c),wrapped:s}}function Of(e,t){let n=ml(e),r=[[]];return n.forEach((o,i)=>{i>0&&r.push([]);for(let a of o){if(a.kind==="text"){kl(r,a.text);continue}wf(r,a.tex,t)}}),r}function kl(e,t){Lr(t).forEach((n,r)=>{r>0&&e.push([]),n.length>0&&e[e.length-1].push({kind:"text",text:n})})}function wf(e,t,n){if(n){let r=n.measureTexEm(t)??Pl(t);e[e.length-1].push({kind:"math",tex:t,metrics:r});return}if(kf(t)){e[e.length-1].push({kind:"math",tex:t,metrics:Pl(t)});return}kl(e,Rl(t))}function kf(e){let t=wl.exec(e);return t!==null&&Bl(t[1])>0}function Bl(e){return(e.match(/\\\\/g)??[]).length}function Pl(e){let t=wl.exec(e),n=t?Bl(t[1])+1:1,r=Mf.test(e)?Pf:Tf,o=Rl(e),i=Math.max(0,...o.split(`
|
|
4
|
+
`).map(Al));return{ascentEm:n*r,descentEm:0,widthEm:i}}function Rl(e){return e.replace(/\\\\(?:\[[^\]]*\])?/g,`
|
|
5
5
|
`).replace(/\\(?:begin|end)\s*\{[^}]*\}/g,"").replace(/\\(?:left|right|displaystyle|textstyle|scriptstyle|scriptscriptstyle)\b/g,"").replace(/\\(?:mathrm|mathbf|mathit|mathsf|mathtt|text|textrm|textbf|textit|operatorname|frac|dfrac|tfrac|sqrt|overline|underline|vec|hat|bar|dot|ddot)\b/g,"").replace(/\\(sin|cos|tan|cot|sec|csc|log|ln|exp|max|min|lim)\b/g,"$1").replace(/\\(?:quad|qquad|,|;|:|!)/g," ").replace(/\\([{}_%&#$])/g,"$1").replace(/\\[a-zA-Z]+/g,"M").replace(/[{}^_]/g,"").split(`
|
|
6
6
|
`).map(t=>t.replace(/\s+/g,"")).join(`
|
|
7
|
-
`)}function bf(e){return e.reduce((t,n)=>t+(n.kind==="text"?Pl(n.text):n.metrics.widthEm),0)}function Sf(e,t){let n=In,r=En;for(let o of e)o.kind==="math"&&(n=Math.max(n,o.metrics.ascentEm),r=Math.max(r,o.metrics.descentEm));return Math.ceil(t*Math.max(Ie,n+r))}function vf(e,t,n){let r=e.flatMap(u=>u.kind==="math"?[{widthEm:u.metrics.widthEm,ascentEm:u.metrics.ascentEm,descentEm:u.metrics.descentEm,isMathAtom:!0}]:Array.from(u.text).map(m=>({widthEm:Ml(m),ascentEm:In,descentEm:En,isMathAtom:!1})));if(r.length===0)return{heightPx:Math.ceil(n*Ie),wrapped:!1,widestMathAtomUnits:0};let o=0,i=!1,a=0,s=0,c=In,l=En,d=()=>{o+=Math.ceil(n*Math.max(Ie,c+l))};for(let u of r)u.isMathAtom&&(a=Math.max(a,u.widthEm)),s>0&&s+u.widthEm>t?(d(),i=!0,s=u.widthEm,c=Math.max(In,u.ascentEm),l=Math.max(En,u.descentEm)):(s+=u.widthEm,c=Math.max(c,u.ascentEm),l=Math.max(l,u.descentEm));return d(),{heightPx:o,wrapped:i,widestMathAtomUnits:a}}function Pl(e){let t=0;for(let n of e)t+=Ml(n);return t}function Ml(e){if(/\s/u.test(e))return .35;let t=e.codePointAt(0)??0;return t>=4352&&t<=4607||t>=11904&&t<=42191||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519?1:/[+\-*/=<>()[\]{}^_,.;:|]/u.test(e)?.45:.58}function Pf(e,t){return Number.isFinite(e)&&e>0?e:t}function Mf(e){return e!==void 0&&Number.isFinite(e)&&e>0?e:void 0}var Tl=new WeakMap;function Ti(e,t,n){let r=Tl.get(e);r||(r=new Map,Tl.set(e,r));let o=r.get(t);if(o)return o;let i=n();return r.set(t,i),i}function Ol(e,t){let n=ze(e),r=`content|${n}|${t??""}`;return Ti(e.props.richText,r,()=>{let o=Cn({richText:e.props.richText,fontSizePx:n,maxWidthPx:t});return{w:o.w,h:o.h}})}function Oi(e){let t=ze(e),n=e.props.w,r=typeof e.props.h=="number"&&Number.isFinite(e.props.h)?e.props.h:void 0,o=e.props.autoSize,i=e.props.maxWidth,a=o?i:Math.max(An,n),s=`effective|${o?"auto":"fixed"}|${t}|${a??""}|${n}|${r??""}`;return Ti(e.props.richText,s,()=>{let c=Ol(e,a),l=Tf(e),d=o&&i!==void 0?i:Math.max(An,n),u=Math.max(r??0,l,c.h);return{w:d,h:u}})}function Ue(e){let t=Math.max(1,e.props.w),n=ze(e),r=`calloutBody|${t}|${e.props.h}|${n}`;return Ti(e.props.richText,r,()=>{let o=Math.max(1,t-2*He),i=Ol(e,o),a=Math.max(e.props.h,i.h+2*He);return{w:t,h:a}})}function Nr(e){let t=Ue(e);return{x:He,y:He,w:Math.max(1,t.w-2*He),h:Math.max(1,t.h-2*He)}}function Tf(e){let t=yt(e);return Math.max(t,bi(e.props.richText)*t)}var wi=1,Of=12;var FO=1-Math.SQRT1_2,Cl=18;function Nn(e){let{w:t,h:n}=Ue(e),r=zt(e),{baseStart:o,baseEnd:i,tip:a,radius:s}=r,c=Rl(i,o,t,n),l=Rl(o,i,t,n);return c>=l?[`M ${Je(o)}`,`L ${Je(a)}`,`L ${Je(i)}`,...kl(i,o,t,n,s),"Z"].join(" "):[`M ${Je(i)}`,`L ${Je(a)}`,`L ${Je(o)}`,...kl(o,i,t,n,s),"Z"].join(" ")}function wl(e,t,n){return t<=0||n===t||e<=0?e:e>=t?e+(n-t):e*n/t}function Fr(e,t){let n=e.props.w,r=e.props.h,{w:o,h:i}=Ue(e);return{x:wl(t.x,n,o),y:wl(t.y,r,i)}}function _r(e,t,n){let{w:r,h:o}=Ue(e),i=kf(t,n,r,o);return wf(e,i,t,n)}function wf(e,t,n,r){let{w:o,h:i}=Ue(e),a=ki(e);return t==="top"?{x:Ln(n,a,o-a),y:0,side:t}:t==="right"?{x:o,y:Ln(r,a,i-a),side:t}:t==="bottom"?{x:Ln(n,a,o-a),y:i,side:t}:{x:0,y:Ln(r,a,i-a),side:t}}function zt(e){let{tail:t}=e.props,{w:n,h:r}=Ue(e),o=ki(e),i=Fr(e,t.baseStart),a=Fr(e,t.baseEnd),s=Fr(e,t.tip),c=_r(e,i.x,i.y),l=_r(e,a.x,a.y),d={x:El(s.x,n*.14),y:El(s.y,r+28)},u=Math.min(0,c.x,l.x,d.x),m=Math.min(0,c.y,l.y,d.y),h=Math.max(n,c.x,l.x,d.x),y=Math.max(r,c.y,l.y,d.y);return{body:{left:0,top:0,right:n,bottom:r},radius:o,baseStart:c,baseEnd:l,tip:d,bounds:{x:u,y:m,w:Math.max(wi,h-u),h:Math.max(wi,y-m)}}}function ki(e){let{w:t,h:n}=Ue(e);return Ll(e.props.radius,t,n)}function Ll(e,t,n){let r=Math.max(0,(Math.min(t,n)-Of)/2);return Ln(Number.isFinite(e)?e:Cl,0,r)}function kf(e,t,n,r){return[["top",Math.abs(t)],["right",Math.abs(n-e)],["bottom",Math.abs(r-t)],["left",Math.abs(e)]].reduce((i,a)=>a[1]<i[1]?a:i)[0]}function kl(e,t,n,r,o){let i=["top","right","bottom","left"],a=i.indexOf(e.side),s=[];for(let c=0;c<5;c+=1){let l=i[a];if(l===t.side&&Bl(t,n,r)>=Bl(c===0?e:Bf(l,n,r,o),n,r))return s.push(`L ${Je(t)}`),s;s.push(...Rf(l,n,r,o)),a=(a+1)%i.length}return s.push(`L ${Je(t)}`),s}function Bf(e,t,n,r){return e==="top"?{x:r,y:0,side:e}:e==="right"?{x:t,y:r,side:e}:e==="bottom"?{x:t-r,y:n,side:e}:{x:0,y:n-r,side:e}}function Bl(e,t,n){return e.side==="top"?e.x:e.side==="right"?e.y:e.side==="bottom"?t-e.x:n-e.y}function Rf(e,t,n,r){return e==="top"?[`L ${t-r} 0`,`Q ${t} 0 ${t} ${r}`]:e==="right"?[`L ${t} ${n-r}`,`Q ${t} ${n} ${t-r} ${n}`]:e==="bottom"?[`L ${r} ${n}`,`Q 0 ${n} 0 ${n-r}`]:[`L 0 ${r}`,`Q 0 0 ${r} 0`]}function Rl(e,t,n,r){let o=Math.max(wi,(n+r)*2),a=((Al(t,n,r)-Al(e,n,r))%o+o)%o;return a===0?o:a}function Al(e,t,n){return e.side==="top"?e.x:e.side==="right"?t+e.y:e.side==="bottom"?t+n+(t-e.x):t*2+n+(n-e.y)}function Je(e){return`${Il(e.x)} ${Il(e.y)}`}function Il(e){return Math.round(e*1e3)/1e3}function El(e,t){return Number.isFinite(e)?e:t}function Ln(e,t,n){return n<t?(t+n)/2:Math.min(n,Math.max(t,e))}var Nl=10,Dr=.5;function de(e){if(e.type==="graph2dShape"){if(e.props.boundsMode==="plot")return{x:e.x,y:e.y,w:e.props.w,h:e.props.h};let t=Ge(e);return{x:t.renderBounds.x+t.plotBox.left*t.scaleX,y:t.renderBounds.y+t.plotBox.top*t.scaleY,w:Math.max(1,e.props.w-(t.plotBox.left+t.plotBox.right)*t.scaleX),h:Math.max(1,e.props.h-(t.plotBox.top+t.plotBox.bottom)*t.scaleY)}}if(e.type==="group"||e.type==="geo"||e.type==="image"||e.type==="tableShape")return{x:e.x,y:e.y,w:e.props.w,h:e.props.h};if(e.type==="callout"){let t=zt(e).bounds;return{x:e.x+t.x,y:e.y+t.y,w:t.w,h:t.h}}if(e.type==="arc"){let{rx:t,ry:n}=ce(e);return{x:e.x,y:e.y,w:t*2,h:n*2}}if(e.type==="text"){let t=Oi(e);return{x:e.x,y:e.y,w:t.w,h:t.h}}return e.type==="arrow"?Gr(e.x,e.y,[e.props.start,e.props.end],Nl):e.type==="line"?Gr(e.x,e.y,e.props.points,Nl):{x:0,y:0,w:1,h:1}}function $r(e){return de(e)}function Bi(e){return e.type==="graph2dShape"?$r(e):e.type==="arrow"?Gr(e.x,e.y,[e.props.start,e.props.end],0):e.type==="line"?Gr(e.x,e.y,e.props.points,0):de(e)}function ve(e){return e.type==="tableShape"||e.type==="group"?0:typeof e.rotation=="number"&&Number.isFinite(e.rotation)?e.rotation:0}function ce(e){let t=Math.max(Dr,e.props.r),n=typeof e.props.rx=="number"&&Number.isFinite(e.props.rx)?Math.max(Dr,e.props.rx):t,r=typeof e.props.ry=="number"&&Number.isFinite(e.props.ry)?Math.max(Dr,e.props.ry):t;return{rx:n,ry:r}}function Gr(e,t,n,r){if(n.length===0)return{x:e,y:t,w:1,h:1};let o=n.map(d=>e+d.x),i=n.map(d=>t+d.y),a=Math.min(...o),s=Math.min(...i),c=Math.max(...o),l=Math.max(...i);return{x:a-r,y:s-r,w:Math.max(1,c-a+r*2),h:Math.max(1,l-s+r*2)}}var Cf=1122.5196850393702,Lf=36,zr=Cf+Lf;function Ri(e,t,n={}){let r=$f(Array.from(t.values())),o=e.map(i=>Nf(i,t,r,n));return Ht(o)}function Ht(e){let t=new Map(e.map(s=>[s.id,s])),n=new Map,r=new Set,o=s=>{let c=n.get(s.id);if(c)return c;if(s.anchor?.type!=="shape")return n.set(s.id,s),s;let l=t.get(s.anchor.shapeId);if(!l||l.id===s.id||r.has(s.id))return n.set(s.id,s),s;r.add(s.id);let d=o(l);r.delete(s.id);let u=Df(s.anchor,d),m=u.x===s.x&&u.y===s.y?s:{...s,x:u.x,y:u.y};return n.set(s.id,m),m},i=!1,a=e.map(s=>{let c=o(s);return i||=c!==s,c});return i?a:e}function Nf(e,t,n,r){if(e.anchor?.type!=="block")return e;let o=t.get(e.anchor.blockId);if(!o)return e;let i=_f(e.anchor,o,n),a=i?.block??o,s=Ff(e.anchor,r),c=typeof e.anchor.dx=="number"&&typeof a.left=="number"?a.left+e.anchor.dx:e.x,l=i===void 0||!e.anchor.line?o.top-s+e.anchor.dy:i.line.top-s+e.anchor.line.dy;return c===e.x&&l===e.y?e:{...e,x:c,y:l}}function Ff(e,t){if(e.reserveSpace!==!0)return 0;let n=t[e.blockId];return typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):0}function _f(e,t,n){if(!e.line||!t.lines?.length)return;let r=t.lines.find(a=>a.index===e.line?.index);if(r)return{block:t,line:r};let o=e.line.index-t.lines.length;if(o<0)return;let i=n.findIndex(a=>a.id===t.id);if(!(i<0))for(let a of n.slice(i+1)){if(a.containerId!==t.containerId||!Dl(t,a))continue;let s=a.lines??[];if(o<s.length)return{block:a,line:s[o]};o-=s.length}}function Df(e,t){let n=Gf(t),r=typeof e.rx=="number"?n.x+n.w*e.rx:t.x,o=typeof e.ry=="number"?n.y+n.h*e.ry:t.y;return{x:r+e.dx,y:o+e.dy}}function Gf(e){if(e.type==="group"||e.type==="geo"||e.type==="image"||e.type==="callout"||e.type==="graph2dShape"||e.type==="tableShape")return{x:e.x,y:e.y,w:e.props.w,h:e.props.h};if(e.type==="arc"){let t=Math.max(.5,e.props.r),n=typeof e.props.rx=="number"&&Number.isFinite(e.props.rx)?Math.max(.5,e.props.rx):t,r=typeof e.props.ry=="number"&&Number.isFinite(e.props.ry)?Math.max(.5,e.props.ry):t;return{x:e.x,y:e.y,w:n*2,h:r*2}}if(e.type==="text"){let t=typeof e.props.h=="number"&&Number.isFinite(e.props.h)?Math.max(1,e.props.h):1;return{x:e.x,y:e.y,w:Math.max(8,e.props.w),h:t}}return e.type==="arrow"?Fl(e.x,e.y,[e.props.start,e.props.end],10):Fl(e.x,e.y,e.props.points,10)}function Fl(e,t,n,r){if(n.length===0)return{x:e,y:t,w:1,h:1};let o=n.map(d=>e+d.x),i=n.map(d=>t+d.y),a=Math.min(...o),s=Math.min(...i),c=Math.max(...o),l=Math.max(...i);return{x:a-r,y:s-r,w:Math.max(1,c-a+r*2),h:Math.max(1,l-s+r*2)}}function Dl(e,t){if(e.left===void 0||t.left===void 0)return!0;let n=e.width??0,r=t.width??0,o=Math.max(4,Math.min(n||0,r||0)*.08);return Math.abs(e.left-t.left)<=o}function $f(e,t=Uf(e)){return t.length<=1?[...e].sort((n,r)=>n.top-r.top):e.map((n,r)=>({block:n,index:r})).sort((n,r)=>zf(_l(n.block,n.index,t),_l(r.block,r.index,t))).map(n=>n.block)}function _l(e,t,n){let r=Hf(e.top);return{page:r.page,column:Vf(e,n)??0,localY:r.localY,top:e.top,index:t}}function zf(e,t){return e.page-t.page||e.column-t.column||e.localY-t.localY||e.top-t.top||e.index-t.index}function Hf(e){let t=Math.max(0,Math.floor((e+.5)/zr));return{page:t,localY:e-t*zr}}function Uf(e){let t=[];for(let n of e){if(typeof n.left!="number"||typeof n.width!="number")continue;let r=t.find(o=>Dl(o.representative,n));if(r){r.left=Math.min(r.left,n.left),r.right=Math.max(r.right,n.left+n.width),r.blockIds.add(n.id);continue}t.push({representative:n,left:n.left,right:n.left+n.width,blockIds:new Set([n.id])})}return t.sort((n,r)=>n.left-r.left).map((n,r)=>({index:r,left:n.left,right:n.right,center:(n.left+n.right)/2,blockIds:n.blockIds}))}function Vf(e,t){return t.find(n=>n.blockIds.has(e.id))?.index}function Pe(e){return e??"polyline"}function Ve(e,t,n){return Pe(e)==="polyline"&&n===!0&&t.length>=3}function Gn(e,t,n){if(e.length===0)return"";let r=Xf(Ii(e,t),n,Pe(t)!=="polyline");return r.length===0?`M ${Fn(e[0])}`:Wf(r)}function Ur(e,t){return Ii(e,t).reduce((n,r)=>n+Math.hypot(r.to.x-r.from.x,r.to.y-r.from.y),0)}function zl(e,t){let n=Ii(e,t);if(n.length===0)return{start:0,end:0};if(Pe(t)!=="polyline"){let r=Ur(e,t);return{start:r,end:r}}return{start:_n(n[0]),end:_n(n[n.length-1])}}function Ut(e,t,n){if(e.length<2)return[...e];let r=[...e],o=r.length-1;return r[0]=Gl(r[0],r[1],t),r[o]=Gl(r[o],r[o-1],n),r}function Gl(e,t,n){if(!Number.isFinite(n)||n<=0)return e;let r=t.x-e.x,o=t.y-e.y,i=Math.hypot(r,o);if(!Number.isFinite(i)||i<=0)return e;let a=Math.min(n,i*Hl);return{x:e.x+r/i*a,y:e.y+o/i*a}}var Hl=.9;function ht(e){return e.map(t=>`${t.x},${t.y}`).join(" ")}function Ai(e){return e.length===0?null:e[Math.floor(e.length/2)]}function Ii(e,t){if(e.length<2)return[];if(Pe(t)==="polyline"||e.length<3){let o=[];for(let i=1;i<e.length;i+=1)o.push({kind:"line",from:e[i-1],to:e[i]});return o}if(e.length===3)return[{kind:"quad",from:e[0],control:e[1],to:e[2]}];let n=[],r=e[0];for(let o=1;o<e.length-1;o+=1){let i=e[o],a=e[o+1],s={x:(i.x+a.x)/2,y:(i.y+a.y)/2};n.push({kind:"quad",from:r,control:i,to:s}),r=s}return n.push({kind:"line",from:r,to:e[e.length-1]}),n}function Wf(e){let t=[`M ${Fn(e[0].from)}`];for(let n of e)t.push(n.kind==="quad"?`Q ${Fn(n.control)} ${Fn(n.to)}`:`L ${Fn(n.to)}`);return t.join(" ")}function Xf(e,t,n){return!t||e.length===0?e:Kf(Yf(e,t.start,n),t.end,n)}function Yf(e,t,n){let r=t;if(!Number.isFinite(r)||r<=0)return e;let o=0;for(;o<e.length;){let i=e[o],a=_n(i),s=o===e.length-1;if(!n||s||r<a){let c=n&&!s?r:Ul(r,a);return c<=0?e.slice(o):[Xl(i,Wl(i,c)).tail,...e.slice(o+1)]}r-=a,o+=1}return e}function Kf(e,t,n){let r=t;if(!Number.isFinite(r)||r<=0)return e;let o=e.length-1;for(;o>=0;){let i=e[o],a=_n(i),s=o===0;if(!n||s||r<a){let c=n&&!s?r:Ul(r,a);if(c<=0)return e.slice(0,o+1);let l=Xl(i,Wl(i,a-c)).head;return[...e.slice(0,o),l]}r-=a,o-=1}return e}function Ul(e,t){return!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?0:Math.min(e,t*Hl)}function _n(e){return e.kind==="line"?Math.hypot(e.to.x-e.from.x,e.to.y-e.from.y):Vl(e)[Dn]}function Vl(e){let t=[0],n=e.from;for(let r=1;r<=Dn;r+=1){let o=jf(e,r/Dn);t.push(t[r-1]+Math.hypot(o.x-n.x,o.y-n.y)),n=o}return t}function Wl(e,t){let n=_n(e);if(!Number.isFinite(n)||n<=0)return 0;if(e.kind==="line")return Math.min(1,Math.max(0,t/n));let r=Vl(e);for(let o=1;o<=Dn;o+=1)if(r[o]>=t){let i=r[o]-r[o-1],a=i>0?(t-r[o-1])/i:0;return(o-1+a)/Dn}return 1}function Xl(e,t){if(e.kind==="line"){let i=Hr(e.from,e.to,t);return{head:{kind:"line",from:e.from,to:i},tail:{kind:"line",from:i,to:e.to}}}let n=Hr(e.from,e.control,t),r=Hr(e.control,e.to,t),o=Hr(n,r,t);return{head:{kind:"quad",from:e.from,control:n,to:o},tail:{kind:"quad",from:o,control:r,to:e.to}}}function jf(e,t){let n=1-t;return{x:n*n*e.from.x+2*n*t*e.control.x+t*t*e.to.x,y:n*n*e.from.y+2*n*t*e.control.y+t*t*e.to.y}}function Hr(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}var Dn=64;function Fn(e){return`${$l(e.x)} ${$l(e.y)}`}function $l(e){return Number(e.toFixed(2)).toString()}var Ei={start:xr,end:xr},Ci=128;function We(e){if(!qf(e))return Ei;if(e.type==="arrow"){let t=[e.props.start,e.props.end],n=Ur(t,"polyline");return br(e.props.arrowheadStart,e.props.arrowheadEnd,re(e.props.size),n,{start:n,end:n})}if(e.type==="line"){let t=Pe(e.props.kind);return Ve(t,e.props.points,e.props.closed)?Ei:br(e.props.arrowheadStart,e.props.arrowheadEnd,re(e.props.size),Ur(e.props.points,t),zl(e.props.points,t))}if(e.type==="arc"){let t=re(e.props.size),n=Jl(e);return br(e.props.arrowheadStart,e.props.arrowheadEnd,t,n.total,{start:n.total,end:n.total},{start:Kl(n,"start",Yl(e.props.arrowheadStart,t),t),end:Kl(n,"end",Yl(e.props.arrowheadEnd,t),t)})}return Ei}function qf(e){return e.type==="arrow"?Vt(e.props.arrowheadStart)||Vt(e.props.arrowheadEnd):e.type==="line"?Ve(Pe(e.props.kind),e.props.points,e.props.closed)?!1:Vt(e.props.arrowheadStart)||Vt(e.props.arrowheadEnd):e.type==="arc"?e.props.kind!=="sector"&&(Vt(e.props.arrowheadStart)||Vt(e.props.arrowheadEnd)):!1}function Vt(e){return typeof e=="string"&&e!=="none"}function Yl(e,t){return Fs(e)*Math.max(0,t)}function Kl(e,t,n,r){if(!(n>0)||!(r>0)||e.total<=0)return 0;let o=Math.min(n,e.total),i=t==="start"?0:e.total-o,a=t==="start"?o:e.total,s=Number.POSITIVE_INFINITY;for(let l=0;l<e.cumulative.length;l+=1){let d=e.cumulative[l];d<i||d>a||(s=Math.min(s,e.curvatureRadius[l]))}if(!Number.isFinite(s))return 0;let c=Math.sqrt(Math.max(0,s)*r);return Number.isFinite(c)?c:0}function Vr(e){return{start:e.start.trimPx,end:e.end.trimPx}}function Wr(e){let{startAngle:t,endAngle:n}=e.props,r=We(e);if(r.start.trimPx<=0&&r.end.trimPx<=0)return{startAngle:t,endAngle:n};let o=Jl(e);return o.total<=0?{startAngle:t,endAngle:n}:{startAngle:Zl(o,r.start.trimPx),endAngle:Zl(o,o.total-r.end.trimPx)}}var jl=new WeakMap;function Jl(e){let t=jl.get(e);if(t)return t;let n=Zf(e);return jl.set(e,n),n}function Zf(e){let{rx:t,ry:n}=ce(e),{startAngle:r}=e.props,o=Se(e.props.endAngle-r);if(!Number.isFinite(o)||o<=0)return{startAngle:r,step:0,cumulative:[0],curvatureRadius:[0],total:0};let i=o/Ci,a=[0],s=[ql(t,n,r)];for(let l=0;l<Ci;l+=1){let d=Li(t,n,r+i*l),u=Li(t,n,r+i*(l+1));a.push(a[l]+(d+u)/2*i),s.push(ql(t,n,r+i*(l+1)))}let c=a[Ci];return{startAngle:r,step:i,cumulative:a,curvatureRadius:s,total:Number.isFinite(c)&&c>0?c:0}}function ql(e,t,n){let r=Li(e,t,n),o=e*t;if(!(o>0))return 0;let i=r*r*r/o;return Number.isFinite(i)?i:0}function Zl(e,t){let n=Math.min(Math.max(t,0),e.total);for(let r=1;r<e.cumulative.length;r+=1)if(e.cumulative[r]>=n){let o=e.cumulative[r]-e.cumulative[r-1],i=o>0?(n-e.cumulative[r-1])/o:0;return e.startAngle+e.step*(r-1+i)}return e.startAngle+e.step*(e.cumulative.length-1)}function Li(e,t,n){let r=Math.hypot(e*Math.sin(n),t*Math.cos(n));return Number.isFinite(r)?r:0}function gt(e,t,n,r,o=0){let i=o,a=Math.max(i+1,e-o),s=o,c=Math.max(s+1,t-o),l=Math.max(1,a-i),d=Math.max(1,c-s),u=s+d/2,m=l*Ql(n),h=Xr(a-m,i+Math.min(8,l*.25),a-1),y=d*ec(r)/2,g=Xr(u-y,s,u),x=Xr(u+y,u,c);return[{x:i,y:g},{x:h,y:g},{x:h,y:s},{x:a,y:u},{x:h,y:c},{x:h,y:x},{x:i,y:x}]}function Ql(e){return tc(e,.32,.18,.75)}function ec(e){return tc(e,.42,.12,.9)}function tc(e,t,n,r){let o=typeof e=="number"?e:Number.parseFloat(String(e));return Xr(Number.isFinite(o)?o:t,n,r)}function Xr(e,t,n){return Math.min(n,Math.max(t,e))}function Ni(e){if(!e)return null;let t=Yr(Math.min(e.topLeft.x,e.bottomRight.x)),n=Yr(Math.min(e.topLeft.y,e.bottomRight.y)),r=Yr(Math.max(e.topLeft.x,e.bottomRight.x)),o=Yr(Math.max(e.topLeft.y,e.bottomRight.y));return r-t<.02||o-n<.02?null:{topLeft:{x:t,y:n},bottomRight:{x:r,y:o}}}function Wt(e,t){let n=Ni(e.props.crop);if(n)return n;let r=Math.max(1,t?.props.w||e.props.w||1),o=Math.max(1,t?.props.h||e.props.h||1),i=Math.max(1,e.props.w),a=Math.max(1,e.props.h),s=r/o,c=i/a;if(s>c){let u=c/s,m=(1-u)/2;return{topLeft:{x:m,y:0},bottomRight:{x:m+u,y:1}}}let l=s/c,d=(1-l)/2;return{topLeft:{x:0,y:d},bottomRight:{x:1,y:d+l}}}function $n(e,t,n=Wt(e,t)){let r=Math.max(1,t?.props.w||e.props.w||1),o=Math.max(1,t?.props.h||e.props.h||1);return nc({w:e.props.w,h:e.props.h},{w:r,h:o},n)}function nc(e,t,n){let r=Math.max(1,t.w),o=Math.max(1,t.h),i=Math.max(.02,n.bottomRight.x-n.topLeft.x),a=Math.max(.02,n.bottomRight.y-n.topLeft.y),s=Math.max(e.w/(r*i),e.h/(o*a)),c=r*s,l=o*s;return{x:-n.topLeft.x*c+(e.w-i*c)/2,y:-n.topLeft.y*l+(e.h-a*l)/2,width:c,height:l}}function Yr(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function xt(e){let t=typeof e=="number"?e:Number.parseInt(String(e),10),n=Math.round(Number.isFinite(t)?t:5);return Math.min(12,Math.max(5,n))}function bt(e,t,n,r=0){let o=Math.max(0,e),i=Math.max(0,t),a=Math.min(Math.max(0,r),o/2),s=Math.min(Math.max(0,r),i/2),c=Math.max(0,o-a*2),l=Math.max(0,i-s*2),d=Array.from({length:n},(R,M)=>{let C=-Math.PI/2+M*Math.PI*2/n;return{x:Math.cos(C),y:Math.sin(C)}}),u=d.map(R=>R.x),m=d.map(R=>R.y),h=Math.min(...u),y=Math.max(...u),g=Math.min(...m),x=Math.max(...m),S=Math.max(Number.EPSILON,y-h),I=Math.max(Number.EPSILON,x-g);return d.map(R=>({x:a+(R.x-h)/S*c,y:s+(R.y-g)/I*l}))}var Aw=Math.sqrt(3)/2;var _w=Math.PI*2;var oy=8;function Kr(e){let t=iy(e),n=t?.props.label;if(!t||!n)return null;let r=t.type==="arrow"?{x:(t.props.start.x+t.props.end.x)/2,y:(t.props.start.y+t.props.end.y)/2}:Ai(t.props.points);return r?{anchor:{x:t.x+r.x,y:t.y+r.y-oy},text:n,fontSizePx:$e(t.props.size)}:null}function iy(e){return e.type==="line"||e.type==="arrow"?e:null}var ay=[0,Math.PI/2,Math.PI,Math.PI*1.5];function oc(e){return e.type==="arc"?sy(e):e.type==="line"||e.type==="arrow"?ly(e):de(e)}function Qe(e){return Ct(oc(e))}function sy(e){let{rx:t,ry:n}=ce(e),r={x:e.x+t,y:e.y+n},o=a=>({x:r.x+Math.cos(a)*t,y:r.y+Math.sin(a)*n}),i=[o(e.props.startAngle),o(e.props.endAngle)];for(let a of ay)pi(a,e.props.startAngle,e.props.endAngle)&&i.push(o(a));return e.props.kind==="sector"&&i.push(r),Lt(i)}function ly(e){let n=(e.type==="arrow"?[e.props.start,e.props.end]:e.props.points).map(r=>({x:e.x+r.x,y:e.y+r.y}));return n.length===0?{x:e.x,y:e.y,w:1,h:1}:e.type==="line"&&e.props.kind!=="polyline"?Lt(cy(n)):Lt(n)}function cy(e){if(e.length<3)return[...e];if(e.length===3)return[e[0],e[2],...rc(e[0],e[1],e[2])];let t=[e[0],e[e.length-1]],n=e[0];for(let r=1;r<e.length-1;r+=1){let o=e[r],i=e[r+1],a={x:(o.x+i.x)/2,y:(o.y+i.y)/2};t.push(a,...rc(n,o,a)),n=a}return t}function rc(e,t,n){let r=[];for(let o of["x","y"]){let i=e[o]-2*t[o]+n[o];if(Math.abs(i)<1e-9)continue;let a=(e[o]-t[o])/i;a<=0||a>=1||r.push(uy(e,t,n,a))}return r}function uy(e,t,n,r){let o=1-r;return{x:o*o*e.x+2*o*r*t.x+r*r*n.x,y:o*o*e.y+2*o*r*t.y+r*r*n.y}}var Sk=Object.freeze({});var ic=["color","strokeOpacity","dash","size"],vk=[...ic,"arrowheadStart","arrowheadEnd"],Pk=[...ic,"fill","fillColor","fillOpacity"];var zn=["lead","prompt","hints","solution"];function Fi(e){return e==="decimal"||e==="paren"?e:void 0}var py=["image/png","image/jpeg","image/webp","image/svg+xml"],my=/^sigma-doc-storage:\/\/[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/,fy=py.map(e=>e.replace("+","\\+")).join("|"),yy=new RegExp(`^data:(?:${fy})(?:;[A-Za-z0-9-]+(?:=[^;,]*)?)*;base64,[A-Za-z0-9+/=\\s]+$`,"i"),hy=/^data:image\/svg\+xml(?:;[A-Za-z0-9-]+(?:=[^;,]*)?)*,[^]+$/i,gy=/\.\./,xy=48*1024*1024;function Hn(e){if(typeof e!="string")return null;let t=e.trim();return!t||t.length>xy?null:my.test(t)||yy.test(t)||hy.test(t)&&!gy.test(t)?t:null}function ac(e){return Hn(e)!==null}var Xt="black";var sc=/[\u0000-\u001f\u007f-\u009f]/u,lc=/[\\;{}<>]/u,cc=/(?:url\s*\(|(?:-webkit-)?image-set\s*\(|element\s*\(|@import\b|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:|\/\*)/iu,by=/^(?:rgb|rgba|hsl|hsla)\(\s*[-+.\d%\s,/]+\)$/iu,Sy=/^#[\da-f]{3,8}$/iu,vy=/^[a-z]+$/iu,Py=/^[\p{L}\p{N}\s,"'_.-]+$/u;function St(e){if(typeof e!="string")return!1;let t=e.trim();return t.length>0&&t.length<=512&&!sc.test(e)&&!lc.test(e)&&!cc.test(e)}function Me(e){if(!St(e))return!1;let t=e.trim();return Sy.test(t)||vy.test(t)||by.test(t)}function jr(e){if(!St(e))return!1;let t=e.trim();return t.length<=200&&Py.test(t)}function et(e){return typeof e!="string"?!1:e.trim().length>0&&e.length<=512&&!sc.test(e)&&!lc.test(e)&&!cc.test(e)}var uc="plot";function My(e){return e.kind==="numberLine"?{left:34,top:20,right:28,bottom:30}:{left:46,top:18,right:18,bottom:34}}function Un(e){if(e.props.boundsMode===uc)return e;let t=e.props.preserveSpecSize===!0?e.props.spec:{...e.props.spec,width:e.props.w,height:e.props.h},n=My(t),r=e.props.w/Math.max(1,t.width),o=e.props.h/Math.max(1,t.height),i=n.left*r,a=n.top*o,s=n.right*r,c=n.bottom*o,l=e.anchor?.type==="block"?{...e.anchor,dy:e.anchor.dy+a,...e.anchor.dx===void 0?{}:{dx:e.anchor.dx+i},...e.anchor.line?{line:{...e.anchor.line,dy:e.anchor.line.dy+a}}:{}}:e.anchor;return{...e,x:e.x+i,y:e.y+a,...l?{anchor:l}:{},props:{...e.props,boundsMode:uc,w:Math.max(1,e.props.w-i-s),h:Math.max(1,e.props.h-a-c),spec:e.props.preserveSpecSize===!0?e.props.spec:t}}}var _i=.5,Ty=8,qr=10;function Di(e){let t=Oy(e);for(let n=0;n<4;n+=1){let r=Ry(By(ky(wy(t))));if(_y(t,r))return r;t=r}return t}function Oy(e){let t=new Map;for(let a of e)a.type==="group"||!a.groupId||t.set(a.groupId,[...t.get(a.groupId)??[],a]);if(t.size===0)return e.map(dc);let n=new Set(e.map(a=>a.id)),r=new Map,o=new Map;for(let[a,s]of t){if(s.length<2)continue;let c=mc(s);if(!c)continue;let l=Ey(()=>a,n);r.set(a,l);let d=Math.max(0,e.findIndex(m=>m.groupId===a)),u={id:l,type:"group",x:c.x,y:c.y,props:{w:c.w,h:c.h}};o.set(d,[...o.get(d)??[],u])}let i=[];return e.forEach((a,s)=>{let c=o.get(s);c&&i.push(...c);let l=a.groupId,d=dc(a),u=l?r.get(l):void 0;i.push(u?{...d,parentId:u}:d)}),i}function wy(e){let t=new Map(e.map(o=>[o.id,o])),n=!1,r=e.map(o=>{if(!o.parentId)return o;let i=t.get(o.parentId);if(!i||i.type!=="group"||i.id===o.id||Iy(o,t)){let a={...o};return delete a.parentId,n=!0,a}return o});return n?r:e}function ky(e){let t=Gi(e),n=new Set(e.filter(o=>o.type==="group").filter(o=>(t.get(o.id)?.length??0)<=1).map(o=>o.id));if(n.size===0)return e;let r=new Map(e.filter(o=>o.type==="group"&&n.has(o.id)).map(o=>[o.id,o.parentId]));return e.flatMap(o=>{if(n.has(o.id))return[];if(o.parentId&&n.has(o.parentId)){let i=r.get(o.parentId),a={...o};return i?a.parentId=i:delete a.parentId,[a]}return[o]})}function By(e){let t=Gi(e),n=new Map(e.map(a=>[a.id,Ay(a,e)])),r=e.filter(a=>a.type==="group").sort((a,s)=>(n.get(s.id)??0)-(n.get(a.id)??0));if(r.length===0)return e;let o=new Map(e.map(a=>[a.id,a])),i=!1;for(let a of r){let s=(t.get(a.id)??[]).map(l=>o.get(l.id)??l),c=mc(s);c&&(Fy(c,{x:a.x,y:a.y,w:a.props.w,h:a.props.h})||(o.set(a.id,{...a,x:c.x,y:c.y,props:{...a.props,w:c.w,h:c.h}}),i=!0))}return i?e.map(a=>o.get(a.id)??a):e}function Ry(e){let t=Gi(e),n=[],r=new Set,o=i=>{if(!r.has(i.id)&&(r.add(i.id),n.push(i),i.type==="group"))for(let a of t.get(i.id)??[])o(a)};for(let i of e)i.parentId||o(i);for(let i of e)o(i);return n}function Gi(e){let t=new Map;for(let n of e)n.parentId&&t.set(n.parentId,[...t.get(n.parentId)??[],n]);return t}function Ay(e,t){let n=0,r=e.parentId,o=new Set([e.id]);for(;r;){let i=t.find(a=>a.id===r);if(!i||o.has(i.id))break;o.add(i.id),n+=1,r=i.parentId}return n}function Iy(e,t){let n=new Set([e.id]),r=e.parentId;for(;r;){if(n.has(r))return!0;n.add(r),r=t.get(r)?.parentId}return!1}function dc(e){if(!e.groupId)return e;let t={...e};return delete t.groupId,t}function Ey(e,t){let n=e(),r=1;for(;t.has(n);)n=`${e()}_${r}`,r+=1;return t.add(n),n}function mc(e){return e.length===0?null:e.map(Cy).reduce((t,n)=>Ny(t,n))}function Cy(e){if(e.type==="graph2dShape"){let t=Un(e);return{x:t.x,y:t.y,w:t.props.w,h:t.props.h}}if(e.type==="group"||e.type==="geo"||e.type==="image"||e.type==="callout"||e.type==="tableShape")return{x:e.x,y:e.y,w:e.props.w,h:e.props.h};if(e.type==="arc"){let t=Math.max(_i,e.props.r),n=typeof e.props.rx=="number"&&Number.isFinite(e.props.rx)?Math.max(_i,e.props.rx):t,r=typeof e.props.ry=="number"&&Number.isFinite(e.props.ry)?Math.max(_i,e.props.ry):t;return{x:e.x,y:e.y,w:n*2,h:r*2}}if(e.type==="text"){let t=Ly(e),n=typeof e.props.h=="number"&&Number.isFinite(e.props.h)?Math.max(t,e.props.h):t;return{x:e.x,y:e.y,w:Math.max(Ty,e.props.w),h:n}}return e.type==="arrow"?pc(e.x,e.y,[e.props.start,e.props.end]):e.type==="line"?pc(e.x,e.y,e.props.points):{x:0,y:0,w:1,h:1}}function Ly(e){let t=yt(e);return Math.max(t,pl(e.props.richText)*t)}function pc(e,t,n){if(n.length===0)return{x:e,y:t,w:1,h:1};let r=n.map(l=>e+l.x),o=n.map(l=>t+l.y),i=Math.min(...r),a=Math.min(...o),s=Math.max(...r),c=Math.max(...o);return{x:i-qr,y:a-qr,w:Math.max(1,s-i+qr*2),h:Math.max(1,c-a+qr*2)}}function Ny(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y),o=Math.max(e.x+e.w,t.x+t.w),i=Math.max(e.y+e.h,t.y+t.h);return{x:n,y:r,w:o-n,h:i-r}}function Fy(e,t){return Math.abs(e.x-t.x)<.01&&Math.abs(e.y-t.y)<.01&&Math.abs(e.w-t.w)<.01&&Math.abs(e.h-t.h)<.01}function _y(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}var Dy=/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})$/;function tt(e){let t=typeof e=="number"?String(e):String(e??"").trim();if(!Dy.test(t))return;let n=Number(t);if(!(!Number.isFinite(n)||n<.8||n>3))return Gy(n)}function Gy(e){return e.toFixed(2).replace(/\.?0+$/,"")}var $i="#9ca3af";var fc="solid",yc=[{label:"\u30D9\u30BF",value:"solid"},{label:"\u53F3\u4E0A\u659C\u7DDA",value:"diagonal"},{label:"\u53F3\u4E0B\u659C\u7DDA",value:"diagonalBack"},{label:"\u683C\u5B50\u659C\u7DDA",value:"cross"},{label:"\u6A2A\u7DDA",value:"horizontal"},{label:"\u7E26\u7DDA",value:"vertical"},{label:"\u70B9\u3005",value:"dots"}];function Zr(e){return yc.some(t=>t.value===e)}function zi(e){return Zr(e)?e:fc}function Hi(e){return typeof e!="number"||!Number.isFinite(e)?.28:Math.min(1,Math.max(0,e))}var Ui=["none","arrow","triangle","openArrow","thinArrow","diamond","dot","bar"];function Xi(e){return qt(e)?e.shapes.every(Zt)&&Object.values(e.assets).every(Xn)&&(e.extensions===void 0||Wn(e.extensions)):!1}function qt(e){return G(e)&&e.version===1&&Array.isArray(e.shapes)&&G(e.assets)}function Wn(e){return G(e)&&Object.keys(e).every($y)&&Object.values(e).every(Vi)}function jt(e){return G(e)&&Array.isArray(e.blocks)&&e.blocks.every(Sc)}function Zt(e){if(!G(e)||typeof e.id!="string"||!k(e.x)||!k(e.y)||e.rotation!==void 0&&!k(e.rotation)||e.parentId!==void 0&&typeof e.parentId!="string"||e.groupId!==void 0&&typeof e.groupId!="string"||e.stackLayer!==void 0&&!Vy(e.stackLayer)||e.locked!==void 0&&typeof e.locked!="boolean"||e.hidden!==void 0&&typeof e.hidden!="boolean"||e.opacity!==void 0&&(!k(e.opacity)||e.opacity<0||e.opacity>1)||e.anchor!==void 0&&!Xy(e.anchor)||!G(e.props))return!1;switch(e.type){case"group":return Yt(e.props)&&(e.props.name===void 0||typeof e.props.name=="string");case"geo":return Yt(e.props)&&(e.props.geo==="rectangle"||e.props.geo==="ellipse"||e.props.geo==="triangle"||e.props.geo==="diamond"||e.props.geo==="pentagon"||e.props.geo==="regularPolygon"||e.props.geo==="blockArrow")&&(e.props.geo!=="regularPolygon"||k(e.props.polygonSides)&&Number.isInteger(e.props.polygonSides)&&e.props.polygonSides>=5&&e.props.polygonSides<=12)&&(e.props.apexX===void 0||k(e.props.apexX))&&(e.props.headLengthRatio===void 0||k(e.props.headLengthRatio)&&e.props.headLengthRatio>0&&e.props.headLengthRatio<1)&&(e.props.shaftRatio===void 0||k(e.props.shaftRatio)&&e.props.shaftRatio>0&&e.props.shaftRatio<=1)&&(e.props.radius===void 0||k(e.props.radius)&&e.props.radius>=0)&&(e.props.fill==="none"||e.props.fill==="solid")&&typeof e.props.color=="string"&&(e.props.fillColor===void 0||typeof e.props.fillColor=="string")&&(e.props.strokeOpacity===void 0||k(e.props.strokeOpacity)&&e.props.strokeOpacity>=0&&e.props.strokeOpacity<=1)&&(e.props.fillOpacity===void 0||k(e.props.fillOpacity)&&e.props.fillOpacity>=0&&e.props.fillOpacity<=1)&&typeof e.props.labelColor=="string"&&Vn(e.props.dash)&&vt(e.props.size)&&(e.props.label===void 0||typeof e.props.label=="string");case"arc":return(e.props.kind===void 0||e.props.kind==="arc"||e.props.kind==="sector")&&k(e.props.r)&&e.props.r>0&&(e.props.rx===void 0||k(e.props.rx)&&e.props.rx>0)&&(e.props.ry===void 0||k(e.props.ry)&&e.props.ry>0)&&k(e.props.startAngle)&&k(e.props.endAngle)&&(e.props.arrowheadStart===void 0||Kt(e.props.arrowheadStart))&&(e.props.arrowheadEnd===void 0||Kt(e.props.arrowheadEnd))&&(e.props.fill===void 0||e.props.fill==="none"||e.props.fill==="solid")&&(e.props.fillColor===void 0||typeof e.props.fillColor=="string")&&(e.props.fillOpacity===void 0||k(e.props.fillOpacity)&&e.props.fillOpacity>=0&&e.props.fillOpacity<=1)&&(e.props.fillPattern===void 0||e.props.fillPattern==="diagonalHatch")&&typeof e.props.color=="string"&&(e.props.strokeOpacity===void 0||k(e.props.strokeOpacity)&&e.props.strokeOpacity>=0&&e.props.strokeOpacity<=1)&&Vn(e.props.dash)&&vt(e.props.size);case"arrow":return nt(e.props.start)&&nt(e.props.end)&&(e.props.arrowheadStart===void 0||Kt(e.props.arrowheadStart))&&Kt(e.props.arrowheadEnd)&&e.props.fill==="none"&&typeof e.props.color=="string"&&(e.props.strokeOpacity===void 0||k(e.props.strokeOpacity)&&e.props.strokeOpacity>=0&&e.props.strokeOpacity<=1)&&typeof e.props.labelColor=="string"&&Vn(e.props.dash)&&vt(e.props.size)&&(e.props.label===void 0||typeof e.props.label=="string");case"line":return Array.isArray(e.props.points)&&e.props.points.length>0&&e.props.points.every(nt)&&(e.props.kind===void 0||Wy(e.props.kind))&&typeof e.props.closed=="boolean"&&(e.props.arrowheadStart===void 0||Kt(e.props.arrowheadStart))&&(e.props.arrowheadEnd===void 0||Kt(e.props.arrowheadEnd))&&(e.props.fill===void 0||e.props.fill==="none"||e.props.fill==="solid")&&(e.props.fillColor===void 0||typeof e.props.fillColor=="string")&&(e.props.fillOpacity===void 0||k(e.props.fillOpacity)&&e.props.fillOpacity>=0&&e.props.fillOpacity<=1)&&typeof e.props.color=="string"&&(e.props.strokeOpacity===void 0||k(e.props.strokeOpacity)&&e.props.strokeOpacity>=0&&e.props.strokeOpacity<=1)&&Vn(e.props.dash)&&vt(e.props.size)&&(e.props.labelColor===void 0||typeof e.props.labelColor=="string")&&(e.props.label===void 0||typeof e.props.label=="string");case"text":return k(e.props.w)&&(e.props.h===void 0||k(e.props.h)&&e.props.h>0)&&(e.props.maxWidth===void 0||k(e.props.maxWidth)&&e.props.maxWidth>0)&&(e.props.scale===void 0||k(e.props.scale)&&e.props.scale>0)&&jt(e.props.richText)&&typeof e.props.autoSize=="boolean"&&typeof e.props.color=="string"&&(e.props.fontSize===void 0||k(e.props.fontSize)&&e.props.fontSize>0)&&vt(e.props.size);case"image":return typeof e.props.assetId=="string"&&Yt(e.props)&&(e.props.crop===void 0||Uy(e.props.crop));case"callout":return Yt(e.props)&&k(e.props.radius)&&e.props.radius>=0&&G(e.props.tail)&&nt(e.props.tail.baseStart)&&nt(e.props.tail.baseEnd)&&nt(e.props.tail.tip)&&jt(e.props.richText)&&typeof e.props.color=="string"&&(e.props.fontSize===void 0||k(e.props.fontSize)&&e.props.fontSize>0)&&vt(e.props.size)&&Vn(e.props.dash)&&vt(e.props.strokeWidth);case"graph2dShape":return Yt(e.props)&&jy(e.props.spec)&&(e.props.boundsMode===void 0||e.props.boundsMode==="plot")&&(e.props.preserveSpecSize===void 0||typeof e.props.preserveSpecSize=="boolean")&&(e.props.axisLabelTextShapeIds===void 0||G(e.props.axisLabelTextShapeIds)&&Object.entries(e.props.axisLabelTextShapeIds).every(([t,n])=>Ky(t)&&typeof n=="string"))&&(e.props.pointLabelTextShapeIdsByPointId===void 0||G(e.props.pointLabelTextShapeIdsByPointId)&&Object.values(e.props.pointLabelTextShapeIdsByPointId).every(t=>typeof t=="string"))&&(e.props.annotationTextShapeIdsByAnnotationId===void 0||G(e.props.annotationTextShapeIdsByAnnotationId)&&Object.values(e.props.annotationTextShapeIdsByAnnotationId).every(t=>typeof t=="string"))&&(e.props.labelTextShapeIds===void 0||Array.isArray(e.props.labelTextShapeIds)&&e.props.labelTextShapeIds.every(t=>typeof t=="string"))&&(e.props.labelTextShapeIdsByCurveId===void 0||G(e.props.labelTextShapeIdsByCurveId)&&Object.values(e.props.labelTextShapeIdsByCurveId).every(t=>typeof t=="string"));case"tableShape":return Yt(e.props)&&Qy(e.props.table);default:return!1}}function Xn(e){return G(e)&&typeof e.id=="string"&&e.type==="image"&&G(e.props)&&k(e.props.w)&&k(e.props.h)&&typeof e.props.name=="string"&&e.props.isAnimated===!1&&(typeof e.props.mimeType=="string"||e.props.mimeType===null)&&typeof e.props.src=="string"&&k(e.props.fileSize)&&(e.props.storage===void 0||zy(e.props.storage))}function $y(e){return/^[a-z][a-z0-9]*(?:[.-][a-z][a-z0-9]*)+$/.test(e)}function Vi(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(Vi):G(e)&&Object.values(e).every(Vi)}function zy(e){return G(e)&&e.kind==="remote-asset"&&typeof e.storageKey=="string"&&typeof e.assetId=="string"}function G(e){return typeof e=="object"&&e!==null}function Sc(e){return!G(e)||e.type!=="paragraph"&&e.type!=="heading"||!Array.isArray(e.children)||!e.children.every(Wi)||e.align!==void 0&&!Yi(e.align)||e.lineHeight!==void 0&&!Hy(e.lineHeight)?!1:e.type!=="heading"||e.level===1||e.level===2||e.level===3}function Hy(e){if(typeof e!="string"||!/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})$/u.test(e))return!1;let t=Number(e);return Number.isFinite(t)&&t>=.8&&t<=3}function k(e){return typeof e=="number"&&Number.isFinite(e)}function Yt(e){return k(e.w)&&k(e.h)}function nt(e){return G(e)&&k(e.x)&&k(e.y)}function Uy(e){return G(e)&&nt(e.topLeft)&&nt(e.bottomRight)&&e.topLeft.x>=0&&e.topLeft.x<=1&&e.topLeft.y>=0&&e.topLeft.y<=1&&e.bottomRight.x>=0&&e.bottomRight.x<=1&&e.bottomRight.y>=0&&e.bottomRight.y<=1&&e.bottomRight.x>e.topLeft.x&&e.bottomRight.y>e.topLeft.y}function vt(e){return e==="s"||e==="m"||e==="l"||e==="xl"}function Vy(e){return e==="foreground"||e==="background"}function Vn(e){return e==="solid"||e==="dashed"||e==="dotted"}function Kt(e){return typeof e=="string"&&Ui.includes(e)}function Wy(e){return e==="polyline"||e==="curve"||e==="freehand"}function Xy(e){return G(e)?e.type==="page"?!0:e.type==="shape"?typeof e.shapeId=="string"&&k(e.dx)&&k(e.dy)&&(e.rx===void 0||k(e.rx))&&(e.ry===void 0||k(e.ry)):e.type==="block"&&typeof e.blockId=="string"&&k(e.dy)&&(e.dx===void 0||k(e.dx))&&(e.reserveSpace===void 0||typeof e.reserveSpace=="boolean")&&(e.line===void 0||Yy(e.line)):!1}function Yy(e){return G(e)&&typeof e.index=="number"&&Number.isInteger(e.index)&&e.index>=0&&k(e.dy)}function Ky(e){return e==="x"||e==="y"||e==="origin"}function jy(e){return!G(e)||e.kind!=="cartesian"&&e.kind!=="numberLine"?!1:typeof e.title=="string"&&k(e.width)&&k(e.height)&&hc(e.viewBox)&&(e.graphViewBox===void 0||hc(e.graphViewBox))&&G(e.axes)&&typeof e.axes.grid=="boolean"&&Array.isArray(e.curves)&&e.curves.every(qy)&&(e.points===void 0||Array.isArray(e.points)&&e.points.every(Zy))&&(e.annotations===void 0||Array.isArray(e.annotations))&&(e.fills===void 0||Array.isArray(e.fills)&&e.fills.every(Jy))&&(e.showFormulaLabels===void 0||typeof e.showFormulaLabels=="boolean")}function qy(e){return G(e)&&typeof e.id=="string"&&typeof e.expr=="string"&&(e.yExpr===void 0||typeof e.yExpr=="string")&&typeof e.color=="string"&&(e.label===void 0||typeof e.label=="string")&&(e.mode===void 0||e.mode==="yOfX"||e.mode==="xOfY"||e.mode==="parametric"||e.mode==="implicit")&&(e.dash===void 0||e.dash==="solid"||e.dash==="dashed"||e.dash==="dotted")&&(e.strokeWidth===void 0||k(e.strokeWidth))&&(e.domain===void 0||G(e.domain)&&(e.domain.min===void 0||typeof e.domain.min=="string")&&(e.domain.max===void 0||typeof e.domain.max=="string"))}function hc(e){return G(e)&&typeof e.xMin=="string"&&typeof e.xMax=="string"&&typeof e.yMin=="string"&&typeof e.yMax=="string"}function Zy(e){return G(e)&&typeof e.id=="string"&&typeof e.x=="string"&&typeof e.y=="string"&&(e.color===void 0||typeof e.color=="string")&&(e.fill===void 0||e.fill==="solid"||e.fill==="none")&&(e.radius===void 0||k(e.radius))&&(e.label===void 0||typeof e.label=="string")&&(e.showXProjection===void 0||typeof e.showXProjection=="boolean")&&(e.showYProjection===void 0||typeof e.showYProjection=="boolean")}function Jy(e){return G(e)&&typeof e.id=="string"&&typeof e.x=="string"&&typeof e.y=="string"&&(e.color===void 0||typeof e.color=="string")&&(e.pattern===void 0||Zr(e.pattern))&&(e.opacity===void 0||k(e.opacity)&&e.opacity>=0&&e.opacity<=1)}function Qy(e){if(!G(e)||e.version!==1||e.kind!=="plain"&&e.kind!=="variation"||!Array.isArray(e.columns)||!Array.isArray(e.rows)||!Array.isArray(e.cells)||!G(e.grid)||!Pc(e.defaultCellStyle)||e.columns.length===0||e.rows.length===0)return!1;let t=new Set;for(let r of e.columns){if(!eh(r)||t.has(r.id))return!1;t.add(r.id)}let n=new Set;for(let r of e.rows){if(!th(r)||n.has(r.id))return!1;n.add(r.id)}return ah(e.grid,n,t)?e.cells.every(r=>nh(r,n,t)):!1}function eh(e){return G(e)&&typeof e.id=="string"&&vc(e.width)&&(e.role===void 0||e.role==="label"||e.role==="point"||e.role==="interval"||e.role==="value")}function th(e){return G(e)&&typeof e.id=="string"&&vc(e.height)&&(e.role===void 0||e.role==="header"||e.role==="body"||e.role==="variable"||e.role==="derivative"||e.role==="variation"||e.role==="note")}function vc(e){return G(e)?e.mode==="fixed"?k(e.value)&&e.value>0:e.mode==="auto"?Jr(e.min)&&Jr(e.max):e.mode==="fr"&&k(e.value)&&e.value>0&&Jr(e.min)&&Jr(e.max):!1}function nh(e,t,n){return G(e)&&typeof e.id=="string"&&typeof e.rowId=="string"&&typeof e.columnId=="string"&&t.has(e.rowId)&&n.has(e.columnId)&&(e.rowSpan===void 0||xc(e.rowSpan))&&(e.colSpan===void 0||xc(e.colSpan))&&Array.isArray(e.content)&&e.content.every(rh)&&(e.style===void 0||ch(e.style))}function rh(e){return!G(e)||typeof e.id!="string"?!1:e.type==="paragraph"?Array.isArray(e.children)&&e.children.every(Wi)&&(e.align===void 0||Yi(e.align)):e.type==="trend"&&(e.direction==="up"||e.direction==="down"||e.direction==="flat")&&(e.label===void 0||Array.isArray(e.label)&&e.label.every(Wi))}function Wi(e){return G(e)?e.type==="text"?typeof e.text=="string"&&(e.marks===void 0||Array.isArray(e.marks)&&e.marks.every(oh))&&(e.color===void 0||typeof e.color=="string")&&(e.backgroundColor===void 0||typeof e.backgroundColor=="string")&&(e.fontFamily===void 0||typeof e.fontFamily=="string")&&(e.fontSize===void 0||k(e.fontSize)&&e.fontSize>0)&&(e.boxedPaddingY===void 0||k(e.boxedPaddingY)&&e.boxedPaddingY>=0)&&gc(e):e.type==="mathInline"&&typeof e.id=="string"&&e.id.length>0&&typeof e.tex=="string"&&e.display==="inline"&&(e.marks===void 0||Array.isArray(e.marks)&&e.marks.every(ih))&&(e.color===void 0||typeof e.color=="string")&&(e.backgroundColor===void 0||typeof e.backgroundColor=="string")&&(e.fontFamily===void 0||typeof e.fontFamily=="string")&&(e.fontSize===void 0||k(e.fontSize)&&e.fontSize>0)&&(e.boxedPaddingY===void 0||k(e.boxedPaddingY)&&e.boxedPaddingY>=0)&&(e.semanticRole===void 0||e.semanticRole==="expression"||e.semanticRole==="equation"||e.semanticRole==="variable")&&(e.altText===void 0||typeof e.altText=="string")&&gc(e):!1}function oh(e){return e==="bold"||e==="italic"||e==="underline"||e==="boxed"}function ih(e){return e==="underline"||e==="boxed"}function gc(e){return(e.boxedVariant===void 0||e.boxedVariant==="frame"||e.boxedVariant==="thick"||e.boxedVariant==="double"||e.boxedVariant==="oval"||e.boxedVariant==="shade")&&(e.boxedTone===void 0||e.boxedTone==="gray"||e.boxedTone==="blue"||e.boxedTone==="green"||e.boxedTone==="red"||e.boxedTone==="yellow")}function ah(e,t,n){return G(e)&&typeof e.borderColor=="string"&&k(e.borderWidth)&&e.borderWidth>=0&&(e.borderStyle===void 0||e.borderStyle==="solid"||e.borderStyle==="dashed"||e.borderStyle==="dotted"||e.borderStyle==="double")&&(e.showOuterBorder===void 0||typeof e.showOuterBorder=="boolean")&&(e.showInnerBorders===void 0||typeof e.showInnerBorders=="boolean")&&(e.lineOverrides===void 0||Array.isArray(e.lineOverrides)&&e.lineOverrides.every(r=>sh(r,t,n)))}function sh(e,t,n){if(!G(e)||!lh(e.style))return!1;if(e.axis==="vertical"){let r="edge"in e,o="beforeColumnId"in e;return r===o?!1:r?e.edge==="left"||e.edge==="right":typeof e.beforeColumnId=="string"&&n.has(e.beforeColumnId)}if(e.axis==="horizontal"){let r="edge"in e,o="beforeRowId"in e;return r===o?!1:r?e.edge==="top"||e.edge==="bottom":typeof e.beforeRowId=="string"&&t.has(e.beforeRowId)}return!1}function lh(e){return G(e)&&(e.visible===void 0||typeof e.visible=="boolean")&&(e.borderColor===void 0||typeof e.borderColor=="string")&&(e.borderWidth===void 0||k(e.borderWidth)&&e.borderWidth>=0)&&(e.borderStyle===void 0||e.borderStyle==="solid"||e.borderStyle==="dashed"||e.borderStyle==="dotted"||e.borderStyle==="double")}function Pc(e){return G(e)&&(e.align===void 0||Yi(e.align))&&(e.verticalAlign===void 0||e.verticalAlign==="top"||e.verticalAlign==="middle"||e.verticalAlign==="bottom")&&bc(e.paddingX)&&bc(e.paddingY)&&(e.color===void 0||typeof e.color=="string")&&(e.backgroundColor===void 0||typeof e.backgroundColor=="string")&&(e.fontFamily===void 0||typeof e.fontFamily=="string")&&(e.fontSize===void 0||k(e.fontSize)&&e.fontSize>0)&&(e.fontWeight===void 0||e.fontWeight==="normal"||e.fontWeight==="bold")}function ch(e){return Pc(e)}function Yi(e){return e==="left"||e==="center"||e==="right"||e==="justify"}function xc(e){return Number.isInteger(e)&&Number(e)>0}function Jr(e){return e===void 0||k(e)&&e>0}function bc(e){return e===void 0||k(e)&&e>=0}function uh(e){if(jt(e)||!he(e)||e.type!=="doc"||!Array.isArray(e.content))return e;let t=dh(e.content);if(!t)return e;let n=[];for(let r of t){let o=ph(r);if(!o)return e;n.push(o)}return{blocks:n}}function Qr(e){if(!he(e)||!Array.isArray(e.shapes))return e;let t=!1,n=e.shapes.map(r=>{if(!he(r)||r.type!=="text"&&r.type!=="callout"||!he(r.props))return r;let o=uh(r.props.richText);return o===r.props.richText?r:(t=!0,{...r,props:{...r.props,richText:o}})});return t?{...e,shapes:n}:e}function dh(e){let t=[];for(let n of e){if(!he(n))return null;if(n.type==="paragraph"||n.type==="heading"){t.push(n);continue}if(!wc(n))return null;let r=t[t.length-1];r?.type==="paragraph"||r?.type==="heading"?t[t.length-1]={...r,content:[...Array.isArray(r.content)?r.content:[],n]}:t.push({type:"paragraph",content:[n]})}return t}function ph(e){if(e.type!=="paragraph"&&e.type!=="heading"||e.content!==void 0&&!Array.isArray(e.content)||e.attrs!==void 0&&!he(e.attrs))return null;let t=mh(Array.isArray(e.content)?e.content:[]);if(!t)return null;let n=he(e.attrs)?e.attrs:{},r=hh(n.textAlign),o=tt(n.lineHeight);return e.type==="heading"?{type:"heading",level:n.level===1||n.level===2||n.level===3?n.level:2,children:t,...r?{align:r}:{},...o?{lineHeight:o}:{}}:{type:"paragraph",children:t,...r?{align:r}:{},...o?{lineHeight:o}:{}}}function mh(e){let t=[];for(let n of e){if(!wc(n))return null;if(n.type==="hardBreak"){Mc(t,`
|
|
8
|
-
`,t[t.length-1]?.type==="text"?t[t.length-1]:{});continue}let r=Array.isArray(n.marks)?n.marks:[],o=Tc(r);if(n.type==="text"){Mc(t,n.text,o);continue}let i=n.attrs,a=fh(r);t.push({type:"mathInline",id:typeof i.id=="string"&&i.id?i.id:`m_inline_${t.length}`,tex:i.tex,display:"inline",...a.length?{marks:a}:{},...Oc(o,a.includes("boxed")),semanticRole:"expression"})}return t}function Tc(e){let t=new Set,n,r,o,i,a,s,c;for(let l of e){if(!he(l)||typeof l.type!="string")continue;if(l.type==="bold"||l.type==="italic"||l.type==="underline"){t.add(l.type);continue}let d=he(l.attrs)?l.attrs:{};if(l.type==="boxed"){t.add("boxed"),a=xh(d.paddingY),s=bh(d.variant),c=Sh(d.tone);continue}l.type==="styledText"&&(n=Ki(d.color),r=Ki(d.backgroundColor),o=Ki(d.fontFamily),i=gh(d.fontSize),(d.fontWeight==="bold"||Number(d.fontWeight)>=600)&&t.add("bold"),d.fontStyle==="italic"&&t.add("italic"),typeof d.textDecoration=="string"&&d.textDecoration.includes("underline")&&t.add("underline"))}return{...t.size?{marks:[...t]}:{},...n?{color:n}:{},...r?{backgroundColor:r}:{},...o?{fontFamily:o}:{},...i?{fontSize:i}:{},...a!==void 0?{boxedPaddingY:a}:{},...s?{boxedVariant:s}:{},...c?{boxedTone:c}:{}}}function fh(e){return(Tc(e).marks??[]).filter(n=>n==="underline"||n==="boxed")}function Mc(e,t,n){let r=e[e.length-1];if(r?.type==="text"&&JSON.stringify(r.marks??[])===JSON.stringify(n.marks??[])&&r.color===n.color&&r.backgroundColor===n.backgroundColor&&r.fontFamily===n.fontFamily&&r.fontSize===n.fontSize&&r.boxedPaddingY===n.boxedPaddingY&&r.boxedVariant===n.boxedVariant&&r.boxedTone===n.boxedTone){r.text+=t;return}e.push({type:"text",text:t,...Oc(n,n.marks?.includes("boxed")??!1),...n.marks?.length?{marks:n.marks}:{}})}function Oc(e,t){return{...e.color?{color:e.color}:{},...e.backgroundColor?{backgroundColor:e.backgroundColor}:{},...e.fontFamily?{fontFamily:e.fontFamily}:{},...e.fontSize?{fontSize:e.fontSize}:{},...t&&e.boxedPaddingY!==void 0?{boxedPaddingY:e.boxedPaddingY}:{},...t&&e.boxedVariant?{boxedVariant:e.boxedVariant}:{},...t&&e.boxedTone?{boxedTone:e.boxedTone}:{}}}function wc(e){return!he(e)||e.marks!==void 0&&(!Array.isArray(e.marks)||!e.marks.every(yh))?!1:e.type==="text"?typeof e.text=="string":e.type==="hardBreak"?!0:e.type==="mathInline"&&he(e.attrs)&&typeof e.attrs.tex=="string"}function yh(e){return he(e)&&(e.type==="bold"||e.type==="italic"||e.type==="underline"||e.type==="boxed"||e.type==="styledText")&&(e.attrs===void 0||he(e.attrs))}function hh(e){return e==="left"||e==="center"||e==="right"||e==="justify"?e:void 0}function gh(e){let t=typeof e=="number"?e:Number.parseFloat(String(e));if(!Number.isFinite(t)||t<=0)return;let n=typeof e=="string"&&/px$/iu.test(e.trim())?t/(96/72):t;return Math.round(n*100)/100}function xh(e){let t=typeof e=="number"?e:Number.parseFloat(String(e));return Number.isFinite(t)&&t>=0?Math.min(12,Math.round(t*10)/10):void 0}function Ki(e){return typeof e=="string"&&e.length>0?e:void 0}function bh(e){return e==="frame"||e==="thick"||e==="double"||e==="oval"||e==="shade"?e:void 0}function Sh(e){return e==="gray"||e==="blue"||e==="green"||e==="red"||e==="yellow"?e:void 0}function he(e){return typeof e=="object"&&e!==null}var vh="sigma.legacy.metadata",Ph=["id","type","x","y","rotation","parentId","groupId","stackLayer","locked","hidden","opacity","anchor","props"],Mh={group:["w","h","name"],geo:["w","h","geo","polygonSides","apexX","headLengthRatio","shaftRatio","radius","fill","color","fillColor","strokeOpacity","fillOpacity","labelColor","dash","size","label"],arc:["kind","r","rx","ry","startAngle","endAngle","arrowheadStart","arrowheadEnd","fill","fillColor","fillOpacity","fillPattern","color","strokeOpacity","dash","size"],arrow:["start","end","arrowheadStart","arrowheadEnd","fill","color","strokeOpacity","labelColor","dash","size","label"],line:["kind","points","closed","arrowheadStart","arrowheadEnd","fill","fillColor","fillOpacity","fillPattern","color","strokeOpacity","labelColor","dash","size","label"],text:["w","h","maxWidth","scale","richText","autoSize","color","fontSize","size"],image:["assetId","w","h","crop"],callout:["w","h","radius","tail","richText","color","fontSize","size","dash","strokeWidth"],graph2dShape:["boundsMode","w","h","spec","preserveSpecSize","axisLabelTextShapeIds","pointLabelTextShapeIdsByPointId","annotationTextShapeIdsByAnnotationId","labelTextShapeIds","labelTextShapeIdsByCurveId"],tableShape:["w","h","table"]};function Rc(){return{version:1,shapes:[],assets:{}}}var kc=new WeakMap;function me(e){let t=typeof e=="object"&&e!==null?e:null,n=t?kc.get(t):void 0;if(n)return n;let r=Qr(e);if(!qt(r))return Rc();let o=Qi(r),i=r.shapes.filter(Zt).map(qi),a={version:1,shapes:Di(Lc(i)),assets:Object.fromEntries(Object.entries(r.assets).filter(s=>Zi(s[1])).map(([s,c])=>[s,Ji(c)])),...o?{extensions:o}:{}};return t&&kc.set(t,a),a}function ji(e){let t=Qr(e);if(!qt(t))return{snapshot:Rc(),issues:[{kind:"snapshot"}]};let n=[],r=t.shapes.flatMap((a,s)=>Zt(a)?[qi(a)]:(n.push({kind:"shape",index:s,id:pe(a)&&typeof a.id=="string"?a.id:void 0,type:pe(a)&&typeof a.type=="string"?a.type:void 0}),[])),o=Object.entries(t.assets).flatMap(([a,s])=>Zi(s)?[[a,Ji(s)]]:(n.push({kind:"asset",key:a}),[])),i=Qi(t);return{snapshot:{version:1,shapes:Di(Lc(r)),assets:Object.fromEntries(o),...i?{extensions:i}:{}},issues:n}}function Ac(e){let t=Qr(e);if(!qt(t)||!t.shapes.every(Zt)||!Object.values(t.assets).every(Xn)||t.extensions!==void 0&&!Wn(t.extensions))return t;let n=Qi(t);return{version:1,shapes:t.shapes.map(qi),assets:Object.fromEntries(Object.entries(t.assets).filter(r=>Zi(r[1])).map(([r,o])=>[r,Ji(o)])),...n?{extensions:n}:{}}}function Th(e){let t={...e};for(let n of["parentId","groupId","stackLayer","locked","hidden","opacity","anchor"])t[n]===void 0&&delete t[n];return t}var Oh={geo:["color","labelColor"],arc:["color"],arrow:["color","labelColor"],line:["color"],text:["color"],callout:["color"]},wh={geo:["fillColor"],arc:["fillColor"],line:["fillColor","labelColor"]};function kh(e,t){for(let n of Oh[e]??[])t[n]!==void 0&&!Me(t[n])&&(t[n]=Xt);for(let n of wh[e]??[])t[n]!==void 0&&!Me(t[n])&&delete t[n];e==="graph2dShape"?t.spec=Bh(t.spec):e==="tableShape"&&(t.table=Rh(t.table))}function Pt(e,t,n=[]){if(!pe(e))return e;let r;for(let o of t)e[o]!==void 0&&!Me(e[o])&&(r??={...e},delete r[o]);for(let o of n)e[o]!==void 0&&!jr(e[o])&&(r??={...e},delete r[o]);return r??e}function Mt(e,t){let n;return e.forEach((r,o)=>{let i=t(r);i!==r&&(n??=[...e],n[o]=i)}),n??e}function Bh(e){if(!pe(e))return e;let t=Pt(e.axes,["axisColor"]),n=Array.isArray(e.curves)?Mt(e.curves,i=>!pe(i)||i.color===void 0||Me(i.color)?i:{...i,color:Xt}):e.curves,r=Array.isArray(e.points)?Mt(e.points,i=>Pt(i,["color"])):e.points,o=Array.isArray(e.fills)?Mt(e.fills,i=>Pt(i,["color"])):e.fills;return t===e.axes&&n===e.curves&&r===e.points&&o===e.fills?e:{...e,axes:t,curves:n,points:r,fills:o}}var Ic=["color","backgroundColor"],Ec=["fontFamily"];function Rh(e){if(!pe(e))return e;let t=Ah(e.grid),n=Pt(e.defaultCellStyle,Ic,Ec),r=Array.isArray(e.cells)?Mt(e.cells,Ih):e.cells;return t===e.grid&&n===e.defaultCellStyle&&r===e.cells?e:{...e,grid:t,defaultCellStyle:n,cells:r}}function Ah(e){if(!pe(e))return e;let t=e.borderColor!==void 0&&!Me(e.borderColor)?Xt:e.borderColor,n=Array.isArray(e.lineOverrides)?Mt(e.lineOverrides,r=>{if(!pe(r))return r;let o=Pt(r.style,["borderColor"]);return o===r.style?r:{...r,style:o}}):e.lineOverrides;return t===e.borderColor&&n===e.lineOverrides?e:{...e,borderColor:t,lineOverrides:n}}function Ih(e){if(!pe(e))return e;let t=Pt(e.style,Ic,Ec),n=Array.isArray(e.content)?Mt(e.content,Eh):e.content;return t===e.style&&n===e.content?e:{...e,style:t,content:n}}function Eh(e){if(!pe(e))return e;let t;for(let n of["children","label"]){let r=e[n];if(!Array.isArray(r))continue;let o=Mt(r,Cc);o!==r&&(t??={...e},t[n]=o)}return t??e}function Cc(e){return Pt(e,["color","backgroundColor"],["fontFamily"])}function qi(e){let n=Yn(e,Ph);n.props=Yn(e.props,Mh[e.type]),e.anchor&&(n.anchor=Nh(e.anchor));let r=n.props;return kh(e.type,r),(e.type==="text"||e.type==="callout")&&(r.richText=Ch(e.props.richText)),e.type==="arrow"?(r.start=rt(e.props.start),r.end=rt(e.props.end)):e.type==="line"?r.points=e.props.points.map(rt):e.type==="image"&&e.props.crop?r.crop={topLeft:rt(e.props.crop.topLeft),bottomRight:rt(e.props.crop.bottomRight)}:e.type==="callout"&&(r.tail={baseStart:rt(e.props.tail.baseStart),baseEnd:rt(e.props.tail.baseEnd),tip:rt(e.props.tail.tip)}),Th(n)}function Zi(e){return Xn(e)&&ac(e.props.src)}function Ji(e){let t=Yn(e.props,["w","h","name","isAnimated","mimeType","src","fileSize","storage"]);return e.props.storage&&(t.storage={kind:"remote-asset",storageKey:e.props.storage.storageKey,assetId:e.props.storage.assetId}),t.src=Hn(e.props.src)??"",{id:e.id,type:"image",props:t}}function Ch(e){return{blocks:e.blocks.map(t=>({...Yn(t,["type","level","align","lineHeight"]),children:t.children.map(Lh)}))}}function Lh(e){let t=e.type==="text"?["type","text","marks","color","backgroundColor","fontFamily","fontSize","boxedPaddingY","boxedVariant","boxedTone"]:["type","id","tex","display","marks","color","backgroundColor","fontFamily","fontSize","boxedPaddingY","boxedVariant","boxedTone","semanticRole","altText"];return Cc(Yn(e,t))}function Nh(e){return e.type==="block"?{type:"block",blockId:e.blockId,dy:e.dy,...e.dx===void 0?{}:{dx:e.dx},...e.line===void 0?{}:{line:{index:e.line.index,dy:e.line.dy}},...e.reserveSpace===void 0?{}:{reserveSpace:e.reserveSpace}}:e.type==="shape"?{type:"shape",shapeId:e.shapeId,dx:e.dx,dy:e.dy,...e.rx===void 0?{}:{rx:e.rx},...e.ry===void 0?{}:{ry:e.ry}}:{type:"page"}}function rt(e){return{x:e.x,y:e.y}}function Qi(e){let t=Wn(e.extensions)?{...e.extensions}:{},n=Object.fromEntries(e.shapes.flatMap(o=>pe(o)&&eo(o.meta)&&Bc(o.meta)?[[typeof o.id=="string"?o.id:`index:${e.shapes.indexOf(o)}`,o.meta]]:[])),r=Object.fromEntries(Object.entries(e.assets).flatMap(([o,i])=>pe(i)&&eo(i.meta)&&Bc(i.meta)?[[o,i.meta]]:[]));return(Object.keys(n).length>0||Object.keys(r).length>0)&&(t[vh]={...Object.keys(n).length>0?{shapes:n}:{},...Object.keys(r).length>0?{assets:r}:{}}),Object.keys(t).length>0?t:void 0}function Yn(e,t){return Object.fromEntries(t.flatMap(n=>e[n]===void 0?[]:[[n,e[n]]]))}function eo(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(eo):pe(e)&&Object.values(e).every(eo)}function Bc(e){return!pe(e)||Object.keys(e).length>0}function pe(e){return typeof e=="object"&&e!==null}function Lc(e){let t=new Map,n=e.map(r=>{if(r.type!=="graph2dShape"||r.props.boundsMode==="plot")return r;let o=Un(r);return t.set(r.id,{previous:r,next:o,dx:o.x-r.x,dy:o.y-r.y}),o});return t.size===0?n:n.map(r=>{let o=r.anchor;if(o?.type!=="shape")return r;let i=t.get(r.id),a=t.get(o.shapeId);if(!i&&!a)return r;if(!a)return{...r,anchor:{...o,dx:o.dx+(i?.dx??0),dy:o.dy+(i?.dy??0)}};let s=a.previous,c=a.next,l=o.rx===void 0?s.x:s.x+s.props.w*o.rx,d=o.ry===void 0?s.y:s.y+s.props.h*o.ry,u=o.rx===void 0?c.x:c.x+c.props.w*o.rx,m=o.ry===void 0?c.y:c.y+c.props.h*o.ry;return{...r,anchor:{...o,dx:l+o.dx+(i?.dx??0)-u,dy:d+o.dy+(i?.dy??0)-m}}})}var Qt=96/25.4,to={A4:{widthMm:210,heightMm:297},A3:{widthMm:297,heightMm:420},B5:{widthMm:182,heightMm:257},B4:{widthMm:257,heightMm:364}},no=to.A4,Jt={top:18,right:17,bottom:18,left:17},Fh={type:"columns",columnCount:1,columnGapMm:8},ro=30,$c={enabled:!1,heightMm:8,offsetMm:5,showOnFirstPage:!0,blocks:[{type:"paragraph",id:"page_header_running_body",children:[{type:"text",text:"{title}"}]}]},zc={enabled:!1,heightMm:8,offsetMm:5,showOnFirstPage:!0,blocks:[{type:"paragraph",id:"page_footer_running_body",children:[{type:"text",text:"{page}"}],align:"center"}]},na={width:ne(no.widthMm),height:ne(no.heightMm)},XB={width:ne(no.widthMm-Jt.left-Jt.right),height:ne(no.heightMm-Jt.top-Jt.bottom)},ra=36;function ne(e){return e*Qt}function Hc(e,t,n){let r=e==="custom"?{widthMm:Kn(n?.widthMm,to.A4.widthMm),heightMm:Kn(n?.heightMm,to.A4.heightMm)}:to[e];return t==="landscape"?{widthMm:Math.max(r.widthMm,r.heightMm),heightMm:Math.min(r.widthMm,r.heightMm)}:{widthMm:Math.min(r.widthMm,r.heightMm),heightMm:Math.max(r.widthMm,r.heightMm)}}function Uc(){return{preset:"A4",orientation:"portrait",pageSize:Hc("A4","portrait"),marginsMm:{...Jt},flow:{...Fh},header:Dc($c),footer:Dc(zc)}}function en(e){let t=Uc(),n=$h(e?.preset)?e.preset:t.preset,r=zh(e?.orientation)?e.orientation:t.orientation,o=n==="custom"?e?.pageSize:void 0,i=Hc(n,r,o),a=Hh(e?.flow?.columnCount,1,4,t.flow.columnCount),s=Ee(e?.flow?.columnGapMm,t.flow.columnGapMm);return{preset:n,orientation:r,pageSize:i,marginsMm:{top:Ee(e?.marginsMm?.top,t.marginsMm.top),right:Ee(e?.marginsMm?.right,t.marginsMm.right),bottom:Ee(e?.marginsMm?.bottom,t.marginsMm.bottom),left:Ee(e?.marginsMm?.left,t.marginsMm.left)},flow:{type:"columns",columnCount:a,columnGapMm:s},header:Nc(e?.header,$c),footer:Nc(e?.footer,zc),overlay:eu(e?.overlay)}}function io(e=Uc()){let t=en(e),n=Math.max(0,t.pageSize.widthMm-t.marginsMm.left-t.marginsMm.right),r=Math.max(0,t.pageSize.heightMm-t.marginsMm.top-t.marginsMm.bottom),o=t.flow.columnGapMm*Math.max(0,t.flow.columnCount-1),i=t.flow.columnCount>0?Math.max(0,(n-o)/t.flow.columnCount):n;return{page:{widthMm:t.pageSize.widthMm,heightMm:t.pageSize.heightMm,widthPx:ne(t.pageSize.widthMm),heightPx:ne(t.pageSize.heightMm)},margins:{topPx:ne(t.marginsMm.top),rightPx:ne(t.marginsMm.right),bottomPx:ne(t.marginsMm.bottom),leftPx:ne(t.marginsMm.left)},content:{widthMm:n,heightMm:r,widthPx:ne(n),heightPx:ne(r)},flow:{columnCount:t.flow.columnCount,columnGapMm:t.flow.columnGapMm,columnGapPx:ne(t.flow.columnGapMm),columnWidthMm:i,columnWidthPx:ne(i)}}}function oa(e){let t=en(e),n={...t.marginsMm};return t.header?.enabled&&(n.top=Math.max(n.top,t.header.offsetMm+t.header.heightMm)),t.footer?.enabled&&(n.bottom=Math.max(n.bottom,t.footer.offsetMm+t.footer.heightMm)),{...t,marginsMm:n}}function Vc(e){let t=[],n=io(e);return(!Number.isFinite(e.pageSize.widthMm)||!Number.isFinite(e.pageSize.heightMm)||e.pageSize.widthMm<=0||e.pageSize.heightMm<=0)&&t.push("\u7528\u7D19\u30B5\u30A4\u30BA\u306F0\u3088\u308A\u5927\u304D\u3044\u5024\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),(!Number.isFinite(e.marginsMm.top)||!Number.isFinite(e.marginsMm.right)||!Number.isFinite(e.marginsMm.bottom)||!Number.isFinite(e.marginsMm.left)||e.marginsMm.top<0||e.marginsMm.right<0||e.marginsMm.bottom<0||e.marginsMm.left<0)&&t.push("\u4F59\u767D\u306F0\u4EE5\u4E0A\u306E\u5024\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),e.marginsMm.left+e.marginsMm.right>=e.pageSize.widthMm&&t.push("\u5DE6\u53F3\u306E\u4F59\u767D\u304C\u7528\u7D19\u5E45\u4EE5\u4E0A\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002"),e.marginsMm.top+e.marginsMm.bottom>e.pageSize.heightMm-ro&&t.push(`\u4E0A\u4E0B\u306E\u4F59\u767D\u306F\u672C\u6587\u3092${ro}mm\u4EE5\u4E0A\u6B8B\u3059\u3088\u3046\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`),(!Number.isInteger(e.flow.columnCount)||e.flow.columnCount<1||e.flow.columnCount>4)&&t.push("\u6BB5\u6570\u306F1\u304B\u30894\u306E\u6574\u6570\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),(!Number.isFinite(e.flow.columnGapMm)||e.flow.columnGapMm<0)&&t.push("\u6BB5\u9593\u306F0\u4EE5\u4E0A\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),e.flow.columnGapMm*Math.max(0,e.flow.columnCount-1)>=n.content.widthMm&&t.push("\u6BB5\u9593\u304C\u672C\u6587\u5E45\u4EE5\u4E0A\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002"),t}function Wc(e){return!!(e?.blocks.some(ru)||Wh(e?.overlay))}function ot(e,t=54){if(e.type==="section")return 64;if(e.type==="heading")return 48+Math.max(0,e.level-1)*4+oo(e.children,t)*10;if(e.type==="paragraph")return 18+oo(e.children,t)*Jc(e.lineHeight);if(e.type==="list")return 12+Zc(e,t);if(e.type==="boxBlock"){let n=e.frame?.paddingPx;return(n?.top??12)+(n?.bottom??12)+Xc(e,t)+Math.max(24,Dh(e.blocks,Yc(t)))}if(e.type==="layoutSection"){let n=Number.isInteger(e.layout.columnCount)?Math.min(4,Math.max(1,e.layout.columnCount)):2,r=Math.max(12,Math.floor(t/n)),o=e.children.reduce((i,a)=>i+ot(a,r),0);return Math.max(32,Math.ceil(o/n))}return e.type==="problem"?Kc.reduce((n,r)=>n+jc(e,r,t),0):48}function Xc(e,t){return e.title&&e.title.length>0?oo(e.title,t)*18:0}function Yc(e){return Math.max(12,e-4)}var Kc=["lead","prompt","solution","hints"];function jc(e,t,n){return Math.max(_h(e[t],n),ne(e.areaLayout?.[t]?.minHeightMm??0))}function _h(e,t){return e.reduce((n,r)=>n+ot(r,t),0)}function Dh(e,t){return e.reduce((n,r)=>n+ot(r,t),0)}function qc(e,t,n=0){return oo(e.children,Gh(t,n))*Jc(void 0)}function Gh(e,t=0){return Math.max(8,e-t*4-3)}function Zc(e,t,n=0){return e.items.reduce((r,o)=>{let i=(o.nested??[]).reduce((a,s)=>a+Zc(s,t,n+1),0);return r+qc(o,t,n)+i},0)}function oo(e,t){let n=e.reduce((r,o)=>o.type==="text"?r+o.text.length:r+Math.max(4,o.tex.length),0);return Math.max(1,Math.ceil(n/t))}function Jc(e){let t=Number(e??"1.75");return 16*(Number.isFinite(t)?t:1.75)}function $h(e){return e==="A4"||e==="A3"||e==="B5"||e==="B4"||e==="custom"}function zh(e){return e==="portrait"||e==="landscape"}function Kn(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function Ee(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function Hh(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)))}function Nc(e,t){let n=Qc(e?.blocks);return{enabled:typeof e?.enabled=="boolean"?e.enabled:t.enabled,heightMm:Kn(e?.heightMm,t.heightMm),offsetMm:Ee(e?.offsetMm,t.offsetMm),showOnFirstPage:typeof e?.showOnFirstPage=="boolean"?e.showOnFirstPage:t.showOnFirstPage,blocks:n??t.blocks.map(tu),overlay:eu(e?.overlay)}}function Qc(e){return Array.isArray(e)?e.flatMap(n=>{if(!n||typeof n!="object"||!("type"in n))return[];if(n.type==="heading"&&Array.isArray(n.children)){let r=n.level===1||n.level===2||n.level===3?n.level:2;return[{type:"heading",id:typeof n.id=="string"&&n.id?n.id:"running_heading",level:r,children:ea(n.children),align:Gc(n.align),lineHeight:tt(n.lineHeight)}]}if(n.type==="paragraph"&&Array.isArray(n.children))return[{type:"paragraph",id:typeof n.id=="string"&&n.id?n.id:"running_paragraph",children:ea(n.children),align:Gc(n.align),lineHeight:tt(n.lineHeight)}];if(n.type==="list"&&(n.listType==="bullet"||n.listType==="ordered")&&Array.isArray(n.items)){let r=Uh(n.items);return r.length===0?[]:[{type:"list",id:typeof n.id=="string"&&n.id?n.id:"running_list",listType:n.listType,start:Kn(n.start,0)||void 0,markerStyle:n.listType==="ordered"?Fi(n.markerStyle):void 0,items:r}]}return[]}):void 0}function Uh(e){return e.flatMap(t=>{if(!Vh(t)||t.type!=="listItem"||!Array.isArray(t.children))return[];let n=Array.isArray(t.nested)?Qc(t.nested)?.filter(r=>r.type==="list"):void 0;return[{type:"listItem",id:typeof t.id=="string"&&t.id?t.id:"running_list_item",children:ea(t.children),...n&&n.length>0?{nested:n}:{}}]})}function Vh(e){return typeof e=="object"&&e!==null}function eu(e){if(!e||typeof e!="object")return;let t=e,n=t.overlaySnapshot?me(t.overlaySnapshot):void 0,r=typeof t.updatedAt=="string"?t.updatedAt:void 0;if(n)return{overlaySnapshot:n,...r?{updatedAt:r}:{}}}function Wh(e){return e?.overlaySnapshot?me(e.overlaySnapshot).shapes.some(t=>!t.hidden):!1}function ea(e){return e.flatMap(t=>{if(!t||typeof t!="object"||!("type"in t))return[];let n=t;if(t.type==="text"){let r=Fc(n.boxedVariant),o=_c(n.boxedTone);return[{type:"text",text:typeof n.text=="string"?n.text:"",marks:Xh(n.marks),color:typeof n.color=="string"?n.color:void 0,backgroundColor:typeof n.backgroundColor=="string"?n.backgroundColor:void 0,fontFamily:typeof n.fontFamily=="string"?n.fontFamily:void 0,fontSize:Kn(n.fontSize,0)||void 0,boxedPaddingY:Ee(n.boxedPaddingY,-1)>=0?Ee(n.boxedPaddingY,0):void 0,...r?{boxedVariant:r}:{},...o?{boxedTone:o}:{}}]}if(t.type==="mathInline"){let r=Yh(n.marks),o=Fc(n.boxedVariant),i=_c(n.boxedTone);return[{type:"mathInline",id:typeof n.id=="string"&&n.id?n.id:"running_math",tex:typeof n.tex=="string"?n.tex:"",display:"inline",...r?{marks:r}:{},...r?.includes("boxed")&&Ee(n.boxedPaddingY,-1)>=0?{boxedPaddingY:Ee(n.boxedPaddingY,0)}:{},...o?{boxedVariant:o}:{},...i?{boxedTone:i}:{},semanticRole:n.semanticRole==="equation"||n.semanticRole==="variable"?n.semanticRole:"expression"}]}return[]})}function Xh(e){if(!Array.isArray(e))return;let t=e.filter(n=>n==="bold"||n==="italic"||n==="underline"||n==="boxed");return t.length>0?Array.from(new Set(t)):void 0}function Yh(e){if(!Array.isArray(e))return;let t=e.filter(n=>n==="underline"||n==="boxed");return t.length>0?Array.from(new Set(t)):void 0}function Fc(e){return e==="frame"||e==="thick"||e==="double"||e==="oval"||e==="shade"?e:void 0}function _c(e){return e==="gray"||e==="blue"||e==="green"||e==="red"||e==="yellow"?e:void 0}function Dc(e){return{...e,blocks:e.blocks?.map(tu),overlay:Kh(e.overlay)}}function Kh(e){if(e)return{...e,overlaySnapshot:e.overlaySnapshot?me(e.overlaySnapshot):void 0}}function tu(e){return e.type==="heading"?{...e,children:e.children.map(ta)}:e.type==="paragraph"?{...e,children:e.children.map(ta)}:nu(e)}function nu(e){return{...e,items:e.items.map(t=>({...t,children:t.children.map(ta),nested:t.nested?.map(nu)}))}}function ta(e){return e.type==="mathInline"?{...e,...e.marks?{marks:[...e.marks]}:{}}:{...e,marks:e.marks?[...e.marks]:void 0}}function ru(e){return e.type==="list"?e.items.some(t=>t.children.some(n=>n.type==="mathInline"?n.tex.trim():n.text.trim())||(t.nested??[]).some(ru)):e.children.some(t=>t.type==="mathInline"?t.tex.trim():t.text.trim())}function Gc(e){return e==="left"||e==="center"||e==="right"||e==="justify"?e:void 0}function ou(e,t){return{heightPx:ne(t?.heightMm??0),widthPx:Math.max(0,e)}}function Tt(e){return e.map(t=>t.type==="text"?t.text:`$${t.tex}$`).join("")}var ag=2;function su(e,t,n,r){let o=sg(e);return lg(o.length>0?o:[e.getBoundingClientRect()]).map((a,s)=>({index:s,top:(a.top-t.top)*r,left:(a.left-t.left)*n,width:Math.max(0,(a.right-a.left)*n),height:Math.max(0,(a.bottom-a.top)*r)}))}function sg(e){let t=e.ownerDocument.createRange();try{return t.selectNodeContents(e),Array.from(t.getClientRects()).filter(n=>n.width>0&&n.height>0)}finally{t.detach()}}function lg(e){let t=[],n=[...e].sort((r,o)=>r.top-o.top||r.left-o.left);for(let r of n){let o=t.find(i=>cg(r,i));if(!o){t.push({top:r.top,right:r.right,bottom:r.bottom,left:r.left});continue}o.top=Math.min(o.top,r.top),o.right=Math.max(o.right,r.right),o.bottom=Math.max(o.bottom,r.bottom),o.left=Math.min(o.left,r.left)}return t.sort((r,o)=>r.top-o.top||r.left-o.left)}function cg(e,t){let n=(e.top+e.bottom)/2,r=(t.top+t.bottom)/2;if(Math.abs(n-r)<=ag)return!0;let o=Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top),i=Math.min(e.height,t.bottom-t.top);return o>Math.max(1,i*.45)}import{useMemo as Av}from"react";var ug=new Set(["newcommand","renewcommand","providecommand"]);function lu(e){let t=[],n={};if(e.length>2e4)return{issues:[{line:1,message:`\u30D7\u30EA\u30A2\u30F3\u30D6\u30EB\u306F${2e4.toLocaleString()}\u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`}],macros:n};let r=0;for(;r<e.length&&(r=ao(e,r),!(r>=e.length));){let o=r,i=ia(e,r);if(!i){t.push({line:Ce(e,r),message:"\u3053\u306E\u884C\u306FTeX\u30B3\u30DE\u30F3\u30C9\u306E\u5B9A\u7FA9\u3068\u3057\u3066\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093\u3002"}),r=Xe(e,r);continue}if(r=i.end,!ug.has(i.name)){t.push({line:Ce(e,o),message:`\\${i.name}\u306B\u306F\u307E\u3060\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002\\newcommand\u3001\\renewcommand\u3001\\providecommand\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002`}),r=Xe(e,r);continue}r=ao(e,r);let a=dg(e,r);if(!a){t.push({line:Ce(e,o),message:"\u5B9A\u7FA9\u3059\u308B\u30B3\u30DE\u30F3\u30C9\u540D\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}),r=Xe(e,r);continue}r=ao(e,a.end);let s=0;if(e[r]==="["){let d=pg(e,r);if(!d||!/^\d+$/.test(d.value.trim())){t.push({line:Ce(e,o),message:"\u5F15\u6570\u306E\u6570\u306F0\u304B\u30899\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}),r=Xe(e,r);continue}if(s=Number(d.value.trim()),s<0||s>9){t.push({line:Ce(e,o),message:"\u5F15\u6570\u306E\u6570\u306F0\u304B\u30899\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}),r=Xe(e,r);continue}if(r=ao(e,d.end),e[r]==="["){t.push({line:Ce(e,o),message:"\u7701\u7565\u53EF\u80FD\u306A\u5F15\u6570\u306B\u306F\u307E\u3060\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002"}),r=Xe(e,r);continue}}let c=cu(e,r);if(!c){t.push({line:Ce(e,o),message:"\u5C55\u958B\u5185\u5BB9\u3092\u6CE2\u62EC\u5F27\u3067\u9589\u3058\u3066\u304F\u3060\u3055\u3044\u3002"}),r=Xe(e,r);continue}r=c.end;let l=n[a.name];if(i.name==="newcommand"&&l){t.push({line:Ce(e,o),message:`\\${a.name}\u306F\u3059\u3067\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059\u3002`});continue}if(i.name==="renewcommand"&&!l){t.push({line:Ce(e,o),message:`\\${a.name}\u306F\u307E\u3060\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002`});continue}if(!(i.name==="providecommand"&&l)){if(!l&&Object.keys(n).length>=100){t.push({line:Ce(e,o),message:"\u72EC\u81EA\u30B3\u30DE\u30F3\u30C9\u306F100\u4EF6\u307E\u3067\u5B9A\u7FA9\u3067\u304D\u307E\u3059\u3002"});continue}n[a.name]={args:s,def:c.value}}}return{issues:t,macros:n}}function ao(e,t){let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n+=1;continue}if(e[n]==="%"&&e[n-1]!=="\\"){n=Xe(e,n);continue}break}return n}function Xe(e,t){let n=e.indexOf(`
|
|
7
|
+
`)}function Bf(e){return e.reduce((t,n)=>t+(n.kind==="text"?Al(n.text):n.metrics.widthEm),0)}function Rf(e,t){let n=Cn,r=Ln;for(let o of e)o.kind==="math"&&(n=Math.max(n,o.metrics.ascentEm),r=Math.max(r,o.metrics.descentEm));return Math.ceil(t*Math.max(Ie,n+r))}function Af(e,t,n){let r=e.flatMap(u=>u.kind==="math"?[{widthEm:u.metrics.widthEm,ascentEm:u.metrics.ascentEm,descentEm:u.metrics.descentEm,isMathAtom:!0}]:Array.from(u.text).map(m=>({widthEm:Il(m),ascentEm:Cn,descentEm:Ln,isMathAtom:!1})));if(r.length===0)return{heightPx:Math.ceil(n*Ie),wrapped:!1,widestMathAtomUnits:0};let o=0,i=!1,a=0,s=0,c=Cn,l=Ln,d=()=>{o+=Math.ceil(n*Math.max(Ie,c+l))};for(let u of r)u.isMathAtom&&(a=Math.max(a,u.widthEm)),s>0&&s+u.widthEm>t?(d(),i=!0,s=u.widthEm,c=Math.max(Cn,u.ascentEm),l=Math.max(Ln,u.descentEm)):(s+=u.widthEm,c=Math.max(c,u.ascentEm),l=Math.max(l,u.descentEm));return d(),{heightPx:o,wrapped:i,widestMathAtomUnits:a}}function Al(e){let t=0;for(let n of e)t+=Il(n);return t}function Il(e){if(/\s/u.test(e))return .35;let t=e.codePointAt(0)??0;return t>=4352&&t<=4607||t>=11904&&t<=42191||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519?1:/[+\-*/=<>()[\]{}^_,.;:|]/u.test(e)?.45:.58}function If(e,t){return Number.isFinite(e)&&e>0?e:t}function Ef(e){return e!==void 0&&Number.isFinite(e)&&e>0?e:void 0}var El=new WeakMap;function Bi(e,t,n){let r=El.get(e);r||(r=new Map,El.set(e,r));let o=r.get(t);if(o)return o;let i=n();return r.set(t,i),i}function Cl(e,t){let n=ze(e),r=`content|${n}|${t??""}`;return Bi(e.props.richText,r,()=>{let o=Nn({richText:e.props.richText,fontSizePx:n,maxWidthPx:t});return{w:o.w,h:o.h}})}function Ri(e){let t=ze(e),n=e.props.w,r=typeof e.props.h=="number"&&Number.isFinite(e.props.h)?e.props.h:void 0,o=e.props.autoSize,i=e.props.maxWidth,a=o?i:Math.max(En,n),s=`effective|${o?"auto":"fixed"}|${t}|${a??""}|${n}|${r??""}`;return Bi(e.props.richText,s,()=>{let c=Cl(e,a),l=Cf(e),d=o&&i!==void 0?i:Math.max(En,n),u=Math.max(r??0,l,c.h);return{w:d,h:u}})}function Ue(e){let t=Math.max(1,e.props.w),n=ze(e),r=`calloutBody|${t}|${e.props.h}|${n}`;return Bi(e.props.richText,r,()=>{let o=Math.max(1,t-2*He),i=Cl(e,o),a=Math.max(e.props.h,i.h+2*He);return{w:t,h:a}})}function Gr(e){let t=Ue(e);return{x:He,y:He,w:Math.max(1,t.w-2*He),h:Math.max(1,t.h-2*He)}}function Cf(e){let t=ht(e);return Math.max(t,Pi(e.props.richText)*t)}var Ai=1,Lf=12;var jO=1-Math.SQRT1_2,zl=18;function _n(e){let{w:t,h:n}=Ue(e),r=Vt(e),{baseStart:o,baseEnd:i,tip:a,radius:s}=r,c=_l(i,o,t,n),l=_l(o,i,t,n);return c>=l?[`M ${Je(o)}`,`L ${Je(a)}`,`L ${Je(i)}`,...Nl(i,o,t,n,s),"Z"].join(" "):[`M ${Je(i)}`,`L ${Je(a)}`,`L ${Je(o)}`,...Nl(o,i,t,n,s),"Z"].join(" ")}function Ll(e,t,n){return t<=0||n===t||e<=0?e:e>=t?e+(n-t):e*n/t}function $r(e,t){let n=e.props.w,r=e.props.h,{w:o,h:i}=Ue(e);return{x:Ll(t.x,n,o),y:Ll(t.y,r,i)}}function zr(e,t,n){let{w:r,h:o}=Ue(e),i=Ff(t,n,r,o);return Nf(e,i,t,n)}function Nf(e,t,n,r){let{w:o,h:i}=Ue(e),a=Ii(e);return t==="top"?{x:Fn(n,a,o-a),y:0,side:t}:t==="right"?{x:o,y:Fn(r,a,i-a),side:t}:t==="bottom"?{x:Fn(n,a,o-a),y:i,side:t}:{x:0,y:Fn(r,a,i-a),side:t}}function Vt(e){let{tail:t}=e.props,{w:n,h:r}=Ue(e),o=Ii(e),i=$r(e,t.baseStart),a=$r(e,t.baseEnd),s=$r(e,t.tip),c=zr(e,i.x,i.y),l=zr(e,a.x,a.y),d={x:$l(s.x,n*.14),y:$l(s.y,r+28)},u=Math.min(0,c.x,l.x,d.x),m=Math.min(0,c.y,l.y,d.y),h=Math.max(n,c.x,l.x,d.x),y=Math.max(r,c.y,l.y,d.y);return{body:{left:0,top:0,right:n,bottom:r},radius:o,baseStart:c,baseEnd:l,tip:d,bounds:{x:u,y:m,w:Math.max(Ai,h-u),h:Math.max(Ai,y-m)}}}function Ii(e){let{w:t,h:n}=Ue(e);return Hl(e.props.radius,t,n)}function Hl(e,t,n){let r=Math.max(0,(Math.min(t,n)-Lf)/2);return Fn(Number.isFinite(e)?e:zl,0,r)}function Ff(e,t,n,r){return[["top",Math.abs(t)],["right",Math.abs(n-e)],["bottom",Math.abs(r-t)],["left",Math.abs(e)]].reduce((i,a)=>a[1]<i[1]?a:i)[0]}function Nl(e,t,n,r,o){let i=["top","right","bottom","left"],a=i.indexOf(e.side),s=[];for(let c=0;c<5;c+=1){let l=i[a];if(l===t.side&&Fl(t,n,r)>=Fl(c===0?e:_f(l,n,r,o),n,r))return s.push(`L ${Je(t)}`),s;s.push(...Df(l,n,r,o)),a=(a+1)%i.length}return s.push(`L ${Je(t)}`),s}function _f(e,t,n,r){return e==="top"?{x:r,y:0,side:e}:e==="right"?{x:t,y:r,side:e}:e==="bottom"?{x:t-r,y:n,side:e}:{x:0,y:n-r,side:e}}function Fl(e,t,n){return e.side==="top"?e.x:e.side==="right"?e.y:e.side==="bottom"?t-e.x:n-e.y}function Df(e,t,n,r){return e==="top"?[`L ${t-r} 0`,`Q ${t} 0 ${t} ${r}`]:e==="right"?[`L ${t} ${n-r}`,`Q ${t} ${n} ${t-r} ${n}`]:e==="bottom"?[`L ${r} ${n}`,`Q 0 ${n} 0 ${n-r}`]:[`L 0 ${r}`,`Q 0 0 ${r} 0`]}function _l(e,t,n,r){let o=Math.max(Ai,(n+r)*2),a=((Dl(t,n,r)-Dl(e,n,r))%o+o)%o;return a===0?o:a}function Dl(e,t,n){return e.side==="top"?e.x:e.side==="right"?t+e.y:e.side==="bottom"?t+n+(t-e.x):t*2+n+(n-e.y)}function Je(e){return`${Gl(e.x)} ${Gl(e.y)}`}function Gl(e){return Math.round(e*1e3)/1e3}function $l(e,t){return Number.isFinite(e)?e:t}function Fn(e,t,n){return n<t?(t+n)/2:Math.min(n,Math.max(t,e))}var Ul=10,Hr=.5;function de(e){if(e.type==="graph2dShape"){if(e.props.boundsMode==="plot")return{x:e.x,y:e.y,w:e.props.w,h:e.props.h};let t=Ge(e);return{x:t.renderBounds.x+t.plotBox.left*t.scaleX,y:t.renderBounds.y+t.plotBox.top*t.scaleY,w:Math.max(1,e.props.w-(t.plotBox.left+t.plotBox.right)*t.scaleX),h:Math.max(1,e.props.h-(t.plotBox.top+t.plotBox.bottom)*t.scaleY)}}if(e.type==="group"||e.type==="geo"||e.type==="image"||e.type==="tableShape")return{x:e.x,y:e.y,w:e.props.w,h:e.props.h};if(e.type==="callout"){let t=Vt(e).bounds;return{x:e.x+t.x,y:e.y+t.y,w:t.w,h:t.h}}if(e.type==="arc"){let{rx:t,ry:n}=ce(e);return{x:e.x,y:e.y,w:t*2,h:n*2}}if(e.type==="text"){let t=Ri(e);return{x:e.x,y:e.y,w:t.w,h:t.h}}return e.type==="arrow"?Ur(e.x,e.y,[e.props.start,e.props.end],Ul):e.type==="line"?Ur(e.x,e.y,e.props.points,Ul):{x:0,y:0,w:1,h:1}}function Vr(e){return de(e)}function Ei(e){return e.type==="graph2dShape"?Vr(e):e.type==="arrow"?Ur(e.x,e.y,[e.props.start,e.props.end],0):e.type==="line"?Ur(e.x,e.y,e.props.points,0):de(e)}function ve(e){return e.type==="tableShape"||e.type==="group"?0:typeof e.rotation=="number"&&Number.isFinite(e.rotation)?e.rotation:0}function ce(e){let t=Math.max(Hr,e.props.r),n=typeof e.props.rx=="number"&&Number.isFinite(e.props.rx)?Math.max(Hr,e.props.rx):t,r=typeof e.props.ry=="number"&&Number.isFinite(e.props.ry)?Math.max(Hr,e.props.ry):t;return{rx:n,ry:r}}function Ur(e,t,n,r){if(n.length===0)return{x:e,y:t,w:1,h:1};let o=n.map(d=>e+d.x),i=n.map(d=>t+d.y),a=Math.min(...o),s=Math.min(...i),c=Math.max(...o),l=Math.max(...i);return{x:a-r,y:s-r,w:Math.max(1,c-a+r*2),h:Math.max(1,l-s+r*2)}}var Hf=1122.5196850393702,Uf=36,Wr=Hf+Uf;function Ci(e,t,n={}){let r=jf(Array.from(t.values())),o=e.map(i=>Vf(i,t,r,n));return Wt(o)}function Wt(e){let t=new Map(e.map(s=>[s.id,s])),n=new Map,r=new Set,o=s=>{let c=n.get(s.id);if(c)return c;if(s.anchor?.type!=="shape")return n.set(s.id,s),s;let l=t.get(s.anchor.shapeId);if(!l||l.id===s.id||r.has(s.id))return n.set(s.id,s),s;r.add(s.id);let d=o(l);r.delete(s.id);let u=Yf(s.anchor,d),m=u.x===s.x&&u.y===s.y?s:{...s,x:u.x,y:u.y};return n.set(s.id,m),m},i=!1,a=e.map(s=>{let c=o(s);return i||=c!==s,c});return i?a:e}function Vf(e,t,n,r){if(e.anchor?.type!=="block")return e;let o=t.get(e.anchor.blockId);if(!o)return e;let i=Xf(e.anchor,o,n),a=i?.block??o,s=Wf(e.anchor,r),c=typeof e.anchor.dx=="number"&&typeof a.left=="number"?a.left+e.anchor.dx:e.x,l=i===void 0||!e.anchor.line?o.top-s+e.anchor.dy:i.line.top-s+e.anchor.line.dy;return c===e.x&&l===e.y?e:{...e,x:c,y:l}}function Wf(e,t){if(e.reserveSpace!==!0)return 0;let n=t[e.blockId];return typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):0}function Xf(e,t,n){if(!e.line||!t.lines?.length)return;let r=t.lines.find(a=>a.index===e.line?.index);if(r)return{block:t,line:r};let o=e.line.index-t.lines.length;if(o<0)return;let i=n.findIndex(a=>a.id===t.id);if(!(i<0))for(let a of n.slice(i+1)){if(a.containerId!==t.containerId||!Xl(t,a))continue;let s=a.lines??[];if(o<s.length)return{block:a,line:s[o]};o-=s.length}}function Yf(e,t){let n=Kf(t),r=typeof e.rx=="number"?n.x+n.w*e.rx:t.x,o=typeof e.ry=="number"?n.y+n.h*e.ry:t.y;return{x:r+e.dx,y:o+e.dy}}function Kf(e){if(e.type==="group"||e.type==="geo"||e.type==="image"||e.type==="callout"||e.type==="graph2dShape"||e.type==="tableShape")return{x:e.x,y:e.y,w:e.props.w,h:e.props.h};if(e.type==="arc"){let t=Math.max(.5,e.props.r),n=typeof e.props.rx=="number"&&Number.isFinite(e.props.rx)?Math.max(.5,e.props.rx):t,r=typeof e.props.ry=="number"&&Number.isFinite(e.props.ry)?Math.max(.5,e.props.ry):t;return{x:e.x,y:e.y,w:n*2,h:r*2}}if(e.type==="text"){let t=typeof e.props.h=="number"&&Number.isFinite(e.props.h)?Math.max(1,e.props.h):1;return{x:e.x,y:e.y,w:Math.max(8,e.props.w),h:t}}return e.type==="arrow"?Vl(e.x,e.y,[e.props.start,e.props.end],10):Vl(e.x,e.y,e.props.points,10)}function Vl(e,t,n,r){if(n.length===0)return{x:e,y:t,w:1,h:1};let o=n.map(d=>e+d.x),i=n.map(d=>t+d.y),a=Math.min(...o),s=Math.min(...i),c=Math.max(...o),l=Math.max(...i);return{x:a-r,y:s-r,w:Math.max(1,c-a+r*2),h:Math.max(1,l-s+r*2)}}function Xl(e,t){if(e.left===void 0||t.left===void 0)return!0;let n=e.width??0,r=t.width??0,o=Math.max(4,Math.min(n||0,r||0)*.08);return Math.abs(e.left-t.left)<=o}function jf(e,t=Jf(e)){return t.length<=1?[...e].sort((n,r)=>n.top-r.top):e.map((n,r)=>({block:n,index:r})).sort((n,r)=>qf(Wl(n.block,n.index,t),Wl(r.block,r.index,t))).map(n=>n.block)}function Wl(e,t,n){let r=Zf(e.top);return{page:r.page,column:Qf(e,n)??0,localY:r.localY,top:e.top,index:t}}function qf(e,t){return e.page-t.page||e.column-t.column||e.localY-t.localY||e.top-t.top||e.index-t.index}function Zf(e){let t=Math.max(0,Math.floor((e+.5)/Wr));return{page:t,localY:e-t*Wr}}function Jf(e){let t=[];for(let n of e){if(typeof n.left!="number"||typeof n.width!="number")continue;let r=t.find(o=>Xl(o.representative,n));if(r){r.left=Math.min(r.left,n.left),r.right=Math.max(r.right,n.left+n.width),r.blockIds.add(n.id);continue}t.push({representative:n,left:n.left,right:n.left+n.width,blockIds:new Set([n.id])})}return t.sort((n,r)=>n.left-r.left).map((n,r)=>({index:r,left:n.left,right:n.right,center:(n.left+n.right)/2,blockIds:n.blockIds}))}function Qf(e,t){return t.find(n=>n.blockIds.has(e.id))?.index}function Me(e){return e??"polyline"}function Ve(e,t,n){return Me(e)==="polyline"&&n===!0&&t.length>=3}function zn(e,t,n){if(e.length===0)return"";let r=ty(Ni(e,t),n,Me(t)!=="polyline");return r.length===0?`M ${Dn(e[0])}`:ey(r)}function Yr(e,t){return Ni(e,t).reduce((n,r)=>n+Math.hypot(r.to.x-r.from.x,r.to.y-r.from.y),0)}function jl(e,t){let n=Ni(e,t);if(n.length===0)return{start:0,end:0};if(Me(t)!=="polyline"){let r=Yr(e,t);return{start:r,end:r}}return{start:Gn(n[0]),end:Gn(n[n.length-1])}}function Xt(e,t,n){if(e.length<2)return[...e];let r=[...e],o=r.length-1;return r[0]=Yl(r[0],r[1],t),r[o]=Yl(r[o],r[o-1],n),r}function Yl(e,t,n){if(!Number.isFinite(n)||n<=0)return e;let r=t.x-e.x,o=t.y-e.y,i=Math.hypot(r,o);if(!Number.isFinite(i)||i<=0)return e;let a=Math.min(n,i*ql);return{x:e.x+r/i*a,y:e.y+o/i*a}}var ql=.9;function gt(e){return e.map(t=>`${t.x},${t.y}`).join(" ")}function Li(e){return e.length===0?null:e[Math.floor(e.length/2)]}function Ni(e,t){if(e.length<2)return[];if(Me(t)==="polyline"||e.length<3){let o=[];for(let i=1;i<e.length;i+=1)o.push({kind:"line",from:e[i-1],to:e[i]});return o}if(e.length===3)return[{kind:"quad",from:e[0],control:e[1],to:e[2]}];let n=[],r=e[0];for(let o=1;o<e.length-1;o+=1){let i=e[o],a=e[o+1],s={x:(i.x+a.x)/2,y:(i.y+a.y)/2};n.push({kind:"quad",from:r,control:i,to:s}),r=s}return n.push({kind:"line",from:r,to:e[e.length-1]}),n}function ey(e){let t=[`M ${Dn(e[0].from)}`];for(let n of e)t.push(n.kind==="quad"?`Q ${Dn(n.control)} ${Dn(n.to)}`:`L ${Dn(n.to)}`);return t.join(" ")}function ty(e,t,n){return!t||e.length===0?e:ry(ny(e,t.start,n),t.end,n)}function ny(e,t,n){let r=t;if(!Number.isFinite(r)||r<=0)return e;let o=0;for(;o<e.length;){let i=e[o],a=Gn(i),s=o===e.length-1;if(!n||s||r<a){let c=n&&!s?r:Zl(r,a);return c<=0?e.slice(o):[ec(i,Ql(i,c)).tail,...e.slice(o+1)]}r-=a,o+=1}return e}function ry(e,t,n){let r=t;if(!Number.isFinite(r)||r<=0)return e;let o=e.length-1;for(;o>=0;){let i=e[o],a=Gn(i),s=o===0;if(!n||s||r<a){let c=n&&!s?r:Zl(r,a);if(c<=0)return e.slice(0,o+1);let l=ec(i,Ql(i,a-c)).head;return[...e.slice(0,o),l]}r-=a,o-=1}return e}function Zl(e,t){return!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?0:Math.min(e,t*ql)}function Gn(e){return e.kind==="line"?Math.hypot(e.to.x-e.from.x,e.to.y-e.from.y):Jl(e)[$n]}function Jl(e){let t=[0],n=e.from;for(let r=1;r<=$n;r+=1){let o=oy(e,r/$n);t.push(t[r-1]+Math.hypot(o.x-n.x,o.y-n.y)),n=o}return t}function Ql(e,t){let n=Gn(e);if(!Number.isFinite(n)||n<=0)return 0;if(e.kind==="line")return Math.min(1,Math.max(0,t/n));let r=Jl(e);for(let o=1;o<=$n;o+=1)if(r[o]>=t){let i=r[o]-r[o-1],a=i>0?(t-r[o-1])/i:0;return(o-1+a)/$n}return 1}function ec(e,t){if(e.kind==="line"){let i=Xr(e.from,e.to,t);return{head:{kind:"line",from:e.from,to:i},tail:{kind:"line",from:i,to:e.to}}}let n=Xr(e.from,e.control,t),r=Xr(e.control,e.to,t),o=Xr(n,r,t);return{head:{kind:"quad",from:e.from,control:n,to:o},tail:{kind:"quad",from:o,control:r,to:e.to}}}function oy(e,t){let n=1-t;return{x:n*n*e.from.x+2*n*t*e.control.x+t*t*e.to.x,y:n*n*e.from.y+2*n*t*e.control.y+t*t*e.to.y}}function Xr(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}var $n=64;function Dn(e){return`${Kl(e.x)} ${Kl(e.y)}`}function Kl(e){return Number(e.toFixed(2)).toString()}var Fi={start:Mr,end:Mr},_i=128;function We(e){if(!iy(e))return Fi;if(e.type==="arrow"){let t=[e.props.start,e.props.end],n=Yr(t,"polyline");return Pr(e.props.arrowheadStart,e.props.arrowheadEnd,re(e.props.size),n,{start:n,end:n})}if(e.type==="line"){let t=Me(e.props.kind);return Ve(t,e.props.points,e.props.closed)?Fi:Pr(e.props.arrowheadStart,e.props.arrowheadEnd,re(e.props.size),Yr(e.props.points,t),jl(e.props.points,t))}if(e.type==="arc"){let t=re(e.props.size),n=ac(e);return Pr(e.props.arrowheadStart,e.props.arrowheadEnd,t,n.total,{start:n.total,end:n.total},{start:nc(n,"start",tc(e.props.arrowheadStart,t),t),end:nc(n,"end",tc(e.props.arrowheadEnd,t),t)})}return Fi}function iy(e){return e.type==="arrow"?Yt(e.props.arrowheadStart)||Yt(e.props.arrowheadEnd):e.type==="line"?Ve(Me(e.props.kind),e.props.points,e.props.closed)?!1:Yt(e.props.arrowheadStart)||Yt(e.props.arrowheadEnd):e.type==="arc"?e.props.kind!=="sector"&&(Yt(e.props.arrowheadStart)||Yt(e.props.arrowheadEnd)):!1}function Yt(e){return typeof e=="string"&&e!=="none"}function tc(e,t){return Us(e)*Math.max(0,t)}function nc(e,t,n,r){if(!(n>0)||!(r>0)||e.total<=0)return 0;let o=Math.min(n,e.total),i=t==="start"?0:e.total-o,a=t==="start"?o:e.total,s=Number.POSITIVE_INFINITY;for(let l=0;l<e.cumulative.length;l+=1){let d=e.cumulative[l];d<i||d>a||(s=Math.min(s,e.curvatureRadius[l]))}if(!Number.isFinite(s))return 0;let c=Math.sqrt(Math.max(0,s)*r);return Number.isFinite(c)?c:0}function Kr(e){return{start:e.start.trimPx,end:e.end.trimPx}}function jr(e){let{startAngle:t,endAngle:n}=e.props,r=We(e);if(r.start.trimPx<=0&&r.end.trimPx<=0)return{startAngle:t,endAngle:n};let o=ac(e);return o.total<=0?{startAngle:t,endAngle:n}:{startAngle:ic(o,r.start.trimPx),endAngle:ic(o,o.total-r.end.trimPx)}}var rc=new WeakMap;function ac(e){let t=rc.get(e);if(t)return t;let n=ay(e);return rc.set(e,n),n}function ay(e){let{rx:t,ry:n}=ce(e),{startAngle:r}=e.props,o=Se(e.props.endAngle-r);if(!Number.isFinite(o)||o<=0)return{startAngle:r,step:0,cumulative:[0],curvatureRadius:[0],total:0};let i=o/_i,a=[0],s=[oc(t,n,r)];for(let l=0;l<_i;l+=1){let d=Di(t,n,r+i*l),u=Di(t,n,r+i*(l+1));a.push(a[l]+(d+u)/2*i),s.push(oc(t,n,r+i*(l+1)))}let c=a[_i];return{startAngle:r,step:i,cumulative:a,curvatureRadius:s,total:Number.isFinite(c)&&c>0?c:0}}function oc(e,t,n){let r=Di(e,t,n),o=e*t;if(!(o>0))return 0;let i=r*r*r/o;return Number.isFinite(i)?i:0}function ic(e,t){let n=Math.min(Math.max(t,0),e.total);for(let r=1;r<e.cumulative.length;r+=1)if(e.cumulative[r]>=n){let o=e.cumulative[r]-e.cumulative[r-1],i=o>0?(n-e.cumulative[r-1])/o:0;return e.startAngle+e.step*(r-1+i)}return e.startAngle+e.step*(e.cumulative.length-1)}function Di(e,t,n){let r=Math.hypot(e*Math.sin(n),t*Math.cos(n));return Number.isFinite(r)?r:0}function xt(e,t,n,r,o=0){let i=o,a=Math.max(i+1,e-o),s=o,c=Math.max(s+1,t-o),l=Math.max(1,a-i),d=Math.max(1,c-s),u=s+d/2,m=l*sc(n),h=qr(a-m,i+Math.min(8,l*.25),a-1),y=d*lc(r)/2,g=qr(u-y,s,u),x=qr(u+y,u,c);return[{x:i,y:g},{x:h,y:g},{x:h,y:s},{x:a,y:u},{x:h,y:c},{x:h,y:x},{x:i,y:x}]}function sc(e){return cc(e,.32,.18,.75)}function lc(e){return cc(e,.42,.12,.9)}function cc(e,t,n,r){let o=typeof e=="number"?e:Number.parseFloat(String(e));return qr(Number.isFinite(o)?o:t,n,r)}function qr(e,t,n){return Math.min(n,Math.max(t,e))}function Gi(e){if(!e)return null;let t=Zr(Math.min(e.topLeft.x,e.bottomRight.x)),n=Zr(Math.min(e.topLeft.y,e.bottomRight.y)),r=Zr(Math.max(e.topLeft.x,e.bottomRight.x)),o=Zr(Math.max(e.topLeft.y,e.bottomRight.y));return r-t<.02||o-n<.02?null:{topLeft:{x:t,y:n},bottomRight:{x:r,y:o}}}function Kt(e,t){let n=Gi(e.props.crop);if(n)return n;let r=Math.max(1,t?.props.w||e.props.w||1),o=Math.max(1,t?.props.h||e.props.h||1),i=Math.max(1,e.props.w),a=Math.max(1,e.props.h),s=r/o,c=i/a;if(s>c){let u=c/s,m=(1-u)/2;return{topLeft:{x:m,y:0},bottomRight:{x:m+u,y:1}}}let l=s/c,d=(1-l)/2;return{topLeft:{x:0,y:d},bottomRight:{x:1,y:d+l}}}function Hn(e,t,n=Kt(e,t)){let r=Math.max(1,t?.props.w||e.props.w||1),o=Math.max(1,t?.props.h||e.props.h||1);return uc({w:e.props.w,h:e.props.h},{w:r,h:o},n)}function uc(e,t,n){let r=Math.max(1,t.w),o=Math.max(1,t.h),i=Math.max(.02,n.bottomRight.x-n.topLeft.x),a=Math.max(.02,n.bottomRight.y-n.topLeft.y),s=Math.max(e.w/(r*i),e.h/(o*a)),c=r*s,l=o*s;return{x:-n.topLeft.x*c+(e.w-i*c)/2,y:-n.topLeft.y*l+(e.h-a*l)/2,width:c,height:l}}function Zr(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function bt(e){let t=typeof e=="number"?e:Number.parseInt(String(e),10),n=Math.round(Number.isFinite(t)?t:5);return Math.min(12,Math.max(5,n))}function St(e,t,n,r=0){let o=Math.max(0,e),i=Math.max(0,t),a=Math.min(Math.max(0,r),o/2),s=Math.min(Math.max(0,r),i/2),c=Math.max(0,o-a*2),l=Math.max(0,i-s*2),d=Array.from({length:n},(R,P)=>{let C=-Math.PI/2+P*Math.PI*2/n;return{x:Math.cos(C),y:Math.sin(C)}}),u=d.map(R=>R.x),m=d.map(R=>R.y),h=Math.min(...u),y=Math.max(...u),g=Math.min(...m),x=Math.max(...m),S=Math.max(Number.EPSILON,y-h),I=Math.max(Number.EPSILON,x-g);return d.map(R=>({x:a+(R.x-h)/S*c,y:s+(R.y-g)/I*l}))}var Uw=Math.sqrt(3)/2;var qw=Math.PI*2;var my=8;function Jr(e){let t=fy(e),n=t?.props.label;if(!t||!n)return null;let r=t.type==="arrow"?{x:(t.props.start.x+t.props.end.x)/2,y:(t.props.start.y+t.props.end.y)/2}:Li(t.props.points);return r?{anchor:{x:t.x+r.x,y:t.y+r.y-my},text:n,fontSizePx:$e(t.props.size)}:null}function fy(e){return e.type==="line"||e.type==="arrow"?e:null}var yy=[0,Math.PI/2,Math.PI,Math.PI*1.5];function pc(e){return e.type==="arc"?hy(e):e.type==="line"||e.type==="arrow"?gy(e):de(e)}function Qe(e){return Ft(pc(e))}function hy(e){let{rx:t,ry:n}=ce(e),r={x:e.x+t,y:e.y+n},o=a=>({x:r.x+Math.cos(a)*t,y:r.y+Math.sin(a)*n}),i=[o(e.props.startAngle),o(e.props.endAngle)];for(let a of yy)hi(a,e.props.startAngle,e.props.endAngle)&&i.push(o(a));return e.props.kind==="sector"&&i.push(r),_t(i)}function gy(e){let n=(e.type==="arrow"?[e.props.start,e.props.end]:e.props.points).map(r=>({x:e.x+r.x,y:e.y+r.y}));return n.length===0?{x:e.x,y:e.y,w:1,h:1}:e.type==="line"&&e.props.kind!=="polyline"?_t(xy(n)):_t(n)}function xy(e){if(e.length<3)return[...e];if(e.length===3)return[e[0],e[2],...dc(e[0],e[1],e[2])];let t=[e[0],e[e.length-1]],n=e[0];for(let r=1;r<e.length-1;r+=1){let o=e[r],i=e[r+1],a={x:(o.x+i.x)/2,y:(o.y+i.y)/2};t.push(a,...dc(n,o,a)),n=a}return t}function dc(e,t,n){let r=[];for(let o of["x","y"]){let i=e[o]-2*t[o]+n[o];if(Math.abs(i)<1e-9)continue;let a=(e[o]-t[o])/i;a<=0||a>=1||r.push(by(e,t,n,a))}return r}function by(e,t,n,r){let o=1-r;return{x:o*o*e.x+2*o*r*t.x+r*r*n.x,y:o*o*e.y+2*o*r*t.y+r*r*n.y}}var Ck=Object.freeze({});var mc=["color","strokeOpacity","dash","size"],Lk=[...mc,"arrowheadStart","arrowheadEnd"],Nk=[...mc,"fill","fillColor","fillOpacity"];var Un=["lead","prompt","hints","solution"];function $i(e){return e==="decimal"||e==="paren"?e:void 0}var vy=["image/png","image/jpeg","image/webp","image/svg+xml"],My=/^sigma-doc-storage:\/\/[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/,Py=vy.map(e=>e.replace("+","\\+")).join("|"),Ty=new RegExp(`^data:(?:${Py})(?:;[A-Za-z0-9-]+(?:=[^;,]*)?)*;base64,[A-Za-z0-9+/=\\s]+$`,"i"),Oy=/^data:image\/svg\+xml(?:;[A-Za-z0-9-]+(?:=[^;,]*)?)*,[^]+$/i,wy=/\.\./,ky=48*1024*1024;function Vn(e){if(typeof e!="string")return null;let t=e.trim();return!t||t.length>ky?null:My.test(t)||Ty.test(t)||Oy.test(t)&&!wy.test(t)?t:null}function zi(e){return Vn(e)!==null}var jt="black";var fc=/[\u0000-\u001f\u007f-\u009f]/u,yc=/[\\;{}<>]/u,hc=/(?:url\s*\(|(?:-webkit-)?image-set\s*\(|element\s*\(|@import\b|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:|\/\*)/iu,By=/^(?:rgb|rgba|hsl|hsla)\(\s*[-+.\d%\s,/]+\)$/iu,Ry=/^#[\da-f]{3,8}$/iu,Ay=/^[a-z]+$/iu,Iy=/^[\p{L}\p{N}\s,"'_.-]+$/u;function vt(e){if(typeof e!="string")return!1;let t=e.trim();return t.length>0&&t.length<=512&&!fc.test(e)&&!yc.test(e)&&!hc.test(e)}function Pe(e){if(!vt(e))return!1;let t=e.trim();return Ry.test(t)||Ay.test(t)||By.test(t)}function Qr(e){if(!vt(e))return!1;let t=e.trim();return t.length<=200&&Iy.test(t)}function et(e){return typeof e!="string"?!1:e.trim().length>0&&e.length<=512&&!fc.test(e)&&!yc.test(e)&&!hc.test(e)}var gc="plot";function Ey(e){return e.kind==="numberLine"?{left:34,top:20,right:28,bottom:30}:{left:46,top:18,right:18,bottom:34}}function Wn(e){if(e.props.boundsMode===gc)return e;let t=e.props.preserveSpecSize===!0?e.props.spec:{...e.props.spec,width:e.props.w,height:e.props.h},n=Ey(t),r=e.props.w/Math.max(1,t.width),o=e.props.h/Math.max(1,t.height),i=n.left*r,a=n.top*o,s=n.right*r,c=n.bottom*o,l=e.anchor?.type==="block"?{...e.anchor,dy:e.anchor.dy+a,...e.anchor.dx===void 0?{}:{dx:e.anchor.dx+i},...e.anchor.line?{line:{...e.anchor.line,dy:e.anchor.line.dy+a}}:{}}:e.anchor;return{...e,x:e.x+i,y:e.y+a,...l?{anchor:l}:{},props:{...e.props,boundsMode:gc,w:Math.max(1,e.props.w-i-s),h:Math.max(1,e.props.h-a-c),spec:e.props.preserveSpecSize===!0?e.props.spec:t}}}var Hi=.5,Cy=8,eo=10;function Ui(e){let t=Ly(e);for(let n=0;n<4;n+=1){let r=Dy(_y(Fy(Ny(t))));if(Xy(t,r))return r;t=r}return t}function Ly(e){let t=new Map;for(let a of e)a.type==="group"||!a.groupId||t.set(a.groupId,[...t.get(a.groupId)??[],a]);if(t.size===0)return e.map(xc);let n=new Set(e.map(a=>a.id)),r=new Map,o=new Map;for(let[a,s]of t){if(s.length<2)continue;let c=Sc(s);if(!c)continue;let l=zy(()=>a,n);r.set(a,l);let d=Math.max(0,e.findIndex(m=>m.groupId===a)),u={id:l,type:"group",x:c.x,y:c.y,props:{w:c.w,h:c.h}};o.set(d,[...o.get(d)??[],u])}let i=[];return e.forEach((a,s)=>{let c=o.get(s);c&&i.push(...c);let l=a.groupId,d=xc(a),u=l?r.get(l):void 0;i.push(u?{...d,parentId:u}:d)}),i}function Ny(e){let t=new Map(e.map(o=>[o.id,o])),n=!1,r=e.map(o=>{if(!o.parentId)return o;let i=t.get(o.parentId);if(!i||i.type!=="group"||i.id===o.id||$y(o,t)){let a={...o};return delete a.parentId,n=!0,a}return o});return n?r:e}function Fy(e){let t=Vi(e),n=new Set(e.filter(o=>o.type==="group").filter(o=>(t.get(o.id)?.length??0)<=1).map(o=>o.id));if(n.size===0)return e;let r=new Map(e.filter(o=>o.type==="group"&&n.has(o.id)).map(o=>[o.id,o.parentId]));return e.flatMap(o=>{if(n.has(o.id))return[];if(o.parentId&&n.has(o.parentId)){let i=r.get(o.parentId),a={...o};return i?a.parentId=i:delete a.parentId,[a]}return[o]})}function _y(e){let t=Vi(e),n=new Map(e.map(a=>[a.id,Gy(a,e)])),r=e.filter(a=>a.type==="group").sort((a,s)=>(n.get(s.id)??0)-(n.get(a.id)??0));if(r.length===0)return e;let o=new Map(e.map(a=>[a.id,a])),i=!1;for(let a of r){let s=(t.get(a.id)??[]).map(l=>o.get(l.id)??l),c=Sc(s);c&&(Wy(c,{x:a.x,y:a.y,w:a.props.w,h:a.props.h})||(o.set(a.id,{...a,x:c.x,y:c.y,props:{...a.props,w:c.w,h:c.h}}),i=!0))}return i?e.map(a=>o.get(a.id)??a):e}function Dy(e){let t=Vi(e),n=[],r=new Set,o=i=>{if(!r.has(i.id)&&(r.add(i.id),n.push(i),i.type==="group"))for(let a of t.get(i.id)??[])o(a)};for(let i of e)i.parentId||o(i);for(let i of e)o(i);return n}function Vi(e){let t=new Map;for(let n of e)n.parentId&&t.set(n.parentId,[...t.get(n.parentId)??[],n]);return t}function Gy(e,t){let n=0,r=e.parentId,o=new Set([e.id]);for(;r;){let i=t.find(a=>a.id===r);if(!i||o.has(i.id))break;o.add(i.id),n+=1,r=i.parentId}return n}function $y(e,t){let n=new Set([e.id]),r=e.parentId;for(;r;){if(n.has(r))return!0;n.add(r),r=t.get(r)?.parentId}return!1}function xc(e){if(!e.groupId)return e;let t={...e};return delete t.groupId,t}function zy(e,t){let n=e(),r=1;for(;t.has(n);)n=`${e()}_${r}`,r+=1;return t.add(n),n}function Sc(e){return e.length===0?null:e.map(Hy).reduce((t,n)=>Vy(t,n))}function Hy(e){if(e.type==="graph2dShape"){let t=Wn(e);return{x:t.x,y:t.y,w:t.props.w,h:t.props.h}}if(e.type==="group"||e.type==="geo"||e.type==="image"||e.type==="callout"||e.type==="tableShape")return{x:e.x,y:e.y,w:e.props.w,h:e.props.h};if(e.type==="arc"){let t=Math.max(Hi,e.props.r),n=typeof e.props.rx=="number"&&Number.isFinite(e.props.rx)?Math.max(Hi,e.props.rx):t,r=typeof e.props.ry=="number"&&Number.isFinite(e.props.ry)?Math.max(Hi,e.props.ry):t;return{x:e.x,y:e.y,w:n*2,h:r*2}}if(e.type==="text"){let t=Uy(e),n=typeof e.props.h=="number"&&Number.isFinite(e.props.h)?Math.max(t,e.props.h):t;return{x:e.x,y:e.y,w:Math.max(Cy,e.props.w),h:n}}return e.type==="arrow"?bc(e.x,e.y,[e.props.start,e.props.end]):e.type==="line"?bc(e.x,e.y,e.props.points):{x:0,y:0,w:1,h:1}}function Uy(e){let t=ht(e);return Math.max(t,Sl(e.props.richText)*t)}function bc(e,t,n){if(n.length===0)return{x:e,y:t,w:1,h:1};let r=n.map(l=>e+l.x),o=n.map(l=>t+l.y),i=Math.min(...r),a=Math.min(...o),s=Math.max(...r),c=Math.max(...o);return{x:i-eo,y:a-eo,w:Math.max(1,s-i+eo*2),h:Math.max(1,c-a+eo*2)}}function Vy(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y),o=Math.max(e.x+e.w,t.x+t.w),i=Math.max(e.y+e.h,t.y+t.h);return{x:n,y:r,w:o-n,h:i-r}}function Wy(e,t){return Math.abs(e.x-t.x)<.01&&Math.abs(e.y-t.y)<.01&&Math.abs(e.w-t.w)<.01&&Math.abs(e.h-t.h)<.01}function Xy(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}var Yy=/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})$/;function tt(e){let t=typeof e=="number"?String(e):String(e??"").trim();if(!Yy.test(t))return;let n=Number(t);if(!(!Number.isFinite(n)||n<.8||n>3))return Ky(n)}function Ky(e){return e.toFixed(2).replace(/\.?0+$/,"")}var Wi="#9ca3af";var vc="solid",Mc=[{label:"\u30D9\u30BF",value:"solid"},{label:"\u53F3\u4E0A\u659C\u7DDA",value:"diagonal"},{label:"\u53F3\u4E0B\u659C\u7DDA",value:"diagonalBack"},{label:"\u683C\u5B50\u659C\u7DDA",value:"cross"},{label:"\u6A2A\u7DDA",value:"horizontal"},{label:"\u7E26\u7DDA",value:"vertical"},{label:"\u70B9\u3005",value:"dots"}];function to(e){return Mc.some(t=>t.value===e)}function Xi(e){return to(e)?e:vc}function Yi(e){return typeof e!="number"||!Number.isFinite(e)?.28:Math.min(1,Math.max(0,e))}var Ki=["none","arrow","triangle","openArrow","thinArrow","diamond","dot","bar"];function Zi(e){return Qt(e)?e.shapes.every(en)&&Object.values(e.assets).every(tn)&&(e.extensions===void 0||Yn(e.extensions)):!1}function Qt(e){return G(e)&&e.version===1&&Array.isArray(e.shapes)&&G(e.assets)}function Yn(e){return G(e)&&Object.keys(e).every(jy)&&Object.values(e).every(ji)}function Jt(e){return G(e)&&Array.isArray(e.blocks)&&e.blocks.every(kc)}function en(e){if(!G(e)||typeof e.id!="string"||!k(e.x)||!k(e.y)||e.rotation!==void 0&&!k(e.rotation)||e.parentId!==void 0&&typeof e.parentId!="string"||e.groupId!==void 0&&typeof e.groupId!="string"||e.stackLayer!==void 0&&!Qy(e.stackLayer)||e.locked!==void 0&&typeof e.locked!="boolean"||e.hidden!==void 0&&typeof e.hidden!="boolean"||e.opacity!==void 0&&(!k(e.opacity)||e.opacity<0||e.opacity>1)||e.anchor!==void 0&&!th(e.anchor)||!G(e.props))return!1;switch(e.type){case"group":return qt(e.props)&&(e.props.name===void 0||typeof e.props.name=="string");case"geo":return qt(e.props)&&(e.props.geo==="rectangle"||e.props.geo==="ellipse"||e.props.geo==="triangle"||e.props.geo==="diamond"||e.props.geo==="pentagon"||e.props.geo==="regularPolygon"||e.props.geo==="blockArrow")&&(e.props.geo!=="regularPolygon"||k(e.props.polygonSides)&&Number.isInteger(e.props.polygonSides)&&e.props.polygonSides>=5&&e.props.polygonSides<=12)&&(e.props.apexX===void 0||k(e.props.apexX))&&(e.props.headLengthRatio===void 0||k(e.props.headLengthRatio)&&e.props.headLengthRatio>0&&e.props.headLengthRatio<1)&&(e.props.shaftRatio===void 0||k(e.props.shaftRatio)&&e.props.shaftRatio>0&&e.props.shaftRatio<=1)&&(e.props.radius===void 0||k(e.props.radius)&&e.props.radius>=0)&&(e.props.fill==="none"||e.props.fill==="solid")&&typeof e.props.color=="string"&&(e.props.fillColor===void 0||typeof e.props.fillColor=="string")&&(e.props.strokeOpacity===void 0||k(e.props.strokeOpacity)&&e.props.strokeOpacity>=0&&e.props.strokeOpacity<=1)&&(e.props.fillOpacity===void 0||k(e.props.fillOpacity)&&e.props.fillOpacity>=0&&e.props.fillOpacity<=1)&&typeof e.props.labelColor=="string"&&Xn(e.props.dash)&&Mt(e.props.size)&&(e.props.label===void 0||typeof e.props.label=="string");case"arc":return(e.props.kind===void 0||e.props.kind==="arc"||e.props.kind==="sector")&&k(e.props.r)&&e.props.r>0&&(e.props.rx===void 0||k(e.props.rx)&&e.props.rx>0)&&(e.props.ry===void 0||k(e.props.ry)&&e.props.ry>0)&&k(e.props.startAngle)&&k(e.props.endAngle)&&(e.props.arrowheadStart===void 0||Zt(e.props.arrowheadStart))&&(e.props.arrowheadEnd===void 0||Zt(e.props.arrowheadEnd))&&(e.props.fill===void 0||e.props.fill==="none"||e.props.fill==="solid")&&(e.props.fillColor===void 0||typeof e.props.fillColor=="string")&&(e.props.fillOpacity===void 0||k(e.props.fillOpacity)&&e.props.fillOpacity>=0&&e.props.fillOpacity<=1)&&(e.props.fillPattern===void 0||e.props.fillPattern==="diagonalHatch")&&typeof e.props.color=="string"&&(e.props.strokeOpacity===void 0||k(e.props.strokeOpacity)&&e.props.strokeOpacity>=0&&e.props.strokeOpacity<=1)&&Xn(e.props.dash)&&Mt(e.props.size);case"arrow":return nt(e.props.start)&&nt(e.props.end)&&(e.props.arrowheadStart===void 0||Zt(e.props.arrowheadStart))&&Zt(e.props.arrowheadEnd)&&e.props.fill==="none"&&typeof e.props.color=="string"&&(e.props.strokeOpacity===void 0||k(e.props.strokeOpacity)&&e.props.strokeOpacity>=0&&e.props.strokeOpacity<=1)&&typeof e.props.labelColor=="string"&&Xn(e.props.dash)&&Mt(e.props.size)&&(e.props.label===void 0||typeof e.props.label=="string");case"line":return Array.isArray(e.props.points)&&e.props.points.length>0&&e.props.points.every(nt)&&(e.props.kind===void 0||eh(e.props.kind))&&typeof e.props.closed=="boolean"&&(e.props.arrowheadStart===void 0||Zt(e.props.arrowheadStart))&&(e.props.arrowheadEnd===void 0||Zt(e.props.arrowheadEnd))&&(e.props.fill===void 0||e.props.fill==="none"||e.props.fill==="solid")&&(e.props.fillColor===void 0||typeof e.props.fillColor=="string")&&(e.props.fillOpacity===void 0||k(e.props.fillOpacity)&&e.props.fillOpacity>=0&&e.props.fillOpacity<=1)&&typeof e.props.color=="string"&&(e.props.strokeOpacity===void 0||k(e.props.strokeOpacity)&&e.props.strokeOpacity>=0&&e.props.strokeOpacity<=1)&&Xn(e.props.dash)&&Mt(e.props.size)&&(e.props.labelColor===void 0||typeof e.props.labelColor=="string")&&(e.props.label===void 0||typeof e.props.label=="string");case"text":return k(e.props.w)&&(e.props.h===void 0||k(e.props.h)&&e.props.h>0)&&(e.props.maxWidth===void 0||k(e.props.maxWidth)&&e.props.maxWidth>0)&&(e.props.scale===void 0||k(e.props.scale)&&e.props.scale>0)&&Jt(e.props.richText)&&typeof e.props.autoSize=="boolean"&&typeof e.props.color=="string"&&(e.props.fontSize===void 0||k(e.props.fontSize)&&e.props.fontSize>0)&&Mt(e.props.size);case"image":return typeof e.props.assetId=="string"&&qt(e.props)&&(e.props.crop===void 0||Jy(e.props.crop));case"callout":return qt(e.props)&&k(e.props.radius)&&e.props.radius>=0&&G(e.props.tail)&&nt(e.props.tail.baseStart)&&nt(e.props.tail.baseEnd)&&nt(e.props.tail.tip)&&Jt(e.props.richText)&&typeof e.props.color=="string"&&(e.props.fontSize===void 0||k(e.props.fontSize)&&e.props.fontSize>0)&&Mt(e.props.size)&&Xn(e.props.dash)&&Mt(e.props.strokeWidth);case"graph2dShape":return qt(e.props)&&oh(e.props.spec)&&(e.props.boundsMode===void 0||e.props.boundsMode==="plot")&&(e.props.preserveSpecSize===void 0||typeof e.props.preserveSpecSize=="boolean")&&(e.props.axisLabelTextShapeIds===void 0||G(e.props.axisLabelTextShapeIds)&&Object.entries(e.props.axisLabelTextShapeIds).every(([t,n])=>rh(t)&&typeof n=="string"))&&(e.props.pointLabelTextShapeIdsByPointId===void 0||G(e.props.pointLabelTextShapeIdsByPointId)&&Object.values(e.props.pointLabelTextShapeIdsByPointId).every(t=>typeof t=="string"))&&(e.props.annotationTextShapeIdsByAnnotationId===void 0||G(e.props.annotationTextShapeIdsByAnnotationId)&&Object.values(e.props.annotationTextShapeIdsByAnnotationId).every(t=>typeof t=="string"))&&(e.props.labelTextShapeIds===void 0||Array.isArray(e.props.labelTextShapeIds)&&e.props.labelTextShapeIds.every(t=>typeof t=="string"))&&(e.props.labelTextShapeIdsByCurveId===void 0||G(e.props.labelTextShapeIdsByCurveId)&&Object.values(e.props.labelTextShapeIdsByCurveId).every(t=>typeof t=="string"));case"tableShape":return qt(e.props)&&lh(e.props.table);default:return!1}}function tn(e){return G(e)&&typeof e.id=="string"&&e.type==="image"&&G(e.props)&&k(e.props.w)&&k(e.props.h)&&typeof e.props.name=="string"&&e.props.isAnimated===!1&&(typeof e.props.mimeType=="string"||e.props.mimeType===null)&&typeof e.props.src=="string"&&k(e.props.fileSize)&&(e.props.storage===void 0||qy(e.props.storage))}function jy(e){return/^[a-z][a-z0-9]*(?:[.-][a-z][a-z0-9]*)+$/.test(e)}function ji(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(ji):G(e)&&Object.values(e).every(ji)}function qy(e){return G(e)&&e.kind==="remote-asset"&&typeof e.storageKey=="string"&&typeof e.assetId=="string"}function G(e){return typeof e=="object"&&e!==null}function kc(e){return!G(e)||e.type!=="paragraph"&&e.type!=="heading"||!Array.isArray(e.children)||!e.children.every(qi)||e.align!==void 0&&!Ji(e.align)||e.lineHeight!==void 0&&!Zy(e.lineHeight)?!1:e.type!=="heading"||e.level===1||e.level===2||e.level===3}function Zy(e){if(typeof e!="string"||!/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})$/u.test(e))return!1;let t=Number(e);return Number.isFinite(t)&&t>=.8&&t<=3}function k(e){return typeof e=="number"&&Number.isFinite(e)}function qt(e){return k(e.w)&&k(e.h)}function nt(e){return G(e)&&k(e.x)&&k(e.y)}function Jy(e){return G(e)&&nt(e.topLeft)&&nt(e.bottomRight)&&e.topLeft.x>=0&&e.topLeft.x<=1&&e.topLeft.y>=0&&e.topLeft.y<=1&&e.bottomRight.x>=0&&e.bottomRight.x<=1&&e.bottomRight.y>=0&&e.bottomRight.y<=1&&e.bottomRight.x>e.topLeft.x&&e.bottomRight.y>e.topLeft.y}function Mt(e){return e==="s"||e==="m"||e==="l"||e==="xl"}function Qy(e){return e==="foreground"||e==="background"}function Xn(e){return e==="solid"||e==="dashed"||e==="dotted"}function Zt(e){return typeof e=="string"&&Ki.includes(e)}function eh(e){return e==="polyline"||e==="curve"||e==="freehand"}function th(e){return G(e)?e.type==="page"?!0:e.type==="shape"?typeof e.shapeId=="string"&&k(e.dx)&&k(e.dy)&&(e.rx===void 0||k(e.rx))&&(e.ry===void 0||k(e.ry)):e.type==="block"&&typeof e.blockId=="string"&&k(e.dy)&&(e.dx===void 0||k(e.dx))&&(e.reserveSpace===void 0||typeof e.reserveSpace=="boolean")&&(e.line===void 0||nh(e.line)):!1}function nh(e){return G(e)&&typeof e.index=="number"&&Number.isInteger(e.index)&&e.index>=0&&k(e.dy)}function rh(e){return e==="x"||e==="y"||e==="origin"}function oh(e){return!G(e)||e.kind!=="cartesian"&&e.kind!=="numberLine"?!1:typeof e.title=="string"&&k(e.width)&&k(e.height)&&Pc(e.viewBox)&&(e.graphViewBox===void 0||Pc(e.graphViewBox))&&G(e.axes)&&typeof e.axes.grid=="boolean"&&Array.isArray(e.curves)&&e.curves.every(ih)&&(e.points===void 0||Array.isArray(e.points)&&e.points.every(ah))&&(e.annotations===void 0||Array.isArray(e.annotations))&&(e.fills===void 0||Array.isArray(e.fills)&&e.fills.every(sh))&&(e.showFormulaLabels===void 0||typeof e.showFormulaLabels=="boolean")}function ih(e){return G(e)&&typeof e.id=="string"&&typeof e.expr=="string"&&(e.yExpr===void 0||typeof e.yExpr=="string")&&typeof e.color=="string"&&(e.label===void 0||typeof e.label=="string")&&(e.mode===void 0||e.mode==="yOfX"||e.mode==="xOfY"||e.mode==="parametric"||e.mode==="implicit")&&(e.dash===void 0||e.dash==="solid"||e.dash==="dashed"||e.dash==="dotted")&&(e.strokeWidth===void 0||k(e.strokeWidth))&&(e.domain===void 0||G(e.domain)&&(e.domain.min===void 0||typeof e.domain.min=="string")&&(e.domain.max===void 0||typeof e.domain.max=="string"))}function Pc(e){return G(e)&&typeof e.xMin=="string"&&typeof e.xMax=="string"&&typeof e.yMin=="string"&&typeof e.yMax=="string"}function ah(e){return G(e)&&typeof e.id=="string"&&typeof e.x=="string"&&typeof e.y=="string"&&(e.color===void 0||typeof e.color=="string")&&(e.fill===void 0||e.fill==="solid"||e.fill==="none")&&(e.radius===void 0||k(e.radius))&&(e.label===void 0||typeof e.label=="string")&&(e.showXProjection===void 0||typeof e.showXProjection=="boolean")&&(e.showYProjection===void 0||typeof e.showYProjection=="boolean")}function sh(e){return G(e)&&typeof e.id=="string"&&typeof e.x=="string"&&typeof e.y=="string"&&(e.color===void 0||typeof e.color=="string")&&(e.pattern===void 0||to(e.pattern))&&(e.opacity===void 0||k(e.opacity)&&e.opacity>=0&&e.opacity<=1)}function lh(e){if(!G(e)||e.version!==1||e.kind!=="plain"&&e.kind!=="variation"||!Array.isArray(e.columns)||!Array.isArray(e.rows)||!Array.isArray(e.cells)||!G(e.grid)||!Rc(e.defaultCellStyle)||e.columns.length===0||e.rows.length===0)return!1;let t=new Set;for(let r of e.columns){if(!ch(r)||t.has(r.id))return!1;t.add(r.id)}let n=new Set;for(let r of e.rows){if(!uh(r)||n.has(r.id))return!1;n.add(r.id)}return yh(e.grid,n,t)?e.cells.every(r=>dh(r,n,t)):!1}function ch(e){return G(e)&&typeof e.id=="string"&&Bc(e.width)&&(e.role===void 0||e.role==="label"||e.role==="point"||e.role==="interval"||e.role==="value")}function uh(e){return G(e)&&typeof e.id=="string"&&Bc(e.height)&&(e.role===void 0||e.role==="header"||e.role==="body"||e.role==="variable"||e.role==="derivative"||e.role==="variation"||e.role==="note")}function Bc(e){return G(e)?e.mode==="fixed"?k(e.value)&&e.value>0:e.mode==="auto"?no(e.min)&&no(e.max):e.mode==="fr"&&k(e.value)&&e.value>0&&no(e.min)&&no(e.max):!1}function dh(e,t,n){return G(e)&&typeof e.id=="string"&&typeof e.rowId=="string"&&typeof e.columnId=="string"&&t.has(e.rowId)&&n.has(e.columnId)&&(e.rowSpan===void 0||Oc(e.rowSpan))&&(e.colSpan===void 0||Oc(e.colSpan))&&Array.isArray(e.content)&&e.content.every(ph)&&(e.style===void 0||xh(e.style))}function ph(e){return!G(e)||typeof e.id!="string"?!1:e.type==="paragraph"?Array.isArray(e.children)&&e.children.every(qi)&&(e.align===void 0||Ji(e.align)):e.type==="trend"&&(e.direction==="up"||e.direction==="down"||e.direction==="flat")&&(e.label===void 0||Array.isArray(e.label)&&e.label.every(qi))}function qi(e){return G(e)?e.type==="text"?typeof e.text=="string"&&(e.marks===void 0||Array.isArray(e.marks)&&e.marks.every(mh))&&(e.color===void 0||typeof e.color=="string")&&(e.backgroundColor===void 0||typeof e.backgroundColor=="string")&&(e.fontFamily===void 0||typeof e.fontFamily=="string")&&(e.fontSize===void 0||k(e.fontSize)&&e.fontSize>0)&&(e.boxedPaddingY===void 0||k(e.boxedPaddingY)&&e.boxedPaddingY>=0)&&Tc(e):e.type==="mathInline"&&typeof e.id=="string"&&e.id.length>0&&typeof e.tex=="string"&&e.display==="inline"&&(e.marks===void 0||Array.isArray(e.marks)&&e.marks.every(fh))&&(e.color===void 0||typeof e.color=="string")&&(e.backgroundColor===void 0||typeof e.backgroundColor=="string")&&(e.fontFamily===void 0||typeof e.fontFamily=="string")&&(e.fontSize===void 0||k(e.fontSize)&&e.fontSize>0)&&(e.boxedPaddingY===void 0||k(e.boxedPaddingY)&&e.boxedPaddingY>=0)&&(e.semanticRole===void 0||e.semanticRole==="expression"||e.semanticRole==="equation"||e.semanticRole==="variable")&&(e.altText===void 0||typeof e.altText=="string")&&Tc(e):!1}function mh(e){return e==="bold"||e==="italic"||e==="underline"||e==="boxed"}function fh(e){return e==="underline"||e==="boxed"}function Tc(e){return(e.boxedVariant===void 0||e.boxedVariant==="frame"||e.boxedVariant==="thick"||e.boxedVariant==="double"||e.boxedVariant==="oval"||e.boxedVariant==="shade")&&(e.boxedTone===void 0||e.boxedTone==="gray"||e.boxedTone==="blue"||e.boxedTone==="green"||e.boxedTone==="red"||e.boxedTone==="yellow")}function yh(e,t,n){return G(e)&&typeof e.borderColor=="string"&&k(e.borderWidth)&&e.borderWidth>=0&&(e.borderStyle===void 0||e.borderStyle==="solid"||e.borderStyle==="dashed"||e.borderStyle==="dotted"||e.borderStyle==="double")&&(e.showOuterBorder===void 0||typeof e.showOuterBorder=="boolean")&&(e.showInnerBorders===void 0||typeof e.showInnerBorders=="boolean")&&(e.lineOverrides===void 0||Array.isArray(e.lineOverrides)&&e.lineOverrides.every(r=>hh(r,t,n)))}function hh(e,t,n){if(!G(e)||!gh(e.style))return!1;if(e.axis==="vertical"){let r="edge"in e,o="beforeColumnId"in e;return r===o?!1:r?e.edge==="left"||e.edge==="right":typeof e.beforeColumnId=="string"&&n.has(e.beforeColumnId)}if(e.axis==="horizontal"){let r="edge"in e,o="beforeRowId"in e;return r===o?!1:r?e.edge==="top"||e.edge==="bottom":typeof e.beforeRowId=="string"&&t.has(e.beforeRowId)}return!1}function gh(e){return G(e)&&(e.visible===void 0||typeof e.visible=="boolean")&&(e.borderColor===void 0||typeof e.borderColor=="string")&&(e.borderWidth===void 0||k(e.borderWidth)&&e.borderWidth>=0)&&(e.borderStyle===void 0||e.borderStyle==="solid"||e.borderStyle==="dashed"||e.borderStyle==="dotted"||e.borderStyle==="double")}function Rc(e){return G(e)&&(e.align===void 0||Ji(e.align))&&(e.verticalAlign===void 0||e.verticalAlign==="top"||e.verticalAlign==="middle"||e.verticalAlign==="bottom")&&wc(e.paddingX)&&wc(e.paddingY)&&(e.color===void 0||typeof e.color=="string")&&(e.backgroundColor===void 0||typeof e.backgroundColor=="string")&&(e.fontFamily===void 0||typeof e.fontFamily=="string")&&(e.fontSize===void 0||k(e.fontSize)&&e.fontSize>0)&&(e.fontWeight===void 0||e.fontWeight==="normal"||e.fontWeight==="bold")}function xh(e){return Rc(e)}function Ji(e){return e==="left"||e==="center"||e==="right"||e==="justify"}function Oc(e){return Number.isInteger(e)&&Number(e)>0}function no(e){return e===void 0||k(e)&&e>0}function wc(e){return e===void 0||k(e)&&e>=0}function bh(e){if(Jt(e)||!he(e)||e.type!=="doc"||!Array.isArray(e.content))return e;let t=Sh(e.content);if(!t)return e;let n=[];for(let r of t){let o=vh(r);if(!o)return e;n.push(o)}return{blocks:n}}function ro(e){if(!he(e)||!Array.isArray(e.shapes))return e;let t=!1,n=e.shapes.map(r=>{if(!he(r)||r.type!=="text"&&r.type!=="callout"||!he(r.props))return r;let o=bh(r.props.richText);return o===r.props.richText?r:(t=!0,{...r,props:{...r.props,richText:o}})});return t?{...e,shapes:n}:e}function Sh(e){let t=[];for(let n of e){if(!he(n))return null;if(n.type==="paragraph"||n.type==="heading"){t.push(n);continue}if(!Cc(n))return null;let r=t[t.length-1];r?.type==="paragraph"||r?.type==="heading"?t[t.length-1]={...r,content:[...Array.isArray(r.content)?r.content:[],n]}:t.push({type:"paragraph",content:[n]})}return t}function vh(e){if(e.type!=="paragraph"&&e.type!=="heading"||e.content!==void 0&&!Array.isArray(e.content)||e.attrs!==void 0&&!he(e.attrs))return null;let t=Mh(Array.isArray(e.content)?e.content:[]);if(!t)return null;let n=he(e.attrs)?e.attrs:{},r=Oh(n.textAlign),o=tt(n.lineHeight);return e.type==="heading"?{type:"heading",level:n.level===1||n.level===2||n.level===3?n.level:2,children:t,...r?{align:r}:{},...o?{lineHeight:o}:{}}:{type:"paragraph",children:t,...r?{align:r}:{},...o?{lineHeight:o}:{}}}function Mh(e){let t=[];for(let n of e){if(!Cc(n))return null;if(n.type==="hardBreak"){Ac(t,`
|
|
8
|
+
`,t[t.length-1]?.type==="text"?t[t.length-1]:{});continue}let r=Array.isArray(n.marks)?n.marks:[],o=Ic(r);if(n.type==="text"){Ac(t,n.text,o);continue}let i=n.attrs,a=Ph(r);t.push({type:"mathInline",id:typeof i.id=="string"&&i.id?i.id:`m_inline_${t.length}`,tex:i.tex,display:"inline",...a.length?{marks:a}:{},...Ec(o,a.includes("boxed")),semanticRole:"expression"})}return t}function Ic(e){let t=new Set,n,r,o,i,a,s,c;for(let l of e){if(!he(l)||typeof l.type!="string")continue;if(l.type==="bold"||l.type==="italic"||l.type==="underline"){t.add(l.type);continue}let d=he(l.attrs)?l.attrs:{};if(l.type==="boxed"){t.add("boxed"),a=kh(d.paddingY),s=Bh(d.variant),c=Rh(d.tone);continue}l.type==="styledText"&&(n=Qi(d.color),r=Qi(d.backgroundColor),o=Qi(d.fontFamily),i=wh(d.fontSize),(d.fontWeight==="bold"||Number(d.fontWeight)>=600)&&t.add("bold"),d.fontStyle==="italic"&&t.add("italic"),typeof d.textDecoration=="string"&&d.textDecoration.includes("underline")&&t.add("underline"))}return{...t.size?{marks:[...t]}:{},...n?{color:n}:{},...r?{backgroundColor:r}:{},...o?{fontFamily:o}:{},...i?{fontSize:i}:{},...a!==void 0?{boxedPaddingY:a}:{},...s?{boxedVariant:s}:{},...c?{boxedTone:c}:{}}}function Ph(e){return(Ic(e).marks??[]).filter(n=>n==="underline"||n==="boxed")}function Ac(e,t,n){let r=e[e.length-1];if(r?.type==="text"&&JSON.stringify(r.marks??[])===JSON.stringify(n.marks??[])&&r.color===n.color&&r.backgroundColor===n.backgroundColor&&r.fontFamily===n.fontFamily&&r.fontSize===n.fontSize&&r.boxedPaddingY===n.boxedPaddingY&&r.boxedVariant===n.boxedVariant&&r.boxedTone===n.boxedTone){r.text+=t;return}e.push({type:"text",text:t,...Ec(n,n.marks?.includes("boxed")??!1),...n.marks?.length?{marks:n.marks}:{}})}function Ec(e,t){return{...e.color?{color:e.color}:{},...e.backgroundColor?{backgroundColor:e.backgroundColor}:{},...e.fontFamily?{fontFamily:e.fontFamily}:{},...e.fontSize?{fontSize:e.fontSize}:{},...t&&e.boxedPaddingY!==void 0?{boxedPaddingY:e.boxedPaddingY}:{},...t&&e.boxedVariant?{boxedVariant:e.boxedVariant}:{},...t&&e.boxedTone?{boxedTone:e.boxedTone}:{}}}function Cc(e){return!he(e)||e.marks!==void 0&&(!Array.isArray(e.marks)||!e.marks.every(Th))?!1:e.type==="text"?typeof e.text=="string":e.type==="hardBreak"?!0:e.type==="mathInline"&&he(e.attrs)&&typeof e.attrs.tex=="string"}function Th(e){return he(e)&&(e.type==="bold"||e.type==="italic"||e.type==="underline"||e.type==="boxed"||e.type==="styledText")&&(e.attrs===void 0||he(e.attrs))}function Oh(e){return e==="left"||e==="center"||e==="right"||e==="justify"?e:void 0}function wh(e){let t=typeof e=="number"?e:Number.parseFloat(String(e));if(!Number.isFinite(t)||t<=0)return;let n=typeof e=="string"&&/px$/iu.test(e.trim())?t/(96/72):t;return Math.round(n*100)/100}function kh(e){let t=typeof e=="number"?e:Number.parseFloat(String(e));return Number.isFinite(t)&&t>=0?Math.min(12,Math.round(t*10)/10):void 0}function Qi(e){return typeof e=="string"&&e.length>0?e:void 0}function Bh(e){return e==="frame"||e==="thick"||e==="double"||e==="oval"||e==="shade"?e:void 0}function Rh(e){return e==="gray"||e==="blue"||e==="green"||e==="red"||e==="yellow"?e:void 0}function he(e){return typeof e=="object"&&e!==null}var Ah="sigma.legacy.metadata",Ih=["id","type","x","y","rotation","parentId","groupId","stackLayer","locked","hidden","opacity","anchor","props"],Eh={group:["w","h","name"],geo:["w","h","geo","polygonSides","apexX","headLengthRatio","shaftRatio","radius","fill","color","fillColor","strokeOpacity","fillOpacity","labelColor","dash","size","label"],arc:["kind","r","rx","ry","startAngle","endAngle","arrowheadStart","arrowheadEnd","fill","fillColor","fillOpacity","fillPattern","color","strokeOpacity","dash","size"],arrow:["start","end","arrowheadStart","arrowheadEnd","fill","color","strokeOpacity","labelColor","dash","size","label"],line:["kind","points","closed","arrowheadStart","arrowheadEnd","fill","fillColor","fillOpacity","fillPattern","color","strokeOpacity","labelColor","dash","size","label"],text:["w","h","maxWidth","scale","richText","autoSize","color","fontSize","size"],image:["assetId","w","h","crop"],callout:["w","h","radius","tail","richText","color","fontSize","size","dash","strokeWidth"],graph2dShape:["boundsMode","w","h","spec","preserveSpecSize","axisLabelTextShapeIds","pointLabelTextShapeIdsByPointId","annotationTextShapeIdsByAnnotationId","labelTextShapeIds","labelTextShapeIdsByCurveId"],tableShape:["w","h","table"]};function Fc(){return{version:1,shapes:[],assets:{}}}var Lc=new WeakMap;function me(e){let t=typeof e=="object"&&e!==null?e:null,n=t?Lc.get(t):void 0;if(n)return n;let r=ro(e);if(!Qt(r))return Fc();let o=oa(r),i=r.shapes.filter(en).map(ta),a={version:1,shapes:Ui(zc(i)),assets:Object.fromEntries(Object.entries(r.assets).filter(s=>na(s[1])).map(([s,c])=>[s,ra(c)])),...o?{extensions:o}:{}};return t&&Lc.set(t,a),a}function ea(e){let t=ro(e);if(!Qt(t))return{snapshot:Fc(),issues:[{kind:"snapshot"}]};let n=[],r=t.shapes.flatMap((a,s)=>en(a)?[ta(a)]:(n.push({kind:"shape",index:s,id:pe(a)&&typeof a.id=="string"?a.id:void 0,type:pe(a)&&typeof a.type=="string"?a.type:void 0}),[])),o=Object.entries(t.assets).flatMap(([a,s])=>na(s)?[[a,ra(s)]]:(n.push({kind:"asset",key:a}),[])),i=oa(t);return{snapshot:{version:1,shapes:Ui(zc(r)),assets:Object.fromEntries(o),...i?{extensions:i}:{}},issues:n}}function _c(e){let t=ro(e);if(!Qt(t)||!t.shapes.every(en)||!Object.values(t.assets).every(tn)||t.extensions!==void 0&&!Yn(t.extensions))return t;let n=oa(t);return{version:1,shapes:t.shapes.map(ta),assets:Object.fromEntries(Object.entries(t.assets).filter(r=>na(r[1])).map(([r,o])=>[r,ra(o)])),...n?{extensions:n}:{}}}function Ch(e){let t={...e};for(let n of["parentId","groupId","stackLayer","locked","hidden","opacity","anchor"])t[n]===void 0&&delete t[n];return t}var Lh={geo:["color","labelColor"],arc:["color"],arrow:["color","labelColor"],line:["color"],text:["color"],callout:["color"]},Nh={geo:["fillColor"],arc:["fillColor"],line:["fillColor","labelColor"]};function Fh(e,t){for(let n of Lh[e]??[])t[n]!==void 0&&!Pe(t[n])&&(t[n]=jt);for(let n of Nh[e]??[])t[n]!==void 0&&!Pe(t[n])&&delete t[n];e==="graph2dShape"?t.spec=_h(t.spec):e==="tableShape"&&(t.table=Dh(t.table))}function Pt(e,t,n=[]){if(!pe(e))return e;let r;for(let o of t)e[o]!==void 0&&!Pe(e[o])&&(r??={...e},delete r[o]);for(let o of n)e[o]!==void 0&&!Qr(e[o])&&(r??={...e},delete r[o]);return r??e}function Tt(e,t){let n;return e.forEach((r,o)=>{let i=t(r);i!==r&&(n??=[...e],n[o]=i)}),n??e}function _h(e){if(!pe(e))return e;let t=Pt(e.axes,["axisColor"]),n=Array.isArray(e.curves)?Tt(e.curves,i=>!pe(i)||i.color===void 0||Pe(i.color)?i:{...i,color:jt}):e.curves,r=Array.isArray(e.points)?Tt(e.points,i=>Pt(i,["color"])):e.points,o=Array.isArray(e.fills)?Tt(e.fills,i=>Pt(i,["color"])):e.fills;return t===e.axes&&n===e.curves&&r===e.points&&o===e.fills?e:{...e,axes:t,curves:n,points:r,fills:o}}var Dc=["color","backgroundColor"],Gc=["fontFamily"];function Dh(e){if(!pe(e))return e;let t=Gh(e.grid),n=Pt(e.defaultCellStyle,Dc,Gc),r=Array.isArray(e.cells)?Tt(e.cells,$h):e.cells;return t===e.grid&&n===e.defaultCellStyle&&r===e.cells?e:{...e,grid:t,defaultCellStyle:n,cells:r}}function Gh(e){if(!pe(e))return e;let t=e.borderColor!==void 0&&!Pe(e.borderColor)?jt:e.borderColor,n=Array.isArray(e.lineOverrides)?Tt(e.lineOverrides,r=>{if(!pe(r))return r;let o=Pt(r.style,["borderColor"]);return o===r.style?r:{...r,style:o}}):e.lineOverrides;return t===e.borderColor&&n===e.lineOverrides?e:{...e,borderColor:t,lineOverrides:n}}function $h(e){if(!pe(e))return e;let t=Pt(e.style,Dc,Gc),n=Array.isArray(e.content)?Tt(e.content,zh):e.content;return t===e.style&&n===e.content?e:{...e,style:t,content:n}}function zh(e){if(!pe(e))return e;let t;for(let n of["children","label"]){let r=e[n];if(!Array.isArray(r))continue;let o=Tt(r,$c);o!==r&&(t??={...e},t[n]=o)}return t??e}function $c(e){return Pt(e,["color","backgroundColor"],["fontFamily"])}function ta(e){let n=Kn(e,Ih);n.props=Kn(e.props,Eh[e.type]),e.anchor&&(n.anchor=Vh(e.anchor));let r=n.props;return Fh(e.type,r),(e.type==="text"||e.type==="callout")&&(r.richText=Hh(e.props.richText)),e.type==="arrow"?(r.start=rt(e.props.start),r.end=rt(e.props.end)):e.type==="line"?r.points=e.props.points.map(rt):e.type==="image"&&e.props.crop?r.crop={topLeft:rt(e.props.crop.topLeft),bottomRight:rt(e.props.crop.bottomRight)}:e.type==="callout"&&(r.tail={baseStart:rt(e.props.tail.baseStart),baseEnd:rt(e.props.tail.baseEnd),tip:rt(e.props.tail.tip)}),Ch(n)}function na(e){return tn(e)&&zi(e.props.src)}function ra(e){let t=Kn(e.props,["w","h","name","isAnimated","mimeType","src","fileSize","storage"]);return e.props.storage&&(t.storage={kind:"remote-asset",storageKey:e.props.storage.storageKey,assetId:e.props.storage.assetId}),t.src=Vn(e.props.src)??"",{id:e.id,type:"image",props:t}}function Hh(e){return{blocks:e.blocks.map(t=>({...Kn(t,["type","level","align","lineHeight"]),children:t.children.map(Uh)}))}}function Uh(e){let t=e.type==="text"?["type","text","marks","color","backgroundColor","fontFamily","fontSize","boxedPaddingY","boxedVariant","boxedTone"]:["type","id","tex","display","marks","color","backgroundColor","fontFamily","fontSize","boxedPaddingY","boxedVariant","boxedTone","semanticRole","altText"];return $c(Kn(e,t))}function Vh(e){return e.type==="block"?{type:"block",blockId:e.blockId,dy:e.dy,...e.dx===void 0?{}:{dx:e.dx},...e.line===void 0?{}:{line:{index:e.line.index,dy:e.line.dy}},...e.reserveSpace===void 0?{}:{reserveSpace:e.reserveSpace}}:e.type==="shape"?{type:"shape",shapeId:e.shapeId,dx:e.dx,dy:e.dy,...e.rx===void 0?{}:{rx:e.rx},...e.ry===void 0?{}:{ry:e.ry}}:{type:"page"}}function rt(e){return{x:e.x,y:e.y}}function oa(e){let t=Yn(e.extensions)?{...e.extensions}:{},n=Object.fromEntries(e.shapes.flatMap(o=>pe(o)&&oo(o.meta)&&Nc(o.meta)?[[typeof o.id=="string"?o.id:`index:${e.shapes.indexOf(o)}`,o.meta]]:[])),r=Object.fromEntries(Object.entries(e.assets).flatMap(([o,i])=>pe(i)&&oo(i.meta)&&Nc(i.meta)?[[o,i.meta]]:[]));return(Object.keys(n).length>0||Object.keys(r).length>0)&&(t[Ah]={...Object.keys(n).length>0?{shapes:n}:{},...Object.keys(r).length>0?{assets:r}:{}}),Object.keys(t).length>0?t:void 0}function Kn(e,t){return Object.fromEntries(t.flatMap(n=>e[n]===void 0?[]:[[n,e[n]]]))}function oo(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(oo):pe(e)&&Object.values(e).every(oo)}function Nc(e){return!pe(e)||Object.keys(e).length>0}function pe(e){return typeof e=="object"&&e!==null}function zc(e){let t=new Map,n=e.map(r=>{if(r.type!=="graph2dShape"||r.props.boundsMode==="plot")return r;let o=Wn(r);return t.set(r.id,{previous:r,next:o,dx:o.x-r.x,dy:o.y-r.y}),o});return t.size===0?n:n.map(r=>{let o=r.anchor;if(o?.type!=="shape")return r;let i=t.get(r.id),a=t.get(o.shapeId);if(!i&&!a)return r;if(!a)return{...r,anchor:{...o,dx:o.dx+(i?.dx??0),dy:o.dy+(i?.dy??0)}};let s=a.previous,c=a.next,l=o.rx===void 0?s.x:s.x+s.props.w*o.rx,d=o.ry===void 0?s.y:s.y+s.props.h*o.ry,u=o.rx===void 0?c.x:c.x+c.props.w*o.rx,m=o.ry===void 0?c.y:c.y+c.props.h*o.ry;return{...r,anchor:{...o,dx:l+o.dx+(i?.dx??0)-u,dy:d+o.dy+(i?.dy??0)-m}}})}var rn=96/25.4,io={A4:{widthMm:210,heightMm:297},A3:{widthMm:297,heightMm:420},B5:{widthMm:182,heightMm:257},B4:{widthMm:257,heightMm:364}},ao=io.A4,nn={top:18,right:17,bottom:18,left:17},Wh={type:"columns",columnCount:1,columnGapMm:8},so=30,Yc={enabled:!1,heightMm:8,offsetMm:5,showOnFirstPage:!0,blocks:[{type:"paragraph",id:"page_header_running_body",children:[{type:"text",text:"{title}"}]}]},Kc={enabled:!1,heightMm:8,offsetMm:5,showOnFirstPage:!0,blocks:[{type:"paragraph",id:"page_footer_running_body",children:[{type:"text",text:"{page}"}],align:"center"}]},sa={width:ne(ao.widthMm),height:ne(ao.heightMm)},iR={width:ne(ao.widthMm-nn.left-nn.right),height:ne(ao.heightMm-nn.top-nn.bottom)},la=36;function ne(e){return e*rn}function jc(e,t,n){let r=e==="custom"?{widthMm:jn(n?.widthMm,io.A4.widthMm),heightMm:jn(n?.heightMm,io.A4.heightMm)}:io[e];return t==="landscape"?{widthMm:Math.max(r.widthMm,r.heightMm),heightMm:Math.min(r.widthMm,r.heightMm)}:{widthMm:Math.min(r.widthMm,r.heightMm),heightMm:Math.max(r.widthMm,r.heightMm)}}function qc(){return{preset:"A4",orientation:"portrait",pageSize:jc("A4","portrait"),marginsMm:{...nn},flow:{...Wh},header:Wc(Yc),footer:Wc(Kc)}}function on(e){let t=qc(),n=jh(e?.preset)?e.preset:t.preset,r=qh(e?.orientation)?e.orientation:t.orientation,o=n==="custom"?e?.pageSize:void 0,i=jc(n,r,o),a=Zh(e?.flow?.columnCount,1,4,t.flow.columnCount),s=Ee(e?.flow?.columnGapMm,t.flow.columnGapMm);return{preset:n,orientation:r,pageSize:i,marginsMm:{top:Ee(e?.marginsMm?.top,t.marginsMm.top),right:Ee(e?.marginsMm?.right,t.marginsMm.right),bottom:Ee(e?.marginsMm?.bottom,t.marginsMm.bottom),left:Ee(e?.marginsMm?.left,t.marginsMm.left)},flow:{type:"columns",columnCount:a,columnGapMm:s},header:Hc(e?.header,Yc),footer:Hc(e?.footer,Kc),overlay:su(e?.overlay)}}function co(e=qc()){let t=on(e),n=Math.max(0,t.pageSize.widthMm-t.marginsMm.left-t.marginsMm.right),r=Math.max(0,t.pageSize.heightMm-t.marginsMm.top-t.marginsMm.bottom),o=t.flow.columnGapMm*Math.max(0,t.flow.columnCount-1),i=t.flow.columnCount>0?Math.max(0,(n-o)/t.flow.columnCount):n;return{page:{widthMm:t.pageSize.widthMm,heightMm:t.pageSize.heightMm,widthPx:ne(t.pageSize.widthMm),heightPx:ne(t.pageSize.heightMm)},margins:{topPx:ne(t.marginsMm.top),rightPx:ne(t.marginsMm.right),bottomPx:ne(t.marginsMm.bottom),leftPx:ne(t.marginsMm.left)},content:{widthMm:n,heightMm:r,widthPx:ne(n),heightPx:ne(r)},flow:{columnCount:t.flow.columnCount,columnGapMm:t.flow.columnGapMm,columnGapPx:ne(t.flow.columnGapMm),columnWidthMm:i,columnWidthPx:ne(i)}}}function ca(e){let t=on(e),n={...t.marginsMm};return t.header?.enabled&&(n.top=Math.max(n.top,t.header.offsetMm+t.header.heightMm)),t.footer?.enabled&&(n.bottom=Math.max(n.bottom,t.footer.offsetMm+t.footer.heightMm)),{...t,marginsMm:n}}function Zc(e){let t=[],n=co(e);return(!Number.isFinite(e.pageSize.widthMm)||!Number.isFinite(e.pageSize.heightMm)||e.pageSize.widthMm<=0||e.pageSize.heightMm<=0)&&t.push("\u7528\u7D19\u30B5\u30A4\u30BA\u306F0\u3088\u308A\u5927\u304D\u3044\u5024\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),(!Number.isFinite(e.marginsMm.top)||!Number.isFinite(e.marginsMm.right)||!Number.isFinite(e.marginsMm.bottom)||!Number.isFinite(e.marginsMm.left)||e.marginsMm.top<0||e.marginsMm.right<0||e.marginsMm.bottom<0||e.marginsMm.left<0)&&t.push("\u4F59\u767D\u306F0\u4EE5\u4E0A\u306E\u5024\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),e.marginsMm.left+e.marginsMm.right>=e.pageSize.widthMm&&t.push("\u5DE6\u53F3\u306E\u4F59\u767D\u304C\u7528\u7D19\u5E45\u4EE5\u4E0A\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002"),e.marginsMm.top+e.marginsMm.bottom>e.pageSize.heightMm-so&&t.push(`\u4E0A\u4E0B\u306E\u4F59\u767D\u306F\u672C\u6587\u3092${so}mm\u4EE5\u4E0A\u6B8B\u3059\u3088\u3046\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`),(!Number.isInteger(e.flow.columnCount)||e.flow.columnCount<1||e.flow.columnCount>4)&&t.push("\u6BB5\u6570\u306F1\u304B\u30894\u306E\u6574\u6570\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),(!Number.isFinite(e.flow.columnGapMm)||e.flow.columnGapMm<0)&&t.push("\u6BB5\u9593\u306F0\u4EE5\u4E0A\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),e.flow.columnGapMm*Math.max(0,e.flow.columnCount-1)>=n.content.widthMm&&t.push("\u6BB5\u9593\u304C\u672C\u6587\u5E45\u4EE5\u4E0A\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002"),t}function Jc(e){return!!(e?.blocks.some(uu)||eg(e?.overlay))}function ot(e,t=54){if(e.type==="section")return 64;if(e.type==="heading")return 48+Math.max(0,e.level-1)*4+lo(e.children,t)*10;if(e.type==="paragraph")return 18+lo(e.children,t)*iu(e.lineHeight);if(e.type==="list")return 12+ou(e,t);if(e.type==="boxBlock"){let n=e.frame?.paddingPx;return(n?.top??12)+(n?.bottom??12)+Qc(e,t)+Math.max(24,Yh(e.blocks,eu(t)))}if(e.type==="layoutSection"){let n=Number.isInteger(e.layout.columnCount)?Math.min(4,Math.max(1,e.layout.columnCount)):2,r=Math.max(12,Math.floor(t/n)),o=e.children.reduce((i,a)=>i+ot(a,r),0);return Math.max(32,Math.ceil(o/n))}return e.type==="problem"?tu.reduce((n,r)=>n+nu(e,r,t),0):48}function Qc(e,t){return e.title&&e.title.length>0?lo(e.title,t)*18:0}function eu(e){return Math.max(12,e-4)}var tu=["lead","prompt","solution","hints"];function nu(e,t,n){return Math.max(Xh(e[t],n),ne(e.areaLayout?.[t]?.minHeightMm??0))}function Xh(e,t){return e.reduce((n,r)=>n+ot(r,t),0)}function Yh(e,t){return e.reduce((n,r)=>n+ot(r,t),0)}function ru(e,t,n=0){return lo(e.children,Kh(t,n))*iu(void 0)}function Kh(e,t=0){return Math.max(8,e-t*4-3)}function ou(e,t,n=0){return e.items.reduce((r,o)=>{let i=(o.nested??[]).reduce((a,s)=>a+ou(s,t,n+1),0);return r+ru(o,t,n)+i},0)}function lo(e,t){let n=e.reduce((r,o)=>o.type==="text"?r+o.text.length:r+Math.max(4,o.tex.length),0);return Math.max(1,Math.ceil(n/t))}function iu(e){let t=Number(e??"1.75");return 16*(Number.isFinite(t)?t:1.75)}function jh(e){return e==="A4"||e==="A3"||e==="B5"||e==="B4"||e==="custom"}function qh(e){return e==="portrait"||e==="landscape"}function jn(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function Ee(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function Zh(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)))}function Hc(e,t){let n=au(e?.blocks);return{enabled:typeof e?.enabled=="boolean"?e.enabled:t.enabled,heightMm:jn(e?.heightMm,t.heightMm),offsetMm:Ee(e?.offsetMm,t.offsetMm),showOnFirstPage:typeof e?.showOnFirstPage=="boolean"?e.showOnFirstPage:t.showOnFirstPage,blocks:n??t.blocks.map(lu),overlay:su(e?.overlay)}}function au(e){return Array.isArray(e)?e.flatMap(n=>{if(!n||typeof n!="object"||!("type"in n))return[];if(n.type==="heading"&&Array.isArray(n.children)){let r=n.level===1||n.level===2||n.level===3?n.level:2;return[{type:"heading",id:typeof n.id=="string"&&n.id?n.id:"running_heading",level:r,children:ia(n.children),align:Xc(n.align),lineHeight:tt(n.lineHeight)}]}if(n.type==="paragraph"&&Array.isArray(n.children))return[{type:"paragraph",id:typeof n.id=="string"&&n.id?n.id:"running_paragraph",children:ia(n.children),align:Xc(n.align),lineHeight:tt(n.lineHeight)}];if(n.type==="list"&&(n.listType==="bullet"||n.listType==="ordered")&&Array.isArray(n.items)){let r=Jh(n.items);return r.length===0?[]:[{type:"list",id:typeof n.id=="string"&&n.id?n.id:"running_list",listType:n.listType,start:jn(n.start,0)||void 0,markerStyle:n.listType==="ordered"?$i(n.markerStyle):void 0,items:r}]}return[]}):void 0}function Jh(e){return e.flatMap(t=>{if(!Qh(t)||t.type!=="listItem"||!Array.isArray(t.children))return[];let n=Array.isArray(t.nested)?au(t.nested)?.filter(r=>r.type==="list"):void 0;return[{type:"listItem",id:typeof t.id=="string"&&t.id?t.id:"running_list_item",children:ia(t.children),...n&&n.length>0?{nested:n}:{}}]})}function Qh(e){return typeof e=="object"&&e!==null}function su(e){if(!e||typeof e!="object")return;let t=e,n=t.overlaySnapshot?me(t.overlaySnapshot):void 0,r=typeof t.updatedAt=="string"?t.updatedAt:void 0;if(n)return{overlaySnapshot:n,...r?{updatedAt:r}:{}}}function eg(e){return e?.overlaySnapshot?me(e.overlaySnapshot).shapes.some(t=>!t.hidden):!1}function ia(e){return e.flatMap(t=>{if(!t||typeof t!="object"||!("type"in t))return[];let n=t;if(t.type==="text"){let r=Uc(n.boxedVariant),o=Vc(n.boxedTone);return[{type:"text",text:typeof n.text=="string"?n.text:"",marks:tg(n.marks),color:typeof n.color=="string"?n.color:void 0,backgroundColor:typeof n.backgroundColor=="string"?n.backgroundColor:void 0,fontFamily:typeof n.fontFamily=="string"?n.fontFamily:void 0,fontSize:jn(n.fontSize,0)||void 0,boxedPaddingY:Ee(n.boxedPaddingY,-1)>=0?Ee(n.boxedPaddingY,0):void 0,...r?{boxedVariant:r}:{},...o?{boxedTone:o}:{}}]}if(t.type==="mathInline"){let r=ng(n.marks),o=Uc(n.boxedVariant),i=Vc(n.boxedTone);return[{type:"mathInline",id:typeof n.id=="string"&&n.id?n.id:"running_math",tex:typeof n.tex=="string"?n.tex:"",display:"inline",...r?{marks:r}:{},...r?.includes("boxed")&&Ee(n.boxedPaddingY,-1)>=0?{boxedPaddingY:Ee(n.boxedPaddingY,0)}:{},...o?{boxedVariant:o}:{},...i?{boxedTone:i}:{},semanticRole:n.semanticRole==="equation"||n.semanticRole==="variable"?n.semanticRole:"expression"}]}return[]})}function tg(e){if(!Array.isArray(e))return;let t=e.filter(n=>n==="bold"||n==="italic"||n==="underline"||n==="boxed");return t.length>0?Array.from(new Set(t)):void 0}function ng(e){if(!Array.isArray(e))return;let t=e.filter(n=>n==="underline"||n==="boxed");return t.length>0?Array.from(new Set(t)):void 0}function Uc(e){return e==="frame"||e==="thick"||e==="double"||e==="oval"||e==="shade"?e:void 0}function Vc(e){return e==="gray"||e==="blue"||e==="green"||e==="red"||e==="yellow"?e:void 0}function Wc(e){return{...e,blocks:e.blocks?.map(lu),overlay:rg(e.overlay)}}function rg(e){if(e)return{...e,overlaySnapshot:e.overlaySnapshot?me(e.overlaySnapshot):void 0}}function lu(e){return e.type==="heading"?{...e,children:e.children.map(aa)}:e.type==="paragraph"?{...e,children:e.children.map(aa)}:cu(e)}function cu(e){return{...e,items:e.items.map(t=>({...t,children:t.children.map(aa),nested:t.nested?.map(cu)}))}}function aa(e){return e.type==="mathInline"?{...e,...e.marks?{marks:[...e.marks]}:{}}:{...e,marks:e.marks?[...e.marks]:void 0}}function uu(e){return e.type==="list"?e.items.some(t=>t.children.some(n=>n.type==="mathInline"?n.tex.trim():n.text.trim())||(t.nested??[]).some(uu)):e.children.some(t=>t.type==="mathInline"?t.tex.trim():t.text.trim())}function Xc(e){return e==="left"||e==="center"||e==="right"||e==="justify"?e:void 0}function du(e,t){return{heightPx:ne(t?.heightMm??0),widthPx:Math.max(0,e)}}function Ot(e){return e.map(t=>t.type==="text"?t.text:`$${t.tex}$`).join("")}function fu(){return null}function wt(e){let t=fu();t&&(t.counters[e]=(t.counters[e]??0)+1)}function ua(e,t){return t();try{return t()}finally{let r=performance.now()-n,o=fu();o&&(o.measures.push({name:e,duration:r,at:Date.now()}),o.measures.length>2e3&&o.measures.splice(0,o.measures.length-2e3))}}var yg=2;function yu(e,t,n,r){let o=hg(e);return gg(o.length>0?o:[e.getBoundingClientRect()]).map((a,s)=>({index:s,top:(a.top-t.top)*r,left:(a.left-t.left)*n,width:Math.max(0,(a.right-a.left)*n),height:Math.max(0,(a.bottom-a.top)*r)}))}function hg(e){let t=e.ownerDocument.createRange();try{return t.selectNodeContents(e),Array.from(t.getClientRects()).filter(n=>n.width>0&&n.height>0)}finally{t.detach()}}function gg(e){let t=[],n=[...e].sort((r,o)=>r.top-o.top||r.left-o.left);for(let r of n){let o=t.find(i=>xg(r,i));if(!o){t.push({top:r.top,right:r.right,bottom:r.bottom,left:r.left});continue}o.top=Math.min(o.top,r.top),o.right=Math.max(o.right,r.right),o.bottom=Math.max(o.bottom,r.bottom),o.left=Math.min(o.left,r.left)}return t.sort((r,o)=>r.top-o.top||r.left-o.left)}function xg(e,t){let n=(e.top+e.bottom)/2,r=(t.top+t.bottom)/2;if(Math.abs(n-r)<=yg)return!0;let o=Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top),i=Math.min(e.height,t.bottom-t.top);return o>Math.max(1,i*.45)}import{useMemo as Hv}from"react";var bg=new Set(["newcommand","renewcommand","providecommand"]);function hu(e){let t=[],n={};if(e.length>2e4)return{issues:[{line:1,message:`\u30D7\u30EA\u30A2\u30F3\u30D6\u30EB\u306F${2e4.toLocaleString()}\u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`}],macros:n};let r=0;for(;r<e.length&&(r=uo(e,r),!(r>=e.length));){let o=r,i=da(e,r);if(!i){t.push({line:Ce(e,r),message:"\u3053\u306E\u884C\u306FTeX\u30B3\u30DE\u30F3\u30C9\u306E\u5B9A\u7FA9\u3068\u3057\u3066\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093\u3002"}),r=Xe(e,r);continue}if(r=i.end,!bg.has(i.name)){t.push({line:Ce(e,o),message:`\\${i.name}\u306B\u306F\u307E\u3060\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002\\newcommand\u3001\\renewcommand\u3001\\providecommand\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002`}),r=Xe(e,r);continue}r=uo(e,r);let a=Sg(e,r);if(!a){t.push({line:Ce(e,o),message:"\u5B9A\u7FA9\u3059\u308B\u30B3\u30DE\u30F3\u30C9\u540D\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}),r=Xe(e,r);continue}r=uo(e,a.end);let s=0;if(e[r]==="["){let d=vg(e,r);if(!d||!/^\d+$/.test(d.value.trim())){t.push({line:Ce(e,o),message:"\u5F15\u6570\u306E\u6570\u306F0\u304B\u30899\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}),r=Xe(e,r);continue}if(s=Number(d.value.trim()),s<0||s>9){t.push({line:Ce(e,o),message:"\u5F15\u6570\u306E\u6570\u306F0\u304B\u30899\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}),r=Xe(e,r);continue}if(r=uo(e,d.end),e[r]==="["){t.push({line:Ce(e,o),message:"\u7701\u7565\u53EF\u80FD\u306A\u5F15\u6570\u306B\u306F\u307E\u3060\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002"}),r=Xe(e,r);continue}}let c=gu(e,r);if(!c){t.push({line:Ce(e,o),message:"\u5C55\u958B\u5185\u5BB9\u3092\u6CE2\u62EC\u5F27\u3067\u9589\u3058\u3066\u304F\u3060\u3055\u3044\u3002"}),r=Xe(e,r);continue}r=c.end;let l=n[a.name];if(i.name==="newcommand"&&l){t.push({line:Ce(e,o),message:`\\${a.name}\u306F\u3059\u3067\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059\u3002`});continue}if(i.name==="renewcommand"&&!l){t.push({line:Ce(e,o),message:`\\${a.name}\u306F\u307E\u3060\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002`});continue}if(!(i.name==="providecommand"&&l)){if(!l&&Object.keys(n).length>=100){t.push({line:Ce(e,o),message:"\u72EC\u81EA\u30B3\u30DE\u30F3\u30C9\u306F100\u4EF6\u307E\u3067\u5B9A\u7FA9\u3067\u304D\u307E\u3059\u3002"});continue}n[a.name]={args:s,def:c.value}}}return{issues:t,macros:n}}function uo(e,t){let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n+=1;continue}if(e[n]==="%"&&e[n-1]!=="\\"){n=Xe(e,n);continue}break}return n}function Xe(e,t){let n=e.indexOf(`
|
|
9
9
|
`,t);return n===-1?e.length:n+1}function Ce(e,t){let n=1;for(let r=0;r<t;r+=1)e[r]===`
|
|
10
|
-
`&&(n+=1);return n}function ia(e,t){if(e[t]!=="\\")return null;let n=t+1;for(;n<e.length&&/[A-Za-z@]/.test(e[n]);)n+=1;return n===t+1?null:{end:n,name:e.slice(t+1,n)}}function dg(e,t){if(e[t]==="{"){let n=cu(e,t);if(!n)return null;let r=ia(n.value.trim(),0);return r&&r.end===n.value.trim().length?{end:n.end,name:r.name}:null}return ia(e,t)}function pg(e,t){let n=e.indexOf("]",t+1);return e[t]==="["&&n>=0?{end:n+1,value:e.slice(t+1,n)}:null}function cu(e,t){if(e[t]!=="{")return null;let n=0;for(let r=t;r<e.length;r+=1){if(e[r]==="%"&&e[r-1]!=="\\"){r=Xe(e,r)-1;continue}if(e[r]==="\\"){r+=1;continue}if(e[r]==="{"&&(n+=1),e[r]==="}"&&(n-=1,n===0))return{end:r+1,value:e.slice(t+1,r)}}return null}var mg={doubleboxed:{def:String.raw`\class{sigma-doubleboxed}{\boxed{#1}}`,args:1},thickboxed:{def:String.raw`\class{sigma-thickboxed}{\boxed{#1}}`,args:1},outerthickdoubleboxed:{def:String.raw`\class{sigma-outerthick-doubleboxed}{\boxed{#1}}`,args:1}},fg={[String.raw`\doubleboxed`]:String.raw`\htmlClass{sigma-doubleboxed}{\boxed{#1}}`,[String.raw`\thickboxed`]:String.raw`\htmlClass{sigma-thickboxed}{\boxed{#1}}`,[String.raw`\outerthickdoubleboxed`]:String.raw`\htmlClass{sigma-outerthick-doubleboxed}{\boxed{#1}}`},jn=new Map,yg=32,uu=0;function aa(e=""){let t=jn.get(e);if(t)return t;let n=lu(e),r=Object.fromEntries(Object.entries(n.macros).map(([a,s])=>[a,s])),o=Object.fromEntries(Object.entries(n.macros).map(([a,s])=>[`\\${a}`,s.def]));uu+=1;let i={issues:n.issues,katexMacros:{...fg,...o},mathLiveMacros:{...mg,...r},signature:`m${uu}`};if(jn.size>=yg){let a=jn.keys().next().value;a!==void 0&&jn.delete(a)}return jn.set(e,i),i}var qn=aa(),hg=new Set(["sigma-doubleboxed","sigma-thickboxed","sigma-outerthick-doubleboxed"]);function tn(e){return e.command===String.raw`\htmlClass`&&!!(e.class&&hg.has(e.class))}var nn={macroSet:qn,typesetStyle:hi};function sa(e,t){return{macroSet:aa(e),typesetStyle:Tr(t)}}function du(e,t){return e.typesetStyle===t?e:{...e,typesetStyle:t}}function Le(e,t){return`${e.typesetStyle}\0${e.macroSet.signature}\0${t}`}import Eg from"katex";import Cg from"katex/src/fontMetricsData.js";import gg from"katex";import{convertLatexToMarkup as xg,validateLatex as DI}from"mathlive";var pu=/\\begin\{(aligned|alignedat|array|cases|displaylines|matrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix|smallmatrix)\}([\s\S]*?)\\end\{\1\}/g,hu="\\\\";var bg=new Set(["mbox","text"]),Sg=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}\u3000-\u303f\uff01-\uff60\uffe0-\uffee]/u,vg={macros:qn.katexMacros,maxExpand:1e3,maxSize:100,output:"html",strict:"ignore",throwOnError:!0,trust:tn},Zn=new Map;var Pg=5e3,Mg=/class="[^"]*\bML__error\b/;function so(e,t){let n=Le(t,e),r=Zn.get(n);if(r!==void 0)return r;let o=Tg(e,t);if(Zn.size>=Pg){let i=Zn.keys().next().value;i!==void 0&&Zn.delete(i)}return Zn.set(n,o),o}function Tg(e,t){let{macroSet:n,typesetStyle:r}=t,o=xg(mt(Og(e)||"\\square",r),{defaultMode:"math",macros:n.mathLiveMacros});return Mg.test(o)?Ig(mt(la(e)||"\\square",r),n)??o:o}function Og(e){return xu(gu(e)).replace(/\\placeholder(?:\[([^\]]*)\])?\{\s*\}/g,(t,n)=>`\\placeholder[${n||"?"}]{\\square}`).replace(/\\placeholder\{([^{}]+)\}/g,(t,n)=>`\\placeholder[?]{${n}}`)}function la(e){return xu(gu(e)).replace(/\\placeholder(?:\[[^\]]*\])?\{([^{}]*)\}/g,(t,n)=>n.trim()?`{${n}}`:"\\square")}function gu(e){if(!e.includes(hu)||/^\s*\\displaylines\{/.test(e))return e;let t="",n=0,r;for(pu.lastIndex=0;(r=pu.exec(e))!==null;)t+=mu(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=mu(e.slice(n)),t}function xu(e){let t="",n=0;for(;n<e.length;){if(e[n]==="\\"){let o=Rg(e,n),i=o.name&&bg.has(o.name)?Ag(e,o.end):-1;if(i>=0){t+=e.slice(n,i+1),n=i+1;continue}t+=e.slice(n,o.end),n=o.end;continue}if(fu(e,n)){let o=n;do n+=yu(e,n);while(n<e.length&&fu(e,n));t+=`\\text{${e.slice(o,n)}}`;continue}let r=yu(e,n);t+=e.slice(n,n+r),n+=r}return t}function mu(e){let t=wg(e.trim()).map(o=>o.trim()).filter(Boolean);if(t.length<2)return e;let n=e.match(/^\s*/)?.[0]??"",r=e.match(/\s*$/)?.[0]??"";return`${n}\\begin{aligned}${t.map(Bg).join(hu)}\\end{aligned}${r}`}function wg(e){let t=[],n=0;for(let r=0;r<e.length-1;r+=1)kg(e,r)&&(t.push(e.slice(n,r)),r+=1,n=r+1);return t.push(e.slice(n)),t}function kg(e,t){return e[t]==="\\"&&e[t+1]==="\\"&&e[t-1]!=="\\"&&e[t+2]!=="\\"}function Bg(e){return e.includes("&")?e:e.replace(/\s*(=|<|>|\\leq{0,2}\b|\\geq{0,2}\b|\\neq?\b|\\approx\b|\\equiv\b|\\iff\b|\\to\b|\\Rightarrow\b|\\Leftarrow\b)/,"&$1")}function Rg(e,t){let n=t+1;for(;n<e.length&&/[a-zA-Z]/.test(e[n]??"");)n+=1;return n>t+1?{end:n,name:e.slice(t+1,n)}:{end:Math.min(t+2,e.length),name:null}}function Ag(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]??"");)n+=1;if(e[n]!=="{")return-1;let r=0;for(;n<e.length;n+=1){let o=e[n];if(o==="\\"){n+=1;continue}if(o==="{")r+=1;else if(o==="}"&&(r-=1,r===0))return n}return-1}function fu(e,t){let n=e.codePointAt(t);return n===void 0?!1:Sg.test(String.fromCodePoint(n))}function yu(e,t){let n=e.codePointAt(t);return n!==void 0&&n>65535?2:1}function Ig(e,t=qn){try{return gg.renderToString(e,{...vg,macros:t.katexMacros})}catch{return null}}var ca=Cg,Lg=Eg.__renderToHTMLTree,Ng=/class="ML__strut" style="height:([0-9.]+)em"/,Fg=/class="ML__strut--bottom" style="height:([0-9.]+)em;vertical-align:-([0-9.]+)em"/,_g={maxExpand:1e3,maxSize:100,output:"html",strict:"ignore",throwOnError:!0,trust:tn},Dg=/\\(?:frac|dfrac|tfrac|cfrac|sqrt|int|oint|iint|iiint|sum|prod|coprod|lim|begin|binom|dbinom|tbinom|overbrace|underbrace)\b/,bu=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],Gg=/^reset-size(\d+)$/,$g=/^size(\d+)$/,zg=.12,Hg=1,Pu=.6,Ug=1e-4,Su=1.05,vu=1.25,Vg=1.05,Wg=1.6,Xg=1,Jn=new Map,Yg=5e3;function co(e,t){let n=Le(t,e),r=Jn.get(n);if(r!==void 0)return r;let o=Kg(e,t);if(Jn.size>=Yg){let i=Jn.keys().next().value;i!==void 0&&Jn.delete(i)}return Jn.set(n,o),o}function Kg(e,t){let n=jg(e,t),r=qg(e,t),o=(r?r.widthEm:nx(e))*Vg;if(n){let i=r?Math.max(n.ascentEm,r.ascentEm):n.ascentEm,a=r?Math.max(n.descentEm,r.descentEm):n.descentEm;return{ascentEm:i*Su,descentEm:a*Su,widthEm:o,source:"mathlive"}}return r?{ascentEm:r.ascentEm*vu,descentEm:r.descentEm*vu,widthEm:o,source:"katex"}:{ascentEm:Dg.test(e)?Wg:Xg,descentEm:0,widthEm:o,source:"heuristic"}}function jg(e,t){let n;try{n=so(e,t)}catch{return null}let r=n.match(Ng);if(!r)return null;let o=n.match(Fg),i=Number.parseFloat(r[1]),a=o?Number.parseFloat(o[2]):0;return!Number.isFinite(i)||!Number.isFinite(a)?null:{ascentEm:i,descentEm:a}}function qg(e,t){try{let n=mt(la(e)||"\\square",t.typesetStyle),r=Lg(n,{..._g,macros:t.macroSet.katexMacros}),o=typeof r.height=="number"?r.height:0,i=typeof r.depth=="number"?r.depth:0;return{ascentEm:o,descentEm:i,widthEm:ua(r,1)}}catch{return null}}function ua(e,t){let n=e.classes??[];if(n.includes("strut")||n.includes("pstrut"))return 0;if(n.includes("nulldelimiter"))return zg*t;if(e.text!==void 0)return Jg(e)*t;let r=t*Zg(n),o=e.children??[],a=n.includes("vlist")||n.includes("vlist-r")||n.includes("vlist-t")||n.includes("vlist-t2")?Math.max(0,...o.map(u=>ua(u,r))):o.reduce((u,m)=>u+ua(m,r),0),s=e.style??{},c=((rn(s.marginLeft)??0)+(rn(s.marginRight)??0)+(rn(s.paddingLeft)??0)+(rn(s.paddingRight)??0))*t,l=a+c,d=rn(s.width)??rn(s.minWidth);return d!==void 0&&(l=Math.max(l,d*t)),typeof e.width=="number"&&(l=Math.max(l,e.width*t)),l}function Zg(e){let t,n;for(let i of e){let a=Gg.exec(i);a&&(t=Number(a[1]));let s=$g.exec(i);s&&(n=Number(s[1]))}if(t===void 0||n===void 0)return 1;let r=bu[t-1],o=bu[n-1];return r&&o?o/r:1}function rn(e){if(!e)return;let t=/^(-?[0-9.]+)em$/.exec(e.trim());if(!t)return;let n=Number.parseFloat(t[1]);return Number.isFinite(n)?n:void 0}function Jg(e){let t=e.text??"",n=Array.from(t);if(n.length===0)return 0;if(n.length===1)return typeof e.width=="number"?e.width:lo(n[0]);let r=n[0].codePointAt(0),o=typeof e.width=="number"&&r!==void 0?Qg(r,e.width):[];if(o.length===0)return n.reduce((a,s)=>a+lo(s),0);let i=o.map(a=>n.reduce((s,c)=>s+ex(c,a),0));return Math.max(...i)}function Qg(e,t){let n=[];for(let r of Object.keys(ca)){let o=ca[r][String(e)];o&&Math.abs(o[4]-t)<Ug&&n.push(r)}return n}function ex(e,t){let n=e.codePointAt(0);if(n===void 0)return 0;let r=ca[t][String(n)];return r?r[4]:lo(e)}function lo(e){return tx(e)?Hg:Pu}function tx(e){let t=e.codePointAt(0)??0;return t>=4352&&t<=4607||t>=11904&&t<=42191||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519}function nx(e){let t=e.replace(/\\(?:begin|end)\s*\{[^}]*\}/g,"").replace(/\\[a-zA-Z]+/g,"M").replace(/[{}^_\\]/g,""),n=0;for(let r of t)n+=lo(r);return Math.max(n,Pu)}function rx(){return{measureTexEm(e){return co(e,nn)}}}function Mu(){gl(rx())}Mu();var Tu="boxed-text",ox="boxed-inline-math";function Ou(e,t={}){let{paddingY:n,tone:r,variant:o}=Mr(e),i={"data-sigma-doc-boxed-text":"true"};return n!==void 0&&(i["data-sigma-doc-boxed-padding-y"]=String(n)),o&&o!=="frame"&&(i["data-sigma-doc-boxed-variant"]=o),r&&(i["data-sigma-doc-boxed-tone"]=r),t.math&&(i["data-sigma-doc-boxed-math"]="true"),{attrs:i,className:t.math?`${Tu} ${ox}`:Tu,style:ix(n)}}function wu(e){if(!e)return{};let t={"data-boxed-run-height-target":"true","data-boxed-run-id":e.runId,"data-boxed-run-segment-id":e.segmentId,"data-boxed-run-segment-index":String(e.segmentIndex),"data-boxed-run-segment-count":String(e.segmentCount),"data-boxed-run-style-key":e.styleKey};return e.connectLeft&&(t["data-boxed-run-connect-left"]="true"),e.connectRight&&(t["data-boxed-run-connect-right"]="true"),t}function ku(e){let t={};return e.color&&(t.color=e.color),e.backgroundColor&&(t["background-color"]=e.backgroundColor),e.fontFamily&&(t["font-family"]=e.fontFamily),e.fontSizePt&&(t["font-size"]=`${e.fontSizePt}pt`),Object.keys(t).length>0?t:void 0}function ix(e){let t=Mr({paddingY:e}).paddingY;return t!==void 0?{"--boxed-text-padding-y":`${t}px`,"--boxed-text-line-height":`calc(1.78em + ${t*2+2}px)`}:void 0}function Bu(e){if(typeof window>"u")return 1;let t=1;for(let n=e;n;n=n.parentElement){let r=window.getComputedStyle(n),o=Number.parseFloat(r.zoom);Number.isFinite(o)&&o>0&&(t*=o),t*=ax(r.transform)}return t>0?t:1}function ax(e){if(!e||e==="none")return 1;let t=/^matrix(?:3d)?\(\s*([-\d.eE+]+)/.exec(e),n=t?Number.parseFloat(t[1]):Number.NaN;return Number.isFinite(n)&&n>0?n:1}var on=[{label:"\u9ED2",value:"#0d0d0d"},{label:"\u30B0\u30EC\u30FC",value:"#6b7280"},{label:"\u8584\u30B0\u30EC\u30FC",value:"#9ca3af"},{label:"\u8D64",value:"#dc2626"},{label:"\u9752",value:"#2563eb"}];var sx=on[0].value,lx=/^#[0-9a-f]{6}$/i,Nu=800,Fu=32,cx=220,ux=32,dx=120,uo=1e-12,px="yOfX",mx="solid",fx=2.4,Ru={min:"0",max:"2*pi"};function wt(e){return Vu(e.viewBox)}function Ye(e){return Vu(e.graphViewBox??e.viewBox)}function ma(e,t=dt){let n=wt(e),r=Ye(e),o=Ix(n,r);if(!o)return{x:t.left,y:t.top,width:0,height:0};let i=Y(o.xMin,o.yMax,n,e,t),a=Y(o.xMax,o.yMin,n,e,t);return{x:i.x,y:i.y,width:Math.max(0,a.x-i.x),height:Math.max(0,a.y-i.y)}}function _u(e,t,n={}){try{let r=le(e),o=wt(e),i=Ye(e),a=Iu(t.left,t.top+t.height,o,e,r),s=Iu(t.left+t.width,t.top,o,e,r),c={xMin:a.x,xMax:s.x,yMin:a.y,yMax:s.y};if(!Eu(c))return null;let l=e.graphViewBox!==void 0&&!Ex(o,i),d=l?{xMin:c.xMin+(o.xMin-i.xMin),xMax:c.xMax+(o.xMax-i.xMax),yMin:c.yMin+(o.yMin-i.yMin),yMax:c.yMax+(o.yMax-i.yMax)}:c;if(!Eu(d))return null;let u=le(e),m={...e,width:n.resizeToCrop?Math.max(1,t.width+u.left+u.right):e.width,height:n.resizeToCrop?Math.max(1,t.height+u.top+u.bottom):e.height,viewBox:Cu(d),curves:e.curves.map(h=>Cx(h,i,c))};return l?m.graphViewBox=Cu(c):delete m.graphViewBox,m}catch{return null}}function Du(e){let t=[];for(let n of e.curves)if(n.mode==="parametric"?n.expr||n.yExpr:n.expr)try{let o=yx(n,e);if(o&&xx(n,e,o)){t.push("\u66F2\u7DDA\u304C\u8868\u793A\u7BC4\u56F2\u306E\u5916\u306B\u3042\u308A\u307E\u3059\u3002\u8868\u793A\u7BC4\u56F2\u3092\u8ABF\u6574\u3057\u3066\u304F\u3060\u3055\u3044\u3002");break}}catch{}return t}function Ot(e){return ae(e,0)}function ke(e,t){if(e===void 0||e.trim()==="")return t;try{return Ot(e)}catch{return null}}function ae(e,t,n="x"){return fo(e,{[n]:t})}function Gu(e,t,n){let r=Dx(e);return r?fo(r.left,{x:t,y:n})-fo(r.right,{x:t,y:n}):fo(e,{x:t,y:n})}function fo(e,t){let r=new pa(e,t).parse();if(!Number.isFinite(r))throw new Error("Expression produced a non-finite value");return r}function yx(e,t){try{let n=Ye(t),r=it(e.mode);if(r==="implicit")return ln(e,"implicit",n)?(Gu(e.expr,(n.xMin+n.xMax)/2,(n.yMin+n.yMax)/2),{xMin:n.xMin,xMax:n.xMax,yMin:n.yMin,yMax:n.yMax}):null;let o=ln(e,r,n);if(!o)return null;let i=Sa(e.samples??180,Fu,Nu),a=1/0,s=-1/0,c=1/0,l=-1/0,d=!1;for(let u=0;u<=i;u+=1){let m=o.min+(o.max-o.min)*u/i;try{let h;if(r==="parametric"){let y=e.yExpr?.trim();if(!y)continue;h={x:ae(e.expr,m,"t"),y:ae(y,m,"t")}}else{let y=ae(e.expr,m,o.variableName);h=r==="xOfY"?{x:y,y:m}:{x:m,y}}if(!Number.isFinite(h.x)||!Number.isFinite(h.y))continue;d=!0,a=Math.min(a,h.x),s=Math.max(s,h.x),c=Math.min(c,h.y),l=Math.max(l,h.y)}catch{}}return d?{xMin:a,xMax:s,yMin:c,yMax:l}:null}catch{return null}}function Au(e,t){return e.min<=t.max&&t.min<=e.max}var hx=40,gx=1e-9;function fa(e,t,n,r,o){let i=t,a=n,s=null,c=Math.abs(r)*gx;for(let l=0;l<hx&&!(Math.abs(a-i)<=c);l+=1){let d=(i+a)/2,u=e(d);if(!u){a=d;continue}if(i=d,s=u,o(u))break}return s}function ya(e,t,n=dt){try{let r=wt(t),o=Ye(t),i=it(e.mode),a=t.width-n.left-n.right,s=t.height-n.top-n.bottom;if(a<=0||s<=0)return"";if(i==="implicit")return bx(e,t,r,o,n);let c=ln(e,i,o);if(!c)return"";let l=Sa(e.samples??180,Fu,Nu),d=o.yMax-o.yMin,u=o.xMax-o.xMin,m=o.xMin-u*8,h=o.xMax+u*8,y=o.yMin-d*8,g=o.yMax+d*8,x=c.max-c.min,S=[],I=!1,R=P=>{try{if(i==="parametric"){let Q=e.yExpr?.trim();if(!Q)return null;let Z={x:ae(e.expr,P,"t"),y:ae(Q,P,"t")};return Number.isFinite(Z.x)&&Number.isFinite(Z.y)?Z:null}let D=ae(e.expr,P,c.variableName);return Number.isFinite(D)?i==="xOfY"?{x:D,y:P}:{x:P,y:D}:null}catch{return null}},M=P=>P.x>=m&&P.x<=h&&P.y>=y&&P.y<=g,C=P=>{let D=Y(P.x,P.y,r,t,n);S.push(`${I?"L":"M"}${sn(D.x)} ${sn(D.y)}`),I=!0},z=(P,D)=>fa(R,P,D,x,Q=>!M(Q)),f=null;for(let P=0;P<=l;P+=1){let D=c.min+x*P/l,Q=R(D);if(!Q){if(f!==null){let Z=z(f,D);Z&&C(Z)}f=null,I=!1;continue}if(!M(Q)){f=D,I=!1;continue}if(f===null&&P>0){let Z=c.min+x*(P-1)/l,v=z(D,Z);v&&C(v)}C(Q),f=D}return S.join(" ")}catch{return""}}function xx(e,t,n){if(ya(e,t).length===0)return!0;let o=Ye(t),i=Au({min:n.xMin,max:n.xMax},{min:o.xMin,max:o.xMax}),a=Au({min:n.yMin,max:n.yMax},{min:o.yMin,max:o.yMax});return!(i&&a)}function bx(e,t,n,r,o){let i=ln(e,"implicit",r);if(!i)return"";let a=Sa(e.samples??dx,ux,cx),s=[];for(let l=0;l<=a;l+=1){let d=r.yMin+(r.yMax-r.yMin)*l/a,u=[];for(let m=0;m<=a;m+=1){let h=i.min+(i.max-i.min)*m/a;u.push({x:h,y:d,value:Sx(e.expr,h,d)})}s.push(u)}let c=[];for(let l=0;l<a;l+=1)for(let d=0;d<a;d+=1){let u=s[l][d],m=s[l][d+1],h=s[l+1][d+1],y=s[l+1][d],g=vx([po(u,m),po(m,h),po(h,y),po(y,u)]);for(let x=0;x+1<g.length;x+=2){let S=Y(g[x].x,g[x].y,n,t,o),I=Y(g[x+1].x,g[x+1].y,n,t,o);Gx(S,I)<=.001||c.push(`M${sn(S.x)} ${sn(S.y)} L${sn(I.x)} ${sn(I.y)}`)}}return c.join(" ")}function Sx(e,t,n){try{return Gu(e,t,n)}catch{return Number.NaN}}function po(e,t){if(!Number.isFinite(e.value)||!Number.isFinite(t.value))return null;let n=Math.abs(e.value)<=uo,r=Math.abs(t.value)<=uo;if(n&&r)return null;if(n)return{x:e.x,y:e.y};if(r)return{x:t.x,y:t.y};if(e.value>0==t.value>0)return null;let o=e.value/(e.value-t.value);if(!Number.isFinite(o)||o<-uo||o>1+uo)return null;let i=Math.min(1,Math.max(0,o));return{x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}}function vx(e){let t=[];for(let n of e)n&&(t.some(r=>Math.abs(r.x-n.x)<1e-9&&Math.abs(r.y-n.y)<1e-9)||t.push(n));return t}function Y(e,t,n,r,o=dt){let i=r.width-o.left-o.right,a=r.height-o.top-o.bottom;return{x:o.left+(e-n.xMin)/(n.xMax-n.xMin)*i,y:o.top+(n.yMax-t)/(n.yMax-n.yMin)*a}}function Iu(e,t,n,r,o=dt){let i=r.width-o.left-o.right,a=r.height-o.top-o.bottom,s=i<=0?1:i,c=a<=0?1:a;return{x:n.xMin+(e-o.left)/s*(n.xMax-n.xMin),y:n.yMax-(t-o.top)/c*(n.yMax-n.yMin)}}function $u(e,t,n,r=12){let o=t-e;if(!Number.isFinite(o)||o<=0)return[];let i=ke(n,null);(i===null||i<=0||!Number.isFinite(i))&&(i=Ox(o/Math.max(2,r-1)));let a=[],s=Math.ceil((e-1e-10)/i)*i,c=Math.min(r*5,80);for(let l=0;l<c;l+=1){let d=s+i*l;if(d>t+i*1e-6)break;d>=e-i*1e-6&&a.push(Nx(d))}return a}function ha(e,t="number",n){if(t==="pi")return Lx(e);let r=Fx(n);return r!==null?_x(e,r):ba(e)}function Qn(e,t=sx){return e&&lx.test(e)?e:t}function it(e){return e==="xOfY"||e==="parametric"||e==="implicit"?e:px}function Px(e){return e==="dashed"||e==="dotted"?e:mx}function ga(e){return!Number.isFinite(e)||e===void 0||e<.5||e>8?fx:e}function Mx(e){let t=it(e.mode);if(t==="parametric"){let r=kx(e);return Uu(r.xExpr,r.yExpr)}let n=e.label?.trim();return n||Tx(t,e.expr)}function Tx(e,t,n){let r=it(e);return r==="parametric"?Uu(t,n??""):r==="implicit"?t.includes("=")?t:`${t} = 0`:`${wx(r)}${t}`}function zu(e){let t=Px(e.dash);if(t==="solid")return;let n=ga(e.strokeWidth);return t==="dashed"?`${da(n*3)} ${da(n*2)}`:`0 ${da(n*2.2)}`}var l0=[{color:on[0].value,dash:"solid"},{color:on[0].value,dash:"dashed"},{color:on[1].value,dash:"solid"},{color:on[0].value,dash:"dotted"},{color:on[1].value,dash:"dashed"}];function xa(e){let t=ke(e.x,null),n=ke(e.y,null);return t===null||n===null?null:{x:t,y:n}}function Hu(e){let t=e.showFormulaLabels===!1?[]:e.curves.map(r=>Mx(r)),n=(e.points??[]).map(r=>r.label).filter(Boolean);return[e.title,...t,...n].filter(Boolean).join(" ")}function Ox(e){if(!Number.isFinite(e)||e<=0)return 1;let n=10**Math.floor(Math.log10(e)),r=e/n;return r<=1?n:r<=2?2*n:r<=5?5*n:10*n}function wx(e){return e==="xOfY"?"x = ":"y = "}function Uu(e,t){return`\\begin{cases} x = ${e} \\\\ y = ${t} \\end{cases}`}function kx(e){return Bx(e.label?.trim()??"")??{xExpr:e.expr,yExpr:e.yExpr??""}}function Bx(e){if(!e)return null;let t=e.match(/^\\begin\{cases\}\s*x\s*=\s*(.*?)\s*\\\\\s*y\s*=\s*(.*?)\s*\\end\{cases\}$/);if(t)return{xExpr:t[1].trim(),yExpr:t[2].trim()};let n=e.match(/^x\s*=\s*(.*?)\s*,\s*y\s*=\s*(.*?)$/);return n?{xExpr:n[1].trim(),yExpr:n[2].trim()}:null}function Rx(e){return e==="parametric"?"t":e==="xOfY"?"y":"x"}function Ax(e,t){return e==="xOfY"?{min:t.yMin,max:t.yMax}:e==="parametric"?{min:Ot(Ru.min),max:Ot(Ru.max)}:{min:t.xMin,max:t.xMax}}function ln(e,t,n){let r=Rx(t),o=Ax(t,n),i=ke(e.domain?.min,o.min),a=ke(e.domain?.max,o.max);if(i===null||a===null)return null;let s=t==="parametric"?i:Math.max(o.min,i),c=t==="parametric"?a:Math.min(o.max,a);return s>=c?null:{min:s,max:c,variableName:r}}function Vu(e){let t=Ot(e.xMin),n=Ot(e.xMax),r=Ot(e.yMin),o=Ot(e.yMax);if(t>=n)throw new Error("xMin must be smaller than xMax");if(r>=o)throw new Error("yMin must be smaller than yMax");return{xMin:t,xMax:n,yMin:r,yMax:o}}function Ix(e,t){let n=Math.max(e.xMin,t.xMin),r=Math.min(e.xMax,t.xMax),o=Math.max(e.yMin,t.yMin),i=Math.min(e.yMax,t.yMax);return n>=r||o>=i?null:{xMin:n,xMax:r,yMin:o,yMax:i}}function Eu(e){return Number.isFinite(e.xMin)&&Number.isFinite(e.xMax)&&Number.isFinite(e.yMin)&&Number.isFinite(e.yMax)&&e.xMin<e.xMax&&e.yMin<e.yMax}function Ex(e,t){return mo(e.xMin,t.xMin)&&mo(e.xMax,t.xMax)&&mo(e.yMin,t.yMin)&&mo(e.yMax,t.yMax)}function mo(e,t){return Math.abs(e-t)<1e-9}function Cu(e){return{xMin:an(e.xMin),xMax:an(e.xMax),yMin:an(e.yMin),yMax:an(e.yMax)}}function Cx(e,t,n){if(!e.domain)return e;let r=it(e.mode);if(r==="parametric")return e;let o=r==="xOfY"?t.yMin:t.xMin,i=r==="xOfY"?t.yMax:t.xMax,a=r==="xOfY"?n.yMin:n.xMin,s=r==="xOfY"?n.yMax:n.xMax,c=Lu(e.domain.min,o,a),l=Lu(e.domain.max,i,s);if(c===e.domain.min&&l===e.domain.max)return e;let d={...e.domain??{},...c===void 0?{}:{min:c},...l===void 0?{}:{max:l}};return{...e,domain:d}}function Lu(e,t,n){if(e===void 0||e.trim()==="")return e;let r=ke(e,null);return r===null?e:an(n+(r-t))}function an(e){return Math.abs(e)<1e-10?"0":Number(e.toFixed(6)).toString()}function ba(e){return Math.abs(e)<1e-9?"0":Number.isInteger(e)?String(e):Number(e.toFixed(3)).toString()}function Lx(e){if(Math.abs(e)<1e-9)return"0";let t=Math.PI/2,n=Math.round(e/t);if(Math.abs(e-n*t)>1e-5)return ba(e);let r=n<0?"-":"",o=Math.abs(n);if(o===1)return`${r}\\dfrac{\\pi}{2}`;if(o===2)return`${r}\\pi`;if(o%2===0){let i=o/2;return`${r}${i}\\pi`}return`${r}\\dfrac{${o}\\pi}{2}`}function Nx(e){return Math.abs(e)<1e-10?0:Number(e.toFixed(10))}function Fx(e){if(!e)return null;let t=e.trim().match(/^-?(\d+)\s*\/\s*(\d+)$/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=1||n===0)return null;let o=Wu(n,r),i=r/o;return i>1?i:null}function _x(e,t){if(Math.abs(e)<1e-9)return"0";let n=e*t,r=Math.round(n);if(Math.abs(n-r)>1e-6)return ba(e);let o=r<0?"-":"",i=Math.abs(r),a=Wu(i,t),s=i/a,c=t/a;return c===1?`${o}${s}`:`${o}\\dfrac{${s}}{${c}}`}function Wu(e,t){let n=Math.abs(Math.round(e)),r=Math.abs(Math.round(t));for(;r>0;){let o=n%r;n=r,r=o}return n||1}function sn(e){return Number(e.toFixed(3))}function da(e){return Number(e.toFixed(2))}function Dx(e){let t=e.split("=");if(t.length!==2)return null;let n=t[0].trim(),r=t[1].trim();return n&&r?{left:n,right:r}:null}function Gx(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Sa(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}var pa=class{constructor(t,n){this.input=t;this.variables=n;this.index=0}parse(){let t=this.parseAdditive();if(this.skipWhitespace(),this.index!==this.input.length)throw new Error(`Unexpected token at ${this.index}`);return t}parseAdditive(){let t=this.parseMultiplicative();for(;;)if(this.skipWhitespace(),this.consume("+"))t+=this.parseMultiplicative();else if(this.consume("-"))t-=this.parseMultiplicative();else return t}parseMultiplicative(){let t=this.parseUnary();for(;;)if(this.skipWhitespace(),this.consume("*"))t*=this.parseUnary();else if(this.consume("/"))t/=this.parseUnary();else if(this.startsImplicitFactor())t*=this.parseUnaryWithoutSign();else return t}parseUnary(){return this.skipWhitespace(),this.consume("+")?this.parseUnary():this.consume("-")?-this.parseUnary():this.parsePower()}parseUnaryWithoutSign(){return this.parsePower()}parsePower(){let t=this.parsePrimary();return this.skipWhitespace(),this.consume("^")?t**this.parseUnary():t}parsePrimary(){if(this.skipWhitespace(),this.consume("(")){let r=this.parseAdditive();if(this.skipWhitespace(),!this.consume(")"))throw new Error("Expected closing parenthesis");return r}let t=this.parseNumber();if(t!==null)return t;let n=this.parseIdentifier();if(n)return this.resolveIdentifier(n);throw new Error(`Expected value at ${this.index}`)}resolveIdentifier(t){let n=t.toLowerCase();if(this.skipWhitespace(),this.consume("(")){let o=this.parseAdditive();if(this.skipWhitespace(),!this.consume(")"))throw new Error("Expected closing parenthesis");return $x(n,o)}let r=this.variables[n];if(r!==void 0)return r;if(n==="pi")return Math.PI;if(n==="e")return Math.E;throw new Error(`Unknown identifier ${t}`)}parseNumber(){let t=/^(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/i.exec(this.input.slice(this.index));return t?(this.index+=t[0].length,Number(t[0])):null}parseIdentifier(){let t=/^[a-zA-Z_][a-zA-Z0-9_]*/.exec(this.input.slice(this.index));return t?(this.index+=t[0].length,t[0]):null}consume(t){return this.input.startsWith(t,this.index)?(this.index+=t.length,!0):!1}skipWhitespace(){for(;/\s/.test(this.input[this.index]??"");)this.index+=1}startsImplicitFactor(){this.skipWhitespace();let t=this.input[this.index]??"";return t==="("||t==="."||/\d|[a-zA-Z_]/.test(t)}};function $x(e,t){switch(e){case"abs":return Math.abs(t);case"acos":return Math.acos(t);case"asin":return Math.asin(t);case"atan":return Math.atan(t);case"cos":return Math.cos(t);case"exp":return Math.exp(t);case"ln":case"log":return Math.log(t);case"sin":return Math.sin(t);case"sqrt":return Math.sqrt(t);case"tan":return Math.tan(t);default:throw new Error(`Unknown function ${e}`)}}var yo="pt";function ho(e="node"){let t=typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;return`${e}_${t}`}function Xu(){return{measureMathLabel(e,t){let n=Cn({inlineContent:[{type:"mathInline",id:"graph_label_measurement",tex:e,display:"inline"}],fontSizePx:$t(t)});return{width:n.w,height:n.h}},evaluateExpression:ae,createInlineMathId:()=>ho("overlay_math")}}var zx="data-list-marker-typography",Hx="--sigma-doc-list-marker-font-family",Ux="--sigma-doc-list-marker-font-size",Vx=/[;{}<>\n\r]|\/\*|\*\//;function Wx(e){if(!e)return;let t={};e.fontFamily&&!Vx.test(e.fontFamily)&&(t[Hx]=e.fontFamily);let{fontSizePt:n}=e;return n!==void 0&&Number.isFinite(n)&&n>0&&(t[Ux]=`${n}pt`),Object.keys(t).length>0?t:void 0}function Yu(e){let t=Wx(zs(Hs(e)));return t?{attrs:{[zx]:""},style:t}:void 0}var Xx="sigma-underline-run",Yx=e=>e,Kx={margin:"0"},jx={margin:"0"};function go(e,t={}){let n=t.runIdPrefix??"overlay",r=gi(e,{runIdPrefix:n}),o=[];return r.children.forEach((i,a)=>{if(i.kind!=="block")return;let s=`${n}-${a}`;o.push({inlineModel:i.children,inlineNodes:e.blocks[a]?.children??[],isBlank:i.isBlank===!0,key:s,selfContainedStyle:Kx,style:Zx(i),tag:qx(i)})}),o}function ju(e){return e.isBlank?[]:Zu(e.inlineModel,{keyPrefix:e.key})}function qx(e){return e.blockType!=="heading"?"p":`h${e.headingLevel??3}`}function Zx(e){let t={};return e.textAlign&&(t["text-align"]=e.textAlign),e.lineHeight&&(t["line-height"]=e.lineHeight),Object.keys(t).length>0?t:void 0}function qu(e,t){return Zu(Or(e,{annotateBoxedRuns:!0,runIdPrefix:t.keyPrefix}).children,t)}function Zu(e,t){let n=[],r=[],o=()=>{if(r.length===0)return;let i=r[0],a=r[r.length-1];n.push({kind:"element",tag:"span",className:Xx,key:`${t.keyPrefix}-underline-run-${i.key}-${a.key}`,attrs:{"data-sigma-doc-underline-text":"true"},selfContainedStyle:cb(r.some(s=>s.entry.kind==="math")),children:r.map(s=>Ku(s,t))}),r=[]};for(let i of Jx(e,t)){if(i.kind==="piece"&&Pa(i.entry.decorations,"underline")){r.push(i);continue}if(o(),i.kind==="break"){n.push({kind:"lineBreak",key:i.key});continue}n.push(Ku(i,t))}return o(),n}function Jx(e,t){let n=t.resolveText??Yx,r=[];return e.forEach((o,i)=>{let a=o.sourceIndex??i;if(o.kind!=="text"){r.push({entry:o,key:`${a}-${o.id}`,kind:"piece"});return}let s=n(o.text).split(`
|
|
11
|
-
`),c=Ma(o.decorations,"box")?.run;s.forEach((l,d)=>{d>0&&r.push({key:`${t.keyPrefix}-${a}-br-${d}`,kind:"break"}),l.length>0&&r.push({entry:o,...c?{boxedRun:Qx(c,d,s.length)}:{},key:`${a}-${d}`,kind:"piece",text:l})})}),r}function Ku(e,t){let n=e.entry,r=`${t.keyPrefix}-${e.key}`,o=eb(Ma(n.decorations,"box"),e.boxedRun),i=ku(db(Ma(n.decorations,"style")?.style)),a=n.kind==="text"?(e.text??"").length>0?[{kind:"text",key:`${r}-text`,text:e.text??""}]:[]:[tb(n,t)];return Pa(n.decorations,"italic")&&(a=[va("em",`${r}-em`,a)]),Pa(n.decorations,"bold")&&(a=[va("strong",`${r}-strong`,a)]),o&&(a=[nb(o,`${r}-boxed`,a,t)]),i?{kind:"element",tag:"span",key:`${r}-styled`,style:i,children:a}:a.length===1?a[0]:va("span",r,a)}function Qx(e,t,n){return n<=1?e:{...e,connectLeft:t===0?e.connectLeft:!1,connectRight:t===n-1?e.connectRight:!1,segmentId:`${e.segmentId}-line-${t}`}}function eb(e,t){return!e||!t||t===e.run?e:{...e,connectLeft:t.connectLeft,connectRight:t.connectRight,run:t}}function tb(e,t){return{kind:"element",tag:"span",className:"inline-math-node",key:`${t.keyPrefix}-${e.id}-frame`,attrs:{"data-sigma-doc-math-inline":"",...e.id?{"data-id":e.id}:{},"data-tex":e.tex,title:e.tex},selfContainedStyle:jx,children:[{kind:"mathBody",key:`${t.keyPrefix}-${e.id}-body`,tex:e.tex}]}}function nb(e,t,n,r){let o=Ou({boxedPaddingY:e.paddingY,boxedTone:e.tone,boxedVariant:e.variant},{math:e.math}),i=e.run?r.alignmentStyles?.[e.run.segmentId]:void 0;return{kind:"element",tag:"span",className:o.className,key:t,attrs:{...o.attrs,...wu(e.run)},style:cn(o.style,i),selfContainedStyle:rb(e),children:n}}function rb(e){let t={...ob};return e.math&&Object.assign(t,ib),e.run&&Object.assign(t,ab),e.connectRight&&Object.assign(t,sb),e.connectLeft&&Object.assign(t,lb),t}var Ju={border:"var(--boxed-text-border-width, 1px) var(--boxed-text-border-style, solid) var(--boxed-text-border-color, currentColor)","border-radius":"var(--boxed-text-border-radius, 2px)","background-color":"var(--boxed-text-background, transparent)"},ob={"box-sizing":"border-box",display:"inline",...Ju,padding:"calc(var(--boxed-text-padding-y, 0px) + var(--boxed-run-extra-padding-y, 0px)) 0.18em","line-height":"var(--boxed-text-line-height, inherit)","box-decoration-break":"clone","-webkit-box-decoration-break":"clone"},ib={display:"inline-flex","align-items":"center","vertical-align":"baseline","line-height":"normal"},ab={"box-sizing":"border-box",display:"inline-flex","align-items":"baseline",...Ju,padding:"calc(var(--boxed-text-padding-y, 0px) + var(--boxed-run-extra-padding-top, 0px)) 0.18em calc(var(--boxed-text-padding-y, 0px) + var(--boxed-run-extra-padding-bottom, 0px))","line-height":"1","vertical-align":"baseline","box-decoration-break":"clone","-webkit-box-decoration-break":"clone"},sb={"border-right-width":"0","border-top-right-radius":"0","border-bottom-right-radius":"0"},lb={"border-left-width":"0","border-top-left-radius":"0","border-bottom-left-radius":"0"};function cb(e){return e?{display:"inline-block","vertical-align":"baseline","max-width":"100%","text-decoration":"none","border-bottom":"1.25px solid currentColor","padding-bottom":"0.1em","box-decoration-break":"clone","-webkit-box-decoration-break":"clone"}:ub()}function ub(){return{"text-decoration-line":"underline","text-decoration-thickness":"1px","text-decoration-color":"currentColor","text-underline-offset":"0.12em","text-decoration-skip-ink":"auto"}}function va(e,t,n){return{kind:"element",tag:e,key:t,children:n}}function db(e){return{backgroundColor:e?.backgroundColor,color:e?.color,fontFamily:e?.fontFamily,fontSizePt:e?.fontSizePt}}function Pa(e,t){return e.some(n=>n.type===t)}function Ma(e,t){return e.find(n=>n.type===t)}function cn(...e){let t={};for(let n of e)n&&Object.assign(t,n);return Object.keys(t).length>0?t:void 0}function Ta(e,t){return go(e,{runIdPrefix:t.runIdPrefix}).map(n=>{let r=t.selfContained?cn(n.selfContainedStyle,n.style):n.style,o=n.isBlank?"<br/>":Qu({kind:"element",tag:"span",className:"rich-inline-content",key:n.key,children:ju(n)},t);return`<${n.tag}${ed(r)}>${o}</${n.tag}>`}).join("")}function Qu(e,t){if(e.kind==="text")return ge(e.text);if(e.kind==="lineBreak")return"<br/>";if(e.kind==="mathBody")return[`<span class="math-preview math-preview-inline" data-empty="${e.tex?"false":"true"}">`,t.renderMathHtml(e.tex),"</span>"].join("");let n=t.selfContained?cn(e.selfContainedStyle,e.style):e.style,r=e.className?` class="${K(e.className)}"`:"",o=e.children.map(i=>Qu(i,t)).join("");return`<${e.tag}${r}${pb(e.attrs)}${ed(n)}>${o}</${e.tag}>`}function pb(e){return e?Object.entries(e).map(([t,n])=>` ${t}="${K(n)}"`).join(""):""}function ed(e){if(!e)return"";let t=Object.entries(e).filter(([,n])=>et(n)).map(([n,r])=>`${n}:${r}`).join(";");return t?` style="${K(t)}"`:""}function ge(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function K(e){return ge(e).replace(/"/g,""")}var mb=new Set(["span","svg","path","line","br","circle","ellipse","g","polygon","polyline","rect"]),fb=new Set(["aria-hidden","class","part","style","cx","cy","d","fill","fill-opacity","fill-rule","height","opacity","points","preserveAspectRatio","r","rx","ry","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-width","transform","vector-effect","viewBox","width","x","x1","x2","xmlns","y","y1","y2"]),td=new Set(["br"]),nd=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)((?:\s+[a-zA-Z_:][a-zA-Z0-9_:.-]*(?:\s*=\s*(?:"[^"<]*"|'[^'<]*'|[^\s"'`=<>]+))?)*)\s*(\/?)>/y,rd=/([a-zA-Z_:][a-zA-Z0-9_:.-]*)(?:\s*=\s*(?:"([^"<]*)"|'([^'<]*)'|([^\s"'`=<>]+)))?/g,od=/&(?:amp|lt|gt|quot|apos|#\d{1,7}|#[xX][0-9a-fA-F]{1,6});/g,yb=new Set(["--bg-color","background-color","border","border-bottom-width","border-radius","border-right-width","border-style","border-top-width","border-width","bottom","box-sizing","color","display","font-size","height","left","line-height","margin-left","margin-right","margin-top","min-width","opacity","overflow","padding-left","padding-right","pointer-events","position","top","vertical-align","width","z-index","border-bottom","border-color","border-left","border-left-width","border-right","border-top","font-family","font-style","font-weight","letter-spacing","margin-bottom","max-height","max-width","min-height","padding-bottom","padding-top","right","text-align","text-decoration","visibility","white-space"]),hb=new Set(["absolute","relative","static"]),gb={"z-index":10},xb=20,md={"":1,em:1,rem:1,pc:1,ex:.5,ch:.5,px:1/16,pt:1/12,cm:2.3622,mm:.23622,q:.05906,in:6},fd=.01,ka=.5,bb=new Set(["height","max-height","min-height","margin-bottom","margin-left","margin-right","margin-top","padding-bottom","padding-left","padding-right","padding-top"]),Sb=new Set(["--bg-color","background-color","border-color","border-style","box-sizing","color","display","font-family","font-style","font-weight","line-height","opacity","overflow","pointer-events","position","text-align","text-decoration","visibility","white-space","z-index"]),yd=20,id=20,Oa=2,wa=320,hd=new Set(["d","points","transform"]),vb=new Set(["cx","cy","height","r","rx","ry","width","x","x1","x2","y","y1","y2"]),ad=/-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?/g,Pb=new Set(["stroke-width","stroke-dasharray"]),Mb=new Set(["cx","rx","width","x","x1","x2"]),Tb=new Set(["cy","height","ry","y","y1","y2"]),sd=/(?<![#\w.])([-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?)(%|[a-z]+)?/gi,Ob=/[\u0000-\u001f\u007f-\u009f]/u,wb=/[\\;{}<>]/u,kb=/(?:url\s*\(|min\s*\(|max\s*\(|clamp\s*\(|attr\s*\(|env\s*\(|@import\b|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:|\/\*|\d\s*(?:[sldp]?v(?:h|w|i|b|min|max)|cq(?:w|h|i|b|min|max))\b)/iu,Bb=16,ld=/(?<![\w-])(-webkit-|-moz-)?([a-z][a-z0-9-]*)\s*\(/gi,Rb=new Set(["calc","var"]),cd=/(?<![\w-])(?:-webkit-|-moz-)?calc\s*\(/gi,Ab=2048,Ib=[/^ML__[A-Za-z0-9_-]+$/,/^katex(?:-[a-z]+)*$/,/^(?:reset-)?size\d{1,2}$/,/^delim-size\d$/,/^col-align-[a-z]$/,/^slice-\d+-of-\d+$/],Eb=new Set(["accent","accent-body","allowbreak","amsrm","arraycolsep","base","boxpad","brace-center","brace-left","brace-right","cjk_fallback","colorbox","delimcenter","delimsizing","fbox","fix","frac-line","hide-tail","hline","inner","large-op","lcGreek","mathbb","mathbf","mathcal","mathdefault","mathfrak","mathit","mathnormal","mathrm","mathscr","mathsf","mathtt","mbin","mclose","mfrac","minner","mop","mopen","mord","mover","mpunct","mrel","mspace","msupsub","mtable","mtight","mult","munder","newline","nobreak","nulldelimiter","op-limits","op-symbol","overlay","overline","overline-line","pstrut","rlap","root","rule","sizing","small-op","smash","sout","sqrt","sqrt-line","sqrt-sign","stretchy","strut","svg-align","text","textbf","sigma-doubleboxed","sigma-outerthick-doubleboxed","sigma-thickboxed","textit","textrm","textsf","texttt","textup","thinbox","underline","underline-line","vbox","vertical-separator","vlist","vlist-r","vlist-s","vlist-t","vlist-t2","x-arrow","x-arrow-pad"]),Cb=/^[\w\-. ]*$/,Lb=/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/u;function So(e){let t="",n=0,r=!0,o=0,i=[],a=[],s=[];for(;n<e.length;){let c=e.indexOf("<",n);if(c<0){t+=xo(e.slice(n));break}t+=xo(e.slice(n,c)),nd.lastIndex=c;let l=nd.exec(e);if(!l){t+="<",n=c+1;continue}let[d,u,m,h,y]=l;n=c+d.length;let g=m.toLowerCase();if(!mb.has(g)){t+=xo(d);continue}if(u){if(td.has(g)){t+=xo(d);continue}i.pop()!==g&&(r=!1),a.pop(),g==="svg"&&(o=Math.max(0,o-1),s.pop()),t+=`</${g}>`;continue}let x=a[a.length-1]??1,S=s[s.length-1]??null,{fontScale:I,serialized:R,viewBox:M}=Nb(h,g,x,g==="svg"&&S===null?null:S),C=y==="/"&&(o>0||g==="svg");if(td.has(g)||C){t+=`<${g}${R}/>`;continue}t+=`<${g}${R}>`,i.push(g),a.push(I),g==="svg"&&(o+=1,s.push(Fb(M)))}return{html:t,safe:r&&i.length===0}}function Nb(e,t,n,r){if(!e.trim())return{fontScale:n,serialized:"",viewBox:null};rd.lastIndex=0;let o=[...e.matchAll(rd)],i=o.find(h=>h[1]==="style"),a=i?.[2]??i?.[3]??i?.[4]??"",s=i&&!ud(a)?zb(a,n):{fontScale:n,safe:!1},c=Math.max(1,s.safe?s.fontScale:n),l=new Set,d="",u=null,m=t!=="svg"||o.some(h=>h[1]==="height")||/(?:^|;)\s*height\s*:/i.test(a);for(let h of o){let y=h[1];if(!fb.has(y)||l.has(y))continue;let g=h[2]??h[3]??h[4]??"";if(ud(g))continue;if(y==="style"){if(!s.safe||r!==null)continue;l.add(y),d+=` ${y}="${g}"`;continue}if(y==="viewBox"&&t==="svg"&&(u=g),!Db(y,g,t,c,r,m))continue;let x=y==="class"?Gb(g):g;x!==null&&(l.add(y),d+=` ${y}="${x}"`)}return{fontScale:c,serialized:d,viewBox:u}}function Fb(e){let t={extent:wa,x:wa,y:wa};if(!e)return t;let n=e.trim().split(/[\s,]+/).map(Number);return n.length!==4||n.some(r=>!Number.isFinite(r))||n[2]<=0||n[3]<=0?t:{extent:Math.max(n[2],n[3])*Oa,x:n[2]*Oa,y:n[3]*Oa}}function _b(e,t,n){if(e==="transform"||!hd.has(e)&&/[a-z%]/i.test(t))return!1;let r=Mb.has(e)?n.x:Tb.has(e)?n.y:n.extent;ad.lastIndex=0;for(let o of t.matchAll(ad)){let i=Math.abs(Number(o[0]));if(!Number.isFinite(i)||i>r)return!1}return!0}function ud(e){return/[<>&"]/.test(e)||Lb.test(e)}function Db(e,t,n,r,o,i){if(n==="svg"&&e==="transform")return!1;if(o!==null&&(hd.has(e)||vb.has(e)||Pb.has(e)))return _b(e,t,o);if(n==="svg"&&e==="width"&&!i){let a=bo(t.trim().toLowerCase(),ka);return a!==null&&a*r<=id}if(n==="svg"&&e==="height"){let a=bo(t.trim().toLowerCase(),ka);return a!==null&&a*r<=id}return!0}function Gb(e){if(!Cb.test(e))return null;let t=e.split(" ").filter(n=>n&&$b(n));return t.length>0?t.join(" "):null}function $b(e){return Eb.has(e)||Ib.some(t=>t.test(e))}function zb(e,t){if(e.length>Ab)return{fontScale:t,safe:!1};let n=e.split(";"),r=t*Hb(n,t);return{fontScale:r,safe:n.every(o=>Ub(o,{effective:r,inherited:t}))}}function Hb(e,t){let n=1;for(let r of e){let o=r.indexOf(":");if(o<=0||r.slice(0,o).trim().toLowerCase()!=="font-size")continue;let i=r.slice(o+1).trim().toLowerCase(),a=gd(i)?bo(i,fd):null;n=a===null||a<=0||t*a>yd?1:a}return n}function gd(e){return/\d/.test(e)}function Ub(e,t){let n=e.trim();if(!n)return!0;if(Ob.test(n)||wb.test(n)||kb.test(n))return!1;let r=n.indexOf(":");if(r<=0)return!1;let o=n.slice(0,r).trim().toLowerCase(),i=n.slice(r+1).trim().toLowerCase();if(!yb.has(o)||!i)return!1;if(o==="position")return hb.has(i);if(o==="z-index"){let l=Number(i);if(!Number.isInteger(l)||l<0)return!1}let a=!Sb.has(o);if(a&&/(?<![\w-])var\s*\(/i.test(i))return!1;let s=bo(i,Vb(o));if(s===null)return!1;if(o==="font-size")return gd(i)&&s>0&&s*t.inherited<=yd;let c=gb[o]??xb;return s*(a?t.effective:1)<=c}function Vb(e){return bb.has(e)?ka:fd}function bo(e,t){ld.lastIndex=0;for(let o of e.matchAll(ld))if(!Rb.has(o[2].toLowerCase()))return null;let n=Wb(e,t);if(n===null)return null;let r=0;sd.lastIndex=0;for(let o of n.matchAll(sd)){let i=(o[2]??"").toLowerCase(),a=i==="%"?t:md[i];if(a===void 0)return null;let s=Math.abs(Number(o[1])*a);if(!Number.isFinite(s))return null;r=Math.max(r,s)}return r}function Wb(e,t){let n="",r=0;for(;;){cd.lastIndex=r;let o=cd.exec(e);if(!o)return n+e.slice(r);let i=o.index+o[0].length-1,a=Xb(e,i);if(a<0)return null;let s=Yb(e.slice(i+1,a),t);if(s===null)return null;n+=`${e.slice(r,o.index)}${s}`,r=a+1}}function Xb(e,t){let n=0;for(let r=t;r<e.length;r+=1)if(e[r]==="(")n+=1;else if(e[r]===")"&&(n-=1,n===0))return r;return-1}function Yb(e,t){let n={index:0,percent:t,text:e},r=xd(n,0);return r===null?null:(er(n),n.index===e.length&&Number.isFinite(r)?r:null)}function xd(e,t){let n=dd(e,t);if(n===null)return null;for(;;){er(e);let r=e.text[e.index];if(r!=="+"&&r!=="-")return n;e.index+=1;let o=dd(e,t);if(o===null)return null;n=r==="+"?n+o:n-o}}function dd(e,t){let n=pd(e,t);if(n===null)return null;for(;;){er(e);let r=e.text[e.index];if(r!=="*"&&r!=="/")return n;e.index+=1;let o=pd(e,t);if(o===null||r==="/"&&o===0)return null;n=r==="*"?n*o:n/o}}function pd(e,t){if(t>Bb)return null;er(e);let n=e.text.slice(e.index),r=/^(?:-webkit-|-moz-)?calc\s*\(/i.exec(n)??/^\(/.exec(n);if(r){e.index+=r[0].length;let l=xd(e,t+1);return l===null||(er(e),e.text[e.index]!==")")?null:(e.index+=1,l)}let o=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?/.exec(n);if(!o)return null;e.index+=o[0].length;let i=/^(?:%|[a-z]+)/i.exec(e.text.slice(e.index));i&&(e.index+=i[0].length);let a=(i?.[0]??"").toLowerCase(),s=a==="%"?e.percent:md[a];if(s===void 0)return null;let c=Number(o[0])*s;return Number.isFinite(c)?c:null}function er(e){for(;e.index<e.text.length&&/\s/.test(e.text[e.index]);)e.index+=1}function xo(e){let t="",n=0;od.lastIndex=0;for(let r of e.matchAll(od))t+=ge(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+ge(e.slice(n))}function Bt(e,t){let n=Le(t,e),r=kt.get(n);if(r!==void 0)return kt.delete(n),kt.set(n,r),r;let o=jb(e,t);if(kt.size>=Kb){let i=kt.keys().next().value;i!==void 0&&kt.delete(i)}return kt.set(n,o),o}function bd(e,t){return!Bt(e,t).startsWith(Sd)}var kt=new Map,Kb=5e3,Sd='<span data-math-unrendered="true">';function jb(e,t){try{let n=so(e,t),r=So(n);if(r.safe)return r.html}catch{}return`${Sd}${ge(e)}</span>`}import{memo as SS}from"react";import{Fragment as nS,memo as rS,useEffect as oS,useLayoutEffect as iS,useMemo as aS,useRef as sS,useState as lS}from"react";import{memo as eS}from"react";function vd(){return null}function un(e){let t=vd();t&&(t.counters[e]=(t.counters[e]??0)+1)}function Ba(e,t){return t();try{return t()}finally{let r=performance.now()-n,o=vd();o&&(o.measures.push({name:e,duration:r,at:Date.now()}),o.measures.length>2e3&&o.measures.splice(0,o.measures.length-2e3))}}import{createContext as qb,useContext as Zb,useMemo as Jb}from"react";import{jsx as Qb}from"react/jsx-runtime";var Pd=qb(nn);function dn({children:e,environment:t}){return Qb(Pd.Provider,{value:t,children:e})}function Rt(){return Zb(Pd)}function Ra(e){let t=Rt();return Jb(()=>e==null?t:du(t,Tr(e)),[t,e])}import{jsx as tS}from"react/jsx-runtime";var Aa=eS(function({tex:t,displayMode:n=!1,className:r,mathFractionSizing:o}){un("MathPreview.render");let i=Ra(o),a=Bt(t,i),s=["math-preview",n?"math-preview-display":"math-preview-inline",r].filter(Boolean).join(" ");return tS("span",{className:s,dangerouslySetInnerHTML:{__html:a},"data-empty":t?"false":"true"})});import{jsx as tr}from"react/jsx-runtime";var Ia='[data-boxed-run-height-target="true"][data-boxed-run-segment-id]',cS=.5,Md=100,uS=typeof window>"u"?oS:iS;function Ea(e){return fi(e)}function pn(e){let t=sS(null),[n,r]=lS({});return uS(()=>{let o=t.current;if(!o||typeof window>"u")return;let i=!1,a=!1,s=null,c=null,l=null,d=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>y()),u=typeof MutationObserver>"u"?null:new MutationObserver(()=>y()),m=()=>{d?.disconnect(),d?.observe(o),o.querySelectorAll(Ia).forEach(g=>{d?.observe(g)})},h=()=>{a=!0,o.classList.add("boxed-run-measuring");try{let g=fS(o);r(x=>bS(x,g)?x:g)}finally{o.classList.remove("boxed-run-measuring"),m(),c=window.requestAnimationFrame(()=>{c=null,l=window.requestAnimationFrame(()=>{l=null,a=!1})})}};function y(){i||a||s!==null||(s=window.requestAnimationFrame(()=>{s=null,h()}))}return m(),u?.observe(o,{attributes:!0,attributeFilter:["class","data-sigma-doc-boxed-padding-y","data-sigma-doc-boxed-variant","data-sigma-doc-boxed-tone"],childList:!0,characterData:!0,subtree:!0}),window.addEventListener("resize",y),y(),()=>{i=!0,s!==null&&window.cancelAnimationFrame(s),c!==null&&window.cancelAnimationFrame(c),l!==null&&window.cancelAnimationFrame(l),d?.disconnect(),u?.disconnect(),window.removeEventListener("resize",y)}},[e]),{aligned:Object.keys(n).length>0,alignmentStyles:n,ref:t}}function xe(e,t={}){let n=t.keyPrefix??"inline";return dS(qu(e,{alignmentStyles:t.alignmentStyles,keyPrefix:n,resolveText:t.resolveText}),t)}function dS(e,t){return e.map(n=>Od(n,t))}function Od(e,t){if(e.kind==="text")return tr(nS,{children:e.text},e.key);if(e.kind==="lineBreak")return tr("br",{},e.key);if(e.kind==="mathBody")return tr(Aa,{tex:e.tex,mathFractionSizing:t.mathFractionSizing},e.key);let n=e.tag,r=t.selfContained?cn(e.selfContainedStyle,e.style):e.style;return tr(n,{className:e.className,style:pS(r),...e.attrs,children:e.children.map(o=>Od(o,t))},e.key)}function pS(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))et(r)&&(t[n.startsWith("--")?n:mS(n)]=r);return t}function mS(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function fS(e){let t=yS(e),n=Gs(t),r={};for(let[o,i]of n)r[o.segmentId]={"--boxed-run-extra-padding-bottom":`${Po(i.extraPaddingBottom)}px`,"--boxed-run-extra-padding-top":`${Po(i.extraPaddingTop)}px`,"--boxed-run-own-height":`${Po(i.ownHeight)}px`,"--boxed-run-target-height":`${Po(i.targetHeight)}px`};return r}function yS(e){let t=[],n=Bu(e),r=o=>{for(let i of Array.from(o.childNodes)){if(i.nodeType===Node.TEXT_NODE){Ft(i.textContent??"")&&i instanceof Text&&t.push(...Pr(hS(i),n));continue}if(!(!(i instanceof HTMLElement)||gS(i))){if(i.matches(Ia)){let a=i.getAttribute("data-boxed-run-segment-id");a&&t.push(...Pr(Td(i),n).map(s=>({...s,boxedTarget:{segmentId:a}})));continue}if(i.tagName!=="BR"){if(i.querySelector(Ia)){r(i);continue}xS(i)&&t.push(...Pr(Td(i),n))}}}};return r(e),t}function hS(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let n=wd(t);return t.detach(),n}function Td(e){let t=wd(e);return t.length>0?t:kd(e.getBoundingClientRect())}function wd(e){return Array.from(e.getClientRects()).flatMap(kd)}function kd(e){return!Number.isFinite(e.top)||!Number.isFinite(e.bottom)||!Number.isFinite(e.height)||e.height<=0?[]:[{top:e.top,bottom:e.bottom,height:e.height}]}function gS(e){return e.getAttribute("aria-hidden")==="true"||e.hidden}function xS(e){return Ft(e.textContent??"")||e.getBoundingClientRect().width>0||e.getBoundingClientRect().height>0}function bS(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length||!n.every(o=>t[o]!==void 0)?!1:n.every(o=>vo(at(e[o],"--boxed-run-extra-padding-bottom"),at(t[o],"--boxed-run-extra-padding-bottom"))&&vo(at(e[o],"--boxed-run-extra-padding-top"),at(t[o],"--boxed-run-extra-padding-top"))&&vo(at(e[o],"--boxed-run-own-height"),at(t[o],"--boxed-run-own-height"))&&vo(at(e[o],"--boxed-run-target-height"),at(t[o],"--boxed-run-target-height")))}function at(e,t){let n=e[t];if(typeof n=="number")return n;if(typeof n=="string"){let r=Number.parseFloat(n);return Number.isFinite(r)?r:0}return 0}function vo(e,t){return Math.abs(e-t)<=cS}function Po(e){return Math.round(e*Md)/Md}var Ca=rS(function({nodes:t,className:n,keyPrefix:r,mathFractionSizing:o}){let i=["rich-inline-content",n].filter(Boolean).join(" "),a=aS(()=>fi(t),[t]),{aligned:s,alignmentStyles:c,ref:l}=pn(a);return tr("span",{ref:l,className:i,"data-boxed-run-aligned":s?"true":void 0,children:xe(t,{alignmentStyles:c,keyPrefix:r,mathFractionSizing:o})})});import{Fragment as MS,jsx as Bd}from"react/jsx-runtime";var vS=SS(function({title:t,nodes:n}){let r=Rt(),o=n===void 0?yi(t):n;return!o||!PS(o,r)?Bd(MS,{children:t}):Bd("span",{className:"rich-inline-content document-title-rich",children:xe(o,{keyPrefix:"doc-title"})})});function PS(e,t){return e.every(n=>n.type!=="mathInline"||bd(n.tex,t))}import ZS from"katex";import{useState as Ha,useRef as mn,useEffect as JS,useId as QS,useMemo as rr}from"react";var Da=32,ko=360,Ga=220,q=1e-6,La=.08,Ao=.25,Io=2,TS=.08,OS=.35,Na=2.4,nr=1e-5;function Fd(e,t,n=le(e)){let r=WS(t);return r?wS(e,r,n)?.path??"":""}function wS(e,t,n=le(e)){if(e.kind!=="cartesian")return null;let r,o;try{r=wt(e),o=Ye(e)}catch{return null}let i=YS(r,o);if(!i||!XS(i,t))return null;let a=Y(t.x,t.y,r,e,n),s=kS(e,r,i,n);if(s.length<4)return null;let c=NS(s),l=_S(c),d=$S(GS(c)),u=RS(e,t,r,i,n),m=Id(a,s,OS);if(m.length>0){if(m.length>1||m.some(I=>I.kind!=="axis"&&za(a,I)<=TS))return null;let S=Ad(a,l,Na,d);return S.openFaceRejected?null:Oo([S.face,u])}let h=Fa(a,l,d);if(h.openFaceRejected)return null;let y=Oo([h.face,u]);if(y)return y;if(Id(a,s,Na).filter(x=>x.kind==="axis").length===1){let x=Ad(a,l,Na*2,d);return Oo([x.face,u])}return null}function kS(e,t,n,r){let o=Y(n.xMin,n.yMax,t,e,r),i=Y(n.xMax,n.yMax,t,e,r),a=Y(n.xMax,n.yMin,t,e,r),s=Y(n.xMin,n.yMin,t,e,r),c=[{a:o,b:i,kind:"frame"},{a:i,b:a,kind:"frame"},{a,b:s,kind:"frame"},{a:s,b:o,kind:"frame"}];e.axes.showX!==!1&&n.yMin<0&&n.yMax>0&&c.push({a:Y(n.xMin,0,t,e,r),b:Y(n.xMax,0,t,e,r),kind:"axis"}),e.axes.showY!==!1&&n.xMin<0&&n.xMax>0&&c.push({a:Y(0,n.yMin,t,e,r),b:Y(0,n.yMax,t,e,r),kind:"axis"});for(let l of e.curves)c.push(...BS(l,e,t,n,r));return c}function BS(e,t,n,r,o){let i=it(e.mode);if(i==="implicit")return[];let a=ln(e,i,r);if(!a)return[];let s=Ro(e.samples??Ga,Da,ko),c=r.xMax-r.xMin,l=r.yMax-r.yMin,d=r.xMin-c*8,u=r.xMax+c*8,m=r.yMin-l*8,h=r.yMax+l*8,y=a.max-a.min,g=[],x=C=>{try{if(i==="parametric"){let f=e.yExpr?.trim();if(!f)return null;let P={x:ae(e.expr,C,"t"),y:ae(f,C,"t")};return Number.isFinite(P.x)&&Number.isFinite(P.y)?P:null}let z=ae(e.expr,C,a.variableName);return Number.isFinite(z)?i==="xOfY"?{x:z,y:C}:{x:C,y:z}:null}catch{return null}},S=C=>C.x>=d&&C.x<=u&&C.y>=m&&C.y<=h,I=(C,z)=>fa(x,C,z,y,f=>!S(f)),R=(C,z)=>{if(!S(C)&&!S(z))return;let f=LS(C,z,r);f&&g.push({a:Y(f.a.x,f.a.y,n,t,o),b:Y(f.b.x,f.b.y,n,t,o),kind:"curve"})},M=null;for(let C=0;C<=s;C+=1){let z=a.min+y*C/s,f=x(z);if(!f){if(M){let P=I(M.independentValue,z);P&&R(M.point,P)}M=null;continue}if(M)R(M.point,f);else if(C>0){let P=a.min+y*(C-1)/s,D=I(z,P);D&&R(D,f)}M={independentValue:z,point:f}}return g}function RS(e,t,n,r,o){let i=[];for(let a of e.curves){let s=it(a.mode);if(s==="parametric"||s==="implicit")continue;if(s==="xOfY"){let l=[r.xMin,r.xMax];e.axes.showY!==!1&&r.xMin<0&&r.xMax>0&&l.push(0);for(let d of l){let u=Rd(a,s,d,t,n,r,e,o);u&&i.push(u)}continue}let c=[r.yMin,r.yMax];e.axes.showX!==!1&&r.yMin<0&&r.yMax>0&&c.push(0);for(let l of c){let d=Rd(a,s,l,t,n,r,e,o);d&&i.push(d)}}return Oo(i)}function Rd(e,t,n,r,o,i,a,s){let c=CS(e,t,i);if(!c)return null;let l=t==="xOfY"?r.y:r.x;if(l<=c.min+q||l>=c.max-q)return null;let d;try{d=ae(e.expr,l,c.variableName)}catch{return null}if(!Number.isFinite(d)||t==="xOfY"&&(d<i.xMin-q||d>i.xMax+q)||t==="yOfX"&&(d<i.yMin-q||d>i.yMax+q)||!qS(t==="xOfY"?r.x:r.y,n,d))return null;let u=IS(e,t,n,c,l,AS(t,a,o,s));for(let m=0;m<u.length-1;m+=1){let h=u[m],y=u[m+1];if(l<=h+nr||l>=y-nr)continue;let g=ES(e,t,n,h,y,c,o,i,a,s);if(g.length<3)continue;let x=Math.abs(Dd(g)),S=Y(r.x,r.y,o,a,s);if(x>Io&&$a(S,g))return{polygon:g,area:x,path:_d(g)}}return null}function AS(e,t,n,r){let o=e==="xOfY"?(t.width-r.left-r.right)/Math.max(n.xMax-n.xMin,q):(t.height-r.top-r.bottom)/Math.max(n.yMax-n.yMin,q);return o>q?Ao/o:0}function IS(e,t,n,r,o,i){let a=Ro(e.samples??Ga,Da,ko),s=Ld([r.min,r.max,o,...Array.from({length:a+1},(u,m)=>r.min+(r.max-r.min)*m/a)]),c=[],l=null,d=null;for(let u of s){let m;try{m=ae(e.expr,u,r.variableName)}catch{l=null,d=null;continue}if(!Number.isFinite(m)){l=null,d=null;continue}let h=m-n;if(Math.abs(h)<=q&&c.push(u),d&&d.delta*h<0){let y=d.delta/(d.delta-h);c.push(d.independent+(u-d.independent)*y)}l&&d&&l.delta*h>0&&Math.abs(d.delta)<=i&&Math.abs(d.delta)<=Math.abs(l.delta)&&Math.abs(d.delta)<=Math.abs(h)&&c.push(d.independent),l=d,d={independent:u,delta:h}}return Ld(c).filter(u=>u>=r.min-nr&&u<=r.max+nr)}function ES(e,t,n,r,o,i,a,s,c,l){let d=Ro(e.samples??Ga,Da,ko),u=(o-r)/Math.max(i.max-i.min,q),m=Ro(Math.ceil(d*u),8,ko),h=[];t==="xOfY"?h.push({x:n,y:r},{x:n,y:o}):h.push({x:r,y:n},{x:o,y:n});for(let y=m;y>=0;y-=1){let g=r+(o-r)*y/m,x;try{x=ae(e.expr,g,i.variableName)}catch{continue}if(!Number.isFinite(x))continue;let S=t==="xOfY"?{x:Nd(x,s.xMin,s.xMax),y:g}:{x:g,y:Nd(x,s.yMin,s.yMax)};(y===m||y===0)&&(t==="xOfY"?S.x=n:S.y=n),h.push(S)}return h.map(y=>Y(y.x,y.y,a,c,l))}function CS(e,t,n){let r=t==="xOfY"?"y":"x",o=t==="xOfY"?{min:n.yMin,max:n.yMax}:{min:n.xMin,max:n.xMax},i=ke(e.domain?.min,o.min)??o.min,a=ke(e.domain?.max,o.max)??o.max,s=Math.max(o.min,i),c=Math.min(o.max,a);return s>=c?null:{min:s,max:c,variableName:r}}function LS(e,t,n){let r=0,o=1,i=t.x-e.x,a=t.y-e.y,s=(c,l)=>{if(Math.abs(c)<q)return l>=-q;let d=l/c;if(c<0){if(d>o)return!1;d>r&&(r=d)}else{if(d<r)return!1;d<o&&(o=d)}return!0};return!s(-i,e.x-n.xMin)||!s(i,n.xMax-e.x)||!s(-a,e.y-n.yMin)||!s(a,n.yMax-e.y)||o-r<=q?null:{a:{x:e.x+i*r,y:e.y+a*r},b:{x:e.x+i*o,y:e.y+a*o}}}function NS(e){let t=e.map(()=>[{t:0},{t:1}]);for(let u=0;u<e.length;u+=1)for(let m=u+1;m<e.length;m+=1){let h=e[u],y=e[m],g=VS(h,y);g&&(t[u].push({t:g.t,point:g.point}),t[m].push({t:g.u,point:g.point})),FS(h,y,t[u],t[m])}let n=new Map,r=new Map,o=new Set,i=[],a=new Map,s=0,c=(u,m)=>`${u}:${m}`,l=u=>{let m=Math.floor(u.x/La),h=Math.floor(u.y/La),y=null,g=La;for(let R=-1;R<=1;R+=1)for(let M=-1;M<=1;M+=1){let C=a.get(c(m+R,h+M));if(C)for(let z of C){let f=_a(z.point,u);f<g&&(y=z,g=f)}}if(y)return y;s+=1;let x={key:`v${s}`,point:u};n.set(x.key,x),r.set(x.key,[]);let S=c(m,h),I=a.get(S);return I||(I=[],a.set(S,I)),I.push(x),x},d=(u,m)=>{if(u.key===m.key)return;let h=u.key<m.key?`${u.key}|${m.key}`:`${m.key}|${u.key}`;o.has(h)||(o.add(h),i.push({a:u.point,b:m.point,fromKey:u.key,toKey:m.key}),r.get(u.key)?.push({key:m.key,angle:Math.atan2(m.point.y-u.point.y,m.point.x-u.point.x)}),r.get(m.key)?.push({key:u.key,angle:Math.atan2(u.point.y-m.point.y,u.point.x-m.point.x)}))};e.forEach((u,m)=>{let h=KS(t[m]);for(let y=0;y<h.length-1;y+=1){let g=Ed(u,h[y]),x=Ed(u,h[y+1]);d(l(g),l(x))}});for(let u of r.values())u.sort((m,h)=>m.angle-h.angle);return{vertices:n,adjacency:r,edges:i,edgeCount:o.size}}function FS(e,t,n,r){let o=Mo(e.a,t),i=Mo(e.b,t),a=Mo(t.a,e),s=Mo(t.b,e);o!==null&&r.push({t:o,point:e.a}),i!==null&&r.push({t:i,point:e.b}),a!==null&&n.push({t:a,point:t.a}),s!==null&&n.push({t:s,point:t.b})}function _S(e){let t=[],n=new Set,r=e.edgeCount*2+8;for(let[o,i]of e.adjacency)for(let a of i){let s=o,c=a.key,l=Cd(s,c);if(n.has(l))continue;let d=[],u=s,m=c,h=!1;for(let y=0;y<r;y+=1){let g=Cd(u,m);if(n.has(g))break;n.add(g),d.push(u);let x=e.adjacency.get(m);if(!x||x.length===0)break;let S=x.findIndex(M=>M.key===u);if(S===-1)break;let I=(S-1+x.length)%x.length,R=x[I].key;if(u=m,m=R,u===s&&m===c){h=!0;break}}if(!(!h||d.length<3))for(let y of DS(d)){let g=y.map(S=>e.vertices.get(S)?.point).filter(S=>!!S),x=Math.abs(Dd(g));x<=Io||t.push({polygon:g,area:x,path:_d(g)})}}return t}function DS(e){let t=[],n=new Map,r=[];for(let o of e){let i=n.get(o);if(i===void 0){n.set(o,t.length),t.push(o);continue}let a=t.slice(i);a.length>=3&&r.push(a);let s=t.splice(i+1);for(let c of s)n.delete(c)}return r.length===0&&t.length>=3&&r.push(t),r}function GS(e){let t=new Map;for(let[o,i]of e.adjacency)t.set(o,i.length);let n=new Set,r=[];for(let[o,i]of t)i<=1&&r.push(o);for(;r.length>0;){let o=r.pop();if(!(n.has(o)||(t.get(o)??0)>1)){n.add(o);for(let i of e.adjacency.get(o)??[]){if(n.has(i.key))continue;let a=(t.get(i.key)??0)-1;t.set(i.key,a),a<=1&&r.push(i.key)}}}return e.edges.filter(o=>!n.has(o.fromKey)&&!n.has(o.toKey))}function $S(e){let t=new Map;return n=>{let r=t.get(n.path);if(r!==void 0)return r;let o=!zS(n,e);return t.set(n.path,o),o}}function zS(e,t){let n=HS(e.polygon);for(let r of t){let o={x:(r.a.x+r.b.x)/2,y:(r.a.y+r.b.y)/2};if(!(o.x<n.minX||o.x>n.maxX||o.y<n.minY||o.y>n.maxY)&&$a(o,e.polygon)&&US(o,e.polygon)>Ao)return!0}return!1}function HS(e){let t=1/0,n=-1/0,r=1/0,o=-1/0;for(let i of e)t=Math.min(t,i.x),n=Math.max(n,i.x),r=Math.min(r,i.y),o=Math.max(o,i.y);return{minX:t,maxX:n,minY:r,maxY:o}}function US(e,t){let n=1/0;for(let r=0,o=t.length-1;r<t.length;o=r,r+=1)if(n=Math.min(n,za(e,{a:t[o],b:t[r],kind:"frame"})),n<=Ao)return n;return n}function Fa(e,t,n){let r=t.filter(o=>o.area>Io&&$a(e,o.polygon)).sort((o,i)=>o.area-i.area);for(let o of r)if(n(o))return{face:o,openFaceRejected:!1};return{face:null,openFaceRejected:r.length>0}}function Ad(e,t,n,r){let o=Fa(e,t,r);if(o.openFaceRejected)return o;let i=o.face,a=[e,{x:e.x+n,y:e.y},{x:e.x-n,y:e.y},{x:e.x,y:e.y+n},{x:e.x,y:e.y-n},{x:e.x+n,y:e.y+n},{x:e.x+n,y:e.y-n},{x:e.x-n,y:e.y+n},{x:e.x-n,y:e.y-n}],s=new Map;i&&s.set(i.path,i);for(let c of a){let l=Fa(c,t,r).face;l&&s.set(l.path,l)}return{face:[...s.values()].sort((c,l)=>c.area-l.area)[0]??null,openFaceRejected:!1}}function Oo(e){return e.filter(t=>t!=null&&t.area>Io).sort((t,n)=>t.area-n.area)[0]??null}function Id(e,t,n){return t.filter(r=>za(e,r)<=n)}function VS(e,t){let n=e.b.x-e.a.x,r=e.b.y-e.a.y,o=t.b.x-t.a.x,i=t.b.y-t.a.y,a=wo({x:n,y:r},{x:o,y:i});if(Math.abs(a)<q)return null;let s=t.a.x-e.a.x,c=t.a.y-e.a.y,l=wo({x:s,y:c},{x:o,y:i})/a,d=wo({x:s,y:c},{x:n,y:r})/a;return!Bo(l)||!Bo(d)?null:{point:{x:e.a.x+n*l,y:e.a.y+r*l},t:l,u:d}}function Mo(e,t){let n=t.b.x-t.a.x,r=t.b.y-t.a.y,o=n*n+r*r;if(o<q)return null;let i=wo({x:n,y:r},{x:e.x-t.a.x,y:e.y-t.a.y});if(Math.abs(i)/Math.sqrt(o)>Ao)return null;let a=((e.x-t.a.x)*n+(e.y-t.a.y)*r)/o;return Bo(a)?a:null}function $a(e,t){let n=!1;for(let r=0,o=t.length-1;r<t.length;o=r,r+=1){let i=t[r],a=t[o];if(!(i.y>e.y!=a.y>e.y))continue;let c=(a.x-i.x)*(e.y-i.y)/(a.y-i.y)+i.x;e.x<c&&(n=!n)}return n}function za(e,t){let n=t.b.x-t.a.x,r=t.b.y-t.a.y,o=n*n+r*r;if(o<=q)return _a(e,t.a);let i=Math.max(0,Math.min(1,((e.x-t.a.x)*n+(e.y-t.a.y)*r)/o));return _a(e,{x:t.a.x+n*i,y:t.a.y+r*i})}function WS(e){let t=ke(e.x,null),n=ke(e.y,null);return t===null||n===null?null:{x:t,y:n}}function XS(e,t){return t.x>e.xMin+q&&t.x<e.xMax-q&&t.y>e.yMin+q&&t.y<e.yMax-q}function YS(e,t){let n=Math.max(e.xMin,t.xMin),r=Math.min(e.xMax,t.xMax),o=Math.max(e.yMin,t.yMin),i=Math.min(e.yMax,t.yMax);return n<r&&o<i?{xMin:n,xMax:r,yMin:o,yMax:i}:null}function KS(e){let t=e.filter(r=>Bo(r.t)).map(r=>({...r,t:Math.min(1,Math.max(0,r.t))})).sort((r,o)=>r.t-o.t),n=[];for(let r of t){let o=n[n.length-1];!o||Math.abs(r.t-o.t)>q?n.push(r):!o.point&&r.point&&(o.point=r.point)}return n}function Bo(e){return Number.isFinite(e)&&e>=-q&&e<=1+q}function jS(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Ed(e,t){return t.point??jS(e.a,e.b,t.t)}function Cd(e,t){return`${e}->${t}`}function _d(e){let[t,...n]=e;return[`M${To(t.x)} ${To(t.y)}`,...n.map(r=>`L${To(r.x)} ${To(r.y)}`),"Z"].join(" ")}function Dd(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n],o=e[(n+1)%e.length];t+=r.x*o.y-o.x*r.y}return t/2}function wo(e,t){return e.x*t.y-e.y*t.x}function _a(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function qS(e,t,n){return e>Math.min(t,n)+q&&e<Math.max(t,n)-q}function Ld(e){let t=e.filter(r=>Number.isFinite(r)).sort((r,o)=>r-o),n=[];for(let r of t){let o=n[n.length-1];(o===void 0||Math.abs(r-o)>nr)&&n.push(r)}return n}function Nd(e,t,n){return Math.max(t,Math.min(n,e))}function To(e){return Number(e.toFixed(3))}function Ro(e,t,n){return Number.isFinite(e)?Math.round(Math.max(t,Math.min(n,e))):t}import{Fragment as Mv,jsx as N,jsxs as Te}from"react/jsx-runtime";var ev=300,Gd=9,tv=new Map,nv=new Map,rv=new Map,or=new Map,ov=2e3;function iv(e,t){let n=Le(t,e),r=or.get(n);if(r!==void 0)return r;let o;try{let i=ZS.renderToString(mt(e||"\\square",t.typesetStyle),{macros:t.macroSet.katexMacros,throwOnError:!1,strict:"ignore",output:"html",trust:tn}),a=So(i);o=a.safe?a.html:`<span data-math-unrendered="true">${ge(e)}</span>`}catch{o=`<span data-math-unrendered="true">${ge(e)}</span>`}if(or.size>=ov){let i=or.keys().next().value;i!==void 0&&or.delete(i)}return or.set(n,o),o}var av={"\\pi":"\u03C0","\\theta":"\u03B8","\\alpha":"\u03B1","\\beta":"\u03B2","\\gamma":"\u03B3","\\delta":"\u03B4","\\epsilon":"\u03B5","\\varepsilon":"\u03B5","\\lambda":"\u03BB","\\mu":"\u03BC","\\sigma":"\u03C3","\\phi":"\u03C6","\\varphi":"\u03C6","\\omega":"\u03C9","\\sin":"sin","\\cos":"cos","\\tan":"tan","\\log":"log","\\ln":"ln","\\exp":"exp","\\sqrt":"\u221A","\\cdot":"\xB7","\\times":"\xD7","\\div":"\xF7","\\pm":"\xB1","\\mp":"\u2213","\\infty":"\u221E","\\leq":"\u2264","\\leqq":"\u2264","\\geq":"\u2265","\\geqq":"\u2265","\\neq":"\u2260","\\approx":"\u2248","\\to":"\u2192"};function sv(e){if(!e)return"";let t=e;for(let n=0;n<4;n+=1){let r=t.replace(/\\d?frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,"$1/$2");if(r===t)break;t=r}for(let[n,r]of Object.entries(av))t.includes(n)&&(t=t.split(n).join(r));return t=t.replace(/\\([a-zA-Z]+)/g,"$1"),t=t.replace(/[{}]/g,""),t=t.replace(/-/g,"\u2212"),t}function $d(e,t){return t==="start"?0:t==="end"?e:e/2}function zd(e){return e==="start"?"flex-start":e==="end"?"flex-end":"center"}function lv(e){return e==="start"?"start":e==="end"?"end":"middle"}function cv(e){return e==="start"?"hanging":e==="end"?"alphabetic":"middle"}var uv=12,dv=12;function Ua(e){return typeof e=="number"&&Number.isFinite(e)}function Hd(e,t,n){let r=co(e||"\\square",n),o=$t(t);return{width:Math.max(uv,Math.ceil(r.widthEm*o)),height:Math.max(dv,Math.ceil((r.ascentEm+r.descentEm)*o))}}function Ud({cx:e,cy:t,width:n,height:r,align:o,vAlign:i,tex:a,className:s,fontSize:c,staticMode:l}){let d=Rt();if(l)return N("text",{x:e,y:t,textAnchor:lv(o),dominantBaseline:cv(i),className:s,style:c!==void 0?{fontSize:`${c}pt`}:void 0,children:sv(a)});let u=e-$d(n,o),m=t-$d(r,i);return N("foreignObject",{x:u,y:m,width:n,height:r,className:s,children:N("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{width:"100%",height:"100%",display:"flex",justifyContent:zd(o),alignItems:zd(i),fontSize:c!==void 0?`${c}pt`:void 0,lineHeight:1,pointerEvents:"none",overflow:"visible"},dangerouslySetInnerHTML:{__html:iv(a,d)}})})}function fn({spec:e,className:t="",idSeed:n,staticMode:r,onSpecChange:o,autoStartCrop:i,disableCropInteraction:a,onCropEnd:s}){un("Graph2DPreview.render");let c=Rt(),[l,d]=Ha(!1),[u,m]=Ha(null),[h,y]=Ha(null),g=mn(null),x=mn(null),S=mn(null),I=mn(null),R=mn(null),M=mn(!1),C=Eo(QS()),z=n?Eo(n):C,f=l&&h?h:e,P=rr(()=>le(f),[f.kind,f.axes.renderStyle]),D=rr(()=>Eo([z,f.title,f.kind,f.width,f.height,f.viewBox.xMin,f.viewBox.xMax,f.viewBox.yMin,f.viewBox.yMax,f.graphViewBox?.xMin??"",f.graphViewBox?.xMax??"",f.graphViewBox?.yMin??"",f.graphViewBox?.yMax??""].join("-")),[z,f.title,f.kind,f.width,f.height,f.viewBox,f.graphViewBox]),Q=rr(()=>Ba("Graph2DPreview.curvePaths",()=>f.curves.map(b=>({curve:b,path:mv(b,f,P)}))),[f.curves,f.viewBox,f.graphViewBox,f.width,f.height,P]),Z=rr(()=>Ba("Graph2DPreview.fillPaths",()=>(f.fills??[]).map(b=>({fill:b,path:fv(f,b,P),color:Qn(b.color,$i),opacity:Hi(b.opacity),pattern:zi(b.pattern),patternId:`graph2d-fill-pattern-${D}-${Eo(b.id)}`})).filter(b=>b.path)),[f.fills,f.curves,f.viewBox,f.graphViewBox,f.width,f.height,f.kind,P,D]),v=rr(()=>Du(f),[f]),w=pv(f),O=hv(f),A=Hu(f)||"\u30B0\u30E9\u30D5",B=b=>{let T=le(b);try{let H=ma(b,T);if(H.width>0&&H.height>0)return{left:H.x,top:H.y,width:H.width,height:H.height}}catch{}return{left:T.left,top:T.top,width:b.width-T.left-T.right,height:b.height-T.top-T.bottom}},F=b=>{let T=B(b);M.current=!1,x.current=T,S.current=b,m(T),y(b),d(!0)},W=()=>{let b=x.current??u;b&&U(b),x.current=null,S.current=null,d(!1),m(null),y(null),s?.()},_=b=>{r||a||!o||(b.preventDefault(),b.stopPropagation(),l?W():F(e))},j=(b,T={})=>{let H=S.current??h;if(!o||!H)return;let te=_u(H,b,T);te&&o(te,{source:"crop",cropBox:b,resizeToCrop:T.resizeToCrop===!0})},U=b=>{M.current||(M.current=!0,j(b,{resizeToCrop:!0}))};JS(()=>{if(i&&!l&&o&&!r){let b=B(e);M.current=!1,x.current=b,S.current=e,m(b),y(e),d(!0)}else if(!i&&l){let b=x.current??u;b&&U(b),x.current=null,S.current=null,d(!1),m(null),y(null)}},[i]);let X=(b,T)=>{!l||!u||(b.preventDefault(),b.stopPropagation(),b.target.setPointerCapture(b.pointerId),g.current={x:b.clientX,y:b.clientY,box:{...u},handle:T})},$=b=>{if(!l||!u||!g.current)return;b.preventDefault(),b.stopPropagation();let T=g.current;if(!I.current)return;let H=I.current.getBoundingClientRect();if(H.width<=0||H.height<=0)return;let te=f.width/H.width,fe=f.height/H.height,De=(b.clientX-T.x)*te,ui=(b.clientY-T.y)*fe,ws=P.left,ks=f.width-P.right,Bs=P.top,Rs=f.height-P.bottom,ye={...T.box},hr=30;if(T.handle==="center")ye.left=Math.max(ws,Math.min(ks-ye.width,T.box.left+De)),ye.top=Math.max(Bs,Math.min(Rs-ye.height,T.box.top+ui));else{if(T.handle.includes("l")){let ut=T.box.left+De,Tn=Math.max(ws,Math.min(T.box.left+T.box.width-hr,ut));ye.width=T.box.left+T.box.width-Tn,ye.left=Tn}if(T.handle.includes("r")){let ut=T.box.width+De;ye.width=Math.max(hr,Math.min(ks-T.box.left,ut))}if(T.handle.includes("t")){let ut=T.box.top+ui,Tn=Math.max(Bs,Math.min(T.box.top+T.box.height-hr,ut));ye.height=T.box.top+T.box.height-Tn,ye.top=Tn}if(T.handle.includes("b")){let ut=T.box.height+ui;ye.height=Math.max(hr,Math.min(Rs-T.box.top,ut))}}x.current=ye,m(ye),j(ye)},ue=b=>{!l||!g.current||(b.preventDefault(),b.stopPropagation(),b.target.releasePointerCapture(b.pointerId),g.current=null)};if(!w||!O)return N("div",{className:`graph2d-container ${t}`,style:{position:"relative"},children:Te("svg",{className:"graph2d-svg","data-testid":"graph2d-svg",role:"img","aria-label":`${A} \u7BC4\u56F2\u30A8\u30E9\u30FC`,viewBox:`0 0 ${f.width} ${f.height}`,children:[N("rect",{width:f.width,height:f.height,rx:"6",className:"graph2d-error-bg"}),N("text",{x:f.width/2,y:f.height/2,textAnchor:"middle",className:"graph2d-error-text",children:"\u30B0\u30E9\u30D5\u3092\u63CF\u753B\u3067\u304D\u307E\u305B\u3093"})]})});let J=gv(w,O),we=J?Vd(J.xMin,J.xMax,f.axes.xTickStep,f.kind==="numberLine"?8:12):[],ee=J&&f.kind!=="numberLine"?Vd(J.yMin,J.yMax,f.axes.yTickStep,9):[],be=f.axes.showX!==!1,Re=f.kind==="cartesian"&&f.axes.showY!==!1,ct=f.axes.showTicks!==!1,oi=J!==null&&J.yMin<=0&&J.yMax>=0,ii=J!==null&&J.xMin<=0&&J.xMax>=0,_e=be&&oi,ai=Re&&ii,yr=xv(w,f,P),vn=Re?bv(w,f,P):null,si=`axis-arrow-${D}`,Pn=(Me(f.axes.axisColor)?f.axes.axisColor:void 0)??(f.axes.renderStyle==="studyaid"?"#0d0d0d":void 0),li=(Ua(f.axes.axisStrokeWidth)?f.axes.axisStrokeWidth:void 0)??(f.axes.renderStyle==="studyaid"?.85:void 0),ci=yv(f.axes.axisDash??(f.axes.renderStyle==="studyaid"?"dashed":void 0)),Ms=Pn||li!==void 0||ci?{...Pn?{stroke:Pn}:{},...li!==void 0?{strokeWidth:li}:{},...ci?{strokeDasharray:ci}:{}}:void 0,hm=`graph2d-plot-clip-${D}`,Mn=`graph2d-graph-clip-${D}`,Ts=Math.max(0,f.width-P.left-P.right),Os=Math.max(0,f.height-P.top-P.bottom),ie=ma(f,P),gm=Q.some(b=>b.path),xm=u?[{name:"tl",x:u.left,y:u.top,cursor:"nwse-resize"},{name:"tr",x:u.left+u.width,y:u.top,cursor:"nesw-resize"},{name:"bl",x:u.left,y:u.top+u.height,cursor:"nesw-resize"},{name:"br",x:u.left+u.width,y:u.top+u.height,cursor:"nwse-resize"},{name:"t",x:u.left+u.width/2,y:u.top,cursor:"ns-resize"},{name:"b",x:u.left+u.width/2,y:u.top+u.height,cursor:"ns-resize"},{name:"l",x:u.left,y:u.top+u.height/2,cursor:"ew-resize"},{name:"r",x:u.left+u.width,y:u.top+u.height/2,cursor:"ew-resize"}]:[];return N("div",{ref:R,className:`graph2d-container ${t} ${l?"cropping":""}`,style:{position:"relative",width:"100%",height:"100%"},onDoubleClick:_,onPointerDown:b=>{l&&(b.stopPropagation(),W())},children:Te("svg",{ref:I,className:"graph2d-svg","data-testid":"graph2d-svg",role:"img","aria-label":A,viewBox:`0 0 ${f.width} ${f.height}`,onPointerMove:$,onPointerUp:ue,style:{touchAction:l?"none":"auto"},children:[N("title",{children:A}),Te("defs",{children:[N("marker",{id:si,markerWidth:"8",markerHeight:"8",refX:"6",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:N("path",{d:"M0 0 L7 4 L0 8 Z",className:"graph2d-axis-arrow",style:Pn?{fill:Pn}:void 0})}),N("clipPath",{id:hm,children:N("rect",{x:P.left,y:P.top,width:Ts,height:Os})}),N("clipPath",{id:Mn,children:N("rect",{x:ie.x,y:ie.y,width:ie.width,height:ie.height})}),Z.map(({pattern:b,patternId:T,color:H,opacity:te})=>b==="solid"?null:N(vv,{id:T,pattern:b,color:H,opacity:te},T))]}),N("rect",{x:P.left,y:P.top,width:Ts,height:Os,rx:"4",className:"graph2d-plot-bg"}),Z.length>0&&N("g",{className:"graph2d-fills",clipPath:`url(#${Mn})`,children:Z.map(({fill:b,path:T,color:H,opacity:te,pattern:fe,patternId:De})=>N("path",{className:"graph2d-fill-region","data-testid":"graph2d-fill-region",d:T,fill:fe==="solid"?H:`url(#${De})`,fillOpacity:fe==="solid"?te:void 0,fillRule:"evenodd"},b.id))}),f.axes.grid&&f.kind==="cartesian"&&Te("g",{className:"graph2d-grid",children:[we.map(b=>{let T=Y(b,0,w,f,P);return N("line",{x1:T.x,x2:T.x,y1:ie.y,y2:ie.y+ie.height},`x-grid-${b}`)}),ee.map(b=>{let T=Y(0,b,w,f,P);return N("line",{x1:ie.x,x2:ie.x+ie.width,y1:T.y,y2:T.y},`y-grid-${b}`)})]}),Te("g",{className:"graph2d-axes",children:[_e&&N("line",{x1:ie.x,x2:ie.x+ie.width,y1:yr,y2:yr,markerEnd:`url(#${si})`,style:Ms}),ai&&vn!==null&&N("line",{x1:vn,x2:vn,y1:ie.y+ie.height,y2:ie.y,markerEnd:`url(#${si})`,style:Ms})]}),ct&&Te("g",{className:"graph2d-ticks",children:[_e&&we.map(b=>{let T=Y(b,0,w,f,P),H=ha(b,f.axes.xTickMode,f.axes.xTickStep),te=Ua(f.axes.tickFontSize)?f.axes.tickFontSize:Gd,fe=Hd(H,te,c);return N(Ud,{cx:T.x,cy:yr+18,width:fe.width,height:fe.height,align:"middle",vAlign:"middle",tex:H,className:"graph2d-tex-label",fontSize:te,staticMode:r},`x-tick-${b}`)}),ai&&ee.map(b=>{let T=Y(0,b,w,f,P),H=ha(b,f.axes.yTickMode,f.axes.yTickStep),te=Ua(f.axes.tickFontSize)?f.axes.tickFontSize:Gd,fe=Hd(H,te,c);return N(Ud,{cx:P.left-8,cy:T.y,width:fe.width,height:fe.height,align:"end",vAlign:"middle",tex:H,className:"graph2d-tex-label",fontSize:te,staticMode:r},`y-tick-${b}`)})]}),N("g",{className:"graph2d-curves",clipPath:`url(#${Mn})`,children:Q.map(({curve:b,path:T})=>T?N("path",{"data-testid":"graph2d-curve",d:T,fill:"none",stroke:Qn(b.color),strokeWidth:ga(b.strokeWidth),strokeDasharray:zu(b),strokeLinecap:"butt",vectorEffect:"non-scaling-stroke"},b.id):null)}),N("g",{className:"graph2d-point-guides",clipPath:`url(#${Mn})`,children:(f.points??[]).map(b=>{let T=xa(b);if(!T)return null;let H=Y(T.x,T.y,w,f,P),te=Qn(b.color,"#dc2626");return Te("g",{children:[b.showXProjection&&_e&&N("line",{"data-testid":"graph2d-point-guide-x",x1:H.x,x2:H.x,y1:H.y,y2:yr,stroke:te,strokeOpacity:.65,strokeDasharray:"4 3",vectorEffect:"non-scaling-stroke"}),b.showYProjection&&ai&&vn!==null&&N("line",{"data-testid":"graph2d-point-guide-y",x1:H.x,x2:vn,y1:H.y,y2:H.y,stroke:te,strokeOpacity:.65,strokeDasharray:"4 3",vectorEffect:"non-scaling-stroke"})]},`point-guides-${b.id}`)})}),N("g",{className:"graph2d-points",clipPath:`url(#${Mn})`,children:(f.points??[]).map(b=>{let T=xa(b);if(!T)return null;let H=Y(T.x,T.y,w,f,P),te=Qn(b.color,"#dc2626"),fe=Sv(b.radius),De=b.fill==="none";return Te("g",{children:[De&&N("circle",{className:"graph2d-point-open-halo",cx:H.x,cy:H.y,r:fe+1.4,fill:"#ffffff",stroke:"none"}),N("circle",{className:"graph2d-point",cx:H.x,cy:H.y,r:fe,fill:De?"#ffffff":te,stroke:te,strokeWidth:De?2.4:0,vectorEffect:"non-scaling-stroke"})]},b.id)})}),v.length>0&&N("text",{x:f.width/2,y:f.height/2,textAnchor:"middle",className:"graph2d-error-text",children:"\u66F2\u7DDA\u304C\u8868\u793A\u7BC4\u56F2\u306E\u5916\u306B\u3042\u308A\u307E\u3059"}),!gm&&v.length===0&&f.curves.length>0&&N("text",{x:f.width/2,y:f.height/2,textAnchor:"middle",className:"graph2d-error-text",children:"\u5F0F\u3092\u8A55\u4FA1\u3067\u304D\u307E\u305B\u3093"}),l&&u&&Te(Mv,{children:[N("rect",{x:P.left,y:P.top,width:Math.max(0,u.left-P.left),height:f.height-P.top-P.bottom,fill:"#0f172a80",style:{pointerEvents:"none"}}),N("rect",{x:u.left+u.width,y:P.top,width:Math.max(0,f.width-P.right-(u.left+u.width)),height:f.height-P.top-P.bottom,fill:"#0f172a80",style:{pointerEvents:"none"}}),N("rect",{x:u.left,y:P.top,width:u.width,height:Math.max(0,u.top-P.top),fill:"#0f172a80",style:{pointerEvents:"none"}}),N("rect",{x:u.left,y:u.top+u.height,width:u.width,height:Math.max(0,f.height-P.bottom-(u.top+u.height)),fill:"#0f172a80",style:{pointerEvents:"none"}}),N("rect",{x:u.left,y:u.top,width:u.width,height:u.height,fill:"none",stroke:"#2563eb",strokeWidth:"2",strokeDasharray:"4 3",style:{cursor:"move",pointerEvents:"all"},onPointerDown:b=>X(b,"center")}),xm.map(b=>Te("g",{children:[N("circle",{cx:b.x,cy:b.y,r:5,fill:"#2563eb",stroke:"#ffffff",strokeWidth:"1.5",style:{pointerEvents:"none"}}),N("circle",{cx:b.x,cy:b.y,r:14,fill:"transparent",style:{cursor:b.cursor,pointerEvents:"all"},onPointerDown:T=>X(T,b.name)})]},b.name))]})]})})}function pv(e){try{return wt(e)}catch{return null}}function mv(e,t,n){let r=Wd({curve:e,graphViewBox:t.graphViewBox,height:t.height,kind:t.kind,plotBox:n,viewBox:t.viewBox,width:t.width});return Va(tv,r,()=>ya(e,t,n))}function fv(e,t,n){let r=Wd({axes:e.axes,curves:e.curves,fill:t,graphViewBox:e.graphViewBox,height:e.height,kind:e.kind,plotBox:n,viewBox:e.viewBox,width:e.width});return Va(nv,r,()=>Fd(e,t,n)??"")}function Vd(e,t,n,r){let o=`${e}:${t}:${n??""}:${r}`;return Va(rv,o,()=>$u(e,t,n,r))}function yv(e){if(e==="dashed")return"3 3";if(e==="dotted")return"1.2 3"}function Va(e,t,n){let r=e.get(t);if(r!==void 0)return e.delete(t),e.set(t,r),r;let o=n();if(e.set(t,o),e.size>ev){let i=e.keys().next().value;i!==void 0&&e.delete(i)}return o}function Wd(e){return JSON.stringify(e)}function hv(e){try{return Ye(e)}catch{return null}}function gv(e,t){let n=Math.max(e.xMin,t.xMin),r=Math.min(e.xMax,t.xMax),o=Math.max(e.yMin,t.yMin),i=Math.min(e.yMax,t.yMax);return n>=r||o>=i?null:{xMin:n,xMax:r,yMin:o,yMax:i}}function xv(e,t,n){return e.yMin<=0&&e.yMax>=0?Y(0,0,{...e,xMin:0,xMax:1},t,n).y:t.height-n.bottom}function bv(e,t,n){return e.xMin<=0&&e.xMax>=0?Y(0,0,e,t,n).x:n.left}function Sv(e){return Number.isFinite(e)&&e!==void 0?Math.min(12,Math.max(1.5,e)):4.3}function Eo(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")||"graph"}function vv({id:e,pattern:t,color:n,opacity:r}){let o=Math.min(.22,r*.45),i=Math.min(.95,Math.max(.36,r+.28)),a={stroke:n,strokeWidth:t==="cross"?1:1.25,strokeOpacity:i,strokeLinecap:"butt"};if(t==="dots")return Te("pattern",{id:e,width:"12",height:"12",patternUnits:"userSpaceOnUse",children:[N("rect",{width:"12",height:"12",fill:n,opacity:o}),N("circle",{cx:"3",cy:"3",r:"1.15",fill:n,opacity:i}),N("circle",{cx:"9",cy:"9",r:"1.15",fill:n,opacity:i})]});let s=Pv(t);return Te("pattern",{id:e,width:"10",height:"10",patternUnits:"userSpaceOnUse",children:[N("rect",{width:"10",height:"10",fill:n,opacity:o}),N("path",{d:s,...a})]})}function Pv(e){switch(e){case"diagonal":return"M -5 10 L 10 -5 M 0 10 L 10 0 M 5 10 L 10 5";case"diagonalBack":return"M 0 5 L 5 10 M 0 0 L 10 10 M 5 0 L 10 5";case"cross":return["M -5 10 L 10 -5","M 0 10 L 10 0","M 5 10 L 10 5","M 0 5 L 5 10","M 0 0 L 10 10","M 5 0 L 10 5"].join(" ");case"horizontal":return"M 0 3.2 H 10 M 0 8.2 H 10";case"vertical":return"M 3.2 0 V 10 M 8.2 0 V 10";case"dots":return""}}import{jsx as se,jsxs as ir}from"react/jsx-runtime";function ar({table:e,width:t,height:n,overflow:r=0,mathFractionSizing:o,selfContained:i,xmlns:a}){let s=qs(e,t,n);return se("div",{...a?{xmlns:a}:{},style:{boxSizing:"border-box",width:`${t+r*2}px`,height:`${n+r*2}px`,overflow:"visible",padding:`${r}px`,...yn(Qs)},children:ir("div",{style:{position:"relative",width:`${t}px`,height:`${n}px`},children:[ir("table",{style:{boxSizing:"border-box",width:`${t}px`,height:`${n}px`,borderCollapse:"collapse",tableLayout:"fixed",background:"transparent",border:0},children:[se("colgroup",{children:e.columns.map((c,l)=>se("col",{style:{width:`${s.columnWidths[l]}px`}},c.id))}),se("tbody",{children:s.rows.map(c=>se("tr",{style:{height:`${c.height}px`},children:c.cells.map(l=>se("td",{rowSpan:l.rowSpan>1?l.rowSpan:void 0,colSpan:l.colSpan>1?l.colSpan:void 0,style:yn({...Js,...tl(e,l.cell,l.rowIndex,l.columnIndex,l.rowSpan,l.colSpan)}),children:se("div",{style:yn({...el,...nl(e,l.cell)}),children:l.cell?.content.map(d=>se(Ov,{cell:l.cell,content:d,mathFractionSizing:o,selfContained:i},d.id))})},l.cell?.id??`${c.rowId}:${l.columnIndex}`))},c.rowId))})]}),se(Tv,{table:e,columnOffsets:s.columnOffsets,rowOffsets:s.rowOffsets})]})})}function Tv({table:e,columnOffsets:t,rowOffsets:n}){let r=rl(e,t,n),o=ol(e,t,n);return r.length===0&&o.length===0?null:ir("div",{style:{position:"absolute",inset:0,zIndex:2,pointerEvents:"none"},children:[r.map(i=>se("div",{style:{position:"absolute",...i.axis==="vertical"?{top:0,bottom:0,width:0}:{right:0,left:0,height:0},...yn(i.style),pointerEvents:"none"}},`rendered-${i.axis}-${i.domKey}`)),o.map(i=>se("div",{style:{position:"absolute",zIndex:3,boxSizing:"border-box",...yn(i.style),pointerEvents:"none"}},i.id))]})}function Ov({cell:e,content:t,mathFractionSizing:n,selfContained:r}){return t.type==="trend"?se(Xd,{colSpan:e?.colSpan??1,content:t,mathFractionSizing:n,selfContained:r}):se("p",{style:{margin:0,...yn(t.align?{textAlign:t.align}:{})},children:xe(t.children,{keyPrefix:t.id,mathFractionSizing:n,selfContained:r})})}function Xd({content:e,colSpan:t,mathFractionSizing:n,selfContained:r}){let o=Zs(e.direction,t);return ir("div",{className:"overlay-table-trend",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"4px",width:"100%",minHeight:"1.75em"},children:[ir("svg",{xmlns:"http://www.w3.org/2000/svg",width:o.width,height:o.height,viewBox:`0 0 ${o.width} ${o.height}`,style:{display:"block",overflow:"visible",width:"100%",height:"100%"},children:[se("line",{x1:o.line.x1,y1:o.line.y1,x2:o.line.x2,y2:o.line.y2,stroke:o.color,strokeWidth:o.strokeWidth}),se("polygon",{points:o.arrowPoints,fill:o.color})]}),e.label?.length?se("span",{children:xe(e.label,{keyPrefix:`${e.id}-label`,mathFractionSizing:n,selfContained:r})}):null]})}function yn(e){let t;for(let[n,r]of Object.entries(e))et(r)||(t??={...e},delete t[n]);return t??e}import{useMemo as wv}from"react";import{Fragment as Rv,jsx as Co}from"react/jsx-runtime";function Wa({node:e,keyPrefix:t="overlay",mathFractionSizing:n}){let r=wv(()=>go(e,{runIdPrefix:t}),[t,e]);return Co(Rv,{children:r.map(o=>kv(o,n))})}function kv(e,t){let n=e.isBlank?Co("br",{}):Co(Ca,{nodes:e.inlineNodes,keyPrefix:e.key,mathFractionSizing:t}),r=Bv(e.style),o=e.tag;return Co(o,{style:r,children:n},e.key)}function Bv(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))t[n.startsWith("--")?n:n.replace(/-([a-z])/g,(o,i)=>i.toUpperCase())]=r;return t}import{jsx as Ne,jsxs as Kd}from"react/jsx-runtime";var Iv=e=>e,Ev={};function Lo({block:e,classNames:t=Ev,mathFractionSizing:n,resolveText:r=Iv}){return e.type==="heading"?Ne(Cv,{block:e,className:t.heading,mathFractionSizing:n,resolveText:r}):e.type==="list"?Ne(Yd,{block:e,classNames:t,mathFractionSizing:n,resolveText:r}):Ne(Lv,{block:e,className:t.paragraph,mathFractionSizing:n,resolveText:r})}function Cv({block:e,className:t,mathFractionSizing:n,resolveText:r}){let o=`h${e.level}`,i=Xa(e.children),{aligned:a,alignmentStyles:s,ref:c}=pn(i);return Ne(o,{ref:c,"data-boxed-run-aligned":a?"true":void 0,"data-sigma-doc-id":e.id,className:t,style:{textAlign:e.align??"left",lineHeight:e.lineHeight},children:xe(e.children,{alignmentStyles:s,keyPrefix:e.id,mathFractionSizing:n,resolveText:r})})}function Lv({block:e,className:t,mathFractionSizing:n,resolveText:r}){let o=Xa(e.children),{aligned:i,alignmentStyles:a,ref:s}=pn(o);return Kd("p",{ref:s,"data-boxed-run-aligned":i?"true":void 0,"data-sigma-doc-id":e.id,className:t,style:{textAlign:e.align??"left",lineHeight:e.lineHeight},children:[xe(e.children,{alignmentStyles:a,keyPrefix:e.id,mathFractionSizing:n,resolveText:r}),!Fv(e.children)&&Ne("br",{},"trailing-break")]})}function Yd({block:e,classNames:t,mathFractionSizing:n,resolveText:r}){let o=e.items.map(i=>{let a=Yu(i.children);return Kd("li",{"data-sigma-doc-id":i.id,...a?.attrs,style:a?.style,children:[Ne(Nv,{item:i,mathFractionSizing:n,resolveText:r}),(i.nested??[]).map(s=>Ne(Yd,{block:s,classNames:t,mathFractionSizing:n,resolveText:r},s.id))]},i.id)});return e.listType==="ordered"?Ne("ol",{"data-sigma-doc-id":e.id,"data-list-marker":e.markerStyle==="paren"?"paren":void 0,className:t.list,start:e.start,children:o}):Ne("ul",{"data-sigma-doc-id":e.id,className:t.list,children:o})}function Nv({item:e,mathFractionSizing:t,resolveText:n}){let r=Xa(e.children),{aligned:o,alignmentStyles:i,ref:a}=pn(r);return Ne("span",{ref:a,"data-boxed-run-aligned":o?"true":void 0,children:xe(e.children,{alignmentStyles:i,keyPrefix:e.id,mathFractionSizing:t,resolveText:n})})}function Fv(e){return e.some(t=>t.type==="text"?t.text.length>0:!0)}function Xa(e){return Av(()=>Ea(e),[e])}import{useMemo as ap}from"react";import{memo as Fo}from"react";function jd(e,t){let n=Wt(e,t),r=$n(e,t,n);return{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}function hn(e){if(e==="dashed")return"8 6";if(e==="dotted")return"1 6"}function Zd(e,t,n,r,o,i,a){return e==="blockArrow"?gt(t,n,o,i,1).map(s=>`${s.x},${s.y}`).join(" "):e==="triangle"?`${Nt(r??t/2,1,Math.max(1,t-1))},1 ${Math.max(1,t-1)},${Math.max(1,n-1)} 1,${Math.max(1,n-1)}`:e==="diamond"?`${t/2},1 ${Math.max(1,t-1)},${n/2} ${t/2},${Math.max(1,n-1)} 1,${n/2}`:bt(t,n,e==="pentagon"?5:xt(a),1).map(s=>`${s.x},${s.y}`).join(" ")}function qd(e,t){let{rx:n,ry:r}=ce(e);return{x:n+Math.cos(t)*n,y:r+Math.sin(t)*r}}function Jd(e){let{rx:t,ry:n}=ce(e),r=Wr(e),o=qd(e,r.startAngle),i=qd(e,r.endAngle),s=Se(r.endAngle-r.startAngle)>Math.PI?1:0;return e.props.kind==="sector"?`M ${t} ${n} L ${o.x} ${o.y} A ${t} ${n} 0 ${s} 1 ${i.x} ${i.y} Z`:`M ${o.x} ${o.y} A ${t} ${n} 0 ${s} 1 ${i.x} ${i.y}`}function Qd(e){return e.props.kind!=="sector"||e.props.fill==="none"?"none":e.props.fillColor??e.props.color}function At(e,t,n){let r=kn(n,e,t);return r?`url(#${r})`:void 0}var rL=Xu();import{Fragment as ip,jsx as L,jsxs as Oe}from"react/jsx-runtime";var No=14;function np(e,t,n){if(!n)return"center";let r=Qe(e);return`${r.x-t.x}px ${r.y-t.y}px`}function ep(e,t){let n=Kr(e);return n?{x:n.anchor.x-t.x,y:n.anchor.y-t.y}:null}var _v=()=>{},Dv=()=>{};var Gv=()=>{},$v=()=>{};function rp({shape:e,assets:t,externalRevision:n=0,diffClassName:r,decoration:o}){return L(zv,{shape:e,assets:t,externalRevision:n,selected:!1,editing:!1,disableGraphCrop:!0,hideGraphAxes:!1,originPickPreview:null,dragTranslate:null,diffClassName:r,decoration:o,onPointerDown:Gv,onDoubleClick:$v,onGraphSpecChange:_v,onGraphCropEnd:Dv})}function op(e,t){let n=[];return t&&(t.x!==0||t.y!==0)&&n.push(`translate(${t.x}px, ${t.y}px)`),e&&n.push(`rotate(${e}rad)`),n.length>0?n.join(" "):void 0}var zv=Fo(function({shape:t,assets:n,externalRevision:r,selected:o,editing:i,disableGraphCrop:a,hideGraphAxes:s,originPickPreview:c,dragTranslate:l,onPointerDown:d,onDoubleClick:u,onGraphSpecChange:m,onGraphCropEnd:h,diffClassName:y,decoration:g,editorRenderers:x}){un("OverlayShapeView.render");let S=de(t),I=ve(t),R=`overlay-shape overlay-shape-${t.type} ${o?"selected":""} ${t.locked?"locked":""} ${g?.className??""} ${y??""}`;return Oe("div",{"data-overlay-shape-id":t.id,className:R,style:{left:S.x,top:S.y,width:S.w,height:S.h,transform:op(I,l),transformOrigin:np(t,S,I),opacity:t.opacity},onPointerDown:M=>d(M,t),onDoubleClickCapture:M=>{t.type==="graph2dShape"&&(M.preventDefault(),M.stopPropagation(),u(M,t))},onDoubleClick:M=>{t.type!=="graph2dShape"&&(M.preventDefault(),M.stopPropagation(),u(M,t))},children:[L(Uv,{shape:t,assets:n,bounds:S,externalRevision:r,editing:i,disableGraphCrop:a,hideGraphAxes:s,originPickPreview:c,onGraphSpecChange:m,onGraphCropEnd:h,editorRenderers:x}),g?.content]})}),OL=Fo(function({shapes:t,dragTranslate:n,movingShapeIds:r}){return L(ip,{children:t.map(o=>L(Hv,{shape:o,dragTranslate:r?.has(o.id)?n:null},`dimension-${o.id}`))})}),Hv=Fo(function({shape:t,dragTranslate:n}){let r=Bi(t),o=di(r,ve(t)),i=r.x+r.w/2,a=n?.x??0,s=n?.y??0;return L("div",{className:"overlay-shape-dimension-label",style:{left:i+a,top:o.y+o.h+2+s},"aria-hidden":"true",children:Xv(r)})}),wL=Fo(function({shape:t,selected:n,dragTranslate:r,onPointerDown:o,onDoubleClick:i}){let a=de(t),s=ve(t);return L("div",{"data-overlay-shape-id":t.id,className:`overlay-shape overlay-shape-hit-target ${n?"selected":""}`,style:{left:a.x,top:a.y,width:a.w,height:a.h,transform:op(s,r),transformOrigin:np(t,a,s)},onPointerDown:c=>o(c,t),onDoubleClick:c=>{c.preventDefault(),c.stopPropagation(),i(c,t)}})});function Uv({shape:e,assets:t,bounds:n,externalRevision:r,editing:o,disableGraphCrop:i,hideGraphAxes:a,originPickPreview:s,onGraphSpecChange:c,onGraphCropEnd:l,editorRenderers:d}){if(e.type==="geo"){let u=re(e.props.size),m={x:e.props.w/2,y:e.props.h/2};return Oe("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${e.props.w} ${e.props.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:u,strokeDasharray:hn(e.props.dash)},children:[L(Vv,{shape:e}),e.props.label&&L("text",{x:m.x,y:m.y,fill:e.props.labelColor,stroke:"none",textAnchor:"middle",dominantBaseline:"middle",fontSize:$e(e.props.size),children:e.props.label})]})}if(e.type==="arrow"){let u={x:e.x+e.props.start.x-n.x,y:e.y+e.props.start.y-n.y},m={x:e.x+e.props.end.x-n.x,y:e.y+e.props.end.y-n.y},h=ep(e,n),y=re(e.props.size),g=We(e),[x,S]=Ut([u,m],g.start.trimPx,g.end.trimPx);return Oe("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:y,strokeDasharray:hn(e.props.dash)},children:[L("defs",{children:L(Ya,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:g})}),L("line",{x1:x.x,y1:x.y,x2:S.x,y2:S.y,strokeOpacity:e.props.strokeOpacity,markerStart:At(e.id,"start",g.start.spec?.kind),markerEnd:At(e.id,"end",g.end.spec?.kind)}),h&&L("text",{x:h.x,y:h.y,fill:e.props.labelColor,stroke:"none",textAnchor:"middle",fontSize:$e(e.props.size),children:e.props.label})]})}if(e.type==="line"){let u=Pe(e.props.kind),m=e.props.points.map(z=>({x:e.x+z.x-n.x,y:e.y+z.y-n.y})),h=Ve(u,m,e.props.closed),y=ep(e,n),g=re(e.props.size),x=We(e),S=Ut(m,x.start.trimPx,x.end.trimPx),I=At(e.id,"start",x.start.spec?.kind),R=At(e.id,"end",x.end.spec?.kind),M=`fill-${e.id}`,C=h&&e.props.fill==="solid"?e.props.fillPattern==="diagonalHatch"?`url(#${M})`:e.props.fillColor??e.props.color:"none";return Oe("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:g,strokeDasharray:hn(e.props.dash)},children:[Oe("defs",{children:[L(Ya,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:x}),e.props.fillPattern==="diagonalHatch"&&Oe("pattern",{id:M,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[L("rect",{width:"6",height:"6",fill:e.props.fillColor??"#ffffff"}),L("path",{d:"M -1 7 L 7 -1",stroke:e.props.color,strokeWidth:"1"})]})]}),h?L("polygon",{points:ht(m),fill:C,fillOpacity:e.props.fillOpacity,strokeOpacity:e.props.strokeOpacity}):u==="polyline"?L("polyline",{points:ht(S),strokeOpacity:e.props.strokeOpacity,markerStart:I,markerEnd:R}):L("path",{d:Gn(m,u,Vr(x)),strokeOpacity:e.props.strokeOpacity,markerStart:I,markerEnd:R}),y&&L("text",{x:y.x,y:y.y,fill:e.props.labelColor??e.props.color,stroke:"none",textAnchor:"middle",fontSize:$e(e.props.size),children:e.props.label})]})}if(e.type==="arc"){let u=re(e.props.size),m=We(e),h=At(e.id,"start",m.start.spec?.kind),y=At(e.id,"end",m.end.spec?.kind);return Oe("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:u,strokeDasharray:hn(e.props.dash)},children:[L("defs",{children:L(Ya,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:m})}),L("path",{d:Jd(e),fill:Qd(e),fillOpacity:e.props.kind==="sector"?e.props.fillOpacity:void 0,stroke:"currentColor",strokeOpacity:e.props.strokeOpacity,markerStart:h,markerEnd:y})]})}if(e.type==="image"){let u=t[e.props.assetId];return u?L(Wv,{shape:e,asset:u,editing:o}):null}if(e.type==="callout"){let u=zt(e),m=Nr(e),h=e.x-n.x,y=e.y-n.y;return Oe("div",{className:"callout-shape overlay-callout-shape",children:[L("svg",{className:"callout-shape-svg",viewBox:`${u.bounds.x} ${u.bounds.y} ${u.bounds.w} ${u.bounds.h}`,"aria-hidden":"true",style:{strokeWidth:re(e.props.strokeWidth),strokeDasharray:hn(e.props.dash)},children:L("path",{d:Nn(e)})}),L("div",{className:"overlay-callout-text-frame",style:{left:h+m.x,top:y+m.y,width:m.w,height:m.h},children:o&&d?d.renderTextEditor({editing:o,externalRevision:r,shape:e}):L(tp,{shape:e})})]})}if(e.type==="graph2dShape"){let u=Ge(e),m=u.spec,h=a?Yv(m):m,y=o||i||a||s!==null;return Oe("div",{id:e.id,className:"graph-shape overlay-graph-shape","data-testid":"overlay-graph2d",style:{position:"absolute",left:u.renderBounds.x-e.x,top:u.renderBounds.y-e.y,width:u.renderBounds.w,height:u.renderBounds.h,pointerEvents:y?"auto":"none"},children:[L(fn,{spec:h,autoStartCrop:o,disableCropInteraction:i,onSpecChange:(g,x)=>c(e.id,g,x),onCropEnd:l}),s&&Oe("div",{className:"graph-origin-preview","data-testid":"overlay-graph-origin-preview","aria-hidden":"true",children:[L(fn,{spec:Kv(s.spec),className:"graph-origin-preview-graph",staticMode:!0,disableCropInteraction:!0}),Oe("svg",{className:"graph-origin-preview-marker","data-testid":"overlay-graph-origin-preview-target",viewBox:`0 0 ${s.spec.width} ${s.spec.height}`,"aria-hidden":"true",children:[L("line",{x1:Math.max(0,s.point.x-No),x2:Math.min(s.spec.width,s.point.x+No),y1:s.point.y,y2:s.point.y}),L("line",{x1:s.point.x,x2:s.point.x,y1:Math.max(0,s.point.y-No),y2:Math.min(s.spec.height,s.point.y+No)}),L("circle",{cx:s.point.x,cy:s.point.y,r:"6"})]})]})]})}return e.type==="tableShape"?d?d.renderTableEditor({editing:o,shape:e}):L(ar,{height:e.props.h,table:e.props.table,width:e.props.w}):e.type==="group"?null:!o||!d?L(tp,{shape:e}):d.renderTextEditor({editing:o,externalRevision:r,shape:e})}function Vv({shape:e}){let n={fill:e.props.fill==="solid"?e.props.fillColor??e.props.color:"transparent",stroke:e.props.color,fillOpacity:e.props.fillOpacity,strokeOpacity:e.props.strokeOpacity};if(e.props.geo==="ellipse")return L("ellipse",{cx:e.props.w/2,cy:e.props.h/2,rx:Math.max(1,e.props.w/2-1),ry:Math.max(1,e.props.h/2-1),...n});if(e.props.geo==="triangle"||e.props.geo==="diamond"||e.props.geo==="pentagon"||e.props.geo==="regularPolygon"||e.props.geo==="blockArrow")return L("polygon",{points:Zd(e.props.geo,e.props.w,e.props.h,e.props.apexX,e.props.headLengthRatio,e.props.shaftRatio,e.props.polygonSides),...n});let r=typeof e.props.radius=="number"&&e.props.radius>0?Math.max(0,Math.min(e.props.radius,e.props.w/2-1,e.props.h/2-1)):void 0;return L("rect",{x:1,y:1,width:Math.max(1,e.props.w-2),height:Math.max(1,e.props.h-2),rx:r,ry:r,...n})}function Ya({shapeId:e,color:t,opacity:n,plan:r}){return L(ip,{children:Sr(e,r).map(({spec:o,endpoint:i,id:a,refX:s})=>L("marker",{id:a,markerWidth:o.markerWidth,markerHeight:o.markerHeight,refX:s,refY:o.refY,orient:vr(o,i),markerUnits:"strokeWidth",children:o.geometry.kind==="circle"?L("circle",{cx:o.geometry.cx,cy:o.geometry.cy,r:o.geometry.r,fill:o.geometry.filled?t:"none",opacity:n,stroke:"none"}):L("path",{d:Bn(o.geometry),fill:o.geometry.filled?t:"none",opacity:n,stroke:o.geometry.filled?"none":t,strokeWidth:o.geometry.filled?void 0:o.geometry.strokeWidth,strokeLinecap:"butt",strokeLinejoin:"miter"})},a))})}function tp({shape:e}){let t=yt(e),n=e.type==="callout",r=e.type==="text"&&e.props.autoSize,o=e.type==="text"&&e.props.autoSize&&e.props.maxWidth!==void 0;return L("div",{className:`overlay-text-shape ${n?"embedded-callout":""} ${r?"auto-size":""} ${o?"constrained":""}`,style:{width:n?"100%":o?e.props.maxWidth:r?"max-content":e.props.w,minWidth:n?0:An,minHeight:n?t:Math.max(e.props.h??0,t),color:e.props.color,fontSize:`${ft(e)}pt`,pointerEvents:"none"},children:L("div",{className:"overlay-text-shape-content ProseMirror",children:L(Wa,{node:e.props.richText,keyPrefix:`overlay-text-${e.id}`})})})}function Wv({shape:e,asset:t,editing:n}){let r=jd(e,t);return Oe("div",{className:`overlay-image-frame ${n?"cropping":""}`,children:[n&&L("div",{className:"overlay-image-crop-ghost",style:{width:r.width,height:r.height,transform:r.transform},"aria-hidden":"true",children:L("img",{src:t.props.src,alt:"",draggable:!1})}),L("div",{className:"overlay-image-crop-viewport",children:L("div",{className:"overlay-image-crop-inner",style:{width:r.width,height:r.height,transform:r.transform},children:L("img",{className:"overlay-image-shape",src:t.props.src,alt:t.props.name,draggable:!1})})})]})}function Xv(e){return`${Math.max(1,Math.round(e.w))} x ${Math.max(1,Math.round(e.h))}`}function Yv(e){return{...e,axes:{...e.axes,grid:!1,showX:!1,showY:!1,showTicks:!1}}}function Kv(e){return{...e,title:"",axes:{...e.axes,grid:!1,showX:!0,showY:e.kind==="cartesian",showTicks:!1},points:void 0,annotations:void 0,fills:void 0,showFormulaLabels:!1}}import{jsx as sp}from"react/jsx-runtime";function lp({overlay:e,widthPx:t,heightPx:n,interactive:r=!1,className:o,onPointerDown:i,onDoubleClick:a}){let s=ap(()=>{let l=e?.overlaySnapshot;if(!l)return[];let d=Ht(me(l).shapes);return Ir(d).map(u=>{let m=Er(d,u);return m===u.opacity?u:{...u,opacity:m}})},[e?.overlaySnapshot]),c=ap(()=>me(e?.overlaySnapshot).assets,[e?.overlaySnapshot]);return sp("div",{className:[o??"page-running-overlay-preview",r?"interactive":""].filter(Boolean).join(" "),"aria-hidden":"true",style:{width:`${t}px`,height:`${n}px`},onPointerDown:i,onDoubleClick:a,children:s.map(l=>sp(rp,{shape:l,assets:c},l.id))})}import{jsx as _o,jsxs as qv}from"react/jsx-runtime";function Ka({region:e,kind:t,title:n,pageNumber:r,totalPages:o,metrics:i,mathFractionSizing:a}){if(!e?.enabled||!Wc(e)||r===1&&!e.showOnFirstPage)return null;let s={left:`${i.margins.leftPx}px`,right:`${i.margins.rightPx}px`,height:`${ne(e.heightMm)}px`,[t==="header"?"top":"bottom"]:`${ne(e.offsetMm)}px`},c=ou(i.content.widthPx,e),l=d=>jv(d,n,r,o);return qv("div",{className:`page-running-region ${t} free`,style:s,children:[_o(lp,{overlay:e.overlay,widthPx:c.widthPx,heightPx:c.heightPx}),_o("div",{className:"page-running-text-layer text-flow-shell",children:_o("div",{className:"text-flow-editor",children:e.blocks.map(d=>_o(Lo,{block:d,mathFractionSizing:a,resolveText:l},d.id))})})]})}function jv(e,t,n,r){return e.split(/(\{title\}|\{page\}|\{total\}|\/\s*title|\/\s*page|\/\s*total)/g).map(o=>{let i=o.replace(/\s+/g,"");return i==="{title}"||i==="/title"?t:i==="{page}"||i==="/page"?String(n):i==="{total}"||i==="/total"?String(r):o}).join("")}import{jsx as Jv}from"react/jsx-runtime";var Zv={heading:"print-heading",list:"print-list",paragraph:"print-paragraph"};function gn({block:e,mathFractionSizing:t,resolveText:n}){return Jv(Lo,{block:e,classNames:Zv,mathFractionSizing:t,resolveText:n})}var Qv=64,st='stroke-linecap="butt" stroke-linejoin="miter"',eP=.6;function cp(e){return Math.ceil(e*eP)}function Za(e,t,n,r,o={}){if(e.length===0)return;let i=me({version:1,shapes:e,assets:t}),a=i.assets,s=Ht(i.shapes),c=o.stackLayer?cl(s,o.stackLayer):s,d=Ir(c).filter(y=>tP(y,n,o.viewportPaddingPx));if(d.length===0)return;let u=n.offsetX??0,m=n.offsetY??0,h=d.map(y=>nP(oP(y,Er(c,y)),a,r)).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${u} ${m} ${n.width} ${n.height}" width="${n.width}" height="${n.height}">`,"<defs>","</defs>",h,"</svg>"].join("")}function tP(e,t,n=Qv){let r=t.offsetX??0,o=t.offsetY??0,i=r-n,a=o-n,s=r+t.width+n,c=o+t.height+n,l=de(e);return l.x+l.w>=i&&l.x<=s&&l.y+l.h>=a&&l.y<=c}function up(e){return Me(e)?e:Xt}function nP(e,t,n){let r="";if(e.type==="group")return"";if(e.type==="geo"){let o=K(e.props.color||"#111111"),i=re(e.props.size),a=sr(e.props.dash),s=e.props.fill==="solid"?K(e.props.fillColor||e.props.color||"#111111"):"transparent",c=lt("stroke-opacity",e.props.strokeOpacity),l=lt("fill-opacity",e.props.fillOpacity);if(e.props.geo==="ellipse")return r=`<ellipse cx="${e.x+e.props.w/2}" cy="${e.y+e.props.h/2}" rx="${e.props.w/2}" ry="${e.props.h/2}" fill="${s}" stroke="${o}" stroke-width="${i}" ${st}${a}${c}${l} />`,Be(e,Fe(e,ja(e,r)));if(e.props.geo==="triangle"||e.props.geo==="diamond"||e.props.geo==="pentagon"||e.props.geo==="regularPolygon"||e.props.geo==="blockArrow")return r=`<polygon points="${cP(aP(e.props.geo,e.props.w,e.props.h,e.props.apexX,e.props.headLengthRatio,e.props.shaftRatio,e.props.polygonSides),e.x,e.y)}" fill="${s}" stroke="${o}" stroke-width="${i}" ${st}${a}${c}${l} />`,Be(e,Fe(e,ja(e,r)));let d=typeof e.props.radius=="number"&&e.props.radius>0?Math.max(0,Math.min(e.props.radius,e.props.w/2,e.props.h/2)):0,u=d>0?` rx="${d}" ry="${d}"`:"";return r=`<rect x="${e.x}" y="${e.y}" width="${e.props.w}" height="${e.props.h}"${u} fill="${s}" stroke="${o}" stroke-width="${i}" ${st}${a}${c}${l} />`,Be(e,Fe(e,ja(e,r)))}if(e.type==="arrow"){let o={x:e.x+e.props.start.x,y:e.y+e.props.start.y},i={x:e.x+e.props.end.x,y:e.y+e.props.end.y},a=We(e),[s,c]=Ut([o,i],a.start.trimPx,a.end.trimPx),l=qa(e.id,e.props.color,e.props.strokeOpacity,a),d=xn("marker-start",e.id,"start",a.start.spec?.kind),u=xn("marker-end",e.id,"end",a.end.spec?.kind);return r=`<defs>${l}</defs><line x1="${s.x}" y1="${s.y}" x2="${c.x}" y2="${c.y}" stroke="${K(e.props.color)}" stroke-width="${re(e.props.size)}" ${st}${sr(e.props.dash)}${lt("stroke-opacity",e.props.strokeOpacity)}${d}${u} />`,Be(e,Fe(e,dp(e,r)))}if(e.type==="line"){let o=Pe(e.props.kind),i=e.props.points.map(x=>({x:e.x+x.x,y:e.y+x.y})),a=Ve(o,i,e.props.closed),s=We(e),c=Ut(i,s.start.trimPx,s.end.trimPx),l=qa(e.id,e.props.color,e.props.strokeOpacity,s),d=xn("marker-start",e.id,"start",s.start.spec?.kind),u=xn("marker-end",e.id,"end",s.end.spec?.kind),m=iP(e),h=a&&e.props.fill==="solid"?e.props.fillPattern==="diagonalHatch"?`url(#${K(mp(e.id))})`:K(e.props.fillColor||e.props.color||"#111111"):"none",y=a?lt("fill-opacity",e.props.fillOpacity):"",g=`fill="${h}" stroke="${K(e.props.color)}" stroke-width="${re(e.props.size)}" ${st}${sr(e.props.dash)}${lt("stroke-opacity",e.props.strokeOpacity)}${y}${d}${u}`;return r=a?`<defs>${l}${m}</defs><polygon points="${ht(i)}" ${g} />`:o==="polyline"?`<defs>${l}${m}</defs><polyline points="${ht(c)}" ${g} />`:`<defs>${l}${m}</defs><path d="${K(Gn(i,o,Vr(s)))}" ${g} />`,Be(e,Fe(e,dp(e,r)))}if(e.type==="arc"){let o=lP(e),i=e.props.kind==="sector"?lt("fill-opacity",e.props.fillOpacity):"",a=We(e),s=qa(e.id,e.props.color,e.props.strokeOpacity,a),c=xn("marker-start",e.id,"start",a.start.spec?.kind),l=xn("marker-end",e.id,"end",a.end.spec?.kind);return r=`<defs>${s}</defs><path d="${K(sP(e))}" fill="${o}" stroke="${K(e.props.color)}" stroke-width="${re(e.props.size)}" ${st}${sr(e.props.dash)}${lt("stroke-opacity",e.props.strokeOpacity)}${i}${c}${l} />`,Be(e,Fe(e,r))}if(e.type==="image"){let o=t[e.props.assetId],i=o?rP(o):null;if(!i)return"";let a=Wt(e,o),s=$n(e,o,a),c=e.x+s.x,l=e.y+s.y,d=`clip-${K(e.id)}`;return r=[`<clipPath id="${d}"><rect x="${e.x}" y="${e.y}" width="${e.props.w}" height="${e.props.h}" /></clipPath>`,`<image x="${c}" y="${l}" width="${s.width}" height="${s.height}" href="${K(i)}" preserveAspectRatio="none" clip-path="url(#${d})" />`].join(""),Be(e,Fe(e,r))}if(e.type==="callout"){let o=Nr(e),i=ft(e),a=cp(ze(e)),s=Ta(e.props.richText,{renderMathHtml:n.renderMathHtml,selfContained:!0}),c=`<path transform="translate(${e.x} ${e.y})" d="${K(Nn(e))}" fill="transparent" stroke="#111111" stroke-width="${re(e.props.strokeWidth)}" ${st}${sr(e.props.dash)} />`,l=Do(e.x+o.x-a,e.y+o.y-a,o.w+a*2,o.h+a*2,[`<div xmlns="http://www.w3.org/1999/xhtml" style="box-sizing:border-box;display:flex;align-items:center;justify-content:center;width:${o.w}px;height:${o.h}px;margin:${a}px;color:${K(up(e.props.color))};font-size:${i}pt;line-height:${Ie};overflow:visible;overflow-wrap:anywhere;white-space:pre-wrap;text-align:center;">`,`<div style="width:100%;min-width:0;">${s}</div>`,"</div>"].join(""),{overflowVisible:!0});return r=`${c}${l}`,Be(e,Fe(e,r))}if(e.type==="graph2dShape"){let o=Ge(e),i=n.renderGraphHtml(o.spec,e.id);return r=Do(o.renderBounds.x,o.renderBounds.y,o.renderBounds.w,o.renderBounds.h,[`<div xmlns="http://www.w3.org/1999/xhtml" style="width:${o.renderBounds.w}px;height:${o.renderBounds.h}px;overflow:hidden;background:transparent;">`,i,"</div>"].join("")),Be(e,Fe(e,r))}if(e.type==="text"){let o=de(e),i=ft(e),a=cp(ze(e)),s=Ta(e.props.richText,{renderMathHtml:n.renderMathHtml,selfContained:!0}),c=e.props.autoSize?e.props.maxWidth!==void 0?"white-space:pre-wrap;overflow-wrap:anywhere;":"white-space:pre;":"white-space:pre-wrap;";return r=Do(e.x-a,e.y-a,o.w+a*2,o.h+a*2,[`<div xmlns="http://www.w3.org/1999/xhtml" style="box-sizing:border-box;width:${o.w}px;min-height:${o.h}px;margin:${a}px;color:${K(up(e.props.color))};font-size:${i}pt;line-height:${Ie};overflow:visible;${c}">`,s,"</div>"].join(""),{overflowVisible:!0}),Be(e,Fe(e,r))}if(e.type==="tableShape"){let o=dP(e.props.table);return r=Do(e.x-o,e.y-o,e.props.w+o*2,e.props.h+o*2,n.renderTableHtml(e.props.table,e.props.w,e.props.h,o)),Be(e,r)}return""}function rP(e){return e.props.storage&&e.props.src.startsWith("sigma-doc-storage://")?null:Hn(e.props.src)}function oP(e,t){return t===void 0?e:{...e,opacity:t}}function Fe(e,t){let n=ve(e);if(!n)return t;let r=Qe(e);return`<g transform="rotate(${uP(n)} ${r.x} ${r.y})">${t}</g>`}function Be(e,t){return e.opacity===void 0||e.opacity>=1?t:`<g opacity="${e.opacity}">${t}</g>`}function ja(e,t){return e.props.label?[t,`<text x="${e.x+e.props.w/2}" y="${e.y+e.props.h/2}" fill="${K(e.props.labelColor)}" stroke="none" text-anchor="middle" dominant-baseline="middle" font-size="${$e(e.props.size)}">${ge(e.props.label)}</text>`].join(""):t}function dp(e,t){let n=Kr(e);return n?[t,`<text x="${n.anchor.x}" y="${n.anchor.y}" fill="${K(e.props.labelColor??e.props.color)}" stroke="none" text-anchor="middle" font-size="${n.fontSizePx}">${ge(n.text)}</text>`].join(""):t}function qa(e,t,n,r){let o=K(t),i=lt("opacity",n);return Sr(e,r).map(({spec:a,endpoint:s,id:c,refX:l})=>{let d=a.geometry.kind==="circle"?`<circle cx="${a.geometry.cx}" cy="${a.geometry.cy}" r="${a.geometry.r}" fill="${a.geometry.filled?o:"none"}"${i} />`:a.geometry.filled?`<path d="${Bn(a.geometry)}" fill="${o}" stroke="none"${i} />`:`<path d="${Bn(a.geometry)}" fill="none" stroke="${o}" stroke-width="${a.geometry.strokeWidth}" ${st}${i} />`;return`<marker id="${K(c)}" markerWidth="${a.markerWidth}" markerHeight="${a.markerHeight}" refX="${l}" refY="${a.refY}" orient="${vr(a,s)}" markerUnits="strokeWidth">${d}</marker>`}).join("")}function mp(e){return`fill-${e}`}function iP(e){if(e.props.fillPattern!=="diagonalHatch")return"";let t=K(mp(e.id)),n=K(e.props.fillColor??"#ffffff"),r=K(e.props.color);return`<pattern id="${t}" patternUnits="userSpaceOnUse" width="6" height="6"><rect width="6" height="6" fill="${n}" /><path d="M -1 7 L 7 -1" stroke="${r}" stroke-width="1" /></pattern>`}function xn(e,t,n,r){let o=kn(r,t,n);return o?` ${e}="url(#${K(o)})"`:""}function sr(e){return e==="dashed"?' stroke-dasharray="8 6"':e==="dotted"?' stroke-dasharray="1 6"':""}function lt(e,t){return t===void 0||t>=1?"":` ${e}="${Math.max(0,t)}"`}function aP(e,t,n,r,o,i,a){return e==="blockArrow"?gt(t,n,o,i):e==="triangle"?[{x:Nt(r??t/2,0,t),y:0},{x:t,y:n},{x:0,y:n}]:e==="diamond"?[{x:t/2,y:0},{x:t,y:n/2},{x:t/2,y:n},{x:0,y:n/2}]:bt(t,n,e==="pentagon"?5:xt(a))}function sP(e){let{rx:t,ry:n}=ce(e),r=Wr(e),o=pp(e,r.startAngle),i=pp(e,r.endAngle),s=Se(r.endAngle-r.startAngle)>Math.PI?1:0;return e.props.kind==="sector"?`M ${e.x+t} ${e.y+n} L ${e.x+o.x} ${e.y+o.y} A ${t} ${n} 0 ${s} 1 ${e.x+i.x} ${e.y+i.y} Z`:`M ${e.x+o.x} ${e.y+o.y} A ${t} ${n} 0 ${s} 1 ${e.x+i.x} ${e.y+i.y}`}function lP(e){return e.props.kind!=="sector"||e.props.fill==="none"?"none":K(e.props.fillColor??e.props.color)}function pp(e,t){let{rx:n,ry:r}=ce(e);return{x:n+Math.cos(t)*n,y:r+Math.sin(t)*r}}function cP(e,t,n){return e.map(r=>`${t+r.x},${n+r.y}`).join(" ")}function uP(e){return e*180/Math.PI}function Do(e,t,n,r,o,i={}){let a=i.overflowVisible?' overflow="visible"':"";return`<foreignObject x="${e}" y="${t}" width="${n}" height="${r}"${a}>${o}</foreignObject>`}function dP(e){let t=0;for(let n=0;n<=e.columns.length;n+=1){let r=Dt(e,n);if(!r)continue;let o=Ae(e,r);o.visible&&(t=Math.max(t,o.borderWidth))}for(let n=0;n<=e.rows.length;n+=1){let r=Gt(e,n);if(!r)continue;let o=Ae(e,r);o.visible&&(t=Math.max(t,o.borderWidth))}return Math.ceil(t)}import{renderToStaticMarkup as yp}from"react-dom/server";import{jsx as Go}from"react/jsx-runtime";var fp=new WeakMap,mP=8;function fP(e,t,n,r,o){let i=fp.get(e);i||(i=new Map,fp.set(e,i));let a=Le(o,`${t}x${n}x${r}`),s=i.get(a);if(s!==void 0)return s;let c=yP(yp(Go(dn,{environment:o,children:Go(ar,{height:n,overflow:r,selfContained:!0,table:e,width:t,xmlns:"http://www.w3.org/1999/xhtml"})})));return i.size>=mP&&i.delete(i.keys().next().value),i.set(a,c),c}function yP(e){return e.replace(/<td\b[^>]*>/g,t=>t.replace(/ (rowSpan|colSpan)=/g,(n,r)=>` ${r.toLowerCase()}=`))}function hP(e){return{renderGraphHtml:(t,n)=>yp(Go(dn,{environment:e,children:Go(fn,{idSeed:n,spec:t,staticMode:!0})})),renderMathHtml:t=>Bt(t,e),renderTableHtml:(t,n,r,o)=>fP(t,n,r,o,e)}}function $o(e,t,n=na,r={}){return Za(e,t,n,hP(r.mathEnvironment??nn),r)}function gP(e){return e.numbering?.enabled!==!1}function hp(e){let t=new Map,n=1;for(let r of e){if(r.type!=="problem"||!gP(r))continue;let o=xP(r)??n;t.set(r.id,o),n=o+1}return t}function xP(e){let t=e.numbering?.value;return typeof t=="number"&&Number.isInteger(t)&&t>0?t:void 0}function gp(e){return String(e)}var xp='"Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Times New Roman", serif',SP=32,vP=21,Qa=57.35,Pp=1,PP=9,MP=18,TP=.15,OP=.62,wP=.6,kP=.25,BP=4,RP=8,AP={cornerSquares:"box-frame--corner-squares",doubleRule:"box-frame--double-rule",titleDoubleRule:"box-frame--title-double-rule",titleBand:"box-frame--title-band",titlePlate:"box-frame--title-plate",leftBar:"box-frame--left-bar",shadow:"box-frame--shadow",horizontalRules:"box-frame--horizontal-rules",notebookRules:"box-frame--notebook-rules"},IP={cornerSquares:"data-box-corner-squares",doubleRule:"data-box-double-rule",titleDoubleRule:"data-box-title-double-rule",titleBand:"data-box-title-band",titlePlate:"data-box-title-plate",leftBar:"data-box-left-bar",shadow:"data-box-shadow",horizontalRules:"data-box-horizontal-rules",notebookRules:"data-box-notebook-rules"},Ja="#1f2937",EP="#cbd5e1",bp="#e2e8f0",CP="#f1f5f9",LP="#f8fafc",NP="#9ca3af",FP="#b9b3a1",_P="#706b5a",DP=[{id:"fancybox",commandName:"fancybox",displayName:"fancybox",description:"\u672C\u6587\u3092\u6BB5\u5E45\u3044\u3063\u3071\u3044\u306E\u67A0\u3067\u56F2\u3080",aliases:["framed","framebox","fbox","box","\u67A0","\u56F2\u307F"],frame:{borderWidthPx:1.4,borderColor:"#111111",borderStyle:"solid",backgroundColor:"#ffffff",cornerStyle:"sharp",paddingPx:{top:12,right:14,bottom:12,left:14}}},{id:"itembox",commandName:"itembox",displayName:"itembox",description:"\u898B\u51FA\u3057\u30E9\u30D9\u30EB\u4ED8\u304D\u306E\u7BB1",aliases:["item","\u898B\u51FA\u3057","\u30DD\u30A4\u30F3\u30C8","\u8981\u70B9"],defaultTitle:"\u30DD\u30A4\u30F3\u30C8",frame:{borderWidthPx:1,borderColor:"#000000",borderStyle:"solid",backgroundColor:"#ffffff",titleBackgroundColor:"#ffffff",titleAlign:"left",titleFontWeight:"bold",cornerStyle:"sharp",paddingPx:{top:16,right:14,bottom:12,left:14},decorations:[]}},{id:"tcolorbox",commandName:"tcolorbox",displayName:"tcolorbox",description:"\u5E2F\u898B\u51FA\u3057\u4ED8\u304D\u306E\u7BB1",aliases:["tcbox","\u5B9A\u7406","\u5B9A\u7FA9","\u5E2F"],defaultTitle:"\u5B9A\u7406",frame:{borderWidthPx:1,borderColor:EP,borderStyle:"solid",backgroundColor:"#ffffff",titleBackgroundColor:bp,titleAlign:"left",titleFontWeight:"bold",cornerStyle:"sharp",paddingPx:{top:42,right:14,bottom:12,left:14},decorations:[{type:"titleBand",heightPx:32,backgroundColor:bp}]}},{id:"tcolorbox-note",commandName:"tcolorbox-note",displayName:"tcolorbox \u30CE\u30FC\u30C8\u7F6B",description:"\u5DE6\u30EA\u30F3\u30B0\u4ED8\u304D\u306E\u30CE\u30FC\u30C8\u7BB1",aliases:["note","notebox","\u30CE\u30FC\u30C8","\u30CE\u30FC\u30C8\u7F6B","\u30EA\u30F3\u30B0","\u7F6B\u7DDA","\u672C\u6587"],frame:{borderWidthPx:1,borderColor:NP,borderStyle:"solid",backgroundColor:"#ffffff",bodyAlign:"justify",bodyFontSizePx:15,bodyLineHeight:"23.35px",cornerStyle:"sharp",paddingPx:{top:18,right:18,bottom:16,left:56},decorations:[{type:"notebookRules",baseBodyWidthPx:660,frameLeftPx:20,frameHeightPx:Qa,frameStrokeOpacity:.85,bindingColor:FP,bindingWidthPx:1,bindingXPx:20,bindingStrokeOpacity:.75,ringColor:_P,ringWidthPx:38,ringHeightPx:12,ringStrokePx:1.2,ringGapPx:23.35,ringTopPx:8,ringCount:Pp,ringLeftOverhangPx:14,minHeightPx:Qa}]}},{id:"doublebox",commandName:"doublebox",displayName:"doublebox",description:"\u4E8C\u91CD\u7F6B\u7DDA\u306E\u7BB1\u3092\u633F\u5165",aliases:["double","\u4E8C\u91CD"],frame:{borderWidthPx:1.1,borderColor:"#111111",borderStyle:"solid",backgroundColor:"#ffffff",cornerStyle:"sharp",paddingPx:{top:14,right:16,bottom:14,left:16},decorations:[{type:"doubleRule",offsetPx:4,widthPx:1,color:"#111111"}]}},{id:"shadebox",commandName:"shadebox",displayName:"shadebox",description:"\u8584\u3044\u5730\u8272\u306E\u7BB1",aliases:["shade","\u80CC\u666F","\u88DC\u8DB3","\u30B3\u30E9\u30E0"],frame:{borderWidthPx:1,borderColor:"#000000",borderStyle:"solid",backgroundColor:CP,cornerStyle:"round",radiusPx:3,paddingPx:{top:12,right:14,bottom:12,left:14}}},{id:"leftbar",commandName:"leftbar",displayName:"leftbar",description:"\u5DE6\u7F6B\u3067\u5F37\u8ABF\u3059\u308B\u7BB1",aliases:["\u5DE6\u7F6B","\u5F15\u7528","\u6CE8\u610F"],frame:{borderWidthPx:1,borderColor:"#000000",borderStyle:"solid",backgroundColor:LP,cornerStyle:"sharp",paddingPx:{top:12,right:14,bottom:12,left:18},decorations:[{type:"leftBar",widthPx:5,color:Ja}]}},{id:"dashedbox",commandName:"dashedbox",displayName:"dashedbox",description:"\u7834\u7DDA\u306E\u7BB1",aliases:["dashed","\u7834\u7DDA","\u8A18\u5165","\u30E1\u30E2"],frame:{borderWidthPx:1.2,borderColor:"#475569",borderStyle:"dashed",backgroundColor:"#ffffff",cornerStyle:"sharp",paddingPx:{top:12,right:14,bottom:12,left:14}}},{id:"ruledbox",commandName:"ruledbox",displayName:"ruledbox",description:"\u4E0A\u4E0B\u7F6B\u3060\u3051\u3067\u533A\u5207\u308B\u7BB1",aliases:["rule","\u4E0A\u4E0B\u7F6B","\u307E\u3068\u3081"],defaultTitle:"\u5B9A\u7FA9",frame:{borderWidthPx:0,borderColor:"transparent",borderStyle:"none",backgroundColor:"#ffffff",titleAlign:"left",titleFontWeight:"bold",cornerStyle:"sharp",paddingPx:{top:12,right:0,bottom:12,left:0},decorations:[{type:"horizontalRules",widthPx:1.2,color:Ja}]}},{id:"screenbox",commandName:"screenbox",displayName:"screenbox",description:"\u89D2\u4E38\u306E\u5E73\u5766\u306A\u7BB1",aliases:["screen","\u30AB\u30FC\u30C9","\u5F71","\u4F8B\u984C"],defaultTitle:"\u4F8B\u984C",frame:{borderWidthPx:1,borderColor:"#000000",borderStyle:"solid",backgroundColor:"#ffffff",titleBackgroundColor:"#ffffff",titleAlign:"left",titleFontWeight:"bold",cornerStyle:"round",radiusPx:3,paddingPx:{top:12,right:14,bottom:12,left:14},decorations:[]}},{id:"ovalbox",commandName:"ovalbox",displayName:"ovalbox",description:"\u89D2\u4E38\u306E\u7BB1",aliases:["oval","\u89D2\u4E38","\u30E9\u30D9\u30EB"],frame:{borderWidthPx:1.2,borderColor:Ja,borderStyle:"solid",backgroundColor:"#ffffff",cornerStyle:"round",radiusPx:18,paddingPx:{top:8,right:16,bottom:8,left:16}}},{id:"cornerbox",commandName:"cornerbox",displayName:"cornerbox",description:"\u56DB\u9685\u306E\u9ED2\u56DB\u89D2\u3068\u4E8C\u91CD\u30AC\u30A4\u30C9\u7F6B\u306E\u7BB1",aliases:["corner","\u89D2"],frame:{borderWidthPx:0,borderColor:"transparent",borderStyle:"none",backgroundColor:"#ffffff",titleAlign:"left",titleFontFamily:xp,titleFontWeight:"normal",titleLineHeight:"1",bodyAlign:"left",bodyFontFamily:xp,bodyLineHeight:"1",cornerStyle:"sharp",paddingPx:{top:24,right:24,bottom:24,left:24},decorations:[{type:"titleDoubleRule",ruleWidthPx:1,ruleColor:"#111111",guideColor:"#b8b8b8"},{type:"cornerSquares",sizePx:8,color:"#000000"}]}}];function GP(e){return DP.find(t=>t.id===e||t.commandName===e)}function zo(e){let t=UP(GP(e.styleId)?.frame,e.frame);return e.styleId==="cornerbox"?$P(t):t}function $P(e){let{titleFontSizePx:t,bodyFontSizePx:n,...r}=e;return{...r,...t===void 0||t===SP?{}:{titleFontSizePx:t},...n===void 0||n===vP?{}:{bodyFontSizePx:n}}}function Ho(e){return e.title?Tt(e.title).trim():""}function Ke(e,t){return e?.decorations?.find(n=>n.type===t)}function Mp(e,t){return e?.decorations?.some(n=>n.type===t)??!1}function Tp(e,t,n){let r=[e,"box-frame"];for(let o of t.decorations??[]){let i=AP[o.type];i&&r.push(i)}return HP(n,t)&&r.push("box-frame--corner","corner-frame"),n==="itembox"&&!Mp(t,"titlePlate")&&r.push("box-frame--title-plate"),r.push(`box-frame--title-position-${t.titlePosition??"l"}`),r.join(" ")}function Op(e){let t={};for(let n of e?.decorations??[]){let r=IP[n.type];r&&(t[r]="true")}return t}function wp(e){let t=e.paddingPx??{top:12,right:14,bottom:12,left:14},n=Ke(e,"cornerSquares"),r=Ke(e,"doubleRule"),o=Ke(e,"titleDoubleRule"),i=Ke(e,"titleBand"),a=Ke(e,"titlePlate"),s=Ke(e,"leftBar"),c=Ke(e,"shadow"),l=Ke(e,"horizontalRules"),d=Ke(e,"notebookRules"),u=a?.paddingPx??{top:2,right:10,bottom:2,left:10},m=d?.frameHeightPx??d?.minHeightPx??Qa,h=d?.ringLeftOverhangPx??14,y=e.titlePosition??"l",g=y==="c"?"center":y==="r"?"right":"left";return{"--sigma-doc-box-border-width":`${e.borderWidthPx??1.2}px`,"--sigma-doc-box-border-color":e.borderColor??"#111111","--sigma-doc-box-border-style":e.borderStyle??"solid","--sigma-doc-box-background":e.backgroundColor??"#ffffff","--sigma-doc-box-title-background":e.titleBackgroundColor??i?.backgroundColor??e.backgroundColor??"#ffffff",...e.titleColor?{"--sigma-doc-box-title-color":e.titleColor}:{},"--sigma-doc-box-title-align":e.titlePosition?g:e.titleAlign??g,...e.titleFontWeight?{"--sigma-doc-box-title-weight":e.titleFontWeight==="bold"?"700":"400"}:{},...e.titleFontFamily?{"--sigma-doc-box-title-font-family":e.titleFontFamily}:{},...e.titleFontSizePx?{"--sigma-doc-box-title-font-size":`${e.titleFontSizePx}px`}:{},...e.titleLineHeight?{"--sigma-doc-box-title-line-height":e.titleLineHeight}:{},...e.bodyColor?{"--sigma-doc-box-body-color":e.bodyColor}:{},...e.bodyAlign?{"--sigma-doc-box-body-align":e.bodyAlign}:{},...e.bodyFontFamily?{"--sigma-doc-box-body-font-family":e.bodyFontFamily}:{},...e.bodyFontSizePx?{"--sigma-doc-box-body-font-size":`${e.bodyFontSizePx}px`}:{},...e.bodyLineHeight?{"--sigma-doc-box-body-line-height":e.bodyLineHeight}:{},"--sigma-doc-box-radius":`${e.cornerStyle==="round"?e.radiusPx??8:0}px`,"--sigma-doc-box-padding-top":`${t.top}px`,"--sigma-doc-box-padding-right":`${t.right}px`,"--sigma-doc-box-padding-bottom":`${t.bottom}px`,"--sigma-doc-box-padding-left":`${t.left}px`,"--sigma-doc-box-corner-size":`${n?.sizePx??0}px`,"--sigma-doc-box-corner-color":n?.color??"#000000","--sigma-doc-box-double-offset":`${r?.offsetPx??0}px`,"--sigma-doc-box-double-width":`${r?.widthPx??1}px`,"--sigma-doc-box-double-color":r?.color??e.borderColor??"#111111","--sigma-doc-box-title-rule-width":`${o?.ruleWidthPx??1}px`,"--sigma-doc-box-title-rule-color":o?.ruleColor??"#111111","--sigma-doc-box-title-guide-color":o?.guideColor??"#b8b8b8","--sigma-doc-box-title-band-height":`${i?.heightPx??32}px`,"--sigma-doc-box-title-plate-border-color":a?.borderColor??e.borderColor??"#111111","--sigma-doc-box-title-plate-radius":`${a?.radiusPx??3}px`,"--sigma-doc-box-title-plate-padding-top":`${u.top}px`,"--sigma-doc-box-title-plate-padding-right":`${u.right}px`,"--sigma-doc-box-title-plate-padding-bottom":`${u.bottom}px`,"--sigma-doc-box-title-plate-padding-left":`${u.left}px`,"--sigma-doc-box-left-bar-width":`${s?.widthPx??0}px`,"--sigma-doc-box-left-bar-color":s?.color??"#111111","--sigma-doc-box-shadow":c?`${c.offsetXPx}px ${c.offsetYPx}px ${c.blurPx??0}px ${c.spreadPx??0}px ${c.color}`:"none","--sigma-doc-box-horizontal-rule-width":`${l?.widthPx??1}px`,"--sigma-doc-box-horizontal-rule-color":l?.color??e.borderColor??"#111111","--sigma-doc-box-notebook-base-body-width":`${d?.baseBodyWidthPx??660}px`,"--sigma-doc-box-notebook-frame-left":`${d?.frameLeftPx??d?.bindingXPx??20}px`,"--sigma-doc-box-notebook-frame-height":`${m}px`,"--sigma-doc-box-notebook-frame-border-color":Sp(e.borderColor??"#9ca3af",d?.frameStrokeOpacity),"--sigma-doc-box-notebook-binding-color":Sp(d?.bindingColor??"#b9b3a1",d?.bindingStrokeOpacity),"--sigma-doc-box-notebook-binding-width":`${d?.bindingWidthPx??1}px`,"--sigma-doc-box-notebook-binding-x":`${d?.bindingXPx??20}px`,"--sigma-doc-box-notebook-ring-color":d?.ringColor??"#706b5a","--sigma-doc-box-notebook-ring-width":`${d?.ringWidthPx??38}px`,"--sigma-doc-box-notebook-ring-height":`${d?.ringHeightPx??12}px`,"--sigma-doc-box-notebook-ring-left-overhang":`${h}px`,"--sigma-doc-box-notebook-ring-stroke":`${d?.ringStrokePx??1.2}px`,"--sigma-doc-box-notebook-ring-gap":`${d?.ringGapPx??23.35}px`,"--sigma-doc-box-notebook-ring-top":`${d?.ringTopPx??8}px`,"--sigma-doc-box-notebook-ring-count":String(d?.ringCount??Pp),"--sigma-doc-box-notebook-min-height":`${d?.minHeightPx??m}px`,"--sigma-doc-box-title-position":y}}function zP(e){let t=Number.isFinite(e)?Math.max(0,e):0;return Math.min(MP,Math.max(PP,t*TP))}function es(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return{};let t=bn(e),n=bn(zP(t)),r=bn(Math.min(RP,Math.max(BP,n*wP))),o=bn(Math.max(r,n*OP)),i=bn(r*kP),a=bn(Math.max(0,o-r/2-i));return{"--corner-frame-reference-height":`${t}px`,"--corner-frame-fold-size":`${n}px`,"--corner-frame-corner-size":`${r}px`,"--corner-frame-guide-inset-x":`${n}px`,"--corner-frame-guide-side-y":`${n}px`,"--corner-frame-rule-x":`${o}px`,"--corner-frame-rule-side-x":`${o}px`,"--corner-frame-rule-y":`${o}px`,"--corner-frame-rule-side-y":`${o}px`,"--corner-frame-corner-x":`${a}px`,"--corner-frame-corner-y":`${a}px`}}function kp(e,t){let n=new Set,r=new Map,o=e instanceof Document?e:e.ownerDocument;if(!o?.head)return()=>{};let i=o.createElement("style");i.setAttribute("data-cornerbox-reference-heights","true"),o.head.appendChild(i);let a=()=>{i.textContent=Array.from(r,([u,m])=>`${u}{${m}}`).join(`
|
|
12
|
-
|
|
13
|
-
${S}`,R=je(()=>new Map,[]),[M,C]=Ep(null),[z,f]=Ep(0),P=M?.key===I?M:null,D=P?.pages??g,Q=P?.blockRects??R,Z=je(()=>dM(c.overlay,Q),[c.overlay,Q]),v=je(()=>pM(D,Z,l.flow.columnCount,l.page.heightPx,d),[D,l.flow.columnCount,l.page.heightPx,d,Z]),w=typeof r=="number"?v.slice(0,Math.max(1,r)):v,O={"--print-page-width":`${l.page.widthMm}mm`,"--print-page-height":`${l.page.heightMm}mm`,"--print-margin-top":`${l.margins.topPx}px`,"--print-margin-right":`${l.margins.rightPx}px`,"--print-margin-bottom":`${l.margins.bottomPx}px`,"--print-margin-left":`${l.margins.leftPx}px`,"--print-column-count":String(l.flow.columnCount),"--print-column-gap":`${l.flow.columnGapMm}mm`,"--print-measure-column-width":`${l.flow.columnWidthPx}px`,"--print-measure-content-width":`${l.content.widthPx}px`};return ns(()=>{let A=m.current;if(A)return kp(A,ZP)},[x,S]),ns(()=>{let A=h.current;if(!A)return;let B=!0,F=null,W=()=>{if(!B||F!==null)return;F=(typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):U=>window.setTimeout(U,0))(()=>{F=null,B&&f(U=>U+1)})},_=typeof ResizeObserver=="function"?new ResizeObserver(W):null;return _?.observe(A),typeof document<"u"&&document.fonts&&document.fonts.ready.then(W),()=>{B=!1,_?.disconnect(),F!==null&&typeof window<"u"&&(window.cancelAnimationFrame?.(F),window.clearTimeout(F))}},[x,S]),ns(()=>{let A=h.current;if(!A)return;let B=sM(A,u),F=B.map($=>$.height),W=B.map($=>$.flowHeight),_=B.map($=>$.descendantRects),j=oM(_),U=is(u,F,W,l.flow.columnCount,l.content.heightPx,0,j,l.flow.columnGapMm),X=iM(U,u,F,W,l.margins.topPx,l.margins.leftPx,l.flow.columnWidthPx,l.flow.columnGapPx,d,0,_,j);C($=>$?.key===I&&fM($.blockRects,X)&&mM($.pages,U)?$:{key:I,pages:U,blockRects:X})},[x,S,I,z,l.content.heightPx,l.flow.columnCount,l.flow.columnGapPx,l.flow.columnGapMm,l.flow.columnWidthPx,l.margins.leftPx,l.margins.topPx,d,u]),E(dn,{environment:s,children:lr("article",{ref:m,className:["print-page-stack",`layout-${t}`,o].filter(Boolean).join(" "),"data-print-preview-layout":t,"data-print-preview-max-pages":typeof r=="number"?String(r):void 0,"data-print-preview-page-count":String(v.length),style:O,children:[n?E("style",{children:`@media print { @page { size: ${l.page.widthMm}mm ${l.page.heightMm}mm; margin: 0; } }`}):null,w.map(A=>{let B=Z?.overlaySnapshot?$o(Z.overlaySnapshot.shapes,Z.overlaySnapshot.assets,{width:l.page.widthPx,height:l.page.heightPx,offsetY:(A.number-1)*d},{mathEnvironment:s,stackLayer:"background",viewportPaddingPx:0}):void 0,F=Z?.overlaySnapshot?$o(Z.overlaySnapshot.shapes,Z.overlaySnapshot.assets,{width:l.page.widthPx,height:l.page.heightPx,offsetY:(A.number-1)*d},{mathEnvironment:s,stackLayer:"foreground",viewportPaddingPx:0}):void 0,W=lr("section",{className:"print-a4-page",style:O,children:[E(Ka,{region:c.header,kind:"header",title:e.metadata.title,pageNumber:A.number,totalPages:v.length,metrics:l,mathFractionSizing:a}),E(Ka,{region:c.footer,kind:"footer",title:e.metadata.title,pageNumber:A.number,totalPages:v.length,metrics:l,mathFractionSizing:a}),B&&E("div",{className:"print-page-overlay-layer background",dangerouslySetInnerHTML:{__html:B}}),lr("div",{className:"print-page-content-layer",children:[$p(A).map((_,j)=>E("div",{className:"print-page-full-span-block",children:E(Ze,{unit:_,columnGapMm:l.flow.columnGapMm,mathFractionSizing:a})},`${A.id}-full-${_.id}-${j}`)),E("div",{className:"print-page-columns",children:A.columns.map(_=>E("div",{className:"print-page-column",children:as(_).map((j,U)=>E(Ze,{unit:j,columnGapMm:l.flow.columnGapMm,mathFractionSizing:a},`${j.id}-${U}`))},`${A.id}-${_.id}`))})]}),F&&E("div",{className:"print-page-overlay-layer foreground",dangerouslySetInnerHTML:{__html:F}})]},A.id);return i?i({page:A,totalPages:v.length,pageNode:W}):W}),E("div",{className:"print-measure-layer",ref:h,style:O,"aria-hidden":"true",children:E("div",{className:"print-measure-column",children:u.map((A,B)=>E("div",{"data-print-measure-index":B,style:qe(A)?{width:"var(--print-measure-content-width)"}:void 0,children:E(Ze,{unit:A,columnGapMm:l.flow.columnGapMm,mathFractionSizing:a})},`${A.id}-${B}`))})})]})})}function JP(e){let t=hp(e);return e.flatMap(n=>{if(n.type!=="problem")return[{type:"block",id:n.id,block:n,pagination:n.pagination}];let r=t.get(n.id),o=zn.map(c=>({area:c,blocks:n[c],minHeightMm:n.areaLayout?.[c]?.minHeightMm,columnSpan:n.areaLayout?.[c]?.columnSpan})).filter(({area:c,blocks:l,minHeightMm:d})=>c==="lead"?typeof r=="number"||l.length>0||!!d:c==="prompt"||l.length>0||!!d),i=o.filter(({area:c})=>rs(c)),a=i[0]?.area,s=i.at(-1)?.area;return o.map((c,l)=>({type:"problemArea",id:`${n.id}:${c.area}`,problemId:n.id,area:c.area,blocks:c.blocks,minHeightMm:c.minHeightMm,problemNumber:r,numberFontSize:gM(n),hasFrame:n.frame?.enabled===!0&&rs(c.area),frameStyleId:n.frame?.enabled===!0&&rs(c.area)?Bp(n):void 0,isFirstProblemArea:l===0,isLastProblemArea:l===o.length-1,isFirstProblemFrameArea:c.area===a,isLastProblemFrameArea:c.area===s,columnSpan:c.columnSpan,pagination:QP(n.pagination,l,o.length)}))})}function QP(e,t,n){if(!e)return;let r={...e};return t>0&&delete r.break,t<n-1&&delete r.keepWithNext,Object.keys(r).length>0?r:void 0}function rs(e){return e==="prompt"}function Lp(e){return e.type==="problemArea"&&ul({isFullSpan:e.columnSpan==="full",isFramedArea:e.hasFrame,blocks:e.blocks})}function eM(e){return e.type==="block"?ot(e.block):e.type==="boxFragment"||e.type==="layoutSectionFragment"?e.estimatedHeightPx:e.type==="blockSlice"?e.sliceHeight:e.type==="problemAreaFragment"?e.estimatedHeightPx:Math.max(e.blocks.reduce((t,n)=>t+ot(n),0),(e.minHeightMm??0)*Qt)}function is(e,t,n,r,o,i,a,s){let c=[],l=1,d=Uo(l,r).columns,u=0,m=()=>d.some(v=>v.blocks.length>0),h=()=>d.some(v=>v.blocks.some(w=>!qe(w))),y=()=>d[u],g=()=>Math.max(0,o-(l===1?i:0)),x=(v=!1)=>{!v&&!m()||(c.push({id:`page_${l}`,number:l,blocks:d.flatMap(w=>w.blocks),columns:d,estimatedContentHeightPx:d.reduce((w,O)=>w+O.estimatedContentHeightPx,0),oversizedBlockIds:d.flatMap(w=>w.oversizedBlockIds)}),l+=1,d=Uo(l,r).columns,u=0)},S=()=>{if(u<r-1){u+=1;return}x()},I=()=>{S()},R=v=>v.blocks.some(w=>!qe(w)),M=()=>Math.max(0,g()-y().estimatedContentHeightPx),C=(v,w,O=w)=>{let A=y();A.blocks.push(v),A.estimatedContentHeightPx+=Math.max(w,O),w>g()&&A.oversizedBlockIds.push(v.id)},z=v=>{let w=e[v];if(Lp(w)||w.type!=="problemArea"||!w.isFirstProblemArea||!R(y()))return;let O=0;for(let B=v;B<e.length;B+=1){let F=e[B];if(F.type!=="problemArea"||F.problemId!==w.problemId)break;if(qe(F)||B>v&&F.pagination?.break===!0)return;O+=Math.max(t[B]||0,n[B]??0)}let A=u<r-1?g():o;O>M()+.5&&O<=A+.5&&S()},f=v=>{let w=e[v],O=e[v+1];if(w.pagination?.keepWithNext!==!0||!O||O.pagination?.break===!0||qe(w)||qe(O))return;let A=Math.max(t[v]||0,n[v]??0)+Math.max(t[v+1]||0,n[v+1]??0),B=u<r-1?g():o;R(y())&&A>M()+.5&&A<=B+.5&&S()},P=(v,w)=>{let O=v.block;if(O.type!=="boxBlock"||O.blocks.length===0||w<=M()+.5)return!1;let A=u<r-1?g():o;if(O.pagination?.keepTogether===!0&&R(y())&&w<=A+.5&&(S(),w<=M()+.5))return!1;let B=[],F=Gp(O),W=O.blocks.map(U=>Sn(U,a)),_=0,j=0;for(;_<O.blocks.length;){R(y())&&M()<Math.min(72,g()*.22)&&S();let U=W[_]??0;R(y())&&F+U>M()+.5&&F+U<=g()+.5&&S();let X=[],$=F;for(;_<O.blocks.length;){let J=W[_]??0;if(!(X.length===0||$+J<=Math.max(F+J,M()+.5))||(X.push(O.blocks[_]),$+=J,_+=1,$>=M()-.5))break}X.length===0&&(X.push(O.blocks[_]),$+=W[_]??0,_+=1);let ue={type:"boxFragment",id:`${O.id}:fragment:${j}`,sourceId:O.id,block:O,blocks:X,fragmentRole:"middle",estimatedHeightPx:$,totalHeight:w,includeTitle:j===0,pagination:j===0?v.pagination:void 0};B.push(ue),C(ue,$),j+=1,_<O.blocks.length&&S()}return B.forEach((U,X)=>{U.fragmentRole=B.length===1?"single":X===0?"first":X===B.length-1?"last":"middle"}),!0},D=(v,w)=>{let O=nM(v.block,w,a),A=[],B=0,F=0;for(let W=0;B<w-.5&&W<400;W+=1){R(y())&&M()<Math.min(48,g()*.2)&&S();let _=Math.max(1,M()),j=w-B,U=j<=_+.5?j:rM(_,O,B,w),X={type:"blockSlice",id:`${v.id}:slice:${F}`,sourceId:v.id,block:v.block,sliceTop:B,sliceHeight:U,totalHeight:w,fragmentRole:"middle",pagination:F===0?v.pagination:void 0};A.push(X),C(X,U),B+=U,F+=1,B<w-.5&&S()}A.forEach((W,_)=>{W.fragmentRole=A.length===1?"single":_===0?"first":_===A.length-1?"last":"middle"})},Q=v=>{if(!Lp(v)||v.blocks.length===0)return!1;let w=v.columnSpan==="full",O=()=>{w?x():S()},A=Ap(v.frameStyleId),B=v.hasFrame?A.y*2*Qt:0,F=y(),W=F.estimatedContentHeightPx,_=[],j=[],U=[],X=B,$=!1,ue=(we,ee)=>{let be=_.length,Re={type:"problemAreaFragment",id:`${v.id}:area-fragment:${be}`,sourceId:v.id,problemId:v.problemId,area:v.area,blocks:we,fragmentRole:"middle",estimatedHeightPx:ee,minHeightMm:v.minHeightMm,problemNumber:v.problemNumber,numberFontSize:v.numberFontSize,hasFrame:v.hasFrame,frameStyleId:v.frameStyleId,columnSpan:v.columnSpan,isFirstProblemArea:v.isFirstProblemArea,isLastProblemArea:v.isLastProblemArea,pagination:be===0?v.pagination:void 0};if(_.push(Re),w){h()&&x(),m()&&y().estimatedContentHeightPx+ee>g()+.5&&x(),d[0].blocks.push(Re);for(let ct of d)ct.estimatedContentHeightPx+=ee;j.push(d[0])}else j.push(y()),C(Re,ee)},J=()=>{U.length!==0&&(ue(U,X),U=[],X=B)};for(let[we,ee]of v.blocks.entries()){if(ee.pagination?.break===!0){let _e=_.length>0||U.length>0||!w&&(R(y())||u>0);J(),_e&&O()}let be=Sn(ee,a),Re=v.blocks[we+1],ct=ee.pagination?.keepWithNext===!0&&Re&&Re.pagination?.break!==!0?be+Sn(Re,a):0,oi=X+ct;if((R(y())||U.length>0)&&ct>0&&oi>M()+.5&&ct+B<=o+.5&&(J(),O()),ee.type==="layoutSection"){J();let _e=be+B;_e>M()+.5&&_e<=o+.5&&O(),ue([ee],_e);continue}if(be>o+.5){J(),_.length===0&&($=!0),D({type:"block",id:ee.id,block:ee,pagination:ee.pagination},be);continue}let ii=Math.max(0,M()-X);(R(y())||U.length>0)&&be>ii+.5&&be+B<=o+.5&&(J(),O()),U.push(ee),X+=be}return J(),_.forEach((we,ee)=>{we.fragmentRole=$?ee===_.length-1?"last":"middle":_.length===1?"single":ee===0?"first":ee===_.length-1?"last":"middle"}),(v.minHeightMm??0)>0&&_.length>0&&j.every(we=>we===F)&&y()===F&&(F.estimatedContentHeightPx=Math.max(F.estimatedContentHeightPx,W+(v.minHeightMm??0)*Qt)),!0},Z=(v,w)=>{let O=v.block;if(O.type!=="layoutSection"||O.children.length===0)return!1;if(O.pagination?.keepTogether===!0&&R(y())&&w>M()+.5&&w<=g()+.5)return S(),!1;let A=O.children.some($=>$.type==="boxBlock"),B=Si(O.children);if(!A&&!B&&w<=g()+.5)return!1;let F=Hp(O.layout.columnCount),W=s,_=O.children.map($=>({type:"block",id:$.id,block:$,pagination:$.pagination})),j=O.children.map($=>Sn($,a,Math.max(12,Math.floor(54/F)))),X=is(_,j,j,F,g(),0,a,W).map(($,ue)=>({type:"layoutSectionFragment",id:`${O.id}:layout-fragment:${ue}`,sourceId:O.id,block:O,columns:$.columns,fragmentRole:"middle",estimatedHeightPx:Math.max(32,...$.columns.map(J=>J.estimatedContentHeightPx)),columnGapMm:W,pagination:ue===0?v.pagination:void 0}));return X.forEach(($,ue)=>{$.fragmentRole=X.length===1?"single":ue===0?"first":ue===X.length-1?"last":"middle",R(y())&&y().estimatedContentHeightPx+$.estimatedHeightPx>g()+.5&&S(),C($,$.estimatedHeightPx),ue<X.length-1&&S()}),!0};return e.forEach((v,w)=>{let O=t[w]||0,A=n[w]??O;if(m()&&v.pagination?.break===!0&&I(),f(w),z(w),v.type==="problemArea"&&Q(v))return;if(qe(v)){h()&&x(),m()&&y().estimatedContentHeightPx+O>g()&&x(),d[0].blocks.push(v);for(let W of d)W.estimatedContentHeightPx+=Math.max(O,A),O>g()&&W.oversizedBlockIds.push(v.id);return}let B=v.type==="block"&&v.block.type==="boxBlock"&&v.block.blocks.length>0,F=v.type==="block"&&(v.block.type==="boxBlock"?tM(v.block,o,a):v.block.type!=="layoutSection"&&O>o+.5);if(B||F||(O>g()+.5&&m()?x():R(y())&&y().estimatedContentHeightPx+O>g()?S():!R(y())&&y().estimatedContentHeightPx>.5&&y().estimatedContentHeightPx+O>g()&&x()),F&&v.type==="block"){D(v,O);return}v.type==="block"&&P(v,O)||v.type==="block"&&Z(v,O)||C(v,O,A)}),x(),c.length>0?c:[Uo(1,r)]}function Gp(e){let n=zo(e).paddingPx??{top:12,right:14,bottom:12,left:14},o=Ho(e)?24:0;return n.top+n.bottom+o}function tM(e,t,n){let r=Gp(e);return e.blocks.some(o=>r+Sn(o,n)>t+.5)}function nM(e,t,n){if(e.type!=="boxBlock")return[];let o=zo(e).paddingPx??{top:12,right:14,bottom:12,left:14},i=Ho(e),a=o.top+(i?24:0),s=[];for(let c of e.blocks)a+=Sn(c,n),a>.5&&a<t-.5&&s.push(Math.round(a));return s}function rM(e,t,n,r){let o=Math.min(Math.max(1,e),r-n),i=n+o,a=n+Math.min(24,Math.max(8,o*.25)),s=t.filter(c=>c>a+.5&&c<=i-.5).at(-1);return s?Math.max(1,s-n):o}function Sn(e,t,n){return t.get(e.id)??ot(e,n)}function oM(e){let t=new Map;return e.forEach(n=>{n.forEach(r=>{t.set(r.id,r.height??0)})}),t}function iM(e,t,n,r,o,i,a,s,c,l,d,u){let m=new Map(t.map((x,S)=>[x.id,n[S]||0])),h=new Map(t.map((x,S)=>[x.id,r[S]??n[S]??0])),y=new Map(t.map((x,S)=>[x.id,d[S]??[]])),g=new Map;for(let x of e){let S=(x.number-1)*c,R=x.number===1?l:0;for(let M of $p(x)){let C=Vo(M,m,u),z={id:M.id,top:S+o+R,left:i,width:a*Math.max(1,x.columns.length)+s*Math.max(0,x.columns.length-1),height:C};g.set(M.id,z);for(let f of y.get(M.id)??[])g.set(f.id,os(f,z.top,z.left));R+=Np(M,m,h,u)}for(let M of x.columns){let C=i+(M.number-1)*(a+s),z=R;for(let f of as(M)){let P=Vo(f,m,u),D={id:f.id,top:S+o+z,left:C,width:a,height:P};if(g.set(f.id,D),f.type==="blockSlice"&&(f.fragmentRole==="first"||f.fragmentRole==="single")&&g.set(f.sourceId,{...D,id:f.sourceId,height:f.totalHeight}),f.type==="problemAreaFragment"){let Q=y.get(f.sourceId)??[];if(f.fragmentRole==="first"||f.fragmentRole==="single"){let B=m.get(f.sourceId)??D.height;if(g.set(f.sourceId,{...D,id:f.sourceId,height:B}),f.isFirstProblemArea){let F=Q.find(W=>W.id===f.problemId);g.set(f.problemId,{...D,id:f.problemId,height:F?.height??B})}}let Z=aM(f.blocks),v=Q.find(B=>B.id===f.blocks[0]?.id),w=v?.top??0,A=f.area==="lead"&&typeof f.problemNumber=="number"&&(f.fragmentRole==="first"||f.fragmentRole==="single")?0:v?.left??0;for(let B of Q)Z.has(B.id)&&g.set(B.id,os(B,D.top-w,D.left,A))}else for(let Q of y.get(f.id)??[])g.set(Q.id,os(Q,D.top,D.left));z+=Np(f,m,h,u)}}}return g}function os(e,t,n,r=0){return{...e,top:t+e.top,left:n+(e.left??0)-r,lines:e.lines?.map(o=>({...o,top:t+o.top,left:typeof o.left=="number"?n+o.left-r:o.left}))}}function aM(e){let t=new Set,n=r=>{if(t.add(r.id),r.type==="list"){for(let o of r.items)t.add(o.id),o.nested?.forEach(n);return}if(r.type==="layoutSection"){r.children.forEach(n);return}if(r.type==="boxBlock"){r.blocks.forEach(n);return}r.type==="problem"&&(r.lead.forEach(n),r.prompt.forEach(n),r.hints.forEach(n),r.solution.forEach(n))};return e.forEach(n),t}function Vo(e,t,n){return e.type==="boxFragment"||e.type==="layoutSectionFragment"||e.type==="problemAreaFragment"?e.estimatedHeightPx:e.type==="blockSlice"?e.sliceHeight:t.get(e.id)??n.get(e.id)??0}function Np(e,t,n,r){return e.type==="boxFragment"||e.type==="layoutSectionFragment"||e.type==="blockSlice"||e.type==="problemAreaFragment"?Vo(e,t,r):Math.max(Vo(e,t,r),n.get(e.id)??0)}function sM(e,t){let n=t.map((r,o)=>{let i=e.querySelector(`[data-print-measure-index="${o}"]`);if(!i)return null;let a=i.getBoundingClientRect();return{element:i,height:a.height,top:a.top,descendantRects:uM(i,r.id)}});return n.map((r,o)=>{if(!r)return{height:0,flowHeight:0,descendantRects:[]};let i=n.slice(o+1).find(s=>s!==null),a=i?Math.max(r.height,i.top-r.top):lM(r.element,r.height);return{height:r.height,flowHeight:a,descendantRects:r.descendantRects}})}function lM(e,t){let n=cM(getComputedStyle(e).marginBottom);return t+n}function cM(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function qe(e){return(e.type==="problemArea"||e.type==="problemAreaFragment")&&e.columnSpan==="full"}function $p(e){return e.columns[0]?.blocks.filter(qe)??[]}function as(e){return e.blocks.filter(t=>!qe(t))}function uM(e,t){let n=e.getBoundingClientRect(),r=new Set([t]),o=[];return e.querySelectorAll("[data-sigma-doc-id]").forEach(i=>{let a=i.getAttribute("data-sigma-doc-id");if(!a||r.has(a))return;r.add(a);let s=i.getBoundingClientRect();o.push({id:a,top:s.top-n.top,left:s.left-n.left,width:s.width,height:s.height,lines:su(i,n,1,1)})}),o}function dM(e,t){if(!e?.overlaySnapshot)return e;let n=me(e.overlaySnapshot),r=Ri(n.shapes,t);return{...e,overlaySnapshot:{...n,shapes:r}}}function pM(e,t,n,r,o){let i=t?.overlaySnapshot?me(t.overlaySnapshot):null;if(!i)return e;let a=i.shapes.reduce((c,l)=>{if(l.hidden)return c;let d=de(l);return Math.max(c,d.y+d.h)},0),s=a>r+Cp?Math.ceil((a-r-Cp)/o)+1:1;return s<=e.length?e:[...e,...Array.from({length:s-e.length},(c,l)=>{let d=e.length+l+1;return Uo(d,n)})]}function Uo(e,t){return{id:`page_${e}`,number:e,blocks:[],columns:Array.from({length:Math.max(1,t)},(n,r)=>({id:`column_${r+1}`,number:r+1,blocks:[],estimatedContentHeightPx:0,oversizedBlockIds:[]})),estimatedContentHeightPx:0,oversizedBlockIds:[]}}function mM(e,t){return!e||e.length!==t.length?!1:e.every((n,r)=>{let o=t[r];return n.columns.length===o.columns.length&&n.columns.every((i,a)=>{let s=o.columns[a];return i.blocks.length===s.blocks.length&&i.blocks.every((c,l)=>zp(c,s.blocks[l]))})})}function zp(e,t){return e.id!==t.id||e.type!==t.type?!1:e.type==="boxFragment"&&t.type==="boxFragment"?e.fragmentRole===t.fragmentRole&&Math.abs(e.estimatedHeightPx-t.estimatedHeightPx)<.5&&Math.abs(e.totalHeight-t.totalHeight)<.5&&e.blocks.length===t.blocks.length&&e.blocks.every((n,r)=>n.id===t.blocks[r].id):e.type==="layoutSectionFragment"&&t.type==="layoutSectionFragment"?e.fragmentRole===t.fragmentRole&&e.columns.length===t.columns.length&&e.columns.every((n,r)=>{let o=t.columns[r];return n.blocks.length===o.blocks.length&&n.blocks.every((i,a)=>zp(i,o.blocks[a]))}):e.type==="blockSlice"&&t.type==="blockSlice"?e.fragmentRole===t.fragmentRole&&Math.abs(e.sliceTop-t.sliceTop)<.5&&Math.abs(e.sliceHeight-t.sliceHeight)<.5:e.type==="problemAreaFragment"&&t.type==="problemAreaFragment"?e.fragmentRole===t.fragmentRole&&Math.abs(e.estimatedHeightPx-t.estimatedHeightPx)<.5&&e.blocks.length===t.blocks.length&&e.blocks.every((n,r)=>n.id===t.blocks[r].id):!0}function fM(e,t){if(e.size!==t.size)return!1;for(let[n,r]of t){let o=e.get(n);if(!o||Math.abs(o.top-r.top)>.5||Math.abs((o.left??0)-(r.left??0))>.5||Math.abs((o.width??0)-(r.width??0))>.5||Math.abs((o.height??0)-(r.height??0))>.5)return!1}return!0}function Ze({unit:e,columnGapMm:t,mathFractionSizing:n}){if(e.type==="problemArea")return E(_p,{problemId:e.problemId,area:e.area,minHeightMm:e.minHeightMm,problemNumber:e.problemNumber,numberFontSize:e.numberFontSize,hasFrame:e.hasFrame,frameStyleId:e.frameStyleId,isFirstProblemArea:e.isFirstProblemArea,isFirstProblemFrameArea:e.isFirstProblemFrameArea,isLastProblemFrameArea:e.isLastProblemFrameArea,columnGapMm:t,mathFractionSizing:n,blocks:e.blocks});if(e.type==="problemAreaFragment"){let o=e.fragmentRole==="single"||e.fragmentRole==="first",i=e.fragmentRole==="single"||e.fragmentRole==="last";return E(_p,{problemId:e.problemId,area:e.area,minHeightMm:e.fragmentRole==="single"?e.minHeightMm:void 0,problemNumber:e.problemNumber,numberFontSize:e.numberFontSize,hasFrame:e.hasFrame,frameStyleId:e.frameStyleId,isFirstProblemArea:e.isFirstProblemArea,isFirstProblemFrameArea:e.hasFrame&&o,isLastProblemFrameArea:e.hasFrame&&i,columnGapMm:t,mathFractionSizing:n,blocks:e.blocks,fragmentRole:e.fragmentRole,sourceId:e.sourceId})}if(e.type==="boxFragment")return E(Fp,{block:e.block,columnGapMm:t,fragmentBlocks:e.blocks,fragmentRole:e.fragmentRole,includeTitle:e.includeTitle,cornerReferenceHeightPx:e.totalHeight,mathFractionSizing:n});if(e.type==="layoutSectionFragment")return E(yM,{unit:e,mathFractionSizing:n});if(e.type==="blockSlice")return E("div",{className:`print-block-slice print-block-slice-${e.fragmentRole}`,"data-block-slice":e.fragmentRole,"data-block-source-id":e.sourceId,style:{height:`${Math.round(e.sliceHeight)}px`,overflow:"hidden"},children:E("div",{className:"print-block-slice-inner",style:{marginTop:`${-Math.round(e.sliceTop)}px`},children:E(Ze,{unit:{type:"block",id:e.sourceId,block:e.block},columnGapMm:t,mathFractionSizing:n})})});let{block:r}=e;if(r.type==="section")return E("h1",{"data-sigma-doc-id":r.id,className:"print-section",style:{textAlign:r.align??"left",lineHeight:r.lineHeight},children:r.title});if(r.type==="heading")return E(gn,{block:r,mathFractionSizing:n});if(r.type==="paragraph")return E(gn,{block:r,mathFractionSizing:n});if(r.type==="list")return E(gn,{block:r,mathFractionSizing:n});if(r.type==="boxBlock")return E(Fp,{block:r,columnGapMm:t,mathFractionSizing:n});if(r.type==="layoutSection"){let o=Hp(r.layout.columnCount),i=t;return E("section",{"data-sigma-doc-id":r.id,className:"print-layout-section",style:{"--print-layout-section-column-count":String(o),"--print-layout-section-column-gap":`${i}mm`},children:r.children.map(a=>{let s=E(Ze,{unit:{type:"block",id:a.id,block:a,pagination:a.pagination},columnGapMm:i,mathFractionSizing:n});return o>1&&a.pagination?.break===!0?E("div",{className:"print-column-break-before",children:s},a.id):E(jP,{children:s},a.id)})})}}function yM({unit:e,mathFractionSizing:t}){let n=e.columns.length,r={"--print-layout-section-column-count":String(n),"--print-layout-section-column-gap":`${e.columnGapMm}mm`,display:"grid",gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`,columnGap:`${e.columnGapMm}mm`};return E("section",{"data-sigma-doc-id":e.fragmentRole==="single"||e.fragmentRole==="first"?e.sourceId:void 0,"data-layout-section-source-id":e.sourceId,"data-layout-section-fragment":e.fragmentRole,className:`print-layout-section print-layout-section-fragment print-layout-section-fragment-${e.fragmentRole}`,style:r,children:e.columns.map(o=>E("div",{className:"print-layout-section-column",style:{minWidth:0},children:as(o).map((i,a)=>E(Ze,{unit:i,columnGapMm:e.columnGapMm,mathFractionSizing:t},`${i.id}-${a}`))},`${e.id}-${o.id}`))})}function Fp({block:e,columnGapMm:t,mathFractionSizing:n,fragmentBlocks:r,fragmentRole:o,includeTitle:i=!0,cornerReferenceHeightPx:a}){let s=zo(e),c=Ho(e).length>0,l=r??e.blocks,d=o?` print-box-fragment print-box-fragment-${o}`:"",u={...wp(s),...es(a)};return lr("section",{"data-sigma-doc-id":!o||o==="single"||o==="first"?e.id:void 0,"data-box-source-id":o?e.id:void 0,"data-box-fragment":o,"data-corner-reference-height":a?"explicit":void 0,className:`${Tp("print-box-block",s,e.styleId)}${d}`,"data-box-style":e.styleId,...Op(s),style:u,children:[E("span",{className:"print-box-corner top-left","aria-hidden":"true"}),E("span",{className:"print-box-corner top-right","aria-hidden":"true"}),E("span",{className:"print-box-corner bottom-left","aria-hidden":"true"}),E("span",{className:"print-box-corner bottom-right","aria-hidden":"true"}),i&&c&&E("div",{className:"print-box-title",children:xe(e.title??[],{keyPrefix:`${e.id}-title`,mathFractionSizing:n})}),E("div",{className:"print-box-body",children:l.map(m=>E(hM,{block:m,columnGapMm:t,mathFractionSizing:n},m.id))})]})}function hM({block:e,columnGapMm:t,mathFractionSizing:n}){return e.type==="layoutSection"?E(Ze,{unit:{type:"block",id:e.id,block:e,pagination:e.pagination},columnGapMm:t,mathFractionSizing:n}):e.type==="section"||e.type==="boxBlock"?E(Ze,{unit:{type:"block",id:e.id,block:e,pagination:e.pagination},columnGapMm:t,mathFractionSizing:n}):E(gn,{block:e,mathFractionSizing:n})}function _p({problemId:e,area:t,blocks:n,minHeightMm:r,problemNumber:o,numberFontSize:i,hasFrame:a,frameStyleId:s,isFirstProblemArea:c,isFirstProblemFrameArea:l,isLastProblemFrameArea:d,columnGapMm:u,mathFractionSizing:m,fragmentRole:h,sourceId:y}){let g=!h||h==="single"||h==="first",x=t==="lead"&&typeof o=="number"&&g;if(n.length===0&&!r&&!x)return null;let S=x&&n.length===0,I=a?Rp("print-problem-area with-frame",s):"print-problem-area",R=h?` print-problem-area-fragment print-problem-area-fragment-${h}`:"";return E("section",{className:`${I}${R} ${a&&l?"first-frame-area":""} ${a&&d?"last-frame-area":""}`,"data-sigma-doc-id":c&&g?e:void 0,"data-problem-area":t,"data-problem-area-fragment":h,"data-problem-source-id":y,"data-problem-frame-style":a?s:void 0,style:r?{minHeight:`${r}mm`}:void 0,children:lr("div",{className:`print-problem-area-content ${x?"with-number":""}`,children:[x&&E("span",{className:"print-problem-number",style:{fontSize:`${i}pt`},children:gp(o)}),E("div",{className:`print-problem-area-body ${S?"empty-lead-placeholder":""}`,children:S?E("div",{className:"print-empty-lead-shell","aria-hidden":"true"}):n.map(M=>M.type==="layoutSection"||M.type==="boxBlock"?E(Ze,{unit:{type:"block",id:M.id,block:M,pagination:M.pagination},columnGapMm:u,mathFractionSizing:m},M.id):E(gn,{block:M,mathFractionSizing:m},M.id))})]})})}function Hp(e){return Number.isInteger(e)?Math.min(4,Math.max(1,e)):2}function gM(e){let t=e.numbering?.fontSize;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:qP}import{z as p}from"zod";var xM=p.object({keepTogether:p.boolean().optional(),keepWithNext:p.boolean().optional(),break:p.boolean().optional()}).optional(),Et=p.object({id:p.string().min(1),pagination:xM}),ls=p.enum(["left","center","right","justify"]).optional(),cs=p.string().transform((e,t)=>{let n=tt(e);return n||(t.addIssue({code:p.ZodIssueCode.custom,message:"lineHeight must be a unitless number between 0.8 and 3"}),p.NEVER)}).optional(),Xp=p.enum(["frame","thick","double","oval","shade"]).optional(),Yp=p.enum(["gray","blue","green","red","yellow"]).optional(),bM=p.object({type:p.literal("text"),text:p.string(),marks:p.array(p.enum(["bold","italic","underline","boxed"])).optional(),color:p.string().optional(),backgroundColor:p.string().optional(),fontFamily:p.string().optional(),fontSize:p.number().positive().optional(),boxedPaddingY:p.number().min(0).optional(),boxedVariant:Xp,boxedTone:Yp}),SM=p.object({type:p.literal("mathInline"),id:p.string().min(1),tex:p.string(),display:p.literal("inline"),marks:p.array(p.enum(["underline","boxed"])).optional(),color:p.string().optional(),backgroundColor:p.string().optional(),fontFamily:p.string().optional(),fontSize:p.number().positive().optional(),boxedPaddingY:p.number().min(0).optional(),boxedVariant:Xp,boxedTone:Yp,semanticRole:p.enum(["expression","equation","variable"]).optional(),altText:p.string().optional()}),cr=p.discriminatedUnion("type",[bM,SM]),Up=p.object({blockId:p.string().min(1),offset:p.number().int().min(0)}),vM=p.discriminatedUnion("type",[p.object({type:p.literal("textRange"),start:Up,end:Up,quote:p.string(),mathInlineIds:p.array(p.string().min(1)).optional(),mathTex:p.array(p.string()).optional()}),p.object({type:p.literal("inlineMath"),blockId:p.string().min(1),mathInlineId:p.string().min(1),quote:p.string().optional(),tex:p.string().optional()}),p.object({type:p.literal("block"),blockId:p.string().min(1),quote:p.string().optional()}),p.object({type:p.literal("overlayShape"),shapeIds:p.array(p.string().min(1)).min(1),quote:p.string().optional()}),p.object({type:p.literal("overlayMath"),shapeId:p.string().min(1).optional(),mathInlineId:p.string().min(1).optional(),quote:p.string().optional(),tex:p.string().optional()})]),Kp=p.object({id:p.string().min(1),emoji:p.string().min(1),authorName:p.string().optional(),createdAt:p.string()}),PM=p.object({id:p.string().min(1),authorName:p.string().optional(),body:p.array(cr),reactions:p.array(Kp).optional(),createdAt:p.string(),updatedAt:p.string().optional()}),MM=p.object({id:p.string().min(1),anchor:vM,messages:p.array(PM).min(1),reactions:p.array(Kp).optional(),resolved:p.boolean().optional(),color:p.string().optional(),createdAt:p.string(),updatedAt:p.string().optional()}),us=Et.extend({type:p.literal("section"),title:p.string(),align:ls,lineHeight:cs}),Yo=Et.extend({type:p.literal("heading"),level:p.union([p.literal(1),p.literal(2),p.literal(3)]),children:p.array(cr),align:ls,lineHeight:cs}),Ko=Et.extend({type:p.literal("paragraph"),children:p.array(cr),align:ls,lineHeight:cs}),ur=p.lazy(()=>Et.extend({type:p.literal("list"),listType:p.enum(["bullet","ordered"]),start:p.number().int().positive().optional(),markerStyle:p.enum(["decimal","paren"]).optional(),items:p.array(TM).min(1)})),TM=p.lazy(()=>p.object({type:p.literal("listItem"),id:p.string().min(1),children:p.array(cr),nested:p.array(ur).optional()})),jp=p.union([Yo,Ko,ur]),qp=p.object({top:p.number().nonnegative(),right:p.number().nonnegative(),bottom:p.number().nonnegative(),left:p.number().nonnegative()}),OM=p.discriminatedUnion("type",[p.object({type:p.literal("cornerSquares"),sizePx:p.number().positive(),color:p.string()}),p.object({type:p.literal("doubleRule"),offsetPx:p.number().nonnegative(),widthPx:p.number().positive().optional(),color:p.string().optional()}),p.object({type:p.literal("titleDoubleRule"),ruleWidthPx:p.number().positive().optional(),ruleColor:p.string().optional(),guideColor:p.string().optional()}),p.object({type:p.literal("titleBand"),heightPx:p.number().positive().optional(),backgroundColor:p.string().optional()}),p.object({type:p.literal("titlePlate"),borderColor:p.string().optional(),radiusPx:p.number().nonnegative().optional(),paddingPx:qp.optional()}),p.object({type:p.literal("leftBar"),widthPx:p.number().positive(),color:p.string()}),p.object({type:p.literal("shadow"),offsetXPx:p.number(),offsetYPx:p.number(),blurPx:p.number().nonnegative().optional(),spreadPx:p.number().optional(),color:p.string()}),p.object({type:p.literal("horizontalRules"),widthPx:p.number().positive().optional(),color:p.string().optional()}),p.object({type:p.literal("notebookRules"),baseBodyWidthPx:p.number().positive().optional(),frameLeftPx:p.number().nonnegative().optional(),frameHeightPx:p.number().positive().optional(),frameStrokeOpacity:p.number().min(0).max(1).optional(),lineColor:p.string().optional(),lineGapPx:p.number().positive().optional(),lineWidthPx:p.number().positive().optional(),lineOffsetPx:p.number().nonnegative().optional(),bindingColor:p.string().optional(),bindingWidthPx:p.number().positive().optional(),bindingXPx:p.number().nonnegative().optional(),bindingStrokeOpacity:p.number().min(0).max(1).optional(),ringColor:p.string().optional(),ringWidthPx:p.number().positive().optional(),ringHeightPx:p.number().positive().optional(),ringStrokePx:p.number().positive().optional(),ringGapPx:p.number().positive().optional(),ringTopPx:p.number().nonnegative().optional(),ringCount:p.number().int().positive().optional(),ringLeftOverhangPx:p.number().nonnegative().optional(),minHeightPx:p.number().positive().optional()})]),wM=p.object({borderWidthPx:p.number().nonnegative().optional(),borderColor:p.string().optional(),borderStyle:p.enum(["solid","dashed","dotted","double","none"]).optional(),backgroundColor:p.string().optional(),titleBackgroundColor:p.string().optional(),titleColor:p.string().optional(),titleAlign:p.enum(["left","center","right","justify"]).optional(),titlePosition:p.enum(["l","c","r"]).optional(),titleFontWeight:p.enum(["normal","bold"]).optional(),titleFontFamily:p.string().optional(),titleFontSizePx:p.number().positive().optional(),titleLineHeight:p.string().optional(),bodyColor:p.string().optional(),bodyAlign:p.enum(["left","center","right","justify"]).optional(),bodyFontFamily:p.string().optional(),bodyFontSizePx:p.number().positive().optional(),bodyLineHeight:p.string().optional(),cornerStyle:p.enum(["sharp","round"]).optional(),radiusPx:p.number().nonnegative().optional(),paddingPx:qp.optional(),decorations:p.array(OM).optional()}).optional();function Vp(e,t,n){e?.break===!0&&n.addIssue({code:p.ZodIssueCode.custom,path:[...t,"break"],message:"boxBlock\u76F4\u4E0B\u3067\u306F\u6539\u30DA\u30FC\u30B8\u3067\u304D\u307E\u305B\u3093\u3002\u7BB1\u5185\u306E\u8907\u6570\u6BB5layoutSection\u3067\u306F\u6539\u6BB5\u3092\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002"})}var kM=p.lazy(()=>p.union([us,Yo,Ko,ur,jo,ds])).superRefine((e,t)=>{Vp(e.pagination,["pagination"],t),e.type==="layoutSection"&&e.layout.columnCount<=1&&e.children.forEach((n,r)=>{Vp(n.pagination,["children",r,"pagination"],t)})}),jo=p.lazy(()=>Et.extend({type:p.literal("boxBlock"),styleId:p.string().min(1),title:p.array(cr).optional(),blocks:p.array(kM).min(1),frame:wM})),BM=p.lazy(()=>p.union([us,Yo,Ko,ur,jo])),Wo=p.object({minHeightMm:p.number().nonnegative().optional(),columnSpan:p.enum(["column","full"]).optional()}),Xo=p.lazy(()=>p.union([jp,ds,jo])),RM=Et.extend({type:p.literal("problem"),tags:p.array(p.string()),lead:p.array(Xo).optional().default([]),prompt:p.array(Xo),answer:p.object({type:p.enum(["math","text"]),expected:p.string()}).optional(),solution:p.array(Xo),hints:p.array(Xo),areaLayout:p.object({lead:Wo.optional(),prompt:Wo.optional(),solution:Wo.optional(),hints:Wo.optional()}).optional(),numbering:p.object({enabled:p.boolean().optional(),fontSize:p.number().positive().optional(),value:p.number().int().positive().optional()}).optional(),frame:p.object({enabled:p.boolean().optional(),styleId:p.string().min(1).optional()}).optional()}),ds=p.lazy(()=>Et.extend({type:p.literal("layoutSection"),layout:p.object({columnCount:p.number().int().min(1).max(4),columnGapMm:p.number().nonnegative().optional()}),children:p.array(BM).min(1)})),AM=p.union([us,Yo,Ko,ur,RM,ds,jo]),IM=p.preprocess(Ac,p.custom(Xi)),Zp=p.object({overlaySnapshot:IM.optional(),updatedAt:p.string().optional()}),EM=p.object({type:p.literal("columns").optional(),columnCount:p.number().int().min(1).max(4).optional(),columnGapMm:p.number().nonnegative().optional()}),Wp=p.object({enabled:p.boolean().optional(),heightMm:p.number().positive().optional(),offsetMm:p.number().nonnegative().optional(),showOnFirstPage:p.boolean().optional(),blocks:p.array(jp).optional(),overlay:Zp.optional()}),CM=p.object({preset:p.enum(["A4","A3","B5","B4","custom"]).optional(),orientation:p.enum(["portrait","landscape"]).optional(),pageSize:p.object({widthMm:p.number().positive().optional(),heightMm:p.number().positive().optional()}).optional(),marginsMm:p.object({top:p.number().nonnegative().optional(),right:p.number().nonnegative().optional(),bottom:p.number().nonnegative().optional(),left:p.number().nonnegative().optional()}).optional(),flow:EM.optional(),header:Wp.optional(),footer:Wp.optional(),overlay:Zp.optional()}).transform(e=>oa(en(e))).superRefine((e,t)=>{for(let n of Vc(e))t.addIssue({code:"custom",message:n})}),LM=p.object({version:p.literal("2.0"),docId:p.string().min(1),metadata:p.object({title:p.string(),source:p.object({format:p.literal("studyaid-prt").optional(),layoutMode:p.literal("fixedOverlay").optional(),printFlowContent:p.boolean().optional()}).optional(),styleUnits:p.object({fontSize:p.literal("pt").optional()}).optional(),mathFractionSizing:p.enum(["uniform","texDefault"]).optional(),texPreamble:p.string().max(2e4).optional()}),content:p.array(AM),outputProfiles:p.object({student:p.object({showSolutions:p.boolean().optional(),showHints:p.boolean().optional(),includeAnswers:p.boolean().optional(),onlySolutions:p.boolean().optional(),includeComments:p.boolean().optional()}),teacher:p.object({showSolutions:p.boolean().optional(),showHints:p.boolean().optional(),includeAnswers:p.boolean().optional(),onlySolutions:p.boolean().optional(),includeComments:p.boolean().optional()}),answerBook:p.object({showSolutions:p.boolean().optional(),showHints:p.boolean().optional(),includeAnswers:p.boolean().optional(),onlySolutions:p.boolean().optional(),includeComments:p.boolean().optional()})}),comments:p.array(MM).optional(),pageLayout:CM.optional(),updatedAt:p.string().optional()}),NM=LM.transform(e=>({...e,version:"2.0",metadata:{...e.metadata,styleUnits:{...e.metadata.styleUnits,fontSize:yo}},pageLayout:en(e.pageLayout)}));function FM(e){if(typeof e!="object"||e===null||Array.isArray(e.content)||!Array.isArray(e.chapters))return e;let{chapters:t,...n}=e,r=t.flatMap(o=>o&&typeof o=="object"&&Array.isArray(o.content)?o.content:[]);return{...n,content:r}}function Jp(e){return NM.parse(_M(FM(e)))}function _M(e){if(!It(e)||e.version!=="2.0")return e;let t=It(e.metadata)?e.metadata:{};if((It(t.styleUnits)?t.styleUnits:{}).fontSize===yo)return e;let r=ss(e);if(!It(r))return r;let o=It(r.metadata)?r.metadata:{},i=It(o.styleUnits)?o.styleUnits:{};return{...r,metadata:{...o,styleUnits:{...i,fontSize:yo}}}}function ss(e){if(Array.isArray(e))return e.map(ss);if(!It(e))return e;let t={};for(let[n,r]of Object.entries(e))n==="fontSize"&&typeof r=="number"&&Number.isFinite(r)&&r>0?t[n]=Rn(r):t[n]=ss(r);return t}function It(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var DM=100,ys=32*1024*1024,Qp=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/u,GM=/[\u0000-\u001f\u007f-\u009f]/u,$M=/^(?:\d+(?:\.\d+)?|\.\d+)(?:px)?$/u,zM=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u,hs=class extends Error{constructor(t){super("Viewer\u3067\u5B89\u5168\u306B\u63CF\u753B\u3067\u304D\u306A\u3044\u30B9\u30BF\u30A4\u30EB\u5024\u304C\u3042\u308A\u307E\u3059\u3002"),this.name="ViewerSafetyValidationError",this.issues=t}};function im(e){let t=HM(e);if(t.length>0)throw new hs(t)}function HM(e){let t=[],n=(r,o)=>{t.length<DM&&t.push(`${r}: ${o}`)};return e.content.forEach((r,o)=>UM(r,`content.${o}`,n)),em(e.pageLayout?.header?.blocks,"pageLayout.header.blocks",n),em(e.pageLayout?.footer?.blocks,"pageLayout.footer.blocks",n),ps(e.pageLayout?.overlay,"pageLayout.overlay",n),ps(e.pageLayout?.header?.overlay,"pageLayout.header.overlay",n),ps(e.pageLayout?.footer?.overlay,"pageLayout.footer.overlay",n),t}function am(e){let t=e.trim();if(!t)return{ok:!1,reason:"\u753B\u50CFsource\u304C\u7A7A\u3067\u3059\u3002"};if(GM.test(t))return{ok:!1,reason:"\u753B\u50CFdata URL\u306B\u5236\u5FA1\u6587\u5B57\u304C\u3042\u308A\u307E\u3059\u3002"};let n=t.indexOf(",");if(n<0)return{ok:!1,reason:"\u753B\u50CFsource\u306Fdata URL\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002"};let r=t.slice(0,n).toLowerCase(),o=t.slice(n+1);if(r==="data:image/png;base64")return ms(t,o,"image/png",nT);if(r==="data:image/jpeg;base64")return ms(t,o,"image/jpeg",rT);if(r==="data:image/webp;base64")return ms(t,o,"image/webp",oT);let i=r==="data:image/svg+xml;base64"||r==="data:image/svg+xml;charset=utf-8;base64"||r==="data:image/svg+xml;charset=us-ascii;base64";if(!i&&!(r==="data:image/svg+xml"||r==="data:image/svg+xml;charset=utf-8"||r==="data:image/svg+xml;charset=us-ascii"))return{ok:!1,reason:"\u753B\u50CF\u306FPNG\u30FBJPEG\u30FBWebP\u30FBSVG\u306Edata URL\u306E\u307F\u8868\u793A\u3067\u304D\u307E\u3059\u3002"};let s;try{if(i){let l=sm(o);if(!l)return{ok:!1,reason:"SVG\u753B\u50CF\u306Ebase64 payload\u304C\u4E0D\u6B63\u3067\u3059\u3002"};s=new TextDecoder("utf-8",{fatal:!0}).decode(l)}else s=decodeURIComponent(o)}catch{return{ok:!1,reason:"SVG\u753B\u50CF\u306Epayload\u3092UTF-8\u3068\u3057\u3066\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093\u3002"}}let c=iT(s);return c?{ok:!1,reason:c}:{ok:!0,value:{src:t,mimeType:"image/svg+xml"}}}function em(e,t,n){e?.forEach((r,o)=>pr(r,`${t}.${o}`,n))}function UM(e,t,n){if(e.type==="section"){ei(e.lineHeight,`${t}.lineHeight`,n);return}if(e.type==="heading"||e.type==="paragraph"||e.type==="list"){pr(e,t,n);return}if(e.type==="problem"){["lead","prompt","hints","solution"].forEach(r=>{e[r].forEach((o,i)=>VM(o,`${t}.${r}.${i}`,n))});return}if(e.type==="layoutSection"){e.children.forEach((r,o)=>Jo(r,`${t}.children.${o}`,n));return}gs(e,t,n)}function VM(e,t,n){if(e.type==="layoutSection"){e.children.forEach((r,o)=>Jo(r,`${t}.children.${o}`,n));return}if(e.type==="boxBlock"){gs(e,t,n);return}pr(e,t,n)}function Jo(e,t,n){e.type==="section"?ei(e.lineHeight,`${t}.lineHeight`,n):e.type==="boxBlock"?gs(e,t,n):pr(e,t,n)}function WM(e,t,n){e.type==="layoutSection"?e.children.forEach((r,o)=>Jo(r,`${t}.children.${o}`,n)):Jo(e,t,n)}function gs(e,t,n){e.title?.forEach((r,o)=>Qo(r,`${t}.title.${o}`,n)),e.blocks.forEach((r,o)=>WM(r,`${t}.blocks.${o}`,n)),XM(e.frame,`${t}.frame`,n)}function pr(e,t,n){if(e.type==="heading"||e.type==="paragraph"){ei(e.lineHeight,`${t}.lineHeight`,n),e.children.forEach((r,o)=>Qo(r,`${t}.children.${o}`,n));return}e.items.forEach((r,o)=>{r.children.forEach((i,a)=>Qo(i,`${t}.items.${o}.children.${a}`,n)),r.nested?.forEach((i,a)=>pr(i,`${t}.items.${o}.nested.${a}`,n))})}function Qo(e,t,n){V(e.color,`${t}.color`,n),V(e.backgroundColor,`${t}.backgroundColor`,n),dr(e.fontFamily,`${t}.fontFamily`,n)}function XM(e,t,n){if(e){for(let r of["borderColor","backgroundColor","titleBackgroundColor","titleColor","bodyColor"])V(e[r],`${t}.${r}`,n);dr(e.titleFontFamily,`${t}.titleFontFamily`,n),dr(e.bodyFontFamily,`${t}.bodyFontFamily`,n),nm(e.titleLineHeight,`${t}.titleLineHeight`,n),nm(e.bodyLineHeight,`${t}.bodyLineHeight`,n),e.titlePosition!==void 0&&!["l","c","r"].includes(e.titlePosition)&&n(`${t}.titlePosition`,"\u30BF\u30A4\u30C8\u30EB\u4F4D\u7F6E\u306Fl\u30FBc\u30FBr\u306E\u3044\u305A\u308C\u304B\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),e.decorations?.forEach((r,o)=>YM(r,`${t}.decorations.${o}`,n))}}function YM(e,t,n){"color"in e&&V(e.color,`${t}.color`,n),"borderColor"in e&&V(e.borderColor,`${t}.borderColor`,n),"backgroundColor"in e&&V(e.backgroundColor,`${t}.backgroundColor`,n),"ruleColor"in e&&V(e.ruleColor,`${t}.ruleColor`,n),"guideColor"in e&&V(e.guideColor,`${t}.guideColor`,n),"lineColor"in e&&V(e.lineColor,`${t}.lineColor`,n),"bindingColor"in e&&V(e.bindingColor,`${t}.bindingColor`,n),"ringColor"in e&&V(e.ringColor,`${t}.ringColor`,n)}function ps(e,t,n){e?.overlaySnapshot&&KM(e.overlaySnapshot,`${t}.overlaySnapshot`,n)}function KM(e,t,n){e.shapes.forEach((r,o)=>jM(r,`${t}.shapes.${o}`,n))}function jM(e,t,n){switch(e.type){case"geo":V(e.props.color,`${t}.props.color`,n),V(e.props.fillColor,`${t}.props.fillColor`,n),V(e.props.labelColor,`${t}.props.labelColor`,n);break;case"arc":V(e.props.color,`${t}.props.color`,n),V(e.props.fillColor,`${t}.props.fillColor`,n);break;case"arrow":V(e.props.color,`${t}.props.color`,n),V(e.props.labelColor,`${t}.props.labelColor`,n);break;case"line":V(e.props.color,`${t}.props.color`,n),V(e.props.fillColor,`${t}.props.fillColor`,n),V(e.props.labelColor,`${t}.props.labelColor`,n);break;case"text":case"callout":V(e.props.color,`${t}.props.color`,n),qM(e.props.richText,`${t}.props.richText`,n);break;case"graph2dShape":JM(e.props.spec,`${t}.props.spec`,n);break;case"tableShape":QM(e.props.table,`${t}.props.table`,n);break;default:break}}function qM(e,t,n){let r=new WeakSet;if(r.has(e)){n(t,"richText\u306B\u5FAA\u74B0\u53C2\u7167\u304C\u3042\u308A\u307E\u3059\u3002");return}r.add(e),e.blocks.forEach((o,i)=>{let a=`${t}.blocks.${i}`;if(r.has(o)){n(a,"richText\u306B\u5FAA\u74B0\u53C2\u7167\u304C\u3042\u308A\u307E\u3059\u3002");return}r.add(o),ei(o.lineHeight,`${a}.lineHeight`,n),o.align!==void 0&&!["left","center","right","justify"].includes(o.align)&&n(`${a}.align`,"\u8A31\u53EF\u3055\u308C\u3066\u3044\u306A\u3044text-align\u3067\u3059\u3002"),o.children.forEach((s,c)=>{ZM(s,`${a}.children.${c}`,n)}),r.delete(o)}),r.delete(e)}function ZM(e,t,n){V(e.color,`${t}.color`,n),V(e.backgroundColor,`${t}.backgroundColor`,n),dr(e.fontFamily,`${t}.fontFamily`,n),e.fontSize!==void 0&&!rm(e.fontSize,512)&&n(`${t}.fontSize`,"font-size\u304C\u4E0D\u6B63\u3067\u3059\u3002"),e.boxedPaddingY!==void 0&&!rm(e.boxedPaddingY,100,!0)&&n(`${t}.boxedPaddingY`,"padding\u304C\u4E0D\u6B63\u3067\u3059\u3002")}function JM(e,t,n){V(e.axes.axisColor,`${t}.axes.axisColor`,n),e.curves.forEach((r,o)=>V(r.color,`${t}.curves.${o}.color`,n)),e.points?.forEach((r,o)=>V(r.color,`${t}.points.${o}.color`,n)),e.fills?.forEach((r,o)=>V(r.color,`${t}.fills.${o}.color`,n))}function QM(e,t,n){V(e.grid.borderColor,`${t}.grid.borderColor`,n),e.grid.lineOverrides?.forEach((r,o)=>eT(r.style,`${t}.grid.lineOverrides.${o}.style`,n)),tm(e.defaultCellStyle,`${t}.defaultCellStyle`,n),e.cells.forEach((r,o)=>{tm(r.style,`${t}.cells.${o}.style`,n),r.content.forEach((i,a)=>tT(i,`${t}.cells.${o}.content.${a}`,n))})}function eT(e,t,n){V(e.borderColor,`${t}.borderColor`,n)}function tm(e,t,n){e&&(V(e.color,`${t}.color`,n),V(e.backgroundColor,`${t}.backgroundColor`,n),dr(e.fontFamily,`${t}.fontFamily`,n))}function tT(e,t,n){let r=e;for(let o of["children","label"]){let i=r[o];Array.isArray(i)&&i.forEach((a,s)=>Qo(a,`${t}.${o}.${s}`,n))}}function V(e,t,n){if(ti(e)){if(!St(e)){n(t,"CSS\u6CE8\u5165\u306B\u3064\u306A\u304C\u308B\u6587\u5B57\u5217\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002");return}Me(e)||n(t,"\u8A31\u53EF\u3055\u308C\u3066\u3044\u306A\u3044\u8272\u8868\u73FE\u3067\u3059\u3002")}}function dr(e,t,n){ti(e)&&(jr(e)||n(t,"font-family\u306B\u5B89\u5168\u3067\u306A\u3044\u5024\u304C\u3042\u308A\u307E\u3059\u3002"))}function ei(e,t,n){if(!ti(e))return;if(!St(e)||!/^(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e.trim())){n(t,"line-height\u306F\u5358\u4F4D\u306A\u3057\u6570\u5024\u3060\u3051\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002");return}let r=Number(e);(!Number.isFinite(r)||r<.5||r>5)&&n(t,"line-height\u304C\u8A31\u53EF\u7BC4\u56F2\u5916\u3067\u3059\u3002")}function nm(e,t,n){if(!ti(e))return;let r=e.trim();if(!St(e)||!$M.test(r)){n(t,"line-height\u306F\u6570\u5024\u307E\u305F\u306Fpx\u5358\u4F4D\u306E\u9577\u3055\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return}let o=Number.parseFloat(r);(!Number.isFinite(o)||o<0||o>999)&&n(t,"line-height\u304C\u8A31\u53EF\u7BC4\u56F2\u5916\u3067\u3059\u3002")}function ti(e){return e!=null}function rm(e,t,n=!1){if(typeof e=="string"&&(!St(e)||!/^(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e.trim())))return!1;let r=typeof e=="number"?e:Number(e);return Number.isFinite(r)&&(n?r>=0:r>0)&&r<=t}function ms(e,t,n,r){let o=sm(t);return!o||!r(o)?{ok:!1,reason:`${n}\u753B\u50CF\u306Epayload\u304C\u4E0D\u6B63\u3067\u3059\u3002`}:{ok:!0,value:{src:e,mimeType:n}}}function sm(e){if(!e||e.length%4!==0||e.length>Math.ceil(ys/3)*4||!zM.test(e))return null;let t=e.endsWith("==")?2:e.endsWith("=")?1:0,n=e.length/4*3-t;if(n<=0||n>ys)return null;let r=new Uint8Array(n),o=0;for(let i=0;i<e.length;i+=4){let a=qo(e.charCodeAt(i)),s=qo(e.charCodeAt(i+1)),c=e[i+2]==="="?0:qo(e.charCodeAt(i+2)),l=e[i+3]==="="?0:qo(e.charCodeAt(i+3));if(a<0||s<0||c<0||l<0)return null;let d=a<<18|s<<12|c<<6|l;o<n&&(r[o++]=d>>>16&255),o<n&&(r[o++]=d>>>8&255),o<n&&(r[o++]=d&255)}return r}function qo(e){return e>=65&&e<=90?e-65:e>=97&&e<=122?e-71:e>=48&&e<=57?e+4:e===43?62:e===47?63:-1}function nT(e){let t=[137,80,78,71,13,10,26,10];if(e.length<45||!t.every((o,i)=>e[i]===o))return!1;let n=8,r=!1;for(;n+12<=e.length;){let o=fs(e,n),i=Zo(e,n+4,4),a=n+12+o;if(a>e.length)return!1;if(!r){if(i!=="IHDR"||o!==13||fs(e,n+8)===0||fs(e,n+12)===0)return!1;r=!0}if(i==="IEND")return o===0&&a===e.length;n=a}return!1}function rT(e){if(e.length<12||e[0]!==255||e[1]!==216||e[e.length-2]!==255||e[e.length-1]!==217)return!1;for(let t=2;t+1<e.length-2;t+=1){if(e[t]!==255)continue;let n=e[t+1];if(n>=192&&n<=195||n>=197&&n<=199||n>=201&&n<=203||n>=205&&n<=207)return!0}return!1}function oT(e){if(e.length<20||Zo(e,0,4)!=="RIFF"||Zo(e,8,4)!=="WEBP"||om(e,4)+8!==e.length)return!1;let t=Zo(e,12,4),n=om(e,16);return(t==="VP8 "||t==="VP8L"||t==="VP8X")&&20+n<=e.length}function iT(e){let t=e.trim();if(!t||t.length>ys||Qp.test(e))return"SVG\u753B\u50CF\u304C\u7A7A\u3001\u904E\u5927\u3001\u307E\u305F\u306F\u5236\u5FA1\u6587\u5B57\u3092\u542B\u3093\u3067\u3044\u307E\u3059\u3002";let n=aT(t);if(n===null||Qp.test(n))return"SVG\u753B\u50CF\u306B\u4E0D\u6B63\u306A\u6587\u5B57\u53C2\u7167\u307E\u305F\u306F\u5236\u5FA1\u6587\u5B57\u304C\u3042\u308A\u307E\u3059\u3002";if(!/^(?:<\?xml\s[^>]*>\s*)?<svg(?:\s|>)[\s\S]*<\/svg>\s*$/iu.test(n))return"SVG\u753B\u50CF\u306B\u6709\u52B9\u306Asvg\u30EB\u30FC\u30C8\u8981\u7D20\u304C\u3042\u308A\u307E\u305B\u3093\u3002";if(/<!doctype\b|<!entity\b|<\?xml-stylesheet\b|<(?:script|foreignObject|iframe|object|embed)\b/iu.test(n))return"SVG\u753B\u50CF\u306B\u8A31\u53EF\u3055\u308C\u3066\u3044\u306A\u3044\u8981\u7D20\u304C\u3042\u308A\u307E\u3059\u3002";if(/\son[a-z][\w:-]*\s*=/iu.test(n))return"SVG\u753B\u50CF\u306B\u30A4\u30D9\u30F3\u30C8\u5C5E\u6027\u304C\u3042\u308A\u307E\u3059\u3002";if(/(?:@import\b|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:|\/\*)/iu.test(n))return"SVG\u753B\u50CF\u306B@import\u307E\u305F\u306F\u5371\u967A\u306ACSS\u304C\u3042\u308A\u307E\u3059\u3002";let r=n.replace(/url\s*\(\s*([^)]*?)\s*\)/giu,(i,a)=>{let s=a.trim(),c=s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")?s.slice(1,-1).trim():s;return/^#[A-Za-z_][\w:.-]*$/u.test(c)?"":i});if(/url\s*\(/iu.test(r))return"SVG\u753B\u50CF\u306Eurl()\u306F\u540C\u4E00SVG\u5185\u306E\u8981\u7D20\u3060\u3051\u53C2\u7167\u3067\u304D\u307E\u3059\u3002";let o=/\s(?:href|xlink:href)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/giu;for(let i of n.matchAll(o))if(!(i[1]??i[2]??i[3]??"").trim().startsWith("#"))return"SVG\u753B\u50CF\u304B\u3089\u5916\u90E8resource\u3092\u53C2\u7167\u3067\u304D\u307E\u305B\u3093\u3002";return null}function aT(e){let t=!0,n=e.replace(/&(?:#(\d+)|#x([\da-f]+)|amp|lt|gt|quot|apos);/giu,(r,o,i)=>{if(o||i){let a=o?Number(o):Number.parseInt(i,16);return sT(a)?String.fromCodePoint(a):(t=!1,"")}return{"&":"&","<":"<",">":">",""":'"',"'":"'"}[r.toLowerCase()]??r});return t?n:null}function sT(e){return Number.isSafeInteger(e)&&(e===9||e===10||e===13||e>=32&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111)}function fs(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function om(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function Zo(e,t,n){let r="";for(let o=0;o<n;o+=1)r+=String.fromCharCode(e[t+o]);return r}import{jsx as oe,jsxs as vs}from"react/jsx-runtime";var cm=96/25.4,uT=["problem","solution","comments"],fr=class extends Error{constructor(t,n){super("SigmaDoc\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002"),this.name="SigmaDocParseError",this.issues=t,n&&"cause"in n&&Object.defineProperty(this,"cause",{configurable:!0,value:n.cause})}};function fm(e){try{let t=dT(e),n=Jp(t);return im(n),n}catch(t){throw new fr(ym(t),{cause:t})}}function dT(e){if(!ri(e)||!ri(e.pageLayout))return e;let t=e.pageLayout,n=!1,r={...t},o=um(t.overlay);o.changed&&(r.overlay=o.value,n=!0);for(let i of["header","footer"]){if(!ri(t[i]))continue;let a=t[i],s=um(a.overlay);s.changed&&(r[i]={...a,overlay:s.value},n=!0)}return n?{...e,pageLayout:r}:e}function um(e){if(!ri(e)||e.overlaySnapshot===void 0)return{value:e,changed:!1};let t=ji(e.overlaySnapshot);return t.issues.length===0?{value:e,changed:!1}:{value:{...e,overlaySnapshot:t.snapshot},changed:!0}}function ri(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function pT({document:e,visibleParts:t,hideProblemNumbers:n=!1,maxHeightPx:r,className:o,style:i,onError:a}){let[s,c]=mr(!1),[l,d]=mr(0),u=lm(()=>AT(t),[t]),m=lm(()=>hT(e,u,n),[e,u,n]);ni(()=>{c(!0)},[]),ni(()=>{if(!(!s||m.kind!=="ready"||!a))for(let S of m.errors)Ps(a,S)},[s,a,m]),ni(()=>{if(!s||typeof globalThis.document>"u")return;let S=globalThis.document.fonts;if(!S)return;let I=!1;return S.ready.then(()=>{I||d(R=>R+1)}),()=>{I=!0}},[s,m.key]);let h=["sigma-viewer",o].filter(Boolean).join(" ");if(!s)return oe("section",{className:h,"data-sigma-viewer":"true","data-sigma-viewer-state":"loading","aria-busy":"true",style:i,children:oe("span",{className:"sigma-viewer__status",children:"\u6587\u66F8\u3092\u6E96\u5099\u3057\u3066\u3044\u307E\u3059\u3002"})});if(m.kind==="error")return a?vs("section",{className:h,"data-sigma-viewer":"true","data-sigma-viewer-state":"error",style:i,children:[oe(fT,{callback:a,error:m.error}),oe(bs,{message:m.error.message})]}):oe("section",{className:h,"data-sigma-viewer":"true","data-sigma-viewer-state":"error",style:i,children:oe(bs,{message:m.error.message})});let y=m.document.pageLayout.pageSize.widthMm*cm,g=m.document.pageLayout.pageSize.heightMm*cm,x=`${m.key}:${l}`;return oe("section",{className:h,"data-sigma-viewer":"true","data-sigma-viewer-state":"ready",style:i,children:oe(mT,{maxHeightPx:r,resetKey:x,children:vs(Ss,{onError:a,children:[oe(Dp,{document:m.document,displayMode:"vertical",includePrintPageStyle:!1,stackClassName:"sigma-viewer__pages",renderPageFrame:({page:S,pageNode:I})=>oe(yT,{pageNumber:S.number,pageWidthPx:y,pageHeightPx:g,children:I},S.id)}),m.placeholderAssetIds.map(S=>oe("span",{className:"sigma-viewer__asset-placeholder-marker","data-sigma-viewer-asset-placeholder":S,"aria-hidden":"true"},S))]},x)})})}function mT({maxHeightPx:e,resetKey:t,children:n}){let r=cT(),o=mm(null),[i,a]=mr(!1),[s,c]=mr(!1),l=IT(e);xs(()=>{a(!1)},[t,l]),xs(()=>{let u=o.current;if(!u||l===void 0){c(!1);return}let m=()=>{c(u.scrollHeight>l+.5)};if(m(),typeof ResizeObserver<"u"){let h=new ResizeObserver(m);return h.observe(u),()=>h.disconnect()}return globalThis.addEventListener?.("resize",m),()=>globalThis.removeEventListener?.("resize",m)},[t,l]);let d=l!==void 0&&!i;return vs("div",{className:`sigma-viewer__viewport ${d?"is-constrained":""}`,"data-sigma-viewer-height-limited":d?"true":"false","data-sigma-viewer-overflow":s?"true":"false",style:d?{maxHeight:`${l}px`}:void 0,children:[oe("div",{className:"sigma-viewer__viewport-content",id:r,ref:o,children:n}),d&&s?oe("div",{className:"sigma-viewer__overflow-control",children:oe("button",{type:"button",className:"sigma-viewer__expand-button","aria-controls":r,"aria-expanded":"false",onClick:()=>a(!0),children:"\u3059\u3079\u3066\u8868\u793A"})}):null]})}function fT({callback:e,error:t}){return ni(()=>{Ps(e,t)},[e,t]),null}function bs({message:e}){return oe("div",{className:"sigma-viewer__error",role:"alert",children:e})}var Ss=class extends lT{constructor(){super(...arguments);this.state={error:null}}static getDerivedStateFromError(n){return{error:{code:"render-failed",message:n instanceof Error&&n.message?`SigmaDoc\u306E\u63CF\u753B\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${n.message}`:"SigmaDoc\u306E\u63CF\u753B\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002"}}}componentDidCatch(n,r){this.state.error&&this.props.onError&&Ps(this.props.onError,this.state.error)}render(){return this.state.error?oe(bs,{message:this.state.error.message}):this.props.children}};function yT({pageNumber:e,pageWidthPx:t,pageHeightPx:n,children:r}){let o=mm(null),[i,a]=mr(1);return xs(()=>{let s=o.current;if(!s||!(t>0))return;let c=()=>{let d=s.getBoundingClientRect().width;if(!(d>0))return;let u=d/t,m=u>=.999?1:Math.min(1,u);a(h=>Math.abs(h-m)<.001?h:m)};if(c(),typeof ResizeObserver>"u")return globalThis.addEventListener?.("resize",c),()=>globalThis.removeEventListener?.("resize",c);let l=new ResizeObserver(c);return l.observe(s),()=>l.disconnect()},[t]),oe("div",{ref:o,className:"sigma-viewer__page","data-sigma-viewer-page":e,style:{width:"100%",maxWidth:`${t}px`,height:`${n*i}px`},children:oe("div",{className:"sigma-viewer__page-scaler",style:{width:`${t}px`,height:`${n}px`,transform:`scale(${i})`},children:r})})}function hT(e,t,n){let r;try{r=fm(e)}catch(a){let s=a instanceof fr?a.issues:ym(a);return{kind:"error",error:{code:"invalid-document",message:"SigmaDoc\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",issues:s},key:`invalid:${pm(s.join(`
|
|
14
|
-
|
|
10
|
+
`&&(n+=1);return n}function da(e,t){if(e[t]!=="\\")return null;let n=t+1;for(;n<e.length&&/[A-Za-z@]/.test(e[n]);)n+=1;return n===t+1?null:{end:n,name:e.slice(t+1,n)}}function Sg(e,t){if(e[t]==="{"){let n=gu(e,t);if(!n)return null;let r=da(n.value.trim(),0);return r&&r.end===n.value.trim().length?{end:n.end,name:r.name}:null}return da(e,t)}function vg(e,t){let n=e.indexOf("]",t+1);return e[t]==="["&&n>=0?{end:n+1,value:e.slice(t+1,n)}:null}function gu(e,t){if(e[t]!=="{")return null;let n=0;for(let r=t;r<e.length;r+=1){if(e[r]==="%"&&e[r-1]!=="\\"){r=Xe(e,r)-1;continue}if(e[r]==="\\"){r+=1;continue}if(e[r]==="{"&&(n+=1),e[r]==="}"&&(n-=1,n===0))return{end:r+1,value:e.slice(t+1,r)}}return null}var kt="sigma-kyoutsuu-choice",QI=String.raw`
|
|
11
|
+
.${kt} {
|
|
12
|
+
align-items: center;
|
|
13
|
+
block-size: 1.28em;
|
|
14
|
+
border: 0.14em solid currentColor;
|
|
15
|
+
border-radius: 50%;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
display: inline-flex !important;
|
|
18
|
+
font-family: Arial, "Helvetica Neue", sans-serif;
|
|
19
|
+
font-style: normal;
|
|
20
|
+
font-variant-numeric: tabular-nums;
|
|
21
|
+
font-weight: 700;
|
|
22
|
+
inline-size: 0.9em;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
line-height: 1;
|
|
25
|
+
vertical-align: -0.2em;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.${kt} > .ML__text,
|
|
29
|
+
.${kt} > .text {
|
|
30
|
+
align-items: center;
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
font-family: inherit !important;
|
|
33
|
+
font-size: 0.78em;
|
|
34
|
+
font-style: inherit;
|
|
35
|
+
font-variant-numeric: inherit;
|
|
36
|
+
font-weight: inherit;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
line-height: 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.${kt} > .text > .mord {
|
|
42
|
+
font: inherit;
|
|
43
|
+
}`,Mg={kyoutsuuchoice:{def:String.raw`\class{${kt}}{\textbf{#1}}`,args:1},doubleboxed:{def:String.raw`\class{sigma-doubleboxed}{\boxed{#1}}`,args:1},thickboxed:{def:String.raw`\class{sigma-thickboxed}{\boxed{#1}}`,args:1},outerthickdoubleboxed:{def:String.raw`\class{sigma-outerthick-doubleboxed}{\boxed{#1}}`,args:1}},Pg={[String.raw`\kyoutsuuchoice`]:String.raw`\htmlClass{${kt}}{\textbf{#1}}`,[String.raw`\doubleboxed`]:String.raw`\htmlClass{sigma-doubleboxed}{\boxed{#1}}`,[String.raw`\thickboxed`]:String.raw`\htmlClass{sigma-thickboxed}{\boxed{#1}}`,[String.raw`\outerthickdoubleboxed`]:String.raw`\htmlClass{sigma-outerthick-doubleboxed}{\boxed{#1}}`},qn=new Map,Tg=32,xu=0;function pa(e=""){let t=qn.get(e);if(t)return t;let n=hu(e),r=Object.fromEntries(Object.entries(n.macros).map(([a,s])=>[a,s])),o=Object.fromEntries(Object.entries(n.macros).map(([a,s])=>[`\\${a}`,s.def]));xu+=1;let i={issues:n.issues,katexMacros:{...Pg,...o},mathLiveMacros:{...Mg,...r},signature:`m${xu}`};if(qn.size>=Tg){let a=qn.keys().next().value;a!==void 0&&qn.delete(a)}return qn.set(e,i),i}var Zn=pa(),ma=new Set([kt,"sigma-doubleboxed","sigma-thickboxed","sigma-outerthick-doubleboxed"]);function an(e){return e.command===String.raw`\htmlClass`&&!!(e.class&&ma.has(e.class))}var sn={macroSet:Zn,typesetStyle:Si};function fa(e,t){return{macroSet:pa(e),typesetStyle:Br(t)}}function bu(e,t){return e.typesetStyle===t?e:{...e,typesetStyle:t}}function Le(e,t){return`${e.typesetStyle}\0${e.macroSet.signature}\0${t}`}import $g from"katex";import zg from"katex/src/fontMetricsData.js";import Og from"katex";import{convertLatexToMarkup as wg,validateLatex as aE}from"mathlive";var Su=/\\begin\{(aligned|alignedat|array|cases|displaylines|matrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix|smallmatrix)\}([\s\S]*?)\\end\{\1\}/g,Tu="\\\\";var kg=new Set(["mbox","text"]),Bg=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}\u3000-\u303f\uff01-\uff60\uffe0-\uffee]/u,Rg={macros:Zn.katexMacros,maxExpand:1e3,maxSize:100,output:"html",strict:"ignore",throwOnError:!0,trust:an},Jn=new Map;var Ag=5e3,Ig=/class="[^"]*\bML__error\b/;function po(e,t){let n=Le(t,e),r=Jn.get(n);if(r!==void 0)return r;let o=Eg(e,t);if(Jn.size>=Ag){let i=Jn.keys().next().value;i!==void 0&&Jn.delete(i)}return Jn.set(n,o),o}function Eg(e,t){let{macroSet:n,typesetStyle:r}=t,o=wg(ft(Cg(e)||"\\square",r),{defaultMode:"math",macros:n.mathLiveMacros});return Ig.test(o)?Gg(ft(ya(e)||"\\square",r),n)??o:o}function Cg(e){return wu(Ou(e)).replace(/\\placeholder(?:\[([^\]]*)\])?\{\s*\}/g,(t,n)=>`\\placeholder[${n||"?"}]{\\square}`).replace(/\\placeholder\{([^{}]+)\}/g,(t,n)=>`\\placeholder[?]{${n}}`)}function ya(e){return wu(Ou(e)).replace(/\\placeholder(?:\[[^\]]*\])?\{([^{}]*)\}/g,(t,n)=>n.trim()?`{${n}}`:"\\square")}function Ou(e){if(!e.includes(Tu)||/^\s*\\displaylines\{/.test(e))return e;let t="",n=0,r;for(Su.lastIndex=0;(r=Su.exec(e))!==null;)t+=vu(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=vu(e.slice(n)),t}function wu(e){let t="",n=0;for(;n<e.length;){if(e[n]==="\\"){let o=_g(e,n),i=o.name&&kg.has(o.name)?Dg(e,o.end):-1;if(i>=0){t+=e.slice(n,i+1),n=i+1;continue}t+=e.slice(n,o.end),n=o.end;continue}if(Mu(e,n)){let o=n;do n+=Pu(e,n);while(n<e.length&&Mu(e,n));t+=`\\text{${e.slice(o,n)}}`;continue}let r=Pu(e,n);t+=e.slice(n,n+r),n+=r}return t}function vu(e){let t=Lg(e.trim()).map(o=>o.trim()).filter(Boolean);if(t.length<2)return e;let n=e.match(/^\s*/)?.[0]??"",r=e.match(/\s*$/)?.[0]??"";return`${n}\\begin{aligned}${t.map(Fg).join(Tu)}\\end{aligned}${r}`}function Lg(e){let t=[],n=0;for(let r=0;r<e.length-1;r+=1)Ng(e,r)&&(t.push(e.slice(n,r)),r+=1,n=r+1);return t.push(e.slice(n)),t}function Ng(e,t){return e[t]==="\\"&&e[t+1]==="\\"&&e[t-1]!=="\\"&&e[t+2]!=="\\"}function Fg(e){return e.includes("&")?e:e.replace(/\s*(=|<|>|\\leq{0,2}\b|\\geq{0,2}\b|\\neq?\b|\\approx\b|\\equiv\b|\\iff\b|\\to\b|\\Rightarrow\b|\\Leftarrow\b)/,"&$1")}function _g(e,t){let n=t+1;for(;n<e.length&&/[a-zA-Z]/.test(e[n]??"");)n+=1;return n>t+1?{end:n,name:e.slice(t+1,n)}:{end:Math.min(t+2,e.length),name:null}}function Dg(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]??"");)n+=1;if(e[n]!=="{")return-1;let r=0;for(;n<e.length;n+=1){let o=e[n];if(o==="\\"){n+=1;continue}if(o==="{")r+=1;else if(o==="}"&&(r-=1,r===0))return n}return-1}function Mu(e,t){let n=e.codePointAt(t);return n===void 0?!1:Bg.test(String.fromCodePoint(n))}function Pu(e,t){let n=e.codePointAt(t);return n!==void 0&&n>65535?2:1}function Gg(e,t=Zn){try{return Og.renderToString(e,{...Rg,macros:t.katexMacros})}catch{return null}}var ha=zg,Hg=$g.__renderToHTMLTree,Ug=/class="ML__strut" style="height:([0-9.]+)em"/,Vg=/class="ML__strut--bottom" style="height:([0-9.]+)em;vertical-align:-([0-9.]+)em"/,Wg={maxExpand:1e3,maxSize:100,output:"html",strict:"ignore",throwOnError:!0,trust:an},Xg=/\\(?:frac|dfrac|tfrac|cfrac|sqrt|int|oint|iint|iiint|sum|prod|coprod|lim|begin|binom|dbinom|tbinom|overbrace|underbrace)\b/,ku=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],Yg=/^reset-size(\d+)$/,Kg=/^size(\d+)$/,jg=.12,qg=1,Au=.6,Zg=1e-4,Bu=1.05,Ru=1.25,Jg=1.05,Qg=1.6,ex=1,Qn=new Map,tx=5e3;function fo(e,t){let n=Le(t,e),r=Qn.get(n);if(r!==void 0)return r;let o=nx(e,t);if(Qn.size>=tx){let i=Qn.keys().next().value;i!==void 0&&Qn.delete(i)}return Qn.set(n,o),o}function nx(e,t){let n=rx(e,t),r=ox(e,t),o=(r?r.widthEm:ux(e))*Jg;if(n){let i=r?Math.max(n.ascentEm,r.ascentEm):n.ascentEm,a=r?Math.max(n.descentEm,r.descentEm):n.descentEm;return{ascentEm:i*Bu,descentEm:a*Bu,widthEm:o,source:"mathlive"}}return r?{ascentEm:r.ascentEm*Ru,descentEm:r.descentEm*Ru,widthEm:o,source:"katex"}:{ascentEm:Xg.test(e)?Qg:ex,descentEm:0,widthEm:o,source:"heuristic"}}function rx(e,t){let n;try{n=po(e,t)}catch{return null}let r=n.match(Ug);if(!r)return null;let o=n.match(Vg),i=Number.parseFloat(r[1]),a=o?Number.parseFloat(o[2]):0;return!Number.isFinite(i)||!Number.isFinite(a)?null:{ascentEm:i,descentEm:a}}function ox(e,t){try{let n=ft(ya(e)||"\\square",t.typesetStyle),r=Hg(n,{...Wg,macros:t.macroSet.katexMacros}),o=typeof r.height=="number"?r.height:0,i=typeof r.depth=="number"?r.depth:0;return{ascentEm:o,descentEm:i,widthEm:ga(r,1)}}catch{return null}}function ga(e,t){let n=e.classes??[];if(n.includes("strut")||n.includes("pstrut"))return 0;if(n.includes("nulldelimiter"))return jg*t;if(e.text!==void 0)return ax(e)*t;let r=t*ix(n),o=e.children??[],a=n.includes("vlist")||n.includes("vlist-r")||n.includes("vlist-t")||n.includes("vlist-t2")?Math.max(0,...o.map(u=>ga(u,r))):o.reduce((u,m)=>u+ga(m,r),0),s=e.style??{},c=((ln(s.marginLeft)??0)+(ln(s.marginRight)??0)+(ln(s.paddingLeft)??0)+(ln(s.paddingRight)??0))*t,l=a+c,d=ln(s.width)??ln(s.minWidth);return d!==void 0&&(l=Math.max(l,d*t)),typeof e.width=="number"&&(l=Math.max(l,e.width*t)),l}function ix(e){let t,n;for(let i of e){let a=Yg.exec(i);a&&(t=Number(a[1]));let s=Kg.exec(i);s&&(n=Number(s[1]))}if(t===void 0||n===void 0)return 1;let r=ku[t-1],o=ku[n-1];return r&&o?o/r:1}function ln(e){if(!e)return;let t=/^(-?[0-9.]+)em$/.exec(e.trim());if(!t)return;let n=Number.parseFloat(t[1]);return Number.isFinite(n)?n:void 0}function ax(e){let t=e.text??"",n=Array.from(t);if(n.length===0)return 0;if(n.length===1)return typeof e.width=="number"?e.width:mo(n[0]);let r=n[0].codePointAt(0),o=typeof e.width=="number"&&r!==void 0?sx(r,e.width):[];if(o.length===0)return n.reduce((a,s)=>a+mo(s),0);let i=o.map(a=>n.reduce((s,c)=>s+lx(c,a),0));return Math.max(...i)}function sx(e,t){let n=[];for(let r of Object.keys(ha)){let o=ha[r][String(e)];o&&Math.abs(o[4]-t)<Zg&&n.push(r)}return n}function lx(e,t){let n=e.codePointAt(0);if(n===void 0)return 0;let r=ha[t][String(n)];return r?r[4]:mo(e)}function mo(e){return cx(e)?qg:Au}function cx(e){let t=e.codePointAt(0)??0;return t>=4352&&t<=4607||t>=11904&&t<=42191||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519}function ux(e){let t=e.replace(/\\(?:begin|end)\s*\{[^}]*\}/g,"").replace(/\\[a-zA-Z]+/g,"M").replace(/[{}^_\\]/g,""),n=0;for(let r of t)n+=mo(r);return Math.max(n,Au)}function dx(){return{measureTexEm(e){return fo(e,sn)}}}function Iu(){Ol(dx())}Iu();var Eu="boxed-text",px="boxed-inline-math";function Cu(e,t={}){let{paddingY:n,tone:r,variant:o}=kr(e),i={"data-sigma-doc-boxed-text":"true"};return n!==void 0&&(i["data-sigma-doc-boxed-padding-y"]=String(n)),o&&o!=="frame"&&(i["data-sigma-doc-boxed-variant"]=o),r&&(i["data-sigma-doc-boxed-tone"]=r),t.math&&(i["data-sigma-doc-boxed-math"]="true"),{attrs:i,className:t.math?`${Eu} ${px}`:Eu,style:mx(n)}}function Lu(e){if(!e)return{};let t={"data-boxed-run-height-target":"true","data-boxed-run-id":e.runId,"data-boxed-run-segment-id":e.segmentId,"data-boxed-run-segment-index":String(e.segmentIndex),"data-boxed-run-segment-count":String(e.segmentCount),"data-boxed-run-style-key":e.styleKey};return e.connectLeft&&(t["data-boxed-run-connect-left"]="true"),e.connectRight&&(t["data-boxed-run-connect-right"]="true"),t}function Nu(e){let t={};return e.color&&(t.color=e.color),e.backgroundColor&&(t["background-color"]=e.backgroundColor),e.fontFamily&&(t["font-family"]=e.fontFamily),e.fontSizePt&&(t["font-size"]=`${e.fontSizePt}pt`),Object.keys(t).length>0?t:void 0}function mx(e){let t=kr({paddingY:e}).paddingY;return t!==void 0?{"--boxed-text-padding-y":`${t}px`,"--boxed-text-line-height":`calc(1.78em + ${t*2+2}px)`}:void 0}function Fu(e){if(typeof window>"u")return 1;let t=1;for(let n=e;n;n=n.parentElement){let r=window.getComputedStyle(n),o=Number.parseFloat(r.zoom);Number.isFinite(o)&&o>0&&(t*=o),t*=fx(r.transform)}return t>0?t:1}function fx(e){if(!e||e==="none")return 1;let t=/^matrix(?:3d)?\(\s*([-\d.eE+]+)/.exec(e),n=t?Number.parseFloat(t[1]):Number.NaN;return Number.isFinite(n)&&n>0?n:1}var cn=[{label:"\u9ED2",value:"#0d0d0d"},{label:"\u30B0\u30EC\u30FC",value:"#6b7280"},{label:"\u8584\u30B0\u30EC\u30FC",value:"#9ca3af"},{label:"\u8D64",value:"#dc2626"},{label:"\u9752",value:"#2563eb"}];var yx=cn[0].value,hx=/^#[0-9a-f]{6}$/i,Uu=800,Vu=32,gx=220,xx=32,bx=120,yo=1e-12,Sx="yOfX",vx="solid",Mx=2.4,_u={min:"0",max:"2*pi"};function Rt(e){return Ju(e.viewBox)}function Ye(e){return Ju(e.graphViewBox??e.viewBox)}function Sa(e,t=pt){let n=Rt(e),r=Ye(e),o=Gx(n,r);if(!o)return{x:t.left,y:t.top,width:0,height:0};let i=Y(o.xMin,o.yMax,n,e,t),a=Y(o.xMax,o.yMin,n,e,t);return{x:i.x,y:i.y,width:Math.max(0,a.x-i.x),height:Math.max(0,a.y-i.y)}}function Wu(e,t,n={}){try{let r=le(e),o=Rt(e),i=Ye(e),a=Gu(t.left,t.top+t.height,o,e,r),s=Gu(t.left+t.width,t.top,o,e,r),c={xMin:a.x,xMax:s.x,yMin:a.y,yMax:s.y};if(!$u(c))return null;let l=e.graphViewBox!==void 0&&!$x(o,i),d=l?{xMin:c.xMin+(o.xMin-i.xMin),xMax:c.xMax+(o.xMax-i.xMax),yMin:c.yMin+(o.yMin-i.yMin),yMax:c.yMax+(o.yMax-i.yMax)}:c;if(!$u(d))return null;let u=le(e),m={...e,width:n.resizeToCrop?Math.max(1,t.width+u.left+u.right):e.width,height:n.resizeToCrop?Math.max(1,t.height+u.top+u.bottom):e.height,viewBox:zu(d),curves:e.curves.map(h=>zx(h,i,c))};return l?m.graphViewBox=zu(c):delete m.graphViewBox,m}catch{return null}}function Xu(e){let t=[];for(let n of e.curves)if(n.mode==="parametric"?n.expr||n.yExpr:n.expr)try{let o=Px(n,e);if(o&&wx(n,e,o)){t.push("\u66F2\u7DDA\u304C\u8868\u793A\u7BC4\u56F2\u306E\u5916\u306B\u3042\u308A\u307E\u3059\u3002\u8868\u793A\u7BC4\u56F2\u3092\u8ABF\u6574\u3057\u3066\u304F\u3060\u3055\u3044\u3002");break}}catch{}return t}function Bt(e){return ae(e,0)}function ke(e,t){if(e===void 0||e.trim()==="")return t;try{return Bt(e)}catch{return null}}function ae(e,t,n="x"){return xo(e,{[n]:t})}function Yu(e,t,n){let r=Xx(e);return r?xo(r.left,{x:t,y:n})-xo(r.right,{x:t,y:n}):xo(e,{x:t,y:n})}function xo(e,t){let r=new ba(e,t).parse();if(!Number.isFinite(r))throw new Error("Expression produced a non-finite value");return r}function Px(e,t){try{let n=Ye(t),r=it(e.mode);if(r==="implicit")return pn(e,"implicit",n)?(Yu(e.expr,(n.xMin+n.xMax)/2,(n.yMin+n.yMax)/2),{xMin:n.xMin,xMax:n.xMax,yMin:n.yMin,yMax:n.yMax}):null;let o=pn(e,r,n);if(!o)return null;let i=ka(e.samples??180,Vu,Uu),a=1/0,s=-1/0,c=1/0,l=-1/0,d=!1;for(let u=0;u<=i;u+=1){let m=o.min+(o.max-o.min)*u/i;try{let h;if(r==="parametric"){let y=e.yExpr?.trim();if(!y)continue;h={x:ae(e.expr,m,"t"),y:ae(y,m,"t")}}else{let y=ae(e.expr,m,o.variableName);h=r==="xOfY"?{x:y,y:m}:{x:m,y}}if(!Number.isFinite(h.x)||!Number.isFinite(h.y))continue;d=!0,a=Math.min(a,h.x),s=Math.max(s,h.x),c=Math.min(c,h.y),l=Math.max(l,h.y)}catch{}}return d?{xMin:a,xMax:s,yMin:c,yMax:l}:null}catch{return null}}function Du(e,t){return e.min<=t.max&&t.min<=e.max}var Tx=40,Ox=1e-9;function va(e,t,n,r,o){let i=t,a=n,s=null,c=Math.abs(r)*Ox;for(let l=0;l<Tx&&!(Math.abs(a-i)<=c);l+=1){let d=(i+a)/2,u=e(d);if(!u){a=d;continue}if(i=d,s=u,o(u))break}return s}function Ma(e,t,n=pt){try{let r=Rt(t),o=Ye(t),i=it(e.mode),a=t.width-n.left-n.right,s=t.height-n.top-n.bottom;if(a<=0||s<=0)return"";if(i==="implicit")return kx(e,t,r,o,n);let c=pn(e,i,o);if(!c)return"";let l=ka(e.samples??180,Vu,Uu),d=o.yMax-o.yMin,u=o.xMax-o.xMin,m=o.xMin-u*8,h=o.xMax+u*8,y=o.yMin-d*8,g=o.yMax+d*8,x=c.max-c.min,S=[],I=!1,R=M=>{try{if(i==="parametric"){let Q=e.yExpr?.trim();if(!Q)return null;let Z={x:ae(e.expr,M,"t"),y:ae(Q,M,"t")};return Number.isFinite(Z.x)&&Number.isFinite(Z.y)?Z:null}let D=ae(e.expr,M,c.variableName);return Number.isFinite(D)?i==="xOfY"?{x:D,y:M}:{x:M,y:D}:null}catch{return null}},P=M=>M.x>=m&&M.x<=h&&M.y>=y&&M.y<=g,C=M=>{let D=Y(M.x,M.y,r,t,n);S.push(`${I?"L":"M"}${dn(D.x)} ${dn(D.y)}`),I=!0},z=(M,D)=>va(R,M,D,x,Q=>!P(Q)),f=null;for(let M=0;M<=l;M+=1){let D=c.min+x*M/l,Q=R(D);if(!Q){if(f!==null){let Z=z(f,D);Z&&C(Z)}f=null,I=!1;continue}if(!P(Q)){f=D,I=!1;continue}if(f===null&&M>0){let Z=c.min+x*(M-1)/l,v=z(D,Z);v&&C(v)}C(Q),f=D}return S.join(" ")}catch{return""}}function wx(e,t,n){if(Ma(e,t).length===0)return!0;let o=Ye(t),i=Du({min:n.xMin,max:n.xMax},{min:o.xMin,max:o.xMax}),a=Du({min:n.yMin,max:n.yMax},{min:o.yMin,max:o.yMax});return!(i&&a)}function kx(e,t,n,r,o){let i=pn(e,"implicit",r);if(!i)return"";let a=ka(e.samples??bx,xx,gx),s=[];for(let l=0;l<=a;l+=1){let d=r.yMin+(r.yMax-r.yMin)*l/a,u=[];for(let m=0;m<=a;m+=1){let h=i.min+(i.max-i.min)*m/a;u.push({x:h,y:d,value:Bx(e.expr,h,d)})}s.push(u)}let c=[];for(let l=0;l<a;l+=1)for(let d=0;d<a;d+=1){let u=s[l][d],m=s[l][d+1],h=s[l+1][d+1],y=s[l+1][d],g=Rx([ho(u,m),ho(m,h),ho(h,y),ho(y,u)]);for(let x=0;x+1<g.length;x+=2){let S=Y(g[x].x,g[x].y,n,t,o),I=Y(g[x+1].x,g[x+1].y,n,t,o);Yx(S,I)<=.001||c.push(`M${dn(S.x)} ${dn(S.y)} L${dn(I.x)} ${dn(I.y)}`)}}return c.join(" ")}function Bx(e,t,n){try{return Yu(e,t,n)}catch{return Number.NaN}}function ho(e,t){if(!Number.isFinite(e.value)||!Number.isFinite(t.value))return null;let n=Math.abs(e.value)<=yo,r=Math.abs(t.value)<=yo;if(n&&r)return null;if(n)return{x:e.x,y:e.y};if(r)return{x:t.x,y:t.y};if(e.value>0==t.value>0)return null;let o=e.value/(e.value-t.value);if(!Number.isFinite(o)||o<-yo||o>1+yo)return null;let i=Math.min(1,Math.max(0,o));return{x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}}function Rx(e){let t=[];for(let n of e)n&&(t.some(r=>Math.abs(r.x-n.x)<1e-9&&Math.abs(r.y-n.y)<1e-9)||t.push(n));return t}function Y(e,t,n,r,o=pt){let i=r.width-o.left-o.right,a=r.height-o.top-o.bottom;return{x:o.left+(e-n.xMin)/(n.xMax-n.xMin)*i,y:o.top+(n.yMax-t)/(n.yMax-n.yMin)*a}}function Gu(e,t,n,r,o=pt){let i=r.width-o.left-o.right,a=r.height-o.top-o.bottom,s=i<=0?1:i,c=a<=0?1:a;return{x:n.xMin+(e-o.left)/s*(n.xMax-n.xMin),y:n.yMax-(t-o.top)/c*(n.yMax-n.yMin)}}function Ku(e,t,n,r=12){let o=t-e;if(!Number.isFinite(o)||o<=0)return[];let i=ke(n,null);(i===null||i<=0||!Number.isFinite(i))&&(i=Cx(o/Math.max(2,r-1)));let a=[],s=Math.ceil((e-1e-10)/i)*i,c=Math.min(r*5,80);for(let l=0;l<c;l+=1){let d=s+i*l;if(d>t+i*1e-6)break;d>=e-i*1e-6&&a.push(Ux(d))}return a}function Pa(e,t="number",n){if(t==="pi")return Hx(e);let r=Vx(n);return r!==null?Wx(e,r):wa(e)}function er(e,t=yx){return e&&hx.test(e)?e:t}function it(e){return e==="xOfY"||e==="parametric"||e==="implicit"?e:Sx}function Ax(e){return e==="dashed"||e==="dotted"?e:vx}function Ta(e){return!Number.isFinite(e)||e===void 0||e<.5||e>8?Mx:e}function Ix(e){let t=it(e.mode);if(t==="parametric"){let r=Nx(e);return Zu(r.xExpr,r.yExpr)}let n=e.label?.trim();return n||Ex(t,e.expr)}function Ex(e,t,n){let r=it(e);return r==="parametric"?Zu(t,n??""):r==="implicit"?t.includes("=")?t:`${t} = 0`:`${Lx(r)}${t}`}function ju(e){let t=Ax(e.dash);if(t==="solid")return;let n=Ta(e.strokeWidth);return t==="dashed"?`${xa(n*3)} ${xa(n*2)}`:`0 ${xa(n*2.2)}`}var AE=[{color:cn[0].value,dash:"solid"},{color:cn[0].value,dash:"dashed"},{color:cn[1].value,dash:"solid"},{color:cn[0].value,dash:"dotted"},{color:cn[1].value,dash:"dashed"}];function Oa(e){let t=ke(e.x,null),n=ke(e.y,null);return t===null||n===null?null:{x:t,y:n}}function qu(e){let t=e.showFormulaLabels===!1?[]:e.curves.map(r=>Ix(r)),n=(e.points??[]).map(r=>r.label).filter(Boolean);return[e.title,...t,...n].filter(Boolean).join(" ")}function Cx(e){if(!Number.isFinite(e)||e<=0)return 1;let n=10**Math.floor(Math.log10(e)),r=e/n;return r<=1?n:r<=2?2*n:r<=5?5*n:10*n}function Lx(e){return e==="xOfY"?"x = ":"y = "}function Zu(e,t){return`\\begin{cases} x = ${e} \\\\ y = ${t} \\end{cases}`}function Nx(e){return Fx(e.label?.trim()??"")??{xExpr:e.expr,yExpr:e.yExpr??""}}function Fx(e){if(!e)return null;let t=e.match(/^\\begin\{cases\}\s*x\s*=\s*(.*?)\s*\\\\\s*y\s*=\s*(.*?)\s*\\end\{cases\}$/);if(t)return{xExpr:t[1].trim(),yExpr:t[2].trim()};let n=e.match(/^x\s*=\s*(.*?)\s*,\s*y\s*=\s*(.*?)$/);return n?{xExpr:n[1].trim(),yExpr:n[2].trim()}:null}function _x(e){return e==="parametric"?"t":e==="xOfY"?"y":"x"}function Dx(e,t){return e==="xOfY"?{min:t.yMin,max:t.yMax}:e==="parametric"?{min:Bt(_u.min),max:Bt(_u.max)}:{min:t.xMin,max:t.xMax}}function pn(e,t,n){let r=_x(t),o=Dx(t,n),i=ke(e.domain?.min,o.min),a=ke(e.domain?.max,o.max);if(i===null||a===null)return null;let s=t==="parametric"?i:Math.max(o.min,i),c=t==="parametric"?a:Math.min(o.max,a);return s>=c?null:{min:s,max:c,variableName:r}}function Ju(e){let t=Bt(e.xMin),n=Bt(e.xMax),r=Bt(e.yMin),o=Bt(e.yMax);if(t>=n)throw new Error("xMin must be smaller than xMax");if(r>=o)throw new Error("yMin must be smaller than yMax");return{xMin:t,xMax:n,yMin:r,yMax:o}}function Gx(e,t){let n=Math.max(e.xMin,t.xMin),r=Math.min(e.xMax,t.xMax),o=Math.max(e.yMin,t.yMin),i=Math.min(e.yMax,t.yMax);return n>=r||o>=i?null:{xMin:n,xMax:r,yMin:o,yMax:i}}function $u(e){return Number.isFinite(e.xMin)&&Number.isFinite(e.xMax)&&Number.isFinite(e.yMin)&&Number.isFinite(e.yMax)&&e.xMin<e.xMax&&e.yMin<e.yMax}function $x(e,t){return go(e.xMin,t.xMin)&&go(e.xMax,t.xMax)&&go(e.yMin,t.yMin)&&go(e.yMax,t.yMax)}function go(e,t){return Math.abs(e-t)<1e-9}function zu(e){return{xMin:un(e.xMin),xMax:un(e.xMax),yMin:un(e.yMin),yMax:un(e.yMax)}}function zx(e,t,n){if(!e.domain)return e;let r=it(e.mode);if(r==="parametric")return e;let o=r==="xOfY"?t.yMin:t.xMin,i=r==="xOfY"?t.yMax:t.xMax,a=r==="xOfY"?n.yMin:n.xMin,s=r==="xOfY"?n.yMax:n.xMax,c=Hu(e.domain.min,o,a),l=Hu(e.domain.max,i,s);if(c===e.domain.min&&l===e.domain.max)return e;let d={...e.domain??{},...c===void 0?{}:{min:c},...l===void 0?{}:{max:l}};return{...e,domain:d}}function Hu(e,t,n){if(e===void 0||e.trim()==="")return e;let r=ke(e,null);return r===null?e:un(n+(r-t))}function un(e){return Math.abs(e)<1e-10?"0":Number(e.toFixed(6)).toString()}function wa(e){return Math.abs(e)<1e-9?"0":Number.isInteger(e)?String(e):Number(e.toFixed(3)).toString()}function Hx(e){if(Math.abs(e)<1e-9)return"0";let t=Math.PI/2,n=Math.round(e/t);if(Math.abs(e-n*t)>1e-5)return wa(e);let r=n<0?"-":"",o=Math.abs(n);if(o===1)return`${r}\\dfrac{\\pi}{2}`;if(o===2)return`${r}\\pi`;if(o%2===0){let i=o/2;return`${r}${i}\\pi`}return`${r}\\dfrac{${o}\\pi}{2}`}function Ux(e){return Math.abs(e)<1e-10?0:Number(e.toFixed(10))}function Vx(e){if(!e)return null;let t=e.trim().match(/^-?(\d+)\s*\/\s*(\d+)$/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=1||n===0)return null;let o=Qu(n,r),i=r/o;return i>1?i:null}function Wx(e,t){if(Math.abs(e)<1e-9)return"0";let n=e*t,r=Math.round(n);if(Math.abs(n-r)>1e-6)return wa(e);let o=r<0?"-":"",i=Math.abs(r),a=Qu(i,t),s=i/a,c=t/a;return c===1?`${o}${s}`:`${o}\\dfrac{${s}}{${c}}`}function Qu(e,t){let n=Math.abs(Math.round(e)),r=Math.abs(Math.round(t));for(;r>0;){let o=n%r;n=r,r=o}return n||1}function dn(e){return Number(e.toFixed(3))}function xa(e){return Number(e.toFixed(2))}function Xx(e){let t=e.split("=");if(t.length!==2)return null;let n=t[0].trim(),r=t[1].trim();return n&&r?{left:n,right:r}:null}function Yx(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function ka(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}var ba=class{constructor(t,n){this.input=t;this.variables=n;this.index=0}parse(){let t=this.parseAdditive();if(this.skipWhitespace(),this.index!==this.input.length)throw new Error(`Unexpected token at ${this.index}`);return t}parseAdditive(){let t=this.parseMultiplicative();for(;;)if(this.skipWhitespace(),this.consume("+"))t+=this.parseMultiplicative();else if(this.consume("-"))t-=this.parseMultiplicative();else return t}parseMultiplicative(){let t=this.parseUnary();for(;;)if(this.skipWhitespace(),this.consume("*"))t*=this.parseUnary();else if(this.consume("/"))t/=this.parseUnary();else if(this.startsImplicitFactor())t*=this.parseUnaryWithoutSign();else return t}parseUnary(){return this.skipWhitespace(),this.consume("+")?this.parseUnary():this.consume("-")?-this.parseUnary():this.parsePower()}parseUnaryWithoutSign(){return this.parsePower()}parsePower(){let t=this.parsePrimary();return this.skipWhitespace(),this.consume("^")?t**this.parseUnary():t}parsePrimary(){if(this.skipWhitespace(),this.consume("(")){let r=this.parseAdditive();if(this.skipWhitespace(),!this.consume(")"))throw new Error("Expected closing parenthesis");return r}let t=this.parseNumber();if(t!==null)return t;let n=this.parseIdentifier();if(n)return this.resolveIdentifier(n);throw new Error(`Expected value at ${this.index}`)}resolveIdentifier(t){let n=t.toLowerCase();if(this.skipWhitespace(),this.consume("(")){let o=this.parseAdditive();if(this.skipWhitespace(),!this.consume(")"))throw new Error("Expected closing parenthesis");return Kx(n,o)}let r=this.variables[n];if(r!==void 0)return r;if(n==="pi")return Math.PI;if(n==="e")return Math.E;throw new Error(`Unknown identifier ${t}`)}parseNumber(){let t=/^(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/i.exec(this.input.slice(this.index));return t?(this.index+=t[0].length,Number(t[0])):null}parseIdentifier(){let t=/^[a-zA-Z_][a-zA-Z0-9_]*/.exec(this.input.slice(this.index));return t?(this.index+=t[0].length,t[0]):null}consume(t){return this.input.startsWith(t,this.index)?(this.index+=t.length,!0):!1}skipWhitespace(){for(;/\s/.test(this.input[this.index]??"");)this.index+=1}startsImplicitFactor(){this.skipWhitespace();let t=this.input[this.index]??"";return t==="("||t==="."||/\d|[a-zA-Z_]/.test(t)}};function Kx(e,t){switch(e){case"abs":return Math.abs(t);case"acos":return Math.acos(t);case"asin":return Math.asin(t);case"atan":return Math.atan(t);case"cos":return Math.cos(t);case"exp":return Math.exp(t);case"ln":case"log":return Math.log(t);case"sin":return Math.sin(t);case"sqrt":return Math.sqrt(t);case"tan":return Math.tan(t);default:throw new Error(`Unknown function ${e}`)}}var bo="pt";function So(e="node"){let t=typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;return`${e}_${t}`}function ed(){return{measureMathLabel(e,t){let n=Nn({inlineContent:[{type:"mathInline",id:"graph_label_measurement",tex:e,display:"inline"}],fontSizePx:Ut(t)});return{width:n.w,height:n.h}},evaluateExpression:ae,createInlineMathId:()=>So("overlay_math")}}var jx="inline-math-node";var qx="math-preview";function tr({className:e,displayMode:t=!1,editing:n=!1,selected:r=!1,textSelected:o=!1}={}){return[jx,t?"display-math-node":"",r?"selected":"",o?"text-selected":"",n?"editing":"",e].filter(Boolean).join(" ")}function nr({id:e,tex:t,title:n=t}){return{"data-sigma-doc-math-inline":"",...e?{"data-id":e}:{},"data-tex":t,title:n}}function rr(e=!1,t){return[qx,e?"math-preview-display":"math-preview-inline",t].filter(Boolean).join(" ")}var Zx="sigma-underline-run",Jx=e=>e,Qx={margin:"0"},eb={margin:"0"};function vo(e,t={}){let n=t.runIdPrefix??"overlay",r=vi(e,{runIdPrefix:n}),o=[];return r.children.forEach((i,a)=>{if(i.kind!=="block")return;let s=`${n}-${a}`;o.push({inlineModel:i.children,inlineNodes:e.blocks[a]?.children??[],isBlank:i.isBlank===!0,key:s,selfContainedStyle:Qx,style:nb(i),tag:tb(i)})}),o}function nd(e){return e.isBlank?[]:od(e.inlineModel,{keyPrefix:e.key})}function tb(e){return e.blockType!=="heading"?"p":`h${e.headingLevel??3}`}function nb(e){let t={};return e.textAlign&&(t["text-align"]=e.textAlign),e.lineHeight&&(t["line-height"]=e.lineHeight),Object.keys(t).length>0?t:void 0}function rd(e,t){return od(Rr(e,{annotateBoxedRuns:!0,runIdPrefix:t.keyPrefix}).children,t)}function od(e,t){let n=[],r=[],o=()=>{if(r.length===0)return;let i=r[0],a=r[r.length-1];n.push({kind:"element",tag:"span",className:Zx,key:`${t.keyPrefix}-underline-run-${i.key}-${a.key}`,attrs:{"data-sigma-doc-underline-text":"true"},selfContainedStyle:fb(r.some(s=>s.entry.kind==="math")),children:r.map(s=>td(s,t))}),r=[]};for(let i of rb(e,t)){if(i.kind==="piece"&&Ra(i.entry.decorations,"underline")){r.push(i);continue}if(o(),i.kind==="break"){n.push({kind:"lineBreak",key:i.key});continue}n.push(td(i,t))}return o(),n}function rb(e,t){let n=t.resolveText??Jx,r=[];return e.forEach((o,i)=>{let a=o.sourceIndex??i;if(o.kind!=="text"){r.push({entry:o,key:`${a}-${o.id}`,kind:"piece"});return}let s=n(o.text).split(`
|
|
44
|
+
`),c=Aa(o.decorations,"box")?.run;s.forEach((l,d)=>{d>0&&r.push({key:`${t.keyPrefix}-${a}-br-${d}`,kind:"break"}),l.length>0&&r.push({entry:o,...c?{boxedRun:ob(c,d,s.length)}:{},key:`${a}-${d}`,kind:"piece",text:l})})}),r}function td(e,t){let n=e.entry,r=`${t.keyPrefix}-${e.key}`,o=ib(Aa(n.decorations,"box"),e.boxedRun),i=Nu(hb(Aa(n.decorations,"style")?.style)),a=n.kind==="text"?(e.text??"").length>0?[{kind:"text",key:`${r}-text`,text:e.text??""}]:[]:[ab(n,t)];return Ra(n.decorations,"italic")&&(a=[Ba("em",`${r}-em`,a)]),Ra(n.decorations,"bold")&&(a=[Ba("strong",`${r}-strong`,a)]),o&&(a=[sb(o,`${r}-boxed`,a,t)]),i?{kind:"element",tag:"span",key:`${r}-styled`,style:i,children:a}:a.length===1?a[0]:Ba("span",r,a)}function ob(e,t,n){return n<=1?e:{...e,connectLeft:t===0?e.connectLeft:!1,connectRight:t===n-1?e.connectRight:!1,segmentId:`${e.segmentId}-line-${t}`}}function ib(e,t){return!e||!t||t===e.run?e:{...e,connectLeft:t.connectLeft,connectRight:t.connectRight,run:t}}function ab(e,t){return{kind:"element",tag:"span",className:tr(),key:`${t.keyPrefix}-${e.id}-frame`,attrs:nr({id:e.id,tex:e.tex}),selfContainedStyle:eb,children:[{kind:"mathBody",key:`${t.keyPrefix}-${e.id}-body`,tex:e.tex}]}}function sb(e,t,n,r){let o=Cu({boxedPaddingY:e.paddingY,boxedTone:e.tone,boxedVariant:e.variant},{math:e.math}),i=e.run?r.alignmentStyles?.[e.run.segmentId]:void 0;return{kind:"element",tag:"span",className:o.className,key:t,attrs:{...o.attrs,...Lu(e.run)},style:mn(o.style,i),selfContainedStyle:lb(e),children:n}}function lb(e){let t={...cb};return e.math&&Object.assign(t,ub),e.run&&Object.assign(t,db),e.connectRight&&Object.assign(t,pb),e.connectLeft&&Object.assign(t,mb),t}var id={border:"var(--boxed-text-border-width, 1px) var(--boxed-text-border-style, solid) var(--boxed-text-border-color, currentColor)","border-radius":"var(--boxed-text-border-radius, 2px)","background-color":"var(--boxed-text-background, transparent)"},cb={"box-sizing":"border-box",display:"inline",...id,padding:"calc(var(--boxed-text-padding-y, 0px) + var(--boxed-run-extra-padding-y, 0px)) 0.18em","line-height":"var(--boxed-text-line-height, inherit)","box-decoration-break":"clone","-webkit-box-decoration-break":"clone"},ub={display:"inline-flex","align-items":"center","vertical-align":"baseline","line-height":"normal"},db={"box-sizing":"border-box",display:"inline-flex","align-items":"baseline",...id,padding:"calc(var(--boxed-text-padding-y, 0px) + var(--boxed-run-extra-padding-top, 0px)) 0.18em calc(var(--boxed-text-padding-y, 0px) + var(--boxed-run-extra-padding-bottom, 0px))","line-height":"1","vertical-align":"baseline","box-decoration-break":"clone","-webkit-box-decoration-break":"clone"},pb={"border-right-width":"0","border-top-right-radius":"0","border-bottom-right-radius":"0"},mb={"border-left-width":"0","border-top-left-radius":"0","border-bottom-left-radius":"0"};function fb(e){return e?{display:"inline-block","vertical-align":"baseline","max-width":"100%","text-decoration":"none","border-bottom":"1.25px solid currentColor","padding-bottom":"0.1em","box-decoration-break":"clone","-webkit-box-decoration-break":"clone"}:yb()}function yb(){return{"text-decoration-line":"underline","text-decoration-thickness":"1px","text-decoration-color":"currentColor","text-underline-offset":"0.12em","text-decoration-skip-ink":"auto"}}function Ba(e,t,n){return{kind:"element",tag:e,key:t,children:n}}function hb(e){return{backgroundColor:e?.backgroundColor,color:e?.color,fontFamily:e?.fontFamily,fontSizePt:e?.fontSizePt}}function Ra(e,t){return e.some(n=>n.type===t)}function Aa(e,t){return e.find(n=>n.type===t)}function mn(...e){let t={};for(let n of e)n&&Object.assign(t,n);return Object.keys(t).length>0?t:void 0}function Ia(e,t){return vo(e,{runIdPrefix:t.runIdPrefix}).map(n=>{let r=t.selfContained?mn(n.selfContainedStyle,n.style):n.style,o=n.isBlank?"<br/>":ad({kind:"element",tag:"span",className:"rich-inline-content",key:n.key,children:nd(n)},t);return`<${n.tag}${sd(r)}>${o}</${n.tag}>`}).join("")}function ad(e,t){if(e.kind==="text")return ge(e.text);if(e.kind==="lineBreak")return"<br/>";if(e.kind==="mathBody")return[`<span class="${rr()}" data-empty="${e.tex?"false":"true"}">`,t.renderMathHtml(e.tex),"</span>"].join("");let n=t.selfContained?mn(e.selfContainedStyle,e.style):e.style,r=e.className?` class="${K(e.className)}"`:"",o=e.children.map(i=>ad(i,t)).join("");return`<${e.tag}${r}${gb(e.attrs)}${sd(n)}>${o}</${e.tag}>`}function gb(e){return e?Object.entries(e).map(([t,n])=>` ${t}="${K(n)}"`).join(""):""}function sd(e){if(!e)return"";let t=Object.entries(e).filter(([,n])=>et(n)).map(([n,r])=>`${n}:${r}`).join(";");return t?` style="${K(t)}"`:""}function ge(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function K(e){return ge(e).replace(/"/g,""")}var xb=new Set(["span","svg","path","line","br","circle","ellipse","g","polygon","polyline","rect"]),bb=new Set(["aria-hidden","class","part","style","cx","cy","d","fill","fill-opacity","fill-rule","height","opacity","points","preserveAspectRatio","r","rx","ry","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-width","transform","vector-effect","viewBox","width","x","x1","x2","xmlns","y","y1","y2"]),ld=new Set(["br"]),cd=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)((?:\s+[a-zA-Z_:][a-zA-Z0-9_:.-]*(?:\s*=\s*(?:"[^"<]*"|'[^'<]*'|[^\s"'`=<>]+))?)*)\s*(\/?)>/y,ud=/([a-zA-Z_:][a-zA-Z0-9_:.-]*)(?:\s*=\s*(?:"([^"<]*)"|'([^'<]*)'|([^\s"'`=<>]+)))?/g,dd=/&(?:amp|lt|gt|quot|apos|#\d{1,7}|#[xX][0-9a-fA-F]{1,6});/g,Sb=new Set(["--bg-color","background-color","border","border-bottom-width","border-radius","border-right-width","border-style","border-top-width","border-width","bottom","box-sizing","color","display","font-size","height","left","line-height","margin-left","margin-right","margin-top","min-width","opacity","overflow","padding-left","padding-right","pointer-events","position","top","vertical-align","width","z-index","border-bottom","border-color","border-left","border-left-width","border-right","border-top","font-family","font-style","font-weight","letter-spacing","margin-bottom","max-height","max-width","min-height","padding-bottom","padding-top","right","text-align","text-decoration","visibility","white-space"]),vb=new Set(["absolute","relative","static"]),Mb={"z-index":10},Pb=20,Sd={"":1,em:1,rem:1,pc:1,ex:.5,ch:.5,px:1/16,pt:1/12,cm:2.3622,mm:.23622,q:.05906,in:6},vd=.01,La=.5,Tb=new Set(["height","max-height","min-height","margin-bottom","margin-left","margin-right","margin-top","padding-bottom","padding-left","padding-right","padding-top"]),Ob=new Set(["--bg-color","background-color","border-color","border-style","box-sizing","color","display","font-family","font-style","font-weight","line-height","opacity","overflow","pointer-events","position","text-align","text-decoration","visibility","white-space","z-index"]),Md=20,pd=20,Ea=2,Ca=320,Pd=new Set(["d","points","transform"]),wb=new Set(["cx","cy","height","r","rx","ry","width","x","x1","x2","y","y1","y2"]),md=/-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?/g,kb=new Set(["stroke-width","stroke-dasharray"]),Bb=new Set(["cx","rx","width","x","x1","x2"]),Rb=new Set(["cy","height","ry","y","y1","y2"]),fd=/(?<![#\w.])([-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?)(%|[a-z]+)?/gi,Ab=/[\u0000-\u001f\u007f-\u009f]/u,Ib=/[\\;{}<>]/u,Eb=/(?:url\s*\(|min\s*\(|max\s*\(|clamp\s*\(|attr\s*\(|env\s*\(|@import\b|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:|\/\*|\d\s*(?:[sldp]?v(?:h|w|i|b|min|max)|cq(?:w|h|i|b|min|max))\b)/iu,Cb=16,yd=/(?<![\w-])(-webkit-|-moz-)?([a-z][a-z0-9-]*)\s*\(/gi,Lb=new Set(["calc","var"]),hd=/(?<![\w-])(?:-webkit-|-moz-)?calc\s*\(/gi,Nb=2048,Fb=[/^ML__[A-Za-z0-9_-]+$/,/^katex(?:-[a-z]+)*$/,/^(?:reset-)?size\d{1,2}$/,/^delim-size\d$/,/^col-align-[a-z]$/,/^slice-\d+-of-\d+$/],_b=new Set([...ma,"accent","accent-body","allowbreak","amsrm","arraycolsep","base","boxpad","brace-center","brace-left","brace-right","cjk_fallback","colorbox","delimcenter","delimsizing","fbox","fix","frac-line","hide-tail","hline","inner","large-op","lcGreek","mathbb","mathbf","mathcal","mathdefault","mathfrak","mathit","mathnormal","mathrm","mathscr","mathsf","mathtt","mbin","mclose","mfrac","minner","mop","mopen","mord","mover","mpunct","mrel","mspace","msupsub","mtable","mtight","mult","munder","newline","nobreak","nulldelimiter","op-limits","op-symbol","overlay","overline","overline-line","pstrut","rlap","root","rule","sizing","small-op","smash","sout","sqrt","sqrt-line","sqrt-sign","stretchy","strut","svg-align","text","textbf","textit","textrm","textsf","texttt","textup","thinbox","underline","underline-line","vbox","vertical-separator","vlist","vlist-r","vlist-s","vlist-t","vlist-t2","x-arrow","x-arrow-pad"]),Db=/^[\w\-. ]*$/,Gb=/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/u;function To(e){let t="",n=0,r=!0,o=0,i=[],a=[],s=[];for(;n<e.length;){let c=e.indexOf("<",n);if(c<0){t+=Mo(e.slice(n));break}t+=Mo(e.slice(n,c)),cd.lastIndex=c;let l=cd.exec(e);if(!l){t+="<",n=c+1;continue}let[d,u,m,h,y]=l;n=c+d.length;let g=m.toLowerCase();if(!xb.has(g)){t+=Mo(d);continue}if(u){if(ld.has(g)){t+=Mo(d);continue}i.pop()!==g&&(r=!1),a.pop(),g==="svg"&&(o=Math.max(0,o-1),s.pop()),t+=`</${g}>`;continue}let x=a[a.length-1]??1,S=s[s.length-1]??null,{fontScale:I,serialized:R,viewBox:P}=$b(h,g,x,g==="svg"&&S===null?null:S),C=y==="/"&&(o>0||g==="svg");if(ld.has(g)||C){t+=`<${g}${R}/>`;continue}t+=`<${g}${R}>`,i.push(g),a.push(I),g==="svg"&&(o+=1,s.push(zb(P)))}return{html:t,safe:r&&i.length===0}}function $b(e,t,n,r){if(!e.trim())return{fontScale:n,serialized:"",viewBox:null};ud.lastIndex=0;let o=[...e.matchAll(ud)],i=o.find(h=>h[1]==="style"),a=i?.[2]??i?.[3]??i?.[4]??"",s=i&&!gd(a)?Xb(a,n):{fontScale:n,safe:!1},c=Math.max(1,s.safe?s.fontScale:n),l=new Set,d="",u=null,m=t!=="svg"||o.some(h=>h[1]==="height")||/(?:^|;)\s*height\s*:/i.test(a);for(let h of o){let y=h[1];if(!bb.has(y)||l.has(y))continue;let g=h[2]??h[3]??h[4]??"";if(gd(g))continue;if(y==="style"){if(!s.safe||r!==null)continue;l.add(y),d+=` ${y}="${g}"`;continue}if(y==="viewBox"&&t==="svg"&&(u=g),!Ub(y,g,t,c,r,m))continue;let x=y==="class"?Vb(g):g;x!==null&&(l.add(y),d+=` ${y}="${x}"`)}return{fontScale:c,serialized:d,viewBox:u}}function zb(e){let t={extent:Ca,x:Ca,y:Ca};if(!e)return t;let n=e.trim().split(/[\s,]+/).map(Number);return n.length!==4||n.some(r=>!Number.isFinite(r))||n[2]<=0||n[3]<=0?t:{extent:Math.max(n[2],n[3])*Ea,x:n[2]*Ea,y:n[3]*Ea}}function Hb(e,t,n){if(e==="transform"||!Pd.has(e)&&/[a-z%]/i.test(t))return!1;let r=Bb.has(e)?n.x:Rb.has(e)?n.y:n.extent;md.lastIndex=0;for(let o of t.matchAll(md)){let i=Math.abs(Number(o[0]));if(!Number.isFinite(i)||i>r)return!1}return!0}function gd(e){return/[<>&"]/.test(e)||Gb.test(e)}function Ub(e,t,n,r,o,i){if(n==="svg"&&e==="transform")return!1;if(o!==null&&(Pd.has(e)||wb.has(e)||kb.has(e)))return Hb(e,t,o);if(n==="svg"&&e==="width"&&!i){let a=Po(t.trim().toLowerCase(),La);return a!==null&&a*r<=pd}if(n==="svg"&&e==="height"){let a=Po(t.trim().toLowerCase(),La);return a!==null&&a*r<=pd}return!0}function Vb(e){if(!Db.test(e))return null;let t=e.split(" ").filter(n=>n&&Wb(n));return t.length>0?t.join(" "):null}function Wb(e){return _b.has(e)||Fb.some(t=>t.test(e))}function Xb(e,t){if(e.length>Nb)return{fontScale:t,safe:!1};let n=e.split(";"),r=t*Yb(n,t);return{fontScale:r,safe:n.every(o=>Kb(o,{effective:r,inherited:t}))}}function Yb(e,t){let n=1;for(let r of e){let o=r.indexOf(":");if(o<=0||r.slice(0,o).trim().toLowerCase()!=="font-size")continue;let i=r.slice(o+1).trim().toLowerCase(),a=Td(i)?Po(i,vd):null;n=a===null||a<=0||t*a>Md?1:a}return n}function Td(e){return/\d/.test(e)}function Kb(e,t){let n=e.trim();if(!n)return!0;if(Ab.test(n)||Ib.test(n)||Eb.test(n))return!1;let r=n.indexOf(":");if(r<=0)return!1;let o=n.slice(0,r).trim().toLowerCase(),i=n.slice(r+1).trim().toLowerCase();if(!Sb.has(o)||!i)return!1;if(o==="position")return vb.has(i);if(o==="z-index"){let l=Number(i);if(!Number.isInteger(l)||l<0)return!1}let a=!Ob.has(o);if(a&&/(?<![\w-])var\s*\(/i.test(i))return!1;let s=Po(i,jb(o));if(s===null)return!1;if(o==="font-size")return Td(i)&&s>0&&s*t.inherited<=Md;let c=Mb[o]??Pb;return s*(a?t.effective:1)<=c}function jb(e){return Tb.has(e)?La:vd}function Po(e,t){yd.lastIndex=0;for(let o of e.matchAll(yd))if(!Lb.has(o[2].toLowerCase()))return null;let n=qb(e,t);if(n===null)return null;let r=0;fd.lastIndex=0;for(let o of n.matchAll(fd)){let i=(o[2]??"").toLowerCase(),a=i==="%"?t:Sd[i];if(a===void 0)return null;let s=Math.abs(Number(o[1])*a);if(!Number.isFinite(s))return null;r=Math.max(r,s)}return r}function qb(e,t){let n="",r=0;for(;;){hd.lastIndex=r;let o=hd.exec(e);if(!o)return n+e.slice(r);let i=o.index+o[0].length-1,a=Zb(e,i);if(a<0)return null;let s=Jb(e.slice(i+1,a),t);if(s===null)return null;n+=`${e.slice(r,o.index)}${s}`,r=a+1}}function Zb(e,t){let n=0;for(let r=t;r<e.length;r+=1)if(e[r]==="(")n+=1;else if(e[r]===")"&&(n-=1,n===0))return r;return-1}function Jb(e,t){let n={index:0,percent:t,text:e},r=Od(n,0);return r===null?null:(or(n),n.index===e.length&&Number.isFinite(r)?r:null)}function Od(e,t){let n=xd(e,t);if(n===null)return null;for(;;){or(e);let r=e.text[e.index];if(r!=="+"&&r!=="-")return n;e.index+=1;let o=xd(e,t);if(o===null)return null;n=r==="+"?n+o:n-o}}function xd(e,t){let n=bd(e,t);if(n===null)return null;for(;;){or(e);let r=e.text[e.index];if(r!=="*"&&r!=="/")return n;e.index+=1;let o=bd(e,t);if(o===null||r==="/"&&o===0)return null;n=r==="*"?n*o:n/o}}function bd(e,t){if(t>Cb)return null;or(e);let n=e.text.slice(e.index),r=/^(?:-webkit-|-moz-)?calc\s*\(/i.exec(n)??/^\(/.exec(n);if(r){e.index+=r[0].length;let l=Od(e,t+1);return l===null||(or(e),e.text[e.index]!==")")?null:(e.index+=1,l)}let o=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?/.exec(n);if(!o)return null;e.index+=o[0].length;let i=/^(?:%|[a-z]+)/i.exec(e.text.slice(e.index));i&&(e.index+=i[0].length);let a=(i?.[0]??"").toLowerCase(),s=a==="%"?e.percent:Sd[a];if(s===void 0)return null;let c=Number(o[0])*s;return Number.isFinite(c)?c:null}function or(e){for(;e.index<e.text.length&&/\s/.test(e.text[e.index]);)e.index+=1}function Mo(e){let t="",n=0;dd.lastIndex=0;for(let r of e.matchAll(dd))t+=ge(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+ge(e.slice(n))}function at(e,t){let n=Le(t,e),r=At.get(n);if(r!==void 0)return At.delete(n),At.set(n,r),r;let o=eS(e,t);if(At.size>=Qb){let i=At.keys().next().value;i!==void 0&&At.delete(i)}return At.set(n,o),o}function wd(e,t){return!at(e,t).startsWith(kd)}var At=new Map,Qb=5e3,kd='<span data-math-unrendered="true">';function eS(e,t){try{let n=po(e,t),r=To(n);if(r.safe)return r.html}catch{}return`${kd}${ge(e)}</span>`}var tS="data-list-marker-typography",nS="--sigma-doc-list-marker-font-family",rS="--sigma-doc-list-marker-font-size",oS=/[;{}<>\n\r]|\/\*|\*\//;function iS(e){if(!e)return;let t={};e.fontFamily&&!oS.test(e.fontFamily)&&(t[nS]=e.fontFamily);let{fontSizePt:n}=e;return n!==void 0&&Number.isFinite(n)&&n>0&&(t[rS]=`${n}pt`),Object.keys(t).length>0?t:void 0}function Bd(e){let t=iS(Ks(js(e)));return t?{attrs:{[tS]:""},style:t}:void 0}import{memo as AS}from"react";import{Fragment as pS,memo as mS,useEffect as fS,useLayoutEffect as yS,useMemo as hS,useRef as gS,useState as xS}from"react";import{memo as uS}from"react";import{createContext as aS,useContext as sS,useMemo as lS}from"react";import{jsx as cS}from"react/jsx-runtime";var Rd=aS(sn);function fn({children:e,environment:t}){return cS(Rd.Provider,{value:t,children:e})}function It(){return sS(Rd)}function Na(e){let t=It();return lS(()=>e==null?t:bu(t,Br(e)),[t,e])}import{jsx as dS}from"react/jsx-runtime";var Fa=uS(function({tex:t,displayMode:n=!1,className:r,mathFractionSizing:o}){wt("MathPreview.render");let i=Na(o),a=at(t,i),s=rr(n,r);return dS("span",{className:s,dangerouslySetInnerHTML:{__html:a},"data-empty":t?"false":"true"})});import{jsx as ir}from"react/jsx-runtime";var _a='[data-boxed-run-height-target="true"][data-boxed-run-segment-id]',bS=.5,Ad=100,SS=typeof window>"u"?fS:yS;function Da(e){return xi(e)}function yn(e){let t=gS(null),[n,r]=xS({});return SS(()=>{let o=t.current;if(!o||typeof window>"u")return;let i=!1,a=!1,s=null,c=null,l=null,d=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>y()),u=typeof MutationObserver>"u"?null:new MutationObserver(()=>y()),m=()=>{d?.disconnect(),d?.observe(o),o.querySelectorAll(_a).forEach(g=>{d?.observe(g)})},h=()=>{a=!0,o.classList.add("boxed-run-measuring");try{let g=TS(o);r(x=>RS(x,g)?x:g)}finally{o.classList.remove("boxed-run-measuring"),m(),c=window.requestAnimationFrame(()=>{c=null,l=window.requestAnimationFrame(()=>{l=null,a=!1})})}};function y(){i||a||s!==null||(s=window.requestAnimationFrame(()=>{s=null,h()}))}return m(),u?.observe(o,{attributes:!0,attributeFilter:["class","data-sigma-doc-boxed-padding-y","data-sigma-doc-boxed-variant","data-sigma-doc-boxed-tone"],childList:!0,characterData:!0,subtree:!0}),window.addEventListener("resize",y),y(),()=>{i=!0,s!==null&&window.cancelAnimationFrame(s),c!==null&&window.cancelAnimationFrame(c),l!==null&&window.cancelAnimationFrame(l),d?.disconnect(),u?.disconnect(),window.removeEventListener("resize",y)}},[e]),{aligned:Object.keys(n).length>0,alignmentStyles:n,ref:t}}function xe(e,t={}){let n=t.keyPrefix??"inline";return vS(rd(e,{alignmentStyles:t.alignmentStyles,keyPrefix:n,resolveText:t.resolveText}),t)}function vS(e,t){return e.map(n=>Ed(n,t))}function Ed(e,t){if(e.kind==="text")return ir(pS,{children:e.text},e.key);if(e.kind==="lineBreak")return ir("br",{},e.key);if(e.kind==="mathBody")return ir(Fa,{tex:e.tex,mathFractionSizing:t.mathFractionSizing},e.key);let n=e.tag,r=t.selfContained?mn(e.selfContainedStyle,e.style):e.style;return ir(n,{className:e.className,style:MS(r),...e.attrs,children:e.children.map(o=>Ed(o,t))},e.key)}function MS(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))et(r)&&(t[n.startsWith("--")?n:PS(n)]=r);return t}function PS(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function TS(e){let t=OS(e),n=Xs(t),r={};for(let[o,i]of n)r[o.segmentId]={"--boxed-run-extra-padding-bottom":`${wo(i.extraPaddingBottom)}px`,"--boxed-run-extra-padding-top":`${wo(i.extraPaddingTop)}px`,"--boxed-run-own-height":`${wo(i.ownHeight)}px`,"--boxed-run-target-height":`${wo(i.targetHeight)}px`};return r}function OS(e){let t=[],n=Fu(e),r=o=>{for(let i of Array.from(o.childNodes)){if(i.nodeType===Node.TEXT_NODE){Gt(i.textContent??"")&&i instanceof Text&&t.push(...wr(wS(i),n));continue}if(!(!(i instanceof HTMLElement)||kS(i))){if(i.matches(_a)){let a=i.getAttribute("data-boxed-run-segment-id");a&&t.push(...wr(Id(i),n).map(s=>({...s,boxedTarget:{segmentId:a}})));continue}if(i.tagName!=="BR"){if(i.querySelector(_a)){r(i);continue}BS(i)&&t.push(...wr(Id(i),n))}}}};return r(e),t}function wS(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let n=Cd(t);return t.detach(),n}function Id(e){let t=Cd(e);return t.length>0?t:Ld(e.getBoundingClientRect())}function Cd(e){return Array.from(e.getClientRects()).flatMap(Ld)}function Ld(e){return!Number.isFinite(e.top)||!Number.isFinite(e.bottom)||!Number.isFinite(e.height)||e.height<=0?[]:[{top:e.top,bottom:e.bottom,height:e.height}]}function kS(e){return e.getAttribute("aria-hidden")==="true"||e.hidden}function BS(e){return Gt(e.textContent??"")||e.getBoundingClientRect().width>0||e.getBoundingClientRect().height>0}function RS(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length||!n.every(o=>t[o]!==void 0)?!1:n.every(o=>Oo(st(e[o],"--boxed-run-extra-padding-bottom"),st(t[o],"--boxed-run-extra-padding-bottom"))&&Oo(st(e[o],"--boxed-run-extra-padding-top"),st(t[o],"--boxed-run-extra-padding-top"))&&Oo(st(e[o],"--boxed-run-own-height"),st(t[o],"--boxed-run-own-height"))&&Oo(st(e[o],"--boxed-run-target-height"),st(t[o],"--boxed-run-target-height")))}function st(e,t){let n=e[t];if(typeof n=="number")return n;if(typeof n=="string"){let r=Number.parseFloat(n);return Number.isFinite(r)?r:0}return 0}function Oo(e,t){return Math.abs(e-t)<=bS}function wo(e){return Math.round(e*Ad)/Ad}var Ga=mS(function({nodes:t,className:n,keyPrefix:r,mathFractionSizing:o}){let i=["rich-inline-content",n].filter(Boolean).join(" "),a=hS(()=>xi(t),[t]),{aligned:s,alignmentStyles:c,ref:l}=yn(a);return ir("span",{ref:l,className:i,"data-boxed-run-aligned":s?"true":void 0,children:xe(t,{alignmentStyles:c,keyPrefix:r,mathFractionSizing:o})})});import{Fragment as CS,jsx as Nd}from"react/jsx-runtime";var IS=AS(function({title:t,nodes:n}){let r=It(),o=n===void 0?bi(t):n;return!o||!ES(o,r)?Nd(CS,{children:t}):Nd("span",{className:"rich-inline-content document-title-rich",children:xe(o,{keyPrefix:"doc-title"})})});function ES(e,t){return e.every(n=>n.type!=="mathInline"||wd(n.tex,t))}import sv from"katex";import{memo as lv,useState as Ka,useRef as hn,useEffect as cv,useId as uv,useMemo as sr}from"react";var Va=32,Io=360,Wa=220,q=1e-6,$a=.08,Lo=.25,No=2,LS=.08,NS=.35,za=2.4,ar=1e-5;function Ud(e,t,n=le(e)){let r=tv(t);return r?FS(e,r,n)?.path??"":""}function FS(e,t,n=le(e)){if(e.kind!=="cartesian")return null;let r,o;try{r=Rt(e),o=Ye(e)}catch{return null}let i=rv(r,o);if(!i||!nv(i,t))return null;let a=Y(t.x,t.y,r,e,n),s=_S(e,r,i,n);if(s.length<4)return null;let c=WS(s),l=YS(c),d=qS(jS(c)),u=GS(e,t,r,i,n),m=Dd(a,s,NS);if(m.length>0){if(m.length>1||m.some(I=>I.kind!=="axis"&&Ya(a,I)<=LS))return null;let S=_d(a,l,za,d);return S.openFaceRejected?null:Ro([S.face,u])}let h=Ha(a,l,d);if(h.openFaceRejected)return null;let y=Ro([h.face,u]);if(y)return y;if(Dd(a,s,za).filter(x=>x.kind==="axis").length===1){let x=_d(a,l,za*2,d);return Ro([x.face,u])}return null}function _S(e,t,n,r){let o=Y(n.xMin,n.yMax,t,e,r),i=Y(n.xMax,n.yMax,t,e,r),a=Y(n.xMax,n.yMin,t,e,r),s=Y(n.xMin,n.yMin,t,e,r),c=[{a:o,b:i,kind:"frame"},{a:i,b:a,kind:"frame"},{a,b:s,kind:"frame"},{a:s,b:o,kind:"frame"}];e.axes.showX!==!1&&n.yMin<0&&n.yMax>0&&c.push({a:Y(n.xMin,0,t,e,r),b:Y(n.xMax,0,t,e,r),kind:"axis"}),e.axes.showY!==!1&&n.xMin<0&&n.xMax>0&&c.push({a:Y(0,n.yMin,t,e,r),b:Y(0,n.yMax,t,e,r),kind:"axis"});for(let l of e.curves)c.push(...DS(l,e,t,n,r));return c}function DS(e,t,n,r,o){let i=it(e.mode);if(i==="implicit")return[];let a=pn(e,i,r);if(!a)return[];let s=Co(e.samples??Wa,Va,Io),c=r.xMax-r.xMin,l=r.yMax-r.yMin,d=r.xMin-c*8,u=r.xMax+c*8,m=r.yMin-l*8,h=r.yMax+l*8,y=a.max-a.min,g=[],x=C=>{try{if(i==="parametric"){let f=e.yExpr?.trim();if(!f)return null;let M={x:ae(e.expr,C,"t"),y:ae(f,C,"t")};return Number.isFinite(M.x)&&Number.isFinite(M.y)?M:null}let z=ae(e.expr,C,a.variableName);return Number.isFinite(z)?i==="xOfY"?{x:z,y:C}:{x:C,y:z}:null}catch{return null}},S=C=>C.x>=d&&C.x<=u&&C.y>=m&&C.y<=h,I=(C,z)=>va(x,C,z,y,f=>!S(f)),R=(C,z)=>{if(!S(C)&&!S(z))return;let f=VS(C,z,r);f&&g.push({a:Y(f.a.x,f.a.y,n,t,o),b:Y(f.b.x,f.b.y,n,t,o),kind:"curve"})},P=null;for(let C=0;C<=s;C+=1){let z=a.min+y*C/s,f=x(z);if(!f){if(P){let M=I(P.independentValue,z);M&&R(P.point,M)}P=null;continue}if(P)R(P.point,f);else if(C>0){let M=a.min+y*(C-1)/s,D=I(z,M);D&&R(D,f)}P={independentValue:z,point:f}}return g}function GS(e,t,n,r,o){let i=[];for(let a of e.curves){let s=it(a.mode);if(s==="parametric"||s==="implicit")continue;if(s==="xOfY"){let l=[r.xMin,r.xMax];e.axes.showY!==!1&&r.xMin<0&&r.xMax>0&&l.push(0);for(let d of l){let u=Fd(a,s,d,t,n,r,e,o);u&&i.push(u)}continue}let c=[r.yMin,r.yMax];e.axes.showX!==!1&&r.yMin<0&&r.yMax>0&&c.push(0);for(let l of c){let d=Fd(a,s,l,t,n,r,e,o);d&&i.push(d)}}return Ro(i)}function Fd(e,t,n,r,o,i,a,s){let c=US(e,t,i);if(!c)return null;let l=t==="xOfY"?r.y:r.x;if(l<=c.min+q||l>=c.max-q)return null;let d;try{d=ae(e.expr,l,c.variableName)}catch{return null}if(!Number.isFinite(d)||t==="xOfY"&&(d<i.xMin-q||d>i.xMax+q)||t==="yOfX"&&(d<i.yMin-q||d>i.yMax+q)||!av(t==="xOfY"?r.x:r.y,n,d))return null;let u=zS(e,t,n,c,l,$S(t,a,o,s));for(let m=0;m<u.length-1;m+=1){let h=u[m],y=u[m+1];if(l<=h+ar||l>=y-ar)continue;let g=HS(e,t,n,h,y,c,o,i,a,s);if(g.length<3)continue;let x=Math.abs(Wd(g)),S=Y(r.x,r.y,o,a,s);if(x>No&&Xa(S,g))return{polygon:g,area:x,path:Vd(g)}}return null}function $S(e,t,n,r){let o=e==="xOfY"?(t.width-r.left-r.right)/Math.max(n.xMax-n.xMin,q):(t.height-r.top-r.bottom)/Math.max(n.yMax-n.yMin,q);return o>q?Lo/o:0}function zS(e,t,n,r,o,i){let a=Co(e.samples??Wa,Va,Io),s=zd([r.min,r.max,o,...Array.from({length:a+1},(u,m)=>r.min+(r.max-r.min)*m/a)]),c=[],l=null,d=null;for(let u of s){let m;try{m=ae(e.expr,u,r.variableName)}catch{l=null,d=null;continue}if(!Number.isFinite(m)){l=null,d=null;continue}let h=m-n;if(Math.abs(h)<=q&&c.push(u),d&&d.delta*h<0){let y=d.delta/(d.delta-h);c.push(d.independent+(u-d.independent)*y)}l&&d&&l.delta*h>0&&Math.abs(d.delta)<=i&&Math.abs(d.delta)<=Math.abs(l.delta)&&Math.abs(d.delta)<=Math.abs(h)&&c.push(d.independent),l=d,d={independent:u,delta:h}}return zd(c).filter(u=>u>=r.min-ar&&u<=r.max+ar)}function HS(e,t,n,r,o,i,a,s,c,l){let d=Co(e.samples??Wa,Va,Io),u=(o-r)/Math.max(i.max-i.min,q),m=Co(Math.ceil(d*u),8,Io),h=[];t==="xOfY"?h.push({x:n,y:r},{x:n,y:o}):h.push({x:r,y:n},{x:o,y:n});for(let y=m;y>=0;y-=1){let g=r+(o-r)*y/m,x;try{x=ae(e.expr,g,i.variableName)}catch{continue}if(!Number.isFinite(x))continue;let S=t==="xOfY"?{x:Hd(x,s.xMin,s.xMax),y:g}:{x:g,y:Hd(x,s.yMin,s.yMax)};(y===m||y===0)&&(t==="xOfY"?S.x=n:S.y=n),h.push(S)}return h.map(y=>Y(y.x,y.y,a,c,l))}function US(e,t,n){let r=t==="xOfY"?"y":"x",o=t==="xOfY"?{min:n.yMin,max:n.yMax}:{min:n.xMin,max:n.xMax},i=ke(e.domain?.min,o.min)??o.min,a=ke(e.domain?.max,o.max)??o.max,s=Math.max(o.min,i),c=Math.min(o.max,a);return s>=c?null:{min:s,max:c,variableName:r}}function VS(e,t,n){let r=0,o=1,i=t.x-e.x,a=t.y-e.y,s=(c,l)=>{if(Math.abs(c)<q)return l>=-q;let d=l/c;if(c<0){if(d>o)return!1;d>r&&(r=d)}else{if(d<r)return!1;d<o&&(o=d)}return!0};return!s(-i,e.x-n.xMin)||!s(i,n.xMax-e.x)||!s(-a,e.y-n.yMin)||!s(a,n.yMax-e.y)||o-r<=q?null:{a:{x:e.x+i*r,y:e.y+a*r},b:{x:e.x+i*o,y:e.y+a*o}}}function WS(e){let t=e.map(()=>[{t:0},{t:1}]);for(let u=0;u<e.length;u+=1)for(let m=u+1;m<e.length;m+=1){let h=e[u],y=e[m],g=ev(h,y);g&&(t[u].push({t:g.t,point:g.point}),t[m].push({t:g.u,point:g.point})),XS(h,y,t[u],t[m])}let n=new Map,r=new Map,o=new Set,i=[],a=new Map,s=0,c=(u,m)=>`${u}:${m}`,l=u=>{let m=Math.floor(u.x/$a),h=Math.floor(u.y/$a),y=null,g=$a;for(let R=-1;R<=1;R+=1)for(let P=-1;P<=1;P+=1){let C=a.get(c(m+R,h+P));if(C)for(let z of C){let f=Ua(z.point,u);f<g&&(y=z,g=f)}}if(y)return y;s+=1;let x={key:`v${s}`,point:u};n.set(x.key,x),r.set(x.key,[]);let S=c(m,h),I=a.get(S);return I||(I=[],a.set(S,I)),I.push(x),x},d=(u,m)=>{if(u.key===m.key)return;let h=u.key<m.key?`${u.key}|${m.key}`:`${m.key}|${u.key}`;o.has(h)||(o.add(h),i.push({a:u.point,b:m.point,fromKey:u.key,toKey:m.key}),r.get(u.key)?.push({key:m.key,angle:Math.atan2(m.point.y-u.point.y,m.point.x-u.point.x)}),r.get(m.key)?.push({key:u.key,angle:Math.atan2(u.point.y-m.point.y,u.point.x-m.point.x)}))};e.forEach((u,m)=>{let h=ov(t[m]);for(let y=0;y<h.length-1;y+=1){let g=Gd(u,h[y]),x=Gd(u,h[y+1]);d(l(g),l(x))}});for(let u of r.values())u.sort((m,h)=>m.angle-h.angle);return{vertices:n,adjacency:r,edges:i,edgeCount:o.size}}function XS(e,t,n,r){let o=ko(e.a,t),i=ko(e.b,t),a=ko(t.a,e),s=ko(t.b,e);o!==null&&r.push({t:o,point:e.a}),i!==null&&r.push({t:i,point:e.b}),a!==null&&n.push({t:a,point:t.a}),s!==null&&n.push({t:s,point:t.b})}function YS(e){let t=[],n=new Set,r=e.edgeCount*2+8;for(let[o,i]of e.adjacency)for(let a of i){let s=o,c=a.key,l=$d(s,c);if(n.has(l))continue;let d=[],u=s,m=c,h=!1;for(let y=0;y<r;y+=1){let g=$d(u,m);if(n.has(g))break;n.add(g),d.push(u);let x=e.adjacency.get(m);if(!x||x.length===0)break;let S=x.findIndex(P=>P.key===u);if(S===-1)break;let I=(S-1+x.length)%x.length,R=x[I].key;if(u=m,m=R,u===s&&m===c){h=!0;break}}if(!(!h||d.length<3))for(let y of KS(d)){let g=y.map(S=>e.vertices.get(S)?.point).filter(S=>!!S),x=Math.abs(Wd(g));x<=No||t.push({polygon:g,area:x,path:Vd(g)})}}return t}function KS(e){let t=[],n=new Map,r=[];for(let o of e){let i=n.get(o);if(i===void 0){n.set(o,t.length),t.push(o);continue}let a=t.slice(i);a.length>=3&&r.push(a);let s=t.splice(i+1);for(let c of s)n.delete(c)}return r.length===0&&t.length>=3&&r.push(t),r}function jS(e){let t=new Map;for(let[o,i]of e.adjacency)t.set(o,i.length);let n=new Set,r=[];for(let[o,i]of t)i<=1&&r.push(o);for(;r.length>0;){let o=r.pop();if(!(n.has(o)||(t.get(o)??0)>1)){n.add(o);for(let i of e.adjacency.get(o)??[]){if(n.has(i.key))continue;let a=(t.get(i.key)??0)-1;t.set(i.key,a),a<=1&&r.push(i.key)}}}return e.edges.filter(o=>!n.has(o.fromKey)&&!n.has(o.toKey))}function qS(e){let t=new Map;return n=>{let r=t.get(n.path);if(r!==void 0)return r;let o=!ZS(n,e);return t.set(n.path,o),o}}function ZS(e,t){let n=JS(e.polygon);for(let r of t){let o={x:(r.a.x+r.b.x)/2,y:(r.a.y+r.b.y)/2};if(!(o.x<n.minX||o.x>n.maxX||o.y<n.minY||o.y>n.maxY)&&Xa(o,e.polygon)&&QS(o,e.polygon)>Lo)return!0}return!1}function JS(e){let t=1/0,n=-1/0,r=1/0,o=-1/0;for(let i of e)t=Math.min(t,i.x),n=Math.max(n,i.x),r=Math.min(r,i.y),o=Math.max(o,i.y);return{minX:t,maxX:n,minY:r,maxY:o}}function QS(e,t){let n=1/0;for(let r=0,o=t.length-1;r<t.length;o=r,r+=1)if(n=Math.min(n,Ya(e,{a:t[o],b:t[r],kind:"frame"})),n<=Lo)return n;return n}function Ha(e,t,n){let r=t.filter(o=>o.area>No&&Xa(e,o.polygon)).sort((o,i)=>o.area-i.area);for(let o of r)if(n(o))return{face:o,openFaceRejected:!1};return{face:null,openFaceRejected:r.length>0}}function _d(e,t,n,r){let o=Ha(e,t,r);if(o.openFaceRejected)return o;let i=o.face,a=[e,{x:e.x+n,y:e.y},{x:e.x-n,y:e.y},{x:e.x,y:e.y+n},{x:e.x,y:e.y-n},{x:e.x+n,y:e.y+n},{x:e.x+n,y:e.y-n},{x:e.x-n,y:e.y+n},{x:e.x-n,y:e.y-n}],s=new Map;i&&s.set(i.path,i);for(let c of a){let l=Ha(c,t,r).face;l&&s.set(l.path,l)}return{face:[...s.values()].sort((c,l)=>c.area-l.area)[0]??null,openFaceRejected:!1}}function Ro(e){return e.filter(t=>t!=null&&t.area>No).sort((t,n)=>t.area-n.area)[0]??null}function Dd(e,t,n){return t.filter(r=>Ya(e,r)<=n)}function ev(e,t){let n=e.b.x-e.a.x,r=e.b.y-e.a.y,o=t.b.x-t.a.x,i=t.b.y-t.a.y,a=Ao({x:n,y:r},{x:o,y:i});if(Math.abs(a)<q)return null;let s=t.a.x-e.a.x,c=t.a.y-e.a.y,l=Ao({x:s,y:c},{x:o,y:i})/a,d=Ao({x:s,y:c},{x:n,y:r})/a;return!Eo(l)||!Eo(d)?null:{point:{x:e.a.x+n*l,y:e.a.y+r*l},t:l,u:d}}function ko(e,t){let n=t.b.x-t.a.x,r=t.b.y-t.a.y,o=n*n+r*r;if(o<q)return null;let i=Ao({x:n,y:r},{x:e.x-t.a.x,y:e.y-t.a.y});if(Math.abs(i)/Math.sqrt(o)>Lo)return null;let a=((e.x-t.a.x)*n+(e.y-t.a.y)*r)/o;return Eo(a)?a:null}function Xa(e,t){let n=!1;for(let r=0,o=t.length-1;r<t.length;o=r,r+=1){let i=t[r],a=t[o];if(!(i.y>e.y!=a.y>e.y))continue;let c=(a.x-i.x)*(e.y-i.y)/(a.y-i.y)+i.x;e.x<c&&(n=!n)}return n}function Ya(e,t){let n=t.b.x-t.a.x,r=t.b.y-t.a.y,o=n*n+r*r;if(o<=q)return Ua(e,t.a);let i=Math.max(0,Math.min(1,((e.x-t.a.x)*n+(e.y-t.a.y)*r)/o));return Ua(e,{x:t.a.x+n*i,y:t.a.y+r*i})}function tv(e){let t=ke(e.x,null),n=ke(e.y,null);return t===null||n===null?null:{x:t,y:n}}function nv(e,t){return t.x>e.xMin+q&&t.x<e.xMax-q&&t.y>e.yMin+q&&t.y<e.yMax-q}function rv(e,t){let n=Math.max(e.xMin,t.xMin),r=Math.min(e.xMax,t.xMax),o=Math.max(e.yMin,t.yMin),i=Math.min(e.yMax,t.yMax);return n<r&&o<i?{xMin:n,xMax:r,yMin:o,yMax:i}:null}function ov(e){let t=e.filter(r=>Eo(r.t)).map(r=>({...r,t:Math.min(1,Math.max(0,r.t))})).sort((r,o)=>r.t-o.t),n=[];for(let r of t){let o=n[n.length-1];!o||Math.abs(r.t-o.t)>q?n.push(r):!o.point&&r.point&&(o.point=r.point)}return n}function Eo(e){return Number.isFinite(e)&&e>=-q&&e<=1+q}function iv(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Gd(e,t){return t.point??iv(e.a,e.b,t.t)}function $d(e,t){return`${e}->${t}`}function Vd(e){let[t,...n]=e;return[`M${Bo(t.x)} ${Bo(t.y)}`,...n.map(r=>`L${Bo(r.x)} ${Bo(r.y)}`),"Z"].join(" ")}function Wd(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n],o=e[(n+1)%e.length];t+=r.x*o.y-o.x*r.y}return t/2}function Ao(e,t){return e.x*t.y-e.y*t.x}function Ua(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function av(e,t,n){return e>Math.min(t,n)+q&&e<Math.max(t,n)-q}function zd(e){let t=e.filter(r=>Number.isFinite(r)).sort((r,o)=>r-o),n=[];for(let r of t){let o=n[n.length-1];(o===void 0||Math.abs(r-o)>ar)&&n.push(r)}return n}function Hd(e,t,n){return Math.max(t,Math.min(n,e))}function Bo(e){return Number(e.toFixed(3))}function Co(e,t,n){return Number.isFinite(e)?Math.round(Math.max(t,Math.min(n,e))):t}import{Fragment as Nv,jsx as N,jsxs as Te}from"react/jsx-runtime";var dv=300,Xd=9,pv=new Map,mv=new Map,fv=new Map,lr=new Map,yv=2e3;function hv(e,t){let n=Le(t,e),r=lr.get(n);if(r!==void 0)return r;let o;try{let i=sv.renderToString(ft(e||"\\square",t.typesetStyle),{macros:t.macroSet.katexMacros,throwOnError:!1,strict:"ignore",output:"html",trust:an}),a=To(i);o=a.safe?a.html:`<span data-math-unrendered="true">${ge(e)}</span>`}catch{o=`<span data-math-unrendered="true">${ge(e)}</span>`}if(lr.size>=yv){let i=lr.keys().next().value;i!==void 0&&lr.delete(i)}return lr.set(n,o),o}var gv={"\\pi":"\u03C0","\\theta":"\u03B8","\\alpha":"\u03B1","\\beta":"\u03B2","\\gamma":"\u03B3","\\delta":"\u03B4","\\epsilon":"\u03B5","\\varepsilon":"\u03B5","\\lambda":"\u03BB","\\mu":"\u03BC","\\sigma":"\u03C3","\\phi":"\u03C6","\\varphi":"\u03C6","\\omega":"\u03C9","\\sin":"sin","\\cos":"cos","\\tan":"tan","\\log":"log","\\ln":"ln","\\exp":"exp","\\sqrt":"\u221A","\\cdot":"\xB7","\\times":"\xD7","\\div":"\xF7","\\pm":"\xB1","\\mp":"\u2213","\\infty":"\u221E","\\leq":"\u2264","\\leqq":"\u2264","\\geq":"\u2265","\\geqq":"\u2265","\\neq":"\u2260","\\approx":"\u2248","\\to":"\u2192"};function xv(e){if(!e)return"";let t=e;for(let n=0;n<4;n+=1){let r=t.replace(/\\d?frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,"$1/$2");if(r===t)break;t=r}for(let[n,r]of Object.entries(gv))t.includes(n)&&(t=t.split(n).join(r));return t=t.replace(/\\([a-zA-Z]+)/g,"$1"),t=t.replace(/[{}]/g,""),t=t.replace(/-/g,"\u2212"),t}function Yd(e,t){return t==="start"?0:t==="end"?e:e/2}function Kd(e){return e==="start"?"flex-start":e==="end"?"flex-end":"center"}function bv(e){return e==="start"?"start":e==="end"?"end":"middle"}function Sv(e){return e==="start"?"hanging":e==="end"?"alphabetic":"middle"}var vv=12,Mv=12;function ja(e){return typeof e=="number"&&Number.isFinite(e)}function jd(e,t,n){let r=fo(e||"\\square",n),o=Ut(t);return{width:Math.max(vv,Math.ceil(r.widthEm*o)),height:Math.max(Mv,Math.ceil((r.ascentEm+r.descentEm)*o))}}function qd({cx:e,cy:t,width:n,height:r,align:o,vAlign:i,tex:a,className:s,fontSize:c,staticMode:l}){let d=It();if(l)return N("text",{x:e,y:t,textAnchor:bv(o),dominantBaseline:Sv(i),className:s,style:c!==void 0?{fontSize:`${c}pt`}:void 0,children:xv(a)});let u=e-Yd(n,o),m=t-Yd(r,i);return N("foreignObject",{x:u,y:m,width:n,height:r,className:s,children:N("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{width:"100%",height:"100%",display:"flex",justifyContent:Kd(o),alignItems:Kd(i),fontSize:c!==void 0?`${c}pt`:void 0,lineHeight:1,pointerEvents:"none",overflow:"visible"},dangerouslySetInnerHTML:{__html:hv(a,d)}})})}function Pv({spec:e,className:t="",idSeed:n,staticMode:r,onSpecChange:o,autoStartCrop:i,disableCropInteraction:a,onCropEnd:s}){wt("Graph2DPreview.render");let c=It(),[l,d]=Ka(!1),[u,m]=Ka(null),[h,y]=Ka(null),g=hn(null),x=hn(null),S=hn(null),I=hn(null),R=hn(null),P=hn(!1),C=Fo(uv()),z=n?Fo(n):C,f=l&&h?h:e,M=sr(()=>le(f),[f.kind,f.axes.renderStyle]),D=sr(()=>Fo([z,f.title,f.kind,f.width,f.height,f.viewBox.xMin,f.viewBox.xMax,f.viewBox.yMin,f.viewBox.yMax,f.graphViewBox?.xMin??"",f.graphViewBox?.xMax??"",f.graphViewBox?.yMin??"",f.graphViewBox?.yMax??""].join("-")),[z,f.title,f.kind,f.width,f.height,f.viewBox,f.graphViewBox]),Q=sr(()=>ua("Graph2DPreview.curvePaths",()=>f.curves.map(b=>({curve:b,path:Ov(b,f,M)}))),[f.curves,f.viewBox,f.graphViewBox,f.width,f.height,M]),Z=sr(()=>ua("Graph2DPreview.fillPaths",()=>(f.fills??[]).map(b=>({fill:b,path:wv(f,b,M),color:er(b.color,Wi),opacity:Yi(b.opacity),pattern:Xi(b.pattern),patternId:`graph2d-fill-pattern-${D}-${Fo(b.id)}`})).filter(b=>b.path)),[f.fills,f.curves,f.viewBox,f.graphViewBox,f.width,f.height,f.kind,M,D]),v=sr(()=>Xu(f),[f]),w=Tv(f),O=Bv(f),A=qu(f)||"\u30B0\u30E9\u30D5",B=b=>{let T=le(b);try{let H=Sa(b,T);if(H.width>0&&H.height>0)return{left:H.x,top:H.y,width:H.width,height:H.height}}catch{}return{left:T.left,top:T.top,width:b.width-T.left-T.right,height:b.height-T.top-T.bottom}},F=b=>{let T=B(b);P.current=!1,x.current=T,S.current=b,m(T),y(b),d(!0)},W=()=>{let b=x.current??u;b&&U(b),x.current=null,S.current=null,d(!1),m(null),y(null),s?.()},_=b=>{r||a||!o||(b.preventDefault(),b.stopPropagation(),l?W():F(e))},j=(b,T={})=>{let H=S.current??h;if(!o||!H)return;let te=Wu(H,b,T);te&&o(te,{source:"crop",cropBox:b,resizeToCrop:T.resizeToCrop===!0})},U=b=>{P.current||(P.current=!0,j(b,{resizeToCrop:!0}))};cv(()=>{if(i&&!l&&o&&!r){let b=B(e);P.current=!1,x.current=b,S.current=e,m(b),y(e),d(!0)}else if(!i&&l){let b=x.current??u;b&&U(b),x.current=null,S.current=null,d(!1),m(null),y(null)}},[i]);let X=(b,T)=>{!l||!u||(b.preventDefault(),b.stopPropagation(),b.target.setPointerCapture(b.pointerId),g.current={x:b.clientX,y:b.clientY,box:{...u},handle:T})},$=b=>{if(!l||!u||!g.current)return;b.preventDefault(),b.stopPropagation();let T=g.current;if(!I.current)return;let H=I.current.getBoundingClientRect();if(H.width<=0||H.height<=0)return;let te=f.width/H.width,fe=f.height/H.height,De=(b.clientX-T.x)*te,fi=(b.clientY-T.y)*fe,Es=M.left,Cs=f.width-M.right,Ls=M.top,Ns=f.height-M.bottom,ye={...T.box},Sr=30;if(T.handle==="center")ye.left=Math.max(Es,Math.min(Cs-ye.width,T.box.left+De)),ye.top=Math.max(Ls,Math.min(Ns-ye.height,T.box.top+fi));else{if(T.handle.includes("l")){let dt=T.box.left+De,wn=Math.max(Es,Math.min(T.box.left+T.box.width-Sr,dt));ye.width=T.box.left+T.box.width-wn,ye.left=wn}if(T.handle.includes("r")){let dt=T.box.width+De;ye.width=Math.max(Sr,Math.min(Cs-T.box.left,dt))}if(T.handle.includes("t")){let dt=T.box.top+fi,wn=Math.max(Ls,Math.min(T.box.top+T.box.height-Sr,dt));ye.height=T.box.top+T.box.height-wn,ye.top=wn}if(T.handle.includes("b")){let dt=T.box.height+fi;ye.height=Math.max(Sr,Math.min(Ns-T.box.top,dt))}}x.current=ye,m(ye),j(ye)},ue=b=>{!l||!g.current||(b.preventDefault(),b.stopPropagation(),b.target.releasePointerCapture(b.pointerId),g.current=null)};if(!w||!O)return N("div",{className:`graph2d-container ${t}`,style:{position:"relative"},children:Te("svg",{className:"graph2d-svg","data-testid":"graph2d-svg",role:"img","aria-label":`${A} \u7BC4\u56F2\u30A8\u30E9\u30FC`,viewBox:`0 0 ${f.width} ${f.height}`,children:[N("rect",{width:f.width,height:f.height,rx:"6",className:"graph2d-error-bg"}),N("text",{x:f.width/2,y:f.height/2,textAnchor:"middle",className:"graph2d-error-text",children:"\u30B0\u30E9\u30D5\u3092\u63CF\u753B\u3067\u304D\u307E\u305B\u3093"})]})});let J=Rv(w,O),we=J?Zd(J.xMin,J.xMax,f.axes.xTickStep,f.kind==="numberLine"?8:12):[],ee=J&&f.kind!=="numberLine"?Zd(J.yMin,J.yMax,f.axes.yTickStep,9):[],be=f.axes.showX!==!1,Re=f.kind==="cartesian"&&f.axes.showY!==!1,ut=f.axes.showTicks!==!1,li=J!==null&&J.yMin<=0&&J.yMax>=0,ci=J!==null&&J.xMin<=0&&J.xMax>=0,_e=be&&li,ui=Re&&ci,br=Av(w,f,M),Pn=Re?Iv(w,f,M):null,di=`axis-arrow-${D}`,Tn=(Pe(f.axes.axisColor)?f.axes.axisColor:void 0)??(f.axes.renderStyle==="studyaid"?"#0d0d0d":void 0),pi=(ja(f.axes.axisStrokeWidth)?f.axes.axisStrokeWidth:void 0)??(f.axes.renderStyle==="studyaid"?.85:void 0),mi=kv(f.axes.axisDash??(f.axes.renderStyle==="studyaid"?"dashed":void 0)),Rs=Tn||pi!==void 0||mi?{...Tn?{stroke:Tn}:{},...pi!==void 0?{strokeWidth:pi}:{},...mi?{strokeDasharray:mi}:{}}:void 0,Pm=`graph2d-plot-clip-${D}`,On=`graph2d-graph-clip-${D}`,As=Math.max(0,f.width-M.left-M.right),Is=Math.max(0,f.height-M.top-M.bottom),ie=Sa(f,M),Tm=Q.some(b=>b.path),Om=u?[{name:"tl",x:u.left,y:u.top,cursor:"nwse-resize"},{name:"tr",x:u.left+u.width,y:u.top,cursor:"nesw-resize"},{name:"bl",x:u.left,y:u.top+u.height,cursor:"nesw-resize"},{name:"br",x:u.left+u.width,y:u.top+u.height,cursor:"nwse-resize"},{name:"t",x:u.left+u.width/2,y:u.top,cursor:"ns-resize"},{name:"b",x:u.left+u.width/2,y:u.top+u.height,cursor:"ns-resize"},{name:"l",x:u.left,y:u.top+u.height/2,cursor:"ew-resize"},{name:"r",x:u.left+u.width,y:u.top+u.height/2,cursor:"ew-resize"}]:[];return N("div",{ref:R,className:`graph2d-container ${t} ${l?"cropping":""}`,style:{position:"relative",width:"100%",height:"100%"},onDoubleClick:_,onPointerDown:b=>{l&&(b.stopPropagation(),W())},children:Te("svg",{ref:I,className:"graph2d-svg","data-testid":"graph2d-svg",role:"img","aria-label":A,viewBox:`0 0 ${f.width} ${f.height}`,onPointerMove:$,onPointerUp:ue,style:{touchAction:l?"none":"auto"},children:[N("title",{children:A}),Te("defs",{children:[N("marker",{id:di,markerWidth:"8",markerHeight:"8",refX:"6",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:N("path",{d:"M0 0 L7 4 L0 8 Z",className:"graph2d-axis-arrow",style:Tn?{fill:Tn}:void 0})}),N("clipPath",{id:Pm,children:N("rect",{x:M.left,y:M.top,width:As,height:Is})}),N("clipPath",{id:On,children:N("rect",{x:ie.x,y:ie.y,width:ie.width,height:ie.height})}),Z.map(({pattern:b,patternId:T,color:H,opacity:te})=>b==="solid"?null:N(Cv,{id:T,pattern:b,color:H,opacity:te},T))]}),N("rect",{x:M.left,y:M.top,width:As,height:Is,rx:"4",className:"graph2d-plot-bg"}),Z.length>0&&N("g",{className:"graph2d-fills",clipPath:`url(#${On})`,children:Z.map(({fill:b,path:T,color:H,opacity:te,pattern:fe,patternId:De})=>N("path",{className:"graph2d-fill-region","data-testid":"graph2d-fill-region",d:T,fill:fe==="solid"?H:`url(#${De})`,fillOpacity:fe==="solid"?te:void 0,fillRule:"evenodd"},b.id))}),f.axes.grid&&f.kind==="cartesian"&&Te("g",{className:"graph2d-grid",children:[we.map(b=>{let T=Y(b,0,w,f,M);return N("line",{x1:T.x,x2:T.x,y1:ie.y,y2:ie.y+ie.height},`x-grid-${b}`)}),ee.map(b=>{let T=Y(0,b,w,f,M);return N("line",{x1:ie.x,x2:ie.x+ie.width,y1:T.y,y2:T.y},`y-grid-${b}`)})]}),Te("g",{className:"graph2d-axes",children:[_e&&N("line",{x1:ie.x,x2:ie.x+ie.width,y1:br,y2:br,markerEnd:`url(#${di})`,style:Rs}),ui&&Pn!==null&&N("line",{x1:Pn,x2:Pn,y1:ie.y+ie.height,y2:ie.y,markerEnd:`url(#${di})`,style:Rs})]}),ut&&Te("g",{className:"graph2d-ticks",children:[_e&&we.map(b=>{let T=Y(b,0,w,f,M),H=Pa(b,f.axes.xTickMode,f.axes.xTickStep),te=ja(f.axes.tickFontSize)?f.axes.tickFontSize:Xd,fe=jd(H,te,c);return N(qd,{cx:T.x,cy:br+18,width:fe.width,height:fe.height,align:"middle",vAlign:"middle",tex:H,className:"graph2d-tex-label",fontSize:te,staticMode:r},`x-tick-${b}`)}),ui&&ee.map(b=>{let T=Y(0,b,w,f,M),H=Pa(b,f.axes.yTickMode,f.axes.yTickStep),te=ja(f.axes.tickFontSize)?f.axes.tickFontSize:Xd,fe=jd(H,te,c);return N(qd,{cx:M.left-8,cy:T.y,width:fe.width,height:fe.height,align:"end",vAlign:"middle",tex:H,className:"graph2d-tex-label",fontSize:te,staticMode:r},`y-tick-${b}`)})]}),N("g",{className:"graph2d-curves",clipPath:`url(#${On})`,children:Q.map(({curve:b,path:T})=>T?N("path",{"data-testid":"graph2d-curve",d:T,fill:"none",stroke:er(b.color),strokeWidth:Ta(b.strokeWidth),strokeDasharray:ju(b),strokeLinecap:"butt",vectorEffect:"non-scaling-stroke"},b.id):null)}),N("g",{className:"graph2d-point-guides",clipPath:`url(#${On})`,children:(f.points??[]).map(b=>{let T=Oa(b);if(!T)return null;let H=Y(T.x,T.y,w,f,M),te=er(b.color,"#dc2626");return Te("g",{children:[b.showXProjection&&_e&&N("line",{"data-testid":"graph2d-point-guide-x",x1:H.x,x2:H.x,y1:H.y,y2:br,stroke:te,strokeOpacity:.65,strokeDasharray:"4 3",vectorEffect:"non-scaling-stroke"}),b.showYProjection&&ui&&Pn!==null&&N("line",{"data-testid":"graph2d-point-guide-y",x1:H.x,x2:Pn,y1:H.y,y2:H.y,stroke:te,strokeOpacity:.65,strokeDasharray:"4 3",vectorEffect:"non-scaling-stroke"})]},`point-guides-${b.id}`)})}),N("g",{className:"graph2d-points",clipPath:`url(#${On})`,children:(f.points??[]).map(b=>{let T=Oa(b);if(!T)return null;let H=Y(T.x,T.y,w,f,M),te=er(b.color,"#dc2626"),fe=Ev(b.radius),De=b.fill==="none";return Te("g",{children:[De&&N("circle",{className:"graph2d-point-open-halo",cx:H.x,cy:H.y,r:fe+1.4,fill:"#ffffff",stroke:"none"}),N("circle",{className:"graph2d-point",cx:H.x,cy:H.y,r:fe,fill:De?"#ffffff":te,stroke:te,strokeWidth:De?2.4:0,vectorEffect:"non-scaling-stroke"})]},b.id)})}),v.length>0&&N("text",{x:f.width/2,y:f.height/2,textAnchor:"middle",className:"graph2d-error-text",children:"\u66F2\u7DDA\u304C\u8868\u793A\u7BC4\u56F2\u306E\u5916\u306B\u3042\u308A\u307E\u3059"}),!Tm&&v.length===0&&f.curves.length>0&&N("text",{x:f.width/2,y:f.height/2,textAnchor:"middle",className:"graph2d-error-text",children:"\u5F0F\u3092\u8A55\u4FA1\u3067\u304D\u307E\u305B\u3093"}),l&&u&&Te(Nv,{children:[N("rect",{x:M.left,y:M.top,width:Math.max(0,u.left-M.left),height:f.height-M.top-M.bottom,fill:"#0f172a80",style:{pointerEvents:"none"}}),N("rect",{x:u.left+u.width,y:M.top,width:Math.max(0,f.width-M.right-(u.left+u.width)),height:f.height-M.top-M.bottom,fill:"#0f172a80",style:{pointerEvents:"none"}}),N("rect",{x:u.left,y:M.top,width:u.width,height:Math.max(0,u.top-M.top),fill:"#0f172a80",style:{pointerEvents:"none"}}),N("rect",{x:u.left,y:u.top+u.height,width:u.width,height:Math.max(0,f.height-M.bottom-(u.top+u.height)),fill:"#0f172a80",style:{pointerEvents:"none"}}),N("rect",{x:u.left,y:u.top,width:u.width,height:u.height,fill:"none",stroke:"#2563eb",strokeWidth:"2",strokeDasharray:"4 3",style:{cursor:"move",pointerEvents:"all"},onPointerDown:b=>X(b,"center")}),Om.map(b=>Te("g",{children:[N("circle",{cx:b.x,cy:b.y,r:5,fill:"#2563eb",stroke:"#ffffff",strokeWidth:"1.5",style:{pointerEvents:"none"}}),N("circle",{cx:b.x,cy:b.y,r:14,fill:"transparent",style:{cursor:b.cursor,pointerEvents:"all"},onPointerDown:T=>X(T,b.name)})]},b.name))]})]})})}function Tv(e){try{return Rt(e)}catch{return null}}function Ov(e,t,n){let r=Jd({curve:e,graphViewBox:t.graphViewBox,height:t.height,kind:t.kind,plotBox:n,viewBox:t.viewBox,width:t.width});return qa(pv,r,()=>Ma(e,t,n))}function wv(e,t,n){let r=Jd({axes:e.axes,curves:e.curves,fill:t,graphViewBox:e.graphViewBox,height:e.height,kind:e.kind,plotBox:n,viewBox:e.viewBox,width:e.width});return qa(mv,r,()=>Ud(e,t,n)??"")}function Zd(e,t,n,r){let o=`${e}:${t}:${n??""}:${r}`;return qa(fv,o,()=>Ku(e,t,n,r))}function kv(e){if(e==="dashed")return"3 3";if(e==="dotted")return"1.2 3"}function qa(e,t,n){let r=e.get(t);if(r!==void 0)return e.delete(t),e.set(t,r),r;let o=n();if(e.set(t,o),e.size>dv){let i=e.keys().next().value;i!==void 0&&e.delete(i)}return o}function Jd(e){return JSON.stringify(e)}function Bv(e){try{return Ye(e)}catch{return null}}function Rv(e,t){let n=Math.max(e.xMin,t.xMin),r=Math.min(e.xMax,t.xMax),o=Math.max(e.yMin,t.yMin),i=Math.min(e.yMax,t.yMax);return n>=r||o>=i?null:{xMin:n,xMax:r,yMin:o,yMax:i}}function Av(e,t,n){return e.yMin<=0&&e.yMax>=0?Y(0,0,{...e,xMin:0,xMax:1},t,n).y:t.height-n.bottom}function Iv(e,t,n){return e.xMin<=0&&e.xMax>=0?Y(0,0,e,t,n).x:n.left}function Ev(e){return Number.isFinite(e)&&e!==void 0?Math.min(12,Math.max(1.5,e)):4.3}function Fo(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")||"graph"}function Cv({id:e,pattern:t,color:n,opacity:r}){let o=Math.min(.22,r*.45),i=Math.min(.95,Math.max(.36,r+.28)),a={stroke:n,strokeWidth:t==="cross"?1:1.25,strokeOpacity:i,strokeLinecap:"butt"};if(t==="dots")return Te("pattern",{id:e,width:"12",height:"12",patternUnits:"userSpaceOnUse",children:[N("rect",{width:"12",height:"12",fill:n,opacity:o}),N("circle",{cx:"3",cy:"3",r:"1.15",fill:n,opacity:i}),N("circle",{cx:"9",cy:"9",r:"1.15",fill:n,opacity:i})]});let s=Lv(t);return Te("pattern",{id:e,width:"10",height:"10",patternUnits:"userSpaceOnUse",children:[N("rect",{width:"10",height:"10",fill:n,opacity:o}),N("path",{d:s,...a})]})}function Lv(e){switch(e){case"diagonal":return"M -5 10 L 10 -5 M 0 10 L 10 0 M 5 10 L 10 5";case"diagonalBack":return"M 0 5 L 5 10 M 0 0 L 10 10 M 5 0 L 10 5";case"cross":return["M -5 10 L 10 -5","M 0 10 L 10 0","M 5 10 L 10 5","M 0 5 L 5 10","M 0 0 L 10 10","M 5 0 L 10 5"].join(" ");case"horizontal":return"M 0 3.2 H 10 M 0 8.2 H 10";case"vertical":return"M 3.2 0 V 10 M 8.2 0 V 10";case"dots":return""}}var Et=lv(Pv);Et.displayName="Graph2DPreview";import{jsx as se,jsxs as cr}from"react/jsx-runtime";function ur({table:e,width:t,height:n,overflow:r=0,mathFractionSizing:o,selfContained:i,xmlns:a}){let s=rl(e,t,n);return se("div",{...a?{xmlns:a}:{},style:{boxSizing:"border-box",width:`${t+r*2}px`,height:`${n+r*2}px`,overflow:"visible",padding:`${r}px`,...gn(al)},children:cr("div",{style:{position:"relative",width:`${t}px`,height:`${n}px`},children:[cr("table",{style:{boxSizing:"border-box",width:`${t}px`,height:`${n}px`,borderCollapse:"collapse",tableLayout:"fixed",background:"transparent",border:0},children:[se("colgroup",{children:e.columns.map((c,l)=>se("col",{style:{width:`${s.columnWidths[l]}px`}},c.id))}),se("tbody",{children:s.rows.map(c=>se("tr",{style:{height:`${c.height}px`},children:c.cells.map(l=>se("td",{rowSpan:l.rowSpan>1?l.rowSpan:void 0,colSpan:l.colSpan>1?l.colSpan:void 0,style:gn({...il,...ll(e,l.cell,l.rowIndex,l.columnIndex,l.rowSpan,l.colSpan)}),children:se("div",{style:gn({...sl,...cl(e,l.cell)}),children:l.cell?.content.map(d=>se(_v,{cell:l.cell,content:d,mathFractionSizing:o,selfContained:i},d.id))})},l.cell?.id??`${c.rowId}:${l.columnIndex}`))},c.rowId))})]}),se(Fv,{table:e,columnOffsets:s.columnOffsets,rowOffsets:s.rowOffsets})]})})}function Fv({table:e,columnOffsets:t,rowOffsets:n}){let r=ul(e,t,n),o=dl(e,t,n);return r.length===0&&o.length===0?null:cr("div",{style:{position:"absolute",inset:0,zIndex:2,pointerEvents:"none"},children:[r.map(i=>se("div",{style:{position:"absolute",...i.axis==="vertical"?{top:0,bottom:0,width:0}:{right:0,left:0,height:0},...gn(i.style),pointerEvents:"none"}},`rendered-${i.axis}-${i.domKey}`)),o.map(i=>se("div",{style:{position:"absolute",zIndex:3,boxSizing:"border-box",...gn(i.style),pointerEvents:"none"}},i.id))]})}function _v({cell:e,content:t,mathFractionSizing:n,selfContained:r}){return t.type==="trend"?se(Qd,{colSpan:e?.colSpan??1,content:t,mathFractionSizing:n,selfContained:r}):se("p",{style:{margin:0,...gn(t.align?{textAlign:t.align}:{})},children:xe(t.children,{keyPrefix:t.id,mathFractionSizing:n,selfContained:r})})}function Qd({content:e,colSpan:t,mathFractionSizing:n,selfContained:r}){let o=ol(e.direction,t);return cr("div",{className:"overlay-table-trend",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"4px",width:"100%",minHeight:"1.75em"},children:[cr("svg",{xmlns:"http://www.w3.org/2000/svg",width:o.width,height:o.height,viewBox:`0 0 ${o.width} ${o.height}`,style:{display:"block",overflow:"visible",width:"100%",height:"100%"},children:[se("line",{x1:o.line.x1,y1:o.line.y1,x2:o.line.x2,y2:o.line.y2,stroke:o.color,strokeWidth:o.strokeWidth}),se("polygon",{points:o.arrowPoints,fill:o.color})]}),e.label?.length?se("span",{children:xe(e.label,{keyPrefix:`${e.id}-label`,mathFractionSizing:n,selfContained:r})}):null]})}function gn(e){let t;for(let[n,r]of Object.entries(e))et(r)||(t??={...e},delete t[n]);return t??e}import{useMemo as Dv}from"react";import{Fragment as zv,jsx as _o}from"react/jsx-runtime";function Za({node:e,keyPrefix:t="overlay",mathFractionSizing:n}){let r=Dv(()=>vo(e,{runIdPrefix:t}),[t,e]);return _o(zv,{children:r.map(o=>Gv(o,n))})}function Gv(e,t){let n=e.isBlank?_o("br",{}):_o(Ga,{nodes:e.inlineNodes,keyPrefix:e.key,mathFractionSizing:t}),r=$v(e.style),o=e.tag;return _o(o,{style:r,children:n},e.key)}function $v(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))t[n.startsWith("--")?n:n.replace(/-([a-z])/g,(o,i)=>i.toUpperCase())]=r;return t}import{jsx as Ne,jsxs as tp}from"react/jsx-runtime";var Uv=e=>e,Vv={};function Do({block:e,classNames:t=Vv,mathFractionSizing:n,resolveText:r=Uv}){return e.type==="heading"?Ne(Wv,{block:e,className:t.heading,mathFractionSizing:n,resolveText:r}):e.type==="list"?Ne(ep,{block:e,classNames:t,mathFractionSizing:n,resolveText:r}):Ne(Xv,{block:e,className:t.paragraph,mathFractionSizing:n,resolveText:r})}function Wv({block:e,className:t,mathFractionSizing:n,resolveText:r}){let o=`h${e.level}`,i=Ja(e.children),{aligned:a,alignmentStyles:s,ref:c}=yn(i);return Ne(o,{ref:c,"data-boxed-run-aligned":a?"true":void 0,"data-sigma-doc-id":e.id,className:t,style:{textAlign:e.align??"left",lineHeight:e.lineHeight},children:xe(e.children,{alignmentStyles:s,keyPrefix:e.id,mathFractionSizing:n,resolveText:r})})}function Xv({block:e,className:t,mathFractionSizing:n,resolveText:r}){let o=Ja(e.children),{aligned:i,alignmentStyles:a,ref:s}=yn(o);return tp("p",{ref:s,"data-boxed-run-aligned":i?"true":void 0,"data-sigma-doc-id":e.id,className:t,style:{textAlign:e.align??"left",lineHeight:e.lineHeight},children:[xe(e.children,{alignmentStyles:a,keyPrefix:e.id,mathFractionSizing:n,resolveText:r}),!Kv(e.children)&&Ne("br",{},"trailing-break")]})}function ep({block:e,classNames:t,mathFractionSizing:n,resolveText:r}){let o=e.items.map(i=>{let a=Bd(i.children);return tp("li",{"data-sigma-doc-id":i.id,...a?.attrs,style:a?.style,children:[Ne(Yv,{item:i,mathFractionSizing:n,resolveText:r}),(i.nested??[]).map(s=>Ne(ep,{block:s,classNames:t,mathFractionSizing:n,resolveText:r},s.id))]},i.id)});return e.listType==="ordered"?Ne("ol",{"data-sigma-doc-id":e.id,"data-list-marker":e.markerStyle==="paren"?"paren":void 0,className:t.list,start:e.start,children:o}):Ne("ul",{"data-sigma-doc-id":e.id,className:t.list,children:o})}function Yv({item:e,mathFractionSizing:t,resolveText:n}){let r=Ja(e.children),{aligned:o,alignmentStyles:i,ref:a}=yn(r);return Ne("span",{ref:a,"data-boxed-run-aligned":o?"true":void 0,children:xe(e.children,{alignmentStyles:i,keyPrefix:e.id,mathFractionSizing:t,resolveText:n})})}function Kv(e){return e.some(t=>t.type==="text"?t.text.length>0:!0)}function Ja(e){return Hv(()=>Da(e),[e])}import{useMemo as mp}from"react";import{memo as $o}from"react";function np(e,t){let n=Kt(e,t),r=Hn(e,t,n);return{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}function xn(e){if(e==="dashed")return"8 6";if(e==="dotted")return"1 6"}function op(e,t,n,r,o,i,a){return e==="blockArrow"?xt(t,n,o,i,1).map(s=>`${s.x},${s.y}`).join(" "):e==="triangle"?`${Dt(r??t/2,1,Math.max(1,t-1))},1 ${Math.max(1,t-1)},${Math.max(1,n-1)} 1,${Math.max(1,n-1)}`:e==="diamond"?`${t/2},1 ${Math.max(1,t-1)},${n/2} ${t/2},${Math.max(1,n-1)} 1,${n/2}`:St(t,n,e==="pentagon"?5:bt(a),1).map(s=>`${s.x},${s.y}`).join(" ")}function rp(e,t){let{rx:n,ry:r}=ce(e);return{x:n+Math.cos(t)*n,y:r+Math.sin(t)*r}}function ip(e){let{rx:t,ry:n}=ce(e),r=jr(e),o=rp(e,r.startAngle),i=rp(e,r.endAngle),s=Se(r.endAngle-r.startAngle)>Math.PI?1:0;return e.props.kind==="sector"?`M ${t} ${n} L ${o.x} ${o.y} A ${t} ${n} 0 ${s} 1 ${i.x} ${i.y} Z`:`M ${o.x} ${o.y} A ${t} ${n} 0 ${s} 1 ${i.x} ${i.y}`}function ap(e){return e.props.kind!=="sector"||e.props.fill==="none"?"none":e.props.fillColor??e.props.color}function Ct(e,t,n){let r=Rn(n,e,t);return r?`url(#${r})`:void 0}var EL=ed();import{Fragment as pp,jsx as L,jsxs as Oe}from"react/jsx-runtime";var Go=14;function cp(e,t,n){if(!n)return"center";let r=Qe(e);return`${r.x-t.x}px ${r.y-t.y}px`}function sp(e,t){let n=Jr(e);return n?{x:n.anchor.x-t.x,y:n.anchor.y-t.y}:null}var jv=()=>{},qv=()=>{};var Zv=()=>{},Jv=()=>{};function up({shape:e,assets:t,externalRevision:n=0,diffClassName:r,decoration:o}){return L(Qv,{shape:e,assets:t,externalRevision:n,selected:!1,editing:!1,disableGraphCrop:!0,hideGraphAxes:!1,originPickPreview:null,dragTranslate:null,diffClassName:r,decoration:o,onPointerDown:Zv,onDoubleClick:Jv,onGraphSpecChange:jv,onGraphCropEnd:qv})}function dp(e,t){let n=[];return t&&(t.x!==0||t.y!==0)&&n.push(`translate(${t.x}px, ${t.y}px)`),e&&n.push(`rotate(${e}rad)`),n.length>0?n.join(" "):void 0}var Qv=$o(function({shape:t,assets:n,externalRevision:r,selected:o,editing:i,disableGraphCrop:a,hideGraphAxes:s,originPickPreview:c,dragTranslate:l,onPointerDown:d,onDoubleClick:u,onGraphSpecChange:m,onGraphCropEnd:h,diffClassName:y,decoration:g,editorRenderers:x}){wt("OverlayShapeView.render");let S=de(t),I=ve(t),R=`overlay-shape overlay-shape-${t.type} ${o?"selected":""} ${t.locked?"locked":""} ${g?.className??""} ${y??""}`;return Oe("div",{"data-overlay-shape-id":t.id,className:R,style:{left:S.x,top:S.y,width:S.w,height:S.h,transform:dp(I,l),transformOrigin:cp(t,S,I),opacity:t.opacity},onPointerDown:P=>d(P,t),onDoubleClickCapture:P=>{t.type==="graph2dShape"&&(P.preventDefault(),P.stopPropagation(),u(P,t))},onDoubleClick:P=>{t.type!=="graph2dShape"&&(P.preventDefault(),P.stopPropagation(),u(P,t))},children:[L(tM,{shape:t,assets:n,bounds:S,externalRevision:r,editing:i,disableGraphCrop:a,hideGraphAxes:s,originPickPreview:c,onGraphSpecChange:m,onGraphCropEnd:h,editorRenderers:x}),g?.content]})}),eN=$o(function({shapes:t,dragTranslate:n,movingShapeIds:r}){return L(pp,{children:t.map(o=>L(eM,{shape:o,dragTranslate:r?.has(o.id)?n:null},`dimension-${o.id}`))})}),eM=$o(function({shape:t,dragTranslate:n}){let r=Ei(t),o=yi(r,ve(t)),i=r.x+r.w/2,a=n?.x??0,s=n?.y??0;return L("div",{className:"overlay-shape-dimension-label",style:{left:i+a,top:o.y+o.h+2+s},"aria-hidden":"true",children:oM(r)})}),tN=$o(function({shape:t,selected:n,dragTranslate:r,onPointerDown:o,onDoubleClick:i}){let a=de(t),s=ve(t);return L("div",{"data-overlay-shape-id":t.id,className:`overlay-shape overlay-shape-hit-target ${n?"selected":""}`,style:{left:a.x,top:a.y,width:a.w,height:a.h,transform:dp(s,r),transformOrigin:cp(t,a,s)},onPointerDown:c=>o(c,t),onDoubleClick:c=>{c.preventDefault(),c.stopPropagation(),i(c,t)}})});function tM({shape:e,assets:t,bounds:n,externalRevision:r,editing:o,disableGraphCrop:i,hideGraphAxes:a,originPickPreview:s,onGraphSpecChange:c,onGraphCropEnd:l,editorRenderers:d}){if(e.type==="geo"){let u=re(e.props.size),m={x:e.props.w/2,y:e.props.h/2};return Oe("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${e.props.w} ${e.props.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:u,strokeDasharray:xn(e.props.dash)},children:[L(nM,{shape:e}),e.props.label&&L("text",{x:m.x,y:m.y,fill:e.props.labelColor,stroke:"none",textAnchor:"middle",dominantBaseline:"middle",fontSize:$e(e.props.size),children:e.props.label})]})}if(e.type==="arrow"){let u={x:e.x+e.props.start.x-n.x,y:e.y+e.props.start.y-n.y},m={x:e.x+e.props.end.x-n.x,y:e.y+e.props.end.y-n.y},h=sp(e,n),y=re(e.props.size),g=We(e),[x,S]=Xt([u,m],g.start.trimPx,g.end.trimPx);return Oe("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:y,strokeDasharray:xn(e.props.dash)},children:[L("defs",{children:L(Qa,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:g})}),L("line",{x1:x.x,y1:x.y,x2:S.x,y2:S.y,strokeOpacity:e.props.strokeOpacity,markerStart:Ct(e.id,"start",g.start.spec?.kind),markerEnd:Ct(e.id,"end",g.end.spec?.kind)}),h&&L("text",{x:h.x,y:h.y,fill:e.props.labelColor,stroke:"none",textAnchor:"middle",fontSize:$e(e.props.size),children:e.props.label})]})}if(e.type==="line"){let u=Me(e.props.kind),m=e.props.points.map(z=>({x:e.x+z.x-n.x,y:e.y+z.y-n.y})),h=Ve(u,m,e.props.closed),y=sp(e,n),g=re(e.props.size),x=We(e),S=Xt(m,x.start.trimPx,x.end.trimPx),I=Ct(e.id,"start",x.start.spec?.kind),R=Ct(e.id,"end",x.end.spec?.kind),P=`fill-${e.id}`,C=h&&e.props.fill==="solid"?e.props.fillPattern==="diagonalHatch"?`url(#${P})`:e.props.fillColor??e.props.color:"none";return Oe("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:g,strokeDasharray:xn(e.props.dash)},children:[Oe("defs",{children:[L(Qa,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:x}),e.props.fillPattern==="diagonalHatch"&&Oe("pattern",{id:P,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[L("rect",{width:"6",height:"6",fill:e.props.fillColor??"#ffffff"}),L("path",{d:"M -1 7 L 7 -1",stroke:e.props.color,strokeWidth:"1"})]})]}),h?L("polygon",{points:gt(m),fill:C,fillOpacity:e.props.fillOpacity,strokeOpacity:e.props.strokeOpacity}):u==="polyline"?L("polyline",{points:gt(S),strokeOpacity:e.props.strokeOpacity,markerStart:I,markerEnd:R}):L("path",{d:zn(m,u,Kr(x)),strokeOpacity:e.props.strokeOpacity,markerStart:I,markerEnd:R}),y&&L("text",{x:y.x,y:y.y,fill:e.props.labelColor??e.props.color,stroke:"none",textAnchor:"middle",fontSize:$e(e.props.size),children:e.props.label})]})}if(e.type==="arc"){let u=re(e.props.size),m=We(e),h=Ct(e.id,"start",m.start.spec?.kind),y=Ct(e.id,"end",m.end.spec?.kind);return Oe("svg",{className:"overlay-vector-svg",viewBox:`0 0 ${n.w} ${n.h}`,"aria-hidden":"true",style:{color:e.props.color,strokeWidth:u,strokeDasharray:xn(e.props.dash)},children:[L("defs",{children:L(Qa,{shapeId:e.id,color:e.props.color,opacity:e.props.strokeOpacity,plan:m})}),L("path",{d:ip(e),fill:ap(e),fillOpacity:e.props.kind==="sector"?e.props.fillOpacity:void 0,stroke:"currentColor",strokeOpacity:e.props.strokeOpacity,markerStart:h,markerEnd:y})]})}if(e.type==="image"){let u=t[e.props.assetId];return u?L(rM,{shape:e,asset:u,editing:o}):null}if(e.type==="callout"){let u=Vt(e),m=Gr(e),h=e.x-n.x,y=e.y-n.y;return Oe("div",{className:"callout-shape overlay-callout-shape",children:[L("svg",{className:"callout-shape-svg",viewBox:`${u.bounds.x} ${u.bounds.y} ${u.bounds.w} ${u.bounds.h}`,"aria-hidden":"true",style:{strokeWidth:re(e.props.strokeWidth),strokeDasharray:xn(e.props.dash)},children:L("path",{d:_n(e)})}),L("div",{className:"overlay-callout-text-frame",style:{left:h+m.x,top:y+m.y,width:m.w,height:m.h},children:o&&d?d.renderTextEditor({editing:o,externalRevision:r,shape:e}):L(lp,{shape:e})})]})}if(e.type==="graph2dShape"){let u=Ge(e),m=u.spec,h=a?iM(m):m,y=o||i||a||s!==null;return Oe("div",{id:e.id,className:"graph-shape overlay-graph-shape","data-testid":"overlay-graph2d",style:{position:"absolute",left:u.renderBounds.x-e.x,top:u.renderBounds.y-e.y,width:u.renderBounds.w,height:u.renderBounds.h,pointerEvents:y?"auto":"none"},children:[L(Et,{spec:h,autoStartCrop:o,disableCropInteraction:i,onSpecChange:(g,x)=>c(e.id,g,x),onCropEnd:l}),s&&Oe("div",{className:"graph-origin-preview","data-testid":"overlay-graph-origin-preview","aria-hidden":"true",children:[L(Et,{spec:aM(s.spec),className:"graph-origin-preview-graph",staticMode:!0,disableCropInteraction:!0}),Oe("svg",{className:"graph-origin-preview-marker","data-testid":"overlay-graph-origin-preview-target",viewBox:`0 0 ${s.spec.width} ${s.spec.height}`,"aria-hidden":"true",children:[L("line",{x1:Math.max(0,s.point.x-Go),x2:Math.min(s.spec.width,s.point.x+Go),y1:s.point.y,y2:s.point.y}),L("line",{x1:s.point.x,x2:s.point.x,y1:Math.max(0,s.point.y-Go),y2:Math.min(s.spec.height,s.point.y+Go)}),L("circle",{cx:s.point.x,cy:s.point.y,r:"6"})]})]})]})}return e.type==="tableShape"?d?d.renderTableEditor({editing:o,shape:e}):L(ur,{height:e.props.h,table:e.props.table,width:e.props.w}):e.type==="group"?null:!o||!d?L(lp,{shape:e}):d.renderTextEditor({editing:o,externalRevision:r,shape:e})}function nM({shape:e}){let n={fill:e.props.fill==="solid"?e.props.fillColor??e.props.color:"transparent",stroke:e.props.color,fillOpacity:e.props.fillOpacity,strokeOpacity:e.props.strokeOpacity};if(e.props.geo==="ellipse")return L("ellipse",{cx:e.props.w/2,cy:e.props.h/2,rx:Math.max(1,e.props.w/2-1),ry:Math.max(1,e.props.h/2-1),...n});if(e.props.geo==="triangle"||e.props.geo==="diamond"||e.props.geo==="pentagon"||e.props.geo==="regularPolygon"||e.props.geo==="blockArrow")return L("polygon",{points:op(e.props.geo,e.props.w,e.props.h,e.props.apexX,e.props.headLengthRatio,e.props.shaftRatio,e.props.polygonSides),...n});let r=typeof e.props.radius=="number"&&e.props.radius>0?Math.max(0,Math.min(e.props.radius,e.props.w/2-1,e.props.h/2-1)):void 0;return L("rect",{x:1,y:1,width:Math.max(1,e.props.w-2),height:Math.max(1,e.props.h-2),rx:r,ry:r,...n})}function Qa({shapeId:e,color:t,opacity:n,plan:r}){return L(pp,{children:Tr(e,r).map(({spec:o,endpoint:i,id:a,refX:s})=>L("marker",{id:a,markerWidth:o.markerWidth,markerHeight:o.markerHeight,refX:s,refY:o.refY,orient:Or(o,i),markerUnits:"strokeWidth",children:o.geometry.kind==="circle"?L("circle",{cx:o.geometry.cx,cy:o.geometry.cy,r:o.geometry.r,fill:o.geometry.filled?t:"none",opacity:n,stroke:"none"}):L("path",{d:An(o.geometry),fill:o.geometry.filled?t:"none",opacity:n,stroke:o.geometry.filled?"none":t,strokeWidth:o.geometry.filled?void 0:o.geometry.strokeWidth,strokeLinecap:"butt",strokeLinejoin:"miter"})},a))})}function lp({shape:e}){let t=ht(e),n=e.type==="callout",r=e.type==="text"&&e.props.autoSize,o=e.type==="text"&&e.props.autoSize&&e.props.maxWidth!==void 0;return L("div",{className:`overlay-text-shape ${n?"embedded-callout":""} ${r?"auto-size":""} ${o?"constrained":""}`,style:{width:n?"100%":o?e.props.maxWidth:r?"max-content":e.props.w,minWidth:n?0:En,minHeight:n?t:Math.max(e.props.h??0,t),color:e.props.color,fontSize:`${yt(e)}pt`,pointerEvents:"none"},children:L("div",{className:"overlay-text-shape-content ProseMirror",children:L(Za,{node:e.props.richText,keyPrefix:`overlay-text-${e.id}`})})})}function rM({shape:e,asset:t,editing:n}){let r=np(e,t);return Oe("div",{className:`overlay-image-frame ${n?"cropping":""}`,children:[n&&L("div",{className:"overlay-image-crop-ghost",style:{width:r.width,height:r.height,transform:r.transform},"aria-hidden":"true",children:L("img",{src:t.props.src,alt:"",draggable:!1})}),L("div",{className:"overlay-image-crop-viewport",children:L("div",{className:"overlay-image-crop-inner",style:{width:r.width,height:r.height,transform:r.transform},children:L("img",{className:"overlay-image-shape",src:t.props.src,alt:t.props.name,draggable:!1})})})]})}function oM(e){return`${Math.max(1,Math.round(e.w))} x ${Math.max(1,Math.round(e.h))}`}function iM(e){return{...e,axes:{...e.axes,grid:!1,showX:!1,showY:!1,showTicks:!1}}}function aM(e){return{...e,title:"",axes:{...e.axes,grid:!1,showX:!0,showY:e.kind==="cartesian",showTicks:!1},points:void 0,annotations:void 0,fills:void 0,showFormulaLabels:!1}}import{jsx as fp}from"react/jsx-runtime";function yp({overlay:e,widthPx:t,heightPx:n,interactive:r=!1,className:o,onPointerDown:i,onDoubleClick:a}){let s=mp(()=>{let l=e?.overlaySnapshot;if(!l)return[];let d=Wt(me(l).shapes);return Nr(d).map(u=>{let m=Fr(d,u);return m===u.opacity?u:{...u,opacity:m}})},[e?.overlaySnapshot]),c=mp(()=>me(e?.overlaySnapshot).assets,[e?.overlaySnapshot]);return fp("div",{className:[o??"page-running-overlay-preview",r?"interactive":""].filter(Boolean).join(" "),"aria-hidden":"true",style:{width:`${t}px`,height:`${n}px`},onPointerDown:i,onDoubleClick:a,children:s.map(l=>fp(up,{shape:l,assets:c},l.id))})}import{jsx as zo,jsxs as lM}from"react/jsx-runtime";function es({region:e,kind:t,title:n,pageNumber:r,totalPages:o,metrics:i,mathFractionSizing:a}){if(!e?.enabled||!Jc(e)||r===1&&!e.showOnFirstPage)return null;let s={left:`${i.margins.leftPx}px`,right:`${i.margins.rightPx}px`,height:`${ne(e.heightMm)}px`,[t==="header"?"top":"bottom"]:`${ne(e.offsetMm)}px`},c=du(i.content.widthPx,e),l=d=>sM(d,n,r,o);return lM("div",{className:`page-running-region ${t} free`,style:s,children:[zo(yp,{overlay:e.overlay,widthPx:c.widthPx,heightPx:c.heightPx}),zo("div",{className:"page-running-text-layer text-flow-shell",children:zo("div",{className:"text-flow-editor",children:e.blocks.map(d=>zo(Do,{block:d,mathFractionSizing:a,resolveText:l},d.id))})})]})}function sM(e,t,n,r){return e.split(/(\{title\}|\{page\}|\{total\}|\/\s*title|\/\s*page|\/\s*total)/g).map(o=>{let i=o.replace(/\s+/g,"");return i==="{title}"||i==="/title"?t:i==="{page}"||i==="/page"?String(n):i==="{total}"||i==="/total"?String(r):o}).join("")}import{jsx as uM}from"react/jsx-runtime";var cM={heading:"print-heading",list:"print-list",paragraph:"print-paragraph"};function bn({block:e,mathFractionSizing:t,resolveText:n}){return uM(Do,{block:e,classNames:cM,mathFractionSizing:t,resolveText:n})}var dM=64,lt='stroke-linecap="butt" stroke-linejoin="miter"',pM=.6;function hp(e){return Math.ceil(e*pM)}function rs(e,t,n,r,o={}){if(e.length===0)return;let i=me({version:1,shapes:e,assets:t}),a=i.assets,s=Wt(i.shapes),c=o.stackLayer?gl(s,o.stackLayer):s,d=Nr(c).filter(y=>mM(y,n,o.viewportPaddingPx));if(d.length===0)return;let u=n.offsetX??0,m=n.offsetY??0,h=d.map(y=>fM(hM(y,Fr(c,y)),a,r)).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${u} ${m} ${n.width} ${n.height}" width="${n.width}" height="${n.height}">`,"<defs>","</defs>",h,"</svg>"].join("")}function mM(e,t,n=dM){let r=t.offsetX??0,o=t.offsetY??0,i=r-n,a=o-n,s=r+t.width+n,c=o+t.height+n,l=de(e);return l.x+l.w>=i&&l.x<=s&&l.y+l.h>=a&&l.y<=c}function gp(e){return Pe(e)?e:jt}function fM(e,t,n){let r="";if(e.type==="group")return"";if(e.type==="geo"){let o=K(e.props.color||"#111111"),i=re(e.props.size),a=dr(e.props.dash),s=e.props.fill==="solid"?K(e.props.fillColor||e.props.color||"#111111"):"transparent",c=ct("stroke-opacity",e.props.strokeOpacity),l=ct("fill-opacity",e.props.fillOpacity);if(e.props.geo==="ellipse")return r=`<ellipse cx="${e.x+e.props.w/2}" cy="${e.y+e.props.h/2}" rx="${e.props.w/2}" ry="${e.props.h/2}" fill="${s}" stroke="${o}" stroke-width="${i}" ${lt}${a}${c}${l} />`,Be(e,Fe(e,ts(e,r)));if(e.props.geo==="triangle"||e.props.geo==="diamond"||e.props.geo==="pentagon"||e.props.geo==="regularPolygon"||e.props.geo==="blockArrow")return r=`<polygon points="${vM(xM(e.props.geo,e.props.w,e.props.h,e.props.apexX,e.props.headLengthRatio,e.props.shaftRatio,e.props.polygonSides),e.x,e.y)}" fill="${s}" stroke="${o}" stroke-width="${i}" ${lt}${a}${c}${l} />`,Be(e,Fe(e,ts(e,r)));let d=typeof e.props.radius=="number"&&e.props.radius>0?Math.max(0,Math.min(e.props.radius,e.props.w/2,e.props.h/2)):0,u=d>0?` rx="${d}" ry="${d}"`:"";return r=`<rect x="${e.x}" y="${e.y}" width="${e.props.w}" height="${e.props.h}"${u} fill="${s}" stroke="${o}" stroke-width="${i}" ${lt}${a}${c}${l} />`,Be(e,Fe(e,ts(e,r)))}if(e.type==="arrow"){let o={x:e.x+e.props.start.x,y:e.y+e.props.start.y},i={x:e.x+e.props.end.x,y:e.y+e.props.end.y},a=We(e),[s,c]=Xt([o,i],a.start.trimPx,a.end.trimPx),l=ns(e.id,e.props.color,e.props.strokeOpacity,a),d=Sn("marker-start",e.id,"start",a.start.spec?.kind),u=Sn("marker-end",e.id,"end",a.end.spec?.kind);return r=`<defs>${l}</defs><line x1="${s.x}" y1="${s.y}" x2="${c.x}" y2="${c.y}" stroke="${K(e.props.color)}" stroke-width="${re(e.props.size)}" ${lt}${dr(e.props.dash)}${ct("stroke-opacity",e.props.strokeOpacity)}${d}${u} />`,Be(e,Fe(e,xp(e,r)))}if(e.type==="line"){let o=Me(e.props.kind),i=e.props.points.map(x=>({x:e.x+x.x,y:e.y+x.y})),a=Ve(o,i,e.props.closed),s=We(e),c=Xt(i,s.start.trimPx,s.end.trimPx),l=ns(e.id,e.props.color,e.props.strokeOpacity,s),d=Sn("marker-start",e.id,"start",s.start.spec?.kind),u=Sn("marker-end",e.id,"end",s.end.spec?.kind),m=gM(e),h=a&&e.props.fill==="solid"?e.props.fillPattern==="diagonalHatch"?`url(#${K(Sp(e.id))})`:K(e.props.fillColor||e.props.color||"#111111"):"none",y=a?ct("fill-opacity",e.props.fillOpacity):"",g=`fill="${h}" stroke="${K(e.props.color)}" stroke-width="${re(e.props.size)}" ${lt}${dr(e.props.dash)}${ct("stroke-opacity",e.props.strokeOpacity)}${y}${d}${u}`;return r=a?`<defs>${l}${m}</defs><polygon points="${gt(i)}" ${g} />`:o==="polyline"?`<defs>${l}${m}</defs><polyline points="${gt(c)}" ${g} />`:`<defs>${l}${m}</defs><path d="${K(zn(i,o,Kr(s)))}" ${g} />`,Be(e,Fe(e,xp(e,r)))}if(e.type==="arc"){let o=SM(e),i=e.props.kind==="sector"?ct("fill-opacity",e.props.fillOpacity):"",a=We(e),s=ns(e.id,e.props.color,e.props.strokeOpacity,a),c=Sn("marker-start",e.id,"start",a.start.spec?.kind),l=Sn("marker-end",e.id,"end",a.end.spec?.kind);return r=`<defs>${s}</defs><path d="${K(bM(e))}" fill="${o}" stroke="${K(e.props.color)}" stroke-width="${re(e.props.size)}" ${lt}${dr(e.props.dash)}${ct("stroke-opacity",e.props.strokeOpacity)}${i}${c}${l} />`,Be(e,Fe(e,r))}if(e.type==="image"){let o=t[e.props.assetId],i=o?yM(o):null;if(!i)return"";let a=Kt(e,o),s=Hn(e,o,a),c=e.x+s.x,l=e.y+s.y,d=`clip-${K(e.id)}`;return r=[`<clipPath id="${d}"><rect x="${e.x}" y="${e.y}" width="${e.props.w}" height="${e.props.h}" /></clipPath>`,`<image x="${c}" y="${l}" width="${s.width}" height="${s.height}" href="${K(i)}" preserveAspectRatio="none" clip-path="url(#${d})" />`].join(""),Be(e,Fe(e,r))}if(e.type==="callout"){let o=Gr(e),i=yt(e),a=hp(ze(e)),s=Ia(e.props.richText,{renderMathHtml:n.renderMathHtml,selfContained:!0}),c=`<path transform="translate(${e.x} ${e.y})" d="${K(_n(e))}" fill="transparent" stroke="#111111" stroke-width="${re(e.props.strokeWidth)}" ${lt}${dr(e.props.dash)} />`,l=Ho(e.x+o.x-a,e.y+o.y-a,o.w+a*2,o.h+a*2,[`<div xmlns="http://www.w3.org/1999/xhtml" style="box-sizing:border-box;display:flex;align-items:center;justify-content:center;width:${o.w}px;height:${o.h}px;margin:${a}px;color:${K(gp(e.props.color))};font-size:${i}pt;line-height:${Ie};overflow:visible;overflow-wrap:anywhere;white-space:pre-wrap;text-align:center;">`,`<div style="width:100%;min-width:0;">${s}</div>`,"</div>"].join(""),{overflowVisible:!0});return r=`${c}${l}`,Be(e,Fe(e,r))}if(e.type==="graph2dShape"){let o=Ge(e),i=n.renderGraphHtml(o.spec,e.id);return r=Ho(o.renderBounds.x,o.renderBounds.y,o.renderBounds.w,o.renderBounds.h,[`<div xmlns="http://www.w3.org/1999/xhtml" style="width:${o.renderBounds.w}px;height:${o.renderBounds.h}px;overflow:hidden;background:transparent;">`,i,"</div>"].join("")),Be(e,Fe(e,r))}if(e.type==="text"){let o=de(e),i=yt(e),a=hp(ze(e)),s=Ia(e.props.richText,{renderMathHtml:n.renderMathHtml,selfContained:!0}),c=e.props.autoSize?e.props.maxWidth!==void 0?"white-space:pre-wrap;overflow-wrap:anywhere;":"white-space:pre;":"white-space:pre-wrap;";return r=Ho(e.x-a,e.y-a,o.w+a*2,o.h+a*2,[`<div xmlns="http://www.w3.org/1999/xhtml" style="box-sizing:border-box;width:${o.w}px;min-height:${o.h}px;margin:${a}px;color:${K(gp(e.props.color))};font-size:${i}pt;line-height:${Ie};overflow:visible;${c}">`,s,"</div>"].join(""),{overflowVisible:!0}),Be(e,Fe(e,r))}if(e.type==="tableShape"){let o=PM(e.props.table);return r=Ho(e.x-o,e.y-o,e.props.w+o*2,e.props.h+o*2,n.renderTableHtml(e.props.table,e.props.w,e.props.h,o)),Be(e,r)}return""}function yM(e){return e.props.storage&&e.props.src.startsWith("sigma-doc-storage://")?null:Vn(e.props.src)}function hM(e,t){return t===void 0?e:{...e,opacity:t}}function Fe(e,t){let n=ve(e);if(!n)return t;let r=Qe(e);return`<g transform="rotate(${MM(n)} ${r.x} ${r.y})">${t}</g>`}function Be(e,t){return e.opacity===void 0||e.opacity>=1?t:`<g opacity="${e.opacity}">${t}</g>`}function ts(e,t){return e.props.label?[t,`<text x="${e.x+e.props.w/2}" y="${e.y+e.props.h/2}" fill="${K(e.props.labelColor)}" stroke="none" text-anchor="middle" dominant-baseline="middle" font-size="${$e(e.props.size)}">${ge(e.props.label)}</text>`].join(""):t}function xp(e,t){let n=Jr(e);return n?[t,`<text x="${n.anchor.x}" y="${n.anchor.y}" fill="${K(e.props.labelColor??e.props.color)}" stroke="none" text-anchor="middle" font-size="${n.fontSizePx}">${ge(n.text)}</text>`].join(""):t}function ns(e,t,n,r){let o=K(t),i=ct("opacity",n);return Tr(e,r).map(({spec:a,endpoint:s,id:c,refX:l})=>{let d=a.geometry.kind==="circle"?`<circle cx="${a.geometry.cx}" cy="${a.geometry.cy}" r="${a.geometry.r}" fill="${a.geometry.filled?o:"none"}"${i} />`:a.geometry.filled?`<path d="${An(a.geometry)}" fill="${o}" stroke="none"${i} />`:`<path d="${An(a.geometry)}" fill="none" stroke="${o}" stroke-width="${a.geometry.strokeWidth}" ${lt}${i} />`;return`<marker id="${K(c)}" markerWidth="${a.markerWidth}" markerHeight="${a.markerHeight}" refX="${l}" refY="${a.refY}" orient="${Or(a,s)}" markerUnits="strokeWidth">${d}</marker>`}).join("")}function Sp(e){return`fill-${e}`}function gM(e){if(e.props.fillPattern!=="diagonalHatch")return"";let t=K(Sp(e.id)),n=K(e.props.fillColor??"#ffffff"),r=K(e.props.color);return`<pattern id="${t}" patternUnits="userSpaceOnUse" width="6" height="6"><rect width="6" height="6" fill="${n}" /><path d="M -1 7 L 7 -1" stroke="${r}" stroke-width="1" /></pattern>`}function Sn(e,t,n,r){let o=Rn(r,t,n);return o?` ${e}="url(#${K(o)})"`:""}function dr(e){return e==="dashed"?' stroke-dasharray="8 6"':e==="dotted"?' stroke-dasharray="1 6"':""}function ct(e,t){return t===void 0||t>=1?"":` ${e}="${Math.max(0,t)}"`}function xM(e,t,n,r,o,i,a){return e==="blockArrow"?xt(t,n,o,i):e==="triangle"?[{x:Dt(r??t/2,0,t),y:0},{x:t,y:n},{x:0,y:n}]:e==="diamond"?[{x:t/2,y:0},{x:t,y:n/2},{x:t/2,y:n},{x:0,y:n/2}]:St(t,n,e==="pentagon"?5:bt(a))}function bM(e){let{rx:t,ry:n}=ce(e),r=jr(e),o=bp(e,r.startAngle),i=bp(e,r.endAngle),s=Se(r.endAngle-r.startAngle)>Math.PI?1:0;return e.props.kind==="sector"?`M ${e.x+t} ${e.y+n} L ${e.x+o.x} ${e.y+o.y} A ${t} ${n} 0 ${s} 1 ${e.x+i.x} ${e.y+i.y} Z`:`M ${e.x+o.x} ${e.y+o.y} A ${t} ${n} 0 ${s} 1 ${e.x+i.x} ${e.y+i.y}`}function SM(e){return e.props.kind!=="sector"||e.props.fill==="none"?"none":K(e.props.fillColor??e.props.color)}function bp(e,t){let{rx:n,ry:r}=ce(e);return{x:n+Math.cos(t)*n,y:r+Math.sin(t)*r}}function vM(e,t,n){return e.map(r=>`${t+r.x},${n+r.y}`).join(" ")}function MM(e){return e*180/Math.PI}function Ho(e,t,n,r,o,i={}){let a=i.overflowVisible?' overflow="visible"':"";return`<foreignObject x="${e}" y="${t}" width="${n}" height="${r}"${a}>${o}</foreignObject>`}function PM(e){let t=0;for(let n=0;n<=e.columns.length;n+=1){let r=zt(e,n);if(!r)continue;let o=Ae(e,r);o.visible&&(t=Math.max(t,o.borderWidth))}for(let n=0;n<=e.rows.length;n+=1){let r=Ht(e,n);if(!r)continue;let o=Ae(e,r);o.visible&&(t=Math.max(t,o.borderWidth))}return Math.ceil(t)}import{renderToStaticMarkup as Mp}from"react-dom/server";import{jsx as Uo}from"react/jsx-runtime";var vp=new WeakMap,OM=8;function wM(e,t,n,r,o){let i=vp.get(e);i||(i=new Map,vp.set(e,i));let a=Le(o,`${t}x${n}x${r}`),s=i.get(a);if(s!==void 0)return s;let c=kM(Mp(Uo(fn,{environment:o,children:Uo(ur,{height:n,overflow:r,selfContained:!0,table:e,width:t,xmlns:"http://www.w3.org/1999/xhtml"})})));return i.size>=OM&&i.delete(i.keys().next().value),i.set(a,c),c}function kM(e){return e.replace(/<td\b[^>]*>/g,t=>t.replace(/ (rowSpan|colSpan)=/g,(n,r)=>` ${r.toLowerCase()}=`))}function BM(e){return{renderGraphHtml:(t,n)=>Mp(Uo(fn,{environment:e,children:Uo(Et,{idSeed:n,spec:t,staticMode:!0})})),renderMathHtml:t=>at(t,e),renderTableHtml:(t,n,r,o)=>wM(t,n,r,o,e)}}function Vo(e,t,n=sa,r={}){return rs(e,t,n,BM(r.mathEnvironment??sn),r)}function RM(e){return e.numbering?.enabled!==!1}function Pp(e){let t=new Map,n=1;for(let r of e){if(r.type!=="problem"||!RM(r))continue;let o=AM(r)??n;t.set(r.id,o),n=o+1}return t}function AM(e){let t=e.numbering?.value;return typeof t=="number"&&Number.isInteger(t)&&t>0?t:void 0}function Tp(e){return String(e)}var Op='"Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Times New Roman", serif',EM=32,CM=21,is=57.35,Rp=1,LM=9,NM=18,FM=.15,_M=.62,DM=.6,GM=.25,$M=4,zM=8,HM={cornerSquares:"box-frame--corner-squares",doubleRule:"box-frame--double-rule",titleDoubleRule:"box-frame--title-double-rule",titleBand:"box-frame--title-band",titlePlate:"box-frame--title-plate",leftBar:"box-frame--left-bar",shadow:"box-frame--shadow",horizontalRules:"box-frame--horizontal-rules",notebookRules:"box-frame--notebook-rules"},UM={cornerSquares:"data-box-corner-squares",doubleRule:"data-box-double-rule",titleDoubleRule:"data-box-title-double-rule",titleBand:"data-box-title-band",titlePlate:"data-box-title-plate",leftBar:"data-box-left-bar",shadow:"data-box-shadow",horizontalRules:"data-box-horizontal-rules",notebookRules:"data-box-notebook-rules"},os="#1f2937",VM="#cbd5e1",wp="#e2e8f0",WM="#f1f5f9",XM="#f8fafc",YM="#9ca3af",KM="#b9b3a1",jM="#706b5a",qM=[{id:"fancybox",commandName:"fancybox",displayName:"fancybox",description:"\u672C\u6587\u3092\u6BB5\u5E45\u3044\u3063\u3071\u3044\u306E\u67A0\u3067\u56F2\u3080",aliases:["framed","framebox","fbox","box","\u67A0","\u56F2\u307F"],frame:{borderWidthPx:1.4,borderColor:"#111111",borderStyle:"solid",backgroundColor:"#ffffff",cornerStyle:"sharp",paddingPx:{top:12,right:14,bottom:12,left:14}}},{id:"itembox",commandName:"itembox",displayName:"itembox",description:"\u898B\u51FA\u3057\u30E9\u30D9\u30EB\u4ED8\u304D\u306E\u7BB1",aliases:["item","\u898B\u51FA\u3057","\u30DD\u30A4\u30F3\u30C8","\u8981\u70B9"],defaultTitle:"\u30DD\u30A4\u30F3\u30C8",frame:{borderWidthPx:1,borderColor:"#000000",borderStyle:"solid",backgroundColor:"#ffffff",titleBackgroundColor:"#ffffff",titleAlign:"left",titleFontWeight:"bold",cornerStyle:"sharp",paddingPx:{top:16,right:14,bottom:12,left:14},decorations:[]}},{id:"tcolorbox",commandName:"tcolorbox",displayName:"tcolorbox",description:"\u5E2F\u898B\u51FA\u3057\u4ED8\u304D\u306E\u7BB1",aliases:["tcbox","\u5B9A\u7406","\u5B9A\u7FA9","\u5E2F"],defaultTitle:"\u5B9A\u7406",frame:{borderWidthPx:1,borderColor:VM,borderStyle:"solid",backgroundColor:"#ffffff",titleBackgroundColor:wp,titleAlign:"left",titleFontWeight:"bold",cornerStyle:"sharp",paddingPx:{top:42,right:14,bottom:12,left:14},decorations:[{type:"titleBand",heightPx:32,backgroundColor:wp}]}},{id:"tcolorbox-note",commandName:"tcolorbox-note",displayName:"tcolorbox \u30CE\u30FC\u30C8\u7F6B",description:"\u5DE6\u30EA\u30F3\u30B0\u4ED8\u304D\u306E\u30CE\u30FC\u30C8\u7BB1",aliases:["note","notebox","\u30CE\u30FC\u30C8","\u30CE\u30FC\u30C8\u7F6B","\u30EA\u30F3\u30B0","\u7F6B\u7DDA","\u672C\u6587"],frame:{borderWidthPx:1,borderColor:YM,borderStyle:"solid",backgroundColor:"#ffffff",bodyAlign:"justify",bodyFontSizePx:15,bodyLineHeight:"23.35px",cornerStyle:"sharp",paddingPx:{top:18,right:18,bottom:16,left:56},decorations:[{type:"notebookRules",baseBodyWidthPx:660,frameLeftPx:20,frameHeightPx:is,frameStrokeOpacity:.85,bindingColor:KM,bindingWidthPx:1,bindingXPx:20,bindingStrokeOpacity:.75,ringColor:jM,ringWidthPx:38,ringHeightPx:12,ringStrokePx:1.2,ringGapPx:23.35,ringTopPx:8,ringCount:Rp,ringLeftOverhangPx:14,minHeightPx:is}]}},{id:"doublebox",commandName:"doublebox",displayName:"doublebox",description:"\u4E8C\u91CD\u7F6B\u7DDA\u306E\u7BB1\u3092\u633F\u5165",aliases:["double","\u4E8C\u91CD"],frame:{borderWidthPx:1.1,borderColor:"#111111",borderStyle:"solid",backgroundColor:"#ffffff",cornerStyle:"sharp",paddingPx:{top:14,right:16,bottom:14,left:16},decorations:[{type:"doubleRule",offsetPx:4,widthPx:1,color:"#111111"}]}},{id:"shadebox",commandName:"shadebox",displayName:"shadebox",description:"\u8584\u3044\u5730\u8272\u306E\u7BB1",aliases:["shade","\u80CC\u666F","\u88DC\u8DB3","\u30B3\u30E9\u30E0"],frame:{borderWidthPx:1,borderColor:"#000000",borderStyle:"solid",backgroundColor:WM,cornerStyle:"round",radiusPx:3,paddingPx:{top:12,right:14,bottom:12,left:14}}},{id:"leftbar",commandName:"leftbar",displayName:"leftbar",description:"\u5DE6\u7F6B\u3067\u5F37\u8ABF\u3059\u308B\u7BB1",aliases:["\u5DE6\u7F6B","\u5F15\u7528","\u6CE8\u610F"],frame:{borderWidthPx:1,borderColor:"#000000",borderStyle:"solid",backgroundColor:XM,cornerStyle:"sharp",paddingPx:{top:12,right:14,bottom:12,left:18},decorations:[{type:"leftBar",widthPx:5,color:os}]}},{id:"dashedbox",commandName:"dashedbox",displayName:"dashedbox",description:"\u7834\u7DDA\u306E\u7BB1",aliases:["dashed","\u7834\u7DDA","\u8A18\u5165","\u30E1\u30E2"],frame:{borderWidthPx:1.2,borderColor:"#475569",borderStyle:"dashed",backgroundColor:"#ffffff",cornerStyle:"sharp",paddingPx:{top:12,right:14,bottom:12,left:14}}},{id:"ruledbox",commandName:"ruledbox",displayName:"ruledbox",description:"\u4E0A\u4E0B\u7F6B\u3060\u3051\u3067\u533A\u5207\u308B\u7BB1",aliases:["rule","\u4E0A\u4E0B\u7F6B","\u307E\u3068\u3081"],defaultTitle:"\u5B9A\u7FA9",frame:{borderWidthPx:0,borderColor:"transparent",borderStyle:"none",backgroundColor:"#ffffff",titleAlign:"left",titleFontWeight:"bold",cornerStyle:"sharp",paddingPx:{top:12,right:0,bottom:12,left:0},decorations:[{type:"horizontalRules",widthPx:1.2,color:os}]}},{id:"screenbox",commandName:"screenbox",displayName:"screenbox",description:"\u89D2\u4E38\u306E\u5E73\u5766\u306A\u7BB1",aliases:["screen","\u30AB\u30FC\u30C9","\u5F71","\u4F8B\u984C"],defaultTitle:"\u4F8B\u984C",frame:{borderWidthPx:1,borderColor:"#000000",borderStyle:"solid",backgroundColor:"#ffffff",titleBackgroundColor:"#ffffff",titleAlign:"left",titleFontWeight:"bold",cornerStyle:"round",radiusPx:3,paddingPx:{top:12,right:14,bottom:12,left:14},decorations:[]}},{id:"ovalbox",commandName:"ovalbox",displayName:"ovalbox",description:"\u89D2\u4E38\u306E\u7BB1",aliases:["oval","\u89D2\u4E38","\u30E9\u30D9\u30EB"],frame:{borderWidthPx:1.2,borderColor:os,borderStyle:"solid",backgroundColor:"#ffffff",cornerStyle:"round",radiusPx:18,paddingPx:{top:8,right:16,bottom:8,left:16}}},{id:"cornerbox",commandName:"cornerbox",displayName:"cornerbox",description:"\u56DB\u9685\u306E\u9ED2\u56DB\u89D2\u3068\u4E8C\u91CD\u30AC\u30A4\u30C9\u7F6B\u306E\u7BB1",aliases:["corner","\u89D2"],frame:{borderWidthPx:0,borderColor:"transparent",borderStyle:"none",backgroundColor:"#ffffff",titleAlign:"left",titleFontFamily:Op,titleFontWeight:"normal",titleLineHeight:"1",bodyAlign:"left",bodyFontFamily:Op,bodyLineHeight:"1",cornerStyle:"sharp",paddingPx:{top:24,right:24,bottom:24,left:24},decorations:[{type:"titleDoubleRule",ruleWidthPx:1,ruleColor:"#111111",guideColor:"#b8b8b8"},{type:"cornerSquares",sizePx:8,color:"#000000"}]}}];function ZM(e){return qM.find(t=>t.id===e||t.commandName===e)}function Wo(e){let t=tP(ZM(e.styleId)?.frame,e.frame);return e.styleId==="cornerbox"?JM(t):t}function JM(e){let{titleFontSizePx:t,bodyFontSizePx:n,...r}=e;return{...r,...t===void 0||t===EM?{}:{titleFontSizePx:t},...n===void 0||n===CM?{}:{bodyFontSizePx:n}}}function Xo(e){return e.title?Ot(e.title).trim():""}function Ke(e,t){return e?.decorations?.find(n=>n.type===t)}function Ap(e,t){return e?.decorations?.some(n=>n.type===t)??!1}function Ip(e,t,n){let r=[e,"box-frame"];for(let o of t.decorations??[]){let i=HM[o.type];i&&r.push(i)}return eP(n,t)&&r.push("box-frame--corner","corner-frame"),n==="itembox"&&!Ap(t,"titlePlate")&&r.push("box-frame--title-plate"),r.push(`box-frame--title-position-${t.titlePosition??"l"}`),r.join(" ")}function Ep(e){let t={};for(let n of e?.decorations??[]){let r=UM[n.type];r&&(t[r]="true")}return t}function Cp(e){let t=e.paddingPx??{top:12,right:14,bottom:12,left:14},n=Ke(e,"cornerSquares"),r=Ke(e,"doubleRule"),o=Ke(e,"titleDoubleRule"),i=Ke(e,"titleBand"),a=Ke(e,"titlePlate"),s=Ke(e,"leftBar"),c=Ke(e,"shadow"),l=Ke(e,"horizontalRules"),d=Ke(e,"notebookRules"),u=a?.paddingPx??{top:2,right:10,bottom:2,left:10},m=d?.frameHeightPx??d?.minHeightPx??is,h=d?.ringLeftOverhangPx??14,y=e.titlePosition??"l",g=y==="c"?"center":y==="r"?"right":"left";return{"--sigma-doc-box-border-width":`${e.borderWidthPx??1.2}px`,"--sigma-doc-box-border-color":e.borderColor??"#111111","--sigma-doc-box-border-style":e.borderStyle??"solid","--sigma-doc-box-background":e.backgroundColor??"#ffffff","--sigma-doc-box-title-background":e.titleBackgroundColor??i?.backgroundColor??e.backgroundColor??"#ffffff",...e.titleColor?{"--sigma-doc-box-title-color":e.titleColor}:{},"--sigma-doc-box-title-align":e.titlePosition?g:e.titleAlign??g,...e.titleFontWeight?{"--sigma-doc-box-title-weight":e.titleFontWeight==="bold"?"700":"400"}:{},...e.titleFontFamily?{"--sigma-doc-box-title-font-family":e.titleFontFamily}:{},...e.titleFontSizePx?{"--sigma-doc-box-title-font-size":`${e.titleFontSizePx}px`}:{},...e.titleLineHeight?{"--sigma-doc-box-title-line-height":e.titleLineHeight}:{},...e.bodyColor?{"--sigma-doc-box-body-color":e.bodyColor}:{},...e.bodyAlign?{"--sigma-doc-box-body-align":e.bodyAlign}:{},...e.bodyFontFamily?{"--sigma-doc-box-body-font-family":e.bodyFontFamily}:{},...e.bodyFontSizePx?{"--sigma-doc-box-body-font-size":`${e.bodyFontSizePx}px`}:{},...e.bodyLineHeight?{"--sigma-doc-box-body-line-height":e.bodyLineHeight}:{},"--sigma-doc-box-radius":`${e.cornerStyle==="round"?e.radiusPx??8:0}px`,"--sigma-doc-box-padding-top":`${t.top}px`,"--sigma-doc-box-padding-right":`${t.right}px`,"--sigma-doc-box-padding-bottom":`${t.bottom}px`,"--sigma-doc-box-padding-left":`${t.left}px`,"--sigma-doc-box-corner-size":`${n?.sizePx??0}px`,"--sigma-doc-box-corner-color":n?.color??"#000000","--sigma-doc-box-double-offset":`${r?.offsetPx??0}px`,"--sigma-doc-box-double-width":`${r?.widthPx??1}px`,"--sigma-doc-box-double-color":r?.color??e.borderColor??"#111111","--sigma-doc-box-title-rule-width":`${o?.ruleWidthPx??1}px`,"--sigma-doc-box-title-rule-color":o?.ruleColor??"#111111","--sigma-doc-box-title-guide-color":o?.guideColor??"#b8b8b8","--sigma-doc-box-title-band-height":`${i?.heightPx??32}px`,"--sigma-doc-box-title-plate-border-color":a?.borderColor??e.borderColor??"#111111","--sigma-doc-box-title-plate-radius":`${a?.radiusPx??3}px`,"--sigma-doc-box-title-plate-padding-top":`${u.top}px`,"--sigma-doc-box-title-plate-padding-right":`${u.right}px`,"--sigma-doc-box-title-plate-padding-bottom":`${u.bottom}px`,"--sigma-doc-box-title-plate-padding-left":`${u.left}px`,"--sigma-doc-box-left-bar-width":`${s?.widthPx??0}px`,"--sigma-doc-box-left-bar-color":s?.color??"#111111","--sigma-doc-box-shadow":c?`${c.offsetXPx}px ${c.offsetYPx}px ${c.blurPx??0}px ${c.spreadPx??0}px ${c.color}`:"none","--sigma-doc-box-horizontal-rule-width":`${l?.widthPx??1}px`,"--sigma-doc-box-horizontal-rule-color":l?.color??e.borderColor??"#111111","--sigma-doc-box-notebook-base-body-width":`${d?.baseBodyWidthPx??660}px`,"--sigma-doc-box-notebook-frame-left":`${d?.frameLeftPx??d?.bindingXPx??20}px`,"--sigma-doc-box-notebook-frame-height":`${m}px`,"--sigma-doc-box-notebook-frame-border-color":kp(e.borderColor??"#9ca3af",d?.frameStrokeOpacity),"--sigma-doc-box-notebook-binding-color":kp(d?.bindingColor??"#b9b3a1",d?.bindingStrokeOpacity),"--sigma-doc-box-notebook-binding-width":`${d?.bindingWidthPx??1}px`,"--sigma-doc-box-notebook-binding-x":`${d?.bindingXPx??20}px`,"--sigma-doc-box-notebook-ring-color":d?.ringColor??"#706b5a","--sigma-doc-box-notebook-ring-width":`${d?.ringWidthPx??38}px`,"--sigma-doc-box-notebook-ring-height":`${d?.ringHeightPx??12}px`,"--sigma-doc-box-notebook-ring-left-overhang":`${h}px`,"--sigma-doc-box-notebook-ring-stroke":`${d?.ringStrokePx??1.2}px`,"--sigma-doc-box-notebook-ring-gap":`${d?.ringGapPx??23.35}px`,"--sigma-doc-box-notebook-ring-top":`${d?.ringTopPx??8}px`,"--sigma-doc-box-notebook-ring-count":String(d?.ringCount??Rp),"--sigma-doc-box-notebook-min-height":`${d?.minHeightPx??m}px`,"--sigma-doc-box-title-position":y}}function QM(e){let t=Number.isFinite(e)?Math.max(0,e):0;return Math.min(NM,Math.max(LM,t*FM))}function as(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return{};let t=vn(e),n=vn(QM(t)),r=vn(Math.min(zM,Math.max($M,n*DM))),o=vn(Math.max(r,n*_M)),i=vn(r*GM),a=vn(Math.max(0,o-r/2-i));return{"--corner-frame-reference-height":`${t}px`,"--corner-frame-fold-size":`${n}px`,"--corner-frame-corner-size":`${r}px`,"--corner-frame-guide-inset-x":`${n}px`,"--corner-frame-guide-side-y":`${n}px`,"--corner-frame-rule-x":`${o}px`,"--corner-frame-rule-side-x":`${o}px`,"--corner-frame-rule-y":`${o}px`,"--corner-frame-rule-side-y":`${o}px`,"--corner-frame-corner-x":`${a}px`,"--corner-frame-corner-y":`${a}px`}}function Lp(e,t){let n=new Set,r=new Map,o=e instanceof Document?e:e.ownerDocument;if(!o?.head)return()=>{};let i=o.createElement("style");i.setAttribute("data-cornerbox-reference-heights","true"),o.head.appendChild(i);let a=()=>{i.textContent=Array.from(r,([u,m])=>`${u}{${m}}`).join(`
|
|
45
|
+
`)},s=u=>{let m=nP(u);if(!m)return;let h=Object.entries(as(u.getBoundingClientRect().height)).map(([y,g])=>`${y}:${g}`).join(";");!h||r.get(m)===h||(r.set(m,h),a())},c=typeof ResizeObserver>"u"?null:new ResizeObserver(u=>{for(let m of u)m.target instanceof HTMLElement&&m.target.getAttribute("data-corner-reference-height")!=="explicit"&&s(m.target)}),l=()=>{for(let u of Array.from(n))o.contains(u)||(c?.unobserve(u),n.delete(u));e.querySelectorAll(t).forEach(u=>{u.getAttribute("data-corner-reference-height")==="explicit"||n.has(u)||(n.add(u),s(u),c?.observe(u))})};l();let d=typeof MutationObserver>"u"?null:new MutationObserver(l);return d?.observe(e,{childList:!0,subtree:!0}),()=>{d?.disconnect(),c?.disconnect(),i.remove(),n.clear(),r.clear()}}function eP(e,t){return e==="cornerbox"&&Ap(t,"titleDoubleRule")}function tP(e,t){let n=t?.paddingPx?{...e?.paddingPx??t.paddingPx,...t.paddingPx}:e?.paddingPx;return{...e??{},...t??{},...n?{paddingPx:n}:{},decorations:t?.decorations??e?.decorations}}function kp(e,t){if(t===void 0)return e;let n=Math.min(1,Math.max(0,t)),r=rP(e);return r?`rgb(${r.r} ${r.g} ${r.b} / ${n})`:e}function vn(e){return Math.round(e*100)/100}function nP(e){let t=e.getAttribute("data-sigma-doc-id");if(t)return`[data-sigma-doc-id="${Bp(t)}"]`;let n=e.getAttribute("data-box-source-id");return n?`[data-box-source-id="${Bp(n)}"]`:null}function Bp(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function rP(e){let t=e.trim(),n=/^#([0-9a-fA-F]{3})$/.exec(t);if(n){let i=n[1]??"";return{r:Number.parseInt(`${i[0]}${i[0]}`,16),g:Number.parseInt(`${i[1]}${i[1]}`,16),b:Number.parseInt(`${i[2]}${i[2]}`,16)}}let r=/^#([0-9a-fA-F]{6})$/.exec(t);if(!r)return null;let o=r[1]??"";return{r:Number.parseInt(o.slice(0,2),16),g:Number.parseInt(o.slice(2,4),16),b:Number.parseInt(o.slice(4,6),16)}}var oP="fancybox",iP=[{id:"fancybox",commandName:"fancybox",label:"\u6A19\u6E96",description:"\u7D30\u3044\u4E00\u91CD\u67A0"},{id:"doublebox",commandName:"doublebox",label:"\u4E8C\u91CD",description:"\u4E8C\u91CD\u7F6B\u7DDA"},{id:"cornerbox",commandName:"cornerbox",label:"\u89D2\u4ED8\u304D",description:"\u9ED2\u3044\u89D2\u3068\u4E8C\u91CD\u30AC\u30A4\u30C9"}],aP=new Set(iP.map(e=>e.id));function ss(e){return aP.has(e??"")?e:oP}function Np(e){return ss(e.frame?.styleId)}function Fp(e,t){let n=ss(t);return[e,"box-frame",n==="doublebox"?"box-frame--double-rule":"",n==="cornerbox"?"box-frame--corner corner-frame":""].filter(Boolean).join(" ")}function _p(e){let t=ss(e);return t==="doublebox"?{x:3.4,y:3}:t==="cornerbox"?{x:8,y:6.4}:{x:3,y:2.5}}import{useCallback as hF,useEffect as gF,useState as xF}from"react";import{Fragment as sP,useCallback as GF,useLayoutEffect as ls,useMemo as je,useRef as Dp,useState as Gp}from"react";import{jsx as E,jsxs as pr}from"react/jsx-runtime";var lP=12,cP=".print-box-block.box-frame--corner[data-box-style='cornerbox']",$p=12;function Wp({document:e,displayMode:t="vertical",includePrintPageStyle:n=!0,maxPages:r,stackClassName:o,renderPageFrame:i}){let a=e.metadata.mathFractionSizing??"uniform",s=je(()=>fa(e.metadata.texPreamble,a),[a,e.metadata.texPreamble]),c=e.pageLayout,l=co(c),d=l.page.heightPx+la,u=je(()=>uP(e.content),[e.content]),m=Dp(null),h=Dp(null),y=je(()=>u.map(A=>pP(A)),[u]),g=je(()=>ds(u,y,y,l.flow.columnCount,l.content.heightPx,0,new Map,l.flow.columnGapMm),[y,l.content.heightPx,l.flow.columnCount,l.flow.columnGapMm,u]),x=je(()=>JSON.stringify(u),[u]),S=je(()=>JSON.stringify(c),[c]),I=`${x}
|
|
46
|
+
${S}`,R=je(()=>new Map,[]),[P,C]=Gp(null),[z,f]=Gp(0),M=P?.key===I?P:null,D=M?.pages??g,Q=M?.blockRects??R,Z=je(()=>PP(c.overlay,Q),[c.overlay,Q]),v=je(()=>TP(D,Z,l.flow.columnCount,l.page.heightPx,d),[D,l.flow.columnCount,l.page.heightPx,d,Z]),w=typeof r=="number"?v.slice(0,Math.max(1,r)):v,O={"--print-page-width":`${l.page.widthMm}mm`,"--print-page-height":`${l.page.heightMm}mm`,"--print-margin-top":`${l.margins.topPx}px`,"--print-margin-right":`${l.margins.rightPx}px`,"--print-margin-bottom":`${l.margins.bottomPx}px`,"--print-margin-left":`${l.margins.leftPx}px`,"--print-column-count":String(l.flow.columnCount),"--print-column-gap":`${l.flow.columnGapMm}mm`,"--print-measure-column-width":`${l.flow.columnWidthPx}px`,"--print-measure-content-width":`${l.content.widthPx}px`};return ls(()=>{let A=m.current;if(A)return Lp(A,cP)},[x,S]),ls(()=>{let A=h.current;if(!A)return;let B=!0,F=null,W=()=>{if(!B||F!==null)return;F=(typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):U=>window.setTimeout(U,0))(()=>{F=null,B&&f(U=>U+1)})},_=typeof ResizeObserver=="function"?new ResizeObserver(W):null;return _?.observe(A),typeof document<"u"&&document.fonts&&document.fonts.ready.then(W),()=>{B=!1,_?.disconnect(),F!==null&&typeof window<"u"&&(window.cancelAnimationFrame?.(F),window.clearTimeout(F))}},[x,S]),ls(()=>{let A=h.current;if(!A)return;let B=bP(A,u),F=B.map($=>$.height),W=B.map($=>$.flowHeight),_=B.map($=>$.descendantRects),j=hP(_),U=ds(u,F,W,l.flow.columnCount,l.content.heightPx,0,j,l.flow.columnGapMm),X=gP(U,u,F,W,l.margins.topPx,l.margins.leftPx,l.flow.columnWidthPx,l.flow.columnGapPx,d,0,_,j);C($=>$?.key===I&&wP($.blockRects,X)&&OP($.pages,U)?$:{key:I,pages:U,blockRects:X})},[x,S,I,z,l.content.heightPx,l.flow.columnCount,l.flow.columnGapPx,l.flow.columnGapMm,l.flow.columnWidthPx,l.margins.leftPx,l.margins.topPx,d,u]),E(fn,{environment:s,children:pr("article",{ref:m,className:["print-page-stack",`layout-${t}`,o].filter(Boolean).join(" "),"data-print-preview-layout":t,"data-print-preview-max-pages":typeof r=="number"?String(r):void 0,"data-print-preview-page-count":String(v.length),style:O,children:[n?E("style",{children:`@media print { @page { size: ${l.page.widthMm}mm ${l.page.heightMm}mm; margin: 0; } }`}):null,w.map(A=>{let B=Z?.overlaySnapshot?Vo(Z.overlaySnapshot.shapes,Z.overlaySnapshot.assets,{width:l.page.widthPx,height:l.page.heightPx,offsetY:(A.number-1)*d},{mathEnvironment:s,stackLayer:"background",viewportPaddingPx:0}):void 0,F=Z?.overlaySnapshot?Vo(Z.overlaySnapshot.shapes,Z.overlaySnapshot.assets,{width:l.page.widthPx,height:l.page.heightPx,offsetY:(A.number-1)*d},{mathEnvironment:s,stackLayer:"foreground",viewportPaddingPx:0}):void 0,W=pr("section",{className:"print-a4-page",style:O,children:[E(es,{region:c.header,kind:"header",title:e.metadata.title,pageNumber:A.number,totalPages:v.length,metrics:l,mathFractionSizing:a}),E(es,{region:c.footer,kind:"footer",title:e.metadata.title,pageNumber:A.number,totalPages:v.length,metrics:l,mathFractionSizing:a}),B&&E("div",{className:"print-page-overlay-layer background",dangerouslySetInnerHTML:{__html:B}}),pr("div",{className:"print-page-content-layer",children:[Yp(A).map((_,j)=>E("div",{className:"print-page-full-span-block",children:E(Ze,{unit:_,columnGapMm:l.flow.columnGapMm,mathFractionSizing:a})},`${A.id}-full-${_.id}-${j}`)),E("div",{className:"print-page-columns",children:A.columns.map(_=>E("div",{className:"print-page-column",children:ps(_).map((j,U)=>E(Ze,{unit:j,columnGapMm:l.flow.columnGapMm,mathFractionSizing:a},`${j.id}-${U}`))},`${A.id}-${_.id}`))})]}),F&&E("div",{className:"print-page-overlay-layer foreground",dangerouslySetInnerHTML:{__html:F}})]},A.id);return i?i({page:A,totalPages:v.length,pageNode:W}):W}),E("div",{className:"print-measure-layer",ref:h,style:O,"aria-hidden":"true",children:E("div",{className:"print-measure-column",children:u.map((A,B)=>E("div",{"data-print-measure-index":B,style:qe(A)?{width:"var(--print-measure-content-width)"}:void 0,children:E(Ze,{unit:A,columnGapMm:l.flow.columnGapMm,mathFractionSizing:a})},`${A.id}-${B}`))})})]})})}function uP(e){let t=Pp(e);return e.flatMap(n=>{if(n.type!=="problem")return[{type:"block",id:n.id,block:n,pagination:n.pagination}];let r=t.get(n.id),o=Un.map(c=>({area:c,blocks:n[c],minHeightMm:n.areaLayout?.[c]?.minHeightMm,columnSpan:n.areaLayout?.[c]?.columnSpan})).filter(({area:c,blocks:l,minHeightMm:d})=>c==="lead"?typeof r=="number"||l.length>0||!!d:c==="prompt"||l.length>0||!!d),i=o.filter(({area:c})=>cs(c)),a=i[0]?.area,s=i.at(-1)?.area;return o.map((c,l)=>({type:"problemArea",id:`${n.id}:${c.area}`,problemId:n.id,area:c.area,blocks:c.blocks,minHeightMm:c.minHeightMm,problemNumber:r,numberFontSize:RP(n),hasFrame:n.frame?.enabled===!0&&cs(c.area),frameStyleId:n.frame?.enabled===!0&&cs(c.area)?Np(n):void 0,isFirstProblemArea:l===0,isLastProblemArea:l===o.length-1,isFirstProblemFrameArea:c.area===a,isLastProblemFrameArea:c.area===s,columnSpan:c.columnSpan,pagination:dP(n.pagination,l,o.length)}))})}function dP(e,t,n){if(!e)return;let r={...e};return t>0&&delete r.break,t<n-1&&delete r.keepWithNext,Object.keys(r).length>0?r:void 0}function cs(e){return e==="prompt"}function zp(e){return e.type==="problemArea"&&xl({isFullSpan:e.columnSpan==="full",isFramedArea:e.hasFrame,blocks:e.blocks})}function pP(e){return e.type==="block"?ot(e.block):e.type==="boxFragment"||e.type==="layoutSectionFragment"?e.estimatedHeightPx:e.type==="blockSlice"?e.sliceHeight:e.type==="problemAreaFragment"?e.estimatedHeightPx:Math.max(e.blocks.reduce((t,n)=>t+ot(n),0),(e.minHeightMm??0)*rn)}function ds(e,t,n,r,o,i,a,s){let c=[],l=1,d=Yo(l,r).columns,u=0,m=()=>d.some(v=>v.blocks.length>0),h=()=>d.some(v=>v.blocks.some(w=>!qe(w))),y=()=>d[u],g=()=>Math.max(0,o-(l===1?i:0)),x=(v=!1)=>{!v&&!m()||(c.push({id:`page_${l}`,number:l,blocks:d.flatMap(w=>w.blocks),columns:d,estimatedContentHeightPx:d.reduce((w,O)=>w+O.estimatedContentHeightPx,0),oversizedBlockIds:d.flatMap(w=>w.oversizedBlockIds)}),l+=1,d=Yo(l,r).columns,u=0)},S=()=>{if(u<r-1){u+=1;return}x()},I=()=>{S()},R=v=>v.blocks.some(w=>!qe(w)),P=()=>Math.max(0,g()-y().estimatedContentHeightPx),C=(v,w,O=w)=>{let A=y();A.blocks.push(v),A.estimatedContentHeightPx+=Math.max(w,O),w>g()&&A.oversizedBlockIds.push(v.id)},z=v=>{let w=e[v];if(zp(w)||w.type!=="problemArea"||!w.isFirstProblemArea||!R(y()))return;let O=0;for(let B=v;B<e.length;B+=1){let F=e[B];if(F.type!=="problemArea"||F.problemId!==w.problemId)break;if(qe(F)||B>v&&F.pagination?.break===!0)return;O+=Math.max(t[B]||0,n[B]??0)}let A=u<r-1?g():o;O>P()+.5&&O<=A+.5&&S()},f=v=>{let w=e[v],O=e[v+1];if(w.pagination?.keepWithNext!==!0||!O||O.pagination?.break===!0||qe(w)||qe(O))return;let A=Math.max(t[v]||0,n[v]??0)+Math.max(t[v+1]||0,n[v+1]??0),B=u<r-1?g():o;R(y())&&A>P()+.5&&A<=B+.5&&S()},M=(v,w)=>{let O=v.block;if(O.type!=="boxBlock"||O.blocks.length===0||w<=P()+.5)return!1;let A=u<r-1?g():o;if(O.pagination?.keepTogether===!0&&R(y())&&w<=A+.5&&(S(),w<=P()+.5))return!1;let B=[],F=Xp(O),W=O.blocks.map(U=>Mn(U,a)),_=0,j=0;for(;_<O.blocks.length;){R(y())&&P()<Math.min(72,g()*.22)&&S();let U=W[_]??0;R(y())&&F+U>P()+.5&&F+U<=g()+.5&&S();let X=[],$=F;for(;_<O.blocks.length;){let J=W[_]??0;if(!(X.length===0||$+J<=Math.max(F+J,P()+.5))||(X.push(O.blocks[_]),$+=J,_+=1,$>=P()-.5))break}X.length===0&&(X.push(O.blocks[_]),$+=W[_]??0,_+=1);let ue={type:"boxFragment",id:`${O.id}:fragment:${j}`,sourceId:O.id,block:O,blocks:X,fragmentRole:"middle",estimatedHeightPx:$,totalHeight:w,includeTitle:j===0,pagination:j===0?v.pagination:void 0};B.push(ue),C(ue,$),j+=1,_<O.blocks.length&&S()}return B.forEach((U,X)=>{U.fragmentRole=B.length===1?"single":X===0?"first":X===B.length-1?"last":"middle"}),!0},D=(v,w)=>{let O=fP(v.block,w,a),A=[],B=0,F=0;for(let W=0;B<w-.5&&W<400;W+=1){R(y())&&P()<Math.min(48,g()*.2)&&S();let _=Math.max(1,P()),j=w-B,U=j<=_+.5?j:yP(_,O,B,w),X={type:"blockSlice",id:`${v.id}:slice:${F}`,sourceId:v.id,block:v.block,sliceTop:B,sliceHeight:U,totalHeight:w,fragmentRole:"middle",pagination:F===0?v.pagination:void 0};A.push(X),C(X,U),B+=U,F+=1,B<w-.5&&S()}A.forEach((W,_)=>{W.fragmentRole=A.length===1?"single":_===0?"first":_===A.length-1?"last":"middle"})},Q=v=>{if(!zp(v)||v.blocks.length===0)return!1;let w=v.columnSpan==="full",O=()=>{w?x():S()},A=_p(v.frameStyleId),B=v.hasFrame?A.y*2*rn:0,F=y(),W=F.estimatedContentHeightPx,_=[],j=[],U=[],X=B,$=!1,ue=(we,ee)=>{let be=_.length,Re={type:"problemAreaFragment",id:`${v.id}:area-fragment:${be}`,sourceId:v.id,problemId:v.problemId,area:v.area,blocks:we,fragmentRole:"middle",estimatedHeightPx:ee,minHeightMm:v.minHeightMm,problemNumber:v.problemNumber,numberFontSize:v.numberFontSize,hasFrame:v.hasFrame,frameStyleId:v.frameStyleId,columnSpan:v.columnSpan,isFirstProblemArea:v.isFirstProblemArea,isLastProblemArea:v.isLastProblemArea,pagination:be===0?v.pagination:void 0};if(_.push(Re),w){h()&&x(),m()&&y().estimatedContentHeightPx+ee>g()+.5&&x(),d[0].blocks.push(Re);for(let ut of d)ut.estimatedContentHeightPx+=ee;j.push(d[0])}else j.push(y()),C(Re,ee)},J=()=>{U.length!==0&&(ue(U,X),U=[],X=B)};for(let[we,ee]of v.blocks.entries()){if(ee.pagination?.break===!0){let _e=_.length>0||U.length>0||!w&&(R(y())||u>0);J(),_e&&O()}let be=Mn(ee,a),Re=v.blocks[we+1],ut=ee.pagination?.keepWithNext===!0&&Re&&Re.pagination?.break!==!0?be+Mn(Re,a):0,li=X+ut;if((R(y())||U.length>0)&&ut>0&&li>P()+.5&&ut+B<=o+.5&&(J(),O()),ee.type==="layoutSection"){J();let _e=be+B;_e>P()+.5&&_e<=o+.5&&O(),ue([ee],_e);continue}if(be>o+.5){J(),_.length===0&&($=!0),D({type:"block",id:ee.id,block:ee,pagination:ee.pagination},be);continue}let ci=Math.max(0,P()-X);(R(y())||U.length>0)&&be>ci+.5&&be+B<=o+.5&&(J(),O()),U.push(ee),X+=be}return J(),_.forEach((we,ee)=>{we.fragmentRole=$?ee===_.length-1?"last":"middle":_.length===1?"single":ee===0?"first":ee===_.length-1?"last":"middle"}),(v.minHeightMm??0)>0&&_.length>0&&j.every(we=>we===F)&&y()===F&&(F.estimatedContentHeightPx=Math.max(F.estimatedContentHeightPx,W+(v.minHeightMm??0)*rn)),!0},Z=(v,w)=>{let O=v.block;if(O.type!=="layoutSection"||O.children.length===0)return!1;if(O.pagination?.keepTogether===!0&&R(y())&&w>P()+.5&&w<=g()+.5)return S(),!1;let A=O.children.some($=>$.type==="boxBlock"),B=Ti(O.children);if(!A&&!B&&w<=g()+.5)return!1;let F=jp(O.layout.columnCount),W=s,_=O.children.map($=>({type:"block",id:$.id,block:$,pagination:$.pagination})),j=O.children.map($=>Mn($,a,Math.max(12,Math.floor(54/F)))),X=ds(_,j,j,F,g(),0,a,W).map(($,ue)=>({type:"layoutSectionFragment",id:`${O.id}:layout-fragment:${ue}`,sourceId:O.id,block:O,columns:$.columns,fragmentRole:"middle",estimatedHeightPx:Math.max(32,...$.columns.map(J=>J.estimatedContentHeightPx)),columnGapMm:W,pagination:ue===0?v.pagination:void 0}));return X.forEach(($,ue)=>{$.fragmentRole=X.length===1?"single":ue===0?"first":ue===X.length-1?"last":"middle",R(y())&&y().estimatedContentHeightPx+$.estimatedHeightPx>g()+.5&&S(),C($,$.estimatedHeightPx),ue<X.length-1&&S()}),!0};return e.forEach((v,w)=>{let O=t[w]||0,A=n[w]??O;if(m()&&v.pagination?.break===!0&&I(),f(w),z(w),v.type==="problemArea"&&Q(v))return;if(qe(v)){h()&&x(),m()&&y().estimatedContentHeightPx+O>g()&&x(),d[0].blocks.push(v);for(let W of d)W.estimatedContentHeightPx+=Math.max(O,A),O>g()&&W.oversizedBlockIds.push(v.id);return}let B=v.type==="block"&&v.block.type==="boxBlock"&&v.block.blocks.length>0,F=v.type==="block"&&(v.block.type==="boxBlock"?mP(v.block,o,a):v.block.type!=="layoutSection"&&O>o+.5);if(B||F||(O>g()+.5&&m()?x():R(y())&&y().estimatedContentHeightPx+O>g()?S():!R(y())&&y().estimatedContentHeightPx>.5&&y().estimatedContentHeightPx+O>g()&&x()),F&&v.type==="block"){D(v,O);return}v.type==="block"&&M(v,O)||v.type==="block"&&Z(v,O)||C(v,O,A)}),x(),c.length>0?c:[Yo(1,r)]}function Xp(e){let n=Wo(e).paddingPx??{top:12,right:14,bottom:12,left:14},o=Xo(e)?24:0;return n.top+n.bottom+o}function mP(e,t,n){let r=Xp(e);return e.blocks.some(o=>r+Mn(o,n)>t+.5)}function fP(e,t,n){if(e.type!=="boxBlock")return[];let o=Wo(e).paddingPx??{top:12,right:14,bottom:12,left:14},i=Xo(e),a=o.top+(i?24:0),s=[];for(let c of e.blocks)a+=Mn(c,n),a>.5&&a<t-.5&&s.push(Math.round(a));return s}function yP(e,t,n,r){let o=Math.min(Math.max(1,e),r-n),i=n+o,a=n+Math.min(24,Math.max(8,o*.25)),s=t.filter(c=>c>a+.5&&c<=i-.5).at(-1);return s?Math.max(1,s-n):o}function Mn(e,t,n){return t.get(e.id)??ot(e,n)}function hP(e){let t=new Map;return e.forEach(n=>{n.forEach(r=>{t.set(r.id,r.height??0)})}),t}function gP(e,t,n,r,o,i,a,s,c,l,d,u){let m=new Map(t.map((x,S)=>[x.id,n[S]||0])),h=new Map(t.map((x,S)=>[x.id,r[S]??n[S]??0])),y=new Map(t.map((x,S)=>[x.id,d[S]??[]])),g=new Map;for(let x of e){let S=(x.number-1)*c,R=x.number===1?l:0;for(let P of Yp(x)){let C=Ko(P,m,u),z={id:P.id,top:S+o+R,left:i,width:a*Math.max(1,x.columns.length)+s*Math.max(0,x.columns.length-1),height:C};g.set(P.id,z);for(let f of y.get(P.id)??[])g.set(f.id,us(f,z.top,z.left));R+=Hp(P,m,h,u)}for(let P of x.columns){let C=i+(P.number-1)*(a+s),z=R;for(let f of ps(P)){let M=Ko(f,m,u),D={id:f.id,top:S+o+z,left:C,width:a,height:M};if(g.set(f.id,D),f.type==="blockSlice"&&(f.fragmentRole==="first"||f.fragmentRole==="single")&&g.set(f.sourceId,{...D,id:f.sourceId,height:f.totalHeight}),f.type==="problemAreaFragment"){let Q=y.get(f.sourceId)??[];if(f.fragmentRole==="first"||f.fragmentRole==="single"){let B=m.get(f.sourceId)??D.height;if(g.set(f.sourceId,{...D,id:f.sourceId,height:B}),f.isFirstProblemArea){let F=Q.find(W=>W.id===f.problemId);g.set(f.problemId,{...D,id:f.problemId,height:F?.height??B})}}let Z=xP(f.blocks),v=Q.find(B=>B.id===f.blocks[0]?.id),w=v?.top??0,A=f.area==="lead"&&typeof f.problemNumber=="number"&&(f.fragmentRole==="first"||f.fragmentRole==="single")?0:v?.left??0;for(let B of Q)Z.has(B.id)&&g.set(B.id,us(B,D.top-w,D.left,A))}else for(let Q of y.get(f.id)??[])g.set(Q.id,us(Q,D.top,D.left));z+=Hp(f,m,h,u)}}}return g}function us(e,t,n,r=0){return{...e,top:t+e.top,left:n+(e.left??0)-r,lines:e.lines?.map(o=>({...o,top:t+o.top,left:typeof o.left=="number"?n+o.left-r:o.left}))}}function xP(e){let t=new Set,n=r=>{if(t.add(r.id),r.type==="list"){for(let o of r.items)t.add(o.id),o.nested?.forEach(n);return}if(r.type==="layoutSection"){r.children.forEach(n);return}if(r.type==="boxBlock"){r.blocks.forEach(n);return}r.type==="problem"&&(r.lead.forEach(n),r.prompt.forEach(n),r.hints.forEach(n),r.solution.forEach(n))};return e.forEach(n),t}function Ko(e,t,n){return e.type==="boxFragment"||e.type==="layoutSectionFragment"||e.type==="problemAreaFragment"?e.estimatedHeightPx:e.type==="blockSlice"?e.sliceHeight:t.get(e.id)??n.get(e.id)??0}function Hp(e,t,n,r){return e.type==="boxFragment"||e.type==="layoutSectionFragment"||e.type==="blockSlice"||e.type==="problemAreaFragment"?Ko(e,t,r):Math.max(Ko(e,t,r),n.get(e.id)??0)}function bP(e,t){let n=t.map((r,o)=>{let i=e.querySelector(`[data-print-measure-index="${o}"]`);if(!i)return null;let a=i.getBoundingClientRect();return{element:i,height:a.height,top:a.top,descendantRects:MP(i,r.id)}});return n.map((r,o)=>{if(!r)return{height:0,flowHeight:0,descendantRects:[]};let i=n.slice(o+1).find(s=>s!==null),a=i?Math.max(r.height,i.top-r.top):SP(r.element,r.height);return{height:r.height,flowHeight:a,descendantRects:r.descendantRects}})}function SP(e,t){let n=vP(getComputedStyle(e).marginBottom);return t+n}function vP(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function qe(e){return(e.type==="problemArea"||e.type==="problemAreaFragment")&&e.columnSpan==="full"}function Yp(e){return e.columns[0]?.blocks.filter(qe)??[]}function ps(e){return e.blocks.filter(t=>!qe(t))}function MP(e,t){let n=e.getBoundingClientRect(),r=new Set([t]),o=[];return e.querySelectorAll("[data-sigma-doc-id]").forEach(i=>{let a=i.getAttribute("data-sigma-doc-id");if(!a||r.has(a))return;r.add(a);let s=i.getBoundingClientRect();o.push({id:a,top:s.top-n.top,left:s.left-n.left,width:s.width,height:s.height,lines:yu(i,n,1,1)})}),o}function PP(e,t){if(!e?.overlaySnapshot)return e;let n=me(e.overlaySnapshot),r=Ci(n.shapes,t);return{...e,overlaySnapshot:{...n,shapes:r}}}function TP(e,t,n,r,o){let i=t?.overlaySnapshot?me(t.overlaySnapshot):null;if(!i)return e;let a=i.shapes.reduce((c,l)=>{if(l.hidden)return c;let d=de(l);return Math.max(c,d.y+d.h)},0),s=a>r+$p?Math.ceil((a-r-$p)/o)+1:1;return s<=e.length?e:[...e,...Array.from({length:s-e.length},(c,l)=>{let d=e.length+l+1;return Yo(d,n)})]}function Yo(e,t){return{id:`page_${e}`,number:e,blocks:[],columns:Array.from({length:Math.max(1,t)},(n,r)=>({id:`column_${r+1}`,number:r+1,blocks:[],estimatedContentHeightPx:0,oversizedBlockIds:[]})),estimatedContentHeightPx:0,oversizedBlockIds:[]}}function OP(e,t){return!e||e.length!==t.length?!1:e.every((n,r)=>{let o=t[r];return n.columns.length===o.columns.length&&n.columns.every((i,a)=>{let s=o.columns[a];return i.blocks.length===s.blocks.length&&i.blocks.every((c,l)=>Kp(c,s.blocks[l]))})})}function Kp(e,t){return e.id!==t.id||e.type!==t.type?!1:e.type==="boxFragment"&&t.type==="boxFragment"?e.fragmentRole===t.fragmentRole&&Math.abs(e.estimatedHeightPx-t.estimatedHeightPx)<.5&&Math.abs(e.totalHeight-t.totalHeight)<.5&&e.blocks.length===t.blocks.length&&e.blocks.every((n,r)=>n.id===t.blocks[r].id):e.type==="layoutSectionFragment"&&t.type==="layoutSectionFragment"?e.fragmentRole===t.fragmentRole&&e.columns.length===t.columns.length&&e.columns.every((n,r)=>{let o=t.columns[r];return n.blocks.length===o.blocks.length&&n.blocks.every((i,a)=>Kp(i,o.blocks[a]))}):e.type==="blockSlice"&&t.type==="blockSlice"?e.fragmentRole===t.fragmentRole&&Math.abs(e.sliceTop-t.sliceTop)<.5&&Math.abs(e.sliceHeight-t.sliceHeight)<.5:e.type==="problemAreaFragment"&&t.type==="problemAreaFragment"?e.fragmentRole===t.fragmentRole&&Math.abs(e.estimatedHeightPx-t.estimatedHeightPx)<.5&&e.blocks.length===t.blocks.length&&e.blocks.every((n,r)=>n.id===t.blocks[r].id):!0}function wP(e,t){if(e.size!==t.size)return!1;for(let[n,r]of t){let o=e.get(n);if(!o||Math.abs(o.top-r.top)>.5||Math.abs((o.left??0)-(r.left??0))>.5||Math.abs((o.width??0)-(r.width??0))>.5||Math.abs((o.height??0)-(r.height??0))>.5)return!1}return!0}function Ze({unit:e,columnGapMm:t,mathFractionSizing:n}){if(e.type==="problemArea")return E(Vp,{problemId:e.problemId,area:e.area,minHeightMm:e.minHeightMm,problemNumber:e.problemNumber,numberFontSize:e.numberFontSize,hasFrame:e.hasFrame,frameStyleId:e.frameStyleId,isFirstProblemArea:e.isFirstProblemArea,isFirstProblemFrameArea:e.isFirstProblemFrameArea,isLastProblemFrameArea:e.isLastProblemFrameArea,columnGapMm:t,mathFractionSizing:n,blocks:e.blocks});if(e.type==="problemAreaFragment"){let o=e.fragmentRole==="single"||e.fragmentRole==="first",i=e.fragmentRole==="single"||e.fragmentRole==="last";return E(Vp,{problemId:e.problemId,area:e.area,minHeightMm:e.fragmentRole==="single"?e.minHeightMm:void 0,problemNumber:e.problemNumber,numberFontSize:e.numberFontSize,hasFrame:e.hasFrame,frameStyleId:e.frameStyleId,isFirstProblemArea:e.isFirstProblemArea,isFirstProblemFrameArea:e.hasFrame&&o,isLastProblemFrameArea:e.hasFrame&&i,columnGapMm:t,mathFractionSizing:n,blocks:e.blocks,fragmentRole:e.fragmentRole,sourceId:e.sourceId})}if(e.type==="boxFragment")return E(Up,{block:e.block,columnGapMm:t,fragmentBlocks:e.blocks,fragmentRole:e.fragmentRole,includeTitle:e.includeTitle,cornerReferenceHeightPx:e.totalHeight,mathFractionSizing:n});if(e.type==="layoutSectionFragment")return E(kP,{unit:e,mathFractionSizing:n});if(e.type==="blockSlice")return E("div",{className:`print-block-slice print-block-slice-${e.fragmentRole}`,"data-block-slice":e.fragmentRole,"data-block-source-id":e.sourceId,style:{height:`${Math.round(e.sliceHeight)}px`,overflow:"hidden"},children:E("div",{className:"print-block-slice-inner",style:{marginTop:`${-Math.round(e.sliceTop)}px`},children:E(Ze,{unit:{type:"block",id:e.sourceId,block:e.block},columnGapMm:t,mathFractionSizing:n})})});let{block:r}=e;if(r.type==="section")return E("h1",{"data-sigma-doc-id":r.id,className:"print-section",style:{textAlign:r.align??"left",lineHeight:r.lineHeight},children:r.title});if(r.type==="heading")return E(bn,{block:r,mathFractionSizing:n});if(r.type==="paragraph")return E(bn,{block:r,mathFractionSizing:n});if(r.type==="list")return E(bn,{block:r,mathFractionSizing:n});if(r.type==="boxBlock")return E(Up,{block:r,columnGapMm:t,mathFractionSizing:n});if(r.type==="layoutSection"){let o=jp(r.layout.columnCount),i=t;return E("section",{"data-sigma-doc-id":r.id,className:"print-layout-section",style:{"--print-layout-section-column-count":String(o),"--print-layout-section-column-gap":`${i}mm`},children:r.children.map(a=>{let s=E(Ze,{unit:{type:"block",id:a.id,block:a,pagination:a.pagination},columnGapMm:i,mathFractionSizing:n});return o>1&&a.pagination?.break===!0?E("div",{className:"print-column-break-before",children:s},a.id):E(sP,{children:s},a.id)})})}}function kP({unit:e,mathFractionSizing:t}){let n=e.columns.length,r={"--print-layout-section-column-count":String(n),"--print-layout-section-column-gap":`${e.columnGapMm}mm`,display:"grid",gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`,columnGap:`${e.columnGapMm}mm`};return E("section",{"data-sigma-doc-id":e.fragmentRole==="single"||e.fragmentRole==="first"?e.sourceId:void 0,"data-layout-section-source-id":e.sourceId,"data-layout-section-fragment":e.fragmentRole,className:`print-layout-section print-layout-section-fragment print-layout-section-fragment-${e.fragmentRole}`,style:r,children:e.columns.map(o=>E("div",{className:"print-layout-section-column",style:{minWidth:0},children:ps(o).map((i,a)=>E(Ze,{unit:i,columnGapMm:e.columnGapMm,mathFractionSizing:t},`${i.id}-${a}`))},`${e.id}-${o.id}`))})}function Up({block:e,columnGapMm:t,mathFractionSizing:n,fragmentBlocks:r,fragmentRole:o,includeTitle:i=!0,cornerReferenceHeightPx:a}){let s=Wo(e),c=Xo(e).length>0,l=r??e.blocks,d=o?` print-box-fragment print-box-fragment-${o}`:"",u={...Cp(s),...as(a)};return pr("section",{"data-sigma-doc-id":!o||o==="single"||o==="first"?e.id:void 0,"data-box-source-id":o?e.id:void 0,"data-box-fragment":o,"data-corner-reference-height":a?"explicit":void 0,className:`${Ip("print-box-block",s,e.styleId)}${d}`,"data-box-style":e.styleId,...Ep(s),style:u,children:[E("span",{className:"print-box-corner top-left","aria-hidden":"true"}),E("span",{className:"print-box-corner top-right","aria-hidden":"true"}),E("span",{className:"print-box-corner bottom-left","aria-hidden":"true"}),E("span",{className:"print-box-corner bottom-right","aria-hidden":"true"}),i&&c&&E("div",{className:"print-box-title",children:xe(e.title??[],{keyPrefix:`${e.id}-title`,mathFractionSizing:n})}),E("div",{className:"print-box-body",children:l.map(m=>E(BP,{block:m,columnGapMm:t,mathFractionSizing:n},m.id))})]})}function BP({block:e,columnGapMm:t,mathFractionSizing:n}){return e.type==="layoutSection"?E(Ze,{unit:{type:"block",id:e.id,block:e,pagination:e.pagination},columnGapMm:t,mathFractionSizing:n}):e.type==="section"||e.type==="boxBlock"?E(Ze,{unit:{type:"block",id:e.id,block:e,pagination:e.pagination},columnGapMm:t,mathFractionSizing:n}):E(bn,{block:e,mathFractionSizing:n})}function Vp({problemId:e,area:t,blocks:n,minHeightMm:r,problemNumber:o,numberFontSize:i,hasFrame:a,frameStyleId:s,isFirstProblemArea:c,isFirstProblemFrameArea:l,isLastProblemFrameArea:d,columnGapMm:u,mathFractionSizing:m,fragmentRole:h,sourceId:y}){let g=!h||h==="single"||h==="first",x=t==="lead"&&typeof o=="number"&&g;if(n.length===0&&!r&&!x)return null;let S=x&&n.length===0,I=a?Fp("print-problem-area with-frame",s):"print-problem-area",R=h?` print-problem-area-fragment print-problem-area-fragment-${h}`:"";return E("section",{className:`${I}${R} ${a&&l?"first-frame-area":""} ${a&&d?"last-frame-area":""}`,"data-sigma-doc-id":c&&g?e:void 0,"data-problem-area":t,"data-problem-area-fragment":h,"data-problem-source-id":y,"data-problem-frame-style":a?s:void 0,style:r?{minHeight:`${r}mm`}:void 0,children:pr("div",{className:`print-problem-area-content ${x?"with-number":""}`,children:[x&&E("span",{className:"print-problem-number",style:{fontSize:`${i}pt`},children:Tp(o)}),E("div",{className:`print-problem-area-body ${S?"empty-lead-placeholder":""}`,children:S?E("div",{className:"print-empty-lead-shell","aria-hidden":"true"}):n.map(P=>P.type==="layoutSection"||P.type==="boxBlock"?E(Ze,{unit:{type:"block",id:P.id,block:P,pagination:P.pagination},columnGapMm:u,mathFractionSizing:m},P.id):E(bn,{block:P,mathFractionSizing:m},P.id))})]})})}function jp(e){return Number.isInteger(e)?Math.min(4,Math.max(1,e)):2}function RP(e){let t=e.numbering?.fontSize;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:lP}import{z as p}from"zod";var AP=p.object({keepTogether:p.boolean().optional(),keepWithNext:p.boolean().optional(),break:p.boolean().optional()}).optional(),Nt=p.object({id:p.string().min(1),pagination:AP}),fs=p.enum(["left","center","right","justify"]).optional(),ys=p.string().transform((e,t)=>{let n=tt(e);return n||(t.addIssue({code:p.ZodIssueCode.custom,message:"lineHeight must be a unitless number between 0.8 and 3"}),p.NEVER)}).optional(),Qp=p.enum(["frame","thick","double","oval","shade"]).optional(),em=p.enum(["gray","blue","green","red","yellow"]).optional(),IP=p.object({type:p.literal("text"),text:p.string(),marks:p.array(p.enum(["bold","italic","underline","boxed"])).optional(),color:p.string().optional(),backgroundColor:p.string().optional(),fontFamily:p.string().optional(),fontSize:p.number().positive().optional(),boxedPaddingY:p.number().min(0).optional(),boxedVariant:Qp,boxedTone:em}),EP=p.object({type:p.literal("mathInline"),id:p.string().min(1),tex:p.string(),display:p.literal("inline"),marks:p.array(p.enum(["underline","boxed"])).optional(),color:p.string().optional(),backgroundColor:p.string().optional(),fontFamily:p.string().optional(),fontSize:p.number().positive().optional(),boxedPaddingY:p.number().min(0).optional(),boxedVariant:Qp,boxedTone:em,semanticRole:p.enum(["expression","equation","variable"]).optional(),altText:p.string().optional()}),mr=p.discriminatedUnion("type",[IP,EP]),qp=p.object({blockId:p.string().min(1),offset:p.number().int().min(0)}),CP=p.discriminatedUnion("type",[p.object({type:p.literal("textRange"),start:qp,end:qp,quote:p.string(),mathInlineIds:p.array(p.string().min(1)).optional(),mathTex:p.array(p.string()).optional()}),p.object({type:p.literal("inlineMath"),blockId:p.string().min(1),mathInlineId:p.string().min(1),quote:p.string().optional(),tex:p.string().optional()}),p.object({type:p.literal("block"),blockId:p.string().min(1),quote:p.string().optional()}),p.object({type:p.literal("overlayShape"),shapeIds:p.array(p.string().min(1)).min(1),quote:p.string().optional()}),p.object({type:p.literal("overlayMath"),shapeId:p.string().min(1).optional(),mathInlineId:p.string().min(1).optional(),quote:p.string().optional(),tex:p.string().optional()})]),tm=p.object({id:p.string().min(1),emoji:p.string().min(1),authorName:p.string().optional(),createdAt:p.string()}),LP=p.object({id:p.string().min(1),authorName:p.string().optional(),body:p.array(mr),reactions:p.array(tm).optional(),createdAt:p.string(),updatedAt:p.string().optional()}),NP=p.object({id:p.string().min(1),anchor:CP,messages:p.array(LP).min(1),reactions:p.array(tm).optional(),resolved:p.boolean().optional(),color:p.string().optional(),createdAt:p.string(),updatedAt:p.string().optional()}),hs=Nt.extend({type:p.literal("section"),title:p.string(),align:fs,lineHeight:ys}),Zo=Nt.extend({type:p.literal("heading"),level:p.union([p.literal(1),p.literal(2),p.literal(3)]),children:p.array(mr),align:fs,lineHeight:ys}),Jo=Nt.extend({type:p.literal("paragraph"),children:p.array(mr),align:fs,lineHeight:ys}),fr=p.lazy(()=>Nt.extend({type:p.literal("list"),listType:p.enum(["bullet","ordered"]),start:p.number().int().positive().optional(),markerStyle:p.enum(["decimal","paren"]).optional(),items:p.array(FP).min(1)})),FP=p.lazy(()=>p.object({type:p.literal("listItem"),id:p.string().min(1),children:p.array(mr),nested:p.array(fr).optional()})),nm=p.union([Zo,Jo,fr]),rm=p.object({top:p.number().nonnegative(),right:p.number().nonnegative(),bottom:p.number().nonnegative(),left:p.number().nonnegative()}),_P=p.discriminatedUnion("type",[p.object({type:p.literal("cornerSquares"),sizePx:p.number().positive(),color:p.string()}),p.object({type:p.literal("doubleRule"),offsetPx:p.number().nonnegative(),widthPx:p.number().positive().optional(),color:p.string().optional()}),p.object({type:p.literal("titleDoubleRule"),ruleWidthPx:p.number().positive().optional(),ruleColor:p.string().optional(),guideColor:p.string().optional()}),p.object({type:p.literal("titleBand"),heightPx:p.number().positive().optional(),backgroundColor:p.string().optional()}),p.object({type:p.literal("titlePlate"),borderColor:p.string().optional(),radiusPx:p.number().nonnegative().optional(),paddingPx:rm.optional()}),p.object({type:p.literal("leftBar"),widthPx:p.number().positive(),color:p.string()}),p.object({type:p.literal("shadow"),offsetXPx:p.number(),offsetYPx:p.number(),blurPx:p.number().nonnegative().optional(),spreadPx:p.number().optional(),color:p.string()}),p.object({type:p.literal("horizontalRules"),widthPx:p.number().positive().optional(),color:p.string().optional()}),p.object({type:p.literal("notebookRules"),baseBodyWidthPx:p.number().positive().optional(),frameLeftPx:p.number().nonnegative().optional(),frameHeightPx:p.number().positive().optional(),frameStrokeOpacity:p.number().min(0).max(1).optional(),lineColor:p.string().optional(),lineGapPx:p.number().positive().optional(),lineWidthPx:p.number().positive().optional(),lineOffsetPx:p.number().nonnegative().optional(),bindingColor:p.string().optional(),bindingWidthPx:p.number().positive().optional(),bindingXPx:p.number().nonnegative().optional(),bindingStrokeOpacity:p.number().min(0).max(1).optional(),ringColor:p.string().optional(),ringWidthPx:p.number().positive().optional(),ringHeightPx:p.number().positive().optional(),ringStrokePx:p.number().positive().optional(),ringGapPx:p.number().positive().optional(),ringTopPx:p.number().nonnegative().optional(),ringCount:p.number().int().positive().optional(),ringLeftOverhangPx:p.number().nonnegative().optional(),minHeightPx:p.number().positive().optional()})]),DP=p.object({borderWidthPx:p.number().nonnegative().optional(),borderColor:p.string().optional(),borderStyle:p.enum(["solid","dashed","dotted","double","none"]).optional(),backgroundColor:p.string().optional(),titleBackgroundColor:p.string().optional(),titleColor:p.string().optional(),titleAlign:p.enum(["left","center","right","justify"]).optional(),titlePosition:p.enum(["l","c","r"]).optional(),titleFontWeight:p.enum(["normal","bold"]).optional(),titleFontFamily:p.string().optional(),titleFontSizePx:p.number().positive().optional(),titleLineHeight:p.string().optional(),bodyColor:p.string().optional(),bodyAlign:p.enum(["left","center","right","justify"]).optional(),bodyFontFamily:p.string().optional(),bodyFontSizePx:p.number().positive().optional(),bodyLineHeight:p.string().optional(),cornerStyle:p.enum(["sharp","round"]).optional(),radiusPx:p.number().nonnegative().optional(),paddingPx:rm.optional(),decorations:p.array(_P).optional()}).optional();function Zp(e,t,n){e?.break===!0&&n.addIssue({code:p.ZodIssueCode.custom,path:[...t,"break"],message:"boxBlock\u76F4\u4E0B\u3067\u306F\u6539\u30DA\u30FC\u30B8\u3067\u304D\u307E\u305B\u3093\u3002\u7BB1\u5185\u306E\u8907\u6570\u6BB5layoutSection\u3067\u306F\u6539\u6BB5\u3092\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002"})}var GP=p.lazy(()=>p.union([hs,Zo,Jo,fr,Qo,gs])).superRefine((e,t)=>{Zp(e.pagination,["pagination"],t),e.type==="layoutSection"&&e.layout.columnCount<=1&&e.children.forEach((n,r)=>{Zp(n.pagination,["children",r,"pagination"],t)})}),Qo=p.lazy(()=>Nt.extend({type:p.literal("boxBlock"),styleId:p.string().min(1),title:p.array(mr).optional(),blocks:p.array(GP).min(1),frame:DP})),$P=p.lazy(()=>p.union([hs,Zo,Jo,fr,Qo])),jo=p.object({minHeightMm:p.number().nonnegative().optional(),columnSpan:p.enum(["column","full"]).optional()}),qo=p.lazy(()=>p.union([nm,gs,Qo])),zP=Nt.extend({type:p.literal("problem"),tags:p.array(p.string()),lead:p.array(qo).optional().default([]),prompt:p.array(qo),answer:p.object({type:p.enum(["math","text"]),expected:p.string()}).optional(),solution:p.array(qo),hints:p.array(qo),areaLayout:p.object({lead:jo.optional(),prompt:jo.optional(),solution:jo.optional(),hints:jo.optional()}).optional(),numbering:p.object({enabled:p.boolean().optional(),fontSize:p.number().positive().optional(),value:p.number().int().positive().optional()}).optional(),frame:p.object({enabled:p.boolean().optional(),styleId:p.string().min(1).optional()}).optional()}),gs=p.lazy(()=>Nt.extend({type:p.literal("layoutSection"),layout:p.object({columnCount:p.number().int().min(1).max(4),columnGapMm:p.number().nonnegative().optional()}),children:p.array($P).min(1)})),HP=[hs,Zo,Jo,fr,zP,gs,Qo],UP=p.discriminatedUnion("type",HP),VP=p.preprocess(_c,p.custom(Zi)),om=p.object({overlaySnapshot:VP.optional(),updatedAt:p.string().optional()}),WP=p.object({type:p.literal("columns").optional(),columnCount:p.number().int().min(1).max(4).optional(),columnGapMm:p.number().nonnegative().optional()}),Jp=p.object({enabled:p.boolean().optional(),heightMm:p.number().positive().optional(),offsetMm:p.number().nonnegative().optional(),showOnFirstPage:p.boolean().optional(),blocks:p.array(nm).optional(),overlay:om.optional()}),XP=p.object({preset:p.enum(["A4","A3","B5","B4","custom"]).optional(),orientation:p.enum(["portrait","landscape"]).optional(),pageSize:p.object({widthMm:p.number().positive().optional(),heightMm:p.number().positive().optional()}).optional(),marginsMm:p.object({top:p.number().nonnegative().optional(),right:p.number().nonnegative().optional(),bottom:p.number().nonnegative().optional(),left:p.number().nonnegative().optional()}).optional(),flow:WP.optional(),header:Jp.optional(),footer:Jp.optional(),overlay:om.optional()}).transform(e=>ca(on(e))).superRefine((e,t)=>{for(let n of Zc(e))t.addIssue({code:"custom",message:n})}),YP=p.object({version:p.literal("2.0"),docId:p.string().min(1),metadata:p.object({title:p.string(),source:p.object({format:p.literal("studyaid-prt").optional(),layoutMode:p.literal("fixedOverlay").optional(),printFlowContent:p.boolean().optional()}).optional(),styleUnits:p.object({fontSize:p.literal("pt").optional()}).optional(),mathFractionSizing:p.enum(["uniform","texDefault"]).optional(),texPreamble:p.string().max(2e4).optional()}),content:p.array(UP),outputProfiles:p.object({student:p.object({showSolutions:p.boolean().optional(),showHints:p.boolean().optional(),includeAnswers:p.boolean().optional(),onlySolutions:p.boolean().optional(),includeComments:p.boolean().optional()}),teacher:p.object({showSolutions:p.boolean().optional(),showHints:p.boolean().optional(),includeAnswers:p.boolean().optional(),onlySolutions:p.boolean().optional(),includeComments:p.boolean().optional()}),answerBook:p.object({showSolutions:p.boolean().optional(),showHints:p.boolean().optional(),includeAnswers:p.boolean().optional(),onlySolutions:p.boolean().optional(),includeComments:p.boolean().optional()})}),comments:p.array(NP).optional(),pageLayout:XP.optional(),updatedAt:p.string().optional()}),KP=YP.transform(e=>({...e,version:"2.0",metadata:{...e.metadata,styleUnits:{...e.metadata.styleUnits,fontSize:bo}},pageLayout:on(e.pageLayout)}));function jP(e){if(typeof e!="object"||e===null||Array.isArray(e.content)||!Array.isArray(e.chapters))return e;let{chapters:t,...n}=e,r=t.flatMap(o=>o&&typeof o=="object"&&Array.isArray(o.content)?o.content:[]);return{...n,content:r}}function im(e){return KP.parse(qP(jP(e)))}function qP(e){if(!Lt(e)||e.version!=="2.0")return e;let t=Lt(e.metadata)?e.metadata:{};if((Lt(t.styleUnits)?t.styleUnits:{}).fontSize===bo)return e;let r=ms(e);if(!Lt(r))return r;let o=Lt(r.metadata)?r.metadata:{},i=Lt(o.styleUnits)?o.styleUnits:{};return{...r,metadata:{...o,styleUnits:{...i,fontSize:bo}}}}function ms(e){if(Array.isArray(e))return e.map(ms);if(!Lt(e))return e;let t={};for(let[n,r]of Object.entries(e))n==="fontSize"&&typeof r=="number"&&Number.isFinite(r)&&r>0?t[n]=In(r):t[n]=ms(r);return t}function Lt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ZP=100,vs=32*1024*1024,am=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/u,JP=/[\u0000-\u001f\u007f-\u009f]/u,QP=/^(?:\d+(?:\.\d+)?|\.\d+)(?:px)?$/u,eT=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u,Ms=class extends Error{constructor(t){super("Viewer\u3067\u5B89\u5168\u306B\u63CF\u753B\u3067\u304D\u306A\u3044\u30B9\u30BF\u30A4\u30EB\u5024\u304C\u3042\u308A\u307E\u3059\u3002"),this.name="ViewerSafetyValidationError",this.issues=t}};function pm(e){let t=tT(e);if(t.length>0)throw new Ms(t)}function tT(e){let t=[],n=(r,o)=>{t.length<ZP&&t.push(`${r}: ${o}`)};return e.content.forEach((r,o)=>nT(r,`content.${o}`,n)),sm(e.pageLayout?.header?.blocks,"pageLayout.header.blocks",n),sm(e.pageLayout?.footer?.blocks,"pageLayout.footer.blocks",n),xs(e.pageLayout?.overlay,"pageLayout.overlay",n),xs(e.pageLayout?.header?.overlay,"pageLayout.header.overlay",n),xs(e.pageLayout?.footer?.overlay,"pageLayout.footer.overlay",n),t}function mm(e){let t=e.trim();if(!t)return{ok:!1,reason:"\u753B\u50CFsource\u304C\u7A7A\u3067\u3059\u3002"};if(JP.test(t))return{ok:!1,reason:"\u753B\u50CFdata URL\u306B\u5236\u5FA1\u6587\u5B57\u304C\u3042\u308A\u307E\u3059\u3002"};let n=t.indexOf(",");if(n<0)return{ok:!1,reason:"\u753B\u50CFsource\u306Fdata URL\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002"};let r=t.slice(0,n).toLowerCase(),o=t.slice(n+1);if(r==="data:image/png;base64")return bs(t,o,"image/png",yT);if(r==="data:image/jpeg;base64")return bs(t,o,"image/jpeg",hT);if(r==="data:image/webp;base64")return bs(t,o,"image/webp",gT);let i=r==="data:image/svg+xml;base64"||r==="data:image/svg+xml;charset=utf-8;base64"||r==="data:image/svg+xml;charset=us-ascii;base64";if(!i&&!(r==="data:image/svg+xml"||r==="data:image/svg+xml;charset=utf-8"||r==="data:image/svg+xml;charset=us-ascii"))return{ok:!1,reason:"\u753B\u50CF\u306FPNG\u30FBJPEG\u30FBWebP\u30FBSVG\u306Edata URL\u306E\u307F\u8868\u793A\u3067\u304D\u307E\u3059\u3002"};let s;try{if(i){let l=fm(o);if(!l)return{ok:!1,reason:"SVG\u753B\u50CF\u306Ebase64 payload\u304C\u4E0D\u6B63\u3067\u3059\u3002"};s=new TextDecoder("utf-8",{fatal:!0}).decode(l)}else s=decodeURIComponent(o)}catch{return{ok:!1,reason:"SVG\u753B\u50CF\u306Epayload\u3092UTF-8\u3068\u3057\u3066\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093\u3002"}}let c=xT(s);return c?{ok:!1,reason:c}:{ok:!0,value:{src:t,mimeType:"image/svg+xml"}}}function sm(e,t,n){e?.forEach((r,o)=>hr(r,`${t}.${o}`,n))}function nT(e,t,n){if(e.type==="section"){oi(e.lineHeight,`${t}.lineHeight`,n);return}if(e.type==="heading"||e.type==="paragraph"||e.type==="list"){hr(e,t,n);return}if(e.type==="problem"){["lead","prompt","hints","solution"].forEach(r=>{e[r].forEach((o,i)=>rT(o,`${t}.${r}.${i}`,n))});return}if(e.type==="layoutSection"){e.children.forEach((r,o)=>ni(r,`${t}.children.${o}`,n));return}Ps(e,t,n)}function rT(e,t,n){if(e.type==="layoutSection"){e.children.forEach((r,o)=>ni(r,`${t}.children.${o}`,n));return}if(e.type==="boxBlock"){Ps(e,t,n);return}hr(e,t,n)}function ni(e,t,n){e.type==="section"?oi(e.lineHeight,`${t}.lineHeight`,n):e.type==="boxBlock"?Ps(e,t,n):hr(e,t,n)}function oT(e,t,n){e.type==="layoutSection"?e.children.forEach((r,o)=>ni(r,`${t}.children.${o}`,n)):ni(e,t,n)}function Ps(e,t,n){e.title?.forEach((r,o)=>ri(r,`${t}.title.${o}`,n)),e.blocks.forEach((r,o)=>oT(r,`${t}.blocks.${o}`,n)),iT(e.frame,`${t}.frame`,n)}function hr(e,t,n){if(e.type==="heading"||e.type==="paragraph"){oi(e.lineHeight,`${t}.lineHeight`,n),e.children.forEach((r,o)=>ri(r,`${t}.children.${o}`,n));return}e.items.forEach((r,o)=>{r.children.forEach((i,a)=>ri(i,`${t}.items.${o}.children.${a}`,n)),r.nested?.forEach((i,a)=>hr(i,`${t}.items.${o}.nested.${a}`,n))})}function ri(e,t,n){V(e.color,`${t}.color`,n),V(e.backgroundColor,`${t}.backgroundColor`,n),yr(e.fontFamily,`${t}.fontFamily`,n)}function iT(e,t,n){if(e){for(let r of["borderColor","backgroundColor","titleBackgroundColor","titleColor","bodyColor"])V(e[r],`${t}.${r}`,n);yr(e.titleFontFamily,`${t}.titleFontFamily`,n),yr(e.bodyFontFamily,`${t}.bodyFontFamily`,n),cm(e.titleLineHeight,`${t}.titleLineHeight`,n),cm(e.bodyLineHeight,`${t}.bodyLineHeight`,n),e.titlePosition!==void 0&&!["l","c","r"].includes(e.titlePosition)&&n(`${t}.titlePosition`,"\u30BF\u30A4\u30C8\u30EB\u4F4D\u7F6E\u306Fl\u30FBc\u30FBr\u306E\u3044\u305A\u308C\u304B\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),e.decorations?.forEach((r,o)=>aT(r,`${t}.decorations.${o}`,n))}}function aT(e,t,n){"color"in e&&V(e.color,`${t}.color`,n),"borderColor"in e&&V(e.borderColor,`${t}.borderColor`,n),"backgroundColor"in e&&V(e.backgroundColor,`${t}.backgroundColor`,n),"ruleColor"in e&&V(e.ruleColor,`${t}.ruleColor`,n),"guideColor"in e&&V(e.guideColor,`${t}.guideColor`,n),"lineColor"in e&&V(e.lineColor,`${t}.lineColor`,n),"bindingColor"in e&&V(e.bindingColor,`${t}.bindingColor`,n),"ringColor"in e&&V(e.ringColor,`${t}.ringColor`,n)}function xs(e,t,n){e?.overlaySnapshot&&sT(e.overlaySnapshot,`${t}.overlaySnapshot`,n)}function sT(e,t,n){e.shapes.forEach((r,o)=>lT(r,`${t}.shapes.${o}`,n))}function lT(e,t,n){switch(e.type){case"geo":V(e.props.color,`${t}.props.color`,n),V(e.props.fillColor,`${t}.props.fillColor`,n),V(e.props.labelColor,`${t}.props.labelColor`,n);break;case"arc":V(e.props.color,`${t}.props.color`,n),V(e.props.fillColor,`${t}.props.fillColor`,n);break;case"arrow":V(e.props.color,`${t}.props.color`,n),V(e.props.labelColor,`${t}.props.labelColor`,n);break;case"line":V(e.props.color,`${t}.props.color`,n),V(e.props.fillColor,`${t}.props.fillColor`,n),V(e.props.labelColor,`${t}.props.labelColor`,n);break;case"text":case"callout":V(e.props.color,`${t}.props.color`,n),cT(e.props.richText,`${t}.props.richText`,n);break;case"graph2dShape":dT(e.props.spec,`${t}.props.spec`,n);break;case"tableShape":pT(e.props.table,`${t}.props.table`,n);break;default:break}}function cT(e,t,n){let r=new WeakSet;if(r.has(e)){n(t,"richText\u306B\u5FAA\u74B0\u53C2\u7167\u304C\u3042\u308A\u307E\u3059\u3002");return}r.add(e),e.blocks.forEach((o,i)=>{let a=`${t}.blocks.${i}`;if(r.has(o)){n(a,"richText\u306B\u5FAA\u74B0\u53C2\u7167\u304C\u3042\u308A\u307E\u3059\u3002");return}r.add(o),oi(o.lineHeight,`${a}.lineHeight`,n),o.align!==void 0&&!["left","center","right","justify"].includes(o.align)&&n(`${a}.align`,"\u8A31\u53EF\u3055\u308C\u3066\u3044\u306A\u3044text-align\u3067\u3059\u3002"),o.children.forEach((s,c)=>{uT(s,`${a}.children.${c}`,n)}),r.delete(o)}),r.delete(e)}function uT(e,t,n){V(e.color,`${t}.color`,n),V(e.backgroundColor,`${t}.backgroundColor`,n),yr(e.fontFamily,`${t}.fontFamily`,n),e.fontSize!==void 0&&!um(e.fontSize,512)&&n(`${t}.fontSize`,"font-size\u304C\u4E0D\u6B63\u3067\u3059\u3002"),e.boxedPaddingY!==void 0&&!um(e.boxedPaddingY,100,!0)&&n(`${t}.boxedPaddingY`,"padding\u304C\u4E0D\u6B63\u3067\u3059\u3002")}function dT(e,t,n){V(e.axes.axisColor,`${t}.axes.axisColor`,n),e.curves.forEach((r,o)=>V(r.color,`${t}.curves.${o}.color`,n)),e.points?.forEach((r,o)=>V(r.color,`${t}.points.${o}.color`,n)),e.fills?.forEach((r,o)=>V(r.color,`${t}.fills.${o}.color`,n))}function pT(e,t,n){V(e.grid.borderColor,`${t}.grid.borderColor`,n),e.grid.lineOverrides?.forEach((r,o)=>mT(r.style,`${t}.grid.lineOverrides.${o}.style`,n)),lm(e.defaultCellStyle,`${t}.defaultCellStyle`,n),e.cells.forEach((r,o)=>{lm(r.style,`${t}.cells.${o}.style`,n),r.content.forEach((i,a)=>fT(i,`${t}.cells.${o}.content.${a}`,n))})}function mT(e,t,n){V(e.borderColor,`${t}.borderColor`,n)}function lm(e,t,n){e&&(V(e.color,`${t}.color`,n),V(e.backgroundColor,`${t}.backgroundColor`,n),yr(e.fontFamily,`${t}.fontFamily`,n))}function fT(e,t,n){let r=e;for(let o of["children","label"]){let i=r[o];Array.isArray(i)&&i.forEach((a,s)=>ri(a,`${t}.${o}.${s}`,n))}}function V(e,t,n){if(ii(e)){if(!vt(e)){n(t,"CSS\u6CE8\u5165\u306B\u3064\u306A\u304C\u308B\u6587\u5B57\u5217\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002");return}Pe(e)||n(t,"\u8A31\u53EF\u3055\u308C\u3066\u3044\u306A\u3044\u8272\u8868\u73FE\u3067\u3059\u3002")}}function yr(e,t,n){ii(e)&&(Qr(e)||n(t,"font-family\u306B\u5B89\u5168\u3067\u306A\u3044\u5024\u304C\u3042\u308A\u307E\u3059\u3002"))}function oi(e,t,n){if(!ii(e))return;if(!vt(e)||!/^(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e.trim())){n(t,"line-height\u306F\u5358\u4F4D\u306A\u3057\u6570\u5024\u3060\u3051\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002");return}let r=Number(e);(!Number.isFinite(r)||r<.5||r>5)&&n(t,"line-height\u304C\u8A31\u53EF\u7BC4\u56F2\u5916\u3067\u3059\u3002")}function cm(e,t,n){if(!ii(e))return;let r=e.trim();if(!vt(e)||!QP.test(r)){n(t,"line-height\u306F\u6570\u5024\u307E\u305F\u306Fpx\u5358\u4F4D\u306E\u9577\u3055\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return}let o=Number.parseFloat(r);(!Number.isFinite(o)||o<0||o>999)&&n(t,"line-height\u304C\u8A31\u53EF\u7BC4\u56F2\u5916\u3067\u3059\u3002")}function ii(e){return e!=null}function um(e,t,n=!1){if(typeof e=="string"&&(!vt(e)||!/^(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e.trim())))return!1;let r=typeof e=="number"?e:Number(e);return Number.isFinite(r)&&(n?r>=0:r>0)&&r<=t}function bs(e,t,n,r){let o=fm(t);return!o||!r(o)?{ok:!1,reason:`${n}\u753B\u50CF\u306Epayload\u304C\u4E0D\u6B63\u3067\u3059\u3002`}:{ok:!0,value:{src:e,mimeType:n}}}function fm(e){if(!e||e.length%4!==0||e.length>Math.ceil(vs/3)*4||!eT.test(e))return null;let t=e.endsWith("==")?2:e.endsWith("=")?1:0,n=e.length/4*3-t;if(n<=0||n>vs)return null;let r=new Uint8Array(n),o=0;for(let i=0;i<e.length;i+=4){let a=ei(e.charCodeAt(i)),s=ei(e.charCodeAt(i+1)),c=e[i+2]==="="?0:ei(e.charCodeAt(i+2)),l=e[i+3]==="="?0:ei(e.charCodeAt(i+3));if(a<0||s<0||c<0||l<0)return null;let d=a<<18|s<<12|c<<6|l;o<n&&(r[o++]=d>>>16&255),o<n&&(r[o++]=d>>>8&255),o<n&&(r[o++]=d&255)}return r}function ei(e){return e>=65&&e<=90?e-65:e>=97&&e<=122?e-71:e>=48&&e<=57?e+4:e===43?62:e===47?63:-1}function yT(e){let t=[137,80,78,71,13,10,26,10];if(e.length<45||!t.every((o,i)=>e[i]===o))return!1;let n=8,r=!1;for(;n+12<=e.length;){let o=Ss(e,n),i=ti(e,n+4,4),a=n+12+o;if(a>e.length)return!1;if(!r){if(i!=="IHDR"||o!==13||Ss(e,n+8)===0||Ss(e,n+12)===0)return!1;r=!0}if(i==="IEND")return o===0&&a===e.length;n=a}return!1}function hT(e){if(e.length<12||e[0]!==255||e[1]!==216||e[e.length-2]!==255||e[e.length-1]!==217)return!1;for(let t=2;t+1<e.length-2;t+=1){if(e[t]!==255)continue;let n=e[t+1];if(n>=192&&n<=195||n>=197&&n<=199||n>=201&&n<=203||n>=205&&n<=207)return!0}return!1}function gT(e){if(e.length<20||ti(e,0,4)!=="RIFF"||ti(e,8,4)!=="WEBP"||dm(e,4)+8!==e.length)return!1;let t=ti(e,12,4),n=dm(e,16);return(t==="VP8 "||t==="VP8L"||t==="VP8X")&&20+n<=e.length}function xT(e){let t=e.trim();if(!t||t.length>vs||am.test(e))return"SVG\u753B\u50CF\u304C\u7A7A\u3001\u904E\u5927\u3001\u307E\u305F\u306F\u5236\u5FA1\u6587\u5B57\u3092\u542B\u3093\u3067\u3044\u307E\u3059\u3002";let n=bT(t);if(n===null||am.test(n))return"SVG\u753B\u50CF\u306B\u4E0D\u6B63\u306A\u6587\u5B57\u53C2\u7167\u307E\u305F\u306F\u5236\u5FA1\u6587\u5B57\u304C\u3042\u308A\u307E\u3059\u3002";if(!/^(?:<\?xml\s[^>]*>\s*)?<svg(?:\s|>)[\s\S]*<\/svg>\s*$/iu.test(n))return"SVG\u753B\u50CF\u306B\u6709\u52B9\u306Asvg\u30EB\u30FC\u30C8\u8981\u7D20\u304C\u3042\u308A\u307E\u305B\u3093\u3002";if(/<!doctype\b|<!entity\b|<\?xml-stylesheet\b|<(?:script|foreignObject|iframe|object|embed)\b/iu.test(n))return"SVG\u753B\u50CF\u306B\u8A31\u53EF\u3055\u308C\u3066\u3044\u306A\u3044\u8981\u7D20\u304C\u3042\u308A\u307E\u3059\u3002";if(/\son[a-z][\w:-]*\s*=/iu.test(n))return"SVG\u753B\u50CF\u306B\u30A4\u30D9\u30F3\u30C8\u5C5E\u6027\u304C\u3042\u308A\u307E\u3059\u3002";if(/(?:@import\b|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:|\/\*)/iu.test(n))return"SVG\u753B\u50CF\u306B@import\u307E\u305F\u306F\u5371\u967A\u306ACSS\u304C\u3042\u308A\u307E\u3059\u3002";let r=n.replace(/url\s*\(\s*([^)]*?)\s*\)/giu,(i,a)=>{let s=a.trim(),c=s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")?s.slice(1,-1).trim():s;return/^#[A-Za-z_][\w:.-]*$/u.test(c)?"":i});if(/url\s*\(/iu.test(r))return"SVG\u753B\u50CF\u306Eurl()\u306F\u540C\u4E00SVG\u5185\u306E\u8981\u7D20\u3060\u3051\u53C2\u7167\u3067\u304D\u307E\u3059\u3002";let o=/\s(?:href|xlink:href)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/giu;for(let i of n.matchAll(o))if(!(i[1]??i[2]??i[3]??"").trim().startsWith("#"))return"SVG\u753B\u50CF\u304B\u3089\u5916\u90E8resource\u3092\u53C2\u7167\u3067\u304D\u307E\u305B\u3093\u3002";return null}function bT(e){let t=!0,n=e.replace(/&(?:#(\d+)|#x([\da-f]+)|amp|lt|gt|quot|apos);/giu,(r,o,i)=>{if(o||i){let a=o?Number(o):Number.parseInt(i,16);return ST(a)?String.fromCodePoint(a):(t=!1,"")}return{"&":"&","<":"<",">":">",""":'"',"'":"'"}[r.toLowerCase()]??r});return t?n:null}function ST(e){return Number.isSafeInteger(e)&&(e===9||e===10||e===13||e>=32&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111)}function Ss(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function dm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function ti(e,t,n){let r="";for(let o=0;o<n;o+=1)r+=String.fromCharCode(e[t+o]);return r}import{jsx as oe,jsxs as ks}from"react/jsx-runtime";var hm=96/25.4,PT=["problem","solution","comments"],xr=class extends Error{constructor(t,n){super("SigmaDoc\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002"),this.name="SigmaDocParseError",this.issues=t,n&&"cause"in n&&Object.defineProperty(this,"cause",{configurable:!0,value:n.cause})}};function vm(e){try{let t=TT(e),n=im(t);return pm(n),n}catch(t){throw new xr(Mm(t),{cause:t})}}function TT(e){if(!si(e)||!si(e.pageLayout))return e;let t=e.pageLayout,n=!1,r={...t},o=gm(t.overlay);o.changed&&(r.overlay=o.value,n=!0);for(let i of["header","footer"]){if(!si(t[i]))continue;let a=t[i],s=gm(a.overlay);s.changed&&(r[i]={...a,overlay:s.value},n=!0)}return n?{...e,pageLayout:r}:e}function gm(e){if(!si(e)||e.overlaySnapshot===void 0)return{value:e,changed:!1};let t=ea(e.overlaySnapshot);return t.issues.length===0?{value:e,changed:!1}:{value:{...e,overlaySnapshot:t.snapshot},changed:!0}}function si(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function OT({document:e,visibleParts:t,hideProblemNumbers:n=!1,maxHeightPx:r,className:o,style:i,onError:a}){let[s,c]=gr(!1),[l,d]=gr(0),u=ym(()=>UT(t),[t]),m=ym(()=>RT(e,u,n),[e,u,n]);ai(()=>{c(!0)},[]),ai(()=>{if(!(!s||m.kind!=="ready"||!a))for(let S of m.errors)Bs(a,S)},[s,a,m]),ai(()=>{if(!s||typeof globalThis.document>"u")return;let S=globalThis.document.fonts;if(!S)return;let I=!1;return S.ready.then(()=>{I||d(R=>R+1)}),()=>{I=!0}},[s,m.key]);let h=["sigma-viewer",o].filter(Boolean).join(" ");if(!s)return oe("section",{className:h,"data-sigma-viewer":"true","data-sigma-viewer-state":"loading","aria-busy":"true",style:i,children:oe("span",{className:"sigma-viewer__status",children:"\u6587\u66F8\u3092\u6E96\u5099\u3057\u3066\u3044\u307E\u3059\u3002"})});if(m.kind==="error")return a?ks("section",{className:h,"data-sigma-viewer":"true","data-sigma-viewer-state":"error",style:i,children:[oe(kT,{callback:a,error:m.error}),oe(Os,{message:m.error.message})]}):oe("section",{className:h,"data-sigma-viewer":"true","data-sigma-viewer-state":"error",style:i,children:oe(Os,{message:m.error.message})});let y=m.document.pageLayout.pageSize.widthMm*hm,g=m.document.pageLayout.pageSize.heightMm*hm,x=`${m.key}:${l}`;return oe("section",{className:h,"data-sigma-viewer":"true","data-sigma-viewer-state":"ready",style:i,children:oe(wT,{maxHeightPx:r,resetKey:x,children:ks(ws,{onError:a,children:[oe(Wp,{document:m.document,displayMode:"vertical",includePrintPageStyle:!1,stackClassName:"sigma-viewer__pages",renderPageFrame:({page:S,pageNode:I})=>oe(BT,{pageNumber:S.number,pageWidthPx:y,pageHeightPx:g,children:I},S.id)}),m.placeholderAssetIds.map(S=>oe("span",{className:"sigma-viewer__asset-placeholder-marker","data-sigma-viewer-asset-placeholder":S,"aria-hidden":"true"},S))]},x)})})}function wT({maxHeightPx:e,resetKey:t,children:n}){let r=MT(),o=Sm(null),[i,a]=gr(!1),[s,c]=gr(!1),l=VT(e);Ts(()=>{a(!1)},[t,l]),Ts(()=>{let u=o.current;if(!u||l===void 0){c(!1);return}let m=()=>{c(u.scrollHeight>l+.5)};if(m(),typeof ResizeObserver<"u"){let h=new ResizeObserver(m);return h.observe(u),()=>h.disconnect()}return globalThis.addEventListener?.("resize",m),()=>globalThis.removeEventListener?.("resize",m)},[t,l]);let d=l!==void 0&&!i;return ks("div",{className:`sigma-viewer__viewport ${d?"is-constrained":""}`,"data-sigma-viewer-height-limited":d?"true":"false","data-sigma-viewer-overflow":s?"true":"false",style:d?{maxHeight:`${l}px`}:void 0,children:[oe("div",{className:"sigma-viewer__viewport-content",id:r,ref:o,children:n}),d&&s?oe("div",{className:"sigma-viewer__overflow-control",children:oe("button",{type:"button",className:"sigma-viewer__expand-button","aria-controls":r,"aria-expanded":"false",onClick:()=>a(!0),children:"\u3059\u3079\u3066\u8868\u793A"})}):null]})}function kT({callback:e,error:t}){return ai(()=>{Bs(e,t)},[e,t]),null}function Os({message:e}){return oe("div",{className:"sigma-viewer__error",role:"alert",children:e})}var ws=class extends vT{constructor(){super(...arguments);this.state={error:null}}static getDerivedStateFromError(n){return{error:{code:"render-failed",message:n instanceof Error&&n.message?`SigmaDoc\u306E\u63CF\u753B\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${n.message}`:"SigmaDoc\u306E\u63CF\u753B\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002"}}}componentDidCatch(n,r){this.state.error&&this.props.onError&&Bs(this.props.onError,this.state.error)}render(){return this.state.error?oe(Os,{message:this.state.error.message}):this.props.children}};function BT({pageNumber:e,pageWidthPx:t,pageHeightPx:n,children:r}){let o=Sm(null),[i,a]=gr(1);return Ts(()=>{let s=o.current;if(!s||!(t>0))return;let c=()=>{let d=s.getBoundingClientRect().width;if(!(d>0))return;let u=d/t,m=u>=.999?1:Math.min(1,u);a(h=>Math.abs(h-m)<.001?h:m)};if(c(),typeof ResizeObserver>"u")return globalThis.addEventListener?.("resize",c),()=>globalThis.removeEventListener?.("resize",c);let l=new ResizeObserver(c);return l.observe(s),()=>l.disconnect()},[t]),oe("div",{ref:o,className:"sigma-viewer__page","data-sigma-viewer-page":e,style:{width:"100%",maxWidth:`${t}px`,height:`${n*i}px`},children:oe("div",{className:"sigma-viewer__page-scaler",style:{width:`${t}px`,height:`${n}px`,transform:`scale(${i})`},children:r})})}function RT(e,t,n){let r;try{r=vm(e)}catch(a){let s=a instanceof xr?a.issues:Mm(a);return{kind:"error",error:{code:"invalid-document",message:"SigmaDoc\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",issues:s},key:`invalid:${bm(s.join(`
|
|
47
|
+
`))}`}}let o=t===void 0?AT(r,n):ET(r,t,n),i=DT(o);return{kind:"ready",document:i.document,errors:i.errors,placeholderAssetIds:i.placeholderAssetIds,key:bm(JSON.stringify(i.document))}}function AT(e,t){return{...e,comments:void 0,content:e.content.map(n=>IT(n,t))}}function IT(e,t){if(e.type!=="problem")return e;let n=t?{...e.numbering,enabled:!1}:e.numbering;return e.answer?{...e,numbering:n,prompt:[...e.prompt,_T(e.id,e.answer)]}:n===e.numbering?e:{...e,numbering:n}}function ET(e,t,n){let r=new Set(t),i=e.content.filter(s=>s.type==="problem").map(s=>CT(s,r,n)),a=LT(i);return{...e,comments:void 0,content:i,pageLayout:NT(e.pageLayout,a)}}function CT(e,t,n){let r=t.has("problem"),o=t.has("solution"),i=t.has("comments"),a=new Set([...r?["lead","prompt"]:[],...o?["solution"]:[],...i?["hints"]:[]]),s=Object.entries(e.areaLayout??{}).filter(([c])=>a.has(c));return{...e,lead:r?e.lead:[],prompt:r?e.prompt:[],answer:void 0,solution:o?e.solution:[],hints:i?e.hints:[],areaLayout:s.length>0?Object.fromEntries(s):void 0,numbering:n||!r?{...e.numbering,enabled:!1}:e.numbering}}function LT(e){let t=new Set,n=r=>{if(t.add(r.id),r.type==="layoutSection")r.children.forEach(n);else if(r.type==="boxBlock")r.blocks.forEach(n);else if(r.type==="list")for(let o of r.items)t.add(o.id),o.nested?.forEach(n)};for(let r of e)t.add(r.id),r.lead.forEach(n),r.prompt.forEach(n),r.solution.forEach(n),r.hints.forEach(n);return t}function NT(e,t){if(!e)return e;let n=e.overlay?.overlaySnapshot;return{...e,header:void 0,footer:void 0,overlay:n?{...e.overlay,overlaySnapshot:{...n,shapes:FT(n.shapes,t)}}:void 0}}function FT(e,t){let n=new Map(e.map(s=>[s.id,s])),r=new Map,o=(s,c=new Set)=>{let l=r.get(s.id);if(l!==void 0)return l;if(c.has(s.id))return r.set(s.id,!1),!1;c.add(s.id);let d=!1;if(s.anchor?.type==="block")d=t.has(s.anchor.blockId);else if(s.anchor?.type==="shape"){let u=n.get(s.anchor.shapeId);d=u?o(u,c):!1}else if(s.parentId){let u=n.get(s.parentId);d=u?o(u,c):!1}return c.delete(s.id),r.set(s.id,d),d},i=new Set(e.filter(s=>o(s)).map(s=>s.id)),a=(s,c=new Set)=>{if(!s.parentId||c.has(s.id))return;let l=n.get(s.parentId);l&&(c.add(s.id),i.add(l.id),a(l,c))};for(let s of e)i.has(s.id)&&a(s);return e.filter(s=>i.has(s.id))}function _T(e,t){return{type:"paragraph",id:`${e}__viewer_answer`,children:t.type==="math"?[{type:"text",text:"\u7B54\u3000",marks:["bold"]},{type:"mathInline",id:`${e}__viewer_answer_math`,tex:t.expected,display:"inline",semanticRole:"expression"}]:[{type:"text",text:"\u7B54\u3000",marks:["bold"]},{type:"text",text:t.expected}]}}function DT(e){let t=[],n=new Set,r=new Set,o=a=>{if(!a?.overlaySnapshot)return a;let s=GT(a.overlaySnapshot,t,n,r);return{...a,overlaySnapshot:s}},i=e.pageLayout;return{document:{...e,pageLayout:{...i,overlay:o(i.overlay),header:i.header?{...i.header,overlay:o(i.header.overlay)}:void 0,footer:i.footer?{...i.footer,overlay:o(i.footer.overlay)}:void 0}},errors:t,placeholderAssetIds:[...n]}}function GT(e,t,n,r){let o={...e.assets};for(let i of e.shapes){if(i.type!=="image")continue;let a=i.props.assetId,s=o[a],c=s?mm(s.props.src):null;if(s&&c?.ok){let{storage:d,...u}=s.props;o[a]={...s,props:{...u,src:c.value.src,mimeType:c.value.mimeType}};continue}n.add(a);let l=s?c&&!c.ok?c.reason:"\u753B\u50CF\u306FPNG\u30FBJPEG\u30FBWebP\u30FBSVG\u306Edata URL\u306E\u307F\u8868\u793A\u3067\u304D\u307E\u3059\u3002":"\u753B\u50CF\u30A2\u30BB\u30C3\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002";HT(a,l,t,r),o[a]=$T(a,s,i.props.w,i.props.h)}return{...e,assets:o}}function $T(e,t,n,r){let o=xm(t?.props.w,n),i=xm(t?.props.h,r);return{id:e,type:"image",props:{w:o,h:i,name:t?.props.name||"unsupported-image",isAnimated:!1,mimeType:"image/svg+xml",src:zT(e,o,i),fileSize:0}}}function zT(e,t,n){let r=Math.max(1,Math.round(t)),o=Math.max(1,Math.round(n)),i=WT(e.length>28?`${e.slice(0,25)}\u2026`:e),a=[`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}" viewBox="0 0 ${r} ${o}">`,'<rect width="100%" height="100%" fill="#f8fafc"/>',`<path d="M0 0L${r} ${o}M${r} 0L0 ${o}" stroke="#cbd5e1" stroke-width="2"/>`,`<rect x="1" y="1" width="${Math.max(0,r-2)}" height="${Math.max(0,o-2)}" fill="none" stroke="#94a3b8"/>`,`<text x="50%" y="50%" text-anchor="middle" dominant-baseline="middle" fill="#475569" font-family="sans-serif" font-size="12">${i}</text>`,"</svg>"].join("");return`data:image/svg+xml,${encodeURIComponent(a)}`}function HT(e,t,n,r){r.has(e)||(r.add(e),n.push({code:"unsupported-asset",assetId:e,message:`${t} (${e})`}))}function xm(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:Math.max(1,t)}function Mm(e){if(e&&typeof e=="object"&&"issues"in e&&Array.isArray(e.issues)){let t=e.issues.map(n=>n&&typeof n=="object"&&"message"in n?`${"path"in n&&Array.isArray(n.path)&&n.path.length?`${n.path.join(".")}: `:""}${String(n.message)}`:String(n));if(t.length)return t}return[e instanceof Error&&e.message?e.message:"\u4E0D\u6B63\u306ASigmaDoc\u3067\u3059\u3002"]}function Bs(e,t){try{e(t)}catch{}}function UT(e){if(e===void 0)return;let t=new Set(e);return PT.filter(n=>t.has(n))}function VT(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function bm(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function WT(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export{xr as SigmaDocParseError,OT as SigmaDocViewer,vm as parseSigmaDocument};
|