reactive-md 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG-ch.md +113 -96
  2. package/CHANGELOG.md +113 -96
  3. package/LICENSE +21 -21
  4. package/README-ch.md +123 -122
  5. package/README-en.md +147 -146
  6. package/README.md +147 -146
  7. package/bin/reactive-md.mjs +1 -1
  8. package/dist-library/reactive-md-react.js +199 -103
  9. package/dist-library/reactive-md.css +1 -1
  10. package/dist-library/reactive-md.js +1 -1
  11. package/dist-library/{runtime-DtjdPXxJ.js → runtime-D3QTVYaz.js} +122 -122
  12. package/dist-standalone/reactive-md-standalone.css +1 -1
  13. package/dist-standalone/reactive-md-standalone.js +1 -1
  14. package/docs/compatibility-ch.md +3 -3
  15. package/docs/compatibility-en.md +3 -3
  16. package/docs/release-0.4.0-ch.md +4 -4
  17. package/docs/release-0.4.0-en.md +4 -4
  18. package/docs/release-0.4.1-ch.md +23 -0
  19. package/docs/release-0.4.1-en.md +23 -0
  20. package/docs/releasing-ch.md +101 -101
  21. package/docs/releasing-en.md +101 -101
  22. package/examples/integration/core/package.json +7 -7
  23. package/examples/integration/react/index.html +12 -12
  24. package/examples/integration/react/main.jsx +21 -21
  25. package/examples/integration/react/package.json +9 -9
  26. package/examples/local/catalog.reactive.md +20 -20
  27. package/examples/local/checklist.reactive.md +32 -32
  28. package/examples/local/comparison.reactive.md +47 -47
  29. package/examples/local/components.reactive.md +44 -44
  30. package/examples/local/counter.reactive.md +7 -7
  31. package/examples/local/diagnostics.reactive.md +54 -54
  32. package/examples/local/diagram.reactive.md +44 -44
  33. package/examples/local/gallery.reactive.md +61 -61
  34. package/examples/local/parameters.reactive.md +36 -36
  35. package/examples/local/planning.reactive.md +24 -24
  36. package/examples/local/pricing.reactive.md +20 -20
  37. package/examples/local/zh/catalog.reactive.md +20 -20
  38. package/examples/local/zh/charts.reactive.md +73 -73
  39. package/examples/local/zh/checklist.reactive.md +32 -32
  40. package/examples/local/zh/comparison.reactive.md +47 -47
  41. package/examples/local/zh/components.reactive.md +44 -44
  42. package/examples/local/zh/counter.reactive.md +7 -7
  43. package/examples/local/zh/diagnostics.reactive.md +54 -54
  44. package/examples/local/zh/diagram.reactive.md +44 -44
  45. package/examples/local/zh/gallery.reactive.md +61 -61
  46. package/examples/local/zh/parameters.reactive.md +36 -36
  47. package/examples/local/zh/planning.reactive.md +24 -24
  48. package/examples/local/zh/pricing.reactive.md +20 -20
  49. package/package.json +91 -90
@@ -53,5 +53,5 @@ Error generating stack: `+e.message+`
53
53
  `,t.range.end),i=r<0?e.source.length:r;return e.source.slice(n,t.range.start).trim()===``&&e.source.slice(t.range.end,i).trim()===``}function rf(e,t,n){let r=Td(e.source,t.node.range.start,t.node.range.end),i=/(?:^|[\s"'/])value\s*=\s*(["'])/.exec(r);if(!i)return t.node.range.start;let a=t.node.range.start+i.index+i[0].length;return Math.min(t.node.range.end,a+n)}function af(e){let t=[],n=new Map,r=new Set(e.nodes);for(let i of e.entries){if(i.name!==`computed`&&i.name!==`const`)continue;let a=i.name,o=i.node;if(!r.has(o)||!nf(e,o)){e.report(`local.computation.placement`,`<${a}> declarations must be standalone tags at the document top level.`,o.range.start,o.range.end);continue}let s=e.attrs.get(o.id)??{},c=s.name,l=typeof c?.value==`string`?c.value:``;if(!c||!l)continue;if(l.length>od){e.report(`local.budget.identifier`,`Computation name exceeds the ${od}-character limit.`,c.offset);continue}if(!id.test(l)){e.report(`local.computation.name`,`Computation name "${l}" must match [A-Za-z_][A-Za-z0-9_]*.`,c.offset);continue}if(ct.has(l)||ld.has(l)){e.report(`local.computation.reserved`,`Computation name "${l}" is reserved; choose another name.`,c.offset);continue}if(Object.hasOwn(e.bindingKinds,l)){e.report(`local.computation.duplicate`,`Computation name "${l}" conflicts with a control parameter of the same name.`,c.offset);continue}if(n.has(l)){e.report(`local.computation.duplicate`,`Computation name "${l}" is declared more than once.`,c.offset);continue}n.set(l,a);let u=s.value;if(!u)continue;let d=gd(u.raw);d?d.expression?t.push({name:l,kind:a,source:d.expression,expressionOffset:rf(e,i,d.start),nodeId:o.id,range:{...o.range}}):e.report(`local.expression.empty`,`Interpolation expression cannot be empty.`,u.offset):e.report(`local.computation.value`,`The value of <${a}> must be exactly one {{ expression }} interpolation.`,u.offset,u.offset+u.raw.length)}let i=Qn(t,e.bindingKinds,e.report);e.computations=i.computations,e.computationKinds=i.kinds}function of(e){return Object.keys(e.computationKinds).length?{...e.bindingKinds,...e.computationKinds}:e.bindingKinds}function sf(e){let t=[];for(let n of e)(n.type!==`component`||n.name!==`computed`&&n.name!==`const`)&&(n.children&&=sf(n.children),t.push(n));return t}function cf(e){let t=of(e),n=Object.keys(t),r=(t,n)=>{t instanceof R?e.report(`local.expression.${t.code||`invalid`}`,`Expression error: ${t.message}`,n+(Number.isFinite(t.offset)?t.offset:0),void 0,{key:`local.expression.error`,params:{detail:t.message,code:t.code||`invalid`,near:e.source.slice(Math.max(n,n+t.offset-16),n+t.offset+24)}}):e.report(`local.expression.invalid`,`Expression error: ${t instanceof Error?t.message:String(t)}`,n,void 0,{key:`local.expression.error`,params:{detail:t instanceof Error?t.message:String(t),code:`invalid`}})},i=(i,a,o)=>{if(!i.trim())return e.report(`local.expression.empty`,`Interpolation expression cannot be empty.`,a,void 0,{key:`local.expression.empty`}),null;let s=null;try{s=Yt(i)}catch(e){return r(e,a),null}if(!s)return null;let c=!1;for(let r of s.dependencies)if(!Object.hasOwn(t,r)){let t=_f(r,n);e.report(`local.binding.unknown`,`Reference to undeclared parameter ${r}.${t?` Did you mean ${t}?`:``}`,a+Math.max(0,i.indexOf(r)),void 0,t?{key:`local.binding.unknown.suggestion`,params:{name:r,suggestion:t}}:{key:`local.binding.unknown`,params:{name:r}}),c=!0}if(c)return null;let l;try{l=s.inferType(t)}catch(e){return r(e,a),null}return o===`number`&&l!==`number`?e.report(`local.type`,`Expected a number here, but the expression evaluates to ${J(l)}.`,a,void 0,{key:`local.type.number`,params:{kind:J(l)}}):o===`boolean`&&l!==`boolean`?e.report(`local.type`,`Expected a boolean here, but the expression evaluates to ${J(l)}.`,a,void 0,{key:`local.type.boolean`,params:{kind:J(l)}}):o===`string`&&l!==`string`?e.report(`local.type`,`Expected a string here, but the expression evaluates to ${J(l)}.`,a,void 0,{key:`local.type.string`,params:{kind:J(l)}}):o===`text`&&(l===`array`||l===`number-array`)&&e.report(`local.type`,`Arrays cannot be displayed directly; convert them first with a function such as len.`,a,void 0,{key:`local.type.array`}),l},a=t=>{for(let n of t){if(n.type===`interpolation`){let t=e.source.slice(n.range.start+2,Math.max(n.range.start+2,n.range.end-2)),r=n.value??``,a=Math.max(0,t.indexOf(r)),o=n.range.start+2+a;e.expressionKinds.set(n.id,i(r,o,`text`))}n.children&&a(n.children)}};a(e.nodes);for(let t of e.entries){if(t.name===`computed`||t.name===`const`)continue;let n=e.attrs.get(t.node.id)??{};for(let[r,a]of Object.entries(n)){let n=t.schema.props[r];if(n&&!n.static&&(t.name!==`data-table`||r!==`rows`&&r!==`key`)&&(t.name!==`column`||r!==`value`)&&(t.name!==`validation`||r!==`when`)){if(n.kind===`string`){let t=hd(a.raw);for(let n of t.unterminated)e.report(`local.interpolation`,`Interpolation is missing }}.`,a.offset+n,void 0,{key:`local.interpolation.unclosed`});for(let e of t.segments)i(e.expression,a.offset+e.start,`text`)}else a.dynamic&&(n.kind===`number`?i(a.expression??``,a.expressionOffset??a.offset,`number`):n.kind===`boolean`?i(a.expression??``,a.expressionOffset??a.offset,`boolean`):n.kind===`enum`&&i(a.expression??``,a.expressionOffset??a.offset,`string`))}}if(t.name===`if`){let t=n.when;t&&!t.dynamic&&e.report(`local.attribute.interpolation`,`The when attribute of if must be a full boolean interpolation, e.g. when="{{ seats >= 5 }}".`,t.offset,void 0,{key:`local.attribute.interpolation`})}}}function lf(e,t,n){let r={syntax:`local`,source:e.source,nodes:e.nodes,initialState:n,bindings:t,...Object.keys(e.computations).length?{computations:e.computations}:{}},i=`__local_core_check__`,a=rr(r,i,!1),o=new Set,s=e=>{for(let t of e){if(t.type===`heading`){let e=a.ids.get(t);e&&e.startsWith(`${i}-`)&&o.add(e.slice(21))}t.children&&s(t.children)}};s(e.nodes);let c=new Set;for(let t of e.entries){if(t.name!==`anchor`)continue;let n=(e.attrs.get(t.node.id)??{}).id;if(!n)continue;let r=typeof n.value==`string`?n.value:``;!r||!uf.test(r)?e.report(`local.anchor.id`,`Anchor id "${r}" must match [A-Za-z_][A-Za-z0-9_-]*.`,n.offset,void 0,{key:`local.anchor.id`,params:{id:r}}):(c.has(r)?e.report(`local.anchor.duplicate`,`Duplicate anchor id "${r}".`,n.offset,void 0,{key:`local.anchor.duplicate`,params:{id:r}}):c.add(r),o.has(r)&&e.report(`local.anchor.duplicate`,`Anchor id "${r}" collides with an automatic heading target.`,n.offset,void 0,{key:`local.anchor.heading-collision`,params:{id:r}}))}for(let t of e.entries){if(t.name!==`jump`)continue;let n=(e.attrs.get(t.node.id)??{}).to;if(!n)continue;let r=typeof n.value==`string`?n.value:``;r?r.startsWith(`#`)||/\s/.test(r)?e.report(`local.jump.target`,`<jump> target "${r}" must be a bare heading slug or anchor id without "#" or whitespace.`,n.offset,void 0,{key:`local.jump.bad-target`,params:{target:r}}):!c.has(r)&&!o.has(r)&&e.report(`local.jump.target`,`<jump> target "${r}" does not resolve to a heading or explicit anchor in this document.`,n.offset,void 0,{key:`local.jump.unresolved`,params:{target:r}}):e.report(`local.jump.target`,`<jump> target cannot be empty.`,n.offset,void 0,{key:`local.jump.empty`})}}var uf=/^[A-Za-z_][A-Za-z0-9_-]*$/;function df(e,t,n){t instanceof R?e.report(`local.expression.${t.code||`invalid`}`,`Expression error: ${t.message}`,n+(Number.isFinite(t.offset)?t.offset:0)):e.report(`local.expression.invalid`,`Expression error: ${t instanceof Error?t.message:String(t)}`,n)}function ff(e,t,n,r,i){if(!t.trim())return e.report(`local.expression.empty`,`Interpolation expression cannot be empty.`,n),null;let a;try{a=Yt(t)}catch(t){return df(e,t,n),null}let o=Object.keys(r),s=!1;for(let i of a.dependencies)if(!Object.hasOwn(r,i)){let r=_f(i,o);e.report(`local.binding.unknown`,`Reference to undeclared parameter ${i}.${r?` Did you mean ${r}?`:``}`,n+Math.max(0,t.indexOf(i))),s=!0}if(s||!i)return{compiled:a,kind:null};let c;try{c=a.inferType(r)}catch(t){return df(e,t,n),null}return{compiled:a,kind:c}}function pf(e,t,n,r,i){if(!e)return null;let a=gd(e.raw);return a?a.expression?{expression:a.expression,base:e.offset+a.start}:(i.report(`local.expression.empty`,`Interpolation expression cannot be empty.`,e.offset+a.start),null):(i.report(t,`<${n}> ${r} must be exactly one {{ expression }} interpolation.`,e.offset,e.offset+e.raw.length),null)}function mf(e){let t=e[`max-rows`];return t&&!t.dynamic&&typeof t.value==`number`&&Number.isInteger(t.value)&&t.value>0&&t.value<=1e3?t.value:100}function hf(e){let t=e.entries.filter(e=>e.name===`data-table`);if(!t.length)return;let n=of(e),r=0,i=0,a=!1,o=!1;for(let s of t){let t=e.attrs.get(s.node.id)??{},c=vd(s.node.children).filter(e=>e.type===`component`&&e.name===`column`),l=mf(t),u=Math.min(c.length,20);r+=l,i+=l*u,!a&&r>2e3&&(a=!0,e.report(`local.budget.data-table.rows`,`The document's generated row budget exceeds ${j}; max-rows summed over every <data-table> must stay within it.`,s.node.range.start,s.node.range.end)),!o&&i>1e4&&(o=!0,e.report(`local.budget.data-table.cells`,`The document's generated cell budget exceeds ${M}; max-rows multiplied by columns, summed over every <data-table>, must stay within it.`,s.node.range.start,s.node.range.end));let d=pf(t.rows,`local.data-table.rows`,`data-table`,`rows`,e),f=`string`,p=!1;if(d){let t=ff(e,d.expression,d.base,n,!0);t?.kind===`array`?(f=`string`,p=!0):t?.kind===`number-array`?(f=`number`,p=!0):t&&t.kind!==null&&e.report(`local.data-table.rows`,`<data-table> rows must evaluate to an array, but the expression evaluates to ${J(t.kind)}.`,d.base)}let m={...n,item:f,index:`number`},h=pf(t.key,`local.data-table.key`,`data-table`,`key`,e);if(h){let t=ff(e,h.expression,h.base,m,p);if(t){let r=t.compiled.dependencies;r.includes(`item`)||e.report(`local.data-table.key`,`<data-table> key must depend on item.`,h.base);for(let t of r)t!==`item`&&(t===`index`?e.report(`local.data-table.key`,`<data-table> key cannot depend on index; use a stable item identifier.`,h.base):Object.hasOwn(n,t)&&e.report(`local.data-table.key`,`<data-table> key cannot depend on global parameter "${t}"; it must be derived from item only.`,h.base));t.kind!==null&&t.kind!==`string`&&t.kind!==`number`&&e.report(`local.data-table.key`,`<data-table> key must evaluate to a string or number, got ${J(t.kind)}.`,h.base)}}for(let t of c){let n=e.attrs.get(t.id)??{},r=n.label;r&&!String(r.value??``).trim()&&e.report(`local.data-table.column`,`<column> label cannot be empty.`,r.offset);let i=pf(n.value,`local.data-table.value`,`column`,`value`,e);if(!i)continue;let a=ff(e,i.expression,i.base,m,p);a&&(a.kind===`array`||a.kind===`number-array`)&&e.report(`local.data-table.value`,`<column> value must be a scalar string, number, boolean or null, got ${J(a.kind)}.`,i.base)}}}function gf(e){let t=[],n=0,r=!1,i=Object.keys(e.bindingKinds),a=of(e);for(let o of e.entries){if(o.name!==`validation`)continue;n+=1;let s=o.node;if(n>100){r||(r=!0,e.report(`local.validation.budget`,`The document declares more than 100 validation rules; rules in hidden regions count too.`,s.range.start,s.range.end));continue}o.parent&&(o.parent.schema.form!==`container`||o.parent.name===`data-table`)&&e.report(`local.validation.placement`,`<validation> can appear in normal prose or a container, but not inside inline content or a data table.`,s.range.start,s.range.end);let c=e.attrs.get(s.id)??{},l=``,u=[],d=c.when;if(d){let t=gd(d.raw);if(!t)e.report(`local.validation.when`,`<validation> when must be exactly one {{ boolean }} interpolation.`,d.offset,d.offset+d.raw.length);else if(t.expression){l=t.expression;let n=ff(e,l,d.offset+t.start,a,!0);n&&(u=[...n.compiled.dependencies],n.kind!==null&&n.kind!==`boolean`&&e.report(`local.type`,`Expected a boolean here, but the expression evaluates to ${J(n.kind)}.`,d.offset+t.start))}}let f=c.fields,p=f?td(f.raw):[];f&&!p.length&&e.report(`local.validation.fields`,`<validation> requires at least one field name.`,f.offset,f.offset+f.raw.length);let m=new Set;for(let t of p)if(m.has(t))e.report(`local.validation.fields`,`Duplicate field "${t}" in <validation> fields.`,f?.offset??s.range.start);else if(m.add(t),!Object.hasOwn(e.bindingKinds,t)){let n=_f(t,i);e.report(`local.validation.fields`,`Field "${t}" is not a public writable parameter.${n?` Did you mean ${n}?`:``}`,f?.offset??s.range.start)}l&&t.push({nodeId:s.id,expression:l,dependencies:u,message:typeof c.message?.value==`string`?c.message.value:``,fields:[...m],range:{...s.range}})}return t}function _f(e,t){if(e.length>od)return;let n,r=1/0;for(let i of t){let t=vf(e,i);t<r&&(n=i,r=t)}return r<=2?n:void 0}function vf(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=n[0];n[0]=r;for(let a=1;a<=t.length;a++){let o=n[a];n[a]=Math.min(n[a]+1,n[a-1]+1,i+(e[r-1]===t[a-1]?0:1)),i=o}}return n[t.length]}function yf(e,t){let n=e.schema.props.samples?.default,r=typeof n==`number`?n:200;return kd(e,t,`samples`)??r}function bf(e){let t=of(e),n=0,r=!1;for(let i of e.entries){if(i.name!==`plot`)continue;let a=e.attrs.get(i.node.id)??{},o=vd(i.node.children).filter(e=>e.type===`math`),s=yf(i,a);o.length>16&&e.report(`local.budget.plot.curves`,`<plot> supports at most 16 curves, but has ${o.length}.`,i.node.range.start,i.node.range.end,{key:`local.budget.plot.curves`,params:{limit:16,count:o.length}});let c=o.length*s,l=n+c;if(!r&&l>2e4&&(e.report(`local.budget.plot.points`,`The document's total plot sample count exceeds the limit of ${O}.`,i.node.range.start,i.node.range.end,{key:`local.budget.plot.points`,params:{limit:O}}),r=!0),n=Math.min(O+1,l),!(o.length>16||r))for(let n of o){let r=(n.value??``).trim();if(!/^y\s*=/u.test(r)){e.report(`local.math.formula`,`<plot> formulas must be written explicitly as y = expression.`,n.range.start,n.range.end,{key:`local.math.formula.shape`});continue}let i=null;try{i=Mn(r)}catch(t){e.report(`local.math`,`Cannot compute plot formula: ${t instanceof Error?t.message:String(t)}`,n.range.start,n.range.end,{key:`local.math.compute`,params:{detail:t instanceof Error?t.message:String(t),code:t&&typeof t==`object`&&`code`in t&&typeof t.code==`string`?t.code:`latex-syntax`,near:r.slice(0,120)}})}if(i)for(let r of i.dependencies)r!==`x`&&r!==`y`&&(Object.hasOwn(t,r)?t[r]!==`number`&&e.report(`local.math.binding`,`Plot parameter "${r}" must be a number, but is ${J(t[r])}.`,n.range.start,n.range.end,{key:`local.math.binding.type`,params:{name:r,kind:J(t[r])}}):e.report(`local.math.binding`,`Plot formula references undeclared parameter "${r}".`,n.range.start,n.range.end,{key:`local.math.binding.unknown`,params:{name:r}}))}}}function xf(e,t,n){let r=(e.children??[]).filter(e=>e.type===`tableRow`);if(!r.length)return t.report(`local.table.header`,`The table for <${n.name}> is missing a header.`,e.range.start,e.range.end,{key:`local.table.header.missing`,params:{name:n.name}}),null;let i=r[0].children??[],a=[];for(let e of i){if(bd(e))return t.report(`local.table.header`,`Table headers cannot contain interpolations.`,e.range.start,e.range.end,{key:`local.table.header.interpolation`}),null;let n=yd(e).trim();if(!n)return t.report(`local.table.header`,`Table headers cannot be empty.`,e.range.start,e.range.end,{key:`local.table.header.empty`}),null;if(a.includes(n))return t.report(`local.table.header`,`Duplicate table header "${n}".`,e.range.start,e.range.end,{key:`local.table.header.duplicate`,params:{name:n}}),null;a.push(n)}if(!a.length)return t.report(`local.table.header`,`Table headers cannot be empty.`,e.range.start,e.range.end,{key:`local.table.header.empty`}),null;let o=[];for(let e of r.slice(1)){let n=e.children??[];n.length===a.length?o.push(n):t.report(`local.table.row`,`Table row has a different column count: header has ${a.length} columns, this row has ${n.length}.`,e.range.start,e.range.end,{key:`local.table.row.mismatch`,params:{header:a.length,row:n.length}})}return{header:a,rows:o}}function Sf(e,t){let n=vd(e.children);if(n.length===1&&n[0].type===`interpolation`){let e=t.expressionKinds.get(n[0].id);if(e===`number`||e===null)return!0;if(e!==void 0)return!1}let r=yd(e).trim();return r?ud(r)!==null:!1}function Cf(e,t,n,r,i){let a=e.header[t];e.rows.forEach((e,i)=>{let o=e[t];if(!o)return;let s=vd(o.children);if(s.length===1&&s[0].type===`interpolation`){let e=n.expressionKinds.get(s[0].id);e!=null&&e!==`number`&&n.report(`local.chart.numeric`,`${r.name===`timeline`?`Timeline`:`Chart`} column "${a}" requires a number in row ${i+1}, but the expression evaluates to ${J(e)}.`,o.range.start,o.range.end,{key:r.name===`timeline`?`local.timeline.numeric.expression`:`local.chart.numeric.expression`,params:{name:a,row:i+1,kind:J(e)}})}else Sf(o,n)||n.report(`local.chart.numeric`,`${r.name===`timeline`?`Timeline`:`Chart`} column "${a}" requires a plain number in row ${i+1}, got "${yd(o).trim()||`empty`}".`,o.range.start,o.range.end,{key:r.name===`timeline`?`local.timeline.numeric.plain`:`local.chart.numeric.plain`,params:{name:a,row:i+1,value:yd(o).trim()||`empty`}})})}function wf(e,t){return e.indexOf(t)}function Tf(e){for(let t of e.entries){if(t.name===`table`){Ef(t,e);continue}if(t.name!==`chart`&&t.name!==`timeline`)continue;let n=Ef(t,e);n&&(t.name===`chart`?kf(t,n,e):Af(t,n,e))}}function Ef(e,t){if(t.tableShapes.has(e.node.id))return t.tableShapes.get(e.node.id)??null;let n=t.tables.get(e.node.id),r=n?xf(n,t,e):null;return t.tableShapes.set(e.node.id,r),r}function Df(e,t){if(t.size===0)return;let n=Object.create(null),r=0;for(let[e,i]of t)i&&(n[e]=Object.freeze({header:Object.freeze([...i.header]),rowIds:Object.freeze(i.rows.map(e=>Object.freeze(e.map(e=>e.id))))}),r+=1);r!==0&&(e.tableShapes=Object.freeze(n))}function Of(e){for(let t of e.entries){if(t.name!==`table`&&t.name!==`chart`)continue;let n=e.attrs.get(t.node.id)??{},r=n.key;if(!r)continue;let i=typeof r.value==`string`?r.value.trim():``;if(!i){e.report(`local.selection.key`,`<${t.name}> key cannot be empty.`,r.offset,void 0,{key:`local.selection.key.empty`,params:{component:t.name}}),e.selections.set(t.node.id,[``]);continue}let a=Ef(t,e);if(!a){e.selections.set(t.node.id,[``]);continue}let o=wf(a.header,i);if(o<0){e.report(`local.selection.key`,`<${t.name}> key column "${i}" does not exist in its table.`,r.offset,void 0,{key:`local.selection.key.missing-column`,params:{component:t.name,name:i}}),e.selections.set(t.node.id,[``]);continue}let s=[],c=new Set;a.rows.forEach((n,r)=>{let a=n[o];if(!a)return;if(bd(a)){e.report(`local.selection.key`,`<${t.name}> key column "${i}" must contain static text; row ${r+1} contains an interpolation.`,a.range.start,a.range.end,{key:`local.selection.key.interpolation`,params:{component:t.name,name:i,row:r+1}});return}let l=yd(a).trim();l?c.has(l)?e.report(`local.selection.key`,`<${t.name}> key column "${i}" must be unique; duplicate value "${l}".`,a.range.start,a.range.end,{key:`local.selection.key.duplicate`,params:{component:t.name,name:i,value:l}}):(c.add(l),s.push(l)):e.report(`local.selection.key`,`<${t.name}> key column "${i}" cannot be empty in row ${r+1}.`,a.range.start,a.range.end,{key:`local.selection.key.empty-cell`,params:{component:t.name,name:i,row:r+1}})}),e.selections.set(t.node.id,[``,...s]);let l=n.initial;l&&typeof l.value==`string`&&l.value!==``&&!s.includes(l.value)&&e.report(`local.initial.option`,`Initial selection "${l.value}" of <${t.name}> is not a value of key column "${i}".`,l.offset,void 0,{key:`local.selection.key.initial`,params:{value:l.value,component:t.name,name:i}})}}function kf(e,t,n){let r=n.attrs.get(e.node.id)??{},i=typeof r.kind?.value==`string`?r.kind.value:`bar`,a=t.header;for(let t of a)t.includes(`,`)&&n.report(`local.chart.column`,`Chart column names cannot contain commas: "${t}".`,e.node.range.start,e.node.range.end,{key:`local.chart.column.comma`,params:{name:t}});let o=typeof r.x?.value==`string`?r.x.value.trim():``,s=typeof r.y?.value==`string`?r.y.value.trim():``;o&&wf(a,o)<0&&n.report(`local.chart.column`,`Chart x column "${o}" does not exist.`,r.x?.offset??e.node.range.start,void 0,{key:`local.chart.column.x-missing`,params:{name:o}});let c=[];if(s){c=s.split(`,`).map(e=>e.trim()).filter(Boolean),c.length||n.report(`local.chart.column`,`Chart y requires a column name.`,r.y?.offset??e.node.range.start,void 0,{key:`local.chart.column.y-required`});for(let t of c)wf(a,t)<0&&n.report(`local.chart.column`,`Chart y column "${t}" does not exist.`,r.y?.offset??e.node.range.start,void 0,{key:`local.chart.column.y-missing`,params:{name:t}})}let l=[];if(i===`bar`||i===`line`||i===`area`){let t=o?Math.max(0,wf(a,o)):0;l=c.length?c.map(e=>wf(a,e)).filter(e=>e>=0):a.map((e,t)=>t).filter(e=>e!==t),l.length||n.report(`local.chart.column`,`Chart requires at least one numeric column.`,e.node.range.start,e.node.range.end,{key:`local.chart.column.needs-numeric`})}else if(i===`scatter`){let r=o?wf(a,o):0;r<0?n.report(`local.chart.column`,`Scatter chart x column "${o}" does not exist.`,e.node.range.start,void 0,{key:`local.chart.column.scatter-x-missing`,params:{name:o}}):Cf(t,r,n,e,`x`),l=c.length?c.map(e=>wf(a,e)).filter(e=>e>=0):a.map((e,t)=>t).filter(e=>e!==r),l.length||n.report(`local.chart.column`,`Scatter chart requires at least one numeric column.`,e.node.range.start,e.node.range.end,{key:`local.chart.column.scatter-needs-numeric`})}else if(i===`donut`){if(a.length<2){n.report(`local.chart.column`,`Donut chart requires a label column and a value column.`,e.node.range.start,e.node.range.end,{key:`local.chart.column.donut-columns`});return}if(c.length===1){let e=wf(a,c[0]);e>=0&&(l=[e])}else c.length>1?n.report(`local.chart.column`,`Donut chart y can only specify one numeric column.`,r.y?.offset??e.node.range.start,void 0,{key:`local.chart.column.donut-y`}):a.length>2?n.report(`local.chart.column`,`A donut chart with more than two columns must use y to specify the single numeric column.`,e.node.range.start,e.node.range.end,{key:`local.chart.column.donut-need-y`}):l=[1]}l=[...new Set(l)];for(let r of l)Cf(t,r,n,e,`y`);if(i===`donut`)for(let e of l)t.rows.forEach((t,r)=>{let i=t[e];if(!i||vd(i.children).length)return;let a=ud(yd(i).trim());a!==null&&a<0&&n.report(`local.chart.negative`,`Donut chart values cannot be negative; row ${r+1} is ${a}.`,i.range.start,i.range.end,{key:`local.chart.negative`,params:{row:r+1,value:a}})})}function Af(e,t,n){let r=[{title:`Task`,start:`Start`,duration:`Duration`,notes:`Notes`},{title:`事项`,start:`开始`,duration:`时长`,notes:`说明`}].find(e=>t.header.includes(e.title)&&t.header.includes(e.start)&&t.header.includes(e.duration));if(!r){n.report(`local.timeline.header`,`Timeline requires either Task, Start and Duration columns or 事项, 开始 and 时长 columns, with optional Notes or 说明.`,e.node.range.start,e.node.range.end,{key:`local.timeline.header.missing`});return}let i=new Set(Object.values(r));for(let r of t.header)i.has(r)||n.report(`local.timeline.header`,`Timeline does not support column "${r}".`,e.node.range.start,e.node.range.end,{key:`local.timeline.header.column`,params:{name:r}});for(let i of[r.start,r.duration]){let r=wf(t.header,i);r>=0&&Cf(t,r,n,e,i)}let a=wf(t.header,r.start),o=wf(t.header,r.duration);t.rows.forEach((e,r)=>{for(let i of[a,o]){if(i<0)continue;let a=e[i];if(!a||vd(a.children).length)continue;let o=ud(yd(a).trim());o!==null&&o<0&&n.report(`local.timeline.value`,`Timeline column "${t.header[i]}" cannot be negative in row ${r+1}.`,a.range.start,a.range.end,{key:`local.timeline.value.negative`,params:{name:t.header[i],row:r+1}})}})}var jf=1e-9,Mf=200;function Nf(e){return Array.isArray(e)?e.slice():e}function Pf(e){return{...e,range:{...e.range}}}function Ff(e,t){return Array.isArray(e)||Array.isArray(t)?!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>e===t[n]):e===t}function If(e){return e===``||be(e)!==null}function Lf(e,t,n){let r=(e-t)/n;return Math.abs(r-Math.round(r))<=jf*Math.max(1,Math.abs(r))}function Rf(e){for(let[t,n]of Object.entries(e))Array.isArray(n)&&!Object.isFrozen(n)&&(e[t]=Object.freeze([...n]));return Object.freeze(e)}function zf(e,t,n,r){let i=Math.max(0,Math.min(e.source.length,t.range.start)),a=e.source.slice(0,i).split(`
54
54
  `);return{code:n,message:et(r),severity:`error`,range:{start:i,end:Math.max(i+1,Math.min(e.source.length,t.range.end))},line:a.length,column:(a.at(-1)??``).length+1,messageKey:r.key,...r.params?{params:r.params}:{}}}function Bf(e,t){return{code:e,message:t,severity:`error`,range:{start:0,end:0},line:1,column:1}}function Vf(e,t){return e.attrs?.[t]}function Hf(e,t){let n=Vf(e,t);if(n===`true`)return!0;if(n===`false`)return!1}function Uf(e,t){let n=Vf(e,t);if(n===void 0)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Wf(e){return nt(e)}function Y(e,t){return{ok:!1,detail:Be(e,t)}}function Gf(e,t){if(e.name===`date`){if(!If(t))return Y(`local.runtime.value.date-invalid`);if(t===``&&Hf(e,`required`)===!0)return Y(`local.runtime.value.date-required`);let n=Vf(e,`min`),r=Vf(e,`max`);return t!==``&&n&&t<n?Y(`local.runtime.value.date-earlier`,{min:n}):t!==``&&r&&t>r?Y(`local.runtime.value.date-later`,{max:r}):{ok:!0,value:t}}if(e.name===`input`||e.name===`textarea`){let n=Wf(t);if(t===``&&Hf(e,`required`)===!0)return Y(`local.runtime.value.field-required`);let r=Uf(e,`min-length`),i=Uf(e,`max-length`);if(r!==void 0&&r>0&&t!==``&&n<r)return Y(`local.runtime.value.min-length`,{min:r});if(i!==void 0&&n>i)return Y(`local.runtime.value.max-length`,{max:i});if(e.name===`input`&&Vf(e,`type`)===`email`&&t!==``){if(t.length>254)return Y(`local.runtime.value.email-length`,{limit:254});if(!N(t))return Y(`local.runtime.value.email-invalid`)}}return{ok:!0,value:t}}function Kf(e,t,n){switch(e.type){case`number`:{if(typeof n!=`number`||!Number.isFinite(n))return Y(`local.runtime.value.finite-number`,{name:e.name});if(e.min!==void 0&&n<e.min)return Y(`local.runtime.value.min`,{name:e.name,min:e.min});if(e.max!==void 0&&n>e.max)return Y(`local.runtime.value.max`,{name:e.name,max:e.max});let t=e.step??1,r=e.min??0;return t>0&&!Lf(n,r,t)?Y(`local.runtime.value.step`,{name:e.name,step:t,base:r}):{ok:!0,value:n}}case`boolean`:return typeof n==`boolean`?{ok:!0,value:n}:Y(`local.runtime.value.boolean`,{name:e.name});case`string`:{if(typeof n!=`string`)return Y(`local.runtime.value.string`,{name:e.name});let r=yt(n);if(r)return Y(`local.runtime.value.budget`,{name:e.name,detail:et(r),detailKey:r.key,...r.params});for(let e of t){let t=Gf(e,n);if(!t.ok)return t}return e.options?.length&&!e.options.includes(n)?Y(`local.runtime.value.option`,{value:n,options:e.options.join(`, `)}):{ok:!0,value:n}}case`array`:{if(!Array.isArray(n))return Y(`local.runtime.value.array`,{name:e.name});let t=yt(n);if(t)return Y(`local.runtime.value.budget`,{name:e.name,detail:et(t),detailKey:t.key,...t.params});let r=new Set;for(let t of n){if(typeof t!=`string`)return Y(`local.runtime.value.array-members`,{name:e.name});if(e.options&&!e.options.includes(t))return Y(`local.runtime.value.checklist-option`,{value:t});r.add(t)}let i=e.options?e.options.filter(e=>r.has(e)):[...r];return e.maxItems!==void 0&&i.length>e.maxItems?Y(`local.runtime.value.max-items`,{name:e.name,max:e.maxItems}):{ok:!0,value:i}}case`null`:return{ok:!0,value:n}}return Y(`local.runtime.value.unsupported-type`,{name:e.name})}function qf(e){if(!e||e.syntax!==`local`)throw Error(`createLocalRuntime requires a local interaction document.`);if(e.syntaxVersion!==void 0&&e.syntaxVersion!==`local-draft-2`||e.versionDeclaration&&e.versionDeclaration.version!==`local-draft-2`)throw Error(`createLocalRuntime requires ${au}; migrate the source before constructing a runtime.`);let t=new Map,n=e=>{for(let r of e)t.set(r.id,r),r.children&&n(r.children)};n(e.nodes);let r={},i=new Map;for(let[n,a]of Object.entries(e.bindings)){let e=yt(a.initial);if(e)throw new R(`expression-budget`,`Parameter "${n}": ${et(e)}`,0);r[n]=Nf(a.initial);let o=[];for(let e of a.nodeIds){let n=t.get(e);n&&o.push(n)}i.set(n,o)}let a=new Map;for(let[t,n]of Object.entries(e.bindingSlots??{}))a.set(t,{...n});let o=Object.freeze(Object.keys(e.bindings).filter(e=>!e.startsWith(`@`)).sort()),s=new Map;for(let[e,t]of a)for(let n of Object.values(t)){if(n.startsWith(`@`))continue;let t=s.get(n)??new Set;t.add(e),s.set(n,t)}let c=(e,t)=>{let n=a.get(e);if(!n?.start||!n?.end)return!1;let r=t[n.start],i=t[n.end];return typeof r==`number`&&typeof i==`number`&&r>i},l=e.computations??{},u=Object.keys(l),d=new Map;for(let[e,t]of Object.entries(l))try{d.set(e,Yt(t.source))}catch{}let{order:f,cyclic:p}=Zn(l),m={},h=new Map,g=e=>e instanceof R?e:new R(`expression-eval`,e instanceof Error?e.message:String(e),0);for(let e of f){let t=l[e];if(!t||t.kind!==`const`)continue;if(Object.hasOwn(t,`value`)){let n=t.value,r=bt(n);if(r){h.set(e,new R(`expression-budget`,`Constant "${e}": ${r}`,0));continue}m[e]=Nf(n);continue}let n=d.get(e);if(!n)h.set(e,new R(`expression-eval`,`Constant "${e}" cannot be evaluated.`,0));else try{let t=n.evaluate({...m}),r=bt(t);if(r){h.set(e,new R(`expression-budget`,`Constant "${e}": ${r}`,0));continue}m[e]=Nf(t)}catch(t){h.set(e,g(t))}}let _=new Map;for(let e of p)_.set(e,new R(`expression-cycle`,`Computation "${e}" is part of a dependency cycle.`,0));let v=[];if(Array.isArray(e.validations)){for(let t of e.validations)if(q(t))try{v.push({rule:t,expression:Yt(t.expression),error:null})}catch(e){v.push({rule:t,expression:null,error:g(e)})}}let y=K(typeof e.source==`string`?e.source:``),b=null,S=e=>{let t;try{t=tn(e,O)}catch{t=$u}return ed(t)},C=()=>{let t=[],n=typeof e.source==`string`?e.source:``;for(let e of v){if(e.error){t.push(nd(n,y,e.rule.range,Qu,ed(`Validation expression is invalid: ${e.error.message}`)));continue}if(!e.expression)continue;let r;try{r=e.expression.evaluate(O)}catch(r){t.push(nd(n,y,e.rule.range,Qu,ed(`Validation expression failed: ${r instanceof Error?r.message:String(r)}`)));continue}typeof r==`boolean`?r||t.push(nd(n,y,e.rule.range,Zu,S(e.rule.message))):t.push(nd(n,y,e.rule.range,Qu,`Validation expression must evaluate to a boolean.`))}return t},w=r,T=0,E={},D=new Map,O={},k={},A={revision:0,state:Rf({})},j=!1,M=new Set,N=new Map,ee=new Map,P=()=>{if(j)throw Error(`The local interaction runtime has been disposed.`)},te=()=>{if(u.length===0)E={},D=new Map;else{let e=$n(l,f,d,w,m);E=e.values,D=e.errors;for(let[e,t]of h)Object.hasOwn(E,e)||D.set(e,t);for(let[e,t]of _)Object.hasOwn(E,e)||D.set(e,t)}let e={};for(let[t,n]of Object.entries(w))e[t]=n;for(let[t,n]of Object.entries(E))e[t]=n;for(let[t,n]of D)Object.hasOwn(E,t)||Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get(){throw n}});O=e;let t={};for(let[e,n]of Object.entries(w))t[e]=n;for(let[e,n]of Object.entries(E))t[e]=n;k=t},F=()=>{A={revision:T,state:Rf(k)}},ne=e=>{w=e,T+=1,te(),F();for(let e of M)e()},re=(n,r)=>{let a=(i.get(n.name)??[])[0]??(n.owner?t.get(n.owner):void 0)??(n.nodeIds[0]?t.get(n.nodeIds[0]):void 0);return a?zf(e,a,`local.runtime.value`,r):Bf(`local.runtime.value`,et(r))},ie=n=>{P();let r=[],a={},o=Object.keys(n).sort();for(let t of o){if(t===`__proto__`){r.push(Bf(`local.runtime.parameter`,`Parameter names cannot be "__proto__".`));continue}if(t.startsWith(`@`)){r.push(Bf(`local.runtime.parameter`,`Internal parameter "${t}" cannot be written by name.`));continue}if(!Object.hasOwn(e.bindings,t)){r.push(Bf(`local.runtime.parameter`,`Unknown parameter "${t}".`));continue}let o=e.bindings[t],s=Kf(o,i.get(t)??[],n[t]);s.ok?a[t]=Nf(s.value):r.push(re(o,s.detail))}if(r.length)return r;if(!o.some(e=>!Ff(w[e],a[e])))return[];let l={...w,...a},u=new Set;for(let e of o)for(let t of s.get(e)??[])u.add(t);for(let n of[...u].sort())if(c(n,l)){let i=t.get(n);r.push(i?zf(e,i,`local.runtime.value`,Be(`local.runtime.value.range-order`)):Bf(`local.runtime.value`,et(Be(`local.runtime.value.range-order`))))}return r.length?r:(ne(l),[])};te(),F();let ae=e=>{let t=ee.get(e);if(!t){if(t=Yt(e),ee.size>=Mf){let e=ee.keys().next().value;e!==void 0&&ee.delete(e)}ee.set(e,t)}return t},oe=e=>{let t=new Set,n=e=>{t.add(e.id);for(let t of e.children??[])n(t)};return n(e),t};return{document:e,snapshot(){return P(),A},get(e,n){P();let r=t.get(e.id);if(!r)return null;let i=n===void 0?x(r):a.get(r.id)?.[n];return i&&Object.hasOwn(w,i)?Nf(w[i]):null},set(n,r,o){P();let s=t.get(n.id);if(!s)return[zf(e,n,`local.runtime.binding`,Be(`local.runtime.binding.no-writable`))];let l=a.get(s.id),u;if(o===void 0){if(l)return[zf(e,s,`local.runtime.binding`,Be(`local.runtime.binding.needs-slot`))];u=x(s)}else if(u=l?.[o],!u)return[zf(e,s,`local.runtime.binding`,Be(`local.runtime.binding.unknown-slot`,{slot:o}))];let d=Object.hasOwn(e.bindings,u)?e.bindings[u]:void 0;if(!d)return[zf(e,s,`local.runtime.binding`,Be(`local.runtime.binding.no-writable`))];let f=Kf(d,i.get(u)??[],r);if(!f.ok)return[zf(e,s,`local.runtime.value`,f.detail)];let p=Nf(f.value);if(Ff(w[u],p))return[];let m={...w,[u]:p};return c(s.id,m)?[zf(e,s,`local.runtime.value`,Be(`local.runtime.value.range-order`))]:(ne(m),[])},setMany(n,r){P();let o=t.get(n.id);if(!o)return[zf(e,n,`local.runtime.binding`,Be(`local.runtime.binding.no-writable`))];let s=a.get(o.id);if(!s)return[zf(e,o,`local.runtime.binding`,Be(`local.runtime.binding.no-multi-slot`))];let l=Object.entries(r);if(!l.length)return[];let u={...w};for(let[t,n]of l){let r=s[t];if(!r||!Object.hasOwn(e.bindings,r))return[zf(e,o,`local.runtime.binding`,Be(`local.runtime.binding.unknown-slot`,{slot:t}))];let a=Kf(e.bindings[r],i.get(r)??[],n);if(!a.ok)return[zf(e,o,`local.runtime.value`,a.detail)];u[r]=Nf(a.value)}return c(o.id,u)?[zf(e,o,`local.runtime.value`,Be(`local.runtime.value.range-order`))]:(l.every(([e,t])=>Ff(w[s[e]],t))||ne(u),[])},parameterNames(){return P(),o},getParameter(t){if(P(),!t.startsWith(`@`)&&Object.hasOwn(e.bindings,t))return Object.hasOwn(w,t)?Nf(w[t]):void 0},getParameters(){P();let e={};for(let t of o){let n=w[t];e[t]=Array.isArray(n)?Object.freeze([...n]):n}return Object.freeze(e)},setParameter(e,t){P();let n=Object.create(null);return n[e]=t,ie(n)},setParameters(e){if(P(),typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`setParameters requires an object of parameter values.`);return ie(e)},evaluate(e){P();let t=ae(e).evaluate(O);return Array.isArray(t)?t.slice():t},validate(){if(P(),b&&b.revision===T)return b.diagnostics.map(Pf);let e=C();return b={revision:T,diagnostics:e},e.map(Pf)},text(e){return P(),tn(e,O)},reset(n){P();let r=t.get(n.id);if(!r)return;let a=oe(r),o={...w};for(let[t,n]of Object.entries(e.bindings)){if(!(i.get(t)??[]).some(e=>a.has(e.id)))continue;let e=yt(n.initial);if(e)throw new R(`expression-budget`,`Parameter "${t}": ${et(e)}`,0);o[t]=Nf(n.initial)}for(let e of a)N.set(e,(N.get(e)??0)+1);ne(o)},resetToken(e){P();let n=t.get(e.id);return n?N.get(n.id)??0:0},subscribe(e){return P(),M.add(e),()=>{M.delete(e)}},dispose(){j||(j=!0,M.clear(),ee.clear(),d.clear(),N.clear())}}}var X=(e,t,...n)=>(0,y.createElement)(e,t,...n),Jf={" ":`space`,",":`thinspace`,":":`medspace`,";":`thickspace`,"!":`negthinspace`,"{":`lbrace`,"}":`rbrace`,"|":`vert`,"%":`percent`,"&":`amp`,"#":`hash`,_:`underscore`,$:`dollar`},Yf=5e4,Xf=2e4,Zf=120,Qf=2e3;function $f(e){return e.length>Qf?`${e.slice(0,Qf)}…`:e}function ep(e){if(e.length>Yf)throw Error(`Math source exceeds the length limit.`);let t=[],n=e=>{if(t.length>=Xf)throw Error(`Math input contains too many tokens.`);t.push(e)},r=0;for(;r<e.length;){let t=e[r];if(t===` `||t===` `||t===`\r`||t===`
55
55
  `)r+=1;else if(t===`%`)for(;r<e.length&&e[r]!==`
56
- `;)r+=1;else if(t===`\\`){if(r+1>=e.length){n({kind:`command`,value:`backslash`,offset:r}),r+=1;continue}let t=e[r+1];if(t===`\\`){n({kind:`newline`,value:`\\\\`,offset:r}),r+=2;continue}if(/[A-Za-z]/.test(t)){let t=r+1;for(;t<e.length&&/[A-Za-z]/.test(e[t]);)t+=1;n({kind:`command`,value:e.slice(r+1,t),offset:r}),r=t;continue}n({kind:`command`,value:Object.hasOwn(Jf,t)?Jf[t]:t,offset:r}),r+=2}else if(t>=`0`&&t<=`9`){let t=/^\d+(?:\.\d*)?/.exec(e.slice(r));n({kind:`number`,value:t[0],offset:r}),r+=t[0].length}else if(t===`.`&&e[r+1]>=`0`&&e[r+1]<=`9`){let t=/^(?:\d+(?:\.\d*)?|\.\d+)/.exec(e.slice(r));n({kind:`number`,value:t[0],offset:r}),r+=t[0].length}else/[A-Za-z]/.test(t)?(n({kind:`letter`,value:t,offset:r}),r+=1):(n({kind:`punct`,value:t,offset:r}),r+=1)}return n({kind:`eof`,value:``,offset:e.length}),t}var tp={alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ϵ`,varepsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,vartheta:`ϑ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,varpi:`ϖ`,rho:`ρ`,varrho:`ϱ`,sigma:`σ`,varsigma:`ς`,tau:`τ`,upsilon:`υ`,phi:`φ`,varphi:`ϕ`,chi:`χ`,psi:`ψ`,omega:`ω`,Gamma:`Γ`,Delta:`Δ`,Theta:`Θ`,Lambda:`Λ`,Xi:`Ξ`,Pi:`Π`,Sigma:`Σ`,Upsilon:`Υ`,Phi:`Φ`,Psi:`Ψ`,Omega:`Ω`},np={cdot:`·`,times:`×`,div:`÷`,pm:`±`,mp:`∓`,le:`≤`,leq:`≤`,ge:`≥`,geq:`≥`,ne:`≠`,neq:`≠`,lt:`<`,gt:`>`,approx:`≈`,equiv:`≡`,sim:`∼`,propto:`∝`,infty:`∞`,partial:`∂`,nabla:`∇`,sum:`∑`,prod:`∏`,int:`∫`,iint:`∬`,oint:`∮`,to:`→`,rightarrow:`→`,leftarrow:`←`,Rightarrow:`⇒`,leftrightarrow:`↔`,in:`∈`,notin:`∉`,ni:`∋`,subset:`⊂`,supset:`⊃`,subseteq:`⊆`,supseteq:`⊇`,cup:`∪`,cap:`∩`,emptyset:`∅`,forall:`∀`,exists:`∃`,neg:`¬`,land:`∧`,lor:`∨`,angle:`∠`,perp:`⊥`,parallel:`∥`,degree:`°`,prime:`′`,ldots:`…`,cdots:`⋯`,dots:`…`,langle:`⟨`,rangle:`⟩`,lbrace:`{`,rbrace:`}`,vert:`|`,lvert:`|`,rvert:`|`,lVert:`‖`,rVert:`‖`,backslash:`\\`,percent:`%`,amp:`&`,hash:`#`,underscore:`_`,dollar:`$`,colon:`:`},rp=new Set([`sin`,`cos`,`tan`,`arcsin`,`arccos`,`arctan`,`exp`,`ln`,`log`,`min`,`max`,`lim`,`det`,`sup`,`inf`,`arg`,`gcd`]),ip={space:`0.25em`,thinspace:`0.167em`,medspace:`0.222em`,thickspace:`0.278em`,negthinspace:`-0.167em`,quad:`1em`,qquad:`2em`,enspace:`0.5em`},ap=new Set([`displaystyle`,`textstyle`,`scriptstyle`,`scriptscriptstyle`,`limits`,`nolimits`]),op=class{tokens;pos=0;source;depth=0;constructor(e){this.source=e,this.tokens=ep(e)}enter(){if(this.depth+=1,this.depth>Zf)throw--this.depth,Error(`Formula is nested too deeply.`)}leave(){--this.depth}render(){let e=this.parseRow({});return e.length===1?e[0]:X(`mrow`,null,...e)}peek(e=0){return this.tokens[Math.min(this.pos+e,this.tokens.length-1)]}take(){return this.tokens[this.pos++]}atPunct(e){let t=this.peek();return t.kind===`punct`&&t.value===e}atCommand(e){let t=this.peek();return t.kind===`command`&&t.value===e}parseRow(e){this.enter();try{let t=[];for(;;){let n=this.peek();if(n.kind===`eof`||n.kind===`punct`&&e.chars?.has(n.value)||n.kind===`command`&&e.commands?.has(n.value)||n.kind===`newline`&&e.newline)break;t.push(this.parseAtom())}return t}finally{this.leave()}}parseAtom(){this.enter();try{return this.parseAtomBody()}finally{this.leave()}}parseAtomBody(){let e=this.peek(),t;return e.kind===`number`?(this.take(),t=X(`mn`,null,e.value)):e.kind===`letter`?(this.take(),t=X(`mi`,null,e.value)):e.kind===`punct`?t=this.parsePunctuation(e):e.kind===`newline`?(this.take(),t=X(`mspace`,{linebreak:`newline`})):e.kind===`command`?t=this.parseCommand(e):(this.take(),t=X(`mtext`,null,``)),this.applyScripts(t)}parsePunctuation(e){return this.take(),e.value===`{`?(--this.pos,this.parseBraceGroup()):e.value===`}`||e.value===`&`||e.value===`#`?X(`mo`,null,e.value):X(`mo`,e.value===`(`||e.value===`)`||e.value===`[`||e.value===`]`||e.value===`|`?{fence:`true`,stretchy:`true`}:null,e.value)}parseCommand(e){let t=e.value;if(t===`frac`||t===`dfrac`||t===`tfrac`)return this.take(),this.parseFraction();if(t===`sqrt`)return this.take(),this.parseRoot();if(t===`left`)return this.take(),this.parseLeft();if(t===`right`)return this.take(),this.readDelimiter()??X(`mrow`,null);if(t===`begin`)return this.take(),this.parseEnvironment();if(t===`end`)return this.take(),this.readRawGroup(),X(`mtext`,null,`\\end`);if(t===`text`||t===`textrm`||t===`mbox`||t===`operatorname`)return this.take(),X(`mtext`,null,this.readRawGroup());if(t===`mathrm`||t===`mathbf`||t===`mathit`||t===`mathsf`){this.take();let e=this.readRawGroup();return X(`mtext`,{mathvariant:t===`mathrm`?`normal`:t===`mathbf`?`bold`:t===`mathit`?`italic`:`sans-serif`},e)}if(t===`overline`||t===`bar`||t===`hat`||t===`tilde`||t===`vec`||t===`dot`||t===`ddot`)return this.take(),X(`mover`,{accent:`true`},this.parseRequiredArgument(),X(`mo`,{stretchy:`true`},t===`overline`||t===`bar`?`¯`:t===`hat`?`^`:t===`tilde`?`~`:t===`vec`?`→`:t===`dot`?`˙`:`¨`));if(ap.has(t))return this.take(),X(`mrow`,null);if(Object.hasOwn(ip,t))return this.take(),X(`mspace`,{width:ip[t]});if(rp.has(t))return this.take(),X(`mo`,{mathvariant:`normal`,form:`prefix`},t);if(Object.hasOwn(tp,t))return this.take(),X(`mi`,null,tp[t]);if(Object.hasOwn(np,t)){this.take();let e=np[t];return X(`mo`,e===`(`||e===`)`||e===`[`||e===`]`||e===`{`||e===`}`||e===`|`||e===`‖`||e===`⟨`||e===`⟩`?{fence:`true`,stretchy:`true`}:null,e)}return this.take(),X(`mtext`,null,`\\${t}`)}parseBraceGroup(){if(!this.atPunct(`{`))return X(`mrow`,null);this.take();let e=this.parseRow({chars:new Set([`}`])});return this.atPunct(`}`)&&this.take(),X(`mrow`,null,...e)}parseFraction(){return X(`mfrac`,null,this.parseRequiredArgument(),this.parseRequiredArgument())}parseRoot(){let e=null;if(this.atPunct(`[`)){this.take();let t=this.parseRow({chars:new Set([`]`])});this.atPunct(`]`)&&this.take(),e=X(`mrow`,null,...t)}let t=this.parseRequiredArgument();return e?X(`mroot`,null,t,e):X(`msqrt`,null,t)}parseRequiredArgument(){return this.atPunct(`{`)?this.parseBraceGroup():this.parseAtom()}parseLeft(){let e=this.readDelimiter(),t=this.parseRow({commands:new Set([`right`])}),n=null;return this.atCommand(`right`)&&(this.take(),n=this.readDelimiter()),!e&&!n?X(`mrow`,null,...t):X(`mrow`,null,e,...t,n)}readDelimiter(){let e=this.peek();if(e.kind===`punct`)return e.value===`.`?(this.take(),null):`()[]|`.includes(e.value)?(this.take(),X(`mo`,{fence:`true`,stretchy:`true`},e.value)):null;if(e.kind===`command`){let t={lbrace:`{`,rbrace:`}`,lvert:`|`,rvert:`|`,vert:`|`,lVert:`‖`,rVert:`‖`,Vert:`‖`,langle:`⟨`,rangle:`⟩`},n=Object.hasOwn(t,e.value)?t[e.value]:void 0;if(n)return this.take(),X(`mo`,{fence:`true`,stretchy:`true`},n)}return null}parseEnvironment(){let e=this.readRawGroup().trim();if(e!==`cases`)return X(`mtext`,null,`\\begin{${e}}`);let t=[],n=0;for(;!this.atCommand(`end`)&&this.peek().kind!==`eof`&&n<500;){n+=1;let e=[];for(;;){let t=this.parseRow({chars:new Set([`&`]),commands:new Set([`end`]),newline:!0});if(e.push(X(`mtd`,{columnalign:`left`},...t)),!this.atPunct(`&`))break;this.take()}if(t.push(X(`mtr`,null,...e)),this.peek().kind===`newline`)this.take();else{if(this.atCommand(`end`)||this.peek().kind===`eof`)break;this.take()}}this.atCommand(`end`)&&(this.take(),this.readRawGroup());let r=X(`mtable`,{columnalign:`left`,columnspacing:`1em`},...t);return X(`mrow`,null,X(`mo`,{fence:`true`,stretchy:`true`},`{`),r)}applyScripts(e){let t=null,n=null,r=!1;for(;;)if(this.atPunct(`^`))this.take(),n=this.parseScriptArgument(),r=!0;else if(this.atPunct(`_`))this.take(),t=this.parseScriptArgument(),r=!0;else break;return r?t!==null&&n!==null?X(`msubsup`,null,e,t,n):n===null?X(`msub`,null,e,t):X(`msup`,null,e,n):e}parseScriptArgument(){return this.atPunct(`{`)?this.parseBraceGroup():this.atPunct(`+`)||this.atPunct(`-`)?X(`mrow`,null,X(`mo`,null,this.take().value),this.parseAtom()):this.parseAtom()}readRawGroup(){if(!this.atPunct(`{`))return``;let e=this.take(),t=1,n=this.pos;for(;n<this.tokens.length;n+=1){let e=this.tokens[n];if(e.kind===`eof`)break;if(e.kind===`punct`){if(e.value===`{`)t+=1;else if(e.value===`}`&&(--t,t===0))break}}if(n>=this.tokens.length||this.tokens[n].kind===`eof`)return this.pos=n,this.source.slice(e.offset+1);let r=this.tokens[n];return this.pos=n+1,this.source.slice(e.offset+1,r.offset)}};function sp({source:e,display:t=!1}){let n=$f(e),r;if(e.length>Yf)r=X(`mtext`,null,n);else try{r=new op(e).render()}catch{r=X(`mtext`,null,n)}let i=e.length>Qf?n:e;return X(`math`,{display:t?`block`:`inline`,className:t?`local-math local-math-block`:`local-math`,"aria-label":i},X(`semantics`,null,X(`mrow`,null,r),X(`annotation`,{encoding:`application/x-tex`},i)))}var cp=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Z=s(((e,t)=>{t.exports=cp()}))(),lp=e=>e,up=(0,y.createContext)(`en`);function dp({locale:e=`en`,children:t}){return(0,Z.jsx)(up.Provider,{value:e,children:t})}function fp(){return(0,y.useContext)(up)}function pp(e,t,n){return e===`zh`?n:t}function Q(){let e=fp();return(0,y.useMemo)(()=>(t,n)=>pp(e,t,n),[e])}var mp=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--chart-5)`,`var(--chart-6)`,`var(--chart-7)`,`var(--chart-8)`],hp=520,gp=320,_p=520,vp=320,yp=520,bp=120,xp=46,Sp=150,Cp=12.5,wp=10,Tp=100,Ep=2,Dp=15,Op=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,kp=/^\s*\{\{([\s\S]*)\}\}\s*$/;function Ap(e){if(!Number.isFinite(e))return`—`;if(Object.is(e,-0))return`0`;let t=Math.abs(e);return t>=0xe8d4a51000||t>0&&t<1e-4?e.toExponential(3).replace(/(\.\d*?)0+e/,`$1e`).replace(/\.e/,`e`):Number(e.toFixed(6)).toString()}function jp(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e6||t>0&&t<.001?e.toExponential(2):Number(e.toFixed(4)).toString()}function Mp(e){return e instanceof Error?e.message:String(e)}function Np(e,t,n,r=``){let i=t?.[n];if(i===void 0)return r;try{return e.text(i)}catch{return r}}function Pp(e,t,n,r){let i=t?.[n];if(i===void 0)return r;let a=i.trim();if(!a)return null;let o=kp.exec(a);try{let t=o?e.evaluate(o[1].trim()):Number(a);return typeof t==`number`&&Number.isFinite(t)?t:null}catch{return null}}function Fp(e,t,n,r){let i=t?.[n];if(i===void 0)return r;let a=i.trim();if(!a||a===`true`)return!0;if(a===`false`)return!1;let o=kp.exec(a);if(!o)return r;try{let t=e.evaluate(o[1].trim());return typeof t==`boolean`?t:r}catch{return r}}function Ip(e,t,n,r){let i=Pp(e,t,n,r);return i===null||!Number.isFinite(i)?r:Math.trunc(i)}function Lp(e,t){return e.length>t?`${e.slice(0,Math.max(1,t-1))}…`:e}function Rp(e,t=8,n=2){if(!e)return[``];let r=[],i=e;for(;i&&r.length<n-1;)r.push(i.slice(0,t)),i=i.slice(t);return(i||r.length===0)&&r.push(i.length>t?`${i.slice(0,Math.max(1,t-1))}…`:i),r}function zp(e,t){let n=Array.from(e),r=Array.from(t),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1){let t=(n[e].codePointAt(0)??0)-(r[e].codePointAt(0)??0);if(t!==0)return t}return n.length-r.length}function Bp(e,t,n=5){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)return[e];let r=(t-e)/Math.max(1,n-1),i=10**Math.floor(Math.log10(r)),a=r/i,o=(a<=1?1:a<=2?2:a<=5?5:10)*i,s=Math.ceil(e/o)*o,c=[];for(let e=s;e<=t+o*1e-9&&c.length<40;e+=o)c.push(Number(e.toFixed(10)));return c}function Vp(e,t){let n=1/0,r=-1/0;for(let t of e)Number.isFinite(t)&&(t<n&&(n=t),t>r&&(r=t));if(!Number.isFinite(n)||!Number.isFinite(r))return{min:0,max:1};if(t&&(n=Math.min(n,0),r=Math.max(r,0)),n===r){let e=Math.abs(n)>0?Math.abs(n)*.15:1;n-=e,r+=e}else{let e=(r-n)*.06;n-=e,r+=e,t&&(n=Math.min(n,0),r=Math.max(r,0))}return{min:n,max:r}}function Hp(e,t){return Math.max(46,...e.map(e=>jp(e).length*6+(t?24:10)))}function Up(e,t,n){let r=e.currentTarget,i=r.ownerSVGElement??r.closest(`svg`);if(!i)return;let a=Array.from(i.querySelectorAll(t)),o=a.indexOf(r);o<0||a.length===0||(e.preventDefault(),a[(o+n+a.length)%a.length]?.focus())}function Wp(e){return e.key===`Enter`||e.key===` `||e.key===`Spacebar`}function Gp(e,t=lp){return e===null?{text:``,kind:`null`,error:null}:typeof e==`string`?{text:e,kind:`string`,error:null}:typeof e==`number`?Number.isFinite(e)?{text:Ap(e),kind:`number`,error:null}:{text:t(`Cannot compute`,`无法计算`),kind:`error`,error:t(`Result is not a finite number`,`结果不是有限数字`)}:typeof e==`boolean`?{text:e?`true`:`false`,kind:`boolean`,error:null}:{text:t(`Cannot compute`,`无法计算`),kind:`array`,error:t(`Arrays must first be converted with a function such as len`,`数组需要先用 len 等函数转换`)}}function Kp(e,t,n=lp){let r=``,i=null;for(let a of e??[])if(a.type===`text`||a.type===`inlineCode`||a.type===`code`)r+=a.value??``;else if(a.type===`interpolation`)try{let e=Gp(t.evaluate((a.value??``).trim()),n);e.error&&(i??=e.error),r+=e.text}catch(e){i??=Mp(e),r+=n(`Cannot compute`,`无法计算`)}else if(a.type===`inlineMath`||a.type===`math`)r+=a.value??``;else if(a.type===`image`)r+=a.alt??``;else if(a.children&&a.children.length>0){let e=Kp(a.children,t,n);r+=e.text,i??=e.error}else a.value&&(r+=a.value);return{text:r,error:i}}function qp(e,t,n=lp){let r=e.children??[],i=r.filter(e=>!(e.type===`text`&&!(e.value??``).trim()));if(i.length===1&&i[0].type===`interpolation`)try{let a=t.evaluate((i[0].value??``).trim()),o=Gp(a,n);return{node:e,children:r,text:o.text,value:a,kind:o.kind,numeric:o.kind===`number`?a:null,error:o.error}}catch(t){return{node:e,children:r,text:n(`Cannot compute`,`无法计算`),value:void 0,kind:`error`,numeric:null,error:Mp(t)}}let a=Kp(r,t,n);if(i.length>0&&i.every(e=>e.type===`text`)&&Op.test(a.text.trim())){let t=Number(a.text.trim());if(Number.isFinite(t))return{node:e,children:r,text:a.text,value:t,kind:`number`,numeric:t,error:null}}let o=!a.text.trim()&&!a.error;return{node:e,children:r,text:a.error?n(`Cannot compute`,`无法计算`):a.text,value:a.text,kind:a.error?`error`:o?`empty`:`string`,numeric:null,error:a.error}}function Jp(e,t=lp){return e?e.error?t(`Cannot compute`,`无法计算`):e.text:``}function Yp(e,t,n=lp){let r=e.children?.find(e=>e.type===`table`);if(!r)return null;let i=r.children?.filter(e=>e.type===`tableRow`)??[];if(i.length===0)return null;let a=(i[0].children??[]).map(e=>qp(e,t,n));return{tableNode:r,header:a,headerText:a.map(e=>Jp(e,n)),rows:i.slice(1).map((e,r)=>({index:r,cells:(e.children??[]).map(e=>qp(e,t,n))}))}}function Xp(e,t){let n=!1;for(let r of e.rows){let e=r.cells[t];if(e&&e.kind!==`empty`){if(e.numeric===null)return!1;n=!0}}return n}function Zp(e,t){let n=(e?.key??``).trim();return n?t.findIndex(e=>e.trim()===n):-1}function Qp(e,t,n){return e<0?``:Jp(t.cells[e],n).trim()}function $p(e,t,n){if(!n)return``;try{let n=e.get(t);return typeof n==`string`?n:``}catch{return``}}function em({className:e,label:t,children:n}){let r=(0,y.useId)();return(0,Z.jsxs)(`figure`,{className:`local-visual ${e}`,"aria-labelledby":r,children:[(0,Z.jsx)(`figcaption`,{id:r,className:`local-visual-title`,children:t}),n]})}function tm({message:e,kind:t=`status`}){return(0,Z.jsx)(`p`,{className:`local-visual-message local-visual-${t}`,role:t,children:e})}function nm({notes:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{className:`local-visual-notes`,role:`status`,children:e.map((e,t)=>(0,Z.jsx)(`li`,{children:e},`${e}-${t}`))})}function rm({items:e,hidden:t,onToggle:n,label:r,mode:i}){let a=Q(),o=i!==`static`;return(0,Z.jsx)(`div`,{className:`local-visual-legend${o?``:` local-static-legend`}`,role:`group`,"aria-label":o?r:a(`Legend`,`图例`),children:e.map((e,r)=>{let i=t.has(r);return o?(0,Z.jsxs)(`button`,{type:`button`,className:`local-visual-legend-item${i?` is-off`:``}`,"aria-pressed":!i,disabled:e.disabled,onClick:()=>n(r),title:i?a(`Show ${e.name}`,`显示 ${e.name}`):a(`Hide ${e.name}`,`隐藏 ${e.name}`),children:[(0,Z.jsx)(`span`,{className:`local-visual-swatch`,style:{backgroundColor:e.color},"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`local-visual-legend-text`,children:[e.name,e.detail?a(` (${e.detail})`,`(${e.detail})`):``]})]},`${e.name}-${r}`):(0,Z.jsxs)(`span`,{className:`local-visual-legend-item local-static-legend-item`,children:[(0,Z.jsx)(`span`,{className:`local-visual-swatch`,style:{backgroundColor:e.color},"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`local-visual-legend-text`,children:[e.name,e.detail?a(` (${e.detail})`,`(${e.detail})`):``]})]},`${e.name}-${r}`)})})}function im({node:e,runtime:t,render:n,mode:r}){let i=Q(),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(1),[d,f]=(0,y.useState)(null),p=t.resetToken(e);(0,y.useEffect)(()=>{o(``),c(null),u(1),f(null)},[p]);let m=Np(t,e.attrs,`label`,i(`Table`,`表格`)),h=Fp(t,e.attrs,`searchable`,!0),g=Fp(t,e.attrs,`sortable`,!0),_=Ip(t,e.attrs,`page-size`,10),v=Math.max(1,_),b=Yp(e,t,i);if(!b||b.header.length===0)return(0,Z.jsx)(em,{className:`local-visual-table-block`,label:m,children:(0,Z.jsx)(tm,{message:i(`Table requires a non-empty Markdown table.`,`表格需要一个非空的 Markdown 表格。`),kind:`alert`})});let x=Zp(e.attrs,b.headerText),S=x>=0,C=$p(t,e,S),w=n=>{f(null);try{let r=t.set(e,n);r.length>0&&f(r.map(e=>i(tt(e,`en`),tt(e,`zh`))).join(`; `))}catch(e){f(Mp(e))}},T=b.header.map((e,t)=>Xp(b,t)),E=a.trim().toLowerCase(),D=[...b.rows.filter(e=>!E||e.cells.some(e=>Jp(e,i).toLowerCase().includes(E)))];if(s){let e=T[s.column];D.sort((t,n)=>{let r=t.cells[s.column],a=n.cells[s.column],o;if(e){let e=r?.numeric??-1/0,t=a?.numeric??-1/0;o=e===t?0:e<t?-1:1}else o=zp(Jp(r,i),Jp(a,i));return o===0?t.index-n.index:s.direction===`asc`?o:-o})}let O=Math.max(1,Math.ceil(D.length/v)),k=Math.min(l,O),A=D.slice((k-1)*v,k*v),j=e=>{u(1),c(t=>!t||t.column!==e?{column:e,direction:`asc`}:t.direction===`asc`?{column:e,direction:`desc`}:null)},M=e=>!s||s.column!==e?``:s.direction===`asc`?i(` (ascending)`,`(升序)`):i(` (descending)`,`(降序)`);return r===`static`?(0,Z.jsxs)(em,{className:`local-visual-table-block local-static-table-block`,label:m,children:[(0,Z.jsx)(`div`,{className:`local-visual-table-scroll local-static-table-scroll`,children:(0,Z.jsxs)(`table`,{className:`local-visual-table local-static-table`,children:[(0,Z.jsx)(`caption`,{className:`local-visual-sr-only`,children:m}),(0,Z.jsx)(`thead`,{children:(0,Z.jsx)(`tr`,{children:b.header.map((e,t)=>(0,Z.jsx)(`th`,{scope:`col`,className:T[t]?`is-numeric`:void 0,children:Jp(e,i)},`head-${t}`))})}),(0,Z.jsx)(`tbody`,{children:b.rows.map(e=>{let t=S?Qp(x,e,i):``,r=S&&t!==``&&t===C;return(0,Z.jsx)(`tr`,{className:r?`is-selected local-static-selected`:void 0,children:b.header.map((t,a)=>{let o=e.cells[a];return(0,Z.jsxs)(`td`,{className:T[a]?`is-numeric`:void 0,children:[r&&a===0?(0,Z.jsx)(`span`,{className:`local-visual-sr-only`,children:i(`Selected row`,`已选择行`)}):null,o?.error?(0,Z.jsx)(`span`,{className:`local-visual-cell-error`,title:o.error,children:i(`Cannot compute`,`无法计算`)}):n(o?.children??[])]},`cell-${e.index}-${a}`)})},`row-${e.index}`)})})]})}),b.rows.length===0?(0,Z.jsx)(tm,{message:i(`No rows to display`,`没有可显示的行`)}):null]}):(0,Z.jsxs)(em,{className:`local-visual-table-block`,label:m,children:[h?(0,Z.jsxs)(`label`,{className:`local-visual-search`,children:[(0,Z.jsx)(`span`,{children:i(`Search`,`搜索`)}),(0,Z.jsx)(`input`,{type:`search`,value:a,placeholder:i(`Search all columns`,`搜索所有列`),"aria-label":i(`Search ${m}`,`搜索${m}`),onChange:e=>{o(e.target.value),u(1)}})]}):null,(0,Z.jsx)(`div`,{className:`local-visual-table-scroll`,children:(0,Z.jsxs)(`table`,{className:`local-visual-table`,children:[(0,Z.jsx)(`caption`,{className:`local-visual-sr-only`,children:m}),(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{children:[S?(0,Z.jsx)(`th`,{scope:`col`,className:`local-visual-select-column`,children:(0,Z.jsx)(`span`,{className:`local-visual-sr-only`,children:i(`Select`,`选择`)})}):null,b.header.map((e,t)=>{let n=s&&s.column===t?s.direction===`asc`?`ascending`:`descending`:`none`;return(0,Z.jsx)(`th`,{scope:`col`,"aria-sort":n,className:T[t]?`is-numeric`:void 0,children:g?(0,Z.jsxs)(`button`,{type:`button`,className:`local-visual-sort-button${s&&s.column===t?` is-sorted`:``}`,onClick:()=>j(t),title:i(`Click to cycle ascending, descending and original order`,`点击切换升序、降序和原始顺序`),children:[Jp(e,i),M(t)]}):Jp(e,i)},`head-${t}`)})]})}),(0,Z.jsx)(`tbody`,{children:A.map(e=>{let t=S?Qp(x,e,i):``,r=S&&t!==``&&t===C;return(0,Z.jsxs)(`tr`,{className:r?`is-selected`:void 0,children:[S?(0,Z.jsx)(`td`,{className:`local-visual-select-cell`,children:t?(0,Z.jsx)(`button`,{type:`button`,className:`local-visual-select-button${r?` is-selected`:``}`,"aria-pressed":r,"aria-label":i(`Select row ${t}`,`选择行 ${t}`),title:i(`Select row ${t}`,`选择行 ${t}`),onClick:()=>w(t),children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:r?`●`:`○`})}):null}):null,b.header.map((t,r)=>{let a=e.cells[r];return(0,Z.jsx)(`td`,{className:T[r]?`is-numeric`:void 0,children:a?.error?(0,Z.jsx)(`span`,{className:`local-visual-cell-error`,title:a.error,children:i(`Cannot compute`,`无法计算`)}):n(a?.children??[])},`cell-${e.index}-${r}`)})]},`row-${e.index}`)})})]})}),d?(0,Z.jsx)(tm,{message:d,kind:`alert`}):null,D.length===0?(0,Z.jsx)(tm,{message:i(`No matching results`,`没有匹配结果`)}):null,O>1?(0,Z.jsxs)(`nav`,{className:`local-visual-pagination`,"aria-label":i(`Table pagination`,`表格分页`),children:[(0,Z.jsx)(`button`,{type:`button`,disabled:k<=1,onClick:()=>u(e=>Math.max(1,e-1)),children:i(`Previous`,`上一页`)}),(0,Z.jsx)(`span`,{children:i(`Page ${k} of ${O} · ${D.length} rows`,`第 ${k} / ${O} 页 · 共 ${D.length} 行`)}),(0,Z.jsx)(`button`,{type:`button`,disabled:k>=O,onClick:()=>u(e=>Math.min(O,e+1)),children:i(`Next`,`下一页`)})]}):null]})}var am=[`bar`,`line`,`area`,`scatter`,`donut`];function om(e,t,n,r,i,a){let o=(n,r)=>[e+n*Math.cos(r),t+n*Math.sin(r)],[s,c]=o(n,i),[l,u]=o(n,a),[d,f]=o(r,a),[p,m]=o(r,i),h=+(a-i>Math.PI);return[`M ${s} ${c}`,`A ${n} ${n} 0 ${h} 1 ${l} ${u}`,`L ${d} ${f}`,`A ${r} ${r} 0 ${h} 0 ${p} ${m}`,`Z`].join(` `)}function sm({node:e,runtime:t,mode:n}){let r=Q(),i=n===`static`,[a,o]=(0,y.useState)(new Set),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),p=t.resetToken(e);(0,y.useEffect)(()=>{o(new Set),c(new Set),u(null),f(null)},[p]);let m=(0,y.useId)(),h=Np(t,e.attrs,`title`,``)||Np(t,e.attrs,`label`,``)||r(`Chart`,`图表`),g=(e.attrs?.kind??`bar`).trim().toLowerCase(),_=am.includes(g)?g:null,v=Np(t,e.attrs,`x-label`,``),b=Np(t,e.attrs,`y-label`,``),x=Yp(e,t,r);if(!x||x.header.length===0)return(0,Z.jsx)(em,{className:`local-visual-chart`,label:h,children:(0,Z.jsx)(tm,{message:r(`chart body requires a non-empty Markdown table.`,`chart 正文需要一个非空的 Markdown 表格。`),kind:`alert`})});let S=x.headerText.map(e=>e.trim()),C=Zp(e.attrs,S),w=C>=0,T=$p(t,e,w),E=n=>{f(null);try{let i=t.set(e,n);i.length>0&&f(i.map(e=>r(tt(e,`en`),tt(e,`zh`))).join(`; `))}catch(e){f(Mp(e))}},D=x.rows.map(e=>({index:e.index,cells:e.cells,texts:S.map((t,n)=>Jp(e.cells[n],r)),keyValue:Qp(C,e,r)}));if(!_)return(0,Z.jsx)(em,{className:`local-visual-chart`,label:h,children:(0,Z.jsx)(tm,{message:r(`Unknown chart type "${g}".`,`未知图表类型“${g}”。`),kind:`alert`})});let O=[],k=[],A=(e.attrs?.x??``).trim(),j=A?S.indexOf(A):0;(j<0||j>=S.length)&&k.push(r(`x column "${A}" does not exist.`,`x 列“${A}”不存在。`));let M=(e.attrs?.y??``).split(`,`).map(e=>e.trim()).filter(Boolean),N=[];if(_===`donut`){if(M.length>1)k.push(r(`donut can only use one numeric column; specify a single column in y.`,`donut 只能使用一个数值列,请在 y 中指定唯一列。`));else if(M.length===1){let e=S.indexOf(M[0]);e<0?k.push(r(`y column "${M[0]}" does not exist.`,`y 列“${M[0]}”不存在。`)):N=[e]}else S.length===2?N=[1]:k.push(r(`A donut chart with more than two columns must use y to specify the single numeric column.`,`donut 多于两列时必须用 y 指定唯一数值列。`))}else if(M.length>0)for(let e of M){let t=S.indexOf(e);t<0?k.push(r(`y column "${e}" does not exist.`,`y 列“${e}”不存在。`)):N.includes(t)||N.push(t)}else N=S.map((e,t)=>t).filter(e=>e!==j);if(k.length===0&&N.length===0&&k.push(r(`Chart requires at least one numeric series.`,`图表至少需要一个数值系列。`)),k.length>0)return(0,Z.jsx)(em,{className:`local-visual-chart local-visual-chart-${_}`,label:h,children:k.map((e,t)=>(0,Z.jsx)(tm,{message:e,kind:`alert`},`${e}-${t}`))});let ee=N.map(e=>S[e]||r(`Series ${e+1}`,`系列 ${e+1}`)),P=0,te=0,F=D.map(e=>{let t=e.cells[j],n=e.texts[j]||r(`Item ${e.index+1}`,`第 ${e.index+1} 项`),i=t&&t.numeric!==null?t.numeric:null,a=N.map(t=>{let n=e.cells[t];return!n||n.kind===`empty`||n.numeric===null?(P+=1,null):(_===`donut`&&n.numeric<0&&(te+=1),n.numeric)});return{index:e.index,label:n,xValue:i,values:a,cells:e.cells,keyValue:e.keyValue}});P>0&&O.push(r(`${P} values are empty or cannot be computed; gaps are kept in the chart.`,`${P} 个数值为空或无法计算,图表中保留空缺。`));for(let e of N)Xp(x,e)||O.push(r(`Column "${S[e]}" is not purely numeric; non-numeric values are treated as gaps.`,`列“${S[e]}”不是纯数值列,非数值按空缺处理。`));_===`donut`&&te>0&&O.push(r(`Donut values must be non-negative; ignored ${te} negative values.`,`环形图数值必须非负,已忽略 ${te} 个负值。`)),_===`scatter`&&!Xp(x,j)&&O.push(r(`scatter horizontal axis column "${S[j]}" requires numeric values.`,`scatter 的横轴列“${S[j]}”需要数值。`));let ne=e=>{u(null),o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},re=e=>{u(null),c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ie=ee.map((e,t)=>({name:e,color:mp[t%mp.length]}));if(_===`donut`){let e=F.map(e=>e.values[0]),t=e.map(e=>e!==null&&e>=0?e:0),a=t.reduce((e,t,n)=>!i&&s.has(n)?e:e+t,0),o=F.map((n,r)=>({name:n.label,color:mp[r%mp.length],detail:e[r]===null?`—`:Ap(e[r]),disabled:t[r]<=0}));if(a<=0)return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-donut`,label:h,children:[(0,Z.jsx)(tm,{message:r(`No share to display`,`暂无占比`)}),(0,Z.jsx)(nm,{notes:O}),(0,Z.jsx)(rm,{items:o,hidden:s,onToggle:re,label:r(`Legend`,`图例`),mode:n})]});let c=hp/2,f=-Math.PI/2,p=[];F.forEach((e,n)=>{if(!i&&s.has(n))return;let r=t[n];if(r<=0)return;let o=r/a*Math.PI*2,l=f,u=f+o;f=u,p.push({key:`donut:${n}`,label:e.label,value:r,start:l,end:u,color:mp[n%mp.length],x:c,y:140,rowKey:e.keyValue})});let g=l?r(`${l.label}: ${Ap(l.value)}`,`${l.label}:${Ap(l.value)}`):r(`Focus a slice or legend to view values`,`聚焦扇区或图例查看数值`);return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-donut${i?` local-static-chart`:``}`,label:h,children:[i?null:(0,Z.jsx)(`div`,{className:`local-visual-readout`,id:m,"aria-live":`polite`,children:g}),(0,Z.jsx)(`div`,{className:`local-visual-svg-wrap`,children:(0,Z.jsxs)(`svg`,{className:`local-visual-svg`,viewBox:`0 0 ${hp} 290`,role:`group`,"aria-label":r(`${h}, donut chart, ${F.length} items`,`${h},环形图,共 ${F.length} 项`),"aria-describedby":i?void 0:m,children:[(0,Z.jsxs)(`g`,{className:`local-visual-donut-center`,"aria-hidden":`true`,children:[(0,Z.jsx)(`text`,{x:c,y:138,textAnchor:`middle`,className:`local-visual-donut-total`,children:Ap(a)}),(0,Z.jsx)(`text`,{x:c,y:158,textAnchor:`middle`,className:`local-visual-donut-caption`,children:Lp(ee[0],14)})]}),p.map(e=>{let t=w&&e.rowKey!==``,n=t&&e.rowKey===T,a={key:e.key,series:ee[0],label:e.label,value:e.value,x:e.x,y:e.y,rowKey:e.rowKey,selectable:t,selected:n},o=i?{}:{"data-chart-mark":``,...t?{"data-chart-selectable":``}:{},tabIndex:0,role:t?`button`:`img`,...t?{"aria-pressed":n}:{},"aria-label":r(`${e.label}: ${Ap(e.value)}`,`${e.label}:${Ap(e.value)}`),onFocus:()=>u(a),onBlur:()=>u(null),onPointerEnter:()=>u(a),onPointerLeave:()=>u(null),onClick:t?()=>E(e.rowKey):void 0,onKeyDown:n=>{t&&Wp(n)?(n.preventDefault(),E(e.rowKey)):n.key===`ArrowRight`||n.key===`ArrowDown`?Up(n,`[data-chart-mark]`,1):(n.key===`ArrowLeft`||n.key===`ArrowUp`)&&Up(n,`[data-chart-mark]`,-1)}},s=`local-visual-donut-slice${n?` is-selected`:``}`;return e.end-e.start>=Math.PI*2-1e-6?(0,Z.jsx)(`circle`,{className:s,cx:c,cy:140,r:78,fill:`none`,style:{stroke:e.color},strokeWidth:40,...o,children:(0,Z.jsx)(`title`,{children:r(`${e.label}: ${Ap(e.value)}`,`${e.label}:${Ap(e.value)}`)})},e.key):(0,Z.jsx)(`path`,{className:s,d:om(c,140,98,58,e.start,e.end),style:{fill:e.color},...o,children:(0,Z.jsx)(`title`,{children:r(`${e.label}: ${Ap(e.value)}`,`${e.label}:${Ap(e.value)}`)})},e.key)})]})}),(0,Z.jsx)(rm,{items:o,hidden:s,onToggle:re,label:r(`Legend, toggle slices`,`图例,可开关扇区`),mode:n}),d?(0,Z.jsx)(tm,{message:d,kind:`alert`}):null,(0,Z.jsx)(nm,{notes:O})]})}let ae=ee.map((e,t)=>t).filter(e=>i||!a.has(e));if(ae.length===0)return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-${_}`,label:h,children:[(0,Z.jsx)(tm,{message:r(`All series are hidden in the legend`,`所有系列已在图例中关闭`)}),(0,Z.jsx)(rm,{items:ie,hidden:a,onToggle:ne,label:r(`Legend, toggle series`,`图例,可开关系列`),mode:n})]});let oe=Xp(x,j),se=_===`scatter`?!0:_===`line`||_===`area`?oe:!1,ce=se?F.filter(e=>e.xValue!==null):F;se&&ce.length<F.length&&O.push(r(`${F.length-ce.length} rows have an empty or non-numeric horizontal axis and are not plotted.`,`${F.length-ce.length} 行横轴为空或不是数值,未参与绘制。`));let le=[];for(let e of ce)for(let t of ae){let n=e.values[t];n!==null&&le.push(n)}if(ce.length===0)return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-${_}`,label:h,children:[(0,Z.jsx)(tm,{message:r(`No data rows to plot`,`没有可绘制的数据行`)}),(0,Z.jsx)(nm,{notes:O}),(0,Z.jsx)(rm,{items:ie,hidden:a,onToggle:ne,label:r(`Legend, toggle series`,`图例,可开关系列`),mode:n})]});if(le.length===0)return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-${_}`,label:h,children:[(0,Z.jsx)(tm,{message:r(`No values to read`,`没有可读取的数值`)}),(0,Z.jsx)(nm,{notes:O}),(0,Z.jsx)(rm,{items:ie,hidden:a,onToggle:ne,label:r(`Legend, toggle series`,`图例,可开关系列`),mode:n})]});let ue=Vp(le,_===`bar`||_===`area`),de=Bp(ue.min,ue.max,5),fe=Hp(de,!!b),pe=506-fe,me=e=>16+(ue.max-e)/(ue.max-ue.min)*258,I=me(Math.max(ue.min,Math.min(ue.max,0))),L=se&&ce.length>0?Vp(ce.map(e=>e.xValue).filter(e=>e!==null),!1):null,he=pe/Math.max(1,F.length),ge=e=>fe+he*(e+.5),_e=e=>fe+(e-L.min)/(L.max-L.min)*pe,ve=(e,t)=>L?e.xValue===null?null:_e(e.xValue):ge(t),ye=[];if(L)ye.push(...Bp(L.min,L.max,5));else{let e=Math.max(1,Math.ceil(F.length/6));for(let t=0;t<F.length;t+=e)ye.push(t);let t=F.length-1;t>=0&&ye[ye.length-1]!==t&&(ye.length>1&&t-ye[ye.length-1]<e*.6?ye[ye.length-1]=t:ye.push(t))}let be=e=>L?fe+(e-L.min)/(L.max-L.min)*pe:ge(e),xe=i||!l?null:L?(0,Z.jsx)(`line`,{className:`local-visual-guide`,x1:Math.max(fe,Math.min(506,l.x)),x2:Math.max(fe,Math.min(506,l.x)),y1:16,y2:274}):null,Se=e=>i?{}:{"data-chart-mark":``,...e.selectable?{"data-chart-selectable":``}:{},tabIndex:0,role:e.selectable?`button`:`img`,...e.selectable?{"aria-pressed":e.selected}:{},"aria-label":r(`${e.series}, ${e.label}${e.selectable&&e.rowKey!==e.label?`, ${e.rowKey}`:``}: ${Ap(e.value)}`,`${e.series},${e.label}${e.selectable&&e.rowKey!==e.label?`,${e.rowKey}`:``}:${Ap(e.value)}`),onFocus:()=>u(e),onBlur:()=>u(null),onPointerEnter:()=>u(e),onPointerLeave:()=>u(null),onClick:e.selectable?()=>E(e.rowKey):void 0,onKeyDown:t=>{e.selectable&&Wp(t)?(t.preventDefault(),E(e.rowKey)):t.key===`ArrowRight`||t.key===`ArrowDown`?Up(t,`[data-chart-mark]`,1):(t.key===`ArrowLeft`||t.key===`ArrowUp`)&&Up(t,`[data-chart-mark]`,-1)}},Ce=(e,t,n,r,i)=>{let a=w&&t.keyValue!==``;return{key:`${e}:${t.index}`,series:ee[e],label:t.label,value:n,x:r,y:i,rowKey:t.keyValue,selectable:a,selected:a&&t.keyValue===T}},we=[];if(_===`bar`){let e=he*.76,t=Math.max(1,e/Math.max(1,ae.length));F.forEach((n,i)=>{ae.forEach((a,o)=>{let s=n.values[a];if(s===null)return;let c=fe+he*i+(he-e)/2+o*t,l=Math.max(1,Math.abs(me(s)-I)),u=s>=0?I-l:I,d=Ce(a,n,s,c+t/2,u+l/2);we.push((0,Z.jsx)(`rect`,{className:`local-visual-bar${d.selected?` is-selected`:``}`,x:c,y:u,width:Math.max(1.5,t-1),height:l,rx:2,style:{fill:mp[a%mp.length]},...Se(d),children:(0,Z.jsx)(`title`,{children:r(`${d.series}, ${d.label}: ${Ap(d.value)}`,`${d.series},${d.label}:${Ap(d.value)}`)})},`bar-${a}-${n.index}`))})})}let Te=[],Ee=[],De=[];if(_===`line`||_===`area`)for(let e of ae){let t=[],n=[],i=()=>{n.length>0&&t.push(n),n=[]};F.forEach((t,r)=>{let a=t.values[e],o=ve(t,r);a===null||o===null?i():n.push({row:t,value:a,x:o,y:me(a)})}),i();for(let n of t){if(n.length>=2){let t=n.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `);if(Te.push((0,Z.jsx)(`path`,{className:`local-visual-line`,d:t,fill:`none`,style:{stroke:mp[e%mp.length]},strokeWidth:2.4,strokeLinejoin:`round`,strokeLinecap:`round`},`line-${e}-${n[0].row.index}`)),_===`area`){let t=I,r=n[0],i=n[n.length-1],a=`M ${r.x} ${t} ${n.map(e=>`L ${e.x} ${e.y}`).join(` `)} L ${i.x} ${t} Z`;Ee.push((0,Z.jsx)(`path`,{className:`local-visual-area`,d:a,style:{fill:mp[e%mp.length]}},`area-${e}-${r.row.index}`))}}for(let t of n){let n=Ce(e,t.row,t.value,t.x,t.y);De.push((0,Z.jsxs)(`g`,{className:`local-visual-point-group`,children:[(0,Z.jsx)(`circle`,{className:`local-visual-hit${n.selected?` is-selected`:``}`,cx:t.x,cy:t.y,r:12,fill:`transparent`,...Se(n),children:(0,Z.jsx)(`title`,{children:r(`${n.series}, ${n.label}: ${Ap(n.value)}`,`${n.series},${n.label}:${Ap(n.value)}`)})}),(0,Z.jsx)(`circle`,{className:`local-visual-point${n.selected?` is-selected`:``}`,cx:t.x,cy:t.y,r:4.5,style:{fill:mp[e%mp.length],stroke:`var(--surface)`},strokeWidth:1.5,pointerEvents:`none`})]},`point-${e}-${t.row.index}`))}}}_===`scatter`&&F.forEach((e,t)=>{let n=ve(e,t);n!==null&&ae.forEach(t=>{let i=e.values[t];if(i===null)return;let a=me(i),o=Ce(t,e,i,n,a);De.push((0,Z.jsxs)(`g`,{className:`local-visual-point-group`,children:[(0,Z.jsx)(`circle`,{className:`local-visual-hit${o.selected?` is-selected`:``}`,cx:n,cy:a,r:15,fill:`transparent`,...Se(o),children:(0,Z.jsx)(`title`,{children:r(`${o.series}, ${o.label}: ${Ap(o.value)}`,`${o.series},${o.label}:${Ap(o.value)}`)})}),(0,Z.jsx)(`circle`,{className:`local-visual-point${o.selected?` is-selected`:``}`,cx:n,cy:a,r:6,style:{fill:mp[t%mp.length],stroke:`var(--surface)`},strokeWidth:1.5,pointerEvents:`none`})]},`scatter-${t}-${e.index}`))})});let Oe=l?r(`${l.series} · ${l.label}: ${Ap(l.value)}`,`${l.series} · ${l.label}:${Ap(l.value)}`):r(`Focus or point at a mark; use arrow keys to change the readout`,`聚焦或指向图形,用方向键切换读数`),ke=r(`${h}, ${_} chart, ${F.length} items, ${ae.length} series`,`${h},${_} 图,共 ${F.length} 项,${ae.length} 个系列`);return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-${_}${i?` local-static-chart`:``}`,label:h,children:[i?null:(0,Z.jsx)(`div`,{className:`local-visual-readout`,id:m,"aria-live":`polite`,children:Oe}),(0,Z.jsx)(`div`,{className:`local-visual-svg-wrap`,children:(0,Z.jsxs)(`svg`,{className:`local-visual-svg`,viewBox:`0 0 ${hp} ${gp}`,role:`group`,"aria-label":ke,"aria-describedby":i?void 0:m,children:[de.map(e=>(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`line`,{className:`local-visual-grid-line`,x1:fe,x2:506,y1:me(e),y2:me(e)}),(0,Z.jsx)(`text`,{className:`local-visual-axis-label`,x:fe-6,y:me(e),textAnchor:`end`,dominantBaseline:`middle`,children:jp(e)})]},`y-${e}`)),ue.min<0&&ue.max>0?(0,Z.jsx)(`line`,{className:`local-visual-zero-line`,x1:fe,x2:506,y1:I,y2:I}):null,(0,Z.jsx)(`line`,{className:`local-visual-axis-line`,x1:fe,x2:506,y1:274,y2:274}),ye.map(e=>{let t=be(e),n=L?jp(e):Lp(F[e]?.label??``,8);return(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`line`,{className:`local-visual-tick`,x1:t,x2:t,y1:274,y2:279}),(0,Z.jsxs)(`text`,{className:`local-visual-axis-label`,x:t,y:293,textAnchor:`middle`,children:[n,!L&&F[e]?(0,Z.jsx)(`title`,{children:F[e].label}):null]})]},`x-${e}`)}),v?(0,Z.jsx)(`text`,{className:`local-visual-axis-title`,x:(fe+506)/2,y:318,textAnchor:`middle`,children:v}):null,b?(0,Z.jsx)(`text`,{className:`local-visual-axis-title`,transform:`translate(12 145) rotate(-90)`,textAnchor:`middle`,children:b}):null,Ee,Te,xe,we,De]})}),(0,Z.jsx)(rm,{items:ie,hidden:a,onToggle:ne,label:r(`Legend, toggle series`,`图例,可开关系列`),mode:n}),d?(0,Z.jsx)(tm,{message:d,kind:`alert`}):null,(0,Z.jsx)(nm,{notes:O})]})}var cm=64,lm=new WeakMap,um=new WeakMap;function dm(e,t){let n=lm.get(e);return n&&n.revision===t||(n={revision:t,requestedPoints:new Map,evaluation:{steps:0,limit:k}},lm.set(e,n)),n}function fm(e){let t=um.get(e);return t||(t=new Map,um.set(e,t)),t}function pm(e,t,n){if(e.size>=cm){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,n),n}function mm(e,t,n){return e.map(e=>{let r=/^y\s*=\s*([\s\S]+)$/.exec((e.value??``).trim());if(!r)return`\u0003${n}`;try{let e=Mn(r[1].trim());return JSON.stringify(e.dependencies.map(e=>t[e]??null))}catch{return`\u0003${n}`}}).join(``)}function hm(e,t,n,r,i,a,o,s,c,l=lp){let u=fm(s),d=u.get(t);if(d)return d;let f=dm(s,c),p=e=>pm(u,t,{ok:!1,message:e});if(n.length>16)return p(l(`plot supports at most 16 curves, but has ${n.length}.`,`plot 最多支持 16 条曲线,当前为 ${n.length} 条。`));let m=n.length*o;f.requestedPoints.set(e,m);let h=0;for(let e of f.requestedPoints.values())h+=e;if(h>2e4)return p(l(`The document's plot sample count exceeds the limit: ${h} requested, at most ${O} allowed. Reduce curves or samples.`,`整篇文档的绘图采样点超过上限:已请求 ${h} 个,最多 ${O} 个。请减少曲线或采样数。`));let g=[],_={message:null},v=n.map((e,t)=>{let n=(e.value??``).trim(),s=/^y\s*=\s*([\s\S]+)$/.exec(n);if(!s)return g.push(l(`Curve ${t+1}: cannot compute (each formula block must be written as y = expression).`,`曲线 ${t+1}:无法计算(每块公式需写成 y = 表达式)。`)),{source:n,expression:null,points:[],endpoint:null,error:`formula`};try{let e=Mn(s[1].trim()),t=In(e,r,i,a,o,f.evaluation);return{source:n,expression:e,points:t.points,endpoint:t.endpoint,error:null}}catch(e){return e instanceof B&&e.code===`latex-budget`?(_.message=e.message,{source:n,expression:null,points:[],endpoint:null,error:e.message}):(g.push(l(`Curve ${t+1}: cannot compute (${Mp(e)}).`,`曲线 ${t+1}:无法计算(${Mp(e)})。`)),{source:n,expression:null,points:[],endpoint:null,error:Mp(e)})}});return _.message===null?pm(u,t,{ok:!0,curves:v,notes:g}):p(l(`Plot computation exceeded the shared execution budget: ${_.message}`,`绘图计算超过共享执行预算:${_.message}`))}function gm(e){if(e.length===0)return 0;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?(t[n-1]+t[n])/2:t[n]}function _m(e,t,n,r){let i=[],a=[],o=(e,i)=>{let a=Math.abs(i.y-e.y),o=e.y*i.y<0&&Math.min(Math.abs(e.y),Math.abs(i.y))>Math.max(1,n*8),s=a>t*.8&&a>Math.max(r,1e-9)*10;return o||s};for(let t of e){if(t.y===null){a.length>0&&i.push(a),a=[];continue}let e={x:t.x,y:t.y},n=a[a.length-1];n&&o(n,e)&&(i.push(a),a=[]),a.push(e)}return a.length>0&&i.push(a),i}function vm({node:e,runtime:t,mode:n}){let r=Q(),i=fp(),a=n===`static`,[o,s]=(0,y.useState)(null),c=t.resetToken(e);(0,y.useEffect)(()=>{s(null)},[c]);let l=(0,y.useId)(),u=Np(t,e.attrs,`label`,``)||r(`Function plot`,`函数图`),d=Np(t,e.attrs,`x-label`,`x`),f=Np(t,e.attrs,`y-label`,`y`),p=Pp(t,e.attrs,`min`,-10),m=Pp(t,e.attrs,`max`,10),h=Math.min(2e3,Math.max(2,Ip(t,e.attrs,`samples`,200))),g=(e.children??[]).filter(e=>e.type===`math`||e.type===`inlineMath`),_=(()=>{try{return{...t.snapshot().state}}catch{return{}}})(),v=0;try{v=t.snapshot().revision}catch{v=0}let b=g.map(e=>`${e.id}\u0000${e.value??``}`).join(``),x=`${e.id}\u0000${p}\u0000${m}\u0000${h}\u0000${i}\u0000${b}`,S=mm(g,_,v),C=`${x}\u0002${S}`,w=(0,y.useMemo)(()=>g.length===0||p===null||m===null||!(m>p)?{ok:!0,curves:[],notes:[]}:hm(e.id,C,g,_,p,m,h,t,v,r),[x,S,e.id,t,r]);if(g.length===0)return(0,Z.jsx)(em,{className:`local-visual-plot`,label:u,children:(0,Z.jsx)(tm,{message:r(`plot body requires one or more $$ formula blocks.`,`plot 正文需要一个或多个 $$ 公式块。`),kind:`alert`})});if(p===null||m===null||!(m>p))return(0,Z.jsx)(em,{className:`local-visual-plot`,label:u,children:(0,Z.jsx)(tm,{message:r(`plot min must be less than max.`,`plot 的 min 必须小于 max。`),kind:`alert`})});if(!w.ok)return(0,Z.jsx)(em,{className:`local-visual-plot`,label:u,children:(0,Z.jsx)(tm,{message:w.message,kind:`alert`})});let{curves:T,notes:E}=w,D=T.flatMap(e=>e.points.filter(e=>e.y!==null&&Number.isFinite(e.y))),O=(0,Z.jsx)(`div`,{className:`local-visual-plot-legend`,role:`list`,"aria-label":r(`Curve legend`,`曲线图例`),children:T.map((e,t)=>(0,Z.jsxs)(`div`,{className:`local-visual-plot-legend-item`,role:`listitem`,children:[(0,Z.jsx)(`span`,{className:`local-visual-swatch`,style:{backgroundColor:mp[t%mp.length]},"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`local-visual-plot-legend-text`,children:(0,Z.jsx)(`span`,{className:`local-visual-plot-formula`,children:(0,Z.jsx)(sp,{source:e.source})})})]},`curve-legend-${t}`))});if(D.length===0)return(0,Z.jsxs)(em,{className:`local-visual-plot`,label:u,children:[(0,Z.jsx)(tm,{message:r(`No plottable values in the current range`,`当前范围内没有可绘制的值`)}),(0,Z.jsx)(nm,{notes:E}),O]});let A=Vp(D.map(e=>e.y),!1),j=Bp(A.min,A.max,5),M=Bp(p,m,5),N=Hp(j,!!f),ee=506-N,P=e=>N+(e-p)/(m-p)*ee,te=e=>16+(A.max-e)/(A.max-A.min)*258,F=gm(D.map(e=>Math.abs(e.y))),ne=[];for(let e of T)for(let t=1;t<e.points.length;t+=1){let n=e.points[t-1],r=e.points[t];n.y!==null&&r.y!==null&&ne.push(Math.abs(r.y-n.y))}let re=gm(ne),ie=A.max-A.min,ae=T.map(e=>_m(e.points,ie,F,re)),oe={steps:0,limit:k},se=(e,t)=>{if(!e.expression)return null;try{let n=e.expression.evaluate(t,_,oe);return typeof n==`number`&&Number.isFinite(n)?n:null}catch{return null}},ce=e=>Math.max(p,Math.min(m,e)),le=(m-p)/100,ue=e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=Math.max(0,Math.min(1,(e.clientX-t.left)/t.width));s(p+n*(m-p))},de=e=>{let t=e.shiftKey?10:1,n=o;if(e.key===`ArrowRight`)n=(o??(p+m)/2)+le*t;else if(e.key===`ArrowLeft`)n=(o??(p+m)/2)-le*t;else if(e.key===`Home`)n=p;else if(e.key===`End`)n=m;else return;e.preventDefault(),s(ce(n))},fe=a||o===null?null:ce(o),pe=fe===null?r(`Range [${Ap(p)}, ${Ap(m)}] · ${h} samples; use arrow keys or pointer to read values`,`区间 [${Ap(p)}, ${Ap(m)}] · ${h} 个采样点;用方向键或指针读取数值`):`${r(`x = ${Ap(fe)}; `,`x = ${Ap(fe)};`)}${T.map((e,t)=>{let n=se(e,fe),i=e.error?r(`cannot compute`,`无法计算`):n===null?r(`undefined`,`无定义`):Ap(n);return r(`Curve ${t+1}: `,`曲线 ${t+1}:`)+i}).join(r(`; `,`;`))}`,me=fe===null?null:T.map((e,t)=>{let n=se(e,fe);return n===null||!e.expression?null:(0,Z.jsx)(`circle`,{className:`local-visual-active-point`,cx:P(fe),cy:te(n),r:4.5,style:{fill:mp[t%mp.length],stroke:`var(--surface)`},strokeWidth:1.5},`active-${t}`)});return(0,Z.jsxs)(em,{className:`local-visual-plot`,label:u,children:[a?null:(0,Z.jsx)(`div`,{className:`local-visual-readout`,id:l,"aria-live":`polite`,children:pe}),(0,Z.jsx)(`div`,{className:`local-visual-svg-wrap`,children:(0,Z.jsxs)(`svg`,{className:`local-visual-svg`,viewBox:`0 0 ${_p} ${vp}`,role:`group`,"aria-label":r(`${u}, range ${Ap(p)} to ${Ap(m)}, ${h} samples`,`${u},区间 ${Ap(p)} 到 ${Ap(m)},${h} 个采样点`),"aria-describedby":a?void 0:l,tabIndex:a?void 0:0,onPointerMove:a?void 0:ue,onPointerLeave:a?void 0:()=>s(null),onFocus:a?void 0:()=>s(e=>e??(p+m)/2),onBlur:a?void 0:()=>s(null),onKeyDown:a?void 0:de,children:[j.map(e=>(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`line`,{className:`local-visual-grid-line`,x1:N,x2:506,y1:te(e),y2:te(e)}),(0,Z.jsx)(`text`,{className:`local-visual-axis-label`,x:N-6,y:te(e),textAnchor:`end`,dominantBaseline:`middle`,children:jp(e)})]},`y-${e}`)),A.min<0&&A.max>0?(0,Z.jsx)(`line`,{className:`local-visual-zero-line`,x1:N,x2:506,y1:te(0),y2:te(0)}):null,(0,Z.jsx)(`line`,{className:`local-visual-axis-line`,x1:N,x2:506,y1:274,y2:274}),M.map(e=>(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`line`,{className:`local-visual-tick`,x1:P(e),x2:P(e),y1:274,y2:279}),(0,Z.jsx)(`text`,{className:`local-visual-axis-label`,x:P(e),y:293,textAnchor:`middle`,children:jp(e)})]},`x-${e}`)),d?(0,Z.jsx)(`text`,{className:`local-visual-axis-title`,x:(N+506)/2,y:318,textAnchor:`middle`,children:d}):null,f?(0,Z.jsx)(`text`,{className:`local-visual-axis-title`,transform:`translate(12 145) rotate(-90)`,textAnchor:`middle`,children:f}):null,ae.map((e,t)=>e.map((e,n)=>{if(e.length<2)return null;let r=e.map((e,t)=>`${t===0?`M`:`L`} ${P(e.x)} ${te(e.y)}`).join(` `);return(0,Z.jsx)(`path`,{className:`local-visual-plot-line`,d:r,fill:`none`,style:{stroke:mp[t%mp.length]},strokeWidth:2.4,strokeLinejoin:`round`,strokeLinecap:`round`},`curve-${t}-${n}`)})),fe===null?null:(0,Z.jsx)(`line`,{className:`local-visual-guide`,x1:P(fe),x2:P(fe),y1:16,y2:274}),me]})}),(0,Z.jsx)(nm,{notes:E}),O]})}var ym={title:`Task`,start:`Start`,duration:`Duration`,notes:`Notes`},bm={title:`事项`,start:`开始`,duration:`时长`,notes:`说明`};function xm(e){let t=t=>e.includes(t.title)&&e.includes(t.start)&&e.includes(t.duration);return t(ym)?ym:t(bm)?bm:null}function Sm({node:e,runtime:t,render:n,mode:r}){let i=Q(),a=r!==`static`,[o,s]=(0,y.useState)(null),c=t.resetToken(e);(0,y.useEffect)(()=>{s(null)},[c]);let l=Np(t,e.attrs,`title`,``)||i(`Timeline`,`时间轴`),u=Np(t,e.attrs,`unit`,i(`minutes`,`分钟`)),d=Yp(e,t,i);if(!d)return(0,Z.jsx)(em,{className:`local-visual-timeline`,label:l,children:(0,Z.jsx)(tm,{message:i(`timeline body requires a Markdown table.`,`timeline 正文需要一个 Markdown 表格。`),kind:`alert`})});let f=d.headerText.map(e=>e.trim()),p=xm(f),m=p?f.indexOf(p.title):-1,h=p?f.indexOf(p.start):-1,g=p?f.indexOf(p.duration):-1,_=p?f.indexOf(p.notes):-1;if(!p||m<0||h<0||g<0)return(0,Z.jsx)(em,{className:`local-visual-timeline`,label:l,children:(0,Z.jsx)(tm,{message:i(`timeline table requires the "Task", "Start" and "Duration" columns.`,`timeline 表格需要“事项”“开始”“时长”三列,或“Task”“Start”“Duration”三列。`),kind:`alert`})});let v=[],b=[],x=[];if(d.rows.forEach((e,t)=>{let n=e.cells[h],r=e.cells[g],a=n?.numeric??null,o=r?.numeric??null;if(a===null||o===null||a<0||o<0){b.push(t+1);return}let s=Jp(e.cells[m],i)||i(`Task ${t+1}`,`事项 ${t+1}`);x.push({key:`item-${e.index}`,title:s,start:a,duration:o,description:_>=0?e.cells[_]?.children??[]:[],sourceIndex:t})}),b.length>0&&v.push(i(`Rows ${b.join(`, `)} have an invalid start or duration (must be non-negative numbers) and are hidden.`,`第 ${b.join(`、`)} 行的开始或时长不是非负数字,未显示。`)),x.length===0)return(0,Z.jsxs)(em,{className:`local-visual-timeline`,label:l,children:[(0,Z.jsx)(tm,{message:i(`No valid timeline items.`,`没有有效的时间轴事项。`)}),(0,Z.jsx)(nm,{notes:v})]});let S=[...x].sort((e,t)=>e.start-t.start||e.sourceIndex-t.sourceIndex),C=S.reduce((e,t)=>Math.max(e,t.start+t.duration),0),w=Math.max(1,C),T=Bp(0,w,5);(T.length===0||T[0]!==0)&&T.unshift(0),T[T.length-1]<w&&T.push(w);let E=u?` ${u}`:``,D=e=>`${Ap(e)}${E}`,O=S.find(e=>e.key===o)??null;return(0,Z.jsxs)(em,{className:`local-visual-timeline${a?``:` local-static-timeline`}`,label:l,children:[(0,Z.jsx)(`div`,{className:`local-visual-timeline-axis`,"aria-hidden":`true`,children:T.map((e,t)=>{let n=e/w*100,r=t===T.length-1?{left:`${n}%`,transform:`translateX(-100%)`}:t===0?{left:`0%`}:{left:`${n}%`,transform:`translateX(-50%)`};return(0,Z.jsx)(`span`,{className:`local-visual-timeline-tick`,style:r,children:jp(e)},`tick-${e}`)})}),(0,Z.jsx)(`ol`,{className:`local-visual-timeline-list`,children:S.map(e=>{let t=e.start+e.duration,r=e.start/w*100,c=e.duration/w*100,l=S.indexOf(e);return(0,Z.jsxs)(`li`,{className:`local-visual-timeline-item${a&&o===e.key?` is-active`:``}${a?``:` local-static-timeline-item`}`,tabIndex:a?0:void 0,"aria-label":a?i(`${e.title}, started ${D(e.start)}, ended ${D(t)}, duration ${D(e.duration)}${e.description.length>0?`, with notes`:``}`,`${e.title},开始 ${D(e.start)},结束 ${D(t)},时长 ${D(e.duration)}${e.description.length>0?`,有说明`:``}`):void 0,onFocus:a?()=>s(e.key):void 0,onBlur:a?()=>s(t=>t===e.key?null:t):void 0,onPointerEnter:a?()=>s(e.key):void 0,onPointerLeave:a?()=>s(t=>t===e.key?null:t):void 0,onKeyDown:a?e=>{e.key===`Escape`&&(e.preventDefault(),s(null))}:void 0,children:[(0,Z.jsxs)(`div`,{className:`local-visual-timeline-head`,children:[(0,Z.jsxs)(`span`,{className:`local-visual-timeline-title`,children:[(0,Z.jsx)(`span`,{className:`local-visual-swatch`,style:{backgroundColor:mp[l%mp.length]},"aria-hidden":`true`}),e.title]}),(0,Z.jsxs)(`span`,{className:`local-visual-timeline-times`,children:[i(`Started`,`开始`),` `,D(e.start),` · `,i(`Ended`,`结束`),` `,D(t),` · `,i(`Duration`,`时长`),` `,D(e.duration)]})]}),(0,Z.jsx)(`div`,{className:`local-visual-timeline-track`,"aria-hidden":`true`,children:(0,Z.jsx)(`span`,{className:`local-visual-timeline-bar${e.duration===0?` is-zero`:``}`,style:{left:`${r}%`,width:`${c}%`,backgroundColor:mp[l%mp.length]}})}),a||e.description.length===0?null:(0,Z.jsx)(`div`,{className:`local-visual-timeline-detail local-static-timeline-detail`,children:n(e.description)})]},e.key)})}),a?(0,Z.jsx)(`div`,{className:`local-visual-timeline-detail`,"aria-live":`polite`,children:O?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`strong`,{children:O.title}),O.description.length>0?n(O.description):(0,Z.jsx)(`span`,{children:i(`No notes.`,`没有说明。`)})]}):(0,Z.jsx)(`span`,{children:i(`Focus or point at an item to view its notes.`,`聚焦或指向事项查看说明。`)})}):null,(0,Z.jsx)(nm,{notes:v})]})}var Cm=/[\u1100-\u115f\u2e80-\u303f\u3040-\u33ff\u3400-\u4dbf\u4e00-\u9fff\uac00-\ud7af\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/u;function wm(e){let t=0;for(let n of e)Cm.test(n)?t+=1:/\s/u.test(n)?t+=.3:t+=.58;return t*Cp}function Tm(e,t){if(wm(e)<=t)return e;let n=``;for(let r of e){if(wm(`${n}${r}…`)>t)break;n+=r}return`${n.trimEnd()}…`}function Em(e){let t=[],n=``;for(let r of e)n&&wm(n+r)>Tp?(t.push(n),n=r):n+=r;if(n&&t.push(n),t.length<=Ep)return t;let r=t.slice(0,Ep);return r[1]=Tm(t.slice(1).join(``),Tp),r}function Dm(e){let t=Em(e);return{width:t.reduce((e,t)=>Math.max(e,wm(t)),0)+10,height:t.length*Dp+6,lines:t}}function Om(e){let t=new Map;for(let n of e){let e=`${n.from}\u0000${n.to}`;t.set(e,(t.get(e)??0)+1)}let n=new Map,r=new Map;for(let i of e){let e=`${i.from}\u0000${i.to}`,a=t.get(e)??1,o=n.get(e)??0;n.set(e,o+1),r.set(i.key,(o-(a-1)/2)*12)}return r}function km(e,t,n){let{width:r,height:i,positions:a}=e,o=Om(t),s=1/0,c=1/0,l=-1/0,u=-1/0;for(let e of t){if(!e.label)continue;let t=a.get(e.from),r=a.get(e.to);if(!t||!r)continue;let i=jm(n,t,r,o.get(e.key)??0,e.from===e.to),d=Dm(e.label);s=Math.min(s,i.labelX-d.width/2),c=Math.min(c,i.labelY-d.height/2),l=Math.max(l,i.labelX+d.width/2),u=Math.max(u,i.labelY+d.height/2)}if(!Number.isFinite(s))return e;let d=Math.max(0,wp-s),f=Math.max(0,wp-c),p=Math.max(0,l+wp-r),m=Math.max(0,u+wp-i);if(d===0&&f===0&&p===0&&m===0)return e;for(let e of a.values())e.x+=d,e.y+=f;return{width:r+d+p,height:i+f+m,positions:a}}function Am(e,t,n){let r=e.map(e=>e.id),i=new Map(r.map((e,t)=>[e,t])),a=new Set(r),o=new Map(r.map(e=>[e,[]]));for(let e of t)e.from!==e.to&&a.has(e.from)&&a.has(e.to)&&o.get(e.from).push(e.to);let s=new Map,c=new Map,l=new Set,u=[],d=[],f=0,p=e=>{s.set(e,f),c.set(e,f),f+=1,u.push(e),l.add(e);for(let t of o.get(e)??[])s.has(t)?l.has(t)&&c.set(e,Math.min(c.get(e),s.get(t))):(p(t),c.set(e,Math.min(c.get(e),c.get(t))));if(c.get(e)===s.get(e)){let t=[],n;do n=u.pop(),l.delete(n),t.push(n);while(n!==e);d.push(t.reverse())}};for(let e of r)s.has(e)||p(e);let m=new Map;d.forEach((e,t)=>{for(let n of e)m.set(n,t)});let h=d.map(()=>new Set),g=d.map(()=>0);for(let e of t){if(!a.has(e.from)||!a.has(e.to))continue;let t=m.get(e.from),n=m.get(e.to);t===n||h[t].has(n)||(h[t].add(n),g[n]+=1)}let _=d.map((e,t)=>({index:t,order:Math.min(...e.map(e=>i.get(e)??0))})),v=_.filter(e=>g[e.index]===0).map(e=>e.index).sort((e,t)=>_[e].order-_[t].order),y=d.map(()=>0);for(;v.length>0;){let e=v.shift();for(let t of h[e])y[t]=Math.max(y[t],y[e]+1),--g[t],g[t]===0&&v.push(t)}let b=Math.max(1,...y)+1,x=Array.from({length:b},()=>[]);for(let e of r)x[y[m.get(e)]].push(e);let S=x.filter(e=>e.length>0),C=Math.max(1,...S.map(e=>e.length)),w=new Map,T,E;if(n===`down`)T=yp,E=Math.max(240,106+(S.length-1)*120),S.forEach((e,t)=>{let n=53+t*120;e.forEach((t,r)=>{let i=e.length===1?T/2:104+r*((T-88-bp)/(e.length-1));w.set(t,{x:i,y:n})})});else{let e=t.reduce((e,t)=>t.label?Math.max(e,Dm(t.label).width):e,0),n=Math.max(Sp,bp+(e>0?e+24:0));T=Math.max(yp,208+(S.length-1)*n),E=Math.max(240,106+(C-1)*74),S.forEach((e,t)=>{let n=S.length===1?T/2:104+t*((T-88-bp)/(S.length-1));e.forEach((t,r)=>{let i=e.length===1?E/2:53+r*((E-60-xp)/(e.length-1));w.set(t,{x:n,y:i})})})}return km({width:T,height:E,positions:w},t,n)}function jm(e,t,n,r,i){let a=bp,o=xp;if(i)return e===`right`?{d:`M ${t.x+20} ${t.y-o/2} C ${t.x+64} ${t.y-o/2-64}, ${t.x-64} ${t.y-o/2-64}, ${t.x-20} ${t.y-o/2}`,labelX:t.x,labelY:t.y-o/2-46}:{d:`M ${t.x+a/2} ${t.y-10} C ${t.x+a/2+64} ${t.y-54}, ${t.x+a/2+64} ${t.y+54}, ${t.x+a/2} ${t.y+10}`,labelX:t.x+a/2+44,labelY:t.y};if(e===`right`){if(n.x>t.x){let e=t.x+a/2,i=t.y+r,o=n.x-a/2,s=n.y+r;return{d:`M ${e} ${i} L ${o} ${s}`,labelX:(e+o)/2,labelY:(i+s)/2-12}}let e=t.x+r,i=n.x+r,s=t.y+o/2,c=n.y-o/2,l=Math.max(70,Math.abs(i-e)*.45);return{d:`M ${e} ${s} C ${e+l} ${s+86}, ${i-l} ${c+86}, ${i} ${c}`,labelX:(e+i)/2,labelY:Math.max(s,c)+48}}if(n.y>t.y){let e=t.x+r,i=n.x+r,a=t.y+o/2,s=n.y-o/2;return{d:`M ${e} ${a} L ${i} ${s}`,labelX:(e+i)/2+10,labelY:(a+s)/2}}let s=t.x+a/2,c=n.x-a/2,l=t.y+r,u=n.y+r,d=Math.max(70,Math.abs(u-l)*.45);return{d:`M ${s} ${l} C ${s+86} ${l+d}, ${c+86} ${u-d}, ${c} ${u}`,labelX:Math.max(s,c)+48,labelY:(l+u)/2}}function Mm({node:e,runtime:t,render:n,mode:r}){let i=Q(),a=r!==`static`,[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(null),u=t.resetToken(e);(0,y.useEffect)(()=>{s(null),l(null)},[u]);let d=(0,y.useId)().replace(/[^a-zA-Z0-9_-]/g,``),f=`local-diagram-arrow-${d}`,p=`local-diagram-description-${d}`,m=Np(t,e.attrs,`label`,``)||i(`Diagram`,`图解`),h=(e.attrs?.direction??`right`).trim().toLowerCase()===`down`?`down`:`right`,g=e.children?.filter(e=>e.type===`component`)??[],_=[],v=[],b=new Set;for(let e of g){if(e.name!==`node`)continue;let n=(e.attrs?.id??``).trim();if(!n){_.push(i(`Ignored a node without an id.`,`已忽略缺少 id 的节点。`));continue}if(b.has(n)){_.push(i(`Duplicate node id ${n}; ignored the later node.`,`节点 id 重复(${n}),已忽略后一个节点。`));continue}b.add(n);let r=Np(t,e.attrs,`tone`,`neutral`).trim(),a=r===`success`||r===`warning`?r:`neutral`;v.push({id:n,label:Np(t,e.attrs,`label`,n)||n,tone:a,children:e.children??[]})}let x=[],S=new Set;for(let e of g){if(e.name!==`edge`)continue;let n=(e.attrs?.from??``).trim(),r=(e.attrs?.to??``).trim();if(!n||!r||!b.has(n)||!b.has(r)){_.push(i(`Edge ${n||`?`} → ${r||`?`} references a missing endpoint; ignored.`,`连线 ${n||`?`} → ${r||`?`} 缺少端点,已忽略。`));continue}let a=Np(t,e.attrs,`label`,``),o=`${n}\u0000${r}\u0000${a}`;S.has(o)?_.push(i(`Duplicate edge: ${n} → ${r}${a?` (${a})`:``}; ignored.`,`重复连线:${n} → ${r}${a?`(${a})`:``},已忽略。`)):(S.add(o),x.push({key:o,from:n,to:r,label:a}))}if(v.length===0)return(0,Z.jsxs)(em,{className:`local-visual-diagram`,label:m,children:[(0,Z.jsx)(tm,{message:`diagram requires at least one node.`,kind:`alert`}),(0,Z.jsx)(nm,{notes:_})]});let C=null;try{let n=t.get(e);typeof n==`string`&&(C=n)}catch{C=null}let w=new Set(v.map(e=>e.id)),T=(e.attrs?.initial??``).trim(),E=T&&w.has(T)?T:v[0].id,D=C&&w.has(C)?C:o&&w.has(o)?o:E,O=v.find(e=>e.id===D)??v[0],k=C&&w.has(C)?C:T&&w.has(T)?T:null,A=n=>{s(n),l(null);try{let r=t.set(e,n);r.length>0&&l(r.map(e=>i(tt(e,`en`),tt(e,`zh`))).join(`; `))}catch(e){l(Mp(e))}},j=Am(v,x,h),M=Om(x),N=[],ee=[];for(let e of x){let t=j.positions.get(e.from),n=j.positions.get(e.to);if(!t||!n)continue;let r=jm(h,t,n,M.get(e.key)??0,e.from===e.to);if(N.push((0,Z.jsx)(`g`,{className:`local-visual-edge`,children:(0,Z.jsx)(`path`,{d:r.d,fill:`none`,style:{stroke:`var(--ink-muted)`},strokeWidth:1.6,markerEnd:`url(#${f})`})},`edge-${e.key}`)),!e.label)continue;let i=Dm(e.label);ee.push((0,Z.jsx)(`g`,{className:`local-visual-edge-label-group`,children:(0,Z.jsx)(`text`,{className:`local-visual-edge-label`,x:r.labelX,y:r.labelY,textAnchor:`middle`,dominantBaseline:`middle`,children:i.lines.map((e,t)=>(0,Z.jsx)(`tspan`,{x:r.labelX,y:r.labelY+(t-(i.lines.length-1)/2)*Dp,children:e},t))})},`edge-label-${e.key}`))}return(0,Z.jsxs)(em,{className:`local-visual-diagram${a?``:` local-static-diagram`}`,label:m,children:[(0,Z.jsx)(`div`,{className:`local-visual-svg-wrap`,children:(0,Z.jsxs)(`svg`,{className:`local-visual-svg local-visual-diagram-svg`,viewBox:`0 0 ${j.width} ${j.height}`,role:`group`,"aria-label":a?`${m}, with ${v.length} nodes and ${x.length} edges; press Tab to focus a node and Enter to select`:i(`${m}, with ${v.length} nodes and ${x.length} edges`,`${m},共 ${v.length} 个节点、${x.length} 条连线`),"aria-describedby":p,children:[(0,Z.jsx)(`defs`,{children:(0,Z.jsx)(`marker`,{id:f,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,style:{fill:`var(--ink-muted)`}})})}),N,v.map(e=>{let t=j.positions.get(e.id);if(!t)return null;let n=a?e.id===D:k!==null&&e.id===k,r=Rp(e.label,8,2);return(0,Z.jsxs)(`g`,{className:`local-visual-node local-visual-node-${e.tone}${n?` is-selected`:``}`,"data-diagram-node":a?``:void 0,transform:`translate(${t.x} ${t.y})`,role:a?`button`:void 0,tabIndex:a?0:void 0,"aria-pressed":a?n:void 0,"aria-label":a?e.label:void 0,onClick:a?()=>A(e.id):void 0,onKeyDown:a?t=>{Wp(t)?(t.preventDefault(),A(e.id)):t.key===`ArrowRight`||t.key===`ArrowDown`?Up(t,`[data-diagram-node]`,1):(t.key===`ArrowLeft`||t.key===`ArrowUp`)&&Up(t,`[data-diagram-node]`,-1)}:void 0,children:[(0,Z.jsx)(`title`,{children:e.label}),(0,Z.jsx)(`rect`,{className:`local-visual-node-shape`,x:-60,y:-23,width:bp,height:xp,rx:10}),(0,Z.jsx)(`text`,{className:`local-visual-node-text`,textAnchor:`middle`,children:r.map((e,t)=>(0,Z.jsx)(`tspan`,{x:0,y:(t-(r.length-1)/2)*16+4,children:e},t))})]},`node-${e.id}`)}),ee]})}),a?(0,Z.jsx)(`div`,{className:`local-visual-diagram-detail`,"aria-live":`polite`,children:O?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`strong`,{children:O.label}),O.children.length>0?n(O.children):(0,Z.jsx)(`span`,{children:i(`This node has no description.`,`此节点没有说明。`)})]}):(0,Z.jsx)(`span`,{children:i(`Click a node, or focus it with Tab and press Enter, to view its description.`,`点击节点,或用 Tab 聚焦后按 Enter 查看说明。`)})}):(0,Z.jsx)(`div`,{className:`local-visual-diagram-detail local-static-diagram-detail`,children:(0,Z.jsx)(`dl`,{className:`local-static-diagram-nodes`,children:v.map(e=>(0,Z.jsxs)(`div`,{className:`local-static-diagram-node`,children:[(0,Z.jsx)(`dt`,{children:e.label}),(0,Z.jsx)(`dd`,{children:e.children.length>0?n(e.children):(0,Z.jsx)(`span`,{children:i(`This node has no description.`,`此节点没有说明。`)})})]},`static-node-${e.id}`))})}),(0,Z.jsxs)(`ul`,{id:p,className:`local-visual-sr-only`,"aria-label":i(`Nodes and edges`,`节点与连线`),children:[v.map(e=>(0,Z.jsx)(`li`,{children:e.label},`description-node-${e.id}`)),x.map(e=>{let t=v.find(t=>t.id===e.from),n=v.find(t=>t.id===e.to);return(0,Z.jsxs)(`li`,{children:[t?.label??e.from,` → `,n?.label??e.to,e.label?` (${e.label})`:``]},`description-edge-${e.key}`)})]}),c?(0,Z.jsx)(tm,{message:c,kind:`alert`}):null,(0,Z.jsx)(nm,{notes:_})]})}function Nm(e){let t={...e,mode:e.mode??`interactive`};switch(t.node.name){case`table`:return(0,Z.jsx)(im,{...t});case`chart`:return(0,Z.jsx)(sm,{...t});case`plot`:return(0,Z.jsx)(vm,{...t});case`timeline`:return(0,Z.jsx)(Sm,{...t});case`diagram`:return(0,Z.jsx)(Mm,{...t});default:return null}}var Pm=class extends Error{failure;constructor(e){super(e),this.name=`DataTableFailureError`,this.failure=e}};function Fm(e){return e===null?``:typeof e==`string`?e:typeof e==`number`?Number.isFinite(e)?String(e):null:typeof e==`boolean`?e?`true`:`false`:null}function Im(e){return typeof e==`string`?e===``?null:`s:${e}`:typeof e==`number`&&Number.isFinite(e)?`n:${e===0?0:e}`:null}function Lm(e,t,n){let r={...n};for(let i of t)Object.hasOwn(n,i)||Object.defineProperty(r,i,{enumerable:!0,configurable:!0,get(){return e.evaluate(i)}});return r}function Rm(e){if(e.length===0)return null;let t=typeof e[0];if(t!==`string`&&t!==`number`)return`rows`;for(let n of e)if(typeof n!==t||typeof n==`number`&&!Number.isFinite(n))return`rows`;return null}function zm(e,t){let n;try{n=Yt(t)}catch{throw new Pm(`rows`)}let r;try{r=n.evaluate(Lm(e,n.dependencies,{}))}catch{throw new Pm(`rows`)}if(!Array.isArray(r))throw new Pm(`rows`);let i=Rm(r);if(i)throw new Pm(i);return r}function Bm(e){let{rows:t,columns:n,keyExpression:r,runtime:i}=e,a=e.maxRows??100,o=e.budget??1e5;if(!Number.isSafeInteger(a)||a<=0||a>1e3)return{ok:!1,failure:`max-rows`};if(n.length<1||n.length>20)return{ok:!1,failure:`columns`};let s=Rm(t);if(s)return{ok:!1,failure:s};if(t.length>a)return{ok:!1,failure:`rows-budget`};let c;try{c=Yt(r)}catch{return{ok:!1,failure:`key`}}let l=c.dependencies;if(l.length!==1||l[0]!==`item`)return{ok:!1,failure:`key`};let u=n.map(e=>{try{return{spec:e,expression:Yt(e.value)}}catch{return{spec:e,expression:null}}}),d=0;for(let e of n)d+=e.label.length;if(t.length===0&&(d+=7),d>o)return{ok:!1,failure:`text-budget`};let f=e=>{if(d+=e,d>o)throw new Pm(`text-budget`)},p=new Set,m=[];try{for(let e=0;e<t.length;e+=1){let n={item:t[e],index:e},r=null;try{r=Im(c.evaluate(n))}catch{return{ok:!1,failure:`key`}}if(r===null||p.has(r))return{ok:!1,failure:`key`};f(r.length),p.add(r);let a=[];for(let e of u){if(!e.expression){f(14),a.push({ok:!1,text:``});continue}let t=null;try{t=Fm(e.expression.evaluate(Lm(i,e.expression.dependencies,n)))}catch{t=null}t===null?(f(14),a.push({ok:!1,text:``})):(f(t.length),a.push({ok:!0,text:t}))}m.push({key:r,cells:a})}}catch(e){return e instanceof Pm?{ok:!1,failure:e.failure}:{ok:!1,failure:`rows`}}return{ok:!0,model:{columns:n.map(e=>e.label),rows:m,empty:t.length===0}}}function Vm(e,t){switch(t){case`label`:return e(`Data table requires a label.`,`数据表需要标签。`);case`columns`:return e(`Data table requires between 1 and 20 column definitions.`,`数据表需要 1 到 20 个列定义。`);case`max-rows`:return e(`max-rows must be a positive integer no greater than ${A}.`,`max-rows 必须是 1 到 ${A} 之间的整数。`);case`rows`:return e(`Rows must evaluate to a list.`,`行数据必须计算为列表。`);case`rows-budget`:return e(`Too many rows for this table.`,`此数据表的行数超过上限。`);case`key`:return e(`Every row needs a unique, non-empty key.`,`每一行都需要唯一且非空的键。`);case`text-budget`:return e(`The table content exceeds the text budget.`,`数据表内容超过文本上限。`)}}var Hm=/^\s*\{\{([\s\S]*)\}\}\s*$/;function Um(e){if(e===void 0)return null;let t=Hm.exec(e),n=t?t[1].trim():``;return n===``?null:n}function Wm(e){return e.type===`comment`||e.type===`text`&&(e.value??``).trim()===``||e.type===`paragraph`&&!e.children?.length&&(e.value??``).trim()===``}function Gm(e){let t=(e.attrs?.label??``).trim();if(t===``)return{ok:!1,failure:`label`};let n=Um(e.attrs?.rows);if(!n)return{ok:!1,failure:`rows`};let r=Um(e.attrs?.key);if(!r)return{ok:!1,failure:`key`};let i=e.attrs?.[`max-rows`],a=100;if(i!==void 0&&(!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(i.trim())||(a=Number(i.trim()),!Number.isSafeInteger(a)||a<=0||a>1e3)))return{ok:!1,failure:`max-rows`};let o=(e.children??[]).filter(e=>!Wm(e)),s=[];for(let e of o){let t=(e.children??[]).filter(e=>!Wm(e));if(e.type!==`component`||e.name!==`column`||t.length>0)return{ok:!1,failure:`columns`};let n=(e.attrs?.label??``).trim(),r=Um(e.attrs?.value);if(n===``||!r)return{ok:!1,failure:`columns`};s.push({label:n,value:r})}return s.length<1||s.length>20?{ok:!1,failure:`columns`}:{ok:!0,table:{label:t,rows:n,key:r,maxRows:a,columns:s}}}function Km({node:e,runtime:t,t:n}){let r=Gm(e);if(!r.ok)return(0,Z.jsx)(`div`,{className:`local-error local-data-table-error`,role:`alert`,children:Vm(n,r.failure)});let i;try{i=Bm({rows:zm(t,r.table.rows),columns:r.table.columns,keyExpression:r.table.key,maxRows:r.table.maxRows,runtime:t})}catch(e){i={ok:!1,failure:e instanceof Pm?e.failure:`rows`}}if(!i.ok)return(0,Z.jsx)(`div`,{className:`local-error local-data-table-error`,role:`alert`,children:Vm(n,i.failure)});let{model:a}=i;return(0,Z.jsx)(`div`,{className:`md-table-scroll local-data-table-scroll`,"data-local-data-table":``,children:(0,Z.jsxs)(`table`,{className:`md-table local-data-table`,"aria-label":r.table.label,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsx)(`tr`,{children:a.columns.map((e,t)=>(0,Z.jsx)(`th`,{scope:`col`,children:e},`column-${t}`))})}),(0,Z.jsx)(`tbody`,{children:a.empty?(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{className:`local-data-table-empty`,colSpan:a.columns.length,children:n(`No rows`,`没有数据`)})}):a.rows.map(e=>(0,Z.jsx)(`tr`,{children:e.cells.map((e,t)=>(0,Z.jsx)(`td`,{children:e.ok?e.text:(0,Z.jsx)(`span`,{className:`local-error local-data-table-cell-error`,children:n(`Cannot compute`,`无法计算`)})},`cell-${t}`))},e.key))})]})})}var qm=(0,y.createContext)(null);function $(){let e=(0,y.useContext)(qm);if(!e)throw Error(`LocalViewContext is not initialized`);return e}var Jm=`local.validation.failed`,Ym=`local.validation.expression`,Xm=2e3,Zm={invalid:!1},Qm={hintFor:()=>null,fieldFor:()=>Zm};function $m(e){return`${e.start}:${e.end}`}function eh(e){return e.length>Xm?`${e.slice(0,1999)}…`:e}function th(e,t,n,r){let i=Array.isArray(e.validations)?e.validations:[];if(i.length===0)return Qm;let a=null;try{typeof t.validate==`function`&&(a=t.validate())}catch{a=null}let o=new Map;for(let e of a??[])(e.code===Jm||e.code===Ym)&&o.set($m(e.range),e);let s=new Map,c=new Map,l=new Map,u=r(`This rule cannot be evaluated`,`无法计算此规则`),d=r(`Validation failed.`,`校验未通过。`);for(let[t,r]of i.entries()){let i=$m(r.range),f=o.get(i),p=a===null||f?.code===Ym,m=f?.code===Jm,h=m?eh(f?.message||r.message||d):p?f?.message?`${u}: ${eh(f.message)}`:u:``,g={id:`${n}-validation-${t}`,failed:m,error:p,message:h};if(s.set(r.nodeId,g),c.set(i,g),m||p)for(let t of r.fields??[]){let n=Object.hasOwn(e.bindings,t)?e.bindings[t]:void 0;if(n)for(let e of n.nodeIds??[]){let t=l.get(e);t?t.includes(g.id)||t.push(g.id):l.set(e,[g.id])}}}return{hintFor(e){return c.get($m(e.range))??s.get(e.id)??null},fieldFor(e){let t=l.get(e.id);return t&&t.length>0?{describedBy:t.join(` `),invalid:!0}:Zm}}}function nh(e){return $().validation.fieldFor(e)}var rh=/^\s*\{\{([\s\S]*)\}\}\s*$/,ih={revision:0,state:{}};function ah(e,t){return e.attrs?.[t]}function oh(e,t,n){let r=ah(t,n);if(r===void 0)return{present:!1};let i=rh.exec(r);if(!i)return{present:!0,ok:!0,value:r};try{return{present:!0,ok:!0,value:e.evaluate(i[1])}}catch{return{present:!0,ok:!1}}}function sh(e){return e===null?``:typeof e==`string`?e:typeof e==`number`?Number.isFinite(e)?String(e):null:typeof e==`boolean`?e?`true`:`false`:null}function ch(e,t,n,r=``,i=lp){let a=ah(t,n);if(a===void 0)return r;let o=rh.exec(a);try{return o?sh(e.evaluate(o[1]))??i(`Cannot compute`,`无法计算`):e.text(a)}catch{return i(`Cannot compute`,`无法计算`)}}function lh(e,t,n,r){let i=ah(t,n);if(i===void 0)return{ok:!0,value:r};let a=rh.exec(i);if(!a)return{ok:!0,value:i===`true`};try{let t=e.evaluate(a[1]);return typeof t==`boolean`?{ok:!0,value:t}:{ok:!1}}catch{return{ok:!1}}}function uh(e,t,n,r=!1){let i=lh(e,t,n,r);return i.ok?i.value:r}function dh(e,t,n,r,i){let a=ah(t,n);if(a===void 0)return{tone:i,error:!1};let o=rh.exec(a);if(!o){let e=a.trim();return{tone:r.includes(e)?e:i,error:!1}}try{let t=e.evaluate(o[1]);return typeof t==`string`&&r.includes(t)?{tone:t,error:!1}:{tone:i,error:!0}}catch{return{tone:i,error:!0}}}function fh(e){try{return e.snapshot().revision}catch{return 0}}function ph(e,t,n,r){let i=ah(t,n);if(i===void 0)return r;let a=rh.exec(i);try{let t=a?e.evaluate(a[1]):Number(i);return typeof t==`number`&&Number.isFinite(t)?t:r}catch{return r}}function mh(e,t){try{return e.get(t)}catch{return null}}function hh(e){return sh(e)??``}var gh=`—`;function _h(e){return e.trim()===``?gh:e}function vh({label:e,value:t,hint:n,className:r=``,multiline:i=!1}){return(0,Z.jsxs)(`div`,{className:`md-control local-static-control ${r}`.trim(),children:[(0,Z.jsx)(`span`,{className:`md-label`,children:e}),(0,Z.jsx)(`span`,{className:`local-static-value${i?` local-static-multiline`:``}`,"data-local-static-value":``,children:t}),n?(0,Z.jsx)(`span`,{className:`md-hint`,children:n}):null]})}function yh({value:e,block:t=!1}){return t?(0,Z.jsx)(`div`,{className:`local-print-value local-print-block`,"aria-hidden":`true`,"data-local-print-value":``,children:e}):(0,Z.jsx)(`span`,{className:`local-print-value`,"aria-hidden":`true`,"data-local-print-value":``,children:e})}function bh(e){let t=ah(e,`color`);if(t===void 0)return;let n=t.trim();return n!==``&&qn(n)?n:void 0}function xh(e){if(e)return{"--local-accent":e,"--local-accent-soft":`color-mix(in srgb, ${e} 14%, var(--surface))`,"--local-accent-strong":e}}var Sh=`(prefers-color-scheme: dark)`;function Ch(e){if(!Array.isArray(e)||e.length===0)return``;try{return e.map(e=>{if(!e||typeof e!=`object`)return``;let t=Array.isArray(e.colorSchemes)?e.colorSchemes.join(``):``;return`${e.name}\u0000${e.protocol}\u0000${t}`}).join(``)}catch{return``}}function wh(e){return e.map(e=>`${e.code}\u0000${e.range.start}\u0000${e.range.end}\u0000${e.message}`).join(``)}function Th(e){return e===`light`||e===`dark`?e:null}function Eh(e){let t=Th(e.getAttribute(`data-theme`));if(t)return t;let n=e.parentElement;for(;n;){let e=Th(n.getAttribute(`data-color-scheme`))??Th(n.getAttribute(`data-theme`));if(e)return e;n=n.parentElement}return null}function Dh(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return null;try{return window.matchMedia(Sh).matches?`dark`:`light`}catch{return null}}function Oh(e,t){let n=Th(t),[r,i]=(0,y.useState)(`light`);return(0,y.useEffect)(()=>{if(n){i(n);return}let t=e.current;if(!t||typeof window>`u`){i(`light`);return}let r=()=>i(Eh(t)??Dh()??`light`);r();let a=[];if(typeof MutationObserver==`function`)try{let e=(e,t)=>{let n=new MutationObserver(r);n.observe(e,{attributes:!0,attributeFilter:t}),a.push(n)};e(t,[`data-theme`]);let n=t.parentElement;for(;n;)e(n,[`data-color-scheme`,`data-theme`]),n=n.parentElement}catch{for(let e of a)e.disconnect();a=[]}let o=()=>r(),s=null;if(typeof window.matchMedia==`function`)try{s=window.matchMedia(Sh),typeof s.addEventListener==`function`?s.addEventListener(`change`,o):typeof s.addListener==`function`&&s.addListener(o)}catch{s=null}return()=>{for(let e of a)e.disconnect();s&&(typeof s.removeEventListener==`function`?s.removeEventListener(`change`,o):typeof s.removeListener==`function`&&s.removeListener(o))}},[n,e]),n??r}function kh(e,t,n){return Math.min(n,Math.max(t,e))}function Ah(e,t,n,r){let i=Number.isFinite(r)&&r>0?r:1,a=Math.max(0,Math.floor((n-t)/i+1e-9)),o=t+Math.max(0,Math.min(a,Math.round((e-t)/i)))*i;return Number(o.toPrecision(15))}function jh(e,t,n,r){try{let i=e.get(t,n);return typeof i==`number`&&Number.isFinite(i)?i:r}catch{return r}}function Mh(e,t,n,r,i,a,o=1){let s=ph(e,t,n,i),c=ph(e,t,r,a);s>c&&([s,c]=[c,s]);let l=ph(e,t,`step`,o);return{min:s,max:c,step:Number.isFinite(l)&&l>0?l:1}}function Nh(e){let{runtime:t,report:n}=$(),r=fp(),i=Q(),[a,o]=(0,y.useState)(null);return{write:(0,y.useCallback)((a,s)=>{try{let i=t.set(e,a,s);return i.length?(o(i.map(e=>tt(e,r)).join(`; `)),n(i),!1):(o(null),!0)}catch(e){return o(e instanceof Error?e.message:i(`Cannot write`,`无法写入`)),!1}},[r,e,n,t,i]),writeMany:(0,y.useCallback)(a=>{try{let i=t.setMany(e,a);return i.length?(o(i.map(e=>tt(e,r)).join(`; `)),n(i),!1):(o(null),!0)}catch(e){return o(e instanceof Error?e.message:i(`Cannot write`,`无法写入`)),!1}},[r,e,n,t,i]),error:a,setError:o}}function Ph(e){let{runtime:t}=$(),n=lh(t,e,`disabled`,!1);return n.ok?{disabled:n.value,invalid:!1}:{disabled:!0,invalid:!0}}function Fh(e,t,n){let r=0;try{r=e.resetToken(t)}catch{r=0}let i=(0,y.useRef)(r),a=(0,y.useRef)(n);a.current=n,(0,y.useEffect)(()=>{i.current!==r&&(i.current=r,a.current())},[r])}function Ih({message:e}){let t=Q();return(0,Z.jsx)(`span`,{className:`local-error`,role:`alert`,children:e??t(`Cannot compute`,`无法计算`)})}var Lh=class extends y.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidUpdate(e){this.state.failed&&e.revision!==this.props.revision&&this.setState({failed:!1})}render(){return this.state.failed?(0,Z.jsx)(Ih,{}):this.props.children}},Rh=new Set([`table`,`chart`,`plot`,`timeline`,`diagram`]);function zh(e,t,n){if(!e)return null;let r=e.trim();if(!r)return null;let i=r.replace(/[\u0000- ]+/g,``),a=/^([a-z][a-z0-9+.-]*):/i.exec(i);if(a){let e=a[1].toLowerCase();if(!(t===`image`?e===`http`||e===`https`:e===`http`||e===`https`||e===`mailto`||e===`tel`))return null}if(!n)return t===`image`?null:r;try{return n(r,t)?r:null}catch{return null}}function Bh(e){return`h${Math.min(6,Math.max(1,e??1))}`}function Vh(e,t){if(e.node!==t.node||e.visible!==t.visible||e.resetToken!==t.resetToken||e.env!==t.env||e.depValues===null||t.depValues===null||e.depValues.length!==t.depValues.length)return!1;for(let n=0;n<e.depValues.length;n+=1)if(!Object.is(e.depValues[n],t.depValues[n]))return!1;return!0}var Hh=(0,y.memo)(function({node:e,index:t,visible:n,env:r}){return qh(r,e,t,n,!0)},Vh);function Uh(e,t,n,r=!0){if(!t||t.length===0)return null;if(!r)return t.map((t,r)=>qh(e,t,r,n,!1));let i=null,a=null;try{i=e.runtime.snapshot().state,a=Vn(e.runtime)}catch{i=null}let o=i;return t.map((t,r)=>{let i=e.dependencies.get(t.id),s=i==null||o===null||a===null?null:i.map(e=>o[e]),c=a?.get(t.id)??0;return(0,Z.jsx)(Hh,{node:t,index:r,visible:n,env:e,depValues:s,resetToken:c},t.id||`${t.type}-${r}`)})}function Wh(e,t){if(typeof t.value==`string`)return t.value;let{start:n,end:r}=t.range;return Number.isInteger(n)&&Number.isInteger(r)&&n>=0&&r>=n?e.runtime.document.source.slice(n,r):``}function Gh(e,t,n,r){return(0,Z.jsx)(`span`,{className:r?`local-fallback local-fallback-block`:`local-fallback local-fallback-inline`,title:e.t(`Unsupported syntax shown as source`,`未支持的语法,已按源码原样显示`),"data-local-fallback":``,children:Wh(e,t)},n)}function Kh(e,t,n){return!t||t.length===0?null:t.map((t,r)=>t.type===`paragraph`||t.type===`root`?(0,Z.jsx)(`span`,{children:Uh(e,t.children,n,!1)},t.id||`inline-${r}`):qh(e,t,r,n,!1))}function qh(e,t,n,r,i=!0){let a=t.id||`${t.type}-${n}`;if(t.type===`component`)return(0,Z.jsx)(Lh,{revision:fh(e.runtime),children:Yh(t,r,e.runtime,e.t)},a);switch(t.type){case`root`:return(0,Z.jsx)(`div`,{children:Uh(e,t.children,r)},a);case`heading`:return(0,y.createElement)(Bh(t.depth),{key:a,id:e.anchors.ids.get(t)},Uh(e,t.children,r,!1));case`paragraph`:return(0,Z.jsx)(`p`,{children:Uh(e,t.children,r,!1)},a);case`text`:return(0,Z.jsx)(`span`,{children:t.value??``},a);case`emphasis`:return(0,Z.jsx)(`em`,{children:Uh(e,t.children,r,!1)},a);case`strong`:return(0,Z.jsx)(`strong`,{children:Uh(e,t.children,r,!1)},a);case`delete`:return(0,Z.jsx)(`del`,{children:Uh(e,t.children,r,!1)},a);case`inlineCode`:return(0,Z.jsx)(`code`,{className:`md-inline-code`,children:t.value??``},a);case`code`:{let e=t.lang?`language-${t.lang}`:void 0;return(0,Z.jsx)(`pre`,{className:`md-code`,children:(0,Z.jsx)(`code`,{className:e,children:t.value??``})},a)}case`blockquote`:return(0,Z.jsx)(`blockquote`,{children:Uh(e,t.children,r)},a);case`break`:return(0,Z.jsx)(`br`,{},a);case`thematicBreak`:return(0,Z.jsx)(`hr`,{},a);case`list`:return t.ordered?(0,Z.jsx)(`ol`,{start:t.start??1,className:`md-list`,children:Uh(e,t.children,r)},a):(0,Z.jsx)(`ul`,{className:`md-list`,children:Uh(e,t.children,r)},a);case`listItem`:{let n=typeof t.checked==`boolean`;return(0,Z.jsxs)(`li`,{className:n?`md-list-item md-task-item`:`md-list-item`,children:[n?e.mode===`static`?(0,Z.jsx)(`span`,{className:`md-task-marker`,role:`img`,"aria-label":t.checked?e.t(`Completed`,`已完成`):e.t(`Not completed`,`未完成`),children:t.checked?`✓`:`☐`}):(0,Z.jsx)(`input`,{type:`checkbox`,className:`md-task-checkbox`,checked:t.checked===!0,readOnly:!0,tabIndex:-1,"aria-label":t.checked?e.t(`Completed`,`已完成`):e.t(`Not completed`,`未完成`)}):null,Uh(e,t.children,r)]},a)}case`link`:{let n=zh(t.url,`link`,e.urlPolicy);if(!n)return(0,Z.jsx)(`span`,{className:`md-link-rejected`,title:e.t(`Unsafe link URL rejected`,`已拒绝不安全的链接地址`),children:Uh(e,t.children,r,!1)},a);let i=e.anchors.resolve(n),o=/^https?:/i.test(i);return(0,Z.jsx)(`a`,{href:i,title:t.title??void 0,target:o?`_blank`:void 0,rel:o?`noopener noreferrer`:void 0,children:Uh(e,t.children,r,!1)},a)}case`image`:{let n=zh(t.url,`image`,e.urlPolicy),r=n;if(n&&e.imageResolver)try{let t=e.imageResolver(n);r=typeof t==`string`&&t.trim()!==``?t:null}catch{r=null}if(!r){let n=e.t(`Unsafe image rejected`,`已拒绝不安全的图片`),r=t.alt?e.t(`: ${t.alt}`,`:${t.alt}`):``;return(0,Z.jsxs)(`span`,{className:`md-image-rejected`,children:[`[`,n,r,`]`]},a)}return(0,Z.jsx)(`img`,{className:`md-image`,src:r,alt:t.alt??``,title:t.title??void 0,loading:`lazy`,referrerPolicy:`no-referrer`},a)}case`table`:{let[n,...i]=t.children??[];return(0,Z.jsx)(`div`,{className:`md-table-scroll`,children:(0,Z.jsxs)(`table`,{className:`md-table`,children:[n?(0,Z.jsx)(`thead`,{children:(0,Z.jsx)(`tr`,{children:Jh(e,n,`th`,t.align,r)})}):null,i.length?(0,Z.jsx)(`tbody`,{children:i.map((n,i)=>(0,Z.jsx)(`tr`,{children:Jh(e,n,`td`,t.align,r)},n.id||`${a}-row-${i}`))}):null]})},a)}case`tableRow`:return(0,Z.jsx)(`tr`,{children:Jh(e,t,`td`,void 0,r)},a);case`tableCell`:{let n=t.align?.[0]??void 0;return(0,Z.jsx)(`td`,{style:{textAlign:n??void 0},children:Uh(e,t.children,r,!1)},a)}case`interpolation`:try{let n=sh(e.runtime.evaluate(t.value??``));if(n===null)throw Error(`Cannot display an array`);return(0,Z.jsx)(`span`,{className:`local-interpolation`,children:n},a)}catch{return(0,Z.jsx)(Ih,{},a)}case`math`:case`inlineMath`:{let n=t.type===`math`;return(0,Z.jsx)(`span`,{className:n?`local-math-display`:`local-math-inline`,children:(0,Z.jsx)(Lh,{revision:fh(e.runtime),children:(0,Z.jsx)(sp,{source:t.value??``,display:n})})},a)}case`html`:return(0,Z.jsx)(`span`,{className:`md-raw-html`,children:t.value??``},a);case`fallback`:return Gh(e,t,a,i);case`footnoteReference`:return Gh(e,t,a,!1);case`footnoteDefinition`:return Gh(e,t,a,i);case`comment`:case`definition`:return null;default:return t.children&&t.children.length?(0,Z.jsx)(`span`,{children:Uh(e,t.children,r,i)},a):typeof t.value==`string`?(0,Z.jsx)(`span`,{children:t.value},a):null}}function Jh(e,t,n,r,i){return(t.children??[]).map((a,o)=>{let s=a.align?.[0]??t.align?.[o]??r?.[o]??void 0;return n===`th`?(0,Z.jsx)(`th`,{style:{textAlign:s??void 0},children:Uh(e,a.children,i,!1)},a.id||`${t.id}-h-${o}`):(0,Z.jsx)(`td`,{style:{textAlign:s??void 0},children:Uh(e,a.children,i,!1)},a.id||`${t.id}-c-${o}`)})}function Yh(e,t,n,r){let i=e.name??``;if(i===`computed`||i===`const`)return null;if(i===`data-table`)return(0,Z.jsx)(Km,{node:e,visible:t,runtime:n,t:r});if(Rh.has(i))return(0,Z.jsx)(Xh,{node:e,visible:t});let a=qg[i];return a?(0,Z.jsx)(a,{node:e,visible:t}):(0,Z.jsxs)(`span`,{className:`component-error`,children:[r(`Unknown component "`,`未知组件“`),i||r(`(missing name)`,`(缺少名称)`),r(`"`,`”`)]})}function Xh({node:e,visible:t}){let{runtime:n,render:r,mode:i}=$(),a=Q(),o=nh(e),s=(0,Z.jsx)(Nm,{node:e,runtime:n,render:r,visible:t,mode:i});if(!n.document.validations?.some(t=>t.fields.some(t=>Object.hasOwn(n.document.bindings,t)&&n.document.bindings[t].nodeIds.includes(e.id))))return s;let c=ch(n,e,`label`,ch(n,e,`title`,a(`Selection`,`选择`),a),a);return(0,Z.jsx)(`div`,{role:`group`,"aria-label":c,"aria-invalid":o.invalid||void 0,"aria-describedby":o.describedBy,children:s})}function Zh({node:e,visible:t}){let{validation:n}=$(),r=n.hintFor(e);if(!r)return null;let i=r.failed||r.error,a=t&&i;return(0,Z.jsx)(`span`,{id:r.id,className:`local-validation-hint`,"data-local-validation":r.error?`error`:r.failed?`failed`:`passed`,role:a?`status`:void 0,"aria-live":a?`polite`:void 0,children:i?r.message:null})}function Qh(){return null}function $h({message:e}){return e?(0,Z.jsx)(`span`,{className:`field-error`,role:`alert`,children:e}):null}function eg(e,t,n=lp){if(t.required&&e.length===0)return n(`This field is required`,`请填写此字段`);if(e.length>1e5)return n(`At most ${w} characters`,`最多允许 ${w} 个字符`);if(t.email&&e!==``&&!N(e))return n(`Enter a valid email address`,`请输入有效的邮箱地址`);let r=nt(e);return t.minLength!==void 0&&t.minLength>0&&e!==``&&r<t.minLength?n(`At least ${t.minLength} characters`,`至少需要 ${t.minLength} 个字符`):t.maxLength!==void 0&&t.maxLength>=0&&r>t.maxLength?n(`At most ${t.maxLength} characters`,`最多允许 ${t.maxLength} 个字符`):null}function tg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o,setError:s}=Nh(e),c=ch(n,e,`label`,e.name??i(`Input`,`输入`),i),l=ch(n,e,`placeholder`,``,i),u=(ah(e,`type`)??`text`)===`email`,d=uh(n,e,`required`,!1),{disabled:f,invalid:p}=Ph(e),m=nh(e),h=ah(e,`min-length`),g=ah(e,`max-length`),_=h===void 0?void 0:Math.max(0,Math.floor(ph(n,e,`min-length`,0))),v=g===void 0?void 0:Math.max(0,Math.floor(ph(n,e,`max-length`,0))),b=hh(mh(n,e)),[x,S]=(0,y.useState)(b),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null),k=(0,y.useRef)(!1),A=(0,y.useRef)(b),j=(0,y.useRef)(b);if(j.current=b,(0,y.useEffect)(()=>{A.current!==b&&(A.current=b,!C&&!k.current&&S(b))},[b,C]),Fh(n,e,()=>{k.current=!1,S(j.current),E(!1),O(null),s(null)}),r===`static`)return(0,Z.jsx)(vh,{className:`local-input${u?` local-input-email`:``}`,label:c,value:_h(b)});let M=e=>eg(e,{required:d,minLength:_,maxLength:v,email:u},i);return(0,Z.jsxs)(`div`,{className:`md-control local-input${u?` local-input-email`:``}`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-input`,children:c}),(0,Z.jsx)(`input`,{id:`${t}-input`,className:`md-text-input`,type:u?`email`:`text`,value:x,placeholder:l||void 0,disabled:f,required:d,"aria-invalid":D||o||m.invalid?!0:void 0,"aria-describedby":m.describedBy,onFocus:()=>w(!0),onBlur:()=>{w(!1),E(!0);let e=M(x);O(e),!e&&x!==b&&a(x)},onChange:e=>{let t=e.target.value;S(t),s(null),T&&O(M(t)),!k.current&&M(t)===null&&a(t)},onCompositionStart:()=>{k.current=!0},onCompositionEnd:e=>{k.current=!1;let t=e.currentTarget.value;S(t),T&&O(M(t)),M(t)===null&&a(t)}}),(0,Z.jsx)(yh,{value:_h(b)}),(0,Z.jsx)($h,{message:p?i(`Cannot compute`,`无法计算`):D??o})]})}function ng({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o,setError:s}=Nh(e),c=ch(n,e,`label`,i(`Text`,`文本`),i),l=ch(n,e,`placeholder`,``,i),u=Math.min(40,Math.max(1,Math.floor(ph(n,e,`rows`,4)))),d=uh(n,e,`required`,!1),{disabled:f,invalid:p}=Ph(e),m=nh(e),h=ah(e,`min-length`),g=ah(e,`max-length`),_=h===void 0?void 0:Math.max(0,Math.floor(ph(n,e,`min-length`,0))),v=g===void 0?void 0:Math.max(0,Math.floor(ph(n,e,`max-length`,0))),b=hh(mh(n,e)),[x,S]=(0,y.useState)(b),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null),k=(0,y.useRef)(!1),A=(0,y.useRef)(b),j=(0,y.useRef)(b);if(j.current=b,(0,y.useEffect)(()=>{A.current!==b&&(A.current=b,!C&&!k.current&&S(b))},[b,C]),Fh(n,e,()=>{k.current=!1,S(j.current),E(!1),O(null),s(null)}),r===`static`)return(0,Z.jsx)(vh,{className:`local-textarea`,label:c,value:_h(b),multiline:!0});let M=e=>eg(e,{required:d,minLength:_,maxLength:v},i);return(0,Z.jsxs)(`div`,{className:`md-control local-textarea`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-textarea`,children:c}),(0,Z.jsx)(`textarea`,{id:`${t}-textarea`,className:`md-text-input`,rows:u,value:x,placeholder:l||void 0,disabled:f,required:d,"aria-invalid":D||o||m.invalid?!0:void 0,"aria-describedby":m.describedBy,onFocus:()=>w(!0),onBlur:()=>{w(!1),E(!0);let e=M(x);O(e),!e&&x!==b&&a(x)},onChange:e=>{let t=e.target.value;S(t),s(null),T&&O(M(t)),!k.current&&M(t)===null&&a(t)},onCompositionStart:()=>{k.current=!0},onCompositionEnd:e=>{k.current=!1;let t=e.currentTarget.value;S(t),T&&O(M(t)),M(t)===null&&a(t)}}),(0,Z.jsx)(yh,{value:_h(b),block:!0}),(0,Z.jsx)($h,{message:p?i(`Cannot compute`,`无法计算`):D??o})]})}function rg(e){let t=e.trim();if(t===``||t===`-`||t===`+`||t===`.`||t===`-.`)return{kind:`empty`};let n=Number(t);return Number.isFinite(n)?{kind:`valid`,value:n}:{kind:`invalid`}}function ig(e,t,n,r,i=lp){let a=1e-9*Math.max(1,Math.abs(e));if(t!==void 0&&e<t-a)return i(`Must be at least ${t}`,`不能小于 ${t}`);if(n!==void 0&&e>n+a)return i(`Must be at most ${n}`,`不能大于 ${n}`);if(!Number.isFinite(r)||r<=0)return i(`Step must be greater than 0`,`步长必须大于 0`);let o=(e-(t??0))/r;return Math.abs(o-Math.round(o))>1e-9*Math.max(1,Math.abs(o))?i(`Must be a multiple of ${r}`,`需要按步长 ${r} 取值`):null}function ag({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o,setError:s}=Nh(e),c=ch(n,e,`label`,i(`Number`,`数字`),i),{disabled:l,invalid:u}=Ph(e),d=nh(e),f=ah(e,`min`)!==void 0,p=ah(e,`max`)!==void 0,m=f?ph(n,e,`min`,0):void 0,h=p?ph(n,e,`max`,0):void 0,g=ph(n,e,`step`,1),_=mh(n,e),v=typeof _==`number`&&Number.isFinite(_)?String(_):``,[b,x]=(0,y.useState)(v),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(null),O=(0,y.useRef)(!1),k=(0,y.useRef)(v),A=(0,y.useRef)(v);A.current=v,(0,y.useEffect)(()=>{k.current!==v&&(k.current=v,!S&&!O.current&&x(v))},[v,S]),Fh(n,e,()=>{O.current=!1,x(A.current),T(!1),D(null),s(null)});let j=(0,Z.jsxs)(Z.Fragment,{children:[m===void 0?``:i(`Min ${m}`,`最小 ${m}`),m!==void 0&&h!==void 0?` · `:``,h===void 0?``:i(`Max ${h}`,`最大 ${h}`),g===void 0?``:i(` · Step ${g}`,` · 步长 ${g}`)]});if(r===`static`)return(0,Z.jsx)(vh,{className:`local-number`,label:c,value:_h(v),hint:j});let M=(e,t)=>{let n=rg(e);if(n.kind!==`valid`)return t&&D(i(`Enter a valid number`,`请输入有效数字`)),!1;let r=ig(n.value,m,h,g,i);return r?(t&&D(r),!1):(D(null),a(n.value))};return(0,Z.jsxs)(`div`,{className:`md-control local-number`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-number`,children:c}),(0,Z.jsx)(`input`,{id:`${t}-number`,className:`md-text-input`,type:`text`,inputMode:`decimal`,value:b,disabled:l,"aria-invalid":E||o||d.invalid?!0:void 0,"aria-describedby":d.describedBy,onFocus:()=>C(!0),onBlur:()=>{C(!1),T(!0),M(b,!0)},onChange:e=>{let t=e.target.value;x(t),s(null),O.current||M(t,w)},onCompositionStart:()=>{O.current=!0},onCompositionEnd:e=>{O.current=!1,M(e.currentTarget.value,w)}}),(0,Z.jsx)(yh,{value:_h(v)}),m!==void 0||h!==void 0||g!==void 0?(0,Z.jsx)(`span`,{className:`md-hint`,children:j}):null,(0,Z.jsx)($h,{message:u?i(`Cannot compute`,`无法计算`):E??o})]})}function og({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Slider`,`滑块`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=ph(n,e,`min`,0),f=ph(n,e,`max`,100),p=ph(n,e,`step`,1),m=mh(n,e),h=Math.min(f,Math.max(d,typeof m==`number`&&Number.isFinite(m)?m:d));return r===`static`?(0,Z.jsx)(vh,{className:`md-slider local-slider`,label:s,value:String(h)}):(0,Z.jsxs)(`div`,{className:`md-control md-slider local-slider`,style:xh(bh(e)),children:[(0,Z.jsxs)(`label`,{className:`md-label`,htmlFor:`${t}-slider`,children:[(0,Z.jsx)(`span`,{children:s}),(0,Z.jsx)(`span`,{className:`md-slider-value`,"aria-hidden":`true`,children:h})]}),(0,Z.jsx)(`input`,{id:`${t}-slider`,type:`range`,min:d,max:f,step:p,value:h,disabled:c,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,onChange:e=>a(Number(e.target.value))}),(0,Z.jsx)(yh,{value:String(h)}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):o})]})}function sg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Toggle`,`开关`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=mh(n,e)===!0,f=d?i(`On`,`开`):i(`Off`,`关`);return r===`static`?(0,Z.jsx)(vh,{className:`md-toggle local-toggle`,label:s,value:f}):(0,Z.jsxs)(`div`,{className:`md-control md-toggle local-toggle`,style:xh(bh(e)),children:[(0,Z.jsxs)(`label`,{className:`md-toggle-label`,htmlFor:`${t}-toggle`,children:[(0,Z.jsx)(`input`,{id:`${t}-toggle`,type:`checkbox`,checked:d,disabled:c,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,onChange:e=>a(e.target.checked)}),(0,Z.jsx)(`span`,{children:s})]}),(0,Z.jsx)(yh,{value:f}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):o})]})}function cg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Checkbox`,`勾选`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=mh(n,e)===!0,f=d?i(`Checked`,`已勾选`):i(`Unchecked`,`未勾选`);return r===`static`?(0,Z.jsx)(vh,{className:`local-checkbox`,label:s,value:f}):(0,Z.jsxs)(`div`,{className:`md-control local-checkbox`,style:xh(bh(e)),children:[(0,Z.jsxs)(`label`,{className:`md-toggle-label`,htmlFor:`${t}-checkbox`,children:[(0,Z.jsx)(`input`,{id:`${t}-checkbox`,type:`checkbox`,checked:d,disabled:c,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,onChange:e=>a(e.target.checked)}),(0,Z.jsx)(`span`,{children:s})]}),(0,Z.jsx)(yh,{value:f}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):o})]})}function lg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Date`,`日期`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=uh(n,e,`required`,!1),f=ch(n,e,`min`,``,i),p=ch(n,e,`max`,``,i),m=mh(n,e),h=typeof m==`string`?m:``,[g,_]=(0,y.useState)(!1),v=g&&d&&h===``?i(`Select a date`,`请选择日期`):null;return r===`static`?(0,Z.jsx)(vh,{className:`local-date`,label:s,value:_h(h)}):(0,Z.jsxs)(`div`,{className:`md-control local-date`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-date`,children:s}),(0,Z.jsx)(`input`,{id:`${t}-date`,className:`md-text-input`,type:`date`,value:h,min:f||void 0,max:p||void 0,required:d,disabled:c,"aria-invalid":v||o||u.invalid?!0:void 0,"aria-describedby":u.describedBy,onBlur:()=>_(!0),onChange:e=>{_(!0),a(e.target.value)}}),(0,Z.jsx)(yh,{value:_h(h)}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):v??o})]})}function ug(e){return(e.children??[]).filter(e=>e.type===`component`&&e.name===`option`).map((e,t)=>({value:ah(e,`value`)??`option-${t+1}`,node:e}))}function dg(e,t,n=lp){if(!t)return``;let r=``;for(let i of t)if(i.type===`text`||i.type===`inlineCode`)r+=i.value??``;else if(i.type===`fallback`)r+=i.value??``;else if(i.type===`interpolation`)try{r+=sh(e.evaluate(i.value??``))??``}catch{r+=n(`Cannot compute`,`无法计算`)}else i.type===`break`?r+=` `:r+=dg(e,i.children,n);return r}function fg(e,t,n=lp){return dg(e,t.children,n)||ah(t,`value`)||``}function pg(){return null}function mg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Select`,`选择`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=ug(e),f=mh(n,e),p=typeof f==`string`?f:``,m=d.some(e=>e.value===p)?p:d[0]?.value??``,h=d.find(e=>e.value===m),g=h?fg(n,h.node,i)||m:``;return d.length===0?(0,Z.jsx)(Ih,{message:i(`Missing options`,`缺少选项`)}):r===`static`?(0,Z.jsx)(vh,{className:`md-select local-select`,label:s,value:_h(g)}):(0,Z.jsxs)(`div`,{className:`md-control md-select local-select`,style:xh(bh(e)),children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-select`,children:s}),(0,Z.jsx)(`select`,{id:`${t}-select`,className:`md-select-input`,value:m,disabled:c,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,onChange:e=>a(e.target.value),children:d.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:fg(n,e.node,i)||e.value},e.node.id))}),(0,Z.jsx)(yh,{value:_h(g)}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):o})]})}function hg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),{write:s,error:c}=Nh(e),l=ch(i,e,`label`,o(`Options`,`选项`),o),{disabled:u,invalid:d}=Ph(e),f=nh(e),p=ug(e),m=mh(i,e),h=typeof m==`string`?m:``,g=p.findIndex(e=>e.value===h),_=g>=0?g:0,v=g>=0?p[g]:void 0,b=v?fg(i,v.node,o):``,x=(0,y.useRef)([]);if(p.length===0)return(0,Z.jsx)(Ih,{message:o(`Missing options`,`缺少选项`)});if(a===`static`)return(0,Z.jsx)(vh,{className:`local-choices`,label:l,value:_h(b)});let S=e=>{let t=p[e];t&&(s(t.value),x.current[e]?.focus())},C=(e,t)=>{let n=-1;e.key===`ArrowRight`||e.key===`ArrowDown`?n=(t+1)%p.length:e.key===`ArrowLeft`||e.key===`ArrowUp`?n=(t-1+p.length)%p.length:e.key===`Home`?n=0:e.key===`End`&&(n=p.length-1),!(n<0)&&(e.preventDefault(),S(n))};return(0,Z.jsxs)(`div`,{className:`md-control local-choices`,style:xh(bh(e)),children:[(0,Z.jsx)(`span`,{className:`md-label`,id:`${n}-choices-label`,children:l}),(0,Z.jsx)(`div`,{className:`local-choice-list`,role:`radiogroup`,"aria-labelledby":`${n}-choices-label`,"aria-disabled":u||void 0,"aria-invalid":f.invalid||void 0,"aria-describedby":f.describedBy,children:p.map((e,n)=>{let i=e.value===h;return(0,Z.jsx)(`button`,{ref:e=>{x.current[n]=e},type:`button`,role:`radio`,"aria-checked":i,tabIndex:n===_?0:-1,disabled:u,className:`local-choice${i?` is-selected`:``}`,onClick:()=>s(e.value),onKeyDown:e=>C(e,n),children:Kh(r,e.node.children,t)},e.node.id)})}),(0,Z.jsx)(yh,{value:_h(b)}),(0,Z.jsx)($h,{message:d?o(`Cannot compute`,`无法计算`):c})]})}function gg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),{write:s,error:c}=Nh(e),l=ch(i,e,`label`,o(`Options`,`选项`),o),{disabled:u,invalid:d}=Ph(e),f=nh(e),p=ug(e),m=mh(i,e),h=typeof m==`string`?m:``,g=n,_=p.find(e=>e.value===h),v=_?fg(i,_.node,o):``;return p.length===0?(0,Z.jsx)(Ih,{message:o(`Missing options`,`缺少选项`)}):a===`static`?(0,Z.jsx)(vh,{className:`local-radio-group`,label:l,value:_h(v)}):(0,Z.jsxs)(`fieldset`,{className:`md-control local-radio-group`,style:xh(bh(e)),disabled:u,"aria-invalid":f.invalid||void 0,"aria-describedby":f.describedBy,children:[(0,Z.jsx)(`legend`,{className:`md-label`,children:l}),p.map(e=>(0,Z.jsxs)(`label`,{className:`local-radio-option`,children:[(0,Z.jsx)(`input`,{type:`radio`,name:g,value:e.value,checked:h===e.value,onChange:()=>s(e.value)}),(0,Z.jsx)(`span`,{children:Kh(r,e.node.children,t)})]},e.node.id)),(0,Z.jsx)(yh,{value:_h(v)}),(0,Z.jsx)($h,{message:d?o(`Cannot compute`,`无法计算`):c})]})}function _g(e){return((e.children??[]).find(e=>e.type===`list`)?.children??[]).filter(e=>e.type===`listItem`).map((e,t)=>({id:`item-${t+1}`,node:e}))}function vg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),{write:s,error:c}=Nh(e),l=ch(i,e,`label`,o(`Checklist`,`清单`),o),{disabled:u,invalid:d}=Ph(e),f=nh(e),p=_g(e),m=mh(i,e),h=Array.isArray(m)?m.filter(e=>typeof e==`string`):[];if(p.length===0)return(0,Z.jsx)(Ih,{message:o(`Checklist requires a task list`,`清单需要任务列表`)});let g=e=>e?o(`Checked`,`已勾选`):o(`Unchecked`,`未勾选`);if(a===`static`)return(0,Z.jsxs)(`div`,{className:`local-checklist local-static-checklist`,style:xh(bh(e)),role:`group`,"aria-label":l,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:l}),(0,Z.jsx)(`ul`,{className:`local-static-list`,children:p.map(e=>{let n=h.includes(e.id);return(0,Z.jsxs)(`li`,{className:`local-static-list-item`,children:[(0,Z.jsx)(`span`,{className:`local-static-state`,children:g(n)}),(0,Z.jsx)(`span`,{className:`local-static-item${n?` is-checked`:``}`,children:Kh(r,e.node.children,t)})]},e.id)})})]});let _=(e,t)=>{let n=new Set(h);t?n.add(e):n.delete(e),s(p.filter(e=>n.has(e.id)).map(e=>e.id))};return(0,Z.jsxs)(`fieldset`,{className:`local-checklist`,style:xh(bh(e)),disabled:u,"aria-invalid":f.invalid||void 0,"aria-describedby":f.describedBy,children:[(0,Z.jsx)(`legend`,{className:`md-label`,children:l}),p.map(e=>{let i=h.includes(e.id);return(0,Z.jsxs)(`div`,{className:`local-checklist-item`,children:[(0,Z.jsx)(`input`,{id:`${n}-${e.id}`,type:`checkbox`,checked:i,onChange:t=>_(e.id,t.target.checked)}),(0,Z.jsx)(`label`,{className:`local-checklist-text${i?` is-checked`:``}`,htmlFor:`${n}-${e.id}`,children:Kh(r,e.node.children,t)})]},e.id)}),(0,Z.jsx)(yh,{block:!0,value:(0,Z.jsx)(`ul`,{className:`local-static-list`,children:p.map(e=>{let t=h.includes(e.id);return(0,Z.jsxs)(`li`,{className:`local-static-list-item`,children:[(0,Z.jsx)(`span`,{className:`local-static-state`,children:g(t)}),(0,Z.jsx)(`span`,{className:`local-static-item${t?` is-checked`:``}`,children:dg(i,e.node.children,o)})]},e.id)})})}),(0,Z.jsx)($h,{message:d?o(`Cannot compute`,`无法计算`):c})]})}function yg(e,t=lp){let n=Math.max(0,Math.floor(e)),r=Math.floor(n/60),i=n%60;return r===0?t(`${i} seconds`,`${i} 秒`):`${r}:${String(i).padStart(2,`0`)}`}function bg({node:e}){let{runtime:t,mode:n}=$(),r=Q(),{write:i,error:a}=Nh(e),o=ch(t,e,`label`,r(`Counter`,`计数`),r),{disabled:s,invalid:c}=Ph(e),l=nh(e),u=ph(t,e,`min`,0),d=ah(e,`max`)===void 0?void 0:ph(t,e,`max`,0),f=ph(t,e,`step`,1),p=mh(t,e),m=typeof p==`number`&&Number.isFinite(p)?p:u,h=Number.isFinite(f)&&f>0?f:1,g=1e-9*Math.max(1,Math.abs(m)),_=m-h>=u-g,v=d===void 0||m+h<=d+g;if(n===`static`)return(0,Z.jsx)(vh,{className:`local-counter`,label:o,value:String(m)});let y=e=>{let t=Number((m+e*h).toFixed(12));i(t)};return(0,Z.jsxs)(`div`,{className:`local-counter`,role:`group`,"aria-label":o,"aria-invalid":l.invalid||void 0,"aria-describedby":l.describedBy,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:o}),(0,Z.jsxs)(`div`,{className:`local-counter-row`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-counter-button`,"aria-label":`${o} ${r(`decrease`,`减少`)}`,disabled:s||!_,onClick:()=>y(-1),children:`−`}),(0,Z.jsx)(`span`,{className:`local-counter-value`,"aria-live":`polite`,children:m}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-counter-button`,"aria-label":`${o} ${r(`increase`,`增加`)}`,disabled:s||!v,onClick:()=>y(1),children:`+`}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-quiet local-counter-reset`,disabled:s,onClick:()=>{try{t.reset(e)}catch{}},children:r(`Reset`,`恢复初值`)})]}),(0,Z.jsx)(yh,{value:String(m)}),(0,Z.jsx)($h,{message:c?r(`Cannot compute`,`无法计算`):a})]})}function xg({node:e,visible:t}){let{runtime:n,mode:r}=$(),i=fp(),a=Q(),o=ch(n,e,`label`,a(`Timer`,`计时器`),a),s=nh(e),c=ph(n,e,`duration`,60),l=Math.floor(c),u=mh(n,e),d=typeof u==`number`&&Number.isFinite(u)?Math.max(0,Math.ceil(u)):l,[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(!1),g=(0,y.useRef)(0),_=(0,y.useRef)(d);_.current=d;let[v,b]=(0,y.useState)(null),x=(0,y.useCallback)(t=>{try{let r=n.set(e,t);r.length&&b(r.map(e=>tt(e,i)).join(`; `))}catch{}},[i,e,n]);return(0,y.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>{let e=Math.max(0,Math.ceil((g.current-performance.now())/1e3));e!==_.current&&(_.current=e,x(e)),e<=0&&(p(!1),h(!0))},200);return()=>window.clearInterval(e)},[f,x]),(0,y.useEffect)(()=>{if(t||!f)return;let e=Math.max(0,Math.ceil((g.current-performance.now())/1e3));_.current=e,x(e),p(!1)},[t,f,x]),Fh(n,e,()=>{p(!1),h(!1),b(null)}),!Number.isFinite(c)||l<=0?(0,Z.jsx)(Ih,{message:a(`Timer duration must be a positive number of seconds`,`计时时长必须是大于 0 的秒数`)}):r===`static`?(0,Z.jsx)(vh,{className:`local-timer`,label:o,value:yg(d,a)}):(0,Z.jsxs)(`div`,{className:`local-timer`,role:`group`,"aria-label":o,"aria-invalid":s.invalid||void 0,"aria-describedby":s.describedBy,children:[(0,Z.jsxs)(`div`,{className:`local-timer-head`,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:o}),(0,Z.jsx)(`span`,{className:`local-timer-value`,role:`timer`,"aria-label":a(`${d} seconds remaining`,`剩余 ${d} 秒`),children:yg(d,a)})]}),(0,Z.jsxs)(`div`,{className:`local-timer-controls`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-primary`,onClick:()=>{if(f)return;let e=d>0?d:l;d<=0&&(_.current=l,x(l)),g.current=performance.now()+e*1e3,h(!1),b(null),p(!0)},disabled:f,children:a(`Start`,`开始`)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary`,onClick:()=>{if(!f)return;let e=Math.max(0,Math.ceil((g.current-performance.now())/1e3));_.current=e,x(e),p(!1)},disabled:!f,children:a(`Pause`,`暂停`)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-quiet`,onClick:()=>{p(!1),h(!1),b(null),_.current=l;try{n.reset(e)}catch{}},children:a(`Reset`,`重置`)})]}),(0,Z.jsx)(`span`,{className:`local-timer-status`,role:`status`,"aria-live":`polite`,children:m?a(`Completed`,`计时完成`):f?a(`Running`,`计时中`):a(`Paused`,`已暂停`)}),(0,Z.jsx)(yh,{value:yg(d,a)}),(0,Z.jsx)($h,{message:v})]})}function Sg({node:e}){let{runtime:t}=$(),n=Q(),r=ch(t,e,`label`,n(`Progress`,`进度`),n),i=ph(t,e,`max`,100),a=oh(t,e,`value`);if(!Number.isFinite(i)||i<=0)return(0,Z.jsx)(Ih,{message:n(`Progress maximum must be positive`,`进度上限必须是正数`)});if(!a.present||!a.ok)return(0,Z.jsx)(Ih,{});let o=a.value,s=typeof o==`number`?o:typeof o==`string`&&o.trim()!==``?Number(o):NaN;if(!Number.isFinite(s))return(0,Z.jsx)(Ih,{});if(s<0||s>i)return(0,Z.jsx)(Ih,{message:n(`Progress value must be between 0 and ${i}`,`进度值需要在 0 到 ${i} 之间`)});let c=s/i*100,l=bh(e);return(0,Z.jsxs)(`div`,{className:`local-progress`,style:l?{"--local-progress-color":l}:void 0,children:[(0,Z.jsxs)(`div`,{className:`local-progress-head`,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:r}),(0,Z.jsxs)(`span`,{className:`local-progress-value`,children:[Math.round(c),`%`]})]}),(0,Z.jsx)(`div`,{className:`local-progress-track`,role:`progressbar`,"aria-label":r||n(`Progress`,`进度`),"aria-valuemin":0,"aria-valuemax":i,"aria-valuenow":s,children:(0,Z.jsx)(`div`,{className:`local-progress-fill`,style:{width:`${c}%`}})})]})}function Cg({node:e,visible:t}){let{runtime:n,render:r,mode:i}=$(),a=Q(),o=ch(n,e,`title`,``,a),s=uh(n,e,`reset`,!0)&&i!==`static`,[c,l]=(0,y.useState)(null);return(0,Z.jsxs)(`section`,{className:`local-panel`,"aria-label":o||a(`Parameter panel`,`参数面板`),children:[o||s?(0,Z.jsxs)(`div`,{className:`local-panel-head`,children:[o?(0,Z.jsx)(`h3`,{className:`local-panel-title`,children:o}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-quiet local-panel-reset`,onClick:()=>{try{n.reset(e),l(null)}catch(e){l(e instanceof Error?e.message:a(`Cannot reset`,`无法恢复默认`))}},"aria-label":o?a(`Reset ${o}`,`${o} 恢复默认`):a(`Reset`,`恢复默认`),children:a(`Reset`,`恢复默认`)}):null]}):null,(0,Z.jsx)(`div`,{className:`local-panel-body`,children:r(e.children??[],t)}),(0,Z.jsx)($h,{message:c})]})}function wg({node:e,visible:t}){let{runtime:n,render:r}=$(),i=ch(n,e,`title`,``,Q());return(0,Z.jsxs)(`section`,{className:`md-card local-card`,children:[i?(0,Z.jsx)(`h3`,{className:`md-card-title`,children:i}):null,(0,Z.jsx)(`div`,{className:`md-card-body`,children:r(e.children??[],t)})]})}function Tg({node:e,visible:t}){let{runtime:n,render:r}=$(),i=Math.min(4,Math.max(1,Math.floor(ph(n,e,`columns`,2))));return(0,Z.jsx)(`div`,{className:`local-grid`,style:{"--local-grid-columns":String(i)},children:r(e.children??[],t)})}function Eg({node:e,visible:t}){let{render:n}=$();return(0,Z.jsx)(`div`,{className:`local-tabpanel-body`,children:n(e.children??[],t)})}function Dg(){return null}function Og({node:e,visible:t}){let n=(0,y.useId)(),{runtime:r,render:i,mode:a}=$(),o=Q(),{write:s,error:c}=Nh(e),l=ch(r,e,`label`,``,o),u=nh(e),d=(e.children??[]).filter(e=>e.type===`component`&&e.name===`tab`),f=d.map((e,t)=>ah(e,`value`)??`tab-${t+1}`),p=d.map((e,t)=>ch(r,e,`label`,f[t],o)),m=ah(e,`initial`)??f[0]??``,h=ah(e,`bind`)!==void 0,g=mh(r,e),_=typeof g==`string`?g:``,[v,b]=(0,y.useState)(()=>f.includes(m)?m:f[0]??``),x=(0,y.useRef)([]);if(Fh(r,e,()=>{b(f.includes(m)?m:f[0]??``)}),d.length===0)return(0,Z.jsx)(Ih,{message:o(`Tabs requires at least one tab`,`标签页至少需要一个 tab`)});if(a===`static`)return(0,Z.jsxs)(`section`,{className:`local-tabs local-static-tabs`,"aria-label":l||o(`Tabs`,`选项卡`),children:[l?(0,Z.jsx)(`div`,{className:`local-tabs-label`,children:l}):null,d.map((e,n)=>(0,Z.jsxs)(`section`,{className:`local-static-tab`,children:[(0,Z.jsx)(`h4`,{className:`local-static-tab-label`,children:p[n]}),(0,Z.jsx)(`div`,{className:`local-static-tab-body`,children:i(e.children??[],t)})]},e.id))]});let S=h?f.includes(_)?_:f[0]:f.includes(v)?v:f[0],C=Math.max(0,f.indexOf(S)),w=e=>{let t=f[e];t!==void 0&&(h?s(t):b(t),x.current[e]?.focus())};return(0,Z.jsxs)(`section`,{className:`local-tabs`,"aria-label":l||o(`Tabs`,`选项卡`),"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,children:[l?(0,Z.jsx)(`div`,{className:`local-tabs-label`,children:l}):null,(0,Z.jsx)(`div`,{className:`local-tablist`,role:`tablist`,"aria-label":l||o(`Tabs`,`选项卡`),onKeyDown:e=>{let t=-1;e.key===`ArrowRight`?t=(C+1)%d.length:e.key===`ArrowLeft`?t=(C-1+d.length)%d.length:e.key===`Home`?t=0:e.key===`End`&&(t=d.length-1),!(t<0)&&(e.preventDefault(),w(t))},children:d.map((e,t)=>{let r=f[t],i=r===S;return(0,Z.jsx)(`button`,{ref:e=>{x.current[t]=e},id:`${n}-tab-${t}`,type:`button`,role:`tab`,className:`local-tab${i?` is-selected`:``}`,"aria-selected":i,"aria-controls":`${n}-panel-${t}`,tabIndex:i?0:-1,onClick:()=>{h?s(r):b(r)},children:p[t]},e.id)})}),d.map((e,r)=>{let a=f[r]===S;return(0,Z.jsxs)(`div`,{id:`${n}-panel-${r}`,className:`local-tabpanel`,role:`tabpanel`,"aria-labelledby":`${n}-tab-${r}`,tabIndex:0,hidden:!a,children:[(0,Z.jsx)(yh,{block:!0,value:p[r]}),i(e.children??[],t&&a)]},e.id)}),(0,Z.jsx)($h,{message:c})]})}function kg({node:e,visible:t}){let{runtime:n,render:r}=$(),i=Q(),a=ch(n,e,`label`,``,i);return(0,Z.jsxs)(`div`,{className:`local-accordion`,role:`group`,"aria-label":a||i(`Accordion`,`折叠面板`),children:[a?(0,Z.jsx)(`div`,{className:`local-accordion-label`,children:a}):null,r(e.children??[],t)]})}function Ag({node:e,visible:t}){let n=(0,y.useId)(),{runtime:r,render:i,mode:a}=$(),o=Q(),s=ch(r,e,`label`,o(`Details`,`折叠内容`),o),c=uh(r,e,`open`,!1),[l,u]=(0,y.useState)(c);if(Fh(r,e,()=>{u(c)}),a===`static`)return(0,Z.jsxs)(`section`,{className:`local-disclosure local-static-disclosure`,children:[(0,Z.jsx)(`h3`,{className:`local-disclosure-heading`,children:s}),(0,Z.jsx)(`div`,{className:`local-disclosure-panel`,children:i(e.children??[],t)})]});let d=`${n}-disclosure-trigger`,f=`${n}-disclosure-panel`;return(0,Z.jsxs)(`div`,{className:`local-disclosure`,children:[(0,Z.jsxs)(`h3`,{className:`local-disclosure-heading`,children:[(0,Z.jsxs)(`button`,{id:d,type:`button`,className:`local-disclosure-trigger`,"aria-expanded":l,"aria-controls":f,onClick:()=>u(e=>!e),children:[(0,Z.jsx)(`span`,{className:`local-chevron${l?` is-open`:``}`,"aria-hidden":`true`,children:`▸`}),(0,Z.jsx)(`span`,{children:s})]}),(0,Z.jsx)(yh,{value:s})]}),(0,Z.jsx)(`div`,{id:f,className:`local-disclosure-panel`,role:`region`,"aria-labelledby":d,hidden:!l,children:i(e.children??[],t&&l)})]})}function jg({node:e,visible:t}){let{runtime:n,render:r}=$(),i=Q(),a=lh(n,e,`when`,!1),o=a.ok?a.value:!1,s=!a.ok,c=(0,y.useRef)(null),l=(0,y.useRef)(o),u=(0,y.useRef)(!1);return(0,y.useEffect)(()=>{if(l.current&&!o){if(u.current){let e=c.current?.closest(`.local-document`);e&&(e.tabIndex=-1,e.focus({preventScroll:!0}))}u.current=!1}l.current=o},[o]),(0,Z.jsxs)(Z.Fragment,{children:[s?(0,Z.jsx)(Ih,{}):null,(0,Z.jsx)(`div`,{ref:c,className:`local-if md-if`,role:`group`,"aria-label":i(`Conditional content`,`条件内容`),tabIndex:-1,hidden:!o,"aria-hidden":!o,onFocus:()=>{u.current=!0},onBlur:e=>{c.current?.contains(e.relatedTarget)||(u.current=!1)},children:r(e.children??[],t&&o)})]})}function Mg(){let e=Q();return(0,Z.jsx)(`span`,{className:`local-error local-tone-error`,role:`status`,children:e(`Invalid tone; using the default style`,`色调无效,已使用默认样式`)})}function Ng({node:e,visible:t}){let{runtime:n,render:r}=$(),i=ch(n,e,`title`,``,Q()),{tone:a,error:o}=dh(n,e,`tone`,[`info`,`success`,`warning`],`info`),s=a===`warning`?`alert`:`status`;return(0,Z.jsxs)(Z.Fragment,{children:[o?(0,Z.jsx)(Mg,{}):null,(0,Z.jsxs)(`div`,{className:`local-alert local-alert-${a}`,role:s,children:[i?(0,Z.jsx)(`div`,{className:`local-alert-title`,children:i}):null,(0,Z.jsx)(`div`,{className:`local-alert-body`,children:r(e.children??[],t)})]})]})}function Pg({node:e,visible:t}){let n=$(),{runtime:r}=n,{tone:i,error:a}=dh(r,e,`tone`,[`neutral`,`success`,`warning`],`neutral`),o=bh(e);return(0,Z.jsxs)(Z.Fragment,{children:[a?(0,Z.jsx)(Mg,{}):null,(0,Z.jsx)(`span`,{className:`md-badge md-badge-${i} local-badge`,style:o?{color:o}:void 0,children:Kh(n,e.children,t)})]})}function Fg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),s=ch(i,e,`text`,o(`Tooltip`,`提示`),o),[c,l]=(0,y.useState)(!1),u=`${n}-tooltip`;return a===`static`?(0,Z.jsxs)(`span`,{className:`local-tooltip local-static-tooltip`,children:[(0,Z.jsx)(`span`,{className:`local-tooltip-trigger`,children:Kh(r,e.children,t)}),(0,Z.jsx)(`span`,{className:`local-tooltip-bubble is-visible`,role:`note`,children:s})]}):(0,Z.jsxs)(`span`,{className:`local-tooltip`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[(0,Z.jsx)(`span`,{className:`local-tooltip-trigger`,tabIndex:0,"aria-describedby":u,onFocus:()=>l(!0),onBlur:()=>l(!1),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),l(!1))},children:Kh(r,e.children,t)}),(0,Z.jsx)(`span`,{id:u,role:`tooltip`,className:`local-tooltip-bubble${c?` is-visible`:``}`,children:s}),(0,Z.jsx)(yh,{value:s})]})}function Ig({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{anchors:i,rootRef:a,runtime:o,urlPolicy:s,mode:c}=r,l=Q(),u=`${n}-jump-feedback`,[d,f]=(0,y.useState)(null),p=ah(e,`to`)??``,m=i.targetId(p),h=ah(e,`appearance`)===`button`?`button`:`link`,g=bh(e),_=m?`#${m}`:`#`,v=m!==void 0;if(v&&s)try{v=s(`#${p}`,`link`)===!0}catch{v=!1}return Fh(o,e,()=>f(null)),c===`static`?v&&m?(0,Z.jsx)(`a`,{href:`#${m}`,className:`local-jump local-jump-link local-jump-static`,style:xh(g),children:Kh(r,e.children,t)}):(0,Z.jsx)(`span`,{className:`local-jump local-jump-static-blocked`,style:xh(g),children:Kh(r,e.children,t)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`a`,{href:v?_:`#`,className:`local-jump local-jump-${h}`,style:xh(g),"data-local-target-missing":m?void 0:`true`,"data-local-jump-blocked":m&&!v?`true`:void 0,"aria-describedby":d?u:void 0,onClick:e=>{if(!v||!m){e.preventDefault(),f(m?l(`Jump is blocked by the host`,`跳转已被主机策略阻止`):l(`Jump target not found`,`找不到跳转目标`));return}let t=a.current;if(!t||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let n=null;try{n=t.querySelector(`[id="${m}"]`)}catch{n=null}if(!n){e.preventDefault(),f(l(`Jump target not found`,`找不到跳转目标`));return}if(n.closest(`[hidden]`)){e.preventDefault(),f(l(`Jump target is hidden`,`跳转目标当前隐藏`));return}e.preventDefault(),n.hasAttribute(`tabindex`)||(n.tabIndex=-1);try{n.focus({preventScroll:!0})}catch{}let r=`smooth`;try{window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&(r=`auto`)}catch{r=`auto`}try{n.scrollIntoView({behavior:r,block:`start`})}catch{}f(null)},children:Kh(r,e.children,t)}),d?(0,Z.jsx)(`span`,{id:u,className:`local-jump-feedback`,role:`status`,"aria-live":`polite`,children:d}):null]})}function Lg({node:e}){let{anchors:t}=$(),n=t.anchorIds.get(e);return n?(0,Z.jsx)(`span`,{className:`local-anchor`,id:n,"data-local-anchor":``}):null}function Rg({node:e,visible:t}){let n=$(),r=bh(e);return(0,Z.jsx)(`span`,{className:`local-text`,style:r?{color:r}:void 0,children:Kh(n,e.children,t)})}function zg({node:e,visible:t}){let{render:n}=$(),r=bh(e);return(0,Z.jsx)(`div`,{className:`local-section`,style:r?{color:r}:void 0,children:n(e.children??[],t)})}function Bg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),{write:s,error:c,setError:l}=Nh(e),u=ch(i,e,`label`,o(`Multi select`,`多选`),o),{disabled:d,invalid:f}=Ph(e),p=nh(e),m=ug(e),h=mh(i,e),g=Array.isArray(h)?h.filter(e=>typeof e==`string`):[],_=m.filter(e=>g.includes(e.value)).map(e=>fg(i,e.node,o)||e.value),v=ph(i,e,`max-selected`,m.length),b=Number.isFinite(v)?Math.max(0,Math.floor(v)):m.length,[x,S]=(0,y.useState)(``);if(Fh(i,e,()=>{S(``),l(null)}),m.length===0)return(0,Z.jsx)(Ih,{message:o(`Missing options`,`缺少选项`)});if(a===`static`)return(0,Z.jsx)(vh,{className:`local-multi-select`,label:u,value:_h(_.join(`, `))});let C=new Set(g),w=g.length>=b,T=x.trim().toLocaleLowerCase(),E=T?m.filter(e=>`${dg(i,e.node.children,o)} ${e.value}`.toLocaleLowerCase().includes(T)):m,D=(e,t)=>{let n=new Set(C);if(t){if(!n.has(e)&&n.size>=b)return;n.add(e)}else n.delete(e);s(m.filter(e=>n.has(e.value)).map(e=>e.value))};return(0,Z.jsxs)(`fieldset`,{className:`local-multi-select`,style:xh(bh(e)),disabled:d,"aria-invalid":p.invalid||void 0,"aria-describedby":p.describedBy,children:[(0,Z.jsx)(`legend`,{className:`md-label`,children:u}),(0,Z.jsxs)(`div`,{className:`local-multi-toolbar`,children:[(0,Z.jsx)(`input`,{id:`${n}-multi-search`,type:`search`,className:`md-text-input local-multi-search`,value:x,placeholder:o(`Search options`,`搜索选项`),"aria-label":o(`Search ${u}`,`搜索${u}`),onChange:e=>S(e.target.value)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-quiet local-multi-clear`,onClick:()=>{S(``),g.length>0&&s([])},children:o(`Clear`,`清除`)})]}),(0,Z.jsx)(`div`,{className:`local-multi-list`,role:`group`,"aria-label":u,children:E.length===0?(0,Z.jsx)(`span`,{className:`local-multi-empty`,children:o(`No matching options`,`没有匹配选项`)}):E.map(e=>{let n=C.has(e.value);return(0,Z.jsxs)(`label`,{className:`local-multi-option${n?` is-selected`:``}`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n,disabled:!n&&w,onChange:t=>D(e.value,t.target.checked)}),(0,Z.jsx)(`span`,{children:Kh(r,e.node.children,t)})]},e.node.id)})}),(0,Z.jsx)(`span`,{className:`local-multi-count`,role:`status`,"aria-live":`polite`,children:o(`${g.length} of ${b} selected`,`已选 ${g.length}/${b}`)}),(0,Z.jsx)(yh,{value:_h(_.join(`, `))}),(0,Z.jsx)($h,{message:f?o(`Cannot compute`,`无法计算`):c})]})}function Vg({node:e}){let{runtime:t,mode:n}=$(),r=Q(),{write:i,error:a,setError:o}=Nh(e),s=ch(t,e,`label`,r(`Range`,`范围`),r),{disabled:c,invalid:l}=Ph(e),u=nh(e),{min:d,max:f,step:p}=Mh(t,e,`min`,`max`,0,100,1),m=Math.floor((f-d)/p+1e-9),h=d,g=kh(d+Math.max(0,m)*p,d,f),_=Ah(jh(t,e,`start`,h),d,f,p),v=Ah(jh(t,e,`end`,g),d,f,p);_>v&&(_=v);let[b,x]=(0,y.useState)(null);Fh(t,e,()=>{x(null),o(null)});let S=r(`Start`,`起点`),C=r(`End`,`终点`),w=`${S}: ${_} · ${C}: ${v}`;if(n===`static`)return(0,Z.jsx)(vh,{className:`local-range-slider`,label:s,value:w});let T=(e,t)=>{let n=Ah(kh(t,d,f),d,f,p);e===`start`&&n>v?x(r(`Start cannot exceed end`,`起点不能超过终点`)):e===`end`&&n<_?x(r(`End cannot be less than start`,`终点不能小于起点`)):(x(null),i(n,e))};return(0,Z.jsxs)(`div`,{className:`md-control local-range-slider`,style:xh(bh(e)),role:`group`,"aria-label":s,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:s}),(0,Z.jsxs)(`div`,{className:`local-range-row`,children:[(0,Z.jsx)(`span`,{className:`local-range-name`,children:r(`Start`,`起点`)}),(0,Z.jsx)(`input`,{type:`range`,className:`local-range-input`,min:d,max:v,step:p,value:_,disabled:c,"aria-label":`${s} ${r(`Start`,`起点`)}`,onChange:e=>T(`start`,Number(e.target.value))}),(0,Z.jsx)(`span`,{className:`local-range-value`,"aria-hidden":`true`,children:_})]}),(0,Z.jsxs)(`div`,{className:`local-range-row`,children:[(0,Z.jsx)(`span`,{className:`local-range-name`,children:r(`End`,`终点`)}),(0,Z.jsx)(`input`,{type:`range`,className:`local-range-input`,min:_,max:f,step:p,value:v,disabled:c,"aria-label":`${s} ${r(`End`,`终点`)}`,onChange:e=>T(`end`,Number(e.target.value))}),(0,Z.jsx)(`span`,{className:`local-range-value`,"aria-hidden":`true`,children:v})]}),(0,Z.jsx)(yh,{value:w}),(0,Z.jsx)($h,{message:l?r(`Cannot compute`,`无法计算`):b??a})]})}function Hg({id:e,label:t,value:n,min:r,max:i,step:a,disabled:o,onCommit:s,reset:c}){let[l,u]=(0,y.useState)(()=>String(n)),[d,f]=(0,y.useState)(!1),p=(0,y.useRef)(n);(0,y.useEffect)(()=>{u(String(n)),f(!1)},[c]),(0,y.useEffect)(()=>{p.current!==n&&(p.current=n,d||u(String(n)))},[n,d]);let m=e=>{let t=e.trim();if(t===``||t===`-`||t===`.`||t===`-.`)return null;let n=Number(t);return Number.isFinite(n)?Ah(kh(n,r,i),r,i,a):null};return(0,Z.jsxs)(`div`,{className:`local-number-field`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:e,children:t}),(0,Z.jsx)(`input`,{id:e,className:`md-text-input`,type:`text`,inputMode:`decimal`,value:l,disabled:o,onFocus:()=>f(!0),onBlur:()=>{f(!1);let e=m(l);u(String(e??n))},onChange:e=>{let t=e.target.value;u(t);let n=m(t);n!==null&&s(n)}})]})}function Ug({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,writeMany:o,error:s,setError:c}=Nh(e),l=ch(n,e,`label`,i(`Coordinate`,`坐标`),i),{disabled:u,invalid:d}=Ph(e),f=nh(e),p=Mh(n,e,`x-min`,`x-max`,-5,5,1),m=Mh(n,e,`y-min`,`y-max`,-5,5,1),h=Ah(0,p.min,p.max,p.step),g=Ah(0,m.min,m.max,m.step),_=Ah(jh(n,e,`x`,h),p.min,p.max,p.step),v=Ah(jh(n,e,`y`,g),m.min,m.max,m.step),b=(0,y.useRef)(null),x=(0,y.useRef)(!1);Fh(n,e,()=>c(null));let S=`X: ${_} · Y: ${v}`;if(r===`static`)return(0,Z.jsx)(vh,{className:`local-coordinate`,label:l,value:S});let C=p.max>p.min?(_-p.min)/(p.max-p.min)*100:0,w=m.max>m.min?(v-m.min)/(m.max-m.min)*100:0,T=e=>{let t=b.current?.getBoundingClientRect();if(!t||t.width===0||t.height===0)return null;let n=kh((e.clientX-t.left)/t.width,0,1),r=kh((e.clientY-t.top)/t.height,0,1);return{x:Ah(p.min+n*(p.max-p.min),p.min,p.max,p.step),y:Ah(m.min+(1-r)*(m.max-m.min),m.min,m.max,m.step)}},E=(e,t)=>{(e!==_||t!==v)&&o({x:e,y:t})};return(0,Z.jsxs)(`div`,{className:`local-coordinate`,style:xh(bh(e)),role:`group`,"aria-label":l,"aria-invalid":f.invalid||void 0,"aria-describedby":f.describedBy,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:l}),(0,Z.jsxs)(`div`,{ref:b,className:`local-coordinate-pad`,role:`group`,"aria-label":i(`${l} drag area`,`${l} 拖拽区`),"aria-disabled":u||void 0,tabIndex:u?-1:0,onKeyDown:e=>{if(u)return;let t=_,n=v;switch(e.key){case`ArrowLeft`:t=Ah(_-p.step,p.min,p.max,p.step);break;case`ArrowRight`:t=Ah(_+p.step,p.min,p.max,p.step);break;case`ArrowDown`:n=Ah(v-m.step,m.min,m.max,m.step);break;case`ArrowUp`:n=Ah(v+m.step,m.min,m.max,m.step);break;case`Home`:t=p.min,n=m.min;break;case`End`:t=Ah(p.max,p.min,p.max,p.step),n=Ah(m.max,m.min,m.max,m.step);break;default:return}e.preventDefault(),E(t,n)},onPointerDown:e=>{if(u)return;e.preventDefault(),x.current=!0,b.current?.focus({preventScroll:!0});try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}let t=T(e);t&&E(t.x,t.y)},onPointerMove:e=>{if(!x.current||u)return;let t=T(e);t&&E(t.x,t.y)},onPointerUp:e=>{x.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}},onPointerCancel:()=>{x.current=!1},children:[(0,Z.jsx)(`span`,{className:`local-coordinate-horizontal`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`local-coordinate-vertical`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`local-coordinate-dot`,"aria-hidden":`true`,style:{left:`${C}%`,top:`${100-w}%`}})]}),(0,Z.jsx)(`span`,{className:`md-hint local-hint`,children:i(`Arrow keys adjust the point; Home and End jump to the lower or upper bounds.`,`方向键调整坐标;Home 和 End 跳到最小或最大边界。`)}),(0,Z.jsxs)(`div`,{className:`local-coordinate-fields`,children:[(0,Z.jsx)(Hg,{id:`${t}-coordinate-x`,reset:n.resetToken(e),label:`${l} X`,value:_,min:p.min,max:p.max,step:p.step,disabled:u,onCommit:e=>a(e,`x`)}),(0,Z.jsx)(Hg,{id:`${t}-coordinate-y`,reset:n.resetToken(e),label:`${l} Y`,value:v,min:m.min,max:m.max,step:m.step,disabled:u,onCommit:e=>a(e,`y`)})]}),(0,Z.jsx)(yh,{value:S}),(0,Z.jsx)($h,{message:d?i(`Cannot compute`,`无法计算`):s})]})}function Wg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),s=ch(i,e,`label`,o(`Quiz`,`测验`),o),c=ah(e,`type`)===`number`?`number`:`choice`,l=(ah(e,`answer`)??``).trim(),u=ph(i,e,`tolerance`,0),d=Number.isFinite(u)&&u>=0?u:0,{disabled:f,invalid:p}=Ph(e),m=ug(e),h=ch(i,e,`explanation`,``,o),[g,_]=(0,y.useState)(``),[v,b]=(0,y.useState)(null);Fh(i,e,()=>{_(``),b(null)});let x=c===`number`?Number(l):NaN;if(c===`number`&&!Number.isFinite(x))return(0,Z.jsx)(Ih,{message:o(`Quiz answer must be a number`,`测验答案必须是数字`)});if(c===`choice`&&m.length===0)return(0,Z.jsx)(Ih,{message:o(`Missing options`,`缺少选项`)});let S=m.map(e=>fg(i,e.node,o)||e.value);if(a===`static`)return(0,Z.jsxs)(`div`,{className:`local-quiz local-static-quiz`,role:`group`,"aria-label":s,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:s}),c===`choice`?(0,Z.jsx)(`ul`,{className:`local-static-list local-static-quiz-options`,children:m.map(e=>(0,Z.jsx)(`li`,{className:`local-static-list-item`,children:Kh(r,e.node.children,t)},e.node.id))}):(0,Z.jsx)(`span`,{className:`local-static-value`,children:o(`Numeric answer`,`数字作答`)})]});let C=()=>{if(c===`choice`){if(g===``){b(`incomplete`);return}b(g===l?`correct`:`incorrect`);return}let e=g.trim(),t=e===``?NaN:Number(e);b(Number.isFinite(t)?Math.abs(t-x)<=d?`correct`:`incorrect`:`incomplete`)},w=()=>{_(``),b(null)},T=v===null?null:v===`correct`?`${o(`Correct`,`回答正确`)}`:v===`incorrect`?`${o(`Not quite`,`回答不正确`)}`:c===`number`?o(`Enter a number first`,`请先输入数字`):o(`Choose an answer first`,`请先选择答案`),E=v===`correct`?` is-correct`:v===`incorrect`?` is-incorrect`:``;return(0,Z.jsxs)(`div`,{className:`local-quiz`,role:`group`,"aria-label":s,children:[c===`choice`?(0,Z.jsxs)(`fieldset`,{className:`local-quiz-options`,disabled:f,children:[(0,Z.jsx)(`legend`,{className:`md-label`,children:s}),m.map(e=>(0,Z.jsxs)(`label`,{className:`local-radio-option`,children:[(0,Z.jsx)(`input`,{type:`radio`,name:`${n}-quiz`,value:e.value,checked:g===e.value,onChange:()=>{_(e.value),b(null)}}),(0,Z.jsx)(`span`,{children:Kh(r,e.node.children,t)})]},e.node.id))]}):(0,Z.jsxs)(`div`,{className:`local-quiz-number`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${n}-quiz`,children:s}),(0,Z.jsx)(`input`,{id:`${n}-quiz`,className:`md-text-input local-quiz-input`,type:`text`,inputMode:`decimal`,value:g,disabled:f,"aria-label":s,onChange:e=>{_(e.target.value),b(null)}})]}),(0,Z.jsxs)(`div`,{className:`local-quiz-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-primary local-quiz-check`,disabled:f,onClick:C,children:o(`Check answer`,`检查答案`)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-quiz-again`,disabled:f,onClick:w,children:o(`Try again`,`再试一次`)})]}),(0,Z.jsx)(`span`,{className:`local-quiz-feedback${E}`,role:`status`,"aria-live":`polite`,children:T?`${v===`correct`?`✓ `:v===`incorrect`?`✗ `:``}${T}`:``}),v!==null&&h?(0,Z.jsx)(`div`,{className:`local-quiz-explanation`,children:h}):null,(0,Z.jsx)(yh,{block:!0,value:c===`choice`?`${T?`${T} · `:``}${S.join(` · `)}`:T||o(`No answer yet`,`尚未作答`)}),(0,Z.jsx)($h,{message:p?o(`Cannot compute`,`无法计算`):null})]})}function Gg({node:e,visible:t}){let n=(0,y.useId)(),{runtime:r,render:i,mode:a}=$(),o=Q(),{write:s,error:c,setError:l}=Nh(e),u=ch(r,e,`label`,``,o),d=nh(e),f=(e.children??[]).filter(e=>e.type===`component`&&e.name===`step`),p=f.map((e,t)=>ah(e,`value`)??`step-${t+1}`),m=f.map((e,t)=>ch(r,e,`label`,p[t],o)),h=ah(e,`initial`)??``,g=p.includes(h)?h:p[0]??``,_=mh(r,e),v=typeof _==`string`?_:``,b=(0,y.useRef)([]),x=(0,y.useRef)(!1);Fh(r,e,()=>{l(null),x.current=!1});let S=p.includes(v)?v:g,C=Math.max(0,p.indexOf(S));if((0,y.useEffect)(()=>{x.current&&(x.current=!1,b.current[C]?.focus({preventScroll:!0}))},[C,S]),f.length===0)return(0,Z.jsx)(Ih,{message:o(`Steps requires at least one step`,`步骤至少需要一个 step`)});if(a===`static`){let e=f[C];return(0,Z.jsxs)(`section`,{className:`local-steps local-static-steps`,"aria-label":u||o(`Steps`,`步骤`),children:[u?(0,Z.jsx)(`div`,{className:`local-steps-label`,children:u}):null,(0,Z.jsx)(`div`,{className:`local-steps-nav local-static-steps-nav`,children:(0,Z.jsx)(`span`,{className:`local-steps-status`,role:`status`,"aria-live":`polite`,children:o(`Step ${C+1} of ${f.length}`,`第 ${C+1} 步,共 ${f.length} 步`)})}),(0,Z.jsx)(`div`,{className:`local-steps-panel`,role:`group`,"aria-label":m[C],children:i(e.children??[],t)})]})}let w=e=>{let t=p[e];t!==void 0&&(x.current=!0,s(t))};return(0,Z.jsxs)(`section`,{className:`local-steps`,"aria-label":u||o(`Steps`,`步骤`),"aria-invalid":d.invalid||void 0,"aria-describedby":d.describedBy,children:[u?(0,Z.jsx)(`div`,{className:`local-steps-label`,children:u}):null,(0,Z.jsxs)(`div`,{className:`local-steps-nav`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-steps-prev`,disabled:C<=0,onClick:()=>w(C-1),children:o(`Previous`,`上一步`)}),(0,Z.jsx)(`span`,{className:`local-steps-status`,role:`status`,"aria-live":`polite`,children:o(`Step ${C+1} of ${f.length}`,`第 ${C+1} 步,共 ${f.length} 步`)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-steps-next`,disabled:C>=f.length-1,onClick:()=>w(C+1),children:o(`Next`,`下一步`)})]}),f.map((e,r)=>{let a=r===C;return(0,Z.jsx)(`div`,{id:`${n}-step-${r}`,ref:e=>{b.current[r]=e},className:`local-steps-panel`,role:`group`,"aria-label":m[r],tabIndex:-1,hidden:!a,children:i(e.children??[],t&&a)},e.id)}),(0,Z.jsx)($h,{message:c})]})}function Kg(){return null}var qg={panel:Cg,card:wg,grid:Tg,tabs:Og,tab:Eg,accordion:kg,disclosure:Ag,if:jg,alert:Ng,badge:Pg,validation:Zh,column:Qh,tooltip:Fg,input:tg,textarea:ng,number:ag,slider:og,toggle:sg,checkbox:cg,date:lg,select:mg,choices:hg,"radio-group":gg,option:pg,node:Eg,edge:Dg,counter:bg,timer:xg,checklist:vg,progress:Sg,jump:Ig,anchor:Lg,text:Rg,section:zg,"multi-select":Bg,"range-slider":Vg,coordinate:Ug,quiz:Wg,steps:Gg,step:Kg};function Jg({document:e,runtime:t,onDiagnostics:n,urlPolicy:r,locale:i=`en`,themes:a,colorScheme:o=`auto`,mode:s=`interactive`,staticFirst:c=!1,imageResolver:l}){let[u,d]=(0,y.useState)(!c);(0,y.useEffect)(()=>{c&&d(!0)},[c]);let f=s===`interactive`&&c&&!u?`static`:s,p=(0,y.useId)(),m=(0,y.useMemo)(()=>(e,t)=>pp(i,e,t),[i]),h=(0,y.useMemo)(()=>rr(e,`local-heading-${p}`),[e,p]),g=(0,y.useMemo)(()=>{try{return Un(e)}catch{return Ln}},[e]),_=(0,y.useRef)(n);_.current=n;let v=(0,y.useRef)(null),b=(0,y.useCallback)(e=>{_.current?.(e)},[]),x=Ch(a),S=(0,y.useMemo)(()=>{try{return Fu(e.theme,a,e.themeRange,e.source)}catch{return{name:Ou.name,diagnostics:[]}}},[e.theme,e.themeRange?.start,e.themeRange?.end,e.source,x]),C=Oh(v,o),w=(0,y.useRef)(``);(0,y.useEffect)(()=>{let e=wh(S.diagnostics);if(e===w.current)return;let t=w.current!==``;w.current=e,(S.diagnostics.length>0||t)&&b(S.diagnostics)},[S,b]);let T=(0,y.useCallback)(e=>{try{return t.subscribe(e)}catch{return()=>{}}},[t]),E=(0,y.useCallback)(()=>{try{return t.snapshot()}catch{return ih}},[t]);(0,y.useSyncExternalStore)(T,E,E);let D=``;if(e.validations?.length)try{D=wh(t.validate())}catch{D=`unavailable`}let O=(0,y.useMemo)(()=>th(e,t,p,m),[e,t,p,m,D]),k=(0,y.useMemo)(()=>({runtime:t,urlPolicy:r,imageResolver:l,anchors:h,t:m,mode:f,dependencies:g}),[t,r,l,h,m,f,g]),A=(0,y.useCallback)((e,t=!0)=>Uh(k,e??[],t),[k]),j=(0,y.useMemo)(()=>({runtime:t,render:A,visible:!0,mode:f,imageResolver:l,validation:O,report:b,urlPolicy:r,anchors:h,rootRef:v,t:m,dependencies:g}),[t,A,b,r,l,f,h,v,m,O,g]);return(0,Z.jsx)(dp,{locale:i,children:(0,Z.jsx)(`article`,{ref:v,className:`md-document local-document${f===`static`?` local-static`:``}`,"data-rmd-theme":S.name,"data-color-scheme":C,"data-render-mode":f,style:{colorScheme:C},"aria-label":f===`static`?m(`Static document`,`静态文档`):m(`Interactive document`,`交互文档`),children:(0,Z.jsx)(qm.Provider,{value:j,children:A(e.nodes,!0)})})})}var Yg=`reactive-md-state/v1`,Xg=1048576,Zg=/^fnv1a32:[0-9a-f]{8}$/,Qg=2166136261,$g=16777619,e_=new Set([`format`,`syntax`,`sourceDigest`,`parameters`,`generator`]),t_=new Set([`name`,`version`]),n_=new TextEncoder;function r_(e,t){return{code:e,message:t.length>2e3?`${t.slice(0,D-1)}…`:t,severity:`error`,range:{start:0,end:0},line:1,column:1}}function i_(e,t,n){e.length<100&&e.push(r_(t,n))}function a_(e){return e instanceof Error?e.message:String(e)}function o_(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){t+=1;continue}return!1}if(n>=56320&&n<=57343)return!1}return!0}function s_(e){if(typeof e!=`string`)throw TypeError(`localSourceDigest requires a source string.`);let t=n_.encode(e),n=Qg;for(let e=0;e<t.length;e+=1)n^=t[e],n=Math.imul(n,$g)>>>0;return`fnv1a32:${n.toString(16).padStart(8,`0`)}`}function c_(e){if(typeof e==`string`)return o_(e)?{ok:!0,value:e}:{ok:!1,message:`contains malformed Unicode.`};if(typeof e==`number`)return Number.isFinite(e)?{ok:!0,value:e}:{ok:!1,message:`must be a finite number.`};if(typeof e==`boolean`||e===null)return{ok:!0,value:e};if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(typeof r!=`string`)return{ok:!1,message:`must be an array of strings.`};if(!o_(r))return{ok:!1,message:`contains malformed Unicode.`};t.push(r)}return{ok:!0,value:Object.freeze(t)}}return{ok:!1,message:`must be a string, finite number, boolean, null or string array.`}}function l_(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function u_(e){return Object.freeze(e.parameters),e.generator&&Object.freeze(e.generator),Object.freeze(e)}function d_(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`generator must be an object with string name and version.`);if(typeof e.name!=`string`||typeof e.version!=`string`)throw TypeError(`generator must have string name and version.`);if(!o_(e.name)||!o_(e.version))throw TypeError(`generator name and version must be well-formed Unicode strings.`);return Object.freeze({name:e.name,version:e.version})}function f_(e){return typeof e==`string`?`"${e.length>48?`${e.slice(0,48)}…`:e}"`:e===null?`null`:Array.isArray(e)?`an array`:typeof e}function p_(e,t){return e.length>t?e.length:n_.encode(e).byteLength}function m_(e,t){let n;try{let t=JSON.stringify(e);if(typeof t!=`string`)return null;n=t}catch{return null}return p_(n,t)}function h_(e){if(e===void 0)return Xg;if(typeof e!=`object`||!e)throw TypeError(`parseLocalState options must be an object.`);let{maxLength:t}=e;if(t===void 0)return Xg;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<=0)throw RangeError(`maxLength must be a finite positive integer.`);return t}function g_(e,t,n){if(!e||e.syntax!==`local`||typeof e.source!=`string`)throw TypeError(`createLocalStateFile requires a compiled local document.`);if(!t||typeof t!=`object`||Array.isArray(t))throw TypeError(`createLocalStateFile requires a state object.`);let r=Object.keys(e.bindings).filter(e=>!e.startsWith(`@`)).sort(),i=new Set(r),a=new Map;for(let n of Object.keys(t)){if(Object.hasOwn(e.computations??{},n))continue;if(n.startsWith(`@`)){if(!Object.hasOwn(e.bindings,n))throw Error(`Cannot persist parameter "${n}": it is not a binding of this document.`);continue}if(!i.has(n))throw Error(`Cannot persist parameter "${n}": it is not a public binding of this document.`);let r=c_(t[n]);if(!r.ok)throw TypeError(`Cannot persist parameter "${n}": the value ${r.message}`);a.set(n,r.value)}let o={};for(let e of r){if(!a.has(e))throw Error(`Cannot persist the document: parameter "${e}" is missing from the supplied state.`);o[e]=a.get(e)}let s={format:Yg,syntax:au,sourceDigest:s_(e.source),parameters:o};return n!==void 0&&(s.generator=d_(n)),u_(s)}function __(e,t){let n=[],r=(e,t)=>i_(n,e,t),i=e;if(typeof e==`string`){if(p_(e,t)>t)return{ok:!1,diagnostics:[r_(`local.state.size`,`The state payload exceeds the ${t}-byte limit.`)]};if(!o_(e))return{ok:!1,diagnostics:[r_(`local.state.utf`,`The state payload contains malformed Unicode.`)]};try{i=JSON.parse(e)}catch(e){return{ok:!1,diagnostics:[r_(`local.state.json`,`The state payload is not valid JSON: ${a_(e)}`)]}}}else{let n=m_(e,t);if(n===null)return{ok:!1,diagnostics:[r_(`local.state.shape`,`The state payload must be a JSON object.`)]};if(n>t)return{ok:!1,diagnostics:[r_(`local.state.size`,`The state payload exceeds the ${t}-byte limit.`)]}}if(!l_(i))return{ok:!1,diagnostics:[r_(`local.state.shape`,`The state payload must be a JSON object.`)]};Object.getOwnPropertySymbols(i).length>0&&r(`local.state.shape`,`The state payload cannot use symbol keys.`);for(let e of Object.keys(i))e_.has(e)||r(`local.state.key`,`Unknown top-level state key "${e}".`);let a=i.format;a!==`reactive-md-state/v1`&&r(`local.state.format`,`Unsupported state format ${f_(a)}; expected "${Yg}".`);let o=i.syntax;o!==`local-draft-2`&&r(`local.state.syntax`,`Unsupported state syntax ${f_(o)}; expected "${au}".`);let s=i.sourceDigest;typeof s==`string`&&Zg.test(s)||r(`local.state.digest`,`sourceDigest must match "fnv1a32:" followed by 8 lowercase hexadecimal digits.`);let c={},l=i.parameters;if(!l_(l))r(`local.state.parameters`,`parameters must be a JSON object of public binding values.`);else for(let e of Object.keys(l).sort()){if(e===`__proto__`){r(`local.state.parameter.prototype`,`Parameter names cannot be "__proto__".`);continue}if(e.startsWith(`@`)){r(`local.state.parameter.internal`,`Internal parameter "${e}" cannot be persisted.`);continue}let t=c_(l[e]);t.ok?c[e]=t.value:r(`local.state.parameter.value`,`Parameter "${e}" ${t.message}`)}let u;if(Object.hasOwn(i,`generator`)){let e=i.generator;if(!l_(e))r(`local.state.generator`,`generator must be an object with string name and version.`);else{for(let t of Object.keys(e))t_.has(t)||r(`local.state.generator`,`generator has unknown key "${t}".`);typeof e.name!=`string`||typeof e.version!=`string`?r(`local.state.generator`,`generator must have string name and version.`):!o_(e.name)||!o_(e.version)?r(`local.state.utf`,`generator contains malformed Unicode.`):u=Object.freeze({name:e.name,version:e.version})}}if(n.length)return{ok:!1,diagnostics:n};let d={format:Yg,syntax:au,sourceDigest:s,parameters:c};return u&&(d.generator=u),{ok:!0,file:u_(d)}}function v_(e,t){let n=h_(t);try{return __(e,n)}catch(e){return{ok:!1,diagnostics:[r_(`local.state.invalid`,`Cannot read the local state: ${a_(e)}`)]}}}function y_(e){let t=new Map,n=e=>{for(let r of e)t.set(r.id,r),r.children&&n(r.children)};return n(e.nodes),t}function b_(e){let t=y_(e),n=new Map,r=[];for(let[i,a]of Object.entries(e.bindingSlots??{})){let e=t.get(i);if(!e)continue;let o={node:e,slots:[]};for(let[t,r]of Object.entries(a))o.slots.push({slot:t,key:r}),r.startsWith(`@`)||n.set(r,{node:e,slot:t});o.slots.length&&r.push(o)}let i=[];for(let[r,a]of Object.entries(e.bindings)){if(r.startsWith(`@`))continue;let e=n.get(r);if(e){i.push({key:r,binding:a,node:e.node,slot:e.slot});continue}let o=a.owner&&t.has(a.owner)?a.owner:a.nodeIds.find(e=>t.has(e));i.push({key:r,binding:a,node:o?t.get(o):void 0})}return{plans:i,groups:r}}function x_(e,t,n){let r=[];for(let i of t.plans)i.slot===void 0&&Object.hasOwn(n,i.key)&&(i.node?Object.is(e.get(i.node),n[i.key])||r.push(...e.set(i.node,n[i.key])):r.push(r_(`local.state.document`,`The document has no component for parameter "${i.key}".`)));for(let i of t.groups){let t={},a=!1;for(let{slot:e,key:r}of i.slots)Object.hasOwn(n,r)&&(t[e]=n[r],a=!0);a&&r.push(...e.setMany(i.node,t))}return r}function S_(e,t){let n=e.snapshot(),r={};for(let e of t){let t=n.state[e];r[e]=Array.isArray(t)?Object.freeze([...t]):t}return Object.freeze(r)}function C_(e,t,n,r){let i=v_(t,r);if(!i.ok)return i;if(!e||e.syntax!==`local`||typeof e.source!=`string`||!Array.isArray(e.nodes)||!e.bindings)return{ok:!1,diagnostics:[r_(`local.state.document`,`resolveLocalState requires a compiled local document.`)]};if(i.file.syntax!==`local-draft-2`)return{ok:!1,diagnostics:[r_(`local.state.syntax`,`This state file uses syntax "${i.file.syntax}", but this build accepts "${au}".`)]};if(i.file.sourceDigest!==s_(e.source))return{ok:!1,diagnostics:[r_(`local.state.source`,`This state file was created for a different document (source digest mismatch).`)]};let a=b_(e),o=new Set(a.plans.map(e=>e.key)),s=[];for(let e of Object.keys(i.file.parameters))o.has(e)||i_(s,`local.state.parameter.unknown`,`The state contains unknown parameter "${e}" for this document.`);for(let e of o)Object.hasOwn(i.file.parameters,e)||i_(s,`local.state.parameter.missing`,`The state is missing parameter "${e}".`);if(s.length)return{ok:!1,diagnostics:s};let c;try{c=qf(e)}catch(e){return{ok:!1,diagnostics:[r_(`local.state.document`,`Cannot validate this document: ${a_(e)}`)]}}try{if(n){let e=x_(c,a,n);if(e.length)return{ok:!1,diagnostics:e}}let e=x_(c,a,i.file.parameters);if(e.length)return{ok:!1,diagnostics:e};let t=[...o].sort();return{ok:!0,file:i.file,state:S_(c,t)}}finally{c.dispose()}}function w_(e,t,n){try{return C_(e,t,void 0,n)}catch(e){return{ok:!1,diagnostics:[r_(`local.state.invalid`,`Cannot resolve the local state: ${a_(e)}`)]}}}function T_(e,t){return g_(e.document,e.getParameters(),t)}function E_(e,t){return{code:e,message:t,severity:`error`,range:{start:0,end:0},line:1,column:1}}function D_(e,t=8){let n=e.slice(0,t).map(e=>`- [${e.code}] ${e.message} (line ${e.line}, column ${e.column})`);return e.length>n.length&&n.push(`- ${e.length-n.length} more diagnostic(s).`),n.join(`
56
+ `;)r+=1;else if(t===`\\`){if(r+1>=e.length){n({kind:`command`,value:`backslash`,offset:r}),r+=1;continue}let t=e[r+1];if(t===`\\`){n({kind:`newline`,value:`\\\\`,offset:r}),r+=2;continue}if(/[A-Za-z]/.test(t)){let t=r+1;for(;t<e.length&&/[A-Za-z]/.test(e[t]);)t+=1;n({kind:`command`,value:e.slice(r+1,t),offset:r}),r=t;continue}n({kind:`command`,value:Object.hasOwn(Jf,t)?Jf[t]:t,offset:r}),r+=2}else if(t>=`0`&&t<=`9`){let t=/^\d+(?:\.\d*)?/.exec(e.slice(r));n({kind:`number`,value:t[0],offset:r}),r+=t[0].length}else if(t===`.`&&e[r+1]>=`0`&&e[r+1]<=`9`){let t=/^(?:\d+(?:\.\d*)?|\.\d+)/.exec(e.slice(r));n({kind:`number`,value:t[0],offset:r}),r+=t[0].length}else/[A-Za-z]/.test(t)?(n({kind:`letter`,value:t,offset:r}),r+=1):(n({kind:`punct`,value:t,offset:r}),r+=1)}return n({kind:`eof`,value:``,offset:e.length}),t}var tp={alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ϵ`,varepsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,vartheta:`ϑ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,varpi:`ϖ`,rho:`ρ`,varrho:`ϱ`,sigma:`σ`,varsigma:`ς`,tau:`τ`,upsilon:`υ`,phi:`φ`,varphi:`ϕ`,chi:`χ`,psi:`ψ`,omega:`ω`,Gamma:`Γ`,Delta:`Δ`,Theta:`Θ`,Lambda:`Λ`,Xi:`Ξ`,Pi:`Π`,Sigma:`Σ`,Upsilon:`Υ`,Phi:`Φ`,Psi:`Ψ`,Omega:`Ω`},np={cdot:`·`,times:`×`,div:`÷`,pm:`±`,mp:`∓`,le:`≤`,leq:`≤`,ge:`≥`,geq:`≥`,ne:`≠`,neq:`≠`,lt:`<`,gt:`>`,approx:`≈`,equiv:`≡`,sim:`∼`,propto:`∝`,infty:`∞`,partial:`∂`,nabla:`∇`,sum:`∑`,prod:`∏`,int:`∫`,iint:`∬`,oint:`∮`,to:`→`,rightarrow:`→`,leftarrow:`←`,Rightarrow:`⇒`,leftrightarrow:`↔`,in:`∈`,notin:`∉`,ni:`∋`,subset:`⊂`,supset:`⊃`,subseteq:`⊆`,supseteq:`⊇`,cup:`∪`,cap:`∩`,emptyset:`∅`,forall:`∀`,exists:`∃`,neg:`¬`,land:`∧`,lor:`∨`,angle:`∠`,perp:`⊥`,parallel:`∥`,degree:`°`,prime:`′`,ldots:`…`,cdots:`⋯`,dots:`…`,langle:`⟨`,rangle:`⟩`,lbrace:`{`,rbrace:`}`,vert:`|`,lvert:`|`,rvert:`|`,lVert:`‖`,rVert:`‖`,backslash:`\\`,percent:`%`,amp:`&`,hash:`#`,underscore:`_`,dollar:`$`,colon:`:`},rp=new Set([`sin`,`cos`,`tan`,`arcsin`,`arccos`,`arctan`,`exp`,`ln`,`log`,`min`,`max`,`lim`,`det`,`sup`,`inf`,`arg`,`gcd`]),ip={space:`0.25em`,thinspace:`0.167em`,medspace:`0.222em`,thickspace:`0.278em`,negthinspace:`-0.167em`,quad:`1em`,qquad:`2em`,enspace:`0.5em`},ap=new Set([`displaystyle`,`textstyle`,`scriptstyle`,`scriptscriptstyle`,`limits`,`nolimits`]),op=class{tokens;pos=0;source;depth=0;constructor(e){this.source=e,this.tokens=ep(e)}enter(){if(this.depth+=1,this.depth>Zf)throw--this.depth,Error(`Formula is nested too deeply.`)}leave(){--this.depth}render(){let e=this.parseRow({});return e.length===1?e[0]:X(`mrow`,null,...e)}peek(e=0){return this.tokens[Math.min(this.pos+e,this.tokens.length-1)]}take(){return this.tokens[this.pos++]}atPunct(e){let t=this.peek();return t.kind===`punct`&&t.value===e}atCommand(e){let t=this.peek();return t.kind===`command`&&t.value===e}parseRow(e){this.enter();try{let t=[];for(;;){let n=this.peek();if(n.kind===`eof`||n.kind===`punct`&&e.chars?.has(n.value)||n.kind===`command`&&e.commands?.has(n.value)||n.kind===`newline`&&e.newline)break;t.push(this.parseAtom())}return t}finally{this.leave()}}parseAtom(){this.enter();try{return this.parseAtomBody()}finally{this.leave()}}parseAtomBody(){let e=this.peek(),t;return e.kind===`number`?(this.take(),t=X(`mn`,null,e.value)):e.kind===`letter`?(this.take(),t=X(`mi`,null,e.value)):e.kind===`punct`?t=this.parsePunctuation(e):e.kind===`newline`?(this.take(),t=X(`mspace`,{linebreak:`newline`})):e.kind===`command`?t=this.parseCommand(e):(this.take(),t=X(`mtext`,null,``)),this.applyScripts(t)}parsePunctuation(e){return this.take(),e.value===`{`?(--this.pos,this.parseBraceGroup()):e.value===`}`||e.value===`&`||e.value===`#`?X(`mo`,null,e.value):X(`mo`,e.value===`(`||e.value===`)`||e.value===`[`||e.value===`]`||e.value===`|`?{fence:`true`,stretchy:`true`}:null,e.value)}parseCommand(e){let t=e.value;if(t===`frac`||t===`dfrac`||t===`tfrac`)return this.take(),this.parseFraction();if(t===`sqrt`)return this.take(),this.parseRoot();if(t===`left`)return this.take(),this.parseLeft();if(t===`right`)return this.take(),this.readDelimiter()??X(`mrow`,null);if(t===`begin`)return this.take(),this.parseEnvironment();if(t===`end`)return this.take(),this.readRawGroup(),X(`mtext`,null,`\\end`);if(t===`text`||t===`textrm`||t===`mbox`||t===`operatorname`)return this.take(),X(`mtext`,null,this.readRawGroup());if(t===`mathrm`||t===`mathbf`||t===`mathit`||t===`mathsf`){this.take();let e=this.readRawGroup();return X(`mtext`,{mathvariant:t===`mathrm`?`normal`:t===`mathbf`?`bold`:t===`mathit`?`italic`:`sans-serif`},e)}if(t===`overline`||t===`bar`||t===`hat`||t===`tilde`||t===`vec`||t===`dot`||t===`ddot`)return this.take(),X(`mover`,{accent:`true`},this.parseRequiredArgument(),X(`mo`,{stretchy:`true`},t===`overline`||t===`bar`?`¯`:t===`hat`?`^`:t===`tilde`?`~`:t===`vec`?`→`:t===`dot`?`˙`:`¨`));if(ap.has(t))return this.take(),X(`mrow`,null);if(Object.hasOwn(ip,t))return this.take(),X(`mspace`,{width:ip[t]});if(rp.has(t))return this.take(),X(`mo`,{mathvariant:`normal`,form:`prefix`},t);if(Object.hasOwn(tp,t))return this.take(),X(`mi`,null,tp[t]);if(Object.hasOwn(np,t)){this.take();let e=np[t];return X(`mo`,e===`(`||e===`)`||e===`[`||e===`]`||e===`{`||e===`}`||e===`|`||e===`‖`||e===`⟨`||e===`⟩`?{fence:`true`,stretchy:`true`}:null,e)}return this.take(),X(`mtext`,null,`\\${t}`)}parseBraceGroup(){if(!this.atPunct(`{`))return X(`mrow`,null);this.take();let e=this.parseRow({chars:new Set([`}`])});return this.atPunct(`}`)&&this.take(),X(`mrow`,null,...e)}parseFraction(){return X(`mfrac`,null,this.parseRequiredArgument(),this.parseRequiredArgument())}parseRoot(){let e=null;if(this.atPunct(`[`)){this.take();let t=this.parseRow({chars:new Set([`]`])});this.atPunct(`]`)&&this.take(),e=X(`mrow`,null,...t)}let t=this.parseRequiredArgument();return e?X(`mroot`,null,t,e):X(`msqrt`,null,t)}parseRequiredArgument(){return this.atPunct(`{`)?this.parseBraceGroup():this.parseAtom()}parseLeft(){let e=this.readDelimiter(),t=this.parseRow({commands:new Set([`right`])}),n=null;return this.atCommand(`right`)&&(this.take(),n=this.readDelimiter()),!e&&!n?X(`mrow`,null,...t):X(`mrow`,null,e,...t,n)}readDelimiter(){let e=this.peek();if(e.kind===`punct`)return e.value===`.`?(this.take(),null):`()[]|`.includes(e.value)?(this.take(),X(`mo`,{fence:`true`,stretchy:`true`},e.value)):null;if(e.kind===`command`){let t={lbrace:`{`,rbrace:`}`,lvert:`|`,rvert:`|`,vert:`|`,lVert:`‖`,rVert:`‖`,Vert:`‖`,langle:`⟨`,rangle:`⟩`},n=Object.hasOwn(t,e.value)?t[e.value]:void 0;if(n)return this.take(),X(`mo`,{fence:`true`,stretchy:`true`},n)}return null}parseEnvironment(){let e=this.readRawGroup().trim();if(e!==`cases`)return X(`mtext`,null,`\\begin{${e}}`);let t=[],n=0;for(;!this.atCommand(`end`)&&this.peek().kind!==`eof`&&n<500;){n+=1;let e=[];for(;;){let t=this.parseRow({chars:new Set([`&`]),commands:new Set([`end`]),newline:!0});if(e.push(X(`mtd`,{columnalign:`left`},...t)),!this.atPunct(`&`))break;this.take()}if(t.push(X(`mtr`,null,...e)),this.peek().kind===`newline`)this.take();else{if(this.atCommand(`end`)||this.peek().kind===`eof`)break;this.take()}}this.atCommand(`end`)&&(this.take(),this.readRawGroup());let r=X(`mtable`,{columnalign:`left`,columnspacing:`1em`},...t);return X(`mrow`,null,X(`mo`,{fence:`true`,stretchy:`true`},`{`),r)}applyScripts(e){let t=null,n=null,r=!1;for(;;)if(this.atPunct(`^`))this.take(),n=this.parseScriptArgument(),r=!0;else if(this.atPunct(`_`))this.take(),t=this.parseScriptArgument(),r=!0;else break;return r?t!==null&&n!==null?X(`msubsup`,null,e,t,n):n===null?X(`msub`,null,e,t):X(`msup`,null,e,n):e}parseScriptArgument(){return this.atPunct(`{`)?this.parseBraceGroup():this.atPunct(`+`)||this.atPunct(`-`)?X(`mrow`,null,X(`mo`,null,this.take().value),this.parseAtom()):this.parseAtom()}readRawGroup(){if(!this.atPunct(`{`))return``;let e=this.take(),t=1,n=this.pos;for(;n<this.tokens.length;n+=1){let e=this.tokens[n];if(e.kind===`eof`)break;if(e.kind===`punct`){if(e.value===`{`)t+=1;else if(e.value===`}`&&(--t,t===0))break}}if(n>=this.tokens.length||this.tokens[n].kind===`eof`)return this.pos=n,this.source.slice(e.offset+1);let r=this.tokens[n];return this.pos=n+1,this.source.slice(e.offset+1,r.offset)}};function sp({source:e,display:t=!1}){let n=$f(e),r;if(e.length>Yf)r=X(`mtext`,null,n);else try{r=new op(e).render()}catch{r=X(`mtext`,null,n)}let i=e.length>Qf?n:e;return X(`math`,{display:t?`block`:`inline`,className:t?`local-math local-math-block`:`local-math`,"aria-label":i},X(`semantics`,null,X(`mrow`,null,r),X(`annotation`,{encoding:`application/x-tex`},i)))}var cp=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Z=s(((e,t)=>{t.exports=cp()}))(),lp=e=>e,up=(0,y.createContext)(`en`);function dp({locale:e=`en`,children:t}){return(0,Z.jsx)(up.Provider,{value:e,children:t})}function fp(){return(0,y.useContext)(up)}function pp(e,t,n){return e===`zh`?n:t}function Q(){let e=fp();return(0,y.useMemo)(()=>(t,n)=>pp(e,t,n),[e])}var mp=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--chart-5)`,`var(--chart-6)`,`var(--chart-7)`,`var(--chart-8)`],hp=520,gp=320,_p=520,vp=320,yp=520,bp=120,xp=46,Sp=150,Cp=12.5,wp=10,Tp=100,Ep=2,Dp=15,Op=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,kp=/^\s*\{\{([\s\S]*)\}\}\s*$/;function Ap(e){if(!Number.isFinite(e))return`—`;if(Object.is(e,-0))return`0`;let t=Math.abs(e);return t>=0xe8d4a51000||t>0&&t<1e-4?e.toExponential(3).replace(/(\.\d*?)0+e/,`$1e`).replace(/\.e/,`e`):Number(e.toFixed(6)).toString()}function jp(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e6||t>0&&t<.001?e.toExponential(2):Number(e.toFixed(4)).toString()}function Mp(e){return e instanceof Error?e.message:String(e)}function Np(e,t,n,r=``){let i=t?.[n];if(i===void 0)return r;try{return e.text(i)}catch{return r}}function Pp(e,t,n,r){let i=t?.[n];if(i===void 0)return r;let a=i.trim();if(!a)return null;let o=kp.exec(a);try{let t=o?e.evaluate(o[1].trim()):Number(a);return typeof t==`number`&&Number.isFinite(t)?t:null}catch{return null}}function Fp(e,t,n,r){let i=t?.[n];if(i===void 0)return r;let a=i.trim();if(!a||a===`true`)return!0;if(a===`false`)return!1;let o=kp.exec(a);if(!o)return r;try{let t=e.evaluate(o[1].trim());return typeof t==`boolean`?t:r}catch{return r}}function Ip(e,t,n,r){let i=Pp(e,t,n,r);return i===null||!Number.isFinite(i)?r:Math.trunc(i)}function Lp(e,t){return e.length>t?`${e.slice(0,Math.max(1,t-1))}…`:e}function Rp(e,t=8,n=2){if(!e)return[``];let r=[],i=e;for(;i&&r.length<n-1;)r.push(i.slice(0,t)),i=i.slice(t);return(i||r.length===0)&&r.push(i.length>t?`${i.slice(0,Math.max(1,t-1))}…`:i),r}function zp(e,t){let n=Array.from(e),r=Array.from(t),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1){let t=(n[e].codePointAt(0)??0)-(r[e].codePointAt(0)??0);if(t!==0)return t}return n.length-r.length}function Bp(e,t,n=5){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)return[e];let r=(t-e)/Math.max(1,n-1),i=10**Math.floor(Math.log10(r)),a=r/i,o=(a<=1?1:a<=2?2:a<=5?5:10)*i,s=Math.ceil(e/o)*o,c=[];for(let e=s;e<=t+o*1e-9&&c.length<40;e+=o)c.push(Number(e.toFixed(10)));return c}function Vp(e,t){let n=1/0,r=-1/0;for(let t of e)Number.isFinite(t)&&(t<n&&(n=t),t>r&&(r=t));if(!Number.isFinite(n)||!Number.isFinite(r))return{min:0,max:1};if(t&&(n=Math.min(n,0),r=Math.max(r,0)),n===r){let e=Math.abs(n)>0?Math.abs(n)*.15:1;n-=e,r+=e}else{let e=(r-n)*.06;n-=e,r+=e,t&&(n=Math.min(n,0),r=Math.max(r,0))}return{min:n,max:r}}function Hp(e,t){return Math.max(46,...e.map(e=>jp(e).length*6+(t?24:10)))}function Up(e,t,n){let r=e.currentTarget,i=r.ownerSVGElement??r.closest(`svg`);if(!i)return;let a=Array.from(i.querySelectorAll(t)),o=a.indexOf(r);o<0||a.length===0||(e.preventDefault(),a[(o+n+a.length)%a.length]?.focus())}function Wp(e){return e.key===`Enter`||e.key===` `||e.key===`Spacebar`}function Gp(e,t=lp){return e===null?{text:``,kind:`null`,error:null}:typeof e==`string`?{text:e,kind:`string`,error:null}:typeof e==`number`?Number.isFinite(e)?{text:Ap(e),kind:`number`,error:null}:{text:t(`Cannot compute`,`无法计算`),kind:`error`,error:t(`Result is not a finite number`,`结果不是有限数字`)}:typeof e==`boolean`?{text:e?`true`:`false`,kind:`boolean`,error:null}:{text:t(`Cannot compute`,`无法计算`),kind:`array`,error:t(`Arrays must first be converted with a function such as len`,`数组需要先用 len 等函数转换`)}}function Kp(e,t,n=lp){let r=``,i=null;for(let a of e??[])if(a.type===`text`||a.type===`inlineCode`||a.type===`code`)r+=a.value??``;else if(a.type===`interpolation`)try{let e=Gp(t.evaluate((a.value??``).trim()),n);e.error&&(i??=e.error),r+=e.text}catch(e){i??=Mp(e),r+=n(`Cannot compute`,`无法计算`)}else if(a.type===`inlineMath`||a.type===`math`)r+=a.value??``;else if(a.type===`image`)r+=a.alt??``;else if(a.children&&a.children.length>0){let e=Kp(a.children,t,n);r+=e.text,i??=e.error}else a.value&&(r+=a.value);return{text:r,error:i}}function qp(e,t,n=lp){let r=e.children??[],i=r.filter(e=>!(e.type===`text`&&!(e.value??``).trim()));if(i.length===1&&i[0].type===`interpolation`)try{let a=t.evaluate((i[0].value??``).trim()),o=Gp(a,n);return{node:e,children:r,text:o.text,value:a,kind:o.kind,numeric:o.kind===`number`?a:null,error:o.error}}catch(t){return{node:e,children:r,text:n(`Cannot compute`,`无法计算`),value:void 0,kind:`error`,numeric:null,error:Mp(t)}}let a=Kp(r,t,n);if(i.length>0&&i.every(e=>e.type===`text`)&&Op.test(a.text.trim())){let t=Number(a.text.trim());if(Number.isFinite(t))return{node:e,children:r,text:a.text,value:t,kind:`number`,numeric:t,error:null}}let o=!a.text.trim()&&!a.error;return{node:e,children:r,text:a.error?n(`Cannot compute`,`无法计算`):a.text,value:a.text,kind:a.error?`error`:o?`empty`:`string`,numeric:null,error:a.error}}function Jp(e,t=lp){return e?e.error?t(`Cannot compute`,`无法计算`):e.text:``}function Yp(e,t,n=lp){let r=e.children?.find(e=>e.type===`table`);if(!r)return null;let i=r.children?.filter(e=>e.type===`tableRow`)??[];if(i.length===0)return null;let a=(i[0].children??[]).map(e=>qp(e,t,n));return{tableNode:r,header:a,headerText:a.map(e=>Jp(e,n)),rows:i.slice(1).map((e,r)=>({index:r,cells:(e.children??[]).map(e=>qp(e,t,n))}))}}function Xp(e,t){let n=!1;for(let r of e.rows){let e=r.cells[t];if(e&&e.kind!==`empty`){if(e.numeric===null)return!1;n=!0}}return n}function Zp(e,t){let n=(e?.key??``).trim();return n?t.findIndex(e=>e.trim()===n):-1}function Qp(e,t,n){return e<0?``:Jp(t.cells[e],n).trim()}function $p(e,t,n){if(!n)return``;try{let n=e.get(t);return typeof n==`string`?n:``}catch{return``}}function em({className:e,label:t,children:n}){let r=(0,y.useId)();return(0,Z.jsxs)(`figure`,{className:`local-visual ${e}`,"aria-labelledby":r,children:[(0,Z.jsx)(`figcaption`,{id:r,className:`local-visual-title`,children:t}),n]})}function tm({message:e,kind:t=`status`}){return(0,Z.jsx)(`p`,{className:`local-visual-message local-visual-${t}`,role:t,children:e})}function nm({notes:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{className:`local-visual-notes`,role:`status`,children:e.map((e,t)=>(0,Z.jsx)(`li`,{children:e},`${e}-${t}`))})}function rm({items:e,hidden:t,onToggle:n,label:r,mode:i}){let a=Q(),o=i!==`static`;return(0,Z.jsx)(`div`,{className:`local-visual-legend${o?``:` local-static-legend`}`,role:`group`,"aria-label":o?r:a(`Legend`,`图例`),children:e.map((e,r)=>{let i=t.has(r);return o?(0,Z.jsxs)(`button`,{type:`button`,className:`local-visual-legend-item${i?` is-off`:``}`,"aria-pressed":!i,disabled:e.disabled,onClick:()=>n(r),title:i?a(`Show ${e.name}`,`显示 ${e.name}`):a(`Hide ${e.name}`,`隐藏 ${e.name}`),children:[(0,Z.jsx)(`span`,{className:`local-visual-swatch`,style:{backgroundColor:e.color},"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`local-visual-legend-text`,children:[e.name,e.detail?a(` (${e.detail})`,`(${e.detail})`):``]})]},`${e.name}-${r}`):(0,Z.jsxs)(`span`,{className:`local-visual-legend-item local-static-legend-item`,children:[(0,Z.jsx)(`span`,{className:`local-visual-swatch`,style:{backgroundColor:e.color},"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`local-visual-legend-text`,children:[e.name,e.detail?a(` (${e.detail})`,`(${e.detail})`):``]})]},`${e.name}-${r}`)})})}function im({node:e,runtime:t,render:n,mode:r}){let i=Q(),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(1),[d,f]=(0,y.useState)(null),p=t.resetToken(e);(0,y.useEffect)(()=>{o(``),c(null),u(1),f(null)},[p]);let m=Np(t,e.attrs,`label`,i(`Table`,`表格`)),h=Fp(t,e.attrs,`searchable`,!0),g=Fp(t,e.attrs,`sortable`,!0),_=Ip(t,e.attrs,`page-size`,10),v=Math.max(1,_),b=Yp(e,t,i);if(!b||b.header.length===0)return(0,Z.jsx)(em,{className:`local-visual-table-block`,label:m,children:(0,Z.jsx)(tm,{message:i(`Table requires a non-empty Markdown table.`,`表格需要一个非空的 Markdown 表格。`),kind:`alert`})});let x=Zp(e.attrs,b.headerText),S=x>=0,C=$p(t,e,S),w=n=>{f(null);try{let r=t.set(e,n);r.length>0&&f(r.map(e=>i(tt(e,`en`),tt(e,`zh`))).join(`; `))}catch(e){f(Mp(e))}},T=b.header.map((e,t)=>Xp(b,t)),E=a.trim().toLowerCase(),D=[...b.rows.filter(e=>!E||e.cells.some(e=>Jp(e,i).toLowerCase().includes(E)))];if(s){let e=T[s.column];D.sort((t,n)=>{let r=t.cells[s.column],a=n.cells[s.column],o;if(e){let e=r?.numeric??-1/0,t=a?.numeric??-1/0;o=e===t?0:e<t?-1:1}else o=zp(Jp(r,i),Jp(a,i));return o===0?t.index-n.index:s.direction===`asc`?o:-o})}let O=Math.max(1,Math.ceil(D.length/v)),k=Math.min(l,O),A=D.slice((k-1)*v,k*v),j=e=>{u(1),c(t=>!t||t.column!==e?{column:e,direction:`asc`}:t.direction===`asc`?{column:e,direction:`desc`}:null)},M=e=>!s||s.column!==e?null:(0,Z.jsx)(`span`,{className:`local-visual-sort-marker`,"aria-hidden":`true`,children:s.direction===`asc`?`▲`:`▼`});return r===`static`?(0,Z.jsxs)(em,{className:`local-visual-table-block local-static-table-block`,label:m,children:[(0,Z.jsx)(`div`,{className:`local-visual-table-scroll local-static-table-scroll`,children:(0,Z.jsxs)(`table`,{className:`local-visual-table local-static-table`,children:[(0,Z.jsx)(`caption`,{className:`local-visual-sr-only`,children:m}),(0,Z.jsx)(`thead`,{children:(0,Z.jsx)(`tr`,{children:b.header.map((e,t)=>(0,Z.jsx)(`th`,{scope:`col`,className:T[t]?`is-numeric`:void 0,children:Jp(e,i)},`head-${t}`))})}),(0,Z.jsx)(`tbody`,{children:b.rows.map(e=>{let t=S?Qp(x,e,i):``,r=S&&t!==``&&t===C;return(0,Z.jsx)(`tr`,{className:r?`is-selected local-static-selected`:void 0,children:b.header.map((t,a)=>{let o=e.cells[a];return(0,Z.jsxs)(`td`,{className:T[a]?`is-numeric`:void 0,children:[r&&a===0?(0,Z.jsx)(`span`,{className:`local-visual-sr-only`,children:i(`Selected row`,`已选择行`)}):null,o?.error?(0,Z.jsx)(`span`,{className:`local-visual-cell-error`,title:o.error,children:i(`Cannot compute`,`无法计算`)}):n(o?.children??[])]},`cell-${e.index}-${a}`)})},`row-${e.index}`)})})]})}),b.rows.length===0?(0,Z.jsx)(tm,{message:i(`No rows to display`,`没有可显示的行`)}):null]}):(0,Z.jsxs)(em,{className:`local-visual-table-block`,label:m,children:[h?(0,Z.jsxs)(`label`,{className:`local-visual-search`,children:[(0,Z.jsx)(`span`,{children:i(`Search`,`搜索`)}),(0,Z.jsx)(`input`,{type:`search`,value:a,placeholder:i(`Search all columns`,`搜索所有列`),"aria-label":i(`Search ${m}`,`搜索${m}`),onChange:e=>{o(e.target.value),u(1)}})]}):null,(0,Z.jsx)(`div`,{className:`local-visual-table-scroll`,children:(0,Z.jsxs)(`table`,{className:`local-visual-table`,children:[(0,Z.jsx)(`caption`,{className:`local-visual-sr-only`,children:m}),(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{children:[S?(0,Z.jsx)(`th`,{scope:`col`,className:`local-visual-select-column`,children:(0,Z.jsx)(`span`,{className:`local-visual-sr-only`,children:i(`Select`,`选择`)})}):null,b.header.map((e,t)=>{let n=s&&s.column===t?s.direction===`asc`?`ascending`:`descending`:`none`;return(0,Z.jsx)(`th`,{scope:`col`,"aria-sort":n,className:T[t]?`is-numeric`:void 0,children:g?(0,Z.jsxs)(`button`,{type:`button`,className:`local-visual-sort-button${s&&s.column===t?` is-sorted`:``}`,onClick:()=>j(t),title:i(`Click to cycle ascending, descending and original order`,`点击切换升序、降序和原始顺序`),children:[Jp(e,i),M(t)]}):Jp(e,i)},`head-${t}`)})]})}),(0,Z.jsx)(`tbody`,{children:A.map(e=>{let t=S?Qp(x,e,i):``,r=S&&t!==``&&t===C;return(0,Z.jsxs)(`tr`,{className:r?`is-selected`:void 0,children:[S?(0,Z.jsx)(`td`,{className:`local-visual-select-cell`,children:t?(0,Z.jsx)(`button`,{type:`button`,className:`local-visual-select-button${r?` is-selected`:``}`,"aria-pressed":r,"aria-label":i(`Select row ${t}`,`选择行 ${t}`),title:i(`Select row ${t}`,`选择行 ${t}`),onClick:()=>w(t),children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:r?`●`:`○`})}):null}):null,b.header.map((t,r)=>{let a=e.cells[r];return(0,Z.jsx)(`td`,{className:T[r]?`is-numeric`:void 0,children:a?.error?(0,Z.jsx)(`span`,{className:`local-visual-cell-error`,title:a.error,children:i(`Cannot compute`,`无法计算`)}):n(a?.children??[])},`cell-${e.index}-${r}`)})]},`row-${e.index}`)})})]})}),d?(0,Z.jsx)(tm,{message:d,kind:`alert`}):null,D.length===0?(0,Z.jsx)(tm,{message:i(`No matching results`,`没有匹配结果`)}):null,O>1?(0,Z.jsxs)(`nav`,{className:`local-visual-pagination`,"aria-label":i(`Table pagination`,`表格分页`),children:[(0,Z.jsx)(`button`,{type:`button`,disabled:k<=1,onClick:()=>u(e=>Math.max(1,e-1)),children:i(`Previous`,`上一页`)}),(0,Z.jsx)(`span`,{children:i(`Page ${k} of ${O} · ${D.length} rows`,`第 ${k} / ${O} 页 · 共 ${D.length} 行`)}),(0,Z.jsx)(`button`,{type:`button`,disabled:k>=O,onClick:()=>u(e=>Math.min(O,e+1)),children:i(`Next`,`下一页`)})]}):null]})}var am=[`bar`,`line`,`area`,`scatter`,`donut`];function om(e,t,n,r,i,a){let o=(n,r)=>[e+n*Math.cos(r),t+n*Math.sin(r)],[s,c]=o(n,i),[l,u]=o(n,a),[d,f]=o(r,a),[p,m]=o(r,i),h=+(a-i>Math.PI);return[`M ${s} ${c}`,`A ${n} ${n} 0 ${h} 1 ${l} ${u}`,`L ${d} ${f}`,`A ${r} ${r} 0 ${h} 0 ${p} ${m}`,`Z`].join(` `)}function sm({node:e,runtime:t,mode:n}){let r=Q(),i=n===`static`,[a,o]=(0,y.useState)(new Set),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),p=t.resetToken(e);(0,y.useEffect)(()=>{o(new Set),c(new Set),u(null),f(null)},[p]);let m=(0,y.useId)(),h=Np(t,e.attrs,`title`,``)||Np(t,e.attrs,`label`,``)||r(`Chart`,`图表`),g=(e.attrs?.kind??`bar`).trim().toLowerCase(),_=am.includes(g)?g:null,v=Np(t,e.attrs,`x-label`,``),b=Np(t,e.attrs,`y-label`,``),x=Yp(e,t,r);if(!x||x.header.length===0)return(0,Z.jsx)(em,{className:`local-visual-chart`,label:h,children:(0,Z.jsx)(tm,{message:r(`chart body requires a non-empty Markdown table.`,`chart 正文需要一个非空的 Markdown 表格。`),kind:`alert`})});let S=x.headerText.map(e=>e.trim()),C=Zp(e.attrs,S),w=C>=0,T=$p(t,e,w),E=n=>{f(null);try{let i=t.set(e,n);i.length>0&&f(i.map(e=>r(tt(e,`en`),tt(e,`zh`))).join(`; `))}catch(e){f(Mp(e))}},D=x.rows.map(e=>({index:e.index,cells:e.cells,texts:S.map((t,n)=>Jp(e.cells[n],r)),keyValue:Qp(C,e,r)}));if(!_)return(0,Z.jsx)(em,{className:`local-visual-chart`,label:h,children:(0,Z.jsx)(tm,{message:r(`Unknown chart type "${g}".`,`未知图表类型“${g}”。`),kind:`alert`})});let O=[],k=[],A=(e.attrs?.x??``).trim(),j=A?S.indexOf(A):0;(j<0||j>=S.length)&&k.push(r(`x column "${A}" does not exist.`,`x 列“${A}”不存在。`));let M=(e.attrs?.y??``).split(`,`).map(e=>e.trim()).filter(Boolean),N=[];if(_===`donut`){if(M.length>1)k.push(r(`donut can only use one numeric column; specify a single column in y.`,`donut 只能使用一个数值列,请在 y 中指定唯一列。`));else if(M.length===1){let e=S.indexOf(M[0]);e<0?k.push(r(`y column "${M[0]}" does not exist.`,`y 列“${M[0]}”不存在。`)):N=[e]}else S.length===2?N=[1]:k.push(r(`A donut chart with more than two columns must use y to specify the single numeric column.`,`donut 多于两列时必须用 y 指定唯一数值列。`))}else if(M.length>0)for(let e of M){let t=S.indexOf(e);t<0?k.push(r(`y column "${e}" does not exist.`,`y 列“${e}”不存在。`)):N.includes(t)||N.push(t)}else N=S.map((e,t)=>t).filter(e=>e!==j);if(k.length===0&&N.length===0&&k.push(r(`Chart requires at least one numeric series.`,`图表至少需要一个数值系列。`)),k.length>0)return(0,Z.jsx)(em,{className:`local-visual-chart local-visual-chart-${_}`,label:h,children:k.map((e,t)=>(0,Z.jsx)(tm,{message:e,kind:`alert`},`${e}-${t}`))});let ee=N.map(e=>S[e]||r(`Series ${e+1}`,`系列 ${e+1}`)),P=0,te=0,F=D.map(e=>{let t=e.cells[j],n=e.texts[j]||r(`Item ${e.index+1}`,`第 ${e.index+1} 项`),i=t&&t.numeric!==null?t.numeric:null,a=N.map(t=>{let n=e.cells[t];return!n||n.kind===`empty`||n.numeric===null?(P+=1,null):(_===`donut`&&n.numeric<0&&(te+=1),n.numeric)});return{index:e.index,label:n,xValue:i,values:a,cells:e.cells,keyValue:e.keyValue}});P>0&&O.push(r(`${P} values are empty or cannot be computed; gaps are kept in the chart.`,`${P} 个数值为空或无法计算,图表中保留空缺。`));for(let e of N)Xp(x,e)||O.push(r(`Column "${S[e]}" is not purely numeric; non-numeric values are treated as gaps.`,`列“${S[e]}”不是纯数值列,非数值按空缺处理。`));_===`donut`&&te>0&&O.push(r(`Donut values must be non-negative; ignored ${te} negative values.`,`环形图数值必须非负,已忽略 ${te} 个负值。`)),_===`scatter`&&!Xp(x,j)&&O.push(r(`scatter horizontal axis column "${S[j]}" requires numeric values.`,`scatter 的横轴列“${S[j]}”需要数值。`));let ne=e=>{u(null),o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},re=e=>{u(null),c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ie=ee.map((e,t)=>({name:e,color:mp[t%mp.length]}));if(_===`donut`){let e=F.map(e=>e.values[0]),t=e.map(e=>e!==null&&e>=0?e:0),a=t.reduce((e,t,n)=>!i&&s.has(n)?e:e+t,0),o=F.map((n,r)=>({name:n.label,color:mp[r%mp.length],detail:e[r]===null?`—`:Ap(e[r]),disabled:t[r]<=0}));if(a<=0)return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-donut`,label:h,children:[(0,Z.jsx)(tm,{message:r(`No share to display`,`暂无占比`)}),(0,Z.jsx)(nm,{notes:O}),(0,Z.jsx)(rm,{items:o,hidden:s,onToggle:re,label:r(`Legend`,`图例`),mode:n})]});let c=-Math.PI/2,f=[];F.forEach((e,n)=>{if(!i&&s.has(n))return;let r=t[n];if(r<=0)return;let o=r/a*Math.PI*2,l=c,u=c+o;c=u,f.push({key:`donut:${n}`,label:e.label,value:r,start:l,end:u,color:mp[n%mp.length],x:170,y:120,rowKey:e.keyValue})});let p=l?r(`${l.label}: ${Ap(l.value)}`,`${l.label}:${Ap(l.value)}`):r(`Focus a slice or legend to view values`,`聚焦扇区或图例查看数值`);return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-donut${i?` local-static-chart`:``}`,label:h,children:[i?null:(0,Z.jsx)(`div`,{className:`local-visual-readout`,id:m,"aria-live":`polite`,children:p}),(0,Z.jsx)(`div`,{className:`local-visual-svg-wrap`,children:(0,Z.jsxs)(`svg`,{className:`local-visual-svg`,viewBox:`0 0 340 240`,role:`group`,"aria-label":r(`${h}, donut chart, ${F.length} items`,`${h},环形图,共 ${F.length} 项`),"aria-describedby":i?void 0:m,children:[(0,Z.jsxs)(`g`,{className:`local-visual-donut-center`,"aria-hidden":`true`,children:[(0,Z.jsx)(`text`,{x:170,y:118,textAnchor:`middle`,className:`local-visual-donut-total`,children:Ap(a)}),(0,Z.jsx)(`text`,{x:170,y:138,textAnchor:`middle`,className:`local-visual-donut-caption`,children:Lp(ee[0],14)})]}),f.map(e=>{let t=w&&e.rowKey!==``,n=t&&e.rowKey===T,a={key:e.key,series:ee[0],label:e.label,value:e.value,x:e.x,y:e.y,rowKey:e.rowKey,selectable:t,selected:n},o=i?{}:{"data-chart-mark":``,...t?{"data-chart-selectable":``}:{},tabIndex:0,role:t?`button`:`img`,...t?{"aria-pressed":n}:{},"aria-label":r(`${e.label}: ${Ap(e.value)}`,`${e.label}:${Ap(e.value)}`),onFocus:()=>u(a),onBlur:()=>u(null),onPointerEnter:()=>u(a),onPointerLeave:()=>u(null),onClick:t?()=>E(e.rowKey):void 0,onKeyDown:n=>{t&&Wp(n)?(n.preventDefault(),E(e.rowKey)):n.key===`ArrowRight`||n.key===`ArrowDown`?Up(n,`[data-chart-mark]`,1):(n.key===`ArrowLeft`||n.key===`ArrowUp`)&&Up(n,`[data-chart-mark]`,-1)}},s=`local-visual-donut-slice${n?` is-selected`:``}`;return e.end-e.start>=Math.PI*2-1e-6?(0,Z.jsx)(`circle`,{className:s,cx:170,cy:120,r:77,fill:`none`,style:{stroke:e.color},strokeWidth:30,...o,children:(0,Z.jsx)(`title`,{children:r(`${e.label}: ${Ap(e.value)}`,`${e.label}:${Ap(e.value)}`)})},e.key):(0,Z.jsx)(`path`,{className:s,d:om(170,120,92,62,e.start,e.end),style:{fill:e.color},...o,children:(0,Z.jsx)(`title`,{children:r(`${e.label}: ${Ap(e.value)}`,`${e.label}:${Ap(e.value)}`)})},e.key)})]})}),(0,Z.jsx)(rm,{items:o,hidden:s,onToggle:re,label:r(`Legend, toggle slices`,`图例,可开关扇区`),mode:n}),d?(0,Z.jsx)(tm,{message:d,kind:`alert`}):null,(0,Z.jsx)(nm,{notes:O})]})}let ae=ee.map((e,t)=>t).filter(e=>i||!a.has(e));if(ae.length===0)return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-${_}`,label:h,children:[(0,Z.jsx)(tm,{message:r(`All series are hidden in the legend`,`所有系列已在图例中关闭`)}),(0,Z.jsx)(rm,{items:ie,hidden:a,onToggle:ne,label:r(`Legend, toggle series`,`图例,可开关系列`),mode:n})]});let oe=Xp(x,j),se=_===`scatter`?!0:_===`line`||_===`area`?oe:!1,ce=se?F.filter(e=>e.xValue!==null):F;se&&ce.length<F.length&&O.push(r(`${F.length-ce.length} rows have an empty or non-numeric horizontal axis and are not plotted.`,`${F.length-ce.length} 行横轴为空或不是数值,未参与绘制。`));let le=[];for(let e of ce)for(let t of ae){let n=e.values[t];n!==null&&le.push(n)}if(ce.length===0)return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-${_}`,label:h,children:[(0,Z.jsx)(tm,{message:r(`No data rows to plot`,`没有可绘制的数据行`)}),(0,Z.jsx)(nm,{notes:O}),(0,Z.jsx)(rm,{items:ie,hidden:a,onToggle:ne,label:r(`Legend, toggle series`,`图例,可开关系列`),mode:n})]});if(le.length===0)return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-${_}`,label:h,children:[(0,Z.jsx)(tm,{message:r(`No values to read`,`没有可读取的数值`)}),(0,Z.jsx)(nm,{notes:O}),(0,Z.jsx)(rm,{items:ie,hidden:a,onToggle:ne,label:r(`Legend, toggle series`,`图例,可开关系列`),mode:n})]});let ue=Vp(le,_===`bar`||_===`area`),de=Bp(ue.min,ue.max,5),fe=Hp(de,!!b),pe=506-fe,me=e=>16+(ue.max-e)/(ue.max-ue.min)*258,I=me(Math.max(ue.min,Math.min(ue.max,0))),L=se&&ce.length>0?Vp(ce.map(e=>e.xValue).filter(e=>e!==null),!1):null,he=pe/Math.max(1,F.length),ge=e=>fe+he*(e+.5),_e=e=>fe+(e-L.min)/(L.max-L.min)*pe,ve=(e,t)=>L?e.xValue===null?null:_e(e.xValue):ge(t),ye=[];if(L)ye.push(...Bp(L.min,L.max,5));else{let e=Math.max(1,Math.ceil(F.length/6));for(let t=0;t<F.length;t+=e)ye.push(t);let t=F.length-1;t>=0&&ye[ye.length-1]!==t&&(ye.length>1&&t-ye[ye.length-1]<e*.6?ye[ye.length-1]=t:ye.push(t))}let be=e=>L?fe+(e-L.min)/(L.max-L.min)*pe:ge(e),xe=i||!l?null:L?(0,Z.jsx)(`line`,{className:`local-visual-guide`,x1:Math.max(fe,Math.min(506,l.x)),x2:Math.max(fe,Math.min(506,l.x)),y1:16,y2:274}):null,Se=e=>i?{}:{"data-chart-mark":``,...e.selectable?{"data-chart-selectable":``}:{},tabIndex:0,role:e.selectable?`button`:`img`,...e.selectable?{"aria-pressed":e.selected}:{},"aria-label":r(`${e.series}, ${e.label}${e.selectable&&e.rowKey!==e.label?`, ${e.rowKey}`:``}: ${Ap(e.value)}`,`${e.series},${e.label}${e.selectable&&e.rowKey!==e.label?`,${e.rowKey}`:``}:${Ap(e.value)}`),onFocus:()=>u(e),onBlur:()=>u(null),onPointerEnter:()=>u(e),onPointerLeave:()=>u(null),onClick:e.selectable?()=>E(e.rowKey):void 0,onKeyDown:t=>{e.selectable&&Wp(t)?(t.preventDefault(),E(e.rowKey)):t.key===`ArrowRight`||t.key===`ArrowDown`?Up(t,`[data-chart-mark]`,1):(t.key===`ArrowLeft`||t.key===`ArrowUp`)&&Up(t,`[data-chart-mark]`,-1)}},Ce=(e,t,n,r,i)=>{let a=w&&t.keyValue!==``;return{key:`${e}:${t.index}`,series:ee[e],label:t.label,value:n,x:r,y:i,rowKey:t.keyValue,selectable:a,selected:a&&t.keyValue===T}},we=[];if(_===`bar`){let e=he*.76,t=Math.max(1,e/Math.max(1,ae.length));F.forEach((n,i)=>{ae.forEach((a,o)=>{let s=n.values[a];if(s===null)return;let c=fe+he*i+(he-e)/2+o*t,l=Math.max(1,Math.abs(me(s)-I)),u=s>=0?I-l:I,d=Math.max(1.5,t-1),f=Math.min(4,d/2,l/2),p=Ce(a,n,s,c+t/2,u+l/2);we.push((0,Z.jsx)(`rect`,{className:`local-visual-bar${p.selected?` is-selected`:``}`,x:c,y:u,width:d,height:l,rx:f,style:{fill:mp[a%mp.length]},...Se(p),children:(0,Z.jsx)(`title`,{children:r(`${p.series}, ${p.label}: ${Ap(p.value)}`,`${p.series},${p.label}:${Ap(p.value)}`)})},`bar-${a}-${n.index}`))})})}let Te=[],Ee=[],De=[];if(_===`line`||_===`area`)for(let e of ae){let t=[],n=[],i=()=>{n.length>0&&t.push(n),n=[]};F.forEach((t,r)=>{let a=t.values[e],o=ve(t,r);a===null||o===null?i():n.push({row:t,value:a,x:o,y:me(a)})}),i();for(let n of t){if(n.length>=2){let t=n.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `);if(Te.push((0,Z.jsx)(`path`,{className:`local-visual-line`,d:t,fill:`none`,style:{stroke:mp[e%mp.length]},strokeWidth:2.4,strokeLinejoin:`round`,strokeLinecap:`round`},`line-${e}-${n[0].row.index}`)),_===`area`){let t=I,r=n[0],i=n[n.length-1],a=`M ${r.x} ${t} ${n.map(e=>`L ${e.x} ${e.y}`).join(` `)} L ${i.x} ${t} Z`;Ee.push((0,Z.jsx)(`path`,{className:`local-visual-area`,d:a,style:{fill:mp[e%mp.length]}},`area-${e}-${r.row.index}`))}}for(let t of n){let n=Ce(e,t.row,t.value,t.x,t.y);De.push((0,Z.jsxs)(`g`,{className:`local-visual-point-group`,children:[(0,Z.jsx)(`circle`,{className:`local-visual-hit${n.selected?` is-selected`:``}`,cx:t.x,cy:t.y,r:12,fill:`transparent`,...Se(n),children:(0,Z.jsx)(`title`,{children:r(`${n.series}, ${n.label}: ${Ap(n.value)}`,`${n.series},${n.label}:${Ap(n.value)}`)})}),(0,Z.jsx)(`circle`,{className:`local-visual-point${n.selected?` is-selected`:``}`,cx:t.x,cy:t.y,r:4.5,style:{fill:mp[e%mp.length],stroke:`var(--surface)`},strokeWidth:1.5,pointerEvents:`none`})]},`point-${e}-${t.row.index}`))}}}_===`scatter`&&F.forEach((e,t)=>{let n=ve(e,t);n!==null&&ae.forEach(t=>{let i=e.values[t];if(i===null)return;let a=me(i),o=Ce(t,e,i,n,a);De.push((0,Z.jsxs)(`g`,{className:`local-visual-point-group`,children:[(0,Z.jsx)(`circle`,{className:`local-visual-hit${o.selected?` is-selected`:``}`,cx:n,cy:a,r:15,fill:`transparent`,...Se(o),children:(0,Z.jsx)(`title`,{children:r(`${o.series}, ${o.label}: ${Ap(o.value)}`,`${o.series},${o.label}:${Ap(o.value)}`)})}),(0,Z.jsx)(`circle`,{className:`local-visual-point${o.selected?` is-selected`:``}`,cx:n,cy:a,r:6,style:{fill:mp[t%mp.length],stroke:`var(--surface)`},strokeWidth:1.5,pointerEvents:`none`})]},`scatter-${t}-${e.index}`))})});let Oe=l?r(`${l.series} · ${l.label}: ${Ap(l.value)}`,`${l.series} · ${l.label}:${Ap(l.value)}`):r(`Focus or point at a mark; use arrow keys to change the readout`,`聚焦或指向图形,用方向键切换读数`),ke=r(`${h}, ${_} chart, ${F.length} items, ${ae.length} series`,`${h},${_} 图,共 ${F.length} 项,${ae.length} 个系列`);return(0,Z.jsxs)(em,{className:`local-visual-chart local-visual-chart-${_}${i?` local-static-chart`:``}`,label:h,children:[i?null:(0,Z.jsx)(`div`,{className:`local-visual-readout`,id:m,"aria-live":`polite`,children:Oe}),(0,Z.jsx)(`div`,{className:`local-visual-svg-wrap`,children:(0,Z.jsxs)(`svg`,{className:`local-visual-svg`,viewBox:`0 0 ${hp} ${gp}`,role:`group`,"aria-label":ke,"aria-describedby":i?void 0:m,children:[de.map(e=>(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`line`,{className:`local-visual-grid-line`,x1:fe,x2:506,y1:me(e),y2:me(e)}),(0,Z.jsx)(`text`,{className:`local-visual-axis-label`,x:fe-6,y:me(e),textAnchor:`end`,dominantBaseline:`middle`,children:jp(e)})]},`y-${e}`)),ue.min<0&&ue.max>0?(0,Z.jsx)(`line`,{className:`local-visual-zero-line`,x1:fe,x2:506,y1:I,y2:I}):null,(0,Z.jsx)(`line`,{className:`local-visual-axis-line`,x1:fe,x2:506,y1:274,y2:274}),ye.map(e=>{let t=be(e),n=L?jp(e):Lp(F[e]?.label??``,8);return(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`line`,{className:`local-visual-tick`,x1:t,x2:t,y1:274,y2:279}),(0,Z.jsxs)(`text`,{className:`local-visual-axis-label`,x:t,y:293,textAnchor:`middle`,children:[n,!L&&F[e]?(0,Z.jsx)(`title`,{children:F[e].label}):null]})]},`x-${e}`)}),v?(0,Z.jsx)(`text`,{className:`local-visual-axis-title`,x:(fe+506)/2,y:318,textAnchor:`middle`,children:v}):null,b?(0,Z.jsx)(`text`,{className:`local-visual-axis-title`,transform:`translate(12 145) rotate(-90)`,textAnchor:`middle`,children:b}):null,Ee,Te,xe,we,De]})}),(0,Z.jsx)(rm,{items:ie,hidden:a,onToggle:ne,label:r(`Legend, toggle series`,`图例,可开关系列`),mode:n}),d?(0,Z.jsx)(tm,{message:d,kind:`alert`}):null,(0,Z.jsx)(nm,{notes:O})]})}var cm=64,lm=new WeakMap,um=new WeakMap;function dm(e,t){let n=lm.get(e);return n&&n.revision===t||(n={revision:t,requestedPoints:new Map,evaluation:{steps:0,limit:k}},lm.set(e,n)),n}function fm(e){let t=um.get(e);return t||(t=new Map,um.set(e,t)),t}function pm(e,t,n){if(e.size>=cm){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,n),n}function mm(e,t,n){return e.map(e=>{let r=/^y\s*=\s*([\s\S]+)$/.exec((e.value??``).trim());if(!r)return`\u0003${n}`;try{let e=Mn(r[1].trim());return JSON.stringify(e.dependencies.map(e=>t[e]??null))}catch{return`\u0003${n}`}}).join(``)}function hm(e,t,n,r,i,a,o,s,c,l=lp){let u=fm(s),d=u.get(t);if(d)return d;let f=dm(s,c),p=e=>pm(u,t,{ok:!1,message:e});if(n.length>16)return p(l(`plot supports at most 16 curves, but has ${n.length}.`,`plot 最多支持 16 条曲线,当前为 ${n.length} 条。`));let m=n.length*o;f.requestedPoints.set(e,m);let h=0;for(let e of f.requestedPoints.values())h+=e;if(h>2e4)return p(l(`The document's plot sample count exceeds the limit: ${h} requested, at most ${O} allowed. Reduce curves or samples.`,`整篇文档的绘图采样点超过上限:已请求 ${h} 个,最多 ${O} 个。请减少曲线或采样数。`));let g=[],_={message:null},v=n.map((e,t)=>{let n=(e.value??``).trim(),s=/^y\s*=\s*([\s\S]+)$/.exec(n);if(!s)return g.push(l(`Curve ${t+1}: cannot compute (each formula block must be written as y = expression).`,`曲线 ${t+1}:无法计算(每块公式需写成 y = 表达式)。`)),{source:n,expression:null,points:[],endpoint:null,error:`formula`};try{let e=Mn(s[1].trim()),t=In(e,r,i,a,o,f.evaluation);return{source:n,expression:e,points:t.points,endpoint:t.endpoint,error:null}}catch(e){return e instanceof B&&e.code===`latex-budget`?(_.message=e.message,{source:n,expression:null,points:[],endpoint:null,error:e.message}):(g.push(l(`Curve ${t+1}: cannot compute (${Mp(e)}).`,`曲线 ${t+1}:无法计算(${Mp(e)})。`)),{source:n,expression:null,points:[],endpoint:null,error:Mp(e)})}});return _.message===null?pm(u,t,{ok:!0,curves:v,notes:g}):p(l(`Plot computation exceeded the shared execution budget: ${_.message}`,`绘图计算超过共享执行预算:${_.message}`))}function gm(e){if(e.length===0)return 0;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?(t[n-1]+t[n])/2:t[n]}function _m(e,t,n,r){let i=[],a=[],o=(e,i)=>{let a=Math.abs(i.y-e.y),o=e.y*i.y<0&&Math.min(Math.abs(e.y),Math.abs(i.y))>Math.max(1,n*8),s=a>t*.8&&a>Math.max(r,1e-9)*10;return o||s};for(let t of e){if(t.y===null){a.length>0&&i.push(a),a=[];continue}let e={x:t.x,y:t.y},n=a[a.length-1];n&&o(n,e)&&(i.push(a),a=[]),a.push(e)}return a.length>0&&i.push(a),i}function vm({node:e,runtime:t,mode:n}){let r=Q(),i=fp(),a=n===`static`,[o,s]=(0,y.useState)(null),c=t.resetToken(e);(0,y.useEffect)(()=>{s(null)},[c]);let l=(0,y.useId)(),u=Np(t,e.attrs,`label`,``)||r(`Function plot`,`函数图`),d=Np(t,e.attrs,`x-label`,`x`),f=Np(t,e.attrs,`y-label`,`y`),p=Pp(t,e.attrs,`min`,-10),m=Pp(t,e.attrs,`max`,10),h=Math.min(2e3,Math.max(2,Ip(t,e.attrs,`samples`,200))),g=(e.children??[]).filter(e=>e.type===`math`||e.type===`inlineMath`),_=(()=>{try{return{...t.snapshot().state}}catch{return{}}})(),v=0;try{v=t.snapshot().revision}catch{v=0}let b=g.map(e=>`${e.id}\u0000${e.value??``}`).join(``),x=`${e.id}\u0000${p}\u0000${m}\u0000${h}\u0000${i}\u0000${b}`,S=mm(g,_,v),C=`${x}\u0002${S}`,w=(0,y.useMemo)(()=>g.length===0||p===null||m===null||!(m>p)?{ok:!0,curves:[],notes:[]}:hm(e.id,C,g,_,p,m,h,t,v,r),[x,S,e.id,t,r]);if(g.length===0)return(0,Z.jsx)(em,{className:`local-visual-plot`,label:u,children:(0,Z.jsx)(tm,{message:r(`plot body requires one or more $$ formula blocks.`,`plot 正文需要一个或多个 $$ 公式块。`),kind:`alert`})});if(p===null||m===null||!(m>p))return(0,Z.jsx)(em,{className:`local-visual-plot`,label:u,children:(0,Z.jsx)(tm,{message:r(`plot min must be less than max.`,`plot 的 min 必须小于 max。`),kind:`alert`})});if(!w.ok)return(0,Z.jsx)(em,{className:`local-visual-plot`,label:u,children:(0,Z.jsx)(tm,{message:w.message,kind:`alert`})});let{curves:T,notes:E}=w,D=T.flatMap(e=>e.points.filter(e=>e.y!==null&&Number.isFinite(e.y))),O=(0,Z.jsx)(`div`,{className:`local-visual-plot-legend`,role:`list`,"aria-label":r(`Curve legend`,`曲线图例`),children:T.map((e,t)=>(0,Z.jsxs)(`div`,{className:`local-visual-plot-legend-item`,role:`listitem`,children:[(0,Z.jsx)(`span`,{className:`local-visual-swatch`,style:{backgroundColor:mp[t%mp.length]},"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`local-visual-plot-legend-text`,children:(0,Z.jsx)(`span`,{className:`local-visual-plot-formula`,children:(0,Z.jsx)(sp,{source:e.source})})})]},`curve-legend-${t}`))});if(D.length===0)return(0,Z.jsxs)(em,{className:`local-visual-plot`,label:u,children:[(0,Z.jsx)(tm,{message:r(`No plottable values in the current range`,`当前范围内没有可绘制的值`)}),(0,Z.jsx)(nm,{notes:E}),O]});let A=Vp(D.map(e=>e.y),!1),j=Bp(A.min,A.max,5),M=Bp(p,m,5),N=Hp(j,!!f),ee=506-N,P=e=>N+(e-p)/(m-p)*ee,te=e=>16+(A.max-e)/(A.max-A.min)*258,F=gm(D.map(e=>Math.abs(e.y))),ne=[];for(let e of T)for(let t=1;t<e.points.length;t+=1){let n=e.points[t-1],r=e.points[t];n.y!==null&&r.y!==null&&ne.push(Math.abs(r.y-n.y))}let re=gm(ne),ie=A.max-A.min,ae=T.map(e=>_m(e.points,ie,F,re)),oe={steps:0,limit:k},se=(e,t)=>{if(!e.expression)return null;try{let n=e.expression.evaluate(t,_,oe);return typeof n==`number`&&Number.isFinite(n)?n:null}catch{return null}},ce=e=>Math.max(p,Math.min(m,e)),le=(m-p)/100,ue=e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=Math.max(0,Math.min(1,(e.clientX-t.left)/t.width));s(p+n*(m-p))},de=e=>{let t=e.shiftKey?10:1,n=o;if(e.key===`ArrowRight`)n=(o??(p+m)/2)+le*t;else if(e.key===`ArrowLeft`)n=(o??(p+m)/2)-le*t;else if(e.key===`Home`)n=p;else if(e.key===`End`)n=m;else return;e.preventDefault(),s(ce(n))},fe=a||o===null?null:ce(o),pe=fe===null?r(`Range [${Ap(p)}, ${Ap(m)}] · ${h} samples; use arrow keys or pointer to read values`,`区间 [${Ap(p)}, ${Ap(m)}] · ${h} 个采样点;用方向键或指针读取数值`):`${r(`x = ${Ap(fe)}; `,`x = ${Ap(fe)};`)}${T.map((e,t)=>{let n=se(e,fe),i=e.error?r(`cannot compute`,`无法计算`):n===null?r(`undefined`,`无定义`):Ap(n);return r(`Curve ${t+1}: `,`曲线 ${t+1}:`)+i}).join(r(`; `,`;`))}`,me=fe===null?null:T.map((e,t)=>{let n=se(e,fe);return n===null||!e.expression?null:(0,Z.jsx)(`circle`,{className:`local-visual-active-point`,cx:P(fe),cy:te(n),r:4.5,style:{fill:mp[t%mp.length],stroke:`var(--surface)`},strokeWidth:1.5},`active-${t}`)});return(0,Z.jsxs)(em,{className:`local-visual-plot`,label:u,children:[a?null:(0,Z.jsx)(`div`,{className:`local-visual-readout`,id:l,"aria-live":`polite`,children:pe}),(0,Z.jsx)(`div`,{className:`local-visual-svg-wrap`,children:(0,Z.jsxs)(`svg`,{className:`local-visual-svg`,viewBox:`0 0 ${_p} ${vp}`,role:`group`,"aria-label":r(`${u}, range ${Ap(p)} to ${Ap(m)}, ${h} samples`,`${u},区间 ${Ap(p)} 到 ${Ap(m)},${h} 个采样点`),"aria-describedby":a?void 0:l,tabIndex:a?void 0:0,onPointerMove:a?void 0:ue,onPointerLeave:a?void 0:()=>s(null),onFocus:a?void 0:()=>s(e=>e??(p+m)/2),onBlur:a?void 0:()=>s(null),onKeyDown:a?void 0:de,children:[j.map(e=>(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`line`,{className:`local-visual-grid-line`,x1:N,x2:506,y1:te(e),y2:te(e)}),(0,Z.jsx)(`text`,{className:`local-visual-axis-label`,x:N-6,y:te(e),textAnchor:`end`,dominantBaseline:`middle`,children:jp(e)})]},`y-${e}`)),A.min<0&&A.max>0?(0,Z.jsx)(`line`,{className:`local-visual-zero-line`,x1:N,x2:506,y1:te(0),y2:te(0)}):null,(0,Z.jsx)(`line`,{className:`local-visual-axis-line`,x1:N,x2:506,y1:274,y2:274}),M.map(e=>(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`line`,{className:`local-visual-tick`,x1:P(e),x2:P(e),y1:274,y2:279}),(0,Z.jsx)(`text`,{className:`local-visual-axis-label`,x:P(e),y:293,textAnchor:`middle`,children:jp(e)})]},`x-${e}`)),d?(0,Z.jsx)(`text`,{className:`local-visual-axis-title`,x:(N+506)/2,y:318,textAnchor:`middle`,children:d}):null,f?(0,Z.jsx)(`text`,{className:`local-visual-axis-title`,transform:`translate(12 145) rotate(-90)`,textAnchor:`middle`,children:f}):null,ae.map((e,t)=>e.map((e,n)=>{if(e.length<2)return null;let r=e.map((e,t)=>`${t===0?`M`:`L`} ${P(e.x)} ${te(e.y)}`).join(` `);return(0,Z.jsx)(`path`,{className:`local-visual-plot-line`,d:r,fill:`none`,style:{stroke:mp[t%mp.length]},strokeWidth:2.4,strokeLinejoin:`round`,strokeLinecap:`round`},`curve-${t}-${n}`)})),fe===null?null:(0,Z.jsx)(`line`,{className:`local-visual-guide`,x1:P(fe),x2:P(fe),y1:16,y2:274}),me]})}),(0,Z.jsx)(nm,{notes:E}),O]})}var ym={title:`Task`,start:`Start`,duration:`Duration`,notes:`Notes`},bm={title:`事项`,start:`开始`,duration:`时长`,notes:`说明`};function xm(e){let t=t=>e.includes(t.title)&&e.includes(t.start)&&e.includes(t.duration);return t(ym)?ym:t(bm)?bm:null}function Sm({node:e,runtime:t,render:n,mode:r}){let i=Q(),a=r!==`static`,[o,s]=(0,y.useState)(null),c=t.resetToken(e);(0,y.useEffect)(()=>{s(null)},[c]);let l=Np(t,e.attrs,`title`,``)||i(`Timeline`,`时间轴`),u=Np(t,e.attrs,`unit`,i(`minutes`,`分钟`)),d=Yp(e,t,i);if(!d)return(0,Z.jsx)(em,{className:`local-visual-timeline`,label:l,children:(0,Z.jsx)(tm,{message:i(`timeline body requires a Markdown table.`,`timeline 正文需要一个 Markdown 表格。`),kind:`alert`})});let f=d.headerText.map(e=>e.trim()),p=xm(f),m=p?f.indexOf(p.title):-1,h=p?f.indexOf(p.start):-1,g=p?f.indexOf(p.duration):-1,_=p?f.indexOf(p.notes):-1;if(!p||m<0||h<0||g<0)return(0,Z.jsx)(em,{className:`local-visual-timeline`,label:l,children:(0,Z.jsx)(tm,{message:i(`timeline table requires the "Task", "Start" and "Duration" columns.`,`timeline 表格需要“事项”“开始”“时长”三列,或“Task”“Start”“Duration”三列。`),kind:`alert`})});let v=[],b=[],x=[];if(d.rows.forEach((e,t)=>{let n=e.cells[h],r=e.cells[g],a=n?.numeric??null,o=r?.numeric??null;if(a===null||o===null||a<0||o<0){b.push(t+1);return}let s=Jp(e.cells[m],i)||i(`Task ${t+1}`,`事项 ${t+1}`);x.push({key:`item-${e.index}`,title:s,start:a,duration:o,description:_>=0?e.cells[_]?.children??[]:[],sourceIndex:t})}),b.length>0&&v.push(i(`Rows ${b.join(`, `)} have an invalid start or duration (must be non-negative numbers) and are hidden.`,`第 ${b.join(`、`)} 行的开始或时长不是非负数字,未显示。`)),x.length===0)return(0,Z.jsxs)(em,{className:`local-visual-timeline`,label:l,children:[(0,Z.jsx)(tm,{message:i(`No valid timeline items.`,`没有有效的时间轴事项。`)}),(0,Z.jsx)(nm,{notes:v})]});let S=[...x].sort((e,t)=>e.start-t.start||e.sourceIndex-t.sourceIndex),C=S.reduce((e,t)=>Math.max(e,t.start+t.duration),0),w=Math.max(1,C),T=Bp(0,w,5);(T.length===0||T[0]!==0)&&T.unshift(0),T[T.length-1]<w&&T.push(w);let E=u?` ${u}`:``,D=e=>`${Ap(e)}${E}`,O=S.find(e=>e.key===o)??null;return(0,Z.jsxs)(em,{className:`local-visual-timeline${a?``:` local-static-timeline`}`,label:l,children:[(0,Z.jsx)(`div`,{className:`local-visual-timeline-axis`,"aria-hidden":`true`,children:T.map((e,t)=>{let n=e/w*100,r=t===T.length-1?{left:`${n}%`,transform:`translateX(-100%)`}:t===0?{left:`0%`}:{left:`${n}%`,transform:`translateX(-50%)`};return(0,Z.jsx)(`span`,{className:`local-visual-timeline-tick`,style:r,children:jp(e)},`tick-${e}`)})}),(0,Z.jsx)(`ol`,{className:`local-visual-timeline-list`,children:S.map(e=>{let t=e.start+e.duration,r=e.start/w*100,c=e.duration/w*100,l=S.indexOf(e);return(0,Z.jsxs)(`li`,{className:`local-visual-timeline-item${a&&o===e.key?` is-active`:``}${a?``:` local-static-timeline-item`}`,tabIndex:a?0:void 0,"aria-label":a?i(`${e.title}, started ${D(e.start)}, ended ${D(t)}, duration ${D(e.duration)}${e.description.length>0?`, with notes`:``}`,`${e.title},开始 ${D(e.start)},结束 ${D(t)},时长 ${D(e.duration)}${e.description.length>0?`,有说明`:``}`):void 0,onFocus:a?()=>s(e.key):void 0,onBlur:a?()=>s(t=>t===e.key?null:t):void 0,onPointerEnter:a?()=>s(e.key):void 0,onPointerLeave:a?()=>s(t=>t===e.key?null:t):void 0,onKeyDown:a?e=>{e.key===`Escape`&&(e.preventDefault(),s(null))}:void 0,children:[(0,Z.jsxs)(`div`,{className:`local-visual-timeline-head`,children:[(0,Z.jsxs)(`span`,{className:`local-visual-timeline-title`,children:[(0,Z.jsx)(`span`,{className:`local-visual-swatch`,style:{backgroundColor:mp[l%mp.length]},"aria-hidden":`true`}),e.title]}),(0,Z.jsxs)(`span`,{className:`local-visual-timeline-times`,children:[i(`Started`,`开始`),` `,D(e.start),` · `,i(`Ended`,`结束`),` `,D(t),` · `,i(`Duration`,`时长`),` `,D(e.duration)]})]}),(0,Z.jsx)(`div`,{className:`local-visual-timeline-track`,"aria-hidden":`true`,children:(0,Z.jsx)(`span`,{className:`local-visual-timeline-bar${e.duration===0?` is-zero`:``}`,style:{left:`${r}%`,width:`${c}%`,backgroundColor:mp[l%mp.length]}})}),a||e.description.length===0?null:(0,Z.jsx)(`div`,{className:`local-visual-timeline-detail local-static-timeline-detail`,children:n(e.description)})]},e.key)})}),a?(0,Z.jsx)(`div`,{className:`local-visual-timeline-detail`,"aria-live":`polite`,children:O?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`strong`,{children:O.title}),O.description.length>0?n(O.description):(0,Z.jsx)(`span`,{children:i(`No notes.`,`没有说明。`)})]}):(0,Z.jsx)(`span`,{children:i(`Focus or point at an item to view its notes.`,`聚焦或指向事项查看说明。`)})}):null,(0,Z.jsx)(nm,{notes:v})]})}var Cm=/[\u1100-\u115f\u2e80-\u303f\u3040-\u33ff\u3400-\u4dbf\u4e00-\u9fff\uac00-\ud7af\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/u;function wm(e){let t=0;for(let n of e)Cm.test(n)?t+=1:/\s/u.test(n)?t+=.3:t+=.58;return t*Cp}function Tm(e,t){if(wm(e)<=t)return e;let n=``;for(let r of e){if(wm(`${n}${r}…`)>t)break;n+=r}return`${n.trimEnd()}…`}function Em(e){let t=[],n=``;for(let r of e)n&&wm(n+r)>Tp?(t.push(n),n=r):n+=r;if(n&&t.push(n),t.length<=Ep)return t;let r=t.slice(0,Ep);return r[1]=Tm(t.slice(1).join(``),Tp),r}function Dm(e){let t=Em(e);return{width:t.reduce((e,t)=>Math.max(e,wm(t)),0)+10,height:t.length*Dp+6,lines:t}}function Om(e){let t=new Map;for(let n of e){let e=`${n.from}\u0000${n.to}`;t.set(e,(t.get(e)??0)+1)}let n=new Map,r=new Map;for(let i of e){let e=`${i.from}\u0000${i.to}`,a=t.get(e)??1,o=n.get(e)??0;n.set(e,o+1),r.set(i.key,(o-(a-1)/2)*12)}return r}function km(e,t,n){let{width:r,height:i,positions:a}=e,o=Om(t),s=1/0,c=1/0,l=-1/0,u=-1/0;for(let e of t){if(!e.label)continue;let t=a.get(e.from),r=a.get(e.to);if(!t||!r)continue;let i=jm(n,t,r,o.get(e.key)??0,e.from===e.to),d=Dm(e.label);s=Math.min(s,i.labelX-d.width/2),c=Math.min(c,i.labelY-d.height/2),l=Math.max(l,i.labelX+d.width/2),u=Math.max(u,i.labelY+d.height/2)}if(!Number.isFinite(s))return e;let d=Math.max(0,wp-s),f=Math.max(0,wp-c),p=Math.max(0,l+wp-r),m=Math.max(0,u+wp-i);if(d===0&&f===0&&p===0&&m===0)return e;for(let e of a.values())e.x+=d,e.y+=f;return{width:r+d+p,height:i+f+m,positions:a}}function Am(e,t,n){let r=e.map(e=>e.id),i=new Map(r.map((e,t)=>[e,t])),a=new Set(r),o=new Map(r.map(e=>[e,[]]));for(let e of t)e.from!==e.to&&a.has(e.from)&&a.has(e.to)&&o.get(e.from).push(e.to);let s=new Map,c=new Map,l=new Set,u=[],d=[],f=0,p=e=>{s.set(e,f),c.set(e,f),f+=1,u.push(e),l.add(e);for(let t of o.get(e)??[])s.has(t)?l.has(t)&&c.set(e,Math.min(c.get(e),s.get(t))):(p(t),c.set(e,Math.min(c.get(e),c.get(t))));if(c.get(e)===s.get(e)){let t=[],n;do n=u.pop(),l.delete(n),t.push(n);while(n!==e);d.push(t.reverse())}};for(let e of r)s.has(e)||p(e);let m=new Map;d.forEach((e,t)=>{for(let n of e)m.set(n,t)});let h=d.map(()=>new Set),g=d.map(()=>0);for(let e of t){if(!a.has(e.from)||!a.has(e.to))continue;let t=m.get(e.from),n=m.get(e.to);t===n||h[t].has(n)||(h[t].add(n),g[n]+=1)}let _=d.map((e,t)=>({index:t,order:Math.min(...e.map(e=>i.get(e)??0))})),v=_.filter(e=>g[e.index]===0).map(e=>e.index).sort((e,t)=>_[e].order-_[t].order),y=d.map(()=>0);for(;v.length>0;){let e=v.shift();for(let t of h[e])y[t]=Math.max(y[t],y[e]+1),--g[t],g[t]===0&&v.push(t)}let b=Math.max(1,...y)+1,x=Array.from({length:b},()=>[]);for(let e of r)x[y[m.get(e)]].push(e);let S=x.filter(e=>e.length>0),C=Math.max(1,...S.map(e=>e.length)),w=new Map,T,E;if(n===`down`)T=yp,E=Math.max(240,106+(S.length-1)*120),S.forEach((e,t)=>{let n=53+t*120;e.forEach((t,r)=>{let i=e.length===1?T/2:104+r*((T-88-bp)/(e.length-1));w.set(t,{x:i,y:n})})});else{let e=t.reduce((e,t)=>t.label?Math.max(e,Dm(t.label).width):e,0),n=Math.max(Sp,bp+(e>0?e+24:0));T=Math.max(yp,208+(S.length-1)*n),E=Math.max(240,106+(C-1)*74),S.forEach((e,t)=>{let n=S.length===1?T/2:104+t*((T-88-bp)/(S.length-1));e.forEach((t,r)=>{let i=e.length===1?E/2:53+r*((E-60-xp)/(e.length-1));w.set(t,{x:n,y:i})})})}return km({width:T,height:E,positions:w},t,n)}function jm(e,t,n,r,i){let a=bp,o=xp;if(i)return e===`right`?{d:`M ${t.x+20} ${t.y-o/2} C ${t.x+64} ${t.y-o/2-64}, ${t.x-64} ${t.y-o/2-64}, ${t.x-20} ${t.y-o/2}`,labelX:t.x,labelY:t.y-o/2-46}:{d:`M ${t.x+a/2} ${t.y-10} C ${t.x+a/2+64} ${t.y-54}, ${t.x+a/2+64} ${t.y+54}, ${t.x+a/2} ${t.y+10}`,labelX:t.x+a/2+44,labelY:t.y};if(e===`right`){if(n.x>t.x){let e=t.x+a/2,i=t.y+r,o=n.x-a/2,s=n.y+r;return{d:`M ${e} ${i} L ${o} ${s}`,labelX:(e+o)/2,labelY:(i+s)/2-12}}let e=t.x+r,i=n.x+r,s=t.y+o/2,c=n.y-o/2,l=Math.max(70,Math.abs(i-e)*.45);return{d:`M ${e} ${s} C ${e+l} ${s+86}, ${i-l} ${c+86}, ${i} ${c}`,labelX:(e+i)/2,labelY:Math.max(s,c)+48}}if(n.y>t.y){let e=t.x+r,i=n.x+r,a=t.y+o/2,s=n.y-o/2;return{d:`M ${e} ${a} L ${i} ${s}`,labelX:(e+i)/2+10,labelY:(a+s)/2}}let s=t.x+a/2,c=n.x-a/2,l=t.y+r,u=n.y+r,d=Math.max(70,Math.abs(u-l)*.45);return{d:`M ${s} ${l} C ${s+86} ${l+d}, ${c+86} ${u-d}, ${c} ${u}`,labelX:Math.max(s,c)+48,labelY:(l+u)/2}}function Mm({node:e,runtime:t,render:n,mode:r}){let i=Q(),a=r!==`static`,[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(null),u=t.resetToken(e);(0,y.useEffect)(()=>{s(null),l(null)},[u]);let d=(0,y.useId)().replace(/[^a-zA-Z0-9_-]/g,``),f=`local-diagram-arrow-${d}`,p=`local-diagram-description-${d}`,m=Np(t,e.attrs,`label`,``)||i(`Diagram`,`图解`),h=(e.attrs?.direction??`right`).trim().toLowerCase()===`down`?`down`:`right`,g=e.children?.filter(e=>e.type===`component`)??[],_=[],v=[],b=new Set;for(let e of g){if(e.name!==`node`)continue;let n=(e.attrs?.id??``).trim();if(!n){_.push(i(`Ignored a node without an id.`,`已忽略缺少 id 的节点。`));continue}if(b.has(n)){_.push(i(`Duplicate node id ${n}; ignored the later node.`,`节点 id 重复(${n}),已忽略后一个节点。`));continue}b.add(n);let r=Np(t,e.attrs,`tone`,`neutral`).trim(),a=r===`success`||r===`warning`?r:`neutral`;v.push({id:n,label:Np(t,e.attrs,`label`,n)||n,tone:a,children:e.children??[]})}let x=[],S=new Set;for(let e of g){if(e.name!==`edge`)continue;let n=(e.attrs?.from??``).trim(),r=(e.attrs?.to??``).trim();if(!n||!r||!b.has(n)||!b.has(r)){_.push(i(`Edge ${n||`?`} → ${r||`?`} references a missing endpoint; ignored.`,`连线 ${n||`?`} → ${r||`?`} 缺少端点,已忽略。`));continue}let a=Np(t,e.attrs,`label`,``),o=`${n}\u0000${r}\u0000${a}`;S.has(o)?_.push(i(`Duplicate edge: ${n} → ${r}${a?` (${a})`:``}; ignored.`,`重复连线:${n} → ${r}${a?`(${a})`:``},已忽略。`)):(S.add(o),x.push({key:o,from:n,to:r,label:a}))}if(v.length===0)return(0,Z.jsxs)(em,{className:`local-visual-diagram`,label:m,children:[(0,Z.jsx)(tm,{message:`diagram requires at least one node.`,kind:`alert`}),(0,Z.jsx)(nm,{notes:_})]});let C=null;try{let n=t.get(e);typeof n==`string`&&(C=n)}catch{C=null}let w=new Set(v.map(e=>e.id)),T=(e.attrs?.initial??``).trim(),E=T&&w.has(T)?T:v[0].id,D=C&&w.has(C)?C:o&&w.has(o)?o:E,O=v.find(e=>e.id===D)??v[0],k=C&&w.has(C)?C:T&&w.has(T)?T:null,A=n=>{s(n),l(null);try{let r=t.set(e,n);r.length>0&&l(r.map(e=>i(tt(e,`en`),tt(e,`zh`))).join(`; `))}catch(e){l(Mp(e))}},j=Am(v,x,h),M=Om(x),N=[],ee=[];for(let e of x){let t=j.positions.get(e.from),n=j.positions.get(e.to);if(!t||!n)continue;let r=jm(h,t,n,M.get(e.key)??0,e.from===e.to);if(N.push((0,Z.jsx)(`g`,{className:`local-visual-edge`,children:(0,Z.jsx)(`path`,{d:r.d,fill:`none`,style:{stroke:`var(--ink-muted)`},strokeWidth:1.6,markerEnd:`url(#${f})`})},`edge-${e.key}`)),!e.label)continue;let i=Dm(e.label);ee.push((0,Z.jsx)(`g`,{className:`local-visual-edge-label-group`,children:(0,Z.jsx)(`text`,{className:`local-visual-edge-label`,x:r.labelX,y:r.labelY,textAnchor:`middle`,dominantBaseline:`middle`,children:i.lines.map((e,t)=>(0,Z.jsx)(`tspan`,{x:r.labelX,y:r.labelY+(t-(i.lines.length-1)/2)*Dp,children:e},t))})},`edge-label-${e.key}`))}return(0,Z.jsxs)(em,{className:`local-visual-diagram${a?``:` local-static-diagram`}`,label:m,children:[(0,Z.jsx)(`div`,{className:`local-visual-svg-wrap`,children:(0,Z.jsxs)(`svg`,{className:`local-visual-svg local-visual-diagram-svg`,viewBox:`0 0 ${j.width} ${j.height}`,role:`group`,"aria-label":a?`${m}, with ${v.length} nodes and ${x.length} edges; press Tab to focus a node and Enter to select`:i(`${m}, with ${v.length} nodes and ${x.length} edges`,`${m},共 ${v.length} 个节点、${x.length} 条连线`),"aria-describedby":p,children:[(0,Z.jsx)(`defs`,{children:(0,Z.jsx)(`marker`,{id:f,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,style:{fill:`var(--ink-muted)`}})})}),N,v.map(e=>{let t=j.positions.get(e.id);if(!t)return null;let n=a?e.id===D:k!==null&&e.id===k,r=Rp(e.label,8,2);return(0,Z.jsxs)(`g`,{className:`local-visual-node local-visual-node-${e.tone}${n?` is-selected`:``}`,"data-diagram-node":a?``:void 0,transform:`translate(${t.x} ${t.y})`,role:a?`button`:void 0,tabIndex:a?0:void 0,"aria-pressed":a?n:void 0,"aria-label":a?e.label:void 0,onClick:a?()=>A(e.id):void 0,onKeyDown:a?t=>{Wp(t)?(t.preventDefault(),A(e.id)):t.key===`ArrowRight`||t.key===`ArrowDown`?Up(t,`[data-diagram-node]`,1):(t.key===`ArrowLeft`||t.key===`ArrowUp`)&&Up(t,`[data-diagram-node]`,-1)}:void 0,children:[(0,Z.jsx)(`title`,{children:e.label}),(0,Z.jsx)(`rect`,{className:`local-visual-node-shape`,x:-60,y:-23,width:bp,height:xp,rx:10}),(0,Z.jsx)(`text`,{className:`local-visual-node-text`,textAnchor:`middle`,children:r.map((e,t)=>(0,Z.jsx)(`tspan`,{x:0,y:(t-(r.length-1)/2)*16+4,children:e},t))})]},`node-${e.id}`)}),ee]})}),a?(0,Z.jsx)(`div`,{className:`local-visual-diagram-detail`,"aria-live":`polite`,children:O?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`strong`,{children:O.label}),O.children.length>0?n(O.children):(0,Z.jsx)(`span`,{children:i(`This node has no description.`,`此节点没有说明。`)})]}):(0,Z.jsx)(`span`,{children:i(`Click a node, or focus it with Tab and press Enter, to view its description.`,`点击节点,或用 Tab 聚焦后按 Enter 查看说明。`)})}):(0,Z.jsx)(`div`,{className:`local-visual-diagram-detail local-static-diagram-detail`,children:(0,Z.jsx)(`dl`,{className:`local-static-diagram-nodes`,children:v.map(e=>(0,Z.jsxs)(`div`,{className:`local-static-diagram-node`,children:[(0,Z.jsx)(`dt`,{children:e.label}),(0,Z.jsx)(`dd`,{children:e.children.length>0?n(e.children):(0,Z.jsx)(`span`,{children:i(`This node has no description.`,`此节点没有说明。`)})})]},`static-node-${e.id}`))})}),(0,Z.jsxs)(`ul`,{id:p,className:`local-visual-sr-only`,"aria-label":i(`Nodes and edges`,`节点与连线`),children:[v.map(e=>(0,Z.jsx)(`li`,{children:e.label},`description-node-${e.id}`)),x.map(e=>{let t=v.find(t=>t.id===e.from),n=v.find(t=>t.id===e.to);return(0,Z.jsxs)(`li`,{children:[t?.label??e.from,` → `,n?.label??e.to,e.label?` (${e.label})`:``]},`description-edge-${e.key}`)})]}),c?(0,Z.jsx)(tm,{message:c,kind:`alert`}):null,(0,Z.jsx)(nm,{notes:_})]})}function Nm(e){let t={...e,mode:e.mode??`interactive`};switch(t.node.name){case`table`:return(0,Z.jsx)(im,{...t});case`chart`:return(0,Z.jsx)(sm,{...t});case`plot`:return(0,Z.jsx)(vm,{...t});case`timeline`:return(0,Z.jsx)(Sm,{...t});case`diagram`:return(0,Z.jsx)(Mm,{...t});default:return null}}var Pm=class extends Error{failure;constructor(e){super(e),this.name=`DataTableFailureError`,this.failure=e}};function Fm(e){return e===null?``:typeof e==`string`?e:typeof e==`number`?Number.isFinite(e)?String(e):null:typeof e==`boolean`?e?`true`:`false`:null}function Im(e){return typeof e==`string`?e===``?null:`s:${e}`:typeof e==`number`&&Number.isFinite(e)?`n:${e===0?0:e}`:null}function Lm(e,t,n){let r={...n};for(let i of t)Object.hasOwn(n,i)||Object.defineProperty(r,i,{enumerable:!0,configurable:!0,get(){return e.evaluate(i)}});return r}function Rm(e){if(e.length===0)return null;let t=typeof e[0];if(t!==`string`&&t!==`number`)return`rows`;for(let n of e)if(typeof n!==t||typeof n==`number`&&!Number.isFinite(n))return`rows`;return null}function zm(e,t){let n;try{n=Yt(t)}catch{throw new Pm(`rows`)}let r;try{r=n.evaluate(Lm(e,n.dependencies,{}))}catch{throw new Pm(`rows`)}if(!Array.isArray(r))throw new Pm(`rows`);let i=Rm(r);if(i)throw new Pm(i);return r}function Bm(e){let{rows:t,columns:n,keyExpression:r,runtime:i}=e,a=e.maxRows??100,o=e.budget??1e5;if(!Number.isSafeInteger(a)||a<=0||a>1e3)return{ok:!1,failure:`max-rows`};if(n.length<1||n.length>20)return{ok:!1,failure:`columns`};let s=Rm(t);if(s)return{ok:!1,failure:s};if(t.length>a)return{ok:!1,failure:`rows-budget`};let c;try{c=Yt(r)}catch{return{ok:!1,failure:`key`}}let l=c.dependencies;if(l.length!==1||l[0]!==`item`)return{ok:!1,failure:`key`};let u=n.map(e=>{try{return{spec:e,expression:Yt(e.value)}}catch{return{spec:e,expression:null}}}),d=0;for(let e of n)d+=e.label.length;if(t.length===0&&(d+=7),d>o)return{ok:!1,failure:`text-budget`};let f=e=>{if(d+=e,d>o)throw new Pm(`text-budget`)},p=new Set,m=[];try{for(let e=0;e<t.length;e+=1){let n={item:t[e],index:e},r=null;try{r=Im(c.evaluate(n))}catch{return{ok:!1,failure:`key`}}if(r===null||p.has(r))return{ok:!1,failure:`key`};f(r.length),p.add(r);let a=[];for(let e of u){if(!e.expression){f(14),a.push({ok:!1,text:``});continue}let t=null;try{t=Fm(e.expression.evaluate(Lm(i,e.expression.dependencies,n)))}catch{t=null}t===null?(f(14),a.push({ok:!1,text:``})):(f(t.length),a.push({ok:!0,text:t}))}m.push({key:r,cells:a})}}catch(e){return e instanceof Pm?{ok:!1,failure:e.failure}:{ok:!1,failure:`rows`}}return{ok:!0,model:{columns:n.map(e=>e.label),rows:m,empty:t.length===0}}}function Vm(e,t){switch(t){case`label`:return e(`Data table requires a label.`,`数据表需要标签。`);case`columns`:return e(`Data table requires between 1 and 20 column definitions.`,`数据表需要 1 到 20 个列定义。`);case`max-rows`:return e(`max-rows must be a positive integer no greater than ${A}.`,`max-rows 必须是 1 到 ${A} 之间的整数。`);case`rows`:return e(`Rows must evaluate to a list.`,`行数据必须计算为列表。`);case`rows-budget`:return e(`Too many rows for this table.`,`此数据表的行数超过上限。`);case`key`:return e(`Every row needs a unique, non-empty key.`,`每一行都需要唯一且非空的键。`);case`text-budget`:return e(`The table content exceeds the text budget.`,`数据表内容超过文本上限。`)}}var Hm=/^\s*\{\{([\s\S]*)\}\}\s*$/;function Um(e){if(e===void 0)return null;let t=Hm.exec(e),n=t?t[1].trim():``;return n===``?null:n}function Wm(e){return e.type===`comment`||e.type===`text`&&(e.value??``).trim()===``||e.type===`paragraph`&&!e.children?.length&&(e.value??``).trim()===``}function Gm(e){let t=(e.attrs?.label??``).trim();if(t===``)return{ok:!1,failure:`label`};let n=Um(e.attrs?.rows);if(!n)return{ok:!1,failure:`rows`};let r=Um(e.attrs?.key);if(!r)return{ok:!1,failure:`key`};let i=e.attrs?.[`max-rows`],a=100;if(i!==void 0&&(!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(i.trim())||(a=Number(i.trim()),!Number.isSafeInteger(a)||a<=0||a>1e3)))return{ok:!1,failure:`max-rows`};let o=(e.children??[]).filter(e=>!Wm(e)),s=[];for(let e of o){let t=(e.children??[]).filter(e=>!Wm(e));if(e.type!==`component`||e.name!==`column`||t.length>0)return{ok:!1,failure:`columns`};let n=(e.attrs?.label??``).trim(),r=Um(e.attrs?.value);if(n===``||!r)return{ok:!1,failure:`columns`};s.push({label:n,value:r})}return s.length<1||s.length>20?{ok:!1,failure:`columns`}:{ok:!0,table:{label:t,rows:n,key:r,maxRows:a,columns:s}}}function Km({node:e,runtime:t,t:n}){let r=Gm(e);if(!r.ok)return(0,Z.jsx)(`div`,{className:`local-error local-data-table-error`,role:`alert`,children:Vm(n,r.failure)});let i;try{i=Bm({rows:zm(t,r.table.rows),columns:r.table.columns,keyExpression:r.table.key,maxRows:r.table.maxRows,runtime:t})}catch(e){i={ok:!1,failure:e instanceof Pm?e.failure:`rows`}}if(!i.ok)return(0,Z.jsx)(`div`,{className:`local-error local-data-table-error`,role:`alert`,children:Vm(n,i.failure)});let{model:a}=i;return(0,Z.jsx)(`div`,{className:`md-table-scroll local-data-table-scroll`,"data-local-data-table":``,children:(0,Z.jsxs)(`table`,{className:`md-table local-data-table`,"aria-label":r.table.label,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsx)(`tr`,{children:a.columns.map((e,t)=>(0,Z.jsx)(`th`,{scope:`col`,children:e},`column-${t}`))})}),(0,Z.jsx)(`tbody`,{children:a.empty?(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{className:`local-data-table-empty`,colSpan:a.columns.length,children:n(`No rows`,`没有数据`)})}):a.rows.map(e=>(0,Z.jsx)(`tr`,{children:e.cells.map((e,t)=>(0,Z.jsx)(`td`,{children:e.ok?e.text:(0,Z.jsx)(`span`,{className:`local-error local-data-table-cell-error`,children:n(`Cannot compute`,`无法计算`)})},`cell-${t}`))},e.key))})]})})}var qm=(0,y.createContext)(null);function $(){let e=(0,y.useContext)(qm);if(!e)throw Error(`LocalViewContext is not initialized`);return e}var Jm=`local.validation.failed`,Ym=`local.validation.expression`,Xm=2e3,Zm={invalid:!1},Qm={hintFor:()=>null,fieldFor:()=>Zm};function $m(e){return`${e.start}:${e.end}`}function eh(e){return e.length>Xm?`${e.slice(0,1999)}…`:e}function th(e,t,n,r){let i=Array.isArray(e.validations)?e.validations:[];if(i.length===0)return Qm;let a=null;try{typeof t.validate==`function`&&(a=t.validate())}catch{a=null}let o=new Map;for(let e of a??[])(e.code===Jm||e.code===Ym)&&o.set($m(e.range),e);let s=new Map,c=new Map,l=new Map,u=r(`This rule cannot be evaluated`,`无法计算此规则`),d=r(`Validation failed.`,`校验未通过。`);for(let[t,r]of i.entries()){let i=$m(r.range),f=o.get(i),p=a===null||f?.code===Ym,m=f?.code===Jm,h=m?eh(f?.message||r.message||d):p?f?.message?`${u}: ${eh(f.message)}`:u:``,g={id:`${n}-validation-${t}`,failed:m,error:p,message:h};if(s.set(r.nodeId,g),c.set(i,g),m||p)for(let t of r.fields??[]){let n=Object.hasOwn(e.bindings,t)?e.bindings[t]:void 0;if(n)for(let e of n.nodeIds??[]){let t=l.get(e);t?t.includes(g.id)||t.push(g.id):l.set(e,[g.id])}}}return{hintFor(e){return c.get($m(e.range))??s.get(e.id)??null},fieldFor(e){let t=l.get(e.id);return t&&t.length>0?{describedBy:t.join(` `),invalid:!0}:Zm}}}function nh(e){return $().validation.fieldFor(e)}var rh=/^\s*\{\{([\s\S]*)\}\}\s*$/,ih={revision:0,state:{}};function ah(e,t){return e.attrs?.[t]}function oh(e,t,n){let r=ah(t,n);if(r===void 0)return{present:!1};let i=rh.exec(r);if(!i)return{present:!0,ok:!0,value:r};try{return{present:!0,ok:!0,value:e.evaluate(i[1])}}catch{return{present:!0,ok:!1}}}function sh(e){return e===null?``:typeof e==`string`?e:typeof e==`number`?Number.isFinite(e)?String(e):null:typeof e==`boolean`?e?`true`:`false`:null}function ch(e,t,n,r=``,i=lp){let a=ah(t,n);if(a===void 0)return r;let o=rh.exec(a);try{return o?sh(e.evaluate(o[1]))??i(`Cannot compute`,`无法计算`):e.text(a)}catch{return i(`Cannot compute`,`无法计算`)}}function lh(e,t,n,r){let i=ah(t,n);if(i===void 0)return{ok:!0,value:r};let a=rh.exec(i);if(!a)return{ok:!0,value:i===`true`};try{let t=e.evaluate(a[1]);return typeof t==`boolean`?{ok:!0,value:t}:{ok:!1}}catch{return{ok:!1}}}function uh(e,t,n,r=!1){let i=lh(e,t,n,r);return i.ok?i.value:r}function dh(e,t,n,r,i){let a=ah(t,n);if(a===void 0)return{tone:i,error:!1};let o=rh.exec(a);if(!o){let e=a.trim();return{tone:r.includes(e)?e:i,error:!1}}try{let t=e.evaluate(o[1]);return typeof t==`string`&&r.includes(t)?{tone:t,error:!1}:{tone:i,error:!0}}catch{return{tone:i,error:!0}}}function fh(e){try{return e.snapshot().revision}catch{return 0}}function ph(e,t,n,r){let i=ah(t,n);if(i===void 0)return r;let a=rh.exec(i);try{let t=a?e.evaluate(a[1]):Number(i);return typeof t==`number`&&Number.isFinite(t)?t:r}catch{return r}}function mh(e,t){try{return e.get(t)}catch{return null}}function hh(e){return sh(e)??``}var gh=`—`;function _h(e){return e.trim()===``?gh:e}function vh({label:e,value:t,hint:n,className:r=``,multiline:i=!1}){return(0,Z.jsxs)(`div`,{className:`md-control local-static-control ${r}`.trim(),children:[(0,Z.jsx)(`span`,{className:`md-label`,children:e}),(0,Z.jsx)(`span`,{className:`local-static-value${i?` local-static-multiline`:``}`,"data-local-static-value":``,children:t}),n?(0,Z.jsx)(`span`,{className:`md-hint`,children:n}):null]})}function yh({value:e,block:t=!1}){return t?(0,Z.jsx)(`div`,{className:`local-print-value local-print-block`,"aria-hidden":`true`,"data-local-print-value":``,children:e}):(0,Z.jsx)(`span`,{className:`local-print-value`,"aria-hidden":`true`,"data-local-print-value":``,children:e})}function bh(e){let t=ah(e,`color`);if(t===void 0)return;let n=t.trim();return n!==``&&qn(n)?n:void 0}function xh(e){if(e)return{"--local-accent":e,"--local-accent-soft":`color-mix(in srgb, ${e} 14%, var(--surface))`,"--local-accent-strong":e}}var Sh=`(prefers-color-scheme: dark)`;function Ch(e){if(!Array.isArray(e)||e.length===0)return``;try{return e.map(e=>{if(!e||typeof e!=`object`)return``;let t=Array.isArray(e.colorSchemes)?e.colorSchemes.join(``):``;return`${e.name}\u0000${e.protocol}\u0000${t}`}).join(``)}catch{return``}}function wh(e){return e.map(e=>`${e.code}\u0000${e.range.start}\u0000${e.range.end}\u0000${e.message}`).join(``)}function Th(e){return e===`light`||e===`dark`?e:null}function Eh(e){let t=Th(e.getAttribute(`data-theme`));if(t)return t;let n=e.parentElement;for(;n;){let e=Th(n.getAttribute(`data-color-scheme`))??Th(n.getAttribute(`data-theme`));if(e)return e;n=n.parentElement}return null}function Dh(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return null;try{return window.matchMedia(Sh).matches?`dark`:`light`}catch{return null}}function Oh(e,t){let n=Th(t),[r,i]=(0,y.useState)(`light`);return(0,y.useEffect)(()=>{if(n){i(n);return}let t=e.current;if(!t||typeof window>`u`){i(`light`);return}let r=()=>i(Eh(t)??Dh()??`light`);r();let a=[];if(typeof MutationObserver==`function`)try{let e=(e,t)=>{let n=new MutationObserver(r);n.observe(e,{attributes:!0,attributeFilter:t}),a.push(n)};e(t,[`data-theme`]);let n=t.parentElement;for(;n;)e(n,[`data-color-scheme`,`data-theme`]),n=n.parentElement}catch{for(let e of a)e.disconnect();a=[]}let o=()=>r(),s=null;if(typeof window.matchMedia==`function`)try{s=window.matchMedia(Sh),typeof s.addEventListener==`function`?s.addEventListener(`change`,o):typeof s.addListener==`function`&&s.addListener(o)}catch{s=null}return()=>{for(let e of a)e.disconnect();s&&(typeof s.removeEventListener==`function`?s.removeEventListener(`change`,o):typeof s.removeListener==`function`&&s.removeListener(o))}},[n,e]),n??r}function kh(e,t,n){return Math.min(n,Math.max(t,e))}function Ah(e,t,n,r){let i=Number.isFinite(r)&&r>0?r:1,a=Math.max(0,Math.floor((n-t)/i+1e-9)),o=t+Math.max(0,Math.min(a,Math.round((e-t)/i)))*i;return Number(o.toPrecision(15))}function jh(e,t,n,r){try{let i=e.get(t,n);return typeof i==`number`&&Number.isFinite(i)?i:r}catch{return r}}function Mh(e,t,n,r,i,a,o=1){let s=ph(e,t,n,i),c=ph(e,t,r,a);s>c&&([s,c]=[c,s]);let l=ph(e,t,`step`,o);return{min:s,max:c,step:Number.isFinite(l)&&l>0?l:1}}function Nh(e){let{runtime:t,report:n}=$(),r=fp(),i=Q(),[a,o]=(0,y.useState)(null);return{write:(0,y.useCallback)((a,s)=>{try{let i=t.set(e,a,s);return i.length?(o(i.map(e=>tt(e,r)).join(`; `)),n(i),!1):(o(null),!0)}catch(e){return o(e instanceof Error?e.message:i(`Cannot write`,`无法写入`)),!1}},[r,e,n,t,i]),writeMany:(0,y.useCallback)(a=>{try{let i=t.setMany(e,a);return i.length?(o(i.map(e=>tt(e,r)).join(`; `)),n(i),!1):(o(null),!0)}catch(e){return o(e instanceof Error?e.message:i(`Cannot write`,`无法写入`)),!1}},[r,e,n,t,i]),error:a,setError:o}}function Ph(e){let{runtime:t}=$(),n=lh(t,e,`disabled`,!1);return n.ok?{disabled:n.value,invalid:!1}:{disabled:!0,invalid:!0}}function Fh(e,t,n){let r=0;try{r=e.resetToken(t)}catch{r=0}let i=(0,y.useRef)(r),a=(0,y.useRef)(n);a.current=n,(0,y.useEffect)(()=>{i.current!==r&&(i.current=r,a.current())},[r])}function Ih({message:e}){let t=Q();return(0,Z.jsx)(`span`,{className:`local-error`,role:`alert`,children:e??t(`Cannot compute`,`无法计算`)})}var Lh=class extends y.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidUpdate(e){this.state.failed&&e.revision!==this.props.revision&&this.setState({failed:!1})}render(){return this.state.failed?(0,Z.jsx)(Ih,{}):this.props.children}},Rh=new Set([`table`,`chart`,`plot`,`timeline`,`diagram`]);function zh(e,t,n){if(!e)return null;let r=e.trim();if(!r)return null;let i=r.replace(/[\u0000- ]+/g,``),a=/^([a-z][a-z0-9+.-]*):/i.exec(i);if(a){let e=a[1].toLowerCase();if(!(t===`image`?e===`http`||e===`https`:e===`http`||e===`https`||e===`mailto`||e===`tel`))return null}if(!n)return t===`image`?null:r;try{return n(r,t)?r:null}catch{return null}}function Bh(e){return`h${Math.min(6,Math.max(1,e??1))}`}function Vh(e,t){if(e.node!==t.node||e.visible!==t.visible||e.resetToken!==t.resetToken||e.env!==t.env||e.depValues===null||t.depValues===null||e.depValues.length!==t.depValues.length)return!1;for(let n=0;n<e.depValues.length;n+=1)if(!Object.is(e.depValues[n],t.depValues[n]))return!1;return!0}var Hh=(0,y.memo)(function({node:e,index:t,visible:n,env:r}){return qh(r,e,t,n,!0)},Vh);function Uh(e,t,n,r=!0){if(!t||t.length===0)return null;if(!r)return t.map((t,r)=>qh(e,t,r,n,!1));let i=null,a=null;try{i=e.runtime.snapshot().state,a=Vn(e.runtime)}catch{i=null}let o=i;return t.map((t,r)=>{let i=e.dependencies.get(t.id),s=i==null||o===null||a===null?null:i.map(e=>o[e]),c=a?.get(t.id)??0;return(0,Z.jsx)(Hh,{node:t,index:r,visible:n,env:e,depValues:s,resetToken:c},t.id||`${t.type}-${r}`)})}function Wh(e,t){if(typeof t.value==`string`)return t.value;let{start:n,end:r}=t.range;return Number.isInteger(n)&&Number.isInteger(r)&&n>=0&&r>=n?e.runtime.document.source.slice(n,r):``}function Gh(e,t,n,r){return(0,Z.jsx)(`span`,{className:r?`local-fallback local-fallback-block`:`local-fallback local-fallback-inline`,title:e.t(`Unsupported syntax shown as source`,`未支持的语法,已按源码原样显示`),"data-local-fallback":``,children:Wh(e,t)},n)}function Kh(e,t,n){return!t||t.length===0?null:t.map((t,r)=>t.type===`paragraph`||t.type===`root`?(0,Z.jsx)(`span`,{children:Uh(e,t.children,n,!1)},t.id||`inline-${r}`):qh(e,t,r,n,!1))}function qh(e,t,n,r,i=!0){let a=t.id||`${t.type}-${n}`;if(t.type===`component`)return(0,Z.jsx)(Lh,{revision:fh(e.runtime),children:Yh(t,r,e.runtime,e.t)},a);switch(t.type){case`root`:return(0,Z.jsx)(`div`,{children:Uh(e,t.children,r)},a);case`heading`:return(0,y.createElement)(Bh(t.depth),{key:a,id:e.anchors.ids.get(t)},Uh(e,t.children,r,!1));case`paragraph`:return(0,Z.jsx)(`p`,{children:Uh(e,t.children,r,!1)},a);case`text`:return(0,Z.jsx)(`span`,{children:t.value??``},a);case`emphasis`:return(0,Z.jsx)(`em`,{children:Uh(e,t.children,r,!1)},a);case`strong`:return(0,Z.jsx)(`strong`,{children:Uh(e,t.children,r,!1)},a);case`delete`:return(0,Z.jsx)(`del`,{children:Uh(e,t.children,r,!1)},a);case`inlineCode`:return(0,Z.jsx)(`code`,{className:`md-inline-code`,children:t.value??``},a);case`code`:{let e=t.lang?`language-${t.lang}`:void 0;return(0,Z.jsx)(`pre`,{className:`md-code`,children:(0,Z.jsx)(`code`,{className:e,children:t.value??``})},a)}case`blockquote`:return(0,Z.jsx)(`blockquote`,{children:Uh(e,t.children,r)},a);case`break`:return(0,Z.jsx)(`br`,{},a);case`thematicBreak`:return(0,Z.jsx)(`hr`,{},a);case`list`:return t.ordered?(0,Z.jsx)(`ol`,{start:t.start??1,className:`md-list`,children:Uh(e,t.children,r)},a):(0,Z.jsx)(`ul`,{className:`md-list`,children:Uh(e,t.children,r)},a);case`listItem`:{let n=typeof t.checked==`boolean`;return(0,Z.jsxs)(`li`,{className:n?`md-list-item md-task-item`:`md-list-item`,children:[n?e.mode===`static`?(0,Z.jsx)(`span`,{className:`md-task-marker`,role:`img`,"aria-label":t.checked?e.t(`Completed`,`已完成`):e.t(`Not completed`,`未完成`),children:t.checked?`✓`:`☐`}):(0,Z.jsx)(`input`,{type:`checkbox`,className:`md-task-checkbox`,checked:t.checked===!0,readOnly:!0,tabIndex:-1,"aria-label":t.checked?e.t(`Completed`,`已完成`):e.t(`Not completed`,`未完成`)}):null,Uh(e,t.children,r)]},a)}case`link`:{let n=zh(t.url,`link`,e.urlPolicy);if(!n)return(0,Z.jsx)(`span`,{className:`md-link-rejected`,title:e.t(`Unsafe link URL rejected`,`已拒绝不安全的链接地址`),children:Uh(e,t.children,r,!1)},a);let i=e.anchors.resolve(n),o=/^https?:/i.test(i);return(0,Z.jsx)(`a`,{href:i,title:t.title??void 0,target:o?`_blank`:void 0,rel:o?`noopener noreferrer`:void 0,children:Uh(e,t.children,r,!1)},a)}case`image`:{let n=zh(t.url,`image`,e.urlPolicy),r=n;if(n&&e.imageResolver)try{let t=e.imageResolver(n);r=typeof t==`string`&&t.trim()!==``?t:null}catch{r=null}if(!r){let n=e.t(`Unsafe image rejected`,`已拒绝不安全的图片`),r=t.alt?e.t(`: ${t.alt}`,`:${t.alt}`):``;return(0,Z.jsxs)(`span`,{className:`md-image-rejected`,children:[`[`,n,r,`]`]},a)}return(0,Z.jsx)(`img`,{className:`md-image`,src:r,alt:t.alt??``,title:t.title??void 0,loading:`lazy`,referrerPolicy:`no-referrer`},a)}case`table`:{let[n,...i]=t.children??[];return(0,Z.jsx)(`div`,{className:`md-table-scroll`,children:(0,Z.jsxs)(`table`,{className:`md-table`,children:[n?(0,Z.jsx)(`thead`,{children:(0,Z.jsx)(`tr`,{children:Jh(e,n,`th`,t.align,r)})}):null,i.length?(0,Z.jsx)(`tbody`,{children:i.map((n,i)=>(0,Z.jsx)(`tr`,{children:Jh(e,n,`td`,t.align,r)},n.id||`${a}-row-${i}`))}):null]})},a)}case`tableRow`:return(0,Z.jsx)(`tr`,{children:Jh(e,t,`td`,void 0,r)},a);case`tableCell`:{let n=t.align?.[0]??void 0;return(0,Z.jsx)(`td`,{style:{textAlign:n??void 0},children:Uh(e,t.children,r,!1)},a)}case`interpolation`:try{let n=sh(e.runtime.evaluate(t.value??``));if(n===null)throw Error(`Cannot display an array`);return(0,Z.jsx)(`span`,{className:`local-interpolation`,children:n},a)}catch{return(0,Z.jsx)(Ih,{},a)}case`math`:case`inlineMath`:{let n=t.type===`math`;return(0,Z.jsx)(`span`,{className:n?`local-math-display`:`local-math-inline`,children:(0,Z.jsx)(Lh,{revision:fh(e.runtime),children:(0,Z.jsx)(sp,{source:t.value??``,display:n})})},a)}case`html`:return(0,Z.jsx)(`span`,{className:`md-raw-html`,children:t.value??``},a);case`fallback`:return Gh(e,t,a,i);case`footnoteReference`:return Gh(e,t,a,!1);case`footnoteDefinition`:return Gh(e,t,a,i);case`comment`:case`definition`:return null;default:return t.children&&t.children.length?(0,Z.jsx)(`span`,{children:Uh(e,t.children,r,i)},a):typeof t.value==`string`?(0,Z.jsx)(`span`,{children:t.value},a):null}}function Jh(e,t,n,r,i){return(t.children??[]).map((a,o)=>{let s=a.align?.[0]??t.align?.[o]??r?.[o]??void 0;return n===`th`?(0,Z.jsx)(`th`,{style:{textAlign:s??void 0},children:Uh(e,a.children,i,!1)},a.id||`${t.id}-h-${o}`):(0,Z.jsx)(`td`,{style:{textAlign:s??void 0},children:Uh(e,a.children,i,!1)},a.id||`${t.id}-c-${o}`)})}function Yh(e,t,n,r){let i=e.name??``;if(i===`computed`||i===`const`)return null;if(i===`data-table`)return(0,Z.jsx)(Km,{node:e,visible:t,runtime:n,t:r});if(Rh.has(i))return(0,Z.jsx)(Xh,{node:e,visible:t});let a=qg[i];return a?(0,Z.jsx)(a,{node:e,visible:t}):(0,Z.jsxs)(`span`,{className:`component-error`,children:[r(`Unknown component "`,`未知组件“`),i||r(`(missing name)`,`(缺少名称)`),r(`"`,`”`)]})}function Xh({node:e,visible:t}){let{runtime:n,render:r,mode:i}=$(),a=Q(),o=nh(e),s=(0,Z.jsx)(Nm,{node:e,runtime:n,render:r,visible:t,mode:i});if(!n.document.validations?.some(t=>t.fields.some(t=>Object.hasOwn(n.document.bindings,t)&&n.document.bindings[t].nodeIds.includes(e.id))))return s;let c=ch(n,e,`label`,ch(n,e,`title`,a(`Selection`,`选择`),a),a);return(0,Z.jsx)(`div`,{role:`group`,"aria-label":c,"aria-invalid":o.invalid||void 0,"aria-describedby":o.describedBy,children:s})}function Zh({node:e,visible:t}){let{validation:n}=$(),r=n.hintFor(e);if(!r)return null;let i=r.failed||r.error,a=t&&i;return(0,Z.jsx)(`span`,{id:r.id,className:`local-validation-hint`,"data-local-validation":r.error?`error`:r.failed?`failed`:`passed`,role:a?`status`:void 0,"aria-live":a?`polite`:void 0,children:i?r.message:null})}function Qh(){return null}function $h({message:e}){return e?(0,Z.jsx)(`span`,{className:`field-error`,role:`alert`,children:e}):null}function eg(e,t,n=lp){if(t.required&&e.length===0)return n(`This field is required`,`请填写此字段`);if(e.length>1e5)return n(`At most ${w} characters`,`最多允许 ${w} 个字符`);if(t.email&&e!==``&&!N(e))return n(`Enter a valid email address`,`请输入有效的邮箱地址`);let r=nt(e);return t.minLength!==void 0&&t.minLength>0&&e!==``&&r<t.minLength?n(`At least ${t.minLength} characters`,`至少需要 ${t.minLength} 个字符`):t.maxLength!==void 0&&t.maxLength>=0&&r>t.maxLength?n(`At most ${t.maxLength} characters`,`最多允许 ${t.maxLength} 个字符`):null}function tg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o,setError:s}=Nh(e),c=ch(n,e,`label`,e.name??i(`Input`,`输入`),i),l=ch(n,e,`placeholder`,``,i),u=(ah(e,`type`)??`text`)===`email`,d=uh(n,e,`required`,!1),{disabled:f,invalid:p}=Ph(e),m=nh(e),h=ah(e,`min-length`),g=ah(e,`max-length`),_=h===void 0?void 0:Math.max(0,Math.floor(ph(n,e,`min-length`,0))),v=g===void 0?void 0:Math.max(0,Math.floor(ph(n,e,`max-length`,0))),b=hh(mh(n,e)),[x,S]=(0,y.useState)(b),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null),k=(0,y.useRef)(!1),A=(0,y.useRef)(b),j=(0,y.useRef)(b);if(j.current=b,(0,y.useEffect)(()=>{A.current!==b&&(A.current=b,!C&&!k.current&&S(b))},[b,C]),Fh(n,e,()=>{k.current=!1,S(j.current),E(!1),O(null),s(null)}),r===`static`)return(0,Z.jsx)(vh,{className:`local-input${u?` local-input-email`:``}`,label:c,value:_h(b)});let M=e=>eg(e,{required:d,minLength:_,maxLength:v,email:u},i);return(0,Z.jsxs)(`div`,{className:`md-control local-input${u?` local-input-email`:``}`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-input`,children:c}),(0,Z.jsx)(`input`,{id:`${t}-input`,className:`md-text-input`,type:u?`email`:`text`,value:x,placeholder:l||void 0,disabled:f,required:d,"aria-invalid":D||o||m.invalid?!0:void 0,"aria-describedby":m.describedBy,onFocus:()=>w(!0),onBlur:()=>{w(!1),E(!0);let e=M(x);O(e),!e&&x!==b&&a(x)},onChange:e=>{let t=e.target.value;S(t),s(null),T&&O(M(t)),!k.current&&M(t)===null&&a(t)},onCompositionStart:()=>{k.current=!0},onCompositionEnd:e=>{k.current=!1;let t=e.currentTarget.value;S(t),T&&O(M(t)),M(t)===null&&a(t)}}),(0,Z.jsx)(yh,{value:_h(b)}),(0,Z.jsx)($h,{message:p?i(`Cannot compute`,`无法计算`):D??o})]})}function ng({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o,setError:s}=Nh(e),c=ch(n,e,`label`,i(`Text`,`文本`),i),l=ch(n,e,`placeholder`,``,i),u=Math.min(40,Math.max(1,Math.floor(ph(n,e,`rows`,4)))),d=uh(n,e,`required`,!1),{disabled:f,invalid:p}=Ph(e),m=nh(e),h=ah(e,`min-length`),g=ah(e,`max-length`),_=h===void 0?void 0:Math.max(0,Math.floor(ph(n,e,`min-length`,0))),v=g===void 0?void 0:Math.max(0,Math.floor(ph(n,e,`max-length`,0))),b=hh(mh(n,e)),[x,S]=(0,y.useState)(b),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null),k=(0,y.useRef)(!1),A=(0,y.useRef)(b),j=(0,y.useRef)(b);if(j.current=b,(0,y.useEffect)(()=>{A.current!==b&&(A.current=b,!C&&!k.current&&S(b))},[b,C]),Fh(n,e,()=>{k.current=!1,S(j.current),E(!1),O(null),s(null)}),r===`static`)return(0,Z.jsx)(vh,{className:`local-textarea`,label:c,value:_h(b),multiline:!0});let M=e=>eg(e,{required:d,minLength:_,maxLength:v},i);return(0,Z.jsxs)(`div`,{className:`md-control local-textarea`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-textarea`,children:c}),(0,Z.jsx)(`textarea`,{id:`${t}-textarea`,className:`md-text-input`,rows:u,value:x,placeholder:l||void 0,disabled:f,required:d,"aria-invalid":D||o||m.invalid?!0:void 0,"aria-describedby":m.describedBy,onFocus:()=>w(!0),onBlur:()=>{w(!1),E(!0);let e=M(x);O(e),!e&&x!==b&&a(x)},onChange:e=>{let t=e.target.value;S(t),s(null),T&&O(M(t)),!k.current&&M(t)===null&&a(t)},onCompositionStart:()=>{k.current=!0},onCompositionEnd:e=>{k.current=!1;let t=e.currentTarget.value;S(t),T&&O(M(t)),M(t)===null&&a(t)}}),(0,Z.jsx)(yh,{value:_h(b),block:!0}),(0,Z.jsx)($h,{message:p?i(`Cannot compute`,`无法计算`):D??o})]})}function rg(e){let t=e.trim();if(t===``||t===`-`||t===`+`||t===`.`||t===`-.`)return{kind:`empty`};let n=Number(t);return Number.isFinite(n)?{kind:`valid`,value:n}:{kind:`invalid`}}function ig(e,t,n,r,i=lp){let a=1e-9*Math.max(1,Math.abs(e));if(t!==void 0&&e<t-a)return i(`Must be at least ${t}`,`不能小于 ${t}`);if(n!==void 0&&e>n+a)return i(`Must be at most ${n}`,`不能大于 ${n}`);if(!Number.isFinite(r)||r<=0)return i(`Step must be greater than 0`,`步长必须大于 0`);let o=(e-(t??0))/r;return Math.abs(o-Math.round(o))>1e-9*Math.max(1,Math.abs(o))?i(`Must be a multiple of ${r}`,`需要按步长 ${r} 取值`):null}function ag({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o,setError:s}=Nh(e),c=ch(n,e,`label`,i(`Number`,`数字`),i),{disabled:l,invalid:u}=Ph(e),d=nh(e),f=ah(e,`min`)!==void 0,p=ah(e,`max`)!==void 0,m=f?ph(n,e,`min`,0):void 0,h=p?ph(n,e,`max`,0):void 0,g=ph(n,e,`step`,1),_=mh(n,e),v=typeof _==`number`&&Number.isFinite(_)?String(_):``,[b,x]=(0,y.useState)(v),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(null),O=(0,y.useRef)(!1),k=(0,y.useRef)(v),A=(0,y.useRef)(v);A.current=v,(0,y.useEffect)(()=>{k.current!==v&&(k.current=v,!S&&!O.current&&x(v))},[v,S]),Fh(n,e,()=>{O.current=!1,x(A.current),T(!1),D(null),s(null)});let j=(0,Z.jsxs)(Z.Fragment,{children:[m===void 0?``:i(`Min ${m}`,`最小 ${m}`),m!==void 0&&h!==void 0?` · `:``,h===void 0?``:i(`Max ${h}`,`最大 ${h}`),g===void 0?``:i(` · Step ${g}`,` · 步长 ${g}`)]});if(r===`static`)return(0,Z.jsx)(vh,{className:`local-number`,label:c,value:_h(v),hint:j});let M=(e,t)=>{let n=rg(e);if(n.kind!==`valid`)return t&&D(i(`Enter a valid number`,`请输入有效数字`)),!1;let r=ig(n.value,m,h,g,i);return r?(t&&D(r),!1):(D(null),a(n.value))};return(0,Z.jsxs)(`div`,{className:`md-control local-number`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-number`,children:c}),(0,Z.jsx)(`input`,{id:`${t}-number`,className:`md-text-input`,type:`text`,inputMode:`decimal`,value:b,disabled:l,"aria-invalid":E||o||d.invalid?!0:void 0,"aria-describedby":d.describedBy,onFocus:()=>C(!0),onBlur:()=>{C(!1),T(!0),M(b,!0)},onChange:e=>{let t=e.target.value;x(t),s(null),O.current||M(t,w)},onCompositionStart:()=>{O.current=!0},onCompositionEnd:e=>{O.current=!1,M(e.currentTarget.value,w)}}),(0,Z.jsx)(yh,{value:_h(v)}),m!==void 0||h!==void 0||g!==void 0?(0,Z.jsx)(`span`,{className:`md-hint`,children:j}):null,(0,Z.jsx)($h,{message:u?i(`Cannot compute`,`无法计算`):E??o})]})}function og({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Slider`,`滑块`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=ph(n,e,`min`,0),f=ph(n,e,`max`,100),p=ph(n,e,`step`,1),m=mh(n,e),h=Math.min(f,Math.max(d,typeof m==`number`&&Number.isFinite(m)?m:d));return r===`static`?(0,Z.jsx)(vh,{className:`md-slider local-slider`,label:s,value:String(h)}):(0,Z.jsxs)(`div`,{className:`md-control md-slider local-slider`,style:xh(bh(e)),children:[(0,Z.jsxs)(`label`,{className:`md-label`,htmlFor:`${t}-slider`,children:[(0,Z.jsx)(`span`,{children:s}),(0,Z.jsx)(`span`,{className:`md-slider-value`,"aria-hidden":`true`,children:h})]}),(0,Z.jsx)(`input`,{id:`${t}-slider`,type:`range`,min:d,max:f,step:p,value:h,disabled:c,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,onChange:e=>a(Number(e.target.value))}),(0,Z.jsx)(yh,{value:String(h)}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):o})]})}function sg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Toggle`,`开关`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=mh(n,e)===!0,f=d?i(`On`,`开`):i(`Off`,`关`);return r===`static`?(0,Z.jsx)(vh,{className:`md-toggle local-toggle`,label:s,value:f}):(0,Z.jsxs)(`div`,{className:`md-control md-toggle local-toggle`,style:xh(bh(e)),children:[(0,Z.jsxs)(`label`,{className:`md-toggle-label`,htmlFor:`${t}-toggle`,children:[(0,Z.jsx)(`input`,{id:`${t}-toggle`,type:`checkbox`,checked:d,disabled:c,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,onChange:e=>a(e.target.checked)}),(0,Z.jsx)(`span`,{children:s})]}),(0,Z.jsx)(yh,{value:f}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):o})]})}function cg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Checkbox`,`勾选`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=mh(n,e)===!0,f=d?i(`Checked`,`已勾选`):i(`Unchecked`,`未勾选`);return r===`static`?(0,Z.jsx)(vh,{className:`local-checkbox`,label:s,value:f}):(0,Z.jsxs)(`div`,{className:`md-control local-checkbox`,style:xh(bh(e)),children:[(0,Z.jsxs)(`label`,{className:`md-toggle-label`,htmlFor:`${t}-checkbox`,children:[(0,Z.jsx)(`input`,{id:`${t}-checkbox`,type:`checkbox`,checked:d,disabled:c,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,onChange:e=>a(e.target.checked)}),(0,Z.jsx)(`span`,{children:s})]}),(0,Z.jsx)(yh,{value:f}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):o})]})}function lg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Date`,`日期`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=uh(n,e,`required`,!1),f=ch(n,e,`min`,``,i),p=ch(n,e,`max`,``,i),m=mh(n,e),h=typeof m==`string`?m:``,[g,_]=(0,y.useState)(!1),v=g&&d&&h===``?i(`Select a date`,`请选择日期`):null;return r===`static`?(0,Z.jsx)(vh,{className:`local-date`,label:s,value:_h(h)}):(0,Z.jsxs)(`div`,{className:`md-control local-date`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-date`,children:s}),(0,Z.jsx)(`input`,{id:`${t}-date`,className:`md-text-input`,type:`date`,value:h,min:f||void 0,max:p||void 0,required:d,disabled:c,"aria-invalid":v||o||u.invalid?!0:void 0,"aria-describedby":u.describedBy,onBlur:()=>_(!0),onChange:e=>{_(!0),a(e.target.value)}}),(0,Z.jsx)(yh,{value:_h(h)}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):v??o})]})}function ug(e){return(e.children??[]).filter(e=>e.type===`component`&&e.name===`option`).map((e,t)=>({value:ah(e,`value`)??`option-${t+1}`,node:e}))}function dg(e,t,n=lp){if(!t)return``;let r=``;for(let i of t)if(i.type===`text`||i.type===`inlineCode`)r+=i.value??``;else if(i.type===`fallback`)r+=i.value??``;else if(i.type===`interpolation`)try{r+=sh(e.evaluate(i.value??``))??``}catch{r+=n(`Cannot compute`,`无法计算`)}else i.type===`break`?r+=` `:r+=dg(e,i.children,n);return r}function fg(e,t,n=lp){return dg(e,t.children,n)||ah(t,`value`)||``}function pg(){return null}function mg({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,error:o}=Nh(e),s=ch(n,e,`label`,i(`Select`,`选择`),i),{disabled:c,invalid:l}=Ph(e),u=nh(e),d=ug(e),f=mh(n,e),p=typeof f==`string`?f:``,m=d.some(e=>e.value===p)?p:d[0]?.value??``,h=d.find(e=>e.value===m),g=h?fg(n,h.node,i)||m:``;return d.length===0?(0,Z.jsx)(Ih,{message:i(`Missing options`,`缺少选项`)}):r===`static`?(0,Z.jsx)(vh,{className:`md-select local-select`,label:s,value:_h(g)}):(0,Z.jsxs)(`div`,{className:`md-control md-select local-select`,style:xh(bh(e)),children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${t}-select`,children:s}),(0,Z.jsx)(`select`,{id:`${t}-select`,className:`md-select-input`,value:m,disabled:c,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,onChange:e=>a(e.target.value),children:d.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:fg(n,e.node,i)||e.value},e.node.id))}),(0,Z.jsx)(yh,{value:_h(g)}),(0,Z.jsx)($h,{message:l?i(`Cannot compute`,`无法计算`):o})]})}function hg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),{write:s,error:c}=Nh(e),l=ch(i,e,`label`,o(`Options`,`选项`),o),{disabled:u,invalid:d}=Ph(e),f=nh(e),p=ug(e),m=mh(i,e),h=typeof m==`string`?m:``,g=p.findIndex(e=>e.value===h),_=g>=0?g:0,v=g>=0?p[g]:void 0,b=v?fg(i,v.node,o):``,x=(0,y.useRef)([]);if(p.length===0)return(0,Z.jsx)(Ih,{message:o(`Missing options`,`缺少选项`)});if(a===`static`)return(0,Z.jsx)(vh,{className:`local-choices`,label:l,value:_h(b)});let S=e=>{let t=p[e];t&&(s(t.value),x.current[e]?.focus())},C=(e,t)=>{let n=-1;e.key===`ArrowRight`||e.key===`ArrowDown`?n=(t+1)%p.length:e.key===`ArrowLeft`||e.key===`ArrowUp`?n=(t-1+p.length)%p.length:e.key===`Home`?n=0:e.key===`End`&&(n=p.length-1),!(n<0)&&(e.preventDefault(),S(n))};return(0,Z.jsxs)(`div`,{className:`md-control local-choices`,style:xh(bh(e)),children:[(0,Z.jsx)(`span`,{className:`md-label`,id:`${n}-choices-label`,children:l}),(0,Z.jsx)(`div`,{className:`local-choice-list`,role:`radiogroup`,"aria-labelledby":`${n}-choices-label`,"aria-disabled":u||void 0,"aria-invalid":f.invalid||void 0,"aria-describedby":f.describedBy,children:p.map((e,n)=>{let i=e.value===h;return(0,Z.jsx)(`button`,{ref:e=>{x.current[n]=e},type:`button`,role:`radio`,"aria-checked":i,tabIndex:n===_?0:-1,disabled:u,className:`local-choice${i?` is-selected`:``}`,onClick:()=>s(e.value),onKeyDown:e=>C(e,n),children:Kh(r,e.node.children,t)},e.node.id)})}),(0,Z.jsx)(yh,{value:_h(b)}),(0,Z.jsx)($h,{message:d?o(`Cannot compute`,`无法计算`):c})]})}function gg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),{write:s,error:c}=Nh(e),l=ch(i,e,`label`,o(`Options`,`选项`),o),{disabled:u,invalid:d}=Ph(e),f=nh(e),p=ug(e),m=mh(i,e),h=typeof m==`string`?m:``,g=n,_=p.find(e=>e.value===h),v=_?fg(i,_.node,o):``;return p.length===0?(0,Z.jsx)(Ih,{message:o(`Missing options`,`缺少选项`)}):a===`static`?(0,Z.jsx)(vh,{className:`local-radio-group`,label:l,value:_h(v)}):(0,Z.jsxs)(`fieldset`,{className:`md-control local-radio-group`,style:xh(bh(e)),disabled:u,"aria-invalid":f.invalid||void 0,"aria-describedby":f.describedBy,children:[(0,Z.jsx)(`legend`,{className:`md-label`,children:l}),p.map(e=>(0,Z.jsxs)(`label`,{className:`local-radio-option`,children:[(0,Z.jsx)(`input`,{type:`radio`,name:g,value:e.value,checked:h===e.value,onChange:()=>s(e.value)}),(0,Z.jsx)(`span`,{children:Kh(r,e.node.children,t)})]},e.node.id)),(0,Z.jsx)(yh,{value:_h(v)}),(0,Z.jsx)($h,{message:d?o(`Cannot compute`,`无法计算`):c})]})}function _g(e){return((e.children??[]).find(e=>e.type===`list`)?.children??[]).filter(e=>e.type===`listItem`).map((e,t)=>({id:`item-${t+1}`,node:e}))}function vg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),{write:s,error:c}=Nh(e),l=ch(i,e,`label`,o(`Checklist`,`清单`),o),{disabled:u,invalid:d}=Ph(e),f=nh(e),p=_g(e),m=mh(i,e),h=Array.isArray(m)?m.filter(e=>typeof e==`string`):[];if(p.length===0)return(0,Z.jsx)(Ih,{message:o(`Checklist requires a task list`,`清单需要任务列表`)});let g=e=>e?o(`Checked`,`已勾选`):o(`Unchecked`,`未勾选`);if(a===`static`)return(0,Z.jsxs)(`div`,{className:`local-checklist local-static-checklist`,style:xh(bh(e)),role:`group`,"aria-label":l,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:l}),(0,Z.jsx)(`ul`,{className:`local-static-list`,children:p.map(e=>{let n=h.includes(e.id);return(0,Z.jsxs)(`li`,{className:`local-static-list-item`,children:[(0,Z.jsx)(`span`,{className:`local-static-state`,children:g(n)}),(0,Z.jsx)(`span`,{className:`local-static-item${n?` is-checked`:``}`,children:Kh(r,e.node.children,t)})]},e.id)})})]});let _=(e,t)=>{let n=new Set(h);t?n.add(e):n.delete(e),s(p.filter(e=>n.has(e.id)).map(e=>e.id))};return(0,Z.jsxs)(`fieldset`,{className:`local-checklist`,style:xh(bh(e)),disabled:u,"aria-invalid":f.invalid||void 0,"aria-describedby":f.describedBy,children:[(0,Z.jsx)(`legend`,{className:`md-label`,children:l}),p.map(e=>{let i=h.includes(e.id);return(0,Z.jsxs)(`div`,{className:`local-checklist-item`,children:[(0,Z.jsx)(`input`,{id:`${n}-${e.id}`,type:`checkbox`,checked:i,onChange:t=>_(e.id,t.target.checked)}),(0,Z.jsx)(`label`,{className:`local-checklist-text${i?` is-checked`:``}`,htmlFor:`${n}-${e.id}`,children:Kh(r,e.node.children,t)})]},e.id)}),(0,Z.jsx)(yh,{block:!0,value:(0,Z.jsx)(`ul`,{className:`local-static-list`,children:p.map(e=>{let t=h.includes(e.id);return(0,Z.jsxs)(`li`,{className:`local-static-list-item`,children:[(0,Z.jsx)(`span`,{className:`local-static-state`,children:g(t)}),(0,Z.jsx)(`span`,{className:`local-static-item${t?` is-checked`:``}`,children:dg(i,e.node.children,o)})]},e.id)})})}),(0,Z.jsx)($h,{message:d?o(`Cannot compute`,`无法计算`):c})]})}function yg(e,t=lp){let n=Math.max(0,Math.floor(e)),r=Math.floor(n/60),i=n%60;return r===0?t(`${i} seconds`,`${i} 秒`):`${r}:${String(i).padStart(2,`0`)}`}function bg({node:e}){let{runtime:t,mode:n}=$(),r=Q(),{write:i,error:a}=Nh(e),o=ch(t,e,`label`,r(`Counter`,`计数`),r),{disabled:s,invalid:c}=Ph(e),l=nh(e),u=ph(t,e,`min`,0),d=ah(e,`max`)===void 0?void 0:ph(t,e,`max`,0),f=ph(t,e,`step`,1),p=mh(t,e),m=typeof p==`number`&&Number.isFinite(p)?p:u,h=Number.isFinite(f)&&f>0?f:1,g=1e-9*Math.max(1,Math.abs(m)),_=m-h>=u-g,v=d===void 0||m+h<=d+g;if(n===`static`)return(0,Z.jsx)(vh,{className:`local-counter`,label:o,value:String(m)});let y=e=>{let t=Number((m+e*h).toFixed(12));i(t)};return(0,Z.jsxs)(`div`,{className:`local-counter`,role:`group`,"aria-label":o,"aria-invalid":l.invalid||void 0,"aria-describedby":l.describedBy,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:o}),(0,Z.jsxs)(`div`,{className:`local-counter-row`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-counter-button`,"aria-label":`${o} ${r(`decrease`,`减少`)}`,disabled:s||!_,onClick:()=>y(-1),children:`−`}),(0,Z.jsx)(`span`,{className:`local-counter-value`,"aria-live":`polite`,children:m}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-counter-button`,"aria-label":`${o} ${r(`increase`,`增加`)}`,disabled:s||!v,onClick:()=>y(1),children:`+`}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-quiet local-counter-reset`,disabled:s,onClick:()=>{try{t.reset(e)}catch{}},children:r(`Reset`,`恢复初值`)})]}),(0,Z.jsx)(yh,{value:String(m)}),(0,Z.jsx)($h,{message:c?r(`Cannot compute`,`无法计算`):a})]})}function xg({node:e,visible:t}){let{runtime:n,mode:r}=$(),i=fp(),a=Q(),o=ch(n,e,`label`,a(`Timer`,`计时器`),a),s=nh(e),c=ph(n,e,`duration`,60),l=Math.floor(c),u=mh(n,e),d=typeof u==`number`&&Number.isFinite(u)?Math.max(0,Math.ceil(u)):l,[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(!1),g=(0,y.useRef)(0),_=(0,y.useRef)(d);_.current=d;let[v,b]=(0,y.useState)(null),x=(0,y.useCallback)(t=>{try{let r=n.set(e,t);r.length&&b(r.map(e=>tt(e,i)).join(`; `))}catch{}},[i,e,n]);return(0,y.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>{let e=Math.max(0,Math.ceil((g.current-performance.now())/1e3));e!==_.current&&(_.current=e,x(e)),e<=0&&(p(!1),h(!0))},200);return()=>window.clearInterval(e)},[f,x]),(0,y.useEffect)(()=>{if(t||!f)return;let e=Math.max(0,Math.ceil((g.current-performance.now())/1e3));_.current=e,x(e),p(!1)},[t,f,x]),Fh(n,e,()=>{p(!1),h(!1),b(null)}),!Number.isFinite(c)||l<=0?(0,Z.jsx)(Ih,{message:a(`Timer duration must be a positive number of seconds`,`计时时长必须是大于 0 的秒数`)}):r===`static`?(0,Z.jsx)(vh,{className:`local-timer`,label:o,value:yg(d,a)}):(0,Z.jsxs)(`div`,{className:`local-timer`,role:`group`,"aria-label":o,"aria-invalid":s.invalid||void 0,"aria-describedby":s.describedBy,children:[(0,Z.jsxs)(`div`,{className:`local-timer-head`,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:o}),(0,Z.jsx)(`span`,{className:`local-timer-value`,role:`timer`,"aria-label":a(`${d} seconds remaining`,`剩余 ${d} 秒`),children:yg(d,a)})]}),(0,Z.jsxs)(`div`,{className:`local-timer-controls`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-primary`,onClick:()=>{if(f)return;let e=d>0?d:l;d<=0&&(_.current=l,x(l)),g.current=performance.now()+e*1e3,h(!1),b(null),p(!0)},disabled:f,children:a(`Start`,`开始`)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary`,onClick:()=>{if(!f)return;let e=Math.max(0,Math.ceil((g.current-performance.now())/1e3));_.current=e,x(e),p(!1)},disabled:!f,children:a(`Pause`,`暂停`)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-quiet`,onClick:()=>{p(!1),h(!1),b(null),_.current=l;try{n.reset(e)}catch{}},children:a(`Reset`,`重置`)})]}),(0,Z.jsx)(`span`,{className:`local-timer-status`,role:`status`,"aria-live":`polite`,children:m?a(`Completed`,`计时完成`):f?a(`Running`,`计时中`):a(`Paused`,`已暂停`)}),(0,Z.jsx)(yh,{value:yg(d,a)}),(0,Z.jsx)($h,{message:v})]})}function Sg({node:e}){let{runtime:t}=$(),n=Q(),r=ch(t,e,`label`,n(`Progress`,`进度`),n),i=ph(t,e,`max`,100),a=oh(t,e,`value`);if(!Number.isFinite(i)||i<=0)return(0,Z.jsx)(Ih,{message:n(`Progress maximum must be positive`,`进度上限必须是正数`)});if(!a.present||!a.ok)return(0,Z.jsx)(Ih,{});let o=a.value,s=typeof o==`number`?o:typeof o==`string`&&o.trim()!==``?Number(o):NaN;if(!Number.isFinite(s))return(0,Z.jsx)(Ih,{});if(s<0||s>i)return(0,Z.jsx)(Ih,{message:n(`Progress value must be between 0 and ${i}`,`进度值需要在 0 到 ${i} 之间`)});let c=s/i*100,l=bh(e);return(0,Z.jsxs)(`div`,{className:`local-progress`,style:l?{"--local-progress-color":l}:void 0,children:[(0,Z.jsxs)(`div`,{className:`local-progress-head`,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:r}),(0,Z.jsxs)(`span`,{className:`local-progress-value`,children:[Math.round(c),`%`]})]}),(0,Z.jsx)(`div`,{className:`local-progress-track`,role:`progressbar`,"aria-label":r||n(`Progress`,`进度`),"aria-valuemin":0,"aria-valuemax":i,"aria-valuenow":s,children:(0,Z.jsx)(`div`,{className:`local-progress-fill`,style:{width:`${c}%`}})})]})}function Cg({node:e,visible:t}){let{runtime:n,render:r,mode:i}=$(),a=Q(),o=ch(n,e,`title`,``,a),s=uh(n,e,`reset`,!0)&&i!==`static`,[c,l]=(0,y.useState)(null);return(0,Z.jsxs)(`section`,{className:`local-panel`,"aria-label":o||a(`Parameter panel`,`参数面板`),children:[o||s?(0,Z.jsxs)(`div`,{className:`local-panel-head`,children:[o?(0,Z.jsx)(`h3`,{className:`local-panel-title`,children:o}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-quiet local-panel-reset`,onClick:()=>{try{n.reset(e),l(null)}catch(e){l(e instanceof Error?e.message:a(`Cannot reset`,`无法恢复默认`))}},"aria-label":o?a(`Reset ${o}`,`${o} 恢复默认`):a(`Reset`,`恢复默认`),children:a(`Reset`,`恢复默认`)}):null]}):null,(0,Z.jsx)(`div`,{className:`local-panel-body`,children:r(e.children??[],t)}),(0,Z.jsx)($h,{message:c})]})}function wg({node:e,visible:t}){let{runtime:n,render:r}=$(),i=ch(n,e,`title`,``,Q());return(0,Z.jsxs)(`section`,{className:`md-card local-card`,children:[i?(0,Z.jsx)(`h3`,{className:`md-card-title`,children:i}):null,(0,Z.jsx)(`div`,{className:`md-card-body`,children:r(e.children??[],t)})]})}function Tg({node:e,visible:t}){let{runtime:n,render:r}=$(),i=Math.min(4,Math.max(1,Math.floor(ph(n,e,`columns`,2))));return(0,Z.jsx)(`div`,{className:`local-grid`,style:{"--local-grid-columns":String(i)},children:r(e.children??[],t)})}function Eg({node:e,visible:t}){let{render:n}=$();return(0,Z.jsx)(`div`,{className:`local-tabpanel-body`,children:n(e.children??[],t)})}function Dg(){return null}function Og({node:e,visible:t}){let n=(0,y.useId)(),{runtime:r,render:i,mode:a}=$(),o=Q(),{write:s,error:c}=Nh(e),l=ch(r,e,`label`,``,o),u=nh(e),d=(e.children??[]).filter(e=>e.type===`component`&&e.name===`tab`),f=d.map((e,t)=>ah(e,`value`)??`tab-${t+1}`),p=d.map((e,t)=>ch(r,e,`label`,f[t],o)),m=ah(e,`initial`)??f[0]??``,h=ah(e,`bind`)!==void 0,g=mh(r,e),_=typeof g==`string`?g:``,[v,b]=(0,y.useState)(()=>f.includes(m)?m:f[0]??``),x=(0,y.useRef)([]);if(Fh(r,e,()=>{b(f.includes(m)?m:f[0]??``)}),d.length===0)return(0,Z.jsx)(Ih,{message:o(`Tabs requires at least one tab`,`标签页至少需要一个 tab`)});if(a===`static`)return(0,Z.jsxs)(`section`,{className:`local-tabs local-static-tabs`,"aria-label":l||o(`Tabs`,`选项卡`),children:[l?(0,Z.jsx)(`div`,{className:`local-tabs-label`,children:l}):null,d.map((e,n)=>(0,Z.jsxs)(`section`,{className:`local-static-tab`,children:[(0,Z.jsx)(`h4`,{className:`local-static-tab-label`,children:p[n]}),(0,Z.jsx)(`div`,{className:`local-static-tab-body`,children:i(e.children??[],t)})]},e.id))]});let S=h?f.includes(_)?_:f[0]:f.includes(v)?v:f[0],C=Math.max(0,f.indexOf(S)),w=e=>{let t=f[e];t!==void 0&&(h?s(t):b(t),x.current[e]?.focus())};return(0,Z.jsxs)(`section`,{className:`local-tabs`,"aria-label":l||o(`Tabs`,`选项卡`),"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,children:[l?(0,Z.jsx)(`div`,{className:`local-tabs-label`,children:l}):null,(0,Z.jsx)(`div`,{className:`local-tablist`,role:`tablist`,"aria-label":l||o(`Tabs`,`选项卡`),onKeyDown:e=>{let t=-1;e.key===`ArrowRight`?t=(C+1)%d.length:e.key===`ArrowLeft`?t=(C-1+d.length)%d.length:e.key===`Home`?t=0:e.key===`End`&&(t=d.length-1),!(t<0)&&(e.preventDefault(),w(t))},children:d.map((e,t)=>{let r=f[t],i=r===S;return(0,Z.jsx)(`button`,{ref:e=>{x.current[t]=e},id:`${n}-tab-${t}`,type:`button`,role:`tab`,className:`local-tab${i?` is-selected`:``}`,"aria-selected":i,"aria-controls":`${n}-panel-${t}`,tabIndex:i?0:-1,onClick:()=>{h?s(r):b(r)},children:p[t]},e.id)})}),d.map((e,r)=>{let a=f[r]===S;return(0,Z.jsxs)(`div`,{id:`${n}-panel-${r}`,className:`local-tabpanel`,role:`tabpanel`,"aria-labelledby":`${n}-tab-${r}`,tabIndex:0,hidden:!a,children:[(0,Z.jsx)(yh,{block:!0,value:p[r]}),i(e.children??[],t&&a)]},e.id)}),(0,Z.jsx)($h,{message:c})]})}function kg({node:e,visible:t}){let{runtime:n,render:r}=$(),i=Q(),a=ch(n,e,`label`,``,i);return(0,Z.jsxs)(`div`,{className:`local-accordion`,role:`group`,"aria-label":a||i(`Accordion`,`折叠面板`),children:[a?(0,Z.jsx)(`div`,{className:`local-accordion-label`,children:a}):null,r(e.children??[],t)]})}function Ag({node:e,visible:t}){let n=(0,y.useId)(),{runtime:r,render:i,mode:a}=$(),o=Q(),s=ch(r,e,`label`,o(`Details`,`折叠内容`),o),c=uh(r,e,`open`,!1),[l,u]=(0,y.useState)(c);if(Fh(r,e,()=>{u(c)}),a===`static`)return(0,Z.jsxs)(`section`,{className:`local-disclosure local-static-disclosure`,children:[(0,Z.jsx)(`h3`,{className:`local-disclosure-heading`,children:s}),(0,Z.jsx)(`div`,{className:`local-disclosure-panel`,children:i(e.children??[],t)})]});let d=`${n}-disclosure-trigger`,f=`${n}-disclosure-panel`;return(0,Z.jsxs)(`div`,{className:`local-disclosure`,children:[(0,Z.jsxs)(`h3`,{className:`local-disclosure-heading`,children:[(0,Z.jsxs)(`button`,{id:d,type:`button`,className:`local-disclosure-trigger`,"aria-expanded":l,"aria-controls":f,onClick:()=>u(e=>!e),children:[(0,Z.jsx)(`span`,{className:`local-chevron${l?` is-open`:``}`,"aria-hidden":`true`,children:`▸`}),(0,Z.jsx)(`span`,{children:s})]}),(0,Z.jsx)(yh,{value:s})]}),(0,Z.jsx)(`div`,{id:f,className:`local-disclosure-panel`,role:`region`,"aria-labelledby":d,hidden:!l,children:i(e.children??[],t&&l)})]})}function jg({node:e,visible:t}){let{runtime:n,render:r}=$(),i=Q(),a=lh(n,e,`when`,!1),o=a.ok?a.value:!1,s=!a.ok,c=(0,y.useRef)(null),l=(0,y.useRef)(o),u=(0,y.useRef)(!1);return(0,y.useEffect)(()=>{if(l.current&&!o){if(u.current){let e=c.current?.closest(`.local-document`);e&&(e.tabIndex=-1,e.focus({preventScroll:!0}))}u.current=!1}l.current=o},[o]),(0,Z.jsxs)(Z.Fragment,{children:[s?(0,Z.jsx)(Ih,{}):null,(0,Z.jsx)(`div`,{ref:c,className:`local-if md-if`,role:`group`,"aria-label":i(`Conditional content`,`条件内容`),tabIndex:-1,hidden:!o,"aria-hidden":!o,onFocus:()=>{u.current=!0},onBlur:e=>{c.current?.contains(e.relatedTarget)||(u.current=!1)},children:r(e.children??[],t&&o)})]})}function Mg(){let e=Q();return(0,Z.jsx)(`span`,{className:`local-error local-tone-error`,role:`status`,children:e(`Invalid tone; using the default style`,`色调无效,已使用默认样式`)})}function Ng({node:e,visible:t}){let{runtime:n,render:r}=$(),i=ch(n,e,`title`,``,Q()),{tone:a,error:o}=dh(n,e,`tone`,[`info`,`success`,`warning`],`info`),s=a===`warning`?`alert`:`status`;return(0,Z.jsxs)(Z.Fragment,{children:[o?(0,Z.jsx)(Mg,{}):null,(0,Z.jsxs)(`div`,{className:`local-alert local-alert-${a}`,role:s,children:[i?(0,Z.jsx)(`div`,{className:`local-alert-title`,children:i}):null,(0,Z.jsx)(`div`,{className:`local-alert-body`,children:r(e.children??[],t)})]})]})}function Pg({node:e,visible:t}){let n=$(),{runtime:r}=n,{tone:i,error:a}=dh(r,e,`tone`,[`neutral`,`success`,`warning`],`neutral`),o=bh(e);return(0,Z.jsxs)(Z.Fragment,{children:[a?(0,Z.jsx)(Mg,{}):null,(0,Z.jsx)(`span`,{className:`md-badge md-badge-${i} local-badge`,style:o?{color:o}:void 0,children:Kh(n,e.children,t)})]})}function Fg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),s=ch(i,e,`text`,o(`Tooltip`,`提示`),o),[c,l]=(0,y.useState)(!1),u=`${n}-tooltip`;return a===`static`?(0,Z.jsxs)(`span`,{className:`local-tooltip local-static-tooltip`,children:[(0,Z.jsx)(`span`,{className:`local-tooltip-trigger`,children:Kh(r,e.children,t)}),(0,Z.jsx)(`span`,{className:`local-tooltip-bubble is-visible`,role:`note`,children:s})]}):(0,Z.jsxs)(`span`,{className:`local-tooltip`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[(0,Z.jsx)(`span`,{className:`local-tooltip-trigger`,tabIndex:0,"aria-describedby":u,onFocus:()=>l(!0),onBlur:()=>l(!1),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),l(!1))},children:Kh(r,e.children,t)}),(0,Z.jsx)(`span`,{id:u,role:`tooltip`,className:`local-tooltip-bubble${c?` is-visible`:``}`,children:s}),(0,Z.jsx)(yh,{value:s})]})}function Ig({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{anchors:i,rootRef:a,runtime:o,urlPolicy:s,mode:c}=r,l=Q(),u=`${n}-jump-feedback`,[d,f]=(0,y.useState)(null),p=ah(e,`to`)??``,m=i.targetId(p),h=ah(e,`appearance`)===`button`?`button`:`link`,g=bh(e),_=m?`#${m}`:`#`,v=m!==void 0;if(v&&s)try{v=s(`#${p}`,`link`)===!0}catch{v=!1}return Fh(o,e,()=>f(null)),c===`static`?v&&m?(0,Z.jsx)(`a`,{href:`#${m}`,className:`local-jump local-jump-link local-jump-static`,style:xh(g),children:Kh(r,e.children,t)}):(0,Z.jsx)(`span`,{className:`local-jump local-jump-static-blocked`,style:xh(g),children:Kh(r,e.children,t)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`a`,{href:v?_:`#`,className:`local-jump local-jump-${h}`,style:xh(g),"data-local-target-missing":m?void 0:`true`,"data-local-jump-blocked":m&&!v?`true`:void 0,"aria-describedby":d?u:void 0,onClick:e=>{if(!v||!m){e.preventDefault(),f(m?l(`Jump is blocked by the host`,`跳转已被主机策略阻止`):l(`Jump target not found`,`找不到跳转目标`));return}let t=a.current;if(!t||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let n=null;try{n=t.querySelector(`[id="${m}"]`)}catch{n=null}if(!n){e.preventDefault(),f(l(`Jump target not found`,`找不到跳转目标`));return}if(n.closest(`[hidden]`)){e.preventDefault(),f(l(`Jump target is hidden`,`跳转目标当前隐藏`));return}e.preventDefault(),n.hasAttribute(`tabindex`)||(n.tabIndex=-1);try{n.focus({preventScroll:!0})}catch{}let r=`smooth`;try{window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&(r=`auto`)}catch{r=`auto`}try{n.scrollIntoView({behavior:r,block:`start`})}catch{}f(null)},children:Kh(r,e.children,t)}),d?(0,Z.jsx)(`span`,{id:u,className:`local-jump-feedback`,role:`status`,"aria-live":`polite`,children:d}):null]})}function Lg({node:e}){let{anchors:t}=$(),n=t.anchorIds.get(e);return n?(0,Z.jsx)(`span`,{className:`local-anchor`,id:n,"data-local-anchor":``}):null}function Rg({node:e,visible:t}){let n=$(),r=bh(e);return(0,Z.jsx)(`span`,{className:`local-text`,style:r?{color:r}:void 0,children:Kh(n,e.children,t)})}function zg({node:e,visible:t}){let{render:n}=$(),r=bh(e);return(0,Z.jsx)(`div`,{className:`local-section`,style:r?{color:r}:void 0,children:n(e.children??[],t)})}function Bg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),{write:s,error:c,setError:l}=Nh(e),u=ch(i,e,`label`,o(`Multi select`,`多选`),o),{disabled:d,invalid:f}=Ph(e),p=nh(e),m=ug(e),h=mh(i,e),g=Array.isArray(h)?h.filter(e=>typeof e==`string`):[],_=m.filter(e=>g.includes(e.value)).map(e=>fg(i,e.node,o)||e.value),v=ph(i,e,`max-selected`,m.length),b=Number.isFinite(v)?Math.max(0,Math.floor(v)):m.length,[x,S]=(0,y.useState)(``);if(Fh(i,e,()=>{S(``),l(null)}),m.length===0)return(0,Z.jsx)(Ih,{message:o(`Missing options`,`缺少选项`)});if(a===`static`)return(0,Z.jsx)(vh,{className:`local-multi-select`,label:u,value:_h(_.join(`, `))});let C=new Set(g),w=g.length>=b,T=x.trim().toLocaleLowerCase(),E=T?m.filter(e=>`${dg(i,e.node.children,o)} ${e.value}`.toLocaleLowerCase().includes(T)):m,D=(e,t)=>{let n=new Set(C);if(t){if(!n.has(e)&&n.size>=b)return;n.add(e)}else n.delete(e);s(m.filter(e=>n.has(e.value)).map(e=>e.value))};return(0,Z.jsxs)(`fieldset`,{className:`local-multi-select`,style:xh(bh(e)),disabled:d,"aria-invalid":p.invalid||void 0,"aria-describedby":p.describedBy,children:[(0,Z.jsx)(`legend`,{className:`md-label`,children:u}),(0,Z.jsxs)(`div`,{className:`local-multi-toolbar`,children:[(0,Z.jsx)(`input`,{id:`${n}-multi-search`,type:`search`,className:`md-text-input local-multi-search`,value:x,placeholder:o(`Search options`,`搜索选项`),"aria-label":o(`Search ${u}`,`搜索${u}`),onChange:e=>S(e.target.value)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-quiet local-multi-clear`,onClick:()=>{S(``),g.length>0&&s([])},children:o(`Clear`,`清除`)})]}),(0,Z.jsx)(`div`,{className:`local-multi-list`,role:`group`,"aria-label":u,children:E.length===0?(0,Z.jsx)(`span`,{className:`local-multi-empty`,children:o(`No matching options`,`没有匹配选项`)}):E.map(e=>{let n=C.has(e.value);return(0,Z.jsxs)(`label`,{className:`local-multi-option${n?` is-selected`:``}`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n,disabled:!n&&w,onChange:t=>D(e.value,t.target.checked)}),(0,Z.jsx)(`span`,{children:Kh(r,e.node.children,t)})]},e.node.id)})}),(0,Z.jsx)(`span`,{className:`local-multi-count`,role:`status`,"aria-live":`polite`,children:o(`${g.length} of ${b} selected`,`已选 ${g.length}/${b}`)}),(0,Z.jsx)(yh,{value:_h(_.join(`, `))}),(0,Z.jsx)($h,{message:f?o(`Cannot compute`,`无法计算`):c})]})}function Vg({node:e}){let{runtime:t,mode:n}=$(),r=Q(),{write:i,error:a,setError:o}=Nh(e),s=ch(t,e,`label`,r(`Range`,`范围`),r),{disabled:c,invalid:l}=Ph(e),u=nh(e),{min:d,max:f,step:p}=Mh(t,e,`min`,`max`,0,100,1),m=Math.floor((f-d)/p+1e-9),h=d,g=kh(d+Math.max(0,m)*p,d,f),_=Ah(jh(t,e,`start`,h),d,f,p),v=Ah(jh(t,e,`end`,g),d,f,p);_>v&&(_=v);let[b,x]=(0,y.useState)(null);Fh(t,e,()=>{x(null),o(null)});let S=r(`Start`,`起点`),C=r(`End`,`终点`),w=`${S}: ${_} · ${C}: ${v}`;if(n===`static`)return(0,Z.jsx)(vh,{className:`local-range-slider`,label:s,value:w});let T=(e,t)=>{let n=Ah(kh(t,d,f),d,f,p);e===`start`&&n>v?x(r(`Start cannot exceed end`,`起点不能超过终点`)):e===`end`&&n<_?x(r(`End cannot be less than start`,`终点不能小于起点`)):(x(null),i(n,e))};return(0,Z.jsxs)(`div`,{className:`md-control local-range-slider`,style:xh(bh(e)),role:`group`,"aria-label":s,"aria-invalid":u.invalid||void 0,"aria-describedby":u.describedBy,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:s}),(0,Z.jsxs)(`div`,{className:`local-range-row`,children:[(0,Z.jsx)(`span`,{className:`local-range-name`,children:r(`Start`,`起点`)}),(0,Z.jsx)(`input`,{type:`range`,className:`local-range-input`,min:d,max:v,step:p,value:_,disabled:c,"aria-label":`${s} ${r(`Start`,`起点`)}`,onChange:e=>T(`start`,Number(e.target.value))}),(0,Z.jsx)(`span`,{className:`local-range-value`,"aria-hidden":`true`,children:_})]}),(0,Z.jsxs)(`div`,{className:`local-range-row`,children:[(0,Z.jsx)(`span`,{className:`local-range-name`,children:r(`End`,`终点`)}),(0,Z.jsx)(`input`,{type:`range`,className:`local-range-input`,min:_,max:f,step:p,value:v,disabled:c,"aria-label":`${s} ${r(`End`,`终点`)}`,onChange:e=>T(`end`,Number(e.target.value))}),(0,Z.jsx)(`span`,{className:`local-range-value`,"aria-hidden":`true`,children:v})]}),(0,Z.jsx)(yh,{value:w}),(0,Z.jsx)($h,{message:l?r(`Cannot compute`,`无法计算`):b??a})]})}function Hg({id:e,label:t,value:n,min:r,max:i,step:a,disabled:o,onCommit:s,reset:c}){let[l,u]=(0,y.useState)(()=>String(n)),[d,f]=(0,y.useState)(!1),p=(0,y.useRef)(n);(0,y.useEffect)(()=>{u(String(n)),f(!1)},[c]),(0,y.useEffect)(()=>{p.current!==n&&(p.current=n,d||u(String(n)))},[n,d]);let m=e=>{let t=e.trim();if(t===``||t===`-`||t===`.`||t===`-.`)return null;let n=Number(t);return Number.isFinite(n)?Ah(kh(n,r,i),r,i,a):null};return(0,Z.jsxs)(`div`,{className:`local-number-field`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:e,children:t}),(0,Z.jsx)(`input`,{id:e,className:`md-text-input`,type:`text`,inputMode:`decimal`,value:l,disabled:o,onFocus:()=>f(!0),onBlur:()=>{f(!1);let e=m(l);u(String(e??n))},onChange:e=>{let t=e.target.value;u(t);let n=m(t);n!==null&&s(n)}})]})}function Ug({node:e}){let t=(0,y.useId)(),{runtime:n,mode:r}=$(),i=Q(),{write:a,writeMany:o,error:s,setError:c}=Nh(e),l=ch(n,e,`label`,i(`Coordinate`,`坐标`),i),{disabled:u,invalid:d}=Ph(e),f=nh(e),p=Mh(n,e,`x-min`,`x-max`,-5,5,1),m=Mh(n,e,`y-min`,`y-max`,-5,5,1),h=Ah(0,p.min,p.max,p.step),g=Ah(0,m.min,m.max,m.step),_=Ah(jh(n,e,`x`,h),p.min,p.max,p.step),v=Ah(jh(n,e,`y`,g),m.min,m.max,m.step),b=(0,y.useRef)(null),x=(0,y.useRef)(!1);Fh(n,e,()=>c(null));let S=`X: ${_} · Y: ${v}`;if(r===`static`)return(0,Z.jsx)(vh,{className:`local-coordinate`,label:l,value:S});let C=e=>p.max>p.min?40+(e-p.min)/(p.max-p.min)*320:200,w=e=>m.max>m.min?360-(e-m.min)/(m.max-m.min)*320:200,T=C(_),E=w(v),D=C(kh(0,p.min,p.max)),O=w(kh(0,m.min,m.max)),k=e=>{let t=e.step*Math.max(1,Math.ceil((e.max-e.min)/(e.step*10))),n=Math.min(11,Math.floor((e.max-e.min)/t)+1);return Array.from({length:n},(n,r)=>e.min+r*t)},A=e=>{let t=b.current?.getBoundingClientRect();if(!t||t.width===0||t.height===0)return null;let n=kh(((e.clientX-t.left)/t.width-.1)/.8,0,1),r=kh(((e.clientY-t.top)/t.height-.1)/.8,0,1);return{x:Ah(p.min+n*(p.max-p.min),p.min,p.max,p.step),y:Ah(m.min+(1-r)*(m.max-m.min),m.min,m.max,m.step)}},j=(e,t)=>{(e!==_||t!==v)&&o({x:e,y:t})};return(0,Z.jsxs)(`div`,{className:`local-coordinate`,style:xh(bh(e)),role:`group`,"aria-label":l,"aria-invalid":f.invalid||void 0,"aria-describedby":f.describedBy,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:l}),(0,Z.jsxs)(`div`,{className:`local-coordinate-surface`,children:[(0,Z.jsx)(`div`,{ref:b,className:`local-coordinate-pad`,role:`group`,"aria-label":i(`${l} drag area`,`${l} 拖拽区`),"aria-disabled":u||void 0,tabIndex:u?-1:0,onKeyDown:e=>{if(u)return;let t=_,n=v;switch(e.key){case`ArrowLeft`:t=Ah(_-p.step,p.min,p.max,p.step);break;case`ArrowRight`:t=Ah(_+p.step,p.min,p.max,p.step);break;case`ArrowDown`:n=Ah(v-m.step,m.min,m.max,m.step);break;case`ArrowUp`:n=Ah(v+m.step,m.min,m.max,m.step);break;case`Home`:t=p.min,n=m.min;break;case`End`:t=Ah(p.max,p.min,p.max,p.step),n=Ah(m.max,m.min,m.max,m.step);break;default:return}e.preventDefault(),j(t,n)},onPointerDown:e=>{if(u)return;e.preventDefault(),x.current=!0,b.current?.focus({preventScroll:!0});try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}let t=A(e);t&&j(t.x,t.y)},onPointerMove:e=>{if(!x.current||u)return;let t=A(e);t&&j(t.x,t.y)},onPointerUp:e=>{x.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}},onPointerCancel:()=>{x.current=!1},children:(0,Z.jsxs)(`svg`,{className:`local-coordinate-svg`,viewBox:`0 0 400 400`,"aria-hidden":`true`,focusable:`false`,children:[(0,Z.jsx)(`defs`,{children:(0,Z.jsx)(`marker`,{id:`${t}-coordinate-arrow`,markerWidth:`8`,markerHeight:`8`,refX:`6`,refY:`4`,orient:`auto`,viewBox:`0 0 8 8`,children:(0,Z.jsx)(`path`,{className:`local-coordinate-arrow`,d:`M1 1 L6 4 L1 7`})})}),(0,Z.jsxs)(`g`,{className:`local-coordinate-grid`,children:[(0,Z.jsx)(`rect`,{x:`40`,y:`40`,width:`320`,height:`320`}),k(p).map((e,t)=>(0,Z.jsx)(`line`,{x1:C(e),y1:`40`,x2:C(e),y2:`360`},`x-${t}`)),k(m).map((e,t)=>(0,Z.jsx)(`line`,{x1:`40`,y1:w(e),x2:`360`,y2:w(e)},`y-${t}`))]}),(0,Z.jsxs)(`g`,{className:`local-coordinate-axes`,children:[(0,Z.jsx)(`line`,{className:`local-coordinate-horizontal`,x1:`26`,y1:O,x2:`372`,y2:O,markerEnd:`url(#${t}-coordinate-arrow)`}),(0,Z.jsx)(`line`,{className:`local-coordinate-vertical`,x1:D,y1:`374`,x2:D,y2:`24`,markerEnd:`url(#${t}-coordinate-arrow)`})]}),(0,Z.jsxs)(`g`,{className:`local-coordinate-axis-label`,children:[(0,Z.jsx)(`text`,{x:`358`,y:O-14,children:`x`}),(0,Z.jsx)(`text`,{x:D+12,y:`40`,children:`y`})]}),(0,Z.jsxs)(`g`,{className:`local-coordinate-projection`,children:[(0,Z.jsx)(`line`,{x1:T,y1:E,x2:T,y2:O}),(0,Z.jsx)(`line`,{x1:T,y1:E,x2:D,y2:E})]}),(0,Z.jsx)(`circle`,{className:`local-coordinate-dot`,cx:T,cy:E,r:`10`}),(0,Z.jsx)(`text`,{className:`local-coordinate-value`,x:T,y:E>330?E-22:E+30,textAnchor:T<80?`start`:T>320?`end`:`middle`,children:`(${_}, ${v})`})]})}),(0,Z.jsx)(`span`,{className:`local-coordinate-caption`,children:i(`Draggable coordinate plane`,`可拖动的坐标平面`)})]}),(0,Z.jsx)(`span`,{className:`md-hint local-hint`,children:i(`Arrow keys adjust the point; Home and End jump to the lower or upper bounds.`,`方向键调整坐标;Home 和 End 跳到最小或最大边界。`)}),(0,Z.jsxs)(`div`,{className:`local-coordinate-fields`,children:[(0,Z.jsx)(Hg,{id:`${t}-coordinate-x`,reset:n.resetToken(e),label:`${l} X`,value:_,min:p.min,max:p.max,step:p.step,disabled:u,onCommit:e=>a(e,`x`)}),(0,Z.jsx)(Hg,{id:`${t}-coordinate-y`,reset:n.resetToken(e),label:`${l} Y`,value:v,min:m.min,max:m.max,step:m.step,disabled:u,onCommit:e=>a(e,`y`)})]}),(0,Z.jsx)(yh,{value:S}),(0,Z.jsx)($h,{message:d?i(`Cannot compute`,`无法计算`):s})]})}function Wg({node:e,visible:t}){let n=(0,y.useId)(),r=$(),{runtime:i,mode:a}=r,o=Q(),s=ch(i,e,`label`,o(`Quiz`,`测验`),o),c=ah(e,`type`)===`number`?`number`:`choice`,l=(ah(e,`answer`)??``).trim(),u=ph(i,e,`tolerance`,0),d=Number.isFinite(u)&&u>=0?u:0,{disabled:f,invalid:p}=Ph(e),m=ug(e),h=ch(i,e,`explanation`,``,o),[g,_]=(0,y.useState)(``),[v,b]=(0,y.useState)(null);Fh(i,e,()=>{_(``),b(null)});let x=c===`number`?Number(l):NaN;if(c===`number`&&!Number.isFinite(x))return(0,Z.jsx)(Ih,{message:o(`Quiz answer must be a number`,`测验答案必须是数字`)});if(c===`choice`&&m.length===0)return(0,Z.jsx)(Ih,{message:o(`Missing options`,`缺少选项`)});let S=m.map(e=>fg(i,e.node,o)||e.value);if(a===`static`)return(0,Z.jsxs)(`div`,{className:`local-quiz local-static-quiz`,role:`group`,"aria-label":s,children:[(0,Z.jsx)(`span`,{className:`md-label`,children:s}),c===`choice`?(0,Z.jsx)(`ul`,{className:`local-static-list local-static-quiz-options`,children:m.map(e=>(0,Z.jsx)(`li`,{className:`local-static-list-item`,children:Kh(r,e.node.children,t)},e.node.id))}):(0,Z.jsx)(`span`,{className:`local-static-value`,children:o(`Numeric answer`,`数字作答`)})]});let C=()=>{if(c===`choice`){if(g===``){b(`incomplete`);return}b(g===l?`correct`:`incorrect`);return}let e=g.trim(),t=e===``?NaN:Number(e);b(Number.isFinite(t)?Math.abs(t-x)<=d?`correct`:`incorrect`:`incomplete`)},w=()=>{_(``),b(null)},T=v===null?null:v===`correct`?`${o(`Correct`,`回答正确`)}`:v===`incorrect`?`${o(`Not quite`,`回答不正确`)}`:c===`number`?o(`Enter a number first`,`请先输入数字`):o(`Choose an answer first`,`请先选择答案`),E=v===`correct`?` is-correct`:v===`incorrect`?` is-incorrect`:``;return(0,Z.jsxs)(`div`,{className:`local-quiz`,role:`group`,"aria-label":s,children:[c===`choice`?(0,Z.jsxs)(`fieldset`,{className:`local-quiz-options`,disabled:f,children:[(0,Z.jsx)(`legend`,{className:`md-label`,children:s}),m.map(e=>(0,Z.jsxs)(`label`,{className:`local-radio-option`,children:[(0,Z.jsx)(`input`,{type:`radio`,name:`${n}-quiz`,value:e.value,checked:g===e.value,onChange:()=>{_(e.value),b(null)}}),(0,Z.jsx)(`span`,{children:Kh(r,e.node.children,t)})]},e.node.id))]}):(0,Z.jsxs)(`div`,{className:`local-quiz-number`,children:[(0,Z.jsx)(`label`,{className:`md-label`,htmlFor:`${n}-quiz`,children:s}),(0,Z.jsx)(`input`,{id:`${n}-quiz`,className:`md-text-input local-quiz-input`,type:`text`,inputMode:`decimal`,value:g,disabled:f,"aria-label":s,onChange:e=>{_(e.target.value),b(null)}})]}),(0,Z.jsxs)(`div`,{className:`local-quiz-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-primary local-quiz-check`,disabled:f,onClick:C,children:o(`Check answer`,`检查答案`)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-quiz-again`,disabled:f,onClick:w,children:o(`Try again`,`再试一次`)})]}),(0,Z.jsx)(`span`,{className:`local-quiz-feedback${E}`,role:`status`,"aria-live":`polite`,children:T?`${v===`correct`?`✓ `:v===`incorrect`?`✗ `:``}${T}`:``}),v!==null&&h?(0,Z.jsx)(`div`,{className:`local-quiz-explanation`,children:h}):null,(0,Z.jsx)(yh,{block:!0,value:c===`choice`?`${T?`${T} · `:``}${S.join(` · `)}`:T||o(`No answer yet`,`尚未作答`)}),(0,Z.jsx)($h,{message:p?o(`Cannot compute`,`无法计算`):null})]})}function Gg({node:e,visible:t}){let n=(0,y.useId)(),{runtime:r,render:i,mode:a}=$(),o=Q(),{write:s,error:c,setError:l}=Nh(e),u=ch(r,e,`label`,``,o),d=nh(e),f=(e.children??[]).filter(e=>e.type===`component`&&e.name===`step`),p=f.map((e,t)=>ah(e,`value`)??`step-${t+1}`),m=f.map((e,t)=>ch(r,e,`label`,p[t],o)),h=ah(e,`initial`)??``,g=p.includes(h)?h:p[0]??``,_=mh(r,e),v=typeof _==`string`?_:``,b=(0,y.useRef)([]),x=(0,y.useRef)(!1);Fh(r,e,()=>{l(null),x.current=!1});let S=p.includes(v)?v:g,C=Math.max(0,p.indexOf(S));if((0,y.useEffect)(()=>{x.current&&(x.current=!1,b.current[C]?.focus({preventScroll:!0}))},[C,S]),f.length===0)return(0,Z.jsx)(Ih,{message:o(`Steps requires at least one step`,`步骤至少需要一个 step`)});if(a===`static`){let e=f[C];return(0,Z.jsxs)(`section`,{className:`local-steps local-static-steps`,"aria-label":u||o(`Steps`,`步骤`),children:[u?(0,Z.jsx)(`div`,{className:`local-steps-label`,children:u}):null,(0,Z.jsx)(`div`,{className:`local-steps-nav local-static-steps-nav`,children:(0,Z.jsx)(`span`,{className:`local-steps-status`,role:`status`,"aria-live":`polite`,children:o(`Step ${C+1} of ${f.length}`,`第 ${C+1} 步,共 ${f.length} 步`)})}),(0,Z.jsx)(`div`,{className:`local-steps-panel`,role:`group`,"aria-label":m[C],children:i(e.children??[],t)})]})}let w=e=>{let t=p[e];t!==void 0&&(x.current=!0,s(t))};return(0,Z.jsxs)(`section`,{className:`local-steps`,"aria-label":u||o(`Steps`,`步骤`),"aria-invalid":d.invalid||void 0,"aria-describedby":d.describedBy,children:[u?(0,Z.jsx)(`div`,{className:`local-steps-label`,children:u}):null,(0,Z.jsxs)(`div`,{className:`local-steps-nav`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-steps-prev`,disabled:C<=0,onClick:()=>w(C-1),children:o(`Previous`,`上一步`)}),(0,Z.jsx)(`span`,{className:`local-steps-status`,role:`status`,"aria-live":`polite`,children:o(`Step ${C+1} of ${f.length}`,`第 ${C+1} 步,共 ${f.length} 步`)}),(0,Z.jsx)(`button`,{type:`button`,className:`md-button md-button-secondary local-steps-next`,disabled:C>=f.length-1,onClick:()=>w(C+1),children:o(`Next`,`下一步`)})]}),f.map((e,r)=>{let a=r===C;return(0,Z.jsx)(`div`,{id:`${n}-step-${r}`,ref:e=>{b.current[r]=e},className:`local-steps-panel`,role:`group`,"aria-label":m[r],tabIndex:-1,hidden:!a,children:i(e.children??[],t&&a)},e.id)}),(0,Z.jsx)($h,{message:c})]})}function Kg(){return null}var qg={panel:Cg,card:wg,grid:Tg,tabs:Og,tab:Eg,accordion:kg,disclosure:Ag,if:jg,alert:Ng,badge:Pg,validation:Zh,column:Qh,tooltip:Fg,input:tg,textarea:ng,number:ag,slider:og,toggle:sg,checkbox:cg,date:lg,select:mg,choices:hg,"radio-group":gg,option:pg,node:Eg,edge:Dg,counter:bg,timer:xg,checklist:vg,progress:Sg,jump:Ig,anchor:Lg,text:Rg,section:zg,"multi-select":Bg,"range-slider":Vg,coordinate:Ug,quiz:Wg,steps:Gg,step:Kg};function Jg({document:e,runtime:t,onDiagnostics:n,urlPolicy:r,locale:i=`en`,themes:a,colorScheme:o=`auto`,mode:s=`interactive`,staticFirst:c=!1,imageResolver:l}){let[u,d]=(0,y.useState)(!c);(0,y.useEffect)(()=>{c&&d(!0)},[c]);let f=s===`interactive`&&c&&!u?`static`:s,p=(0,y.useId)(),m=(0,y.useMemo)(()=>(e,t)=>pp(i,e,t),[i]),h=(0,y.useMemo)(()=>rr(e,`local-heading-${p}`),[e,p]),g=(0,y.useMemo)(()=>{try{return Un(e)}catch{return Ln}},[e]),_=(0,y.useRef)(n);_.current=n;let v=(0,y.useRef)(null),b=(0,y.useCallback)(e=>{_.current?.(e)},[]),x=Ch(a),S=(0,y.useMemo)(()=>{try{return Fu(e.theme,a,e.themeRange,e.source)}catch{return{name:Ou.name,diagnostics:[]}}},[e.theme,e.themeRange?.start,e.themeRange?.end,e.source,x]),C=Oh(v,o),w=(0,y.useRef)(``);(0,y.useEffect)(()=>{let e=wh(S.diagnostics);if(e===w.current)return;let t=w.current!==``;w.current=e,(S.diagnostics.length>0||t)&&b(S.diagnostics)},[S,b]);let T=(0,y.useCallback)(e=>{try{return t.subscribe(e)}catch{return()=>{}}},[t]),E=(0,y.useCallback)(()=>{try{return t.snapshot()}catch{return ih}},[t]);(0,y.useSyncExternalStore)(T,E,E);let D=``;if(e.validations?.length)try{D=wh(t.validate())}catch{D=`unavailable`}let O=(0,y.useMemo)(()=>th(e,t,p,m),[e,t,p,m,D]),k=(0,y.useMemo)(()=>({runtime:t,urlPolicy:r,imageResolver:l,anchors:h,t:m,mode:f,dependencies:g}),[t,r,l,h,m,f,g]),A=(0,y.useCallback)((e,t=!0)=>Uh(k,e??[],t),[k]),j=(0,y.useMemo)(()=>({runtime:t,render:A,visible:!0,mode:f,imageResolver:l,validation:O,report:b,urlPolicy:r,anchors:h,rootRef:v,t:m,dependencies:g}),[t,A,b,r,l,f,h,v,m,O,g]);return(0,Z.jsx)(dp,{locale:i,children:(0,Z.jsx)(`article`,{ref:v,className:`md-document local-document${f===`static`?` local-static`:``}`,"data-rmd-theme":S.name,"data-color-scheme":C,"data-render-mode":f,style:{colorScheme:C},"aria-label":f===`static`?m(`Static document`,`静态文档`):m(`Interactive document`,`交互文档`),children:(0,Z.jsx)(qm.Provider,{value:j,children:A(e.nodes,!0)})})})}var Yg=`reactive-md-state/v1`,Xg=1048576,Zg=/^fnv1a32:[0-9a-f]{8}$/,Qg=2166136261,$g=16777619,e_=new Set([`format`,`syntax`,`sourceDigest`,`parameters`,`generator`]),t_=new Set([`name`,`version`]),n_=new TextEncoder;function r_(e,t){return{code:e,message:t.length>2e3?`${t.slice(0,D-1)}…`:t,severity:`error`,range:{start:0,end:0},line:1,column:1}}function i_(e,t,n){e.length<100&&e.push(r_(t,n))}function a_(e){return e instanceof Error?e.message:String(e)}function o_(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){t+=1;continue}return!1}if(n>=56320&&n<=57343)return!1}return!0}function s_(e){if(typeof e!=`string`)throw TypeError(`localSourceDigest requires a source string.`);let t=n_.encode(e),n=Qg;for(let e=0;e<t.length;e+=1)n^=t[e],n=Math.imul(n,$g)>>>0;return`fnv1a32:${n.toString(16).padStart(8,`0`)}`}function c_(e){if(typeof e==`string`)return o_(e)?{ok:!0,value:e}:{ok:!1,message:`contains malformed Unicode.`};if(typeof e==`number`)return Number.isFinite(e)?{ok:!0,value:e}:{ok:!1,message:`must be a finite number.`};if(typeof e==`boolean`||e===null)return{ok:!0,value:e};if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(typeof r!=`string`)return{ok:!1,message:`must be an array of strings.`};if(!o_(r))return{ok:!1,message:`contains malformed Unicode.`};t.push(r)}return{ok:!0,value:Object.freeze(t)}}return{ok:!1,message:`must be a string, finite number, boolean, null or string array.`}}function l_(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function u_(e){return Object.freeze(e.parameters),e.generator&&Object.freeze(e.generator),Object.freeze(e)}function d_(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`generator must be an object with string name and version.`);if(typeof e.name!=`string`||typeof e.version!=`string`)throw TypeError(`generator must have string name and version.`);if(!o_(e.name)||!o_(e.version))throw TypeError(`generator name and version must be well-formed Unicode strings.`);return Object.freeze({name:e.name,version:e.version})}function f_(e){return typeof e==`string`?`"${e.length>48?`${e.slice(0,48)}…`:e}"`:e===null?`null`:Array.isArray(e)?`an array`:typeof e}function p_(e,t){return e.length>t?e.length:n_.encode(e).byteLength}function m_(e,t){let n;try{let t=JSON.stringify(e);if(typeof t!=`string`)return null;n=t}catch{return null}return p_(n,t)}function h_(e){if(e===void 0)return Xg;if(typeof e!=`object`||!e)throw TypeError(`parseLocalState options must be an object.`);let{maxLength:t}=e;if(t===void 0)return Xg;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<=0)throw RangeError(`maxLength must be a finite positive integer.`);return t}function g_(e,t,n){if(!e||e.syntax!==`local`||typeof e.source!=`string`)throw TypeError(`createLocalStateFile requires a compiled local document.`);if(!t||typeof t!=`object`||Array.isArray(t))throw TypeError(`createLocalStateFile requires a state object.`);let r=Object.keys(e.bindings).filter(e=>!e.startsWith(`@`)).sort(),i=new Set(r),a=new Map;for(let n of Object.keys(t)){if(Object.hasOwn(e.computations??{},n))continue;if(n.startsWith(`@`)){if(!Object.hasOwn(e.bindings,n))throw Error(`Cannot persist parameter "${n}": it is not a binding of this document.`);continue}if(!i.has(n))throw Error(`Cannot persist parameter "${n}": it is not a public binding of this document.`);let r=c_(t[n]);if(!r.ok)throw TypeError(`Cannot persist parameter "${n}": the value ${r.message}`);a.set(n,r.value)}let o={};for(let e of r){if(!a.has(e))throw Error(`Cannot persist the document: parameter "${e}" is missing from the supplied state.`);o[e]=a.get(e)}let s={format:Yg,syntax:au,sourceDigest:s_(e.source),parameters:o};return n!==void 0&&(s.generator=d_(n)),u_(s)}function __(e,t){let n=[],r=(e,t)=>i_(n,e,t),i=e;if(typeof e==`string`){if(p_(e,t)>t)return{ok:!1,diagnostics:[r_(`local.state.size`,`The state payload exceeds the ${t}-byte limit.`)]};if(!o_(e))return{ok:!1,diagnostics:[r_(`local.state.utf`,`The state payload contains malformed Unicode.`)]};try{i=JSON.parse(e)}catch(e){return{ok:!1,diagnostics:[r_(`local.state.json`,`The state payload is not valid JSON: ${a_(e)}`)]}}}else{let n=m_(e,t);if(n===null)return{ok:!1,diagnostics:[r_(`local.state.shape`,`The state payload must be a JSON object.`)]};if(n>t)return{ok:!1,diagnostics:[r_(`local.state.size`,`The state payload exceeds the ${t}-byte limit.`)]}}if(!l_(i))return{ok:!1,diagnostics:[r_(`local.state.shape`,`The state payload must be a JSON object.`)]};Object.getOwnPropertySymbols(i).length>0&&r(`local.state.shape`,`The state payload cannot use symbol keys.`);for(let e of Object.keys(i))e_.has(e)||r(`local.state.key`,`Unknown top-level state key "${e}".`);let a=i.format;a!==`reactive-md-state/v1`&&r(`local.state.format`,`Unsupported state format ${f_(a)}; expected "${Yg}".`);let o=i.syntax;o!==`local-draft-2`&&r(`local.state.syntax`,`Unsupported state syntax ${f_(o)}; expected "${au}".`);let s=i.sourceDigest;typeof s==`string`&&Zg.test(s)||r(`local.state.digest`,`sourceDigest must match "fnv1a32:" followed by 8 lowercase hexadecimal digits.`);let c={},l=i.parameters;if(!l_(l))r(`local.state.parameters`,`parameters must be a JSON object of public binding values.`);else for(let e of Object.keys(l).sort()){if(e===`__proto__`){r(`local.state.parameter.prototype`,`Parameter names cannot be "__proto__".`);continue}if(e.startsWith(`@`)){r(`local.state.parameter.internal`,`Internal parameter "${e}" cannot be persisted.`);continue}let t=c_(l[e]);t.ok?c[e]=t.value:r(`local.state.parameter.value`,`Parameter "${e}" ${t.message}`)}let u;if(Object.hasOwn(i,`generator`)){let e=i.generator;if(!l_(e))r(`local.state.generator`,`generator must be an object with string name and version.`);else{for(let t of Object.keys(e))t_.has(t)||r(`local.state.generator`,`generator has unknown key "${t}".`);typeof e.name!=`string`||typeof e.version!=`string`?r(`local.state.generator`,`generator must have string name and version.`):!o_(e.name)||!o_(e.version)?r(`local.state.utf`,`generator contains malformed Unicode.`):u=Object.freeze({name:e.name,version:e.version})}}if(n.length)return{ok:!1,diagnostics:n};let d={format:Yg,syntax:au,sourceDigest:s,parameters:c};return u&&(d.generator=u),{ok:!0,file:u_(d)}}function v_(e,t){let n=h_(t);try{return __(e,n)}catch(e){return{ok:!1,diagnostics:[r_(`local.state.invalid`,`Cannot read the local state: ${a_(e)}`)]}}}function y_(e){let t=new Map,n=e=>{for(let r of e)t.set(r.id,r),r.children&&n(r.children)};return n(e.nodes),t}function b_(e){let t=y_(e),n=new Map,r=[];for(let[i,a]of Object.entries(e.bindingSlots??{})){let e=t.get(i);if(!e)continue;let o={node:e,slots:[]};for(let[t,r]of Object.entries(a))o.slots.push({slot:t,key:r}),r.startsWith(`@`)||n.set(r,{node:e,slot:t});o.slots.length&&r.push(o)}let i=[];for(let[r,a]of Object.entries(e.bindings)){if(r.startsWith(`@`))continue;let e=n.get(r);if(e){i.push({key:r,binding:a,node:e.node,slot:e.slot});continue}let o=a.owner&&t.has(a.owner)?a.owner:a.nodeIds.find(e=>t.has(e));i.push({key:r,binding:a,node:o?t.get(o):void 0})}return{plans:i,groups:r}}function x_(e,t,n){let r=[];for(let i of t.plans)i.slot===void 0&&Object.hasOwn(n,i.key)&&(i.node?Object.is(e.get(i.node),n[i.key])||r.push(...e.set(i.node,n[i.key])):r.push(r_(`local.state.document`,`The document has no component for parameter "${i.key}".`)));for(let i of t.groups){let t={},a=!1;for(let{slot:e,key:r}of i.slots)Object.hasOwn(n,r)&&(t[e]=n[r],a=!0);a&&r.push(...e.setMany(i.node,t))}return r}function S_(e,t){let n=e.snapshot(),r={};for(let e of t){let t=n.state[e];r[e]=Array.isArray(t)?Object.freeze([...t]):t}return Object.freeze(r)}function C_(e,t,n,r){let i=v_(t,r);if(!i.ok)return i;if(!e||e.syntax!==`local`||typeof e.source!=`string`||!Array.isArray(e.nodes)||!e.bindings)return{ok:!1,diagnostics:[r_(`local.state.document`,`resolveLocalState requires a compiled local document.`)]};if(i.file.syntax!==`local-draft-2`)return{ok:!1,diagnostics:[r_(`local.state.syntax`,`This state file uses syntax "${i.file.syntax}", but this build accepts "${au}".`)]};if(i.file.sourceDigest!==s_(e.source))return{ok:!1,diagnostics:[r_(`local.state.source`,`This state file was created for a different document (source digest mismatch).`)]};let a=b_(e),o=new Set(a.plans.map(e=>e.key)),s=[];for(let e of Object.keys(i.file.parameters))o.has(e)||i_(s,`local.state.parameter.unknown`,`The state contains unknown parameter "${e}" for this document.`);for(let e of o)Object.hasOwn(i.file.parameters,e)||i_(s,`local.state.parameter.missing`,`The state is missing parameter "${e}".`);if(s.length)return{ok:!1,diagnostics:s};let c;try{c=qf(e)}catch(e){return{ok:!1,diagnostics:[r_(`local.state.document`,`Cannot validate this document: ${a_(e)}`)]}}try{if(n){let e=x_(c,a,n);if(e.length)return{ok:!1,diagnostics:e}}let e=x_(c,a,i.file.parameters);if(e.length)return{ok:!1,diagnostics:e};let t=[...o].sort();return{ok:!0,file:i.file,state:S_(c,t)}}finally{c.dispose()}}function w_(e,t,n){try{return C_(e,t,void 0,n)}catch(e){return{ok:!1,diagnostics:[r_(`local.state.invalid`,`Cannot resolve the local state: ${a_(e)}`)]}}}function T_(e,t){return g_(e.document,e.getParameters(),t)}function E_(e,t){return{code:e,message:t,severity:`error`,range:{start:0,end:0},line:1,column:1}}function D_(e,t=8){let n=e.slice(0,t).map(e=>`- [${e.code}] ${e.message} (line ${e.line}, column ${e.column})`);return e.length>n.length&&n.push(`- ${e.length-n.length} more diagnostic(s).`),n.join(`
57
57
  `)}function O_(e){return e instanceof Error?e.message:String(e)}var k_=class extends Error{diagnostics;constructor(e,t){let n=D_(t);super(n?`${e}\n${n}`:e),this.name=`ReactiveMDMountError`,this.diagnostics=t}};function A_(e,t=`standalone.mount`){if(typeof e==`object`&&e&&Array.isArray(e.diagnostics)){let t=e.diagnostics;if(t.length>0)return t}return[E_(t,O_(e))]}var j_=`reactive-md-diagnostics`,M_=`reactive-md-state-change`,N_=/^[A-Za-z][A-Za-z0-9_-]*$/,P_=256,F_=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/,I_=/[\u0000-\u001f\u007f-\u009f]/,L_=64,R_=4096,z_=41943040;function B_(e,t){if(e===void 0)return;if(!V_(e)){t(`standalone.payload.images`,`images must be a JSON object mapping image URLs to data URLs.`);return}let n=Object.entries(e);if(n.length>L_){t(`standalone.payload.images`,`images cannot contain more than ${L_} entries.`);return}let r=Object.create(null),i=0;for(let[e,a]of n)if(!e||e.length>R_||e===`__proto__`||I_.test(e)||typeof a!=`string`||!F_.test(a))t(`standalone.payload.images`,`Every image entry must use a bounded URL key and a base64 raster data URL.`);else{if(i+=a.length,i>z_){t(`standalone.payload.images`,`The embedded image map exceeds the 40 MiB budget.`);return}r[e]=a}return r}function V_(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function H_(e){let t=[],n=(e,n)=>{t.push(E_(e,n))};if(!V_(e))return{ok:!1,diagnostics:[E_(`standalone.payload.shape`,`The reactive-md payload must be a JSON object.`)]};e.version!==1&&n(`standalone.payload.version`,`The reactive-md payload must use version 1.`);let r=e.target;typeof r!=`string`||r.length===0||r.length>P_?n(`standalone.payload.target`,`The payload target must be an element id of 1-${P_} characters.`):N_.test(r)||n(`standalone.payload.target`,`The payload target must start with a letter and use only letters, digits, underscores or hyphens.`);let i=e.source;typeof i!=`string`&&n(`standalone.payload.source`,`The payload source must be a string.`);let a=e.locale===void 0?`en`:e.locale;a!==`en`&&a!==`zh`&&n(`standalone.payload.locale`,`The payload locale must be "en" or "zh".`);let o=e.colorScheme===void 0?`auto`:e.colorScheme;o!==`light`&&o!==`dark`&&o!==`auto`&&n(`standalone.payload.color-scheme`,`The payload colorScheme must be "light", "dark" or "auto".`);let s=e.hydrate!==void 0&&e.hydrate;typeof s!=`boolean`&&n(`standalone.payload.hydrate`,`The payload hydrate flag must be a boolean.`);let c=e.state;V_(c)||n(`standalone.payload.state`,`The payload state must be a JSON object.`);let l=B_(e.images,n);return t.length>0?{ok:!1,diagnostics:t}:{ok:!0,payload:{version:1,target:r,source:i,state:c,locale:a,colorScheme:o,hydrate:s,...l&&Object.keys(l).length>0?{images:l}:{}}}}function U_(e){try{return H_(e)}catch(e){return{ok:!1,diagnostics:[E_(`standalone.payload.invalid`,`The reactive-md payload could not be read: ${O_(e)}`)]}}}function W_(e){return Array.isArray(e)?e.slice():e}function G_(e,t){let n=w_(e,t);if(!n.ok)return n;let r={};for(let[t,i]of Object.entries(e.bindings))r[t]=Object.hasOwn(n.state,t)?{...i,initial:W_(n.state[t])}:i;let i={...e.initialState};for(let[e,t]of Object.entries(n.state))i[e]=W_(t);return{ok:!0,baseline:{document:{...e,bindings:r,initialState:i},state:n.state}}}function K_(e,t,n){if(typeof e!=`string`)throw new k_(`Cannot mount a Reactive MD document: source must be a string.`,[E_(`standalone.source`,`source must be a string.`)]);let r=Sd(e);if(!r.ok)throw new k_(`Cannot mount a Reactive MD document: the source contains syntax errors.`,r.diagnostics);let i=r.document;if(t!==void 0){let e=v_(t);if(!e.ok)throw new k_(`Cannot mount a Reactive MD document: the state payload is invalid.`,e.diagnostics);let n=G_(i,e.file);if(!n.ok)throw new k_(`Cannot mount a Reactive MD document: the state does not match this source.`,n.diagnostics);i=n.baseline.document}return typeof n==`string`&&n.trim().length>0&&(i={...i,theme:n.trim(),themeRange:void 0}),{document:i,diagnostics:r.diagnostics.slice()}}var q_=`0.4.0`,J_=Object.freeze({name:`reactive-md-standalone`,version:q_}),Y_=`data-reactive-md-mounted`,X_=`script[type="application/reactive-md+json"][data-reactive-md-auto]`,Z_=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/,Q_=64;function $_(e){if(!e)return{};let t=new Map;for(let[n,r]of Object.entries(e).slice(0,Q_))typeof n==`string`&&n.length>0&&typeof r==`string`&&Z_.test(r)&&t.set(n,r);return t.size===0?{}:{urlPolicy:(e,n)=>n===`link`||t.has(e),imageResolver:e=>t.get(e)??null}}var ev=new WeakSet;function tv(e){return ev.has(e)||e.hasAttribute(`data-reactive-md-mounted`)}function nv(e,t){return T_(e,t)}function rv(e){if(e)try{e()}catch{}}function iv(e){let t=()=>{let t=e.querySelector(`article.local-document`);t&&(t.classList.remove(`local-static-first`,`reactive-md-static-first`,`reactive-md-hydrating`),t.removeAttribute(`data-static-first`),t.removeAttribute(`data-reactive-md-static-first`)),e.classList.remove(`local-static-first`,`reactive-md-static-first`),e.removeAttribute(`data-static-first`)};if(typeof requestAnimationFrame!=`function`)return t(),()=>{};let n=0,r=0;return n=requestAnimationFrame(()=>{t(),r=requestAnimationFrame(t)}),()=>{typeof cancelAnimationFrame==`function`&&(cancelAnimationFrame(n),r&&cancelAnimationFrame(r))}}function av(e,t,n={}){if(!e||typeof e!=`object`||!(`nodeType`in e)||!e.hasAttribute)throw new k_(`Cannot mount a Reactive MD document: element must be an HTMLElement.`,[E_(`standalone.element`,`element must be an HTMLElement.`)]);if(tv(e))throw new k_(`Cannot mount a Reactive MD document: this element is already mounted.`,[E_(`standalone.mount`,`The target element already hosts a Reactive MD document.`)]);if(!t||typeof t!=`object`)throw new k_(`Cannot mount a Reactive MD document: options are required.`,[E_(`standalone.options`,`mount requires an options object with a source string.`)]);let r=K_(t.source,t.state,n.theme),i;try{i=qf(r.document)}catch(e){throw new k_(`Cannot mount a Reactive MD document: the interactive runtime could not be created.`,[E_(`standalone.runtime`,O_(e))])}let a=t.generator??J_,o=$_(t.images),s=t.urlPolicy??o.urlPolicy,c=t.imageResolver??o.imageResolver,l=()=>nv(i,a),u;try{u=l()}catch(e){try{i.dispose()}catch{}throw new k_(`Cannot mount a Reactive MD document: the initial state could not be captured.`,[E_(`standalone.state`,O_(e))])}let d=!1,f=e=>{d||rv(n.onDiagnostics?()=>n.onDiagnostics(e):void 0)},p=t.hydrate===!0&&e.hasChildNodes(),m=(0,Z.jsx)(Jg,{document:r.document,runtime:i,onDiagnostics:f,urlPolicy:s,locale:t.locale??`en`,themes:t.themes,colorScheme:t.colorScheme??`auto`,mode:`interactive`,staticFirst:p,imageResolver:c});if(!p)for(;e.firstChild;)e.removeChild(e.firstChild);let h=null;try{h=p?(0,b.hydrateRoot)(e,m):(0,b.createRoot)(e),p||h.render(m)}catch(e){try{h?.unmount()}catch{}try{i.dispose()}catch{}throw new k_(`Cannot mount a Reactive MD document: React could not render the document.`,A_(e,`standalone.render`))}ev.add(e),e.setAttribute(Y_,``);let g=n.onStateChange?i.subscribe(()=>{if(d)return;let e;try{e=l()}catch{return}rv(n.onStateChange?()=>n.onStateChange(e):void 0)}):()=>{};rv(n.onStateChange?()=>n.onStateChange(u):void 0),r.diagnostics.length>0&&f(r.diagnostics);let _=p?iv(e):()=>{};return{element:e,getState(){if(d)throw Error(`This Reactive MD document has been unmounted.`);return l()},unmount:()=>{if(!d){d=!0,g(),_();try{h?.unmount()}catch{}try{i.dispose()}catch{}ev.delete(e),e.getAttribute(`data-reactive-md-mounted`)===``&&e.removeAttribute(Y_)}}}}function ov(e,t){return av(e,t)}function sv(e,t,n){if(typeof console<`u`&&typeof console.error==`function`)try{console.error(`Reactive MD: ${n.map(e=>`[${e.code}] ${e.message}`).join(` `)}`)}catch{}let r=e.defaultView?.CustomEvent;if(typeof r==`function`)try{t.dispatchEvent(new r(j_,{detail:n,bubbles:!0,composed:!0}))}catch{}}function cv(e,t){let n=t.defaultView?.HTMLElement;return n?e instanceof n:e.namespaceURI===`http://www.w3.org/1999/xhtml`}function lv(e){if(typeof document>`u`)return[];let t=e??document,n=t,r=n.nodeType===9?t:n.ownerDocument??document,i=[],a;try{a=Array.from(t.querySelectorAll(X_))}catch{return i}for(let e of a){let a;try{a=U_(JSON.parse(e.textContent??``))}catch(t){sv(r,e,[E_(`standalone.payload.json`,`The reactive-md payload is not valid JSON: ${O_(t)}`)]);continue}if(!a.ok){sv(r,e,a.diagnostics);continue}let o=a.payload,s=t,c=(typeof s.getElementById==`function`?s.getElementById(o.target):null)??r.getElementById(o.target);if(!c)sv(r,e,[E_(`standalone.target.missing`,`The reactive-md payload target "#${o.target}" was not found.`)]);else if(n!==r&&!n.contains(c))sv(r,e,[E_(`standalone.target.scope`,`The reactive-md payload target is outside the scanned root.`)]);else if(!cv(c,r))sv(r,e,[E_(`standalone.target.type`,`The reactive-md payload target must be an HTML element.`)]);else if(!tv(c))try{i.push(ov(c,{source:o.source,state:o.state,locale:o.locale,colorScheme:o.colorScheme,hydrate:o.hydrate,images:o.images}))}catch(e){sv(r,c,A_(e))}}return i}var uv=`reactive-md-doc`,dv=typeof HTMLElement<`u`?HTMLElement:class{};function fv(e){return typeof e==`object`&&!!e&&e.name===`AbortError`}var pv=class extends dv{static observedAttributes=[`src`,`source`,`locale`,`color-scheme`,`theme`];_source;_state;_urlPolicy;_imageResolver;_themes;_connected=!1;_generation=0;_restartScheduled=!1;_session=null;_abort=null;_stateTimer=null;_pendingState=null;_cache=null;connectedCallback(){this._connected||(this._connected=!0,this._start())}disconnectedCallback(){this._connected&&(this._connected=!1,this._generation+=1,this._restartScheduled=!1,this._abortFetch(),this._clearStateTimer(),this._teardown(),this._cache=null)}attributeChangedCallback(e,t,n){t!==n&&(e===`src`&&(this._cache=null),this._requestRestart())}get src(){return this.getAttribute(`src`)??void 0}set src(e){e==null?this.removeAttribute(`src`):this.setAttribute(`src`,e)}get theme(){return this.getAttribute(`theme`)??void 0}set theme(e){e==null?this.removeAttribute(`theme`):this.setAttribute(`theme`,e)}get source(){return this._source===void 0?this.getAttribute(`source`)??void 0:this._source}set source(e){let t=typeof e==`string`?e:void 0;t!==this._source&&(this._source=t,this._requestRestart())}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._requestRestart())}get urlPolicy(){return this._urlPolicy}set urlPolicy(e){e!==this._urlPolicy&&(this._urlPolicy=e,this._requestRestart())}get imageResolver(){return this._imageResolver}set imageResolver(e){e!==this._imageResolver&&(this._imageResolver=e,this._requestRestart())}get themes(){return this._themes}set themes(e){e!==this._themes&&(this._themes=e,this._requestRestart())}get _locale(){return this.getAttribute(`locale`)===`zh`?`zh`:`en`}get _colorScheme(){let e=this.getAttribute(`color-scheme`);return e===`light`||e===`dark`?e:`auto`}get _themeOverride(){return this.getAttribute(`theme`)?.trim()||void 0}_requestRestart(){this._connected&&!this._restartScheduled&&(this._restartScheduled=!0,queueMicrotask(()=>{this._restartScheduled=!1,this._connected&&this._start()}))}_start(){this._generation+=1;let e=this._generation;this._abortFetch(),this._clearStateTimer(),this._teardown(),this._load(e)}async _load(e){let t=this.getAttribute(`src`)?.trim()??``,n=this.source;if(t){if(this._cache&&this._cache.src===t)n=this._cache.text;else{let r=null;try{r=typeof AbortController==`function`?new AbortController:null,this._abort=r;let i=await fetch(t,r?{signal:r.signal}:{});if(!i.ok)throw Error(`HTTP ${i.status}${i.statusText?` ${i.statusText}`:``}`);let a=await i.text();if(!this._connected||e!==this._generation)return;this._cache={src:t,text:a},n=a}catch(n){if(!this._connected||e!==this._generation||fv(n))return;this._showError([E_(`standalone.fetch`,`Cannot load "${t}": ${O_(n)}`)]);return}finally{this._abort===r&&(this._abort=null)}}}if(this._connected&&e===this._generation){if(typeof n!=`string`)this._showError([E_(`standalone.source`,`The <reactive-md-doc> element requires a "src" attribute or a "source" attribute/property.`)]);else try{let t=av(this,{source:n,state:this._state,locale:this._locale,colorScheme:this._colorScheme,themes:this._themes,urlPolicy:this._urlPolicy,imageResolver:this._imageResolver},{theme:this._themeOverride,onDiagnostics:e=>this._emitDiagnostics(e),onStateChange:e=>this._queueState(e)});if(!this._connected||e!==this._generation){try{t.unmount()}catch{}return}this._session=t}catch(e){this._session=null,this._showError(A_(e))}}}_teardown(){let e=this._session;if(this._session=null,e)try{e.unmount()}catch{}}_abortFetch(){let e=this._abort;if(this._abort=null,e)try{e.abort()}catch{}}_clearStateTimer(){this._stateTimer!==null&&(clearTimeout(this._stateTimer),this._stateTimer=null),this._pendingState=null}_queueState(e){this._connected&&(this._pendingState=e,this._stateTimer===null&&(this._stateTimer=setTimeout(()=>{this._stateTimer=null;let e=this._pendingState;this._pendingState=null,this._connected&&e&&this._dispatch(M_,e)},0)))}_emitDiagnostics(e){this._connected&&e.length!==0&&this._dispatch(j_,e)}_showError(e){if(!this._connected)return;this._teardown(),this._clearStateTimer();let t=this.ownerDocument;for(;this.firstChild;)this.removeChild(this.firstChild);let n=t.createElement(`div`);n.className=`local-inactive reactive-md-standalone-error`,n.setAttribute(`role`,`alert`),n.setAttribute(`data-reactive-md-error`,``);let r=t.createElement(`p`);if(r.className=`local-inactive-title`,r.textContent=this._locale===`zh`?`无法加载交互文档。`:`This interactive document could not be loaded.`,n.appendChild(r),e.length>0){let r=t.createElement(`ul`);r.className=`local-inactive-list`;for(let n of e.slice(0,12)){let e=t.createElement(`li`);e.textContent=`${n.message} (line ${n.line}, column ${n.column})`,r.appendChild(e)}n.appendChild(r)}this.appendChild(n),this._emitDiagnostics(e)}_dispatch(e,t){if(!this._connected)return;let n=this.ownerDocument.defaultView?.CustomEvent;if(typeof n==`function`)try{this.dispatchEvent(new n(e,{detail:t,bubbles:!0,composed:!0}))}catch{}}};function mv(){typeof customElements<`u`&&(customElements.get(`reactive-md-doc`)||customElements.define(uv,pv))}mv();var hv=!1;function gv(){if(hv||typeof document>`u`)return;hv=!0;let e=()=>{try{lv(document)}catch(e){typeof console<`u`&&typeof console.error==`function`&&console.error(`Reactive MD: automatic mounting failed.`,e)}};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,e,{once:!0}):queueMicrotask(e)}return gv(),e.REACTIVE_MD_DIAGNOSTICS_EVENT=j_,e.REACTIVE_MD_DOC_TAG=uv,e.REACTIVE_MD_MOUNTED_ATTRIBUTE=Y_,e.REACTIVE_MD_STANDALONE_GENERATOR=J_,e.REACTIVE_MD_STANDALONE_VERSION=q_,e.REACTIVE_MD_STATE_CHANGE_EVENT=M_,e.ReactiveMDDocElement=pv,e.ReactiveMDMountError=k_,e.defineReactiveMDDoc=mv,e.diagnosticsFromError=A_,e.isReactiveMDMounted=tv,e.mount=ov,e.mountAll=lv,e.parseMountPayload=U_,e.prepareStandaloneDocument=K_,e})({});