chapterhouse 0.12.0 → 0.13.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.
- package/dist/copilot/agents.js +12 -3
- package/dist/wiki/frontmatter.js +18 -6
- package/dist/wiki/frontmatter.test.js +40 -0
- package/package.json +1 -1
- package/web/dist/assets/{WikiEdit-BZYsJt-4.js → WikiEdit-CGRxNazp.js} +2 -2
- package/web/dist/assets/{WikiEdit-BZYsJt-4.js.map → WikiEdit-CGRxNazp.js.map} +1 -1
- package/web/dist/assets/{WikiGraph-B7ZZWSa3.js → WikiGraph-eVWNhZS3.js} +2 -2
- package/web/dist/assets/{WikiGraph-B7ZZWSa3.js.map → WikiGraph-eVWNhZS3.js.map} +1 -1
- package/web/dist/assets/index-DmO1TJpc.css +10 -0
- package/web/dist/assets/{index-gV0gH0Oi.js → index-gAvLNEvJ.js} +52 -52
- package/web/dist/assets/index-gAvLNEvJ.js.map +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-gV0gH0Oi.js.map +0 -1
- package/web/dist/assets/index-v0vtknrU.css +0 -10
package/dist/copilot/agents.js
CHANGED
|
@@ -23,6 +23,7 @@ const agentFrontmatterSchema = z.object({
|
|
|
23
23
|
model: z.string().min(1),
|
|
24
24
|
skills: z.array(z.string()).optional(),
|
|
25
25
|
tools: z.array(z.string()).optional(),
|
|
26
|
+
management_tools: z.array(z.string()).optional(),
|
|
26
27
|
mcpServers: z.array(z.string()).optional(),
|
|
27
28
|
allowed_paths: z.array(z.string()).optional(),
|
|
28
29
|
persistent: z.union([z.boolean(), z.string()]).optional().transform((value) => {
|
|
@@ -83,6 +84,7 @@ export function parseAgentMdOrThrow(content, slug) {
|
|
|
83
84
|
scope: fm.scope,
|
|
84
85
|
skills: fm.skills,
|
|
85
86
|
tools: fm.tools,
|
|
87
|
+
managementTools: fm.management_tools,
|
|
86
88
|
mcpServers: fm.mcpServers,
|
|
87
89
|
allowedPaths: fm.allowed_paths,
|
|
88
90
|
systemMessage: body,
|
|
@@ -374,13 +376,20 @@ export function filterToolsForAgent(agent, allTools) {
|
|
|
374
376
|
if (agent.tools && agent.tools.length > 0) {
|
|
375
377
|
// Agent specifies an explicit allowlist — give those + wiki tools
|
|
376
378
|
const allowed = new Set([...agent.tools, ...WIKI_TOOL_NAMES]);
|
|
377
|
-
return allTools.filter((t) => allowed.has(t.name)
|
|
379
|
+
return allTools.filter((t) => allowed.has(t.name));
|
|
378
380
|
}
|
|
379
|
-
// Default: all tools except management (only @chapterhouse gets those)
|
|
381
|
+
// Default: all tools except management (only @chapterhouse gets those by default)
|
|
380
382
|
if (agent.slug === "chapterhouse") {
|
|
381
383
|
return allTools;
|
|
382
384
|
}
|
|
383
|
-
|
|
385
|
+
const baseTools = allTools.filter((t) => !MANAGEMENT_TOOL_NAMES.has(t.name));
|
|
386
|
+
// Agents can opt into specific management tools via management_tools: in their config
|
|
387
|
+
if (agent.managementTools && agent.managementTools.length > 0) {
|
|
388
|
+
const optedIn = new Set(agent.managementTools);
|
|
389
|
+
const extra = allTools.filter((t) => MANAGEMENT_TOOL_NAMES.has(t.name) && optedIn.has(t.name));
|
|
390
|
+
return [...baseTools, ...extra];
|
|
391
|
+
}
|
|
392
|
+
return baseTools;
|
|
384
393
|
}
|
|
385
394
|
/** Filter MCP servers based on agent config. */
|
|
386
395
|
export function filterMcpServersForAgent(agent, allMcpServers) {
|
package/dist/wiki/frontmatter.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { normalizeWikiPath } from "./path-utils.js";
|
|
2
2
|
import { DEFAULT_SCHEMA, load } from "js-yaml";
|
|
3
3
|
const FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n?/;
|
|
4
|
-
|
|
4
|
+
// Markdown formatting that must not appear in a one-line plain-text summary.
|
|
5
|
+
// Detects *actual* formatting — paired or line-anchored — not lone characters:
|
|
6
|
+
// a bare underscore/asterisk inside a word (e.g. `ask_user_question`) is plain
|
|
7
|
+
// text, not emphasis, and must not be rejected.
|
|
8
|
+
const SUMMARY_MARKDOWN_RE = /(\*\*[^*]+\*\*|__[^_]+__|\*[^\s*][^*]*\*|(?<![A-Za-z0-9])_[^\s_][^_]*_(?![A-Za-z0-9])|`[^`]+`|~~[^~]+~~|^\s*#+\s|\[[^\]]+\]\([^)]+\)|!\[[^\]]*\]\([^)]+\)|^\s*>)/m;
|
|
5
9
|
const FRONTMATTER_TEMPLATE = `---\ntitle: <title>\nsummary: <plain-text one-line summary, max 200 chars>\nupdated: YYYY-MM-DD\ntags: []\nrelated: []\n---`;
|
|
6
10
|
const PROJECT_RULES_HARD_DEFAULTS = {
|
|
7
11
|
auto_pr: true,
|
|
@@ -159,14 +163,22 @@ export function validateWikiFrontmatter(content, options = {}) {
|
|
|
159
163
|
}
|
|
160
164
|
else {
|
|
161
165
|
const summary = parsed.summary.trim();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
const markdownMatch = summary.match(SUMMARY_MARKDOWN_RE);
|
|
167
|
+
let reason;
|
|
168
|
+
if (summary.length > 200) {
|
|
169
|
+
reason = `invalid 'summary' — it is ${summary.length} characters; the maximum is 200`;
|
|
170
|
+
}
|
|
171
|
+
else if (summary.includes("\n") || summary.includes("\r")) {
|
|
172
|
+
reason = "invalid 'summary' — it must be a single line";
|
|
173
|
+
}
|
|
174
|
+
else if (markdownMatch) {
|
|
175
|
+
reason = `invalid 'summary' — it must be plain text, but contains markdown formatting (${JSON.stringify(markdownMatch[0])})`;
|
|
176
|
+
}
|
|
177
|
+
if (reason) {
|
|
166
178
|
errors.push({
|
|
167
179
|
rule: "invalid-summary",
|
|
168
180
|
field: "summary",
|
|
169
|
-
message: formatFrontmatterMessage(
|
|
181
|
+
message: formatFrontmatterMessage(reason),
|
|
170
182
|
});
|
|
171
183
|
}
|
|
172
184
|
}
|
|
@@ -293,4 +293,44 @@ test("validateAndBackfillFrontmatter backfilled last_updated is valid ISO timest
|
|
|
293
293
|
const ts = match[1].trim();
|
|
294
294
|
assert.doesNotThrow(() => new Date(ts).toISOString(), `${ts} should be valid ISO timestamp`);
|
|
295
295
|
});
|
|
296
|
+
// ── Issue #458: summary markdown detection must not flag plain text ──────────
|
|
297
|
+
test("validateWikiFrontmatter accepts a plain-text summary containing technical identifiers", async () => {
|
|
298
|
+
const { validateWikiFrontmatter } = await loadFrontmatterModule();
|
|
299
|
+
const result = validateWikiFrontmatter(`---
|
|
300
|
+
title: Ask User Question
|
|
301
|
+
summary: Design notes for the ask_user_question tool, stored under ~/.chapterhouse
|
|
302
|
+
updated: 2026-05-19
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
# Ask User Question
|
|
306
|
+
`);
|
|
307
|
+
assert.equal(result.valid, true, JSON.stringify(result.errors));
|
|
308
|
+
});
|
|
309
|
+
test("validateWikiFrontmatter still rejects genuine markdown formatting in summaries", async () => {
|
|
310
|
+
const { validateWikiFrontmatter } = await loadFrontmatterModule();
|
|
311
|
+
const markdownSummaries = [
|
|
312
|
+
"**bold text**",
|
|
313
|
+
"__bold text__",
|
|
314
|
+
"an *italic* word",
|
|
315
|
+
"an _italic_ word",
|
|
316
|
+
"a `code` span",
|
|
317
|
+
"a ~~struck~~ phrase",
|
|
318
|
+
"[a link](https://example.com)",
|
|
319
|
+
];
|
|
320
|
+
for (const summary of markdownSummaries) {
|
|
321
|
+
const result = validateWikiFrontmatter(`---\ntitle: T\nsummary: ${summary}\nupdated: 2026-05-19\n---\n\n# T\n`);
|
|
322
|
+
assert.equal(result.valid, false, `expected "${summary}" to be rejected`);
|
|
323
|
+
assert.equal(result.errors[0]?.rule, "invalid-summary", `"${summary}" should fail invalid-summary`);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
test("validateWikiFrontmatter invalid-summary message identifies the specific problem", async () => {
|
|
327
|
+
const { validateWikiFrontmatter } = await loadFrontmatterModule();
|
|
328
|
+
const markdown = validateWikiFrontmatter(`---\ntitle: T\nsummary: a \`code\` span\nupdated: 2026-05-19\n---\n\n# T\n`);
|
|
329
|
+
assert.equal(markdown.valid, false);
|
|
330
|
+
assert.match(markdown.errors[0].message, /markdown formatting/i);
|
|
331
|
+
assert.match(markdown.errors[0].message, /`code`/);
|
|
332
|
+
const tooLong = validateWikiFrontmatter(`---\ntitle: T\nsummary: ${"x".repeat(201)}\nupdated: 2026-05-19\n---\n\n# T\n`);
|
|
333
|
+
assert.equal(tooLong.valid, false);
|
|
334
|
+
assert.match(tooLong.errors[0].message, /200/);
|
|
335
|
+
});
|
|
296
336
|
//# sourceMappingURL=frontmatter.test.js.map
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as re,j as Pe,u as fp,a as up,b as Oa,L as dp,E as Op}from"./index-
|
|
1
|
+
import{r as re,j as Pe,u as fp,a as up,b as Oa,L as dp,E as Op}from"./index-gAvLNEvJ.js";function ao(){return ao=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},ao.apply(null,arguments)}function pp(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.indexOf(i)!==-1)continue;t[i]=n[i]}return t}let ho=[],Jc=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?Jc:ho).push(t=t+n[e])})();function mp(n){if(n<768)return!1;for(let e=0,t=ho.length;;){let i=e+t>>1;if(n<ho[i])t=i;else if(n>=Jc[i])e=i+1;else return!0;if(e==t)return!1}}function pa(n){return n>=127462&&n<=127487}const ma=8205;function gp(n,e,t=!0,i=!0){return(t?ef:Sp)(n,e,i)}function ef(n,e,t){if(e==n.length)return e;e&&tf(n.charCodeAt(e))&&nf(n.charCodeAt(e-1))&&e--;let i=gs(n,e);for(e+=ga(i);e<n.length;){let r=gs(n,e);if(i==ma||r==ma||t&&mp(r))e+=ga(r),i=r;else if(pa(r)){let s=0,o=e-2;for(;o>=0&&pa(gs(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Sp(n,e,t){for(;e>0;){let i=ef(n,e-2,t);if(i<e)return i;e--}return 0}function gs(n,e){let t=n.charCodeAt(e);if(!nf(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return tf(i)?(t-55296<<10)+(i-56320)+65536:t}function tf(n){return n>=56320&&n<57344}function nf(n){return n>=55296&&n<56320}function ga(n){return n<65536?1:2}class q{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=bi(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),at.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=bi(this,e,t);let i=[];return this.decompose(e,t,i,0),at.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new Fi(this),s=new Fi(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new Fi(this,e)}iterRange(e,t=this.length){return new rf(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new sf(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?q.empty:e.length<=32?new se(e):at.from(se.split(e,[]))}}class se extends q{constructor(e,t=bp(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new yp(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new se(Sa(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=fr(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new se(l,o.length+s.length));else{let a=l.length>>1;i.push(new se(l.slice(0,a)),new se(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof se))return super.replace(e,t,i);[e,t]=bi(this,e,t);let r=fr(this.text,fr(i.text,Sa(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new se(r,s):at.from(se.split(r,[]),s)}sliceString(e,t=this.length,i=`
|
|
2
2
|
`){[e,t]=bi(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new se(i,r)),i=[],r=-1);return r>-1&&t.push(new se(i,r)),t}}class at extends q{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=bi(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new at(c,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
3
|
`){[e,t]=bi(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof at))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let O of e)O.flatten(d);return new se(d,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(d){let O;if(d.lines>s&&d instanceof at)for(let p of d.children)f(p);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof se&&a&&(O=c[c.length-1])instanceof se&&d.lines+O.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new se(O.text.concat(d.text),O.length+1+d.length)):(a+d.lines>r&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:at.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new at(l,t)}}q.empty=new se([""],0);function bp(n){let e=-1;for(let t of n)e+=t.length+1;return e}function fr(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function Sa(n,e,t){return fr(n,[""],e,t)}class Fi{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof se?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof se?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
4
|
`,this;e--}else if(r instanceof se){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof se?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class rf{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Fi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class sf{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(q.prototype[Symbol.iterator]=function(){return this.iter()},Fi.prototype[Symbol.iterator]=rf.prototype[Symbol.iterator]=sf.prototype[Symbol.iterator]=function(){return this});let yp=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function bi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function de(n,e,t=!0,i=!0){return gp(n,e,t,i)}function xp(n){return n>=56320&&n<57344}function kp(n){return n>=55296&&n<56320}function Ce(n,e){let t=n.charCodeAt(e);if(!kp(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return xp(i)?(t-55296<<10)+(i-56320)+65536:t}function ul(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function ht(n){return n<65536?1:2}const co=/\r\n?|\n/;var ge=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(ge||(ge={}));class pt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){fo(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new pt(e)}composeDesc(e){return this.empty?e:e.empty?this:of(this,e)}mapDesc(e,t=!1){return e.empty?this:uo(this,e,t)}mapPos(e,t=-1,i=ge.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=ge.Simple&&h>=e&&(i==ge.TrackDel&&r<e&&h>e||i==ge.TrackBefore&&r<e||i==ge.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new pt(e)}static create(e){return new pt(e)}}class he extends pt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return fo(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return uo(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(q.empty);i.push(o?e.slice(s,s+o):q.empty)}s+=o}return new he(t,i)}compose(e){return this.empty?e:e.empty?this:of(this,e,!0)}map(e,t=!1){return e.empty?this:uo(this,e,t,!0)}iterChanges(e,t=!1){fo(this,e,t)}get desc(){return pt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new on(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);ke(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;ke(t,c,f),f>0&&Xt(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);ke(t,c,-1),ke(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new he(t,i),filtered:pt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&ke(r,t-o,-1);let f=new he(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof he){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let O=d?typeof d=="string"?q.of(d.split(i||co)):d:q.empty,p=O.length;if(f==u&&p==0)return;f<o&&a(),f>o&&ke(r,f-o,-1),ke(r,u-f,p),Xt(s,r,O),o=u}}return h(e),a(!l),l}static empty(e){return new he(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(q.empty);i[r]=q.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new he(t,i)}static createSet(e,t){return new he(e,t)}}function ke(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Xt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(q.empty);n.push(t)}}function fo(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=q.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function uo(n,e,t,i=!1){let r=[],s=i?[]:null,o=new on(n),l=new on(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);ke(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(ke(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(ke(r,0,o.ins),s&&Xt(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;ke(r,h,a<o.i?o.ins:0),s&&a<o.i&&Xt(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?he.createSet(r,s):pt.create(r);throw new Error("Mismatched change set lengths")}}}function of(n,e,t=!1){let i=[],r=t?[]:null,s=new on(n),o=new on(e);for(let l=!1;;){if(s.done&&o.done)return r?he.createSet(i,r):pt.create(i);if(s.ins==0)ke(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)ke(i,0,o.ins,l),r&&Xt(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;ke(i,a,c,l),r&&c&&Xt(r,i,o.text)}else o.ins==-1?(ke(i,s.off?0:s.len,a,l),r&&Xt(r,i,s.textBit(a))):(ke(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Xt(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}class on{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?q.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?q.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Gt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Gt(i,r,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return y.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return y.range(this.anchor,r,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return y.range(e.anchor,e.head)}static create(e,t,i){return new Gt(e,t,i)}}class y{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:y.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new y([this.main],0)}addRange(e,t=!0){return y.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,y.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new y(e.ranges.map(t=>Gt.fromJSON(t)),e.main)}static single(e,t=e){return new y([y.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return y.normalized(e.slice(),t);i=s.to}return new y(e,t)}static cursor(e,t=0,i,r){return Gt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r??16777215)<<6)}static range(e,t,i,r,s){let o=(i??16777215)<<6|(r==null?7:Math.min(6,r));return!s&&e!=t&&(s=t<e?1:-1),t<e?Gt.create(t,e,48|o):Gt.create(e,t,(s?s<0?8:16:0)|o)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?y.range(a,l):y.range(l,a))}}return new y(e,t)}}function lf(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let dl=0;class C{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=dl++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new C(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Ol),!!e.static,e.enables)}of(e){return new ur([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ur(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ur(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Ol(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class ur{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=dl++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Oo(f,c)){let d=i(f);if(l?!ba(d,f.values[o],r):!r(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,O=u.config.address[s];if(O!=null){let p=wr(u,O);if(this.dependencies.every(g=>g instanceof C?u.facet(g)===f.facet(g):g instanceof be?u.field(g,!1)==f.field(g,!1):!0)||(l?ba(d=i(f),p,r):r(d=i(f),p)))return f.values[o]=p,0}else d=i(f);return f.values[o]=d,1}}}}function ba(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function Oo(n,e){let t=!1;for(let i of e)Hi(n,i)&1&&(t=!0);return t}function Qp(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=wr(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Hi(a,h);return a.values[o]=l(a),1},update(a,h){if(!Oo(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Oo(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Ol(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Dn=C.define({static:!0});class be{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new be(dl++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Dn).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(Dn),o=r.facet(Dn),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Dn.of({field:this,create:e})]}get extension(){return this}}const qt={lowest:4,low:3,default:2,high:1,highest:0};function zi(n){return e=>new af(e,n)}const Pt={highest:zi(qt.highest),high:zi(qt.high),default:zi(qt.default),low:zi(qt.low),lowest:zi(qt.lowest)};class af{constructor(e,t){this.inner=e,this.prec=t}}class is{of(e){return new po(this,e)}reconfigure(e){return is.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class po{constructor(e,t){this.compartment=e,this.inner=t}}class Qr{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of wp(e,t,o))u instanceof be?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in s){let d=s[u],O=d[0].facet,p=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[O.id]=a.length<<1|1,Ol(p,d))a.push(i.facet(O));else{let g=O.combine(d.map(S=>S.value));a.push(i&&O.compare(g,i.facet(O))?i.facet(O):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(S=>g.dynamicSlot(S)));l[O.id]=h.length<<1,h.push(g=>Qp(g,O,d))}}let f=h.map(u=>u(l));return new Qr(e,o,f,l,a,s)}}function wp(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof po&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof po){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof af)s(o.inner,o.prec);else if(o instanceof be)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ur)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,qt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(n,qt.default),i.reduce((o,l)=>o.concat(l))}function Hi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function wr(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const hf=C.define(),mo=C.define({combine:n=>n.some(e=>e),static:!0}),cf=C.define({combine:n=>n.length?n[0]:void 0,static:!0}),ff=C.define(),uf=C.define(),df=C.define(),Of=C.define({combine:n=>n.length?n[0]:!1});class gt{constructor(e,t){this.type=e,this.value=t}static define(){return new $p}}class $p{of(e){return new gt(this,e)}}class vp{constructor(e){this.map=e}of(e){return new E(this,e)}}class E{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new E(this.type,t)}is(e){return this.type==e}static define(e={}){return new vp(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}}E.reconfigure=E.define();E.appendConfig=E.define();class le{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&lf(i,t.newLength),s.some(l=>l.type==le.time)||(this.annotations=s.concat(le.time.of(Date.now())))}static create(e,t,i,r,s,o){return new le(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(le.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}le.time=gt.define();le.userEvent=gt.define();le.addToHistory=gt.define();le.remote=gt.define();function Pp(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function pf(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=he.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:E.mapEffects(n.effects,r).concat(E.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function go(n,e,t){let i=e.selection,r=fi(e.annotations);return e.userEvent&&(r=r.concat(le.userEvent.of(e.userEvent))),{changes:e.changes instanceof he?e.changes:he.of(e.changes||[],t,n.facet(cf)),selection:i&&(i instanceof y?i:y.single(i.anchor,i.head)),effects:fi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function mf(n,e,t){let i=go(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=pf(i,go(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=le.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Cp(t?Tp(r):r)}function Tp(n){let e=n.startState,t=!0;for(let r of e.facet(ff)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:Pp(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=he.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=le.create(e,r,n.selection&&n.selection.map(s),E.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(uf);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof le?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof le?n=s[0]:n=mf(e,fi(s),!1)}return n}function Cp(n){let e=n.startState,t=e.facet(df),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=pf(i,go(e,s,n.changes.newLength),!0))}return i==n?n:le.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Zp=[];function fi(n){return n==null?Zp:Array.isArray(n)?n:[n]}var te=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(te||(te={}));const Ap=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let So;try{So=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Xp(n){if(So)return So.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Ap.test(t)))return!0}return!1}function Mp(n){return e=>{if(!/\S/.test(e))return te.Space;if(Xp(e))return te.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return te.Word;return te.Other}}class Y{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Hi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Hi(this,i),wr(this,i)}update(...e){return mf(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(is.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(E.reconfigure)?(t=null,i=l.value):l.is(E.appendConfig)&&(t=null,i=fi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Qr.resolve(i,r,this),s=new Y(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(mo)?e.newSelection:e.newSelection.asSingle();new Y(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=fi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=E.mapEffects(o,c).concat(E.mapEffects(fi(a.effects),f))}return{changes:r,selection:y.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof he?e:he.of(e,this.doc.length,this.facet(Y.lineSeparator))}toText(e){return q.of(e.split(this.facet(Y.lineSeparator)||co))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Hi(this,t),wr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof be&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return Y.create({doc:e.doc,selection:y.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Qr.resolve(e.extensions||[],new Map),i=e.doc instanceof q?e.doc:q.of((e.doc||"").split(t.staticFacet(Y.lineSeparator)||co)),r=e.selection?e.selection instanceof y?e.selection:y.single(e.selection.anchor,e.selection.head):y.single(0);return lf(r,i.length),t.staticFacet(mo)||(r=r.asSingle()),new Y(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Y.tabSize)}get lineBreak(){return this.facet(Y.lineSeparator)||`
|
|
@@ -27,4 +27,4 @@ import{r as re,j as Pe,u as fp,a as up,b as Oa,L as dp,E as Op}from"./index-gV0g
|
|
|
27
27
|
\${}
|
|
28
28
|
}
|
|
29
29
|
}`,{label:"class",detail:"definition",type:"keyword"}),Te('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Te('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],ZQ=_O.concat([Te("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Te("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Te("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),qc=new Cu,VO=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Bi(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const AQ=["FunctionDeclaration"],XQ={FunctionDeclaration:Bi("function"),ClassDeclaration:Bi("class"),ClassExpression:()=>!0,EnumDeclaration:Bi("constant"),TypeAliasDeclaration:Bi("type"),NamespaceDeclaration:Bi("namespace"),VariableDefinition(n,e){n.matchContext(AQ)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function YO(n,e){let t=qc.get(e);if(t)return t;let i=[],r=!0;function s(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(G.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=XQ[o.name];if(l&&l(o,s)||VO.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of YO(n,o.node))i.push(l);return!1}}),qc.set(e,i),i}const Ic=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,BO=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function MQ(n){let e=J(n.state).resolveInner(n.pos,-1);if(BO.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Ic.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let r=e;r;r=r.parent)VO.has(r.name)&&(i=i.concat(YO(n.state.doc,r)));return{options:i,from:t?e.from:n.pos,validFor:Ic}}const mt=wi.define({name:"javascript",parser:CQ.configure({props:[Mn.add({IfStatement:Sr({except:/^\s*({|else\b)/}),TryStatement:Sr({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:r1,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:n1({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Sr({except:/^\s*{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Ri.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":ju,BlockComment(n){return{from:n.from+2,to:n.to-2}},JSXElement(n){let e=n.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=n.lastChild;return{from:e.to,to:t.type.isError?n.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(n){var e;let t=(e=n.firstChild)===null||e===void 0?void 0:e.nextSibling,i=n.lastChild;return!t||t.type.isError?null:{from:t.to,to:i.type.isError?n.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),qO={test:n=>/^JSX/.test(n.name),facet:Ll({commentTokens:{block:{open:"{/*",close:"*/}"}}})},IO=mt.configure({dialect:"ts"},"typescript"),NO=mt.configure({dialect:"jsx",props:[El.add(n=>n.isTop?[qO]:void 0)]}),GO=mt.configure({dialect:"jsx ts",props:[El.add(n=>n.isTop?[qO]:void 0)]},"typescript");let UO=n=>({label:n,type:"keyword"});const FO="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(UO),RQ=FO.concat(["declare","implements","private","protected","public"].map(UO));function LQ(n={}){let e=n.jsx?n.typescript?GO:NO:n.typescript?IO:mt,t=n.typescript?ZQ.concat(RQ):_O.concat(FO);return new gn(e,[mt.data.of({autocomplete:wb(BO,Wd(t))}),mt.data.of({autocomplete:MQ}),n.jsx?zQ:[]])}function EQ(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function Nc(n,e,t=n.length){for(let i=e==null?void 0:e.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const jQ=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),zQ=P.inputHandler.of((n,e,t,i,r)=>{if((jQ?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!mt.isActiveAt(n.state,e,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(a=>{var h;let{head:c}=a,f=J(o).resolveInner(c-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(c-1,c)!=i||f.name=="JSXAttributeValue"&&f.to>c)){if(i==">"&&f.name=="JSXFragmentTag")return{range:a,changes:{from:c,insert:"</>"}};if(i=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,O=d.parent;if(O&&d.from==c-2&&((u=Nc(o.doc,O.firstChild,c))||((h=O.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let p=`${u}>`;return{range:y.cursor(c+p.length,-1),changes:{from:c,insert:p}}}}else if(i==">"){let d=EQ(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(u=Nc(o.doc,d,c)))return{range:a,changes:{from:c,insert:`</${u}>`}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),qi=["_blank","_self","_top","_parent"],io=["ascii","utf-8","utf-16","latin1","latin1"],no=["get","post","put","delete"],ro=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],je=["true","false"],A={},WQ={a:{attrs:{href:null,ping:null,type:null,media:null,target:qi,hreflang:null}},abbr:A,address:A,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:A,aside:A,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:A,base:{attrs:{href:null,target:qi}},bdi:A,bdo:A,blockquote:{attrs:{cite:null}},body:A,br:A,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:ro,formmethod:no,formnovalidate:["novalidate"],formtarget:qi,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:A,center:A,cite:A,code:A,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:A,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:A,div:A,dl:A,dt:A,em:A,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:A,figure:A,footer:A,form:{attrs:{action:null,name:null,"accept-charset":io,autocomplete:["on","off"],enctype:ro,method:no,novalidate:["novalidate"],target:qi}},h1:A,h2:A,h3:A,h4:A,h5:A,h6:A,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:A,hgroup:A,hr:A,html:{attrs:{manifest:null}},i:A,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:ro,formmethod:no,formnovalidate:["novalidate"],formtarget:qi,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:A,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:A,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:A,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:io,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:A,noscript:A,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:A,param:{attrs:{name:null,value:null}},pre:A,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:A,rt:A,ruby:A,samp:A,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:io}},section:A,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:A,source:{attrs:{src:null,type:null,media:null}},span:A,strong:A,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:A,summary:A,sup:A,table:A,tbody:A,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:A,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:A,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:A,time:{attrs:{datetime:null}},title:A,tr:A,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:A,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:A},HO={accesskey:null,class:null,contenteditable:je,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:je,autocorrect:je,autocapitalize:je,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":je,"aria-autocomplete":["inline","list","both","none"],"aria-busy":je,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":je,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":je,"aria-hidden":je,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":je,"aria-multiselectable":je,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":je,"aria-relevant":null,"aria-required":je,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},KO="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(n=>"on"+n);for(let n of KO)HO[n]=null;class Tn{constructor(e,t){this.tags={...WQ,...e},this.globalAttrs={...HO,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}Tn.default=new Tn;function Ci(n,e,t=n.length){if(!e)return"";let i=e.firstChild,r=i&&i.getChild("TagName");return r?n.sliceString(r.from,Math.min(r.to,t)):""}function Zi(n,e=!1){for(;n;n=n.parent)if(n.name=="Element")if(e)e=!1;else return n;return null}function JO(n,e,t){let i=t.tags[Ci(n,Zi(e))];return(i==null?void 0:i.children)||t.allTags}function ca(n,e){let t=[];for(let i=Zi(e);i&&!i.type.isTop;i=Zi(i.parent)){let r=Ci(n,i);if(r&&i.lastChild.name=="CloseTag")break;r&&t.indexOf(r)<0&&(e.name=="EndTag"||e.from>=i.firstChild.to)&&t.push(r)}return t}const ep=/^[:\-\.\w\u00b7-\uffff]*$/;function Gc(n,e,t,i,r){let s=/\s*>/.test(n.sliceDoc(r,r+5))?"":">",o=Zi(t,t.name=="StartTag"||t.name=="TagName");return{from:i,to:r,options:JO(n.doc,o,e).map(l=>({label:l,type:"type"})).concat(ca(n.doc,t).map((l,a)=>({label:"/"+l,apply:"/"+l+s,type:"type",boost:99-a}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function Uc(n,e,t,i){let r=/\s*>/.test(n.sliceDoc(i,i+5))?"":">";return{from:t,to:i,options:ca(n.doc,e).map((s,o)=>({label:s,apply:s+r,type:"type",boost:99-o})),validFor:ep}}function DQ(n,e,t,i){let r=[],s=0;for(let o of JO(n.doc,t,e))r.push({label:"<"+o,type:"type"});for(let o of ca(n.doc,t))r.push({label:"</"+o+">",type:"type",boost:99-s++});return{from:i,to:i,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function _Q(n,e,t,i,r){let s=Zi(t),o=s?e.tags[Ci(n.doc,s)]:null,l=o&&o.attrs?Object.keys(o.attrs):[],a=o&&o.globalAttrs===!1?l:l.length?l.concat(e.globalAttrNames):e.globalAttrNames;return{from:i,to:r,options:a.map(h=>({label:h,type:"property"})),validFor:ep}}function VQ(n,e,t,i,r){var s;let o=(s=t.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),l=[],a;if(o){let h=n.sliceDoc(o.from,o.to),c=e.globalAttrs[h];if(!c){let f=Zi(t),u=f?e.tags[Ci(n.doc,f)]:null;c=(u==null?void 0:u.attrs)&&u.attrs[h]}if(c){let f=n.sliceDoc(i,r).toLowerCase(),u='"',d='"';/^['"]/.test(f)?(a=f[0]=='"'?/^[^"]*$/:/^[^']*$/,u="",d=n.sliceDoc(r,r+1)==f[0]?"":f[0],f=f.slice(1),i++):a=/^[^\s<>='"]*$/;for(let O of c)l.push({label:O,apply:u+O+d,type:"constant"})}}return{from:i,to:r,options:l,validFor:a}}function tp(n,e){let{state:t,pos:i}=e,r=J(t).resolveInner(i,-1),s=r.resolve(i);for(let o=i,l;s==r&&(l=r.childBefore(o));){let a=l.lastChild;if(!a||!a.type.isError||a.from<a.to)break;s=r=l,o=a.from}return r.name=="TagName"?r.parent&&/CloseTag$/.test(r.parent.name)?Uc(t,r,r.from,i):Gc(t,n,r,r.from,i):r.name=="StartTag"||r.name=="IncompleteTag"?Gc(t,n,r,i,i):r.name=="StartCloseTag"||r.name=="IncompleteCloseTag"?Uc(t,r,i,i):r.name=="OpenTag"||r.name=="SelfClosingTag"||r.name=="AttributeName"?_Q(t,n,r,r.name=="AttributeName"?r.from:i,i):r.name=="Is"||r.name=="AttributeValue"||r.name=="UnquotedAttributeValue"?VQ(t,n,r,r.name=="Is"?i:r.from,i):e.explicit&&(s.name=="Element"||s.name=="Text"||s.name=="Document")?DQ(t,n,r,i):null}function YQ(n){return tp(Tn.default,n)}function BQ(n){let{extraTags:e,extraGlobalAttributes:t}=n,i=t||e?new Tn(e,t):Tn.default;return r=>tp(i,r)}const qQ=mt.parser.configure({top:"SingleExpression"}),ip=[{tag:"script",attrs:n=>n.type=="text/typescript"||n.lang=="ts",parser:IO.parser},{tag:"script",attrs:n=>n.type=="text/babel"||n.type=="text/jsx",parser:NO.parser},{tag:"script",attrs:n=>n.type=="text/typescript-jsx",parser:GO.parser},{tag:"script",attrs(n){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(n.type)},parser:qQ},{tag:"script",attrs(n){return!n.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(n.type)},parser:mt.parser},{tag:"style",attrs(n){return(!n.lang||n.lang=="css")&&(!n.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(n.type))},parser:es.parser}],np=[{name:"style",parser:es.parser.configure({top:"Styles"})}].concat(KO.map(n=>({name:n,parser:mt.parser}))),rp=wi.define({name:"html",parser:mk.configure({props:[Mn.add({Element(n){let e=/^(\s*)(<\/)?/.exec(n.textAfter);return n.node.to<=n.pos+e[0].length?n.continue():n.lineIndent(n.node.from)+(e[2]?0:n.unit)},"OpenTag CloseTag SelfClosingTag"(n){return n.column(n.node.from)+n.unit},Document(n){if(n.pos+/\s*/.exec(n.textAfter)[0].length<n.node.to)return n.continue();let e=null,t;for(let i=n.node;;){let r=i.lastChild;if(!r||r.name!="Element"||r.to!=i.to)break;e=i=r}return e&&!((t=e.lastChild)&&(t.name=="CloseTag"||t.name=="SelfClosingTag"))?n.lineIndent(e.from)+n.unit:null}}),Ri.add({Element(n){let e=n.firstChild,t=n.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:n.to}}}),Fu.add({"OpenTag CloseTag":n=>n.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),kr=rp.configure({wrap:RO(ip,np)});function IQ(n={}){let e="",t;n.matchClosingTags===!1&&(e="noMatch"),n.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(n.nestedLanguages&&n.nestedLanguages.length||n.nestedAttributes&&n.nestedAttributes.length)&&(t=RO((n.nestedLanguages||[]).concat(ip),(n.nestedAttributes||[]).concat(np)));let i=t?rp.configure({wrap:t,dialect:e}):e?kr.configure({dialect:e}):kr;return new gn(i,[kr.data.of({autocomplete:BQ(n)}),n.autoCloseTags!==!1?NQ:[],LQ().support,Kk().support])}const Fc=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),NQ=P.inputHandler.of((n,e,t,i,r)=>{if(n.composing||n.state.readOnly||e!=t||i!=">"&&i!="/"||!kr.isActiveAt(n.state,e,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(a=>{var h,c,f;let u=o.doc.sliceString(a.from-1,a.to)==i,{head:d}=a,O=J(o).resolveInner(d,-1),p;if(u&&i==">"&&O.name=="EndTag"){let g=O.parent;if(((c=(h=g.parent)===null||h===void 0?void 0:h.lastChild)===null||c===void 0?void 0:c.name)!="CloseTag"&&(p=Ci(o.doc,g.parent,d))&&!Fc.has(p)){let S=d+(o.doc.sliceString(d,d+1)===">"?1:0),b=`</${p}>`;return{range:a,changes:{from:d,to:S,insert:b}}}}else if(u&&i=="/"&&O.name=="IncompleteCloseTag"){let g=O.parent;if(O.from==d-2&&((f=g.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(p=Ci(o.doc,g,d))&&!Fc.has(p)){let S=d+(o.doc.sliceString(d,d+1)===">"?1:0),b=`${p}>`;return{range:y.cursor(d+b.length,-1),changes:{from:d,to:S,insert:b}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),sp=Ll({commentTokens:{block:{open:"<!--",close:"-->"}}}),op=new j,lp=cx.configure({props:[Ri.add(n=>!n.is("Block")||n.is("Document")||fl(n)!=null||GQ(n)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),op.add(fl),Mn.add({Document:()=>null}),Ft.add({Document:sp})]});function fl(n){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(n.name);return e?+e[1]:void 0}function GQ(n){return n.name=="OrderedList"||n.name=="BulletList"}function UQ(n,e){let t=n;for(;;){let i=t.nextSibling,r;if(!i||(r=fl(i.type))!=null&&r<=e)break;t=i}return t.to}const FQ=Eu.of((n,e,t)=>{for(let i=J(n).resolveInner(t,-1);i&&!(i.from<e);i=i.parent){let r=i.type.prop(op);if(r==null)continue;let s=UQ(i,r);if(s>t)return{from:t,to:s}}return null});function fa(n){return new qe(sp,n,[],"markdown")}const HQ=fa(lp),KQ=lp.configure([xx,Qx,kx,wx,{props:[Ri.add({Table:(n,e)=>({from:e.doc.lineAt(n.from).to,to:n.to})})]}]),ts=fa(KQ);function JQ(n,e){return t=>{if(t&&n){let i=null;if(t=/\S*/.exec(t)[0],typeof n=="function"?i=n(t):i=Er.matchLanguageName(n,t,!0),i instanceof Er)return i.support?i.support.language.parser:mn.getSkippingParser(i.load());if(i)return i.parser}return e?e.parser:null}}class so{constructor(e,t,i,r,s,o,l){this.node=e,this.from=t,this.to=i,this.spaceBefore=r,this.spaceAfter=s,this.type=o,this.item=l}blank(e,t=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;i.length<e;)i+=" ";return i}else{for(let r=this.to-this.from-i.length-this.spaceAfter.length;r>0;r--)i+=" ";return i+(t?this.spaceAfter:"")}}marker(e,t){let i=this.node.name=="OrderedList"?String(+hp(this.item,e)[2]+t):"";return this.spaceBefore+i+this.type+this.spaceAfter}}function ap(n,e){let t=[],i=[];for(let r=n;r;r=r.parent){if(r.name=="FencedCode")return i;(r.name=="ListItem"||r.name=="Blockquote")&&t.push(r)}for(let r=t.length-1;r>=0;r--){let s=t[r],o,l=e.lineAt(s.from),a=s.from-l.from;if(s.name=="Blockquote"&&(o=/^ *>( ?)/.exec(l.text.slice(a))))i.push(new so(s,a,a+o[0].length,"",o[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(l.text.slice(a)))){let h=o[3],c=o[0].length;h.length>=4&&(h=h.slice(0,h.length-4),c-=4),i.push(new so(s.parent,a,a+c,o[1],h,o[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(a)))){let h=o[4],c=o[0].length;h.length>4&&(h=h.slice(0,h.length-4),c-=4);let f=o[2];o[3]&&(f+=o[3].replace(/[xX]/," ")),i.push(new so(s.parent,a,a+c,o[1],h,f,s))}}return i}function hp(n,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(n.from,n.from+10))}function oo(n,e,t,i=0){for(let r=-1,s=n;;){if(s.name=="ListItem"){let l=hp(s,e),a=+l[2];if(r>=0){if(a!=r+1)return;t.push({from:s.from+l[1].length,to:s.from+l[0].length,insert:String(r+2+i)})}r=a}let o=s.nextSibling;if(!o)break;s=o}}function ua(n,e){let t=/^[ \t]*/.exec(n)[0].length;if(!t||e.facet(Mi)!=" ")return n;let i=Ke(n,4,t),r="";for(let s=i;s>0;)s>=4?(r+=" ",s-=4):(r+=" ",s--);return r+n.slice(t)}const ew=(n={})=>({state:e,dispatch:t})=>{let i=J(e),{doc:r}=e,s=null,o=e.changeByRange(l=>{if(!l.empty||!ts.isActiveAt(e,l.from,-1)&&!ts.isActiveAt(e,l.from,1))return s={range:l};let a=l.from,h=r.lineAt(a),c=ap(i.resolveInner(a,-1),r);for(;c.length&&c[c.length-1].from>a-h.from;)c.pop();if(!c.length)return s={range:l};let f=c[c.length-1];if(f.to-f.spaceAfter.length>a-h.from)return s={range:l};let u=a>=f.to-f.spaceAfter.length&&!/\S/.test(h.text.slice(f.to));if(f.item&&u){let S=f.node.firstChild,b=f.node.getChild("ListItem","ListItem");if(S.to>=a||b&&b.to<a||h.from>0&&!/[^\s>]/.test(r.lineAt(h.from-1).text)||n.nonTightLists===!1){let x=c.length>1?c[c.length-2]:null,v,k="";x&&x.item?(v=h.from+x.from,k=x.marker(r,1)):v=h.from+(x?x.to:0);let Q=[{from:v,to:a,insert:k}];return f.node.name=="OrderedList"&&oo(f.item,r,Q,-2),x&&x.node.name=="OrderedList"&&oo(x.item,r,Q),{range:y.cursor(v+k.length),changes:Q}}else{let x=Kc(c,e,h);return{range:y.cursor(a+x.length+1),changes:{from:h.from,insert:x+e.lineBreak}}}}if(f.node.name=="Blockquote"&&u&&h.from){let S=r.lineAt(h.from-1),b=/>\s*$/.exec(S.text);if(b&&b.index==f.from){let x=e.changes([{from:S.from+b.index,to:S.to},{from:h.from+f.from,to:h.to}]);return{range:l.map(x),changes:x}}}let d=[];f.node.name=="OrderedList"&&oo(f.item,r,d);let O=f.item&&f.item.from<h.from,p="";if(!O||/^[\s\d.)\-+*>]*/.exec(h.text)[0].length>=f.to)for(let S=0,b=c.length-1;S<=b;S++)p+=S==b&&!O?c[S].marker(r,1):c[S].blank(S<b?Ke(h.text,4,c[S+1].from)-p.length:null);let g=a;for(;g>h.from&&/\s/.test(h.text.charAt(g-h.from-1));)g--;return p=ua(p,e),iw(f.node,e.doc)&&(p=Kc(c,e,h)+e.lineBreak+p),d.push({from:g,to:a,insert:e.lineBreak+p}),{range:y.cursor(g+p.length+1),changes:d}});return s?!1:(t(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},tw=ew();function Hc(n){return n.name=="QuoteMark"||n.name=="ListMark"}function iw(n,e){if(n.name!="OrderedList"&&n.name!="BulletList")return!1;let t=n.firstChild,i=n.getChild("ListItem","ListItem");if(!i)return!1;let r=e.lineAt(t.to),s=e.lineAt(i.from),o=/^[\s>]*$/.test(r.text);return r.number+(o?0:1)<s.number}function Kc(n,e,t){let i="";for(let r=0,s=n.length-2;r<=s;r++)i+=n[r].blank(r<s?Ke(t.text,4,n[r+1].from)-i.length:null,r<s);return ua(i,e)}function nw(n,e){let t=n.resolveInner(e,-1),i=e;Hc(t)&&(i=t.from,t=t.parent);for(let r;r=t.childBefore(i);)if(Hc(r))i=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")t=r.lastChild,i=t.to;else break;return t}const rw=({state:n,dispatch:e})=>{let t=J(n),i=null,r=n.changeByRange(s=>{let o=s.from,{doc:l}=n;if(s.empty&&ts.isActiveAt(n,s.from)){let a=l.lineAt(o),h=ap(nw(t,o),l);if(h.length){let c=h[h.length-1],f=c.to-c.spaceAfter.length+(c.spaceAfter?1:0);if(o-a.from>f&&!/\S/.test(a.text.slice(f,o-a.from)))return{range:y.cursor(a.from+f),changes:{from:a.from+f,to:o}};if(o-a.from==f&&(!c.item||a.from<=c.item.from||!/\S/.test(a.text.slice(0,c.to)))){let u=a.from+c.from;if(c.item&&c.node.from<c.item.from&&/\S/.test(a.text.slice(c.from,c.to))){let d=c.blank(Ke(a.text,4,c.to)-Ke(a.text,4,c.from));return u==a.from&&(d=ua(d,n)),{range:y.cursor(u+d.length),changes:{from:u,to:a.from+c.to,insert:d}}}if(u<o)return{range:y.cursor(u),changes:{from:u,to:o}}}}}return i={range:s}});return i?!1:(e(n.update(r,{scrollIntoView:!0,userEvent:"delete"})),!0)},sw=[{key:"Enter",run:tw},{key:"Backspace",run:rw}],cp=IQ({matchClosingTags:!1});function ow(n={}){let{codeLanguages:e,defaultCodeLanguage:t,addKeymap:i=!0,base:{parser:r}=HQ,completeHTMLTags:s=!0,pasteURLAsLink:o=!0,htmlTagLanguage:l=cp}=n;if(!(r instanceof ms))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let a=n.extensions?[n.extensions]:[],h=[l.support,FQ],c;o&&h.push(cw),t instanceof gn?(h.push(t.support),c=t.language):t&&(c=t);let f=e||c?JQ(e,c):void 0;a.push(ux({codeParser:f,htmlParser:l.language.parser})),i&&h.push(Pt.high(Ai.of(sw)));let u=fa(r.configure(a));return s&&h.push(u.data.of({autocomplete:lw})),new gn(u,h)}function lw(n){let{state:e,pos:t}=n,i=/<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(t-25,t));if(!i)return null;let r=J(e).resolveInner(t,-1);for(;r&&!r.type.isTop;){if(r.name=="CodeBlock"||r.name=="FencedCode"||r.name=="ProcessingInstructionBlock"||r.name=="CommentBlock"||r.name=="Link"||r.name=="Image")return null;r=r.parent}return{from:t-i[0].length,to:t,options:aw(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let lo=null;function aw(){if(lo)return lo;let n=YQ(new Il(Y.create({extensions:cp}),0,!0));return lo=n?n.options:[]}const hw=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,cw=P.domEventHandlers({paste:(n,e)=>{var t;let{main:i}=e.state.selection;if(i.empty)return!1;let r=(t=n.clipboardData)===null||t===void 0?void 0:t.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!ts.isActiveAt(e.state,i.from,1)))return!1;let s=J(e.state),o=!1;return s.iterate({from:i.from,to:i.to,enter:l=>{(l.from>i.from||hw.test(l.name))&&(o=!0)},leave:l=>{l.to<i.to&&(o=!0)}}),o?!1:(e.dispatch({changes:[{from:i.from,insert:"["},{from:i.to,insert:`](${r})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}});function Sw(){const[n]=fp(),e=n.get("path"),t=n.get("new")==="1",[i,r]=re.useState(e||"pages/"),[s,o]=re.useState(""),[l,a]=re.useState(t),[h,c]=re.useState(!1),[f,u]=re.useState(null),d=up();re.useEffect(()=>{if(!e||t){a(!0);return}a(!1),Oa.readPage(e).then(p=>{o(p.content),a(!0),u(null)}).catch(p=>u(p instanceof Error?p.message:String(p)))},[e,t]);async function O(){if(!i.startsWith("pages/")||!i.endsWith(".md")){u("Path must start with pages/ and end in .md");return}c(!0),u(null);try{await Oa.writePage(i,s),d(`/wiki?selected=${encodeURIComponent(i)}`)}catch(p){u(p instanceof Error?p.message:String(p))}finally{c(!1)}}return l?Pe.jsxs("div",{className:"page wiki-edit",children:[Pe.jsx("header",{className:"page-header",children:Pe.jsx("h1",{children:t?"New page":"Edit page"})}),f?Pe.jsx(Op,{inline:!0,message:f,onRetry:()=>void O()}):null,Pe.jsx("div",{className:"row",children:Pe.jsxs("label",{htmlFor:"wiki-path",children:["Path",Pe.jsx("input",{id:"wiki-path",type:"text",value:i,onChange:p=>r(p.target.value),disabled:!t,"aria-invalid":!!(f&&(!i.startsWith("pages/")||!i.endsWith(".md")))})]})}),Pe.jsx("div",{className:"wiki-editor","aria-label":"Markdown editor",children:Pe.jsx(eO,{value:s,height:"60vh",extensions:[ow()],onChange:p=>o(p),theme:"dark"})}),Pe.jsxs("div",{className:"composer-actions",children:[Pe.jsx("button",{type:"button",className:"btn primary",onClick:()=>void O(),disabled:h,children:h?"Saving…":"Save"}),Pe.jsx("button",{type:"button",className:"btn",onClick:()=>d(e?`/wiki?selected=${encodeURIComponent(e)}`:"/wiki"),children:"Cancel"})]})]}):Pe.jsx(dp,{centered:!0,label:"Loading editor",detail:"Fetching the wiki page content."})}export{Sw as WikiEdit};
|
|
30
|
-
//# sourceMappingURL=WikiEdit-
|
|
30
|
+
//# sourceMappingURL=WikiEdit-CGRxNazp.js.map
|